pinokiod 1.0.11 → 1.0.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -34,7 +34,6 @@
34
34
  "isomorphic-git": "^1.23.0",
35
35
  "jsonpath-plus": "^7.2.0",
36
36
  "key-store": "^1.2.0",
37
- "localtunnel": "^2.0.2",
38
37
  "lodash": "^4.17.21",
39
38
  "marked": "^5.0.1",
40
39
  "mime-types": "^2.1.35",
package/server/index.js CHANGED
@@ -20,7 +20,9 @@ const git = require('isomorphic-git')
20
20
  const http = require('isomorphic-git/http/node')
21
21
  const marked = require('marked')
22
22
  const multer = require('multer');
23
- const localtunnel = require('localtunnel');
23
+ //const localtunnel = require('localtunnel');
24
+ //const ngrok = require("@ngrok/ngrok");
25
+
24
26
  const ejs = require('ejs');
25
27
 
26
28
 
@@ -35,7 +37,7 @@ class Server {
35
37
  this.agent = config.agent
36
38
  this.port = config.port
37
39
  this.kernel = new Kernel(config.store)
38
- this.tunnels = {}
40
+ // this.tunnels = {}
39
41
  this.version = {
40
42
  pinokiod: packagejson.version,
41
43
  pinokio: config.version
@@ -95,23 +97,24 @@ class Server {
95
97
  for(let key in localMem) {
96
98
  let val = localMem[key]
97
99
  // check for localhost url
98
- let localhost = false
99
- let tunnel
100
- try {
101
- let url = new URL(val)
102
- if (localhosts.includes(url.hostname)) {
103
- localhost = true
104
- if (this.tunnels[val]) {
105
- tunnel = this.tunnels[val].url
106
- }
107
- }
108
- } catch (e) { }
100
+ // let localhost = false
101
+ // let tunnel
102
+ // try {
103
+ // let url = new URL(val)
104
+ // if (localhosts.includes(url.hostname)) {
105
+ // localhost = true
106
+ // if (this.tunnels[val]) {
107
+ // tunnel = this.tunnels[val].url()
108
+ // //tunnel = this.tunnels[val].url
109
+ // }
110
+ // }
111
+ // } catch (e) { }
109
112
  mem.push({
110
113
  type: "local",
111
114
  key,
112
115
  val,
113
- tunnel,
114
- localhost,
116
+ // tunnel,
117
+ // localhost,
115
118
  })
116
119
  }
117
120
  return mem
@@ -262,6 +265,7 @@ class Server {
262
265
  if (pathComponents.length === 0 && req.query.mode === "explore") {
263
266
  res.render("explore", {
264
267
  version: this.version,
268
+ schema: this.kernel.schema,
265
269
  logo: this.logo,
266
270
  theme: this.theme,
267
271
  agent: this.agent,
@@ -1752,41 +1756,57 @@ class Server {
1752
1756
  let mem = this.getMemory(filepath)
1753
1757
  res.json(mem)
1754
1758
  })
1755
- this.app.post("/pinokio/tunnel", async (req, res) => {
1756
- let port
1757
- let local_host
1758
- try {
1759
- let u = new URL(req.body.url)
1760
- port = u.port
1761
- local_host = u.hostname
1762
- console.log({ local_host, port })
1763
- if (req.body.action === "start") {
1764
- //const tunnel = await localtunnel({ local_host, port: parseInt(port) });
1765
- //const tunnel = await localtunnel({ local_host: "127.0.0.1", port: parseInt(port) });
1766
- const tunnel = await localtunnel({ port: parseInt(port) });
1767
- let url = req.body.url
1768
- this.tunnels[url] = tunnel
1769
- tunnel.on('error', (err) => {
1770
- console.log(err)
1771
- delete this.tunnels[url]
1772
- })
1773
- tunnel.on('close', () => {
1774
- // tunnels are closed
1775
- console.log("tunnel closed", { url, tunnel_url: tunnel.url })
1776
- delete this.tunnels[url]
1777
- });
1778
- res.json({ url: tunnel.url })
1779
- } else if (req.body.action === "stop") {
1780
- let url = req.body.url
1781
- console.log({ tunnels: this.tunnels, url })
1782
- this.tunnels[url].close()
1783
- res.json({ url })
1784
- }
1785
- } catch (e) {
1786
- console.log("ERROR", e)
1787
- res.json({ error: e.message })
1788
- }
1789
- })
1759
+ // this.app.post("/pinokio/tunnel", async (req, res) => {
1760
+ // let port
1761
+ // let local_host
1762
+ // try {
1763
+ // let u = new URL(req.body.url)
1764
+ // port = u.port
1765
+ // local_host = u.hostname
1766
+ // console.log({ local_host, port })
1767
+ // if (req.body.action === "start") {
1768
+ // // Output ngrok url to console
1769
+ //
1770
+ // let url = req.body.url
1771
+ // console.log("tunnel", req.body)
1772
+ // const tunnel = await ngrok.forward({ addr: port, authtoken: req.body.token });
1773
+ // console.log("created", tunnel)
1774
+ // console.log("url", tunnel.url())
1775
+ // this.tunnels[url] = tunnel
1776
+ // res.json({ url: tunnel.url() })
1777
+ //
1778
+ //
1779
+ // // localtunnel
1780
+ // //const tunnel = await localtunnel({ local_host, port: parseInt(port) });
1781
+ // //const tunnel = await localtunnel({ local_host: "127.0.0.1", port: parseInt(port) });
1782
+ //
1783
+ // //const tunnel = await localtunnel({ port: parseInt(port) });
1784
+ // //this.tunnels[url] = tunnel
1785
+ // //tunnel.on('error', (err) => {
1786
+ // // console.log(err)
1787
+ // // delete this.tunnels[url]
1788
+ // //})
1789
+ // //tunnel.on('close', () => {
1790
+ // // // tunnels are closed
1791
+ // // console.log("tunnel closed", { url, tunnel_url: tunnel.url })
1792
+ // // delete this.tunnels[url]
1793
+ // //});
1794
+ // //res.json({ url: tunnel.url })
1795
+ // } else if (req.body.action === "stop") {
1796
+ // let url = req.body.url
1797
+ // await this.tunnels[url].close()
1798
+ // delete this.tunnels[url]
1799
+ // res.json({ url })
1800
+ //// let url = req.body.url
1801
+ //// console.log({ tunnels: this.tunnels, url })
1802
+ //// this.tunnels[url].close()
1803
+ //// res.json({ url })
1804
+ // }
1805
+ // } catch (e) {
1806
+ // console.log("ERROR", e)
1807
+ // res.json({ error: e.message })
1808
+ // }
1809
+ // })
1790
1810
  this.app.post("/pinokio/tabs", async (req, res) => {
1791
1811
  this.tabs[req.body.name] = req.body.tabs
1792
1812
  res.json({ success: true })
@@ -53,7 +53,6 @@ const install = async (name, url, term, socket, options) => {
53
53
  url = url + ".git"
54
54
  }
55
55
 
56
- console.log({ url , branch })
57
56
  let cmd
58
57
  if (branch) {
59
58
  cmd = `git clone -b ${branch} ${url} ${name}`
@@ -666,6 +666,7 @@ body.dark .memory {
666
666
  }
667
667
  */
668
668
  .memory {
669
+ display: none;
669
670
  position: absolute;
670
671
  z-index: 10000;
671
672
  top: 10px;
@@ -636,40 +636,43 @@ document.addEventListener("DOMContentLoaded", async () => {
636
636
  })
637
637
  Reporter()
638
638
  */
639
- document.querySelector(".memory").addEventListener("click", async (e) => {
640
- let target = e.target.classList.contains("tunnel") ? e.target : e.target.closest(".tunnel")
641
- let target2 = e.target.classList.contains("tunnel-stop") ? e.target : e.target.closest(".tunnel-stop")
642
- if (target) {
643
- e.preventDefault()
644
- e.stopPropagation()
645
- let url = target.getAttribute("data-url")
646
- let response = await fetch("/pinokio/tunnel", {
647
- method: "POST",
648
- headers: {
649
- "Content-Type": "application/json"
650
- },
651
- body: JSON.stringify({ url, action: "start" })
652
- }).then((res) => {
653
- return res.json()
654
- })
655
- await reloadMemory()
656
- } else if (target2) {
657
- console.log("target2", target2)
658
- e.preventDefault()
659
- e.stopPropagation()
660
- let url = target2.getAttribute("data-url")
661
- let response = await fetch("/pinokio/tunnel", {
662
- method: "POST",
663
- headers: {
664
- "Content-Type": "application/json"
665
- },
666
- body: JSON.stringify({ url, action: "stop" })
667
- }).then((res) => {
668
- return res.json()
669
- })
670
- await reloadMemory()
671
- }
672
- })
639
+ // document.querySelector(".memory").addEventListener("click", async (e) => {
640
+ // let target = e.target.classList.contains("tunnel") ? e.target : e.target.closest(".tunnel")
641
+ // let target2 = e.target.classList.contains("tunnel-stop") ? e.target : e.target.closest(".tunnel-stop")
642
+ // if (target) {
643
+ // e.preventDefault()
644
+ // e.stopPropagation()
645
+ // let url = target.getAttribute("data-url")
646
+ // const token = prompt("Enter an Ngrok auth token to expose your machine to the public Internet https://ngrok.com/")
647
+ // if (token && token.length > 0) {
648
+ // let response = await fetch("/pinokio/tunnel", {
649
+ // method: "POST",
650
+ // headers: {
651
+ // "Content-Type": "application/json"
652
+ // },
653
+ // body: JSON.stringify({ url, action: "start", token })
654
+ // }).then((res) => {
655
+ // return res.json()
656
+ // })
657
+ // await reloadMemory()
658
+ // }
659
+ // } else if (target2) {
660
+ // console.log("target2", target2)
661
+ // e.preventDefault()
662
+ // e.stopPropagation()
663
+ // let url = target2.getAttribute("data-url")
664
+ // let response = await fetch("/pinokio/tunnel", {
665
+ // method: "POST",
666
+ // headers: {
667
+ // "Content-Type": "application/json"
668
+ // },
669
+ // body: JSON.stringify({ url, action: "stop" })
670
+ // }).then((res) => {
671
+ // return res.json()
672
+ // })
673
+ // await reloadMemory()
674
+ // }
675
+ // })
673
676
  document.querySelector("#lv").addEventListener("click", (e) => {
674
677
  let m = e.target.closest(".memory")
675
678
  m.classList.toggle("collapsed")
@@ -145,9 +145,12 @@ body main iframe {
145
145
  </header>
146
146
  <main>
147
147
  <% if (theme === "dark") { %>
148
- <iframe name="<%=version.pinokiod%>" src="https://pinokio.computer/dark"></iframe>
148
+ <iframe name="<%=schema%>" src="https://pinokio.computer/dark"></iframe>
149
149
  <% } else { %>
150
- <iframe name="<%=version.pinokiod%>" src="https://pinokio.computer/app"></iframe>
150
+ <!--
151
+ <iframe name="<%=schema%>" src="https://pinokio.computer/app"></iframe>
152
+ -->
153
+ <iframe name="<%=schema%>" src="http://127.0.0.1:3000/app"></iframe>
151
154
  <% } %>
152
155
  </main>
153
156
  <link href="/xterm.min.css" rel="stylesheet" />
@@ -619,40 +619,46 @@ document.addEventListener("DOMContentLoaded", async () => {
619
619
  })
620
620
  Reporter()
621
621
  */
622
- document.querySelector(".memory").addEventListener("click", async (e) => {
623
- let target = e.target.classList.contains("tunnel") ? e.target : e.target.closest(".tunnel")
624
- let target2 = e.target.classList.contains("tunnel-stop") ? e.target : e.target.closest(".tunnel-stop")
625
- if (target) {
626
- e.preventDefault()
627
- e.stopPropagation()
628
- let url = target.getAttribute("data-url")
629
- let response = await fetch("/pinokio/tunnel", {
630
- method: "POST",
631
- headers: {
632
- "Content-Type": "application/json"
633
- },
634
- body: JSON.stringify({ url, action: "start" })
635
- }).then((res) => {
636
- return res.json()
637
- })
638
- await reloadMemory()
639
- } else if (target2) {
640
- console.log("target2", target2)
641
- e.preventDefault()
642
- e.stopPropagation()
643
- let url = target2.getAttribute("data-url")
644
- let response = await fetch("/pinokio/tunnel", {
645
- method: "POST",
646
- headers: {
647
- "Content-Type": "application/json"
648
- },
649
- body: JSON.stringify({ url, action: "stop" })
650
- }).then((res) => {
651
- return res.json()
652
- })
653
- await reloadMemory()
654
- }
655
- })
622
+
623
+
624
+
625
+ // document.querySelector(".memory").addEventListener("click", async (e) => {
626
+ // let target = e.target.classList.contains("tunnel") ? e.target : e.target.closest(".tunnel")
627
+ // let target2 = e.target.classList.contains("tunnel-stop") ? e.target : e.target.closest(".tunnel-stop")
628
+ // if (target) {
629
+ // e.preventDefault()
630
+ // e.stopPropagation()
631
+ // let url = target.getAttribute("data-url")
632
+ // const token = prompt("Enter an Ngrok auth token to expose your machine to the public Internet https://ngrok.com/")
633
+ // if (token && token.length > 0) {
634
+ // let response = await fetch("/pinokio/tunnel", {
635
+ // method: "POST",
636
+ // headers: {
637
+ // "Content-Type": "application/json"
638
+ // },
639
+ // body: JSON.stringify({ url, action: "start", token })
640
+ // }).then((res) => {
641
+ // return res.json()
642
+ // })
643
+ // await reloadMemory()
644
+ // }
645
+ // } else if (target2) {
646
+ // console.log("target2", target2)
647
+ // e.preventDefault()
648
+ // e.stopPropagation()
649
+ // let url = target2.getAttribute("data-url")
650
+ // let response = await fetch("/pinokio/tunnel", {
651
+ // method: "POST",
652
+ // headers: {
653
+ // "Content-Type": "application/json"
654
+ // },
655
+ // body: JSON.stringify({ url, action: "stop" })
656
+ // }).then((res) => {
657
+ // return res.json()
658
+ // })
659
+ // await reloadMemory()
660
+ // }
661
+ // })
656
662
  /*
657
663
  document.querySelector("#source").addEventListener("click", (e) => {
658
664
  refreshParent({