pinokiod 1.0.59 → 1.1.1
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/index.js +18 -1
- package/package.json +1 -1
- package/server/index.js +13 -1
- package/server/views/browser.ejs +70 -9
- package/server/views/index.ejs +23 -1
- package/server/views/partials/menu.ejs +2 -2
package/kernel/api/index.js
CHANGED
|
@@ -24,7 +24,25 @@ class Api {
|
|
|
24
24
|
this.proxies = {}
|
|
25
25
|
this.lproxy = new Lproxy()
|
|
26
26
|
}
|
|
27
|
+
checkProxy(config) {
|
|
28
|
+
// if config.name exists, throw error
|
|
29
|
+
// if config.uri exists, throw error
|
|
30
|
+
for(let scriptPath in this.proxies) {
|
|
31
|
+
let proxies = this.proxies[scriptPath]
|
|
32
|
+
for(let p of proxies) {
|
|
33
|
+
if (p.target === config.uri) {
|
|
34
|
+
throw new Error(`A proxy for the uri ${config.uri} already exists`)
|
|
35
|
+
}
|
|
36
|
+
// if (p.name === config.name) {
|
|
37
|
+
// throw new Error(`A proxy with the name ${config.name} already exists`)
|
|
38
|
+
// }
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
27
42
|
async startProxy(scriptPath, uri, name) {
|
|
43
|
+
this.checkProxy({ uri, name })
|
|
44
|
+
// if the name exists, throw error
|
|
45
|
+
// if the uri exists, throw error
|
|
28
46
|
console.log("startProxy", { scriptPath, uri, proxies: this.proxies })
|
|
29
47
|
let proxy_uri = await this.lproxy.start(uri)
|
|
30
48
|
console.log({ proxy_uri, uri })
|
|
@@ -37,7 +55,6 @@ class Api {
|
|
|
37
55
|
target: uri,
|
|
38
56
|
proxy: proxy_uri
|
|
39
57
|
}
|
|
40
|
-
console.log("started", { proxies: this.proxies })
|
|
41
58
|
}
|
|
42
59
|
stopProxy(config) {
|
|
43
60
|
console.log("stopProxy", { config, proxies: this.proxies })
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -993,8 +993,11 @@ class Server {
|
|
|
993
993
|
// let U = `${_p}/${pathComponents.join("/")}`
|
|
994
994
|
// console.log("*******", { filepath, pathComponents, U })
|
|
995
995
|
|
|
996
|
+
let pinokio_proxy = this.kernel.api.proxies["/"]
|
|
997
|
+
console.log("pinokio_proxy", pinokio_proxy)
|
|
996
998
|
|
|
997
999
|
res.render("index", {
|
|
1000
|
+
proxy: pinokio_proxy[0],
|
|
998
1001
|
error: error,
|
|
999
1002
|
logo: this.logo,
|
|
1000
1003
|
// memory: mem,
|
|
@@ -1180,6 +1183,13 @@ class Server {
|
|
|
1180
1183
|
} else {
|
|
1181
1184
|
config.menu[i].target = "@" + (config.menu[i].id || config.menu[i].src)
|
|
1182
1185
|
}
|
|
1186
|
+
|
|
1187
|
+
|
|
1188
|
+
if (config.menu[i].href && config.menu[i].href.startsWith("http")) {
|
|
1189
|
+
if (this.agent !== "electron") {
|
|
1190
|
+
config.menu[i].target = "_blank"
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1183
1193
|
}
|
|
1184
1194
|
|
|
1185
1195
|
|
|
@@ -1209,7 +1219,7 @@ class Server {
|
|
|
1209
1219
|
let proxyMenu = []
|
|
1210
1220
|
for(let proxy of childProxies) {
|
|
1211
1221
|
proxyMenu.push({
|
|
1212
|
-
btn: `<i class="fa-solid fa-
|
|
1222
|
+
btn: `<i class="fa-solid fa-wifi"></i> <strong>WiFi</strong> - ${proxy.name}`,
|
|
1213
1223
|
target: "_blank",
|
|
1214
1224
|
href: proxy.proxy
|
|
1215
1225
|
})
|
|
@@ -1598,6 +1608,8 @@ class Server {
|
|
|
1598
1608
|
|
|
1599
1609
|
console.log("homedir", this.kernel.homedir)
|
|
1600
1610
|
|
|
1611
|
+
// start proxy for Pinokio itself
|
|
1612
|
+
await this.kernel.api.startProxy("/", `http://127.0.0.1:${this.port}`, "/")
|
|
1601
1613
|
|
|
1602
1614
|
// if (!debug) {
|
|
1603
1615
|
// let logsdir = path.resolve(this.kernel.homedir, "logs")
|
package/server/views/browser.ejs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<html>
|
|
2
2
|
<head>
|
|
3
3
|
<meta charset="UTF-8">
|
|
4
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
|
|
5
5
|
<link href="/css/fontawesome.min.css" rel="stylesheet">
|
|
6
6
|
<link href="/css/solid.min.css" rel="stylesheet">
|
|
7
7
|
<link href="/css/regular.min.css" rel="stylesheet">
|
|
@@ -390,6 +390,9 @@ body.dark #new-tab {
|
|
|
390
390
|
padding-left: 15px;
|
|
391
391
|
box-sizing: border-box;
|
|
392
392
|
}
|
|
393
|
+
.loader-dialog {
|
|
394
|
+
padding: 10px;
|
|
395
|
+
}
|
|
393
396
|
body.dark .loader-popup {
|
|
394
397
|
background: rgba(0,0,0,0.2);
|
|
395
398
|
color: whitesmoke;
|
|
@@ -405,10 +408,39 @@ body.dark .loader-popup {
|
|
|
405
408
|
body.dark .loader-container {
|
|
406
409
|
background: rgba(255,255,255,0.3);
|
|
407
410
|
}
|
|
411
|
+
@media only screen and (max-width: 480px) {
|
|
412
|
+
.app-info {
|
|
413
|
+
display: flex;
|
|
414
|
+
padding: 10px;
|
|
415
|
+
}
|
|
416
|
+
.app-info img {
|
|
417
|
+
width: 60px;
|
|
418
|
+
height: 60px;
|
|
419
|
+
}
|
|
420
|
+
.header-item {
|
|
421
|
+
font-size: 16px;
|
|
422
|
+
}
|
|
423
|
+
aside.active {
|
|
424
|
+
width: 100%;
|
|
425
|
+
z-index: 10000000;
|
|
426
|
+
}
|
|
427
|
+
aside:not(.active) {
|
|
428
|
+
display: none;
|
|
429
|
+
}
|
|
430
|
+
.container.active {
|
|
431
|
+
position: absolute;
|
|
432
|
+
z-index: 10000000;
|
|
433
|
+
width: 100%;
|
|
434
|
+
height: 100%;
|
|
435
|
+
}
|
|
436
|
+
.grid-btns {
|
|
437
|
+
display: none;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
408
440
|
</style>
|
|
409
441
|
</head>
|
|
410
442
|
<body class='<%=theme%>'>
|
|
411
|
-
<aside>
|
|
443
|
+
<aside class='active'>
|
|
412
444
|
<div class='header-top header-item'>
|
|
413
445
|
<div class='app-info'>
|
|
414
446
|
<img src="<%=rawpath%>/<%=config.icon%>?raw=true"/>
|
|
@@ -457,6 +489,7 @@ body.dark .loader-container {
|
|
|
457
489
|
<div class='container'>
|
|
458
490
|
<nav>
|
|
459
491
|
<div class='hidden bar'>
|
|
492
|
+
<button class='btn2' id='menu'><i class="fa-solid fa-bars"></i></button>
|
|
460
493
|
<% if (agent === "electron") { %>
|
|
461
494
|
<button class='btn2' id='back'><i class="fa-solid fa-arrow-left"></i></button>
|
|
462
495
|
<button class='btn2' id='forward'><i class="fa-solid fa-arrow-right"></i></button>
|
|
@@ -510,7 +543,6 @@ const getTarget = (href) => {
|
|
|
510
543
|
}
|
|
511
544
|
}
|
|
512
545
|
const subUrlOf = (s, f) => {
|
|
513
|
-
debugger
|
|
514
546
|
|
|
515
547
|
let subsetUrl = (s.startsWith("http") ? s : "http://localhost" + s)
|
|
516
548
|
let fullUrl = (f.startsWith("http") ? f: "http://localhost" + f)
|
|
@@ -633,6 +665,20 @@ const renderSelection = (e, force) => {
|
|
|
633
665
|
//
|
|
634
666
|
// => select that tab and frame
|
|
635
667
|
|
|
668
|
+
console.log("target", target)
|
|
669
|
+
if (target) {
|
|
670
|
+
|
|
671
|
+
// display the menu button at the top
|
|
672
|
+
// maximize container
|
|
673
|
+
// minimize aside
|
|
674
|
+
|
|
675
|
+
document.querySelector(".container").classList.add("active")
|
|
676
|
+
document.querySelector("aside").classList.remove("active")
|
|
677
|
+
} else {
|
|
678
|
+
document.querySelector(".container").classList.remove("active")
|
|
679
|
+
document.querySelector("aside").classList.add("active")
|
|
680
|
+
}
|
|
681
|
+
|
|
636
682
|
if (target) {
|
|
637
683
|
console.log("# 3")
|
|
638
684
|
|
|
@@ -642,7 +688,7 @@ const renderSelection = (e, force) => {
|
|
|
642
688
|
console.log("> url", url)
|
|
643
689
|
document.querySelector("#open-browser").href = url
|
|
644
690
|
document.querySelector("#clone-tab").setAttribute("data-href", url)
|
|
645
|
-
|
|
691
|
+
document.querySelector("#location").innerHTML = url
|
|
646
692
|
|
|
647
693
|
|
|
648
694
|
// select the selected target element (tab)
|
|
@@ -654,7 +700,6 @@ const renderSelection = (e, force) => {
|
|
|
654
700
|
})
|
|
655
701
|
|
|
656
702
|
|
|
657
|
-
debugger
|
|
658
703
|
|
|
659
704
|
// Look for the frame
|
|
660
705
|
// 1. if it's hard (".h")
|
|
@@ -728,7 +773,6 @@ const renderSelection = (e, force) => {
|
|
|
728
773
|
} else {
|
|
729
774
|
if (e) {
|
|
730
775
|
if (target.closest(".h")) {
|
|
731
|
-
debugger
|
|
732
776
|
e.preventDefault()
|
|
733
777
|
e.stopPropagation()
|
|
734
778
|
let sub = subUrlOf(target.href, targetFrame.src)
|
|
@@ -868,6 +912,8 @@ const renderSelection = (e, force) => {
|
|
|
868
912
|
} else {
|
|
869
913
|
console.log("# 14")
|
|
870
914
|
// document.querySelector(".bar").classList.add("hidden")
|
|
915
|
+
document.querySelector(".container").classList.remove("active")
|
|
916
|
+
document.querySelector("aside").classList.add("active")
|
|
871
917
|
}
|
|
872
918
|
}
|
|
873
919
|
console.log("loaded before", loaded)
|
|
@@ -985,6 +1031,10 @@ const addTab = async (url) => {
|
|
|
985
1031
|
|
|
986
1032
|
|
|
987
1033
|
|
|
1034
|
+
document.querySelector("#menu").addEventListener("click", async (e) => {
|
|
1035
|
+
location.hash = ""
|
|
1036
|
+
renderSelection()
|
|
1037
|
+
})
|
|
988
1038
|
document.querySelector(".app-info").addEventListener("click", async (e) => {
|
|
989
1039
|
e.preventDefault()
|
|
990
1040
|
e.stopPropagation()
|
|
@@ -997,9 +1047,6 @@ document.querySelector("#delete").addEventListener("click", async (e) => {
|
|
|
997
1047
|
e.stopPropagation()
|
|
998
1048
|
const confirmed = confirm("Are you sure you wish to delete the app?")
|
|
999
1049
|
if (confirmed) {
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
1050
|
let name = document.querySelector("#delete").getAttribute("data-name")
|
|
1004
1051
|
console.log("delete", name)
|
|
1005
1052
|
Swal.fire({
|
|
@@ -1072,6 +1119,20 @@ document.querySelector("aside").addEventListener("click", async (e) => {
|
|
|
1072
1119
|
|
|
1073
1120
|
|
|
1074
1121
|
if (target) {
|
|
1122
|
+
|
|
1123
|
+
// if data-confirm exists, ask for confirmation
|
|
1124
|
+
// if not, then just go forward
|
|
1125
|
+
let confirmText = target.getAttribute("data-confirm")
|
|
1126
|
+
if (confirmText && confirmText.length > 0) {
|
|
1127
|
+
const confirmed = confirm(confirmText)
|
|
1128
|
+
console.log('confirmed', confirmed)
|
|
1129
|
+
if (!confirmed) {
|
|
1130
|
+
e.preventDefault()
|
|
1131
|
+
e.stopPropagation()
|
|
1132
|
+
return
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1075
1136
|
if (target.target === "_blank") {
|
|
1076
1137
|
// nothing
|
|
1077
1138
|
} else {
|
package/server/views/index.ejs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<html>
|
|
2
2
|
<head>
|
|
3
3
|
<meta charset="UTF-8">
|
|
4
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
|
|
5
5
|
<link href="/xterm.min.css" rel="stylesheet" />
|
|
6
6
|
<link href="/css/fontawesome.min.css" rel="stylesheet">
|
|
7
7
|
<link href="/css/solid.min.css" rel="stylesheet">
|
|
@@ -52,6 +52,27 @@
|
|
|
52
52
|
header .runner {
|
|
53
53
|
padding: 10px 0 0;
|
|
54
54
|
}
|
|
55
|
+
.proxy {
|
|
56
|
+
padding: 0 10px;
|
|
57
|
+
text-align: right;
|
|
58
|
+
}
|
|
59
|
+
.proxy a {
|
|
60
|
+
text-decoration: none;
|
|
61
|
+
display: inline-block;
|
|
62
|
+
padding: 5px 10px;
|
|
63
|
+
border-radius: 2px;
|
|
64
|
+
background: black;
|
|
65
|
+
color: white;
|
|
66
|
+
}
|
|
67
|
+
@media only screen and (max-width: 480px) {
|
|
68
|
+
.btn2 {
|
|
69
|
+
padding: 5px;
|
|
70
|
+
font-size: 11px;
|
|
71
|
+
}
|
|
72
|
+
.nav-btns {
|
|
73
|
+
flex-grow: 1;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
55
76
|
</style>
|
|
56
77
|
<script src="/hotkeys.min.js"></script>
|
|
57
78
|
<script src="/sweetalert2.js"></script>
|
|
@@ -98,6 +119,7 @@ header .runner {
|
|
|
98
119
|
<% if (ishome) { %>
|
|
99
120
|
<div class='nav-btns'>
|
|
100
121
|
<a class='btn2' id='explore'><div><i class="fa-solid fa-globe"></i></div><div>Discover</div></a>
|
|
122
|
+
<a class='btn2' href="<%=proxy.proxy%>" target="_blank"><div><i class="fa-solid fa-wifi"></i></div><div>WiFi</div></a>
|
|
101
123
|
<a class='btn2' id='report'><div><i class="fa-solid fa-bug"></i></div><div>Report Bug</div></a>
|
|
102
124
|
<a class='btn2' href='https://discord.gg/TQdNwadtE4' target="_blank"><div><i class="fa-brands fa-discord"></i></div><div>Discord</div></a>
|
|
103
125
|
<a class='btn2' href='https://twitter.com/cocktailpeanut' target="_blank"><div><i class="fa-brands fa-twitter"></i></div><div>Twitter</div></a>
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
<% } else { %>
|
|
12
12
|
<% if (item.btn) { %>
|
|
13
13
|
<% if (item.target === "_blank") { %>
|
|
14
|
-
<a data-index="<%=index%>" target="<%=item.target%>" data-mode="<%=item.mode%>" href="<%=item.href%>" class='btn header-item frame-link'>
|
|
14
|
+
<a data-confirm="<%=item.confirm%>" data-index="<%=index%>" target="<%=item.target%>" data-mode="<%=item.mode%>" href="<%=item.href%>" class='btn header-item frame-link'>
|
|
15
15
|
<div class='tab'><%-item.btn%></div>
|
|
16
16
|
<div class='loader'>
|
|
17
17
|
<i class="fa-solid fa-up-right-from-square"></i>
|
|
18
18
|
</div>
|
|
19
19
|
</a>
|
|
20
20
|
<% } else { %>
|
|
21
|
-
<a data-index="<%=index%>" target="<%=item.target%>" data-mode="<%=item.mode%>" href="<%=item.href%>" class='btn header-item frame-link'>
|
|
21
|
+
<a data-confirm="<%=item.confirm%>" data-index="<%=index%>" target="<%=item.target%>" data-mode="<%=item.mode%>" href="<%=item.href%>" class='btn header-item frame-link'>
|
|
22
22
|
<div class='tab'><%-item.btn%></div>
|
|
23
23
|
<% if (item.running) { %>
|
|
24
24
|
<div class='loader'>
|