@electerm/electerm-react 1.72.48 → 1.80.3

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.
Files changed (49) hide show
  1. package/client/common/constants.js +1 -1
  2. package/client/common/sftp.js +3 -1
  3. package/client/components/ai/ai-config.jsx +7 -1
  4. package/client/components/batch-op/batch-op.jsx +4 -5
  5. package/client/components/bg/css-overwrite.jsx +179 -0
  6. package/client/components/bg/shapes.js +501 -0
  7. package/client/components/bookmark-form/form-tabs.jsx +1 -0
  8. package/client/components/bookmark-form/local-form-ui.jsx +7 -1
  9. package/client/components/bookmark-form/render-bg.jsx +43 -0
  10. package/client/components/bookmark-form/serial-form-ui.jsx +7 -1
  11. package/client/components/bookmark-form/ssh-form-ui.jsx +14 -3
  12. package/client/components/bookmark-form/telnet-form-ui.jsx +7 -1
  13. package/client/components/bookmark-form/use-ui.jsx +68 -72
  14. package/client/components/common/ref.js +2 -0
  15. package/client/components/{sftp/confirm-modal-store.jsx → file-transfer/conflict-resolve.jsx} +86 -48
  16. package/client/components/file-transfer/transfer-queue.jsx +151 -0
  17. package/client/components/file-transfer/transfer.jsx +582 -0
  18. package/client/components/{sftp → file-transfer}/transports-action-store.jsx +35 -32
  19. package/client/components/{sftp → file-transfer}/transports-ui-store.jsx +2 -2
  20. package/client/components/main/main.jsx +25 -18
  21. package/client/components/main/wrapper.styl +16 -0
  22. package/client/components/profile/profile-list.jsx +1 -1
  23. package/client/components/quick-commands/qm.styl +4 -1
  24. package/client/components/quick-commands/quick-commands-list.jsx +16 -4
  25. package/client/components/setting-panel/list.jsx +1 -1
  26. package/client/components/setting-panel/setting-common.jsx +25 -23
  27. package/client/components/setting-panel/setting-terminal.jsx +2 -1
  28. package/client/components/setting-panel/terminal-bg-config.jsx +15 -2
  29. package/client/components/sftp/file-info-modal.jsx +3 -0
  30. package/client/components/sftp/file-item.jsx +25 -23
  31. package/client/components/sftp/file-read.js +1 -27
  32. package/client/components/sftp/list-table-ui.jsx +2 -2
  33. package/client/components/sidebar/transfer-history-modal.jsx +1 -1
  34. package/client/components/sidebar/transfer-list-control.jsx +1 -1
  35. package/client/components/sidebar/transport-ui.jsx +16 -9
  36. package/client/components/terminal/terminal.jsx +23 -1
  37. package/client/components/text-editor/simple-editor.jsx +164 -0
  38. package/client/components/text-editor/text-editor-form.jsx +6 -9
  39. package/client/css/includes/box.styl +2 -2
  40. package/client/store/tab.js +5 -1
  41. package/client/store/transfer-list.js +10 -51
  42. package/package.json +1 -1
  43. package/client/components/main/css-overwrite.jsx +0 -91
  44. package/client/components/sftp/transfer-conflict-store.jsx +0 -284
  45. package/client/components/sftp/transport-action-store.jsx +0 -422
  46. package/client/components/sftp/zip.js +0 -42
  47. /package/client/components/{main → bg}/custom-css.jsx +0 -0
  48. /package/client/components/{sftp → file-transfer}/transfer-speed-format.js +0 -0
  49. /package/client/components/{sftp → file-transfer}/transfer.styl +0 -0
@@ -1,422 +0,0 @@
1
- import { Component } from 'react'
2
- import copy from 'json-deep-copy'
3
- import { isFunction } from 'lodash-es'
4
- import generate from '../../common/uid'
5
- import { typeMap, transferTypeMap } from '../../common/constants'
6
- import fs from '../../common/fs'
7
- import format, { computeLeftTime, computePassedTime } from './transfer-speed-format'
8
- import {
9
- getFolderFromFilePath
10
- } from './file-read'
11
- import resolve from '../../common/resolve'
12
- import delay from '../../common/wait'
13
- import { refs } from '../common/ref'
14
- import { zipCmd, unzipCmd, rmCmd, mvCmd, mkdirCmd } from './zip'
15
- import './transfer.styl'
16
-
17
- export default class TransportAction extends Component {
18
- constructor (props) {
19
- super(props)
20
- this.sessionId = props.transfer.sessionId
21
- }
22
-
23
- inst = {}
24
- unzipping = false
25
-
26
- componentDidMount () {
27
- if (this.props.inited) {
28
- this.initTransfer()
29
- }
30
- }
31
-
32
- componentDidUpdate (prevProps) {
33
- if (
34
- prevProps.inited !== this.props.inited &&
35
- this.props.inited === true
36
- ) {
37
- this.initTransfer()
38
- }
39
- if (
40
- this.props.pausing !== prevProps.pausing
41
- ) {
42
- if (this.props.pausing) {
43
- this.pause()
44
- } else {
45
- this.resume()
46
- }
47
- }
48
- }
49
-
50
- componentWillUnmount () {
51
- this.transport && this.transport.destroy()
52
- this.transport = null
53
- this.inst = null
54
- }
55
-
56
- update = (up) => {
57
- const { transfer } = this.props
58
- const {
59
- store
60
- } = window
61
- store.updateTransfer(
62
- transfer.id,
63
- up
64
- )
65
- }
66
-
67
- insert = (insts) => {
68
- const { fileTransfers } = window.store
69
- const { index } = this.props
70
- fileTransfers.splice(index, 1, ...insts)
71
- }
72
-
73
- remoteList = () => {
74
- window.store.remoteList(this.sessionId)
75
- }
76
-
77
- localList = () => {
78
- window.store.localList(this.sessionId)
79
- }
80
-
81
- onEnd = (update = {}) => {
82
- if (this.onCancel) {
83
- return
84
- }
85
- const {
86
- transfer,
87
- config
88
- } = this.props
89
- const {
90
- typeTo,
91
- next
92
- } = transfer
93
- const finishTime = Date.now()
94
- if (!config.disableTransferHistory) {
95
- const r = copy(transfer)
96
- delete transfer.next
97
- Object.assign(r, update, {
98
- finishTime,
99
- startTime: this.startTime,
100
- size: transfer.fromFile.size,
101
- next: null,
102
- speed: format(transfer.fromFile.size, this?.startTime)
103
- })
104
- window.store.addTransferHistory(
105
- r
106
- )
107
- }
108
- const cbs = [
109
- this[typeTo + 'List']
110
- ]
111
- if (next) {
112
- cbs.push(() => {
113
- setTimeout(
114
- () => {
115
- window.store.fileTransfers.splice(
116
- this.props.index, 0, copy(next)
117
- )
118
- },
119
- 100
120
- )
121
- })
122
- }
123
- const cb = () => {
124
- cbs.forEach(cb => cb())
125
- }
126
- this.cancel(cb)
127
- }
128
-
129
- onData = (transferred) => {
130
- if (this.onCancel) {
131
- return
132
- }
133
- const { transfer } = this.props
134
- const up = {}
135
- const total = transfer.fromFile.size
136
- let percent = total === 0
137
- ? 0
138
- : Math.floor(100 * transferred / total)
139
- percent = percent >= 100 ? 99 : percent
140
- up.percent = percent
141
- up.status = 'active'
142
- up.transferred = transferred
143
- up.startTime = this.startTime
144
- up.speed = format(transferred, up.startTime)
145
- Object.assign(
146
- up,
147
- computeLeftTime(transferred, total, up.startTime)
148
- )
149
- up.passedTime = computePassedTime(up.startTime)
150
- this.update(up)
151
- }
152
-
153
- cancel = (callback) => {
154
- if (this.onCancel) {
155
- return
156
- }
157
- this.onCancel = true
158
- this.transport && this.transport.destroy()
159
- this.transport = null
160
- window.store.fileTransfers.splice(
161
- this.props.index, 1
162
- )
163
- if (isFunction(callback)) {
164
- callback()
165
- }
166
- }
167
-
168
- pause = () => {
169
- this.transport && this.transport.pause()
170
- }
171
-
172
- resume = () => {
173
- this.transport && this.transport.resume()
174
- }
175
-
176
- mvOrCp = () => {
177
- const {
178
- transfer
179
- } = this.props
180
- const {
181
- fromPath,
182
- toPath,
183
- typeFrom,
184
- sessionId,
185
- operation // 'mv' or 'cp'
186
- } = transfer
187
- if (typeFrom === typeMap.local) {
188
- return fs[operation](fromPath, toPath)
189
- .then(this.onEnd)
190
- .catch(e => {
191
- this.onEnd()
192
- this.onError(e)
193
- })
194
- }
195
- const sftp = refs.get('sftp-' + sessionId).sftp
196
- return sftp[operation](fromPath, toPath)
197
- .then(this.onEnd)
198
- .catch(e => {
199
- this.onEnd()
200
- this.onError(e)
201
- })
202
- }
203
-
204
- zipTransfer = async () => {
205
- const {
206
- transfer
207
- } = this.props
208
- const {
209
- fromPath,
210
- toPath,
211
- typeFrom,
212
- sessionId
213
- } = transfer
214
- let p
215
- let isFromRemote
216
- if (typeFrom === typeMap.local) {
217
- isFromRemote = false
218
- p = await fs.zipFolder(fromPath)
219
- } else {
220
- isFromRemote = true
221
- p = await zipCmd('', sessionId, fromPath)
222
- }
223
- const { name } = getFolderFromFilePath(p, isFromRemote)
224
- const { path } = getFolderFromFilePath(toPath, !isFromRemote)
225
- const nTo = resolve(path, name)
226
- const newTrans1 = {
227
- ...copy(transfer),
228
- toPathReal: transfer.toPath,
229
- fromPathReal: transfer.fromPath,
230
- toPath: nTo,
231
- fromPath: p,
232
- originalId: transfer.id,
233
- id: generate()
234
- }
235
- delete newTrans1.inited
236
- delete newTrans1.zip
237
- delete newTrans1.fromFile
238
- const newTrans2 = copy(newTrans1)
239
- newTrans2.unzip = true
240
- newTrans2.id = generate()
241
- newTrans1.next = newTrans2
242
- this.insert([newTrans1])
243
- }
244
-
245
- buildUnzipPath = (transfer) => {
246
- const {
247
- newName,
248
- toPath,
249
- typeTo,
250
- oldName
251
- } = transfer
252
- const isToRemote = typeTo === typeMap.remote
253
- const { path } = getFolderFromFilePath(toPath, isToRemote)
254
- const np = newName
255
- ? resolve(path, 'temp-' + newName)
256
- : path
257
- return {
258
- targetPath: path,
259
- path: np,
260
- name: oldName
261
- }
262
- }
263
-
264
- unzipFile = async () => {
265
- if (this.unzipping) {
266
- return false
267
- }
268
- this.unzipping = true
269
- const { transfer } = this.props
270
- const {
271
- fromPath,
272
- toPath,
273
- typeTo,
274
- newName,
275
- sessionId
276
- } = transfer
277
- const isToRemote = typeTo === typeMap.remote
278
- const {
279
- path,
280
- name,
281
- targetPath
282
- } = this.buildUnzipPath(transfer)
283
- if (isToRemote) {
284
- if (newName) {
285
- await mkdirCmd('', sessionId, path)
286
- await delay(1000)
287
- }
288
- await unzipCmd('', sessionId, toPath, path)
289
- if (newName) {
290
- const mvFrom = resolve(path, name)
291
- const mvTo = resolve(targetPath, newName)
292
- await mvCmd('', sessionId, mvFrom, mvTo)
293
- }
294
- } else {
295
- if (newName) {
296
- await fs.mkdir(path)
297
- }
298
- await fs.unzipFile(toPath, path)
299
- if (newName) {
300
- const mvFrom = resolve(path, name)
301
- const mvTo = resolve(targetPath, newName)
302
- await fs.mv(mvFrom, mvTo)
303
- }
304
- }
305
- await rmCmd('', sessionId, !isToRemote ? fromPath : toPath)
306
- await fs.rmrf(!isToRemote ? toPath : fromPath)
307
- if (newName) {
308
- if (isToRemote) {
309
- await rmCmd('', sessionId, path)
310
- } else {
311
- await fs.rmrf(path)
312
- }
313
- }
314
- this.onEnd()
315
- }
316
-
317
- doTransfer = async () => {
318
- const { transfer } = this.props
319
- const {
320
- fromPath,
321
- toPath,
322
- typeFrom,
323
- fromFile: {
324
- mode: fromMode
325
- },
326
- toFile = {}
327
- } = transfer
328
- const transferType = typeFrom === typeMap.local ? transferTypeMap.upload : transferTypeMap.download
329
- const isDown = transferType === transferTypeMap.download
330
- const localPath = isDown
331
- ? toPath
332
- : fromPath
333
- const remotePath = isDown
334
- ? fromPath
335
- : toPath
336
- const mode = toFile.mode || fromMode
337
- const sftp = refs.get('sftp-' + this.sessionId).sftp
338
- this.transport = await sftp[transferType]({
339
- remotePath,
340
- localPath,
341
- options: { mode },
342
- onData: this.onData,
343
- onError: this.onError,
344
- onEnd: this.onEnd
345
- })
346
- }
347
-
348
- isTransferAction = (action) => {
349
- return action.includes('rename') || action === 'transfer'
350
- }
351
-
352
- initTransfer = async () => {
353
- if (this.started) {
354
- return
355
- }
356
- const { transfer } = this.props
357
- const {
358
- typeFrom,
359
- typeTo,
360
- fromFile: {
361
- isDirectory
362
- },
363
- action,
364
- expanded,
365
- zip,
366
- unzip,
367
- inited
368
- } = transfer
369
- const t = Date.now()
370
- this.update({
371
- startTime: t
372
- })
373
- this.startTime = t
374
- this.started = true
375
- if (typeFrom === typeTo) {
376
- return this.mvOrCp()
377
- } else if (unzip && inited) {
378
- this.unzipFile()
379
- } else if (zip && inited) {
380
- this.zipTransfer()
381
- } else if (isDirectory && expanded && this.isTransferAction(action)) {
382
- return this.mkdir()
383
- .then(this.onEnd)
384
- .catch(this.onError)
385
- } else if (!isDirectory) {
386
- this.doTransfer()
387
- } else if (expanded && isDirectory && !this.isTransferAction(action)) {
388
- this.cancel()
389
- }
390
- }
391
-
392
- onError = (e) => {
393
- const up = {
394
- status: 'exception',
395
- error: e.message
396
- }
397
- this.onEnd(up)
398
- window.store.onError(e)
399
- }
400
-
401
- mkdir = async () => {
402
- const {
403
- transfer
404
- } = this.props
405
- const {
406
- typeTo,
407
- toPath,
408
- sessionId
409
- } = transfer
410
- if (typeTo === typeMap.local) {
411
- return fs.mkdir(toPath)
412
- .catch(this.onError)
413
- }
414
- const sftp = refs.get('sftp-' + sessionId).sftp
415
- return sftp.mkdir(toPath)
416
- .catch(this.onError)
417
- }
418
-
419
- render () {
420
- return null
421
- }
422
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * zip/unzip remote files
3
- * should only support linux server
4
- */
5
-
6
- import { runCmd } from '../terminal/terminal-apis'
7
- import { getFolderFromFilePath } from './file-read'
8
- import resolve from '../../common/resolve'
9
- import generate from '../../common/uid'
10
-
11
- const isRemote = true
12
- const temp = '/tmp'
13
-
14
- export async function zipCmd (pid, sessionId, filePath) {
15
- // tar -czf bin.tar bin
16
- const id = generate()
17
- const { path, name } = getFolderFromFilePath(filePath, isRemote)
18
- const np = resolve(temp, `electerm-${id}.tar`)
19
- const cmd = `tar -C "${path}" -cf "${np}" "${name}"`
20
- await runCmd(pid, sessionId, cmd)
21
- return np
22
- }
23
-
24
- export function unzipCmd (pid, sessionId, from, to) {
25
- const cmd = `tar -xf "${from}" -C "${to}"`
26
- return runCmd(pid, sessionId, cmd)
27
- }
28
-
29
- export async function rmCmd (pid, sessionId, path) {
30
- const cmd = `rm -rf "${path}"`
31
- return runCmd(pid, sessionId, cmd)
32
- }
33
-
34
- export async function mvCmd (pid, sessionId, from, to) {
35
- const cmd = `mv "${from}" "${to}"`
36
- return runCmd(pid, sessionId, cmd)
37
- }
38
-
39
- export async function mkdirCmd (pid, sessionId, p) {
40
- const cmd = `mkdir "${p}"`
41
- return runCmd(pid, sessionId, cmd)
42
- }
File without changes