pinokiod 3.25.0 → 3.27.0
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/bin/caddy.js +1 -1
- package/kernel/index.js +1 -6
- package/kernel/peer.js +23 -5
- package/kernel/prototype.js +2 -0
- package/kernel/util.js +0 -1
- package/package.json +1 -1
- package/server/index.js +121 -56
- package/server/public/modalinput.js +3 -1
- package/server/views/500.ejs +7 -6
- package/server/views/app.ejs +32 -1
- package/server/views/d.ejs +52 -0
- package/server/views/init/index.ejs +82 -36
- package/server/views/install.ejs +7 -1
- package/server/views/net.ejs +94 -165
- package/server/views/start.ejs +38 -3
package/kernel/bin/caddy.js
CHANGED
|
@@ -113,7 +113,7 @@ class Caddy {
|
|
|
113
113
|
//let response = await this.kernel.api.wait(id)
|
|
114
114
|
console.log("ondata", ondata.toString())
|
|
115
115
|
setTimeout(() => {
|
|
116
|
-
ondata({ html: `<b><i class="fa-solid fa-keyboard"></i> Enter the system password to generate
|
|
116
|
+
ondata({ html: `<b><i class="fa-solid fa-keyboard"></i> Enter the system password to generate an HTTPS certificate</b>` }, "notify3")
|
|
117
117
|
}, 2000)
|
|
118
118
|
await this.kernel.exec({
|
|
119
119
|
input: true,
|
package/kernel/index.js
CHANGED
|
@@ -293,16 +293,11 @@ class Kernel {
|
|
|
293
293
|
async refresh(notify_peers) {
|
|
294
294
|
const ts = Date.now()
|
|
295
295
|
let network_active = await this.network_active()
|
|
296
|
-
// console.log({ network_active })
|
|
297
296
|
if (!network_active) {
|
|
298
297
|
return
|
|
299
298
|
}
|
|
300
299
|
let network_running = await this.network_running()
|
|
301
|
-
// console.log({ network_running })
|
|
302
|
-
// console.log({ refreshing: this.processes.refreshing })
|
|
303
300
|
if (network_running) {
|
|
304
|
-
|
|
305
|
-
|
|
306
301
|
let ts = Date.now()
|
|
307
302
|
if (this.processes.refreshing) {
|
|
308
303
|
// process list refreshing. try again later
|
|
@@ -680,7 +675,7 @@ class Kernel {
|
|
|
680
675
|
this.processes = new Procs(this)
|
|
681
676
|
this.kv = new KV(this)
|
|
682
677
|
this.cloudflare = new Cloudflare()
|
|
683
|
-
this.peer = new Peer()
|
|
678
|
+
this.peer = new Peer(this)
|
|
684
679
|
this.git = new Git(this)
|
|
685
680
|
|
|
686
681
|
this.homedir = home
|
package/kernel/peer.js
CHANGED
|
@@ -3,7 +3,8 @@ const axios = require('axios');
|
|
|
3
3
|
const os = require('os')
|
|
4
4
|
const Environment = require("./environment")
|
|
5
5
|
class PeerDiscovery {
|
|
6
|
-
constructor(port = 41234, message = 'ping', interval = 1000) {
|
|
6
|
+
constructor(kernel, port = 41234, message = 'ping', interval = 1000) {
|
|
7
|
+
this.kernel = kernel
|
|
7
8
|
this.port = port;
|
|
8
9
|
this.message = Buffer.from(message);
|
|
9
10
|
this.interval = interval;
|
|
@@ -100,10 +101,14 @@ class PeerDiscovery {
|
|
|
100
101
|
}
|
|
101
102
|
async _refresh(host) {
|
|
102
103
|
try {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
104
|
+
if (host === this.host) {
|
|
105
|
+
return this.current_host()
|
|
106
|
+
} else {
|
|
107
|
+
let res = await axios.get(`http://${host}:${this.default_port}/pinokio/peer`, {
|
|
108
|
+
timeout: 2000
|
|
109
|
+
})
|
|
110
|
+
return res.data
|
|
111
|
+
}
|
|
107
112
|
} catch (e) {
|
|
108
113
|
console.log("_refresh error", { host , e })
|
|
109
114
|
return null
|
|
@@ -128,6 +133,19 @@ class PeerDiscovery {
|
|
|
128
133
|
return res
|
|
129
134
|
}
|
|
130
135
|
}
|
|
136
|
+
current_host() {
|
|
137
|
+
return {
|
|
138
|
+
home: this.kernel.homedir,
|
|
139
|
+
arch: this.kernel.arch,
|
|
140
|
+
platform: this.kernel.platform,
|
|
141
|
+
name: this.kernel.peer.name,
|
|
142
|
+
host: this.kernel.peer.host,
|
|
143
|
+
port_mapping: this.kernel.router.port_mapping,
|
|
144
|
+
proc: this.kernel.processes.info,
|
|
145
|
+
router: this.kernel.router.published(),
|
|
146
|
+
memory: this.kernel.memory
|
|
147
|
+
}
|
|
148
|
+
}
|
|
131
149
|
// refresh peer info
|
|
132
150
|
async refresh(peers) {
|
|
133
151
|
// if (this.active) {
|
package/kernel/prototype.js
CHANGED
|
@@ -67,6 +67,7 @@ class Proto {
|
|
|
67
67
|
title,
|
|
68
68
|
description,
|
|
69
69
|
meta,
|
|
70
|
+
data,
|
|
70
71
|
content
|
|
71
72
|
})
|
|
72
73
|
}
|
|
@@ -76,6 +77,7 @@ class Proto {
|
|
|
76
77
|
await fs.promises.rm(this.kernel.path("prototype"), { recursive: true })
|
|
77
78
|
}
|
|
78
79
|
async create(req, ondata) {
|
|
80
|
+
console.log("REQ", req)
|
|
79
81
|
try {
|
|
80
82
|
let projectType = req.params.projectType
|
|
81
83
|
let startType = req.params.cliType || req.params.startType
|
package/kernel/util.js
CHANGED
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -384,6 +384,20 @@ class Server {
|
|
|
384
384
|
}
|
|
385
385
|
// console.timeEnd("1 chrome " + d)
|
|
386
386
|
|
|
387
|
+
|
|
388
|
+
console.log("req.query", req.query)
|
|
389
|
+
if (req.query.autolaunch === "1") {
|
|
390
|
+
let fullpath = path.resolve(this.kernel.homedir, "ENVIRONMENT")
|
|
391
|
+
await Util.update_env(fullpath, {
|
|
392
|
+
PINOKIO_ONDEMAND_AUTOLAUNCH: "1"
|
|
393
|
+
})
|
|
394
|
+
} else if (req.query.autolaunch === "0") {
|
|
395
|
+
let fullpath = path.resolve(this.kernel.homedir, "ENVIRONMENT")
|
|
396
|
+
await Util.update_env(fullpath, {
|
|
397
|
+
PINOKIO_ONDEMAND_AUTOLAUNCH: "0"
|
|
398
|
+
})
|
|
399
|
+
}
|
|
400
|
+
|
|
387
401
|
let name = req.params.name
|
|
388
402
|
let config = await this.kernel.api.meta(name)
|
|
389
403
|
|
|
@@ -439,7 +453,12 @@ class Server {
|
|
|
439
453
|
}
|
|
440
454
|
|
|
441
455
|
let uri = this.kernel.path("api")
|
|
442
|
-
|
|
456
|
+
try {
|
|
457
|
+
await this.renderMenu(uri, name, config, [])
|
|
458
|
+
} catch(e) {
|
|
459
|
+
config.menu = []
|
|
460
|
+
err = e.stack
|
|
461
|
+
}
|
|
443
462
|
|
|
444
463
|
|
|
445
464
|
let platform = os.platform()
|
|
@@ -1756,8 +1775,6 @@ class Server {
|
|
|
1756
1775
|
let unix_path = Util.p2u(cwd)
|
|
1757
1776
|
let shell_id = this.get_shell_id(unix_path, currentIndexPath, rendered)
|
|
1758
1777
|
|
|
1759
|
-
console.log("SHELL ID 1", shell_id)
|
|
1760
|
-
|
|
1761
1778
|
// let hash = crypto.createHash('md5').update(JSON.stringify(rendered)).digest('hex')
|
|
1762
1779
|
// let shell_id
|
|
1763
1780
|
// if (rendered.id) {
|
|
@@ -1778,7 +1795,6 @@ class Server {
|
|
|
1778
1795
|
}
|
|
1779
1796
|
}
|
|
1780
1797
|
}
|
|
1781
|
-
console.log("renderShell", menuitem)
|
|
1782
1798
|
return menuitem
|
|
1783
1799
|
}
|
|
1784
1800
|
|
|
@@ -2881,17 +2897,25 @@ class Server {
|
|
|
2881
2897
|
let host = u.host
|
|
2882
2898
|
if (host.endsWith(".localhost")) {
|
|
2883
2899
|
let name = host.replace(/\.localhost$/, '')
|
|
2900
|
+
let env = await Environment.get(this.kernel.homedir)
|
|
2901
|
+
let autolaunch = false
|
|
2902
|
+
if (env && env.PINOKIO_ONDEMAND_AUTOLAUNCH === "1") {
|
|
2903
|
+
autolaunch = true
|
|
2904
|
+
}
|
|
2884
2905
|
let api_path = this.kernel.path("api", name)
|
|
2885
2906
|
let exists = await this.exists(api_path)
|
|
2886
2907
|
if (exists) {
|
|
2887
2908
|
let meta = await this.kernel.api.meta(name)
|
|
2909
|
+
console.log({ autolaunch })
|
|
2888
2910
|
res.render("start", {
|
|
2911
|
+
autolaunch,
|
|
2889
2912
|
logo: this.logo,
|
|
2890
2913
|
theme: this.theme,
|
|
2891
2914
|
agent: this.agent,
|
|
2892
2915
|
name: meta.title,
|
|
2893
2916
|
image: meta.icon,
|
|
2894
|
-
link: "/p/" + name
|
|
2917
|
+
//link: autolaunch ? "/p/" + name : "/p/" + name + "?autolaunch"
|
|
2918
|
+
link: autolaunch ? "/p/" + name + "?autolaunch=1" : "/p/" + name + "?autolaunch=0"
|
|
2895
2919
|
})
|
|
2896
2920
|
return
|
|
2897
2921
|
}
|
|
@@ -3121,6 +3145,12 @@ class Server {
|
|
|
3121
3145
|
// await this.kernel.proto.init()
|
|
3122
3146
|
let list = this.getPeerInfo()
|
|
3123
3147
|
let ai = await this.kernel.proto.ai()
|
|
3148
|
+
ai.push({
|
|
3149
|
+
title: "Use your own AI recipe",
|
|
3150
|
+
description: "Enter your own markdown instruction for AI",
|
|
3151
|
+
meta: {},
|
|
3152
|
+
content: ""
|
|
3153
|
+
})
|
|
3124
3154
|
console.log("ai", ai)
|
|
3125
3155
|
res.render("init/index", {
|
|
3126
3156
|
list,
|
|
@@ -3753,6 +3783,25 @@ class Server {
|
|
|
3753
3783
|
agent: this.agent,
|
|
3754
3784
|
})
|
|
3755
3785
|
}))
|
|
3786
|
+
this.app.post("/plugin/update", ex(async (req, res) => {
|
|
3787
|
+
console.time("/plugin/update")
|
|
3788
|
+
try {
|
|
3789
|
+
await this.kernel.exec({
|
|
3790
|
+
message: "git pull",
|
|
3791
|
+
path: this.kernel.path("plugin/code")
|
|
3792
|
+
}, (e) => {
|
|
3793
|
+
console.log(e)
|
|
3794
|
+
})
|
|
3795
|
+
console.timeEnd("/plugin/update")
|
|
3796
|
+
res.json({
|
|
3797
|
+
success: true
|
|
3798
|
+
})
|
|
3799
|
+
} catch (e) {
|
|
3800
|
+
res.json({
|
|
3801
|
+
error: e.stack
|
|
3802
|
+
})
|
|
3803
|
+
}
|
|
3804
|
+
}))
|
|
3756
3805
|
this.app.post("/network/reset", ex(async (req, res) => {
|
|
3757
3806
|
let caddy_path = this.kernel.path("cache/XDG_DATA_HOME/caddy")
|
|
3758
3807
|
await rimraf(caddy_path)
|
|
@@ -3775,6 +3824,7 @@ class Server {
|
|
|
3775
3824
|
})
|
|
3776
3825
|
}))
|
|
3777
3826
|
this.app.get("/net/:name", ex(async (req, res) => {
|
|
3827
|
+
let protocol = req.get('X-Forwarded-Proto')
|
|
3778
3828
|
let { requirements, install_required, requirements_pending, error } = await this.kernel.bin.check({
|
|
3779
3829
|
bin: this.kernel.bin.preset("network"),
|
|
3780
3830
|
})
|
|
@@ -3786,7 +3836,7 @@ class Server {
|
|
|
3786
3836
|
}
|
|
3787
3837
|
|
|
3788
3838
|
let list = this.getPeerInfo()
|
|
3789
|
-
let processes
|
|
3839
|
+
let processes = []
|
|
3790
3840
|
let host
|
|
3791
3841
|
let peer
|
|
3792
3842
|
for(let item of list) {
|
|
@@ -3799,7 +3849,6 @@ class Server {
|
|
|
3799
3849
|
let favicons = {}
|
|
3800
3850
|
let titles = {}
|
|
3801
3851
|
let descriptions = {}
|
|
3802
|
-
console.time("Favicon")
|
|
3803
3852
|
//await Promise.all(peer.processes.map((proc) => {
|
|
3804
3853
|
// console.log("Proc", proc)
|
|
3805
3854
|
// return new Promise(async (resolve, reject) => {
|
|
@@ -3810,55 +3859,63 @@ class Server {
|
|
|
3810
3859
|
// }
|
|
3811
3860
|
// })
|
|
3812
3861
|
//}))
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
//
|
|
3823
|
-
let
|
|
3824
|
-
|
|
3825
|
-
let
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
let
|
|
3830
|
-
if (
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3862
|
+
|
|
3863
|
+
if (peer && peer.processes) {
|
|
3864
|
+
let pinokio_ip
|
|
3865
|
+
for(let proc of peer.processes) {
|
|
3866
|
+
if (proc.internal_port === 42000) {
|
|
3867
|
+
// pinokio ip
|
|
3868
|
+
pinokio_ip = proc.external_ip
|
|
3869
|
+
}
|
|
3870
|
+
if (proc.external_router) {
|
|
3871
|
+
// try to get icons from pinokio
|
|
3872
|
+
for(let router of proc.external_router) {
|
|
3873
|
+
// replace the root domain: facefusion-pinokio.git.x.localhost => facefusion-pinokio.git
|
|
3874
|
+
let pattern = `.${req.params.name}.localhost`
|
|
3875
|
+
if (router.endsWith(pattern)) {
|
|
3876
|
+
let name = router.replace(pattern, "")
|
|
3877
|
+
let api_path = this.kernel.path("api", name)
|
|
3878
|
+
let exists = await this.exists(api_path)
|
|
3879
|
+
if (exists) {
|
|
3880
|
+
let meta = await this.kernel.api.meta(name)
|
|
3881
|
+
if (meta.icon) {
|
|
3882
|
+
favicons[proc.external_ip] = meta.icon
|
|
3883
|
+
}
|
|
3884
|
+
if (meta.title) {
|
|
3885
|
+
titles[proc.external_ip] = meta.title
|
|
3886
|
+
}
|
|
3887
|
+
if (meta.description) {
|
|
3888
|
+
descriptions[proc.external_ip] = meta.description
|
|
3889
|
+
}
|
|
3835
3890
|
}
|
|
3836
|
-
|
|
3837
|
-
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
}
|
|
3894
|
+
// if not an app running inside pinokio, try to fetch and infer the favicon
|
|
3895
|
+
if (!favicons[proc.external_ip]) {
|
|
3896
|
+
if (protocol === "https") {
|
|
3897
|
+
if (proc.external_router.length > 0) {
|
|
3898
|
+
let favicon = await this.kernel.favicon.get("https://" + proc.external_router[0])
|
|
3899
|
+
if (favicon) {
|
|
3900
|
+
favicons[proc.external_ip] = favicon
|
|
3838
3901
|
}
|
|
3839
3902
|
}
|
|
3903
|
+
} else {
|
|
3904
|
+
let favicon = await this.kernel.favicon.get("http://" + proc.external_ip)
|
|
3905
|
+
if (favicon) {
|
|
3906
|
+
favicons[proc.external_ip] = favicon
|
|
3907
|
+
}
|
|
3840
3908
|
}
|
|
3841
3909
|
}
|
|
3842
3910
|
}
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
favicons[proc.external_ip] = favicon
|
|
3911
|
+
for (let external_ip in favicons) {
|
|
3912
|
+
let favicon_path = favicons[external_ip]
|
|
3913
|
+
if (!favicon_path.startsWith("http")) {
|
|
3914
|
+
favicons[external_ip] = "http://" + pinokio_ip + favicon_path
|
|
3848
3915
|
}
|
|
3849
3916
|
}
|
|
3850
3917
|
}
|
|
3851
|
-
for (let external_ip in favicons) {
|
|
3852
|
-
let favicon_path = favicons[external_ip]
|
|
3853
|
-
if (!favicon_path.startsWith("http")) {
|
|
3854
|
-
favicons[external_ip] = "http://" + pinokio_ip + favicon_path
|
|
3855
|
-
}
|
|
3856
|
-
}
|
|
3857
|
-
console.timeEnd("Favicon")
|
|
3858
|
-
console.log("favicons", favicons)
|
|
3859
|
-
|
|
3860
3918
|
let current_urls = await this.current_urls(req.originalUrl.slice(1))
|
|
3861
|
-
console.log("LIST", JSON.stringify(list, null, 2))
|
|
3862
3919
|
res.render("net", {
|
|
3863
3920
|
selected_name: req.params.name,
|
|
3864
3921
|
favicons,
|
|
@@ -4019,7 +4076,6 @@ class Server {
|
|
|
4019
4076
|
})
|
|
4020
4077
|
}))
|
|
4021
4078
|
this.app.post("/state", ex(async (req, res) => {
|
|
4022
|
-
console.log("POST /state", req.body)
|
|
4023
4079
|
/*
|
|
4024
4080
|
req.body := {
|
|
4025
4081
|
name: <name>,
|
|
@@ -4045,7 +4101,6 @@ class Server {
|
|
|
4045
4101
|
this.menu_hidden[req.body.name][req.body.type] = true
|
|
4046
4102
|
}
|
|
4047
4103
|
}
|
|
4048
|
-
console.log("select", req.body)
|
|
4049
4104
|
res.json({
|
|
4050
4105
|
success: true
|
|
4051
4106
|
})
|
|
@@ -4956,8 +5011,10 @@ class Server {
|
|
|
4956
5011
|
})
|
|
4957
5012
|
}))
|
|
4958
5013
|
this.app.get("/d/*", ex(async (req, res) => {
|
|
5014
|
+
console.log("> 1")
|
|
4959
5015
|
let filepath = Util.u2p(req.params[0])
|
|
4960
5016
|
let plugin = await this.getPluginGlobal(filepath)
|
|
5017
|
+
console.log("> 2")
|
|
4961
5018
|
let html = ""
|
|
4962
5019
|
let plugin_menu
|
|
4963
5020
|
try {
|
|
@@ -4967,12 +5024,14 @@ class Server {
|
|
|
4967
5024
|
plugin_menu = []
|
|
4968
5025
|
}
|
|
4969
5026
|
let current_urls = await this.current_urls(req.originalUrl.slice(1))
|
|
5027
|
+
console.log("> 3")
|
|
4970
5028
|
let retry = false
|
|
4971
5029
|
// if plugin_menu is empty, try again in 1 sec
|
|
4972
5030
|
if (plugin_menu.length === 0) {
|
|
4973
5031
|
retry = true
|
|
4974
5032
|
}
|
|
4975
5033
|
let venvs = await Util.find_venv(filepath)
|
|
5034
|
+
console.log("> 4")
|
|
4976
5035
|
let terminal
|
|
4977
5036
|
if (venvs.length > 0) {
|
|
4978
5037
|
let terminals = []
|
|
@@ -5016,6 +5075,7 @@ class Server {
|
|
|
5016
5075
|
})]
|
|
5017
5076
|
}
|
|
5018
5077
|
}
|
|
5078
|
+
console.log("> 5")
|
|
5019
5079
|
|
|
5020
5080
|
let exec_menus = []
|
|
5021
5081
|
let shell_menus = []
|
|
@@ -5045,6 +5105,7 @@ class Server {
|
|
|
5045
5105
|
exec_menus.sort((a, b) => { return a > b })
|
|
5046
5106
|
shell_menus.sort((a, b) => { return a > b })
|
|
5047
5107
|
}
|
|
5108
|
+
console.log("> 6")
|
|
5048
5109
|
let dynamic = [
|
|
5049
5110
|
{
|
|
5050
5111
|
icon: "fa-solid fa-robot",
|
|
@@ -5060,6 +5121,7 @@ class Server {
|
|
|
5060
5121
|
},
|
|
5061
5122
|
terminal,
|
|
5062
5123
|
]
|
|
5124
|
+
console.log("> 7")
|
|
5063
5125
|
res.render("d", {
|
|
5064
5126
|
retry,
|
|
5065
5127
|
current_urls,
|
|
@@ -5215,7 +5277,6 @@ class Server {
|
|
|
5215
5277
|
// await this.kernel.plugin.init()
|
|
5216
5278
|
let plugin = await this.getPlugin(req.params.name)
|
|
5217
5279
|
let html = ""
|
|
5218
|
-
console.log("plugin", JSON.stringify(plugin, null, 2))
|
|
5219
5280
|
let plugin_menu
|
|
5220
5281
|
if (plugin) {
|
|
5221
5282
|
if (plugin && plugin.menu && Array.isArray(plugin.menu)) {
|
|
@@ -5348,6 +5409,9 @@ class Server {
|
|
|
5348
5409
|
}))
|
|
5349
5410
|
this.app.get("/pinokio/peer", ex(async (req, res) => {
|
|
5350
5411
|
// await this.kernel.refresh()
|
|
5412
|
+
let current_peer_info = this.kernel.peer.current_host(this.kernel)
|
|
5413
|
+
res.json(current_peer_info)
|
|
5414
|
+
/*
|
|
5351
5415
|
res.json({
|
|
5352
5416
|
home: this.kernel.homedir,
|
|
5353
5417
|
arch: this.kernel.arch,
|
|
@@ -5360,6 +5424,7 @@ class Server {
|
|
|
5360
5424
|
router: this.kernel.router.published(),
|
|
5361
5425
|
memory: this.kernel.memory
|
|
5362
5426
|
})
|
|
5427
|
+
*/
|
|
5363
5428
|
}))
|
|
5364
5429
|
this.app.get("/pinokio/memory", ex((req, res) => {
|
|
5365
5430
|
let filepath = req.query.filepath
|
|
@@ -5431,25 +5496,25 @@ class Server {
|
|
|
5431
5496
|
}
|
|
5432
5497
|
}))
|
|
5433
5498
|
this.app.get("/pinokio/launch/:name", ex(async (req, res) => {
|
|
5434
|
-
this.chrome(req, res, "launch")
|
|
5499
|
+
await this.chrome(req, res, "launch")
|
|
5435
5500
|
}))
|
|
5436
5501
|
this.app.get("/pinokio/browser/:name/dev", ex(async (req, res) => {
|
|
5437
|
-
this.chrome(req, res, "browse")
|
|
5502
|
+
await this.chrome(req, res, "browse")
|
|
5438
5503
|
}))
|
|
5439
5504
|
this.app.get("/pinokio/browser/:name/browse", ex(async (req, res) => {
|
|
5440
|
-
this.chrome(req, res, "browse")
|
|
5505
|
+
await this.chrome(req, res, "browse")
|
|
5441
5506
|
}))
|
|
5442
5507
|
this.app.get("/pinokio/browser/:name", ex(async (req, res) => {
|
|
5443
|
-
this.chrome(req, res, "run")
|
|
5508
|
+
await this.chrome(req, res, "run")
|
|
5444
5509
|
}))
|
|
5445
5510
|
this.app.get("/p/:name/dev", ex(async (req, res) => {
|
|
5446
|
-
this.chrome(req, res, "browse")
|
|
5511
|
+
await this.chrome(req, res, "browse")
|
|
5447
5512
|
}))
|
|
5448
5513
|
this.app.get("/p/:name/browse", ex(async (req, res) => {
|
|
5449
|
-
this.chrome(req, res, "browse")
|
|
5514
|
+
await this.chrome(req, res, "browse")
|
|
5450
5515
|
}))
|
|
5451
5516
|
this.app.get("/p/:name", ex(async (req, res) => {
|
|
5452
|
-
this.chrome(req, res, "run")
|
|
5517
|
+
await this.chrome(req, res, "run")
|
|
5453
5518
|
}))
|
|
5454
5519
|
this.app.post("/pinokio/delete", ex(async (req, res) => {
|
|
5455
5520
|
try {
|
|
@@ -3,6 +3,7 @@ const ModalInput = async (params, uri) => {
|
|
|
3
3
|
{
|
|
4
4
|
title,
|
|
5
5
|
type: "modal" (default) |"notify"
|
|
6
|
+
confirm: "OK",
|
|
6
7
|
form: [{
|
|
7
8
|
type,
|
|
8
9
|
items,
|
|
@@ -20,6 +21,7 @@ const ModalInput = async (params, uri) => {
|
|
|
20
21
|
let description = (params.description ? `<div class='desc'>${params.description}</div>` : "")
|
|
21
22
|
let result = await Swal.fire({
|
|
22
23
|
title: (params.title || ""),
|
|
24
|
+
customClass: params.customClass,
|
|
23
25
|
html: description + form.map((field) => {
|
|
24
26
|
let type = (field.type ? field.type : "text")
|
|
25
27
|
let autofocus = (field.autofocus ? "autofocus" : "")
|
|
@@ -68,7 +70,7 @@ const ModalInput = async (params, uri) => {
|
|
|
68
70
|
}
|
|
69
71
|
}).join("\n"),
|
|
70
72
|
//focusConfirm: false,
|
|
71
|
-
confirmButtonText: 'Done',
|
|
73
|
+
confirmButtonText: params.confirm || 'Done',
|
|
72
74
|
didRender: () => {
|
|
73
75
|
Swal.getPopup().querySelectorAll('[data-type=file]').forEach((el, index) => {
|
|
74
76
|
const dz = new Dropzone(el, {
|
package/server/views/500.ejs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<meta charset="UTF-8">
|
|
4
4
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
5
5
|
<style>
|
|
6
|
-
body
|
|
6
|
+
body.error-body {
|
|
7
7
|
width: 100%;
|
|
8
8
|
margin: 0;
|
|
9
9
|
background: royalblue;
|
|
@@ -20,26 +20,27 @@ h1 {
|
|
|
20
20
|
pre {
|
|
21
21
|
width: 100%;
|
|
22
22
|
}
|
|
23
|
-
footer {
|
|
23
|
+
body.error-body footer.error-footer {
|
|
24
|
+
display: block;
|
|
24
25
|
border-left: 4px solid white;
|
|
25
26
|
padding: 10px 20px;
|
|
26
27
|
margin-top: 50px;
|
|
27
28
|
}
|
|
28
|
-
footer ol {
|
|
29
|
+
body.error-body footer.error-footer ol {
|
|
29
30
|
padding-inline-start: 20px;
|
|
30
31
|
margin: 0;
|
|
31
32
|
padding-top: 10px;
|
|
32
33
|
}
|
|
33
|
-
footer a {
|
|
34
|
+
body.error-body footer.error-footer a {
|
|
34
35
|
color: white;
|
|
35
36
|
font-weight: bold;
|
|
36
37
|
}
|
|
37
38
|
</style>
|
|
38
39
|
</head>
|
|
39
|
-
<body>
|
|
40
|
+
<body class='error-body'>
|
|
40
41
|
<h1>Error</h1>
|
|
41
42
|
<pre><%=stack%></pre>
|
|
42
|
-
<footer>
|
|
43
|
+
<footer class='error-footer'>
|
|
43
44
|
<div>You may want to try:</div>
|
|
44
45
|
<ol>
|
|
45
46
|
<li>Update Pinokio: Simply install the latest version, it should only update the app binary while keeping all the data in tact. <a href="<%=install%>" target="_blank">Go to Download Page</a></li>
|
package/server/views/app.ejs
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
<link href="/filepond-plugin-image-preview.min.css" rel="stylesheet" />
|
|
14
14
|
<link href="/filepond-plugin-image-edit.min.css" rel="stylesheet" />
|
|
15
15
|
<link href="/style.css" rel="stylesheet"/>
|
|
16
|
+
<script src="/modalinput.js"></script>
|
|
16
17
|
<% if (agent === "electron") { %>
|
|
17
18
|
<link href="/electron.css" rel="stylesheet"/>
|
|
18
19
|
<% } %>
|
|
@@ -623,7 +624,9 @@ nav .logo {
|
|
|
623
624
|
}
|
|
624
625
|
.error-message {
|
|
625
626
|
width: 100%;
|
|
627
|
+
/*
|
|
626
628
|
background: royalblue !important;
|
|
629
|
+
*/
|
|
627
630
|
color: white;
|
|
628
631
|
display: flex;
|
|
629
632
|
justify-content: center;
|
|
@@ -1161,7 +1164,7 @@ body.dark .mode-selector .btn2.selected {
|
|
|
1161
1164
|
<% if (error) { %>
|
|
1162
1165
|
<div class='error-message'>
|
|
1163
1166
|
<div>
|
|
1164
|
-
<h1>Error</h1>
|
|
1167
|
+
<h1><i class="fa-solid fa-triangle-exclamation"></i> Error</h1>
|
|
1165
1168
|
<div><%=error%></div>
|
|
1166
1169
|
</div>
|
|
1167
1170
|
</div>
|
|
@@ -2190,9 +2193,23 @@ body.dark .mode-selector .btn2.selected {
|
|
|
2190
2193
|
const try_dynamic = async () => {
|
|
2191
2194
|
console.log("Try_dynamic")
|
|
2192
2195
|
let rendered
|
|
2196
|
+
let status
|
|
2193
2197
|
const dynamic = await fetch("<%=dynamic%>").then((res) => {
|
|
2198
|
+
status = res.status
|
|
2194
2199
|
return res.text()
|
|
2195
2200
|
})
|
|
2201
|
+
console.log("STatus", status)
|
|
2202
|
+
if (status == 500) {
|
|
2203
|
+
ModalInput({
|
|
2204
|
+
description: dynamic,
|
|
2205
|
+
confirm: "OK",
|
|
2206
|
+
customClass: {
|
|
2207
|
+
popup: "full-popup",
|
|
2208
|
+
title: "full-title"
|
|
2209
|
+
}
|
|
2210
|
+
})
|
|
2211
|
+
return
|
|
2212
|
+
}
|
|
2196
2213
|
if (dynamic && dynamic.length > 0) {
|
|
2197
2214
|
console.log({ dynamic })
|
|
2198
2215
|
if (document.querySelector(".dynamic .submenu")) {
|
|
@@ -2233,9 +2250,23 @@ body.dark .mode-selector .btn2.selected {
|
|
|
2233
2250
|
}, 1000)
|
|
2234
2251
|
})
|
|
2235
2252
|
}
|
|
2253
|
+
let status
|
|
2236
2254
|
const html = await fetch("<%=sidebar%>").then((res) => {
|
|
2255
|
+
status = res.status
|
|
2237
2256
|
return res.text()
|
|
2238
2257
|
})
|
|
2258
|
+
console.log({ status })
|
|
2259
|
+
if (status == 500) {
|
|
2260
|
+
ModalInput({
|
|
2261
|
+
description: html,
|
|
2262
|
+
confirm: "OK",
|
|
2263
|
+
customClass: {
|
|
2264
|
+
popup: "full-popup",
|
|
2265
|
+
title: "full-title"
|
|
2266
|
+
}
|
|
2267
|
+
})
|
|
2268
|
+
return
|
|
2269
|
+
}
|
|
2239
2270
|
document.querySelector(".menu").innerHTML = html
|
|
2240
2271
|
|
|
2241
2272
|
<% if (type !== 'run') { %>
|