@dotrino/terminal-agent 0.11.1 → 0.12.0
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/consoles.js +11 -4
- package/package.json +1 -1
package/consoles.js
CHANGED
|
@@ -27,8 +27,9 @@ export const REPLAY_CHUNK = 64 * 1024
|
|
|
27
27
|
const randomId = () => [...crypto.getRandomValues(new Uint8Array(8))].map((x) => x.toString(16).padStart(2, '0')).join('')
|
|
28
28
|
|
|
29
29
|
class Console {
|
|
30
|
-
constructor ({ id, pty, cols, rows, origin }) {
|
|
30
|
+
constructor ({ id, n, pty, cols, rows, origin }) {
|
|
31
31
|
this.id = id
|
|
32
|
+
this.n = n // su número, fijo mientras viva (ver ConsoleHub.create)
|
|
32
33
|
this.pty = pty
|
|
33
34
|
this.origin = origin // 'local' (una ventana de esta máquina) | 'remote' (otro aparato)
|
|
34
35
|
this.title = '' // el que pone la shell (OSC 0/2), para reconocerla en la lista
|
|
@@ -98,7 +99,7 @@ class Console {
|
|
|
98
99
|
*/
|
|
99
100
|
info () {
|
|
100
101
|
const watchers = [...this.viewers].filter((v) => v.origin).map((v) => ({ origin: v.origin, device: v.device || null, tag: v.tag || null }))
|
|
101
|
-
return { id: this.id, origin: this.origin, title: this.title, cols: this.cols, rows: this.rows, createdAt: this.createdAt, lastActive: this.lastActive, viewers: this.viewers.size, watchers }
|
|
102
|
+
return { id: this.id, n: this.n, origin: this.origin, title: this.title, cols: this.cols, rows: this.rows, createdAt: this.createdAt, lastActive: this.lastActive, viewers: this.viewers.size, watchers }
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
|
|
@@ -115,8 +116,14 @@ export class ConsoleHub {
|
|
|
115
116
|
|
|
116
117
|
create ({ cols = 80, rows = 24, origin = 'remote', cwd = null } = {}) {
|
|
117
118
|
const id = randomId()
|
|
119
|
+
// Su NÚMERO: el libre más bajo, y no cambia mientras viva. Si se cierra la 1, la 2 sigue
|
|
120
|
+
// siendo la 2 y la próxima nueva será la 1. Lo da el agente para que sea el mismo en todas
|
|
121
|
+
// las ventanas y aparatos.
|
|
122
|
+
const used = new Set([...this.consoles.values()].map((c) => c.n))
|
|
123
|
+
let n = 1
|
|
124
|
+
while (used.has(n)) n++
|
|
118
125
|
const pty = this._spawn({ cols, rows, cwd })
|
|
119
|
-
const c = new Console({ id, pty, cols, rows, origin })
|
|
126
|
+
const c = new Console({ id, n, pty, cols, rows, origin })
|
|
120
127
|
pty.onData((d) => c._out(d))
|
|
121
128
|
pty.onExit(({ exitCode }) => {
|
|
122
129
|
c.exited = true
|
|
@@ -131,7 +138,7 @@ export class ConsoleHub {
|
|
|
131
138
|
|
|
132
139
|
get (id) { return this.consoles.get(id) || null }
|
|
133
140
|
|
|
134
|
-
list () { return [...this.consoles.values()].map((c) => c.info()) }
|
|
141
|
+
list () { return [...this.consoles.values()].map((c) => c.info()).sort((a, b) => a.n - b.n) }
|
|
135
142
|
|
|
136
143
|
kill (id) {
|
|
137
144
|
const c = this.consoles.get(id)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/terminal-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Dotrino Terminal: las ventanas de esta máquina (dotrino-terminal) y su agente, que deja abrir esas mismas consolas desde los otros aparatos de tu cuenta, cifrado punto a punto.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|