pinokiod 1.0.29 → 1.0.31

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/shell.js CHANGED
@@ -31,6 +31,11 @@ class Shell {
31
31
  this.platform = os.platform()
32
32
  this.logs = {}
33
33
  this.shell = this.platform === 'win32' ? 'cmd.exe' : 'bash';
34
+
35
+ // Windows: /D => ignore AutoRun Registry Key
36
+ // Others: --noprofile => ignore .bash_profile, --norc => ignore .bashrc
37
+ this.args = this.platform === 'win32' ? ["/D"] : ["--noprofile", "--norc"]
38
+
34
39
  //this.vt = new Terminal({ allowProposedApi: true, scrollback: 5, })
35
40
  // this.vt = new Terminal({
36
41
  // allowProposedApi: true,
@@ -113,6 +118,9 @@ class Shell {
113
118
  this.env.GRADIO_TEMP_DIR = path.resolve(this.kernel.homedir, "cache", "GRADIO_TEMP_DIR")
114
119
  this.env.PIP_CONFIG_FILE = path.resolve(this.kernel.homedir, "pipconfig")
115
120
 
121
+ this.env.PS1 = "<<PINOKIO SHELL>> "
122
+ // this.env.PROMPT_COMMAND = "export PS1=\"<<PINOKIO SHELL>> \""
123
+
116
124
  let PATH_KEY;
117
125
  if (this.env.Path) {
118
126
  PATH_KEY = "Path"
@@ -182,6 +190,8 @@ class Shell {
182
190
  // automatically add self to the shells registry
183
191
  this.kernel.shell.add(this)
184
192
 
193
+ console.log("** this.env", this.env)
194
+
185
195
  if (params.sudo) {
186
196
  let options = {
187
197
  name: "Pinokio",
@@ -352,7 +362,7 @@ class Shell {
352
362
  //let re = /([\r\n]+[^\r\n]+)(\1)/gs
353
363
  let re = /(.+)(\1)/gs
354
364
  console.log("get prompt - pty.spawn", config)
355
- let term = pty.spawn(this.shell, [], config)
365
+ let term = pty.spawn(this.shell, this.args, config)
356
366
  console.log("terminal spawned", term)
357
367
  let ready
358
368
  console.log("create terminal for prompt")
@@ -544,7 +554,7 @@ class Shell {
544
554
  if (!this.ptyProcess) {
545
555
  // ptyProcess doesn't exist => create
546
556
  this.done = false
547
- this.ptyProcess = pty.spawn(this.shell, [], config)
557
+ this.ptyProcess = pty.spawn(this.shell, this.args, config)
548
558
  this.ptyProcess.onData((data) => {
549
559
  if (!this.done) {
550
560
  this.queue.push(data)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -1849,9 +1849,25 @@ class Server {
1849
1849
  theme: this.theme,
1850
1850
  agent: this.agent,
1851
1851
  src: "/_api/" + name,
1852
- rawpath
1852
+ rawpath,
1853
1853
  })
1854
1854
  })
1855
+ this.app.post("/pinokio/delete", async (req, res) => {
1856
+ if (req.body.name) {
1857
+ let folderPath = this.kernel.path("api", req.body.name)
1858
+ console.log("delete", folderPath)
1859
+ await rimraf(folderPath)
1860
+ await new Promise((resolve, reject) => {
1861
+ setTimeout(() => {
1862
+ resolve()
1863
+ }, 5000)
1864
+ })
1865
+ console.log("deleted")
1866
+ res.json({ success: true })
1867
+ } else {
1868
+ res.json({ error: e.stack })
1869
+ }
1870
+ })
1855
1871
  // this.app.get("/pinokio/shell_state", (req, res) => {
1856
1872
  // let states = this.kernel.shell.shells.map((s) => {
1857
1873
  // return {
@@ -135,7 +135,8 @@ const createTerm = () => {
135
135
  //theme: xtermTheme.Piatto_Light,
136
136
  //theme: xtermTheme.Github,
137
137
  //theme: xtermTheme.Cobalt_Neon, // top legibility
138
- theme: xtermTheme.Duotone_Dark,
138
+ //theme: xtermTheme.Duotone_Dark,
139
+ theme: xtermTheme.FrontEndDelight,
139
140
  //theme: xtermTheme.Seafoam_Pastel,
140
141
  //theme: xtermTheme.IC_Green_PPL,
141
142
  //theme: xtermTheme.FunForrest,
@@ -7,19 +7,21 @@
7
7
  */
8
8
  /*
9
9
  --dark-nav-bg: #161616;
10
- */
11
10
  --dark-nav-bg: rgb(31, 29, 39);
11
+ */
12
+ --dark-nav-bg: rgb(27, 28, 29);
12
13
 
14
+ --dark-bg: rgb(27, 28, 29);
13
15
  /*
14
16
  --dark-bg: #202020;
15
- */
16
17
  --dark-bg: rgb(31, 29, 39);
18
+ */
17
19
  --light-bg: rgba(0,0,150,0.05);
18
20
 
19
21
  --light-thin: rgba(0,0,0,0.1);
20
22
  --dark-thin: rgba(255,255,255,0.03);
21
23
 
22
- --dark-color: rgba(255,255,255,0.9);
24
+ --dark-color: rgba(255,255,255,0.8);
23
25
  --light-color: rgba(0,0,0,0.9);
24
26
 
25
27
  --dark-fade: rgba(255,255,255,0.6);
@@ -43,7 +45,10 @@
43
45
  --light-btn-color: white;
44
46
 
45
47
  --dark-btn-bg: rgba(0,0,0,0.8);
48
+ /*
46
49
  --dark-btn-color: #b7a1ff;
50
+ */
51
+ --dark-btn-color: whitesmoke;
47
52
  }
48
53
  body.columns footer {
49
54
  }
@@ -77,14 +82,19 @@ footer pre {
77
82
  background: none !important;
78
83
  }
79
84
  footer {
85
+ font-family: verdana;
80
86
  overflow: hidden;
87
+ font-size: 11px;
88
+ font-weight: normal;
81
89
  /*
82
90
  overflow: auto;
83
91
  */
84
92
  box-sizing: border-box;
85
93
  color: var(--dark-color);
86
94
  background: var(--dark-bg);
95
+ /*
87
96
  border-top: 1px solid rgba(255,255,255,0.05);
97
+ */
88
98
  display: flex;
89
99
  align-items: center;
90
100
  padding: 10px;
@@ -99,6 +109,8 @@ footer b {
99
109
  flex-shrink: 0;
100
110
  color: var(--dark-btn-color);
101
111
  margin-right: 10px;
112
+ font-weight: normal;
113
+ font-size: 11px;
102
114
  /*
103
115
  background: var(--dark-btn-color);
104
116
  color: var(--dark-bg);
@@ -837,9 +849,12 @@ body.dark .line:hover {
837
849
  vertical-align: middle;
838
850
  font-weight: normal;
839
851
  }
852
+ body.dark .line .avatar i {
853
+ color: var(--dark-btn-color);
854
+ }
840
855
  .line .avatar i {
841
856
  font-size: 60px;
842
- color: var(--dark-btn-color);
857
+ color: var(--dark-bg);
843
858
  }
844
859
  .line .description {
845
860
  font-size: 13px;
@@ -132,7 +132,8 @@ document.addEventListener("DOMContentLoaded", () => {
132
132
  //theme: xtermTheme.Seafoam_Pastel,
133
133
  //theme: xtermTheme.IC_Green_PPL,
134
134
  //theme: xtermTheme.FunForrest,
135
- theme: xtermTheme.Jackie_Brown,
135
+ //theme: xtermTheme.Jackie_Brown,
136
+ theme: xtermTheme.FrontEndDelight,
136
137
  //theme: xtermTheme.Ocean,
137
138
 
138
139
  //theme: xtermTheme.Blazer,
@@ -30,6 +30,12 @@ body {
30
30
  .menu {
31
31
  overflow: auto;
32
32
  }
33
+ body.dark .m {
34
+ border-top: 1px solid rgba(255,255,255,0.04);
35
+ }
36
+ .m {
37
+ border-top: 1px solid rgba(0,0,0,0.04);
38
+ }
33
39
  .container {
34
40
  display: flex;
35
41
  flex-direction: column;
@@ -196,6 +202,9 @@ body.dark .header-item.cursor {
196
202
  border-left: 5px solid gold;
197
203
  */
198
204
  }
205
+ .frame-link {
206
+ cursor: pointer;
207
+ }
199
208
  body .frame-link.selected {
200
209
  /*
201
210
  border-right: 10px solid gold;
@@ -210,7 +219,10 @@ body .frame-link.selected {
210
219
  color: white;
211
220
  }
212
221
  body.dark .frame-link.selected {
213
- background: rgba(0,0,0,0.2) !important;
222
+ background: rgba(0,0,0,0.7) !important;
223
+ }
224
+ .frame-link .loader {
225
+ padding: 5px;
214
226
  }
215
227
  .frame-link .tab {
216
228
  flex-grow: 1;
@@ -218,7 +230,9 @@ body.dark .frame-link.selected {
218
230
  width: 100%;
219
231
  */
220
232
  word-break: break-word;
233
+ /*
221
234
  margin-right: 10px;
235
+ */
222
236
  }
223
237
  .frame-link .tab .flexible {
224
238
  min-width: 5px;
@@ -265,22 +279,31 @@ body.dark .grid-btns .btn2 {
265
279
  margin-right: 10px;
266
280
  }
267
281
  .temp-menu {
282
+ /*
268
283
  border-top: 1px solid rgba(0,0,0,0.1);
284
+ */
269
285
  }
270
286
  .temp-menu .del i {
271
287
  margin: 0;
272
288
  }
289
+ #delete {
290
+ color: brown;
291
+ }
273
292
  body .footer {
274
293
  }
275
294
  body.dark nav {
295
+ /*
276
296
  border-bottom: 1px solid rgba(255,255,255,0.04);
297
+ */
277
298
  }
278
299
  nav {
279
300
  background: white;
280
301
  padding: 5px;
281
302
  cursor: grab !important;
282
303
  -webkit-app-region: drag !important;
304
+ /*
283
305
  border-bottom: 1px solid rgba(0,0,0,0.04);
306
+ */
284
307
  box-sizing: border-box;
285
308
  }
286
309
  nav .btn2 {
@@ -293,7 +316,8 @@ nav .logo {
293
316
  }
294
317
  #location {
295
318
  padding: 5px;
296
- font-size: 14px;
319
+ font-size: 12px;
320
+ font-family: verdana;
297
321
  }
298
322
  .bar {
299
323
  -webkit-app-region: no-drag !important;
@@ -312,8 +336,10 @@ body.dark .header-item.cursor.header-top {
312
336
  display: block;
313
337
  }
314
338
  #new-tab:hover {
315
- background: rgba(0,0,0,0.07) !important;
339
+ background: rgba(0,0,0,0.06) !important;
340
+ color: rgb(200,0,0) !important;
316
341
  }
342
+
317
343
  #new-tab {
318
344
  cursor: pointer !important;
319
345
  justify-content: center;
@@ -331,6 +357,21 @@ body.dark #new-tab {
331
357
  padding-left: 15px;
332
358
  box-sizing: border-box;
333
359
  }
360
+ body.dark .loader-popup {
361
+ background: rgba(0,0,0,0.2);
362
+ color: whitesmoke;
363
+ }
364
+ .loader-popup {
365
+ text-transform: uppercase;
366
+ font-size: 12px;
367
+ letter-spacing: 1px;
368
+ padding: 20px;
369
+ background: rgba(0,0,0,0.2);
370
+ color: white;
371
+ }
372
+ body.dark .loader-container {
373
+ background: rgba(255,255,255,0.3);
374
+ }
334
375
  </style>
335
376
  </head>
336
377
  <body class='<%=theme%>'>
@@ -341,9 +382,12 @@ body.dark #new-tab {
341
382
  <div><%=config.title%></div>
342
383
  </div>
343
384
  </div>
344
- <div class='m system'>
385
+ <div class='m n system' data-type="n">
345
386
  <!--<a data-index="0" target="<%=src%>" href="<%=src%>" class='btn header-item frame-link'>-->
346
- <a target="<%=src%>" href="<%=src%>" class='btn header-item frame-link'>
387
+ <div id='delete' data-name="<%=name%>" class='btn header-item frame-link'>
388
+ <div class='tab'><i class="fa-solid fa-trash-can"></i> Delete</div>
389
+ </div>
390
+ <a target="<%=src%>" href="<%=src%>" class='btn header-item frame-link' data-index="0">
347
391
  <div class='tab'><i class="fa-regular fa-folder-open"></i> Files</div>
348
392
  </a>
349
393
  </div>
@@ -362,7 +406,7 @@ body.dark #new-tab {
362
406
  <%})%>
363
407
  </div>
364
408
  <div id='new-tab' class='btn header-item'>
365
- <i class="fa-solid fa-circle-plus"></i>
409
+ <i class="fa-solid fa-plus"></i>
366
410
  </div>
367
411
  <div class='flexible'></div>
368
412
  <div class='grid-btns'>
@@ -463,7 +507,7 @@ const renderSelection = (e, force) => {
463
507
  let type = id[0]
464
508
  let index = id.slice(1)
465
509
 
466
- console.log({ type, index })
510
+ console.log({ type, index })
467
511
 
468
512
  // select the selected link
469
513
  // document.querySelectorAll(".frame-link").forEach((el) => {
@@ -473,107 +517,153 @@ console.log({ type, index })
473
517
 
474
518
 
475
519
  // const target = document.querySelector(`[target='${id}']`)
520
+
521
+
476
522
  let target
477
523
  if (e) {
524
+ // If the renderSelection is triggered by an event, look for the frame-link that's triggering the event
478
525
  if (e.target.classList.contains("frame-link")) {
479
526
  target = e.target
480
527
  } else {
481
528
  target = e.target.closest(".frame-link")
482
529
  }
530
+ } else {
531
+ // if not triggered by an event, look for the target from the location hash
532
+ target = document.querySelector(`aside .${type} [data-index='${index}']`)
483
533
  }
484
534
 
485
535
 
486
- if (!target) {
487
- // find target by id
488
- //target = document.querySelector("aside [target='" + id + "']")
489
- target = document.querySelector(`aside .${type} [data-index='${index}']`)
490
- }
536
+ // if the target was found either through:
537
+ // 1. looking for the frame-link that triggered the event
538
+ // 2. or by looking at the location hash
539
+ //
540
+ // => select that tab and frame
491
541
 
492
542
  if (target) {
493
543
  console.log("# 3")
494
544
 
495
545
 
546
+ // Instantiate a frame with the selected target's href
496
547
  let url = target.href
548
+ console.log("> url", url)
497
549
  document.querySelector("#open-browser").href = url
498
550
  document.querySelector("#clone-tab").setAttribute("data-href", url)
499
551
  document.querySelector("#location").innerHTML = url
500
552
 
501
- // document.querySelector("#location").innerHTML = location.hash.slice(1)
502
- //
503
- // if (location.hash.slice(1).startsWith("/")) {
504
- // //document.querySelector("#open-browser").classList.add("hidden")
505
- // document.querySelector("#open-browser").classList.remove("hidden")
506
- // document.querySelector("#open-browser").href = location.hash.slice(1)
507
- // } else {
508
- // document.querySelector("#open-browser").classList.remove("hidden")
509
- // //document.querySelector("#open-browser").href = id
510
- // document.querySelector("#open-browser").href = location.hash.slice(1)
511
- // }
512
- // document.querySelector("#clone-tab").setAttribute("data-href", location.hash.slice(1))
513
-
514
-
515
553
 
554
+ // select the selected target element (tab)
516
555
  target.classList.add("selected")
517
556
 
518
- // select the iframe
557
+ // hide all frames
519
558
  document.querySelectorAll("iframe").forEach((el) => {
520
559
  el.classList.add("hidden")
521
560
  })
522
- let targetFrame = document.querySelector(`iframe[name='${target.target}']`)
523
- if (targetFrame) {
524
- targetFrame.classList.remove("hidden")
525
561
 
526
- // if the iframe already exists, do not
527
- if (loaded[target.target]){
528
562
 
529
- let mode = target.getAttribute("data-mode")
530
- if (mode === "refresh") {
531
- targetFrame.src = target.href
532
- return
563
+
564
+ // Look for the frame
565
+ // 1. if it's hard (".h")
566
+ // look for the url that matches
567
+ // 2. if it's soft (".s")
568
+ // find using the name attribute
569
+ let targetFrame;
570
+ if (target.closest(".h")) {
571
+ let hardFrames = document.querySelectorAll(".browserview iframe[name^=h]")
572
+ let port = new URL(target.href).port
573
+ for(let frame of hardFrames) {
574
+ console.log({ src: frame.src, href: target.href, target: target.target })
575
+ // Types of links in the tab
576
+ if (String(port) === "42000") {
577
+ // 1. running from 42000 => find a frame whose base URL matches the tab's base URL
578
+ // Pinokio links
579
+ let targetPath = new URL(target.href).pathname
580
+ let framePath = new URL(frame.src).pathname
581
+ if (targetPath === framePath) {
582
+ let beforeName = frame.name
583
+ frame.name = target.target
584
+ console.log("SET FRAME", { before: beforeName, after: frame.name, target: target.target })
585
+ targetFrame = frame
586
+ break
587
+ }
588
+ } else {
589
+ // 2. rest => find the frame whose src exactly matches the tab's url
590
+ if (target.href === frame.src) {
591
+ frame.name = target.target
592
+ targetFrame = frame
593
+ break
594
+ }
533
595
  }
596
+ // find the frame whose path matches
597
+ }
598
+ } else if (target.closest(".s")) {
599
+ targetFrame = document.querySelector(`iframe[name='${target.target}']`)
600
+ } else if (target.closest(".n")) {
601
+ targetFrame = document.querySelector(`iframe[name='${target.target}']`)
602
+ }
603
+
604
+
605
+ /*
606
+ // Load the link in the frame
607
+
608
+ 1. if the frame was found:
609
+ - if "refresh": true => refresh
610
+ - otherwise,
611
+ - if the target frame has been already loaded, don't do anything
612
+ - frame: start.json?mode=abc, link: start.json?mode=abc => don't touch
613
+ - link === frame
614
+ - frame: start.json?mode=abc, link: start.json?mode=def => should load
615
+ - link !== frame && !frame.includes(link)
616
+ - frame: start.json?mode=abc, link: start.json => don't touch
617
+ - link !== frame && frame.includes(link)
534
618
 
535
- console.log("# 4")
536
619
 
620
+
621
+ if the link is different
622
+
623
+ - if the target frame has not been loaded, refresh
624
+ 2. if the frame was NOT found => create one
625
+
626
+ */
627
+
628
+ if (targetFrame) {
629
+ targetFrame.classList.remove("hidden")
630
+ let mode = target.getAttribute("data-mode")
631
+ if (mode === "refresh") {
632
+ targetFrame.src = target.href
633
+ } else {
537
634
  if (e) {
538
- console.log("# 5", { src: targetFrame.src, href: target.href, target: target.target })
539
- // triggered with a click
540
- // do not reload iframe if the href and the src is the same
541
635
  if (target.closest(".h")) {
542
- // if (targetFrame.src.includes(target.target)) {
543
- if (targetFrame.src.includes(target.href)) {
544
- // if (targetFrame.src === target.href) {
636
+ if (target.href === targetFrame.src) {
637
+ // same url. don't do anything
545
638
  e.preventDefault()
546
639
  e.stopPropagation()
640
+ } else {
641
+ if (targetFrame.src.includes(target.href)) {
642
+ // different url, but the frame's url contains the tab url => don't touch
643
+ e.preventDefault()
644
+ e.stopPropagation()
645
+ } else {
646
+ // different url, and the frame's url does not contain the tab url => change the src of the frame and load
647
+ targetFrame.src = target.href
648
+ e.preventDefault()
649
+ e.stopPropagation()
650
+ }
547
651
  }
548
652
  } else if (target.closest(".s")) {
653
+ // load unconditionally => .s doesn't change
654
+ e.preventDefault()
655
+ e.stopPropagation()
656
+ } else if (target.closest(".n")) {
657
+ // load unconditionally => .n doesn't change
549
658
  e.preventDefault()
550
659
  e.stopPropagation()
551
660
  }
552
661
  } else {
553
- console.log("# 6")
554
662
  if (force) {
555
663
  console.log("# 7")
556
- // if (targetFrame.src !== target.href) {
557
- targetFrame.src = target.href
558
- // }
664
+ targetFrame.src = target.href
559
665
  }
560
666
  }
561
- } else {
562
- console.log("# 8")
563
- //targetFrame.contentWindow.addEventListener("load", () => {
564
- if (e) {
565
- console.log("# 9")
566
- // coming from a click => don't need to set the src
567
- } else {
568
- console.log("# 10")
569
- // load without click
570
- if (targetFrame.src !== target.href) {
571
- console.log("# 11")
572
- targetFrame.src = target.href
573
- }
574
- }
575
- loaded[target.target] = true
576
- //});
577
667
  }
578
668
  } else {
579
669
  console.log("# 12")
@@ -587,6 +677,84 @@ console.log({ type, index })
587
677
  document.querySelector("main").appendChild(frame)
588
678
  loaded[target.target] = true
589
679
  }
680
+
681
+ // if (targetFrame) {
682
+ // targetFrame.classList.remove("hidden")
683
+ //
684
+ // // if the iframe already exists, do not
685
+ // if (loaded[target.target]){
686
+ //
687
+ // // Force refresh option
688
+ // //
689
+ // // menu := [{
690
+ // // text,
691
+ // // icon,
692
+ // // mode: "refresh" => refresh regardless of any condition
693
+ // // }]
694
+ // let mode = target.getAttribute("data-mode")
695
+ // if (mode === "refresh") {
696
+ // targetFrame.src = target.href
697
+ // } else {
698
+ // console.log("# 4")
699
+ // if (e) {
700
+ // // if triggered by a click event,
701
+ // // 1. if it's a hard link (".h")
702
+ // // - ignore if the pathname is the same
703
+ // // - reload if
704
+ // console.log("# 5", { src: targetFrame.src, href: target.href, target: target.target })
705
+ // // triggered with a click
706
+ // // do not reload iframe if the href and the src is the same
707
+ // if (target.closest(".h")) {
708
+ // // if (targetFrame.src.includes(target.target)) {
709
+ // if (targetFrame.src.includes(target.href)) {
710
+ // // if (targetFrame.src === target.href) {
711
+ // e.preventDefault()
712
+ // e.stopPropagation()
713
+ // }
714
+ // } else if (target.closest(".s")) {
715
+ // e.preventDefault()
716
+ // e.stopPropagation()
717
+ // }
718
+ // } else {
719
+ // // if not triggered by event
720
+ // // refresh ONLY if programmatically forced refresh
721
+ // console.log("# 6")
722
+ // if (force) {
723
+ // console.log("# 7")
724
+ // targetFrame.src = target.href
725
+ // }
726
+ // }
727
+ // }
728
+ //
729
+ // } else {
730
+ // console.log("# 8")
731
+ // //targetFrame.contentWindow.addEventListener("load", () => {
732
+ // if (e) {
733
+ // console.log("# 9")
734
+ // // coming from a click => don't need to set the src
735
+ // } else {
736
+ // console.log("# 10")
737
+ // // load without click
738
+ // if (targetFrame.src !== target.href) {
739
+ // console.log("# 11")
740
+ // targetFrame.src = target.href
741
+ // }
742
+ // }
743
+ // loaded[target.target] = true
744
+ // //});
745
+ // }
746
+ // } else {
747
+ // console.log("# 12")
748
+ // let frame = document.createElement("iframe")
749
+ // frame.name = target.target
750
+ // frame.src = target.href
751
+ // frame.setAttribute(
752
+ // "allow",
753
+ // "clipboard-read *; clipboard-write *; accelerometer *; ambient-light-sensor *; autoplay *; battery *; camera *; display-capture *; gamepad *; geolocation *; gyroscope *; hid *; identity-credentials-get *; microphone *; midi *; otp-credentials *; serial *;"
754
+ // )
755
+ // document.querySelector("main").appendChild(frame)
756
+ // loaded[target.target] = true
757
+ // }
590
758
  } else {
591
759
  console.log("# 13")
592
760
  // couldn't find item,
@@ -596,7 +764,7 @@ console.log({ type, index })
596
764
  }
597
765
  } else {
598
766
  console.log("# 14")
599
- document.querySelector(".bar").classList.add("hidden")
767
+ // document.querySelector(".bar").classList.add("hidden")
600
768
  }
601
769
  }
602
770
  console.log("loaded before", loaded)
@@ -671,7 +839,6 @@ const syncTabs = async () => {
671
839
  })
672
840
  }
673
841
  const addTab = async (url) => {
674
- debugger
675
842
  let item = document.createElement("a")
676
843
  //let id = "ts" + Date.now()
677
844
  let index = document.querySelectorAll("aside .s .frame-link").length
@@ -688,6 +855,7 @@ const addTab = async (url) => {
688
855
 
689
856
  let frame = document.createElement("iframe")
690
857
  frame.name = id
858
+ frame.src = item.href
691
859
  frame.setAttribute(
692
860
  "allow",
693
861
  "clipboard-read *; clipboard-write *; accelerometer *; ambient-light-sensor *; autoplay *; battery *; camera *; display-capture *; gamepad *; geolocation *; gyroscope *; hid *; identity-credentials-get *; microphone *; midi *; otp-credentials *; serial *;"
@@ -714,6 +882,47 @@ document.querySelector(".app-info").addEventListener("click", async (e) => {
714
882
  renderSelection()
715
883
 
716
884
  })
885
+ document.querySelector("#delete").addEventListener("click", async (e) => {
886
+ e.preventDefault()
887
+ e.stopPropagation()
888
+ const confirmed = confirm("Are you sure you wish to delete the app?")
889
+ if (confirmed) {
890
+
891
+
892
+
893
+ let name = document.querySelector("#delete").getAttribute("data-name")
894
+ console.log("delete", name)
895
+ Swal.fire({
896
+ html: '<i class="fa-solid fa-circle-notch fa-spin"></i> Deleting',
897
+ customClass: {
898
+ container: "loader-container",
899
+ popup: "loader-popup",
900
+ htmlContainer: "loader-dialog",
901
+ footer: "hidden",
902
+ actions: "hidden"
903
+ }
904
+ });
905
+ let res = await fetch("/pinokio/delete", {
906
+ method: "post",
907
+ headers: {
908
+ "Content-Type": "application/json"
909
+ },
910
+ body: JSON.stringify({ name })
911
+ }).then((res) => {
912
+ return res.json()
913
+ })
914
+ console.log("res", res)
915
+ Swal.close()
916
+ if (res) {
917
+ if (res.success) {
918
+ location.href = "/"
919
+ } else if (res.error) {
920
+ alert(res.error)
921
+ }
922
+ }
923
+ } else {
924
+ }
925
+ })
717
926
  document.querySelector("aside").addEventListener("click", async (e) => {
718
927
  let target
719
928
 
@@ -770,6 +979,9 @@ document.querySelector("aside").addEventListener("click", async (e) => {
770
979
  //location.hash = target.getAttribute("href")
771
980
  let index = target.getAttribute("data-index")
772
981
  let type = target.closest(".m").getAttribute("data-type")
982
+
983
+ console.log({ type, index })
984
+
773
985
  location.hash = type + index
774
986
 
775
987
  document.querySelectorAll(".frame-link").forEach((el) => {
@@ -809,6 +1021,27 @@ const refresh = async () => {
809
1021
  console.log("refresh", html)
810
1022
  */
811
1023
  document.querySelector(".menu").innerHTML = html
1024
+
1025
+
1026
+ // update the frames so the name matches the tab links
1027
+
1028
+ // 1. iterate through all the "h" menu items
1029
+ // 2. for each tab that starts with "h" (hard), iterate through all iframes
1030
+ // 3. to find a frame whose src.includes(item.href)
1031
+ // 4. update the frame's name to the target attribute
1032
+
1033
+ // let hardFrames = document.querySelectorAll(".browserview iframe[name^=h]")
1034
+ // for(let frame of hardFrames) {
1035
+ // frame.removeAttribute("name")
1036
+ // location.hash = ""
1037
+ // }
1038
+ location.hash = ""
1039
+
1040
+
1041
+
1042
+
1043
+ //
1044
+
812
1045
  renderSelection()
813
1046
  // cursorIndex = 0
814
1047
  //renderCursor()
@@ -517,7 +517,8 @@ document.addEventListener("DOMContentLoaded", async () => {
517
517
  //theme: xtermTheme.Github,
518
518
 
519
519
  //theme: xtermTheme.Cobalt_Neon, // top legibility
520
- theme: xtermTheme.Duotone_Dark,
520
+ //theme: xtermTheme.Duotone_Dark,
521
+ theme: xtermTheme.FrontEndDelight,
521
522
  //theme: xtermTheme.Seafoam_Pastel,
522
523
  //theme: xtermTheme.IC_Green_PPL,
523
524
  //theme: xtermTheme.FunForrest,
@@ -508,7 +508,10 @@ document.addEventListener("DOMContentLoaded", async () => {
508
508
  //theme: xtermTheme.Github,
509
509
 
510
510
  //theme: xtermTheme.Cobalt_Neon, // top legibility
511
- theme: xtermTheme.Duotone_Dark,
511
+ //theme: xtermTheme.Duotone_Dark,
512
+ //theme: xtermTheme.Batman,
513
+ //theme: xtermTheme.Brogrammer,
514
+ theme: xtermTheme.FrontEndDelight,
512
515
  //theme: xtermTheme.Seafoam_Pastel,
513
516
  //theme: xtermTheme.IC_Green_PPL,
514
517
  //theme: xtermTheme.FunForrest,
@@ -128,7 +128,8 @@ const createTerm = () => {
128
128
  //theme: xtermTheme.Github,
129
129
 
130
130
  //theme: xtermTheme.Cobalt_Neon, // top legibility
131
- theme: xtermTheme.Duotone_Dark,
131
+ //theme: xtermTheme.Duotone_Dark,
132
+ theme: xtermTheme.FrontEndDelight,
132
133
  //theme: xtermTheme.Seafoam_Pastel,
133
134
  //theme: xtermTheme.IC_Green_PPL,
134
135
  //theme: xtermTheme.FunForrest,
@@ -87,9 +87,7 @@ body.dark .item select {
87
87
  padding: 10px;
88
88
  flex-grow: 1;
89
89
  border: none;
90
- /*
91
90
  background: rgba(0,0,0,0.05);
92
- */
93
91
  width: 100%;
94
92
  }
95
93
  .item select {