wao 0.1.0

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 (60) hide show
  1. package/cjs/accounts.js +96 -0
  2. package/cjs/ao.js +1543 -0
  3. package/cjs/aoconnect.js +758 -0
  4. package/cjs/ar.js +794 -0
  5. package/cjs/dirname.js +7 -0
  6. package/cjs/helpers.js +381 -0
  7. package/cjs/index.js +20 -0
  8. package/cjs/utils.js +438 -0
  9. package/esm/.cache/opt.json +1 -0
  10. package/esm/accounts.js +91 -0
  11. package/esm/ao.js +737 -0
  12. package/esm/aoconnect.js +318 -0
  13. package/esm/ar.js +243 -0
  14. package/esm/dirname.js +1 -0
  15. package/esm/helpers.js +161 -0
  16. package/esm/index.js +4 -0
  17. package/esm/lua/aos-sqlite.wasm +0 -0
  18. package/esm/lua/aos.wasm +0 -0
  19. package/esm/lua/aos2.lua +33 -0
  20. package/esm/lua/aos2_0_1.wasm +0 -0
  21. package/esm/lua/atomic-asset.lua +238 -0
  22. package/esm/lua/atomic-note-library.lua +2274 -0
  23. package/esm/lua/atomic-note.lua +11 -0
  24. package/esm/lua/collection-registry.lua +202 -0
  25. package/esm/lua/collection.lua +173 -0
  26. package/esm/lua/notebook.lua +173 -0
  27. package/esm/lua/profile.lua +858 -0
  28. package/esm/lua/profile000.lua +666 -0
  29. package/esm/lua/proxy.lua +24 -0
  30. package/esm/lua/registry.lua +858 -0
  31. package/esm/lua/registry000.lua +636 -0
  32. package/esm/test.js +94 -0
  33. package/esm/utils.js +342 -0
  34. package/package.json +21 -0
  35. package/test/.cache/opt.json +1 -0
  36. package/test/accounts.js +91 -0
  37. package/test/ao.js +737 -0
  38. package/test/aoconnect.js +318 -0
  39. package/test/ar.js +243 -0
  40. package/test/dirname.js +1 -0
  41. package/test/helpers.js +161 -0
  42. package/test/index.js +4 -0
  43. package/test/lua/aos-sqlite.wasm +0 -0
  44. package/test/lua/aos.wasm +0 -0
  45. package/test/lua/aos2.lua +33 -0
  46. package/test/lua/aos2_0_1.wasm +0 -0
  47. package/test/lua/atomic-asset.lua +238 -0
  48. package/test/lua/atomic-note-library.lua +2274 -0
  49. package/test/lua/atomic-note.lua +11 -0
  50. package/test/lua/collection-registry.lua +202 -0
  51. package/test/lua/collection.lua +173 -0
  52. package/test/lua/notebook.lua +173 -0
  53. package/test/lua/profile.lua +858 -0
  54. package/test/lua/profile000.lua +666 -0
  55. package/test/lua/proxy.lua +24 -0
  56. package/test/lua/registry.lua +858 -0
  57. package/test/lua/registry000.lua +636 -0
  58. package/test/package.json +21 -0
  59. package/test/test.js +94 -0
  60. package/test/utils.js +342 -0
package/cjs/ao.js ADDED
@@ -0,0 +1,1543 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var WarpArBundles = _interopRequireWildcard(require("warp-arbundles"));
8
+ var _ar2 = _interopRequireDefault(require("./ar.js"));
9
+ var _aoconnect = require("@permaweb/aoconnect");
10
+ var _ramda = require("ramda");
11
+ var _utils = require("./utils.js");
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13
+ 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; }
14
+ 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; }
15
+ 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; }
16
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
17
+ 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; } }
18
+ 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; }
19
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
20
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
21
+ 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); }
22
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
23
+ 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); } }
24
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
25
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
26
+ 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); }
27
+ 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; }
28
+ 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); }
29
+ 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); }); }; }
30
+ var pkg = WarpArBundles["default"] ? WarpArBundles["default"] : WarpArBundles;
31
+ var createData = pkg.createData,
32
+ ArweaveSigner = pkg.ArweaveSigner;
33
+ function createDataItemSigner2(wallet) {
34
+ var signer = /*#__PURE__*/function () {
35
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
36
+ var data, tags, target, anchor, signer, dataItem;
37
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
38
+ while (1) switch (_context2.prev = _context2.next) {
39
+ case 0:
40
+ data = _ref.data, tags = _ref.tags, target = _ref.target, anchor = _ref.anchor;
41
+ signer = new ArweaveSigner(wallet);
42
+ dataItem = createData(data, signer, {
43
+ tags: tags,
44
+ target: target,
45
+ anchor: anchor
46
+ });
47
+ return _context2.abrupt("return", dataItem.sign(signer).then(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
48
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
49
+ while (1) switch (_context.prev = _context.next) {
50
+ case 0:
51
+ _context.next = 2;
52
+ return dataItem.id;
53
+ case 2:
54
+ _context.t0 = _context.sent;
55
+ _context.next = 5;
56
+ return dataItem.getRaw();
57
+ case 5:
58
+ _context.t1 = _context.sent;
59
+ return _context.abrupt("return", {
60
+ id: _context.t0,
61
+ raw: _context.t1
62
+ });
63
+ case 7:
64
+ case "end":
65
+ return _context.stop();
66
+ }
67
+ }, _callee);
68
+ }))));
69
+ case 4:
70
+ case "end":
71
+ return _context2.stop();
72
+ }
73
+ }, _callee2);
74
+ }));
75
+ return function signer(_x) {
76
+ return _ref2.apply(this, arguments);
77
+ };
78
+ }();
79
+ return signer;
80
+ }
81
+ var AO = /*#__PURE__*/function () {
82
+ function AO() {
83
+ var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
84
+ _ref4$authority = _ref4.authority,
85
+ authority = _ref4$authority === void 0 ? _utils.srcs.authority : _ref4$authority,
86
+ module = _ref4.module,
87
+ _ref4$module_type = _ref4.module_type,
88
+ module_type = _ref4$module_type === void 0 ? "aos2" : _ref4$module_type,
89
+ _ref4$scheduler = _ref4.scheduler,
90
+ scheduler = _ref4$scheduler === void 0 ? _utils.srcs.scheduler : _ref4$scheduler,
91
+ aoconnect = _ref4.aoconnect,
92
+ in_memory = _ref4.in_memory,
93
+ _ref4$ar = _ref4.ar,
94
+ ar = _ref4$ar === void 0 ? {} : _ref4$ar;
95
+ _classCallCheck(this, AO);
96
+ if (!module) {
97
+ switch (module_type) {
98
+ case "sqlite":
99
+ module = _utils.srcs.module_sqlite;
100
+ break;
101
+ case "aos2":
102
+ module = _utils.srcs.module_aos2;
103
+ break;
104
+ default:
105
+ module = _utils.srcs.module;
106
+ }
107
+ }
108
+ this.__type__ = "ao";
109
+ if ((ar === null || ar === void 0 ? void 0 : ar.__type__) === "ar") this.ar = ar;else {
110
+ var _ar = _typeof(ar) === "object" ? ar : {};
111
+ this.ar = new _ar2["default"](ar);
112
+ }
113
+ this.in_memory = in_memory;
114
+ if (aoconnect) {
115
+ if (in_memory) {} else {
116
+ var _connect = (0, _aoconnect.connect)(aoconnect),
117
+ _results = _connect.results,
118
+ _assign = _connect.assign,
119
+ _result = _connect.result,
120
+ _message = _connect.message,
121
+ _spawn = _connect.spawn,
122
+ _dryrun = _connect.dryrun;
123
+ this.assign = _assign;
124
+ this.result = _result;
125
+ this.results = _results;
126
+ this.message = _message;
127
+ this.spawn = _spawn;
128
+ this.dryrun = _dryrun;
129
+ }
130
+ } else {
131
+ this.assign = _aoconnect.assign;
132
+ this.result = _aoconnect.result;
133
+ this.results = _aoconnect.results;
134
+ this.message = _aoconnect.message;
135
+ this.spawn = _aoconnect.spawn;
136
+ this.dryrun = _aoconnect.dryrun;
137
+ }
138
+ this.module = module;
139
+ this.scheduler = scheduler;
140
+ this.authority = authority;
141
+ }
142
+ return _createClass(AO, [{
143
+ key: "init",
144
+ value: function () {
145
+ var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(jwk) {
146
+ var _jwk, v, _v$connect, accounts, modules, _results2, _assign2, _result2, _message2, _spawn2, _dryrun2, txs;
147
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
148
+ while (1) switch (_context3.prev = _context3.next) {
149
+ case 0:
150
+ if (!this.in_memory) {
151
+ _context3.next = 14;
152
+ break;
153
+ }
154
+ _context3.next = 3;
155
+ return Promise.resolve().then(function () {
156
+ return _interopRequireWildcard(require("./aoconnect.js"));
157
+ });
158
+ case 3:
159
+ v = _context3.sent;
160
+ _v$connect = v.connect(), accounts = _v$connect.accounts, modules = _v$connect.modules, _results2 = _v$connect.results, _assign2 = _v$connect.assign, _result2 = _v$connect.result, _message2 = _v$connect.message, _spawn2 = _v$connect.spawn, _dryrun2 = _v$connect.dryrun, txs = _v$connect.txs;
161
+ this.module = modules.aos_2_0_1;
162
+ this.assign = _assign2;
163
+ this.result = _result2;
164
+ this.results = _results2;
165
+ this.message = _message2;
166
+ this.spawn = _spawn2;
167
+ this.dryrun = _dryrun2;
168
+ this.ar.txs = txs;
169
+ (_jwk = jwk) !== null && _jwk !== void 0 ? _jwk : jwk = accounts[0].jwk;
170
+ case 14:
171
+ _context3.next = 16;
172
+ return this.ar.init(jwk);
173
+ case 16:
174
+ return _context3.abrupt("return", this);
175
+ case 17:
176
+ case "end":
177
+ return _context3.stop();
178
+ }
179
+ }, _callee3, this);
180
+ }));
181
+ function init(_x2) {
182
+ return _init.apply(this, arguments);
183
+ }
184
+ return init;
185
+ }()
186
+ }, {
187
+ key: "toSigner",
188
+ value: function toSigner(wallet) {
189
+ if (wallet !== null && wallet !== void 0 && wallet.n && typeof window !== "undefined") {
190
+ return createDataItemSigner2(wallet);
191
+ } else if (wallet.test) {
192
+ return (0, _aoconnect.createDataItemSigner)(wallet.jwk);
193
+ } else {
194
+ return (0, _aoconnect.createDataItemSigner)(wallet);
195
+ }
196
+ }
197
+ }, {
198
+ key: "pipe",
199
+ value: function () {
200
+ var _pipe = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref5) {
201
+ var _fns$0$args, _ret2;
202
+ var jwk, _ref5$fns, fns, cb, _, out, res, i, nextArgs, ret, err, pid, mid, id, copy, binds, _iterator, _step, _binds$v$fn, _v$bind, _v$name, _v$fn, _fns$args, _fns, v, bind, name, fn, _fn, _res, _err, _ret, k;
203
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
204
+ while (1) switch (_context4.prev = _context4.next) {
205
+ case 0:
206
+ jwk = _ref5.jwk, _ref5$fns = _ref5.fns, fns = _ref5$fns === void 0 ? [] : _ref5$fns, cb = _ref5.cb;
207
+ _ = {}, out = {}, res = [], i = 0;
208
+ nextArgs = (_fns$0$args = fns[0].args) !== null && _fns$0$args !== void 0 ? _fns$0$args : {};
209
+ ret = null, err = null, pid = null, mid = null, id = null;
210
+ if (!jwk) fns.unshift({
211
+ fn: "checkWallet"
212
+ });
213
+ copy = function copy(_ref6) {
214
+ var _args$_from$slice$joi, _out$_from$slice$join, _inp$_from$slice$join, _inp$from;
215
+ var _ = _ref6._,
216
+ inp = _ref6.inp,
217
+ out = _ref6.out,
218
+ args = _ref6.args,
219
+ from = _ref6.from,
220
+ to = _ref6.to,
221
+ pid = _ref6.pid,
222
+ mid = _ref6.mid,
223
+ id = _ref6.id;
224
+ var _from = from.split(".");
225
+ var _to = to.split(".");
226
+ var field = null,
227
+ val = null,
228
+ target = null;
229
+ if (_to[0] === "_") {
230
+ target = _;
231
+ field = _to.slice(1).join(".");
232
+ } else if (_to[0] === "args") {
233
+ target = args;
234
+ field = _to.slice(1).join(".");
235
+ } else if (_to[0] === "out") {
236
+ target = out;
237
+ field = _to.slice(1).join(".");
238
+ } else {
239
+ target = out;
240
+ field = _to.join(".");
241
+ }
242
+ if (from === "inp") val = inp;else if (from === "mid") val = mid;else if (from === "id") val = id;else if (from === "pid") val = pid;else if (_from[0] === "args") val = (_args$_from$slice$joi = args[_from.slice(1).join(".")]) !== null && _args$_from$slice$joi !== void 0 ? _args$_from$slice$joi : null;else if (_from[0] === "out") val = (_out$_from$slice$join = out[_from.slice(1).join(".")]) !== null && _out$_from$slice$join !== void 0 ? _out$_from$slice$join : null;else if (_from[0] === "inp") val = (_inp$_from$slice$join = inp[_from.slice(1).join(".")]) !== null && _inp$_from$slice$join !== void 0 ? _inp$_from$slice$join : null;else val = (_inp$from = inp[from]) !== null && _inp$from !== void 0 ? _inp$from : null;
243
+ if (target) target[field] = val;
244
+ };
245
+ binds = {
246
+ post: this.ar,
247
+ bundle: this.ar,
248
+ postTx: this.ar,
249
+ checkWallet: this.ar,
250
+ transfer: this.ar
251
+ };
252
+ _iterator = _createForOfIteratorHelper(fns);
253
+ _context4.prev = 8;
254
+ _iterator.s();
255
+ case 10:
256
+ if ((_step = _iterator.n()).done) {
257
+ _context4.next = 50;
258
+ break;
259
+ }
260
+ v = _step.value;
261
+ bind = null;
262
+ if (typeof v.fn === "string" && !v.bind) bind = (_binds$v$fn = binds[v.fn]) !== null && _binds$v$fn !== void 0 ? _binds$v$fn : this;else bind = (_v$bind = v.bind) !== null && _v$bind !== void 0 ? _v$bind : this;
263
+ name = ((_v$name = v.name) !== null && _v$name !== void 0 ? _v$name : _typeof(!v.fn)) ? "msg" : typeof v.fn === "string" ? v.fn : null;
264
+ fn = typeof v.fn === "string" ? bind[v.fn] : (_v$fn = v.fn) !== null && _v$fn !== void 0 ? _v$fn : this.msg;
265
+ _fn = fn.bind(bind);
266
+ _context4.next = 19;
267
+ return _fn(_objectSpread({
268
+ jwk: jwk
269
+ }, nextArgs));
270
+ case 19:
271
+ _res = _context4.sent;
272
+ res.push(_res);
273
+ if (!_res.err) {
274
+ _context4.next = 24;
275
+ break;
276
+ }
277
+ err = _res.err;
278
+ return _context4.abrupt("break", 50);
279
+ case 24:
280
+ if (!(typeof v.err === "function")) {
281
+ _context4.next = 31;
282
+ break;
283
+ }
284
+ _context4.next = 27;
285
+ return v.err({
286
+ name: name,
287
+ _: _,
288
+ jwk: jwk,
289
+ res: _res.res,
290
+ args: nextArgs,
291
+ out: out,
292
+ pid: pid,
293
+ inp: _res.out,
294
+ mid: mid,
295
+ id: id
296
+ });
297
+ case 27:
298
+ _err = _context4.sent;
299
+ if (!_err) {
300
+ _context4.next = 31;
301
+ break;
302
+ }
303
+ err = _err;
304
+ return _context4.abrupt("break", 50);
305
+ case 31:
306
+ if (_res.pid) pid = _res.pid;
307
+ if (_res.mid) mid = _res.mid;
308
+ if (_res.id) id = _res.id;
309
+ if (_res.jwk) jwk = _res.jwk;
310
+ nextArgs = (_fns$args = (_fns = fns[i + 1]) === null || _fns === void 0 ? void 0 : _fns.args) !== null && _fns$args !== void 0 ? _fns$args : {};
311
+ if (!(typeof v.then === "function")) {
312
+ _context4.next = 45;
313
+ break;
314
+ }
315
+ _context4.next = 39;
316
+ return v.then({
317
+ name: name,
318
+ _: _,
319
+ jwk: jwk,
320
+ res: _res.res,
321
+ args: nextArgs,
322
+ out: out,
323
+ pid: pid,
324
+ inp: _res.out,
325
+ mid: mid,
326
+ id: id
327
+ });
328
+ case 39:
329
+ _ret = _context4.sent;
330
+ if (!(typeof _ret !== "undefined")) {
331
+ _context4.next = 43;
332
+ break;
333
+ }
334
+ ret = _ret;
335
+ return _context4.abrupt("break", 50);
336
+ case 43:
337
+ _context4.next = 46;
338
+ break;
339
+ case 45:
340
+ if ((0, _ramda.is)(Object, v.then)) {
341
+ for (k in v.then) {
342
+ copy({
343
+ name: name,
344
+ _: _,
345
+ inp: _res.out,
346
+ out: out,
347
+ args: nextArgs,
348
+ pid: pid,
349
+ mid: mid,
350
+ from: v.then[k],
351
+ to: k,
352
+ id: id
353
+ });
354
+ }
355
+ }
356
+ case 46:
357
+ if (typeof cb === "function") {
358
+ cb({
359
+ name: name,
360
+ fns: fns,
361
+ i: i + 1,
362
+ _: _,
363
+ jwk: jwk,
364
+ res: _res.res,
365
+ args: nextArgs,
366
+ out: out,
367
+ pid: pid,
368
+ inp: _res.out,
369
+ mid: mid,
370
+ id: id
371
+ });
372
+ }
373
+ i++;
374
+ case 48:
375
+ _context4.next = 10;
376
+ break;
377
+ case 50:
378
+ _context4.next = 55;
379
+ break;
380
+ case 52:
381
+ _context4.prev = 52;
382
+ _context4.t0 = _context4["catch"](8);
383
+ _iterator.e(_context4.t0);
384
+ case 55:
385
+ _context4.prev = 55;
386
+ _iterator.f();
387
+ return _context4.finish(55);
388
+ case 58:
389
+ return _context4.abrupt("return", (_ret2 = ret) !== null && _ret2 !== void 0 ? _ret2 : _objectSpread({
390
+ jwk: jwk,
391
+ err: err,
392
+ res: res,
393
+ out: out,
394
+ pid: pid,
395
+ mid: mid,
396
+ id: id
397
+ }, _));
398
+ case 59:
399
+ case "end":
400
+ return _context4.stop();
401
+ }
402
+ }, _callee4, this, [[8, 52, 55, 58]]);
403
+ }));
404
+ function pipe(_x3) {
405
+ return _pipe.apply(this, arguments);
406
+ }
407
+ return pipe;
408
+ }()
409
+ }, {
410
+ key: "postModule",
411
+ value: function () {
412
+ var _postModule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref7) {
413
+ var _this = this;
414
+ var data, jwk, _ref7$tags, tags, _ref7$overwrite, overwrite, _tags, fns;
415
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
416
+ while (1) switch (_context5.prev = _context5.next) {
417
+ case 0:
418
+ data = _ref7.data, jwk = _ref7.jwk, _ref7$tags = _ref7.tags, tags = _ref7$tags === void 0 ? {} : _ref7$tags, _ref7$overwrite = _ref7.overwrite, overwrite = _ref7$overwrite === void 0 ? false : _ref7$overwrite;
419
+ _tags = (0, _ramda.mergeLeft)(tags, {
420
+ "Data-Protocol": "ao",
421
+ Variant: "ao.TN.1",
422
+ Type: "Module",
423
+ "Module-Format": "wasm64-unknown-emscripten-draft_2024_02_15",
424
+ "Input-Encoding": "JSON-V1",
425
+ "Output-Encoding": "JSON-V1",
426
+ "Memory-Limit": "1-gb",
427
+ "Compute-Limit": "9000000000000"
428
+ });
429
+ fns = [{
430
+ fn: "post",
431
+ args: {
432
+ data: data,
433
+ tags: _tags
434
+ },
435
+ then: function then(_ref8) {
436
+ var id = _ref8.id;
437
+ if (!_this.module || overwrite) _this.module = id;
438
+ }
439
+ }];
440
+ _context5.next = 5;
441
+ return this.pipe({
442
+ jwk: jwk,
443
+ fns: fns
444
+ });
445
+ case 5:
446
+ return _context5.abrupt("return", _context5.sent);
447
+ case 6:
448
+ case "end":
449
+ return _context5.stop();
450
+ }
451
+ }, _callee5, this);
452
+ }));
453
+ function postModule(_x4) {
454
+ return _postModule.apply(this, arguments);
455
+ }
456
+ return postModule;
457
+ }()
458
+ }, {
459
+ key: "postScheduler",
460
+ value: function () {
461
+ var _postScheduler = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref9) {
462
+ var _this2 = this;
463
+ var jwk, url, _ref9$tags, tags, _ref9$overwrite, overwrite, _tags, then, fns;
464
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
465
+ while (1) switch (_context7.prev = _context7.next) {
466
+ case 0:
467
+ jwk = _ref9.jwk, url = _ref9.url, _ref9$tags = _ref9.tags, tags = _ref9$tags === void 0 ? {} : _ref9$tags, _ref9$overwrite = _ref9.overwrite, overwrite = _ref9$overwrite === void 0 ? false : _ref9$overwrite;
468
+ _tags = (0, _ramda.mergeLeft)(tags, {
469
+ "Data-Protocol": "ao",
470
+ Variant: "ao.TN.1",
471
+ Type: "Scheduler-Location",
472
+ Url: url,
473
+ "Time-To-Live": "3600000"
474
+ });
475
+ then = /*#__PURE__*/function () {
476
+ var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref10) {
477
+ var jwk, out, _;
478
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
479
+ while (1) switch (_context6.prev = _context6.next) {
480
+ case 0:
481
+ jwk = _ref10.jwk, out = _ref10.out, _ = _ref10._;
482
+ _context6.next = 3;
483
+ return _this2.ar.toAddr(jwk);
484
+ case 3:
485
+ _.scheduler = _context6.sent;
486
+ if (!_this2.scheduler || overwrite) _this2.scheduler = _.scheduler;
487
+ case 5:
488
+ case "end":
489
+ return _context6.stop();
490
+ }
491
+ }, _callee6);
492
+ }));
493
+ return function then(_x6) {
494
+ return _ref11.apply(this, arguments);
495
+ };
496
+ }();
497
+ fns = [{
498
+ fn: "post",
499
+ args: {
500
+ tags: _tags
501
+ },
502
+ then: then
503
+ }];
504
+ _context7.next = 6;
505
+ return this.pipe({
506
+ jwk: jwk,
507
+ fns: fns
508
+ });
509
+ case 6:
510
+ return _context7.abrupt("return", _context7.sent);
511
+ case 7:
512
+ case "end":
513
+ return _context7.stop();
514
+ }
515
+ }, _callee7, this);
516
+ }));
517
+ function postScheduler(_x5) {
518
+ return _postScheduler.apply(this, arguments);
519
+ }
520
+ return postScheduler;
521
+ }()
522
+ }, {
523
+ key: "spwn",
524
+ value: function () {
525
+ var _spwn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
526
+ var _ref12,
527
+ boot,
528
+ _ref12$module,
529
+ module,
530
+ _ref12$scheduler,
531
+ scheduler,
532
+ jwk,
533
+ _ref12$tags,
534
+ tags,
535
+ data,
536
+ auth,
537
+ err,
538
+ _yield$this$ar$checkW,
539
+ pid,
540
+ _tags,
541
+ _args8 = arguments;
542
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
543
+ while (1) switch (_context8.prev = _context8.next) {
544
+ case 0:
545
+ _ref12 = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {}, boot = _ref12.boot, _ref12$module = _ref12.module, module = _ref12$module === void 0 ? this.module : _ref12$module, _ref12$scheduler = _ref12.scheduler, scheduler = _ref12$scheduler === void 0 ? this.scheduler : _ref12$scheduler, jwk = _ref12.jwk, _ref12$tags = _ref12.tags, tags = _ref12$tags === void 0 ? {} : _ref12$tags, data = _ref12.data, auth = _ref12.auth;
546
+ err = null;
547
+ _context8.next = 4;
548
+ return this.ar.checkWallet({
549
+ jwk: jwk
550
+ });
551
+ case 4:
552
+ _yield$this$ar$checkW = _context8.sent;
553
+ jwk = _yield$this$ar$checkW.jwk;
554
+ err = _yield$this$ar$checkW.err;
555
+ if (!err) {
556
+ _context8.next = 9;
557
+ break;
558
+ }
559
+ return _context8.abrupt("return", {
560
+ err: err
561
+ });
562
+ case 9:
563
+ pid = null;
564
+ _context8.prev = 10;
565
+ if (boot) tags["On-Boot"] = boot;
566
+ if (auth) tags.Authority = auth;
567
+ if (!tags.Authority && this.authority) tags.Authority = this.authority;
568
+ _tags = (0, _utils.buildTags)(null, tags);
569
+ _context8.next = 17;
570
+ return this.spawn({
571
+ module: module,
572
+ scheduler: scheduler,
573
+ signer: this.toSigner(jwk),
574
+ tags: _tags,
575
+ data: (0, _utils.jsonToStr)(data)
576
+ });
577
+ case 17:
578
+ pid = _context8.sent;
579
+ _context8.next = 23;
580
+ break;
581
+ case 20:
582
+ _context8.prev = 20;
583
+ _context8.t0 = _context8["catch"](10);
584
+ err = _context8.t0;
585
+ case 23:
586
+ return _context8.abrupt("return", {
587
+ err: err,
588
+ pid: pid
589
+ });
590
+ case 24:
591
+ case "end":
592
+ return _context8.stop();
593
+ }
594
+ }, _callee8, this, [[10, 20]]);
595
+ }));
596
+ function spwn() {
597
+ return _spwn.apply(this, arguments);
598
+ }
599
+ return spwn;
600
+ }()
601
+ }, {
602
+ key: "msg",
603
+ value: function () {
604
+ var _msg = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(_ref13) {
605
+ var _this3 = this;
606
+ var pid, jwk, data, _ref13$act, act, _ref13$tags, tags, _ref13$check, check, get, _ref13$timeout, timeout, err, _yield$this$ar$checkW2, res, out, mid, results, _tags, start, exRef, _getRef, cache, checks, isOK, _getResult, _yield$_getResult2;
607
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
608
+ while (1) switch (_context11.prev = _context11.next) {
609
+ case 0:
610
+ pid = _ref13.pid, jwk = _ref13.jwk, data = _ref13.data, _ref13$act = _ref13.act, act = _ref13$act === void 0 ? "Eval" : _ref13$act, _ref13$tags = _ref13.tags, tags = _ref13$tags === void 0 ? {} : _ref13$tags, _ref13$check = _ref13.check, check = _ref13$check === void 0 ? [] : _ref13$check, get = _ref13.get, _ref13$timeout = _ref13.timeout, timeout = _ref13$timeout === void 0 ? 10000 : _ref13$timeout;
611
+ err = null;
612
+ _context11.next = 4;
613
+ return this.ar.checkWallet({
614
+ jwk: jwk
615
+ });
616
+ case 4:
617
+ _yield$this$ar$checkW2 = _context11.sent;
618
+ jwk = _yield$this$ar$checkW2.jwk;
619
+ err = _yield$this$ar$checkW2.err;
620
+ if (!err) {
621
+ _context11.next = 9;
622
+ break;
623
+ }
624
+ return _context11.abrupt("return", {
625
+ err: err
626
+ });
627
+ case 9:
628
+ res = null, out = null, mid = null, results = [];
629
+ _tags = (0, _utils.buildTags)(act, tags);
630
+ start = Date.now();
631
+ _context11.prev = 12;
632
+ _context11.next = 15;
633
+ return this.message({
634
+ process: pid,
635
+ signer: this.toSigner(jwk),
636
+ tags: _tags,
637
+ data: (0, _utils.jsonToStr)(data)
638
+ });
639
+ case 15:
640
+ mid = _context11.sent;
641
+ exRef = function exRef(ref, txs) {
642
+ var _iterator2 = _createForOfIteratorHelper(txs !== null && txs !== void 0 ? txs : []),
643
+ _step2;
644
+ try {
645
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
646
+ var v2 = _step2.value;
647
+ var t = (0, _utils.ltags)(v2.tags);
648
+ if (t.type === "Message" && t["x-reference"] === ref) return true;
649
+ }
650
+ } catch (err) {
651
+ _iterator2.e(err);
652
+ } finally {
653
+ _iterator2.f();
654
+ }
655
+ return false;
656
+ };
657
+ _getRef = /*#__PURE__*/function () {
658
+ var _ref14 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(ref) {
659
+ var txs,
660
+ ex,
661
+ _args9 = arguments;
662
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
663
+ while (1) switch (_context9.prev = _context9.next) {
664
+ case 0:
665
+ txs = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : [];
666
+ ex = exRef(ref, txs);
667
+ if (ex) {
668
+ _context9.next = 10;
669
+ break;
670
+ }
671
+ if (_this3.local) {
672
+ _context9.next = 6;
673
+ break;
674
+ }
675
+ _context9.next = 6;
676
+ return (0, _utils.wait)(1000);
677
+ case 6:
678
+ _context9.next = 8;
679
+ return _this3.ar.txs(pid);
680
+ case 8:
681
+ txs = _context9.sent;
682
+ ex = exRef(ref, txs);
683
+ case 10:
684
+ if (!ex) {
685
+ _context9.next = 12;
686
+ break;
687
+ }
688
+ return _context9.abrupt("return", txs);
689
+ case 12:
690
+ if (!_this3.local) {
691
+ _context9.next = 15;
692
+ break;
693
+ }
694
+ _context9.next = 15;
695
+ return (0, _utils.wait)(1);
696
+ case 15:
697
+ if (!(Date.now() - start < (_this3.local ? timeout / 1000 : timeout))) {
698
+ _context9.next = 21;
699
+ break;
700
+ }
701
+ _context9.next = 18;
702
+ return _getRef(ref);
703
+ case 18:
704
+ _context9.t0 = _context9.sent;
705
+ _context9.next = 22;
706
+ break;
707
+ case 21:
708
+ _context9.t0 = [];
709
+ case 22:
710
+ return _context9.abrupt("return", _context9.t0);
711
+ case 23:
712
+ case "end":
713
+ return _context9.stop();
714
+ }
715
+ }, _callee9);
716
+ }));
717
+ return function getRef(_x8) {
718
+ return _ref14.apply(this, arguments);
719
+ };
720
+ }();
721
+ cache = [], checks = [], isOK = false;
722
+ _getResult = /*#__PURE__*/function () {
723
+ var _ref15 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(mid) {
724
+ var res, err, i, _iterator3, _step3, _checks$i, v, _checks, checks2, k, refs, _iterator4, _step4, _v, _ltags, _iterator5, _step5, _v2, _ltags3, txs, _iterator6, _step6, v2, _ltags2, _yield$_getResult, _res, _out, _err, _ok;
725
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
726
+ while (1) switch (_context10.prev = _context10.next) {
727
+ case 0:
728
+ _context10.next = 2;
729
+ return _this3.result({
730
+ process: pid,
731
+ message: mid
732
+ });
733
+ case 2:
734
+ res = _context10.sent;
735
+ results.push({
736
+ mid: mid,
737
+ res: res
738
+ });
739
+ err = null;
740
+ if (res.Error) err = res.Error;else {
741
+ if (!(0, _ramda.is)(Array, check)) check = [check];
742
+ i = 0;
743
+ _iterator3 = _createForOfIteratorHelper(check);
744
+ try {
745
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
746
+ v = _step3.value;
747
+ _checks = (_checks$i = checks[i]) !== null && _checks$i !== void 0 ? _checks$i : null;
748
+ if ((0, _utils.isRegExp)(v) || (0, _ramda.includes)(_typeof(v))(["string", "boolean"])) {
749
+ _checks = (0, _utils.mergeChecks)(_checks, (0, _utils.isData)(v, res), v);
750
+ } else {
751
+ checks2 = {};
752
+ for (k in v !== null && v !== void 0 ? v : {}) {
753
+ checks2[k] = (0, _utils.checkTag)(res, k, v[k]);
754
+ }
755
+ _checks = (0, _utils.mergeChecks)(_checks, checks2, v);
756
+ }
757
+ checks[i] = _checks;
758
+ i++;
759
+ }
760
+ } catch (err) {
761
+ _iterator3.e(err);
762
+ } finally {
763
+ _iterator3.f();
764
+ }
765
+ if ((0, _utils.isCheckComplete)(checks, check)) isOK = true;
766
+ if (!(0, _ramda.isNil)(get) && !(0, _utils.isOutComplete)(out, get)) {
767
+ out = (0, _utils.mergeOut)(out, (0, _utils.getTagVal)(get, res), get);
768
+ }
769
+ }
770
+ if (!((!(0, _utils.isOutComplete)(out, get) || !isOK) && !err)) {
771
+ _context10.next = 63;
772
+ break;
773
+ }
774
+ refs = [];
775
+ _iterator4 = _createForOfIteratorHelper(res.Messages);
776
+ try {
777
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
778
+ _v = _step4.value;
779
+ _ltags = (0, _utils.ltags)(_v.Tags);
780
+ if (_ltags.type === "Message" && _ltags.reference) {
781
+ refs.push(_ltags.reference);
782
+ }
783
+ }
784
+ } catch (err) {
785
+ _iterator4.e(err);
786
+ } finally {
787
+ _iterator4.f();
788
+ }
789
+ _iterator5 = _createForOfIteratorHelper(res.Messages);
790
+ _context10.prev = 11;
791
+ _iterator5.s();
792
+ case 13:
793
+ if ((_step5 = _iterator5.n()).done) {
794
+ _context10.next = 55;
795
+ break;
796
+ }
797
+ _v2 = _step5.value;
798
+ _ltags3 = (0, _utils.ltags)(_v2.Tags);
799
+ if (!(_ltags3.type === "Message" && _ltags3.reference)) {
800
+ _context10.next = 53;
801
+ break;
802
+ }
803
+ _context10.next = 19;
804
+ return _getRef(_ltags3.reference, cache);
805
+ case 19:
806
+ txs = _context10.sent;
807
+ cache = (0, _ramda.o)((0, _ramda.uniqBy)((0, _ramda.prop)("id")), (0, _ramda.concat)(cache))(txs);
808
+ _iterator6 = _createForOfIteratorHelper(txs);
809
+ _context10.prev = 22;
810
+ _iterator6.s();
811
+ case 24:
812
+ if ((_step6 = _iterator6.n()).done) {
813
+ _context10.next = 43;
814
+ break;
815
+ }
816
+ v2 = _step6.value;
817
+ _ltags2 = (0, _utils.ltags)(v2.tags);
818
+ if (!(_ltags2.type === "Message" && _ltags2["x-reference"] === _ltags3.reference)) {
819
+ _context10.next = 41;
820
+ break;
821
+ }
822
+ _context10.next = 30;
823
+ return _getResult(v2.id);
824
+ case 30:
825
+ _yield$_getResult = _context10.sent;
826
+ _res = _yield$_getResult.res;
827
+ _out = _yield$_getResult.out;
828
+ _err = _yield$_getResult.err;
829
+ _ok = _yield$_getResult.ok;
830
+ if (!_err) {
831
+ _context10.next = 38;
832
+ break;
833
+ }
834
+ err = _err;
835
+ return _context10.abrupt("break", 43);
836
+ case 38:
837
+ if (!(0, _utils.isOutComplete)(out, get) && _out) out = (0, _utils.mergeOut)(out, _out, get);
838
+ if (!((0, _utils.isOutComplete)(out, get) && isOK)) {
839
+ _context10.next = 41;
840
+ break;
841
+ }
842
+ return _context10.abrupt("break", 43);
843
+ case 41:
844
+ _context10.next = 24;
845
+ break;
846
+ case 43:
847
+ _context10.next = 48;
848
+ break;
849
+ case 45:
850
+ _context10.prev = 45;
851
+ _context10.t0 = _context10["catch"](22);
852
+ _iterator6.e(_context10.t0);
853
+ case 48:
854
+ _context10.prev = 48;
855
+ _iterator6.f();
856
+ return _context10.finish(48);
857
+ case 51:
858
+ if (!((0, _utils.isOutComplete)(out, get) && isOK)) {
859
+ _context10.next = 53;
860
+ break;
861
+ }
862
+ return _context10.abrupt("break", 55);
863
+ case 53:
864
+ _context10.next = 13;
865
+ break;
866
+ case 55:
867
+ _context10.next = 60;
868
+ break;
869
+ case 57:
870
+ _context10.prev = 57;
871
+ _context10.t1 = _context10["catch"](11);
872
+ _iterator5.e(_context10.t1);
873
+ case 60:
874
+ _context10.prev = 60;
875
+ _iterator5.f();
876
+ return _context10.finish(60);
877
+ case 63:
878
+ return _context10.abrupt("return", {
879
+ res: res,
880
+ err: err
881
+ });
882
+ case 64:
883
+ case "end":
884
+ return _context10.stop();
885
+ }
886
+ }, _callee10, null, [[11, 57, 60, 63], [22, 45, 48, 51]]);
887
+ }));
888
+ return function getResult(_x9) {
889
+ return _ref15.apply(this, arguments);
890
+ };
891
+ }();
892
+ _context11.next = 22;
893
+ return _getResult(mid);
894
+ case 22:
895
+ _yield$_getResult2 = _context11.sent;
896
+ res = _yield$_getResult2.res;
897
+ err = _yield$_getResult2.err;
898
+ if (!isOK && !err) err = "something went wrong!";
899
+ _context11.next = 31;
900
+ break;
901
+ case 28:
902
+ _context11.prev = 28;
903
+ _context11.t0 = _context11["catch"](12);
904
+ err = _context11.t0;
905
+ case 31:
906
+ return _context11.abrupt("return", {
907
+ mid: mid,
908
+ res: res,
909
+ err: err,
910
+ out: out,
911
+ results: results
912
+ });
913
+ case 32:
914
+ case "end":
915
+ return _context11.stop();
916
+ }
917
+ }, _callee11, this, [[12, 28]]);
918
+ }));
919
+ function msg(_x7) {
920
+ return _msg.apply(this, arguments);
921
+ }
922
+ return msg;
923
+ }()
924
+ }, {
925
+ key: "asgn",
926
+ value: function () {
927
+ var _asgn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(_ref16) {
928
+ var pid, mid, jwk, check, get, err, _yield$this$ar$checkW3, res, out, checks, i, _iterator7, _step7, _checks$i2, v, _checks, checks2, k;
929
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
930
+ while (1) switch (_context12.prev = _context12.next) {
931
+ case 0:
932
+ pid = _ref16.pid, mid = _ref16.mid, jwk = _ref16.jwk, check = _ref16.check, get = _ref16.get;
933
+ err = null;
934
+ _context12.next = 4;
935
+ return this.ar.checkWallet({
936
+ jwk: jwk
937
+ });
938
+ case 4:
939
+ _yield$this$ar$checkW3 = _context12.sent;
940
+ jwk = _yield$this$ar$checkW3.jwk;
941
+ err = _yield$this$ar$checkW3.err;
942
+ if (!err) {
943
+ _context12.next = 9;
944
+ break;
945
+ }
946
+ return _context12.abrupt("return", {
947
+ err: err
948
+ });
949
+ case 9:
950
+ res = null, out = null;
951
+ _context12.prev = 10;
952
+ _context12.next = 13;
953
+ return this.assign({
954
+ process: pid,
955
+ message: mid,
956
+ signer: this.toSigner(jwk)
957
+ });
958
+ case 13:
959
+ mid = _context12.sent;
960
+ _context12.next = 16;
961
+ return this.result({
962
+ process: pid,
963
+ message: mid
964
+ });
965
+ case 16:
966
+ res = _context12.sent;
967
+ if (!res) err = "something went wrong";
968
+ if (res.Error) err = res.Error;else {
969
+ checks = [];
970
+ if (!(0, _ramda.is)(Array, check)) check = [check];
971
+ i = 0;
972
+ _iterator7 = _createForOfIteratorHelper(check);
973
+ try {
974
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
975
+ v = _step7.value;
976
+ _checks = (_checks$i2 = checks[i]) !== null && _checks$i2 !== void 0 ? _checks$i2 : null;
977
+ if ((0, _utils.isRegExp)(v) || (0, _ramda.includes)(_typeof(v))(["string", "boolean"])) {
978
+ _checks = (0, _utils.mergeChecks)(_checks, (0, _utils.isData)(v, res), v);
979
+ } else {
980
+ checks2 = {};
981
+ for (k in v !== null && v !== void 0 ? v : {}) {
982
+ checks2[k] = (0, _utils.checkTag)(res, k, v[k]);
983
+ }
984
+ _checks = (0, _utils.mergeChecks)(_checks, checks2, v);
985
+ }
986
+ checks[i] = _checks;
987
+ i++;
988
+ }
989
+ } catch (err) {
990
+ _iterator7.e(err);
991
+ } finally {
992
+ _iterator7.f();
993
+ }
994
+ if (!(0, _utils.isCheckComplete)(checks, check)) err = "something went wrong";
995
+ if (!err && !(0, _ramda.isNil)(get)) out = (0, _utils.getTagVal)(get, res);
996
+ }
997
+ _context12.next = 24;
998
+ break;
999
+ case 21:
1000
+ _context12.prev = 21;
1001
+ _context12.t0 = _context12["catch"](10);
1002
+ err = _context12.t0;
1003
+ case 24:
1004
+ return _context12.abrupt("return", {
1005
+ mid: mid,
1006
+ res: res,
1007
+ err: err,
1008
+ out: out
1009
+ });
1010
+ case 25:
1011
+ case "end":
1012
+ return _context12.stop();
1013
+ }
1014
+ }, _callee12, this, [[10, 21]]);
1015
+ }));
1016
+ function asgn(_x10) {
1017
+ return _asgn.apply(this, arguments);
1018
+ }
1019
+ return asgn;
1020
+ }()
1021
+ }, {
1022
+ key: "dry",
1023
+ value: function () {
1024
+ var _dry = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(_ref17) {
1025
+ var pid, jwk, data, _ref17$act, act, _ref17$tags, tags, check, get, _ref17$timeout, timeout, err, _yield$this$ar$checkW4, res, out, _tags, _res, checks, i, _iterator8, _step8, _checks$i3, v, _checks, checks2, k;
1026
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1027
+ while (1) switch (_context13.prev = _context13.next) {
1028
+ case 0:
1029
+ pid = _ref17.pid, jwk = _ref17.jwk, data = _ref17.data, _ref17$act = _ref17.act, act = _ref17$act === void 0 ? "Eval" : _ref17$act, _ref17$tags = _ref17.tags, tags = _ref17$tags === void 0 ? {} : _ref17$tags, check = _ref17.check, get = _ref17.get, _ref17$timeout = _ref17.timeout, timeout = _ref17$timeout === void 0 ? 10000 : _ref17$timeout;
1030
+ err = null;
1031
+ _context13.next = 4;
1032
+ return this.ar.checkWallet({
1033
+ jwk: jwk
1034
+ });
1035
+ case 4:
1036
+ _yield$this$ar$checkW4 = _context13.sent;
1037
+ jwk = _yield$this$ar$checkW4.jwk;
1038
+ err = _yield$this$ar$checkW4.err;
1039
+ if (!err) {
1040
+ _context13.next = 9;
1041
+ break;
1042
+ }
1043
+ return _context13.abrupt("return", {
1044
+ err: err
1045
+ });
1046
+ case 9:
1047
+ res = null, out = null;
1048
+ _tags = (0, _utils.buildTags)(act, tags);
1049
+ _context13.prev = 11;
1050
+ _context13.next = 14;
1051
+ return this.dryrun({
1052
+ process: pid,
1053
+ signer: this.toSigner(jwk),
1054
+ tags: _tags,
1055
+ data: (0, _utils.jsonToStr)(data)
1056
+ });
1057
+ case 14:
1058
+ _res = _context13.sent;
1059
+ res = _res;
1060
+ checks = [];
1061
+ if (!(0, _ramda.is)(Array, check)) check = [check];
1062
+ i = 0;
1063
+ _iterator8 = _createForOfIteratorHelper(check);
1064
+ try {
1065
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1066
+ v = _step8.value;
1067
+ _checks = (_checks$i3 = checks[i]) !== null && _checks$i3 !== void 0 ? _checks$i3 : null;
1068
+ if ((0, _utils.isRegExp)(v) || (0, _ramda.includes)(_typeof(v))(["string", "boolean"])) {
1069
+ _checks = (0, _utils.mergeChecks)(_checks, (0, _utils.isData)(v, res), v);
1070
+ } else {
1071
+ checks2 = {};
1072
+ for (k in v !== null && v !== void 0 ? v : {}) {
1073
+ checks2[k] = (0, _utils.checkTag)(res, k, v[k]);
1074
+ }
1075
+ _checks = (0, _utils.mergeChecks)(_checks, checks2, v);
1076
+ }
1077
+ checks[i] = _checks;
1078
+ i++;
1079
+ }
1080
+ } catch (err) {
1081
+ _iterator8.e(err);
1082
+ } finally {
1083
+ _iterator8.f();
1084
+ }
1085
+ if (!(0, _utils.isCheckComplete)(checks, check)) err = "something went wrong";
1086
+ if (!err && !(0, _ramda.isNil)(get)) out = (0, _utils.getTagVal)(get, res);
1087
+ _context13.next = 28;
1088
+ break;
1089
+ case 25:
1090
+ _context13.prev = 25;
1091
+ _context13.t0 = _context13["catch"](11);
1092
+ err = _context13.t0;
1093
+ case 28:
1094
+ return _context13.abrupt("return", {
1095
+ res: res,
1096
+ err: err,
1097
+ out: out
1098
+ });
1099
+ case 29:
1100
+ case "end":
1101
+ return _context13.stop();
1102
+ }
1103
+ }, _callee13, this, [[11, 25]]);
1104
+ }));
1105
+ function dry(_x11) {
1106
+ return _dry.apply(this, arguments);
1107
+ }
1108
+ return dry;
1109
+ }()
1110
+ }, {
1111
+ key: "eval",
1112
+ value: function () {
1113
+ var _eval2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(_ref18) {
1114
+ var pid, jwk, data, fns;
1115
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1116
+ while (1) switch (_context14.prev = _context14.next) {
1117
+ case 0:
1118
+ pid = _ref18.pid, jwk = _ref18.jwk, data = _ref18.data;
1119
+ fns = [{
1120
+ args: {
1121
+ pid: pid,
1122
+ data: data,
1123
+ act: "Eval"
1124
+ },
1125
+ err: function err(_ref19) {
1126
+ var _res$Output, _res$Output2, _res$Output3;
1127
+ var res = _ref19.res;
1128
+ return _typeof(res === null || res === void 0 || (_res$Output = res.Output) === null || _res$Output === void 0 ? void 0 : _res$Output.data) !== "object" && !(typeof (res === null || res === void 0 || (_res$Output2 = res.Output) === null || _res$Output2 === void 0 ? void 0 : _res$Output2.prompt) === "string" && /aos\-/.test(res === null || res === void 0 || (_res$Output3 = res.Output) === null || _res$Output3 === void 0 ? void 0 : _res$Output3.prompt));
1129
+ }
1130
+ }];
1131
+ _context14.next = 4;
1132
+ return this.pipe({
1133
+ jwk: jwk,
1134
+ fns: fns
1135
+ });
1136
+ case 4:
1137
+ return _context14.abrupt("return", _context14.sent);
1138
+ case 5:
1139
+ case "end":
1140
+ return _context14.stop();
1141
+ }
1142
+ }, _callee14, this);
1143
+ }));
1144
+ function _eval(_x12) {
1145
+ return _eval2.apply(this, arguments);
1146
+ }
1147
+ return _eval;
1148
+ }()
1149
+ }, {
1150
+ key: "transform",
1151
+ value: function () {
1152
+ var _transform = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(_ref20) {
1153
+ var src, data, fills, err, out, _data, k, text;
1154
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1155
+ while (1) switch (_context15.prev = _context15.next) {
1156
+ case 0:
1157
+ src = _ref20.src, data = _ref20.data, fills = _ref20.fills;
1158
+ err = null, out = null;
1159
+ if (!(data !== null && data !== void 0)) {
1160
+ _context15.next = 6;
1161
+ break;
1162
+ }
1163
+ _context15.t0 = data;
1164
+ _context15.next = 9;
1165
+ break;
1166
+ case 6:
1167
+ _context15.next = 8;
1168
+ return this.ar.data(src, true);
1169
+ case 8:
1170
+ _context15.t0 = _context15.sent;
1171
+ case 9:
1172
+ _data = _context15.t0;
1173
+ if (!_data) err = "data doesn't exist";else {
1174
+ for (k in fills !== null && fills !== void 0 ? fills : {}) {
1175
+ text = fills[k];
1176
+ if (typeof text === "number") text = Number(text).toString();
1177
+ _data = _data.replace(new RegExp("<".concat(k, ">"), "g"), text.replace(/'/g, "\\'"));
1178
+ }
1179
+ out = _data;
1180
+ }
1181
+ return _context15.abrupt("return", {
1182
+ err: err,
1183
+ out: out
1184
+ });
1185
+ case 12:
1186
+ case "end":
1187
+ return _context15.stop();
1188
+ }
1189
+ }, _callee15, this);
1190
+ }));
1191
+ function transform(_x13) {
1192
+ return _transform.apply(this, arguments);
1193
+ }
1194
+ return transform;
1195
+ }()
1196
+ }, {
1197
+ key: "load",
1198
+ value: function () {
1199
+ var _load = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(_ref21) {
1200
+ var src, data, fills, pid, jwk, fns;
1201
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1202
+ while (1) switch (_context16.prev = _context16.next) {
1203
+ case 0:
1204
+ src = _ref21.src, data = _ref21.data, fills = _ref21.fills, pid = _ref21.pid, jwk = _ref21.jwk;
1205
+ fns = [{
1206
+ fn: this.transform,
1207
+ args: {
1208
+ src: src,
1209
+ fills: fills,
1210
+ data: data
1211
+ },
1212
+ then: {
1213
+ "args.data": "inp"
1214
+ }
1215
+ }, {
1216
+ fn: this.eval,
1217
+ args: {
1218
+ pid: pid
1219
+ }
1220
+ }];
1221
+ _context16.next = 4;
1222
+ return this.pipe({
1223
+ jwk: jwk,
1224
+ fns: fns
1225
+ });
1226
+ case 4:
1227
+ return _context16.abrupt("return", _context16.sent);
1228
+ case 5:
1229
+ case "end":
1230
+ return _context16.stop();
1231
+ }
1232
+ }, _callee16, this);
1233
+ }));
1234
+ function load(_x14) {
1235
+ return _load.apply(this, arguments);
1236
+ }
1237
+ return load;
1238
+ }()
1239
+ }, {
1240
+ key: "wait",
1241
+ value: function () {
1242
+ var _wait2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref22) {
1243
+ var pid, _ref22$attempts, attempts, exist, err, _yield$this$dry, res, _err;
1244
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1245
+ while (1) switch (_context17.prev = _context17.next) {
1246
+ case 0:
1247
+ pid = _ref22.pid, _ref22$attempts = _ref22.attempts, attempts = _ref22$attempts === void 0 ? 5 : _ref22$attempts;
1248
+ exist = false;
1249
+ err = null;
1250
+ case 3:
1251
+ if (!(attempts > 0)) {
1252
+ _context17.next = 17;
1253
+ break;
1254
+ }
1255
+ _context17.next = 6;
1256
+ return (0, _utils.wait)(1000);
1257
+ case 6:
1258
+ _context17.next = 8;
1259
+ return this.dry({
1260
+ pid: pid,
1261
+ data: "#Inbox"
1262
+ });
1263
+ case 8:
1264
+ _yield$this$dry = _context17.sent;
1265
+ res = _yield$this$dry.res;
1266
+ _err = _yield$this$dry.err;
1267
+ if (!(_typeof(res === null || res === void 0 ? void 0 : res.Output) === "object")) {
1268
+ _context17.next = 13;
1269
+ break;
1270
+ }
1271
+ return _context17.abrupt("break", 17);
1272
+ case 13:
1273
+ attempts -= 1;
1274
+ if (attempts === 0) err = "timeout";
1275
+ _context17.next = 3;
1276
+ break;
1277
+ case 17:
1278
+ return _context17.abrupt("return", {
1279
+ err: err,
1280
+ pid: pid
1281
+ });
1282
+ case 18:
1283
+ case "end":
1284
+ return _context17.stop();
1285
+ }
1286
+ }, _callee17, this);
1287
+ }));
1288
+ function wait(_x15) {
1289
+ return _wait2.apply(this, arguments);
1290
+ }
1291
+ return wait;
1292
+ }()
1293
+ }, {
1294
+ key: "deploy",
1295
+ value: function () {
1296
+ var _deploy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_ref23) {
1297
+ var boot, loads, src, src_data, _ref23$fills, fills, _ref23$module, module, _ref23$scheduler, scheduler, jwk, _ref23$tags, tags, data, fns, isBoot, i, _iterator9, _step9, v, result;
1298
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1299
+ while (1) switch (_context18.prev = _context18.next) {
1300
+ case 0:
1301
+ boot = _ref23.boot, loads = _ref23.loads, src = _ref23.src, src_data = _ref23.src_data, _ref23$fills = _ref23.fills, fills = _ref23$fills === void 0 ? {} : _ref23$fills, _ref23$module = _ref23.module, module = _ref23$module === void 0 ? this.module : _ref23$module, _ref23$scheduler = _ref23.scheduler, scheduler = _ref23$scheduler === void 0 ? this.scheduler : _ref23$scheduler, jwk = _ref23.jwk, _ref23$tags = _ref23.tags, tags = _ref23$tags === void 0 ? {} : _ref23$tags, data = _ref23.data;
1302
+ fns = [], isBoot = false;
1303
+ if (boot === true && !data) {
1304
+ isBoot = true;
1305
+ fns = [{
1306
+ fn: this.transform,
1307
+ args: {
1308
+ src: src,
1309
+ fills: fills,
1310
+ data: src_data
1311
+ },
1312
+ then: {
1313
+ "args.data": "inp"
1314
+ }
1315
+ }, {
1316
+ fn: this.spwn,
1317
+ args: {
1318
+ boot: "Data",
1319
+ module: module,
1320
+ scheduler: scheduler,
1321
+ tags: tags
1322
+ },
1323
+ then: {
1324
+ "args.pid": "pid"
1325
+ }
1326
+ }];
1327
+ } else {
1328
+ fns = [{
1329
+ fn: this.spwn,
1330
+ args: {
1331
+ boot: boot,
1332
+ module: module,
1333
+ scheduler: scheduler,
1334
+ tags: tags,
1335
+ data: data
1336
+ },
1337
+ then: {
1338
+ "args.pid": "pid"
1339
+ }
1340
+ }];
1341
+ }
1342
+ fns.push({
1343
+ fn: this.wait,
1344
+ then: {
1345
+ "args.pid": "pid"
1346
+ }
1347
+ });
1348
+ i = 0;
1349
+ _iterator9 = _createForOfIteratorHelper(!loads ? [{
1350
+ data: src_data,
1351
+ src: src,
1352
+ fills: fills
1353
+ }] : loads);
1354
+ try {
1355
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1356
+ v = _step9.value;
1357
+ if (!isBoot || i !== 0) {
1358
+ fns.push({
1359
+ fn: this.load,
1360
+ args: v,
1361
+ then: {
1362
+ "args.pid": "pid"
1363
+ }
1364
+ });
1365
+ }
1366
+ i++;
1367
+ }
1368
+ } catch (err) {
1369
+ _iterator9.e(err);
1370
+ } finally {
1371
+ _iterator9.f();
1372
+ }
1373
+ _context18.next = 9;
1374
+ return this.pipe({
1375
+ jwk: jwk,
1376
+ fns: fns
1377
+ });
1378
+ case 9:
1379
+ result = _context18.sent;
1380
+ if (result.pid) result.p = this.p(result.pid);
1381
+ return _context18.abrupt("return", result);
1382
+ case 12:
1383
+ case "end":
1384
+ return _context18.stop();
1385
+ }
1386
+ }, _callee18, this);
1387
+ }));
1388
+ function deploy(_x16) {
1389
+ return _deploy.apply(this, arguments);
1390
+ }
1391
+ return deploy;
1392
+ }()
1393
+ }, {
1394
+ key: "p",
1395
+ value: function p(pid) {
1396
+ return new Process(pid, this);
1397
+ }
1398
+ }]);
1399
+ }();
1400
+ var getParams = function getParams(tags, opts) {
1401
+ var _tags = tags;
1402
+ var _opts = opts;
1403
+ if ((!(0, _ramda.isNil)(tags === null || tags === void 0 ? void 0 : tags.get) || !(0, _ramda.isNil)(tags === null || tags === void 0 ? void 0 : tags.check) || (0, _ramda.is)(Boolean, tags) || (0, _ramda.is)(String, tags)) && (0, _ramda.isNil)(opts)) {
1404
+ _opts = tags;
1405
+ _tags = null;
1406
+ }
1407
+ if ((0, _ramda.isNil)(_opts)) _opts = {
1408
+ get: true
1409
+ };else if ((0, _ramda.is)(Boolean, _opts) || (0, _ramda.is)(String, _opts)) _opts = {
1410
+ get: _opts
1411
+ };
1412
+ return {
1413
+ _tags: _tags,
1414
+ _opts: _opts
1415
+ };
1416
+ };
1417
+ var Process = /*#__PURE__*/function () {
1418
+ function Process(pid, ao) {
1419
+ _classCallCheck(this, Process);
1420
+ this.ao = ao;
1421
+ this.pid = pid;
1422
+ }
1423
+ return _createClass(Process, [{
1424
+ key: "msg",
1425
+ value: function () {
1426
+ var _msg2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(act, tags, opts) {
1427
+ var _getParams, _tags, _opts;
1428
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1429
+ while (1) switch (_context19.prev = _context19.next) {
1430
+ case 0:
1431
+ _getParams = getParams(tags, opts), _tags = _getParams._tags, _opts = _getParams._opts;
1432
+ _context19.next = 3;
1433
+ return this.ao.msg(_objectSpread({
1434
+ pid: this.pid,
1435
+ act: act,
1436
+ tags: _tags
1437
+ }, _opts));
1438
+ case 3:
1439
+ return _context19.abrupt("return", _context19.sent);
1440
+ case 4:
1441
+ case "end":
1442
+ return _context19.stop();
1443
+ }
1444
+ }, _callee19, this);
1445
+ }));
1446
+ function msg(_x17, _x18, _x19) {
1447
+ return _msg2.apply(this, arguments);
1448
+ }
1449
+ return msg;
1450
+ }()
1451
+ }, {
1452
+ key: "dry",
1453
+ value: function () {
1454
+ var _dry2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20(act, tags, opts) {
1455
+ var _getParams2, _tags, _opts;
1456
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1457
+ while (1) switch (_context20.prev = _context20.next) {
1458
+ case 0:
1459
+ _getParams2 = getParams(tags, opts), _tags = _getParams2._tags, _opts = _getParams2._opts;
1460
+ _context20.next = 3;
1461
+ return this.ao.dry(_objectSpread({
1462
+ pid: this.pid,
1463
+ act: act,
1464
+ tags: _tags
1465
+ }, _opts));
1466
+ case 3:
1467
+ return _context20.abrupt("return", _context20.sent);
1468
+ case 4:
1469
+ case "end":
1470
+ return _context20.stop();
1471
+ }
1472
+ }, _callee20, this);
1473
+ }));
1474
+ function dry(_x20, _x21, _x22) {
1475
+ return _dry2.apply(this, arguments);
1476
+ }
1477
+ return dry;
1478
+ }()
1479
+ }, {
1480
+ key: "m",
1481
+ value: function () {
1482
+ var _m = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1483
+ var res,
1484
+ _args21 = arguments;
1485
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1486
+ while (1) switch (_context21.prev = _context21.next) {
1487
+ case 0:
1488
+ _context21.next = 2;
1489
+ return this.msg.apply(this, _args21);
1490
+ case 2:
1491
+ res = _context21.sent;
1492
+ if (!res.err) {
1493
+ _context21.next = 5;
1494
+ break;
1495
+ }
1496
+ throw Error(res.err);
1497
+ case 5:
1498
+ return _context21.abrupt("return", res.out);
1499
+ case 6:
1500
+ case "end":
1501
+ return _context21.stop();
1502
+ }
1503
+ }, _callee21, this);
1504
+ }));
1505
+ function m() {
1506
+ return _m.apply(this, arguments);
1507
+ }
1508
+ return m;
1509
+ }()
1510
+ }, {
1511
+ key: "d",
1512
+ value: function () {
1513
+ var _d = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1514
+ var res,
1515
+ _args22 = arguments;
1516
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1517
+ while (1) switch (_context22.prev = _context22.next) {
1518
+ case 0:
1519
+ _context22.next = 2;
1520
+ return this.dry.apply(this, _args22);
1521
+ case 2:
1522
+ res = _context22.sent;
1523
+ if (!res.err) {
1524
+ _context22.next = 5;
1525
+ break;
1526
+ }
1527
+ throw Error(res.err);
1528
+ case 5:
1529
+ return _context22.abrupt("return", res.out);
1530
+ case 6:
1531
+ case "end":
1532
+ return _context22.stop();
1533
+ }
1534
+ }, _callee22, this);
1535
+ }));
1536
+ function d() {
1537
+ return _d.apply(this, arguments);
1538
+ }
1539
+ return d;
1540
+ }()
1541
+ }]);
1542
+ }();
1543
+ var _default = exports["default"] = AO;