pinokiod 0.1.47 → 0.1.49
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/fs/index.js +70 -27
- package/package.json +2 -2
- package/server/views/browser.ejs +32 -13
- package/server/views/partials/menu.ejs +2 -0
package/kernel/api/fs/index.js
CHANGED
|
@@ -39,38 +39,81 @@ class FS {
|
|
|
39
39
|
async share(req, ondata, kernel) {
|
|
40
40
|
/////////////////////////////////////////////////////////////////////////////
|
|
41
41
|
//
|
|
42
|
+
// 1. 1:1 Interface mapping (1 interface, 1 file path)
|
|
42
43
|
// {
|
|
43
44
|
// “method”: “fs.share”,
|
|
44
45
|
// “params”: {
|
|
45
|
-
// "
|
|
46
|
-
//
|
|
46
|
+
// "interface": {
|
|
47
|
+
// “models/checkpoints": "app/models/checkpoints",
|
|
48
|
+
// “models/vae": "app/models/VAE",
|
|
49
|
+
// },
|
|
50
|
+
// “peers”: [ “https://github.com/cocktailpeanut/comfyui.git" ]
|
|
51
|
+
// }
|
|
52
|
+
// }
|
|
53
|
+
//
|
|
54
|
+
//
|
|
55
|
+
// 2. 1:N Interface mapping (1 interface, N file paths)
|
|
56
|
+
// {
|
|
57
|
+
// “method”: “fs.share”,
|
|
58
|
+
// “params”: {
|
|
59
|
+
// "interface": {
|
|
60
|
+
// “models/checkpoints": "app/models/checkpoints",
|
|
61
|
+
// “models/loras": [ "app/models/Lora", "app/models/LyCORIS" ],
|
|
62
|
+
// },
|
|
47
63
|
// “peers”: [ “https://github.com/cocktailpeanut/comfyui.git" ]
|
|
48
64
|
// }
|
|
49
65
|
// }
|
|
50
66
|
//
|
|
51
67
|
/////////////////////////////////////////////////////////////////////////////
|
|
52
68
|
|
|
53
|
-
console.log("fs.share", req)
|
|
54
|
-
|
|
55
69
|
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
if (req.params.interface) {
|
|
71
|
+
const drivePath = kernel.path("drive")
|
|
72
|
+
const drive = new Pdrive(drivePath)
|
|
73
|
+
for(const route in req.params.interface) {
|
|
74
|
+
const link = req.params.interface[route]
|
|
75
|
+
// Link path validation
|
|
76
|
+
if (Array.isArray(link)) {
|
|
77
|
+
let toContinue = false;
|
|
78
|
+
for(let ln of link) {
|
|
79
|
+
if (path.isAbsolute(ln) || ln.startsWith(".")) {
|
|
80
|
+
toContinue = true
|
|
81
|
+
break
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (toContinue) continue
|
|
85
|
+
} else {
|
|
86
|
+
if (path.isAbsolute(link) || link.startsWith(".")) {
|
|
87
|
+
continue
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Interface path validation
|
|
91
|
+
if (path.isAbsolute(route) || route.startsWith(".")) {
|
|
92
|
+
toContinue = true
|
|
93
|
+
break
|
|
94
|
+
}
|
|
62
95
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
96
|
+
let linkPath
|
|
97
|
+
if (Array.isArray(link)) {
|
|
98
|
+
linkPath = link.map((ln) => {
|
|
99
|
+
return path.resolve(req.cwd, ln)
|
|
100
|
+
})
|
|
101
|
+
} else {
|
|
102
|
+
linkPath = path.resolve(req.cwd, link)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
req.params.interface[route] = linkPath
|
|
106
|
+
}
|
|
107
|
+
await drive.create({
|
|
108
|
+
uri: req.parent.git,
|
|
109
|
+
interface: req.params.interface,
|
|
110
|
+
peers: (req.params.peers ? req.params.peers : [])
|
|
111
|
+
})
|
|
112
|
+
ondata({ raw: `\r\nDone!` })
|
|
113
|
+
} else {
|
|
114
|
+
ondata({ raw: `\r\nMust pass an 'interface' mapping` })
|
|
115
|
+
}
|
|
66
116
|
|
|
67
|
-
ondata({ raw: `\r\nLinking ${fsPath} to ${drivePath}...\r\n` })
|
|
68
|
-
await drive.create(fsPath, {
|
|
69
|
-
uri: req.parent.git,
|
|
70
|
-
path: req.params.drive,
|
|
71
|
-
peers: (req.params.peers ? req.params.peers : [])
|
|
72
|
-
})
|
|
73
|
-
ondata({ raw: `\r\nDone!` })
|
|
74
117
|
}
|
|
75
118
|
async rm(req, ondata, kernel) {
|
|
76
119
|
let cwd = (req.cwd ? req.cwd : kernel.api.userdir)
|
|
@@ -239,7 +282,7 @@ class FS {
|
|
|
239
282
|
})
|
|
240
283
|
dl.on('error', (err) => {
|
|
241
284
|
console.log('Download Failed', err)
|
|
242
|
-
ondata({ raw: `\r\
|
|
285
|
+
ondata({ raw: `\r\n[Download Failed] ${err.message}!\r\n` })
|
|
243
286
|
reject(err)
|
|
244
287
|
})
|
|
245
288
|
dl.on('progress', (stats) => {
|
|
@@ -254,18 +297,18 @@ class FS {
|
|
|
254
297
|
ondata({ raw: `\r${str}` })
|
|
255
298
|
})
|
|
256
299
|
dl.on('download', (downloadInfo) => {
|
|
257
|
-
const msg = `\r\
|
|
300
|
+
const msg = `\r\n[Download Started] ${JSON.stringify({ name: downloadInfo.fileName, total: downloadInfo.totalSize })}\r\n`
|
|
258
301
|
console.log(msg)
|
|
259
302
|
ondata({ raw: msg })
|
|
260
303
|
})
|
|
261
304
|
dl.on('skip', (skipInfo) => {
|
|
262
|
-
const msg = `\r\
|
|
305
|
+
const msg = `\r\n[Download Skipped] File already exists: ${JSON.stringify(skipInfo)}\r\n`
|
|
263
306
|
console.log(msg)
|
|
264
307
|
ondata({ raw: msg })
|
|
265
308
|
resolve()
|
|
266
309
|
})
|
|
267
310
|
dl.on('retry', (attempt, opts, err) => {
|
|
268
|
-
const msg = "\r\
|
|
311
|
+
const msg = "\r\n[Retrying] " + JSON.stringify({
|
|
269
312
|
RetryAttempt: `${attempt}/${opts.maxRetries}`,
|
|
270
313
|
StartsOn: `${opts.delay / 1000} secs`,
|
|
271
314
|
Reason: err ? err.message : 'unknown'
|
|
@@ -274,19 +317,19 @@ class FS {
|
|
|
274
317
|
ondata({ raw: msg })
|
|
275
318
|
})
|
|
276
319
|
dl.on('stateChanged', (state) => {
|
|
277
|
-
const msg = "\r\
|
|
320
|
+
const msg = "\r\n[State changed] " + state + "\r\n"
|
|
278
321
|
console.log(msg)
|
|
279
322
|
ondata({ raw: msg })
|
|
280
323
|
})
|
|
281
324
|
dl.on('redirected', (newUrl, oldUrl) => {
|
|
282
|
-
const msg = `\r\
|
|
325
|
+
const msg = `\r\n[Redirected] '${oldUrl}' => '${newUrl}'\r\n`
|
|
283
326
|
console.log(msg)
|
|
284
327
|
ondata({ raw: msg })
|
|
285
328
|
})
|
|
286
329
|
|
|
287
330
|
dl.start().catch((err) => {
|
|
288
331
|
console.log('Download Failed', err)
|
|
289
|
-
ondata({ raw: `\r\
|
|
332
|
+
ondata({ raw: `\r\n[Download Failed] ${err.message}!\r\n` })
|
|
290
333
|
reject(err)
|
|
291
334
|
})
|
|
292
335
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pinokiod",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.49",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"multer": "^1.4.5-lts.1",
|
|
41
41
|
"node-downloader-helper": "^2.1.9",
|
|
42
42
|
"node-pty-prebuilt-multiarch-cp": "^0.10.1-pre.48",
|
|
43
|
-
"pdrive": "^0.0.
|
|
43
|
+
"pdrive": "^0.0.8",
|
|
44
44
|
"portfinder": "^1.0.32",
|
|
45
45
|
"rimraf": "^5.0.0",
|
|
46
46
|
"sanitize-filename": "^1.6.3",
|
package/server/views/browser.ejs
CHANGED
|
@@ -149,7 +149,7 @@ body.dark #new-window {
|
|
|
149
149
|
text-align: center;;
|
|
150
150
|
font-weight: bold;
|
|
151
151
|
align-items: center;
|
|
152
|
-
padding:
|
|
152
|
+
padding: 20px 0px;
|
|
153
153
|
}
|
|
154
154
|
.app-info > * {
|
|
155
155
|
padding: 5px;
|
|
@@ -210,7 +210,11 @@ body.dark .frame-link.selected {
|
|
|
210
210
|
}
|
|
211
211
|
.frame-link .tab {
|
|
212
212
|
flex-grow: 1;
|
|
213
|
+
/*
|
|
213
214
|
width: 100%;
|
|
215
|
+
*/
|
|
216
|
+
word-break: break-word;
|
|
217
|
+
margin-right: 10px;
|
|
214
218
|
}
|
|
215
219
|
.frame-link .tab .flexible {
|
|
216
220
|
min-width: 5px;
|
|
@@ -419,16 +423,6 @@ const renderSelection = (e, force) => {
|
|
|
419
423
|
document.querySelector(".bar").classList.remove("hidden")
|
|
420
424
|
let id = getTarget(location.hash.slice(1))
|
|
421
425
|
|
|
422
|
-
//document.querySelector("#location").innerHTML = id
|
|
423
|
-
document.querySelector("#location").innerHTML = location.hash.slice(1)
|
|
424
|
-
|
|
425
|
-
if (location.hash.slice(1).startsWith("/")) {
|
|
426
|
-
document.querySelector("#open-browser").classList.add("hidden")
|
|
427
|
-
} else {
|
|
428
|
-
document.querySelector("#open-browser").classList.remove("hidden")
|
|
429
|
-
//document.querySelector("#open-browser").href = id
|
|
430
|
-
document.querySelector("#open-browser").href = location.hash.slice(1)
|
|
431
|
-
}
|
|
432
426
|
|
|
433
427
|
// select the selected link
|
|
434
428
|
// document.querySelectorAll(".frame-link").forEach((el) => {
|
|
@@ -447,7 +441,27 @@ const renderSelection = (e, force) => {
|
|
|
447
441
|
}
|
|
448
442
|
}
|
|
449
443
|
|
|
444
|
+
|
|
445
|
+
if (!target) {
|
|
446
|
+
// find target by id
|
|
447
|
+
target = document.querySelector("aside [target='" + id + "']")
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
debugger
|
|
450
451
|
if (target) {
|
|
452
|
+
|
|
453
|
+
//document.querySelector("#location").innerHTML = id
|
|
454
|
+
document.querySelector("#location").innerHTML = location.hash.slice(1)
|
|
455
|
+
|
|
456
|
+
if (location.hash.slice(1).startsWith("/")) {
|
|
457
|
+
document.querySelector("#open-browser").classList.add("hidden")
|
|
458
|
+
} else {
|
|
459
|
+
document.querySelector("#open-browser").classList.remove("hidden")
|
|
460
|
+
//document.querySelector("#open-browser").href = id
|
|
461
|
+
document.querySelector("#open-browser").href = location.hash.slice(1)
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
|
|
451
465
|
target.classList.add("selected")
|
|
452
466
|
|
|
453
467
|
// select the iframe
|
|
@@ -469,9 +483,9 @@ const renderSelection = (e, force) => {
|
|
|
469
483
|
}
|
|
470
484
|
} else {
|
|
471
485
|
if (force) {
|
|
472
|
-
if (targetFrame.src !== target.href) {
|
|
486
|
+
// if (targetFrame.src !== target.href) {
|
|
473
487
|
targetFrame.src = target.href
|
|
474
|
-
}
|
|
488
|
+
// }
|
|
475
489
|
}
|
|
476
490
|
}
|
|
477
491
|
} else {
|
|
@@ -494,6 +508,11 @@ const renderSelection = (e, force) => {
|
|
|
494
508
|
document.querySelector("main").appendChild(frame)
|
|
495
509
|
loaded[target.target] = true
|
|
496
510
|
}
|
|
511
|
+
} else {
|
|
512
|
+
// couldn't find item,
|
|
513
|
+
// clear the hash
|
|
514
|
+
//
|
|
515
|
+
location.hash = ""
|
|
497
516
|
}
|
|
498
517
|
} else {
|
|
499
518
|
document.querySelector(".bar").classList.add("hidden")
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
<a data-index="<%=index%>" target="<%=item.src%>" href="<%=item.href%>" class='btn header-item frame-link'>
|
|
14
14
|
<div class='tab'><%-item.btn%></div>
|
|
15
15
|
<% if (item.running) { %>
|
|
16
|
+
<div class='loader'>
|
|
16
17
|
<i class='fa-solid fa-spin fa-circle-notch'></i>
|
|
18
|
+
</div>
|
|
17
19
|
<% } %>
|
|
18
20
|
</a>
|
|
19
21
|
<% } %>
|