wao 0.14.5 → 0.14.6

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.
Files changed (3) hide show
  1. package/cjs/ao.js +200 -47
  2. package/esm/ao.js +37 -2
  3. package/package.json +2 -2
package/cjs/ao.js CHANGED
@@ -1545,6 +1545,124 @@ var AO = /*#__PURE__*/function () {
1545
1545
  }
1546
1546
  return deploy;
1547
1547
  }()
1548
+ }, {
1549
+ key: "var",
1550
+ value: function () {
1551
+ var _var2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22(_ref26) {
1552
+ var pid, data, _ref26$json, json, _ref26$pretty, pretty, _yield$this$dry2, _var3, _yield$this$dry3, _var4;
1553
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1554
+ while (1) switch (_context22.prev = _context22.next) {
1555
+ case 0:
1556
+ pid = _ref26.pid, data = _ref26.data, _ref26$json = _ref26.json, json = _ref26$json === void 0 ? true : _ref26$json, _ref26$pretty = _ref26.pretty, pretty = _ref26$pretty === void 0 ? false : _ref26$pretty;
1557
+ if (!json) {
1558
+ _context22.next = 31;
1559
+ break;
1560
+ }
1561
+ _context22.next = 4;
1562
+ return this.dry({
1563
+ act: "Eval",
1564
+ data: "require(\"json\").encode(".concat(data, ")"),
1565
+ pid: pid
1566
+ });
1567
+ case 4:
1568
+ _context22.t3 = _yield$this$dry2 = _context22.sent;
1569
+ _context22.t2 = _context22.t3 === null;
1570
+ if (_context22.t2) {
1571
+ _context22.next = 8;
1572
+ break;
1573
+ }
1574
+ _context22.t2 = _yield$this$dry2 === void 0;
1575
+ case 8:
1576
+ _context22.t1 = _context22.t2;
1577
+ if (_context22.t1) {
1578
+ _context22.next = 11;
1579
+ break;
1580
+ }
1581
+ _context22.t1 = (_yield$this$dry2 = _yield$this$dry2.res) === null || _yield$this$dry2 === void 0;
1582
+ case 11:
1583
+ _context22.t0 = _context22.t1;
1584
+ if (_context22.t0) {
1585
+ _context22.next = 14;
1586
+ break;
1587
+ }
1588
+ _context22.t0 = (_yield$this$dry2 = _yield$this$dry2.Output) === null || _yield$this$dry2 === void 0;
1589
+ case 14:
1590
+ if (!_context22.t0) {
1591
+ _context22.next = 18;
1592
+ break;
1593
+ }
1594
+ _context22.t4 = void 0;
1595
+ _context22.next = 19;
1596
+ break;
1597
+ case 18:
1598
+ _context22.t4 = _yield$this$dry2.data;
1599
+ case 19:
1600
+ _var3 = _context22.t4;
1601
+ if (!_var3) {
1602
+ _context22.next = 28;
1603
+ break;
1604
+ }
1605
+ _context22.prev = 21;
1606
+ return _context22.abrupt("return", JSON.parse(strip(_var3)));
1607
+ case 25:
1608
+ _context22.prev = 25;
1609
+ _context22.t5 = _context22["catch"](21);
1610
+ return _context22.abrupt("return", strip(_var3));
1611
+ case 28:
1612
+ return _context22.abrupt("return", _var3);
1613
+ case 31:
1614
+ _context22.next = 33;
1615
+ return this.dry({
1616
+ act: "Eval",
1617
+ data: data,
1618
+ pid: pid
1619
+ });
1620
+ case 33:
1621
+ _context22.t9 = _yield$this$dry3 = _context22.sent;
1622
+ _context22.t8 = _context22.t9 === null;
1623
+ if (_context22.t8) {
1624
+ _context22.next = 37;
1625
+ break;
1626
+ }
1627
+ _context22.t8 = _yield$this$dry3 === void 0;
1628
+ case 37:
1629
+ _context22.t7 = _context22.t8;
1630
+ if (_context22.t7) {
1631
+ _context22.next = 40;
1632
+ break;
1633
+ }
1634
+ _context22.t7 = (_yield$this$dry3 = _yield$this$dry3.res) === null || _yield$this$dry3 === void 0;
1635
+ case 40:
1636
+ _context22.t6 = _context22.t7;
1637
+ if (_context22.t6) {
1638
+ _context22.next = 43;
1639
+ break;
1640
+ }
1641
+ _context22.t6 = (_yield$this$dry3 = _yield$this$dry3.Output) === null || _yield$this$dry3 === void 0;
1642
+ case 43:
1643
+ if (!_context22.t6) {
1644
+ _context22.next = 47;
1645
+ break;
1646
+ }
1647
+ _context22.t10 = void 0;
1648
+ _context22.next = 48;
1649
+ break;
1650
+ case 47:
1651
+ _context22.t10 = _yield$this$dry3.data;
1652
+ case 48:
1653
+ _var4 = _context22.t10;
1654
+ return _context22.abrupt("return", pretty ? _var4 : strip(_var4));
1655
+ case 50:
1656
+ case "end":
1657
+ return _context22.stop();
1658
+ }
1659
+ }, _callee22, this, [[21, 25]]);
1660
+ }));
1661
+ function _var(_x25) {
1662
+ return _var2.apply(this, arguments);
1663
+ }
1664
+ return _var;
1665
+ }()
1548
1666
  }, {
1549
1667
  key: "p",
1550
1668
  value: function p(pid) {
@@ -1552,6 +1670,9 @@ var AO = /*#__PURE__*/function () {
1552
1670
  }
1553
1671
  }]);
1554
1672
  }();
1673
+ function strip(str) {
1674
+ return str.replace(/\x1B\[[0-9;]*[JKmsu]/g, "");
1675
+ }
1555
1676
  var getParams = function getParams(tags, opts) {
1556
1677
  var _tags = tags;
1557
1678
  var _opts = opts;
@@ -1578,24 +1699,24 @@ var Process = /*#__PURE__*/function () {
1578
1699
  return _createClass(Process, [{
1579
1700
  key: "load",
1580
1701
  value: function () {
1581
- var _load2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1702
+ var _load2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1582
1703
  var opt,
1583
- _args22 = arguments;
1584
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1585
- while (1) switch (_context22.prev = _context22.next) {
1704
+ _args23 = arguments;
1705
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1706
+ while (1) switch (_context23.prev = _context23.next) {
1586
1707
  case 0:
1587
- opt = _args22.length > 0 && _args22[0] !== undefined ? _args22[0] : {};
1588
- _context22.next = 3;
1708
+ opt = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {};
1709
+ _context23.next = 3;
1589
1710
  return this.ao.load(_objectSpread({
1590
1711
  pid: this.pid
1591
1712
  }, opt));
1592
1713
  case 3:
1593
- return _context22.abrupt("return", _context22.sent);
1714
+ return _context23.abrupt("return", _context23.sent);
1594
1715
  case 4:
1595
1716
  case "end":
1596
- return _context22.stop();
1717
+ return _context23.stop();
1597
1718
  }
1598
- }, _callee22, this);
1719
+ }, _callee23, this);
1599
1720
  }));
1600
1721
  function load() {
1601
1722
  return _load2.apply(this, arguments);
@@ -1605,27 +1726,27 @@ var Process = /*#__PURE__*/function () {
1605
1726
  }, {
1606
1727
  key: "msg",
1607
1728
  value: function () {
1608
- var _msg2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23(act, tags, opts) {
1729
+ var _msg2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24(act, tags, opts) {
1609
1730
  var _getParams, _tags, _opts;
1610
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1611
- while (1) switch (_context23.prev = _context23.next) {
1731
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1732
+ while (1) switch (_context24.prev = _context24.next) {
1612
1733
  case 0:
1613
1734
  _getParams = getParams(tags, opts), _tags = _getParams._tags, _opts = _getParams._opts;
1614
- _context23.next = 3;
1735
+ _context24.next = 3;
1615
1736
  return this.ao.msg(_objectSpread({
1616
1737
  pid: this.pid,
1617
1738
  act: act,
1618
1739
  tags: _tags
1619
1740
  }, _opts));
1620
1741
  case 3:
1621
- return _context23.abrupt("return", _context23.sent);
1742
+ return _context24.abrupt("return", _context24.sent);
1622
1743
  case 4:
1623
1744
  case "end":
1624
- return _context23.stop();
1745
+ return _context24.stop();
1625
1746
  }
1626
- }, _callee23, this);
1747
+ }, _callee24, this);
1627
1748
  }));
1628
- function msg(_x25, _x26, _x27) {
1749
+ function msg(_x26, _x27, _x28) {
1629
1750
  return _msg2.apply(this, arguments);
1630
1751
  }
1631
1752
  return msg;
@@ -1633,27 +1754,27 @@ var Process = /*#__PURE__*/function () {
1633
1754
  }, {
1634
1755
  key: "dry",
1635
1756
  value: function () {
1636
- var _dry2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24(act, tags, opts) {
1757
+ var _dry2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25(act, tags, opts) {
1637
1758
  var _getParams2, _tags, _opts;
1638
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1639
- while (1) switch (_context24.prev = _context24.next) {
1759
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1760
+ while (1) switch (_context25.prev = _context25.next) {
1640
1761
  case 0:
1641
1762
  _getParams2 = getParams(tags, opts), _tags = _getParams2._tags, _opts = _getParams2._opts;
1642
- _context24.next = 3;
1763
+ _context25.next = 3;
1643
1764
  return this.ao.dry(_objectSpread({
1644
1765
  pid: this.pid,
1645
1766
  act: act,
1646
1767
  tags: _tags
1647
1768
  }, _opts));
1648
1769
  case 3:
1649
- return _context24.abrupt("return", _context24.sent);
1770
+ return _context25.abrupt("return", _context25.sent);
1650
1771
  case 4:
1651
1772
  case "end":
1652
- return _context24.stop();
1773
+ return _context25.stop();
1653
1774
  }
1654
- }, _callee24, this);
1775
+ }, _callee25, this);
1655
1776
  }));
1656
- function dry(_x28, _x29, _x30) {
1777
+ function dry(_x29, _x30, _x31) {
1657
1778
  return _dry2.apply(this, arguments);
1658
1779
  }
1659
1780
  return dry;
@@ -1661,28 +1782,28 @@ var Process = /*#__PURE__*/function () {
1661
1782
  }, {
1662
1783
  key: "m",
1663
1784
  value: function () {
1664
- var _m = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
1785
+ var _m = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
1665
1786
  var res,
1666
- _args25 = arguments;
1667
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1668
- while (1) switch (_context25.prev = _context25.next) {
1787
+ _args26 = arguments;
1788
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1789
+ while (1) switch (_context26.prev = _context26.next) {
1669
1790
  case 0:
1670
- _context25.next = 2;
1671
- return this.msg.apply(this, _args25);
1791
+ _context26.next = 2;
1792
+ return this.msg.apply(this, _args26);
1672
1793
  case 2:
1673
- res = _context25.sent;
1794
+ res = _context26.sent;
1674
1795
  if (!res.err) {
1675
- _context25.next = 5;
1796
+ _context26.next = 5;
1676
1797
  break;
1677
1798
  }
1678
1799
  throw Error(res.err);
1679
1800
  case 5:
1680
- return _context25.abrupt("return", res.out);
1801
+ return _context26.abrupt("return", res.out);
1681
1802
  case 6:
1682
1803
  case "end":
1683
- return _context25.stop();
1804
+ return _context26.stop();
1684
1805
  }
1685
- }, _callee25, this);
1806
+ }, _callee26, this);
1686
1807
  }));
1687
1808
  function m() {
1688
1809
  return _m.apply(this, arguments);
@@ -1692,34 +1813,66 @@ var Process = /*#__PURE__*/function () {
1692
1813
  }, {
1693
1814
  key: "d",
1694
1815
  value: function () {
1695
- var _d = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
1816
+ var _d = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
1696
1817
  var res,
1697
- _args26 = arguments;
1698
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1699
- while (1) switch (_context26.prev = _context26.next) {
1818
+ _args27 = arguments;
1819
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1820
+ while (1) switch (_context27.prev = _context27.next) {
1700
1821
  case 0:
1701
- _context26.next = 2;
1702
- return this.dry.apply(this, _args26);
1822
+ _context27.next = 2;
1823
+ return this.dry.apply(this, _args27);
1703
1824
  case 2:
1704
- res = _context26.sent;
1825
+ res = _context27.sent;
1705
1826
  if (!res.err) {
1706
- _context26.next = 5;
1827
+ _context27.next = 5;
1707
1828
  break;
1708
1829
  }
1709
1830
  throw Error(res.err);
1710
1831
  case 5:
1711
- return _context26.abrupt("return", res.out);
1832
+ return _context27.abrupt("return", res.out);
1712
1833
  case 6:
1713
1834
  case "end":
1714
- return _context26.stop();
1835
+ return _context27.stop();
1715
1836
  }
1716
- }, _callee26, this);
1837
+ }, _callee27, this);
1717
1838
  }));
1718
1839
  function d() {
1719
1840
  return _d.apply(this, arguments);
1720
1841
  }
1721
1842
  return d;
1722
1843
  }()
1844
+ }, {
1845
+ key: "v",
1846
+ value: function () {
1847
+ var _v2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28(data) {
1848
+ var json,
1849
+ pretty,
1850
+ _args28 = arguments;
1851
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
1852
+ while (1) switch (_context28.prev = _context28.next) {
1853
+ case 0:
1854
+ json = _args28.length > 1 && _args28[1] !== undefined ? _args28[1] : true;
1855
+ pretty = _args28.length > 2 && _args28[2] !== undefined ? _args28[2] : false;
1856
+ _context28.next = 4;
1857
+ return this.ao["var"]({
1858
+ pid: this.pid,
1859
+ data: data,
1860
+ json: json,
1861
+ pretty: pretty
1862
+ });
1863
+ case 4:
1864
+ return _context28.abrupt("return", _context28.sent);
1865
+ case 5:
1866
+ case "end":
1867
+ return _context28.stop();
1868
+ }
1869
+ }, _callee28, this);
1870
+ }));
1871
+ function v(_x32) {
1872
+ return _v2.apply(this, arguments);
1873
+ }
1874
+ return v;
1875
+ }()
1723
1876
  }]);
1724
1877
  }();
1725
1878
  var _default = exports["default"] = AO;
package/esm/ao.js CHANGED
@@ -59,7 +59,7 @@ const getHash = res =>
59
59
  Messages: res.Messages ?? [],
60
60
  Spawns: res.Spawns ?? [],
61
61
  Assignments: res.Assignments ?? [],
62
- }),
62
+ })
63
63
  )
64
64
 
65
65
  function createDataItemSigner2(wallet) {
@@ -597,7 +597,7 @@ class AO {
597
597
  if (typeof text === "number") text = Number(text).toString()
598
598
  _data = _data.replace(
599
599
  new RegExp(`\<${k}\>`, "g"),
600
- text.replace(/'/g, "\\'"),
600
+ text.replace(/'/g, "\\'")
601
601
  )
602
602
  }
603
603
  out = _data
@@ -707,11 +707,43 @@ class AO {
707
707
  if (result.pid) result.p = this.p(result.pid)
708
708
  return result
709
709
  }
710
+ async var({ pid, data, json = true, pretty = false }) {
711
+ if (json) {
712
+ const _var = (
713
+ await this.dry({
714
+ act: "Eval",
715
+ data: `require("json").encode(${data})`,
716
+ pid,
717
+ })
718
+ )?.res?.Output?.data
719
+ if (_var) {
720
+ try {
721
+ return JSON.parse(strip(_var))
722
+ } catch (e) {
723
+ return strip(_var)
724
+ }
725
+ }
726
+ return _var
727
+ } else {
728
+ const _var = (
729
+ await this.dry({
730
+ act: "Eval",
731
+ data,
732
+ pid,
733
+ })
734
+ )?.res?.Output?.data
735
+ return pretty ? _var : strip(_var)
736
+ }
737
+ }
710
738
  p(pid) {
711
739
  return new Process(pid, this)
712
740
  }
713
741
  }
714
742
 
743
+ function strip(str) {
744
+ return str.replace(/\x1B\[[0-9;]*[JKmsu]/g, "")
745
+ }
746
+
715
747
  const getParams = (tags, opts) => {
716
748
  let _tags = tags
717
749
  let _opts = opts
@@ -760,6 +792,9 @@ class Process {
760
792
  if (res.err) throw Error(res.err)
761
793
  return res.out
762
794
  }
795
+ async v(data, json = true, pretty = false) {
796
+ return await this.ao.var({ pid: this.pid, data, json, pretty })
797
+ }
763
798
  }
764
799
 
765
800
  export default AO
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.14.5",
3
+ "version": "0.14.6",
4
4
  "bin": {
5
5
  "wao": "./cjs/cli.js",
6
6
  "wao-esm": "./esm/cli.js"
@@ -26,12 +26,12 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "aoconnect-wao": "https://gitpkg.vercel.app/weavedb/ao/connect?abd2992689dc5983d5cd48b38fb997b0532f192a&scripts.postinstall=npm%20install%20--ignore-scripts%20%26%26%20npm%20run%20build",
30
29
  "@babel/plugin-transform-modules-commonjs": "^7.24.8",
31
30
  "@bokuweb/zstd-wasm": "^0.0.22",
32
31
  "@dha-team/arbundles": "^1.0.1",
33
32
  "@permaweb/ao-loader": "^0.0.44",
34
33
  "@permaweb/aoconnect": "^0.0.62",
34
+ "aoconnect-wao": "https://gitpkg.vercel.app/weavedb/ao/connect?abd2992689dc5983d5cd48b38fb997b0532f192a&scripts.postinstall=npm%20install%20--ignore-scripts%20%26%26%20npm%20run%20build",
35
35
  "arbundles": "^0.11.1",
36
36
  "arjson": "^0.0.2",
37
37
  "arweave": "^1.15.1",