wao 0.1.6 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/ao.js CHANGED
@@ -10,14 +10,14 @@ var _aoconnect = require("@permaweb/aoconnect");
10
10
  var _ramda = require("ramda");
11
11
  var _utils = require("./utils.js");
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13
+ 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); }
14
+ 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; }
13
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; }
14
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; }
15
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; }
16
18
  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
19
  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
20
  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
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
22
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
23
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); } }
@@ -89,9 +89,10 @@ var AO = /*#__PURE__*/function () {
89
89
  _ref4$scheduler = _ref4.scheduler,
90
90
  scheduler = _ref4$scheduler === void 0 ? _utils.srcs.scheduler : _ref4$scheduler,
91
91
  aoconnect = _ref4.aoconnect,
92
- in_memory = _ref4.in_memory,
93
92
  _ref4$ar = _ref4.ar,
94
- ar = _ref4$ar === void 0 ? {} : _ref4$ar;
93
+ ar = _ref4$ar === void 0 ? {} : _ref4$ar,
94
+ _ref4$in_memory = _ref4.in_memory,
95
+ in_memory = _ref4$in_memory === void 0 ? false : _ref4$in_memory;
95
96
  _classCallCheck(this, AO);
96
97
  if (!module) {
97
98
  switch (module_type) {
@@ -110,23 +111,20 @@ var AO = /*#__PURE__*/function () {
110
111
  var _ar = _typeof(ar) === "object" ? ar : {};
111
112
  this.ar = new _ar2["default"](ar);
112
113
  }
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
- }
114
+ if (in_memory) {} else if (aoconnect) {
115
+ var _connect = (0, _aoconnect.connect)(aoconnect),
116
+ _results = _connect.results,
117
+ _assign = _connect.assign,
118
+ _result = _connect.result,
119
+ _message = _connect.message,
120
+ _spawn = _connect.spawn,
121
+ _dryrun = _connect.dryrun;
122
+ this.assign = _assign;
123
+ this.result = _result;
124
+ this.results = _results;
125
+ this.message = _message;
126
+ this.spawn = _spawn;
127
+ this.dryrun = _dryrun;
130
128
  } else {
131
129
  this.assign = _aoconnect.assign;
132
130
  this.result = _aoconnect.result;
@@ -143,36 +141,14 @@ var AO = /*#__PURE__*/function () {
143
141
  key: "init",
144
142
  value: function () {
145
143
  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
144
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
148
145
  while (1) switch (_context3.prev = _context3.next) {
149
146
  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;
147
+ _context3.next = 2;
172
148
  return this.ar.init(jwk);
173
- case 16:
149
+ case 2:
174
150
  return _context3.abrupt("return", this);
175
- case 17:
151
+ case 3:
176
152
  case "end":
177
153
  return _context3.stop();
178
154
  }
@@ -668,7 +644,7 @@ var AO = /*#__PURE__*/function () {
668
644
  _context9.next = 10;
669
645
  break;
670
646
  }
671
- if (_this3.local) {
647
+ if (_this3.in_memory) {
672
648
  _context9.next = 6;
673
649
  break;
674
650
  }
@@ -687,7 +663,7 @@ var AO = /*#__PURE__*/function () {
687
663
  }
688
664
  return _context9.abrupt("return", txs);
689
665
  case 12:
690
- if (!_this3.local) {
666
+ if (!_this3.in_memory) {
691
667
  _context9.next = 15;
692
668
  break;
693
669
  }
package/cjs/helpers.js CHANGED
@@ -4,10 +4,31 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.setup = exports.ok = exports.fail = exports.Src = void 0;
7
+ Object.defineProperty(exports, "AO", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _tao["default"];
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "AR", {
14
+ enumerable: true,
15
+ get: function get() {
16
+ return _index.AR;
17
+ }
18
+ });
19
+ exports.Src = void 0;
20
+ Object.defineProperty(exports, "connect", {
21
+ enumerable: true,
22
+ get: function get() {
23
+ return _aoconnect3.connect;
24
+ }
25
+ });
26
+ exports.setup = exports.ok = exports.fail = void 0;
27
+ var _aoconnect3 = require("./aoconnect.js");
8
28
  var _index = require("./index.js");
29
+ var _tao = _interopRequireDefault(require("./tao.js"));
9
30
  var _assert = _interopRequireDefault(require("assert"));
10
- var _aoconnect3 = require("@permaweb/aoconnect");
31
+ var _aoconnect4 = require("@permaweb/aoconnect");
11
32
  var _path = require("path");
12
33
  var _fs = require("fs");
13
34
  var _yargs = _interopRequireDefault(require("yargs"));
@@ -198,11 +219,11 @@ var setup = exports.setup = /*#__PURE__*/function () {
198
219
  dir: dir
199
220
  });
200
221
  _context3.next = 25;
201
- return new _index.AO(opt.ao).init(opt.jwk);
222
+ return new _tao["default"](opt.ao).init(opt.jwk);
202
223
  case 25:
203
224
  _ao = _context3.sent;
204
225
  _context3.next = 28;
205
- return new _index.AO(opt.ao2).init(opt.jwk);
226
+ return new _tao["default"](opt.ao2).init(opt.jwk);
206
227
  case 28:
207
228
  _ao2 = _context3.sent;
208
229
  console.log("cache:\t", optPath);
@@ -260,7 +281,7 @@ var setup = exports.setup = /*#__PURE__*/function () {
260
281
  return src.upload("aos2_0_1", "wasm");
261
282
  case 51:
262
283
  wasm_aos2 = _context3.sent;
263
- ao = new _index.AO({
284
+ ao = new _tao["default"]({
264
285
  aoconnect: aoconnect,
265
286
  ar: ar,
266
287
  authority: auth
@@ -324,7 +345,7 @@ var setup = exports.setup = /*#__PURE__*/function () {
324
345
 
325
346
  // ao2
326
347
  _context3.next = 87;
327
- return new _index.AO({
348
+ return new _tao["default"]({
328
349
  aoconnect: aoconnect,
329
350
  ar: ar,
330
351
  authority: auth,
package/cjs/tao.js ADDED
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _ao = _interopRequireDefault(require("./ao.js"));
9
+ var _utils = require("./utils.js");
10
+ var _ar = _interopRequireDefault(require("./ar.js"));
11
+ var _aoconnect = require("./aoconnect.js");
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13
+ 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; }
14
+ 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); }
15
+ 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); }); }; }
16
+ 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; }
17
+ 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; }
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 _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
20
+ 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); } }
21
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
22
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
23
+ 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); }
24
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
25
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
26
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
27
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
28
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
29
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
30
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
31
+ var AO = /*#__PURE__*/function (_MAO) {
32
+ function AO() {
33
+ var _this;
34
+ var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
35
+ _classCallCheck(this, AO);
36
+ _this = _callSuper(this, AO, [_objectSpread(_objectSpread({}, opt), {}, {
37
+ in_memory: true
38
+ })]);
39
+ _this.in_memory = true;
40
+ var _connect = (0, _aoconnect.connect)(),
41
+ accounts = _connect.accounts,
42
+ modules = _connect.modules,
43
+ results = _connect.results,
44
+ assign = _connect.assign,
45
+ result = _connect.result,
46
+ message = _connect.message,
47
+ spawn = _connect.spawn,
48
+ dryrun = _connect.dryrun,
49
+ txs = _connect.txs;
50
+ _this.module = modules.aos_2_0_1;
51
+ _this.assign = assign;
52
+ _this.result = result;
53
+ _this.results = results;
54
+ _this.message = message;
55
+ _this.spawn = spawn;
56
+ _this.dryrun = dryrun;
57
+ _this.ar.txs = txs;
58
+ _this.accounts = accounts;
59
+ return _this;
60
+ }
61
+ _inherits(AO, _MAO);
62
+ return _createClass(AO, [{
63
+ key: "init",
64
+ value: function () {
65
+ var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(jwk) {
66
+ var _this$accounts;
67
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
68
+ while (1) switch (_context.prev = _context.next) {
69
+ case 0:
70
+ if (!jwk && (_this$accounts = this.accounts) !== null && _this$accounts !== void 0 && _this$accounts[0]) jwk = this.accounts[0].jwk;
71
+ _context.next = 3;
72
+ return this.ar.init(jwk);
73
+ case 3:
74
+ return _context.abrupt("return", this);
75
+ case 4:
76
+ case "end":
77
+ return _context.stop();
78
+ }
79
+ }, _callee, this);
80
+ }));
81
+ function init(_x) {
82
+ return _init.apply(this, arguments);
83
+ }
84
+ return init;
85
+ }()
86
+ }]);
87
+ }(_ao["default"]);
88
+ var _default = exports["default"] = AO;
package/esm/ao.js CHANGED
@@ -64,8 +64,8 @@ class AO {
64
64
  module_type = "aos2",
65
65
  scheduler = srcs.scheduler,
66
66
  aoconnect,
67
- in_memory,
68
67
  ar = {},
68
+ in_memory = false,
69
69
  } = {}) {
70
70
  if (!module) {
71
71
  switch (module_type) {
@@ -86,19 +86,16 @@ class AO {
86
86
  let _ar = typeof ar === "object" ? ar : {}
87
87
  this.ar = new AR(ar)
88
88
  }
89
- this.in_memory = in_memory
90
- if (aoconnect) {
91
- if (in_memory) {
92
- } else {
93
- const { results, assign, result, message, spawn, dryrun } =
94
- connect(aoconnect)
95
- this.assign = assign
96
- this.result = result
97
- this.results = results
98
- this.message = message
99
- this.spawn = spawn
100
- this.dryrun = dryrun
101
- }
89
+ if (in_memory) {
90
+ } else if (aoconnect) {
91
+ const { results, assign, result, message, spawn, dryrun } =
92
+ connect(aoconnect)
93
+ this.assign = assign
94
+ this.result = result
95
+ this.results = results
96
+ this.message = message
97
+ this.spawn = spawn
98
+ this.dryrun = dryrun
102
99
  } else {
103
100
  this.assign = assign
104
101
  this.result = result
@@ -113,29 +110,6 @@ class AO {
113
110
  }
114
111
 
115
112
  async init(jwk) {
116
- if (this.in_memory) {
117
- const v = await import("./aoconnect.js")
118
- const {
119
- accounts,
120
- modules,
121
- results,
122
- assign,
123
- result,
124
- message,
125
- spawn,
126
- dryrun,
127
- txs,
128
- } = v.connect()
129
- this.module = modules.aos_2_0_1
130
- this.assign = assign
131
- this.result = result
132
- this.results = results
133
- this.message = message
134
- this.spawn = spawn
135
- this.dryrun = dryrun
136
- this.ar.txs = txs
137
- jwk ??= accounts[0].jwk
138
- }
139
113
  await this.ar.init(jwk)
140
114
  return this
141
115
  }
@@ -394,12 +368,12 @@ class AO {
394
368
  const getRef = async (ref, txs = []) => {
395
369
  let ex = exRef(ref, txs)
396
370
  if (!ex) {
397
- if (!this.local) await wait(1000)
371
+ if (!this.in_memory) await wait(1000)
398
372
  txs = await this.ar.txs(pid)
399
373
  ex = exRef(ref, txs)
400
374
  }
401
375
  if (ex) return txs
402
- if (this.local) await wait(1)
376
+ if (this.in_memory) await wait(1)
403
377
  return Date.now() - start < (this.local ? timeout / 1000 : timeout)
404
378
  ? await getRef(ref)
405
379
  : []
package/esm/helpers.js CHANGED
@@ -1,4 +1,6 @@
1
- import { AR, AO } from "./index.js"
1
+ import { connect as tconnect } from "./aoconnect.js"
2
+ import { AR } from "./index.js"
3
+ import AO from "./tao.js"
2
4
  import assert from "assert"
3
5
  import { createDataItemSigner, connect } from "@permaweb/aoconnect"
4
6
  import { dirname as _dirname, resolve } from "path"
@@ -159,3 +161,5 @@ export const fail = obj => {
159
161
  assert.notEqual(obj.err, null)
160
162
  return obj
161
163
  }
164
+
165
+ export { AO, AR, tconnect as connect }
package/esm/tao.js ADDED
@@ -0,0 +1,39 @@
1
+ import MAO from "./ao.js"
2
+ import { srcs } from "./utils.js"
3
+ import AR from "./ar.js"
4
+ import { connect } from "./aoconnect.js"
5
+
6
+ class AO extends MAO {
7
+ constructor(opt = {}) {
8
+ super({ ...opt, in_memory: true })
9
+ this.in_memory = true
10
+ const {
11
+ accounts,
12
+ modules,
13
+ results,
14
+ assign,
15
+ result,
16
+ message,
17
+ spawn,
18
+ dryrun,
19
+ txs,
20
+ } = connect()
21
+ this.module = modules.aos_2_0_1
22
+ this.assign = assign
23
+ this.result = result
24
+ this.results = results
25
+ this.message = message
26
+ this.spawn = spawn
27
+ this.dryrun = dryrun
28
+ this.ar.txs = txs
29
+ this.accounts = accounts
30
+ }
31
+
32
+ async init(jwk) {
33
+ if (!jwk && this.accounts?.[0]) jwk = this.accounts[0].jwk
34
+ await this.ar.init(jwk)
35
+ return this
36
+ }
37
+ }
38
+
39
+ export default AO
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.1.6",
3
+ "version": "0.2.1",
4
4
  "description": "",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -13,10 +13,6 @@
13
13
  "require": "./cjs/utils.js",
14
14
  "import": "./esm/utils.js"
15
15
  },
16
- "./connect": {
17
- "require": "./cjs/aoconnect.js",
18
- "import": "./esm/aoconnect.js"
19
- },
20
16
  "./test": {
21
17
  "require": "./cjs/helpers.js",
22
18
  "import": "./esm/helpers.js"
package/esm/test.js DELETED
@@ -1,94 +0,0 @@
1
- import { Profile, AR, AO, Collection, Notebook } from "./index.js"
2
- import { expect } from "chai"
3
- import { createDataItemSigner, connect } from "@permaweb/aoconnect"
4
- import { resolve } from "path"
5
- import { readFileSync } from "fs"
6
- export class Src {
7
- constructor({ ar, base = "./lua", readFileSync, dir, resolve }) {
8
- this.ar = ar
9
- this.base = base
10
- this.dir = dir
11
- }
12
- async upload(file, ext = "lua") {
13
- const data = readFileSync(
14
- `${this.dir}/${this.base}/${file}.${ext}`,
15
- ext === "wasm" ? null : "utf8",
16
- )
17
- const res = await this.ar.post({ data })
18
- return res.err ? null : res.id
19
- }
20
- }
21
-
22
- export const setup = async ({ aoconnect, arweave } = {}) => {
23
- console.error = () => {}
24
- console.warn = () => {}
25
- arweave ??= { port: 4000 }
26
- aoconnect ??= {
27
- MU_URL: "http://localhost:4002",
28
- CU_URL: "http://localhost:4004",
29
- GATEWAY_URL: "http://localhost:4000",
30
- }
31
- const dir = resolve(import.meta.dirname)
32
- const thumbnail = readFileSync(`${dir}/assets/thumbnail.png`)
33
- const banner = readFileSync(resolve(`${dir}/assets/banner.png`))
34
- const ar = new AR(arweave)
35
- await ar.gen("10")
36
- const src = new Src({ ar, readFileSync, dir })
37
- const notelib_src = await src.upload("atomic-note-library")
38
- const registry_src = await src.upload("registry000")
39
- const profile_src = await src.upload("profile000")
40
- const collection_registry_src = await src.upload("collection-registry")
41
- const notebook_src = await src.upload("notebook")
42
- const note_src = await src.upload("atomic-note")
43
- const proxy = await src.upload("proxy")
44
- const wasm = await src.upload("aos-sqlite", "wasm")
45
- const wasm2 = await src.upload("aos", "wasm")
46
- const ao = new AO({ aoconnect, ar })
47
-
48
- const { id: module_sqlite } = await ao.postModule({
49
- data: await ar.data(wasm),
50
- overwrite: true,
51
- })
52
-
53
- const { scheduler } = await ao.postScheduler({
54
- url: "http://su",
55
- overwrite: true,
56
- })
57
-
58
- const profile = new Profile({ profile_src, registry_src, ao })
59
- await profile.createRegistry({})
60
- const notebook = new Notebook({
61
- notebook_src,
62
- registry_src: collection_registry_src,
63
- profile,
64
- })
65
-
66
- await notebook.createRegistry()
67
- const { id: module } = await ao.postModule({ data: await ar.data(wasm2) })
68
- const { pid: proxy_pid } = await ao.deploy({ src: proxy, module })
69
-
70
- let opt = {
71
- ar: { ...arweave },
72
- profile: { registry_src, registry: profile.registry, profile_src },
73
- ao: { module: module_sqlite, scheduler, aoconnect },
74
- note: { proxy: proxy_pid, note_src, notelib_src },
75
- notebook: {
76
- notebook_src,
77
- registry: notebook.registry,
78
- registry_src: collection_registry_src,
79
- },
80
- }
81
- return { opt, profile, ao, ar, thumbnail, banner }
82
- }
83
-
84
- export const ok = obj => {
85
- if (obj.err) console.log(obj.err)
86
- expect(obj.err).to.eql(null)
87
- return obj
88
- }
89
-
90
- export const fail = obj => {
91
- if (!obj.err) console.log(obj.res)
92
- expect(obj.err).to.not.eql(null)
93
- return obj
94
- }