pinokiod 3.9.28 → 3.9.30
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 +0 -20
- package/kernel/api/input/index.js +2 -1
- package/kernel/api/shell/index.js +1 -1
- package/kernel/bin/index.js +0 -15
- package/kernel/index.js +9 -31
- package/kernel/loader.js +1 -0
- package/kernel/plugin.js +2 -2
- package/kernel/prototype.js +28 -23
- package/kernel/shells.js +6 -2
- package/package.json +1 -1
- package/server/index.js +111 -32
- package/server/public/fseditor.js +2 -9
- package/server/public/modalinput.js +28 -9
- package/server/public/opener.js +0 -1
- package/server/public/style.css +44 -5
- package/server/views/app.ejs +50 -40
- package/server/views/connect.ejs +96 -13
- package/server/views/network.ejs +4 -2
- package/server/views/partials/dynamic.ejs +3 -5
- package/server/views/partials/menu.ejs +1 -1
- package/server/views/prototype/index.ejs +967 -310
- package/server/views/prototype/old_index.ejs +646 -0
- package/server/views/prototype/show.ejs +11 -158
- package/server/views/settings.ejs +6 -3
package/kernel/api/index.js
CHANGED
|
@@ -173,8 +173,6 @@ class Api {
|
|
|
173
173
|
// 1. set the "stop" flag for the uri, so the next execution in the queue for the uri will NOT queue another task
|
|
174
174
|
// 2. stream a message closing the socket
|
|
175
175
|
|
|
176
|
-
console.log("STOP", req)
|
|
177
|
-
|
|
178
176
|
if (req.params.id) {
|
|
179
177
|
// /Users/x/pinokio/prototype/system/aicode/template/claude.json?cwd=/Users/x/pinokio/api/MMAudio.git
|
|
180
178
|
// take the first part only since the rest is the cwd
|
|
@@ -191,18 +189,12 @@ class Api {
|
|
|
191
189
|
}
|
|
192
190
|
// reset modules
|
|
193
191
|
let modpath = this.resolvePath(cwd, req.params.uri)
|
|
194
|
-
console.log("STOP modpath", modpath)
|
|
195
|
-
console.log("this.mods before", this.mods)
|
|
196
|
-
console.log("this.child_procs before", this.child_procs)
|
|
197
192
|
if (this.child_procs[modpath]) {
|
|
198
193
|
let child_procs = Array.from(this.child_procs[modpath])
|
|
199
194
|
for(let proc of child_procs) {
|
|
200
|
-
console.log("reset child proc", proc)
|
|
201
195
|
delete this.mods[proc]
|
|
202
196
|
}
|
|
203
197
|
delete this.child_procs[modpath]
|
|
204
|
-
console.log("this.mods after", this.mods)
|
|
205
|
-
console.log("this.child_procs after", this.child_procs)
|
|
206
198
|
}
|
|
207
199
|
|
|
208
200
|
|
|
@@ -225,10 +217,7 @@ class Api {
|
|
|
225
217
|
this.waiter[requestPath].reject()
|
|
226
218
|
delete this.waiter[requestPath]
|
|
227
219
|
}
|
|
228
|
-
|
|
229
|
-
console.log("Stop", { req, requestPath })
|
|
230
220
|
if (req.params.id) {
|
|
231
|
-
console.log("delete", req.params.id, this.running[req.params.id])
|
|
232
221
|
delete this.running[req.params.id]
|
|
233
222
|
delete this.kernel.memory.local[req.params.id]
|
|
234
223
|
} else {
|
|
@@ -533,7 +522,6 @@ class Api {
|
|
|
533
522
|
}
|
|
534
523
|
mod = m.resolved
|
|
535
524
|
dirname = m.dirname
|
|
536
|
-
console.log({ m })
|
|
537
525
|
method = mod[req.method].bind(mod)
|
|
538
526
|
} else {
|
|
539
527
|
// KERNEL
|
|
@@ -551,7 +539,6 @@ class Api {
|
|
|
551
539
|
if (chunks.length === 1) {
|
|
552
540
|
let methodName = chunks[0]
|
|
553
541
|
modpath = path.resolve(__dirname, methodName)
|
|
554
|
-
console.log({ modpath })
|
|
555
542
|
mod = (await this.loader.load(modpath))
|
|
556
543
|
method = mod.resolved
|
|
557
544
|
dirname = mod.dirname
|
|
@@ -656,8 +643,6 @@ class Api {
|
|
|
656
643
|
cwd = request.cwd
|
|
657
644
|
}
|
|
658
645
|
|
|
659
|
-
console.log("STEP", { request, rawrpc, input, args })
|
|
660
|
-
|
|
661
646
|
let id = request.id || request.path
|
|
662
647
|
|
|
663
648
|
let memory = {
|
|
@@ -713,7 +698,6 @@ class Api {
|
|
|
713
698
|
}
|
|
714
699
|
// replace {{{ }}} with {{ }}
|
|
715
700
|
rpc = this.kernel.template.flatten(rpc)
|
|
716
|
-
console.log({ rpc })
|
|
717
701
|
|
|
718
702
|
// 6. rpc must have method names
|
|
719
703
|
if (rpc.method) {
|
|
@@ -728,8 +712,6 @@ class Api {
|
|
|
728
712
|
// 7. resolve the rpc
|
|
729
713
|
let resolved = await this.resolveMethod(rpc, cwd)
|
|
730
714
|
|
|
731
|
-
console.log({ resolved })
|
|
732
|
-
|
|
733
715
|
// 8. the endpoint must exist
|
|
734
716
|
if (!resolved.method) {
|
|
735
717
|
this.ondata({
|
|
@@ -1142,7 +1124,6 @@ class Api {
|
|
|
1142
1124
|
this.queues[queue_id] = fastq.promise(async ({ request, rawrpc, input, step, total, cwd, args }) => {
|
|
1143
1125
|
try {
|
|
1144
1126
|
let response = await this.step(request, rawrpc, input, step, total, args)
|
|
1145
|
-
console.log("Handle Response", { request, response })
|
|
1146
1127
|
if (response) {
|
|
1147
1128
|
if (response.rawrpc) {
|
|
1148
1129
|
this.queue(response.request, response.rawrpc, response.input, response.step, response.total, cwd, args)
|
|
@@ -1264,7 +1245,6 @@ class Api {
|
|
|
1264
1245
|
}
|
|
1265
1246
|
}
|
|
1266
1247
|
async process(request, done) {
|
|
1267
|
-
console.log("Process", request)
|
|
1268
1248
|
/**************************************************************
|
|
1269
1249
|
*
|
|
1270
1250
|
* req := { uri: <relative path>|<absolute path>|<url> }
|
|
@@ -2,6 +2,7 @@ module.exports = async (req, ondata, kernel) => {
|
|
|
2
2
|
// send "input" type event so the frontend triggers a modal
|
|
3
3
|
ondata(req.params, "input")
|
|
4
4
|
// then, wait until the frontend responds
|
|
5
|
-
let
|
|
5
|
+
let id = req.parent.id || req.parent.path
|
|
6
|
+
let response = await kernel.api.wait(id)
|
|
6
7
|
return response
|
|
7
8
|
}
|
|
@@ -129,7 +129,7 @@ class Shell {
|
|
|
129
129
|
req.params.cols = req.client.cols
|
|
130
130
|
}
|
|
131
131
|
let response = await kernel.shell.run(req.params, options, async (stream) => {
|
|
132
|
-
process.stdout.write(stream.raw)
|
|
132
|
+
// process.stdout.write(stream.raw)
|
|
133
133
|
ondata(stream)
|
|
134
134
|
})
|
|
135
135
|
return response
|
package/kernel/bin/index.js
CHANGED
|
@@ -39,20 +39,7 @@ class Bin {
|
|
|
39
39
|
this.platform = os.platform()
|
|
40
40
|
}
|
|
41
41
|
async shell_kill(params, ondata) {
|
|
42
|
-
console.log("shell_kill", params)
|
|
43
42
|
this.kernel.shell.kill(params.params)
|
|
44
|
-
|
|
45
|
-
// let id = params.params.id
|
|
46
|
-
// console.log("id", id)
|
|
47
|
-
// console.log("api.running", this.kernel.api.running)
|
|
48
|
-
// delete this.kernel.api.running[id]
|
|
49
|
-
// delete this.kernel.memory.local[id]
|
|
50
|
-
//
|
|
51
|
-
// ondata({
|
|
52
|
-
// id,
|
|
53
|
-
// type: "disconnect"
|
|
54
|
-
// })
|
|
55
|
-
// this.kernel.refresh(true)
|
|
56
43
|
}
|
|
57
44
|
async shell_start(params, ondata) {
|
|
58
45
|
params.path = params.path || this.path()
|
|
@@ -254,8 +241,6 @@ class Bin {
|
|
|
254
241
|
return file.endsWith(".js") && file !== "index.js" && file !== "cmake.js"
|
|
255
242
|
})
|
|
256
243
|
|
|
257
|
-
console.log("BIN INIT")
|
|
258
|
-
|
|
259
244
|
for(let filename of modfiles) {
|
|
260
245
|
// 1. get all the modules in __dirname
|
|
261
246
|
// 2. load them
|
package/kernel/index.js
CHANGED
|
@@ -728,30 +728,6 @@ class Kernel {
|
|
|
728
728
|
return this.api.get_proxy_url("/proxy", port)
|
|
729
729
|
},
|
|
730
730
|
})
|
|
731
|
-
// console.log("> 2")
|
|
732
|
-
// this.sys = new Sysinfo()
|
|
733
|
-
// await this.sys.init(this)
|
|
734
|
-
// console.log("> 3")
|
|
735
|
-
// let info = this.sys.info
|
|
736
|
-
//
|
|
737
|
-
// this.sysinfo = info
|
|
738
|
-
//
|
|
739
|
-
// await this.getInfo()
|
|
740
|
-
// console.log("> 4")
|
|
741
|
-
|
|
742
|
-
// await fs.promises.mkdir(this.path("logs"), { recursive: true }).catch((e) => { })
|
|
743
|
-
// console.log("> 5")
|
|
744
|
-
// await fs.promises.writeFile(this.path("logs/system.json"), JSON.stringify(this.i, null, 2))
|
|
745
|
-
// console.log("> 6")
|
|
746
|
-
// let pwpath = this.bin.path("playwright/node_modules/playwright")
|
|
747
|
-
// this.playwright = (await this.loader.load(pwpath)).resolved
|
|
748
|
-
//
|
|
749
|
-
// console.log("> 7")
|
|
750
|
-
|
|
751
|
-
// await this.proto.init()
|
|
752
|
-
// console.log("> 8")
|
|
753
|
-
// await this.plugin.init()
|
|
754
|
-
// console.log("> 9")
|
|
755
731
|
|
|
756
732
|
// refresh every 5 second
|
|
757
733
|
if (this.refresh_interval) {
|
|
@@ -776,13 +752,15 @@ class Kernel {
|
|
|
776
752
|
}
|
|
777
753
|
async update_sysinfo() {
|
|
778
754
|
try {
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
755
|
+
if (this.sys) {
|
|
756
|
+
await this.sys.refresh()
|
|
757
|
+
let info = this.sys.info
|
|
758
|
+
this.template.update(info)
|
|
759
|
+
this.sysinfo = info
|
|
760
|
+
this.gpu = info.gpu
|
|
761
|
+
this.gpu_model = info.gpu_model
|
|
762
|
+
this.gpus = info.gpus
|
|
763
|
+
}
|
|
786
764
|
} catch (e) {
|
|
787
765
|
console.log("sysinfo error", e)
|
|
788
766
|
}
|
package/kernel/loader.js
CHANGED
package/kernel/plugin.js
CHANGED
|
@@ -4,7 +4,7 @@ class Plugin {
|
|
|
4
4
|
this.kernel = kernel
|
|
5
5
|
}
|
|
6
6
|
async init() {
|
|
7
|
-
if (this.kernel.bin.installed.conda.has("git")) {
|
|
7
|
+
if (this.kernel.bin.installed && this.kernel.bin.installed.conda && this.kernel.bin.installed.conda.has("git")) {
|
|
8
8
|
// if ~/pinokio/prototype doesn't exist, clone
|
|
9
9
|
let exists = await this.kernel.exists("plugin")
|
|
10
10
|
if (!exists) {
|
|
@@ -22,7 +22,7 @@ class Plugin {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
async update() {
|
|
25
|
-
if (this.kernel.bin.installed.conda.has("git")) {
|
|
25
|
+
if (this.kernel.bin.installed && this.kernel.bin.installed.conda && this.kernel.bin.installed.conda.has("git")) {
|
|
26
26
|
let exists = await this.kernel.exists("plugin")
|
|
27
27
|
if (!exists) {
|
|
28
28
|
await this.kernel.exec({
|
package/kernel/prototype.js
CHANGED
|
@@ -9,7 +9,7 @@ class Proto {
|
|
|
9
9
|
async init() {
|
|
10
10
|
this.items = []
|
|
11
11
|
this.kv = {}
|
|
12
|
-
if (this.kernel.bin.installed.conda.has("git")) {
|
|
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
15
|
let exists = await this.kernel.exists("prototype")
|
|
@@ -17,35 +17,40 @@ class Proto {
|
|
|
17
17
|
console.log("prototype doesn't exist. cloning...")
|
|
18
18
|
await fs.promises.mkdir(this.kernel.path("prototype"), { recursive: true }).catch((e) => { })
|
|
19
19
|
await this.kernel.exec({
|
|
20
|
-
message: "git clone https://github.com/peanutcocktail/prototype system",
|
|
20
|
+
//message: "git clone https://github.com/peanutcocktail/prototype system",
|
|
21
|
+
message: "git clone https://github.com/cocktailpeanutlabs/proto system",
|
|
21
22
|
path: this.kernel.path("prototype")
|
|
22
23
|
}, (e) => {
|
|
23
24
|
process.stdout.write(e.raw)
|
|
24
25
|
})
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
let pinokiojs_path = this.kernel.path("prototype/system/pinokio.js")
|
|
29
|
+
let config = await this.kernel.require(pinokiojs_path)
|
|
30
|
+
this.config = config
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
let
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
let
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.
|
|
47
|
-
|
|
48
|
-
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
//// let prototype_paths = (await glob('**/pinokio.js', { cwd }))
|
|
35
|
+
// let prototype_dir = path.resolve(this.kernel.homedir, "prototype")
|
|
36
|
+
// for(let prototype_path of prototype_paths) {
|
|
37
|
+
// let proto = path.dirname(prototype_path)
|
|
38
|
+
// let pinokiojs = path.resolve(prototype_dir, prototype_path)
|
|
39
|
+
// let config = await this.kernel.require(pinokiojs)
|
|
40
|
+
// if (config && config.run) {
|
|
41
|
+
// if (config.icon) {
|
|
42
|
+
// config.icon = "/prototype/" + proto + "/" + config.icon
|
|
43
|
+
// } else {
|
|
44
|
+
// config.icon === "/pinokio-black.png"
|
|
45
|
+
// }
|
|
46
|
+
// let c = {
|
|
47
|
+
// id: proto,
|
|
48
|
+
// ...config
|
|
49
|
+
// }
|
|
50
|
+
// this.items.push(c)
|
|
51
|
+
// this.kv[proto] = c
|
|
52
|
+
// }
|
|
53
|
+
// }
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
56
|
async readme(proto) {
|
package/kernel/shells.js
CHANGED
|
@@ -145,7 +145,9 @@ class Shells {
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
ondata
|
|
148
|
+
if (ondata) {
|
|
149
|
+
ondata(stream)
|
|
150
|
+
}
|
|
149
151
|
})
|
|
150
152
|
/*
|
|
151
153
|
{
|
|
@@ -284,7 +286,9 @@ class Shells {
|
|
|
284
286
|
// if the stream includes "prompt": true, don't emit the event since that event is only for
|
|
285
287
|
// handling listeners
|
|
286
288
|
if (!stream.prompt) {
|
|
287
|
-
ondata
|
|
289
|
+
if (ondata) {
|
|
290
|
+
ondata(stream)
|
|
291
|
+
}
|
|
288
292
|
}
|
|
289
293
|
if (params.on) {
|
|
290
294
|
for(let handler of params.on) {
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -102,12 +102,9 @@ class Server {
|
|
|
102
102
|
return new Promise(r=>fs.access(s, fs.constants.F_OK, e => r(!e)))
|
|
103
103
|
}
|
|
104
104
|
async updateMeta(formData, app_path) {
|
|
105
|
-
console.log("updateMeta", formData)
|
|
106
|
-
|
|
107
105
|
// write title/description to pinokio.json
|
|
108
106
|
let dirty
|
|
109
107
|
let meta_path = this.kernel.path("api", app_path, "pinokio.json")
|
|
110
|
-
console.log("meta_path", meta_path)
|
|
111
108
|
let meta = (await this.kernel.loader.load(meta_path)).resolved
|
|
112
109
|
if (!meta) meta = {}
|
|
113
110
|
if (formData.title) {
|
|
@@ -128,13 +125,11 @@ class Server {
|
|
|
128
125
|
//
|
|
129
126
|
// write icon file
|
|
130
127
|
let icon_path = this.kernel.path("api", formData.new_path, formData.icon_path)
|
|
131
|
-
console.log({ icon_path })
|
|
132
128
|
await fs.promises.writeFile(icon_path, formData.avatar)
|
|
133
129
|
meta.icon = formData.icon_path
|
|
134
130
|
dirty = true
|
|
135
131
|
}
|
|
136
132
|
if (dirty) {
|
|
137
|
-
console.log("Save", meta_path, meta)
|
|
138
133
|
await fs.promises.writeFile(meta_path, JSON.stringify(meta, null, 2))
|
|
139
134
|
}
|
|
140
135
|
}
|
|
@@ -516,6 +511,12 @@ class Server {
|
|
|
516
511
|
execUrl: "/api/" + name,
|
|
517
512
|
// rawpath,
|
|
518
513
|
}
|
|
514
|
+
if (!this.kernel.proto.config) {
|
|
515
|
+
await this.kernel.proto.init()
|
|
516
|
+
}
|
|
517
|
+
if (!this.kernel.plugin.config) {
|
|
518
|
+
await this.kernel.plugin.init()
|
|
519
|
+
}
|
|
519
520
|
res.render("app", result)
|
|
520
521
|
}
|
|
521
522
|
getVariationUrls(req) {
|
|
@@ -1006,7 +1007,6 @@ class Server {
|
|
|
1006
1007
|
script_path: (req.base ? full_filepath : null),
|
|
1007
1008
|
}
|
|
1008
1009
|
|
|
1009
|
-
|
|
1010
1010
|
res.render(template, result)
|
|
1011
1011
|
}
|
|
1012
1012
|
|
|
@@ -1186,8 +1186,6 @@ class Server {
|
|
|
1186
1186
|
pinokioPath = `pinokio://?uri=${gitRemote}/${pathComponents.slice(1).join("/")}`
|
|
1187
1187
|
}
|
|
1188
1188
|
|
|
1189
|
-
console.log("API.RUNNING", this.kernel.api.running)
|
|
1190
|
-
|
|
1191
1189
|
let running = []
|
|
1192
1190
|
let notRunning = []
|
|
1193
1191
|
if (pathComponents.length === 0) {
|
|
@@ -1257,7 +1255,6 @@ class Server {
|
|
|
1257
1255
|
for(let key in this.kernel.api.running) {
|
|
1258
1256
|
//let p = this.kernel.path("api", items[i].name) + path.sep
|
|
1259
1257
|
let p = this.kernel.path("api", items[i].name)
|
|
1260
|
-
console.log({ key, p })
|
|
1261
1258
|
|
|
1262
1259
|
//let re = new RegExp(items[i].name)
|
|
1263
1260
|
//if (re.test(key)) {
|
|
@@ -1542,6 +1539,49 @@ class Server {
|
|
|
1542
1539
|
}
|
|
1543
1540
|
|
|
1544
1541
|
|
|
1542
|
+
renderMenu2(config, base, keypath) {
|
|
1543
|
+
// when the config has not loaded yet
|
|
1544
|
+
if (!config) {
|
|
1545
|
+
return { menu: [] }
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
if (config.menu) {
|
|
1549
|
+
for(let i=0; i<config.menu.length; i++) {
|
|
1550
|
+
let item = config.menu[i]
|
|
1551
|
+
let new_keypath
|
|
1552
|
+
if (keypath) {
|
|
1553
|
+
new_keypath = keypath.concat(i)
|
|
1554
|
+
} else {
|
|
1555
|
+
new_keypath = [i]
|
|
1556
|
+
}
|
|
1557
|
+
let c = this.renderMenu2(item, base, new_keypath)
|
|
1558
|
+
config.menu[i] = c
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
if (config.text) {
|
|
1562
|
+
if (config.hasOwnProperty("icon")) {
|
|
1563
|
+
config.html = `<i class="${config.icon}"></i> ${config.text}`
|
|
1564
|
+
} else if (config.hasOwnProperty("image")) {
|
|
1565
|
+
let imagePath = `${base.path}/${config.image}`
|
|
1566
|
+
config.html = `<img class='menu-item-image' src='${imagePath}' /> ${config.text}`
|
|
1567
|
+
} else {
|
|
1568
|
+
config.html = `${config.text}`
|
|
1569
|
+
}
|
|
1570
|
+
config.btn = config.html
|
|
1571
|
+
}
|
|
1572
|
+
/*
|
|
1573
|
+
if (config.href && !config.href.startsWith("/")) {
|
|
1574
|
+
if (base.href) {
|
|
1575
|
+
config.href = base.href + "/" + config.href
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
*/
|
|
1579
|
+
if (keypath) {
|
|
1580
|
+
config.href = base.href + "/" + keypath.join("/") + "?path=" + base.cwd
|
|
1581
|
+
}
|
|
1582
|
+
return config
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1545
1585
|
async renderMenu(uri, name, config, pathComponents, indexPath) {
|
|
1546
1586
|
if (config.menu) {
|
|
1547
1587
|
|
|
@@ -1579,7 +1619,7 @@ class Server {
|
|
|
1579
1619
|
menuitem.menu = m.menu
|
|
1580
1620
|
}
|
|
1581
1621
|
|
|
1582
|
-
if (menuitem.base
|
|
1622
|
+
if (menuitem.base && menuitem.base.startsWith("/")) {
|
|
1583
1623
|
config.menu[i].href = menuitem.base + menuitem.href
|
|
1584
1624
|
} else {
|
|
1585
1625
|
if (menuitem.href && !menuitem.href.startsWith("http")) {
|
|
@@ -2547,6 +2587,12 @@ class Server {
|
|
|
2547
2587
|
// return
|
|
2548
2588
|
// }
|
|
2549
2589
|
|
|
2590
|
+
if (!this.kernel.proto.config) {
|
|
2591
|
+
await this.kernel.proto.init()
|
|
2592
|
+
}
|
|
2593
|
+
if (!this.kernel.plugin.config) {
|
|
2594
|
+
await this.kernel.plugin.init()
|
|
2595
|
+
}
|
|
2550
2596
|
|
|
2551
2597
|
if (req.query.mode !== "settings" && !home) {
|
|
2552
2598
|
res.redirect("/?mode=settings")
|
|
@@ -2845,7 +2891,6 @@ class Server {
|
|
|
2845
2891
|
//Util.openfs(req.body.path, req.body.mode)
|
|
2846
2892
|
let cwd = req.body.cwd
|
|
2847
2893
|
let cmd = req.body.run
|
|
2848
|
-
console.log({ cmd, cwd })
|
|
2849
2894
|
Util.run(cmd, cwd, this.kernel)
|
|
2850
2895
|
res.json({ success: true })
|
|
2851
2896
|
}))
|
|
@@ -3483,22 +3528,34 @@ class Server {
|
|
|
3483
3528
|
}))
|
|
3484
3529
|
this.app.get("/prototype/show/*", ex(async (req, res) => {
|
|
3485
3530
|
let name = req.params[0].split("/").filter((x) => { return x }).join("/")
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3531
|
+
|
|
3532
|
+
// print readme
|
|
3533
|
+
|
|
3534
|
+
|
|
3535
|
+
|
|
3536
|
+
|
|
3537
|
+
let paths = req.params[0].split("/")
|
|
3538
|
+
let item
|
|
3539
|
+
let config = this.kernel.proto.config
|
|
3540
|
+
for(let key of paths) {
|
|
3541
|
+
config = config.menu[key]
|
|
3542
|
+
}
|
|
3543
|
+
let run_path = "/run/prototype/system/" + config.href + "?cwd=" + req.query.path
|
|
3544
|
+
console.log({ config, run_path, query: req.query })
|
|
3545
|
+
let readme_path = this.kernel.path("prototype/system", config.readme)
|
|
3546
|
+
console.log("config.readme.split", config.readme.split("/").slice(0, -1))
|
|
3547
|
+
let md = await fs.promises.readFile(readme_path, "utf8")
|
|
3548
|
+
console.log({ readme_path, md })
|
|
3549
|
+
let baseUrl = "/asset/prototype/system/" + (config.readme.split("/").slice(0, -1).join("/")) + "/"
|
|
3550
|
+
console.log("baseUrl", baseUrl)
|
|
3551
|
+
let readme = marked.parse(md, {
|
|
3552
|
+
baseUrl
|
|
3553
|
+
})
|
|
3554
|
+
|
|
3491
3555
|
res.render("prototype/show", {
|
|
3492
|
-
|
|
3493
|
-
path: req.query.path,
|
|
3494
|
-
icon,
|
|
3495
|
-
title,
|
|
3496
|
-
description,
|
|
3497
|
-
name,
|
|
3498
|
-
prototype_path: name,
|
|
3556
|
+
run_path,
|
|
3499
3557
|
portal: this.portal,
|
|
3500
3558
|
readme,
|
|
3501
|
-
items: this.kernel.proto.items.filter(item => item.type === 'init'),
|
|
3502
3559
|
logo: this.logo,
|
|
3503
3560
|
theme: this.theme,
|
|
3504
3561
|
agent: this.agent,
|
|
@@ -3507,11 +3564,11 @@ class Server {
|
|
|
3507
3564
|
}))
|
|
3508
3565
|
this.app.get("/prototype", ex(async (req, res) => {
|
|
3509
3566
|
// load meta
|
|
3510
|
-
let config = await this.kernel.api.meta({ path: req.query.path })
|
|
3511
|
-
let items = this.kernel.proto.items
|
|
3512
|
-
if (req.query.type) {
|
|
3513
|
-
items = this.kernel.proto.items.filter(item => item.type === req.query.type)
|
|
3514
|
-
}
|
|
3567
|
+
// let config = await this.kernel.api.meta({ path: req.query.path })
|
|
3568
|
+
// let items = this.kernel.proto.items
|
|
3569
|
+
// if (req.query.type) {
|
|
3570
|
+
// items = this.kernel.proto.items.filter(item => item.type === req.query.type)
|
|
3571
|
+
// }
|
|
3515
3572
|
let title
|
|
3516
3573
|
let description
|
|
3517
3574
|
if (req.query.type === "init") {
|
|
@@ -3521,14 +3578,38 @@ class Server {
|
|
|
3521
3578
|
title = "Extensions"
|
|
3522
3579
|
description = "Add extension modules to the current folder"
|
|
3523
3580
|
}
|
|
3581
|
+
|
|
3582
|
+
let config = structuredClone(this.kernel.proto.config)
|
|
3583
|
+
config = this.renderMenu2(config, {
|
|
3584
|
+
cwd: req.query.path,
|
|
3585
|
+
href: "/prototype/show",
|
|
3586
|
+
path: "/asset/prototype/system"
|
|
3587
|
+
})
|
|
3588
|
+
|
|
3589
|
+
// {
|
|
3590
|
+
// "icon": "fa-solid fa-power-off",
|
|
3591
|
+
// "text": "Run Default",
|
|
3592
|
+
// "href": "/api/facefusion-pinokio.git/run.js?run=true&fullscreen=true&mode=Default",
|
|
3593
|
+
// "params": {
|
|
3594
|
+
// "run": true,
|
|
3595
|
+
// "fullscreen": true,
|
|
3596
|
+
// "mode": "Default"
|
|
3597
|
+
// },
|
|
3598
|
+
// "src": "/api/facefusion-pinokio.git/run.js",
|
|
3599
|
+
// "html": "<i class=\"fa-solid fa-power-off\"></i> Run Default",
|
|
3600
|
+
// "btn": "<i class=\"fa-solid fa-power-off\"></i> Run Default",
|
|
3601
|
+
// "target": "@/api/facefusion-pinokio.git/run.js"
|
|
3602
|
+
// },
|
|
3603
|
+
//
|
|
3524
3604
|
res.render("prototype/index", {
|
|
3525
3605
|
title,
|
|
3526
3606
|
description,
|
|
3527
3607
|
config,
|
|
3528
3608
|
path: req.query.path,
|
|
3529
3609
|
portal: this.portal,
|
|
3530
|
-
items,
|
|
3610
|
+
// items,
|
|
3531
3611
|
logo: this.logo,
|
|
3612
|
+
platform: this.kernel.platform,
|
|
3532
3613
|
theme: this.theme,
|
|
3533
3614
|
agent: this.agent,
|
|
3534
3615
|
kernel: this.kernel,
|
|
@@ -4291,10 +4372,8 @@ class Server {
|
|
|
4291
4372
|
*/
|
|
4292
4373
|
|
|
4293
4374
|
let formData = req.body
|
|
4294
|
-
console.log("req.files", req.files)
|
|
4295
4375
|
for(let key in req.files) {
|
|
4296
4376
|
let file = req.files[key]
|
|
4297
|
-
console.log({ key, file })
|
|
4298
4377
|
formData[file.fieldname] = file.buffer
|
|
4299
4378
|
}
|
|
4300
4379
|
console.log({ formData })
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
const FSEditor = async ({title, description, old_path, icon, iconpath, redirect, copy, move, edit }) => {
|
|
2
|
-
console.log({ icon, iconpath })
|
|
3
2
|
const compare = async (file1, file2) => {
|
|
4
3
|
if (file1.size !== file2.size) return false;
|
|
5
|
-
console.log({ file1, file2 })
|
|
6
4
|
const buffer1 = await file1.arrayBuffer();
|
|
7
5
|
const buffer2 = await file2.arrayBuffer();
|
|
8
6
|
const view1 = new Uint8Array(buffer1);
|
|
@@ -49,11 +47,11 @@ const FSEditor = async ({title, description, old_path, icon, iconpath, redirect,
|
|
|
49
47
|
${folderpath_html}
|
|
50
48
|
<div class='folder-row ${meta_class}'>
|
|
51
49
|
<label for='new-folder-title'>Title</label>
|
|
52
|
-
<input id="new-folder-title" class="swal2-input" placeholder="
|
|
50
|
+
<input id="new-folder-title" class="swal2-input" placeholder="Project Name (stored in pinokio.js)" value="${title}" />
|
|
53
51
|
</div>
|
|
54
52
|
<div class='folder-row ${meta_class}'>
|
|
55
53
|
<label for='new-folder-description'>Description</label>
|
|
56
|
-
<textarea id="new-folder-description" class="swal2-input" placeholder="
|
|
54
|
+
<textarea id="new-folder-description" class="swal2-input" placeholder="Project Description (stored in pinokio.js)">${description}</textarea>
|
|
57
55
|
</div>
|
|
58
56
|
</div>
|
|
59
57
|
</div>`,
|
|
@@ -103,8 +101,6 @@ const FSEditor = async ({title, description, old_path, icon, iconpath, redirect,
|
|
|
103
101
|
// url: '/pinokio/upload', // optional if same as above
|
|
104
102
|
process: async (fieldName, file, metadata, load, error, progress, abort) => {
|
|
105
103
|
const formData = new FormData();
|
|
106
|
-
|
|
107
|
-
console.log("upload", { dirty, file })
|
|
108
104
|
formData.append('avatar', file)
|
|
109
105
|
if (dirty) {
|
|
110
106
|
formData.append("icon_dirty", true)
|
|
@@ -128,7 +124,6 @@ const FSEditor = async ({title, description, old_path, icon, iconpath, redirect,
|
|
|
128
124
|
path = old_path
|
|
129
125
|
formData.append("new_path", old_path)
|
|
130
126
|
}
|
|
131
|
-
debugger
|
|
132
127
|
if (mode === "copy") {
|
|
133
128
|
formData.append("copy", true)
|
|
134
129
|
} else if (mode === "move") {
|
|
@@ -165,8 +160,6 @@ const FSEditor = async ({title, description, old_path, icon, iconpath, redirect,
|
|
|
165
160
|
}
|
|
166
161
|
},
|
|
167
162
|
onaddfile(error, file) {
|
|
168
|
-
console.log({ file, initial_file })
|
|
169
|
-
debugger
|
|
170
163
|
if (initial_file) {
|
|
171
164
|
compare(initial_file.file, file.file).then((same) => {
|
|
172
165
|
if (same) {
|