pinokiod 3.19.58 → 3.19.59

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.
@@ -0,0 +1,43 @@
1
+ const Util = require("../../util")
2
+ /*
3
+ {
4
+ "run": [
5
+ {
6
+ "method": "clipboard.copy",
7
+ "params": {
8
+ "text": "hello world"
9
+ }
10
+ },
11
+ {
12
+ "method": "clipboard.paste"
13
+ },
14
+ {
15
+ "method": "log",
16
+ "params": {
17
+ "raw": "{{input}}"
18
+ }
19
+ }
20
+ ]
21
+ }
22
+ */
23
+ class Clipboard {
24
+ /*
25
+ method: "clipboard.copy",
26
+ params: {
27
+ text: <text>
28
+ }
29
+ */
30
+ async copy(req, ondata, kernel) {
31
+ await Util.clipboard({
32
+ type: "copy",
33
+ text: req.params.text
34
+ })
35
+ }
36
+ async paste(req, ondata, kernel) {
37
+ let text = await Util.clipboard({
38
+ type: "paste",
39
+ })
40
+ return text
41
+ }
42
+ }
43
+ module.exports = Clipboard
package/kernel/bin/cli.js CHANGED
@@ -26,7 +26,7 @@ class CLI {
26
26
  let res = await this.kernel.exec({
27
27
  message: "pinokio version terminal"
28
28
  }, ondata)
29
- if (res.stdout && /.*pterm@0\.0\.6.*/.test(res.stdout)) {
29
+ if (res.stdout && /.*pterm@0\.0\.7.*/.test(res.stdout)) {
30
30
  console.log("Installed")
31
31
  return true
32
32
  } else {
@@ -336,33 +336,31 @@ const ENV = async (type, homedir) => {
336
336
  if (type === 'app') {
337
337
  system_env = await get_raw(homedir)
338
338
  if (e.key in system_env) {
339
- console.log(`original ${e.key}=${val}`)
339
+ // console.log(`original ${e.key}=${val}`)
340
340
  val = system_env[e.key]
341
- console.log(`inherited from system_env: ${e.key}=${val}`)
341
+ // console.log(`inherited from system_env: ${e.key}=${val}`)
342
342
  keys.add(e.key)
343
343
  }
344
344
  }
345
345
 
346
346
  let kv = `${e.key}=${val}`
347
- console.log("kv", kv)
348
347
  lines.push(comment+kv)
349
348
  }
350
349
 
351
350
  // In case of type: app, inherit any other custom ENVIRONMENT variable not yet included
352
- console.log({ irrelevant_keys })
353
351
  if (type === "app" && system_env) {
354
352
  for(let key in system_env) {
355
353
  if (!keys.has(key)) {
356
354
  // the key has not been processed, need to add to the lines
357
355
  if (irrelevant_keys.includes(key)) {
358
356
  // if the key was explicitly stated to be not included, skip
359
- console.log("irrelevant key", key)
357
+ // console.log("irrelevant key", key)
360
358
  } else {
361
- console.log("relevant key", key)
359
+ // console.log("relevant key", key)
362
360
  let val = system_env[key]
363
361
  let kv = `${key}=${val}`
364
362
  lines.push(kv)
365
- console.log(`inherited custom environment key from system_env: ${kv}`)
363
+ // console.log(`inherited custom environment key from system_env: ${kv}`)
366
364
  }
367
365
  }
368
366
  }
package/kernel/shell.js CHANGED
@@ -253,9 +253,6 @@ class Shell {
253
253
 
254
254
  this.ondata({ raw: `\r\n████\r\n██ Starting Shell ${this.id}\r\n` })
255
255
 
256
- console.log("SHELL PARAMS", params)
257
-
258
-
259
256
  this.start_time = Date.now()
260
257
  this.params = params
261
258
  this.EOL = os.EOL
@@ -289,7 +286,6 @@ class Shell {
289
286
  //}
290
287
  }
291
288
  }
292
- console.log({ shell: this.shell, args: this.args, eol: this.EOL })
293
289
 
294
290
  // 3. path => path can be http, relative, absolute
295
291
  this.path = params.path
package/kernel/util.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const fs = require('fs')
2
2
  const { spawn } = require('child_process')
3
+ const Clipboard = require('copy-paste/promises');
3
4
  const http = require('http');
4
5
  const notifier = require('node-notifier');
5
6
  const os = require('os')
@@ -38,6 +39,21 @@ const du = async (folderpath) => {
38
39
  return totalSize;
39
40
  }
40
41
 
42
+ const clipboard = async (req, ondata, kernel) => {
43
+ /*
44
+ req := {
45
+ type: "copy"|"paste",
46
+ text: <text (only when copy)>
47
+ }
48
+ */
49
+ if (req.type === "copy") {
50
+ await Clipboard.copy(req.text)
51
+ } else if (req.type === "paste") {
52
+ let content = await Clipboard.paste()
53
+ return content
54
+ }
55
+ }
56
+
41
57
  const filepicker = async(req, ondata, kernel) => {
42
58
  if (req.params.filetype) {
43
59
  /*
@@ -631,5 +647,5 @@ function diffLinesWithContext(diffs, context = 3) {
631
647
  return summarized;
632
648
  }
633
649
  module.exports = {
634
- parse_env, log_path, api_path, update_env, parse_env_detail, openfs, port_running, du, is_port_available, find_python, find_venv, fill_object, run, openURL, u2p, p2u, log, diffLinesWithContext, classifyChange, push, filepicker, exists
650
+ parse_env, log_path, api_path, update_env, parse_env_detail, openfs, port_running, du, is_port_available, find_python, find_venv, fill_object, run, openURL, u2p, p2u, log, diffLinesWithContext, classifyChange, push, filepicker, exists, clipboard
635
651
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.19.58",
3
+ "version": "3.19.59",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,6 +17,7 @@
17
17
  "clear-module": "^4.1.2",
18
18
  "compressing": "^1.10.0",
19
19
  "cookie-parser": "^1.4.6",
20
+ "copy-paste": "^2.2.0",
20
21
  "cors": "^2.8.5",
21
22
  "cross-fetch": "^3.1.5",
22
23
  "csv-parse": "^5.3.10",
package/server/index.js CHANGED
@@ -1501,7 +1501,6 @@ class Server {
1501
1501
 
1502
1502
  if (meta) {
1503
1503
  items = running.concat(notRunning)
1504
- console.log("INDEX2")
1505
1504
  res.render("index", {
1506
1505
  current_urls,
1507
1506
  portal: this.portal,
@@ -3159,6 +3158,18 @@ class Server {
3159
3158
  res.json({ error: e.message })
3160
3159
  }
3161
3160
  }))
3161
+ this.app.post("/clipboard", ex(async (req, res) => {
3162
+ try {
3163
+ let r = await Util.clipboard(req.body)
3164
+ if (r) {
3165
+ res.json({ text: r })
3166
+ } else {
3167
+ res.json({ success: true })
3168
+ }
3169
+ } catch (e) {
3170
+ res.json({ error: e.stack })
3171
+ }
3172
+ }))
3162
3173
  this.app.post("/push", ex(async (req, res) => {
3163
3174
  try {
3164
3175
  Util.push(req.body)
package/server/socket.js CHANGED
@@ -228,14 +228,19 @@ class Socket {
228
228
  await Util.log(logpath, buf, session)
229
229
  }
230
230
  } else {
231
- // SHELL
231
+ // Only log SHELL
232
232
  /*
233
233
  SHELL Changed { cwd: '/Users/x/pinokio/api/kernel.api.stop', key: 'kernel.api.stop' }
234
234
  */
235
- let cwd = this.parent.kernel.path("api", key.split("_")[0])
236
- let session = this.sessions[key]
237
- let logpath = path.resolve(cwd, "logs/shell")
238
- await Util.log(logpath, buf, session)
235
+ if (key.startsWith("kernel.")) {
236
+ // do not log since these are not shell operations
237
+ // need to refactor later to make this logic cleaner
238
+ } else {
239
+ let cwd = this.parent.kernel.path("api", key.split("_")[0])
240
+ let session = this.sessions[key]
241
+ let logpath = path.resolve(cwd, "logs/shell")
242
+ await Util.log(logpath, buf, session)
243
+ }
239
244
 
240
245
 
241
246
  }