pinokiod 0.1.45 → 0.1.47

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.
@@ -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,45 @@ class FS {
30
33
  // }
31
34
  // await decompress(...req.params)
32
35
  // }
36
+
37
+
38
+
39
+ async share(req, ondata, kernel) {
40
+ /////////////////////////////////////////////////////////////////////////////
41
+ //
42
+ // {
43
+ // “method”: “fs.share”,
44
+ // “params”: {
45
+ // "fs": "app/models/checkpoints",
46
+ // “drive": “models/checkpoints",
47
+ // “peers”: [ “https://github.com/cocktailpeanut/comfyui.git" ]
48
+ // }
49
+ // }
50
+ //
51
+ /////////////////////////////////////////////////////////////////////////////
52
+
53
+ console.log("fs.share", req)
54
+
55
+
56
+ if (path.isAbsolute(req.params.fs) || req.params.fs.startsWith(".")) {
57
+ return
58
+ }
59
+ if (path.isAbsolute(req.params.drive) || req.params.drive.startsWith(".")) {
60
+ return
61
+ }
62
+
63
+ const drivePath = kernel.path("drive")
64
+ const drive = new Pdrive(drivePath)
65
+ const fsPath = path.resolve(req.cwd, req.params.fs)
66
+
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
+ }
33
75
  async rm(req, ondata, kernel) {
34
76
  let cwd = (req.cwd ? req.cwd : kernel.api.userdir)
35
77
  let filepath = path.resolve(cwd, req.params.path)
@@ -161,6 +203,10 @@ class FS {
161
203
  console.log("folder", folder)
162
204
  await fs.promises.mkdir(folder, { recursive: true }).catch((e) => { })
163
205
  dl = new DownloaderHelper(url, folder, {
206
+ override: {
207
+ skip: true,
208
+ skipSmaller: false,
209
+ },
164
210
  resumeIfFileExists: true,
165
211
  removeOnStop: false,
166
212
  removeOnFail: false,
@@ -173,6 +219,10 @@ class FS {
173
219
  await fs.promises.mkdir(folder, { recursive: true }).catch((e) => { })
174
220
  let filename = path.basename(filepath)
175
221
  dl = new DownloaderHelper(url, folder, {
222
+ override: {
223
+ skip: true,
224
+ skipSmaller: false,
225
+ },
176
226
  fileName: filename,
177
227
  resumeIfFileExists: true,
178
228
  removeOnStop: false,
@@ -203,6 +253,37 @@ class FS {
203
253
  }
204
254
  ondata({ raw: `\r${str}` })
205
255
  })
256
+ dl.on('download', (downloadInfo) => {
257
+ const msg = `\r\nDownload Begins: ${JSON.stringify({ name: downloadInfo.fileName, total: downloadInfo.totalSize })}\r\n`
258
+ console.log(msg)
259
+ ondata({ raw: msg })
260
+ })
261
+ dl.on('skip', (skipInfo) => {
262
+ const msg = `\r\nDownload skipped, file already exists: ${JSON.stringify(skipInfo)}\r\n`
263
+ console.log(msg)
264
+ ondata({ raw: msg })
265
+ resolve()
266
+ })
267
+ dl.on('retry', (attempt, opts, err) => {
268
+ const msg = "\r\nRetrying... " + JSON.stringify({
269
+ RetryAttempt: `${attempt}/${opts.maxRetries}`,
270
+ StartsOn: `${opts.delay / 1000} secs`,
271
+ Reason: err ? err.message : 'unknown'
272
+ }) + "\r\n";
273
+ console.log(msg)
274
+ ondata({ raw: msg })
275
+ })
276
+ dl.on('stateChanged', (state) => {
277
+ const msg = "\r\nstate changed: " + state + "\r\n"
278
+ console.log(msg)
279
+ ondata({ raw: msg })
280
+ })
281
+ dl.on('redirected', (newUrl, oldUrl) => {
282
+ const msg = `\r\nRedirect from '${newUrl}' => '${oldUrl}'\r\n`
283
+ console.log(msg)
284
+ ondata({ raw: msg })
285
+ })
286
+
206
287
  dl.start().catch((err) => {
207
288
  console.log('Download Failed', err)
208
289
  ondata({ raw: `\r\nDownload Failed: ${err.message}!\r\n` })
@@ -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.45",
3
+ "version": "0.1.47",
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.1",
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",
@@ -332,21 +332,9 @@ body.dark #new-tab {
332
332
  </a>
333
333
  </div>
334
334
  <div class='menu'>
335
+ <% if (config.menu) { %>
335
336
  <%- 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
- -->
337
+ <% } %>
350
338
  </div>
351
339
  <div class='temp-menu'>
352
340
  <%tabs.forEach((tab) => { %>
@@ -391,14 +379,13 @@ body.dark #new-tab {
391
379
  -->
392
380
  </nav>
393
381
  <main class='browserview'>
394
- <!--
395
- <pre><%=JSON.stringify({ memory, running }, null, 2)%></pre>
396
- <% config.menu.forEach((item) => { %>
397
- <% if (item.btn && item.src) { %>
398
- <iframe name='<%=item.src%>' class='hidden'></iframe>
399
- <% } %>
400
- <% }) %>
401
- -->
382
+ <% if (false && config.menu) { %>
383
+ <% config.menu.forEach((item) => { %>
384
+ <% if (item.btn && item.src) { %>
385
+ <iframe name='<%=item.src%>' class='hidden'></iframe>
386
+ <% } %>
387
+ <% }) %>
388
+ <% } %>
402
389
  </main>
403
390
  </div>
404
391
  <script>
@@ -626,12 +626,14 @@ document.addEventListener("DOMContentLoaded", async () => {
626
626
  <% } %>
627
627
  <% } %>
628
628
  <% } %>
629
+ /*
629
630
  document.querySelector("#explore").addEventListener("click", async (e) => {
630
631
  e.preventDefault()
631
632
  e.stopPropagation()
632
633
  location.href = "/?mode=explore"
633
634
  })
634
635
  Reporter()
636
+ */
635
637
  document.querySelector(".memory").addEventListener("click", async (e) => {
636
638
  let target = e.target.classList.contains("tunnel") ? e.target : e.target.closest(".tunnel")
637
639
  let target2 = e.target.classList.contains("tunnel-stop") ? e.target : e.target.closest(".tunnel-stop")
@@ -705,11 +707,13 @@ const reloadMemory = async () => {
705
707
  <a class='path' href="<%=path.path%>"><%-path.name%></a>
706
708
  <% } %>
707
709
  <% }) %>
710
+ <!--
708
711
  <div class='flexible'></div>
709
712
  <button class='btn2' id='explore'><div><i class="fa-solid fa-globe"></i></div><div>Discover</div></button>
710
713
  <button class='btn2' id='report'><div><i class="fa-solid fa-bug"></i></div><div>Report Bug</div></button>
711
714
  <a class='btn2' href="/?mode=settings"><div><i class="fa-solid fa-gear"></i></div><div>Settings</div></a>
712
715
  <button id='new-window' title='open a new window'><i class="fa-solid fa-plus"></i></button>
716
+ -->
713
717
  </h1>
714
718
  <a class='gitremote' data-filepath="<%=filepath%>"><%=filepath%></a>
715
719
  <% if (pinokioPath) { %>