pinokiod 0.1.46 → 0.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.
- package/kernel/api/fs/index.js +126 -2
- package/kernel/api/index.js +12 -0
- package/package.json +3 -1
- package/server/views/browser.ejs +15 -23
- package/server/views/partials/menu.ejs +2 -0
package/kernel/api/fs/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
2
|
//const decompress = require('decompress');
|
|
3
3
|
const fs = require("fs")
|
|
4
|
+
const Pdrive = require('pdrive')
|
|
4
5
|
const { DownloaderHelper } = require('node-downloader-helper');
|
|
6
|
+
const symlinkDir = require('symlink-dir')
|
|
7
|
+
|
|
5
8
|
class FS {
|
|
6
9
|
async read(req, ondata, kernel) {
|
|
7
10
|
/*
|
|
@@ -30,6 +33,88 @@ class FS {
|
|
|
30
33
|
// }
|
|
31
34
|
// await decompress(...req.params)
|
|
32
35
|
// }
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
async share(req, ondata, kernel) {
|
|
40
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
41
|
+
//
|
|
42
|
+
// 1. 1:1 Interface mapping (1 interface, 1 file path)
|
|
43
|
+
// {
|
|
44
|
+
// “method”: “fs.share”,
|
|
45
|
+
// “params”: {
|
|
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
|
+
// },
|
|
63
|
+
// “peers”: [ “https://github.com/cocktailpeanut/comfyui.git" ]
|
|
64
|
+
// }
|
|
65
|
+
// }
|
|
66
|
+
//
|
|
67
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
68
|
+
|
|
69
|
+
|
|
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
|
+
}
|
|
95
|
+
|
|
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
|
+
}
|
|
116
|
+
|
|
117
|
+
}
|
|
33
118
|
async rm(req, ondata, kernel) {
|
|
34
119
|
let cwd = (req.cwd ? req.cwd : kernel.api.userdir)
|
|
35
120
|
let filepath = path.resolve(cwd, req.params.path)
|
|
@@ -161,6 +246,10 @@ class FS {
|
|
|
161
246
|
console.log("folder", folder)
|
|
162
247
|
await fs.promises.mkdir(folder, { recursive: true }).catch((e) => { })
|
|
163
248
|
dl = new DownloaderHelper(url, folder, {
|
|
249
|
+
override: {
|
|
250
|
+
skip: true,
|
|
251
|
+
skipSmaller: false,
|
|
252
|
+
},
|
|
164
253
|
resumeIfFileExists: true,
|
|
165
254
|
removeOnStop: false,
|
|
166
255
|
removeOnFail: false,
|
|
@@ -173,6 +262,10 @@ class FS {
|
|
|
173
262
|
await fs.promises.mkdir(folder, { recursive: true }).catch((e) => { })
|
|
174
263
|
let filename = path.basename(filepath)
|
|
175
264
|
dl = new DownloaderHelper(url, folder, {
|
|
265
|
+
override: {
|
|
266
|
+
skip: true,
|
|
267
|
+
skipSmaller: false,
|
|
268
|
+
},
|
|
176
269
|
fileName: filename,
|
|
177
270
|
resumeIfFileExists: true,
|
|
178
271
|
removeOnStop: false,
|
|
@@ -189,7 +282,7 @@ class FS {
|
|
|
189
282
|
})
|
|
190
283
|
dl.on('error', (err) => {
|
|
191
284
|
console.log('Download Failed', err)
|
|
192
|
-
ondata({ raw: `\r\
|
|
285
|
+
ondata({ raw: `\r\n[Download Failed] ${err.message}!\r\n` })
|
|
193
286
|
reject(err)
|
|
194
287
|
})
|
|
195
288
|
dl.on('progress', (stats) => {
|
|
@@ -203,9 +296,40 @@ class FS {
|
|
|
203
296
|
}
|
|
204
297
|
ondata({ raw: `\r${str}` })
|
|
205
298
|
})
|
|
299
|
+
dl.on('download', (downloadInfo) => {
|
|
300
|
+
const msg = `\r\n[Download Started] ${JSON.stringify({ name: downloadInfo.fileName, total: downloadInfo.totalSize })}\r\n`
|
|
301
|
+
console.log(msg)
|
|
302
|
+
ondata({ raw: msg })
|
|
303
|
+
})
|
|
304
|
+
dl.on('skip', (skipInfo) => {
|
|
305
|
+
const msg = `\r\n[Download Skipped] File already exists: ${JSON.stringify(skipInfo)}\r\n`
|
|
306
|
+
console.log(msg)
|
|
307
|
+
ondata({ raw: msg })
|
|
308
|
+
resolve()
|
|
309
|
+
})
|
|
310
|
+
dl.on('retry', (attempt, opts, err) => {
|
|
311
|
+
const msg = "\r\n[Retrying] " + JSON.stringify({
|
|
312
|
+
RetryAttempt: `${attempt}/${opts.maxRetries}`,
|
|
313
|
+
StartsOn: `${opts.delay / 1000} secs`,
|
|
314
|
+
Reason: err ? err.message : 'unknown'
|
|
315
|
+
}) + "\r\n";
|
|
316
|
+
console.log(msg)
|
|
317
|
+
ondata({ raw: msg })
|
|
318
|
+
})
|
|
319
|
+
dl.on('stateChanged', (state) => {
|
|
320
|
+
const msg = "\r\n[State changed] " + state + "\r\n"
|
|
321
|
+
console.log(msg)
|
|
322
|
+
ondata({ raw: msg })
|
|
323
|
+
})
|
|
324
|
+
dl.on('redirected', (newUrl, oldUrl) => {
|
|
325
|
+
const msg = `\r\n[Redirected] '${oldUrl}' => '${newUrl}'\r\n`
|
|
326
|
+
console.log(msg)
|
|
327
|
+
ondata({ raw: msg })
|
|
328
|
+
})
|
|
329
|
+
|
|
206
330
|
dl.start().catch((err) => {
|
|
207
331
|
console.log('Download Failed', err)
|
|
208
|
-
ondata({ raw: `\r\
|
|
332
|
+
ondata({ raw: `\r\n[Download Failed] ${err.message}!\r\n` })
|
|
209
333
|
reject(err)
|
|
210
334
|
})
|
|
211
335
|
})
|
package/kernel/api/index.js
CHANGED
|
@@ -140,6 +140,7 @@ class Api {
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
+
console.log("gitPath", this.gitPath)
|
|
143
144
|
}
|
|
144
145
|
denormalize(gitRemote) {
|
|
145
146
|
let denormalized
|
|
@@ -160,6 +161,16 @@ class Api {
|
|
|
160
161
|
return normalized
|
|
161
162
|
}
|
|
162
163
|
|
|
164
|
+
parentGitURI(requestPath) {
|
|
165
|
+
for(let repo in this.gitPath) {
|
|
166
|
+
let val = this.gitPath[repo]
|
|
167
|
+
if (requestPath.includes(val)) {
|
|
168
|
+
return repo
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return null
|
|
172
|
+
}
|
|
173
|
+
|
|
163
174
|
resolveWebPath(uri) {
|
|
164
175
|
let repos = Object.keys(this.gitPath)
|
|
165
176
|
let matched_repo = repos.filter((repo) => {
|
|
@@ -461,6 +472,7 @@ class Api {
|
|
|
461
472
|
rpc.parent = {
|
|
462
473
|
uri: request.uri,
|
|
463
474
|
path: request.path,
|
|
475
|
+
git: this.parentGitURI(request.path),
|
|
464
476
|
body: script
|
|
465
477
|
}
|
|
466
478
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pinokiod",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.48",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -40,12 +40,14 @@
|
|
|
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.8",
|
|
43
44
|
"portfinder": "^1.0.32",
|
|
44
45
|
"rimraf": "^5.0.0",
|
|
45
46
|
"sanitize-filename": "^1.6.3",
|
|
46
47
|
"semver": "^7.5.4",
|
|
47
48
|
"shell-path": "^2.0.0",
|
|
48
49
|
"sudo-prompt-programfiles-x86": "^9.2.8",
|
|
50
|
+
"symlink-dir": "^5.2.1",
|
|
49
51
|
"systeminformation": "^5.18.4",
|
|
50
52
|
"uuid": "^9.0.0",
|
|
51
53
|
"watcher": "^2.2.2",
|
package/server/views/browser.ejs
CHANGED
|
@@ -48,7 +48,9 @@ body.dark aside {
|
|
|
48
48
|
aside {
|
|
49
49
|
display: flex;
|
|
50
50
|
flex-direction: column;
|
|
51
|
+
/*
|
|
51
52
|
width: 200px;
|
|
53
|
+
*/
|
|
52
54
|
overflow: auto;
|
|
53
55
|
box-sizing: border-box;
|
|
54
56
|
}
|
|
@@ -149,7 +151,7 @@ body.dark #new-window {
|
|
|
149
151
|
text-align: center;;
|
|
150
152
|
font-weight: bold;
|
|
151
153
|
align-items: center;
|
|
152
|
-
padding:
|
|
154
|
+
padding: 20px 0px;
|
|
153
155
|
}
|
|
154
156
|
.app-info > * {
|
|
155
157
|
padding: 5px;
|
|
@@ -210,7 +212,10 @@ body.dark .frame-link.selected {
|
|
|
210
212
|
}
|
|
211
213
|
.frame-link .tab {
|
|
212
214
|
flex-grow: 1;
|
|
215
|
+
/*
|
|
213
216
|
width: 100%;
|
|
217
|
+
*/
|
|
218
|
+
margin-right: 5px;
|
|
214
219
|
}
|
|
215
220
|
.frame-link .tab .flexible {
|
|
216
221
|
min-width: 5px;
|
|
@@ -332,21 +337,9 @@ body.dark #new-tab {
|
|
|
332
337
|
</a>
|
|
333
338
|
</div>
|
|
334
339
|
<div class='menu'>
|
|
340
|
+
<% if (config.menu) { %>
|
|
335
341
|
<%- include('./partials/menu', { menu: config.menu }) %>
|
|
336
|
-
|
|
337
|
-
<% config.menu.forEach((item, index) => { %>
|
|
338
|
-
<% if (item.btn) { %>
|
|
339
|
-
<a data-index="<%=index+1%>" target="<%=item.src%>" href="<%=item.href%>" class='btn header-item frame-link'>
|
|
340
|
-
<div class='tab'><%-item.btn%></div>
|
|
341
|
-
<% if (item.running) { %>
|
|
342
|
-
<i class='fa-solid fa-spin fa-circle-notch'></i>
|
|
343
|
-
<% } %>
|
|
344
|
-
</a>
|
|
345
|
-
<% } else if (item.label) { %>
|
|
346
|
-
<label class='btn label header-item'><%-item.label%></label>
|
|
347
|
-
<% } %>
|
|
348
|
-
<% }) %>
|
|
349
|
-
-->
|
|
342
|
+
<% } %>
|
|
350
343
|
</div>
|
|
351
344
|
<div class='temp-menu'>
|
|
352
345
|
<%tabs.forEach((tab) => { %>
|
|
@@ -391,14 +384,13 @@ body.dark #new-tab {
|
|
|
391
384
|
-->
|
|
392
385
|
</nav>
|
|
393
386
|
<main class='browserview'>
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
<% } %>
|
|
400
|
-
<% }
|
|
401
|
-
-->
|
|
387
|
+
<% if (false && config.menu) { %>
|
|
388
|
+
<% config.menu.forEach((item) => { %>
|
|
389
|
+
<% if (item.btn && item.src) { %>
|
|
390
|
+
<iframe name='<%=item.src%>' class='hidden'></iframe>
|
|
391
|
+
<% } %>
|
|
392
|
+
<% }) %>
|
|
393
|
+
<% } %>
|
|
402
394
|
</main>
|
|
403
395
|
</div>
|
|
404
396
|
<script>
|
|
@@ -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
|
<% } %>
|