@lvce-editor/pty-host 0.22.3 → 0.22.4
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/package.json
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import * as Pty from '../Pty/Pty.js'
|
|
2
|
-
import * as Debug from '../Debug/Debug.js'
|
|
3
1
|
import * as Assert from '../Assert/Assert.js'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
2
|
+
import * as Debug from '../Debug/Debug.js'
|
|
3
|
+
import * as Pty from '../Pty/Pty.js'
|
|
4
|
+
import * as PtyState from '../PtyState/PtyState.js'
|
|
8
5
|
|
|
9
6
|
// TODO maybe merge pty and pty controller
|
|
10
7
|
export const create = (ipc, id, cwd, command, args) => {
|
|
@@ -23,11 +20,11 @@ export const create = (ipc, id, cwd, command, args) => {
|
|
|
23
20
|
})
|
|
24
21
|
}
|
|
25
22
|
Pty.onData(pty, handleData)
|
|
26
|
-
|
|
23
|
+
PtyState.set(id, pty)
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
export const write = (id, data) => {
|
|
30
|
-
const pty =
|
|
27
|
+
const pty = PtyState.get(id)
|
|
31
28
|
if (!pty) {
|
|
32
29
|
throw new Error(`pty ${id} not found`)
|
|
33
30
|
}
|
|
@@ -35,7 +32,7 @@ export const write = (id, data) => {
|
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
export const resize = (id, columns, rows) => {
|
|
38
|
-
const pty =
|
|
35
|
+
const pty = PtyState.get(id)
|
|
39
36
|
if (!pty) {
|
|
40
37
|
throw new Error(`pty ${id} not found`)
|
|
41
38
|
}
|
|
@@ -43,17 +40,16 @@ export const resize = (id, columns, rows) => {
|
|
|
43
40
|
}
|
|
44
41
|
|
|
45
42
|
export const dispose = (id) => {
|
|
46
|
-
const
|
|
47
|
-
const pty = ptyMap[id]
|
|
43
|
+
const pty = PtyState.get(id)
|
|
48
44
|
if (!pty) {
|
|
49
45
|
throw new Error(`pty ${id} not found`)
|
|
50
46
|
}
|
|
51
47
|
Pty.dispose(pty)
|
|
52
|
-
|
|
48
|
+
PtyState.remove(id)
|
|
53
49
|
}
|
|
54
50
|
|
|
55
51
|
export const disposeAll = () => {
|
|
56
|
-
for (const id in
|
|
52
|
+
for (const id in PtyState.getAll()) {
|
|
57
53
|
dispose(id)
|
|
58
54
|
}
|
|
59
55
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const state = {
|
|
2
|
+
ptyMap: Object.create(null),
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export const set = (id, pty) => {
|
|
6
|
+
state.ptyMap[id] = pty
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const get = (id) => {
|
|
10
|
+
return state.ptyMap[id]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const remove = (id) => {
|
|
14
|
+
delete state.ptyMap[id]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const getAll = () => {
|
|
18
|
+
return state.ptyMap
|
|
19
|
+
}
|