socket-function 0.8.40 → 0.9.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.
Files changed (45) hide show
  1. package/.eslintrc.js +50 -50
  2. package/SocketFunction.ts +280 -276
  3. package/SocketFunctionTypes.ts +90 -90
  4. package/hot/HotReloadController.ts +105 -70
  5. package/mobx/UrlParam.ts +39 -39
  6. package/mobx/observer.tsx +49 -49
  7. package/mobx/promiseToObservable.tsx +41 -41
  8. package/package.json +30 -28
  9. package/require/CSSShim.ts +19 -19
  10. package/require/RequireController.ts +252 -252
  11. package/require/buffer.js +2368 -2368
  12. package/require/compileFlags.ts +44 -44
  13. package/require/require.html +13 -13
  14. package/require/require.js +462 -454
  15. package/spec.txt +115 -115
  16. package/src/CallFactory.ts +389 -383
  17. package/src/JSONLACKS/JSONLACKS.generated.js +17 -17
  18. package/src/JSONLACKS/JSONLACKS.pegjs +247 -247
  19. package/src/JSONLACKS/JSONLACKS.ts +429 -375
  20. package/src/args.ts +21 -21
  21. package/src/batching.ts +170 -126
  22. package/src/caching.ts +318 -314
  23. package/src/callHTTPHandler.ts +203 -203
  24. package/src/callManager.ts +134 -134
  25. package/src/certStore.ts +29 -25
  26. package/src/fixLargeNetworkCalls.ts +8 -8
  27. package/src/formatting/colors.ts +78 -78
  28. package/src/formatting/format.ts +160 -156
  29. package/src/formatting/logColors.ts +17 -17
  30. package/src/misc.ts +302 -150
  31. package/src/nodeCache.ts +92 -92
  32. package/src/nodeProxy.ts +54 -54
  33. package/src/profiling/getOwnTime.ts +142 -142
  34. package/src/profiling/measure.ts +273 -244
  35. package/src/profiling/stats.ts +212 -212
  36. package/src/profiling/tcpLagProxy.ts +63 -63
  37. package/src/storagePath.ts +10 -10
  38. package/src/tlsParsing.ts +96 -96
  39. package/src/types.ts +8 -8
  40. package/src/webSocketServer.ts +250 -237
  41. package/test/client.css +2 -2
  42. package/test/client.ts +46 -46
  43. package/test/server.ts +43 -43
  44. package/test/shared.ts +52 -58
  45. package/tsconfig.json +26 -26
package/test/server.ts CHANGED
@@ -1,43 +1,43 @@
1
- // import debugbreak from "debugbreak";
2
- // debugbreak(1);
3
- // debugger;
4
-
5
- import { RequireController } from "../require/RequireController";
6
- import { SocketFunction } from "../SocketFunction";
7
- import { getArgs } from "../src/args";
8
- import { Test } from "./shared";
9
- import path from "path";
10
- import { compileTransform, compileTransformBefore } from "typenode";
11
-
12
- // Must add CSS shim before we import any clientside files
13
- // NOTE: The css shim only need to run serverside, as clientside doesn't run compilation,
14
- // and instead just copies serverside module contents.
15
- import "../require/CSSShim";
16
-
17
- // Import clientside files, so they can be whitelisted
18
- import "./client";
19
- import { getCallObj } from "../src/nodeProxy";
20
-
21
-
22
- void main();
23
-
24
- async function main() {
25
- SocketFunction.rejectUnauthorized = false;
26
-
27
- SocketFunction.expose(Test);
28
-
29
- SocketFunction.expose(RequireController);
30
- SocketFunction.setDefaultHTTPCall(RequireController, "requireHTML", "./test/client");
31
-
32
- const port = 2542;
33
-
34
- await SocketFunction.mount({ port });
35
-
36
-
37
- {
38
- let serverId = await SocketFunction.connect({ port, address: "letx.ca" });
39
- let call = Test.nodes[serverId].add[getCallObj](1, 2);
40
- console.log(call);
41
- console.log(await SocketFunction.getHTTPCallLink(call));
42
- }
43
- }
1
+ // import debugbreak from "debugbreak";
2
+ // debugbreak(1);
3
+ // debugger;
4
+
5
+ import { RequireController } from "../require/RequireController";
6
+ import { SocketFunction } from "../SocketFunction";
7
+ import { getArgs } from "../src/args";
8
+ import { Test } from "./shared";
9
+ import path from "path";
10
+ import { compileTransform, compileTransformBefore } from "typenode";
11
+
12
+ // Must add CSS shim before we import any clientside files
13
+ // NOTE: The css shim only need to run serverside, as clientside doesn't run compilation,
14
+ // and instead just copies serverside module contents.
15
+ import "../require/CSSShim";
16
+
17
+ // Import clientside files, so they can be whitelisted
18
+ import "./client";
19
+ import { getCallObj } from "../src/nodeProxy";
20
+
21
+
22
+ void main();
23
+
24
+ async function main() {
25
+ SocketFunction.rejectUnauthorized = false;
26
+
27
+ SocketFunction.expose(Test);
28
+
29
+ SocketFunction.expose(RequireController);
30
+ SocketFunction.setDefaultHTTPCall(RequireController, "requireHTML", "./test/client");
31
+
32
+ const port = 2542;
33
+
34
+ await SocketFunction.mount({ port });
35
+
36
+
37
+ {
38
+ let serverId = await SocketFunction.connect({ port, address: "letx.ca" });
39
+ let call = Test.nodes[serverId].add[getCallObj](1, 2);
40
+ console.log(call);
41
+ console.log(await SocketFunction.getHTTPCallLink(call));
42
+ }
43
+ }
package/test/shared.ts CHANGED
@@ -1,59 +1,53 @@
1
- import { getArgs } from "../src/args";
2
- import { SocketFunction } from "../SocketFunction";
3
-
4
- import "typenode";
5
- module.moduleContents;
6
-
7
- class TestBase {
8
- memberVariable = 5;
9
-
10
- async add(lhs: number, rhs: number) {
11
- let caller = Test.context.caller?.nodeId;
12
- if (!caller) {
13
- throw new Error("No caller?");
14
- }
15
- console.log(`Caller is ${caller}`);
16
- return lhs + rhs;
17
- }
18
-
19
- async callMe() {
20
- let caller = Test.context.caller?.nodeId;
21
- if (!caller) {
22
- throw new Error("No caller?");
23
- }
24
- console.log(`Caller is ${caller}`);
25
- void (async () => {
26
- let seqNum = 1;
27
- while (true) {
28
- console.log(`Calling client at ${seqNum}`);
29
- await Test.nodes[caller].callBack();
30
- await new Promise(resolve => setTimeout(resolve, 1000));
31
- seqNum++;
32
- }
33
- })();
34
- }
35
-
36
- async callBack() {
37
- console.log(`Got callback at ${Date.now()}`);
38
- }
39
- }
40
-
41
- export const Test = SocketFunction.register(
42
- "80d9f328-72df-4baa-8be8-019c1003d4a2",
43
- new TestBase(),
44
- () => ({
45
- add: {
46
- // hooks: [
47
- // async (config) => {
48
-
49
- // }
50
- // ]
51
- },
52
- callMe: {},
53
- callBack: {
54
-
55
- },
56
- //fncNotAsync: {},
57
- //notAFnc: {},
58
- })
1
+ import { getArgs } from "../src/args";
2
+ import { SocketFunction } from "../SocketFunction";
3
+
4
+ import "typenode";
5
+ module.moduleContents;
6
+
7
+ class TestBase {
8
+ memberVariable = 5;
9
+
10
+ async add(lhs: number, rhs: number) {
11
+ let caller = SocketFunction.getCaller().nodeId;
12
+ console.log(`Caller is ${caller}`);
13
+ return lhs + rhs;
14
+ }
15
+
16
+ async callMe() {
17
+ let caller = SocketFunction.getCaller().nodeId;
18
+ console.log(`Caller is ${caller}`);
19
+ void (async () => {
20
+ let seqNum = 1;
21
+ while (true) {
22
+ console.log(`Calling client at ${seqNum}`);
23
+ await Test.nodes[caller].callBack();
24
+ await new Promise(resolve => setTimeout(resolve, 1000));
25
+ seqNum++;
26
+ }
27
+ })();
28
+ }
29
+
30
+ async callBack() {
31
+ console.log(`Got callback at ${Date.now()}`);
32
+ }
33
+ }
34
+
35
+ export const Test = SocketFunction.register(
36
+ "80d9f328-72df-4baa-8be8-019c1003d4a2",
37
+ new TestBase(),
38
+ () => ({
39
+ add: {
40
+ // hooks: [
41
+ // async (config) => {
42
+
43
+ // }
44
+ // ]
45
+ },
46
+ callMe: {},
47
+ callBack: {
48
+
49
+ },
50
+ //fncNotAsync: {},
51
+ //notAFnc: {},
52
+ })
59
53
  );
package/tsconfig.json CHANGED
@@ -1,27 +1,27 @@
1
- {
2
- "compilerOptions": {
3
- "strict": true,
4
- "module": "CommonJS",
5
- "esModuleInterop": true,
6
- "allowSyntheticDefaultImports": true,
7
- "moduleResolution": "node",
8
- "target": "es2018",
9
- "lib": [
10
- "ESNext",
11
- "dom",
12
- "dom.iterable"
13
- ],
14
- "jsx": "react",
15
- "alwaysStrict": true,
16
- "jsxFactory": "preact.createElement",
17
- "jsxFragmentFactory": "preact.Fragment",
18
- "types": [
19
- "node",
20
- ],
21
- "experimentalDecorators": true,
22
- "emitDecoratorMetadata": false,
23
- "skipLibCheck": true,
24
- "inlineSourceMap": true,
25
- "inlineSources": true,
26
- },
1
+ {
2
+ "compilerOptions": {
3
+ "strict": true,
4
+ "module": "CommonJS",
5
+ "esModuleInterop": true,
6
+ "allowSyntheticDefaultImports": true,
7
+ "moduleResolution": "node",
8
+ "target": "es2018",
9
+ "lib": [
10
+ "ESNext",
11
+ "dom",
12
+ "dom.iterable"
13
+ ],
14
+ "jsx": "react",
15
+ "alwaysStrict": true,
16
+ "jsxFactory": "preact.createElement",
17
+ "jsxFragmentFactory": "preact.Fragment",
18
+ "types": [
19
+ "node",
20
+ ],
21
+ "experimentalDecorators": true,
22
+ "emitDecoratorMetadata": false,
23
+ "skipLibCheck": true,
24
+ "inlineSourceMap": true,
25
+ "inlineSources": true,
26
+ },
27
27
  }