pinokiod 3.9.0 → 3.9.2

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.
Files changed (118) hide show
  1. package/kernel/api/filepicker/index.js +59 -0
  2. package/kernel/api/fs/index.js +6 -4
  3. package/kernel/api/index.js +123 -37
  4. package/kernel/api/input/index.js +2 -0
  5. package/kernel/api/web/index.js +6 -0
  6. package/kernel/bin/caddy.js +127 -0
  7. package/kernel/bin/cloudflared.js +1 -0
  8. package/kernel/bin/conda.js +10 -2
  9. package/kernel/bin/cuda.js +0 -16
  10. package/kernel/bin/ffmpeg.js +4 -6
  11. package/kernel/bin/git.js +55 -29
  12. package/kernel/bin/gxx.js +8 -6
  13. package/kernel/bin/huggingface.js +4 -5
  14. package/kernel/bin/index.js +347 -88
  15. package/kernel/bin/node.js +13 -6
  16. package/kernel/bin/py.js +1 -1
  17. package/kernel/bin/setup.js +146 -0
  18. package/kernel/bin/uv.js +4 -5
  19. package/kernel/bin/zip.js +7 -8
  20. package/kernel/connect/index.js +25 -0
  21. package/kernel/connect/providers/github/README.md +11 -0
  22. package/kernel/connect/providers/x/README.md +96 -0
  23. package/kernel/connect/providers/x/index.js +152 -0
  24. package/kernel/environment.js +50 -1
  25. package/kernel/index.js +152 -32
  26. package/kernel/info.js +4 -2
  27. package/kernel/kv.js +38 -0
  28. package/kernel/loader.js +13 -3
  29. package/kernel/peer.js +161 -0
  30. package/kernel/procs.js +116 -0
  31. package/kernel/prototype.js +62 -0
  32. package/kernel/router/common.js +42 -0
  33. package/kernel/router/connector.js +81 -0
  34. package/kernel/router/index.js +235 -0
  35. package/kernel/router/localhost_home_router.js +84 -0
  36. package/kernel/router/localhost_port_router.js +15 -0
  37. package/kernel/router/localhost_variable_router.js +37 -0
  38. package/kernel/router/peer_home_router.js +15 -0
  39. package/kernel/router/peer_peer_router.js +26 -0
  40. package/kernel/router/peer_port_router.js +45 -0
  41. package/kernel/router/peer_variable_router.js +46 -0
  42. package/kernel/router/processor.js +31 -0
  43. package/kernel/shell.js +141 -60
  44. package/kernel/shells.js +32 -17
  45. package/kernel/store.js +58 -0
  46. package/kernel/sysinfo.js +0 -1
  47. package/kernel/util.js +143 -36
  48. package/package.json +4 -1
  49. package/pipe/index.js +0 -2
  50. package/script/index.js +12 -0
  51. package/server/index.js +1473 -553
  52. package/server/public/Socket.js +5 -1
  53. package/server/public/SourceCodePro-Regular.ttf +0 -0
  54. package/server/public/SpaceMono-Bold.ttf +0 -0
  55. package/server/public/SpaceMono-BoldItalic.ttf +0 -0
  56. package/server/public/SpaceMono-Italic.ttf +0 -0
  57. package/server/public/SpaceMono-Regular.ttf +0 -0
  58. package/server/public/commander.js +40 -0
  59. package/server/public/common.js +60 -0
  60. package/server/public/dropzone-min.js +2 -0
  61. package/server/public/dropzone.css +1 -0
  62. package/server/public/filepond-plugin-file-validate-type.min.js +9 -0
  63. package/server/public/filepond-plugin-image-crop.min.js +9 -0
  64. package/server/public/filepond-plugin-image-edit.min.css +8 -0
  65. package/server/public/filepond-plugin-image-edit.min.js +9 -0
  66. package/server/public/filepond-plugin-image-exif-orientation.min.js +9 -0
  67. package/server/public/filepond-plugin-image-preview.min.css +8 -0
  68. package/server/public/filepond-plugin-image-preview.min.js +9 -0
  69. package/server/public/filepond-plugin-image-resize.min.js +9 -0
  70. package/server/public/filepond-plugin-image-transform.min.js +9 -0
  71. package/server/public/filepond.min.css +8 -0
  72. package/server/public/filepond.min.js +9 -0
  73. package/server/public/fscreator.js +174 -0
  74. package/server/public/fseditor.js +212 -0
  75. package/server/public/github.png +0 -0
  76. package/server/public/highlight-js.js +81 -0
  77. package/server/public/highlight.css +9 -0
  78. package/server/public/highlight.js +1244 -0
  79. package/server/public/install.js +17 -20
  80. package/server/public/modalinput.js +105 -9
  81. package/server/public/opener.js +3 -1
  82. package/server/public/pinokio-black.png +0 -0
  83. package/server/public/pinokio-black2.png +0 -0
  84. package/server/public/redoc.standalone.js +1832 -0
  85. package/server/public/style.css +211 -17
  86. package/server/public/swagger-ui-bundle.js +2 -0
  87. package/server/public/swagger-ui.css +3 -0
  88. package/server/public/x.js +63 -0
  89. package/server/socket.js +136 -39
  90. package/server/views/404.ejs +0 -1
  91. package/server/views/app.ejs +356 -90
  92. package/server/views/bootstrap.ejs +22 -19
  93. package/server/views/connect/x.ejs +324 -0
  94. package/server/views/connect.ejs +197 -0
  95. package/server/views/download.ejs +7 -1
  96. package/server/views/editor.ejs +68 -9
  97. package/server/views/explore.ejs +13 -10
  98. package/server/views/file_explorer.ejs +10 -37
  99. package/server/views/github.ejs +218 -0
  100. package/server/views/help.ejs +4 -3
  101. package/server/views/index.ejs +268 -118
  102. package/server/views/install.ejs +56 -29
  103. package/server/views/keys.ejs +276 -0
  104. package/server/views/network.ejs +889 -0
  105. package/server/views/partials/dynamic.ejs +9 -0
  106. package/server/views/partials/menu.ejs +7 -1
  107. package/server/views/prototype/index.ejs +311 -0
  108. package/server/views/prototype/show.ejs +383 -0
  109. package/server/views/redoc.ejs +18 -0
  110. package/server/views/required_env_editor.ejs +11 -2
  111. package/server/views/settings.ejs +38 -10
  112. package/server/views/setup.ejs +254 -0
  113. package/server/views/setup_home.ejs +192 -0
  114. package/server/views/shell.ejs +781 -0
  115. package/server/views/swaggerui.ejs +19 -0
  116. package/server/views/terminal.ejs +174 -42
  117. package/LICENSE +0 -7
  118. package/server/views/proxy.ejs +0 -405
@@ -9,11 +9,20 @@
9
9
  <link href="/css/brands.min.css" rel="stylesheet">
10
10
  <link href="/markdown.css" rel="stylesheet"/>
11
11
  <link href="/noty.css" rel="stylesheet"/>
12
+ <link href="/filepond.min.css" rel="stylesheet" />
13
+ <link href="/filepond-plugin-image-preview.min.css" rel="stylesheet" />
14
+ <link href="/filepond-plugin-image-edit.min.css" rel="stylesheet" />
12
15
  <link href="/style.css" rel="stylesheet"/>
13
16
  <% if (agent === "electron") { %>
14
17
  <link href="/electron.css" rel="stylesheet"/>
15
18
  <% } %>
16
19
  <style>
20
+ .online {
21
+ width: 10px;
22
+ height: 10px;
23
+ background: yellowgreen;
24
+ border-radius: 10px;
25
+ }
17
26
  #menu {
18
27
  display: flex;
19
28
  }
@@ -29,7 +38,9 @@
29
38
  */
30
39
  }
31
40
  #menu.margin {
41
+ /*
32
42
  padding: 5px;
43
+ */
33
44
  }
34
45
  #menu.margin i {
35
46
  display: none;
@@ -44,6 +55,7 @@ html, body {
44
55
  }
45
56
  body {
46
57
  display: flex;
58
+ flex-direction: column;
47
59
  }
48
60
  .menu {
49
61
  overflow: auto;
@@ -133,7 +145,9 @@ body.dark .header-item .btn2 {
133
145
  */
134
146
  height: 80px;
135
147
  width: 80px;
148
+ /*
136
149
  border-radius: 10px;
150
+ */
137
151
  object-fit: contain;
138
152
  display: inline-block;
139
153
  /*
@@ -173,7 +187,13 @@ body.dark #new-window {
173
187
  color: white;
174
188
  */
175
189
  }
190
+ /*
191
+ .dark .app-info {
192
+ background: rgba(255,255,255,0.04);
193
+ }
194
+ */
176
195
  .app-info {
196
+
177
197
  /*
178
198
  display: flex;
179
199
  */
@@ -181,10 +201,56 @@ body.dark #new-window {
181
201
  text-align: center;;
182
202
  font-weight: bold;
183
203
  align-items: center;
184
- padding: 20px 0px;
204
+ padding: 20px 0px 0px;
205
+ /*
206
+ background: rgba(0,0,0,0.04);
207
+ */
208
+ }
209
+ .folderbuttons {
210
+ display: grid;
211
+ grid-template-columns: repeat(4, 1fr);
212
+ gap: 0px;
213
+ }
214
+ .header-btns {
215
+ padding: 0 !important;
216
+ }
217
+ body.dark .header-btns {
218
+ border-top: 1px solid rgba(255,255,255,0.04);
219
+ }
220
+ .app-info-edit {
221
+ text-decoration: none;
222
+ color: black;
223
+ border-bottom: 1px solid rgba(255,255,255,0.1);
224
+ }
225
+ /*
226
+ .dark .app-info-edit {
227
+ border-top: 1px solid rgba(255,255,255,0.2);
228
+ border-bottom: 1px solid rgba(255,255,255,0.2);
229
+ }
230
+ */
231
+ .dark .app-info-edit:hover {
232
+ background: rgba(0,0,0,0.2);
233
+ }
234
+ .app-info-edit:hover{
235
+ background: rgba(0,0,0,0.05);
236
+ }
237
+ .app-info-edit i{
238
+ display: block;
239
+ }
240
+ .app-info-edit, .app-info-copy {
241
+ font-weight: normal;
242
+
243
+ /*
244
+ border-radius: 20px;
245
+ */
246
+ font-size: 12px;
247
+ padding: 15px 5px;
248
+ /*
249
+ margin: 10px 20px 0;
250
+ */
185
251
  }
186
- .app-info i {
187
- font-size: 60px;
252
+ .app-info .btn {
253
+ width: 100%;
188
254
  }
189
255
  .app-info > * {
190
256
  padding: 5px;
@@ -428,10 +494,12 @@ nav .logo {
428
494
  }
429
495
  body.dark #location {
430
496
  color: white;
497
+ background: rgba(255,255,255,0.03);
431
498
  }
432
499
  #location {
433
- background: none;
434
- padding: 15px;
500
+ background: rgba(0,0,0,0.04);
501
+ padding: 10px;
502
+ margin: 0 10px;
435
503
  font-size: 12px;
436
504
  font-family: verdana;
437
505
  box-sizing: border-box;
@@ -515,6 +583,31 @@ body.dark .loader-container {
515
583
  margin-right: 5px;
516
584
  font-size: 16px !important;
517
585
  }
586
+
587
+
588
+ .custom-label {
589
+ position: absolute;
590
+ top: 0;
591
+ left: 0;
592
+ right: 0;
593
+ bottom: 0;
594
+ display: flex;
595
+ align-items: center;
596
+ justify-content: center;
597
+ pointer-events: none; /* Let clicks fall through to FilePond */
598
+ font-size: 14px;
599
+ color: rgba(0, 0, 0, 0.5);
600
+ z-index: 5;
601
+ }
602
+ .appcanvas {
603
+ display: flex;
604
+ flex-grow: 1;
605
+ border-top: 1px solid rgba(0, 0,0 ,0.04);
606
+ }
607
+ body.dark .appcanvas {
608
+ border-top: 1px solid rgba(255,255,255,0.04);
609
+ }
610
+
518
611
  @media only screen and (max-width: 480px) {
519
612
  nav .btn2 {
520
613
  width: auto !important;
@@ -574,43 +667,124 @@ body.dark .loader-container {
574
667
  <script src="/Socket.js"></script>
575
668
  <script src="/noty.js"></script>
576
669
  <script src="/notyq.js"></script>
670
+ <script src="/filepond-plugin-file-validate-type.min.js"></script>
671
+ <script src="/filepond-plugin-image-exif-orientation.min.js"></script>
672
+ <script src="/filepond-plugin-image-preview.min.js"></script>
673
+ <script src="/filepond-plugin-image-edit.min.js"></script>
674
+ <script src="/filepond-plugin-image-crop.min.js"></script>
675
+ <script src="/filepond-plugin-image-resize.min.js"></script>
676
+ <script src="/filepond-plugin-image-transform.min.js"></script>
677
+ <script src="/filepond.min.js"></script>
678
+ <script src="/fseditor.js"></script>
577
679
  </head>
578
680
  <body class='<%=theme%>' data-platform="<%=platform%>">
681
+ <header class='navheader grabbable'>
682
+ <h1>
683
+ <a class='home' href="/"><i class="fa-solid fa-house"></i></a>
684
+ <button class='btn2' id='back'><div><i class="fa-solid fa-chevron-left"></i></div><div>Prev</div></button>
685
+ <button class='btn2' id='forward'><div><i class="fa-solid fa-chevron-right"></i></div><div>Next</div></button>
686
+ <a class='btn2 create-new' id='create-new-folder'><div><i class='fa-solid fa-plus'></i></div><div>New</div></a>
687
+ <a class='btn2' id='explore' href="/?mode=explore"><div><i class="fa-solid fa-globe"></i></div><div>Discover</div></a>
688
+ <a href="/network" class='btn2'><div><i class="fa-solid fa-wifi"></i></div><div>Network</div></a>
689
+ <a href="/connect" class='btn2'><div><i class="fa-solid fa-circle-user"></i></div><div>Connect</div></a>
690
+ <input type='url' id='location' readonly>
691
+ <div class='nav-btns'>
692
+ <a class='btn2' href="<%=portal%>" target="_blank"><div><i class="fa-solid fa-question"></i></div><div>Help</div></a>
693
+ <button class='btn2' id='genlog'><div><i class="fa-solid fa-laptop-code"></i></div><div>Logs</div></button>
694
+ <a id='downloadlogs' download class='hidden btn2' href="/pinokio/logs.zip"><div><i class="fa-solid fa-download"></i></div><div>Download logs</div></a>
695
+ <a class='btn2' href="/?mode=settings"><div><i class="fa-solid fa-gear"></i></div><div>Settings</div></a>
696
+ <% if (agent === "electron") { %>
697
+ <a href="/" target="_blank" class='btn2' features="browser"><div><i class="fa-solid fa-square-up-right"></i></div><div>Open</div></a>
698
+ <% } else { %>
699
+ <a href="/" target="_blank" class='btn2'><div><i class="fa-solid fa-square-up-right"></i></div><div>Open</div></a>
700
+ <% } %>
701
+ <button id='new-window' title='open a new window' class='btn2'><div><i class="fa-solid fa-plus"></i></div><div>Window</div></button>
702
+ </div>
703
+ </h1>
704
+ </header>
705
+ <div class='appcanvas'>
579
706
  <aside class='active'>
580
707
  <div class='header-top header-item'>
581
708
  <div class='app-info'>
582
709
  <% if (config.icon) { %>
583
- <img src="<%=rawpath%>/<%=config.icon%>?raw=true"/>
710
+ <img src="<%=config.icon%>"/>
584
711
  <% } else { %>
585
712
  <i class="fa-regular fa-circle-dot"></i>
586
713
  <% } %>
587
714
  <div><%=config.title%></div>
715
+ <div class="folderpath">/api/<%=name%></div>
716
+ <div class='header-btns'>
717
+ <a class='btn header-item frame-link' href="/prototype">
718
+ <div class='tab'>
719
+ <i class='fa-solid fa-bolt'></i> Setup
720
+ </div>
721
+ </a>
722
+ <button class='btn header-item frame-link' id='edit-toggle'>
723
+ <div class='tab'>
724
+ <i class='fa-solid fa-pen-to-square'></i> Edit
725
+ </div>
726
+ </button>
727
+ </div>
728
+ <div class='editsubmenu submenu hidden'>
729
+ <div class='btn header-item frame-link' id='edit'>
730
+ <div class='tab'><i class="fa-solid fa-pencil"></i> Edit info</div>
731
+ </div>
732
+ <div class='btn header-item frame-link' id='move'>
733
+ <div class='tab'><i class="fa-solid fa-right-to-bracket"></i> Move folder</div>
734
+ </div>
735
+ <div class='btn header-item frame-link' id='copy'>
736
+ <div class='tab'><i class="fa-solid fa-copy"></i> Copy folder</div>
737
+ </div>
738
+ <div class='btn header-item frame-link' id='delete' data-name="<%=name%>">
739
+ <div class='tab'><i class="fa-solid fa-trash-can"></i> Delete folder</div>
740
+ </div>
741
+ </div>
588
742
  </div>
589
743
  </div>
590
744
  <div class='m n system' data-type="n">
591
745
  <!--<a data-index="0" target="<%=src%>" href="<%=src%>" class='btn header-item frame-link'>-->
746
+ <!--
747
+ <div id='copy' data-name="<%=name%>" class='btn header-item frame-link'>
748
+ <div class='tab'><i class="fa-solid fa-copy"></i> Copy</div>
749
+ </div>
592
750
  <div id='delete' data-name="<%=name%>" class='btn header-item frame-link'>
593
751
  <div class='tab'><i class="fa-solid fa-trash-can"></i> Delete</div>
594
752
  </div>
753
+ -->
595
754
  <a target="<%=src%>" href="<%=src%>" class='btn header-item frame-link' data-index="0">
596
755
  <div class='tab'><i class="fa-regular fa-folder-open"></i> Files <div class='disk-usage'></div></div>
597
756
  </a>
757
+ <div class='dynamic'>
758
+ <% if (plugin_menu) { %>
759
+ <%- include('./partials/dynamic', { dynamic: plugin_menu, }) %>
760
+ <% } %>
761
+ </div>
762
+ <!--
763
+ <a target="run_frame" href="/run/<%=name%>" class='btn header-item frame-link' data-index="1">
764
+ <div class='tab'><i class="fa-solid fa-bolt-lightning"></i> Run...</div>
765
+ </a>
766
+ -->
767
+ <!--
768
+ <a target="_blank" href="/terminal/<%=name%>/<%=Date.now()%>" class='btn header-item frame-link' data-index="1">
769
+ <div class='tab'><i class="fa-solid fa-terminal"></i> Terminal</div>
770
+ </a>
771
+ -->
598
772
  <a target="_blank" href="<%=profile%>" class='btn header-item frame-link'>
599
773
  <div class='tab'><i class="fa-regular fa-circle-user"></i> Publisher</div>
600
774
  </a>
601
775
  <a target="_blank" href="<%=feed%>" class='btn header-item frame-link'>
602
776
  <div class='tab'><i class="fa-solid fa-rss"></i> Newsfeed</div>
603
777
  </a>
604
- <a target="/share/<%=name%>" href="/share/<%=name%>", class="btn header-item frame-link" data-index="1" data-mode="refresh">
778
+ <a target="/share/<%=name%>" href="/share/<%=name%>", class="btn header-item frame-link" data-index="2" data-mode="refresh">
605
779
  <div class='tab'><i class="fa-solid fa-wifi"></i> Share</div>
606
780
  </a>
607
- <a target="/env/api/<%=name%>" href="/env/api/<%=name%>", class="btn header-item frame-link" data-index="1" data-mode="refresh">
781
+ <a target="/env/api/<%=name%>" href="/env/api/<%=name%>", class="btn header-item frame-link" data-index="3" data-mode="refresh">
608
782
  <div class='tab'><i class="fa-solid fa-gear"></i> Configure</div>
609
783
  </a>
610
784
  </div>
611
785
  <div class='m h menu' data-type='h'>
612
786
  <% if (config.menu) { %>
613
- <%- include('./partials/menu', { menu: config.menu }) %>
787
+ <%- include('./partials/menu', { menu: config.menu, }) %>
614
788
  <% } %>
615
789
  </div>
616
790
  <div class='m s temp-menu' data-type='s'>
@@ -631,13 +805,6 @@ body.dark .loader-container {
631
805
  <button class='btn header-item' id='reload'><div class='tab'><i class="fa-solid fa-rotate-right"></i> Refresh</div></button>
632
806
  </div>
633
807
  -->
634
- <div class='grid-btns'>
635
- <a class='btn2' href="<%=portal%>" target="_blank"><div><i class="fa-solid fa-question"></i></div><div>Help</div></a>
636
- <button class='btn2' id='genlog'><div><i class="fa-solid fa-laptop-code"></i></div><div>Debug</div></button>
637
- <a id='downloadlogs' download class='hidden btn2' href="/pinokio/logs.zip"><div><i class="fa-solid fa-download"></i></div><div>Download logs</div></a>
638
- <a class='btn2' href="/"><div><i class="fa-solid fa-house"></i></div><div>Home</div></a>
639
- <button class='btn2' id='new-window' title='open a new window'><div><i class="fa-solid fa-plus"></i></div><div>Window</div></button>
640
- </div>
641
808
  <!--
642
809
  <div class='grid-btns'>
643
810
  <a class='btn2' href="/?mode=explore" id='explore'><div><i class="fa-solid fa-globe"></i></div><div>Discover</div></a>
@@ -655,11 +822,12 @@ body.dark .loader-container {
655
822
  </div>
656
823
  <% } else { %>
657
824
  <div class='container'>
825
+ <!--
658
826
  <nav>
659
827
  <div class='bar'>
660
828
  <button class='btn2' id='menu-mobile'><i class="fa-solid fa-bars"></i></button>
661
829
  <button class='btn2' id='menu'>
662
- <img src="<%=rawpath%>/<%=config.icon%>?raw=true"/>
830
+ <img src="<%=config.icon%>"/>
663
831
  <i class="fa-solid fa-arrow-right-to-bracket fa-rotate-180"></i>
664
832
  </button>
665
833
  <% if (agent === "electron") { %>
@@ -677,6 +845,7 @@ body.dark .loader-container {
677
845
  <input type='url' id='location' readonly>
678
846
  </div>
679
847
  </nav>
848
+ -->
680
849
  <main class='browserview'>
681
850
  <% if (false) { %>
682
851
  <% if (config.menu) { %>
@@ -689,9 +858,15 @@ body.dark .loader-container {
689
858
  <% } %>
690
859
  </main>
691
860
  </div>
861
+ </div>
692
862
  <script>
863
+ let started_script
693
864
  let loaded = {}
694
865
  let cursorIndex = 0;
866
+ let interacted = false
867
+ document.addEventListener("click", (e) => {
868
+ interacted = true
869
+ })
695
870
  const n = new N()
696
871
  const getTarget = (href) => {
697
872
  let u
@@ -777,8 +952,38 @@ body.dark .loader-container {
777
952
  // }
778
953
  }
779
954
  const renderSelection = (e, force) => {
780
- // if the menu has a default item, or if the url specifies a selection
781
- let selection = document.querySelector("[data-default]")
955
+ console.log("renderSelection", { e, force, started_script })
956
+ // if the renderSelection was NOT caused by the user (e is null) ==> automatic execution
957
+ // and the user has already interacted with the page, don't renderselection
958
+ console.log("> 1")
959
+ // let selection
960
+ // if (interacted) {
961
+ // if (e) {
962
+ // selection = document.querySelector("[data-default]")
963
+ // } else {
964
+ // if (started_script) {
965
+ // selection = document.querySelector(`[data-key="${started_script}"]`)
966
+ // started_script = null
967
+ // } else {
968
+ // return
969
+ // }
970
+ // }
971
+ // } else {
972
+ // selection = document.querySelector("[data-default]")
973
+ // }
974
+ let selection = document.querySelector("[data-default]")
975
+
976
+ // console.log("> 3")
977
+ // let selection
978
+ // if (started_script) {
979
+ // selection = document.querySelector(`[data-filepath="${started_script}"]`)
980
+ // started_script = null
981
+ // } else {
982
+ // // if the menu has a default item, or if the url specifies a selection
983
+ // selection = document.querySelector("[data-default]")
984
+ // }
985
+ console.log({ selection })
986
+ // let selection = document.querySelector("[data-default]")
782
987
  if (selection || location.hash && location.hash.length > 0) {
783
988
  let target
784
989
  if (location.hash && location.hash.length > 0) {
@@ -851,12 +1056,15 @@ body.dark .loader-container {
851
1056
 
852
1057
  // Instantiate a frame with the selected target's href
853
1058
  let url = target.href
854
- document.querySelector("#open-browser").href = url
855
- document.querySelector("#clone-tab").setAttribute("data-href", url)
1059
+ // document.querySelector("#open-browser").href = url
1060
+ // document.querySelector("#clone-tab").setAttribute("data-href", url)
856
1061
  document.querySelector("#location").value = url
857
1062
 
858
1063
 
859
1064
  // select the selected target element (tab)
1065
+ document.querySelectorAll(".frame-link").forEach((el) => {
1066
+ el.classList.remove("selected")
1067
+ })
860
1068
  target.classList.add("selected")
861
1069
 
862
1070
  // hide all frames
@@ -1080,25 +1288,11 @@ body.dark .loader-container {
1080
1288
 
1081
1289
  }
1082
1290
  }
1083
- console.log("loaded before", loaded)
1084
1291
  <% if (type === "run" && env.PINOKIO_SCRIPT_DEFAULT && env.PINOKIO_SCRIPT_DEFAULT.toString().toLowerCase() === "true") { %>
1085
1292
  renderSelection()
1086
1293
  <% } %>
1087
1294
  //renderCursor()
1088
- console.log("loaded after", loaded)
1089
1295
  //Reporter()
1090
- document.querySelector("#reload").addEventListener("click", (e) => {
1091
- /*
1092
- // get selected
1093
- let target = document.querySelector(".selected").target
1094
- location.hash = target
1095
- // force refresh
1096
- renderSelection(null, true)
1097
- */
1098
- let frame = document.querySelector("iframe:not(.hidden)")
1099
- frame.src = frame.src
1100
- // frame.contentWindow.location.reload();
1101
- })
1102
1296
  <% if (agent === "electron") { %>
1103
1297
  document.querySelector("#back").addEventListener("click", (e) => {
1104
1298
  nav("back")
@@ -1108,43 +1302,6 @@ body.dark .loader-container {
1108
1302
  })
1109
1303
  <% } %>
1110
1304
 
1111
- document.querySelector("#new-tab").addEventListener("click", async (e) => {
1112
- const u = prompt("url")
1113
-
1114
- if (u) {
1115
- let url
1116
- if (/^[ ]*http:/i.test(u)) {
1117
- url = u
1118
- } else if (/^[ ]*https:/i.test(u)) {
1119
- url = u
1120
- } else {
1121
- let o = {}
1122
- if (/^[0-9.:]/.test(u)) {
1123
- o.forceHttp = true
1124
- } else if (/^localhost/.test(u)) {
1125
- o.forceHttp = true
1126
- } else {
1127
- o.forceHttps = true
1128
- }
1129
- url = normalizeURL(u, o)
1130
- }
1131
-
1132
- if (url && url.trim().length > 0) {
1133
- console.log("url", url)
1134
- const { tab, frame } = await addTab(url)
1135
- tab.click()
1136
- }
1137
- }
1138
- })
1139
- document.querySelector("#clone-tab").addEventListener("click", async (e) => {
1140
- const url = document.querySelector("#clone-tab").getAttribute("data-href")
1141
- if (url && url.trim().length > 0) {
1142
- console.log("url", url)
1143
- const { tab, frame } = await addTab(url)
1144
- tab.click()
1145
- }
1146
- })
1147
-
1148
1305
  const syncTabs = async () => {
1149
1306
  let tabs = []
1150
1307
  document.querySelectorAll(".temp-menu .frame-link").forEach((el) => {
@@ -1215,12 +1372,95 @@ body.dark .loader-container {
1215
1372
  document.querySelector("#menu").classList.toggle("margin")
1216
1373
  })
1217
1374
  }
1218
- document.querySelector(".app-info").addEventListener("click", async (e) => {
1375
+ document.querySelector("#edit-toggle").addEventListener("click", async (e) => {
1219
1376
  e.preventDefault()
1220
1377
  e.stopPropagation()
1221
- location.hash = ""
1222
- renderSelection()
1223
-
1378
+ document.querySelector(".editsubmenu").classList.toggle("hidden")
1379
+ })
1380
+ document.querySelector("#move").addEventListener("click", async (e) => {
1381
+ e.preventDefault()
1382
+ e.stopPropagation()
1383
+ await FSEditor({
1384
+ title: `<%=config.title%>`,
1385
+ description: `<%=config.description%>`,
1386
+ old_path: `<%=name%>`,
1387
+ icon: `<%=config.icon%>`,
1388
+ iconpath: `<%=config.iconpath%>`,
1389
+ move: true,
1390
+ edit: true,
1391
+ redirect: (new_path) => {
1392
+ return new_path
1393
+ }
1394
+ })
1395
+ })
1396
+ document.querySelector("#edit").addEventListener("click", async (e) => {
1397
+ e.preventDefault()
1398
+ e.stopPropagation()
1399
+ await FSEditor({
1400
+ title: `<%=config.title%>`,
1401
+ description: `<%=config.description%>`,
1402
+ old_path: `<%=name%>`,
1403
+ icon: `<%=config.icon%>`,
1404
+ iconpath: `<%=config.iconpath%>`,
1405
+ edit: true,
1406
+ redirect: (new_path) => {
1407
+ return new_path
1408
+ }
1409
+ })
1410
+ })
1411
+ document.querySelector("#copy").addEventListener("click", async (e) => {
1412
+ e.preventDefault()
1413
+ e.stopPropagation()
1414
+ await FSEditor({
1415
+ title: `<%=config.title%>`,
1416
+ description: `<%=config.description%>`,
1417
+ old_path: `<%=name%>`,
1418
+ icon: `<%=config.icon%>`,
1419
+ iconpath: `<%=config.iconpath%>`,
1420
+ copy: true,
1421
+ edit: true,
1422
+ redirect: (new_path) => {
1423
+ return new_path
1424
+ }
1425
+ })
1426
+ /*
1427
+ e.preventDefault()
1428
+ e.stopPropagation()
1429
+ let folder = prompt("Enter a folder name to copy to")
1430
+ if (folder.includes(' ')) {
1431
+ alert("Please use a folder name without a space")
1432
+ return
1433
+ }
1434
+ Swal.fire({
1435
+ html: `<i class="fa-solid fa-circle-notch fa-spin"></i> Copying from <%=name%> to ${folder}`,
1436
+ customClass: {
1437
+ container: "loader-container",
1438
+ popup: "loader-popup",
1439
+ htmlContainer: "loader-dialog",
1440
+ footer: "hidden",
1441
+ actions: "hidden"
1442
+ }
1443
+ });
1444
+ let res = await fetch("/copy", {
1445
+ method: "post",
1446
+ headers: {
1447
+ "Content-Type": "application/json"
1448
+ },
1449
+ body: JSON.stringify({
1450
+ src: "<%=name%>",
1451
+ dest: folder
1452
+ })
1453
+ }).then((res) => {
1454
+ return res.json()
1455
+ })
1456
+ Swal.close()
1457
+ if (res.error) {
1458
+ alert(res.error)
1459
+ } else {
1460
+ console.log(res)
1461
+ location.href = res.success
1462
+ }
1463
+ */
1224
1464
  })
1225
1465
  document.querySelector("#delete").addEventListener("click", async (e) => {
1226
1466
  e.preventDefault()
@@ -1423,25 +1663,29 @@ body.dark .loader-container {
1423
1663
  fetch("/du/<%=name%>").then((res) => {
1424
1664
  return res.json()
1425
1665
  }).then((res) => {
1426
- let val
1427
- //let k = 1024
1428
- let k = 1000
1429
- if (res.du > k * k * k) {
1430
- // GB
1431
- val = `${Math.floor(res.du/k/k/k * 100) / 100} GB`
1432
- } else if (res.du > k * k) {
1433
- // MB
1434
- val = `${Math.floor(res.du/k/k * 100) / 100} MB`
1666
+ if (res.du > 0) {
1667
+ let val
1668
+ //let k = 1024
1669
+ let k = 1000
1670
+ if (res.du > k * k * k) {
1671
+ // GB
1672
+ val = `${Math.floor(res.du/k/k/k * 100) / 100} GB`
1673
+ } else if (res.du > k * k) {
1674
+ // MB
1675
+ val = `${Math.floor(res.du/k/k * 100) / 100} MB`
1676
+ } else {
1677
+ // KB
1678
+ val = `${Math.floor(res.du/k * 100) / 100} KB`
1679
+ }
1680
+ console.log("DU VAL", val)
1681
+ document.querySelector(".disk-usage").innerHTML = val
1435
1682
  } else {
1436
- // KB
1437
- val = `${Math.floor(res.du/k * 100) / 100} KB`
1438
1683
  }
1439
- console.log("DU VAL", val)
1440
- //document.querySelector(".disk-usage").innerHTML = `<i class="fa-regular fa-hard-drive"></i> ${val}`
1441
- document.querySelector(".disk-usage").innerHTML = val
1442
1684
  })
1443
1685
  }
1444
1686
  const refresh = async (silent, options) => {
1687
+
1688
+
1445
1689
  if (options && options.nodelay) {
1446
1690
  } else {
1447
1691
  await new Promise((resolve, reject) => {
@@ -1454,6 +1698,13 @@ body.dark .loader-container {
1454
1698
  return res.text()
1455
1699
  })
1456
1700
  document.querySelector(".menu").innerHTML = html
1701
+
1702
+ const dynamic = await fetch("<%=dynamic%>").then((res) => {
1703
+ return res.text()
1704
+ })
1705
+ console.log({ dynamic })
1706
+ document.querySelector(".dynamic").innerHTML = dynamic
1707
+
1457
1708
  location.hash = ""
1458
1709
 
1459
1710
  // render the selected frame only if not silent
@@ -1516,9 +1767,24 @@ body.dark .loader-container {
1516
1767
  console.log("asideHidden", asideHidden)
1517
1768
  if (!asideHidden) {
1518
1769
  // refresh only if aside
1770
+ console.log("type", event.data.type)
1519
1771
  if (event.data.type === 'disconnect') {
1520
1772
  console.log("Refresh 1")
1521
1773
  refresh()
1774
+ // } else if (event.data.type === 'start') {
1775
+ // // script start => select the tab
1776
+ // started_script = event.data.id
1777
+ // /*
1778
+ // id := /Users/x/pinokio/quick/system/claude/pinokio.js
1779
+ // need to transform to /run/Dia/system/claude/pinokio.js
1780
+ // */
1781
+ // let run_frame = document.querySelector(".browserview iframe[name=run_frame]")
1782
+ // const url = run_frame.contentWindow.location.pathname;
1783
+ // console.log("url", url)
1784
+ // //run_frame.name = event.data.id
1785
+ // run_frame.name = url
1786
+ //// run_frame.remove()
1787
+ // refresh()
1522
1788
  } else {
1523
1789
  console.log("Refresh 2")
1524
1790
  refresh()