wao 0.2.0 → 0.2.2

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
@@ -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;
@@ -646,7 +644,7 @@ var AO = /*#__PURE__*/function () {
646
644
  _context9.next = 10;
647
645
  break;
648
646
  }
649
- if (_this3.local) {
647
+ if (_this3.in_memory) {
650
648
  _context9.next = 6;
651
649
  break;
652
650
  }
@@ -665,7 +663,7 @@ var AO = /*#__PURE__*/function () {
665
663
  }
666
664
  return _context9.abrupt("return", txs);
667
665
  case 12:
668
- if (!_this3.local) {
666
+ if (!_this3.in_memory) {
669
667
  _context9.next = 15;
670
668
  break;
671
669
  }
package/cjs/aoconnect.js CHANGED
@@ -118,10 +118,20 @@ var connect = exports.connect = function connect() {
118
118
  "Do_Uc2Sju_ffp6Ev0AnLVdPtot15rvMjP-a9VVaA5fM": {
119
119
  file: "aos2_0_1",
120
120
  format: "wasm64-unknown-emscripten-draft_2024_02_15"
121
+ },
122
+ cNlipBptaF9JeFAf4wUmpi43EojNanIBos3EfNrEOWo: {
123
+ file: "aos_1",
124
+ format: "wasm64-unknown-emscripten-draft_2024_02_15"
125
+ },
126
+ ghSkge2sIUD_F00ym5sEimC63BDBuBrq4b5OcwxOjiw: {
127
+ file: "sqlite",
128
+ format: "wasm64-unknown-emscripten-draft_2024_02_15"
121
129
  }
122
130
  };
123
131
  var modules = {
124
- aos_2_0_1: "Do_Uc2Sju_ffp6Ev0AnLVdPtot15rvMjP-a9VVaA5fM"
132
+ aos_2_0_1: "Do_Uc2Sju_ffp6Ev0AnLVdPtot15rvMjP-a9VVaA5fM",
133
+ aos_1: "cNlipBptaF9JeFAf4wUmpi43EojNanIBos3EfNrEOWo",
134
+ sqlite: "ghSkge2sIUD_F00ym5sEimC63BDBuBrq4b5OcwxOjiw"
125
135
  };
126
136
  var modmap = {};
127
137
  var env = {
@@ -402,6 +412,7 @@ var connect = exports.connect = function connect() {
402
412
  };
403
413
  }();
404
414
  return {
415
+ scheduler: "GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA",
405
416
  modules: modules,
406
417
  accounts: _accounts["default"].users,
407
418
  message: _message,
@@ -459,33 +470,45 @@ var connect = exports.connect = function connect() {
459
470
  while (1) switch (_context6.prev = _context6.next) {
460
471
  case 0:
461
472
  opt = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
473
+ if (opt.module) {
474
+ _context6.next = 3;
475
+ break;
476
+ }
477
+ throw Error("module.missing");
478
+ case 3:
479
+ if (opt.scheduler) {
480
+ _context6.next = 5;
481
+ break;
482
+ }
483
+ throw Error("scheduler.missing");
484
+ case 5:
462
485
  mod = (_opt$module = opt.module) !== null && _opt$module !== void 0 ? _opt$module : modules["aos_2_0_1"];
463
486
  if (!(!modmap[mod] && wasms[mod])) {
464
- _context6.next = 11;
487
+ _context6.next = 15;
465
488
  break;
466
489
  }
467
- _context6.next = 5;
490
+ _context6.next = 9;
468
491
  return dirname();
469
- case 5:
492
+ case 9:
470
493
  _dirname = _context6.sent;
471
494
  wasm = (0, _fs.readFileSync)((0, _path.resolve)(_dirname, "lua/".concat(wasms[mod].file, ".wasm")));
472
- _context6.next = 9;
495
+ _context6.next = 13;
473
496
  return (0, _aoLoader["default"])(wasm, {
474
497
  format: wasms[mod].format
475
498
  });
476
- case 9:
499
+ case 13:
477
500
  handle = _context6.sent;
478
501
  modmap[mod] = {
479
502
  handle: handle,
480
503
  id: mod
481
504
  };
482
- case 11:
505
+ case 15:
483
506
  if (mod) {
484
- _context6.next = 13;
507
+ _context6.next = 17;
485
508
  break;
486
509
  }
487
510
  throw Error("module not found");
488
- case 13:
511
+ case 17:
489
512
  _module = modmap[mod];
490
513
  ex = false;
491
514
  (_opt$tags = opt.tags) !== null && _opt$tags !== void 0 ? _opt$tags : opt.tags = [];
@@ -504,9 +527,9 @@ var connect = exports.connect = function connect() {
504
527
  name: "Type",
505
528
  value: "Process"
506
529
  });
507
- _context6.next = 21;
530
+ _context6.next = 25;
508
531
  return parse(opt);
509
- case 21:
532
+ case 25:
510
533
  _yield$parse3 = _context6.sent;
511
534
  id = _yield$parse3.id;
512
535
  owner = _yield$parse3.owner;
@@ -525,7 +548,7 @@ var connect = exports.connect = function connect() {
525
548
  txs: []
526
549
  };
527
550
  return _context6.abrupt("return", id);
528
- case 27:
551
+ case 31:
529
552
  case "end":
530
553
  return _context6.stop();
531
554
  }
package/cjs/helpers.js CHANGED
@@ -270,7 +270,7 @@ var setup = exports.setup = /*#__PURE__*/function () {
270
270
  auth = _context3.sent.address;
271
271
  case 43:
272
272
  _context3.next = 45;
273
- return src.upload("aos-sqlite", "wasm");
273
+ return src.upload("sqlite", "wasm");
274
274
  case 45:
275
275
  wasm = _context3.sent;
276
276
  _context3.next = 48;
Binary file
Binary file
package/cjs/tao.js CHANGED
@@ -6,12 +6,16 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports["default"] = void 0;
8
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");
9
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
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; }
11
- 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); }
12
- 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
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); }
14
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; }
15
19
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
16
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); } }
17
21
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
@@ -26,44 +30,49 @@ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new T
26
30
  function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
27
31
  var AO = /*#__PURE__*/function (_MAO) {
28
32
  function AO() {
33
+ var _this;
34
+ var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
29
35
  _classCallCheck(this, AO);
30
- return _callSuper(this, AO, arguments);
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;
31
60
  }
32
61
  _inherits(AO, _MAO);
33
62
  return _createClass(AO, [{
34
63
  key: "init",
35
64
  value: function () {
36
65
  var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(jwk) {
37
- var _jwk, v, _v$connect, accounts, modules, results, assign, result, message, spawn, dryrun, txs;
66
+ var _this$accounts;
38
67
  return _regeneratorRuntime().wrap(function _callee$(_context) {
39
68
  while (1) switch (_context.prev = _context.next) {
40
69
  case 0:
41
- if (!this.in_memory) {
42
- _context.next = 14;
43
- break;
44
- }
70
+ if (!jwk && (_this$accounts = this.accounts) !== null && _this$accounts !== void 0 && _this$accounts[0]) jwk = this.accounts[0].jwk;
45
71
  _context.next = 3;
46
- return Promise.resolve().then(function () {
47
- return _interopRequireWildcard(require("./aoconnect.js"));
48
- });
49
- case 3:
50
- v = _context.sent;
51
- _v$connect = v.connect(), accounts = _v$connect.accounts, modules = _v$connect.modules, results = _v$connect.results, assign = _v$connect.assign, result = _v$connect.result, message = _v$connect.message, spawn = _v$connect.spawn, dryrun = _v$connect.dryrun, txs = _v$connect.txs;
52
- this.module = modules.aos_2_0_1;
53
- this.assign = assign;
54
- this.result = result;
55
- this.results = results;
56
- this.message = message;
57
- this.spawn = spawn;
58
- this.dryrun = dryrun;
59
- this.ar.txs = txs;
60
- (_jwk = jwk) !== null && _jwk !== void 0 ? _jwk : jwk = accounts[0].jwk;
61
- case 14:
62
- _context.next = 16;
63
72
  return this.ar.init(jwk);
64
- case 16:
73
+ case 3:
65
74
  return _context.abrupt("return", this);
66
- case 17:
75
+ case 4:
67
76
  case "end":
68
77
  return _context.stop();
69
78
  }
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
@@ -371,12 +368,12 @@ class AO {
371
368
  const getRef = async (ref, txs = []) => {
372
369
  let ex = exRef(ref, txs)
373
370
  if (!ex) {
374
- if (!this.local) await wait(1000)
371
+ if (!this.in_memory) await wait(1000)
375
372
  txs = await this.ar.txs(pid)
376
373
  ex = exRef(ref, txs)
377
374
  }
378
375
  if (ex) return txs
379
- if (this.local) await wait(1)
376
+ if (this.in_memory) await wait(1)
380
377
  return Date.now() - start < (this.local ? timeout / 1000 : timeout)
381
378
  ? await getRef(ref)
382
379
  : []
package/esm/aoconnect.js CHANGED
@@ -55,9 +55,19 @@ export const connect = () => {
55
55
  file: "aos2_0_1",
56
56
  format: "wasm64-unknown-emscripten-draft_2024_02_15",
57
57
  },
58
+ cNlipBptaF9JeFAf4wUmpi43EojNanIBos3EfNrEOWo: {
59
+ file: "aos_1",
60
+ format: "wasm64-unknown-emscripten-draft_2024_02_15",
61
+ },
62
+ ghSkge2sIUD_F00ym5sEimC63BDBuBrq4b5OcwxOjiw: {
63
+ file: "sqlite",
64
+ format: "wasm64-unknown-emscripten-draft_2024_02_15",
65
+ },
58
66
  }
59
67
  let modules = {
60
68
  aos_2_0_1: "Do_Uc2Sju_ffp6Ev0AnLVdPtot15rvMjP-a9VVaA5fM",
69
+ aos_1: "cNlipBptaF9JeFAf4wUmpi43EojNanIBos3EfNrEOWo",
70
+ sqlite: "ghSkge2sIUD_F00ym5sEimC63BDBuBrq4b5OcwxOjiw",
61
71
  }
62
72
  let modmap = {}
63
73
  let env = { msgs: {} }
@@ -196,6 +206,7 @@ export const connect = () => {
196
206
  }
197
207
 
198
208
  return {
209
+ scheduler: "GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA",
199
210
  modules,
200
211
  accounts: accounts.users,
201
212
  message,
@@ -205,6 +216,8 @@ export const connect = () => {
205
216
  return _txs
206
217
  },
207
218
  spawn: async (opt = {}) => {
219
+ if (!opt.module) throw Error("module.missing")
220
+ if (!opt.scheduler) throw Error("scheduler.missing")
208
221
  let mod = opt.module ?? modules["aos_2_0_1"]
209
222
  if (!modmap[mod] && wasms[mod]) {
210
223
  const __dirname = await dirname()
package/esm/helpers.js CHANGED
@@ -87,7 +87,7 @@ export const setup = async ({
87
87
  }
88
88
 
89
89
  // ao
90
- const wasm = await src.upload("aos-sqlite", "wasm")
90
+ const wasm = await src.upload("sqlite", "wasm")
91
91
  const wasm2 = await src.upload("aos", "wasm")
92
92
  const wasm_aos2 = await src.upload("aos2_0_1", "wasm")
93
93
 
Binary file
Binary file
package/esm/tao.js CHANGED
@@ -1,30 +1,36 @@
1
1
  import MAO from "./ao.js"
2
+ import { srcs } from "./utils.js"
3
+ import AR from "./ar.js"
4
+ import { connect } from "./aoconnect.js"
2
5
 
3
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
+
4
32
  async init(jwk) {
5
- if (this.in_memory) {
6
- const v = await import("./aoconnect.js")
7
- const {
8
- accounts,
9
- modules,
10
- results,
11
- assign,
12
- result,
13
- message,
14
- spawn,
15
- dryrun,
16
- txs,
17
- } = v.connect()
18
- this.module = modules.aos_2_0_1
19
- this.assign = assign
20
- this.result = result
21
- this.results = results
22
- this.message = message
23
- this.spawn = spawn
24
- this.dryrun = dryrun
25
- this.ar.txs = txs
26
- jwk ??= accounts[0].jwk
27
- }
33
+ if (!jwk && this.accounts?.[0]) jwk = this.accounts[0].jwk
28
34
  await this.ar.init(jwk)
29
35
  return this
30
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",