pinokiod 1.3.60 → 1.3.62
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 +2 -0
- package/kernel/api/env/index.js +22 -0
- package/kernel/api/fs/index.js +5 -3
- package/kernel/api/index.js +23 -10
- package/kernel/environment.js +14 -1
- package/kernel/index.js +18 -0
- package/kernel/shell.js +14 -9
- package/kernel/shells.js +0 -3
- package/kernel/util.js +107 -1
- package/package.json +2 -1
- package/server/index.js +88 -10
- package/server/public/style.css +6 -7
- package/server/socket.js +24 -6
- package/server/views/browser-experimental.ejs +31 -4
- package/server/views/env_editor.ejs +184 -0
- package/server/views/fullscreen_editor.ejs +53 -8
- package/server/views/general_editor.ejs +2 -2
- package/server/views/help.ejs +4 -0
- package/server/views/index.ejs +33 -18
- package/server/views/partials/menu.ejs +3 -1
- package/server/views/settings.ejs +5 -1
- package/server/views/share_editor.ejs +196 -0
|
@@ -12,6 +12,7 @@ class C {
|
|
|
12
12
|
|
|
13
13
|
=> cloudflared tunnel --url http://localhost:8080
|
|
14
14
|
*/
|
|
15
|
+
console.log("TUNNEL", req)
|
|
15
16
|
const message = `cloudflared tunnel --url ${req.params.uri}`
|
|
16
17
|
let params = {
|
|
17
18
|
id: message,
|
|
@@ -25,6 +26,7 @@ class C {
|
|
|
25
26
|
if (req.cwd) options.cwd = req.cwd
|
|
26
27
|
if (req.parent && req.parent.path) options.group = req.parent.path
|
|
27
28
|
let pattern = /(https:.+?trycloudflare\.com)/
|
|
29
|
+
console.log("params", params)
|
|
28
30
|
let cloudflare_url = await new Promise((resolve, reject) => {
|
|
29
31
|
kernel.shell.start(params, options, (e) => {
|
|
30
32
|
ondata(e)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const set = require("../set")
|
|
2
|
+
const rm = require("../rm")
|
|
3
|
+
const Environment = require('../../environment')
|
|
4
|
+
const Util = require("../../util")
|
|
5
|
+
class Env {
|
|
6
|
+
async set(req, ondata, kernel) {
|
|
7
|
+
/*
|
|
8
|
+
req := {
|
|
9
|
+
"method": "env.set",
|
|
10
|
+
"params": {
|
|
11
|
+
<key>: <val>,
|
|
12
|
+
<key>: <val>,
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
*/
|
|
16
|
+
// write to current app folder's ENVIRONMENT
|
|
17
|
+
|
|
18
|
+
let api_path = await Util.api_path(req.parent.path, kernel)
|
|
19
|
+
await Util.update_env(api_path, req.params)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
module.exports = Env
|
package/kernel/api/fs/index.js
CHANGED
|
@@ -129,11 +129,13 @@ class FS {
|
|
|
129
129
|
ondata({ raw: "\r\ncreating a shared drive:\r\n" + JSON.stringify(req.params, null, 2).replace(/\n/g, "\r\n") })
|
|
130
130
|
|
|
131
131
|
|
|
132
|
-
|
|
133
|
-
let current_env = await Environment.get(api_path)
|
|
132
|
+
// start with the proces.env => merge pinokio global ENVIRONMENT => merge app ENVIRONMENT
|
|
134
133
|
let default_env = await Environment.get(kernel.homedir)
|
|
135
|
-
|
|
134
|
+
let api_path = await Util.api_path(req.parent.path, kernel)
|
|
135
|
+
let api_env = await Environment.get(api_path)
|
|
136
|
+
let current_env = Object.assign(process.env, default_env, api_env)
|
|
136
137
|
|
|
138
|
+
// if PINOKIO_DRIVE environment variable is specified, use this custom value for the drive path instead of ~/pinokio/drive
|
|
137
139
|
let env_drive_path = current_env.PINOKIO_DRIVE
|
|
138
140
|
let drive_home
|
|
139
141
|
if (env_drive_path) {
|
package/kernel/api/index.js
CHANGED
|
@@ -560,7 +560,6 @@ class Api {
|
|
|
560
560
|
// 6. rpc must have method names
|
|
561
561
|
if (rpc.method) {
|
|
562
562
|
|
|
563
|
-
|
|
564
563
|
// 7. resolve the rpc
|
|
565
564
|
let resolved = await this.resolveMethod(rpc, cwd)
|
|
566
565
|
|
|
@@ -1051,20 +1050,34 @@ class Api {
|
|
|
1051
1050
|
}
|
|
1052
1051
|
}
|
|
1053
1052
|
} else if (request.method) {
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1053
|
+
let pass = 0;
|
|
1054
|
+
while(true) {
|
|
1055
|
+
request = this.kernel.template.render(request, { kernel: this.kernel })
|
|
1056
|
+
if (this.kernel.template.istemplate(request)) {
|
|
1057
|
+
pass++;
|
|
1058
|
+
if (pass >= 4) {
|
|
1059
|
+
// only try 4 times
|
|
1060
|
+
break;
|
|
1061
|
+
} else {
|
|
1062
|
+
continue;
|
|
1063
|
+
}
|
|
1061
1064
|
} else {
|
|
1062
|
-
|
|
1065
|
+
break;
|
|
1063
1066
|
}
|
|
1064
1067
|
}
|
|
1068
|
+
if (this.kernel.template.istemplate(request)) {
|
|
1069
|
+
console.log("something wrong with the request", request)
|
|
1070
|
+
return
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
// replace {{{ }}} with {{ }}
|
|
1074
|
+
request = this.kernel.template.flatten(request)
|
|
1075
|
+
|
|
1076
|
+
if (request.params && request.params.path) {
|
|
1077
|
+
request.params.path = this.resolvePath(this.userdir, request.params.path)
|
|
1078
|
+
}
|
|
1065
1079
|
|
|
1066
1080
|
// Kernel Call
|
|
1067
|
-
console.log("REQUEST", request)
|
|
1068
1081
|
let resolved = await this.resolveMethod(request)
|
|
1069
1082
|
try {
|
|
1070
1083
|
resolved.dirname = resolved.dirname
|
package/kernel/environment.js
CHANGED
|
@@ -66,6 +66,11 @@ const ENVS = [{
|
|
|
66
66
|
val: (home) => {
|
|
67
67
|
return path.resolve(home, "drive")
|
|
68
68
|
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "PINOKIO_SCRIPT_DEFAULT",
|
|
71
|
+
val: (home) => {
|
|
72
|
+
return "true"
|
|
73
|
+
}
|
|
69
74
|
}];
|
|
70
75
|
const folders = ENVS.filter((env) => {
|
|
71
76
|
return env.type === "cache_folder" || env.type === "folder"
|
|
@@ -141,6 +146,15 @@ const APP_ENV = () => {
|
|
|
141
146
|
"#",
|
|
142
147
|
"##########################################################################",
|
|
143
148
|
"PINOKIO_SHARE_CLOUDFLARE=false",
|
|
149
|
+
"",
|
|
150
|
+
"##########################################################################",
|
|
151
|
+
"#",
|
|
152
|
+
"# PINOKIO_SCRIPT_DEFAULT",
|
|
153
|
+
"# If this variable is false, 'default': true menu items in pinokio.js",
|
|
154
|
+
"# will NOT automatically run",
|
|
155
|
+
"#",
|
|
156
|
+
"##########################################################################",
|
|
157
|
+
"PINOKIO_SCRIPT_DEFAULT=true",
|
|
144
158
|
]
|
|
145
159
|
return items.join("\n")
|
|
146
160
|
}
|
|
@@ -160,7 +174,6 @@ const init_folders = async (homedir) => {
|
|
|
160
174
|
}
|
|
161
175
|
}
|
|
162
176
|
}
|
|
163
|
-
|
|
164
177
|
const get = async (homedir) => {
|
|
165
178
|
const env_path = path.resolve(homedir, "ENVIRONMENT")
|
|
166
179
|
const current_env = await util.parse_env(env_path)
|
package/kernel/index.js
CHANGED
|
@@ -43,6 +43,24 @@ class Kernel {
|
|
|
43
43
|
this.exposed = {}
|
|
44
44
|
this.envs = {}
|
|
45
45
|
}
|
|
46
|
+
/*
|
|
47
|
+
kernel.env() => return the system environment
|
|
48
|
+
kernel.env("api/stablediffusion") => returns the full environment object
|
|
49
|
+
*/
|
|
50
|
+
async env(...args) {
|
|
51
|
+
let folderpath
|
|
52
|
+
if (args) {
|
|
53
|
+
folderpath = path.resolve(this.homedir, ...args)
|
|
54
|
+
} else {
|
|
55
|
+
folderpath = this.homedir
|
|
56
|
+
}
|
|
57
|
+
console.log({ args , folderpath,homedir: this.homedir })
|
|
58
|
+
let api_path = await Util.api_path(folderpath, this)
|
|
59
|
+
let current_env = await Environment.get(api_path)
|
|
60
|
+
let default_env = await Environment.get(this.homedir)
|
|
61
|
+
console.log({ api_path, current_env, default_env })
|
|
62
|
+
return Object.assign(process.env, default_env, current_env)
|
|
63
|
+
}
|
|
46
64
|
resumeprocess(uri) {
|
|
47
65
|
let proc = this.procs[uri]
|
|
48
66
|
if (proc && proc.resolve) {
|
package/kernel/shell.js
CHANGED
|
@@ -71,6 +71,8 @@ class Shell {
|
|
|
71
71
|
this.cols = params.cols ? params.cols : 100;
|
|
72
72
|
this.rows = params.rows ? params.rows : 30;
|
|
73
73
|
|
|
74
|
+
console.log({ cols: this.cols, rows: this.rows })
|
|
75
|
+
|
|
74
76
|
this.vt = new Terminal({
|
|
75
77
|
allowProposedApi: true,
|
|
76
78
|
cols: this.cols,
|
|
@@ -112,19 +114,22 @@ class Shell {
|
|
|
112
114
|
|
|
113
115
|
this.env.CMAKE_OBJECT_PATH_MAX = 1024
|
|
114
116
|
|
|
115
|
-
|
|
116
|
-
let
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
// First override this.env with system env
|
|
118
|
+
let system_env = await Environment.get(this.kernel.homedir)
|
|
119
|
+
this.env = Object.assign(this.env, system_env)
|
|
120
|
+
|
|
121
|
+
// if the shell is running from a script file, the params.$parent will include the path to the parent script
|
|
122
|
+
// this means we need to apply app environment as well
|
|
120
123
|
if (params.$parent) {
|
|
121
124
|
let api_path = await Util.api_path(params.$parent.path, this.kernel)
|
|
125
|
+
|
|
126
|
+
// initialize folders
|
|
122
127
|
await Environment.init_folders(api_path)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
128
|
+
|
|
129
|
+
// apply app env to this.env
|
|
130
|
+
let app_env = await Environment.get(api_path)
|
|
131
|
+
this.env = Object.assign(this.env, app_env)
|
|
126
132
|
}
|
|
127
|
-
console.log("THIS.env after", this.env)
|
|
128
133
|
let PATH_KEY;
|
|
129
134
|
if (this.env.Path) {
|
|
130
135
|
PATH_KEY = "Path"
|
package/kernel/shells.js
CHANGED
|
@@ -160,7 +160,6 @@ class Shells {
|
|
|
160
160
|
matches[2] += "g" // if g option is not included, include it (need it for matchAll)
|
|
161
161
|
}
|
|
162
162
|
let re = new RegExp(matches[1], matches[2])
|
|
163
|
-
console.log("stream", stream)
|
|
164
163
|
let line = stream.cleaned.replaceAll(/[\r\n]/g, "")
|
|
165
164
|
//let rendered_event = [...stream.cleaned.matchAll(re)]
|
|
166
165
|
let rendered_event = [...line.matchAll(re)]
|
|
@@ -222,7 +221,6 @@ class Shells {
|
|
|
222
221
|
for(let i=0; i<shells.length; i++) {
|
|
223
222
|
let shell = shells[i]
|
|
224
223
|
if (shell.id === request.id) {
|
|
225
|
-
console.log("FOUND SHELL TO KILL", shell.id)
|
|
226
224
|
shell.kill(message, true)
|
|
227
225
|
}
|
|
228
226
|
}
|
|
@@ -235,7 +233,6 @@ class Shells {
|
|
|
235
233
|
for(let i=0; i<shells.length; i++) {
|
|
236
234
|
let shell = shells[i]
|
|
237
235
|
if (shell.group === request.group) {
|
|
238
|
-
console.log("kill shell ", request.group, i, shell)
|
|
239
236
|
shell.kill(message, true)
|
|
240
237
|
}
|
|
241
238
|
}
|
package/kernel/util.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require('path')
|
|
3
3
|
const dotenv = require('dotenv')
|
|
4
|
+
|
|
5
|
+
const {auto: normalizeEOL} = require("eol");
|
|
6
|
+
const {EOL} = require("os");
|
|
7
|
+
const breakPattern = /\n/g;
|
|
8
|
+
const breakReplacement = "\\n";
|
|
9
|
+
const groupPattern = /\$/g;
|
|
10
|
+
const groupReplacement = "$$$";
|
|
11
|
+
const h = "[^\\S\\r\\n]"; // simulate `\h`
|
|
12
|
+
const returnPattern = /\r/g;
|
|
13
|
+
const returnReplacement = "\\r";
|
|
14
|
+
|
|
4
15
|
const parse_env = async (filename) => {
|
|
5
16
|
try {
|
|
6
17
|
const buf = await fs.promises.readFile(filename)
|
|
@@ -10,6 +21,52 @@ const parse_env = async (filename) => {
|
|
|
10
21
|
return {}
|
|
11
22
|
}
|
|
12
23
|
}
|
|
24
|
+
|
|
25
|
+
const parse_env_detail = async (filename) => {
|
|
26
|
+
// takes env and returns an array
|
|
27
|
+
const config = parse_env(filename)
|
|
28
|
+
/*
|
|
29
|
+
config := {
|
|
30
|
+
key1: val1,
|
|
31
|
+
key2; val2,
|
|
32
|
+
...
|
|
33
|
+
}
|
|
34
|
+
*/
|
|
35
|
+
const keys = Object.keys(config)
|
|
36
|
+
const str = await fs.promises.readFile(filename, "utf8")
|
|
37
|
+
const lines = str.split(EOL)
|
|
38
|
+
|
|
39
|
+
let items = []
|
|
40
|
+
|
|
41
|
+
for(let line of lines) {
|
|
42
|
+
if (line.trim().startsWith("#")) {
|
|
43
|
+
items.push({
|
|
44
|
+
type: "comment",
|
|
45
|
+
val: line
|
|
46
|
+
})
|
|
47
|
+
} else {
|
|
48
|
+
const buf = Buffer.from(line)
|
|
49
|
+
const parsed = dotenv.parse(buf)
|
|
50
|
+
const key = Object.keys(parsed)
|
|
51
|
+
if (key.length > 0) {
|
|
52
|
+
items.push({ key: key[0], val: parsed[key[0]] })
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/*
|
|
57
|
+
items := [{
|
|
58
|
+
type: "comment",
|
|
59
|
+
val: "###################################",
|
|
60
|
+
}, {
|
|
61
|
+
type: "comment",
|
|
62
|
+
val: "# this is a comment",
|
|
63
|
+
}, {
|
|
64
|
+
key: "TMPDIR",
|
|
65
|
+
val: "/tmp"
|
|
66
|
+
}]
|
|
67
|
+
*/
|
|
68
|
+
return items
|
|
69
|
+
}
|
|
13
70
|
const api_path = async (fullpath, kernel) => {
|
|
14
71
|
let api_path = `${kernel.homedir}${path.sep}api`
|
|
15
72
|
let rel_path = path.relative(api_path, fullpath)
|
|
@@ -17,6 +74,55 @@ const api_path = async (fullpath, kernel) => {
|
|
|
17
74
|
let current_api_path = `${api_path}${path.sep}${api_name}`
|
|
18
75
|
return current_api_path
|
|
19
76
|
}
|
|
77
|
+
const escapeStringRegexp = (string) => {
|
|
78
|
+
if (typeof string !== 'string') {
|
|
79
|
+
throw new TypeError('Expected a string');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Escape characters with special meaning either inside or outside character sets.
|
|
83
|
+
// Use a simple backslash escape when it’s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
|
|
84
|
+
return string
|
|
85
|
+
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
|
|
86
|
+
.replace(/-/g, '\\x2d');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const update_env = async (filepath, changes) => {
|
|
90
|
+
const envString = await fs.promises.readFile(filepath, "utf8")
|
|
91
|
+
console.log({ filepath, envString, changes })
|
|
92
|
+
let hasAppended = false;
|
|
93
|
+
console.log("changes", changes)
|
|
94
|
+
const newval = Object.keys(changes).reduce((result, varname) => {
|
|
95
|
+
const value = changes[varname].toString()
|
|
96
|
+
.replace(breakPattern, breakReplacement)
|
|
97
|
+
.replace(returnPattern, returnReplacement)
|
|
98
|
+
.trim();
|
|
99
|
+
const safeName = escapeStringRegexp(varname);
|
|
100
|
+
const varPattern = new RegExp(`^(${h}*${safeName}${h}*=${h}*)\\S*(${h}*)$`, "gm");
|
|
101
|
+
if (varPattern.test(result)) {
|
|
102
|
+
const safeValue = value.replace(groupPattern, groupReplacement);
|
|
103
|
+
return result.replace(varPattern, `$1${safeValue}$2`);
|
|
104
|
+
} else if (result === "") {
|
|
105
|
+
hasAppended = true;
|
|
106
|
+
return `${varname}=${value}${EOL}`;
|
|
107
|
+
} else if (!result.endsWith(EOL) && !hasAppended) {
|
|
108
|
+
hasAppended = true;
|
|
109
|
+
// Add an extra break between previously defined and newly appended variable
|
|
110
|
+
return `${result}${EOL}${EOL}${varname}=${value}`;
|
|
111
|
+
} else if (!result.endsWith(EOL)) {
|
|
112
|
+
// Add break for appended variable
|
|
113
|
+
return `${result}${EOL}${varname}=${value}`;
|
|
114
|
+
} else if (result.endsWith(EOL) && !hasAppended) {
|
|
115
|
+
hasAppended = true;
|
|
116
|
+
// Add an extra break between previously defined and newly appended variable
|
|
117
|
+
return `${result}${EOL}${varname}=${value}${EOL}`;
|
|
118
|
+
} else /*if (result.endsWith(EOL))*/ {
|
|
119
|
+
// Add break for appended variable
|
|
120
|
+
return `${result}${varname}=${value}${EOL}`;
|
|
121
|
+
}
|
|
122
|
+
}, normalizeEOL(envString));
|
|
123
|
+
console.log("updated ENVIRONMENT", newval)
|
|
124
|
+
await fs.promises.writeFile(filepath, newval)
|
|
125
|
+
};
|
|
20
126
|
module.exports = {
|
|
21
|
-
parse_env, api_path
|
|
127
|
+
parse_env, api_path, update_env, parse_env_detail
|
|
22
128
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pinokiod",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.62",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"decompress": "^4.2.1",
|
|
22
22
|
"dotenv": "^16.4.5",
|
|
23
23
|
"ejs": "^3.1.9",
|
|
24
|
+
"eol": "^0.9.1",
|
|
24
25
|
"express": "^4.18.2",
|
|
25
26
|
"express-http-proxy-cp": "^2.0.3",
|
|
26
27
|
"express-session": "^1.17.3",
|
package/server/index.js
CHANGED
|
@@ -36,6 +36,7 @@ const Kernel = require("../kernel")
|
|
|
36
36
|
const packagejson = require("../package.json")
|
|
37
37
|
const Environment = require("../kernel/environment")
|
|
38
38
|
const Cloudflare = require("../kernel/api/cloudflare")
|
|
39
|
+
const Util = require("../kernel/util")
|
|
39
40
|
class Server {
|
|
40
41
|
constructor(config) {
|
|
41
42
|
this.tabs = {}
|
|
@@ -233,14 +234,26 @@ class Server {
|
|
|
233
234
|
let current = this.kernel.path("api", name, "ENVIRONMENT")
|
|
234
235
|
// if environment.json doesn't exist,
|
|
235
236
|
let exists = await this.exists(current)
|
|
237
|
+
console.log("exists", exists)
|
|
236
238
|
if (!exists) {
|
|
237
239
|
let content = await Environment.APP_ENV()
|
|
240
|
+
console.log("write", content)
|
|
238
241
|
await fs.promises.writeFile(current, content)
|
|
239
242
|
}
|
|
240
243
|
|
|
244
|
+
let mode = "run"
|
|
245
|
+
console.log("req.query", req.query)
|
|
246
|
+
if (req.query && req.query.mode) {
|
|
247
|
+
mode = req.query.mode
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const env = await this.kernel.env("api/" + name)
|
|
251
|
+
console.log("env", env)
|
|
241
252
|
|
|
242
253
|
//res.render("browser", {
|
|
243
254
|
res.render("browser-experimental", {
|
|
255
|
+
env,
|
|
256
|
+
mode,
|
|
244
257
|
port: this.port,
|
|
245
258
|
mem,
|
|
246
259
|
type,
|
|
@@ -1272,9 +1285,22 @@ class Server {
|
|
|
1272
1285
|
if (config.menu) {
|
|
1273
1286
|
|
|
1274
1287
|
config.menu = [{
|
|
1288
|
+
base: "/",
|
|
1275
1289
|
text: "Configure",
|
|
1276
|
-
href:
|
|
1290
|
+
href: `env/api/${name}/ENVIRONMENT`,
|
|
1277
1291
|
icon: "fa-solid fa-gear"
|
|
1292
|
+
// }, {
|
|
1293
|
+
// base: "/",
|
|
1294
|
+
// text: "Public Share",
|
|
1295
|
+
// action: {
|
|
1296
|
+
// method: "env.set",
|
|
1297
|
+
// params: {
|
|
1298
|
+
// "PINOKIO_SHARE_CLOUDFLARE": true,
|
|
1299
|
+
// "PINOKIO_SHARE_LOCAL": true
|
|
1300
|
+
// }
|
|
1301
|
+
// },
|
|
1302
|
+
// href: `env/api/${name}/ENVIRONMENT`,
|
|
1303
|
+
// icon: "fa-solid fa-gear"
|
|
1278
1304
|
}].concat(config.menu)
|
|
1279
1305
|
|
|
1280
1306
|
for(let i=0; i<config.menu.length; i++) {
|
|
@@ -1285,14 +1311,18 @@ class Server {
|
|
|
1285
1311
|
menuitem.menu = m.menu
|
|
1286
1312
|
}
|
|
1287
1313
|
|
|
1288
|
-
if (menuitem.
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1314
|
+
if (menuitem.base === "/") {
|
|
1315
|
+
config.menu[i].href = menuitem.base + menuitem.href
|
|
1316
|
+
} else {
|
|
1317
|
+
if (menuitem.href && !menuitem.href.startsWith("http")) {
|
|
1318
|
+
|
|
1319
|
+
// href resolution
|
|
1320
|
+
let absolute = path.resolve(__dirname, ...pathComponents, menuitem.href)
|
|
1321
|
+
let seed = path.resolve(__dirname)
|
|
1322
|
+
let p = absolute.replace(seed, "")
|
|
1323
|
+
let link = p.split(/[\/\\]/).filter((x) => { return x }).join("/")
|
|
1324
|
+
config.menu[i].href = "/api/" + name + "/" + link
|
|
1325
|
+
}
|
|
1296
1326
|
}
|
|
1297
1327
|
|
|
1298
1328
|
if (menuitem.href && menuitem.params) {
|
|
@@ -2118,6 +2148,49 @@ class Server {
|
|
|
2118
2148
|
res.json({ error: "type must be 'local' or 'cloudflare'" })
|
|
2119
2149
|
}
|
|
2120
2150
|
})
|
|
2151
|
+
this.app.post("/env", async (req, res) => {
|
|
2152
|
+
console.log("req.body", req.body)
|
|
2153
|
+
let fullpath = path.resolve(this.kernel.homedir, req.body.filepath)
|
|
2154
|
+
let updated = req.body.vals
|
|
2155
|
+
await Util.update_env(fullpath, updated)
|
|
2156
|
+
res.json({})
|
|
2157
|
+
})
|
|
2158
|
+
this.app.get("/env/*", async (req, res) => {
|
|
2159
|
+
let pathComponents = req.params[0].split("/")
|
|
2160
|
+
let filepath = path.resolve(this.kernel.homedir, req.params[0])
|
|
2161
|
+
let editorpath = "/edit/" + req.params[0]
|
|
2162
|
+
const items = await Util.parse_env_detail(filepath)
|
|
2163
|
+
res.render("env_editor", {
|
|
2164
|
+
editorpath,
|
|
2165
|
+
items,
|
|
2166
|
+
theme: this.theme,
|
|
2167
|
+
filepath,
|
|
2168
|
+
agent: this.agent,
|
|
2169
|
+
})
|
|
2170
|
+
})
|
|
2171
|
+
this.app.get("/share/:name", async (req, res) => {
|
|
2172
|
+
let filepath = path.resolve(this.kernel.homedir, "api", req.params.name, "ENVIRONMENT")
|
|
2173
|
+
//let filepath = path.resolve(this.kernel.homedir, req.params[0])
|
|
2174
|
+
console.log("filepath", filepath)
|
|
2175
|
+
const config = await Util.parse_env(filepath)
|
|
2176
|
+
console.log("config", config)
|
|
2177
|
+
const keys = [
|
|
2178
|
+
"PINOKIO_SHARE_CLOUDFLARE",
|
|
2179
|
+
"PINOKIO_SHARE_LOCAL",
|
|
2180
|
+
]
|
|
2181
|
+
for(let key of keys) {
|
|
2182
|
+
if (!config[key]) {
|
|
2183
|
+
config[key] = ""
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
res.render("share_editor", {
|
|
2187
|
+
keys,
|
|
2188
|
+
config,
|
|
2189
|
+
theme: this.theme,
|
|
2190
|
+
filepath,
|
|
2191
|
+
agent: this.agent,
|
|
2192
|
+
})
|
|
2193
|
+
})
|
|
2121
2194
|
this.app.get("/edit/*", async (req, res) => {
|
|
2122
2195
|
let pathComponents = req.params[0].split("/")
|
|
2123
2196
|
let filepath = path.resolve(this.kernel.homedir, req.params[0])
|
|
@@ -2292,8 +2365,13 @@ class Server {
|
|
|
2292
2365
|
this.app.get("/pinokio/launch/:name", async (req, res) => {
|
|
2293
2366
|
this.chrome(req, res, "launch")
|
|
2294
2367
|
})
|
|
2368
|
+
this.app.get("/pinokio/browser/:name/browse", async (req, res) => {
|
|
2369
|
+
console.log("browse mode")
|
|
2370
|
+
this.chrome(req, res, "browse")
|
|
2371
|
+
})
|
|
2295
2372
|
this.app.get("/pinokio/browser/:name", async (req, res) => {
|
|
2296
|
-
|
|
2373
|
+
console.log("run mode")
|
|
2374
|
+
this.chrome(req, res, "run")
|
|
2297
2375
|
})
|
|
2298
2376
|
this.app.post("/pinokio/delete", async (req, res) => {
|
|
2299
2377
|
try {
|
package/server/public/style.css
CHANGED
|
@@ -21,7 +21,10 @@
|
|
|
21
21
|
--light-thin: rgba(0,0,0,0.1);
|
|
22
22
|
--dark-thin: rgba(255,255,255,0.03);
|
|
23
23
|
|
|
24
|
+
/*
|
|
24
25
|
--dark-color: rgba(255,255,255,0.8);
|
|
26
|
+
*/
|
|
27
|
+
--dark-color: white;
|
|
25
28
|
--light-color: rgba(0,0,0,0.9);
|
|
26
29
|
|
|
27
30
|
--dark-fade: rgba(255,255,255,0.6);
|
|
@@ -894,13 +897,11 @@ body.dark .readme a {
|
|
|
894
897
|
body.dark .line {
|
|
895
898
|
border-bottom: 1px solid var(--dark-thin);
|
|
896
899
|
}
|
|
897
|
-
body.dark .line.selected {
|
|
900
|
+
body.dark .line.selected, body.dark .line:hover {
|
|
898
901
|
/*
|
|
899
902
|
border-left: 6px solid white;
|
|
900
903
|
*/
|
|
901
904
|
background: rgba(80, 100, 70, 0.1);
|
|
902
|
-
border-top: 1px solid rgba(80, 100, 70, 0.1);
|
|
903
|
-
border-bottom: 1px solid rgba(80, 100, 70, 0.1);
|
|
904
905
|
}
|
|
905
906
|
/*
|
|
906
907
|
body.dark .line:hover {
|
|
@@ -910,13 +911,11 @@ body.dark .line:hover {
|
|
|
910
911
|
border-left: 6px solid black;
|
|
911
912
|
}
|
|
912
913
|
*/
|
|
913
|
-
.line.selected {
|
|
914
|
+
.line.selected, .line:hover {
|
|
914
915
|
/*
|
|
915
916
|
border-left: 6px solid black;
|
|
916
917
|
*/
|
|
917
918
|
background: rgba(70, 200, 250, 0.1);
|
|
918
|
-
border-top: 1px solid rgba(70, 200, 250, 0.3);
|
|
919
|
-
border-bottom: 1px solid rgba(70, 200, 250, 0.3);
|
|
920
919
|
}
|
|
921
920
|
.line {
|
|
922
921
|
text-decoration: none;
|
|
@@ -1554,7 +1553,7 @@ nav.error-message {
|
|
|
1554
1553
|
color: #8fd400;
|
|
1555
1554
|
}
|
|
1556
1555
|
*/
|
|
1557
|
-
.running-apps .spinner {
|
|
1556
|
+
.running-apps .spinner, .not-running-apps .spinner {
|
|
1558
1557
|
width: 50px;
|
|
1559
1558
|
text-align: center;
|
|
1560
1559
|
font-size: 20px;
|
package/server/socket.js
CHANGED
|
@@ -106,9 +106,17 @@ class Socket {
|
|
|
106
106
|
//const subscribers = this.subscriptions.get(e.id) || new Set();
|
|
107
107
|
subscribers.forEach((subscriber) => {
|
|
108
108
|
if (subscriber.readyState === WebSocket.OPEN) {
|
|
109
|
-
|
|
110
|
-
delete
|
|
111
|
-
|
|
109
|
+
let res = Object.assign({}, e)
|
|
110
|
+
delete res.rpc
|
|
111
|
+
delete res.rawrpc
|
|
112
|
+
if (res.data && res.data.id && res.data.raw) {
|
|
113
|
+
res.data = {
|
|
114
|
+
id: res.data.id,
|
|
115
|
+
raw: res.data.raw
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
console.log("*** res1", res)
|
|
119
|
+
subscriber.send(JSON.stringify(res))
|
|
112
120
|
}
|
|
113
121
|
});
|
|
114
122
|
}
|
|
@@ -126,9 +134,19 @@ class Socket {
|
|
|
126
134
|
if (subscribers.size > 0) {
|
|
127
135
|
subscribers.forEach((subscriber) => {
|
|
128
136
|
if (subscriber.readyState === WebSocket.OPEN) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
137
|
+
|
|
138
|
+
let res = Object.assign({}, e)
|
|
139
|
+
delete res.rpc
|
|
140
|
+
delete res.rawrpc
|
|
141
|
+
if (res.data && res.data.id && res.data.raw) {
|
|
142
|
+
res.data = {
|
|
143
|
+
id: res.data.id,
|
|
144
|
+
raw: res.data.raw
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
console.log("*** res2", res)
|
|
148
|
+
subscriber.send(JSON.stringify(res))
|
|
149
|
+
|
|
132
150
|
}
|
|
133
151
|
});
|
|
134
152
|
}
|