socket-function 0.7.1 → 0.7.4

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": "socket-function",
3
- "version": "0.7.1",
3
+ "version": "0.7.4",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -9,7 +9,7 @@
9
9
  "@types/ws": "^8.5.3",
10
10
  "cookie": "^0.5.0",
11
11
  "debugbreak": "^0.6.5",
12
- "typenode": "^0.4.3",
12
+ "typenode": "*",
13
13
  "ws": "^8.8.0"
14
14
  },
15
15
  "scripts": {
@@ -2,6 +2,7 @@ import debugbreak from "debugbreak";
2
2
  import fs from "fs";
3
3
  import { SocketFunction } from "../SocketFunction";
4
4
  import { setHTTPResultHeaders } from "../src/callHTTPHandler";
5
+ import { isNodeTrue } from "../src/misc";
5
6
 
6
7
  module.allowclient = true;
7
8
 
@@ -54,11 +55,11 @@ let nextModuleSeqNum = 1;
54
55
 
55
56
  const requireSeqNumProcessId = "requireSeqNumProcessId_" + Date.now() + "_" + Math.random();
56
57
 
57
- const htmlFile = fs.readFileSync(__dirname + "/require.html").toString();
58
- const jsFile = fs.readFileSync(__dirname + "/require.js").toString();
59
- const bufferShim = fs.readFileSync(__dirname + "/buffer.js").toString();
58
+ const htmlFile = isNodeTrue() && fs.readFileSync(__dirname + "/require.html").toString();
59
+ const jsFile = isNodeTrue() && fs.readFileSync(__dirname + "/require.js").toString();
60
+ const bufferShim = isNodeTrue() && fs.readFileSync(__dirname + "/buffer.js").toString();
60
61
 
61
- const resolvedHTMLFile = (
62
+ const resolvedHTMLFile = isNodeTrue() && (
62
63
  htmlFile
63
64
  .replace(`<script src="./buffer.js"></script>`, `<script>${bufferShim}</script>`)
64
65
  .replace(`<script src="./require.js"></script>`, `<script>${jsFile}</script>`)
package/src/misc.ts CHANGED
@@ -23,6 +23,10 @@ export function isNode() {
23
23
  return typeof document === "undefined";
24
24
  }
25
25
 
26
+ export function isNodeTrue() {
27
+ return isNode() as true;
28
+ }
29
+
26
30
 
27
31
  if (isNode()) {
28
32
  // TODO: Find a better place for this...