@electerm/electerm-react 3.15.38 → 3.15.39

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.
@@ -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})`
@@ -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) {
@@ -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
  })
@@ -248,7 +247,7 @@ export class FileTransferManager {
248
247
  const fullPath = osResolve(savePath[0], fileInfo.name)
249
248
 
250
249
  const fd = await new Promise((resolve, reject) => {
251
- fs.open(fullPath, O_WRONLY | O_CREAT | O_TRUNC, (err, fd) => {
250
+ window.fs.open(fullPath, O_WRONLY | O_CREAT | O_TRUNC, (err, fd) => {
252
251
  if (err) reject(err)
253
252
  else resolve(fd)
254
253
  })
@@ -259,14 +258,14 @@ export class FileTransferManager {
259
258
  const data = new Uint8Array(arrayBuffer)
260
259
 
261
260
  await new Promise((resolve, reject) => {
262
- fs.write(fd, data, (err) => {
261
+ window.fs.write(fd, data, (err) => {
263
262
  if (err) reject(err)
264
263
  else resolve()
265
264
  })
266
265
  })
267
266
 
268
267
  await new Promise((resolve, reject) => {
269
- fs.close(fd, (err) => {
268
+ window.fs.close(fd, (err) => {
270
269
  if (err) reject(err)
271
270
  else resolve()
272
271
  })
@@ -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')
@@ -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
@@ -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)
@@ -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 (
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.39",
4
4
  "description": "react components src for electerm",
5
5
  "main": "./client/components/main/main.jsx",
6
6
  "license": "MIT",