pinokiod 1.3.38 → 1.3.40
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/cloudflare/index.js +44 -1
- package/package.json +2 -1
- package/server/index.js +19 -8
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
const { yellow, green, blue } = require('kleur');
|
|
2
|
+
const QRCode = require('qrcode');
|
|
1
3
|
class C {
|
|
2
|
-
async
|
|
4
|
+
async tunnel (req, ondata, kernel) {
|
|
3
5
|
/*
|
|
4
6
|
{
|
|
5
7
|
"method": "cloundflare.tunnel",
|
|
@@ -10,6 +12,47 @@ class C {
|
|
|
10
12
|
|
|
11
13
|
=> cloudflared tunnel --url http://localhost:8080
|
|
12
14
|
*/
|
|
15
|
+
const message = `cloudflared tunnel --url ${req.params.uri}`
|
|
16
|
+
let params = {
|
|
17
|
+
id: message,
|
|
18
|
+
message
|
|
19
|
+
}
|
|
20
|
+
if (req.client) {
|
|
21
|
+
params.rows = req.client.rows
|
|
22
|
+
params.cols = req.client.cols
|
|
23
|
+
}
|
|
24
|
+
let options = {}
|
|
25
|
+
if (req.cwd) options.cwd = req.cwd
|
|
26
|
+
if (req.parent && req.parent.path) options.group = req.parent.path
|
|
27
|
+
console.log("shells before", kernel.shell.shells)
|
|
28
|
+
let pattern = /(https:.+?trycloudflare\.com)/
|
|
29
|
+
let cloudflare_url = await new Promise((resolve, reject) => {
|
|
30
|
+
kernel.shell.start(params, options, (e) => {
|
|
31
|
+
ondata(e)
|
|
32
|
+
let test = pattern.exec(e.cleaned)
|
|
33
|
+
if (test && test.length > 0) {
|
|
34
|
+
resolve(test[1])
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
console.log("cloudflare_url", cloudflare_url)
|
|
39
|
+
|
|
40
|
+
ondata({ raw: yellow("\r\n## Scan the QR code to open in any device\r\n\r\n") })
|
|
41
|
+
ondata({ raw: blue(`${cloudflare_url}\r\n\r\n`) })
|
|
42
|
+
|
|
43
|
+
await new Promise((resolve, reject) => {
|
|
44
|
+
QRCode.toString(cloudflare_url, {
|
|
45
|
+
type: "terminal"
|
|
46
|
+
}, function(err, data) {
|
|
47
|
+
ondata({ raw: green(data).replaceAll("\n", "\r\n") })
|
|
48
|
+
ondata({ raw: "\r\n" })
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
resolve()
|
|
51
|
+
}, 2000)
|
|
52
|
+
});
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
return { uri: cloudflare_url }
|
|
13
56
|
}
|
|
14
57
|
async stop (req, ondata, kernel) {
|
|
15
58
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pinokiod",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.40",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"jsdom": "^24.0.0",
|
|
38
38
|
"jsonpath-plus": "^7.2.0",
|
|
39
39
|
"key-store": "^1.2.0",
|
|
40
|
+
"kleur": "^4.1.5",
|
|
40
41
|
"lodash": "^4.17.21",
|
|
41
42
|
"lproxy": "^0.0.9",
|
|
42
43
|
"marked": "^5.0.1",
|
package/server/index.js
CHANGED
|
@@ -355,10 +355,6 @@ class Server {
|
|
|
355
355
|
type: "conda",
|
|
356
356
|
name: ["nodejs", "ffmpeg"],
|
|
357
357
|
args: "-c conda-forge"
|
|
358
|
-
}, {
|
|
359
|
-
name: "py"
|
|
360
|
-
}, {
|
|
361
|
-
name: "cloudflared"
|
|
362
358
|
}]
|
|
363
359
|
let platform = os.platform()
|
|
364
360
|
if (platform === "win32") {
|
|
@@ -369,11 +365,22 @@ class Server {
|
|
|
369
365
|
name: "vs"
|
|
370
366
|
})
|
|
371
367
|
}
|
|
368
|
+
if (platform === "darwin") {
|
|
369
|
+
requirements.push({
|
|
370
|
+
name: "brew"
|
|
371
|
+
})
|
|
372
|
+
}
|
|
372
373
|
if (this.kernel.gpu === "nvidia") {
|
|
373
374
|
requirements.push({
|
|
374
375
|
name: "cuda"
|
|
375
376
|
})
|
|
376
377
|
}
|
|
378
|
+
requirements = requirements.concat([{
|
|
379
|
+
name: "py"
|
|
380
|
+
}, {
|
|
381
|
+
name: "cloudflared"
|
|
382
|
+
}])
|
|
383
|
+
|
|
377
384
|
let requirements_pending = !this.kernel.bin.installed_initialized
|
|
378
385
|
|
|
379
386
|
|
|
@@ -616,16 +623,15 @@ class Server {
|
|
|
616
623
|
type: "conda",
|
|
617
624
|
name: ["nodejs", "ffmpeg"],
|
|
618
625
|
args: "-c conda-forge"
|
|
619
|
-
}, {
|
|
620
|
-
name: "py"
|
|
621
|
-
}, {
|
|
622
|
-
name: "cloudflared"
|
|
623
626
|
}]
|
|
624
627
|
let platform = os.platform()
|
|
625
628
|
if (platform === "win32") {
|
|
626
629
|
requirements.push({
|
|
627
630
|
name: "registry"
|
|
628
631
|
})
|
|
632
|
+
requirements.push({
|
|
633
|
+
name: "vs"
|
|
634
|
+
})
|
|
629
635
|
}
|
|
630
636
|
if (platform === "darwin") {
|
|
631
637
|
requirements.push({
|
|
@@ -637,6 +643,11 @@ class Server {
|
|
|
637
643
|
name: "cuda"
|
|
638
644
|
})
|
|
639
645
|
}
|
|
646
|
+
requirements = requirements.concat([{
|
|
647
|
+
name: "py"
|
|
648
|
+
}, {
|
|
649
|
+
name: "cloudflared"
|
|
650
|
+
}])
|
|
640
651
|
// if (platform === "linux") {
|
|
641
652
|
// requirements.push({
|
|
642
653
|
// name: "brew"
|