@electerm/electerm-react 1.34.30
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/LICENSE +21 -0
- package/README.md +31 -0
- package/client/common/auto-complete-data-mapper.js +6 -0
- package/client/common/byte-format.js +14 -0
- package/client/common/class.js +52 -0
- package/client/common/clipboard.js +49 -0
- package/client/common/constants.js +308 -0
- package/client/common/create-lang-edit-link.js +7 -0
- package/client/common/create-title.js +29 -0
- package/client/common/db-fix.js +24 -0
- package/client/common/db.js +155 -0
- package/client/common/download-mirrors.js +10 -0
- package/client/common/download.js +16 -0
- package/client/common/error-handler.jsx +27 -0
- package/client/common/fetch-from-server.js +47 -0
- package/client/common/fetch.jsx +71 -0
- package/client/common/find-bookmark-group-id.js +15 -0
- package/client/common/find-parent.js +30 -0
- package/client/common/form-layout.js +27 -0
- package/client/common/fs.js +21 -0
- package/client/common/get-proxy.js +8 -0
- package/client/common/id-with-stamp.js +10 -0
- package/client/common/index-sorter.js +4 -0
- package/client/common/init-setting-item.js +32 -0
- package/client/common/is-absolute-path.js +3 -0
- package/client/common/is-ip.js +16 -0
- package/client/common/is-valid-path.js +7 -0
- package/client/common/key-control-pressed.js +13 -0
- package/client/common/key-pressed.js +13 -0
- package/client/common/key-shift-pressed.js +7 -0
- package/client/common/mode2permission.js +81 -0
- package/client/common/new-terminal.js +31 -0
- package/client/common/parse-int10.js +3 -0
- package/client/common/parse-json-safe.js +11 -0
- package/client/common/pass-enc.js +25 -0
- package/client/common/post-msg.js +3 -0
- package/client/common/pre.js +156 -0
- package/client/common/promise-timeout.js +27 -0
- package/client/common/resolve.js +31 -0
- package/client/common/run-idle.js +1 -0
- package/client/common/safe-local-storage.js +35 -0
- package/client/common/safe-name.js +19 -0
- package/client/common/sftp.js +74 -0
- package/client/common/terminal-theme.js +158 -0
- package/client/common/test-connection.js +12 -0
- package/client/common/time.js +30 -0
- package/client/common/to-simple-obj.js +5 -0
- package/client/common/track.js +7 -0
- package/client/common/transfer.js +76 -0
- package/client/common/trzsz.js +62 -0
- package/client/common/ui-theme.js +44 -0
- package/client/common/uid.js +5 -0
- package/client/common/update-check.js +79 -0
- package/client/common/upgrade.js +68 -0
- package/client/common/wait.js +8 -0
- package/client/common/ws.js +161 -0
- package/client/components/batch-op/batch-op.jsx +650 -0
- package/client/components/bookmark-form/bookmark-form.styl +8 -0
- package/client/components/bookmark-form/bookmark-group-tree-format.js +39 -0
- package/client/components/bookmark-form/encodes.js +44 -0
- package/client/components/bookmark-form/form-ssh-common.jsx +208 -0
- package/client/components/bookmark-form/form-tabs.jsx +69 -0
- package/client/components/bookmark-form/index.jsx +159 -0
- package/client/components/bookmark-form/local-form-ui.jsx +152 -0
- package/client/components/bookmark-form/local-form.jsx +16 -0
- package/client/components/bookmark-form/proxy.jsx +49 -0
- package/client/components/bookmark-form/quick-command-list.jsx +31 -0
- package/client/components/bookmark-form/quick-command.jsx +228 -0
- package/client/components/bookmark-form/render-auth-ssh.jsx +104 -0
- package/client/components/bookmark-form/render-connection-hopping.jsx +229 -0
- package/client/components/bookmark-form/render-delayed-scripts.jsx +88 -0
- package/client/components/bookmark-form/render-ssh-tunnel.jsx +116 -0
- package/client/components/bookmark-form/serial-form-ui.jsx +311 -0
- package/client/components/bookmark-form/serial-form.jsx +20 -0
- package/client/components/bookmark-form/sftp-enable.jsx +33 -0
- package/client/components/bookmark-form/ssh-form-ui.jsx +100 -0
- package/client/components/bookmark-form/ssh-form.jsx +348 -0
- package/client/components/bookmark-form/telnet-form-ui.jsx +154 -0
- package/client/components/bookmark-form/telnet-form.jsx +16 -0
- package/client/components/bookmark-form/tree-delete.jsx +87 -0
- package/client/components/bookmark-form/use-form-funcs.jsx +50 -0
- package/client/components/bookmark-form/use-quick-commands.jsx +83 -0
- package/client/components/bookmark-form/use-submit.jsx +77 -0
- package/client/components/bookmark-form/use-ui.jsx +82 -0
- package/client/components/bookmark-form/x11.jsx +23 -0
- package/client/components/common/animate-text.jsx +37 -0
- package/client/components/common/animate-text.styl +54 -0
- package/client/components/common/external-link.jsx +28 -0
- package/client/components/common/help-icon.jsx +25 -0
- package/client/components/common/highlight.jsx +23 -0
- package/client/components/common/highlight.styl +3 -0
- package/client/components/common/input-auto-focus.jsx +68 -0
- package/client/components/common/input-confirm.jsx +66 -0
- package/client/components/common/logo-elem.jsx +22 -0
- package/client/components/common/markdown.jsx +27 -0
- package/client/components/common/react-subx.jsx +1 -0
- package/client/components/common/resize-wrap.jsx +222 -0
- package/client/components/common/resize-wrap.styl +9 -0
- package/client/components/common/search.jsx +9 -0
- package/client/components/common/show-item.jsx +27 -0
- package/client/components/context-menu/boomarks.jsx +15 -0
- package/client/components/context-menu/context-menu.jsx +340 -0
- package/client/components/context-menu/context-menu.styl +90 -0
- package/client/components/context-menu/history.jsx +27 -0
- package/client/components/context-menu/icon-holder.jsx +5 -0
- package/client/components/context-menu/menu-btn.jsx +224 -0
- package/client/components/context-menu/sub-tab-menu.jsx +23 -0
- package/client/components/context-menu/tabs.jsx +22 -0
- package/client/components/context-menu/zoom.jsx +40 -0
- package/client/components/footer/batch-input.jsx +177 -0
- package/client/components/footer/footer-entry.jsx +141 -0
- package/client/components/footer/footer.styl +47 -0
- package/client/components/icons/match-case.jsx +10 -0
- package/client/components/icons/match-whole-word.jsx +13 -0
- package/client/components/icons/regular-exp.jsx +10 -0
- package/client/components/main/css-overwrite.jsx +92 -0
- package/client/components/main/error-wrapper.jsx +59 -0
- package/client/components/main/index.jsx +11 -0
- package/client/components/main/loading.jsx +25 -0
- package/client/components/main/main.jsx +149 -0
- package/client/components/main/term-fullscreen-control.jsx +21 -0
- package/client/components/main/term-fullscreen.styl +27 -0
- package/client/components/main/ui-theme.jsx +31 -0
- package/client/components/main/upgrade.jsx +351 -0
- package/client/components/main/upgrade.styl +27 -0
- package/client/components/main/wrapper.styl +41 -0
- package/client/components/quick-commands/qm.styl +29 -0
- package/client/components/quick-commands/quick-command-item.jsx +36 -0
- package/client/components/quick-commands/quick-command-transport-mod.jsx +54 -0
- package/client/components/quick-commands/quick-command-transport.jsx +12 -0
- package/client/components/quick-commands/quick-commands-box.jsx +233 -0
- package/client/components/quick-commands/quick-commands-form-elem.jsx +119 -0
- package/client/components/quick-commands/quick-commands-form.jsx +33 -0
- package/client/components/quick-commands/quick-commands-list.jsx +128 -0
- package/client/components/quick-commands/quick-commands-select.jsx +38 -0
- package/client/components/session/session.jsx +533 -0
- package/client/components/session/session.styl +53 -0
- package/client/components/session/sessions.jsx +445 -0
- package/client/components/setting-panel/bookmark-transport.jsx +148 -0
- package/client/components/setting-panel/bookmark-tree-list.jsx +14 -0
- package/client/components/setting-panel/col.jsx +18 -0
- package/client/components/setting-panel/list.jsx +186 -0
- package/client/components/setting-panel/list.styl +33 -0
- package/client/components/setting-panel/on-tree-drop.js +222 -0
- package/client/components/setting-panel/setting-modal.jsx +163 -0
- package/client/components/setting-panel/setting-wrap.jsx +37 -0
- package/client/components/setting-panel/setting-wrap.styl +52 -0
- package/client/components/setting-panel/setting.jsx +858 -0
- package/client/components/setting-panel/setting.styl +4 -0
- package/client/components/setting-panel/start-session-select.jsx +91 -0
- package/client/components/setting-panel/tab-bookmarks.jsx +37 -0
- package/client/components/setting-panel/tab-history.jsx +44 -0
- package/client/components/setting-panel/tab-quick-commands.jsx +38 -0
- package/client/components/setting-panel/tab-settings.jsx +42 -0
- package/client/components/setting-panel/tab-themes.jsx +34 -0
- package/client/components/setting-panel/tree-list.jsx +978 -0
- package/client/components/setting-panel/tree-list.styl +57 -0
- package/client/components/setting-sync/data-import.jsx +65 -0
- package/client/components/setting-sync/setting-sync-form.jsx +271 -0
- package/client/components/setting-sync/setting-sync.jsx +81 -0
- package/client/components/setting-sync/sync.styl +7 -0
- package/client/components/sftp/address-bar.jsx +139 -0
- package/client/components/sftp/address-bookmark-item.jsx +47 -0
- package/client/components/sftp/address-bookmark.jsx +81 -0
- package/client/components/sftp/address-bookmark.styl +8 -0
- package/client/components/sftp/confirm-modal.jsx +184 -0
- package/client/components/sftp/file-icon.jsx +22 -0
- package/client/components/sftp/file-item.jsx +1226 -0
- package/client/components/sftp/file-mode-modal.jsx +205 -0
- package/client/components/sftp/file-props-modal.jsx +211 -0
- package/client/components/sftp/file-read.js +81 -0
- package/client/components/sftp/list-table-ui.jsx +547 -0
- package/client/components/sftp/owner-list.js +97 -0
- package/client/components/sftp/paged-list.jsx +60 -0
- package/client/components/sftp/permission-render.jsx +42 -0
- package/client/components/sftp/sftp-entry.jsx +1069 -0
- package/client/components/sftp/sftp.styl +217 -0
- package/client/components/sftp/transfer-common.js +9 -0
- package/client/components/sftp/transfer-conflict.jsx +315 -0
- package/client/components/sftp/transfer-speed-format.js +60 -0
- package/client/components/sftp/transfer-tag.jsx +40 -0
- package/client/components/sftp/transfer-tag.styl +11 -0
- package/client/components/sftp/transfer.styl +55 -0
- package/client/components/sftp/transport-action.jsx +410 -0
- package/client/components/sftp/transport-entry.jsx +108 -0
- package/client/components/sftp/transport-types.js +8 -0
- package/client/components/sftp/transports-action.jsx +111 -0
- package/client/components/sftp/transports-ui.jsx +93 -0
- package/client/components/sftp/zip.js +42 -0
- package/client/components/sidebar/bookmark-select.jsx +48 -0
- package/client/components/sidebar/bookmark.jsx +82 -0
- package/client/components/sidebar/history.jsx +66 -0
- package/client/components/sidebar/index.jsx +230 -0
- package/client/components/sidebar/info-modal.jsx +250 -0
- package/client/components/sidebar/info.styl +27 -0
- package/client/components/sidebar/side-icon.jsx +25 -0
- package/client/components/sidebar/sidebar.styl +128 -0
- package/client/components/sidebar/transfer-history-modal.jsx +110 -0
- package/client/components/sidebar/transfer-history.styl +3 -0
- package/client/components/sidebar/transfer-list-control.jsx +205 -0
- package/client/components/sidebar/transfer-list.jsx +55 -0
- package/client/components/sidebar/transfer-modal.jsx +76 -0
- package/client/components/sidebar/transfer.styl +8 -0
- package/client/components/sidebar/transport-ui.jsx +109 -0
- package/client/components/tabs/index.jsx +320 -0
- package/client/components/tabs/tab.jsx +427 -0
- package/client/components/tabs/tabs.styl +220 -0
- package/client/components/tabs/window-control.jsx +55 -0
- package/client/components/terminal/attach-addon-custom.js +70 -0
- package/client/components/terminal/build-ls-term-id.js +5 -0
- package/client/components/terminal/index.jsx +1358 -0
- package/client/components/terminal/normal-buffer.jsx +33 -0
- package/client/components/terminal/term-search.jsx +224 -0
- package/client/components/terminal/term-search.styl +15 -0
- package/client/components/terminal/terminal-apis.js +31 -0
- package/client/components/terminal/terminal-interactive.jsx +148 -0
- package/client/components/terminal/terminal.styl +96 -0
- package/client/components/terminal/xterm-zmodem.js +48 -0
- package/client/components/terminal/zmodem-transfer.jsx +98 -0
- package/client/components/terminal/zmodem.styl +14 -0
- package/client/components/terminal-info/activity.jsx +54 -0
- package/client/components/terminal-info/base.jsx +25 -0
- package/client/components/terminal-info/content.jsx +101 -0
- package/client/components/terminal-info/data-cols-parser.jsx +50 -0
- package/client/components/terminal-info/disk.jsx +29 -0
- package/client/components/terminal-info/index.jsx +25 -0
- package/client/components/terminal-info/network.jsx +114 -0
- package/client/components/terminal-info/resource.jsx +80 -0
- package/client/components/terminal-info/run-cmd.jsx +273 -0
- package/client/components/terminal-info/terminal-info.styl +29 -0
- package/client/components/terminal-info/up.jsx +15 -0
- package/client/components/terminal-theme/index.jsx +264 -0
- package/client/components/terminal-theme/terminal-theme-list.styl +3 -0
- package/client/components/terminal-theme/theme-list.jsx +146 -0
- package/client/components/text-editor/text-editor-form.jsx +97 -0
- package/client/components/text-editor/text-editor.jsx +182 -0
- package/client/css/antd-overwrite.styl +14 -0
- package/client/css/basic.styl +38 -0
- package/client/css/includes/box.styl +154 -0
- package/client/css/includes/font-size.styl +6 -0
- package/client/css/includes/index.styl +3 -0
- package/client/css/includes/text.styl +31 -0
- package/client/css/includes/theme-default.styl +20 -0
- package/client/entry/basic.js +58 -0
- package/client/entry/index.jsx +15 -0
- package/client/entry/worker.js +137 -0
- package/client/store/address-bookmark.js +25 -0
- package/client/store/app-upgrade.js +23 -0
- package/client/store/batch-input-history.js +26 -0
- package/client/store/bookmark-group.js +128 -0
- package/client/store/bookmark.js +22 -0
- package/client/store/common.js +140 -0
- package/client/store/context-menu.js +23 -0
- package/client/store/db-upgrade.js +43 -0
- package/client/store/event.js +70 -0
- package/client/store/index.js +335 -0
- package/client/store/init-state.js +191 -0
- package/client/store/item.js +120 -0
- package/client/store/load-data.js +198 -0
- package/client/store/quick-command.js +43 -0
- package/client/store/session.js +54 -0
- package/client/store/setting.js +208 -0
- package/client/store/sidebar.js +48 -0
- package/client/store/sync.js +390 -0
- package/client/store/system-menu.js +120 -0
- package/client/store/tab.js +74 -0
- package/client/store/terminal-theme.js +116 -0
- package/client/store/transfer-history.js +27 -0
- package/client/store/transfer-list.js +20 -0
- package/client/store/ui-theme.js +71 -0
- package/client/store/watch.js +116 -0
- package/client/views/index.pug +58 -0
- package/package.json +34 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* init app data then write main script to html body
|
|
3
|
+
*/
|
|
4
|
+
import '../css/basic.styl'
|
|
5
|
+
import { get as _get } from 'lodash-es'
|
|
6
|
+
import '../common/pre'
|
|
7
|
+
|
|
8
|
+
const { isDev } = window.et
|
|
9
|
+
const { version } = window.pre.packInfo
|
|
10
|
+
|
|
11
|
+
async function loadWorker () {
|
|
12
|
+
return new Promise((resolve) => {
|
|
13
|
+
const url = !isDev ? `js/worker-${version}.js` : 'js/worker.js'
|
|
14
|
+
window.worker = new window.Worker(url)
|
|
15
|
+
function onInit (e) {
|
|
16
|
+
if (!e || !e.data) {
|
|
17
|
+
return false
|
|
18
|
+
}
|
|
19
|
+
const {
|
|
20
|
+
action
|
|
21
|
+
} = e.data
|
|
22
|
+
if (action === 'worker-init') {
|
|
23
|
+
window.worker.removeEventListener('message', onInit)
|
|
24
|
+
resolve(1)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
window.worker.addEventListener('message', onInit)
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function load () {
|
|
32
|
+
window.capitalizeFirstLetter = (string) => {
|
|
33
|
+
return string.charAt(0).toUpperCase() + string.slice(1)
|
|
34
|
+
}
|
|
35
|
+
function loadScript () {
|
|
36
|
+
const rcs = document.createElement('script')
|
|
37
|
+
const url = !isDev ? `js/electerm-${version}.js` : 'js/electerm.js'
|
|
38
|
+
rcs.src = url
|
|
39
|
+
rcs.type = 'module'
|
|
40
|
+
document.body.appendChild(rcs)
|
|
41
|
+
}
|
|
42
|
+
window.getLang = (lang = window.store?.config.language || 'en_us') => {
|
|
43
|
+
return _get(window.langMap, `[${lang}].lang`)
|
|
44
|
+
}
|
|
45
|
+
window.prefix = prefix => {
|
|
46
|
+
return (id) => {
|
|
47
|
+
const lang = window.getLang()
|
|
48
|
+
const str = _get(lang, `[${prefix}][${id}]`) || id
|
|
49
|
+
return window.capitalizeFirstLetter(str)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
await loadWorker()
|
|
53
|
+
loadScript()
|
|
54
|
+
document.body.removeChild(document.getElementById('content-loading'))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// window.addEventListener('load', load)
|
|
58
|
+
load()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { render } from 'react-dom'
|
|
2
|
+
import '../../../node_modules/antd/dist/reset.css'
|
|
3
|
+
import '../../../node_modules/xterm/css/xterm.css'
|
|
4
|
+
import '../common/trzsz'
|
|
5
|
+
import Main from '../components/main'
|
|
6
|
+
import { notification } from 'antd'
|
|
7
|
+
notification.config({
|
|
8
|
+
placement: 'bottomRight'
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
const rootElement = document.getElementById('container')
|
|
12
|
+
render(
|
|
13
|
+
<Main />,
|
|
14
|
+
rootElement
|
|
15
|
+
)
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* web worker
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
self.insts = {}
|
|
6
|
+
|
|
7
|
+
function createWs (
|
|
8
|
+
type,
|
|
9
|
+
id,
|
|
10
|
+
sessionId = '',
|
|
11
|
+
sftpId = '',
|
|
12
|
+
config
|
|
13
|
+
) {
|
|
14
|
+
// init gloabl ws
|
|
15
|
+
const { host, port, tokenElecterm } = config
|
|
16
|
+
const wsUrl = `ws://${host}:${port}/${type}/${id}?sessionId=${sessionId}&sftpId=${sftpId}&token=${tokenElecterm}`
|
|
17
|
+
const ws = new WebSocket(wsUrl)
|
|
18
|
+
ws.s = msg => {
|
|
19
|
+
ws.send(JSON.stringify(msg))
|
|
20
|
+
}
|
|
21
|
+
ws.id = id
|
|
22
|
+
ws.once = (callack, id) => {
|
|
23
|
+
const func = (evt) => {
|
|
24
|
+
const arg = JSON.parse(evt.data)
|
|
25
|
+
if (id === arg.id) {
|
|
26
|
+
callack(arg)
|
|
27
|
+
ws.removeEventListener('message', func)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
ws.addEventListener('message', func)
|
|
31
|
+
}
|
|
32
|
+
ws.onclose = () => {
|
|
33
|
+
if (ws.dup) {
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
send({
|
|
37
|
+
id: ws.id,
|
|
38
|
+
action: 'close'
|
|
39
|
+
})
|
|
40
|
+
delete self.insts[ws.id]
|
|
41
|
+
}
|
|
42
|
+
return new Promise((resolve) => {
|
|
43
|
+
ws.onopen = () => {
|
|
44
|
+
if (self.insts[ws.id]) {
|
|
45
|
+
ws.dup = true
|
|
46
|
+
ws.close()
|
|
47
|
+
resolve(null)
|
|
48
|
+
} else {
|
|
49
|
+
resolve(ws)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function send (data) {
|
|
56
|
+
self.postMessage(data)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function onMsg (e) {
|
|
60
|
+
const {
|
|
61
|
+
id,
|
|
62
|
+
wsId,
|
|
63
|
+
args,
|
|
64
|
+
action,
|
|
65
|
+
type,
|
|
66
|
+
persist
|
|
67
|
+
} = e.data
|
|
68
|
+
if (action === 'create') {
|
|
69
|
+
const inst = self.insts[id]
|
|
70
|
+
if (inst instanceof WebSocket) {
|
|
71
|
+
return send({
|
|
72
|
+
action,
|
|
73
|
+
id,
|
|
74
|
+
persist
|
|
75
|
+
}, '*')
|
|
76
|
+
} else if (inst) {
|
|
77
|
+
return false
|
|
78
|
+
} else {
|
|
79
|
+
const ws = await createWs(...args)
|
|
80
|
+
if (ws) {
|
|
81
|
+
self.insts[id] = ws
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
send({
|
|
85
|
+
action,
|
|
86
|
+
persist,
|
|
87
|
+
id
|
|
88
|
+
}, '*')
|
|
89
|
+
} else if (action === 'once') {
|
|
90
|
+
const ws = self.insts[wsId]
|
|
91
|
+
if (ws) {
|
|
92
|
+
const cb = (data) => {
|
|
93
|
+
send({
|
|
94
|
+
id,
|
|
95
|
+
wsId,
|
|
96
|
+
data
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
ws.once(cb, id)
|
|
100
|
+
}
|
|
101
|
+
} else if (action === 'close') {
|
|
102
|
+
const ws = self.insts[wsId]
|
|
103
|
+
if (ws) {
|
|
104
|
+
ws.close()
|
|
105
|
+
}
|
|
106
|
+
} else if (action === 's') {
|
|
107
|
+
const ws = self.insts[wsId]
|
|
108
|
+
if (ws) {
|
|
109
|
+
ws.s(...args)
|
|
110
|
+
}
|
|
111
|
+
} else if (action === 'addEventListener') {
|
|
112
|
+
const ws = self.insts[wsId]
|
|
113
|
+
if (ws) {
|
|
114
|
+
ws.cb = (e) => {
|
|
115
|
+
send({
|
|
116
|
+
wsId,
|
|
117
|
+
id,
|
|
118
|
+
data: {
|
|
119
|
+
data: e.data
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
ws.addEventListener(type, ws.cb)
|
|
124
|
+
}
|
|
125
|
+
} else if (action === 'removeEventListener') {
|
|
126
|
+
const ws = self.insts[wsId]
|
|
127
|
+
if (ws) {
|
|
128
|
+
ws.removeEventListener(type, ws.cb)
|
|
129
|
+
delete ws.cb
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
self.addEventListener('message', onMsg)
|
|
135
|
+
send({
|
|
136
|
+
action: 'worker-init'
|
|
137
|
+
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function getType (item) {
|
|
2
|
+
return item.host
|
|
3
|
+
? 'addressBookmarks'
|
|
4
|
+
: 'addressBookmarksLocal'
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default Store => {
|
|
8
|
+
Store.prototype.addAddressBookmark = (item) => {
|
|
9
|
+
return window.store.addItem(item, getType(item))
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
Store.prototype.delAddressBookmark = (item) => {
|
|
13
|
+
return window.store.delItem(item, getType(item))
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Store.prototype.listAddressBookmark = () => {
|
|
17
|
+
const { store } = window
|
|
18
|
+
return [
|
|
19
|
+
...store.addressBookmarksLocal,
|
|
20
|
+
...store.addressBookmarks.sort((a, b) => {
|
|
21
|
+
return a.host > b.host ? 1 : -1
|
|
22
|
+
})
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* app upgrade
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { commonActions } from '../common/constants'
|
|
6
|
+
|
|
7
|
+
export default Store => {
|
|
8
|
+
Store.prototype.onCheckUpdate = () => {
|
|
9
|
+
window.postMessage({
|
|
10
|
+
action: commonActions.appUpdateCheck
|
|
11
|
+
}, '*')
|
|
12
|
+
}
|
|
13
|
+
Store.prototype.getProxySetting = function () {
|
|
14
|
+
const {
|
|
15
|
+
proxy,
|
|
16
|
+
enableGlobalProxy
|
|
17
|
+
} = window.store.config
|
|
18
|
+
if (!enableGlobalProxy) {
|
|
19
|
+
return ''
|
|
20
|
+
}
|
|
21
|
+
return typeof proxy !== 'string' ? '' : proxy
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* batch input functions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import copy from 'json-deep-copy'
|
|
6
|
+
import { maxBatchInput, batchInputLsKey } from '../common/constants'
|
|
7
|
+
import { uniq } from 'lodash-es'
|
|
8
|
+
import * as ls from '../common/safe-local-storage'
|
|
9
|
+
|
|
10
|
+
export default Store => {
|
|
11
|
+
Store.prototype.addBatchInput = function (str) {
|
|
12
|
+
let batchInputs = copy(window.store.batchInputs)
|
|
13
|
+
batchInputs.push(str)
|
|
14
|
+
batchInputs = uniq(batchInputs)
|
|
15
|
+
const len = batchInputs.length
|
|
16
|
+
if (len > maxBatchInput) {
|
|
17
|
+
batchInputs = batchInputs.slice(len - maxBatchInput)
|
|
18
|
+
}
|
|
19
|
+
ls.setItemJSON(batchInputLsKey, batchInputs)
|
|
20
|
+
window.store.batchInputs = batchInputs
|
|
21
|
+
}
|
|
22
|
+
Store.prototype.clearBatchInput = function () {
|
|
23
|
+
window.store.batchInputs = []
|
|
24
|
+
ls.setItemJSON(batchInputLsKey, [])
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bookmark group functions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { find, findIndex } from 'lodash-es'
|
|
6
|
+
import {
|
|
7
|
+
defaultBookmarkGroupId,
|
|
8
|
+
settingMap,
|
|
9
|
+
terminalSshConfigType
|
|
10
|
+
} from '../common/constants'
|
|
11
|
+
|
|
12
|
+
export default Store => {
|
|
13
|
+
Store.prototype.getBookmarkGroups = function () {
|
|
14
|
+
return window.store.getItems(settingMap.bookmarkGroups)
|
|
15
|
+
}
|
|
16
|
+
Store.prototype.getBookmarkGroupsTotal = function () {
|
|
17
|
+
const { store } = window
|
|
18
|
+
return store.sshConfigItems.length
|
|
19
|
+
? [
|
|
20
|
+
...store.getBookmarkGroups(),
|
|
21
|
+
{
|
|
22
|
+
title: terminalSshConfigType,
|
|
23
|
+
id: terminalSshConfigType,
|
|
24
|
+
bookmarkIds: store.sshConfigItems.map(d => d.id)
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
: store.getBookmarkGroups()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
Store.prototype.setBookmarkGroups = function (items) {
|
|
31
|
+
return window.store.setItems('bookmarkGroups', items)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
Store.prototype.addBookmarkGroup = async function (group) {
|
|
35
|
+
window.store.addItem(group, settingMap.bookmarkGroups)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Store.prototype.editBookmarkGroup = function (id, updates) {
|
|
39
|
+
window.store.editItem(id, updates, settingMap.bookmarkGroups)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Store.prototype.openAllBookmarkInCategory = function (item) {
|
|
43
|
+
const { store } = window
|
|
44
|
+
let ids = item.bookmarkIds
|
|
45
|
+
const gids = item.bookmarkGroupIds || []
|
|
46
|
+
const bookmarkGroups = store.getBookmarkGroups()
|
|
47
|
+
for (const gid of gids) {
|
|
48
|
+
const g = find(bookmarkGroups, g => g.id === gid)
|
|
49
|
+
if (g && g.bookmarkIds && g.bookmarkIds.length) {
|
|
50
|
+
ids = [
|
|
51
|
+
...ids,
|
|
52
|
+
...g.bookmarkIds
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
for (const id of ids) {
|
|
57
|
+
store.onSelectBookmark(id)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
Store.prototype.delBookmarkGroup = function ({ id }) {
|
|
62
|
+
const { store } = window
|
|
63
|
+
if (id === defaultBookmarkGroupId) {
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
let bookmarkGroups = store.getBookmarkGroups()
|
|
67
|
+
const tobeDel = find(bookmarkGroups, bg => bg.id === id)
|
|
68
|
+
if (!tobeDel) {
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
let groups = [tobeDel]
|
|
72
|
+
if (
|
|
73
|
+
tobeDel.level !== 2 &&
|
|
74
|
+
tobeDel.bookmarkGroupIds &&
|
|
75
|
+
tobeDel.bookmarkGroupIds.length > 0
|
|
76
|
+
) {
|
|
77
|
+
const childs = bookmarkGroups.filter(
|
|
78
|
+
bg => tobeDel.bookmarkGroupIds.includes(bg.id)
|
|
79
|
+
)
|
|
80
|
+
groups = [
|
|
81
|
+
...groups,
|
|
82
|
+
...childs
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
const groupIds = groups.map(g => g.id)
|
|
86
|
+
const updates = []
|
|
87
|
+
const defaultCatIndex = tobeDel.level !== 2
|
|
88
|
+
? findIndex(
|
|
89
|
+
bookmarkGroups,
|
|
90
|
+
g => g.id === defaultBookmarkGroupId
|
|
91
|
+
)
|
|
92
|
+
: findIndex(
|
|
93
|
+
bookmarkGroups,
|
|
94
|
+
g => (g.bookmarkGroupIds || []).includes(tobeDel.id)
|
|
95
|
+
)
|
|
96
|
+
for (const g of groups) {
|
|
97
|
+
if (g.bookmarkIds.length) {
|
|
98
|
+
const def = bookmarkGroups[defaultCatIndex]
|
|
99
|
+
def.bookmarkIds = [
|
|
100
|
+
...g.bookmarkIds,
|
|
101
|
+
...def.bookmarkIds
|
|
102
|
+
]
|
|
103
|
+
updates.push({
|
|
104
|
+
id: def.id,
|
|
105
|
+
db: 'bookmarkGroups',
|
|
106
|
+
upsert: false,
|
|
107
|
+
update: {
|
|
108
|
+
bookmarkIds: def.bookmarkIds
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
bookmarkGroups = bookmarkGroups.filter(t => {
|
|
114
|
+
return !groupIds.includes(t.id)
|
|
115
|
+
})
|
|
116
|
+
store.batchDbUpdate(updates)
|
|
117
|
+
store.batchDbDel(groupIds.map(id => {
|
|
118
|
+
return {
|
|
119
|
+
id,
|
|
120
|
+
db: 'bookmarkGroups'
|
|
121
|
+
}
|
|
122
|
+
}))
|
|
123
|
+
store.setBookmarkGroups(bookmarkGroups)
|
|
124
|
+
if (id === store.currentBookmarkGroupId) {
|
|
125
|
+
store.currentBookmarkGroupId = ''
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bookmark
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export default Store => {
|
|
6
|
+
Store.prototype.handleGetSerials = async function () {
|
|
7
|
+
const { store } = window
|
|
8
|
+
store.loaddingSerials = true
|
|
9
|
+
const res = await window.pre.runGlobalAsync('listSerialPorts')
|
|
10
|
+
.catch(store.onError)
|
|
11
|
+
if (res) {
|
|
12
|
+
store._serials = JSON.stringify(res)
|
|
13
|
+
}
|
|
14
|
+
store.loaddingSerials = false
|
|
15
|
+
}
|
|
16
|
+
Store.prototype.getBookmarks = function () {
|
|
17
|
+
return window.store.getItems('bookmarks')
|
|
18
|
+
}
|
|
19
|
+
Store.prototype.setBookmarks = function (items) {
|
|
20
|
+
return window.store.setItems('bookmarks', items)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* common functions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import handleError from '../common/error-handler'
|
|
6
|
+
import { debounce } from 'lodash-es'
|
|
7
|
+
import postMessage from '../common/post-msg'
|
|
8
|
+
import {
|
|
9
|
+
commonActions,
|
|
10
|
+
tabActions,
|
|
11
|
+
modals
|
|
12
|
+
} from '../common/constants'
|
|
13
|
+
|
|
14
|
+
export default Store => {
|
|
15
|
+
Store.prototype.storeAssign = function (updates) {
|
|
16
|
+
Object.assign(this, updates)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
Store.prototype.setOffline = function () {
|
|
20
|
+
postMessage({
|
|
21
|
+
action: tabActions.setAllTabOffline
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Store.prototype.onError = function (e) {
|
|
26
|
+
handleError(e)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
Store.prototype.updateConfig = function (ext) {
|
|
30
|
+
window.store.setConfig(ext)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Store.prototype.openFileInfoModal = function (data) {
|
|
34
|
+
postMessage({
|
|
35
|
+
data,
|
|
36
|
+
action: commonActions.showFileInfoModal
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
Store.prototype.openFileModeModal = function (data, file) {
|
|
41
|
+
postMessage({
|
|
42
|
+
data,
|
|
43
|
+
file,
|
|
44
|
+
action: commonActions.showFileModeModal
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
Store.prototype.onResize = debounce(async function () {
|
|
49
|
+
const { width, height } = await window.pre.runGlobalAsync('getScreenSize')
|
|
50
|
+
const isMaximized = window.pre.runSync('isMaximized')
|
|
51
|
+
const update = {
|
|
52
|
+
height: window.innerHeight,
|
|
53
|
+
innerWidth: window.innerWidth,
|
|
54
|
+
screenWidth: width,
|
|
55
|
+
screenHeight: height,
|
|
56
|
+
isMaximized
|
|
57
|
+
}
|
|
58
|
+
window.store.storeAssign(update)
|
|
59
|
+
window.pre.runGlobalAsync('setWindowSize', {
|
|
60
|
+
...update,
|
|
61
|
+
height: window.outerHeight
|
|
62
|
+
})
|
|
63
|
+
}, 100, {
|
|
64
|
+
leading: true
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
Store.prototype.toggleTerminalSearch = function () {
|
|
68
|
+
const now = Date.now()
|
|
69
|
+
if (window.lastToggleTerminalSearch && now - window.lastToggleTerminalSearch < 300) {
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
window.lastToggleTerminalSearch = now
|
|
73
|
+
window.store.termSearchOpen = !window.store.termSearchOpen
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
Store.prototype.setState = function (name, value) {
|
|
77
|
+
window.store['_' + name] = JSON.stringify(value)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
Store.prototype.toggleBatchOp = function () {
|
|
81
|
+
window.store.showModal = window.store.showModal === modals.batchOps ? modals.hide : modals.batchOps
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
Store.prototype.runBatchOp = function (path) {
|
|
85
|
+
window.store.showModal = modals.batchOps
|
|
86
|
+
function updateText () {
|
|
87
|
+
const text = window.pre.readFileSync(path).toString()
|
|
88
|
+
postMessage({
|
|
89
|
+
action: commonActions.batchOp,
|
|
90
|
+
batchOp: {
|
|
91
|
+
func: 'setState',
|
|
92
|
+
args: [
|
|
93
|
+
{
|
|
94
|
+
text
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
function queue () {
|
|
101
|
+
postMessage({
|
|
102
|
+
action: commonActions.batchOp,
|
|
103
|
+
batchOp: {
|
|
104
|
+
func: 'handleClick',
|
|
105
|
+
args: []
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
function run () {
|
|
110
|
+
postMessage({
|
|
111
|
+
action: commonActions.batchOp,
|
|
112
|
+
batchOp: {
|
|
113
|
+
func: 'handleExec',
|
|
114
|
+
args: []
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
setTimeout(updateText, 2000)
|
|
120
|
+
setTimeout(queue, 3000)
|
|
121
|
+
setTimeout(run, 4000)
|
|
122
|
+
} catch (e) {
|
|
123
|
+
log.error(e)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
Store.prototype.setSettingItem = function (v) {
|
|
128
|
+
window.store.setState('settingItem', v)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
Store.prototype.setTermSearchOption = function (update) {
|
|
132
|
+
const {
|
|
133
|
+
store
|
|
134
|
+
} = window
|
|
135
|
+
store.setState('termSearchOptions', {
|
|
136
|
+
...JSON.parse(window.store._termSearchOptions),
|
|
137
|
+
...update
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* context menu related functions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import postMessage from '../common/post-msg'
|
|
6
|
+
import {
|
|
7
|
+
commonActions
|
|
8
|
+
} from '../common/constants'
|
|
9
|
+
|
|
10
|
+
export default Store => {
|
|
11
|
+
Store.prototype.openContextMenu = function (data) {
|
|
12
|
+
postMessage({
|
|
13
|
+
data,
|
|
14
|
+
type: commonActions.openContextMenu
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Store.prototype.closeContextMenu = function () {
|
|
19
|
+
postMessage({
|
|
20
|
+
action: commonActions.closeContextMenu
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* db upgrade
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Modal } from 'antd'
|
|
6
|
+
import delay from '../common/wait'
|
|
7
|
+
|
|
8
|
+
export default (Store) => {
|
|
9
|
+
Store.prototype.checkForDbUpgrade = async function () {
|
|
10
|
+
const { store } = window
|
|
11
|
+
if (store.isSencondInstance) {
|
|
12
|
+
return false
|
|
13
|
+
}
|
|
14
|
+
const shouldUpgrade = await window.pre.runGlobalAsync('checkDbUpgrade')
|
|
15
|
+
if (!shouldUpgrade) {
|
|
16
|
+
return false
|
|
17
|
+
}
|
|
18
|
+
const {
|
|
19
|
+
dbVersion,
|
|
20
|
+
packVersion
|
|
21
|
+
} = shouldUpgrade
|
|
22
|
+
const mod = Modal.info({
|
|
23
|
+
title: 'Upgrading database',
|
|
24
|
+
content: `Upgrading database... from v${dbVersion} to v${packVersion} please wait`,
|
|
25
|
+
keyboard: false,
|
|
26
|
+
okButtonProps: {
|
|
27
|
+
style: {
|
|
28
|
+
display: 'none'
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
await window.pre.runGlobalAsync('doUpgrade')
|
|
33
|
+
mod.update({
|
|
34
|
+
title: 'Done',
|
|
35
|
+
content: 'Database Upgraded',
|
|
36
|
+
okButtonProps: {}
|
|
37
|
+
})
|
|
38
|
+
await delay(3000)
|
|
39
|
+
mod.destroy()
|
|
40
|
+
await store.restart()
|
|
41
|
+
return true
|
|
42
|
+
}
|
|
43
|
+
}
|