olum-compiler 1.0.0 → 1.0.1

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/bin/dev.js CHANGED
@@ -24,7 +24,8 @@ serve(entryPoint).then(({ server, wsPort, PORT, log, setWsPort }) => {
24
24
  watch.on("unlink", handleChange);
25
25
 
26
26
  (function startWs(port) {
27
- const wss = new WebSocket.Server({ port });
27
+ // const wss = new WebSocket.Server({ port });
28
+ const wss = new WebSocket.Server({ server }); // using the same server port
28
29
  wss.on("listening", () => setWsPort(port)); // tell server.js the real ws port to inject
29
30
  wss.on("error", (e) => { if (e.code === "EADDRINUSE") startWs(port + 1); });
30
31
  wss.on("connection", (ws) => {
package/bin/server.js CHANGED
@@ -5,11 +5,11 @@ const http = require("http");
5
5
  const jsdom = require("jsdom");
6
6
  const colors = require("../lib/colors");
7
7
  const mimes = require("./mimes.json");
8
- let wsPort = 8090;
8
+ let wsPort = 8090; // old way of ws -- it was using seperated port from server
9
9
 
10
10
  function handleWsFile() {
11
11
  let file = fs.readFileSync(path.resolve(__dirname, "./ws.js")).toString();
12
- file = file.replace(/{{port}}/, wsPort);
12
+ // file = file.replace(/{{port}}/, wsPort);
13
13
  file = "<script>" + file + "</script>";
14
14
  return file;
15
15
  }
@@ -51,7 +51,7 @@ function getPath(entry, url) {
51
51
  */
52
52
  function serve(entry, port) {
53
53
  return new Promise((resolve, reject) => {
54
- const PORT = port ? port : process.env.PORT || 8000;
54
+ const PORT = Number(port || process.env.PORT || 3000);
55
55
  const domain = `http://localhost:${PORT}`;
56
56
 
57
57
  const server = http.createServer(handler);
package/bin/ws.js CHANGED
@@ -4,7 +4,9 @@
4
4
  const interval = 500;
5
5
  const maxAttempts = 30;
6
6
  let attempts = 0;
7
- const socketUrl = "ws://localhost:{{port}}";
7
+ const wsProtocol = location.protocol === "https:" ? "wss:" : "ws:";
8
+ // const socketUrl = `${wsProtocol}//${location.hostname}:{{port}}`;
9
+ const socketUrl = `${wsProtocol}//${location.host}`; // removing port so it uses the server port
8
10
  let socket = new WebSocket(socketUrl);
9
11
 
10
12
  socket.onmessage = function (res) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "olum-compiler",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A module for compiling/bundling olumjs projects",
5
5
  "main": "bin/index.js",
6
6
  "bin": {