@electerm/electerm-react 3.15.38 → 3.15.41

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 (27) hide show
  1. package/client/common/choose-save-folder.js +3 -2
  2. package/client/common/download.jsx +4 -16
  3. package/client/components/batch-op/batch-op-editor.jsx +5 -6
  4. package/client/components/bg/css-overwrite.jsx +1 -2
  5. package/client/components/bookmark-form/common/ssh-auth-selector.jsx +3 -2
  6. package/client/components/common/upload.jsx +9 -1
  7. package/client/components/file-transfer/remote2remote-handler.jsx +1 -2
  8. package/client/components/file-transfer/transfer.jsx +8 -9
  9. package/client/components/main/main.jsx +1 -0
  10. package/client/components/quick-commands/quick-command-transport-mod.jsx +3 -2
  11. package/client/components/rdp/file-transfer.js +8 -8
  12. package/client/components/rdp/rdp-session.jsx +2 -1
  13. package/client/components/setting-panel/keywords-transport.jsx +3 -2
  14. package/client/components/setting-panel/setting-terminal.jsx +6 -4
  15. package/client/components/setting-panel/terminal-bg-config.jsx +3 -0
  16. package/client/components/sftp/address-bar.jsx +1 -0
  17. package/client/components/sftp/file-info-modal.jsx +1 -2
  18. package/client/components/sftp/file-item.jsx +12 -13
  19. package/client/components/sftp/file-read.js +2 -3
  20. package/client/components/sftp/owner-list.js +4 -5
  21. package/client/components/sftp/sftp-entry.jsx +4 -5
  22. package/client/components/terminal/transfer-client-base.js +4 -3
  23. package/client/components/theme/theme-form.jsx +3 -2
  24. package/client/components/tree-list/bookmark-upload.js +3 -2
  25. package/client/store/load-data.js +1 -2
  26. package/client/store/sync.js +3 -3
  27. package/package.json +1 -1
@@ -2,7 +2,7 @@ const {
2
2
  openDialog
3
3
  } = window.api
4
4
 
5
- export async function chooseSaveDirectory () {
5
+ export async function chooseSaveDirectory (opts) {
6
6
  const savePaths = await openDialog({
7
7
  title: 'Choose a folder to save file(s)',
8
8
  message: 'Choose a folder to save file(s)',
@@ -13,7 +13,8 @@ export async function chooseSaveDirectory () {
13
13
  'noResolveAliases',
14
14
  'treatPackageAsDirectory',
15
15
  'dontAddToRecent'
16
- ]
16
+ ],
17
+ ...opts
17
18
  })
18
19
  if (!savePaths || !savePaths.length) {
19
20
  return undefined
@@ -6,23 +6,11 @@ import ShowItem from '../components/common/show-item'
6
6
  import { chooseSaveDirectory } from './choose-save-folder'
7
7
  import { DownloadOutlined } from '@ant-design/icons'
8
8
 
9
- // function downloadForBrowser (filename, text) {
10
- // const blob = new Blob([text], { type: 'text/plain;charset=utf-8' })
11
- // const url = URL.createObjectURL(blob)
12
- // const a = document.createElement('a')
13
- // a.href = url
14
- // a.download = filename
15
- // document.body.appendChild(a)
16
- // a.click()
17
- // document.body.removeChild(a)
18
- // URL.revokeObjectURL(url)
19
- // }
20
-
21
9
  export default async function download (filename, text) {
22
- // if (window.et.isWebApp) {
23
- // return downloadForBrowser(filename, text)
24
- // }
25
- const savePath = await chooseSaveDirectory()
10
+ const opts = window.et.isWebApp
11
+ ? { filename, content: text }
12
+ : undefined
13
+ const savePath = await chooseSaveDirectory(opts)
26
14
  if (!savePath) {
27
15
  return
28
16
  }
@@ -14,7 +14,6 @@ import BatchOpLogs from './batch-op-logs'
14
14
  import message from '../common/message'
15
15
  import { refsStatic } from '../common/ref'
16
16
  import generate from '../../common/uid'
17
- import fs from '../../common/fs'
18
17
  import { safeGetItem, safeSetItem } from '../../common/safe-local-storage'
19
18
 
20
19
  const batchOpEditorKey = 'batch-op-editor-content'
@@ -134,14 +133,14 @@ export default function BatchOpEditor ({ widget }) {
134
133
  const handleEditWithSystemEditor = useCallback(async () => {
135
134
  const id = generate()
136
135
  const tempPath = window.pre.resolve(window.pre.tempDir, `electerm-batch-op-${id}.json`)
137
- await fs.writeFile(tempPath, value)
136
+ await window.fs.writeFile(tempPath, value)
138
137
  window.pre.runGlobalAsync('watchFile', tempPath)
139
- fs.openFile(tempPath).catch(window.store.onError)
138
+ window.fs.openFile(tempPath).catch(window.store.onError)
140
139
  window.pre.showItemInFolder(tempPath)
141
140
  const onFileChange = (e, text) => {
142
141
  setValue(text)
143
142
  window.pre.ipcOffEvent('file-change', onFileChange)
144
- fs.unlink(tempPath).catch(console.log)
143
+ window.fs.unlink(tempPath).catch(console.log)
145
144
  }
146
145
  window.pre.ipcOnEvent('file-change', onFileChange)
147
146
  }, [value])
@@ -149,13 +148,13 @@ export default function BatchOpEditor ({ widget }) {
149
148
  const handleEditWithCustom = useCallback(async (editorCommand) => {
150
149
  const id = generate()
151
150
  const tempPath = window.pre.resolve(window.pre.tempDir, `electerm-batch-op-${id}.json`)
152
- await fs.writeFile(tempPath, value)
151
+ await window.fs.writeFile(tempPath, value)
153
152
  window.pre.runGlobalAsync('watchFile', tempPath)
154
153
  await window.pre.runGlobalAsync('openFileWithEditor', tempPath, editorCommand)
155
154
  const onFileChange = (e, text) => {
156
155
  setValue(text)
157
156
  window.pre.ipcOffEvent('file-change', onFileChange)
158
- fs.unlink(tempPath).catch(console.log)
157
+ window.fs.unlink(tempPath).catch(console.log)
159
158
  }
160
159
  window.pre.ipcOnEvent('file-change', onFileChange)
161
160
  }, [value])
@@ -2,7 +2,6 @@
2
2
  * btns
3
3
  */
4
4
  import { useEffect, useRef } from 'react'
5
- import fs from '../../common/fs'
6
5
  import { noTerminalBgValue, textTerminalBgValue } from '../../common/constants'
7
6
  import { generateMosaicBackground } from './shapes'
8
7
 
@@ -24,7 +23,7 @@ function createBackgroundStyle (imagePath) {
24
23
  } else if (textTerminalBgValue === imagePath) {
25
24
  st = 'text'
26
25
  } else if (imagePath && !isWebImg) {
27
- return fs.readFileAsBase64(imagePath)
26
+ return window.fs.readFileAsBase64(imagePath)
28
27
  .then(content => {
29
28
  if (content) {
30
29
  return `url(data:image;base64,${content})`
@@ -26,8 +26,9 @@ export default function renderAuth (props) {
26
26
  profileFilter = (d) => d
27
27
  } = props
28
28
  const commonBeforeUpload = (fieldName) => async (file) => {
29
- const filePath = file.filePath
30
- const content = await window.fs.readFile(filePath)
29
+ const content = file.fileContent !== undefined
30
+ ? file.fileContent
31
+ : await window.fs.readFile(file.filePath)
31
32
  form.setFieldsValue({
32
33
  [fieldName]: content
33
34
  })
@@ -8,6 +8,7 @@ import { getLocalFileInfo } from '../sftp/file-read'
8
8
 
9
9
  /**
10
10
  * Open a single file select dialog
11
+ * Supports browser upload in web app mode
11
12
  * @returns {Promise<Object|null>} - File object with path info or null if cancelled
12
13
  */
13
14
  const openFileSelect = async () => {
@@ -23,7 +24,14 @@ const openFileSelect = async () => {
23
24
  message: 'Choose a file',
24
25
  properties
25
26
  }).catch(() => false)
26
- if (!files || !files.length) {
27
+ if (!files) {
28
+ return null
29
+ }
30
+ // Browser upload returns { fileContent, fileName }
31
+ if (files.fileContent !== undefined) {
32
+ return files
33
+ }
34
+ if (!files.length) {
27
35
  return null
28
36
  }
29
37
  const filePath = files[0]
@@ -2,7 +2,6 @@ import { autoRun } from 'manate'
2
2
  import copy from 'json-deep-copy'
3
3
  import uid from '../../common/uid'
4
4
  import resolve from '../../common/resolve'
5
- import fs from '../../common/fs'
6
5
  import { typeMap } from '../../common/constants'
7
6
  import { getFolderFromFilePath, getLocalFileInfo } from '../sftp/file-read'
8
7
 
@@ -154,7 +153,7 @@ export default class Remote2RemoteHandler {
154
153
  if (!this.tempPath) {
155
154
  return
156
155
  }
157
- await fs.rmrf(this.tempPath).catch(() => {})
156
+ await window.fs.rmrf(this.tempPath).catch(() => {})
158
157
  }
159
158
 
160
159
  finish = async (error) => {
@@ -3,7 +3,6 @@ import copy from 'json-deep-copy'
3
3
  import { isFunction } from 'lodash-es'
4
4
  import generate from '../../common/uid'
5
5
  import { typeMap, transferTypeMap, fileOperationsMap, fileActions } from '../../common/constants'
6
- import fs from '../../common/fs'
7
6
  import format, { computeLeftTime, computePassedTime } from './transfer-speed-format'
8
7
  import {
9
8
  getLocalFileInfo,
@@ -257,7 +256,7 @@ export default class TransportAction extends Component {
257
256
  })
258
257
  }
259
258
  if (typeFrom === typeMap.local) {
260
- return fs[operation](fromPath, finalToPath)
259
+ return window.fs[operation](fromPath, finalToPath)
261
260
  .then(this.onEnd)
262
261
  .catch(e => {
263
262
  this.onEnd()
@@ -436,7 +435,7 @@ export default class TransportAction extends Component {
436
435
  let isFromRemote
437
436
  if (typeFrom === typeMap.local) {
438
437
  isFromRemote = false
439
- p = await fs.zipFolder(fromPath)
438
+ p = await window.fs.zipFolder(fromPath)
440
439
  } else {
441
440
  isFromRemote = true
442
441
  const terminalId = refs.get('sftp-' + this.tabId)?.terminalId
@@ -484,22 +483,22 @@ export default class TransportAction extends Component {
484
483
  }
485
484
  } else {
486
485
  if (newName) {
487
- await fs.mkdir(path)
486
+ await window.fs.mkdir(path)
488
487
  }
489
- await fs.unzipFile(toPath, path)
488
+ await window.fs.unzipFile(toPath, path)
490
489
  if (newName) {
491
490
  const mvFrom = resolve(path, name)
492
491
  const mvTo = resolve(targetPath, newName)
493
- await fs.mv(mvFrom, mvTo)
492
+ await window.fs.mv(mvFrom, mvTo)
494
493
  }
495
494
  }
496
495
  await rmCmd(terminalId, !isToRemote ? fromPath : toPath)
497
- await fs.rmrf(!isToRemote ? toPath : fromPath)
496
+ await window.fs.rmrf(!isToRemote ? toPath : fromPath)
498
497
  if (newName) {
499
498
  if (isToRemote) {
500
499
  await rmCmd(terminalId, path)
501
500
  } else {
502
- await fs.rmrf(path)
501
+ await window.fs.rmrf(path)
503
502
  }
504
503
  }
505
504
  this.onEnd()
@@ -821,7 +820,7 @@ export default class TransportAction extends Component {
821
820
  tabId
822
821
  } = transfer
823
822
  if (typeTo === typeMap.local) {
824
- return fs.mkdir(toPath)
823
+ return window.fs.mkdir(toPath)
825
824
  .then(() => true)
826
825
  .catch(() => false)
827
826
  }
@@ -40,6 +40,7 @@ import { pick } from 'lodash-es'
40
40
  import deepCopy from 'json-deep-copy'
41
41
  import './wrapper.styl'
42
42
  import TerminalInfo from '../terminal-info/terminal-info-entry'
43
+ import '../../common/fs.js'
43
44
  import './term-fullscreen.styl'
44
45
 
45
46
  export default auto(function Index (props) {
@@ -7,8 +7,9 @@ export default class QmTransport extends BookmarkTransport {
7
7
  name = 'quickCommands'
8
8
  beforeUpload = async (file) => {
9
9
  const { store } = this.props
10
- const filePath = file.filePath
11
- const txt = await window.fs.readFile(filePath)
10
+ const txt = file.fileContent !== undefined
11
+ ? file.fileContent
12
+ : await window.fs.readFile(file.filePath)
12
13
  try {
13
14
  const arr = JSON.parse(txt)
14
15
  const state = store[this.name]
@@ -3,7 +3,6 @@
3
3
  * Handles file upload/download between local and remote desktop via IronRDP CLIPRDR channel
4
4
  */
5
5
 
6
- import fs from '../../common/fs'
7
6
  import { getLocalFileInfo } from '../sftp/file-read'
8
7
  import { osResolve } from '../../common/resolve'
9
8
  import { filesize } from 'filesize'
@@ -115,7 +114,7 @@ export class FileTransferManager {
115
114
  const length = request.size
116
115
 
117
116
  const fd = await new Promise((resolve, reject) => {
118
- fs.open(file.filePath, O_RDONLY, (err, fd) => {
117
+ window.fs.open(file.filePath, O_RDONLY, (err, fd) => {
119
118
  if (err) reject(err)
120
119
  else resolve(fd)
121
120
  })
@@ -123,14 +122,14 @@ export class FileTransferManager {
123
122
 
124
123
  const buffer = new Uint8Array(length)
125
124
  const { bytesRead, buffer: readBuffer } = await new Promise((resolve, reject) => {
126
- fs.read(fd, buffer, 0, length, start, (err, bytesRead, buffer) => {
125
+ window.fs.read(fd, buffer, 0, length, start, (err, bytesRead, buffer) => {
127
126
  if (err) reject(err)
128
127
  else resolve({ bytesRead, buffer })
129
128
  })
130
129
  })
131
130
 
132
131
  await new Promise((resolve, reject) => {
133
- fs.close(fd, (err) => {
132
+ window.fs.close(fd, (err) => {
134
133
  if (err) reject(err)
135
134
  else resolve()
136
135
  })
@@ -234,7 +233,8 @@ export class FileTransferManager {
234
233
  const savePath = await window.api.openDialog({
235
234
  title: `Save ${fileInfo.name}`,
236
235
  message: `Choose where to save ${fileInfo.name}`,
237
- properties: ['openDirectory', 'createDirectory']
236
+ properties: ['openDirectory', 'createDirectory'],
237
+ noBrowserTransfer: true
238
238
  }).catch((err) => {
239
239
  this.log(`Save dialog error: ${err.message}`, 'error')
240
240
  return false
@@ -248,7 +248,7 @@ export class FileTransferManager {
248
248
  const fullPath = osResolve(savePath[0], fileInfo.name)
249
249
 
250
250
  const fd = await new Promise((resolve, reject) => {
251
- fs.open(fullPath, O_WRONLY | O_CREAT | O_TRUNC, (err, fd) => {
251
+ window.fs.open(fullPath, O_WRONLY | O_CREAT | O_TRUNC, (err, fd) => {
252
252
  if (err) reject(err)
253
253
  else resolve(fd)
254
254
  })
@@ -259,14 +259,14 @@ export class FileTransferManager {
259
259
  const data = new Uint8Array(arrayBuffer)
260
260
 
261
261
  await new Promise((resolve, reject) => {
262
- fs.write(fd, data, (err) => {
262
+ window.fs.write(fd, data, (err) => {
263
263
  if (err) reject(err)
264
264
  else resolve()
265
265
  })
266
266
  })
267
267
 
268
268
  await new Promise((resolve, reject) => {
269
- fs.close(fd, (err) => {
269
+ window.fs.close(fd, (err) => {
270
270
  if (err) reject(err)
271
271
  else resolve()
272
272
  })
@@ -562,7 +562,8 @@ export default class RdpSession extends PureComponent {
562
562
  const files = await window.api.openDialog({
563
563
  title: 'Choose files to upload to remote desktop',
564
564
  message: 'Choose files to upload',
565
- properties
565
+ properties,
566
+ noBrowserTransfer: true
566
567
  }).catch((err) => {
567
568
  this.log(`File dialog error: ${err.message}`, 'error')
568
569
  return false
@@ -6,8 +6,9 @@ export default class KeywordsTransport extends BookmarkTransport {
6
6
  name = 'keywords-highlight'
7
7
  beforeUpload = async (file) => {
8
8
  const { store } = this.props
9
- const filePath = file.filePath
10
- const txt = await window.fs.readFile(filePath)
9
+ const txt = file.fileContent !== undefined
10
+ ? file.fileContent
11
+ : await window.fs.readFile(file.filePath)
11
12
  try {
12
13
  store.setConfig({
13
14
  keywords: JSON.parse(txt)
@@ -31,7 +31,6 @@ import Link from '../common/external-link'
31
31
  import FontSelect from '../common/font-select'
32
32
  import HelpIcon from '../common/help-icon'
33
33
  import KeywordsTransport from './keywords-transport'
34
- import fs from '../../common/fs'
35
34
  import uid from '../../common/uid'
36
35
  import createDefaultSessionLogPath from '../../common/default-log-path'
37
36
  import TerminalBackgroundConfig from './terminal-bg-config'
@@ -136,14 +135,14 @@ export default class SettingTerminal extends Component {
136
135
 
137
136
  testFolderPathCanSaveLog = async (path) => {
138
137
  try {
139
- const st = await fs.statCustom(path)
138
+ const st = await window.fs.statCustom(path)
140
139
  if (!st.isD) {
141
140
  message.error('invalid log folder')
142
141
  return false
143
142
  }
144
143
  const testFile = osResolve(path, uid + '.test.log')
145
- await fs.touch(testFile)
146
- await fs.unlink(testFile)
144
+ await window.fs.touch(testFile)
145
+ await window.fs.unlink(testFile)
147
146
  return true
148
147
  } catch (err) {
149
148
  message.error('invalid log folder')
@@ -265,6 +264,9 @@ export default class SettingTerminal extends Component {
265
264
  const after = (
266
265
  <Upload
267
266
  beforeUpload={(file) => {
267
+ if (file.fileContent !== undefined) {
268
+ return
269
+ }
268
270
  const filePath = file.filePath
269
271
  this.onChangeValue(filePath, name)
270
272
  }}
@@ -32,6 +32,9 @@ export default function TerminalBackgroundConfig ({
32
32
  const after = (
33
33
  <Upload
34
34
  beforeUpload={(file) => {
35
+ if (file.fileContent !== undefined) {
36
+ return
37
+ }
35
38
  const filePath = file.filePath
36
39
  onChangeValue(filePath, name)
37
40
  }}
@@ -89,6 +89,7 @@ function renderAddonAfter (isLoadingRemote, onGoto, GoIcon, type, handleUploadFr
89
89
  ? (
90
90
  <PlusOutlined
91
91
  className='mg1r'
92
+ title={e('uploadFromBrowser')}
92
93
  onClick={(e) => {
93
94
  e.stopPropagation()
94
95
  handleUploadFromBrowser()
@@ -11,7 +11,6 @@ import { update } from 'lodash-es'
11
11
  import { mode2permission, permission2mode } from '../../common/mode2permission'
12
12
  import renderPermission from './permission-render'
13
13
  import FileIcon from './file-icon'
14
- import fs from '../../common/fs'
15
14
  import { filesize } from 'filesize'
16
15
  import { runCmd } from '../terminal/terminal-apis'
17
16
  import {
@@ -166,7 +165,7 @@ export default class FileMode extends React.PureComponent {
166
165
  ? `Get-ChildItem -Recurse '${folder}' | Measure-Object -Property Length -Sum`
167
166
  : `du -sh '${folder}'`
168
167
  const func = isWin ? 'runWinCmd' : 'run'
169
- const res = await fs[func](cmd).catch(window.store.onError)
168
+ const res = await window.fs[func](cmd).catch(window.store.onError)
170
169
  return this.getSize(res)
171
170
  }
172
171
 
@@ -31,7 +31,6 @@ import sorter from '../../common/index-sorter'
31
31
  import { getFolderFromFilePath, getLocalFileInfo } from './file-read'
32
32
  import { readClipboard, copy as copyToClipboard, hasFileInClipboardText } from '../../common/clipboard'
33
33
  import { getDropFileList } from '../../common/file-drop-utils'
34
- import fs from '../../common/fs'
35
34
  import time from '../../common/time'
36
35
  import { filesize } from 'filesize'
37
36
  import { createTransferProps } from './transfer-common'
@@ -391,8 +390,8 @@ export default class FileSection extends React.Component {
391
390
  const { localPath } = this.props
392
391
  const p = resolve(localPath, nameTemp)
393
392
  const func = isDirectory
394
- ? fs.mkdir
395
- : fs.touch
393
+ ? window.fs.mkdir
394
+ : window.fs.touch
396
395
  const res = await func(p)
397
396
  .then(() => true)
398
397
  .catch(window.store.onError)
@@ -496,7 +495,7 @@ export default class FileSection extends React.Component {
496
495
  this.clearRef()
497
496
  const { permission, type, path, name } = file
498
497
  const func = type === typeMap.local
499
- ? fs.chmod
498
+ ? window.fs.chmod
500
499
  : this.props.sftp.chmod
501
500
  const p = resolve(path, name)
502
501
  await func(p, permission).catch(window.store.onError)
@@ -546,7 +545,7 @@ export default class FileSection extends React.Component {
546
545
  const { localPath } = this.props
547
546
  const p1 = resolve(localPath, oldname)
548
547
  const p2 = resolve(localPath, newname)
549
- await fs.rename(p1, p2).catch(window.store.onError)
548
+ await window.fs.rename(p1, p2).catch(window.store.onError)
550
549
  this.props.localList()
551
550
  }
552
551
 
@@ -593,7 +592,7 @@ export default class FileSection extends React.Component {
593
592
 
594
593
  openFile = file => {
595
594
  const filePath = resolve(file.path, file.name)
596
- fs.openFile(filePath)
595
+ window.fs.openFile(filePath)
597
596
  .catch(window.store.onError)
598
597
  }
599
598
 
@@ -602,7 +601,7 @@ export default class FileSection extends React.Component {
602
601
  if (this.watchingFile) {
603
602
  window.pre.ipcOffEvent('file-change', this.onFileChange)
604
603
  window.pre.runGlobalAsync('unwatchFile', this.watchingFile)
605
- fs.unlink(this.watchingFile).catch(console.log)
604
+ window.fs.unlink(this.watchingFile).catch(console.log)
606
605
  delete this.watchingFile
607
606
  }
608
607
  }
@@ -621,7 +620,7 @@ export default class FileSection extends React.Component {
621
620
  tempPath = window.pre.resolve(
622
621
  window.pre.tempDir, `electerm-temp-${id}-${name}`
623
622
  )
624
- await fs.writeFile(tempPath, text)
623
+ await window.fs.writeFile(tempPath, text)
625
624
  }
626
625
  this.watchingFile = tempPath
627
626
  this.watchFile(tempPath)
@@ -641,7 +640,7 @@ export default class FileSection extends React.Component {
641
640
  tempPath = window.pre.resolve(
642
641
  window.pre.tempDir, `electerm-temp-${id}-${name}`
643
642
  )
644
- await fs.writeFile(tempPath, text)
643
+ await window.fs.writeFile(tempPath, text)
645
644
  }
646
645
  this.watchingFile = tempPath
647
646
  window.pre.runGlobalAsync('watchFile', tempPath)
@@ -658,7 +657,7 @@ export default class FileSection extends React.Component {
658
657
 
659
658
  watchFile = async (tempPath) => {
660
659
  window.pre.runGlobalAsync('watchFile', tempPath)
661
- fs.openFile(tempPath)
660
+ window.fs.openFile(tempPath)
662
661
  .catch(window.store.onError)
663
662
  window.pre.showItemInFolder(tempPath)
664
663
  window.pre.ipcOnEvent('file-change', this.onFileChange)
@@ -688,7 +687,7 @@ export default class FileSection extends React.Component {
688
687
  // const sftp = sftpFunc()
689
688
  const text = typeMap.remote === type
690
689
  ? await this.props.sftp.readFile(path)
691
- : await fs.readFile(path)
690
+ : await window.fs.readFile(path)
692
691
  return text
693
692
  }
694
693
 
@@ -699,7 +698,7 @@ export default class FileSection extends React.Component {
699
698
  text,
700
699
  mode
701
700
  ).catch(window.store.onError)
702
- : await fs.writeFile(
701
+ : await window.fs.writeFile(
703
702
  path,
704
703
  text,
705
704
  mode
@@ -1069,7 +1068,7 @@ export default class FileSection extends React.Component {
1069
1068
  res.push({
1070
1069
  func: 'downloadFromBrowser',
1071
1070
  icon: 'DownloadOutlined',
1072
- text: 'Download from browser'
1071
+ text: e('downloadFromBrowser')
1073
1072
  })
1074
1073
  }
1075
1074
  if (showEdit) {
@@ -3,7 +3,6 @@
3
3
  */
4
4
 
5
5
  import generate from '../../common/uid'
6
- import fs from '../../common/fs'
7
6
  import { isWin } from '../../common/constants'
8
7
 
9
8
  export const getFileExt = fileName => {
@@ -106,8 +105,8 @@ export const getFolderFromFilePath = (filePath, isRemote) => {
106
105
  }
107
106
 
108
107
  export const getLocalFileInfo = async (filePath) => {
109
- const statr = await fs.statAsync(filePath)
110
- const stat = await fs.lstatAsync(filePath)
108
+ const statr = await window.fs.statAsync(filePath)
109
+ const stat = await window.fs.lstatAsync(filePath)
111
110
  return {
112
111
  size: stat.size,
113
112
  accessTime: stat.atime || stat.atimeMs,
@@ -9,7 +9,6 @@
9
9
  * for windows list groups: do not know yet
10
10
  */
11
11
 
12
- import fs from '../../common/fs'
13
12
  import { runCmd } from '../terminal/terminal-apis'
14
13
  import { isWin, isMac } from '../../common/constants'
15
14
 
@@ -49,7 +48,7 @@ export async function localListUsers () {
49
48
  if (isWin) {
50
49
  return {}
51
50
  } else if (isMac) {
52
- const g = await fs.run('dscl . -list /Users UniqueID')
51
+ const g = await window.fs.run('dscl . -list /Users UniqueID')
53
52
  .catch(console.error)
54
53
  return g
55
54
  ? g.split('\n')
@@ -65,7 +64,7 @@ export async function localListUsers () {
65
64
  }, {})
66
65
  : {}
67
66
  } else {
68
- const g = await fs.run(linuxListUser).catch(console.error)
67
+ const g = await window.fs.run(linuxListUser).catch(console.error)
69
68
  return g
70
69
  ? parseNames(g)
71
70
  : {}
@@ -76,7 +75,7 @@ export async function localListGroups () {
76
75
  if (isWin) {
77
76
  return {}
78
77
  } else if (isMac) {
79
- const g = await fs.run('dscl . list /Groups PrimaryGroupID')
78
+ const g = await window.fs.run('dscl . list /Groups PrimaryGroupID')
80
79
  .catch(console.error)
81
80
  return g
82
81
  ? g.split('\n')
@@ -89,7 +88,7 @@ export async function localListGroups () {
89
88
  }, {})
90
89
  : {}
91
90
  } else {
92
- const g = await fs.run(linuxListGroup).catch(console.error)
91
+ const g = await window.fs.run(linuxListGroup).catch(console.error)
93
92
  return g
94
93
  ? parseNames(g)
95
94
  : {}
@@ -25,7 +25,6 @@ import {
25
25
  } from '../../common/constants'
26
26
  import { hasFileInClipboardText } from '../../common/clipboard'
27
27
  import Client from '../../common/sftp'
28
- import fs from '../../common/fs'
29
28
  import ListTable from './list-table-ui'
30
29
  import deepCopy from 'json-deep-copy'
31
30
  import isValidPath from '../../common/is-valid-path'
@@ -410,8 +409,8 @@ export default class Sftp extends Component {
410
409
  localDel = async (file) => {
411
410
  const { name, isDirectory, path } = file
412
411
  const func = !isDirectory
413
- ? fs.unlink
414
- : fs.rmrf
412
+ ? window.fs.unlink
413
+ : window.fs.rmrf
415
414
  const p = resolve(path, name)
416
415
  await func(p).catch(window.store.onError)
417
416
  }
@@ -878,7 +877,7 @@ export default class Sftp extends Component {
878
877
  }
879
878
 
880
879
  localList = async (returnList = false, localPathReal, oldPath) => {
881
- if (!fs) return
880
+ if (!window.fs) return
882
881
  if (!returnList) {
883
882
  this.setState({
884
883
  localLoading: true
@@ -892,7 +891,7 @@ export default class Sftp extends Component {
892
891
  const localPath = noPathInit ||
893
892
  this.getCwdLocal() ||
894
893
  this.getLocalHome()
895
- const locals = await fs.readdirAsync(localPath)
894
+ const locals = await window.fs.readdirAsync(localPath)
896
895
  const local = []
897
896
  for (const name of locals) {
898
897
  const p = resolve(localPath, name)
@@ -203,11 +203,11 @@ export class TransferClientBase {
203
203
  'treatPackageAsDirectory',
204
204
  'dontAddToRecent'
205
205
  ]
206
-
207
206
  files = await window.api.openDialog({
208
207
  title,
209
208
  message,
210
- properties
209
+ properties,
210
+ noBrowserTransfer: true
211
211
  }).catch(() => false)
212
212
  }
213
213
 
@@ -253,7 +253,8 @@ export class TransferClientBase {
253
253
  'noResolveAliases',
254
254
  'treatPackageAsDirectory',
255
255
  'dontAddToRecent'
256
- ]
256
+ ],
257
+ noBrowserTransfer: true
257
258
  }).catch(() => false)
258
259
 
259
260
  if (!savePaths || !savePaths.length) {
@@ -154,8 +154,9 @@ export default function ThemeForm (props) {
154
154
  }
155
155
 
156
156
  async function beforeUpload (file) {
157
- const filePath = file.filePath
158
- const txt = await window.fs.readFile(filePath)
157
+ const txt = file.fileContent !== undefined
158
+ ? file.fileContent
159
+ : await window.fs.readFile(file.filePath)
159
160
  const { name, themeConfig, uiThemeConfig } = convertTheme(txt)
160
161
  const tt = convertThemeToText({
161
162
  themeConfig, uiThemeConfig
@@ -25,8 +25,9 @@ export const bookmarkUpload = action(async (file) => {
25
25
  const { store } = window
26
26
  const { bookmarks, bookmarkGroups } = store
27
27
 
28
- const filePath = file.filePath
29
- const txt = await window.fs.readFile(filePath)
28
+ const txt = file.fileContent !== undefined
29
+ ? file.fileContent
30
+ : await window.fs.readFile(file.filePath)
30
31
 
31
32
  const content = JSON.parse(txt)
32
33
  let bookmarkGroups1 = []
@@ -5,7 +5,6 @@
5
5
  import { dbNames, getData, fetchInitData } from '../common/db'
6
6
  import parseInt10 from '../common/parse-int10'
7
7
  import { infoTabs, statusMap, defaultEnvLang } from '../common/constants'
8
- import fs from '../common/fs'
9
8
  import generate from '../common/id-with-stamp'
10
9
  import { refsStatic } from '../components/common/ref'
11
10
  import defaultSettings from '../common/default-setting'
@@ -107,7 +106,7 @@ export async function addTabFromCommandLine (store, opts) {
107
106
  }
108
107
  Object.assign(conf, update)
109
108
  if (options.privateKeyPath) {
110
- conf.privateKey = await fs.readFile(options.privateKeyPath)
109
+ conf.privateKey = await window.fs.readFile(options.privateKeyPath)
111
110
  }
112
111
  console.debug('command line opts', conf)
113
112
  if (
@@ -565,9 +565,9 @@ export default (Store) => {
565
565
  }
566
566
 
567
567
  Store.prototype.importAll = async function (file) {
568
- const filePath = file.filePath
569
- const txt = await window.fs
570
- .readFile(filePath)
568
+ const txt = file.fileContent !== undefined
569
+ ? file.fileContent
570
+ : await window.fs.readFile(file.filePath)
571
571
  const { store } = window
572
572
  const objs = JSON.parse(txt)
573
573
  const { names } = store.getDataSyncNames(true)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/electerm-react",
3
- "version": "3.15.38",
3
+ "version": "3.15.41",
4
4
  "description": "react components src for electerm",
5
5
  "main": "./client/components/main/main.jsx",
6
6
  "license": "MIT",