pinokiod 3.2.148 → 3.2.150
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/python/index.js +32 -6
- package/package.json +1 -1
- package/server/index.js +16 -0
- package/server/views/app.ejs +55 -41
package/kernel/python/index.js
CHANGED
|
@@ -6,8 +6,40 @@ class Python {
|
|
|
6
6
|
}
|
|
7
7
|
async call(modname, modpath, method, args, ondata) {
|
|
8
8
|
console.log("CALL", { modname, modpath, method, args })
|
|
9
|
+
let res
|
|
10
|
+
for(let i=0; i<5; i++) {
|
|
11
|
+
console.log(`call attempt: ${i}`)
|
|
12
|
+
ondata({
|
|
13
|
+
raw: `\r\ncall attempt: ${i}\r\n`
|
|
14
|
+
})
|
|
15
|
+
res = await this._call(modname, modpath, method, args, ondata)
|
|
16
|
+
if (res) {
|
|
17
|
+
console.log("request successful")
|
|
18
|
+
ondata({
|
|
19
|
+
raw: "\r\nrequest successful\r\n"
|
|
20
|
+
})
|
|
21
|
+
break
|
|
22
|
+
} else {
|
|
23
|
+
console.log("request unsuccessful. retrying in 3 seconds...")
|
|
24
|
+
ondata({
|
|
25
|
+
raw: "\r\nrequest unsuccessful. retrying in 3 seconds...\r\n"
|
|
26
|
+
})
|
|
27
|
+
await new Promise((resolve, reject) => {
|
|
28
|
+
setTimeout(() => {
|
|
29
|
+
resolve()
|
|
30
|
+
}, 3000)
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return res
|
|
35
|
+
}
|
|
36
|
+
async _call(modname, modpath, method, args, ondata) {
|
|
9
37
|
// if this.proc doesn't exist, create
|
|
10
38
|
if (!this.proc) {
|
|
39
|
+
console.log("python rpc server not running. starting...")
|
|
40
|
+
ondata({
|
|
41
|
+
raw: "\r\npython rpc server not running. starting...\r\n"
|
|
42
|
+
})
|
|
11
43
|
await new Promise((resolve, reject) => {
|
|
12
44
|
this.kernel.exec({
|
|
13
45
|
message: "uvicorn --port 42001 server:app",
|
|
@@ -20,12 +52,6 @@ class Python {
|
|
|
20
52
|
}
|
|
21
53
|
})
|
|
22
54
|
})
|
|
23
|
-
console.log("Server Started")
|
|
24
|
-
await new Promise((resolve, reject) => {
|
|
25
|
-
setTimeout(() => {
|
|
26
|
-
resolve()
|
|
27
|
-
}, 3000)
|
|
28
|
-
})
|
|
29
55
|
}
|
|
30
56
|
|
|
31
57
|
try {
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -226,6 +226,18 @@ class Server {
|
|
|
226
226
|
let rawpath = "/api/" + name
|
|
227
227
|
let config = (await this.kernel.loader.load(app_path)).resolved
|
|
228
228
|
|
|
229
|
+
let error = null
|
|
230
|
+
if (config && config.version) {
|
|
231
|
+
let coerced = semver.coerce(config.version)
|
|
232
|
+
console.log("version", { coerced, v: config.version })
|
|
233
|
+
if (semver.satisfies(coerced, this.kernel.schema)) {
|
|
234
|
+
console.log("semver satisfied", config.version, this.kernel.schema)
|
|
235
|
+
} else {
|
|
236
|
+
console.log("semver NOT satisfied", config.version, this.kernel.schema)
|
|
237
|
+
error = `Please update Pinokio to the latest version (current script version: ${config.version}, supported: ${this.kernel.schema}`
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
229
241
|
|
|
230
242
|
|
|
231
243
|
// let requires_instantiation = false
|
|
@@ -316,6 +328,7 @@ class Server {
|
|
|
316
328
|
const env = await this.kernel.env("api/" + name)
|
|
317
329
|
|
|
318
330
|
res.render("app", {
|
|
331
|
+
error,
|
|
319
332
|
env,
|
|
320
333
|
mode,
|
|
321
334
|
port: this.port,
|
|
@@ -398,6 +411,7 @@ class Server {
|
|
|
398
411
|
} catch (e) {
|
|
399
412
|
// console.log("ERROR", e)
|
|
400
413
|
}
|
|
414
|
+
|
|
401
415
|
}
|
|
402
416
|
|
|
403
417
|
// if (pathComponents.length > 1) {
|
|
@@ -1159,6 +1173,7 @@ class Server {
|
|
|
1159
1173
|
let p = path.resolve(uri, item.name, "pinokio.js")
|
|
1160
1174
|
let config = (await this.kernel.loader.load(p)).resolved
|
|
1161
1175
|
if (config) {
|
|
1176
|
+
/*
|
|
1162
1177
|
if (config.version) {
|
|
1163
1178
|
let coerced = semver.coerce(config.version)
|
|
1164
1179
|
console.log("version", { coerced, v: config.version })
|
|
@@ -1169,6 +1184,7 @@ class Server {
|
|
|
1169
1184
|
error = `Please update Pinokio to the latest version (current script version: ${config.version}, supported: ${this.kernel.schema}`
|
|
1170
1185
|
}
|
|
1171
1186
|
}
|
|
1187
|
+
*/
|
|
1172
1188
|
// if (config.run) {
|
|
1173
1189
|
// items[i].run = config.run
|
|
1174
1190
|
// }
|
package/server/views/app.ejs
CHANGED
|
@@ -399,6 +399,20 @@ nav .logo {
|
|
|
399
399
|
font-size: 14px;
|
|
400
400
|
padding: 10px;
|
|
401
401
|
}
|
|
402
|
+
nav.error-message .btn {
|
|
403
|
+
letter-spacing: 0px;
|
|
404
|
+
background: royalblue;
|
|
405
|
+
font-size: 20px;
|
|
406
|
+
padding: 10px 20px;
|
|
407
|
+
}
|
|
408
|
+
nav.error-message {
|
|
409
|
+
background: yellow !important;
|
|
410
|
+
flex-grow: 1;
|
|
411
|
+
padding: 50px;
|
|
412
|
+
font-size: 40px;
|
|
413
|
+
color: black;
|
|
414
|
+
letter-spacing: -2px;
|
|
415
|
+
}
|
|
402
416
|
body.dark #location {
|
|
403
417
|
color: white;
|
|
404
418
|
}
|
|
@@ -550,14 +564,6 @@ body.dark .loader-container {
|
|
|
550
564
|
</head>
|
|
551
565
|
<body class='<%=theme%>' data-platform="<%=platform%>">
|
|
552
566
|
<aside class='active'>
|
|
553
|
-
<!--
|
|
554
|
-
<div class='footer'>
|
|
555
|
-
<button class='btn header-item' id='clone-tab'><i class='fa-regular fa-copy'></i></button>
|
|
556
|
-
<a class='btn header-item' id='open-browser' target="_blank" href="" features="browser"><i class="fa-solid fa-square-arrow-up-right"></i></a>
|
|
557
|
-
<button class='btn header-item' id='reload'><i class="fa-solid fa-rotate-right"></i></button>
|
|
558
|
-
<div id='new-tab' class='btn header-item'><i class="fa-solid fa-plus"></i></div>
|
|
559
|
-
</div>
|
|
560
|
-
-->
|
|
561
567
|
<div class='header-top header-item'>
|
|
562
568
|
<div class='app-info'>
|
|
563
569
|
<% if (config.icon) { %>
|
|
@@ -622,41 +628,49 @@ body.dark .loader-container {
|
|
|
622
628
|
</div>
|
|
623
629
|
-->
|
|
624
630
|
</aside>
|
|
625
|
-
|
|
626
|
-
<nav>
|
|
627
|
-
<div class=
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
<img src="<%=rawpath%>/<%=config.icon%>?raw=true"/>
|
|
631
|
-
<i class="fa-solid fa-arrow-right-to-bracket fa-rotate-180"></i>
|
|
632
|
-
</button>
|
|
633
|
-
<% if (agent === "electron") { %>
|
|
634
|
-
<button class='btn2' id='back'><i class="fa-solid fa-chevron-left"></i></button>
|
|
635
|
-
<button class='btn2' id='forward'><i class="fa-solid fa-chevron-right"></i></button>
|
|
636
|
-
<% } %>
|
|
637
|
-
<button class='btn2' id='reload'><i class="fa-solid fa-rotate-right"></i> Refresh</button>
|
|
638
|
-
<% if (agent === "electron") { %>
|
|
639
|
-
<a class='btn2' id='open-browser' target="_blank" href="" features="browser"><i class="fa-solid fa-square-arrow-up-right"></i> Popout</a>
|
|
640
|
-
<% } else { %>
|
|
641
|
-
<a class='btn2' id='open-browser' target="_blank" href=""><i class="fa-solid fa-square-arrow-up-right"></i> Popout</a>
|
|
642
|
-
<% } %>
|
|
643
|
-
<button class='btn2' id='clone-tab'><i class='fa-regular fa-copy'></i> Clone</button>
|
|
644
|
-
<div id='new-tab' class='btn2'><i class="fa-solid fa-plus"></i> Tab</div>
|
|
645
|
-
<input type='url' id='location' readonly>
|
|
646
|
-
</div>
|
|
631
|
+
<% if (error) { %>
|
|
632
|
+
<nav class='error-message'>
|
|
633
|
+
<div><i class="fa-solid fa-rotate"></i> <%=error%></div>
|
|
634
|
+
<div class='flexible'></div>
|
|
635
|
+
<a class='btn' target="_blank" href="https://program.pinokio.computer/#/?id=install">Download</a>
|
|
647
636
|
</nav>
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
637
|
+
<% } else { %>
|
|
638
|
+
<div class='container'>
|
|
639
|
+
<nav>
|
|
640
|
+
<div class='bar'>
|
|
641
|
+
<button class='btn2' id='menu-mobile'><i class="fa-solid fa-bars"></i></button>
|
|
642
|
+
<button class='btn2' id='menu'>
|
|
643
|
+
<img src="<%=rawpath%>/<%=config.icon%>?raw=true"/>
|
|
644
|
+
<i class="fa-solid fa-arrow-right-to-bracket fa-rotate-180"></i>
|
|
645
|
+
</button>
|
|
646
|
+
<% if (agent === "electron") { %>
|
|
647
|
+
<button class='btn2' id='back'><i class="fa-solid fa-chevron-left"></i></button>
|
|
648
|
+
<button class='btn2' id='forward'><i class="fa-solid fa-chevron-right"></i></button>
|
|
649
|
+
<% } %>
|
|
650
|
+
<button class='btn2' id='reload'><i class="fa-solid fa-rotate-right"></i> Refresh</button>
|
|
651
|
+
<% if (agent === "electron") { %>
|
|
652
|
+
<a class='btn2' id='open-browser' target="_blank" href="" features="browser"><i class="fa-solid fa-square-arrow-up-right"></i> Popout</a>
|
|
653
|
+
<% } else { %>
|
|
654
|
+
<a class='btn2' id='open-browser' target="_blank" href=""><i class="fa-solid fa-square-arrow-up-right"></i> Popout</a>
|
|
655
|
+
<% } %>
|
|
656
|
+
<button class='btn2' id='clone-tab'><i class='fa-regular fa-copy'></i> Clone</button>
|
|
657
|
+
<div id='new-tab' class='btn2'><i class="fa-solid fa-plus"></i> Tab</div>
|
|
658
|
+
<input type='url' id='location' readonly>
|
|
659
|
+
</div>
|
|
660
|
+
</nav>
|
|
661
|
+
<main class='browserview'>
|
|
662
|
+
<% if (false) { %>
|
|
663
|
+
<% if (config.menu) { %>
|
|
664
|
+
<% config.menu.forEach((item) => { %>
|
|
665
|
+
<% if (item.btn && item.src) { %>
|
|
666
|
+
<iframe name='<%=item.src%>' class='hidden'></iframe>
|
|
667
|
+
<% } %>
|
|
668
|
+
<% }) %>
|
|
669
|
+
<% } %>
|
|
656
670
|
<% } %>
|
|
657
|
-
|
|
658
|
-
</
|
|
659
|
-
|
|
671
|
+
</main>
|
|
672
|
+
</div>
|
|
673
|
+
<% } %>
|
|
660
674
|
<script>
|
|
661
675
|
let loaded = {}
|
|
662
676
|
let cursorIndex = 0;
|