wao 0.9.0 → 0.9.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/armem-web.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
@@ -8,13 +7,15 @@ exports["default"] = void 0;
8
7
  var _arweave = _interopRequireDefault(require("arweave"));
9
8
  var _ramda = require("ramda");
10
9
  var _utils = require("./utils.js");
10
+ var _localforage = _interopRequireDefault(require("localforage"));
11
11
  var _weavedbLite = _interopRequireDefault(require("./lua/weavedb-lite.js"));
12
12
  var _Arweave$default;
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
14
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
14
15
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
15
16
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
16
17
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
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; }
18
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
18
19
  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); }
19
20
  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
21
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
@@ -23,8 +24,6 @@ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r),
23
24
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
24
25
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
25
26
  var Arweave = (_Arweave$default = _arweave["default"]["default"]) !== null && _Arweave$default !== void 0 ? _Arweave$default : _arweave["default"];
26
- //import { readFileSync } from "fs"
27
- //import { resolve } from "path"
28
27
  var ArMem = exports["default"] = /*#__PURE__*/function () {
29
28
  function ArMem() {
30
29
  var _this = this;
@@ -38,7 +37,155 @@ var ArMem = exports["default"] = /*#__PURE__*/function () {
38
37
  _classCallCheck(this, ArMem);
39
38
  this.__type__ = "mem";
40
39
  this.isInit = false;
41
- //if (cache) this.db = open({ path: cache, compression: true })
40
+ this.keyInit = false;
41
+ this.keys = {};
42
+ this.db = {
43
+ put: function () {
44
+ var _put = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(key, val) {
45
+ var _val, k, _arr, _iterator, _step, v, __val, k2, _val2, _k;
46
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
47
+ while (1) switch (_context.prev = _context.next) {
48
+ case 0:
49
+ _val = null;
50
+ if (_typeof(val) === "object" && !(0, _ramda.is)(Array, val)) {
51
+ _val = {};
52
+ for (k in val) {
53
+ if (typeof val[k] !== "function") {
54
+ if ((0, _ramda.is)(Array, val[k])) {
55
+ _arr = [];
56
+ _iterator = _createForOfIteratorHelper(val[k]);
57
+ try {
58
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
59
+ v = _step.value;
60
+ if (_typeof(v) === "object" && !(0, _ramda.is)(Array, v) && !(v instanceof Uint8Array) && !(v instanceof ArrayBuffer)) {
61
+ __val = {};
62
+ for (k2 in v) {
63
+ if (typeof v[k2] !== "function") __val[k2] = v[k2];
64
+ }
65
+ _arr.push(__val);
66
+ } else {
67
+ _arr.push(v);
68
+ }
69
+ }
70
+ } catch (err) {
71
+ _iterator.e(err);
72
+ } finally {
73
+ _iterator.f();
74
+ }
75
+ _val[k] = _arr;
76
+ } else if (_typeof(val[k]) === "object" && !(val[k] instanceof Uint8Array) && !(val[k] instanceof ArrayBuffer)) {
77
+ _val2 = {};
78
+ for (_k in val[k]) {
79
+ if (typeof val[k][_k] !== "function") _val2[_k] = val[k][_k];
80
+ }
81
+ _val[k] = _val2;
82
+ } else {
83
+ _val[k] = val[k];
84
+ }
85
+ }
86
+ }
87
+ } else _val = val;
88
+ _context.next = 4;
89
+ return _localforage["default"].setItem(key, _val);
90
+ case 4:
91
+ _this.keys[key] = true;
92
+ _context.next = 7;
93
+ return _localforage["default"].setItem("keys", (0, _ramda.keys)(_this.keys));
94
+ case 7:
95
+ case "end":
96
+ return _context.stop();
97
+ }
98
+ }, _callee);
99
+ }));
100
+ function put(_x, _x2) {
101
+ return _put.apply(this, arguments);
102
+ }
103
+ return put;
104
+ }(),
105
+ get: function () {
106
+ var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key) {
107
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
108
+ while (1) switch (_context2.prev = _context2.next) {
109
+ case 0:
110
+ _context2.next = 2;
111
+ return _localforage["default"].getItem(key);
112
+ case 2:
113
+ return _context2.abrupt("return", _context2.sent);
114
+ case 3:
115
+ case "end":
116
+ return _context2.stop();
117
+ }
118
+ }, _callee2);
119
+ }));
120
+ function get(_x3) {
121
+ return _get.apply(this, arguments);
122
+ }
123
+ return get;
124
+ }(),
125
+ getKeys: function () {
126
+ var _getKeys = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
127
+ var start, end, _yield$lf$getItem, _keys, _iterator2, _step2, v, __keys, k, sp;
128
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
129
+ while (1) switch (_context3.prev = _context3.next) {
130
+ case 0:
131
+ start = _ref2.start, end = _ref2.end;
132
+ if (_this.keyInit) {
133
+ _context3.next = 17;
134
+ break;
135
+ }
136
+ _context3.next = 4;
137
+ return _localforage["default"].getItem("keys");
138
+ case 4:
139
+ _context3.t1 = _yield$lf$getItem = _context3.sent;
140
+ _context3.t0 = _context3.t1 !== null;
141
+ if (!_context3.t0) {
142
+ _context3.next = 8;
143
+ break;
144
+ }
145
+ _context3.t0 = _yield$lf$getItem !== void 0;
146
+ case 8:
147
+ if (!_context3.t0) {
148
+ _context3.next = 12;
149
+ break;
150
+ }
151
+ _context3.t2 = _yield$lf$getItem;
152
+ _context3.next = 13;
153
+ break;
154
+ case 12:
155
+ _context3.t2 = [];
156
+ case 13:
157
+ _keys = _context3.t2;
158
+ _this.keys = {};
159
+ _iterator2 = _createForOfIteratorHelper(_keys);
160
+ try {
161
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
162
+ v = _step2.value;
163
+ _this.keys[v] = true;
164
+ }
165
+ } catch (err) {
166
+ _iterator2.e(err);
167
+ } finally {
168
+ _iterator2.f();
169
+ }
170
+ case 17:
171
+ __keys = [];
172
+ for (k in _this.keys) {
173
+ sp = k.split(".");
174
+ if (sp[0] === start) __keys.push(k);
175
+ }
176
+ return _context3.abrupt("return", __keys);
177
+ case 20:
178
+ case "end":
179
+ return _context3.stop();
180
+ }
181
+ }, _callee3);
182
+ }));
183
+ function getKeys(_x4) {
184
+ return _getKeys.apply(this, arguments);
185
+ }
186
+ return getKeys;
187
+ }()
188
+ };
42
189
  this.arweave = Arweave.init();
43
190
  this.arweave.transactions.getTransactionAnchor = function () {
44
191
  return _this.getAnchor();
@@ -53,30 +200,30 @@ var ArMem = exports["default"] = /*#__PURE__*/function () {
53
200
  return _createClass(ArMem, [{
54
201
  key: "putAll",
55
202
  value: function () {
56
- var _putAll = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(key) {
203
+ var _putAll = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(key) {
57
204
  var k;
58
- return _regeneratorRuntime().wrap(function _callee$(_context) {
59
- while (1) switch (_context.prev = _context.next) {
205
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
206
+ while (1) switch (_context4.prev = _context4.next) {
60
207
  case 0:
61
- _context.t0 = _regeneratorRuntime().keys(this[key]);
208
+ _context4.t0 = _regeneratorRuntime().keys(this[key]);
62
209
  case 1:
63
- if ((_context.t1 = _context.t0()).done) {
64
- _context.next = 7;
210
+ if ((_context4.t1 = _context4.t0()).done) {
211
+ _context4.next = 7;
65
212
  break;
66
213
  }
67
- k = _context.t1.value;
68
- _context.next = 5;
214
+ k = _context4.t1.value;
215
+ _context4.next = 5;
69
216
  return this.set(this[key][k], key, k);
70
217
  case 5:
71
- _context.next = 1;
218
+ _context4.next = 1;
72
219
  break;
73
220
  case 7:
74
221
  case "end":
75
- return _context.stop();
222
+ return _context4.stop();
76
223
  }
77
- }, _callee, this);
224
+ }, _callee4, this);
78
225
  }));
79
- function putAll(_x) {
226
+ function putAll(_x5) {
80
227
  return _putAll.apply(this, arguments);
81
228
  }
82
229
  return putAll;
@@ -84,126 +231,126 @@ var ArMem = exports["default"] = /*#__PURE__*/function () {
84
231
  }, {
85
232
  key: "init",
86
233
  value: function () {
87
- var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
88
- var _i, _arr, v, _i2, _arr2, _this$_v, _v, items, _iterator, _step, v2, key, field, _i3, _arr3, _v2, _i4, _arr4, _v3;
89
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
90
- while (1) switch (_context2.prev = _context2.next) {
234
+ var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
235
+ var _i, _arr2, v, _i2, _arr3, _this$_v, _v, items, _iterator3, _step3, v2, key, field, _i3, _arr4, _v2, _i4, _arr5, _v3;
236
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
237
+ while (1) switch (_context5.prev = _context5.next) {
91
238
  case 0:
92
239
  if (!this.isInit) {
93
- _context2.next = 2;
240
+ _context5.next = 2;
94
241
  break;
95
242
  }
96
- return _context2.abrupt("return");
243
+ return _context5.abrupt("return");
97
244
  case 2:
98
245
  this.isInit = true;
99
246
  if (!this.db) {
100
- _context2.next = 46;
247
+ _context5.next = 46;
101
248
  break;
102
249
  }
103
- _i = 0, _arr = ["height", "blocks"];
250
+ _i = 0, _arr2 = ["height", "blocks"];
104
251
  case 5:
105
- if (!(_i < _arr.length)) {
106
- _context2.next = 13;
252
+ if (!(_i < _arr2.length)) {
253
+ _context5.next = 13;
107
254
  break;
108
255
  }
109
- v = _arr[_i];
110
- _context2.next = 9;
256
+ v = _arr2[_i];
257
+ _context5.next = 9;
111
258
  return this.get(v);
112
259
  case 9:
113
- this[v] = _context2.sent;
260
+ this[v] = _context5.sent;
114
261
  case 10:
115
262
  _i++;
116
- _context2.next = 5;
263
+ _context5.next = 5;
117
264
  break;
118
265
  case 13:
119
- _i2 = 0, _arr2 = ["txs", "jwks", "env", "modules", "wasms", "addrmap", "blockmap", "modmap", "msgs"];
266
+ _i2 = 0, _arr3 = ["txs", "jwks", "env", "modules", "wasms", "addrmap", "blockmap", "modmap", "msgs"];
120
267
  case 14:
121
- if (!(_i2 < _arr2.length)) {
122
- _context2.next = 44;
268
+ if (!(_i2 < _arr3.length)) {
269
+ _context5.next = 44;
123
270
  break;
124
271
  }
125
- _v = _arr2[_i2];
272
+ _v = _arr3[_i2];
126
273
  (_this$_v = this[_v]) !== null && _this$_v !== void 0 ? _this$_v : this[_v] = {};
127
- _context2.next = 19;
274
+ _context5.next = 19;
128
275
  return this.db.getKeys({
129
276
  start: _v,
130
277
  end: _v + "a"
131
278
  });
132
279
  case 19:
133
- items = _context2.sent;
134
- _iterator = _createForOfIteratorHelper(items);
135
- _context2.prev = 21;
136
- _iterator.s();
280
+ items = _context5.sent;
281
+ _iterator3 = _createForOfIteratorHelper(items || []);
282
+ _context5.prev = 21;
283
+ _iterator3.s();
137
284
  case 23:
138
- if ((_step = _iterator.n()).done) {
139
- _context2.next = 33;
285
+ if ((_step3 = _iterator3.n()).done) {
286
+ _context5.next = 33;
140
287
  break;
141
288
  }
142
- v2 = _step.value;
289
+ v2 = _step3.value;
143
290
  key = v2.split(".")[0];
144
291
  field = v2.split(".")[1];
145
292
  if (!(key === _v)) {
146
- _context2.next = 31;
293
+ _context5.next = 31;
147
294
  break;
148
295
  }
149
- _context2.next = 30;
296
+ _context5.next = 30;
150
297
  return this.db.get(v2);
151
298
  case 30:
152
- this[_v][field] = _context2.sent;
299
+ this[_v][field] = _context5.sent;
153
300
  case 31:
154
- _context2.next = 23;
301
+ _context5.next = 23;
155
302
  break;
156
303
  case 33:
157
- _context2.next = 38;
304
+ _context5.next = 38;
158
305
  break;
159
306
  case 35:
160
- _context2.prev = 35;
161
- _context2.t0 = _context2["catch"](21);
162
- _iterator.e(_context2.t0);
307
+ _context5.prev = 35;
308
+ _context5.t0 = _context5["catch"](21);
309
+ _iterator3.e(_context5.t0);
163
310
  case 38:
164
- _context2.prev = 38;
165
- _iterator.f();
166
- return _context2.finish(38);
311
+ _context5.prev = 38;
312
+ _iterator3.f();
313
+ return _context5.finish(38);
167
314
  case 41:
168
315
  _i2++;
169
- _context2.next = 14;
316
+ _context5.next = 14;
170
317
  break;
171
318
  case 44:
172
- _context2.next = 62;
319
+ _context5.next = 62;
173
320
  break;
174
321
  case 46:
175
- _i3 = 0, _arr3 = ["height", "blocks"];
322
+ _i3 = 0, _arr4 = ["height", "blocks"];
176
323
  case 47:
177
- if (!(_i3 < _arr3.length)) {
178
- _context2.next = 54;
324
+ if (!(_i3 < _arr4.length)) {
325
+ _context5.next = 54;
179
326
  break;
180
327
  }
181
- _v2 = _arr3[_i3];
182
- _context2.next = 51;
328
+ _v2 = _arr4[_i3];
329
+ _context5.next = 51;
183
330
  return this.set(this[_v2], _v2);
184
331
  case 51:
185
332
  _i3++;
186
- _context2.next = 47;
333
+ _context5.next = 47;
187
334
  break;
188
335
  case 54:
189
- _i4 = 0, _arr4 = ["modules", "wasms", "addrmap", "blockmap"];
336
+ _i4 = 0, _arr5 = ["modules", "wasms", "addrmap", "blockmap"];
190
337
  case 55:
191
- if (!(_i4 < _arr4.length)) {
192
- _context2.next = 62;
338
+ if (!(_i4 < _arr5.length)) {
339
+ _context5.next = 62;
193
340
  break;
194
341
  }
195
- _v3 = _arr4[_i4];
196
- _context2.next = 59;
342
+ _v3 = _arr5[_i4];
343
+ _context5.next = 59;
197
344
  return this.putAll(_v3);
198
345
  case 59:
199
346
  _i4++;
200
- _context2.next = 55;
347
+ _context5.next = 55;
201
348
  break;
202
349
  case 62:
203
350
  case "end":
204
- return _context2.stop();
351
+ return _context5.stop();
205
352
  }
206
- }, _callee2, this, [[21, 35, 38, 41]]);
353
+ }, _callee5, this, [[21, 35, 38, 41]]);
207
354
  }));
208
355
  function init() {
209
356
  return _init.apply(this, arguments);
@@ -213,69 +360,69 @@ var ArMem = exports["default"] = /*#__PURE__*/function () {
213
360
  }, {
214
361
  key: "getWasm",
215
362
  value: function () {
216
- var _getWasm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(module) {
363
+ var _getWasm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(module) {
217
364
  var _format;
218
365
  var mod, __dirname, format, _wasm, wasm, tx;
219
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
220
- while (1) switch (_context3.prev = _context3.next) {
366
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
367
+ while (1) switch (_context6.prev = _context6.next) {
221
368
  case 0:
222
369
  mod = module !== null && module !== void 0 ? module : this.modules.aos2_0_1;
223
370
  if (mod) {
224
- _context3.next = 3;
371
+ _context6.next = 3;
225
372
  break;
226
373
  }
227
374
  throw Error("module not found");
228
375
  case 3:
229
- _context3.next = 5;
376
+ _context6.next = 5;
230
377
  return (0, _utils.dirname)();
231
378
  case 5:
232
- __dirname = _context3.sent;
379
+ __dirname = _context6.sent;
233
380
  format = null;
234
- _context3.next = 9;
381
+ _context6.next = 9;
235
382
  return this.wasms[mod];
236
383
  case 9:
237
- _wasm = _context3.sent;
384
+ _wasm = _context6.sent;
238
385
  wasm = _wasm === null || _wasm === void 0 ? void 0 : _wasm.data;
239
386
  if (wasm) {
240
- _context3.next = 23;
387
+ _context6.next = 23;
241
388
  break;
242
389
  }
243
390
  if (!(_wasm !== null && _wasm !== void 0 && _wasm.file)) {
244
- _context3.next = 17;
391
+ _context6.next = 17;
245
392
  break;
246
393
  }
247
394
  wasm = Buffer.from(_weavedbLite["default"], "base64");
248
395
  format = _wasm.format;
249
- _context3.next = 21;
396
+ _context6.next = 21;
250
397
  break;
251
398
  case 17:
252
- _context3.next = 19;
399
+ _context6.next = 19;
253
400
  return this.get("txs", mod);
254
401
  case 19:
255
- tx = _context3.sent;
402
+ tx = _context6.sent;
256
403
  if (tx) {
257
404
  wasm = Buffer.from(tx.data, "base64");
258
405
  format = (0, _utils.tags)(tx.tags)["Module-Format"];
259
406
  }
260
407
  case 21:
261
- _context3.next = 24;
408
+ _context6.next = 24;
262
409
  break;
263
410
  case 23:
264
411
  format = _wasm.format;
265
412
  case 24:
266
413
  (_format = format) !== null && _format !== void 0 ? _format : format = "wasm64-unknown-emscripten-draft_2024_02_15";
267
- return _context3.abrupt("return", {
414
+ return _context6.abrupt("return", {
268
415
  format: format,
269
416
  mod: mod,
270
417
  wasm: wasm
271
418
  });
272
419
  case 26:
273
420
  case "end":
274
- return _context3.stop();
421
+ return _context6.stop();
275
422
  }
276
- }, _callee3, this);
423
+ }, _callee6, this);
277
424
  }));
278
- function getWasm(_x2) {
425
+ function getWasm(_x6) {
279
426
  return _getWasm.apply(this, arguments);
280
427
  }
281
428
  return getWasm;
@@ -367,73 +514,73 @@ var ArMem = exports["default"] = /*#__PURE__*/function () {
367
514
  }, {
368
515
  key: "get",
369
516
  value: function () {
370
- var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(key, field) {
517
+ var _get2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(key, field) {
371
518
  var _this$key;
372
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
373
- while (1) switch (_context4.prev = _context4.next) {
519
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
520
+ while (1) switch (_context7.prev = _context7.next) {
374
521
  case 0:
375
- _context4.next = 2;
522
+ _context7.next = 2;
376
523
  return this.init();
377
524
  case 2:
378
525
  if (field) {
379
- _context4.next = 4;
526
+ _context7.next = 4;
380
527
  break;
381
528
  }
382
- return _context4.abrupt("return", this[key]);
529
+ return _context7.abrupt("return", this[key]);
383
530
  case 4:
384
- return _context4.abrupt("return", (_this$key = this[key]) === null || _this$key === void 0 ? void 0 : _this$key[field]);
531
+ return _context7.abrupt("return", (_this$key = this[key]) === null || _this$key === void 0 ? void 0 : _this$key[field]);
385
532
  case 5:
386
533
  case "end":
387
- return _context4.stop();
534
+ return _context7.stop();
388
535
  }
389
- }, _callee4, this);
536
+ }, _callee7, this);
390
537
  }));
391
- function get(_x3, _x4) {
392
- return _get.apply(this, arguments);
538
+ function get(_x7, _x8) {
539
+ return _get2.apply(this, arguments);
393
540
  }
394
541
  return get;
395
542
  }()
396
543
  }, {
397
544
  key: "set",
398
545
  value: function () {
399
- var _set = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(val, key, field) {
546
+ var _set = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(val, key, field) {
400
547
  var _this$key2;
401
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
402
- while (1) switch (_context5.prev = _context5.next) {
548
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
549
+ while (1) switch (_context8.prev = _context8.next) {
403
550
  case 0:
404
- _context5.next = 2;
551
+ _context8.next = 2;
405
552
  return this.init();
406
553
  case 2:
407
554
  if (field) {
408
- _context5.next = 9;
555
+ _context8.next = 9;
409
556
  break;
410
557
  }
411
558
  this[key] = val;
412
559
  if (!this.db) {
413
- _context5.next = 7;
560
+ _context8.next = 7;
414
561
  break;
415
562
  }
416
- _context5.next = 7;
563
+ _context8.next = 7;
417
564
  return this.db.put("".concat(key), this[key]);
418
565
  case 7:
419
- _context5.next = 14;
566
+ _context8.next = 14;
420
567
  break;
421
568
  case 9:
422
569
  (_this$key2 = this[key]) !== null && _this$key2 !== void 0 ? _this$key2 : this[key] = {};
423
570
  this[key][field] = val;
424
571
  if (!this.db) {
425
- _context5.next = 14;
572
+ _context8.next = 14;
426
573
  break;
427
574
  }
428
- _context5.next = 14;
575
+ _context8.next = 14;
429
576
  return this.db.put("".concat(key, ".").concat(field), this[key][field]);
430
577
  case 14:
431
578
  case "end":
432
- return _context5.stop();
579
+ return _context8.stop();
433
580
  }
434
- }, _callee5, this);
581
+ }, _callee8, this);
435
582
  }));
436
- function set(_x5, _x6, _x7) {
583
+ function set(_x9, _x10, _x11) {
437
584
  return _set.apply(this, arguments);
438
585
  }
439
586
  return set;
package/esm/armem-web.js CHANGED
@@ -1,15 +1,79 @@
1
1
  import _Arweave from "arweave"
2
- import { last } from "ramda"
2
+ import { is, last, keys } from "ramda"
3
3
  import { tags, buildTags, dirname } from "./utils.js"
4
4
  const Arweave = _Arweave.default ?? _Arweave
5
- //import { readFileSync } from "fs"
6
- //import { resolve } from "path"
5
+ import lf from "localforage"
7
6
  import wdb from "./lua/weavedb-lite.js"
7
+
8
8
  export default class ArMem {
9
9
  constructor({ MU_URL, CU_URL, SU_URL, GATEWAY_URL, scheduler, cache } = {}) {
10
10
  this.__type__ = "mem"
11
11
  this.isInit = false
12
- //if (cache) this.db = open({ path: cache, compression: true })
12
+ this.keyInit = false
13
+ this.keys = {}
14
+ this.db = {
15
+ put: async (key, val) => {
16
+ let _val = null
17
+ if (typeof val === "object" && !is(Array, val)) {
18
+ _val = {}
19
+ for (let k in val) {
20
+ if (typeof val[k] !== "function") {
21
+ if (is(Array, val[k])) {
22
+ let _arr = []
23
+ for (let v of val[k]) {
24
+ if (
25
+ typeof v === "object" &&
26
+ !is(Array, v) &&
27
+ !(v instanceof Uint8Array) &&
28
+ !(v instanceof ArrayBuffer)
29
+ ) {
30
+ let __val = {}
31
+ for (let k2 in v) {
32
+ if (typeof v[k2] !== "function") __val[k2] = v[k2]
33
+ }
34
+ _arr.push(__val)
35
+ } else {
36
+ _arr.push(v)
37
+ }
38
+ }
39
+ _val[k] = _arr
40
+ } else if (
41
+ typeof val[k] === "object" &&
42
+ !(val[k] instanceof Uint8Array) &&
43
+ !(val[k] instanceof ArrayBuffer)
44
+ ) {
45
+ let __val = {}
46
+ for (let k2 in val[k]) {
47
+ if (typeof val[k][k2] !== "function") __val[k2] = val[k][k2]
48
+ }
49
+ _val[k] = __val
50
+ } else {
51
+ _val[k] = val[k]
52
+ }
53
+ }
54
+ }
55
+ } else _val = val
56
+ await lf.setItem(key, _val)
57
+ this.keys[key] = true
58
+ await lf.setItem("keys", keys(this.keys))
59
+ },
60
+ get: async key => {
61
+ return await lf.getItem(key)
62
+ },
63
+ getKeys: async ({ start, end }) => {
64
+ if (!this.keyInit) {
65
+ const _keys = (await lf.getItem("keys")) ?? []
66
+ this.keys = {}
67
+ for (const v of _keys) this.keys[v] = true
68
+ }
69
+ let __keys = []
70
+ for (const k in this.keys) {
71
+ const sp = k.split(".")
72
+ if (sp[0] === start) __keys.push(k)
73
+ }
74
+ return __keys
75
+ },
76
+ }
13
77
  this.arweave = Arweave.init()
14
78
  this.arweave.transactions.getTransactionAnchor = () => this.getAnchor()
15
79
  this.arweave.transactions.getPrice = () => 0
@@ -38,7 +102,7 @@ export default class ArMem {
38
102
  ]) {
39
103
  this[v] ??= {}
40
104
  const items = await this.db.getKeys({ start: v, end: v + "a" })
41
- for (const v2 of items) {
105
+ for (const v2 of items || []) {
42
106
  const key = v2.split(".")[0]
43
107
  const field = v2.split(".")[1]
44
108
  if (key === v) this[v][field] = await this.db.get(v2)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "bin": {
5
5
  "wao": "./cjs/cli.js",
6
6
  "wao-esm": "./esm/cli.js"
@@ -38,6 +38,7 @@
38
38
  "express": "^4.21.2",
39
39
  "graphql": "^16.10.0",
40
40
  "lmdb": "^3.2.2",
41
+ "localforage": "^1.10.0",
41
42
  "pm2": "^5.4.3",
42
43
  "ramda": "^0.30.1",
43
44
  "yargs": "^17.7.2"