pinokiod 3.12.2 → 3.12.3
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 +2 -5
- package/kernel/util.js +1 -0
- package/package.json +1 -1
- package/server/public/opener.js +1 -0
- package/server/views/shell.ejs +4 -0
- package/server/views/terminal.ejs +36 -0
package/kernel/shell.js
CHANGED
|
@@ -324,17 +324,17 @@ class Shell {
|
|
|
324
324
|
this.vt.resize(cols, rows)
|
|
325
325
|
}
|
|
326
326
|
emit2(message) {
|
|
327
|
-
console.log("emit2", message)
|
|
328
327
|
let i = 0;
|
|
328
|
+
let total = message.length
|
|
329
329
|
const interval = setInterval(() => {
|
|
330
330
|
if (i >= message.length) {
|
|
331
331
|
clearInterval(interval);
|
|
332
332
|
return;
|
|
333
333
|
}
|
|
334
334
|
let chunk = message.slice(i, i+1024)
|
|
335
|
-
console.log("chunk", i, chunk)
|
|
336
335
|
this.ptyProcess.write(chunk)
|
|
337
336
|
i += 1024;
|
|
337
|
+
this.ondata({ i, total, type: "emit2" })
|
|
338
338
|
}, 10);
|
|
339
339
|
}
|
|
340
340
|
emit(message) {
|
|
@@ -343,7 +343,6 @@ class Shell {
|
|
|
343
343
|
} else {
|
|
344
344
|
if (this.ptyProcess) {
|
|
345
345
|
if (this.input) {
|
|
346
|
-
console.log("emit", { message })
|
|
347
346
|
console.log(Buffer.from(message))
|
|
348
347
|
this.ptyProcess.write(message)
|
|
349
348
|
}
|
|
@@ -933,8 +932,6 @@ class Shell {
|
|
|
933
932
|
this.done = false
|
|
934
933
|
this.ptyProcess = pty.spawn(this.shell, this.args, config)
|
|
935
934
|
this.ptyProcess.onData((data) => {
|
|
936
|
-
console.log("onData", { data })
|
|
937
|
-
console.log([...data].map(c => c.charCodeAt(0)));
|
|
938
935
|
if (!this.done) {
|
|
939
936
|
this.queue.push(data)
|
|
940
937
|
}
|
package/kernel/util.js
CHANGED
package/package.json
CHANGED
package/server/public/opener.js
CHANGED
package/server/views/shell.ejs
CHANGED
|
@@ -296,6 +296,10 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
296
296
|
if (packet.data.type === "shell.kill") {
|
|
297
297
|
this.socket.close()
|
|
298
298
|
}
|
|
299
|
+
if (packet.data.type === "emit2") {
|
|
300
|
+
// long text => still posting to the shell => show progress
|
|
301
|
+
console.log("emit2", { packet.data })
|
|
302
|
+
}
|
|
299
303
|
document.querySelector(".play-btn").classList.add("hidden")
|
|
300
304
|
document.querySelector(".starting-btn").classList.add("hidden")
|
|
301
305
|
document.querySelector(".stop-btn").classList.remove("hidden")
|
|
@@ -105,10 +105,15 @@ header {
|
|
|
105
105
|
}
|
|
106
106
|
*/
|
|
107
107
|
#status-window {
|
|
108
|
+
/*
|
|
108
109
|
flex-grow: 1;
|
|
109
110
|
text-align: right;
|
|
111
|
+
*/
|
|
110
112
|
padding: 0 10px;
|
|
111
113
|
}
|
|
114
|
+
#status-window strong {
|
|
115
|
+
color: yellowgreen;
|
|
116
|
+
}
|
|
112
117
|
#status-window b {
|
|
113
118
|
color: black;
|
|
114
119
|
font-weight: normal;
|
|
@@ -116,6 +121,22 @@ header {
|
|
|
116
121
|
body.dark #status-window b {
|
|
117
122
|
color: white;
|
|
118
123
|
}
|
|
124
|
+
#progress-window {
|
|
125
|
+
flex-shrink: 0;
|
|
126
|
+
width: 100px;
|
|
127
|
+
background: #eee;
|
|
128
|
+
height: 15px;
|
|
129
|
+
/*
|
|
130
|
+
border-radius: 5px;
|
|
131
|
+
*/
|
|
132
|
+
overflow: hidden;
|
|
133
|
+
}
|
|
134
|
+
#progress-bar {
|
|
135
|
+
width: 0%;
|
|
136
|
+
height: 100%;
|
|
137
|
+
background: yellowgreen;
|
|
138
|
+
transition: width 0.2s;
|
|
139
|
+
}
|
|
119
140
|
#del-bin {
|
|
120
141
|
color: royalblue;
|
|
121
142
|
cursor: pointer;
|
|
@@ -297,6 +318,18 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
297
318
|
this.write(JSON.stringify(packet.data.json2, null, 2).replace(/\n/g, "\r\n"))
|
|
298
319
|
this.write("\r\n")
|
|
299
320
|
}
|
|
321
|
+
if (packet.data.type === "emit2") {
|
|
322
|
+
// long text => still posting to the shell => show progress
|
|
323
|
+
console.log("emit2", packet.data)
|
|
324
|
+
document.querySelector("#status-window").innerHTML = `<strong>Pasting... (${Math.floor(100 * packet.data.i/packet.data.total)}%)</strong>`
|
|
325
|
+
let percent = Math.floor(100 * packet.data.i/packet.data.total)
|
|
326
|
+
document.querySelector("#progress-window").classList.remove("hidden")
|
|
327
|
+
document.querySelector("#progress-bar").style.width = "" + percent + "%";
|
|
328
|
+
} else {
|
|
329
|
+
document.querySelector("#status-window").innerHTML = "<b>Ready</b>"
|
|
330
|
+
document.querySelector("#progress-window").classList.add("hidden")
|
|
331
|
+
document.querySelector("#progress-bar").style.width = "0%"
|
|
332
|
+
}
|
|
300
333
|
document.querySelector(".run .play").classList.add("hidden")
|
|
301
334
|
document.querySelector(".run .starting").classList.add("hidden")
|
|
302
335
|
document.querySelector(".run .stop").classList.remove("hidden")
|
|
@@ -934,6 +967,9 @@ const reloadMemory = async () => {
|
|
|
934
967
|
<button class='btn' id='open-fs' data-filepath="<%=filepath%>"><i class="fa-solid fa-eye"></i> View File</button>
|
|
935
968
|
<% } %>
|
|
936
969
|
<div id='status-window'></div>
|
|
970
|
+
<div id='progress-window' class='hidden'><div id='progress-bar'></div></div>
|
|
971
|
+
</div>
|
|
972
|
+
|
|
937
973
|
</div>
|
|
938
974
|
</header>
|
|
939
975
|
<% } %>
|