pinokiod 3.10.0 → 3.10.2

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/info.js CHANGED
@@ -6,6 +6,7 @@ info.path(...args)
6
6
  */
7
7
  const path = require('path')
8
8
  const fs = require("fs")
9
+ const Util = require('./util')
9
10
  class Info {
10
11
  constructor(kernel) {
11
12
  this.kernel = kernel
@@ -26,6 +27,11 @@ class Info {
26
27
  Error.prepareStackTrace = _prepareStackTrace;
27
28
  }
28
29
  }
30
+ async venv(_cwd) {
31
+ let cwd = _cwd || this.cwd()
32
+ let venv = await Util.find_venv(cwd)
33
+ return venv
34
+ }
29
35
  cwd() {
30
36
  return path.dirname(this.caller())
31
37
  }
package/kernel/plugin.js CHANGED
@@ -4,7 +4,9 @@ class Plugin {
4
4
  this.kernel = kernel
5
5
  }
6
6
  async init() {
7
+ console.log("Plugin.init")
7
8
  if (this.kernel.bin.installed && this.kernel.bin.installed.conda && this.kernel.bin.installed.conda.has("git")) {
9
+ console.log("INSTALLED")
8
10
  // if ~/pinokio/prototype doesn't exist, clone
9
11
  let exists = await this.kernel.exists("plugin")
10
12
  if (!exists) {
@@ -15,10 +17,13 @@ class Plugin {
15
17
  process.stdout.write(e.raw)
16
18
  })
17
19
  }
20
+ console.log("#################")
18
21
 
19
22
  let plugin_dir = path.resolve(this.kernel.homedir, "plugin")
20
23
  let pinokiojs = path.resolve(plugin_dir, "pinokio.js")
24
+ console.log("pinokiojs", pinokiojs)
21
25
  this.config = await this.kernel.require(pinokiojs)
26
+ console.log("this.config", this.config)
22
27
  }
23
28
  }
24
29
  async update() {
@@ -12,7 +12,7 @@ class Proto {
12
12
  if (this.kernel.bin.installed && this.kernel.bin.installed.conda && this.kernel.bin.installed.conda.has("git")) {
13
13
 
14
14
  // if ~/pinokio/prototype doesn't exist, clone
15
- let exists = await this.kernel.exists("prototype")
15
+ let exists = await this.kernel.exists("prototype/system")
16
16
  if (!exists) {
17
17
  console.log("prototype doesn't exist. cloning...")
18
18
  await fs.promises.mkdir(this.kernel.path("prototype"), { recursive: true }).catch((e) => { })
@@ -27,16 +27,21 @@ 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)
30
31
  this.config = config
31
32
 
32
- this.config.menu.push({
33
- icon: "fa-solid fa-rotate",
34
- text: "Update",
35
- shell: {
36
- message: "git pull",
37
- path: this.kernel.path("prototype/system")
38
- }
39
- })
33
+ if (this.config.menu) {
34
+ this.config.menu.push({
35
+ icon: "fa-solid fa-rotate",
36
+ text: "Update",
37
+ shell: {
38
+ message: "git pull",
39
+ path: this.kernel.path("prototype/system")
40
+ }
41
+ })
42
+ }
43
+
44
+
40
45
 
41
46
 
42
47
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.10.0",
3
+ "version": "3.10.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -146,6 +146,7 @@ class Server {
146
146
  } else {
147
147
  newIndexPath = "" + i
148
148
  }
149
+ console.log({ item, i, indexPath, newIndexPath })
149
150
  traverse(item, newIndexPath);
150
151
  }
151
152
  } else if (obj !== null && typeof obj === 'object') {
@@ -174,7 +175,9 @@ class Server {
174
175
  }
175
176
  }
176
177
  } else if (key === "shell") {
178
+ console.log("shell", key, obj[key], indexPath)
177
179
  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)
178
181
  if (this.kernel.api.running[shell_id]) {
179
182
  obj.display = "indent"
180
183
  running_dynamic.push(obj)
@@ -475,6 +478,7 @@ class Server {
475
478
  feed = this.newsfeed(gitRemote)
476
479
  }
477
480
 
481
+ await this.kernel.plugin.init()
478
482
  let plugin = await this.getPlugin(name)
479
483
  let plugin_menu = null
480
484
  if (plugin && plugin.menu && Array.isArray(plugin.menu)) {
@@ -1722,7 +1726,9 @@ class Server {
1722
1726
  } else {
1723
1727
  currentIndexPath = "" + i
1724
1728
  }
1729
+ console.log(">>", { indexPath, currentIndexPath, i })
1725
1730
  let shell_id = this.get_shell_id(name, currentIndexPath, rendered)
1731
+ console.log(">>", { name, shell_id, })
1726
1732
 
1727
1733
 
1728
1734
  // let hash = crypto.createHash('md5').update(JSON.stringify(rendered)).digest('hex')
@@ -3049,6 +3055,7 @@ class Server {
3049
3055
  // params.set("kill", "/Logged in/i")
3050
3056
  params.set("kill_message", "Click to return home")
3051
3057
  params.set("callback", encodeURIComponent("/github"))
3058
+ params.set("target", "_top")
3052
3059
  params.set("id", id)
3053
3060
  let url = `/shell/${id}?${params.toString()}`
3054
3061
  res.redirect(url)
@@ -3063,6 +3070,7 @@ class Server {
3063
3070
  params.set("kill_message", "Click to return home")
3064
3071
  params.set("callback", encodeURIComponent("/github"))
3065
3072
  params.set("id", id)
3073
+ params.set("target", "_top")
3066
3074
  let url = `/shell/${id}?${params.toString()}`
3067
3075
  res.redirect(url)
3068
3076
  }))
@@ -3086,6 +3094,7 @@ class Server {
3086
3094
  params.set("kill_message", "Your Github account is now connected.")
3087
3095
  params.set("callback", encodeURIComponent("/github"))
3088
3096
  params.set("id", id)
3097
+ params.set("target", "_top")
3089
3098
  let url = `/shell/${id}?${params.toString()}`
3090
3099
  res.redirect(url)
3091
3100
  }))
@@ -3107,6 +3116,7 @@ class Server {
3107
3116
 
3108
3117
  // create a new term from cwd
3109
3118
  let id = decodeURIComponent(req.params.id)
3119
+ let target = req.query.target ? req.query.target : null
3110
3120
  let cwd = this.kernel.path(this.kernel.api.filePath(decodeURIComponent(req.query.path)))
3111
3121
  let message = req.query.message ? decodeURIComponent(req.query.message) : null
3112
3122
  //let message = req.query.message ? req.query.message : null
@@ -3146,6 +3156,7 @@ class Server {
3146
3156
 
3147
3157
  let shell = this.kernel.shell.get(id)
3148
3158
  res.render("shell", {
3159
+ target,
3149
3160
  filepath: cwd,
3150
3161
  theme: this.theme,
3151
3162
  agent: this.agent,
@@ -4069,6 +4080,7 @@ class Server {
4069
4080
  }
4070
4081
  }))
4071
4082
  this.app.get("/pinokio/dynamic/:name", ex(async (req, res) => {
4083
+ await this.kernel.plugin.init()
4072
4084
  let plugin = await this.getPlugin(req.params.name)
4073
4085
  let html = ""
4074
4086
  if (plugin && plugin.menu && Array.isArray(plugin.menu)) {
@@ -25,6 +25,9 @@ const Commander = async (config) => {
25
25
  if (config.venv) {
26
26
  search_params.set("venv", config.venv)
27
27
  }
28
+ if (config.target) {
29
+ search_params.set("target", config.target)
30
+ }
28
31
 
29
32
  // env
30
33
  if (config.env) {
@@ -668,6 +668,7 @@ document.querySelector("#advanced-label").addEventListener("click", (e) => {
668
668
  title: "Custom Router",
669
669
  placeholder: "enter a custom router git url",
670
670
  description: `<div>you can write your own custom routers to handle custom request handling for any port <a target="_blank" href="<%=docs%>">Learn more</a></div>`,
671
+ target: "_top",
671
672
  message: (url) => {
672
673
  let name = new URL(url).pathname.split("/").slice(-2).join("_")
673
674
  return encodeURIComponent(`git clone ${url} ${name}`)
@@ -198,8 +198,6 @@ document.addEventListener("DOMContentLoaded", async () => {
198
198
  await this.socket.close()
199
199
 
200
200
  let query = Object.fromEntries(new URLSearchParams(location.search))
201
- console.log(">>>>>>>> 1")
202
-
203
201
  let firstPacketReceived = false
204
202
  this.socket.run({
205
203
  //method: "kernel.bin.shell_start",
@@ -208,7 +206,7 @@ document.addEventListener("DOMContentLoaded", async () => {
208
206
  message: "<%-message%>",
209
207
  <% } %>
210
208
  <% if (venv) { %>
211
- venv: "<%=venv%>",
209
+ venv: "<%-JSON.stringify(venv).slice(1, -1)%>",
212
210
  <% } %>
213
211
  <% if (kill) { %>
214
212
  on: [{
@@ -760,8 +758,15 @@ document.addEventListener("DOMContentLoaded", async () => {
760
758
  </script>
761
759
  </head>
762
760
  <body class='<%=theme%>'>
763
- <header class='navheader grabbable'>
764
- <div class='navheader3'>
761
+ <% if (target === "_top") { %>
762
+ <header class='navheader grabbable'>
763
+ <% } else { %>
764
+ <header class='navheader3'>
765
+ <% } %>
766
+ <h1>
767
+ <% if (target === "_top") { %>
768
+ <a class='home' href="/"><img class='icon' src="/pinokio-black.png"></a>
769
+ <% } %>
765
770
  <div class='hidden btn run play-btn'>
766
771
  <span class='play'><i class="fa-solid fa-play"></i> Start</span>
767
772
  </div>
@@ -774,7 +779,7 @@ document.addEventListener("DOMContentLoaded", async () => {
774
779
  <div class='hidden btn stopped-btn'>
775
780
  <span class='stopped'><i class="fa-solid fa-hand"></i> Stopped</span>
776
781
  </div>
777
- </div>
782
+ </h1>
778
783
  </header>
779
784
  <div class='terminal-container'>
780
785
  <div id='terminal'></div>