pinokiod 3.12.1 → 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 CHANGED
@@ -37,7 +37,7 @@ class Shell {
37
37
 
38
38
  // Windows: /D => ignore AutoRun Registry Key
39
39
  // Others: --noprofile => ignore .bash_profile, --norc => ignore .bashrc
40
- this.args = this.platform === 'win32' ? ["/D"] : ["--noprofile", "--norc"]
40
+ this.args = this.platform === 'win32' ? ["/D"] : ["--noprofile", "--norc",]
41
41
 
42
42
  //this.vt = new Terminal({ allowProposedApi: true, scrollback: 5, })
43
43
  // this.vt = new Terminal({
@@ -325,6 +325,7 @@ class Shell {
325
325
  }
326
326
  emit2(message) {
327
327
  let i = 0;
328
+ let total = message.length
328
329
  const interval = setInterval(() => {
329
330
  if (i >= message.length) {
330
331
  clearInterval(interval);
@@ -333,6 +334,7 @@ class Shell {
333
334
  let chunk = message.slice(i, i+1024)
334
335
  this.ptyProcess.write(chunk)
335
336
  i += 1024;
337
+ this.ondata({ i, total, type: "emit2" })
336
338
  }, 10);
337
339
  }
338
340
  emit(message) {
@@ -341,6 +343,7 @@ class Shell {
341
343
  } else {
342
344
  if (this.ptyProcess) {
343
345
  if (this.input) {
346
+ console.log(Buffer.from(message))
344
347
  this.ptyProcess.write(message)
345
348
  }
346
349
  }
@@ -1160,6 +1163,9 @@ ${cleaned}
1160
1163
  this.ready = true
1161
1164
  if (this.ptyProcess) {
1162
1165
  this.ptyProcess.write(`${this.cmd}${os.EOL}`)
1166
+ // setTimeout(() => {
1167
+ // this.ptyProcess.write('\x1B[?2004h');
1168
+ // }, 500)
1163
1169
  }
1164
1170
  }
1165
1171
  }
package/kernel/util.js CHANGED
@@ -92,6 +92,7 @@ const parse_env = async (filename) => {
92
92
  }
93
93
  }
94
94
  const run = (cmd, cwd, kernel) => {
95
+ console.log("Util.run", { cmd, cwd })
95
96
  child_process.exec(cmd, { cwd })
96
97
  /*
97
98
  if (kernel) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.12.1",
3
+ "version": "3.12.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -29,6 +29,7 @@ const open_url = (href, target, features) => {
29
29
  }
30
30
  }
31
31
  document.addEventListener("click", async (e) => {
32
+ debugger
32
33
  // [data-filepath] should open in file explorer
33
34
  let el = e.target.closest("[data-filepath]")
34
35
  if (!el) {
package/server/socket.js CHANGED
@@ -25,6 +25,7 @@ class Socket {
25
25
  });
26
26
  ws.on('message', async (message, isBinary) => {
27
27
  let req
28
+ console.log({ message, isBinary })
28
29
  if (isBinary) {
29
30
  const buffer = Buffer.from(message);
30
31
  const sepIndex = buffer.indexOf(0);
@@ -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")
@@ -662,8 +666,10 @@ document.addEventListener("DOMContentLoaded", async () => {
662
666
  }
663
667
  if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
664
668
  navigator.clipboard.readText().then((text) => {
669
+ console.log({ text })
665
670
  this.socket.run({
666
- key: "\x1b[200~" + text + "\x1b[201~",
671
+ //key: "\x1b[200~" + text + "\x1b[201~",
672
+ key: text,
667
673
  id: shell_id
668
674
  })
669
675
  })
@@ -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")
@@ -688,8 +721,11 @@ document.addEventListener("DOMContentLoaded", async () => {
688
721
  }
689
722
  if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
690
723
  navigator.clipboard.readText().then((text) => {
724
+ console.log({ text })
725
+ debugger
691
726
  this.socket.run({
692
- key: "\x1b[200~" + text + "\x1b[201~",
727
+ //key: "\x1b[200~" + text + "\x1b[201~",
728
+ key: text,
693
729
  id: shell_id
694
730
  })
695
731
  })
@@ -705,6 +741,7 @@ document.addEventListener("DOMContentLoaded", async () => {
705
741
  //term.resize(cols, rows);
706
742
 
707
743
  term.onKey(({ key }) => {
744
+ console.log({ key })
708
745
  if (this.socket) {
709
746
  if (shell_id) {
710
747
  this.socket.run({
@@ -930,6 +967,9 @@ const reloadMemory = async () => {
930
967
  <button class='btn' id='open-fs' data-filepath="<%=filepath%>"><i class="fa-solid fa-eye"></i> View File</button>
931
968
  <% } %>
932
969
  <div id='status-window'></div>
970
+ <div id='progress-window' class='hidden'><div id='progress-bar'></div></div>
971
+ </div>
972
+
933
973
  </div>
934
974
  </header>
935
975
  <% } %>