godprotocol 1.0.839 → 1.0.841

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.
@@ -1,40 +1,57 @@
1
- class Explorer {
2
- constructor() {}
3
-
4
- chain_props = ["blocks"];
5
-
6
- explore = (query) => {
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ 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); }
8
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
9
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
10
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
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 Explorer = /*#__PURE__*/_createClass(function Explorer() {
15
+ var _this = this;
16
+ _classCallCheck(this, Explorer);
17
+ _defineProperty(this, "chain_props", ["blocks"]);
18
+ _defineProperty(this, "explore", function (query) {
7
19
  if (!query) return;
8
-
9
20
  if (query.startsWith("{")) query = query.slice(1, -1);
10
21
  query = query.split(":");
11
-
12
22
  query[0] = query[0].split(".");
13
-
14
- let q2 = Number(query[1]),
23
+ var q2 = Number(query[1]),
15
24
  prop;
16
-
17
- if (this.chain_props.includes(query[0][0])) prop = query[0][0];
18
-
19
- let obj;
25
+ if (_this.chain_props.includes(query[0][0])) prop = query[0][0];
26
+ var obj;
20
27
  if (isNaN(q2)) {
21
- obj = this[prop || "connections"].find((c) => c.hash === query[1]);
28
+ var arr = _this[prop || "connections"];
29
+ for (var b = 0; b < arr.length; b++) {
30
+ var blk = _this.build_block(arr[b]);
31
+ if (blk.hash === query[1]) {
32
+ obj = blk;
33
+ break;
34
+ }
35
+ }
22
36
  } else if (q2 >= 0) {
23
- obj = this[prop || "connections"].find((q) => q.index === q2);
37
+ var _arr = _this[prop || "connections"];
38
+ for (var _b = 0; _b < _arr.length; _b++) {
39
+ var _blk = _this.build_block(_arr[_b]);
40
+ if (_blk.index === q2) {
41
+ obj = _blk;
42
+ break;
43
+ }
44
+ }
24
45
  } else {
25
- obj = this[prop || "connections"].slice(q2)[0];
46
+ obj = _this.build_block(_this[prop || "connections"].slice(q2)[0]);
47
+ }
48
+ if (!prop) for (var q = 0; q < query[0].length; q++) {
49
+ var que = query[0][q];
50
+ if (!obj) break;
51
+ obj = obj[que];
26
52
  }
27
-
28
- if (!prop)
29
- for (let q = 0; q < query[0].length; q++) {
30
- let que = query[0][q];
31
-
32
- if (!obj) break;
33
- obj = obj[que];
34
- }
35
-
36
53
  return obj;
37
- };
38
- }
39
-
40
- export default Explorer;
54
+ });
55
+ });
56
+ var _default = Explorer;
57
+ exports["default"] = _default;
@@ -1,57 +1,54 @@
1
- import { hash } from "../utils/hash";
2
-
3
- class Filesystem {
4
- constructor() {
5
- this.base_address = process.env.BASE_ADDRESS || "Accounts";
6
- }
7
-
8
- parse_path = (path) => {
9
- if (!path || (path && !path.includes("/"))) return path;
10
-
11
- return this.read(path);
12
- };
13
-
14
- read = (datapath) => {
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _hash = require("../utils/hash");
8
+ 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); }
9
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
10
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
12
+ 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; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
14
+ 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); }
15
+ var Filesystem = /*#__PURE__*/_createClass(function Filesystem() {
16
+ var _this = this;
17
+ _classCallCheck(this, Filesystem);
18
+ _defineProperty(this, "parse_path", function (path) {
19
+ if (!path || path && !path.includes("/")) return path;
20
+ return _this.read(path);
21
+ });
22
+ _defineProperty(this, "read", function (datapath) {
15
23
  if (!datapath) return null;
16
-
17
- let type_folder = this.account.manager.oracle.get(datapath);
18
-
24
+ var type_folder = _this.account.manager.oracle.get(datapath);
19
25
  if (!type_folder) return datapath;
20
-
21
- let content;
26
+ var content;
22
27
  if (type_folder.type === "twain") {
23
28
  content = {};
24
- for (let prop in type_folder.obj) {
25
- let val = type_folder.obj[prop];
26
-
27
- content[this.parse_path(prop)] = this.parse_path(val);
29
+ for (var prop in type_folder.obj) {
30
+ var val = type_folder.obj[prop];
31
+ content[_this.parse_path(prop)] = _this.parse_path(val);
28
32
  }
29
33
  } else if (type_folder.type === "array") {
30
34
  content = [];
31
- type_folder.obj.map((t) => {
32
- content.push(this.parse_path(t));
35
+ type_folder.obj.map(function (t) {
36
+ content.push(_this.parse_path(t));
33
37
  });
34
38
  } else content = type_folder.obj;
35
-
36
39
  return content;
37
- };
38
-
39
- save = (content, chain, just_obj) => {
40
- let addr, obj;
41
-
42
- let type = typeof chain === "string" ? chain : this.get_type(chain);
43
-
40
+ });
41
+ _defineProperty(this, "save", function (content, chain, just_obj) {
42
+ var addr, obj;
43
+ var type = typeof chain === "string" ? chain : _this.get_type(chain);
44
44
  if (type === "array" || type === "string") {
45
45
  obj = [];
46
-
47
- for (let curs in content)
48
- obj.splice(Number(curs) || -1, 0, content[curs]);
49
-
46
+ for (var curs in content) obj.splice(Number(curs) || -1, 0, content[curs]);
50
47
  if (type === "string") obj = obj.join(" ");
51
48
  } else if (type === "twain") {
52
49
  obj = {};
53
- for (let curs in content) {
54
- obj[curs] = content[curs];
50
+ for (var _curs in content) {
51
+ obj[_curs] = content[_curs];
55
52
  }
56
53
  } else if (type === "number") {
57
54
  obj = Number(content["-1"]);
@@ -59,84 +56,71 @@ class Filesystem {
59
56
  } else {
60
57
  obj = null;
61
58
  }
62
-
63
59
  if (just_obj) return obj;
64
-
65
- addr = `${chain.path}/${hash(JSON.stringify(obj))}`;
66
- this;
67
- if (obj != null) this.manager.oracle.write(addr, obj);
68
-
69
- this.manager.oracle.set(addr, { obj, type });
70
-
60
+ addr = "".concat(chain.path, "/").concat((0, _hash.hash)(JSON.stringify(obj)));
61
+ _this;
62
+ if (obj != null) _this.manager.oracle.write(addr, obj);
63
+ _this.manager.oracle.set(addr, {
64
+ obj: obj,
65
+ type: type
66
+ });
71
67
  return addr;
72
- };
73
-
74
- data_addr = (type) => {
75
- return `${this.physical_address}/Datatypes/${type}`;
76
- };
77
-
78
- get_type = (chain) => {
68
+ });
69
+ _defineProperty(this, "data_addr", function (type) {
70
+ return "".concat(_this.physical_address, "/Datatypes/").concat(type);
71
+ });
72
+ _defineProperty(this, "get_type", function (chain) {
79
73
  switch (chain.physical_address) {
80
- case this.data_addr(`Number`):
74
+ case _this.data_addr("Number"):
81
75
  return "number";
82
- case this.data_addr(`String`):
76
+ case _this.data_addr("String"):
83
77
  return "string";
84
- case this.data_addr(`Twain`):
78
+ case _this.data_addr("Twain"):
85
79
  return "twain";
86
- case this.data_addr(`Array`):
80
+ case _this.data_addr("Array"):
87
81
  return "array";
88
- case this.data_addr(`Boolean`):
82
+ case _this.data_addr("Boolean"):
89
83
  return "boolean";
90
- case this.data_addr(`Void`):
84
+ case _this.data_addr("Void"):
91
85
  return "void";
92
86
  }
93
- };
94
-
95
- write = (arg, context) => {
96
- let content = context.get_buffer();
97
-
87
+ });
88
+ _defineProperty(this, "write", function (arg, context) {
89
+ var content = context.get_buffer();
98
90
  if (!content || !arg) return;
99
-
100
91
  content[context.cursor] = arg;
101
92
  // console.log(`Writing: ${arg}`);
102
- };
103
-
104
- name_hash = () => {
105
- this.hash = hash(this.name);
106
- };
107
-
108
- set_paths = (chain) => {
93
+ });
94
+ _defineProperty(this, "name_hash", function () {
95
+ _this.hash = (0, _hash.hash)(_this.name);
96
+ });
97
+ _defineProperty(this, "set_paths", function (chain) {
109
98
  if (chain.parent && chain.parent.manager) {
110
99
  chain.path = chain.parent.path;
111
100
  return;
112
101
  }
113
- chain.path = `${chain.parent ? chain.parent.path : this.base_address}/${
114
- chain.hash
115
- }`;
116
-
117
- let fs = this.manager.oracle.fs;
118
-
119
- if (!fs.existsSync(chain.path)) {
120
- fs.mkdirSync(chain.path, { recursive: true });
102
+ chain.path = "".concat(chain.parent ? chain.parent.path : _this.base_address, "/").concat(chain.hash);
103
+ var fs = _this.manager.oracle.fs;
104
+ if (!fs.existsSync("".concat(_this.root, "/").concat(chain.path))) {
105
+ fs.mkdirSync("".concat(_this.root, "/").concat(chain.path), {
106
+ recursive: true
107
+ });
121
108
  }
122
- };
123
-
124
- add_chain = (name, parent) => {
125
- let chain = this.manager.web.get(`${parent.physical_address}/${name}`);
126
- if (!chain) chain = this.manager.web.set(parent, name);
127
-
109
+ });
110
+ _defineProperty(this, "add_chain", function (name, parent) {
111
+ var chain = _this.manager.web.get("".concat(parent.physical_address, "/").concat(name));
112
+ if (!chain) chain = _this.manager.web.set(parent, name);
128
113
  return chain;
129
- };
130
-
131
- account_chain = (account) => {
132
- let chain = this.manager.web.get(account.physical_address);
133
-
114
+ });
115
+ _defineProperty(this, "account_chain", function (account) {
116
+ var chain = _this.manager.web.get(account.physical_address);
134
117
  if (!chain) {
135
- chain = this.manager.web.set(account);
118
+ chain = _this.manager.web.set(account);
136
119
  }
137
-
138
120
  return chain;
139
- };
140
- }
141
-
142
- export default Filesystem;
121
+ });
122
+ this.root = process.env.ROOT || __dirname;
123
+ this.base_address = process.env.BASE_ADDRESS || "Accounts";
124
+ });
125
+ var _default = Filesystem;
126
+ exports["default"] = _default;
package/Objects/Frame.js CHANGED
@@ -1,47 +1,52 @@
1
- import { array_to_nested_objects } from "../utils/functions";
2
-
3
- class Frame {
4
- constructor(object, parent) {
5
- this.parent = parent;
6
-
7
- this.object = Array.isArray(object)
8
- ? array_to_nested_objects(object)
9
- : object;
10
-
11
- this.children = new Array();
12
- this.instructions = new Array();
13
- }
14
-
15
- frame = (object) => {
16
- let frame = new Frame(object, this);
17
-
18
- this.instructions.push(frame);
19
- this.children.push(frame);
20
-
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _functions = require("../utils/functions");
8
+ 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); }
9
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
10
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
12
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
13
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
14
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
15
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
16
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
17
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
18
+ 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; }
19
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
20
+ 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); }
21
+ var Frame = /*#__PURE__*/_createClass(function Frame(_object, parent) {
22
+ var _this = this;
23
+ _classCallCheck(this, Frame);
24
+ _defineProperty(this, "frame", function (object) {
25
+ var frame = new Frame(object, _this);
26
+ _this.instructions.push(frame);
27
+ _this.children.push(frame);
21
28
  return frame;
22
- };
23
-
24
- to_instruction = () => {
25
- for (let prop in this.object) {
26
- let val = this.object[prop];
27
- this.instructions.push(`chain ${prop}`);
28
-
29
- val && this.frame(val).to_instruction();
30
-
31
- this.instructions.push(`pop ${prop}`);
29
+ });
30
+ _defineProperty(this, "to_instruction", function () {
31
+ for (var prop in _this.object) {
32
+ var val = _this.object[prop];
33
+ _this.instructions.push("chain ".concat(prop));
34
+ val && _this.frame(val).to_instruction();
35
+ _this.instructions.push("pop ".concat(prop));
32
36
  }
33
- };
34
-
35
- flatten_instructions = () => {
36
- let inss = new Array();
37
-
38
- for (let i = 0; i < this.instructions.length; i++) {
39
- let ins = this.instructions[i];
40
- if (ins instanceof Frame) inss.push(...ins.flatten_instructions());
41
- else inss.push(ins);
37
+ });
38
+ _defineProperty(this, "flatten_instructions", function () {
39
+ var inss = new Array();
40
+ for (var i = 0; i < _this.instructions.length; i++) {
41
+ var ins = _this.instructions[i];
42
+ if (ins instanceof Frame) inss.push.apply(inss, _toConsumableArray(ins.flatten_instructions()));else inss.push(ins);
42
43
  }
43
44
  return inss;
44
- };
45
- }
46
-
47
- export default Frame;
45
+ });
46
+ this.parent = parent;
47
+ this.object = Array.isArray(_object) ? (0, _functions.array_to_nested_objects)(_object) : _object;
48
+ this.children = new Array();
49
+ this.instructions = new Array();
50
+ });
51
+ var _default = Frame;
52
+ exports["default"] = _default;