pinokiod 1.3.29 → 1.3.31

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.29",
3
+ "version": "1.3.31",
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 {
@@ -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 = {}
@@ -713,9 +715,7 @@ const renderSelection = (e, force) => {
713
715
 
714
716
 
715
717
  let target
716
- if (selection) {
717
- target = selection
718
- } else {
718
+ if (location.hash && location.hash.length > 0) {
719
719
  // document.querySelector(".bar").classList.remove("hidden")
720
720
  //let id = getTarget(location.hash.slice(1))
721
721
  let id = location.hash.slice(1)
@@ -753,6 +753,10 @@ const renderSelection = (e, force) => {
753
753
  // if not triggered by an event, look for the target from the location hash
754
754
  target = document.querySelector(selector)
755
755
  }
756
+ } else {
757
+ if (selection) {
758
+ target = selection
759
+ }
756
760
  }
757
761
 
758
762
 
@@ -1202,7 +1206,7 @@ document.querySelector("aside").addEventListener("click", async (e) => {
1202
1206
  let target
1203
1207
 
1204
1208
 
1205
- // delete
1209
+ // 1. handle delete
1206
1210
  if (e.target.classList.contains("del")) {
1207
1211
  target = e.target
1208
1212
  } else {
@@ -1225,98 +1229,128 @@ document.querySelector("aside").addEventListener("click", async (e) => {
1225
1229
  el.remove()
1226
1230
  // update tabs
1227
1231
  await syncTabs()
1232
+ return
1233
+ }
1234
+
1228
1235
 
1236
+ // 2. handle shudown
1237
+ if (e.target.classList.contains("shutdown")) {
1238
+ target = e.target
1229
1239
  } else {
1230
- // Select
1231
- if (e.target.classList.contains("frame-link")) {
1232
- target = e.target
1233
- } else {
1234
- target = e.target.closest(".frame-link")
1235
- }
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
+ })
1236
1263
 
1264
+ return
1265
+ }
1237
1266
 
1238
1267
 
1239
- if (target) {
1240
1268
 
1241
- // if data-confirm exists, ask for confirmation
1242
- // if not, then just go forward
1243
- let confirmText = target.getAttribute("data-confirm")
1244
- if (confirmText && confirmText.length > 0) {
1245
- const confirmed = confirm(confirmText)
1246
- console.log('confirmed', confirmed)
1247
- if (!confirmed) {
1248
- e.preventDefault()
1249
- e.stopPropagation()
1250
- return
1251
- }
1252
- }
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
+ }
1253
1275
 
1254
- if (target.getAttribute("data-action")) {
1255
- let actionStr = target.getAttribute("data-action")
1256
- let action = JSON.parse(actionStr)
1257
- console.log("action", action)
1258
- if (action.method === "stop" && action.uri) {
1259
- let socket = new Socket()
1260
- socket.run({
1261
- method: "kernel.api.stop",
1262
- params: {
1263
- uri: action.uri//"~" + location.pathname
1264
- }
1265
- }, (packet) => {
1266
- console.log("packet", packet)
1267
- if (packet.type === "result") {
1268
- socket.close()
1269
- // location.href = location.href
1270
- }
1271
- })
1272
- }
1273
- } else if (target.target === "_blank") {
1274
- // nothing
1275
- } else {
1276
- if (target.classList.contains("reveal")) {
1277
- // nested menu
1278
- target.closest(".nested-menu").querySelector(".submenu").classList.toggle("hidden")
1279
- e.preventDefault()
1280
- e.stopPropagation()
1281
- } else {
1282
- //location.hash = target.target
1283
1276
 
1284
1277
 
1285
- // let id = getTarget(target.getAttribute("href"))
1286
- // console.log("ID", id, target.href)
1287
- // location.hash = id
1278
+ if (target) {
1288
1279
 
1289
- //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
+ }
1290
1292
 
1291
- if (target.closest(".h")) {
1292
- location.hash = target.target
1293
- } else {
1294
- let index = target.getAttribute("data-index")
1295
- 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
1296
1322
 
1297
1323
 
1298
- location.hash = type + index
1299
- }
1324
+ // let id = getTarget(target.getAttribute("href"))
1325
+ // console.log("ID", id, target.href)
1326
+ // location.hash = id
1300
1327
 
1301
- document.querySelectorAll(".frame-link").forEach((el) => {
1302
- el.classList.remove("selected")
1303
- })
1304
- target.classList.add("selected")
1328
+ //location.hash = target.getAttribute("href")
1305
1329
 
1306
- renderSelection(e)
1307
- }
1308
- }
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")
1309
1335
 
1310
1336
 
1337
+ location.hash = type + index
1338
+ }
1311
1339
 
1340
+ document.querySelectorAll(".frame-link").forEach((el) => {
1341
+ el.classList.remove("selected")
1342
+ })
1343
+ target.classList.add("selected")
1312
1344
 
1345
+ renderSelection(e)
1346
+ }
1313
1347
  }
1314
1348
  }
1315
1349
 
1316
1350
 
1317
1351
 
1318
1352
  })
1319
- const refresh = async () => {
1353
+ const refresh = async (silent) => {
1320
1354
  console.log("REFRESH")
1321
1355
  await new Promise((resolve, reject) => {
1322
1356
  setTimeout(() => {
@@ -1328,7 +1362,12 @@ const refresh = async () => {
1328
1362
  })
1329
1363
  document.querySelector(".menu").innerHTML = html
1330
1364
  location.hash = ""
1331
- renderSelection()
1365
+
1366
+ // render the selected frame only if not silent
1367
+ if (silent) {
1368
+ } else {
1369
+ renderSelection()
1370
+ }
1332
1371
  }
1333
1372
  window.addEventListener('message', (event) => {
1334
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({
@@ -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>