pinokiod 1.1.46 → 1.1.48

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.
@@ -33,9 +33,6 @@ class Api {
33
33
  if (p.target === config.uri) {
34
34
  throw new Error(`A proxy for the uri ${config.uri} already exists`)
35
35
  }
36
- // if (p.name === config.name) {
37
- // throw new Error(`A proxy with the name ${config.name} already exists`)
38
- // }
39
36
  }
40
37
  }
41
38
  }
@@ -45,7 +42,6 @@ class Api {
45
42
  // if the uri exists, throw error
46
43
  console.log("startProxy", { scriptPath, uri, proxies: this.proxies })
47
44
  let proxy_uri = await this.lproxy.start(uri, options)
48
- console.log({ proxy_uri, uri })
49
45
  if (this.proxies[scriptPath]) {
50
46
  this.proxies[scriptPath].push({ target: uri, proxy: proxy_uri, name})
51
47
  } else {
@@ -62,7 +58,6 @@ class Api {
62
58
  // stop all proxies for the script
63
59
  if (this.proxies[config.script]) {
64
60
  for(let p of this.proxies[config.script]) {
65
- console.log("P", p)
66
61
  this.stopProxy({ uri: p.target })
67
62
  }
68
63
  }
@@ -74,7 +69,6 @@ class Api {
74
69
  // remove the uri from the proxies array
75
70
  for(let scriptPath in this.proxies) {
76
71
  let p = this.proxies[scriptPath]
77
- console.log("pp", p)
78
72
  // iterate through p and find the one whose target matches config.uri
79
73
  // and remove it
80
74
  this.proxies[scriptPath] = this.proxies[scriptPath].filter((item) => {
@@ -702,7 +696,6 @@ class Api {
702
696
  // kill all connected shells
703
697
  // if not daemon
704
698
  if (script.daemon) {
705
- console.log("## DONE")
706
699
  this.ondata({
707
700
  id: request.path,
708
701
  type: "start",
@@ -124,26 +124,71 @@ class Process {
124
124
  async wait (req, ondata, kernel) {
125
125
  /*
126
126
  params := {
127
- <sec>|<min>: <num>
127
+ sec: <SECONDS>,
128
+ message: (optional) Description to display while waiting,
129
+ menu: (optional) menu to display in the modal while waiting,
130
+ // ok: (optional) <ok button text> (if not specified, no ok button),
131
+ // cancel: (optional) <cancel button text> (if not specified, no cancel button)
128
132
  }
133
+
134
+ or
135
+
136
+ params := {
137
+ min: <MINUTES>,
138
+ message: (optional) Description to display while waiting,
139
+ menu: (optional) menu to display in the modal while waiting,
140
+ // ok: (optional) <ok button text> (if not specified, no ok button),
141
+ // cancel: (optional) <cancel button text> (if not specified, no cancel button)
142
+ }
143
+
144
+ or
145
+
146
+ params := {
147
+ on: <wait-on condition https://github.com/jeffbski/wait-on>,
148
+ message: (optional) Description to display while waiting,
149
+ menu: (optional) menu to display in the modal while waiting,
150
+ // ok: (optional) <ok button text> (if not specified, no ok button),
151
+ // cancel: (optional) <cancel button text> (if not specified, no cancel button)
152
+ }
153
+
154
+
155
+ if 'ok' is pressed before the condition is met, goes to the next step
156
+ if 'cancel' is pressed before the condition is met, stops the script
157
+
129
158
  */
130
159
  let ms
131
160
  if (req.params) {
132
- if (req.params.sec) {
133
- ms = req.params.sec * 1000
134
- } else if (req.params.min) {
135
- ms = req.params.min * 60 * 1000
136
- }
137
- await new Promise((resolve, reject) => {
138
- this.resolve = resolve
161
+ // Display modal
162
+ if (req.params.sec || req.params.min) {
163
+ // Wait
164
+ if (req.params.sec) {
165
+ ms = req.params.sec * 1000
166
+ } else if (req.params.min) {
167
+ ms = req.params.min * 60 * 1000
168
+ }
169
+ await new Promise((resolve, reject) => {
170
+ this.resolve = resolve
139
171
 
140
- // register the process with the root uri so it can be manually resolved (with this.resolve()) later
141
- kernel.procs[req.parent.path] = this
172
+ // register the process with the root uri so it can be manually resolved (with this.resolve()) later
173
+ kernel.procs[req.parent.path] = this
142
174
 
143
- setTimeout(() => {
144
- this.resolve()
145
- }, ms)
146
- })
175
+ setTimeout(() => {
176
+ this.resolve()
177
+ }, ms)
178
+ })
179
+ } else if (req.params.on) {
180
+ // Wait
181
+ if (req.params.message) {
182
+ ondata({
183
+ raw: `\r\nWaiting: ${JSON.stringify(req.params.on)}\r\n`
184
+ })
185
+ ondata(req.params, "wait")
186
+ }
187
+ console.log("Wait", req.params.on)
188
+ await waitOn(req.params.on)
189
+ console.log("Wait finished")
190
+ ondata(req.params, "wait.end")
191
+ }
147
192
  } else {
148
193
  await new Promise((resolve, reject) => {
149
194
  this.resolve = resolve
@@ -17,7 +17,7 @@ class P {
17
17
  console.log("proxy.start", { name, uri, o })
18
18
  let response = await kernel.api.startProxy(req.parent.path, req.params.uri, req.params.name, o)
19
19
  ondata({
20
- raw: "Proxy Started"
20
+ raw: "Proxy Started\r\n"
21
21
  })
22
22
  return response
23
23
  }
@@ -35,7 +35,7 @@ class P {
35
35
  })
36
36
  kernel.api.stopProxy({ uri: req.params.uri })
37
37
  ondata({
38
- raw: "Proxy Stopped"
38
+ raw: "Proxy Stopped\r\n"
39
39
  })
40
40
  }
41
41
  }
package/kernel/shell.js CHANGED
@@ -191,8 +191,6 @@ class Shell {
191
191
  // automatically add self to the shells registry
192
192
  this.kernel.shell.add(this)
193
193
 
194
- console.log("** this.env", this.env)
195
-
196
194
  if (params.sudo) {
197
195
  let options = {
198
196
  name: "Pinokio",
@@ -465,7 +463,6 @@ class Shell {
465
463
  }
466
464
  }
467
465
  async activate(params) {
468
- console.log("activate", params)
469
466
  if (params.conda) {
470
467
  if (params.conda === "base") {
471
468
  // using the base env
@@ -475,7 +472,7 @@ class Shell {
475
472
  `conda deactivate`,
476
473
  `conda deactivate`,
477
474
  `conda activate ${params.conda}`,
478
- 'pip install --upgrade wheel pip setuptools',
475
+ // 'pip install --upgrade wheel pip setuptools',
479
476
  ].concat(params.message)
480
477
  } else {
481
478
  if (typeof params.conda === "string") {
@@ -489,7 +486,7 @@ class Shell {
489
486
  `conda deactivate`,
490
487
  `conda deactivate`,
491
488
  `conda activate ${env_path}`,
492
- 'pip install --upgrade wheel pip setuptools',
489
+ // 'pip install --upgrade wheel pip setuptools',
493
490
  ].concat(params.message)
494
491
  } else {
495
492
  params.message = [
@@ -500,7 +497,7 @@ class Shell {
500
497
  `conda deactivate`,
501
498
  `conda deactivate`,
502
499
  `conda activate ${env_path}`,
503
- 'pip install --upgrade wheel pip setuptools',
500
+ // 'pip install --upgrade wheel pip setuptools',
504
501
  ].concat(params.message)
505
502
  }
506
503
  } else if (typeof params.conda === "object" && params.conda.path) {
@@ -513,7 +510,7 @@ class Shell {
513
510
  `conda deactivate`,
514
511
  `conda deactivate`,
515
512
  `conda activate ${env_path}`,
516
- 'pip install --upgrade wheel pip setuptools',
513
+ // 'pip install --upgrade wheel pip setuptools',
517
514
  ].concat(params.message)
518
515
  } else {
519
516
  let create_command
@@ -529,7 +526,7 @@ class Shell {
529
526
  `conda deactivate`,
530
527
  `conda deactivate`,
531
528
  `conda activate ${env_path}`,
532
- 'pip install --upgrade wheel pip setuptools',
529
+ // 'pip install --upgrade wheel pip setuptools',
533
530
  ].concat(params.message)
534
531
  }
535
532
  }
@@ -550,14 +547,14 @@ class Shell {
550
547
  params.message = [
551
548
  (this.platform === "win32" ? `${activate_path} ${env_path}` : `source ${activate_path} ${env_path}`),
552
549
  //'pip install --upgrade pip',
553
- 'pip install --upgrade wheel pip setuptools',
550
+ // 'pip install --upgrade wheel pip setuptools',
554
551
  ].concat(params.message)
555
552
  } else {
556
553
  params.message = [
557
554
  `python -m venv ${env_path}`,
558
555
  (this.platform === "win32" ? `${activate_path} ${env_path}` : `source ${activate_path} ${env_path}`),
559
556
  //'pip install --upgrade pip',
560
- 'pip install --upgrade wheel pip setuptools',
557
+ // 'pip install --upgrade wheel pip setuptools',
561
558
  ].concat(params.message)
562
559
  }
563
560
  }
@@ -566,7 +563,6 @@ class Shell {
566
563
  }
567
564
  async exec(params) {
568
565
  params = await this.activate(params)
569
- console.log("** params", params)
570
566
 
571
567
  this.cmd = this.build(params)
572
568
  let res = await new Promise((resolve, reject) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "1.1.46",
3
+ "version": "1.1.48",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -37,7 +37,7 @@
37
37
  "jsonpath-plus": "^7.2.0",
38
38
  "key-store": "^1.2.0",
39
39
  "lodash": "^4.17.21",
40
- "lproxy": "^0.0.6",
40
+ "lproxy": "^0.0.7",
41
41
  "marked": "^5.0.1",
42
42
  "mime-types": "^2.1.35",
43
43
  "multer": "^1.4.5-lts.1",
package/server/index.js CHANGED
@@ -92,8 +92,6 @@ class Server {
92
92
  }
93
93
  }
94
94
  getMemory(filepath) {
95
- console.log("memory", this.kernel.memory.local)
96
- console.log("filepath", filepath)
97
95
  let localMem = this.kernel.memory.local[filepath]
98
96
  let globalMem = this.kernel.memory.global[filepath]
99
97
 
@@ -267,7 +265,6 @@ class Server {
267
265
 
268
266
 
269
267
  let stat = await fs.promises.stat(filepath)
270
- console.log("ST", { stat, filepath, isfile: stat.isFile() })
271
268
  if (pathComponents.length === 0 && req.query.mode === "explore") {
272
269
  res.render("explore", {
273
270
  version: this.version,
@@ -442,8 +439,6 @@ class Server {
442
439
 
443
440
  let runner = json || js
444
441
 
445
- console.log({ runner, json, js, editmode, m })
446
-
447
442
  let rawpath = `/raw/${pathComponents.join('/')}` + "?frame=true"
448
443
  if (editmode) {
449
444
  let content = await fs.promises.readFile(filepath, "utf8")
@@ -776,7 +771,6 @@ class Server {
776
771
 
777
772
  res.render(template, result)
778
773
  } else {
779
- console.log("FRAME", rawpath)
780
774
  res.render("frame", {
781
775
  logo: this.logo,
782
776
  theme: this.theme,
@@ -6,13 +6,3 @@ const refreshParent = (e) => {
6
6
  window.parent.postMessage(e, "*")
7
7
  }
8
8
  }
9
- //window.addEventListener('message', (event) => {
10
- // console.log("Message received from the child: ", event.data); // Message received from child
11
- // if (event.data && event.data.action) {
12
- // if (event.data.action === "back") {
13
- // history.back()
14
- // } else if (event.data.action === "forward") {
15
- // history.forward()
16
- // }
17
- // }
18
- //});
@@ -15,13 +15,5 @@ const SimpleModal = async (params) => {
15
15
  ${params.description || ""}
16
16
  </div>
17
17
  <div class='simple-modal-content'>${btns}</div>`,
18
- // showConfirmButton: false,
19
- // footer: `<div class='simple-modal-footer'>
20
- //<div class='flexible'></div>
21
- //<div id='simple-modal-close'>Done</div>
22
- //</div>`,
23
- // didClose: (result) => {
24
- // // Optional: Handle overall modal closing if needed
25
- // }
26
18
  })
27
19
  }
@@ -81,6 +81,17 @@ footer .toggle-expand {
81
81
  footer pre {
82
82
  background: none !important;
83
83
  }
84
+ .wait-modal {
85
+ padding: 20px;
86
+ text-align: center;
87
+ }
88
+ .wait-modal-desc h1 {
89
+ padding-right: 10px;
90
+ }
91
+ .wait-modal-desc {
92
+ display: flex;
93
+ align-items: center;
94
+ }
84
95
  .simple-modal-desc {
85
96
  padding-bottom: 15px;
86
97
  text-align: left;
@@ -0,0 +1,24 @@
1
+ const WaitModal = async (params) => {
2
+ let menu = (params.menu ? params.menu : [])
3
+ let btns = menu.map((item) => {
4
+ if (item.href) {
5
+ let icon = (item.icon ? `<i class="${item.icon}"></i> ` : "")
6
+ return `<a class='btn' href='${item.href}' target='_blank'>${icon}${item.text}</a>`
7
+ } else if (item.action) {
8
+ return `<a class='btn' target='_blank'>${item.text}</a>`
9
+ }
10
+ }).join("")
11
+ let c = {
12
+ html: `<div class='wait-modal'>
13
+ <div class='simple-modal-desc wait-modal-desc'>
14
+ <h1><i class="fa-solid fa-spin fa-circle-notch"></i></h1>
15
+ <div>${params.message || ""}</div>
16
+ </div>
17
+ <div class='simple-modal-content'>${btns}</div>
18
+ </div>`,
19
+ allowOutsideClick: false,
20
+ allowEscapeKey: false,
21
+ showConfirmButton: false
22
+ }
23
+ await Swal.fire(c)
24
+ }
@@ -1,5 +1,6 @@
1
1
  <html class='columns'>
2
2
  <head>
3
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
3
4
  <script src="/hotkeys.min.js"></script>
4
5
  <script src="/ace/ace.js"></script>
5
6
  <script src="/noty.js"></script>
@@ -19,6 +20,7 @@
19
20
  <script src="/autoexpand.js"></script>
20
21
  <script src="/modalinput.js"></script>
21
22
  <script src="/simplemodal.js"></script>
23
+ <script src="/waitmodal.js"></script>
22
24
  <script src="/notifyinput.js"></script>
23
25
  <script src="/report.js"></script>
24
26
  <link href="/xterm.min.css" rel="stylesheet" />
@@ -309,6 +311,14 @@ document.addEventListener("DOMContentLoaded", async () => {
309
311
  document.querySelector(".run .play").classList.add("hidden")
310
312
  document.querySelector(".run .starting").classList.add("hidden")
311
313
  document.querySelector(".run .stop").classList.remove("hidden")
314
+ } else if (packet.type === 'wait.end') {
315
+ Swal.close()
316
+ } else if (packet.type === 'wait') {
317
+ await WaitModal(packet.data)
318
+ this.socket.respond({
319
+ response: {},
320
+ uri: "~" + location.pathname,
321
+ })
312
322
  } else if (packet.type === "modal") {
313
323
  await SimpleModal(packet.data)
314
324
  } else if (packet.type === "input") {
@@ -1,7 +1,7 @@
1
1
  <html>
2
2
  <head>
3
3
  <meta charset="UTF-8">
4
- <meta name="viewport" content="width=device-width, initial-scale=1" />
4
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
5
5
  <style>
6
6
  body {
7
7
  }
@@ -1,7 +1,7 @@
1
1
  <html>
2
2
  <head>
3
3
  <meta charset="UTF-8">
4
- <meta name="viewport" content="width=device-width, initial-scale=1" />
4
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
5
5
  <link href="/css/fontawesome.min.css" rel="stylesheet">
6
6
  <link href="/css/solid.min.css" rel="stylesheet">
7
7
  <link href="/css/regular.min.css" rel="stylesheet">
@@ -1,5 +1,6 @@
1
1
  <html>
2
2
  <head>
3
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
3
4
  <script src="/hotkeys.min.js"></script>
4
5
  <script src="/ace/ace.js"></script>
5
6
  <script src="/noty.js"></script>
@@ -21,6 +22,7 @@
21
22
  <script src="/autoexpand.js"></script>
22
23
  <script src="/modalinput.js"></script>
23
24
  <script src="/simplemodal.js"></script>
25
+ <script src="/waitmodal.js"></script>
24
26
  <script src="/notifyinput.js"></script>
25
27
  <script src="/report.js"></script>
26
28
  <link href="/xterm.min.css" rel="stylesheet" />
@@ -288,6 +290,17 @@ document.addEventListener("DOMContentLoaded", async () => {
288
290
  // uri: "~" + location.pathname,
289
291
  // })
290
292
  // }
293
+ } else if (packet.type === 'wait.end') {
294
+ try {
295
+ Swal.close()
296
+ } catch (e) {
297
+ }
298
+ this.socket.respond({
299
+ response: {},
300
+ uri: "~" + location.pathname,
301
+ })
302
+ } else if (packet.type === 'wait') {
303
+ await WaitModal(packet.data)
291
304
  } else if (packet.type === "modal") {
292
305
  await SimpleModal(packet.data)
293
306
  this.socket.respond({
@@ -1,7 +1,7 @@
1
1
  <html>
2
2
  <head>
3
3
  <meta charset="UTF-8">
4
- <meta name="viewport" content="width=device-width, initial-scale=1" />
4
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
5
5
  <link href="/xterm.min.css" rel="stylesheet" />
6
6
  <link href="/css/fontawesome.min.css" rel="stylesheet">
7
7
  <link href="/css/solid.min.css" rel="stylesheet">
@@ -1,7 +1,7 @@
1
1
  <html>
2
2
  <head>
3
3
  <meta charset="UTF-8">
4
- <meta name="viewport" content="width=device-width, initial-scale=1" />
4
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
5
5
  <link href="/xterm.min.css" rel="stylesheet" />
6
6
  <link href="/css/fontawesome.min.css" rel="stylesheet">
7
7
  <link href="/css/solid.min.css" rel="stylesheet">
@@ -1,7 +1,7 @@
1
1
  <html>
2
2
  <head>
3
3
  <meta charset="UTF-8">
4
- <meta name="viewport" content="width=device-width, initial-scale=1" />
4
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
5
5
  <link href="/xterm.min.css" rel="stylesheet" />
6
6
  <link href="/css/fontawesome.min.css" rel="stylesheet">
7
7
  <link href="/css/solid.min.css" rel="stylesheet">
@@ -66,7 +66,6 @@
66
66
  padding: 20px 0;
67
67
  }
68
68
  .titleview h1 {
69
- font-family: verdana;
70
69
  font-size: 40px;
71
70
  text-transform: uppercase;
72
71
  letter-spacing: 0;
@@ -78,7 +77,6 @@
78
77
  padding: 10px 20px;
79
78
  }
80
79
  .item label {
81
- font-family: verdana;
82
80
  display: block;
83
81
  text-transform: capitalize;
84
82
  font-size: 20px;
@@ -1,40 +0,0 @@
1
- import sys
2
- import importlib
3
- import importlib_metadata
4
- import os
5
- # Get all the pip packages for the base path
6
- def get(sitepackages_base):
7
- sys.path=[sitepackages_base]
8
- importlib.invalidate_caches()
9
- dists = importlib_metadata.packages_distributions()
10
- dict = {}
11
- for package_name in dists:
12
- for dist_name in dists[package_name]:
13
- dict[dist_name] = {}
14
- # get package path
15
- try:
16
- meta = importlib_metadata.metadata(dist_name)
17
- files = importlib_metadata.files(dist_name)
18
- move = set()
19
- copy = set()
20
- for file in files:
21
- filepath = os.path.join(sitepackages_base, file)
22
- dirpath = os.path.abspath(os.path.dirname(filepath))
23
- try:
24
- relpath = Path(dirpath).relative_to(sitepackages_base)
25
- # site package handling
26
- chunks = str(relpath).split(os.sep)
27
- if len(chunks) > 1:
28
- folder = chunks[0]
29
- move.add(os.path.join(sitepackages_base, folder))
30
- except:
31
- # non site package handling
32
- # add the full file paths => so they can be copied
33
- copy.add(str(filepath))
34
- dict[dist_name]["copy"] = list(copy)
35
- dict[dist_name]["move"] = list(move)
36
- except Exception as error:
37
- print(f"#ERR {error}")
38
- return dict
39
- if __name__ == "__main__":
40
- get("/Users/x/pinokio/api/comfyui.git/app/env/lib/python3.10/site-packages")
@@ -1,27 +0,0 @@
1
- from fastapi import FastAPI, Body
2
- from typing import List
3
- from pydantic import BaseModel
4
- import sys
5
- import os
6
-
7
- import importlib
8
- class Params(BaseModel):
9
- values: List[str]
10
-
11
- app = FastAPI()
12
- #@app.get("/")
13
- #async def root():
14
- # return {"greeting":"Hello world"}
15
-
16
- # { name: "pip.py", method: "list", params: [ ] }
17
- @app.post("/call")
18
- async def call(item: dict = Body(...)):
19
- print(f"item={item}")
20
- sys.path.insert(0, os.path.dirname(item["path"]))
21
- #async def call(path: str, method: str, params: Params):
22
- mod = importlib.import_module(item["name"], item["path"])
23
- print(f"Mod = {mod}")
24
- fun = getattr(mod, item["method"])
25
- print(f"Fun = {fun}")
26
- result = fun(*item["params"])
27
- return result