pinokiod 3.11.2 → 3.11.6

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/index.js CHANGED
@@ -649,6 +649,13 @@ class Kernel {
649
649
  // 2. mkdir all the folders if not already created
650
650
  await Environment.init_folders(this.homedir)
651
651
 
652
+ // if key.json doesn't exist, create an empty json file
653
+ let ee = await this.exists(this.homedir, "key.json")
654
+ if (!ee) {
655
+ await fs.promises.writeFile(path.resolve(this.homedir, "key.json"), JSON.stringify({}))
656
+ }
657
+
658
+
652
659
 
653
660
  // // 3. check if Caddyfile exists
654
661
  // let e2 = await this.exists(this.homedir, "Caddyfile")
@@ -30,7 +30,7 @@ class Proto {
30
30
  console.log("--config", config)
31
31
  this.config = config
32
32
 
33
- if (this.config.menu) {
33
+ if (this.config && this.config.menu) {
34
34
  this.config.menu.push({
35
35
  icon: "fa-solid fa-rotate",
36
36
  text: "Update",
package/kernel/shell.js CHANGED
@@ -318,6 +318,11 @@ class Shell {
318
318
 
319
319
  // return this.id
320
320
  }
321
+ resize({ cols, rows }) {
322
+ console.log("RESIZE", { cols, rows })
323
+ this.ptyProcess.resize(cols, rows)
324
+ this.vt.resize(cols, rows)
325
+ }
321
326
  emit2(message) {
322
327
  let i = 0;
323
328
  const interval = setInterval(() => {
package/kernel/shells.js CHANGED
@@ -257,6 +257,21 @@ class Shells {
257
257
  let response = await this.send(params, ondata)
258
258
  return response
259
259
  }
260
+ resize(params) {
261
+ /*
262
+ params := {
263
+ "id": <shell id>,
264
+ "resize": {
265
+ "cols": <cols>,
266
+ "rows": <rows>,
267
+ }
268
+ }
269
+ */
270
+ let session = this.get(params.id)
271
+ if (session) {
272
+ session.resize(params.resize)
273
+ }
274
+ }
260
275
  emit(params) {
261
276
  /*
262
277
  params := {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.11.2",
3
+ "version": "3.11.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -2449,6 +2449,9 @@ class Server {
2449
2449
  let p2 = path.resolve(home, "prototype")
2450
2450
  await fse.remove(p2)
2451
2451
 
2452
+ let p3 = path.resolve(home, "plugin")
2453
+ await fse.remove(p3)
2454
+
2452
2455
  let gitconfig = path.resolve(home, "gitconfig")
2453
2456
  await fse.remove(gitconfig)
2454
2457
 
package/server/socket.js CHANGED
@@ -153,6 +153,11 @@ class Socket {
153
153
  id: req.id,
154
154
  emit: req.key
155
155
  })
156
+ } else if (req.resize && req.id) {
157
+ this.parent.kernel.shell.resize({
158
+ id: req.id,
159
+ resize: req.resize
160
+ })
156
161
  }
157
162
  }
158
163
 
@@ -811,11 +811,13 @@ body.dark .appcanvas {
811
811
  <a target="<%=src%>" href="<%=src%>" class='btn header-item frame-link' data-index="0" data-mode="refresh">
812
812
  <div class='tab'><i class="fa-regular fa-folder-open"></i> Files <div class='disk-usage'></div></div>
813
813
  </a>
814
- <a <%=config.init_required ? 'data-init' : ''%> class='btn header-item frame-link' href="/prototype?type=init&path=<%=path%>" target="/prototype?type=init&path=<%=path%>" data-index="1" data-mode="refresh">
815
- <div class='tab'>
816
- <i class='fa-solid fa-bolt'></i> Initialize
817
- </div>
818
- </a>
814
+ <% if (config.init_required) { %>
815
+ <a data-init class='btn header-item frame-link' href="/prototype?type=init&path=<%=path%>" target="/prototype?type=init&path=<%=path%>" data-index="1" data-mode="refresh">
816
+ <div class='tab'>
817
+ <i class='fa-solid fa-bolt'></i> Initialize
818
+ </div>
819
+ </a>
820
+ <% } %>
819
821
  <% if (profile || feed) { %>
820
822
  <div class='btn header-item frame-link revealer' data-group='.info-group'>
821
823
  <div class='tab'>
@@ -142,6 +142,7 @@ body.dark .context-menu-wrapper {
142
142
  transition: max-height 1s ease-in-out;
143
143
  */
144
144
  display: flex;
145
+ margin: 0 5px 0 0;
145
146
  }
146
147
  .context-menu .btn:hover {
147
148
  color: cornflowerblue !important;
@@ -245,6 +246,7 @@ body.dark .open-menu, body.dark .browse {
245
246
  <a class='home' href="/"><img class='icon' src="/pinokio-black.png"></a>
246
247
  <button class='btn2' id='back'><div><i class="fa-solid fa-chevron-left"></i></div><div>Prev</div></button>
247
248
  <button class='btn2' id='forward'><div><i class="fa-solid fa-chevron-right"></i></div><div>Next</div></button>
249
+ <button class='btn2' id='refresh-page'><div><i class="fa-solid fa-rotate-right"></i></div><div>Refresh</div></button>
248
250
  <a class='btn2 create-new' id='create-new-folder'><div><i class="fa-solid fa-folder-plus"></i></div><div>Create</div></a>
249
251
  <!--
250
252
  <a href="/new" class='btn2'><div><i class='fa-solid fa-folder-plus'></i></div><div>Create</div></a>
@@ -387,9 +389,15 @@ body.dark .open-menu, body.dark .browse {
387
389
  <button class='btn copy-menu' data-src="<%=item.browser_url%>/dev">
388
390
  <i class='fa-solid fa-copy'></i> Copy
389
391
  </button>
392
+ <button class='btn move-menu' data-src="<%=item.browser_url%>/dev" data-disable="To move the folder, the app should not be running.">
393
+ <i class="fa-solid fa-right-to-bracket"></i> Move
394
+ </button>
390
395
  <button class='btn edit-menu' data-src="<%=item.browser_url%>/dev">
391
396
  <i class='fa-solid fa-pen-to-square'></i> Edit
392
397
  </button>
398
+ <button class='btn del' data-src="<%=item.url%>" data-disable="To delete the folder, the app should not be running.">
399
+ <i class="fa-solid fa-trash-can"></i> Delete
400
+ </button>
393
401
  </div>
394
402
  </div>
395
403
  <% if (item.running_scripts) { %>
@@ -939,6 +947,13 @@ document.addEventListener("click", async (e) => {
939
947
  if (target) {
940
948
  e.preventDefault()
941
949
  e.stopPropagation()
950
+
951
+ let disable_message = target.getAttribute('data-disable')
952
+ if (disable_message && disable_message.length > 0) {
953
+ alert(disable_message)
954
+ return
955
+ }
956
+
942
957
  let line = target.closest(".line")
943
958
  let title = line.getAttribute("data-title")
944
959
  let icon = line.getAttribute("data-icon")
@@ -1043,6 +1058,13 @@ document.addEventListener("click", async (e) => {
1043
1058
  if (target) {
1044
1059
  e.preventDefault()
1045
1060
  e.stopPropagation()
1061
+
1062
+ let disable_message = target.getAttribute('data-disable')
1063
+ if (disable_message && disable_message.length > 0) {
1064
+ alert(disable_message)
1065
+ return
1066
+ }
1067
+
1046
1068
  let confirmed = confirm("Are you sure you want to delete the folder? All files in the folder will be gone.")
1047
1069
  if (confirmed) {
1048
1070
  let itemEl = target.closest(".line[data-uri]")
@@ -143,6 +143,8 @@ body {
143
143
  //
144
144
  // /install_bin?type=bin&uri=conda
145
145
  //
146
+ let shell_id
147
+ let fitAddon
146
148
  const createTerm = async (_theme) => {
147
149
  //const theme = Object.assign({ }, xtermTheme.Terminal_Basic, {
148
150
  const theme = Object.assign({ }, _theme, {
@@ -173,7 +175,7 @@ const createTerm = async (_theme) => {
173
175
  return true;
174
176
  });
175
177
 
176
- const fitAddon = new FitAddon.FitAddon();
178
+ fitAddon = new FitAddon.FitAddon();
177
179
  term.loadAddon(fitAddon);
178
180
  <% if (agent === "electron") { %>
179
181
  term.loadAddon(new WebLinksAddon.WebLinksAddon((event, uri) => {
@@ -187,7 +189,6 @@ const createTerm = async (_theme) => {
187
189
  return term
188
190
  }
189
191
  document.addEventListener("DOMContentLoaded", async () => {
190
- debugger
191
192
  const n = new N()
192
193
  let socket = new Socket()
193
194
  <% if (theme === "dark") { %>
@@ -210,6 +211,24 @@ document.addEventListener("DOMContentLoaded", async () => {
210
211
  emit: e.key
211
212
  })
212
213
  })
214
+ let observer = new ResizeObserver(() => {
215
+ fitAddon.fit()
216
+ console.log(`Resized to ${term.cols}x${term.rows}`);
217
+ // Trigger your custom handler here
218
+ if (socket) {
219
+ console.log({ shell_id, cols: term.cols, rows: term.rows })
220
+ if (shell_id) {
221
+ socket.run({
222
+ resize: {
223
+ cols: term.cols,
224
+ rows: term.rows,
225
+ },
226
+ id: shell_id
227
+ })
228
+ }
229
+ }
230
+ });
231
+ observer.observe(document.body)
213
232
  await new Promise((resolve, reject) => {
214
233
  socket.run({
215
234
  id: location.pathname,
@@ -223,6 +242,9 @@ document.addEventListener("DOMContentLoaded", async () => {
223
242
  }, async (packet) => {
224
243
  console.log("packet", packet)
225
244
  if (packet.type === "stream") {
245
+ if (packet.data.id) {
246
+ shell_id = packet.data.id
247
+ }
226
248
  term.write(packet.data.raw)
227
249
  } else if (packet.type === "result") {
228
250
  resolve()
@@ -212,6 +212,17 @@ footer .btn.go-home {
212
212
  input[type=text] {
213
213
  margin-bottom: 5px;
214
214
  }
215
+ main {
216
+ display: flex;
217
+ flex-direction: column;
218
+ height: 100%;
219
+ }
220
+ main .empty {
221
+ flex-grow: 1;
222
+ justify-content: center;
223
+ align-items: center;
224
+ opacity: 1;
225
+ }
215
226
  </style>
216
227
  <script>
217
228
  document.addEventListener("DOMContentLoaded", async () => {
@@ -254,23 +265,31 @@ document.addEventListener("DOMContentLoaded", async () => {
254
265
  <a class='home-button home' href="/"><i class='fa-solid fa-home'></i></a>
255
266
  <div class='flexible'></div>
256
267
  <div class='nav-btns'>
257
- <button class='btn' id='open-fs' data-filepath="<%=filepath%>"><i class="fa-solid fa-eye"></i> Open in File Explorer</button>
268
+ <button class='btn' id='open-fs' data-filepath="<%=filepath%>" data-command="view"><i class="fa-solid fa-eye"></i> Open in File Explorer</button>
258
269
  <div id='save' class='btn'>
259
270
  <span class='save'><i class="fa-solid fa-check"></i> Save</span>
260
271
  </div>
261
272
  </div>
262
273
  </h1>
263
274
  </header>
264
- <div id='editor'>
265
- <% items.forEach((item) => { %>
266
- <div class='env-item'>
267
- <label for="<%=item.host%>"><%=item.host%></label>
268
- <% item.vals.forEach((val, index) => { %>
269
- <input data-host="<%=item.host%>" data-index="<%=index%>" type="text" value="<%=val%>">
270
- <% }) %>
271
- </div>
272
- <% }) %>
273
- </div>
275
+ <% if (items.length > 0) { %>
276
+ <div id='editor'>
277
+ <% items.forEach((item) => { %>
278
+ <div class='env-item'>
279
+ <label for="<%=item.host%>"><%=item.host%></label>
280
+ <% item.vals.forEach((val, index) => { %>
281
+ <input data-host="<%=item.host%>" data-index="<%=index%>" type="text" value="<%=val%>">
282
+ <% }) %>
283
+ </div>
284
+ <% }) %>
285
+ </div>
286
+ <% } else { %>
287
+ <div class='empty'>
288
+ <div>no keys are set</div>
289
+ <br>
290
+ <a target="_blank" href="https://pinokiocomputer.github.io/home/docs/#/?id=autofill-from-shared-key-store" class='btn'>Learn how this works</a>
291
+ </div>
292
+ <% } %>
274
293
  </main>
275
294
  </body>
276
295
  </html>
@@ -709,6 +709,23 @@ document.addEventListener("DOMContentLoaded", async () => {
709
709
 
710
710
  }
711
711
  this.term.focus()
712
+ this.observer = new ResizeObserver(() => {
713
+ this.fit.fit()
714
+ console.log(`Resized to ${this.term.cols}x${this.term.rows}`);
715
+ // Trigger your custom handler here
716
+ if (this.socket) {
717
+ if (shell_id) {
718
+ this.socket.run({
719
+ resize: {
720
+ cols: this.term.cols,
721
+ rows: this.term.rows,
722
+ },
723
+ id: shell_id
724
+ })
725
+ }
726
+ }
727
+ });
728
+ this.observer.observe(document.body)
712
729
  }
713
730
  }
714
731
  const rpc = new RPC()
@@ -734,6 +734,23 @@ document.addEventListener("DOMContentLoaded", async () => {
734
734
 
735
735
  }
736
736
  this.term.focus()
737
+ this.observer = new ResizeObserver(() => {
738
+ this.fit.fit()
739
+ console.log(`Resized to ${this.term.cols}x${this.term.rows}`);
740
+ // Trigger your custom handler here
741
+ if (this.socket) {
742
+ if (shell_id) {
743
+ this.socket.run({
744
+ resize: {
745
+ cols: this.term.cols,
746
+ rows: this.term.rows,
747
+ },
748
+ id: shell_id
749
+ })
750
+ }
751
+ }
752
+ });
753
+ this.observer.observe(document.body)
737
754
  }
738
755
  }
739
756
  <% if (!install_required) { %>