pinokiod 1.3.30 → 1.3.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "1.3.30",
3
+ "version": "1.3.33",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -156,6 +156,7 @@ class Server {
156
156
  menu: x.menu,
157
157
  shortcuts: x.shortcuts,
158
158
  index: x.index,
159
+ running_scripts: x.running_scripts,
159
160
  //icon: (x.isDirectory() ? "fa-solid fa-folder" : "fa-regular fa-file"),
160
161
  name,
161
162
  uri,
@@ -1036,6 +1037,7 @@ class Server {
1036
1037
 
1037
1038
  // check if there is a running process with this folder name
1038
1039
  let runningApps = new Set()
1040
+ console.log("running", this.kernel.api.running)
1039
1041
  for(let key in this.kernel.api.running) {
1040
1042
  let p = this.kernel.path("api", items[i].name) + path.sep
1041
1043
  //let re = new RegExp(items[i].name)
@@ -1044,6 +1046,11 @@ class Server {
1044
1046
  if (key.includes(p)) {
1045
1047
  items[i].running = true
1046
1048
  items[i].index = index
1049
+ if (items[i].running_scripts) {
1050
+ items[i].running_scripts.push({ path: path.relative(this.kernel.homedir, key), name: path.relative(p, key) })
1051
+ } else {
1052
+ items[i].running_scripts = [{ path: path.relative(this.kernel.homedir, key), name: path.relative(p, key) }]
1053
+ }
1047
1054
  index++;
1048
1055
  running.push(items[i])
1049
1056
  break
@@ -1081,6 +1088,8 @@ class Server {
1081
1088
  }
1082
1089
 
1083
1090
 
1091
+ console.log("running", JSON.stringify(running, null, 2))
1092
+
1084
1093
 
1085
1094
  res.render("index", {
1086
1095
  proxy: pinokio_proxy[0],
@@ -1364,6 +1373,8 @@ class Server {
1364
1373
  }
1365
1374
  config.menu = proxyMenu.concat(config.menu)
1366
1375
 
1376
+ console.log("MENU", JSON.stringify(config.menu, null, 2))
1377
+
1367
1378
 
1368
1379
  return config
1369
1380
  } else {
@@ -1711,6 +1722,7 @@ class Server {
1711
1722
  }
1712
1723
  }
1713
1724
  async start(options) {
1725
+ console.log("** start", options)
1714
1726
  this.debug = false
1715
1727
  if (options) {
1716
1728
  this.debug = options.debug
@@ -1752,11 +1764,13 @@ class Server {
1752
1764
  // check version from this.store
1753
1765
  let version = this.kernel.store.get("version")
1754
1766
  // if the version is different from package.json version, run update logic
1767
+ console.log({_homedir: this.kernel.homedir, version, pinokiod: this.version.pinokiod })
1755
1768
  if (this.kernel.homedir) {
1756
1769
  if (version === this.version.pinokiod) {
1757
1770
  console.log("version up to date")
1758
1771
  } else {
1759
1772
  // update the py module if it's already installed
1773
+ console.log("not up to date")
1760
1774
  let installed = await this.kernel.bin.mod.py.installed()
1761
1775
  console.log("py installed", installed)
1762
1776
  if (installed) {
@@ -1775,7 +1789,7 @@ class Server {
1775
1789
  this.kernel.store.set("version", this.version.pinokiod)
1776
1790
  console.log("RESTART")
1777
1791
  this.listening = true // set this.listening = true so all http connections get reset when restarting
1778
- this.start(this.debug)
1792
+ this.start({ debug: this.debug, browser: this.browser })
1779
1793
  }
1780
1794
  }
1781
1795
 
@@ -490,6 +490,16 @@ body.fullscreen .btn {
490
490
  color: royalblue;
491
491
  }
492
492
  */
493
+ .mini-btn {
494
+ /*
495
+ background: none;
496
+ */
497
+ margin-right: 10px;
498
+ padding: 4px 8px !important;
499
+ /*
500
+ border: 1px solid rgba(0,0,0,0.1);
501
+ */
502
+ }
493
503
  .runnables {
494
504
  padding: 20px;
495
505
  box-sizing: border-box;
@@ -933,6 +943,7 @@ body.dark .line .avatar i {
933
943
  .line .description {
934
944
  font-size: 13px;
935
945
  opacity: 0.8;
946
+ margin-bottom: 5px;
936
947
  }
937
948
  body.dark a.line {
938
949
  color: var(--dark-color);
@@ -343,10 +343,12 @@ body.dark nav {
343
343
  nav {
344
344
  display: none;
345
345
  background: white;
346
+ /*
346
347
  position: absolute;
347
348
  bottom: 0;
348
349
  left: 0;
349
350
  right: 0;
351
+ */
350
352
  /*
351
353
  padding: 5px;
352
354
  */
@@ -571,6 +573,17 @@ body.dark .loader-container {
571
573
  -->
572
574
  </aside>
573
575
  <div class='container'>
576
+ <main class='browserview'>
577
+ <% if (false) { %>
578
+ <% if (config.menu) { %>
579
+ <% config.menu.forEach((item) => { %>
580
+ <% if (item.btn && item.src) { %>
581
+ <iframe name='<%=item.src%>' class='hidden'></iframe>
582
+ <% } %>
583
+ <% }) %>
584
+ <% } %>
585
+ <% } %>
586
+ </main>
574
587
  <nav>
575
588
  <div class='bar'>
576
589
  <button class='btn2' id='menu-mobile'><i class="fa-solid fa-bars"></i></button>
@@ -602,17 +615,6 @@ body.dark .loader-container {
602
615
  <a class='btn2' href='https://twitter.com/cocktailpeanut' target="_blank"><div><i class="fa-brands fa-twitter"></i></div><div>Twitter</div></a>
603
616
  -->
604
617
  </nav>
605
- <main class='browserview'>
606
- <% if (false) { %>
607
- <% if (config.menu) { %>
608
- <% config.menu.forEach((item) => { %>
609
- <% if (item.btn && item.src) { %>
610
- <iframe name='<%=item.src%>' class='hidden'></iframe>
611
- <% } %>
612
- <% }) %>
613
- <% } %>
614
- <% } %>
615
- </main>
616
618
  </div>
617
619
  <script>
618
620
  let loaded = {}
@@ -1204,7 +1206,7 @@ document.querySelector("aside").addEventListener("click", async (e) => {
1204
1206
  let target
1205
1207
 
1206
1208
 
1207
- // delete
1209
+ // 1. handle delete
1208
1210
  if (e.target.classList.contains("del")) {
1209
1211
  target = e.target
1210
1212
  } else {
@@ -1227,98 +1229,128 @@ document.querySelector("aside").addEventListener("click", async (e) => {
1227
1229
  el.remove()
1228
1230
  // update tabs
1229
1231
  await syncTabs()
1232
+ return
1233
+ }
1230
1234
 
1235
+
1236
+ // 2. handle shudown
1237
+ if (e.target.classList.contains("shutdown")) {
1238
+ target = e.target
1231
1239
  } else {
1232
- // Select
1233
- if (e.target.classList.contains("frame-link")) {
1234
- target = e.target
1235
- } else {
1236
- target = e.target.closest(".frame-link")
1237
- }
1240
+ target = e.target.closest(".shutdown")
1241
+ }
1242
+ if (target) {
1243
+ e.preventDefault()
1244
+ e.stopPropagation()
1245
+ let link = target.closest("[href]")
1246
+ let src = new URL(link.href).pathname
1247
+ console.log("src", src)
1248
+ debugger
1249
+
1250
+ let socket = new Socket()
1251
+ socket.run({
1252
+ method: "kernel.api.stop",
1253
+ params: {
1254
+ uri: "~" + src
1255
+ }
1256
+ }, (packet) => {
1257
+ console.log("packet", packet)
1258
+ if (packet.type === "result") {
1259
+ socket.close()
1260
+ refresh(true)
1261
+ }
1262
+ })
1238
1263
 
1264
+ return
1265
+ }
1239
1266
 
1240
1267
 
1241
- if (target) {
1242
1268
 
1243
- // if data-confirm exists, ask for confirmation
1244
- // if not, then just go forward
1245
- let confirmText = target.getAttribute("data-confirm")
1246
- if (confirmText && confirmText.length > 0) {
1247
- const confirmed = confirm(confirmText)
1248
- console.log('confirmed', confirmed)
1249
- if (!confirmed) {
1250
- e.preventDefault()
1251
- e.stopPropagation()
1252
- return
1253
- }
1254
- }
1269
+ // 3. handle select
1270
+ if (e.target.classList.contains("frame-link")) {
1271
+ target = e.target
1272
+ } else {
1273
+ target = e.target.closest(".frame-link")
1274
+ }
1255
1275
 
1256
- if (target.getAttribute("data-action")) {
1257
- let actionStr = target.getAttribute("data-action")
1258
- let action = JSON.parse(actionStr)
1259
- console.log("action", action)
1260
- if (action.method === "stop" && action.uri) {
1261
- let socket = new Socket()
1262
- socket.run({
1263
- method: "kernel.api.stop",
1264
- params: {
1265
- uri: action.uri//"~" + location.pathname
1266
- }
1267
- }, (packet) => {
1268
- console.log("packet", packet)
1269
- if (packet.type === "result") {
1270
- socket.close()
1271
- // location.href = location.href
1272
- }
1273
- })
1274
- }
1275
- } else if (target.target === "_blank") {
1276
- // nothing
1277
- } else {
1278
- if (target.classList.contains("reveal")) {
1279
- // nested menu
1280
- target.closest(".nested-menu").querySelector(".submenu").classList.toggle("hidden")
1281
- e.preventDefault()
1282
- e.stopPropagation()
1283
- } else {
1284
- //location.hash = target.target
1285
1276
 
1286
1277
 
1287
- // let id = getTarget(target.getAttribute("href"))
1288
- // console.log("ID", id, target.href)
1289
- // location.hash = id
1278
+ if (target) {
1290
1279
 
1291
- //location.hash = target.getAttribute("href")
1280
+ // if data-confirm exists, ask for confirmation
1281
+ // if not, then just go forward
1282
+ let confirmText = target.getAttribute("data-confirm")
1283
+ if (confirmText && confirmText.length > 0) {
1284
+ const confirmed = confirm(confirmText)
1285
+ console.log('confirmed', confirmed)
1286
+ if (!confirmed) {
1287
+ e.preventDefault()
1288
+ e.stopPropagation()
1289
+ return
1290
+ }
1291
+ }
1292
1292
 
1293
- if (target.closest(".h")) {
1294
- location.hash = target.target
1295
- } else {
1296
- let index = target.getAttribute("data-index")
1297
- let type = target.closest(".m").getAttribute("data-type")
1293
+ if (target.getAttribute("data-action")) {
1294
+ let actionStr = target.getAttribute("data-action")
1295
+ let action = JSON.parse(actionStr)
1296
+ console.log("action", action)
1297
+ if (action.method === "stop" && action.uri) {
1298
+ let socket = new Socket()
1299
+ socket.run({
1300
+ method: "kernel.api.stop",
1301
+ params: {
1302
+ uri: action.uri//"~" + location.pathname
1303
+ }
1304
+ }, (packet) => {
1305
+ console.log("packet", packet)
1306
+ if (packet.type === "result") {
1307
+ socket.close()
1308
+ // location.href = location.href
1309
+ }
1310
+ })
1311
+ }
1312
+ } else if (target.target === "_blank") {
1313
+ // nothing
1314
+ } else {
1315
+ if (target.classList.contains("reveal")) {
1316
+ // nested menu
1317
+ target.closest(".nested-menu").querySelector(".submenu").classList.toggle("hidden")
1318
+ e.preventDefault()
1319
+ e.stopPropagation()
1320
+ } else {
1321
+ //location.hash = target.target
1298
1322
 
1299
1323
 
1300
- location.hash = type + index
1301
- }
1324
+ // let id = getTarget(target.getAttribute("href"))
1325
+ // console.log("ID", id, target.href)
1326
+ // location.hash = id
1302
1327
 
1303
- document.querySelectorAll(".frame-link").forEach((el) => {
1304
- el.classList.remove("selected")
1305
- })
1306
- target.classList.add("selected")
1328
+ //location.hash = target.getAttribute("href")
1307
1329
 
1308
- renderSelection(e)
1309
- }
1310
- }
1330
+ if (target.closest(".h")) {
1331
+ location.hash = target.target
1332
+ } else {
1333
+ let index = target.getAttribute("data-index")
1334
+ let type = target.closest(".m").getAttribute("data-type")
1311
1335
 
1312
1336
 
1337
+ location.hash = type + index
1338
+ }
1313
1339
 
1340
+ document.querySelectorAll(".frame-link").forEach((el) => {
1341
+ el.classList.remove("selected")
1342
+ })
1343
+ target.classList.add("selected")
1314
1344
 
1345
+ renderSelection(e)
1346
+ }
1315
1347
  }
1316
1348
  }
1317
1349
 
1318
1350
 
1319
1351
 
1320
1352
  })
1321
- const refresh = async () => {
1353
+ const refresh = async (silent) => {
1322
1354
  console.log("REFRESH")
1323
1355
  await new Promise((resolve, reject) => {
1324
1356
  setTimeout(() => {
@@ -1330,7 +1362,12 @@ const refresh = async () => {
1330
1362
  })
1331
1363
  document.querySelector(".menu").innerHTML = html
1332
1364
  location.hash = ""
1333
- renderSelection()
1365
+
1366
+ // render the selected frame only if not silent
1367
+ if (silent) {
1368
+ } else {
1369
+ renderSelection()
1370
+ }
1334
1371
  }
1335
1372
  window.addEventListener('message', (event) => {
1336
1373
 
@@ -595,6 +595,10 @@ document.addEventListener("DOMContentLoaded", async () => {
595
595
  const rpc = new RPC()
596
596
 
597
597
  <% if (mod && runnable) { %>
598
+ window.addEventListener('message', function(event) {
599
+ console.log("Message received from the parent: ", event.data); // Message received from parent
600
+ });
601
+
598
602
  document.querySelector(".stop").addEventListener("click", async (e) => {
599
603
  await rpc.stop()
600
604
  // socket.run({
@@ -102,7 +102,7 @@ header .runner {
102
102
  <!--
103
103
  <header class='grabbable'>
104
104
  -->
105
- <header class='navheader'>
105
+ <header class='navheader grabbable'>
106
106
  <h1>
107
107
  <% if (ishome) { %>
108
108
  <a class='home' href="/"><i class="fa-solid fa-house"></i></a>
@@ -189,6 +189,16 @@ header .runner {
189
189
  <div class='uri'><i class="fa-regular fa-folder"></i><%=item.url%></div>
190
190
  <div class='title'><%=item.name%></div>
191
191
  <div class='description'><%=item.description%></div>
192
+ <% if (item.running_scripts) { %>
193
+ <% item.running_scripts.forEach((s) => { %>
194
+ <div>
195
+ <button class='btn shutdown' data-src="<%=s.path%>">
196
+ <i class="fa-solid fa-stop"></i> Stop <%=s.name%>&nbsp;
197
+ <i class='fa-solid fa-spin fa-circle-notch'></i>
198
+ </button>
199
+ </div>
200
+ <% }) %>
201
+ <% } %>
192
202
  <% if (item.shortcuts && item.shortcuts.length > 0) { %>
193
203
  <div class='btns'>
194
204
  <% item.shortcuts.forEach((btn) => { %>
@@ -200,7 +210,10 @@ header .runner {
200
210
  <% } %>
201
211
  </div>
202
212
  <div class='spinner'>
213
+ <i class="fa-solid fa-chevron-right"></i>
214
+ <!--
203
215
  <i class="fa-solid fa-circle-notch fa-spin"></i>
216
+ -->
204
217
  </div>
205
218
  </h3>
206
219
  </a>
@@ -472,45 +485,6 @@ document.querySelector("form input[type=search]").addEventListener("input", (e)
472
485
  document.querySelector("form input[type=search]").focus()
473
486
  <% } %>
474
487
 
475
- if (document.querySelector(".container")) {
476
- document.querySelector(".container").addEventListener("click", async (e) => {
477
- let el = e.target.closest(".menu-btn")
478
- if (!el) {
479
- if (el.classList.contains("menu-btn")) {
480
- el = e.target
481
- }
482
- }
483
-
484
- console.log("EL", el)
485
- debugger
486
-
487
- if (el) {
488
- e.preventDefault()
489
- e.stopPropagation()
490
- let actionStr = el.getAttribute("data-action")
491
- if (actionStr) {
492
- let action = JSON.parse(actionStr)
493
- console.log("action", action)
494
- if (action.method === "stop" && action.uri) {
495
- socket.run({
496
- method: "kernel.api.stop",
497
- params: {
498
- uri: action.uri//"~" + location.pathname
499
- }
500
- }, (packet) => {
501
- console.log("packet", packet)
502
- if (packet.type === "result") {
503
- socket.close()
504
- location.href = location.href
505
- }
506
- })
507
- }
508
- }
509
-
510
- }
511
- })
512
- }
513
-
514
488
 
515
489
  // if (el) {
516
490
  // let url = el.getAttribute("data-url")
@@ -643,7 +617,82 @@ document.addEventListener("keydown", (e) => {
643
617
  }
644
618
  });
645
619
  document.addEventListener("click", (e) => {
646
- let target = (e.target.classList.contains(".btn") ? e.target : e.target.closest(".btn"))
620
+
621
+ let target
622
+
623
+ if (e.target.classList.contains("shutdown")) {
624
+ target = e.target
625
+ } else {
626
+ target = e.target.closest(".shutdown")
627
+ }
628
+ if (target) {
629
+ e.preventDefault()
630
+ e.stopPropagation()
631
+ let src = target.getAttribute("data-src")
632
+ console.log("src", src)
633
+ debugger
634
+
635
+ socket.run({
636
+ method: "kernel.api.stop",
637
+ params: {
638
+ uri: "~/" + src
639
+ }
640
+ }, (packet) => {
641
+ console.log("packet", packet)
642
+ if (packet.type === "result") {
643
+ socket.close()
644
+ location.href = location.href
645
+ }
646
+ })
647
+
648
+ return
649
+ }
650
+
651
+
652
+ if (document.querySelector(".container")) {
653
+ document.querySelector(".container").addEventListener("click", async (e) => {
654
+ let el = e.target.closest(".menu-btn")
655
+ if (!el) {
656
+ if (el.classList.contains("menu-btn")) {
657
+ el = e.target
658
+ }
659
+ }
660
+
661
+ console.log("EL", el)
662
+ debugger
663
+
664
+ if (el) {
665
+ e.preventDefault()
666
+ e.stopPropagation()
667
+ let actionStr = el.getAttribute("data-action")
668
+ if (actionStr) {
669
+ let action = JSON.parse(actionStr)
670
+ console.log("action", action)
671
+ if (action.method === "stop" && action.uri) {
672
+ socket.run({
673
+ method: "kernel.api.stop",
674
+ params: {
675
+ uri: action.uri//"~" + location.pathname
676
+ }
677
+ }, (packet) => {
678
+ console.log("packet", packet)
679
+ if (packet.type === "result") {
680
+ socket.close()
681
+ location.href = location.href
682
+ }
683
+ })
684
+ return
685
+ }
686
+ }
687
+
688
+ }
689
+ })
690
+ }
691
+
692
+
693
+
694
+
695
+ target = (e.target.classList.contains(".btn") ? e.target : e.target.closest(".btn"))
647
696
  if (target) {
648
697
  target.classList.add("clicked")
649
698
  document.querySelectorAll(".line .btns .btn").forEach((e) => {
@@ -651,7 +700,10 @@ document.addEventListener("click", (e) => {
651
700
  })
652
701
  target.classList.add("selected")
653
702
  target.closest(".line").classList.add("selected")
703
+ return
654
704
  }
705
+
706
+
655
707
  })
656
708
  <% if (qr) { %>
657
709
  document.querySelector("#wifi").addEventListener("click", async (e) => {
@@ -25,8 +25,12 @@
25
25
  <a <%=item.default ? 'data-default' : ''%> data-confirm="<%=item.confirm%>" data-index="<%=index%>" target="<%=item.target%>" data-mode="<%=item.mode%>" href="<%=item.href%>" class='btn header-item frame-link'>
26
26
  <div class='tab'><%-item.btn%></div>
27
27
  <% if (item.running) { %>
28
- <div class='loader'>
29
- <i class='fa-solid fa-spin fa-circle-notch'></i>
28
+ <div class='loader shutdown'>
29
+ <!--
30
+ <i class='fa-solid fa-spin fa-circle-notch'></i>
31
+ <i class="fa-solid fa-chevron-right"></i>
32
+ -->
33
+ <i class="fa-solid fa-xmark"></i>
30
34
  </div>
31
35
  <% } %>
32
36
  </a>