pinokiod 3.8.149 → 3.8.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.
@@ -61,11 +61,9 @@ class Router {
61
61
  }
62
62
  */
63
63
  this.custom_routers = {}
64
- console.log({ router_paths })
65
64
  for(let router_path of router_paths) {
66
65
  let router_abs_path = this.kernel.path("network", router_path)
67
66
  let config = await this.kernel.require(router_abs_path)
68
- console.log({ config })
69
67
  for(let port in config) {
70
68
  this.custom_routers[port] = config[port]
71
69
  }
@@ -91,8 +89,6 @@ class Router {
91
89
  mapping[host][url] = Array.from(internal_maps[url])
92
90
  }
93
91
  }
94
-
95
-
96
92
  let host_mapping = mapping[this.kernel.peer.host]
97
93
  if (host_mapping) {
98
94
  for(let key in host_mapping) {
@@ -101,36 +97,13 @@ class Router {
101
97
  let transformed = key.replace(":" + cache_key, '')
102
98
  let port = this.port_cache[cache_key]
103
99
  host_mapping[transformed + ":" + port] = host_mapping[key]
104
- // console.log("replacing", transformed + ":" + port, "with", host_mapping[key])
105
100
  delete host_mapping[key]
106
101
  }
107
102
  }
108
103
  }
109
104
  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
105
  }
121
-
122
-
123
106
  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
107
  }
135
108
  /*
136
109
  returns only the published peer info
@@ -147,17 +120,12 @@ class Router {
147
120
  */
148
121
  published() {
149
122
  let pub = {}
150
- // console.log("published info", this.info)
151
123
  if (this.info) {
152
124
  let routes = this.info[this.kernel.peer.host]
153
125
  for(let dial in routes) {
154
126
  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
- // }
127
+ pub[dial] = matches
159
128
  }
160
- // console.log({ pub })
161
129
  }
162
130
  return pub
163
131
  }
@@ -166,27 +134,9 @@ class Router {
166
134
  // find all PORT_PLACEHOLDER patterns
167
135
  const matches = jsonString.match(/:PORT_PLACEHOLDER_[0-9.:]+/g)
168
136
 
169
-
170
137
  // iterate through them and see if the port already exists
171
138
  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
139
  let new_config
189
-
190
140
  if (count > 0) {
191
141
  let ports = await this.kernel.ports(count)
192
142
  let response = Util.fill_object(this.config, /PORT_PLACEHOLDER_.+/, ports, this.port_cache)
@@ -198,36 +148,27 @@ class Router {
198
148
  let chunks = local_share_key.split(":")
199
149
  let original_port = chunks[chunks.length-1]
200
150
  let local_share_ip = chunks.slice(0, chunks.length-1).join(":")
201
-
202
151
  let local_share_port = replaced_map[key]
203
152
  if (!this.local_network_mapping[local_share_ip]) {
204
153
  this.local_network_mapping[local_share_ip] = {}
205
154
  }
206
155
  this.local_network_mapping[local_share_ip][original_port] = local_share_port
207
-
208
-
209
156
  //let original_port = key.replace("PORT_PLACEHOLDER_", "")
210
157
  this.port_mapping[original_port] = replaced_map[key]
211
- // console.log("set port_mapping", { original_port, key, replaced_map })
212
158
  }
213
159
  this.port_cache = replaced_map
214
160
  }
215
-
216
161
  }
217
162
 
218
163
 
219
164
  // set local config
220
165
  async local() {
221
166
  this._mapping = {}
222
- // this._tree = {}
223
167
  this.localhost_home_router.handle()
224
168
  this.localhost_variable_router.handle(this.kernel.memory.local)
225
169
  for(let proc of this.kernel.processes.info) {
226
170
  this.localhost_port_router.handle(proc)
227
171
  }
228
- //this.mapping = this._mapping
229
-
230
-
231
172
  for(let host in this.kernel.peer.info) {
232
173
  let peer = this.kernel.peer.info[host]
233
174
  if (peer.host === this.kernel.peer.host) {
@@ -238,7 +179,6 @@ class Router {
238
179
  }
239
180
  await this.fill()
240
181
  this.mapping = this._mapping
241
- // this.tree = this._tree
242
182
  }
243
183
 
244
184
  // set remote config
@@ -251,9 +191,7 @@ class Router {
251
191
  }
252
192
  //await this.fill()
253
193
  this.mapping = this._mapping
254
- // this.tree = this._tree
255
194
  this.info = this._info()
256
- // console.log("TREE", JSON.stringify(this.tree, null, 2))
257
195
  }
258
196
 
259
197
  // update caddy config
@@ -269,64 +207,9 @@ class Router {
269
207
  console.log("Caddy Response", { response })
270
208
  this.old_config = this.config
271
209
  } catch (e) {
272
- console.log("EEEEEEEEEEEEE", e.message)
210
+ console.log("EEEEEEEEEEEEE", e)
273
211
  }
274
212
  }
275
213
  }
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
214
  }
332
215
  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.150",
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');
@@ -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;
@@ -591,12 +591,16 @@ document.addEventListener("DOMContentLoaded", async () => {
591
591
  // })
592
592
  // }
593
593
 
594
- await this.createTerm()
594
+ <% if (theme === "dark") { %>
595
+ await this.createTerm(xtermTheme.FrontEndDelight)
596
+ <% } else { %>
597
+ await this.createTerm(xtermTheme.Tomorrow)
598
+ <% } %>
595
599
  await this.start(mode)
596
600
  }
597
- async createTerm () {
601
+ async createTerm (_theme) {
598
602
  if (!this.term) {
599
- const theme = Object.assign({ }, xtermTheme.Terminal_Basic, {
603
+ const theme = Object.assign({ }, _theme, {
600
604
  selectionBackground: "red",
601
605
  selectionForeground: "white"
602
606
  })
@@ -455,9 +455,15 @@ var term
455
455
  const n = new N()
456
456
  let socket = new Socket()
457
457
  const pull = async () => {
458
- if (!term) term = createTerm()
459
458
  socket.close()
460
459
  await new Promise((resolve, reject) => {
460
+ if (!term) {
461
+ <% if (theme === "dark") { %>
462
+ await createTerm(xtermTheme.FrontEndDelight)
463
+ <% } else { %>
464
+ await createTerm(xtermTheme.Tomorrow)
465
+ <% } %>
466
+ }
461
467
  let cwd
462
468
  let chunks = location.pathname.split("/").filter((x) => { return x })
463
469
  if (chunks.length > 0) {
@@ -489,7 +489,13 @@ var term
489
489
  const n = new N()
490
490
  let socket = new Socket()
491
491
  const pull = async () => {
492
- if (!term) term = createTerm()
492
+ if (!term) {
493
+ <% if (theme === "dark") { %>
494
+ term = await createTerm(xtermTheme.FrontEndDelight)
495
+ <% } else { %>
496
+ term = await createTerm(xtermTheme.Tomorrow)
497
+ <% } %>
498
+ }
493
499
  socket.close()
494
500
  await new Promise((resolve, reject) => {
495
501
  let cwd
@@ -131,9 +131,7 @@ body {
131
131
  <script src="/notifyinput.js"></script>
132
132
  </head>
133
133
  <body class='<%=theme%>'>
134
- <!--
135
134
  <header class='grabbable'></header>
136
- -->
137
135
  <div id='status-screen'><b><i class="fas fa-circle-notch fa-spin"></i> Setting up...</b><br>Setting up core modules including conda, uv, git, etc.</div>
138
136
  <div class='terminal-container'>
139
137
  <div id='terminal'></div>
@@ -144,8 +142,9 @@ body {
144
142
  //
145
143
  // /install_bin?type=bin&uri=conda
146
144
  //
147
- const createTerm = async () => {
148
- const theme = Object.assign({ }, xtermTheme.Terminal_Basic, {
145
+ const createTerm = async (_theme) => {
146
+ //const theme = Object.assign({ }, xtermTheme.Terminal_Basic, {
147
+ const theme = Object.assign({ }, _theme, {
149
148
  selectionBackground: "red",
150
149
  selectionForeground: "white"
151
150
  })
@@ -189,7 +188,11 @@ const createTerm = async () => {
189
188
  document.addEventListener("DOMContentLoaded", async () => {
190
189
  const n = new N()
191
190
  let socket = new Socket()
192
- let term = await createTerm()
191
+ <% if (theme === "dark") { %>
192
+ let term = await createTerm(xtermTheme.FrontEndDelight)
193
+ <% } else { %>
194
+ let term = await createTerm(xtermTheme.Tomorrow)
195
+ <% } %>
193
196
  let params = new URLSearchParams(location.search)
194
197
  let entries = [...params.entries()]
195
198
  let options;
@@ -547,13 +547,17 @@ document.addEventListener("DOMContentLoaded", async () => {
547
547
  // })
548
548
  // }
549
549
 
550
- await this.createTerm()
550
+ <% if (theme === "dark") { %>
551
+ await this.createTerm(xtermTheme.FrontEndDelight)
552
+ <% } else { %>
553
+ await this.createTerm(xtermTheme.Tomorrow)
554
+ <% } %>
551
555
  await this.start(mode)
552
556
  }
553
- async createTerm () {
557
+ async createTerm (_theme) {
554
558
  console.log(xtermTheme)
555
559
  if (!this.term) {
556
- const theme = Object.assign({ }, xtermTheme.Terminal_Basic, {
560
+ const theme = Object.assign({ }, _theme, {
557
561
  selectionBackground: "red",
558
562
  selectionForeground: "white"
559
563
  })