socket-function 0.10.0 → 0.10.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/package.json +2 -2
- package/test/allowclient.flag +0 -0
- package/test/client.css +0 -3
- package/test/client.ts +0 -46
- package/test/server.ts +0 -43
- package/test/shared.ts +0 -53
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "socket-function",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
|
|
7
7
|
"dependencies": {
|
|
8
|
+
"@types/ws": "^8.5.3",
|
|
8
9
|
"cbor-x": "^1.5.6",
|
|
9
10
|
"cookie": "^0.5.0",
|
|
10
11
|
"mobx": "^6.6.2",
|
|
@@ -23,7 +24,6 @@
|
|
|
23
24
|
"devDependencies": {
|
|
24
25
|
"@types/cookie": "^0.5.1",
|
|
25
26
|
"@types/node-forge": "^1.3.1",
|
|
26
|
-
"@types/ws": "^8.5.3",
|
|
27
27
|
"debugbreak": "^0.6.5",
|
|
28
28
|
"pegjs": "^0.10.0",
|
|
29
29
|
"typedev": "^0.1.1"
|
package/test/allowclient.flag
DELETED
|
File without changes
|
package/test/client.css
DELETED
package/test/client.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/// <reference path="../require/RequireController.ts" />
|
|
2
|
-
|
|
3
|
-
// https://letx.ca:2542/?classGuid=RequireController-e2f811f3-14b8-4759-b0d6-73f14516cf1d&functionName=requireHTML&args=[%22./test/test%22]
|
|
4
|
-
|
|
5
|
-
//import typescript from "typescript";
|
|
6
|
-
|
|
7
|
-
import debugbreak from "debugbreak";
|
|
8
|
-
import { setFlag } from "../require/compileFlags";
|
|
9
|
-
import { SocketFunction } from "../SocketFunction";
|
|
10
|
-
import { Test } from "./shared";
|
|
11
|
-
|
|
12
|
-
import "../require/CSSShim";
|
|
13
|
-
import "./client.css";
|
|
14
|
-
import { isNode } from "../src/misc";
|
|
15
|
-
import { getCallObj } from "../src/nodeProxy";
|
|
16
|
-
|
|
17
|
-
module.allowclient = true;
|
|
18
|
-
|
|
19
|
-
//console.log(typeof typescript);
|
|
20
|
-
|
|
21
|
-
//setFlag(require, "typescript", "allowclient", true);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
void main();
|
|
25
|
-
|
|
26
|
-
async function main() {
|
|
27
|
-
if (isNode()) return;
|
|
28
|
-
|
|
29
|
-
SocketFunction.expose(Test);
|
|
30
|
-
|
|
31
|
-
console.log("cool");
|
|
32
|
-
|
|
33
|
-
const port = 2542;
|
|
34
|
-
|
|
35
|
-
let serverId = await SocketFunction.connect({ port, address: "localhost" });
|
|
36
|
-
let test = await Test.nodes[serverId].add(1, 2);
|
|
37
|
-
console.log(`${test}=${1 + 2}`);
|
|
38
|
-
|
|
39
|
-
// while (true) {
|
|
40
|
-
// let test = await TestClass.nodes[serverId].add(1, 2);
|
|
41
|
-
// console.log(`${test}=${1 + 2}`);
|
|
42
|
-
// await new Promise(resolve => setTimeout(resolve, 1000));
|
|
43
|
-
// }
|
|
44
|
-
|
|
45
|
-
await Test.nodes[serverId].callMe();
|
|
46
|
-
}
|
package/test/server.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
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
|
-
})
|
|
53
|
-
);
|