pinokiod 3.19.33 → 3.19.35
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/kernel/shell.js +29 -28
- package/package.json +1 -1
package/kernel/shell.js
CHANGED
|
@@ -494,7 +494,6 @@ class Shell {
|
|
|
494
494
|
console.log("Prompt spawn", this.shell)
|
|
495
495
|
console.log("Prompt config", config)
|
|
496
496
|
let term = pty.spawn(this.shell, this.args, config)
|
|
497
|
-
let ready
|
|
498
497
|
let vt = new Terminal({
|
|
499
498
|
allowProposedApi: true
|
|
500
499
|
})
|
|
@@ -502,38 +501,40 @@ class Shell {
|
|
|
502
501
|
vt.loadAddon(vts)
|
|
503
502
|
|
|
504
503
|
let queue = fastq((data, cb) => {
|
|
505
|
-
console.log("Vt.write", data)
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
504
|
+
console.log("Vt.write", { data, prompt_ready: this.prompt_ready })
|
|
505
|
+
if (this.prompt_ready) {
|
|
506
|
+
vt.write(data, () => {
|
|
507
|
+
let buf = vts.serialize()
|
|
508
|
+
console.log({ buf })
|
|
509
|
+
let re = /(.+)echo pinokio[\r\n]+pinokio[\r\n]+(\1)/gs
|
|
510
|
+
const match = re.exec(buf)
|
|
511
|
+
console.log({ match })
|
|
512
|
+
if (match && match.length > 0) {
|
|
513
|
+
this.prompt_ready = false
|
|
514
|
+
let stripped = this.stripAnsi(match[1])
|
|
515
|
+
console.log({ stripped, prompt_ready: this.prompt_ready })
|
|
516
|
+
const p = stripped
|
|
517
|
+
.replaceAll(/[\r\n]/g, "")
|
|
518
|
+
.trim()
|
|
519
|
+
.replaceAll(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
520
|
+
term.kill()
|
|
521
|
+
vt.dispose()
|
|
522
|
+
queue.killAndDrain()
|
|
523
|
+
resolve(p)
|
|
524
|
+
}
|
|
525
|
+
})
|
|
526
|
+
cb()
|
|
527
|
+
}
|
|
527
528
|
}, 1)
|
|
528
529
|
term.onData((data) => {
|
|
529
|
-
console.log("Prompt onData", { data,
|
|
530
|
-
if (
|
|
530
|
+
console.log("Prompt onData", { data, prompt_ready: this.prompt_ready })
|
|
531
|
+
if (this.prompt_ready) {
|
|
531
532
|
queue.push(data)
|
|
532
533
|
} else {
|
|
533
534
|
setTimeout(() => {
|
|
534
|
-
if (!
|
|
535
|
-
|
|
536
|
-
console.log("P", { eol: this.EOL, shell: this.shell, args: this.args,
|
|
535
|
+
if (!this.prompt_ready) {
|
|
536
|
+
this.prompt_ready = true
|
|
537
|
+
console.log("P", { eol: this.EOL, shell: this.shell, args: this.args, prompt_ready: this.prompt_ready })
|
|
537
538
|
term.write(`echo pinokio${this.EOL}echo pinokio${this.EOL}`)
|
|
538
539
|
}
|
|
539
540
|
}, 500)
|