godprotocol 1.0.81 → 1.0.83
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/.babelrc +3 -0
- package/Index.js +8 -19
- package/Loader_sequence/main.js +368 -234
- package/Objects/Account.js +229 -176
- package/Objects/Block.js +64 -61
- package/Objects/Blockweb.js +27 -34
- package/Objects/Chain.js +122 -118
- package/Objects/Explorer.js +30 -37
- package/Objects/Filesystem.js +96 -81
- package/Objects/Frame.js +43 -48
- package/Objects/Manager.js +60 -69
- package/Objects/Opcodes.js +39 -101
- package/Objects/Oracle.js +71 -69
- package/Objects/Virtual_machine.js +135 -132
- package/[object Object]/.GDS/godprotocol/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/0100dcacc00a6dc0263290e414f3d199b50f82b4dcbf9232b8a0bad9365d6878/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/03a089ffda6ca7be6e9327749c7417b3f759f4447de4dc1d8508c72571c8a46c/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/0ee263de3fb9e3e08e7d5abe21db8c0fe66188829979996dcddd3533d855a817/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/0ee263de3fb9e3e08e7d5abe21db8c0fe66188829979996dcddd3533d855a817/0ee263de3fb9e3e08e7d5abe21db8c0fe66188829979996dcddd3533d855a817~9wMLAwapUgr25rjl~1721561106826 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/0ee263de3fb9e3e08e7d5abe21db8c0fe66188829979996dcddd3533d855a817/0ee263de3fb9e3e08e7d5abe21db8c0fe66188829979996dcddd3533d855a817~xipvdPqJsd5PneYbcFNbJ0vQxthmu~1721561134383 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/0f4659b04f82c52bf8bf75ae0b4dc407574652ad35c84aa62ff4a52a868c7096/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/14fbd9082d61d0554e4917cb8e1b47966358762689a2bf021fc5e1dc38c7b239/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/221dbfff32f92e889762b6eb632423cbf51439fc16552940ee7ea7a2f92db662/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/2569577431a0c797f7526c5f2c59251343a1131adfd03f53363725951b7fd0d4/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/2743cfe8f897cdd0b22cb93cfd18fc58269705169bf0a01117edd1894cdce537/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/30dc10d3485923c0c19083559094fe636f9491bff9c997306ffdbf3e1618a402/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/30dc10d3485923c0c19083559094fe636f9491bff9c997306ffdbf3e1618a402/30dc10d3485923c0c19083559094fe636f9491bff9c997306ffdbf3e1618a402~5BrzgFCkRU4H7Cmlht1UyjorCm~1721561134375 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/30dc10d3485923c0c19083559094fe636f9491bff9c997306ffdbf3e1618a402/30dc10d3485923c0c19083559094fe636f9491bff9c997306ffdbf3e1618a402~VMHaNZbDCtpoSB~1721561106813 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/3ef66e0b0e059670edfa53a5c505196a5bc451d3c9e3a1b71f58519ca3c86146/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/3ff3661353ccadcaf9c6759a539d8d31e19c07ed0dd888170b9e55c7a18721da/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/3ff3661353ccadcaf9c6759a539d8d31e19c07ed0dd888170b9e55c7a18721da/3ff3661353ccadcaf9c6759a539d8d31e19c07ed0dd888170b9e55c7a18721da~GJVjeKlgSCUdKGWUJ~1721561134114 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/3ff3661353ccadcaf9c6759a539d8d31e19c07ed0dd888170b9e55c7a18721da/3ff3661353ccadcaf9c6759a539d8d31e19c07ed0dd888170b9e55c7a18721da~OsMwcPCk8F5SaSUdCGmM6~1721561106561 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/40149a5ceadd07e7cadcbad839efd7e1ac2a14b3d4a17dfa70aeff14778ed820/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/4503206d1cc4cdcef228061891a7a54a6a9838dce526bc4d755b0762d0da896b/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/4dc569813ce0a2f446a3eec01358f5774f8564641ef8d579ff5b6d94b4d031a7/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/4dc569813ce0a2f446a3eec01358f5774f8564641ef8d579ff5b6d94b4d031a7/4dc569813ce0a2f446a3eec01358f5774f8564641ef8d579ff5b6d94b4d031a7~8dBekgqAvRnIyZomf~1721561134269 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/4dc569813ce0a2f446a3eec01358f5774f8564641ef8d579ff5b6d94b4d031a7/4dc569813ce0a2f446a3eec01358f5774f8564641ef8d579ff5b6d94b4d031a7~Zc7Fa5AIsUySTCcWEiXmmYg3~1721561106712 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/54b16422271d6924c17c2abf55806035f5f36d4f4edb7f68bdd326bdb0abe500/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/57551ba66193cbc4696ca16cc27e9ccb73b79ddfae6b10fdf382747099033f3f/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/57d351527a4e63d51d13771038ac9ad59810f01960cc74b0f18158de872a20cc/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/5f87c4e573fa678825d72d8009f9aacce94d94bade4a26123db3c9e3a7488dc8/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/60fe28ac093915ec5e5cd08cb71650e3dab0e4c3644c32dd1ab13672f828f073/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/61bdf0593cd727752cb917ab968a08853d45142b8a8e4cdcd0fe03d1616f3586/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/61f3b3350c0c092e4c864b1a8c94f8b9272a132b100f8a5eb3a2e54dd20983be/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/646f04e302b372dc14871693fd87b6f80575c48f0045276f1a2b3ff999ae45fb/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/695853d02abbfe2f2a380598a871741caafa602d096a45adbe863e8f7e72f255/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/75944e73a11a149023ecf3430316a2b301a0b72c00cbd0b129f62b0f96e02f32/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/787456fe235bf126b6299374ecedb92c54e280238e67a2bed7446ff581cb6a6f/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/81e5bdff5d308919377d7d85da689f6888cbdc61b3ca73e18648fd7c365d4684/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/83e0dcafe93e39fa0973ee663d38477b5302704f4aca728b8701a919675340db/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/88f7c75e6701c06b4ffa070f7b4bab01c1aee299140234cf06fd83bf1a6af372/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/a965464a6d9f981543ce3aede226bd0fb989d9300cd8468f41cd1fc0139c8f44/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/a965464a6d9f981543ce3aede226bd0fb989d9300cd8468f41cd1fc0139c8f44/a965464a6d9f981543ce3aede226bd0fb989d9300cd8468f41cd1fc0139c8f44~2pZyTBlnZEjqeqLRX49qa~1721561134187 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/a965464a6d9f981543ce3aede226bd0fb989d9300cd8468f41cd1fc0139c8f44/a965464a6d9f981543ce3aede226bd0fb989d9300cd8468f41cd1fc0139c8f44~GacmVaFxSmu5yLRhGW4kvf~1721561106631 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/b15dcc79636744d7df8a3e28bfb9551bbb2f766d3e93885964ee4cda0070ec5d/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/b6d738d96a23a2b0638541041328e58895358c5ef9c21e2f8304939bff3e27f2/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/b6d738d96a23a2b0638541041328e58895358c5ef9c21e2f8304939bff3e27f2/b6d738d96a23a2b0638541041328e58895358c5ef9c21e2f8304939bff3e27f2~rB45nHr3uT34~1721561106844 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/b6d738d96a23a2b0638541041328e58895358c5ef9c21e2f8304939bff3e27f2/b6d738d96a23a2b0638541041328e58895358c5ef9c21e2f8304939bff3e27f2~tmfqGhOsoJv91mdvgo5~1721561134385 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/blocks/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/c9c105370802042618805ccac28f7d9aaaf49db9873e14eb7a4e74a73f3cce89/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/cac2db27e0f3f0e4c80a3c28aea1fee8b935d0a41f2384f4a90acb57a888ac22/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/cbf8ec551d71fc89a73768c65a6c0d630cd3d85fe88dcab7d6b45ea6bd6a9e33/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/d479db3b8a1efa0e6ac5106c1aba0b6b806744df0f6a4730c0b9f6a01cac8a33/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/de551b5a493859e532316cbbf1e4a14eb06e0512556b1c1295ad60ffe07c185b/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/f0ffe7cc032479994c0732c6a65b7887c09afafb1b0aa20062ccad2810d25101/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/f13022c98357d9d9da982270f21ce304af3d89fecbf9364ab0a00a87e39bde57/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/f3184b1d23adf18ef18e5d3f6e6978a77364642eef9edba0240b77d626334235/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/f8a165e3f556ca2ea189f4d4401d139b22a6f19d0b38329fe4a5f14599840634/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/f968ed8cf7958218d4604b3de0bf074f09bac7925e86f7d1f495f8b2c67f31a7/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/f968ed8cf7958218d4604b3de0bf074f09bac7925e86f7d1f495f8b2c67f31a7/f968ed8cf7958218d4604b3de0bf074f09bac7925e86f7d1f495f8b2c67f31a7~3EOv6CEb1xPUw8~1721561134016 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/f968ed8cf7958218d4604b3de0bf074f09bac7925e86f7d1f495f8b2c67f31a7/f968ed8cf7958218d4604b3de0bf074f09bac7925e86f7d1f495f8b2c67f31a7~DEp3QlIt6A44WxAccRmf~1721561106464 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/fcc2a595781c53a76c4cd54382d3758d15120d3c4fcfae30f86067f8e6a830a2/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/fce39acf93dd6bdd9bc2e28288fd5b1c3c3c23313fe8527ec1d4d32a0081c94f/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/fda5b539dcb04ba96e6e929d05d8df7b42316351de91f2d33b66edb97ede4dc5/.config +1 -0
- package/build/Account.js +187 -0
- package/build/Block.js +68 -0
- package/build/Blockweb.js +36 -0
- package/build/Chain.js +119 -0
- package/build/Explorer.js +47 -0
- package/build/Filesystem.js +127 -0
- package/build/Frame.js +52 -0
- package/build/Index.js +20 -0
- package/build/Manager.js +86 -0
- package/build/Opcodes.js +109 -0
- package/build/Oracle.js +81 -0
- package/build/Virtual_machine.js +136 -0
- package/build/add.js +26 -0
- package/build/create_server.js +132 -0
- package/build/framer.js +59 -0
- package/build/functions.js +82 -0
- package/build/hash.js +14 -0
- package/build/indices.js +31 -0
- package/build/jmp.js +19 -0
- package/build/main.js +327 -0
- package/build/opcodes.js +60 -0
- package/build/privacy.js +27 -0
- package/build/services.js +50 -0
- package/build/std.js +15 -0
- package/framer.js +36 -34
- package/opcodes/add.js +9 -25
- package/opcodes/indices.js +13 -16
- package/opcodes/jmp.js +7 -12
- package/opcodes/std.js +7 -13
- package/opcodes.js +34 -42
- package/package.json +1 -1
- package/readme.md +4 -4
- package/utils/create_server.js +72 -105
- package/utils/functions.js +31 -43
- package/utils/hash.js +10 -11
- package/utils/privacy.js +10 -15
- package/utils/services.js +32 -33
package/build/std.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.stdout = void 0;
|
|
7
|
+
var stdout = function stdout(args, vm) {
|
|
8
|
+
if (!args) return;
|
|
9
|
+
vm.account.stdout.push({
|
|
10
|
+
data: args,
|
|
11
|
+
pid: vm.track.pid
|
|
12
|
+
});
|
|
13
|
+
for (var v in args) console.log(args[v]);
|
|
14
|
+
};
|
|
15
|
+
exports.stdout = stdout;
|
package/framer.js
CHANGED
|
@@ -1,59 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.obj = exports["default"] = void 0;
|
|
7
|
-
var _Frame = _interopRequireDefault(require("./Objects/Frame"));
|
|
8
|
-
var _Opcodes;
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
12
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
13
|
-
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); }
|
|
14
|
-
var obj = {
|
|
15
|
-
Opcodes: (_Opcodes = {
|
|
1
|
+
import Frame from "./Objects/Frame";
|
|
2
|
+
|
|
3
|
+
let obj = {
|
|
4
|
+
Opcodes: {
|
|
16
5
|
add: null,
|
|
17
6
|
equal: null,
|
|
18
7
|
multiply: null,
|
|
19
8
|
subtract: null,
|
|
20
9
|
divide: null,
|
|
21
|
-
exp: null
|
|
22
|
-
|
|
10
|
+
exp: null,
|
|
11
|
+
equal: null,
|
|
12
|
+
|
|
13
|
+
send: null,
|
|
14
|
+
readonly: null,
|
|
15
|
+
socket_send: null,
|
|
16
|
+
|
|
17
|
+
jmp: null,
|
|
18
|
+
|
|
19
|
+
stdout: null,
|
|
20
|
+
stdin: null,
|
|
21
|
+
|
|
22
|
+
run: null,
|
|
23
|
+
load: null,
|
|
24
|
+
parse: null,
|
|
25
|
+
create_account: null,
|
|
26
|
+
},
|
|
23
27
|
Datatypes: {
|
|
24
28
|
Number: null,
|
|
25
29
|
String: null,
|
|
26
30
|
Twain: null,
|
|
27
|
-
Array: null
|
|
31
|
+
Array: null,
|
|
28
32
|
},
|
|
29
33
|
Objects: {
|
|
30
34
|
Blockchain: {
|
|
31
35
|
Chain: null,
|
|
32
|
-
Block: null
|
|
36
|
+
Block: null,
|
|
33
37
|
},
|
|
34
38
|
Folder: {
|
|
35
39
|
active_file: null,
|
|
36
40
|
folder: null,
|
|
37
|
-
file: null
|
|
41
|
+
file: null,
|
|
38
42
|
},
|
|
39
43
|
File: {
|
|
40
44
|
row: null,
|
|
41
45
|
parse: null,
|
|
42
46
|
column: null,
|
|
43
|
-
write: null
|
|
44
|
-
}
|
|
45
|
-
}
|
|
47
|
+
write: null,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
46
50
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
|
|
52
|
+
const framer = (initiator) => {
|
|
53
|
+
let frame = new Frame(obj);
|
|
50
54
|
frame.to_instruction();
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
instructions: instructions
|
|
55
|
-
}
|
|
56
|
-
});
|
|
55
|
+
let instructions = frame.flatten_instructions();
|
|
56
|
+
|
|
57
|
+
initiator.load({ program: { instructions } });
|
|
57
58
|
};
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
|
|
60
|
+
export default framer;
|
|
61
|
+
export { obj };
|
package/opcodes/add.js
CHANGED
|
@@ -1,26 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
let ops = [
|
|
2
|
+
{ name: "add", sign: "+" },
|
|
3
|
+
{ name: "multiply", sign: "*" },
|
|
4
|
+
{ name: "subtract", sign: "-" },
|
|
5
|
+
{ name: "divide", sign: "/" },
|
|
6
|
+
{ name: "exp", sign: "**" },
|
|
7
|
+
{ name: "equal", sign: "==" },
|
|
8
|
+
];
|
|
2
9
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ops = void 0;
|
|
7
|
-
var ops = [{
|
|
8
|
-
name: "add",
|
|
9
|
-
sign: "+"
|
|
10
|
-
}, {
|
|
11
|
-
name: "multiply",
|
|
12
|
-
sign: "*"
|
|
13
|
-
}, {
|
|
14
|
-
name: "subtract",
|
|
15
|
-
sign: "-"
|
|
16
|
-
}, {
|
|
17
|
-
name: "divide",
|
|
18
|
-
sign: "/"
|
|
19
|
-
}, {
|
|
20
|
-
name: "exp",
|
|
21
|
-
sign: "**"
|
|
22
|
-
}, {
|
|
23
|
-
name: "equal",
|
|
24
|
-
sign: "=="
|
|
25
|
-
}];
|
|
26
|
-
exports.ops = ops;
|
|
10
|
+
export { ops };
|
package/opcodes/indices.js
CHANGED
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true,
|
|
5
|
-
});
|
|
6
|
-
exports.setter = exports.getter = void 0;
|
|
7
|
-
var getter = function getter(args) {
|
|
8
|
-
var base = args.op0;
|
|
1
|
+
const getter = (args) => {
|
|
2
|
+
let base = args.op0;
|
|
9
3
|
if (typeof base === "number") return base;
|
|
4
|
+
|
|
10
5
|
if (typeof base === "string") return base[args.op1];
|
|
6
|
+
|
|
11
7
|
if (Array.isArray(base)) return base.slice(args.op1)[0];
|
|
8
|
+
|
|
12
9
|
return base[args.op1];
|
|
13
10
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
|
|
12
|
+
const setter = (args) => {
|
|
13
|
+
let base = args.op0;
|
|
17
14
|
if (typeof base === "number") return base;
|
|
15
|
+
|
|
18
16
|
if (typeof base === "string") {
|
|
19
|
-
base =
|
|
20
|
-
.concat(base.slice(0, args.op2))
|
|
21
|
-
.concat(args.op1)
|
|
22
|
-
.concat(base.slice(args.op2 + 1));
|
|
17
|
+
base = `${base.slice(0, args.op2)}${args.op1}${base.slice(args.op2 + 1)}`;
|
|
23
18
|
} else {
|
|
24
19
|
if (Array.isArray(base)) {
|
|
25
20
|
if (args.op2 == null || args.op2 >= base.length) base.push(args.op1);
|
|
26
21
|
else base[args.op2] = args.op1;
|
|
27
22
|
} else base[args.op2] = args.op1;
|
|
28
23
|
}
|
|
24
|
+
|
|
29
25
|
return base;
|
|
30
26
|
};
|
|
31
|
-
|
|
27
|
+
|
|
28
|
+
export { setter, getter };
|
package/opcodes/jmp.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.jmp = void 0;
|
|
7
|
-
var jmp = function jmp(args, vm, meta) {
|
|
1
|
+
const jmp = (args, vm, meta) => {
|
|
8
2
|
meta = meta || {};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var condition;
|
|
3
|
+
let { flag, inverse } = meta;
|
|
4
|
+
|
|
5
|
+
let condition;
|
|
13
6
|
if (flag) condition = vm.flags[flag];
|
|
14
7
|
if (inverse) condition = !!!condition;
|
|
8
|
+
|
|
15
9
|
if ((condition || !flag) && typeof args.op0 === "number") {
|
|
16
10
|
vm.track.pointer = args.op0;
|
|
17
11
|
}
|
|
18
12
|
};
|
|
19
|
-
|
|
13
|
+
|
|
14
|
+
export { jmp };
|
package/opcodes/std.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.stdout = void 0;
|
|
7
|
-
var stdout = function stdout(args, vm) {
|
|
1
|
+
const stdout = (args, vm) => {
|
|
8
2
|
if (!args) return;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
for (var v in args) console.log(args[v]);
|
|
3
|
+
|
|
4
|
+
vm.account.stdout.push({ data: args, pid: vm.track.pid });
|
|
5
|
+
|
|
6
|
+
for (let v in args) console.log(args[v]);
|
|
14
7
|
};
|
|
15
|
-
|
|
8
|
+
|
|
9
|
+
export { stdout };
|
package/opcodes.js
CHANGED
|
@@ -1,60 +1,52 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _add = require("./opcodes/add");
|
|
8
|
-
var _indices = require("./opcodes/indices");
|
|
9
|
-
var _jmp = require("./opcodes/jmp");
|
|
10
|
-
var _std = require("./opcodes/std");
|
|
11
|
-
var _services = require("./utils/services");
|
|
12
1
|
// import { socket_send } from "./Socket";
|
|
2
|
+
import { ops } from "./opcodes/add";
|
|
3
|
+
import { getter, setter } from "./opcodes/indices";
|
|
4
|
+
import { jmp } from "./opcodes/jmp";
|
|
5
|
+
import { stdout } from "./opcodes/std";
|
|
6
|
+
import { post_request } from "./utils/services";
|
|
13
7
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
const opcodes = (account) => {
|
|
9
|
+
let set = account.vm.set;
|
|
10
|
+
|
|
11
|
+
ops.map((op) => {
|
|
12
|
+
set(op.name, (args) => {
|
|
18
13
|
if (!args) return;
|
|
14
|
+
|
|
19
15
|
try {
|
|
20
|
-
|
|
16
|
+
let result = eval(`${args.op0} ${op.sign} ${args.op1}`);
|
|
21
17
|
if (op.sign === "==") {
|
|
22
18
|
account.vm.flags.equal = !!result;
|
|
23
19
|
return;
|
|
24
20
|
}
|
|
21
|
+
|
|
25
22
|
return result;
|
|
26
23
|
} catch (e) {
|
|
27
24
|
console.log(e.message);
|
|
28
25
|
}
|
|
29
26
|
});
|
|
30
27
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
set("jmp_not_".concat(flag), function (args, vm) {
|
|
38
|
-
return (0, _jmp.jmp)(args, vm, {
|
|
39
|
-
flag: flag,
|
|
40
|
-
inverse: true
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
set("jmp", _jmp.jmp);
|
|
45
|
-
set("setter", _indices.setter);
|
|
46
|
-
set("getter", _indices.getter);
|
|
47
|
-
set("send", function (data) {
|
|
48
|
-
return (0, _services.post_request)(data, account.vm.stdin);
|
|
28
|
+
|
|
29
|
+
Object.keys(account.vm.flags).map((flag) => {
|
|
30
|
+
set(`jmp_${flag}`, (args, vm) => jmp(args, vm, { flag }));
|
|
31
|
+
set(`jmp_not_${flag}`, (args, vm) =>
|
|
32
|
+
jmp(args, vm, { flag, inverse: true })
|
|
33
|
+
);
|
|
49
34
|
});
|
|
35
|
+
set("jmp", jmp);
|
|
36
|
+
|
|
37
|
+
set("setter", setter);
|
|
38
|
+
set("getter", getter);
|
|
39
|
+
|
|
40
|
+
set("send", (data) => post_request(data, account.vm.stdin));
|
|
50
41
|
// set("socket_send", socket_send);
|
|
51
42
|
|
|
52
|
-
set("stdout",
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
43
|
+
set("stdout", stdout);
|
|
44
|
+
|
|
45
|
+
set("add_server", (args, vm) => account.add_server(args && args.op0))[
|
|
46
|
+
("run", "load", "parse", "create_account")
|
|
47
|
+
].map((op) =>
|
|
48
|
+
set(op, (arg) => arg && arg.op0 && account[op](arg && arg.op0))
|
|
49
|
+
);
|
|
58
50
|
};
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
|
|
52
|
+
export default opcodes;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -20,10 +20,10 @@ You can get overall comprehension in just 4 method calls.
|
|
|
20
20
|
Accounts comes with their own VM, thereby providing concurrency on processes being executed.
|
|
21
21
|
|
|
22
22
|
```js
|
|
23
|
-
import
|
|
23
|
+
import start from "godprotocol";
|
|
24
24
|
|
|
25
25
|
// Create an initial account
|
|
26
|
-
let initiator =
|
|
26
|
+
let initiator = start(`name`, { private: true || false });
|
|
27
27
|
// if private is set to `true`, communication to the account instance must be validated by sigining with the private key.
|
|
28
28
|
// N.B your keypairs are generated offline.
|
|
29
29
|
```
|
|
@@ -70,7 +70,7 @@ The run is technically the second in the pipeline.
|
|
|
70
70
|
initiator.run(
|
|
71
71
|
{
|
|
72
72
|
physical_address: "Account/initiator/Datatypes/Number", // This points to a chain
|
|
73
|
-
query:
|
|
73
|
+
query: { blocks: 0 }, // Basically saying, index 0 block in physical_address chain, run again its instructions.
|
|
74
74
|
account: `public_key`,
|
|
75
75
|
},
|
|
76
76
|
cb
|
|
@@ -99,7 +99,7 @@ It is used to retrieve blocks and chains, and also extract their properties.
|
|
|
99
99
|
initiator.parse(
|
|
100
100
|
{
|
|
101
101
|
physical_address: "Account/initiator/Datatypes/Number", // This points to a chain
|
|
102
|
-
query:
|
|
102
|
+
query: { blocks: 0 }, // Basically saying, index 0 block in physical_address chain, retrieve it.
|
|
103
103
|
account: `public_key`,
|
|
104
104
|
},
|
|
105
105
|
cb
|
package/utils/create_server.js
CHANGED
|
@@ -1,132 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _functions = require("./functions");
|
|
9
|
-
var _Index = require("../Index");
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
12
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
13
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
14
|
-
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
15
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
18
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
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
|
-
var PORT = Number(process.env.PORT) || 1408;
|
|
21
|
-
exports.PORT = PORT;
|
|
22
|
-
var cb = function cb(res, data) {
|
|
1
|
+
import http from "http";
|
|
2
|
+
import { is_port_available } from "./functions";
|
|
3
|
+
import { initiator } from "../Index";
|
|
4
|
+
|
|
5
|
+
let PORT = Number(process.env.PORT) || 1408;
|
|
6
|
+
|
|
7
|
+
const cb = (res, data) => {
|
|
23
8
|
if (typeof data !== "string") data = JSON.stringify(data);
|
|
9
|
+
|
|
24
10
|
res(data);
|
|
25
11
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
|
|
13
|
+
let extensions = new Object();
|
|
14
|
+
|
|
15
|
+
const extension = (route, handler) => {
|
|
16
|
+
let handlers = extensions[route];
|
|
29
17
|
if (!handlers) {
|
|
30
18
|
handlers = new Array();
|
|
31
19
|
extensions[route] = handlers;
|
|
32
20
|
}
|
|
21
|
+
|
|
33
22
|
handlers.push(handler);
|
|
34
23
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
24
|
+
|
|
25
|
+
const handle_routes = (req, res, app) => {
|
|
26
|
+
let data = "";
|
|
27
|
+
|
|
28
|
+
let is_in_default_routes = [
|
|
29
|
+
"run",
|
|
30
|
+
"load",
|
|
31
|
+
"parse",
|
|
32
|
+
"create_account",
|
|
33
|
+
].includes(req.url.slice(1));
|
|
34
|
+
|
|
35
|
+
if (is_in_default_routes || (!is_in_default_routes && !app)) {
|
|
36
|
+
req.on("data", (chunk) => {
|
|
41
37
|
data += chunk;
|
|
42
38
|
});
|
|
43
|
-
|
|
39
|
+
|
|
40
|
+
req.on("end", () => {
|
|
44
41
|
try {
|
|
45
42
|
data = JSON.parse(data);
|
|
46
43
|
} catch (e) {
|
|
47
|
-
return cb(res.end, {
|
|
48
|
-
error_message: "Invalid data",
|
|
49
|
-
error: true
|
|
50
|
-
});
|
|
44
|
+
return cb(res.end, { error_message: "Invalid data", error: true });
|
|
51
45
|
}
|
|
46
|
+
|
|
52
47
|
if (req.url === "/create_account") {
|
|
53
|
-
|
|
48
|
+
let account = initiator.create_account(data);
|
|
54
49
|
res.end(account.stringify(true));
|
|
55
50
|
} else if (["run", "load", "parse"].includes(req.url.slice(1))) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
_Index.initiator.endpoint(req.url.slice(1), payload);
|
|
51
|
+
let payload = {
|
|
52
|
+
...data,
|
|
53
|
+
callback: (datagram) => cb(res.end, datagram),
|
|
54
|
+
};
|
|
55
|
+
initiator.endpoint(req.url.slice(1), payload);
|
|
62
56
|
} else {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
res
|
|
57
|
+
let extension = extensions[req.url.slice(1)];
|
|
58
|
+
|
|
59
|
+
extension &&
|
|
60
|
+
extension.map((ex) => {
|
|
61
|
+
typeof ex === "function" && ex(data, { req, res });
|
|
68
62
|
});
|
|
69
|
-
});
|
|
70
63
|
}
|
|
71
64
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
});
|
|
76
|
-
res.end(JSON.stringify({
|
|
77
|
-
status: "error",
|
|
78
|
-
message: e.message
|
|
79
|
-
}));
|
|
65
|
+
|
|
66
|
+
req.on("error", (e) => {
|
|
67
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
68
|
+
res.end(JSON.stringify({ status: "error", message: e.message }));
|
|
80
69
|
});
|
|
81
70
|
} else {
|
|
82
71
|
app && app(req, res);
|
|
83
72
|
}
|
|
84
73
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
_context.next = 6;
|
|
112
|
-
break;
|
|
113
|
-
case 13:
|
|
114
|
-
exports.PORT = PORT = port;
|
|
115
|
-
server = _http["default"].createServer(function (req, res) {
|
|
116
|
-
return handle_routes(req, res, app);
|
|
117
|
-
});
|
|
118
|
-
server.listen(port, function () {
|
|
119
|
-
console.log("\n...GOD PROTOCOL RUNNING :".concat(port));
|
|
120
|
-
});
|
|
121
|
-
case 16:
|
|
122
|
-
case "end":
|
|
123
|
-
return _context.stop();
|
|
124
|
-
}
|
|
125
|
-
}, _callee);
|
|
126
|
-
}));
|
|
127
|
-
return function create_server(_x, _x2) {
|
|
128
|
-
return _ref.apply(this, arguments);
|
|
129
|
-
};
|
|
130
|
-
}();
|
|
131
|
-
var _default = create_server;
|
|
132
|
-
exports["default"] = _default;
|
|
74
|
+
|
|
75
|
+
const create_server = async (app, settings) => {
|
|
76
|
+
settings = settings || {};
|
|
77
|
+
|
|
78
|
+
let port = settings.port || PORT,
|
|
79
|
+
port_search = settings.port_search;
|
|
80
|
+
|
|
81
|
+
if (port_search) {
|
|
82
|
+
let av = await is_port_available(port);
|
|
83
|
+
|
|
84
|
+
while (!av) {
|
|
85
|
+
port++;
|
|
86
|
+
av = await is_port_available(port);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
PORT = port;
|
|
90
|
+
|
|
91
|
+
let server = http.createServer((req, res) => handle_routes(req, res, app));
|
|
92
|
+
|
|
93
|
+
server.listen(port, () => {
|
|
94
|
+
console.log(`\n...GOD PROTOCOL RUNNING :${port}`);
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export default create_server;
|
|
99
|
+
export { PORT, extension };
|