wao 0.6.0 → 0.6.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
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var WarpArBundles = _interopRequireWildcard(require("warp-arbundles"));
8
- var _ar2 = _interopRequireDefault(require("./ar.js"));
8
+ var _ar3 = _interopRequireDefault(require("./ar.js"));
9
9
  var _aoconnect = require("@permaweb/aoconnect");
10
10
  var _ramda = require("ramda");
11
11
  var _utils = require("./utils.js");
@@ -81,20 +81,32 @@ function createDataItemSigner2(wallet) {
81
81
  }
82
82
  var AO = /*#__PURE__*/function () {
83
83
  function AO() {
84
- var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
85
- _ref4$authority = _ref4.authority,
86
- authority = _ref4$authority === void 0 ? _utils.srcs.authority : _ref4$authority,
87
- module = _ref4.module,
88
- _ref4$module_type = _ref4.module_type,
89
- module_type = _ref4$module_type === void 0 ? "aos2" : _ref4$module_type,
90
- _ref4$scheduler = _ref4.scheduler,
91
- scheduler = _ref4$scheduler === void 0 ? _utils.srcs.scheduler : _ref4$scheduler,
92
- aoconnect = _ref4.aoconnect,
93
- _ref4$ar = _ref4.ar,
94
- ar = _ref4$ar === void 0 ? {} : _ref4$ar,
95
- _ref4$in_memory = _ref4.in_memory,
96
- in_memory = _ref4$in_memory === void 0 ? false : _ref4$in_memory;
84
+ var _ar2;
85
+ var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
97
86
  _classCallCheck(this, AO);
87
+ var _port = null;
88
+ if (typeof opt === "number") {
89
+ _port = opt;
90
+ opt = {};
91
+ }
92
+ var _opt = opt,
93
+ _opt$authority = _opt.authority,
94
+ authority = _opt$authority === void 0 ? _utils.srcs.authority : _opt$authority,
95
+ module = _opt.module,
96
+ _opt$module_type = _opt.module_type,
97
+ module_type = _opt$module_type === void 0 ? "aos2" : _opt$module_type,
98
+ _opt$scheduler = _opt.scheduler,
99
+ scheduler = _opt$scheduler === void 0 ? _utils.srcs.scheduler : _opt$scheduler,
100
+ aoconnect = _opt.aoconnect,
101
+ ar = _opt.ar,
102
+ _opt$in_memory = _opt.in_memory,
103
+ in_memory = _opt$in_memory === void 0 ? false : _opt$in_memory,
104
+ port = _opt.port;
105
+ if (!_port && port) _port = port;
106
+ if (!aoconnect && _port) aoconnect = (0, _utils.optAO)(_port);
107
+ if (!ar && _port) ar = {
108
+ port: _port
109
+ };
98
110
  if (!module) {
99
111
  switch (module_type) {
100
112
  case "sqlite":
@@ -108,11 +120,11 @@ var AO = /*#__PURE__*/function () {
108
120
  }
109
121
  }
110
122
  this.__type__ = "ao";
111
- if ((ar === null || ar === void 0 ? void 0 : ar.__type__) === "ar") this.ar = ar;else {
123
+ if (((_ar2 = ar) === null || _ar2 === void 0 ? void 0 : _ar2.__type__) === "ar") this.ar = ar;else {
112
124
  var _ar = _typeof(ar) === "object" ? ar : {};
113
- this.ar = new _ar2["default"](ar);
125
+ this.ar = new _ar3["default"](_ar);
114
126
  }
115
- if (in_memory) {} else if (aoconnect) {
127
+ if (!in_memory && aoconnect) {
116
128
  var _connect = (0, _aoconnect.connect)(aoconnect),
117
129
  _results = _connect.results,
118
130
  _assign = _connect.assign,
@@ -180,30 +192,30 @@ var AO = /*#__PURE__*/function () {
180
192
  }, {
181
193
  key: "pipe",
182
194
  value: function () {
183
- var _pipe = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref5) {
195
+ var _pipe = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref4) {
184
196
  var _fns$0$args, _ret2;
185
- 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;
197
+ var jwk, _ref4$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;
186
198
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
187
199
  while (1) switch (_context4.prev = _context4.next) {
188
200
  case 0:
189
- jwk = _ref5.jwk, _ref5$fns = _ref5.fns, fns = _ref5$fns === void 0 ? [] : _ref5$fns, cb = _ref5.cb;
201
+ jwk = _ref4.jwk, _ref4$fns = _ref4.fns, fns = _ref4$fns === void 0 ? [] : _ref4$fns, cb = _ref4.cb;
190
202
  _ = {}, out = {}, res = [], i = 0;
191
203
  nextArgs = (_fns$0$args = fns[0].args) !== null && _fns$0$args !== void 0 ? _fns$0$args : {};
192
204
  ret = null, err = null, pid = null, mid = null, id = null;
193
205
  if (!jwk) fns.unshift({
194
206
  fn: "checkWallet"
195
207
  });
196
- copy = function copy(_ref6) {
208
+ copy = function copy(_ref5) {
197
209
  var _args$_from$slice$joi, _out$_from$slice$join, _inp$_from$slice$join, _inp$from;
198
- var _ = _ref6._,
199
- inp = _ref6.inp,
200
- out = _ref6.out,
201
- args = _ref6.args,
202
- from = _ref6.from,
203
- to = _ref6.to,
204
- pid = _ref6.pid,
205
- mid = _ref6.mid,
206
- id = _ref6.id;
210
+ var _ = _ref5._,
211
+ inp = _ref5.inp,
212
+ out = _ref5.out,
213
+ args = _ref5.args,
214
+ from = _ref5.from,
215
+ to = _ref5.to,
216
+ pid = _ref5.pid,
217
+ mid = _ref5.mid,
218
+ id = _ref5.id;
207
219
  var _from = from.split(".");
208
220
  var _to = to.split(".");
209
221
  var field = null,
@@ -392,13 +404,13 @@ var AO = /*#__PURE__*/function () {
392
404
  }, {
393
405
  key: "postModule",
394
406
  value: function () {
395
- var _postModule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref7) {
407
+ var _postModule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref6) {
396
408
  var _this = this;
397
- var data, jwk, _ref7$tags, tags, _ref7$overwrite, overwrite, _tags, fns;
409
+ var data, jwk, _ref6$tags, tags, _ref6$overwrite, overwrite, _tags, fns;
398
410
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
399
411
  while (1) switch (_context5.prev = _context5.next) {
400
412
  case 0:
401
- 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;
413
+ data = _ref6.data, jwk = _ref6.jwk, _ref6$tags = _ref6.tags, tags = _ref6$tags === void 0 ? {} : _ref6$tags, _ref6$overwrite = _ref6.overwrite, overwrite = _ref6$overwrite === void 0 ? false : _ref6$overwrite;
402
414
  _tags = (0, _ramda.mergeLeft)(tags, {
403
415
  "Data-Protocol": "ao",
404
416
  Variant: "ao.TN.1",
@@ -416,8 +428,8 @@ var AO = /*#__PURE__*/function () {
416
428
  data: data,
417
429
  tags: _tags
418
430
  },
419
- then: function then(_ref8) {
420
- var id = _ref8.id;
431
+ then: function then(_ref7) {
432
+ var id = _ref7.id;
421
433
  if (!_this.module || overwrite) _this.module = id;
422
434
  }
423
435
  }];
@@ -442,13 +454,13 @@ var AO = /*#__PURE__*/function () {
442
454
  }, {
443
455
  key: "postScheduler",
444
456
  value: function () {
445
- var _postScheduler = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref9) {
457
+ var _postScheduler = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref8) {
446
458
  var _this2 = this;
447
- var jwk, url, _ref9$tags, tags, _ref9$overwrite, overwrite, _tags, then, fns;
459
+ var jwk, url, _ref8$tags, tags, _ref8$overwrite, overwrite, _tags, then, fns;
448
460
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
449
461
  while (1) switch (_context7.prev = _context7.next) {
450
462
  case 0:
451
- 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;
463
+ jwk = _ref8.jwk, url = _ref8.url, _ref8$tags = _ref8.tags, tags = _ref8$tags === void 0 ? {} : _ref8$tags, _ref8$overwrite = _ref8.overwrite, overwrite = _ref8$overwrite === void 0 ? false : _ref8$overwrite;
452
464
  _tags = (0, _ramda.mergeLeft)(tags, {
453
465
  "Data-Protocol": "ao",
454
466
  Variant: "ao.TN.1",
@@ -457,12 +469,12 @@ var AO = /*#__PURE__*/function () {
457
469
  "Time-To-Live": "3600000"
458
470
  });
459
471
  then = /*#__PURE__*/function () {
460
- var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref10) {
472
+ var _ref10 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref9) {
461
473
  var jwk, out, _;
462
474
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
463
475
  while (1) switch (_context6.prev = _context6.next) {
464
476
  case 0:
465
- jwk = _ref10.jwk, out = _ref10.out, _ = _ref10._;
477
+ jwk = _ref9.jwk, out = _ref9.out, _ = _ref9._;
466
478
  _context6.next = 3;
467
479
  return _this2.ar.toAddr(jwk);
468
480
  case 3:
@@ -475,7 +487,7 @@ var AO = /*#__PURE__*/function () {
475
487
  }, _callee6);
476
488
  }));
477
489
  return function then(_x6) {
478
- return _ref11.apply(this, arguments);
490
+ return _ref10.apply(this, arguments);
479
491
  };
480
492
  }();
481
493
  fns = [{
@@ -507,14 +519,14 @@ var AO = /*#__PURE__*/function () {
507
519
  key: "spwn",
508
520
  value: function () {
509
521
  var _spwn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
510
- var _ref12,
522
+ var _ref11,
511
523
  boot,
512
- _ref12$module,
524
+ _ref11$module,
513
525
  module,
514
- _ref12$scheduler,
526
+ _ref11$scheduler,
515
527
  scheduler,
516
528
  jwk,
517
- _ref12$tags,
529
+ _ref11$tags,
518
530
  tags,
519
531
  data,
520
532
  auth,
@@ -526,7 +538,7 @@ var AO = /*#__PURE__*/function () {
526
538
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
527
539
  while (1) switch (_context8.prev = _context8.next) {
528
540
  case 0:
529
- _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;
541
+ _ref11 = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {}, boot = _ref11.boot, _ref11$module = _ref11.module, module = _ref11$module === void 0 ? this.module : _ref11$module, _ref11$scheduler = _ref11.scheduler, scheduler = _ref11$scheduler === void 0 ? this.scheduler : _ref11$scheduler, jwk = _ref11.jwk, _ref11$tags = _ref11.tags, tags = _ref11$tags === void 0 ? {} : _ref11$tags, data = _ref11.data, auth = _ref11.auth;
530
542
  err = null;
531
543
  _context8.next = 4;
532
544
  return this.ar.checkWallet({
@@ -586,13 +598,13 @@ var AO = /*#__PURE__*/function () {
586
598
  }, {
587
599
  key: "msg",
588
600
  value: function () {
589
- var _msg = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(_ref13) {
601
+ var _msg = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(_ref12) {
590
602
  var _this3 = this;
591
- 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;
603
+ var pid, jwk, data, _ref12$act, act, _ref12$tags, tags, _ref12$check, check, get, _ref12$timeout, timeout, err, _yield$this$ar$checkW2, res, out, mid, results, _tags, start, exRef, _getRef, cache, checks, isOK, _getResult, _yield$_getResult2;
592
604
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
593
605
  while (1) switch (_context11.prev = _context11.next) {
594
606
  case 0:
595
- 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;
607
+ pid = _ref12.pid, jwk = _ref12.jwk, data = _ref12.data, _ref12$act = _ref12.act, act = _ref12$act === void 0 ? "Eval" : _ref12$act, _ref12$tags = _ref12.tags, tags = _ref12$tags === void 0 ? {} : _ref12$tags, _ref12$check = _ref12.check, check = _ref12$check === void 0 ? [] : _ref12$check, get = _ref12.get, _ref12$timeout = _ref12.timeout, timeout = _ref12$timeout === void 0 ? 10000 : _ref12$timeout;
596
608
  err = null;
597
609
  _context11.next = 4;
598
610
  return this.ar.checkWallet({
@@ -640,7 +652,7 @@ var AO = /*#__PURE__*/function () {
640
652
  return false;
641
653
  };
642
654
  _getRef = /*#__PURE__*/function () {
643
- var _ref14 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(ref) {
655
+ var _ref13 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(ref) {
644
656
  var txs,
645
657
  ex,
646
658
  _args9 = arguments;
@@ -705,12 +717,12 @@ var AO = /*#__PURE__*/function () {
705
717
  }, _callee9);
706
718
  }));
707
719
  return function getRef(_x8) {
708
- return _ref14.apply(this, arguments);
720
+ return _ref13.apply(this, arguments);
709
721
  };
710
722
  }();
711
723
  cache = [], checks = [], isOK = false;
712
724
  _getResult = /*#__PURE__*/function () {
713
- var _ref15 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(mid) {
725
+ var _ref14 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(mid) {
714
726
  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;
715
727
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
716
728
  while (1) switch (_context10.prev = _context10.next) {
@@ -876,7 +888,7 @@ var AO = /*#__PURE__*/function () {
876
888
  }, _callee10, null, [[11, 57, 60, 63], [22, 45, 48, 51]]);
877
889
  }));
878
890
  return function getResult(_x9) {
879
- return _ref15.apply(this, arguments);
891
+ return _ref14.apply(this, arguments);
880
892
  };
881
893
  }();
882
894
  _context11.next = 22;
@@ -914,12 +926,12 @@ var AO = /*#__PURE__*/function () {
914
926
  }, {
915
927
  key: "asgn",
916
928
  value: function () {
917
- var _asgn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(_ref16) {
929
+ var _asgn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(_ref15) {
918
930
  var pid, mid, jwk, check, get, err, _yield$this$ar$checkW3, res, out, checks, i, _iterator7, _step7, _checks$i2, v, _checks, checks2, k;
919
931
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
920
932
  while (1) switch (_context12.prev = _context12.next) {
921
933
  case 0:
922
- pid = _ref16.pid, mid = _ref16.mid, jwk = _ref16.jwk, check = _ref16.check, get = _ref16.get;
934
+ pid = _ref15.pid, mid = _ref15.mid, jwk = _ref15.jwk, check = _ref15.check, get = _ref15.get;
923
935
  err = null;
924
936
  _context12.next = 4;
925
937
  return this.ar.checkWallet({
@@ -1011,12 +1023,12 @@ var AO = /*#__PURE__*/function () {
1011
1023
  }, {
1012
1024
  key: "dry",
1013
1025
  value: function () {
1014
- var _dry = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(_ref17) {
1015
- 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
+ var _dry = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(_ref16) {
1027
+ var pid, jwk, data, _ref16$act, act, _ref16$tags, tags, check, get, _ref16$timeout, timeout, err, _yield$this$ar$checkW4, res, out, _tags, _res, checks, i, _iterator8, _step8, _checks$i3, v, _checks, checks2, k;
1016
1028
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1017
1029
  while (1) switch (_context13.prev = _context13.next) {
1018
1030
  case 0:
1019
- 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;
1031
+ pid = _ref16.pid, jwk = _ref16.jwk, data = _ref16.data, _ref16$act = _ref16.act, act = _ref16$act === void 0 ? "Eval" : _ref16$act, _ref16$tags = _ref16.tags, tags = _ref16$tags === void 0 ? {} : _ref16$tags, check = _ref16.check, get = _ref16.get, _ref16$timeout = _ref16.timeout, timeout = _ref16$timeout === void 0 ? 10000 : _ref16$timeout;
1020
1032
  err = null;
1021
1033
  _context13.next = 4;
1022
1034
  return this.ar.checkWallet({
@@ -1100,21 +1112,21 @@ var AO = /*#__PURE__*/function () {
1100
1112
  }, {
1101
1113
  key: "eval",
1102
1114
  value: function () {
1103
- var _eval2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(_ref18) {
1115
+ var _eval2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(_ref17) {
1104
1116
  var pid, jwk, data, fns;
1105
1117
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1106
1118
  while (1) switch (_context14.prev = _context14.next) {
1107
1119
  case 0:
1108
- pid = _ref18.pid, jwk = _ref18.jwk, data = _ref18.data;
1120
+ pid = _ref17.pid, jwk = _ref17.jwk, data = _ref17.data;
1109
1121
  fns = [{
1110
1122
  args: {
1111
1123
  pid: pid,
1112
1124
  data: data,
1113
1125
  act: "Eval"
1114
1126
  },
1115
- err: function err(_ref19) {
1127
+ err: function err(_ref18) {
1116
1128
  var _res$Output, _res$Output2, _res$Output3;
1117
- var res = _ref19.res;
1129
+ var res = _ref18.res;
1118
1130
  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));
1119
1131
  }
1120
1132
  }];
@@ -1139,12 +1151,12 @@ var AO = /*#__PURE__*/function () {
1139
1151
  }, {
1140
1152
  key: "transform",
1141
1153
  value: function () {
1142
- var _transform = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(_ref20) {
1154
+ var _transform = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(_ref19) {
1143
1155
  var src, data, fills, err, out, _data, k, text;
1144
1156
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1145
1157
  while (1) switch (_context15.prev = _context15.next) {
1146
1158
  case 0:
1147
- src = _ref20.src, data = _ref20.data, fills = _ref20.fills;
1159
+ src = _ref19.src, data = _ref19.data, fills = _ref19.fills;
1148
1160
  err = null, out = null;
1149
1161
  if (!(data !== null && data !== void 0)) {
1150
1162
  _context15.next = 6;
@@ -1186,12 +1198,12 @@ var AO = /*#__PURE__*/function () {
1186
1198
  }, {
1187
1199
  key: "load",
1188
1200
  value: function () {
1189
- var _load = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(_ref21) {
1201
+ var _load = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(_ref20) {
1190
1202
  var src, data, fills, pid, jwk, fns;
1191
1203
  return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1192
1204
  while (1) switch (_context16.prev = _context16.next) {
1193
1205
  case 0:
1194
- src = _ref21.src, data = _ref21.data, fills = _ref21.fills, pid = _ref21.pid, jwk = _ref21.jwk;
1206
+ src = _ref20.src, data = _ref20.data, fills = _ref20.fills, pid = _ref20.pid, jwk = _ref20.jwk;
1195
1207
  fns = [{
1196
1208
  fn: this.transform,
1197
1209
  args: {
@@ -1229,17 +1241,17 @@ var AO = /*#__PURE__*/function () {
1229
1241
  }, {
1230
1242
  key: "wait",
1231
1243
  value: function () {
1232
- var _wait2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref22) {
1233
- var pid, _ref22$attempts, attempts, exist, err, _yield$this$dry, res, _err;
1244
+ var _wait2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref21) {
1245
+ var pid, _ref21$attempts, attempts, exist, err, _yield$this$dry, res, _err;
1234
1246
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1235
1247
  while (1) switch (_context17.prev = _context17.next) {
1236
1248
  case 0:
1237
- pid = _ref22.pid, _ref22$attempts = _ref22.attempts, attempts = _ref22$attempts === void 0 ? 5 : _ref22$attempts;
1249
+ pid = _ref21.pid, _ref21$attempts = _ref21.attempts, attempts = _ref21$attempts === void 0 ? 5 : _ref21$attempts;
1238
1250
  exist = false;
1239
1251
  err = null;
1240
1252
  case 3:
1241
1253
  if (!(attempts > 0)) {
1242
- _context17.next = 18;
1254
+ _context17.next = 20;
1243
1255
  break;
1244
1256
  }
1245
1257
  if (this.in_memory) {
@@ -1258,22 +1270,31 @@ var AO = /*#__PURE__*/function () {
1258
1270
  _yield$this$dry = _context17.sent;
1259
1271
  res = _yield$this$dry.res;
1260
1272
  _err = _yield$this$dry.err;
1261
- if (!(_typeof(res === null || res === void 0 ? void 0 : res.Output) === "object")) {
1273
+ if (!(res !== null && res !== void 0 && res.error)) {
1262
1274
  _context17.next = 14;
1263
1275
  break;
1264
1276
  }
1265
- return _context17.abrupt("break", 18);
1277
+ return _context17.abrupt("return", {
1278
+ err: res.error,
1279
+ pid: pid
1280
+ });
1266
1281
  case 14:
1282
+ if (!(_typeof(res === null || res === void 0 ? void 0 : res.Output) === "object")) {
1283
+ _context17.next = 16;
1284
+ break;
1285
+ }
1286
+ return _context17.abrupt("break", 20);
1287
+ case 16:
1267
1288
  attempts -= 1;
1268
1289
  if (attempts === 0) err = "timeout";
1269
1290
  _context17.next = 3;
1270
1291
  break;
1271
- case 18:
1292
+ case 20:
1272
1293
  return _context17.abrupt("return", {
1273
1294
  err: err,
1274
1295
  pid: pid
1275
1296
  });
1276
- case 19:
1297
+ case 21:
1277
1298
  case "end":
1278
1299
  return _context17.stop();
1279
1300
  }
@@ -1287,12 +1308,12 @@ var AO = /*#__PURE__*/function () {
1287
1308
  }, {
1288
1309
  key: "attest",
1289
1310
  value: function () {
1290
- var _attest = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_ref23) {
1311
+ var _attest = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_ref22) {
1291
1312
  var id, jwk, tags;
1292
1313
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1293
1314
  while (1) switch (_context18.prev = _context18.next) {
1294
1315
  case 0:
1295
- id = _ref23.id, jwk = _ref23.jwk, tags = _ref23.tags;
1316
+ id = _ref22.id, jwk = _ref22.jwk, tags = _ref22.tags;
1296
1317
  _context18.next = 3;
1297
1318
  return this.ar.post({
1298
1319
  tags: (0, _ramda.mergeLeft)(tags, {
@@ -1318,12 +1339,12 @@ var AO = /*#__PURE__*/function () {
1318
1339
  }, {
1319
1340
  key: "avail",
1320
1341
  value: function () {
1321
- var _avail = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(_ref24) {
1342
+ var _avail = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(_ref23) {
1322
1343
  var ids, jwk, tags;
1323
1344
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1324
1345
  while (1) switch (_context19.prev = _context19.next) {
1325
1346
  case 0:
1326
- ids = _ref24.ids, jwk = _ref24.jwk, tags = _ref24.tags;
1347
+ ids = _ref23.ids, jwk = _ref23.jwk, tags = _ref23.tags;
1327
1348
  _context19.next = 3;
1328
1349
  return this.ar.post({
1329
1350
  tags: (0, _ramda.mergeLeft)(tags, {
@@ -1350,12 +1371,12 @@ var AO = /*#__PURE__*/function () {
1350
1371
  }, {
1351
1372
  key: "deploy",
1352
1373
  value: function () {
1353
- var _deploy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20(_ref25) {
1354
- var boot, loads, src, src_data, _ref25$fills, fills, _ref25$module, module, _ref25$scheduler, scheduler, jwk, _ref25$tags, tags, data, fns, isBoot, i, _iterator9, _step9, v, args, result;
1374
+ var _deploy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20(_ref24) {
1375
+ var boot, loads, src, src_data, _ref24$fills, fills, _ref24$module, module, _ref24$scheduler, scheduler, jwk, _ref24$tags, tags, data, fns, isBoot, i, _iterator9, _step9, v, args, result;
1355
1376
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1356
1377
  while (1) switch (_context20.prev = _context20.next) {
1357
1378
  case 0:
1358
- boot = _ref25.boot, loads = _ref25.loads, src = _ref25.src, src_data = _ref25.src_data, _ref25$fills = _ref25.fills, fills = _ref25$fills === void 0 ? {} : _ref25$fills, _ref25$module = _ref25.module, module = _ref25$module === void 0 ? this.module : _ref25$module, _ref25$scheduler = _ref25.scheduler, scheduler = _ref25$scheduler === void 0 ? this.scheduler : _ref25$scheduler, jwk = _ref25.jwk, _ref25$tags = _ref25.tags, tags = _ref25$tags === void 0 ? {} : _ref25$tags, data = _ref25.data;
1379
+ boot = _ref24.boot, loads = _ref24.loads, src = _ref24.src, src_data = _ref24.src_data, _ref24$fills = _ref24.fills, fills = _ref24$fills === void 0 ? {} : _ref24$fills, _ref24$module = _ref24.module, module = _ref24$module === void 0 ? this.module : _ref24$module, _ref24$scheduler = _ref24.scheduler, scheduler = _ref24$scheduler === void 0 ? this.scheduler : _ref24$scheduler, jwk = _ref24.jwk, _ref24$tags = _ref24.tags, tags = _ref24$tags === void 0 ? {} : _ref24$tags, data = _ref24.data;
1359
1380
  fns = [], isBoot = false;
1360
1381
  if (boot === true && !data) {
1361
1382
  isBoot = true;
package/cjs/aoconnect.js CHANGED
@@ -11,6 +11,7 @@ var _base64url = _interopRequireDefault(require("base64url"));
11
11
  var _utils = require("./utils.js");
12
12
  var _armem = _interopRequireDefault(require("./armem.js"));
13
13
  var _weavedrive = _interopRequireDefault(require("./weavedrive.js"));
14
+ var _kv = _interopRequireDefault(require("./kv.js"));
14
15
  var _aoLoader = _interopRequireDefault(require("@permaweb/ao-loader"));
15
16
  var _fs = require("fs");
16
17
  var _path = require("path");
@@ -56,6 +57,7 @@ var connect = exports.connect = function connect(mem) {
56
57
  log: log
57
58
  });
58
59
  var WeaveDrive = new _weavedrive["default"](ar).drive;
60
+ var KV = new _kv["default"](ar).kv;
59
61
  var transform = function transform(input) {
60
62
  var _input$Tags;
61
63
  var output = {
@@ -162,6 +164,8 @@ var connect = exports.connect = function connect(mem) {
162
164
  item,
163
165
  __tags,
164
166
  now,
167
+ t,
168
+ wd,
165
169
  handle,
166
170
  _tags,
167
171
  res,
@@ -269,15 +273,17 @@ var connect = exports.connect = function connect(mem) {
269
273
  return ar.postItems(item, _test.su.jwk);
270
274
  case 33:
271
275
  now = Date.now;
272
- _context.next = 36;
276
+ t = (0, _utils.tags)(opt.tags);
277
+ wd = t.Extension === "KV" ? KV : WeaveDrive;
278
+ _context.next = 38;
273
279
  return (0, _aoLoader["default"])(wasm, {
274
280
  format: format,
275
- WeaveDrive: WeaveDrive,
281
+ WeaveDrive: wd,
276
282
  spawn: item,
277
283
  module: mem.txs[mod],
278
284
  blockHeight: "100"
279
285
  });
280
- case 36:
286
+ case 38:
281
287
  handle = _context.sent;
282
288
  _module = {
283
289
  handle: handle,
@@ -302,7 +308,7 @@ var connect = exports.connect = function connect(mem) {
302
308
  opt: opt
303
309
  };
304
310
  if (!(_tags["On-Boot"] || true)) {
305
- _context.next = 57;
311
+ _context.next = 59;
306
312
  break;
307
313
  }
308
314
  data = "";
@@ -315,51 +321,51 @@ var connect = exports.connect = function connect(mem) {
315
321
  auth: _test.mu.addr
316
322
  });
317
323
  _t = (0, _utils.tags)(msg.Tags);
318
- _context.next = 51;
324
+ _context.next = 53;
319
325
  return _module.handle(null, msg, _env);
320
- case 51:
326
+ case 53:
321
327
  res = _context.sent;
322
328
  p.memory = res.Memory;
323
329
  delete res.Memory;
324
330
  p.res[id] = res;
325
- _context.next = 58;
331
+ _context.next = 60;
326
332
  break;
327
- case 57:
333
+ case 59:
328
334
  p.height += 1;
329
- case 58:
335
+ case 60:
330
336
  mem.msgs[id] = opt;
331
337
  mem.env[id] = p;
332
338
  if (!_tags["Cron-Interval"]) {
333
- _context.next = 84;
339
+ _context.next = 86;
334
340
  break;
335
341
  }
336
342
  _tags$CronInterval$s = _tags["Cron-Interval"].split("-"), _tags$CronInterval$s2 = _slicedToArray(_tags$CronInterval$s, 2), num = _tags$CronInterval$s2[0], unit = _tags$CronInterval$s2[1];
337
343
  _int = 0;
338
344
  _context.t0 = unit.replace(/s$/, "");
339
- _context.next = _context.t0 === "millisecond" ? 66 : _context.t0 === "second" ? 68 : _context.t0 === "minute" ? 70 : _context.t0 === "hour" ? 72 : _context.t0 === "day" ? 74 : _context.t0 === "month" ? 76 : _context.t0 === "year" ? 78 : 80;
345
+ _context.next = _context.t0 === "millisecond" ? 68 : _context.t0 === "second" ? 70 : _context.t0 === "minute" ? 72 : _context.t0 === "hour" ? 74 : _context.t0 === "day" ? 76 : _context.t0 === "month" ? 78 : _context.t0 === "year" ? 80 : 82;
340
346
  break;
341
- case 66:
342
- _int = num;
343
- return _context.abrupt("break", 80);
344
347
  case 68:
345
- _int = num * 1000;
346
- return _context.abrupt("break", 80);
348
+ _int = num;
349
+ return _context.abrupt("break", 82);
347
350
  case 70:
348
- _int = num * 1000 * 60;
349
- return _context.abrupt("break", 80);
351
+ _int = num * 1000;
352
+ return _context.abrupt("break", 82);
350
353
  case 72:
351
- _int = num * 1000 * 60 * 60;
352
- return _context.abrupt("break", 80);
354
+ _int = num * 1000 * 60;
355
+ return _context.abrupt("break", 82);
353
356
  case 74:
354
- _int = num * 1000 * 60 * 60 * 24;
355
- return _context.abrupt("break", 80);
357
+ _int = num * 1000 * 60 * 60;
358
+ return _context.abrupt("break", 82);
356
359
  case 76:
357
- _int = num * 1000 * 60 * 60 * 24 * 30;
358
- return _context.abrupt("break", 80);
360
+ _int = num * 1000 * 60 * 60 * 24;
361
+ return _context.abrupt("break", 82);
359
362
  case 78:
360
- _int = num * 1000 * 60 * 60 * 24 * 365;
361
- return _context.abrupt("break", 80);
363
+ _int = num * 1000 * 60 * 60 * 24 * 30;
364
+ return _context.abrupt("break", 82);
362
365
  case 80:
366
+ _int = num * 1000 * 60 * 60 * 24 * 365;
367
+ return _context.abrupt("break", 82);
368
+ case 82:
363
369
  cronTags = [];
364
370
  for (k in _tags) {
365
371
  if (/^Cron-Tag-/.test(k)) {
@@ -371,9 +377,9 @@ var connect = exports.connect = function connect(mem) {
371
377
  }
372
378
  mem.env[id].cronTags = cronTags;
373
379
  mem.env[id].span = _int;
374
- case 84:
380
+ case 86:
375
381
  return _context.abrupt("return", id);
376
- case 85:
382
+ case 87:
377
383
  case "end":
378
384
  return _context.stop();
379
385
  }
@@ -692,7 +698,6 @@ var connect = exports.connect = function connect(mem) {
692
698
  id = _yield$ar$dataitem3.id;
693
699
  owner = _yield$ar$dataitem3.owner;
694
700
  case 17:
695
- //await ar.postItems(item, su.jwk)
696
701
  mem.msgs[id] = opt;
697
702
  _context3.next = 20;
698
703
  return _assign({
@@ -897,12 +902,11 @@ var connect = exports.connect = function connect(mem) {
897
902
  case 12:
898
903
  _context9.prev = 12;
899
904
  cloneMemory = function cloneMemory(memory) {
900
- var buffer = memory.buffer.slice(0); // Clone the ArrayBuffer
905
+ var buffer = memory.buffer.slice(0);
901
906
  return new WebAssembly.Memory({
902
907
  initial: memory.buffer.byteLength / 65536,
903
- // Memory size in pages (64KB per page)
904
908
  maximum: memory.maximum || undefined,
905
- shared: memory.shared || false // Retain sharing if applicable
909
+ shared: memory.shared || false
906
910
  });
907
911
  };
908
912
  msg = genMsg(id, p, (_opt$data3 = opt.data) !== null && _opt$data3 !== void 0 ? _opt$data3 : "", opt.tags, owner, _test.mu.addr, true);