wao 0.9.2 → 0.10.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
@@ -584,21 +584,20 @@ var AO = /*#__PURE__*/function () {
584
584
  });
585
585
  case 17:
586
586
  pid = _context8.sent;
587
- _context8.next = 24;
587
+ _context8.next = 23;
588
588
  break;
589
589
  case 20:
590
590
  _context8.prev = 20;
591
591
  _context8.t0 = _context8["catch"](10);
592
- console.log(_context8.t0);
593
592
  err = _context8.t0;
594
- case 24:
593
+ case 23:
595
594
  p = pid ? this.p(pid) : null;
596
595
  return _context8.abrupt("return", {
597
596
  err: err,
598
597
  pid: pid,
599
598
  p: p
600
599
  });
601
- case 26:
600
+ case 25:
602
601
  case "end":
603
602
  return _context8.stop();
604
603
  }
@@ -683,54 +682,54 @@ var AO = /*#__PURE__*/function () {
683
682
  };
684
683
  }();
685
684
  checkOut = /*#__PURE__*/function () {
686
- var _ref14 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(get, _txs, _txmap) {
687
- var out, _iterator3, _step3, v, _res2;
685
+ var _ref14 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(get, _txs, _txmap, out) {
686
+ var _iterator3, _step3, v, _res2, _out;
688
687
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
689
688
  while (1) switch (_context10.prev = _context10.next) {
690
689
  case 0:
691
- out = null;
692
690
  _iterator3 = _createForOfIteratorHelper(_txs);
693
- _context10.prev = 2;
691
+ _context10.prev = 1;
694
692
  _iterator3.s();
695
- case 4:
693
+ case 3:
696
694
  if ((_step3 = _iterator3.n()).done) {
697
695
  _context10.next = 18;
698
696
  break;
699
697
  }
700
698
  v = _step3.value;
701
699
  if (!(0, _ramda.isNil)(_txmap[v.id].res)) {
702
- _context10.next = 11;
700
+ _context10.next = 10;
703
701
  break;
704
702
  }
705
- _context10.next = 9;
703
+ _context10.next = 8;
706
704
  return _this3.result({
707
705
  process: pid,
708
706
  message: v.id
709
707
  });
710
- case 9:
708
+ case 8:
711
709
  _res2 = _context10.sent;
712
710
  _txmap[v.id].res = _res2;
713
- case 11:
711
+ case 10:
714
712
  if (!(!(0, _ramda.isNil)(_txmap[v.id].res) && _txmap[v.id].out !== true)) {
715
713
  _context10.next = 16;
716
714
  break;
717
715
  }
718
716
  _txmap[v.id].out = true;
719
- out = (0, _utils.getTagVal)(get, _txmap[v.id].res, v.from);
720
- if (!out) {
717
+ _out = (0, _utils.getTagVal)(get, _txmap[v.id].res, v.from);
718
+ out = (0, _utils.mergeOut)(out, _out, get);
719
+ if (!(0, _utils.isOutComplete)(out, get)) {
721
720
  _context10.next = 16;
722
721
  break;
723
722
  }
724
723
  return _context10.abrupt("break", 18);
725
724
  case 16:
726
- _context10.next = 4;
725
+ _context10.next = 3;
727
726
  break;
728
727
  case 18:
729
728
  _context10.next = 23;
730
729
  break;
731
730
  case 20:
732
731
  _context10.prev = 20;
733
- _context10.t0 = _context10["catch"](2);
732
+ _context10.t0 = _context10["catch"](1);
734
733
  _iterator3.e(_context10.t0);
735
734
  case 23:
736
735
  _context10.prev = 23;
@@ -742,9 +741,9 @@ var AO = /*#__PURE__*/function () {
742
741
  case "end":
743
742
  return _context10.stop();
744
743
  }
745
- }, _callee10, null, [[2, 20, 23, 26]]);
744
+ }, _callee10, null, [[1, 20, 23, 26]]);
746
745
  }));
747
- return function checkOut(_x11, _x12, _x13) {
746
+ return function checkOut(_x11, _x12, _x13, _x14) {
748
747
  return _ref14.apply(this, arguments);
749
748
  };
750
749
  }();
@@ -859,7 +858,7 @@ var AO = /*#__PURE__*/function () {
859
858
  _context11.t4 = _utils.mergeOut;
860
859
  _context11.t5 = out;
861
860
  _context11.next = 69;
862
- return checkOut(get, _txs, _txmap);
861
+ return checkOut(get, _txs, _txmap, out);
863
862
  case 69:
864
863
  _context11.t6 = _context11.sent;
865
864
  _context11.t7 = get;
@@ -879,7 +878,7 @@ var AO = /*#__PURE__*/function () {
879
878
  _context11.t8 = _utils.mergeOut;
880
879
  _context11.t9 = out;
881
880
  _context11.next = 80;
882
- return checkOut(get, _txs, _txmap);
881
+ return checkOut(get, _txs, _txmap, out);
883
882
  case 80:
884
883
  _context11.t10 = _context11.sent;
885
884
  _context11.t11 = get;
@@ -989,7 +988,7 @@ var AO = /*#__PURE__*/function () {
989
988
  }
990
989
  }, _callee12, this, [[10, 21]]);
991
990
  }));
992
- function asgn(_x14) {
991
+ function asgn(_x15) {
993
992
  return _asgn.apply(this, arguments);
994
993
  }
995
994
  return asgn;
@@ -1055,7 +1054,7 @@ var AO = /*#__PURE__*/function () {
1055
1054
  }
1056
1055
  }, _callee13, this, [[11, 22]]);
1057
1056
  }));
1058
- function dry(_x15) {
1057
+ function dry(_x16) {
1059
1058
  return _dry.apply(this, arguments);
1060
1059
  }
1061
1060
  return dry;
@@ -1094,7 +1093,7 @@ var AO = /*#__PURE__*/function () {
1094
1093
  }
1095
1094
  }, _callee14, this);
1096
1095
  }));
1097
- function _eval(_x16) {
1096
+ function _eval(_x17) {
1098
1097
  return _eval2.apply(this, arguments);
1099
1098
  }
1100
1099
  return _eval;
@@ -1141,7 +1140,7 @@ var AO = /*#__PURE__*/function () {
1141
1140
  }
1142
1141
  }, _callee15, this);
1143
1142
  }));
1144
- function transform(_x17) {
1143
+ function transform(_x18) {
1145
1144
  return _transform.apply(this, arguments);
1146
1145
  }
1147
1146
  return transform;
@@ -1184,7 +1183,7 @@ var AO = /*#__PURE__*/function () {
1184
1183
  }
1185
1184
  }, _callee16, this);
1186
1185
  }));
1187
- function load(_x18) {
1186
+ function load(_x19) {
1188
1187
  return _load.apply(this, arguments);
1189
1188
  }
1190
1189
  return load;
@@ -1251,7 +1250,7 @@ var AO = /*#__PURE__*/function () {
1251
1250
  }
1252
1251
  }, _callee17, this);
1253
1252
  }));
1254
- function wait(_x19) {
1253
+ function wait(_x20) {
1255
1254
  return _wait2.apply(this, arguments);
1256
1255
  }
1257
1256
  return wait;
@@ -1282,7 +1281,7 @@ var AO = /*#__PURE__*/function () {
1282
1281
  }
1283
1282
  }, _callee18, this);
1284
1283
  }));
1285
- function attest(_x20) {
1284
+ function attest(_x21) {
1286
1285
  return _attest.apply(this, arguments);
1287
1286
  }
1288
1287
  return attest;
@@ -1314,7 +1313,7 @@ var AO = /*#__PURE__*/function () {
1314
1313
  }
1315
1314
  }, _callee19, this);
1316
1315
  }));
1317
- function avail(_x21) {
1316
+ function avail(_x22) {
1318
1317
  return _avail.apply(this, arguments);
1319
1318
  }
1320
1319
  return avail;
@@ -1418,7 +1417,7 @@ var AO = /*#__PURE__*/function () {
1418
1417
  }
1419
1418
  }, _callee20, this);
1420
1419
  }));
1421
- function deploy(_x22) {
1420
+ function deploy(_x23) {
1422
1421
  return _deploy.apply(this, arguments);
1423
1422
  }
1424
1423
  return deploy;
@@ -1503,7 +1502,7 @@ var Process = /*#__PURE__*/function () {
1503
1502
  }
1504
1503
  }, _callee22, this);
1505
1504
  }));
1506
- function msg(_x23, _x24, _x25) {
1505
+ function msg(_x24, _x25, _x26) {
1507
1506
  return _msg2.apply(this, arguments);
1508
1507
  }
1509
1508
  return msg;
@@ -1531,7 +1530,7 @@ var Process = /*#__PURE__*/function () {
1531
1530
  }
1532
1531
  }, _callee23, this);
1533
1532
  }));
1534
- function dry(_x26, _x27, _x28) {
1533
+ function dry(_x27, _x28, _x29) {
1535
1534
  return _dry2.apply(this, arguments);
1536
1535
  }
1537
1536
  return dry;
@@ -594,7 +594,7 @@ var _default = exports["default"] = function _default() {
594
594
  return mem.get("env", opt.process);
595
595
  case 2:
596
596
  p = _context4.sent;
597
- if (p) {
597
+ if (!(!p || !opt.process)) {
598
598
  _context4.next = 5;
599
599
  break;
600
600
  }
package/cjs/armem-base.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports["default"] = void 0;
8
8
  var _arweave = _interopRequireDefault(require("arweave"));
9
+ var _compress = require("./compress.js");
9
10
  var _ramda = require("ramda");
10
11
  var _utils = require("./utils.js");
11
12
  var _Arweave$default;
@@ -31,9 +32,15 @@ var ArMemBase = exports["default"] = /*#__PURE__*/function () {
31
32
  SU_URL = _ref.SU_URL,
32
33
  GATEWAY_URL = _ref.GATEWAY_URL,
33
34
  scheduler = _ref.scheduler,
34
- cache = _ref.cache;
35
+ cache = _ref.cache,
36
+ init = _ref.init,
37
+ Compressor = _ref.Compressor,
38
+ Decompressor = _ref.Decompressor;
35
39
  _classCallCheck(this, ArMemBase);
36
40
  this.__type__ = "mem";
41
+ this._init = init;
42
+ this.Compressor = Compressor;
43
+ this.Decompressor = Decompressor;
37
44
  this.isInit = false;
38
45
  this.keyInit = false;
39
46
  this.keys = {};
@@ -85,7 +92,7 @@ var ArMemBase = exports["default"] = /*#__PURE__*/function () {
85
92
  key: "set",
86
93
  value: function () {
87
94
  var _set = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(val, key, field) {
88
- var _this$key2;
95
+ var _this$key2, memory;
89
96
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
90
97
  while (1) switch (_context2.prev = _context2.next) {
91
98
  case 0:
@@ -104,18 +111,34 @@ var ArMemBase = exports["default"] = /*#__PURE__*/function () {
104
111
  _context2.next = 7;
105
112
  return this.db.put("".concat(key), this[key]);
106
113
  case 7:
107
- _context2.next = 14;
114
+ _context2.next = 21;
108
115
  break;
109
116
  case 9:
110
117
  (_this$key2 = this[key]) !== null && _this$key2 !== void 0 ? _this$key2 : this[key] = {};
111
118
  this[key][field] = val;
112
119
  if (!this.db) {
113
- _context2.next = 14;
120
+ _context2.next = 21;
114
121
  break;
115
122
  }
116
- _context2.next = 14;
123
+ if (!(key === "env")) {
124
+ _context2.next = 19;
125
+ break;
126
+ }
127
+ memory = val.memory;
128
+ try {
129
+ memory = Array.from(this.compressor.compress(val.memory));
130
+ } catch (e) {
131
+ memory = (0, _compress.compress)(val.memory);
132
+ }
133
+ _context2.next = 17;
134
+ return this.db.put("".concat(key, ".").concat(field), (0, _ramda.assoc)("memory", memory, this[key][field]));
135
+ case 17:
136
+ _context2.next = 21;
137
+ break;
138
+ case 19:
139
+ _context2.next = 21;
117
140
  return this.db.put("".concat(key, ".").concat(field), this[key][field]);
118
- case 14:
141
+ case 21:
119
142
  case "end":
120
143
  return _context2.stop();
121
144
  }
@@ -240,7 +263,7 @@ var ArMemBase = exports["default"] = /*#__PURE__*/function () {
240
263
  key: "init",
241
264
  value: function () {
242
265
  var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
243
- var _i, _arr, v, _i2, _arr2, _this$_v, _v, items, _iterator, _step, v2, key, field, _i3, _arr3, _v2, _i4, _arr4, _v3;
266
+ var _i, _arr, v, _i2, _arr2, _this$_v, _v, items, _iterator, _step, v2, key, field, v3, _i3, _arr3, _v2, _i4, _arr4, _v3;
244
267
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
245
268
  while (1) switch (_context4.prev = _context4.next) {
246
269
  case 0:
@@ -251,114 +274,142 @@ var ArMemBase = exports["default"] = /*#__PURE__*/function () {
251
274
  return _context4.abrupt("return");
252
275
  case 2:
253
276
  this.isInit = true;
277
+ if (!(typeof this._init === "function")) {
278
+ _context4.next = 6;
279
+ break;
280
+ }
281
+ _context4.next = 6;
282
+ return this._init();
283
+ case 6:
284
+ this.compressor = new this.Compressor();
285
+ this.decompressor = new this.Decompressor();
254
286
  if (!this.db) {
255
- _context4.next = 46;
287
+ _context4.next = 59;
256
288
  break;
257
289
  }
258
290
  _i = 0, _arr = ["height", "blocks"];
259
- case 5:
291
+ case 10:
260
292
  if (!(_i < _arr.length)) {
261
- _context4.next = 13;
293
+ _context4.next = 18;
262
294
  break;
263
295
  }
264
296
  v = _arr[_i];
265
- _context4.next = 9;
297
+ _context4.next = 14;
266
298
  return this.get(v);
267
- case 9:
299
+ case 14:
268
300
  this[v] = _context4.sent;
269
- case 10:
301
+ case 15:
270
302
  _i++;
271
- _context4.next = 5;
303
+ _context4.next = 10;
272
304
  break;
273
- case 13:
305
+ case 18:
274
306
  _i2 = 0, _arr2 = ["txs", "jwks", "env", "modules", "wasms", "addrmap", "blockmap", "modmap", "msgs"];
275
- case 14:
307
+ case 19:
276
308
  if (!(_i2 < _arr2.length)) {
277
- _context4.next = 44;
309
+ _context4.next = 57;
278
310
  break;
279
311
  }
280
312
  _v = _arr2[_i2];
281
313
  (_this$_v = this[_v]) !== null && _this$_v !== void 0 ? _this$_v : this[_v] = {};
282
- _context4.next = 19;
314
+ _context4.next = 24;
283
315
  return this.db.getKeys({
284
316
  start: _v,
285
317
  end: _v + "a"
286
318
  });
287
- case 19:
319
+ case 24:
288
320
  items = _context4.sent;
289
321
  _iterator = _createForOfIteratorHelper(items || []);
290
- _context4.prev = 21;
322
+ _context4.prev = 26;
291
323
  _iterator.s();
292
- case 23:
324
+ case 28:
293
325
  if ((_step = _iterator.n()).done) {
294
- _context4.next = 33;
326
+ _context4.next = 46;
295
327
  break;
296
328
  }
297
329
  v2 = _step.value;
298
330
  key = v2.split(".")[0];
299
331
  field = v2.split(".")[1];
300
332
  if (!(key === _v)) {
301
- _context4.next = 31;
333
+ _context4.next = 44;
334
+ break;
335
+ }
336
+ if (!key.match(/^env/)) {
337
+ _context4.next = 41;
302
338
  break;
303
339
  }
304
- _context4.next = 30;
340
+ _context4.next = 36;
341
+ return this.db.get(v2);
342
+ case 36:
343
+ v3 = _context4.sent;
344
+ if ((0, _ramda.is)(Array, v3.memory)) {
345
+ try {
346
+ v3.memory = this.decompressor.decompress(v3.memory);
347
+ } catch (e) {
348
+ v3.memory = (0, _compress.decompress)(v3.memory);
349
+ }
350
+ }
351
+ this[_v][field] = v3;
352
+ _context4.next = 44;
353
+ break;
354
+ case 41:
355
+ _context4.next = 43;
305
356
  return this.db.get(v2);
306
- case 30:
357
+ case 43:
307
358
  this[_v][field] = _context4.sent;
308
- case 31:
309
- _context4.next = 23;
359
+ case 44:
360
+ _context4.next = 28;
310
361
  break;
311
- case 33:
312
- _context4.next = 38;
362
+ case 46:
363
+ _context4.next = 51;
313
364
  break;
314
- case 35:
315
- _context4.prev = 35;
316
- _context4.t0 = _context4["catch"](21);
365
+ case 48:
366
+ _context4.prev = 48;
367
+ _context4.t0 = _context4["catch"](26);
317
368
  _iterator.e(_context4.t0);
318
- case 38:
319
- _context4.prev = 38;
369
+ case 51:
370
+ _context4.prev = 51;
320
371
  _iterator.f();
321
- return _context4.finish(38);
322
- case 41:
372
+ return _context4.finish(51);
373
+ case 54:
323
374
  _i2++;
324
- _context4.next = 14;
375
+ _context4.next = 19;
325
376
  break;
326
- case 44:
327
- _context4.next = 62;
377
+ case 57:
378
+ _context4.next = 75;
328
379
  break;
329
- case 46:
380
+ case 59:
330
381
  _i3 = 0, _arr3 = ["height", "blocks"];
331
- case 47:
382
+ case 60:
332
383
  if (!(_i3 < _arr3.length)) {
333
- _context4.next = 54;
384
+ _context4.next = 67;
334
385
  break;
335
386
  }
336
387
  _v2 = _arr3[_i3];
337
- _context4.next = 51;
388
+ _context4.next = 64;
338
389
  return this.set(this[_v2], _v2);
339
- case 51:
390
+ case 64:
340
391
  _i3++;
341
- _context4.next = 47;
392
+ _context4.next = 60;
342
393
  break;
343
- case 54:
394
+ case 67:
344
395
  _i4 = 0, _arr4 = ["modules", "wasms", "addrmap", "blockmap"];
345
- case 55:
396
+ case 68:
346
397
  if (!(_i4 < _arr4.length)) {
347
- _context4.next = 62;
398
+ _context4.next = 75;
348
399
  break;
349
400
  }
350
401
  _v3 = _arr4[_i4];
351
- _context4.next = 59;
402
+ _context4.next = 72;
352
403
  return this.putAll(_v3);
353
- case 59:
404
+ case 72:
354
405
  _i4++;
355
- _context4.next = 55;
406
+ _context4.next = 68;
356
407
  break;
357
- case 62:
408
+ case 75:
358
409
  case "end":
359
410
  return _context4.stop();
360
411
  }
361
- }, _callee4, this, [[21, 35, 38, 41]]);
412
+ }, _callee4, this, [[26, 48, 51, 54]]);
362
413
  }));
363
414
  function init() {
364
415
  return _init.apply(this, arguments);
package/cjs/armem-web.js CHANGED
@@ -8,10 +8,16 @@ exports["default"] = void 0;
8
8
  var _weavedbLite = _interopRequireDefault(require("./lua/weavedb-lite.js"));
9
9
  var _armemBase = _interopRequireDefault(require("./armem-base.js"));
10
10
  var _lfdb = _interopRequireDefault(require("./lfdb.js"));
11
+ var _waosm = _interopRequireWildcard(require("./waosm/waosm.js"));
12
+ 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); }
13
+ 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; }
11
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
12
15
  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; }
13
16
  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
17
  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); }); }; }
18
+ 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; }
19
+ 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; }
20
+ 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
21
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
16
22
  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
23
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
@@ -29,7 +35,11 @@ var ArMem = exports["default"] = /*#__PURE__*/function (_Base) {
29
35
  var _this;
30
36
  var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
31
37
  _classCallCheck(this, ArMem);
32
- _this = _callSuper(this, ArMem, [args]);
38
+ _this = _callSuper(this, ArMem, [_objectSpread(_objectSpread({}, args), {}, {
39
+ init: _waosm["default"],
40
+ Compressor: _waosm.Compressor,
41
+ Decompressor: _waosm.Decompressor
42
+ })]);
33
43
  _this.db = (0, _lfdb["default"])(_this);
34
44
  _this.initSync();
35
45
  return _this;
package/cjs/armem.js CHANGED
@@ -12,10 +12,14 @@ var _lmdb = require("lmdb");
12
12
  var _fs = require("fs");
13
13
  var _path = require("path");
14
14
  var _armemBase = _interopRequireDefault(require("./armem-base.js"));
15
+ var _waosmNode = require("./waosm-node.js");
15
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
16
17
  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; }
17
18
  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); }
18
19
  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); }); }; }
20
+ 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; }
21
+ 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; }
22
+ 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
23
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
20
24
  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
25
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
@@ -34,7 +38,10 @@ var ArMem = exports["default"] = /*#__PURE__*/function (_Base) {
34
38
  var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
35
39
  _classCallCheck(this, ArMem);
36
40
  var cache = args.cache;
37
- _this = _callSuper(this, ArMem, [args]);
41
+ _this = _callSuper(this, ArMem, [_objectSpread(_objectSpread({}, args), {}, {
42
+ Compressor: _waosmNode.Compressor,
43
+ Decompressor: _waosmNode.Decompressor
44
+ })]);
38
45
  if (cache) _this.db = (0, _lmdb.open)({
39
46
  path: cache,
40
47
  compression: true
package/cjs/build.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ var _fs = _interopRequireDefault(require("fs"));
4
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
5
+ var wasmBytes = _fs["default"].readFileSync("./waosm/waosm_bg.wasm");
6
+ var wasmB64 = wasmBytes.toString("base64");
7
+ var _exports = "export const wasmB64 = \"".concat(wasmB64, "\";");
8
+ _fs["default"].writeFileSync("./waosm/waosm_b64.js", _exports);