pinokiod 3.6.27 → 3.6.29
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 +0 -2
- package/kernel/bin/index.js +0 -51
- package/kernel/index.js +3 -25
- package/kernel/shell.js +15 -25
- package/kernel/shells.js +0 -1
- package/kernel/sysinfo.js +16 -5
- package/kernel/util.js +6 -6
- package/package.json +1 -1
- package/script/index.js +0 -12
- package/server/index.js +79 -100
- package/server/socket.js +0 -6
- package/server/views/terminal.ejs +0 -19
- package/kernel/store.js +0 -58
package/kernel/api/index.js
CHANGED
|
@@ -795,7 +795,6 @@ class Api {
|
|
|
795
795
|
} else {
|
|
796
796
|
// 11. actually make the rpc call
|
|
797
797
|
result = await this.run(resolved.method, rpc, (stream, type) => {
|
|
798
|
-
console.log("RUN RESULT", { stream ,type })
|
|
799
798
|
let m = {
|
|
800
799
|
id: request.path,
|
|
801
800
|
caller: request.caller,
|
|
@@ -819,7 +818,6 @@ class Api {
|
|
|
819
818
|
// }
|
|
820
819
|
this.ondata(m)
|
|
821
820
|
})
|
|
822
|
-
console.log("EXEC RESULT", { result })
|
|
823
821
|
}
|
|
824
822
|
|
|
825
823
|
|
package/kernel/bin/index.js
CHANGED
|
@@ -588,57 +588,6 @@ class Bin {
|
|
|
588
588
|
}
|
|
589
589
|
// }
|
|
590
590
|
}
|
|
591
|
-
async install2(req, ondata) {
|
|
592
|
-
let requirements = [{
|
|
593
|
-
name: "conda",
|
|
594
|
-
}, {
|
|
595
|
-
name: "git",
|
|
596
|
-
}, {
|
|
597
|
-
name: "zip",
|
|
598
|
-
}, {
|
|
599
|
-
name: "node",
|
|
600
|
-
}, {
|
|
601
|
-
name: "ffmpeg",
|
|
602
|
-
}]
|
|
603
|
-
let platform = os.platform()
|
|
604
|
-
if (platform === "win32") {
|
|
605
|
-
requirements.push({
|
|
606
|
-
name: "registry"
|
|
607
|
-
})
|
|
608
|
-
requirements.push({
|
|
609
|
-
name: "vs"
|
|
610
|
-
})
|
|
611
|
-
}
|
|
612
|
-
if (platform === "darwin") {
|
|
613
|
-
requirements.push({
|
|
614
|
-
name: "brew"
|
|
615
|
-
})
|
|
616
|
-
}
|
|
617
|
-
if (platform === "linux") {
|
|
618
|
-
requirements.push({
|
|
619
|
-
name: "gxx"
|
|
620
|
-
})
|
|
621
|
-
}
|
|
622
|
-
if (this.kernel.gpu === "nvidia") {
|
|
623
|
-
requirements.push({
|
|
624
|
-
name: "cuda"
|
|
625
|
-
})
|
|
626
|
-
}
|
|
627
|
-
requirements = requirements.concat([{
|
|
628
|
-
name: "py"
|
|
629
|
-
}, {
|
|
630
|
-
name: "cloudflared"
|
|
631
|
-
}, {
|
|
632
|
-
name: "playwright"
|
|
633
|
-
}, {
|
|
634
|
-
name: "huggingface"
|
|
635
|
-
}, {
|
|
636
|
-
name: "uv"
|
|
637
|
-
}])
|
|
638
|
-
req.params = JSON.stringify(requirements)
|
|
639
|
-
let res = await this.install(req, ondata)
|
|
640
|
-
return res
|
|
641
|
-
}
|
|
642
591
|
async install(req, ondata) {
|
|
643
592
|
/*
|
|
644
593
|
req.params := {
|
package/kernel/index.js
CHANGED
|
@@ -26,7 +26,6 @@ const Config = require("./pinokio.json")
|
|
|
26
26
|
const Info = require('./info')
|
|
27
27
|
const Pipe = require("../pipe")
|
|
28
28
|
const Cloudflare = require('./api/cloudflare')
|
|
29
|
-
const Store = require('./store')
|
|
30
29
|
const VARS = {
|
|
31
30
|
pip: {
|
|
32
31
|
install: {
|
|
@@ -40,32 +39,10 @@ class Kernel {
|
|
|
40
39
|
//schema = ">=1.0.0"
|
|
41
40
|
//schema = "<=2.1.0"
|
|
42
41
|
//schema = "<=3.2.0"
|
|
43
|
-
schema = "<=3.
|
|
42
|
+
schema = "<=3.7.0"
|
|
44
43
|
constructor(store) {
|
|
45
44
|
this.fetch = fetch
|
|
46
|
-
|
|
47
|
-
// STORE
|
|
48
|
-
// Previously custom STORE could be passed in. This was to support both electron and server based initialization
|
|
49
|
-
// But this creates complexity because the store location is not fixed
|
|
50
|
-
// Migrating it to ~/.pinokio/config.json
|
|
51
|
-
//
|
|
52
|
-
// 1. does ~/.pinokio exist?
|
|
53
|
-
// - load from that file
|
|
54
|
-
// 2. does ~/.pinokio NOT exist?
|
|
55
|
-
// - save the passed in options to the `~/.pinokio`
|
|
56
|
-
// - load the config
|
|
57
|
-
|
|
58
|
-
this.store = new Store()
|
|
59
|
-
let exists = this.store.exists()
|
|
60
|
-
console.log("Store exists?", exists)
|
|
61
|
-
if (!exists) {
|
|
62
|
-
console.log("doesn't exist")
|
|
63
|
-
// clone the store to the new store
|
|
64
|
-
this.store.clone(store.store)
|
|
65
|
-
// load from the store (this will be the last time this is used, since the next time it loads, it will load from the new store)
|
|
66
|
-
}
|
|
67
|
-
console.log("this.store", this.store.store())
|
|
68
|
-
|
|
45
|
+
this.store = store
|
|
69
46
|
this.arch = os.arch()
|
|
70
47
|
this.os = os
|
|
71
48
|
this.platform = os.platform()
|
|
@@ -692,6 +669,7 @@ class Kernel {
|
|
|
692
669
|
this.template.update(info)
|
|
693
670
|
this.sysinfo = info
|
|
694
671
|
this.gpu = info.gpu
|
|
672
|
+
this.gpu_model = info.gpu_model
|
|
695
673
|
this.gpus = info.gpus
|
|
696
674
|
} catch (e) {
|
|
697
675
|
console.log("sysinfo error", e)
|
package/kernel/shell.js
CHANGED
|
@@ -274,12 +274,11 @@ class Shell {
|
|
|
274
274
|
return response
|
|
275
275
|
} else {
|
|
276
276
|
let response = await this.request(params, async (stream) => {
|
|
277
|
-
if (
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
// }
|
|
277
|
+
if (stream.prompt) {
|
|
278
|
+
this.resolve()
|
|
279
|
+
} else {
|
|
280
|
+
if (ondata) ondata(stream)
|
|
281
|
+
}
|
|
283
282
|
})
|
|
284
283
|
return response
|
|
285
284
|
}
|
|
@@ -288,10 +287,7 @@ class Shell {
|
|
|
288
287
|
}
|
|
289
288
|
emit(message) {
|
|
290
289
|
if (this.ptyProcess) {
|
|
291
|
-
|
|
292
|
-
if (this.input) {
|
|
293
|
-
this.ptyProcess.write(message)
|
|
294
|
-
}
|
|
290
|
+
this.ptyProcess.write(message)
|
|
295
291
|
}
|
|
296
292
|
}
|
|
297
293
|
send(message, newline, cb) {
|
|
@@ -373,9 +369,6 @@ class Shell {
|
|
|
373
369
|
|
|
374
370
|
// not connected => make a new connection => which means get a new prompt
|
|
375
371
|
// if already connected => no need for a new prompt
|
|
376
|
-
if (params.input) {
|
|
377
|
-
this.input = params.input
|
|
378
|
-
}
|
|
379
372
|
if (params.persistent) {
|
|
380
373
|
this.persistent = params.persistent
|
|
381
374
|
}
|
|
@@ -907,7 +900,6 @@ class Shell {
|
|
|
907
900
|
}
|
|
908
901
|
}
|
|
909
902
|
kill(message, force) {
|
|
910
|
-
console.log("KILL")
|
|
911
903
|
|
|
912
904
|
this.done = true
|
|
913
905
|
this.ready = false
|
|
@@ -1015,7 +1007,6 @@ ${cleaned}
|
|
|
1015
1007
|
|
|
1016
1008
|
}
|
|
1017
1009
|
stream(msg, callback) {
|
|
1018
|
-
console.log("vt write", msg)
|
|
1019
1010
|
this.vt.write(msg, () => {
|
|
1020
1011
|
let buf = this.vts.serialize()
|
|
1021
1012
|
let cleaned = this.stripAnsi(buf)
|
|
@@ -1025,7 +1016,6 @@ ${cleaned}
|
|
|
1025
1016
|
cleaned,
|
|
1026
1017
|
state: cleaned
|
|
1027
1018
|
}
|
|
1028
|
-
console.log({ response })
|
|
1029
1019
|
if (this.cb) this.cb(response)
|
|
1030
1020
|
|
|
1031
1021
|
// Decide whether to kill or continue
|
|
@@ -1040,15 +1030,15 @@ ${cleaned}
|
|
|
1040
1030
|
// todo: may need to handle cases when the command returns immediately with no output (example: 'which brew' returns immediately with no text if brew doesn't exist)
|
|
1041
1031
|
setTimeout(() => {
|
|
1042
1032
|
if (cache === cleaned) {
|
|
1043
|
-
if (this.
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1033
|
+
if (this.persistent) {
|
|
1034
|
+
if (this.cb) this.cb({
|
|
1035
|
+
//raw: cached_msg,
|
|
1036
|
+
//raw: msg,
|
|
1037
|
+
//raw: "",
|
|
1038
|
+
cleaned,
|
|
1039
|
+
state: cleaned,
|
|
1040
|
+
prompt: true
|
|
1041
|
+
})
|
|
1052
1042
|
callback()
|
|
1053
1043
|
} else {
|
|
1054
1044
|
callback()
|
package/kernel/shells.js
CHANGED
package/kernel/sysinfo.js
CHANGED
|
@@ -29,24 +29,34 @@ class Sysinfo {
|
|
|
29
29
|
let g = await system.graphics()
|
|
30
30
|
let gpus
|
|
31
31
|
if (g && g.controllers && g.controllers.length > 0) {
|
|
32
|
-
gpus = g.controllers.map((x) => {
|
|
32
|
+
gpus = g.controllers.map((x) => {
|
|
33
|
+
return {
|
|
34
|
+
name: x.vendor.toLowerCase(),
|
|
35
|
+
model: x.model.toLowerCase()
|
|
36
|
+
}
|
|
37
|
+
})
|
|
33
38
|
} else {
|
|
34
39
|
gpus = []
|
|
35
40
|
}
|
|
36
41
|
|
|
37
|
-
let is_nvidia = gpus.find(gpu => /nvidia/i.test(gpu))
|
|
38
|
-
let is_amd = gpus.find(gpu => /(amd|advanced micro devices)/i.test(gpu))
|
|
39
|
-
let is_apple = gpus.find(gpu => /apple/i.test(gpu))
|
|
42
|
+
let is_nvidia = gpus.find(gpu => /nvidia/i.test(gpu.name))
|
|
43
|
+
let is_amd = gpus.find(gpu => /(amd|advanced micro devices)/i.test(gpu.name))
|
|
44
|
+
let is_apple = gpus.find(gpu => /apple/i.test(gpu.name))
|
|
40
45
|
|
|
41
46
|
let gpu
|
|
47
|
+
let gpu_model
|
|
42
48
|
if (is_nvidia) {
|
|
43
49
|
gpu = "nvidia"
|
|
50
|
+
gpu_model = is_nvidia.model
|
|
44
51
|
} else if (is_amd) {
|
|
45
52
|
gpu = "amd"
|
|
53
|
+
gpu_model = is_amd.model
|
|
46
54
|
} else if (is_apple) {
|
|
47
55
|
gpu = "apple"
|
|
56
|
+
gpu_model = is_apple.model
|
|
48
57
|
} else if (gpus.length > 0) {
|
|
49
|
-
gpu = gpus[0]
|
|
58
|
+
gpu = gpus[0].name
|
|
59
|
+
gpu_model = gpus[0].model
|
|
50
60
|
} else {
|
|
51
61
|
gpu = "none"
|
|
52
62
|
}
|
|
@@ -54,6 +64,7 @@ class Sysinfo {
|
|
|
54
64
|
this.info.graphics = g
|
|
55
65
|
this.info.gpus = gpus
|
|
56
66
|
this.info.gpu = gpu
|
|
67
|
+
this.info.gpu_model = gpu_model
|
|
57
68
|
|
|
58
69
|
}
|
|
59
70
|
// async time() {
|
package/kernel/util.js
CHANGED
|
@@ -36,26 +36,26 @@ const du = async (folderpath) => {
|
|
|
36
36
|
const is_port_available = async (port) => {
|
|
37
37
|
return new Promise((resolve) => {
|
|
38
38
|
const server = http.createServer();
|
|
39
|
-
|
|
39
|
+
console.log("> Checking port availability", port)
|
|
40
40
|
try {
|
|
41
41
|
server.listen(port, (err) => {
|
|
42
42
|
if (err) {
|
|
43
|
-
|
|
43
|
+
console.log("> [1 port not available]", err)
|
|
44
44
|
resolve(false); // Port is occupied
|
|
45
45
|
} else {
|
|
46
|
-
|
|
46
|
+
console.log("> [2 port available] test server started. closing test server now.")
|
|
47
47
|
server.close(() => {
|
|
48
|
-
|
|
48
|
+
console.log("> Test server closed.")
|
|
49
49
|
resolve(true); // Port is free
|
|
50
50
|
}); // Close the server immediately after testing
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
server.on('error', (err) => {
|
|
54
|
-
|
|
54
|
+
console.log("> [3 port not available]", err);
|
|
55
55
|
resolve(false); // Port is occupied
|
|
56
56
|
});
|
|
57
57
|
} catch (e) {
|
|
58
|
-
|
|
58
|
+
console.log("> [4 port not available]", err)
|
|
59
59
|
resolve(false) // port not available
|
|
60
60
|
}
|
|
61
61
|
});
|
package/package.json
CHANGED
package/script/index.js
CHANGED
|
@@ -4,16 +4,6 @@ const os = require('os')
|
|
|
4
4
|
const platform = os.platform()
|
|
5
5
|
const Server = require('../server')
|
|
6
6
|
class Store {
|
|
7
|
-
constructor() {
|
|
8
|
-
let o
|
|
9
|
-
try {
|
|
10
|
-
let str = fs.readFileSync(path.resolve(__dirname, "pinokio.json"), "utf8")
|
|
11
|
-
o = JSON.parse(str)
|
|
12
|
-
} catch(e) {
|
|
13
|
-
o = {}
|
|
14
|
-
}
|
|
15
|
-
this.store = o
|
|
16
|
-
}
|
|
17
7
|
set(key, val) {
|
|
18
8
|
let o
|
|
19
9
|
try {
|
|
@@ -23,7 +13,6 @@ class Store {
|
|
|
23
13
|
o = {}
|
|
24
14
|
}
|
|
25
15
|
o[key] = val
|
|
26
|
-
this.store = o
|
|
27
16
|
fs.writeFileSync(path.resolve(__dirname, "pinokio.json"), JSON.stringify(o, null, 2))
|
|
28
17
|
}
|
|
29
18
|
get(key) {
|
|
@@ -42,7 +31,6 @@ class Store {
|
|
|
42
31
|
console.log("before delete", o)
|
|
43
32
|
delete o[key]
|
|
44
33
|
console.log("after delete", o)
|
|
45
|
-
this.store = o
|
|
46
34
|
fs.writeFileSync(path.resolve(__dirname, "pinokio.json"), JSON.stringify(o, null, 2))
|
|
47
35
|
} catch (e) {
|
|
48
36
|
}
|
package/server/index.js
CHANGED
|
@@ -28,8 +28,6 @@ const multer = require('multer');
|
|
|
28
28
|
|
|
29
29
|
const ejs = require('ejs');
|
|
30
30
|
|
|
31
|
-
const DEFAULT_PORT = 42000
|
|
32
|
-
|
|
33
31
|
const ex = fn => (req, res, next) => {
|
|
34
32
|
Promise.resolve(fn(req, res, next)).catch(next);
|
|
35
33
|
};
|
|
@@ -47,8 +45,7 @@ class Server {
|
|
|
47
45
|
constructor(config) {
|
|
48
46
|
this.tabs = {}
|
|
49
47
|
this.agent = config.agent
|
|
50
|
-
this.port =
|
|
51
|
-
// this.port = config.port
|
|
48
|
+
this.port = config.port
|
|
52
49
|
this.kernel = new Kernel(config.store)
|
|
53
50
|
// this.tunnels = {}
|
|
54
51
|
this.version = {
|
|
@@ -1889,76 +1886,76 @@ class Server {
|
|
|
1889
1886
|
// 5. existing home is NOT set + new home is set => go through with the "home" setting procedure
|
|
1890
1887
|
// 6. existing home is NOT set + new home is NOT set => don't touch anything => the homedir will be the default home
|
|
1891
1888
|
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1889
|
+
// 2. HOME
|
|
1890
|
+
// 2.1. Check if the config includes NEW_HOME => if so,
|
|
1891
|
+
// - move the HOME folder to NEW_HOME
|
|
1892
|
+
// - set HOME=NEW_HOME
|
|
1893
|
+
// - remove NEW_HOME
|
|
1894
|
+
let existing_home = this.kernel.store.get("home")
|
|
1895
|
+
let new_home = this.kernel.store.get("new_home")
|
|
1896
|
+
|
|
1897
|
+
if (existing_home) {
|
|
1898
|
+
let exists = await fse.pathExists(existing_home)
|
|
1899
|
+
if (exists) {
|
|
1900
|
+
if (new_home) {
|
|
1901
|
+
let new_home_exists = await fse.pathExists(new_home)
|
|
1902
|
+
if (new_home_exists) {
|
|
1903
|
+
// - existing home is set
|
|
1904
|
+
// - existing home exists
|
|
1905
|
+
// - new home is set
|
|
1906
|
+
// - new home exists already
|
|
1907
|
+
// => delete store.new_home ==> will load at store.home
|
|
1908
|
+
this.kernel.store.delete("new_home")
|
|
1909
|
+
} else {
|
|
1910
|
+
// - existing home is set
|
|
1911
|
+
// - existing home exists
|
|
1912
|
+
// - new home is set
|
|
1913
|
+
// - new home does not exist
|
|
1914
|
+
// => run mv()
|
|
1915
|
+
// => update store.home
|
|
1916
|
+
// => delete store.new_home
|
|
1917
|
+
await this.mv(existing_home, new_home)
|
|
1918
|
+
this.kernel.store.set("home", new_home)
|
|
1919
|
+
this.kernel.store.delete("new_home")
|
|
1920
|
+
}
|
|
1921
|
+
} else {
|
|
1922
|
+
// - existing home is set
|
|
1923
|
+
// - existing home exists
|
|
1924
|
+
// - new home is not set
|
|
1925
|
+
// => This is most typical scenario => don't touch anything => the homedir will be the existing home
|
|
1926
|
+
}
|
|
1927
|
+
} else {
|
|
1928
|
+
if (new_home) {
|
|
1929
|
+
// - existing home is set
|
|
1930
|
+
// - but the existing home path DOES NOT exist
|
|
1931
|
+
// - new home is set
|
|
1932
|
+
// => This is an invalid scenario => Just to avoid disaster, just delete store.home and delete store.new_home
|
|
1933
|
+
// => the app will load at ~/pinokio
|
|
1934
|
+
this.kernel.store.delete("home")
|
|
1935
|
+
this.kernel.store.delete("new_home")
|
|
1936
|
+
} else {
|
|
1937
|
+
// - existing home is set
|
|
1938
|
+
// - but the existing home path DOES NOT exist
|
|
1939
|
+
// - new home is NOT set
|
|
1940
|
+
// => This is an invalid scenario => just delete store.home
|
|
1941
|
+
// => the app will load at ~/pinokio
|
|
1942
|
+
this.kernel.store.delete("home")
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
} else {
|
|
1946
|
+
if (new_home) {
|
|
1947
|
+
// - existing home is NOT set
|
|
1948
|
+
// - new home is set
|
|
1949
|
+
// => update store.home
|
|
1950
|
+
// => delete store.new_home
|
|
1951
|
+
this.kernel.store.set("home", new_home)
|
|
1952
|
+
this.kernel.store.delete("new_home")
|
|
1953
|
+
} else {
|
|
1954
|
+
// - existing home is NOT set
|
|
1955
|
+
// - new home is NOT set
|
|
1956
|
+
// => don't touch anything => will load at ~/pinokio
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1962
1959
|
}
|
|
1963
1960
|
async setConfig(config) {
|
|
1964
1961
|
let home = this.kernel.store.get("home")
|
|
@@ -1983,14 +1980,13 @@ class Server {
|
|
|
1983
1980
|
throw new Error("Invalid path: " + config.home)
|
|
1984
1981
|
}
|
|
1985
1982
|
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1983
|
+
// check if the destination already exists => throw error
|
|
1984
|
+
let exists = await fse.pathExists(config.home)
|
|
1985
|
+
if (exists) {
|
|
1986
|
+
throw new Error(`The path ${config.home} already exists. Please remove the folder and retry`)
|
|
1987
|
+
}
|
|
1991
1988
|
|
|
1992
|
-
|
|
1993
|
-
this.kernel.store.set("home", config.home)
|
|
1989
|
+
this.kernel.store.set("new_home", config.home)
|
|
1994
1990
|
}
|
|
1995
1991
|
|
|
1996
1992
|
}
|
|
@@ -2019,6 +2015,7 @@ class Server {
|
|
|
2019
2015
|
|
|
2020
2016
|
home = this.kernel.store.get("home")
|
|
2021
2017
|
theme = this.kernel.store.get("theme")
|
|
2018
|
+
let new_home = this.kernel.store.get("new_home")
|
|
2022
2019
|
}
|
|
2023
2020
|
async startLogging(homedir) {
|
|
2024
2021
|
console.log(">>>>>>> startLogging", homedir)
|
|
@@ -2055,25 +2052,7 @@ class Server {
|
|
|
2055
2052
|
}
|
|
2056
2053
|
}
|
|
2057
2054
|
}
|
|
2058
|
-
async running(port) {
|
|
2059
|
-
let p = port || DEFAULT_PORT
|
|
2060
|
-
const available = await Util.is_port_available(p)
|
|
2061
|
-
if (available) {
|
|
2062
|
-
return false
|
|
2063
|
-
} else {
|
|
2064
|
-
return true
|
|
2065
|
-
}
|
|
2066
|
-
}
|
|
2067
2055
|
async start(options) {
|
|
2068
|
-
|
|
2069
|
-
// // ONLY start if not already running
|
|
2070
|
-
// let is_running = await this.running(this.port || DEFAULT_PORT)
|
|
2071
|
-
// if (is_running) {
|
|
2072
|
-
// console.log("pinokiod already running, skip..")
|
|
2073
|
-
// return
|
|
2074
|
-
// }
|
|
2075
|
-
//
|
|
2076
|
-
|
|
2077
2056
|
this.debug = false
|
|
2078
2057
|
if (options) {
|
|
2079
2058
|
this.debug = options.debug
|
|
@@ -2122,7 +2101,7 @@ class Server {
|
|
|
2122
2101
|
// determine port if port is not passed in
|
|
2123
2102
|
|
|
2124
2103
|
if (!this.port) {
|
|
2125
|
-
this.port =
|
|
2104
|
+
this.port = 42000
|
|
2126
2105
|
// let platform = os.platform()
|
|
2127
2106
|
// if (platform === 'linux') {
|
|
2128
2107
|
// // on linux you are not allowed to listen on ports below 1024
|
package/server/socket.js
CHANGED
|
@@ -111,7 +111,6 @@ body.frozen {
|
|
|
111
111
|
</style>
|
|
112
112
|
<link href="/terminal.css" rel="stylesheet"/>
|
|
113
113
|
<script>
|
|
114
|
-
let shell_id
|
|
115
114
|
document.addEventListener("DOMContentLoaded", async () => {
|
|
116
115
|
<% if (error) { %>
|
|
117
116
|
document.querySelector(".requirements .content").innerHTML = '<div class="loading"><i class="fa-solid fa-circle-exclamation"></i> <%=error%></div>'
|
|
@@ -204,7 +203,6 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
204
203
|
rows: this.term.rows,
|
|
205
204
|
}
|
|
206
205
|
}, async (packet) => {
|
|
207
|
-
console.log({ packet })
|
|
208
206
|
if (packet.type === 'start') {
|
|
209
207
|
refreshParent(packet)
|
|
210
208
|
reloadMemory()
|
|
@@ -236,10 +234,6 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
236
234
|
// </div>`
|
|
237
235
|
}
|
|
238
236
|
} else if (packet.type === "stream") {
|
|
239
|
-
// set the current shell id
|
|
240
|
-
if (packet.data.id) {
|
|
241
|
-
shell_id = packet.data.id
|
|
242
|
-
}
|
|
243
237
|
if (packet.data.raw) {
|
|
244
238
|
this.write(packet.data.raw)
|
|
245
239
|
} else if (packet.data.json) {
|
|
@@ -595,18 +589,6 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
595
589
|
////term.resize(cols, rows-5);
|
|
596
590
|
//term.resize(cols, rows);
|
|
597
591
|
|
|
598
|
-
term.onKey(({ key }) => {
|
|
599
|
-
console.log({ key })
|
|
600
|
-
if (this.socket) {
|
|
601
|
-
if (shell_id) {
|
|
602
|
-
this.socket.run({
|
|
603
|
-
key,
|
|
604
|
-
id: shell_id
|
|
605
|
-
})
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
});
|
|
609
|
-
|
|
610
592
|
const fitAddon = new FitAddon.FitAddon();
|
|
611
593
|
// const searchAddon = new SearchAddon.SearchAddon();
|
|
612
594
|
// const searchAddonBar = new SearchBarAddon.SearchBarAddon({searchAddon});
|
|
@@ -624,7 +606,6 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
624
606
|
fitAddon.fit();
|
|
625
607
|
this.term = term
|
|
626
608
|
this.fit = fitAddon
|
|
627
|
-
|
|
628
609
|
}
|
|
629
610
|
this.term.focus()
|
|
630
611
|
}
|
package/kernel/store.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
const os = require('os')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
class Store {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.root = path.resolve(os.homedir(), ".pinokio")
|
|
7
|
-
if (!fs.existsSync(path.resolve(this.root))) {
|
|
8
|
-
fs.mkdirSync(path.resolve(this.root))
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exists() {
|
|
12
|
-
let p = path.resolve(this.root, "config.json")
|
|
13
|
-
return fs.existsSync(p)
|
|
14
|
-
}
|
|
15
|
-
clone(old) {
|
|
16
|
-
console.log("clone", old)
|
|
17
|
-
let p = path.resolve(this.root, "config.json")
|
|
18
|
-
fs.writeFileSync(p, JSON.stringify(old, null, 2))
|
|
19
|
-
}
|
|
20
|
-
set(key, val) {
|
|
21
|
-
let o
|
|
22
|
-
try {
|
|
23
|
-
let str = fs.readFileSync(path.resolve(this.root, "config.json"), "utf8")
|
|
24
|
-
o = JSON.parse(str)
|
|
25
|
-
} catch(e) {
|
|
26
|
-
o = {}
|
|
27
|
-
}
|
|
28
|
-
o[key] = val
|
|
29
|
-
fs.writeFileSync(path.resolve(this.root, "config.json"), JSON.stringify(o, null, 2))
|
|
30
|
-
}
|
|
31
|
-
get(key) {
|
|
32
|
-
try {
|
|
33
|
-
let str = fs.readFileSync(path.resolve(this.root, "config.json"), "utf8")
|
|
34
|
-
let o = JSON.parse(str)
|
|
35
|
-
return o[key]
|
|
36
|
-
} catch (e) {
|
|
37
|
-
return null
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
delete(key) {
|
|
41
|
-
try {
|
|
42
|
-
let str = fs.readFileSync(path.resolve(this.root, "config.json"), "utf8")
|
|
43
|
-
let o = JSON.parse(str)
|
|
44
|
-
delete o[key]
|
|
45
|
-
fs.writeFileSync(path.resolve(this.root, "config.json"), JSON.stringify(o, null, 2))
|
|
46
|
-
} catch (e) {
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
store() {
|
|
50
|
-
try {
|
|
51
|
-
let str = fs.readFileSync(path.resolve(this.root, "config.json"), "utf8")
|
|
52
|
-
let o = JSON.parse(str)
|
|
53
|
-
return o
|
|
54
|
-
} catch (e) {
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
module.exports = Store
|