pinokiod 3.8.149 → 3.8.151

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.
@@ -5,12 +5,10 @@ class Connector extends Processor {
5
5
  this.router = router
6
6
  }
7
7
  handle ({ match, connector, dial, }) {
8
- // console.log("connector.handle", { match, connector, dial })
9
8
  let connector_name = connector.host + ":" + connector.port
10
9
  let listener = "0.0.0.0:PORT_PLACEHOLDER_" + connector_name
11
10
  let listener_pointer = connector.host + ":PORT_PLACEHOLDER_" + connector_name
12
11
  let port_placeholder = "PORT_PLACEHOLDER_" + connector_name
13
- // console.log("CONNECTING", { listener, dial, listener_pointer, match })
14
12
 
15
13
  let handler = [{
16
14
  "handler": "reverse_proxy",
@@ -18,7 +16,6 @@ class Connector extends Processor {
18
16
  "headers": {
19
17
  "request": {
20
18
  "set": {
21
- // "Origin": ["http://127.0.0.1:11434"],
22
19
  "X-Forwarded-Proto": ["{http.request.header.X-Forwarded-Proto}"],
23
20
  //"X-Forwarded-Proto": ["{http.request.scheme}"],
24
21
  //"X-Forwarded-Proto": ["https"],
@@ -34,23 +31,6 @@ class Connector extends Processor {
34
31
  }
35
32
  }
36
33
  }
37
- // {
38
- // "handler": "headers",
39
- // "request": {
40
- // "set": {
41
- // "X-Forwarded-Proto": ["https"],
42
- // "X-Forwarded-Host": ["{http.request.host}"]
43
- // }
44
- // },
45
- // "response": {
46
- // "set": {
47
- // "Access-Control-Allow-Origin": ["*"],
48
- // "Access-Control-Allow-Methods": ["GET, POST, OPTIONS, PUT, DELETE"],
49
- // "Access-Control-Allow-Headers": ["*"],
50
- // "Vary": ["Origin"]
51
- // }
52
- // }
53
- // }
54
34
  }]
55
35
  // if the dial port has been overridden by router.custom_routers, use that instead
56
36
  let parsed_dial = this.parse_ip(dial)
@@ -93,28 +73,9 @@ class Connector extends Processor {
93
73
  }
94
74
  }
95
75
  },
96
- // {
97
- // "handler": "headers",
98
- // "request": {
99
- // "set": {
100
- // "X-Forwarded-Proto": ["https"],
101
- // "X-Forwarded-Host": ["{http.request.host}"]
102
- // }
103
- // },
104
- // "response": {
105
- // "set": {
106
- // "Access-Control-Allow-Origin": ["*"],
107
- // "Access-Control-Allow-Methods": ["GET, POST, OPTIONS, PUT, DELETE"],
108
- // "Access-Control-Allow-Headers": ["*"],
109
- // "Vary": ["Origin"]
110
- // }
111
- // }
112
- // }
113
76
  ]
114
77
  })
115
78
  this.router.add({ host: connector.host, dial: listener_pointer, match })
116
- // this.router._tree[connector_name] = dial
117
- // this.router._tree[connector_name] = dial
118
79
  }
119
80
  }
120
81
  module.exports = Connector
@@ -9,6 +9,7 @@ const PeerHomeRouter = require('./peer_home_router')
9
9
  const PeerVariableRouter = require('./peer_variable_router')
10
10
  const PeerPortRouter = require('./peer_port_router')
11
11
  const PeerPeerRouter = require('./peer_peer_router')
12
+ const Environment = require("../environment")
12
13
  class Router {
13
14
  constructor(kernel) {
14
15
  this.kernel = kernel
@@ -61,15 +62,21 @@ class Router {
61
62
  }
62
63
  */
63
64
  this.custom_routers = {}
64
- console.log({ router_paths })
65
65
  for(let router_path of router_paths) {
66
66
  let router_abs_path = this.kernel.path("network", router_path)
67
67
  let config = await this.kernel.require(router_abs_path)
68
- console.log({ config })
69
68
  for(let port in config) {
70
69
  this.custom_routers[port] = config[port]
71
70
  }
72
71
  }
72
+
73
+ let env = await Environment.get(this.kernel.homedir)
74
+ this.active = false
75
+ if (env && env.PINOKIO_HTTPS_ACTIVE && (env.PINOKIO_HTTPS_ACTIVE==="1" || env.PINOKIO_HTTPS_ACTIVE.toLowerCase()==="true")) {
76
+ this.active = true
77
+ }
78
+
79
+
73
80
  }
74
81
  async add({ host, match, dial }) {
75
82
  if (!this._mapping[host]) {
@@ -91,8 +98,6 @@ class Router {
91
98
  mapping[host][url] = Array.from(internal_maps[url])
92
99
  }
93
100
  }
94
-
95
-
96
101
  let host_mapping = mapping[this.kernel.peer.host]
97
102
  if (host_mapping) {
98
103
  for(let key in host_mapping) {
@@ -101,36 +106,13 @@ class Router {
101
106
  let transformed = key.replace(":" + cache_key, '')
102
107
  let port = this.port_cache[cache_key]
103
108
  host_mapping[transformed + ":" + port] = host_mapping[key]
104
- // console.log("replacing", transformed + ":" + port, "with", host_mapping[key])
105
109
  delete host_mapping[key]
106
110
  }
107
111
  }
108
112
  }
109
113
  mapping[this.kernel.peer.host] = host_mapping
110
- // let json = JSON.stringify(host_mapping)
111
- // for(let key in this.port_cache) {
112
- // console.log("replacing", key, "with", this.port_cache[key])
113
- // json = json.replaceAll(key, this.port_cache[key])
114
- // }
115
- // console.log("json", json)
116
- // let m = JSON.parse(json)
117
- //
118
- // mapping[this.kernel.peer.host] = m
119
- // console.log("AFTER REPLACING", mapping)
120
114
  }
121
-
122
-
123
115
  return mapping
124
-
125
- // let json = JSON.stringify(mapping)
126
- // for(let key in this.port_cache) {
127
- // console.log("replacing", key, "with", this.port_cache[key])
128
- // json = json.replaceAll(key, this.port_cache[key])
129
- // }
130
- // let m = JSON.parse(json)
131
- //
132
- // console.log("AFTER REPLACING", m)
133
- // return m
134
116
  }
135
117
  /*
136
118
  returns only the published peer info
@@ -147,17 +129,12 @@ class Router {
147
129
  */
148
130
  published() {
149
131
  let pub = {}
150
- // console.log("published info", this.info)
151
132
  if (this.info) {
152
133
  let routes = this.info[this.kernel.peer.host]
153
134
  for(let dial in routes) {
154
135
  let matches = routes[dial]
155
- // current host => the single source of truth
156
- // if (dial.startsWith(this.kernel.peer.host)) {
157
- pub[dial] = matches
158
- // }
136
+ pub[dial] = matches
159
137
  }
160
- // console.log({ pub })
161
138
  }
162
139
  return pub
163
140
  }
@@ -166,27 +143,9 @@ class Router {
166
143
  // find all PORT_PLACEHOLDER patterns
167
144
  const matches = jsonString.match(/:PORT_PLACEHOLDER_[0-9.:]+/g)
168
145
 
169
-
170
146
  // iterate through them and see if the port already exists
171
147
  let count = matches ? new Set(matches).size : 0
172
- //console.log("fill matches", { matches, count })
173
- /*
174
- let count = 0
175
- if (matches) {
176
- for(let match of matches) {
177
- console.log("testing", match)
178
- const port_match = match.match(/[0-9.]+:([0-9]+)/);
179
- let port = port_match ? port_match[1] : null
180
- console.log({ port, port_match })
181
- if (port && !this.port_mapping[port]) {
182
- count++
183
- }
184
- }
185
- }
186
- */
187
-
188
148
  let new_config
189
-
190
149
  if (count > 0) {
191
150
  let ports = await this.kernel.ports(count)
192
151
  let response = Util.fill_object(this.config, /PORT_PLACEHOLDER_.+/, ports, this.port_cache)
@@ -198,47 +157,40 @@ class Router {
198
157
  let chunks = local_share_key.split(":")
199
158
  let original_port = chunks[chunks.length-1]
200
159
  let local_share_ip = chunks.slice(0, chunks.length-1).join(":")
201
-
202
160
  let local_share_port = replaced_map[key]
203
161
  if (!this.local_network_mapping[local_share_ip]) {
204
162
  this.local_network_mapping[local_share_ip] = {}
205
163
  }
206
164
  this.local_network_mapping[local_share_ip][original_port] = local_share_port
207
-
208
-
209
165
  //let original_port = key.replace("PORT_PLACEHOLDER_", "")
210
166
  this.port_mapping[original_port] = replaced_map[key]
211
- // console.log("set port_mapping", { original_port, key, replaced_map })
212
167
  }
213
168
  this.port_cache = replaced_map
214
169
  }
215
-
216
170
  }
217
171
 
218
172
 
219
173
  // set local config
220
174
  async local() {
221
175
  this._mapping = {}
222
- // this._tree = {}
223
176
  this.localhost_home_router.handle()
224
177
  this.localhost_variable_router.handle(this.kernel.memory.local)
225
178
  for(let proc of this.kernel.processes.info) {
226
179
  this.localhost_port_router.handle(proc)
227
180
  }
228
- //this.mapping = this._mapping
229
-
230
-
231
- for(let host in this.kernel.peer.info) {
232
- let peer = this.kernel.peer.info[host]
233
- if (peer.host === this.kernel.peer.host) {
234
- this.peer_home_router.handle(peer)
235
- this.peer_variable_router.handle(peer)
236
- this.peer_port_router.handle(peer)
181
+ if (this.kernel.peer.active) {
182
+ for(let host in this.kernel.peer.info) {
183
+ let peer = this.kernel.peer.info[host]
184
+ if (peer.host === this.kernel.peer.host) {
185
+ this.peer_home_router.handle(peer)
186
+ this.peer_variable_router.handle(peer)
187
+ this.peer_port_router.handle(peer)
188
+ }
237
189
  }
190
+ await this.fill()
238
191
  }
239
- await this.fill()
240
192
  this.mapping = this._mapping
241
- // this.tree = this._tree
193
+ console.log("after local()", JSON.stringify(this.mapping, null, 2))
242
194
  }
243
195
 
244
196
  // set remote config
@@ -251,9 +203,7 @@ class Router {
251
203
  }
252
204
  //await this.fill()
253
205
  this.mapping = this._mapping
254
- // this.tree = this._tree
255
206
  this.info = this._info()
256
- // console.log("TREE", JSON.stringify(this.tree, null, 2))
257
207
  }
258
208
 
259
209
  // update caddy config
@@ -269,64 +219,9 @@ class Router {
269
219
  console.log("Caddy Response", { response })
270
220
  this.old_config = this.config
271
221
  } catch (e) {
272
- console.log("EEEEEEEEEEEEE", e.message)
222
+ console.log("EEEEEEEEEEEEE", e)
273
223
  }
274
224
  }
275
225
  }
276
-
277
- // async refresh() {
278
- //// console.log("router.refresh")
279
- //// console.time("router.refresh")
280
- //// console.log("> procs", this.kernel.processes.info)
281
- //// console.log("> peers", this.kernel.peer.info)
282
- // this._mapping = {}
283
- //// this.port_mapping = {} // 127.0.0.1 => 192.168,..
284
- //// this.local_network_mapping = {}
285
- //
286
- // let old_config = this.config
287
- //
288
- // // 1. Localhost handling
289
- // this.localhost_home_router.handle()
290
- // this.localhost_variable_router.handle(this.kernel.memory.local)
291
- // for(let proc of this.kernel.processes.info) {
292
- // this.localhost_port_router.handle(proc)
293
- // }
294
- // this.mapping = this._mapping
295
- //
296
- // // 2. Peers handling
297
- // for(let host in this.kernel.peer.info) {
298
- // let peer = this.kernel.peer.info[host]
299
- // if (peer.host === this.kernel.peer.host) {
300
- // this.peer_home_router.handle(peer)
301
- // this.peer_variable_router.handle(peer)
302
- // this.peer_port_router.handle(peer)
303
- // } else {
304
- // this.peer_peer_router.handle(peer)
305
- // }
306
- // }
307
- // // replace :PORT_PLACEHOLDER with available ports
308
- //
309
- //
310
- // await this.fill()
311
- // this.mapping = this._mapping
312
- // console.timeEnd("router.refresh")
313
- //
314
- //
315
- // // compare old config with new config
316
- // // if it hasn't changed, don't do anything
317
- // // if it has changed, refresh
318
- //
319
- // if (JSON.stringify(this.config) === JSON.stringify(old_config)) {
320
- // console.log("config hasn't updated")
321
- // } else {
322
- // console.log("config has updated")
323
- // let response = await axios.post('http://127.0.0.1:2019/load', this.config, {
324
- // headers: { 'Content-Type': 'application/json' }
325
- // }).catch((e) => {
326
- // console.log("EEEEEEEEEEEEE", e.message)
327
- // })
328
- // console.log("Caddy Response", { response })
329
- // }
330
- // }
331
226
  }
332
227
  module.exports = Router
@@ -54,23 +54,6 @@ class LocalhostHomeRouter {
54
54
  }
55
55
  }
56
56
  },
57
- //{
58
- // "handler": "headers",
59
- // "request": {
60
- // "set": {
61
- // "X-Forwarded-Proto": ["https"],
62
- // "X-Forwarded-Host": ["{http.request.host}"]
63
- // }
64
- // },
65
- // "response": {
66
- // "set": {
67
- // "Access-Control-Allow-Origin": ["*"],
68
- // "Access-Control-Allow-Methods": ["GET, POST, OPTIONS, PUT, DELETE"],
69
- // "Access-Control-Allow-Headers": ["*"],
70
- // "Vary": ["Origin"]
71
- // }
72
- // }
73
- //}
74
57
  ]
75
58
  },
76
59
  ]
@@ -83,7 +66,13 @@ class LocalhostHomeRouter {
83
66
  "default": {
84
67
  "writer": {
85
68
  "output": "file",
86
- "filename": this.router.kernel.path("logs/caddy.log")
69
+ "filename": this.router.kernel.path("logs/caddy.log"),
70
+ "roll": true,
71
+ "roll_size_mb": 1,
72
+ "roll_keep": 1,
73
+ "roll_keep_days": 1,
74
+ "roll_gzip": false,
75
+ "roll_local_time": true
87
76
  },
88
77
  "level": "INFO"
89
78
  }
@@ -15,7 +15,6 @@ class LocalhostVariableRouter extends Processor {
15
15
  if (val.startsWith("http")) {
16
16
  let dial = val.replace(/https?:\/\//, '')
17
17
  let name = this.api_name(this.router.kernel.platform, this.router.kernel.homedir, script_path)
18
- console.log({ dial, name, has_port: this.has_port(dial), parsed_dial: this.parse_ip(dial) })
19
18
  if (this.has_port(dial)) {
20
19
  if (key === "url") {
21
20
  this.common.handle({
@@ -5,7 +5,6 @@ class Processor {
5
5
  return chunks.length === 2
6
6
  }
7
7
  api_name(platform, home, str) {
8
- console.log({ platform, home, str })
9
8
  let api_path
10
9
  let rel_path
11
10
  let name
@@ -19,9 +18,7 @@ class Processor {
19
18
  api_path = _path.resolve(home, "api")
20
19
  rel_path = _path.relative(api_path, str)
21
20
  }
22
- console.log({ api_path, rel_path, })
23
21
  name = rel_path.split(_path.sep)[0]
24
- console.log({ name })
25
22
  return name
26
23
  }
27
24
  parse_ip(str) {
package/kernel/shell.js CHANGED
@@ -2,7 +2,6 @@ const { Terminal } = require('xterm-headless');
2
2
  const { SerializeAddon } = require("xterm-addon-serialize");
3
3
  const sanitize = require("sanitize-filename");
4
4
  const YAML = require('yaml')
5
- //const kill = require('./tree-kill');
6
5
  const kill = require('kill-sync')
7
6
  const fastq = require('fastq')
8
7
  const { v4: uuidv4 } = require('uuid');
@@ -988,18 +987,6 @@ class Shell {
988
987
  this.ondata({ raw: `\r\n\r\n██ Terminated Shell ${this.id}\r\n████\r\n` })
989
988
  console.log("before cb 1")
990
989
  cb()
991
-
992
- // let map = this.kernel.processes.map || {}
993
- // kill(this.ptyProcess.pid, map, 'SIGKILL', () => {
994
- // console.log("child procs killed for", this.ptyProcess.pid)
995
- // this.ptyProcess.kill()
996
- // this.ptyProcess = undefined
997
- // // automatically remove the shell from this.kernel.shells
998
- // this.kernel.shell.rm(this.id)
999
- // this.ondata({ raw: `\r\n\r\n██ Terminated Shell ${this.id}\r\n████\r\n` })
1000
- // console.log("before cb 1")
1001
- // cb()
1002
- // });
1003
990
  } else {
1004
991
  kill(this.ptyProcess.pid, "SIGKILL", true)
1005
992
  this.ptyProcess.kill()
@@ -1007,18 +994,8 @@ class Shell {
1007
994
  // automatically remove the shell from this.kernel.shells
1008
995
  this.kernel.shell.rm(this.id)
1009
996
  this.ondata({ raw: `\r\n\r\n██ Terminated Shell ${this.id}\r\n████\r\n` })
1010
-
1011
- // let map = this.kernel.processes.map || {}
1012
- // kill(this.ptyProcess.pid, map, 'SIGKILL');
1013
- // console.log("child procs killed for", this.ptyProcess.pid)
1014
- // this.ptyProcess.kill()
1015
- // this.ptyProcess = undefined
1016
- // // automatically remove the shell from this.kernel.shells
1017
- // this.kernel.shell.rm(this.id)
1018
- // this.ondata({ raw: `\r\n\r\n██ Terminated Shell ${this.id}\r\n████\r\n` })
1019
997
  }
1020
998
  } else {
1021
- // // automatically remove the shell from this.kernel.shells
1022
999
  this.kernel.shell.rm(this.id)
1023
1000
  this.ondata({ raw: `\r\n\r\n██ Terminated Shell ${this.id}\r\n████\r\n` })
1024
1001
  }
package/kernel/shells.js CHANGED
@@ -35,20 +35,9 @@ class Shells {
35
35
  } else {
36
36
  m = "ls"
37
37
  }
38
- console.time("init_env")
39
38
  await sh.init_env({
40
39
  env: this.kernel.bin.envs({}),
41
40
  })
42
- console.timeEnd("init_env")
43
- // let response = await sh.start({
44
- // message: m,
45
- // env: this.kernel.bin.envs({}),
46
- // conda: {
47
- // skip: true
48
- // }
49
- // }, async (stream) => {
50
- // process.stdout.write(stream.raw)
51
- // })
52
41
 
53
42
  this.kernel.envs = sh.env
54
43
  // also set the uppercase variables if they're not set
@@ -157,9 +146,6 @@ class Shells {
157
146
  }
158
147
  ondata(stream)
159
148
  })
160
- console.log("SHELL RESPONSE", response)
161
-
162
-
163
149
  /*
164
150
  {
165
151
  method: "shell.run",
@@ -246,12 +232,10 @@ class Shells {
246
232
  line = line.replaceAll(err, "")
247
233
  }
248
234
  }
249
- console.log("BEFORE SHELL RETURN 1")
250
235
 
251
236
  // don't return if there's an error
252
237
  return { id: sh.id, response, stdout: response, event: m, error: shortened_errs }
253
238
  } else {
254
- console.log("BEFORE SHELL RETURN 2")
255
239
  // need to make a request
256
240
  return { id: sh.id, response, stdout: response, event: m }
257
241
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.8.149",
3
+ "version": "3.8.151",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  const express = require('express');
2
- //const kill = require('../kernel/tree-kill');
3
2
  const kill = require('kill-sync')
4
3
  const portfinder = require('portfinder-cp');
5
4
  const proxy = require('express-http-proxy-cp');
@@ -2623,7 +2622,8 @@ class Server {
2623
2622
  peers,
2624
2623
  list,
2625
2624
  name: this.kernel.peer.name,
2626
- active: this.kernel.peer.active,
2625
+ https_active: this.kernel.router.active,
2626
+ peer_active: this.kernel.peer.active,
2627
2627
  port_mapping: this.kernel.router.port_mapping,
2628
2628
  // port_mapping: this.kernel.caddy.port_mapping,
2629
2629
  // ip_mapping: this.kernel.caddy.ip_mapping,
@@ -109,8 +109,8 @@ const install = async (name, url, term, socket, options) => {
109
109
 
110
110
  }
111
111
  }
112
- const createTerm = async () => {
113
- const theme = Object.assign({ }, xtermTheme.Terminal_Basic, {
112
+ const createTerm = async (_theme) => {
113
+ const theme = Object.assign({ }, _theme, {
114
114
  selectionBackground: "red",
115
115
  selectionForeground: "white"
116
116
  })
@@ -111,7 +111,9 @@ body.dark .type-tabs {
111
111
  }
112
112
  .navheader2 {
113
113
  padding: 15px 10px;
114
+ /*
114
115
  background: white;
116
+ */
115
117
  }
116
118
  .navheader {
117
119
  backdrop-filter: blur(16px);
@@ -632,7 +634,9 @@ body.columns .containers {
632
634
  }
633
635
  .terminal-container {
634
636
  padding: 10px 0;
637
+ /*
635
638
  background: white;
639
+ */
636
640
  flex-grow: 1;
637
641
  position: relative;
638
642
  /*
package/server/socket.js CHANGED
@@ -19,7 +19,6 @@ class Socket {
19
19
  });
20
20
  ws.on('message', async (message) => {
21
21
  const req = JSON.parse(message);
22
- console.log({ req })
23
22
  if (req.response) {
24
23
  this.parent.kernel.api.respond(req)
25
24
  } else {
@@ -28,15 +27,11 @@ class Socket {
28
27
  // look for repos that match
29
28
 
30
29
  if (req.uri) {
31
- console.log("## 1")
32
30
  if (req.mode === "open") {
33
- console.log("## 2")
34
31
  // get the default script and respond
35
32
  let id = this.parent.kernel.api.filePath(req.uri)
36
33
  try {
37
- console.log("## 3")
38
34
  let default_url = await this.parent.kernel.api.get_default(id)
39
- console.log({ id, default_url })
40
35
  ws.send(JSON.stringify({
41
36
  data: {
42
37
  uri: default_url
@@ -46,15 +41,10 @@ class Socket {
46
41
  console.log(e)
47
42
  }
48
43
  } else {
49
- console.log("## 4")
50
- console.log("REQ.URI", req.uri)
51
44
  if (req.uri.startsWith("http")) {
52
- console.log("## 5")
53
45
  // open
54
46
  Util.openfs(req.uri, { mode: "open" })
55
47
  } else {
56
- console.log("## 6")
57
- console.log("sdfsfsfsdfsd>>>>>>>>>>>>>>>>>>>>>>>>>>>")
58
48
  /******************************************************************
59
49
  *
60
50
  * req.uri is ALWAYS either of the two:
@@ -69,24 +59,18 @@ class Socket {
69
59
  let id = this.parent.kernel.api.filePath(req.uri)
70
60
 
71
61
  if (req.status) {
72
- console.log("## 7")
73
62
  ws.send(JSON.stringify({
74
63
  data: this.parent.kernel.api.running[id] ? true : false
75
64
  }))
76
65
  } else if (req.stop) {
77
- console.log("## 8")
78
- console.log(">>>>>>>>>>>>>>>>>>>>>")
79
66
  this.parent.kernel.api.stop({ params: req })
80
67
  } else {
81
- console.log("## 9")
82
68
  let buf = this.buffer[id]
83
69
  let sh = this.active_shell[id]
84
70
  this.subscribe(ws, id, buf, sh)
85
71
  if (req.mode !== "listen") {
86
- console.log("## 10")
87
72
  // Run only if currently not running
88
73
  if (!this.parent.kernel.api.running[id]) {
89
- console.log("## 11")
90
74
 
91
75
  // clear the log first
92
76
 
@@ -102,32 +86,21 @@ class Socket {
102
86
  }
103
87
  } else if (req.method) {
104
88
  if (req.id) {
105
- console.log("req.id", req.id)
106
89
  let buf = this.buffer[req.id]
107
90
  let sh = this.active_shell[req.id]
108
- console.log({ buf, sh })
109
91
  this.subscribe(ws, req.id, buf, sh)
110
- console.log("Process 2")
111
92
  if (!sh) {
112
- //if (req.mode !== "listen") {
113
- console.log("Process 3")
114
93
  this.parent.kernel.api.process(req)
115
- console.log("Process 4")
116
94
  }
117
95
  } else {
118
- console.log("Process 1")
119
96
  this.subscribe(ws, req.method)
120
- console.log("Process 2")
121
97
  if (req.mode !== "listen") {
122
- console.log("Process 3")
123
98
  this.parent.kernel.api.process(req)
124
- console.log("Process 4")
125
99
  }
126
100
  }
127
101
  } else if (req.emit) {
128
102
  this.parent.kernel.shell.emit(req)
129
103
  } else if (req.key && req.id) {
130
- console.log("SOCKET", req)
131
104
  this.parent.kernel.shell.emit({
132
105
  id: req.id,
133
106
  emit: req.key
@@ -125,7 +125,12 @@ document.addEventListener("DOMContentLoaded", () => {
125
125
  document.querySelector("#bootstrap").classList.add("hidden")
126
126
  document.querySelector(".explain").classList.add("hidden")
127
127
 
128
- const theme = Object.assign({ }, xtermTheme.Terminal_Basic, {
128
+ <% if (theme === "dark") { %>
129
+ let _theme = xtermTheme.FrontEndDelight
130
+ <% } else { %>
131
+ let _theme = xtermTheme.Tomorrow
132
+ <% } %>
133
+ const theme = Object.assign({ }, _theme, {
129
134
  selectionBackground: "red",
130
135
  selectionForeground: "white"
131
136
  })
@@ -220,7 +220,13 @@ document.addEventListener("DOMContentLoaded", async () => {
220
220
  // let name = "0x" + url.split("").map(c => c.charCodeAt(0).toString(16).padStart(2, "0")).join("");
221
221
  let name = await installname(url)
222
222
  if (name) {
223
- if (!term) term = await createTerm()
223
+ if (!term) {
224
+ <% if (theme === "dark") { %>
225
+ term = await createTerm(xtermTheme.FrontEndDelight)
226
+ <% } else { %>
227
+ term = await createTerm(xtermTheme.Tomorrow)
228
+ <% } %>
229
+ }
224
230
  let params = new URLSearchParams(location.search)
225
231
  let entries = [...params.entries()]
226
232
  let options;