pinokiod 1.1.23 → 1.1.25
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/api/index.js +21 -0
- package/kernel/api/modal/index.js +5 -0
- package/kernel/api/process/index.js +122 -0
- package/kernel/index.js +12 -2
- package/package.json +4 -2
- package/server/index.js +18 -9
- package/server/public/install.js +0 -22
- package/server/public/simplemodal.js +24 -0
- package/server/public/style.css +19 -0
- package/server/socket.js +0 -4
- package/server/views/editor.ejs +3 -0
- package/server/views/fullscreen_editor.ejs +3 -0
package/kernel/api/index.js
CHANGED
|
@@ -240,6 +240,26 @@ class Api {
|
|
|
240
240
|
}
|
|
241
241
|
return null
|
|
242
242
|
}
|
|
243
|
+
resolveBrowserPath(uri) {
|
|
244
|
+
let repos = Object.keys(this.gitPath)
|
|
245
|
+
let matched_repo = repos.filter((repo) => {
|
|
246
|
+
return uri.includes(repo)
|
|
247
|
+
})
|
|
248
|
+
if (matched_repo.length > 0) {
|
|
249
|
+
let repo_uri = matched_repo[0]
|
|
250
|
+
|
|
251
|
+
let relative_path = uri
|
|
252
|
+
.replace(repo_uri, "") // remove the git repo uri
|
|
253
|
+
.slice(1) // remove the leading '/' for relative path
|
|
254
|
+
|
|
255
|
+
let repopath = this.gitPath[repo_uri]
|
|
256
|
+
let reponame = path.basename(repopath)
|
|
257
|
+
|
|
258
|
+
return `/pinokio/browser/${reponame}/${relative_path}`
|
|
259
|
+
} else {
|
|
260
|
+
return null
|
|
261
|
+
}
|
|
262
|
+
}
|
|
243
263
|
|
|
244
264
|
resolveWebPath(uri) {
|
|
245
265
|
let repos = Object.keys(this.gitPath)
|
|
@@ -682,6 +702,7 @@ class Api {
|
|
|
682
702
|
// kill all connected shells
|
|
683
703
|
// if not daemon
|
|
684
704
|
if (script.daemon) {
|
|
705
|
+
console.log("## DONE")
|
|
685
706
|
this.ondata({
|
|
686
707
|
id: request.path,
|
|
687
708
|
type: "start",
|
|
@@ -1,4 +1,126 @@
|
|
|
1
|
+
const waitOn = require('wait-on');
|
|
1
2
|
class Process {
|
|
3
|
+
// async start(req, ondata, kernel) {
|
|
4
|
+
// /*
|
|
5
|
+
// req := {
|
|
6
|
+
// method: "process.start",
|
|
7
|
+
// params: {
|
|
8
|
+
// uri: "https://github.com/cocktailpeanutlabs/comfyui.git/start.js",
|
|
9
|
+
// html: "please install ollama",
|
|
10
|
+
// }
|
|
11
|
+
// }
|
|
12
|
+
// */
|
|
13
|
+
// if (kernel.running(req.params.uri)) {
|
|
14
|
+
// // nothing
|
|
15
|
+
// } else {
|
|
16
|
+
// // if exists
|
|
17
|
+
// let uri = req.params.uri
|
|
18
|
+
// let filePath = kernel.api.filePath(uri)
|
|
19
|
+
// if (kernel.exists(filePath)) {
|
|
20
|
+
// // run script
|
|
21
|
+
// await kernel.api.init()
|
|
22
|
+
// console.log("start process", uri)
|
|
23
|
+
// await kernel.api.process({ uri })
|
|
24
|
+
// console.log("process finished")
|
|
25
|
+
// } else {
|
|
26
|
+
// // display html notify
|
|
27
|
+
// let repo = new URL(uri)
|
|
28
|
+
// let href = `https://pinokio.computer/item?uri=${repo}`
|
|
29
|
+
// ondata({
|
|
30
|
+
// html: req.params.html,
|
|
31
|
+
// href,
|
|
32
|
+
// target: "_blank",
|
|
33
|
+
// }, "notify")
|
|
34
|
+
// }
|
|
35
|
+
// }
|
|
36
|
+
// }
|
|
37
|
+
// async run (req, ondata, kernel) {
|
|
38
|
+
// /*
|
|
39
|
+
// // if uri is not specified => just wait
|
|
40
|
+
// req := {
|
|
41
|
+
// method: "process.wait",
|
|
42
|
+
// params: {
|
|
43
|
+
// wait: <waitOn object>,
|
|
44
|
+
// href: "https://ollama.com",
|
|
45
|
+
// html: "please install ollama",
|
|
46
|
+
// }
|
|
47
|
+
// }
|
|
48
|
+
//
|
|
49
|
+
// // if uri is specified => it's pinokio script
|
|
50
|
+
// 1. if the wait condition is met => return immediately
|
|
51
|
+
// 2. if the wait condition is not met
|
|
52
|
+
// 2.1. if the script exists
|
|
53
|
+
// run the script
|
|
54
|
+
// and wait for the wait condition
|
|
55
|
+
// 2.2. if the script does not exist
|
|
56
|
+
// display the 'message' and the 'link'
|
|
57
|
+
//
|
|
58
|
+
// req := {
|
|
59
|
+
// method: "process.wait",
|
|
60
|
+
// params: {
|
|
61
|
+
// start: "https://github.com/cocktailpeanutlabs/comfyui.git/start.js",
|
|
62
|
+
// wait: <waitOn object>,
|
|
63
|
+
// html: "start comfyui",
|
|
64
|
+
// }
|
|
65
|
+
// }
|
|
66
|
+
// */
|
|
67
|
+
//
|
|
68
|
+
// if (req.params) {
|
|
69
|
+
// if (req.params.wait) {
|
|
70
|
+
//
|
|
71
|
+
// await new Promise((resolve, reject) => {
|
|
72
|
+
// let options = req.params.wait
|
|
73
|
+
// waitOn(options).then(() => {
|
|
74
|
+
// resolve()
|
|
75
|
+
// })
|
|
76
|
+
//
|
|
77
|
+
// // 1. if there's a script attribute
|
|
78
|
+
// // 1.0. check if the script repo exists
|
|
79
|
+
// // => if exists, go to the next step
|
|
80
|
+
// // => if not exists, display the message and the link
|
|
81
|
+
// // 1.1. check if the script is running
|
|
82
|
+
// // => if running, don't do anything => waitOn() will automatically return
|
|
83
|
+
// // => if not running, start the script
|
|
84
|
+
// // 1.2. check if the script is not repo exists
|
|
85
|
+
// // 2. if there's no script attribute => display the message and the link
|
|
86
|
+
// if (req.params.start) {
|
|
87
|
+
// if (kernel.running(req.params.start)) {
|
|
88
|
+
// // nothing
|
|
89
|
+
// } else {
|
|
90
|
+
// // if exists
|
|
91
|
+
// let uri = req.params.start
|
|
92
|
+
// let filePath = kernel.api.filePath(uri)
|
|
93
|
+
// if (kernel.exists(filePath)) {
|
|
94
|
+
// // run script
|
|
95
|
+
// //await kernel.api.init()
|
|
96
|
+
// kernel.api.process({ uri })
|
|
97
|
+
// } else {
|
|
98
|
+
// // display html
|
|
99
|
+
// let repo = new URL(uri)
|
|
100
|
+
// let href = `https://pinokio.computer/item?uri=${repo}`
|
|
101
|
+
// ondata({
|
|
102
|
+
// html: req.params.html,
|
|
103
|
+
// href,
|
|
104
|
+
// target: "_blank",
|
|
105
|
+
// }, "notify")
|
|
106
|
+
// }
|
|
107
|
+
// }
|
|
108
|
+
// } else {
|
|
109
|
+
// ondata({
|
|
110
|
+
// html: req.params.html,
|
|
111
|
+
// href: req.params.href,
|
|
112
|
+
// target: "_blank",
|
|
113
|
+
// }, "notify")
|
|
114
|
+
// }
|
|
115
|
+
// })
|
|
116
|
+
// }
|
|
117
|
+
// }
|
|
118
|
+
//
|
|
119
|
+
//
|
|
120
|
+
//
|
|
121
|
+
//
|
|
122
|
+
//
|
|
123
|
+
// }
|
|
2
124
|
async wait (req, ondata, kernel) {
|
|
3
125
|
/*
|
|
4
126
|
params := {
|
package/kernel/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const {JSONPath} = require('jsonpath-plus');
|
|
3
3
|
const os = require("os")
|
|
4
|
+
const jsdom = require("jsdom");
|
|
4
5
|
const path = require('path')
|
|
5
6
|
const fastq = require('fastq')
|
|
6
7
|
const fetch = require('cross-fetch');
|
|
8
|
+
const waitOn = require('wait-on');
|
|
7
9
|
const system = require('systeminformation');
|
|
8
10
|
const Sysinfo = require('./sysinfo')
|
|
9
11
|
const portfinder = require('portfinder');
|
|
@@ -34,6 +36,7 @@ class Kernel {
|
|
|
34
36
|
this.os = os
|
|
35
37
|
this.platform = os.platform()
|
|
36
38
|
this.key = new Key()
|
|
39
|
+
this.jsdom = jsdom
|
|
37
40
|
}
|
|
38
41
|
resumeprocess(uri) {
|
|
39
42
|
let proc = this.procs[uri]
|
|
@@ -44,7 +47,9 @@ class Kernel {
|
|
|
44
47
|
}
|
|
45
48
|
local(...args) {
|
|
46
49
|
// get local variables at path
|
|
47
|
-
let
|
|
50
|
+
let filePath = this.api.filePath(path.resolve(...args))
|
|
51
|
+
let v = this.memory.local[filePath]
|
|
52
|
+
//let v = this.memory.local[path.resolve(...args)]
|
|
48
53
|
if (v) {
|
|
49
54
|
return v
|
|
50
55
|
} else {
|
|
@@ -53,7 +58,9 @@ class Kernel {
|
|
|
53
58
|
}
|
|
54
59
|
global(...args) {
|
|
55
60
|
// get local variables at path
|
|
56
|
-
let
|
|
61
|
+
let filePath = this.api.filePath(path.resolve(...args))
|
|
62
|
+
let v = this.memory.global[filePath]
|
|
63
|
+
// let v = this.memory.global[path.resolve(...args)]
|
|
57
64
|
if (v) {
|
|
58
65
|
return v
|
|
59
66
|
} else {
|
|
@@ -138,6 +145,9 @@ class Kernel {
|
|
|
138
145
|
}
|
|
139
146
|
}
|
|
140
147
|
|
|
148
|
+
async wait(options) {
|
|
149
|
+
await waitOn(options)
|
|
150
|
+
}
|
|
141
151
|
|
|
142
152
|
async init() {
|
|
143
153
|
let home = this.store.get("home")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pinokiod",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.25",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
"fastq": "^1.15.0",
|
|
27
27
|
"form-data": "^4.0.0",
|
|
28
28
|
"fs-extra": "^11.1.1",
|
|
29
|
-
"gepeto": "^0.0.33",
|
|
30
29
|
"glob": "^10.3.3",
|
|
31
30
|
"glob-gitignore": "^1.0.14",
|
|
32
31
|
"handlebars": "^4.7.7",
|
|
@@ -34,6 +33,7 @@
|
|
|
34
33
|
"http-terminator": "^3.2.0",
|
|
35
34
|
"isomorphic-git": "^1.23.0",
|
|
36
35
|
"jimini": "^0.0.2",
|
|
36
|
+
"jsdom": "^24.0.0",
|
|
37
37
|
"jsonpath-plus": "^7.2.0",
|
|
38
38
|
"key-store": "^1.2.0",
|
|
39
39
|
"lodash": "^4.17.21",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"node-calls-python": "^1.8.2",
|
|
45
45
|
"node-downloader-helper": "^2.1.9",
|
|
46
46
|
"node-pty-prebuilt-multiarch-cp": "^0.10.1-pre.48",
|
|
47
|
+
"open": "8.4.2",
|
|
47
48
|
"pdrive": "^0.0.23",
|
|
48
49
|
"portfinder": "^1.0.32",
|
|
49
50
|
"random-useragent": "^0.5.0",
|
|
@@ -55,6 +56,7 @@
|
|
|
55
56
|
"symlink-dir": "^5.2.1",
|
|
56
57
|
"systeminformation": "^5.18.4",
|
|
57
58
|
"uuid": "^9.0.0",
|
|
59
|
+
"wait-on": "^7.2.0",
|
|
58
60
|
"watcher": "^2.2.2",
|
|
59
61
|
"ws": "^8.13.0",
|
|
60
62
|
"xterm-addon-fit": "^0.8.0",
|
package/server/index.js
CHANGED
|
@@ -11,7 +11,6 @@ const cors = require('cors');
|
|
|
11
11
|
const path = require("path")
|
|
12
12
|
const fs = require('fs');
|
|
13
13
|
const os = require('os')
|
|
14
|
-
const gepeto = require('gepeto')
|
|
15
14
|
const { fork } = require('child_process');
|
|
16
15
|
const semver = require('semver')
|
|
17
16
|
const fse = require('fs-extra')
|
|
@@ -262,6 +261,7 @@ class Server {
|
|
|
262
261
|
|
|
263
262
|
|
|
264
263
|
let stat = await fs.promises.stat(filepath)
|
|
264
|
+
console.log("ST", { stat, filepath, isfile: stat.isFile() })
|
|
265
265
|
if (pathComponents.length === 0 && req.query.mode === "explore") {
|
|
266
266
|
res.render("explore", {
|
|
267
267
|
version: this.version,
|
|
@@ -368,6 +368,7 @@ class Server {
|
|
|
368
368
|
query: req.query
|
|
369
369
|
})
|
|
370
370
|
} else if (stat.isFile()) {
|
|
371
|
+
console.log("isfile")
|
|
371
372
|
|
|
372
373
|
if (req.query && req.query.raw) {
|
|
373
374
|
try {
|
|
@@ -426,6 +427,8 @@ class Server {
|
|
|
426
427
|
|
|
427
428
|
let runner = json || js
|
|
428
429
|
|
|
430
|
+
console.log({ runner, json, js, editmode, m })
|
|
431
|
+
|
|
429
432
|
let rawpath = `/raw/${pathComponents.join('/')}` + "?frame=true"
|
|
430
433
|
if (editmode) {
|
|
431
434
|
let content = await fs.promises.readFile(filepath, "utf8")
|
|
@@ -758,6 +761,7 @@ class Server {
|
|
|
758
761
|
|
|
759
762
|
res.render(template, result)
|
|
760
763
|
} else {
|
|
764
|
+
console.log("FRAME", rawpath)
|
|
761
765
|
res.render("frame", {
|
|
762
766
|
logo: this.logo,
|
|
763
767
|
theme: this.theme,
|
|
@@ -1192,6 +1196,8 @@ class Server {
|
|
|
1192
1196
|
config.menu[i].target = "_blank"
|
|
1193
1197
|
}
|
|
1194
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
|
|
1195
1201
|
}
|
|
1196
1202
|
|
|
1197
1203
|
|
|
@@ -1877,6 +1883,17 @@ class Server {
|
|
|
1877
1883
|
this.tabs[req.body.name] = req.body.tabs
|
|
1878
1884
|
res.json({ success: true })
|
|
1879
1885
|
})
|
|
1886
|
+
this.app.get("/pinokio/browser", async (req, res) => {
|
|
1887
|
+
console.log("req.query", req.query)
|
|
1888
|
+
if (req.query && req.query.uri) {
|
|
1889
|
+
let uri = req.query.uri
|
|
1890
|
+
let p = this.kernel.api.resolveBrowserPath(uri)
|
|
1891
|
+
console.log({ uri, p})
|
|
1892
|
+
res.redirect(p)
|
|
1893
|
+
} else {
|
|
1894
|
+
res.redirect("/")
|
|
1895
|
+
}
|
|
1896
|
+
})
|
|
1880
1897
|
this.app.get("/pinokio/browser/:name", async (req, res) => {
|
|
1881
1898
|
let name = req.params.name
|
|
1882
1899
|
let app_path = this.kernel.path("api", name, "pinokio.js")
|
|
@@ -2273,14 +2290,6 @@ class Server {
|
|
|
2273
2290
|
this.app.get("/check", (req, res) => {
|
|
2274
2291
|
res.json({ success: true })
|
|
2275
2292
|
})
|
|
2276
|
-
this.app.post("/gepeto", async (req, res) => {
|
|
2277
|
-
try {
|
|
2278
|
-
await gepeto(path.resolve(this.kernel.homedir, "api", req.body.name))
|
|
2279
|
-
} catch (e) {
|
|
2280
|
-
console.log("gepeto error", e)
|
|
2281
|
-
}
|
|
2282
|
-
res.json({ success: true })
|
|
2283
|
-
})
|
|
2284
2293
|
this.app.post("/restart", async (req, res) => {
|
|
2285
2294
|
console.log("post /restart")
|
|
2286
2295
|
this.start(this.debug)
|
package/server/public/install.js
CHANGED
|
@@ -106,28 +106,6 @@ const install = async (name, url, term, socket, options) => {
|
|
|
106
106
|
// ask the backend to create install.json and start.json if gradio
|
|
107
107
|
location.href = `/?selected=${name}`
|
|
108
108
|
|
|
109
|
-
// await fetch("/gepeto", {
|
|
110
|
-
// method: "post",
|
|
111
|
-
// headers: {
|
|
112
|
-
// "Content-Type": "application/json"
|
|
113
|
-
// },
|
|
114
|
-
// body: JSON.stringify({
|
|
115
|
-
// name
|
|
116
|
-
// })
|
|
117
|
-
// })
|
|
118
|
-
//
|
|
119
|
-
// //location.href = "/api/" + name
|
|
120
|
-
// location.href = `/?selected=${name}`
|
|
121
|
-
// /*
|
|
122
|
-
// n.Noty({
|
|
123
|
-
// text: "Success! Click here to continue.",
|
|
124
|
-
// callbacks: {
|
|
125
|
-
// onClose: () => {
|
|
126
|
-
// location.href = "/api/" + name
|
|
127
|
-
// }
|
|
128
|
-
// }
|
|
129
|
-
// })
|
|
130
|
-
// */
|
|
131
109
|
}
|
|
132
110
|
}
|
|
133
111
|
const createTerm = () => {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const SimpleModal = async (params) => {
|
|
2
|
+
let btns = params.menu.map((item) => {
|
|
3
|
+
if (item.href) {
|
|
4
|
+
return `<a class='btn' href='${item.href}' target='_blank'>${item.text}</a>`
|
|
5
|
+
} else if (item.action) {
|
|
6
|
+
return `<a class='btn' target='_blank'>${item.text}</a>`
|
|
7
|
+
}
|
|
8
|
+
}).join("")
|
|
9
|
+
await Swal.fire({
|
|
10
|
+
title: params.title,
|
|
11
|
+
html: `<div class='simple-modal-desc'>
|
|
12
|
+
${params.description}
|
|
13
|
+
</div>
|
|
14
|
+
<div class='simple-modal-content'>${btns}</div>`,
|
|
15
|
+
// showConfirmButton: false,
|
|
16
|
+
// footer: `<div class='simple-modal-footer'>
|
|
17
|
+
//<div class='flexible'></div>
|
|
18
|
+
//<div id='simple-modal-close'>Done</div>
|
|
19
|
+
//</div>`,
|
|
20
|
+
// didClose: (result) => {
|
|
21
|
+
// // Optional: Handle overall modal closing if needed
|
|
22
|
+
// }
|
|
23
|
+
})
|
|
24
|
+
}
|
package/server/public/style.css
CHANGED
|
@@ -81,6 +81,25 @@ footer .toggle-expand {
|
|
|
81
81
|
footer pre {
|
|
82
82
|
background: none !important;
|
|
83
83
|
}
|
|
84
|
+
.simple-modal-desc {
|
|
85
|
+
padding-bottom: 10px;
|
|
86
|
+
text-align: left;
|
|
87
|
+
font-size: 14px;
|
|
88
|
+
}
|
|
89
|
+
.simple-modal-content {
|
|
90
|
+
text-align: left;
|
|
91
|
+
width: 100%;
|
|
92
|
+
box-sizing: border-box;
|
|
93
|
+
}
|
|
94
|
+
.simple-modal-content .btn {
|
|
95
|
+
margin-right: 5px;
|
|
96
|
+
}
|
|
97
|
+
.simple-modal-footer {
|
|
98
|
+
display: flex;
|
|
99
|
+
padding: 10px;
|
|
100
|
+
width: 100%;
|
|
101
|
+
box-sizing: border-box;
|
|
102
|
+
}
|
|
84
103
|
footer {
|
|
85
104
|
font-family: verdana;
|
|
86
105
|
overflow: hidden;
|
package/server/socket.js
CHANGED
|
@@ -40,10 +40,6 @@ class Socket {
|
|
|
40
40
|
|
|
41
41
|
console.log("socket ID", { id, req })
|
|
42
42
|
|
|
43
|
-
// if (req.mode !== "listen") {
|
|
44
|
-
// // since the event came from the client, connect the buffer
|
|
45
|
-
// this.buffer[id] = []
|
|
46
|
-
// }
|
|
47
43
|
if (req.status) {
|
|
48
44
|
ws.send(JSON.stringify({
|
|
49
45
|
data: this.parent.kernel.api.running[id] ? true : false
|
package/server/views/editor.ejs
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
<script src="/nav.js"></script>
|
|
19
19
|
<script src="/autoexpand.js"></script>
|
|
20
20
|
<script src="/modalinput.js"></script>
|
|
21
|
+
<script src="/simplemodal.js"></script>
|
|
21
22
|
<script src="/notifyinput.js"></script>
|
|
22
23
|
<script src="/report.js"></script>
|
|
23
24
|
<link href="/xterm.min.css" rel="stylesheet" />
|
|
@@ -308,6 +309,8 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
308
309
|
document.querySelector(".run .play").classList.add("hidden")
|
|
309
310
|
document.querySelector(".run .starting").classList.add("hidden")
|
|
310
311
|
document.querySelector(".run .stop").classList.remove("hidden")
|
|
312
|
+
} else if (packet.type === "modal") {
|
|
313
|
+
await SimpleModal(packet.data)
|
|
311
314
|
} else if (packet.type === "input") {
|
|
312
315
|
let params = packet.data
|
|
313
316
|
let type = (params.type ? params.type : "modal")
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
-->
|
|
21
21
|
<script src="/autoexpand.js"></script>
|
|
22
22
|
<script src="/modalinput.js"></script>
|
|
23
|
+
<script src="/simplemodal.js"></script>
|
|
23
24
|
<script src="/notifyinput.js"></script>
|
|
24
25
|
<script src="/report.js"></script>
|
|
25
26
|
<link href="/xterm.min.css" rel="stylesheet" />
|
|
@@ -287,6 +288,8 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
287
288
|
// uri: "~" + location.pathname,
|
|
288
289
|
// })
|
|
289
290
|
// }
|
|
291
|
+
} else if (packet.type === "modal") {
|
|
292
|
+
await SimpleModal(packet.data)
|
|
290
293
|
} else if (packet.type === "input") {
|
|
291
294
|
let params = packet.data
|
|
292
295
|
let type = (params.type ? params.type : "modal")
|