pinokiod 3.12.3 → 3.14.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.
@@ -22,6 +22,8 @@ class Node {
22
22
  return {
23
23
  PATH: [this.kernel.path("bin/npm"), this.kernel.path("bin/npm/bin")],
24
24
  NPM_CONFIG_PREFIX: this.kernel.path("bin/npm"),
25
+ npm_cache_config: this.kernel.path("cache/npm_cache_config"),
26
+ NPM_CONFIG_PREFIX: this.kernel.path("bin/npm"),
25
27
  npm_config_prefix: this.kernel.path("bin/npm"),
26
28
  PNPM_HOME: this.kernel.path("bin/npm"),
27
29
  pnpm_home: this.kernel.path("bin/npm"),
package/kernel/plugin.js CHANGED
@@ -4,9 +4,7 @@ class Plugin {
4
4
  this.kernel = kernel
5
5
  }
6
6
  async init() {
7
- console.log("Plugin.init")
8
7
  if (this.kernel.bin.installed && this.kernel.bin.installed.conda && this.kernel.bin.installed.conda.has("git")) {
9
- console.log("INSTALLED")
10
8
  // if ~/pinokio/prototype doesn't exist, clone
11
9
  let exists = await this.kernel.exists("plugin")
12
10
  if (!exists) {
@@ -18,13 +16,9 @@ class Plugin {
18
16
  process.stdout.write(e.raw)
19
17
  })
20
18
  }
21
- console.log("#################")
22
-
23
19
  let plugin_dir = path.resolve(this.kernel.homedir, "plugin")
24
20
  let pinokiojs = path.resolve(plugin_dir, "pinokio.js")
25
- console.log("pinokiojs", pinokiojs)
26
21
  this.config = await this.kernel.require(pinokiojs)
27
- console.log("this.config", this.config)
28
22
  }
29
23
  }
30
24
  async update() {
@@ -27,7 +27,6 @@ class Proto {
27
27
 
28
28
  let pinokiojs_path = this.kernel.path("prototype/system/pinokio.js")
29
29
  let config = await this.kernel.require(pinokiojs_path)
30
- console.log("--config", config)
31
30
  this.config = config
32
31
 
33
32
  if (this.config && this.config.menu) {
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({
@@ -55,7 +55,6 @@ class Shell {
55
55
  }
56
56
  this.queue = fastq((data, cb) => {
57
57
  this.stream(data, cb)
58
- // cb()
59
58
  }, 1)
60
59
 
61
60
  }
@@ -323,27 +322,38 @@ class Shell {
323
322
  this.ptyProcess.resize(cols, rows)
324
323
  this.vt.resize(cols, rows)
325
324
  }
326
- emit2(message) {
327
- let i = 0;
328
- let total = message.length
329
- const interval = setInterval(() => {
330
- if (i >= message.length) {
331
- clearInterval(interval);
332
- return;
333
- }
334
- let chunk = message.slice(i, i+1024)
325
+ async emit2(message) {
326
+ /*
327
+ // buffer size
328
+ 1. default:256
329
+ 2. "interactive": true => 1024
330
+ 3. "buffer": n => n
331
+ */
332
+ let chunk_size = 256 // default buffer: 256
333
+ if (this.params && this.params.buffer) {
334
+ chunk_size = this.params.buffer
335
+ } else if (this.params.interactive) {
336
+ chunk_size = 1024
337
+ }
338
+ console.log({ interactive: this.params.interactive, chunk_size })
339
+ for(let i=0; i<message.length; i+=chunk_size) {
340
+ let chunk = message.slice(i, i+chunk_size)
335
341
  this.ptyProcess.write(chunk)
336
- i += 1024;
337
- this.ondata({ i, total, type: "emit2" })
338
- }, 10);
342
+ this.ondata({ i, total: message.length, type: "emit2" })
343
+ await new Promise(r => setTimeout(r, 10));
344
+ // if (interactive) {
345
+ // await new Promise(queueMicrotask); // zero-delay yield to avoid blocking
346
+ // } else {
347
+ // await new Promise(r => setTimeout(r, 1));
348
+ // }
349
+ }
339
350
  }
340
351
  emit(message) {
341
- if (message.length > 1024) {
342
- this.emit2(message)
343
- } else {
352
+ if (this.input) {
344
353
  if (this.ptyProcess) {
345
- if (this.input) {
346
- console.log(Buffer.from(message))
354
+ if (message.length > 1024) {
355
+ this.emit2(message)
356
+ } else {
347
357
  this.ptyProcess.write(message)
348
358
  }
349
359
  }
@@ -490,9 +500,6 @@ class Shell {
490
500
  })
491
501
  cb()
492
502
  }, 1)
493
- // term.onExit((result) => {
494
- // console.log("onExit", { result })
495
- // })
496
503
  term.onData((data) => {
497
504
  if (ready) {
498
505
  queue.push(data)
@@ -926,7 +933,6 @@ class Shell {
926
933
  }
927
934
 
928
935
  config.env = this.env
929
-
930
936
  if (!this.ptyProcess) {
931
937
  // ptyProcess doesn't exist => create
932
938
  this.done = false
@@ -936,9 +942,6 @@ class Shell {
936
942
  this.queue.push(data)
937
943
  }
938
944
  });
939
- // this.ptyProcess.onExit((result) => {
940
- // console.log(">>>>>>>>>>>>>>>>>>> exec onExit", result)
941
- // })
942
945
  }
943
946
  } catch (e) {
944
947
  console.log("** Error", e)
@@ -1118,7 +1121,9 @@ ${cleaned}
1118
1121
  shell_id: this.id
1119
1122
  }
1120
1123
  this.state = cleaned
1121
- if (this.cb) this.cb(response)
1124
+ if (this.cb) {
1125
+ this.cb(response)
1126
+ }
1122
1127
 
1123
1128
  // Decide whether to kill or continue
1124
1129
  if (this.ready) {
package/kernel/shells.js CHANGED
@@ -281,7 +281,12 @@ class Shells {
281
281
  */
282
282
  let session = this.get(params.id)
283
283
  if (session) {
284
- session.emit(params.emit)
284
+ if (params.paste) {
285
+ //session.emit("\x1b[?2004h\x1b[200~" + params.emit+ "\x1b[201~")
286
+ session.emit(params.emit)
287
+ } else {
288
+ session.emit(params.emit)
289
+ }
285
290
  }
286
291
  }
287
292
  async send(params, ondata, enter) {
package/kernel/util.js CHANGED
@@ -92,9 +92,8 @@ const parse_env = async (filename) => {
92
92
  }
93
93
  }
94
94
  const run = (cmd, cwd, kernel) => {
95
- console.log("Util.run", { cmd, cwd })
96
- child_process.exec(cmd, { cwd })
97
- /*
95
+ // console.log("Util.run", { cmd, cwd })
96
+ // child_process.exec(cmd, { cwd })
98
97
  if (kernel) {
99
98
  kernel.exec({
100
99
  message: cmd,
@@ -107,8 +106,6 @@ const run = (cmd, cwd, kernel) => {
107
106
  } else {
108
107
  child_process.exec(command)
109
108
  }
110
- */
111
-
112
109
  }
113
110
  const openURL = (url) => {
114
111
  const platform = os.platform()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.12.3",
3
+ "version": "3.14.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -146,7 +146,6 @@ class Server {
146
146
  } else {
147
147
  newIndexPath = "" + i
148
148
  }
149
- console.log({ item, i, indexPath, newIndexPath })
150
149
  traverse(item, newIndexPath);
151
150
  }
152
151
  } else if (obj !== null && typeof obj === 'object') {
@@ -175,9 +174,7 @@ class Server {
175
174
  }
176
175
  }
177
176
  } else if (key === "shell") {
178
- console.log("shell", key, obj[key], indexPath)
179
177
  let shell_id = this.get_shell_id(name, indexPath, obj[key])
180
- console.log("shell_id", shell_id, this.kernel.api.running[shell_id], this.kernel.api.running)
181
178
  if (this.kernel.api.running[shell_id]) {
182
179
  obj.display = "indent"
183
180
  running_dynamic.push(obj)
@@ -2454,7 +2451,7 @@ class Server {
2454
2451
 
2455
2452
  let gitconfig = path.resolve(home, "gitconfig")
2456
2453
  await fse.remove(gitconfig)
2457
-
2454
+
2458
2455
 
2459
2456
  console.log("[TRY] Updating to the new version")
2460
2457
  this.kernel.store.set("version", this.version.pinokiod)
@@ -3702,13 +3699,9 @@ class Server {
3702
3699
  res.redirect(href)
3703
3700
  } else {
3704
3701
  let run_path = "/run/prototype/system/" + config.href + "?cwd=" + req.query.path
3705
- console.log({ config, run_path, query: req.query })
3706
3702
  let readme_path = this.kernel.path("prototype/system", config.readme)
3707
- console.log("config.readme.split", config.readme.split("/").slice(0, -1))
3708
3703
  let md = await fs.promises.readFile(readme_path, "utf8")
3709
- console.log({ readme_path, md })
3710
3704
  let baseUrl = "/asset/prototype/system/" + (config.readme.split("/").slice(0, -1).join("/")) + "/"
3711
- console.log("baseUrl", baseUrl)
3712
3705
  let readme = marked.parse(md, {
3713
3706
  baseUrl
3714
3707
  })
@@ -3747,7 +3740,6 @@ class Server {
3747
3740
  href: "/prototype/show",
3748
3741
  path: "/asset/prototype/system"
3749
3742
  })
3750
- console.log("FINAL CONFIG", JSON.stringify(config, null, 2))
3751
3743
 
3752
3744
  // {
3753
3745
  // "icon": "fa-solid fa-power-off",
@@ -15,7 +15,6 @@ document.addEventListener("DOMContentLoaded", () => {
15
15
  if (document.querySelector("#new-window")) {
16
16
  document.querySelector("#new-window").addEventListener("click", (e) => {
17
17
  let agent = document.body.getAttribute("data-agent")
18
- debugger
19
18
  if (agent === "electron") {
20
19
  window.open("/", "_blank", "self")
21
20
  } else {
@@ -29,7 +29,6 @@ const open_url = (href, target, features) => {
29
29
  }
30
30
  }
31
31
  document.addEventListener("click", async (e) => {
32
- debugger
33
32
  // [data-filepath] should open in file explorer
34
33
  let el = e.target.closest("[data-filepath]")
35
34
  if (!el) {
package/server/socket.js CHANGED
@@ -25,7 +25,6 @@ class Socket {
25
25
  });
26
26
  ws.on('message', async (message, isBinary) => {
27
27
  let req
28
- console.log({ message, isBinary })
29
28
  if (isBinary) {
30
29
  const buffer = Buffer.from(message);
31
30
  const sepIndex = buffer.indexOf(0);
@@ -152,7 +151,8 @@ class Socket {
152
151
  } else if (req.key && req.id) {
153
152
  this.parent.kernel.shell.emit({
154
153
  id: req.id,
155
- emit: req.key
154
+ emit: req.key,
155
+ paste: req.paste
156
156
  })
157
157
  } else if (req.resize && req.id) {
158
158
  this.parent.kernel.shell.resize({
@@ -134,6 +134,39 @@ body.frozen {
134
134
  .terminal-container {
135
135
  padding: 0;
136
136
  }
137
+ #status-window {
138
+ /*
139
+ flex-grow: 1;
140
+ text-align: right;
141
+ */
142
+ padding: 0 10px;
143
+ }
144
+ #status-window strong {
145
+ color: royalblue;
146
+ }
147
+ #status-window b {
148
+ color: black;
149
+ font-weight: normal;
150
+ }
151
+ body.dark #status-window b {
152
+ color: white;
153
+ }
154
+ #progress-window {
155
+ flex-shrink: 0;
156
+ width: 100px;
157
+ background: #eee;
158
+ height: 15px;
159
+ /*
160
+ border-radius: 5px;
161
+ */
162
+ overflow: hidden;
163
+ }
164
+ #progress-bar {
165
+ width: 0%;
166
+ height: 100%;
167
+ background: royalblue;
168
+ transition: width 0.2s;
169
+ }
137
170
  </style>
138
171
  <link href="/terminal.css" rel="stylesheet"/>
139
172
  <script>
@@ -298,7 +331,15 @@ document.addEventListener("DOMContentLoaded", async () => {
298
331
  }
299
332
  if (packet.data.type === "emit2") {
300
333
  // long text => still posting to the shell => show progress
301
- console.log("emit2", { packet.data })
334
+ console.log("emit2", packet.data)
335
+ document.querySelector("#status-window").innerHTML = `<strong>Pasting... (${Math.floor(100 * packet.data.i/packet.data.total)}%)</strong>`
336
+ let percent = Math.floor(100 * packet.data.i/packet.data.total)
337
+ document.querySelector("#progress-window").classList.remove("hidden")
338
+ document.querySelector("#progress-bar").style.width = "" + percent + "%";
339
+ } else {
340
+ document.querySelector("#status-window").innerHTML = "<b>Ready</b>"
341
+ document.querySelector("#progress-window").classList.add("hidden")
342
+ document.querySelector("#progress-bar").style.width = "0%"
302
343
  }
303
344
  document.querySelector(".play-btn").classList.add("hidden")
304
345
  document.querySelector(".starting-btn").classList.add("hidden")
@@ -667,11 +708,18 @@ document.addEventListener("DOMContentLoaded", async () => {
667
708
  if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
668
709
  navigator.clipboard.readText().then((text) => {
669
710
  console.log({ text })
711
+ //this.socket.run({
712
+ // //key: "\x1b[200~" + text + "\x1b[201~",
713
+ // key: text,
714
+ // id: shell_id
715
+ //})
670
716
  this.socket.run({
671
717
  //key: "\x1b[200~" + text + "\x1b[201~",
672
718
  key: text,
673
- id: shell_id
719
+ id: shell_id,
720
+ paste: true
674
721
  })
722
+
675
723
  })
676
724
  return false
677
725
  }
@@ -813,6 +861,8 @@ document.addEventListener("DOMContentLoaded", async () => {
813
861
  <div class='hidden btn stopped-btn'>
814
862
  <span class='stopped'><i class="fa-solid fa-hand"></i> Stopped</span>
815
863
  </div>
864
+ <div id='status-window'></div>
865
+ <div id='progress-window' class='hidden'><div id='progress-bar'></div></div>
816
866
  </h1>
817
867
  </header>
818
868
  <div class='terminal-container'>
@@ -112,7 +112,7 @@ header {
112
112
  padding: 0 10px;
113
113
  }
114
114
  #status-window strong {
115
- color: yellowgreen;
115
+ color: royalblue;
116
116
  }
117
117
  #status-window b {
118
118
  color: black;
@@ -134,7 +134,7 @@ body.dark #status-window b {
134
134
  #progress-bar {
135
135
  width: 0%;
136
136
  height: 100%;
137
- background: yellowgreen;
137
+ background: royalblue;
138
138
  transition: width 0.2s;
139
139
  }
140
140
  #del-bin {
@@ -722,12 +722,20 @@ document.addEventListener("DOMContentLoaded", async () => {
722
722
  if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
723
723
  navigator.clipboard.readText().then((text) => {
724
724
  console.log({ text })
725
- debugger
725
+
726
726
  this.socket.run({
727
727
  //key: "\x1b[200~" + text + "\x1b[201~",
728
728
  key: text,
729
- id: shell_id
729
+ id: shell_id,
730
+ paste: true
730
731
  })
732
+
733
+
734
+ // this.socket.run({
735
+ // //key: "\x1b[200~" + text + "\x1b[201~",
736
+ // key: text,
737
+ // id: shell_id
738
+ // })
731
739
  })
732
740
  return false
733
741
  }
@@ -741,7 +749,7 @@ document.addEventListener("DOMContentLoaded", async () => {
741
749
  //term.resize(cols, rows);
742
750
 
743
751
  term.onKey(({ key }) => {
744
- console.log({ key })
752
+ console.log({ key, shell_id })
745
753
  if (this.socket) {
746
754
  if (shell_id) {
747
755
  this.socket.run({