pinokiod 3.9.0 → 3.9.3

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