wao 0.19.6 → 0.19.7
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/cjs/hub/fs.js +5 -2
- package/cjs/hub/index.js +4 -1
- package/cjs/hub/ws-proxy.js +37 -33
- package/cjs/workspace/README.md +27 -0
- package/cjs/workspace/test/test.js +3 -3
- package/esm/hub/fs.js +4 -2
- package/esm/hub/index.js +3 -2
- package/esm/hub/ws-proxy.js +32 -32
- package/esm/workspace/README.md +27 -0
- package/esm/workspace/test/test.js +3 -3
- package/package.json +1 -1
package/cjs/hub/fs.js
CHANGED
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
var _chokidar = _interopRequireDefault(require("chokidar"));
|
|
4
4
|
var _utils = require("./utils.js");
|
|
5
5
|
var _ws = _interopRequireDefault(require("ws"));
|
|
6
|
+
var _yargs = _interopRequireDefault(require("yargs"));
|
|
6
7
|
var _ramda = require("ramda");
|
|
7
8
|
var _path = require("path");
|
|
8
9
|
var _fs = require("fs");
|
|
9
10
|
var _process$argv$;
|
|
10
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
|
+
var _yargs$argv$port = (0, _yargs["default"])(process.argv.slice(2)).argv.port,
|
|
13
|
+
port = _yargs$argv$port === void 0 ? 4006 : _yargs$argv$port;
|
|
11
14
|
var ws_server = new _ws["default"].Server({
|
|
12
|
-
port:
|
|
15
|
+
port: port
|
|
13
16
|
});
|
|
14
17
|
var _dir = (_process$argv$ = process.argv[2]) !== null && _process$argv$ !== void 0 ? _process$argv$ : "./";
|
|
15
18
|
var sus = {};
|
|
@@ -70,7 +73,7 @@ var sendContent = function sendContent(content, path) {
|
|
|
70
73
|
}));
|
|
71
74
|
}
|
|
72
75
|
};
|
|
73
|
-
console.log("WAO FS running on port
|
|
76
|
+
console.log("WAO FS running on port ".concat(port));
|
|
74
77
|
var wd = (0, _path.resolve)(cwd, _dir);
|
|
75
78
|
console.log("Directory:", wd);
|
|
76
79
|
_chokidar["default"].watch(wd, {
|
package/cjs/hub/index.js
CHANGED
|
@@ -7,10 +7,13 @@ var _ramda = require("ramda");
|
|
|
7
7
|
var _utils = require("./utils.js");
|
|
8
8
|
var _bundler = _interopRequireDefault(require("./bundler.js"));
|
|
9
9
|
var _cu = _interopRequireDefault(require("./cu.js"));
|
|
10
|
+
var _yargs = _interopRequireDefault(require("yargs"));
|
|
10
11
|
var _ws = _interopRequireDefault(require("ws"));
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
|
+
var _yargs$argv$port = (0, _yargs["default"])(process.argv.slice(2)).argv.port,
|
|
14
|
+
port = _yargs$argv$port === void 0 ? 8080 : _yargs$argv$port;
|
|
12
15
|
var ws_server = new _ws["default"].Server({
|
|
13
|
-
port:
|
|
16
|
+
port: port
|
|
14
17
|
});
|
|
15
18
|
var sus = {};
|
|
16
19
|
var cbs = {};
|
package/cjs/hub/ws-proxy.js
CHANGED
|
@@ -18,42 +18,14 @@ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r),
|
|
|
18
18
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
19
19
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
20
20
|
var _yargs$argv$port = (0, _yargs["default"])(process.argv.slice(2)).argv.port,
|
|
21
|
-
port = _yargs$argv$port === void 0 ?
|
|
21
|
+
port = _yargs$argv$port === void 0 ? 4000 : _yargs$argv$port;
|
|
22
|
+
var proxy_port = port + 5;
|
|
22
23
|
var ws_server = new _ws["default"].Server({
|
|
23
|
-
port:
|
|
24
|
+
port: proxy_port
|
|
24
25
|
});
|
|
25
26
|
var sus = {};
|
|
26
27
|
var cbs = {};
|
|
27
|
-
|
|
28
|
-
ws_server.on("connection", function (socket) {
|
|
29
|
-
_socket = socket;
|
|
30
|
-
var clientId = (0, _utils.generateId)();
|
|
31
|
-
console.log("new ws:", clientId);
|
|
32
|
-
sus[clientId] = {
|
|
33
|
-
socket: socket,
|
|
34
|
-
su: false,
|
|
35
|
-
connections: {},
|
|
36
|
-
address: null
|
|
37
|
-
};
|
|
38
|
-
socket.send(JSON.stringify({
|
|
39
|
-
type: "registered",
|
|
40
|
-
id: clientId
|
|
41
|
-
}));
|
|
42
|
-
socket.on("message", function (message) {
|
|
43
|
-
var data = JSON.parse(message);
|
|
44
|
-
if (data.type === "msg") {
|
|
45
|
-
if (cbs[data.id]) {
|
|
46
|
-
cbs[data.id](data.res);
|
|
47
|
-
delete cbs[data.id];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
socket.on("close", function () {
|
|
52
|
-
console.log("ws disconnected", clientId);
|
|
53
|
-
delete sus[clientId];
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
console.log("WAO FS running on port 7070");
|
|
28
|
+
console.log("Starting WAO Proxy servers...");
|
|
57
29
|
var Adaptor = /*#__PURE__*/function () {
|
|
58
30
|
function Adaptor() {
|
|
59
31
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
@@ -135,4 +107,36 @@ var main = /*#__PURE__*/function () {
|
|
|
135
107
|
return _ref2.apply(this, arguments);
|
|
136
108
|
};
|
|
137
109
|
}();
|
|
138
|
-
main();
|
|
110
|
+
main();
|
|
111
|
+
var _socket = null;
|
|
112
|
+
ws_server.on("connection", function (socket) {
|
|
113
|
+
_socket = socket;
|
|
114
|
+
var clientId = (0, _utils.generateId)();
|
|
115
|
+
console.log("new ws:", clientId);
|
|
116
|
+
sus[clientId] = {
|
|
117
|
+
socket: socket,
|
|
118
|
+
su: false,
|
|
119
|
+
connections: {},
|
|
120
|
+
address: null
|
|
121
|
+
};
|
|
122
|
+
socket.send(JSON.stringify({
|
|
123
|
+
type: "registered",
|
|
124
|
+
id: clientId
|
|
125
|
+
}));
|
|
126
|
+
socket.on("message", function (message) {
|
|
127
|
+
var data = JSON.parse(message);
|
|
128
|
+
if (data.type === "msg") {
|
|
129
|
+
if (cbs[data.id]) {
|
|
130
|
+
cbs[data.id](data.res);
|
|
131
|
+
delete cbs[data.id];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
socket.on("close", function () {
|
|
136
|
+
console.log("ws disconnected", clientId);
|
|
137
|
+
delete sus[clientId];
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
setTimeout(function () {
|
|
141
|
+
return console.log("WS on port ".concat(proxy_port));
|
|
142
|
+
}, 10);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#### 1. Create an APP
|
|
2
|
+
|
|
3
|
+
```bash
|
|
4
|
+
npx wao create waoapp && cd waoapp
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
#### 2. Run WAO Proxy
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx wao proxy
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
#### 3. Connect the Browser to the Proxy
|
|
14
|
+
|
|
15
|
+
Go to [the web app](https://wao-localnet.vercel.app/) and open `Networks`, then click `Proxy`.
|
|
16
|
+
|
|
17
|
+
#### 4. Run Test
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
yarn test test/test.js
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
#### 5. Deploy a Process to AO Testnet
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
yarn deploy src/counter.lua --wallet PATH_TO_WALLET_JSON
|
|
27
|
+
```
|
|
@@ -23,11 +23,11 @@ describe("WAO", function () {
|
|
|
23
23
|
|
|
24
24
|
// WAO Proxy must be running on your computer => "npx wao proxy"
|
|
25
25
|
it("should spawn a process and send messages to the browser", async () => {
|
|
26
|
-
// connect with
|
|
27
|
-
const ao = await new WAO(
|
|
26
|
+
// connect with 4000 - 4004 ports
|
|
27
|
+
const ao = await new WAO(4000).init(acc[0])
|
|
28
28
|
|
|
29
29
|
// post Scheduler-Location (acc[0])
|
|
30
|
-
const { res, id } = await ao.postScheduler({ url: "http://localhost:
|
|
30
|
+
const { res, id } = await ao.postScheduler({ url: "http://localhost:4003" })
|
|
31
31
|
|
|
32
32
|
const { p, pid } = await ao.deploy({
|
|
33
33
|
src_data,
|
package/esm/hub/fs.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import chokidar from "chokidar"
|
|
2
2
|
import { generateId } from "./utils.js"
|
|
3
3
|
import WebSocket from "ws"
|
|
4
|
-
|
|
4
|
+
import yargs from "yargs"
|
|
5
|
+
let { port = 4006 } = yargs(process.argv.slice(2)).argv
|
|
6
|
+
const ws_server = new WebSocket.Server({ port })
|
|
5
7
|
import { keys, omit, isNil, mergeLeft } from "ramda"
|
|
6
8
|
import { resolve } from "path"
|
|
7
9
|
import { writeFileSync, readFileSync } from "fs"
|
|
@@ -70,7 +72,7 @@ const sendContent = (content, path) => {
|
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
console.log(
|
|
75
|
+
console.log(`WAO FS running on port ${port}`)
|
|
74
76
|
const wd = resolve(cwd, _dir)
|
|
75
77
|
console.log("Directory:", wd)
|
|
76
78
|
chokidar
|
package/esm/hub/index.js
CHANGED
|
@@ -5,9 +5,10 @@ import { keys, omit, isNil, mergeLeft } from "ramda"
|
|
|
5
5
|
import { generateId, toANS104Request, parseSignatureInput } from "./utils.js"
|
|
6
6
|
import bundler from "./bundler.js"
|
|
7
7
|
import cu from "./cu.js"
|
|
8
|
-
|
|
8
|
+
import yargs from "yargs"
|
|
9
|
+
let { port = 8080 } = yargs(process.argv.slice(2)).argv
|
|
9
10
|
import WebSocket from "ws"
|
|
10
|
-
const ws_server = new WebSocket.Server({ port
|
|
11
|
+
const ws_server = new WebSocket.Server({ port })
|
|
11
12
|
|
|
12
13
|
let sus = {}
|
|
13
14
|
let cbs = {}
|
package/esm/hub/ws-proxy.js
CHANGED
|
@@ -1,44 +1,16 @@
|
|
|
1
1
|
import yargs from "yargs"
|
|
2
|
-
let { port =
|
|
2
|
+
let { port = 4000 } = yargs(process.argv.slice(2)).argv
|
|
3
3
|
import { Server } from "../test.js"
|
|
4
4
|
import { generateId } from "./utils.js"
|
|
5
5
|
import WebSocket from "ws"
|
|
6
|
-
const
|
|
6
|
+
const proxy_port = port + 5
|
|
7
|
+
const ws_server = new WebSocket.Server({ port: proxy_port })
|
|
7
8
|
import { keys, omit, isNil, mergeLeft } from "ramda"
|
|
8
9
|
import { resolve } from "path"
|
|
9
10
|
import { writeFileSync, readFileSync } from "fs"
|
|
10
11
|
let sus = {}
|
|
11
12
|
let cbs = {}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
ws_server.on("connection", socket => {
|
|
15
|
-
_socket = socket
|
|
16
|
-
const clientId = generateId()
|
|
17
|
-
console.log("new ws:", clientId)
|
|
18
|
-
sus[clientId] = {
|
|
19
|
-
socket,
|
|
20
|
-
su: false,
|
|
21
|
-
connections: {},
|
|
22
|
-
address: null,
|
|
23
|
-
}
|
|
24
|
-
socket.send(JSON.stringify({ type: "registered", id: clientId }))
|
|
25
|
-
socket.on("message", message => {
|
|
26
|
-
const data = JSON.parse(message)
|
|
27
|
-
if (data.type === "msg") {
|
|
28
|
-
if (cbs[data.id]) {
|
|
29
|
-
cbs[data.id](data.res)
|
|
30
|
-
delete cbs[data.id]
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
socket.on("close", () => {
|
|
36
|
-
console.log("ws disconnected", clientId)
|
|
37
|
-
delete sus[clientId]
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
console.log("WAO FS running on port 7070")
|
|
13
|
+
console.log(`Starting WAO Proxy servers...`)
|
|
42
14
|
class Adaptor {
|
|
43
15
|
constructor({ hb_url, aoconnect, log = false, db } = {}) {}
|
|
44
16
|
async get(req, res) {
|
|
@@ -65,3 +37,31 @@ class Adaptor {
|
|
|
65
37
|
const main = async () => new Server({ log: true, port, adaptor: new Adaptor() })
|
|
66
38
|
|
|
67
39
|
main()
|
|
40
|
+
|
|
41
|
+
let _socket = null
|
|
42
|
+
ws_server.on("connection", socket => {
|
|
43
|
+
_socket = socket
|
|
44
|
+
const clientId = generateId()
|
|
45
|
+
console.log("new ws:", clientId)
|
|
46
|
+
sus[clientId] = {
|
|
47
|
+
socket,
|
|
48
|
+
su: false,
|
|
49
|
+
connections: {},
|
|
50
|
+
address: null,
|
|
51
|
+
}
|
|
52
|
+
socket.send(JSON.stringify({ type: "registered", id: clientId }))
|
|
53
|
+
socket.on("message", message => {
|
|
54
|
+
const data = JSON.parse(message)
|
|
55
|
+
if (data.type === "msg") {
|
|
56
|
+
if (cbs[data.id]) {
|
|
57
|
+
cbs[data.id](data.res)
|
|
58
|
+
delete cbs[data.id]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
socket.on("close", () => {
|
|
63
|
+
console.log("ws disconnected", clientId)
|
|
64
|
+
delete sus[clientId]
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
setTimeout(() => console.log(`WS on port ${proxy_port}`), 10)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#### 1. Create an APP
|
|
2
|
+
|
|
3
|
+
```bash
|
|
4
|
+
npx wao create waoapp && cd waoapp
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
#### 2. Run WAO Proxy
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx wao proxy
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
#### 3. Connect the Browser to the Proxy
|
|
14
|
+
|
|
15
|
+
Go to [the web app](https://wao-localnet.vercel.app/) and open `Networks`, then click `Proxy`.
|
|
16
|
+
|
|
17
|
+
#### 4. Run Test
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
yarn test test/test.js
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
#### 5. Deploy a Process to AO Testnet
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
yarn deploy src/counter.lua --wallet PATH_TO_WALLET_JSON
|
|
27
|
+
```
|
|
@@ -23,11 +23,11 @@ describe("WAO", function () {
|
|
|
23
23
|
|
|
24
24
|
// WAO Proxy must be running on your computer => "npx wao proxy"
|
|
25
25
|
it("should spawn a process and send messages to the browser", async () => {
|
|
26
|
-
// connect with
|
|
27
|
-
const ao = await new WAO(
|
|
26
|
+
// connect with 4000 - 4004 ports
|
|
27
|
+
const ao = await new WAO(4000).init(acc[0])
|
|
28
28
|
|
|
29
29
|
// post Scheduler-Location (acc[0])
|
|
30
|
-
const { res, id } = await ao.postScheduler({ url: "http://localhost:
|
|
30
|
+
const { res, id } = await ao.postScheduler({ url: "http://localhost:4003" })
|
|
31
31
|
|
|
32
32
|
const { p, pid } = await ao.deploy({
|
|
33
33
|
src_data,
|