wao 0.1.0
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/accounts.js +96 -0
- package/cjs/ao.js +1543 -0
- package/cjs/aoconnect.js +758 -0
- package/cjs/ar.js +794 -0
- package/cjs/dirname.js +7 -0
- package/cjs/helpers.js +381 -0
- package/cjs/index.js +20 -0
- package/cjs/utils.js +438 -0
- package/esm/.cache/opt.json +1 -0
- package/esm/accounts.js +91 -0
- package/esm/ao.js +737 -0
- package/esm/aoconnect.js +318 -0
- package/esm/ar.js +243 -0
- package/esm/dirname.js +1 -0
- package/esm/helpers.js +161 -0
- package/esm/index.js +4 -0
- package/esm/lua/aos-sqlite.wasm +0 -0
- package/esm/lua/aos.wasm +0 -0
- package/esm/lua/aos2.lua +33 -0
- package/esm/lua/aos2_0_1.wasm +0 -0
- package/esm/lua/atomic-asset.lua +238 -0
- package/esm/lua/atomic-note-library.lua +2274 -0
- package/esm/lua/atomic-note.lua +11 -0
- package/esm/lua/collection-registry.lua +202 -0
- package/esm/lua/collection.lua +173 -0
- package/esm/lua/notebook.lua +173 -0
- package/esm/lua/profile.lua +858 -0
- package/esm/lua/profile000.lua +666 -0
- package/esm/lua/proxy.lua +24 -0
- package/esm/lua/registry.lua +858 -0
- package/esm/lua/registry000.lua +636 -0
- package/esm/test.js +94 -0
- package/esm/utils.js +342 -0
- package/package.json +21 -0
- package/test/.cache/opt.json +1 -0
- package/test/accounts.js +91 -0
- package/test/ao.js +737 -0
- package/test/aoconnect.js +318 -0
- package/test/ar.js +243 -0
- package/test/dirname.js +1 -0
- package/test/helpers.js +161 -0
- package/test/index.js +4 -0
- package/test/lua/aos-sqlite.wasm +0 -0
- package/test/lua/aos.wasm +0 -0
- package/test/lua/aos2.lua +33 -0
- package/test/lua/aos2_0_1.wasm +0 -0
- package/test/lua/atomic-asset.lua +238 -0
- package/test/lua/atomic-note-library.lua +2274 -0
- package/test/lua/atomic-note.lua +11 -0
- package/test/lua/collection-registry.lua +202 -0
- package/test/lua/collection.lua +173 -0
- package/test/lua/notebook.lua +173 -0
- package/test/lua/profile.lua +858 -0
- package/test/lua/profile000.lua +666 -0
- package/test/lua/proxy.lua +24 -0
- package/test/lua/registry.lua +858 -0
- package/test/lua/registry000.lua +636 -0
- package/test/package.json +21 -0
- package/test/test.js +94 -0
- package/test/utils.js +342 -0
package/cjs/dirname.js
ADDED
package/cjs/helpers.js
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.setup = exports.ok = exports.fail = exports.Src = void 0;
|
|
8
|
+
var _index = require("./index.js");
|
|
9
|
+
var _assert = _interopRequireDefault(require("assert"));
|
|
10
|
+
var _aoconnect3 = require("@permaweb/aoconnect");
|
|
11
|
+
var _path = require("path");
|
|
12
|
+
var _fs = require("fs");
|
|
13
|
+
var _yargs = _interopRequireDefault(require("yargs"));
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
15
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
18
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
19
|
+
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); } }
|
|
20
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
21
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
22
|
+
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); }
|
|
23
|
+
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; }
|
|
24
|
+
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); }
|
|
25
|
+
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; }
|
|
26
|
+
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); }
|
|
27
|
+
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); }); }; }
|
|
28
|
+
var _yargs$argv = (0, _yargs["default"])(process.argv.slice(2)).argv,
|
|
29
|
+
_yargs$argv$reset = _yargs$argv.reset,
|
|
30
|
+
reset = _yargs$argv$reset === void 0 ? false : _yargs$argv$reset,
|
|
31
|
+
_yargs$argv$cache = _yargs$argv.cache,
|
|
32
|
+
cache = _yargs$argv$cache === void 0 ? false : _yargs$argv$cache,
|
|
33
|
+
_yargs$argv$auth = _yargs$argv.auth,
|
|
34
|
+
auth = _yargs$argv$auth === void 0 ? null : _yargs$argv$auth;
|
|
35
|
+
var dirname = /*#__PURE__*/function () {
|
|
36
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
37
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
38
|
+
while (1) switch (_context.prev = _context.next) {
|
|
39
|
+
case 0:
|
|
40
|
+
if (!(typeof __dirname != "undefined")) {
|
|
41
|
+
_context.next = 4;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
_context.t0 = __dirname;
|
|
45
|
+
_context.next = 7;
|
|
46
|
+
break;
|
|
47
|
+
case 4:
|
|
48
|
+
_context.next = 6;
|
|
49
|
+
return Promise.resolve().then(function () {
|
|
50
|
+
return _interopRequireWildcard(require("./dirname.js"));
|
|
51
|
+
});
|
|
52
|
+
case 6:
|
|
53
|
+
_context.t0 = _context.sent["default"];
|
|
54
|
+
case 7:
|
|
55
|
+
return _context.abrupt("return", _context.t0);
|
|
56
|
+
case 8:
|
|
57
|
+
case "end":
|
|
58
|
+
return _context.stop();
|
|
59
|
+
}
|
|
60
|
+
}, _callee);
|
|
61
|
+
}));
|
|
62
|
+
return function dirname() {
|
|
63
|
+
return _ref.apply(this, arguments);
|
|
64
|
+
};
|
|
65
|
+
}();
|
|
66
|
+
var Src = exports.Src = /*#__PURE__*/function () {
|
|
67
|
+
function Src() {
|
|
68
|
+
var _this = this;
|
|
69
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
70
|
+
ar = _ref2.ar,
|
|
71
|
+
dir = _ref2.dir;
|
|
72
|
+
_classCallCheck(this, Src);
|
|
73
|
+
this.ar = ar;
|
|
74
|
+
this.dir = dir;
|
|
75
|
+
if (!dir) dirname().then(function (v) {
|
|
76
|
+
return _this.dir = v;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return _createClass(Src, [{
|
|
80
|
+
key: "data",
|
|
81
|
+
value: function data(file) {
|
|
82
|
+
var ext = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "lua";
|
|
83
|
+
return (0, _fs.readFileSync)("".concat(this.dir, "/").concat(file, ".").concat(ext), ext === "wasm" ? null : "utf8");
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
key: "upload",
|
|
87
|
+
value: function () {
|
|
88
|
+
var _upload = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(file) {
|
|
89
|
+
var ext,
|
|
90
|
+
res,
|
|
91
|
+
_args2 = arguments;
|
|
92
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
93
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
94
|
+
case 0:
|
|
95
|
+
ext = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : "lua";
|
|
96
|
+
_context2.next = 3;
|
|
97
|
+
return this.ar.post({
|
|
98
|
+
data: this.data(file, ext)
|
|
99
|
+
});
|
|
100
|
+
case 3:
|
|
101
|
+
res = _context2.sent;
|
|
102
|
+
return _context2.abrupt("return", res.err ? null : res.id);
|
|
103
|
+
case 5:
|
|
104
|
+
case "end":
|
|
105
|
+
return _context2.stop();
|
|
106
|
+
}
|
|
107
|
+
}, _callee2, this);
|
|
108
|
+
}));
|
|
109
|
+
function upload(_x) {
|
|
110
|
+
return _upload.apply(this, arguments);
|
|
111
|
+
}
|
|
112
|
+
return upload;
|
|
113
|
+
}()
|
|
114
|
+
}]);
|
|
115
|
+
}();
|
|
116
|
+
var setup = exports.setup = /*#__PURE__*/function () {
|
|
117
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
118
|
+
var _arweave, _aoconnect, _aoconnect$CU_URL, _aoconnect2;
|
|
119
|
+
var _ref4,
|
|
120
|
+
aoconnect,
|
|
121
|
+
arweave,
|
|
122
|
+
_ref4$cacheDir,
|
|
123
|
+
cacheDir,
|
|
124
|
+
_ref4$targets,
|
|
125
|
+
targets,
|
|
126
|
+
opt,
|
|
127
|
+
dir,
|
|
128
|
+
_cacheDir,
|
|
129
|
+
optPath,
|
|
130
|
+
_ar,
|
|
131
|
+
_src,
|
|
132
|
+
_ao,
|
|
133
|
+
_ao2,
|
|
134
|
+
ar,
|
|
135
|
+
src,
|
|
136
|
+
wasm,
|
|
137
|
+
wasm2,
|
|
138
|
+
wasm_aos2,
|
|
139
|
+
ao,
|
|
140
|
+
_yield$ao$postModule,
|
|
141
|
+
module_aos2,
|
|
142
|
+
_yield$ao$postModule2,
|
|
143
|
+
module_sqlite,
|
|
144
|
+
_yield$ao$postModule3,
|
|
145
|
+
module,
|
|
146
|
+
_yield$ao$postSchedul,
|
|
147
|
+
scheduler,
|
|
148
|
+
ao2,
|
|
149
|
+
_args3 = arguments;
|
|
150
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
151
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
152
|
+
case 0:
|
|
153
|
+
_ref4 = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {}, aoconnect = _ref4.aoconnect, arweave = _ref4.arweave, _ref4$cacheDir = _ref4.cacheDir, cacheDir = _ref4$cacheDir === void 0 ? ".cache" : _ref4$cacheDir, _ref4$targets = _ref4.targets, targets = _ref4$targets === void 0 ? {
|
|
154
|
+
profile: false,
|
|
155
|
+
note: false,
|
|
156
|
+
asset: false
|
|
157
|
+
} : _ref4$targets;
|
|
158
|
+
if (targets.asset || targets.note) targets.profile = true;
|
|
159
|
+
opt = null;
|
|
160
|
+
console.error = function () {};
|
|
161
|
+
console.warn = function () {};
|
|
162
|
+
_context3.t0 = _path.resolve;
|
|
163
|
+
_context3.next = 8;
|
|
164
|
+
return dirname();
|
|
165
|
+
case 8:
|
|
166
|
+
_context3.t1 = _context3.sent;
|
|
167
|
+
dir = (0, _context3.t0)(_context3.t1, "lua");
|
|
168
|
+
_context3.t2 = _path.resolve;
|
|
169
|
+
_context3.next = 13;
|
|
170
|
+
return dirname();
|
|
171
|
+
case 13:
|
|
172
|
+
_context3.t3 = _context3.sent;
|
|
173
|
+
_context3.t4 = cacheDir;
|
|
174
|
+
_cacheDir = (0, _context3.t2)(_context3.t3, _context3.t4);
|
|
175
|
+
optPath = "".concat(_cacheDir, "/opt.json");
|
|
176
|
+
if (cache && !reset) {
|
|
177
|
+
try {
|
|
178
|
+
if ((0, _fs.existsSync)(optPath)) {
|
|
179
|
+
opt = JSON.parse((0, _fs.readFileSync)(optPath, "utf8"));
|
|
180
|
+
} else {
|
|
181
|
+
console.log("cache doesn't exist:", optPath);
|
|
182
|
+
}
|
|
183
|
+
} catch (e) {
|
|
184
|
+
console.log(e);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (!opt) {
|
|
188
|
+
_context3.next = 32;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
_context3.next = 21;
|
|
192
|
+
return new _index.AR(opt.ar).init(opt.jwk);
|
|
193
|
+
case 21:
|
|
194
|
+
_ar = _context3.sent;
|
|
195
|
+
_src = new Src({
|
|
196
|
+
ar: _ar,
|
|
197
|
+
readFileSync: _fs.readFileSync,
|
|
198
|
+
dir: dir
|
|
199
|
+
});
|
|
200
|
+
_context3.next = 25;
|
|
201
|
+
return new _index.AO(opt.ao).init(opt.jwk);
|
|
202
|
+
case 25:
|
|
203
|
+
_ao = _context3.sent;
|
|
204
|
+
_context3.next = 28;
|
|
205
|
+
return new _index.AO(opt.ao2).init(opt.jwk);
|
|
206
|
+
case 28:
|
|
207
|
+
_ao2 = _context3.sent;
|
|
208
|
+
console.log("cache:\t", optPath);
|
|
209
|
+
console.log("addr:\t", _ar.addr);
|
|
210
|
+
return _context3.abrupt("return", {
|
|
211
|
+
opt: opt,
|
|
212
|
+
ar: _ar,
|
|
213
|
+
ao2: _ao2,
|
|
214
|
+
ao: _ao,
|
|
215
|
+
src: _src
|
|
216
|
+
});
|
|
217
|
+
case 32:
|
|
218
|
+
// ar
|
|
219
|
+
(_arweave = arweave) !== null && _arweave !== void 0 ? _arweave : arweave = {
|
|
220
|
+
port: 4000
|
|
221
|
+
};
|
|
222
|
+
(_aoconnect = aoconnect) !== null && _aoconnect !== void 0 ? _aoconnect : aoconnect = {
|
|
223
|
+
MU_URL: "http://localhost:4002",
|
|
224
|
+
CU_URL: "http://localhost:4004",
|
|
225
|
+
GATEWAY_URL: "http://localhost:4000"
|
|
226
|
+
};
|
|
227
|
+
ar = new _index.AR(arweave);
|
|
228
|
+
_context3.next = 37;
|
|
229
|
+
return ar.gen("10");
|
|
230
|
+
case 37:
|
|
231
|
+
src = new Src({
|
|
232
|
+
ar: ar,
|
|
233
|
+
readFileSync: _fs.readFileSync,
|
|
234
|
+
dir: dir
|
|
235
|
+
});
|
|
236
|
+
opt = {
|
|
237
|
+
ar: _objectSpread({}, arweave),
|
|
238
|
+
jwk: ar.jwk
|
|
239
|
+
};
|
|
240
|
+
if (!(!auth && /localhost/.test((_aoconnect$CU_URL = (_aoconnect2 = aoconnect) === null || _aoconnect2 === void 0 ? void 0 : _aoconnect2.CU_URL) !== null && _aoconnect$CU_URL !== void 0 ? _aoconnect$CU_URL : ""))) {
|
|
241
|
+
_context3.next = 43;
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
_context3.next = 42;
|
|
245
|
+
return fetch(aoconnect.CU_URL).then(function (r) {
|
|
246
|
+
return r.json();
|
|
247
|
+
});
|
|
248
|
+
case 42:
|
|
249
|
+
auth = _context3.sent.address;
|
|
250
|
+
case 43:
|
|
251
|
+
_context3.next = 45;
|
|
252
|
+
return src.upload("aos-sqlite", "wasm");
|
|
253
|
+
case 45:
|
|
254
|
+
wasm = _context3.sent;
|
|
255
|
+
_context3.next = 48;
|
|
256
|
+
return src.upload("aos", "wasm");
|
|
257
|
+
case 48:
|
|
258
|
+
wasm2 = _context3.sent;
|
|
259
|
+
_context3.next = 51;
|
|
260
|
+
return src.upload("aos2_0_1", "wasm");
|
|
261
|
+
case 51:
|
|
262
|
+
wasm_aos2 = _context3.sent;
|
|
263
|
+
ao = new _index.AO({
|
|
264
|
+
aoconnect: aoconnect,
|
|
265
|
+
ar: ar,
|
|
266
|
+
authority: auth
|
|
267
|
+
});
|
|
268
|
+
_context3.t5 = ao;
|
|
269
|
+
_context3.next = 56;
|
|
270
|
+
return ar.data(wasm_aos2);
|
|
271
|
+
case 56:
|
|
272
|
+
_context3.t6 = _context3.sent;
|
|
273
|
+
_context3.t7 = {
|
|
274
|
+
data: _context3.t6
|
|
275
|
+
};
|
|
276
|
+
_context3.next = 60;
|
|
277
|
+
return _context3.t5.postModule.call(_context3.t5, _context3.t7);
|
|
278
|
+
case 60:
|
|
279
|
+
_yield$ao$postModule = _context3.sent;
|
|
280
|
+
module_aos2 = _yield$ao$postModule.id;
|
|
281
|
+
_context3.t8 = ao;
|
|
282
|
+
_context3.next = 65;
|
|
283
|
+
return ar.data(wasm);
|
|
284
|
+
case 65:
|
|
285
|
+
_context3.t9 = _context3.sent;
|
|
286
|
+
_context3.t10 = {
|
|
287
|
+
data: _context3.t9,
|
|
288
|
+
overwrite: true
|
|
289
|
+
};
|
|
290
|
+
_context3.next = 69;
|
|
291
|
+
return _context3.t8.postModule.call(_context3.t8, _context3.t10);
|
|
292
|
+
case 69:
|
|
293
|
+
_yield$ao$postModule2 = _context3.sent;
|
|
294
|
+
module_sqlite = _yield$ao$postModule2.id;
|
|
295
|
+
_context3.t11 = ao;
|
|
296
|
+
_context3.next = 74;
|
|
297
|
+
return ar.data(wasm2);
|
|
298
|
+
case 74:
|
|
299
|
+
_context3.t12 = _context3.sent;
|
|
300
|
+
_context3.t13 = {
|
|
301
|
+
data: _context3.t12,
|
|
302
|
+
overwrite: true
|
|
303
|
+
};
|
|
304
|
+
_context3.next = 78;
|
|
305
|
+
return _context3.t11.postModule.call(_context3.t11, _context3.t13);
|
|
306
|
+
case 78:
|
|
307
|
+
_yield$ao$postModule3 = _context3.sent;
|
|
308
|
+
module = _yield$ao$postModule3.id;
|
|
309
|
+
_context3.next = 82;
|
|
310
|
+
return ao.postScheduler({
|
|
311
|
+
url: "http://su",
|
|
312
|
+
overwrite: true
|
|
313
|
+
});
|
|
314
|
+
case 82:
|
|
315
|
+
_yield$ao$postSchedul = _context3.sent;
|
|
316
|
+
scheduler = _yield$ao$postSchedul.scheduler;
|
|
317
|
+
opt.ao = {
|
|
318
|
+
module: module_sqlite,
|
|
319
|
+
scheduler: scheduler,
|
|
320
|
+
aoconnect: aoconnect,
|
|
321
|
+
ar: opt.ar,
|
|
322
|
+
authority: auth
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
// ao2
|
|
326
|
+
_context3.next = 87;
|
|
327
|
+
return new _index.AO({
|
|
328
|
+
aoconnect: aoconnect,
|
|
329
|
+
ar: ar,
|
|
330
|
+
authority: auth,
|
|
331
|
+
module: module_aos2,
|
|
332
|
+
scheduler: scheduler
|
|
333
|
+
}).init(ar.jwk);
|
|
334
|
+
case 87:
|
|
335
|
+
ao2 = _context3.sent;
|
|
336
|
+
opt.ao2 = {
|
|
337
|
+
module: module_aos2,
|
|
338
|
+
scheduler: scheduler,
|
|
339
|
+
aoconnect: aoconnect,
|
|
340
|
+
ar: opt.ar,
|
|
341
|
+
authority: auth
|
|
342
|
+
};
|
|
343
|
+
if (auth) opt.ao.authority = auth;
|
|
344
|
+
opt.authority = auth;
|
|
345
|
+
opt.targets = targets;
|
|
346
|
+
opt.modules = {
|
|
347
|
+
aos2: module_aos2,
|
|
348
|
+
aos1: module,
|
|
349
|
+
sqlite: module_sqlite
|
|
350
|
+
};
|
|
351
|
+
if (cache) {
|
|
352
|
+
if (!(0, _fs.existsSync)(_cacheDir)) (0, _fs.mkdirSync)(_cacheDir);
|
|
353
|
+
(0, _fs.writeFileSync)(optPath, JSON.stringify(opt));
|
|
354
|
+
}
|
|
355
|
+
return _context3.abrupt("return", {
|
|
356
|
+
opt: opt,
|
|
357
|
+
ao: ao,
|
|
358
|
+
ar: ar,
|
|
359
|
+
src: src,
|
|
360
|
+
ao2: ao2
|
|
361
|
+
});
|
|
362
|
+
case 95:
|
|
363
|
+
case "end":
|
|
364
|
+
return _context3.stop();
|
|
365
|
+
}
|
|
366
|
+
}, _callee3);
|
|
367
|
+
}));
|
|
368
|
+
return function setup() {
|
|
369
|
+
return _ref3.apply(this, arguments);
|
|
370
|
+
};
|
|
371
|
+
}();
|
|
372
|
+
var ok = exports.ok = function ok(obj) {
|
|
373
|
+
if (obj.err) console.log(obj.err);
|
|
374
|
+
_assert["default"].equal(obj.err, null);
|
|
375
|
+
return obj;
|
|
376
|
+
};
|
|
377
|
+
var fail = exports.fail = function fail(obj) {
|
|
378
|
+
if (!obj.err) console.log(obj.res);
|
|
379
|
+
_assert["default"].notEqual(obj.err, null);
|
|
380
|
+
return obj;
|
|
381
|
+
};
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "AO", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _ao["default"];
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "AR", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _ar["default"];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _ar = _interopRequireDefault(require("./ar.js"));
|
|
19
|
+
var _ao = _interopRequireDefault(require("./ao.js"));
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|