wao 0.7.0 → 0.7.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/tar.js CHANGED
@@ -265,7 +265,7 @@ var AR = /*#__PURE__*/function (_MAR) {
265
265
  };
266
266
  data = di.data;
267
267
  try {
268
- data = _base64url["default"].decode(di.data);
268
+ //data = base64url.decode(di.data)
269
269
  } catch (e) {}
270
270
  _context4.t0 = {
271
271
  size: data_size,
@@ -545,7 +545,7 @@ var AR = /*#__PURE__*/function (_MAR) {
545
545
  }, {
546
546
  key: "data",
547
547
  value: function () {
548
- var _data2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(id, _string) {
548
+ var _data2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(id, _string, log) {
549
549
  var _tx$data;
550
550
  var decode, string, tx, _data, isBuf, isStr;
551
551
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
@@ -559,7 +559,11 @@ var AR = /*#__PURE__*/function (_MAR) {
559
559
  }
560
560
  tx = this.mem.txs[id];
561
561
  _data = (_tx$data = tx === null || tx === void 0 ? void 0 : tx.data) !== null && _tx$data !== void 0 ? _tx$data : null;
562
- if ((tx === null || tx === void 0 ? void 0 : tx.format) === 2 && _data) _data = Buffer.from(_data, "base64");
562
+ if ((tx === null || tx === void 0 ? void 0 : tx.format) === 2 && _data) {
563
+ _data = Buffer.from(_data, "base64");
564
+ } else {
565
+ _data = Buffer.from(_base64url["default"].decode(_data));
566
+ }
563
567
  isBuf = (0, _ramda.is)(Uint8Array, _data) || (0, _ramda.is)(ArrayBuffer, _data);
564
568
  isStr = (0, _ramda.is)(String, _data);
565
569
  if (!(decode === false)) {
@@ -573,7 +577,7 @@ var AR = /*#__PURE__*/function (_MAR) {
573
577
  _context7.next = 17;
574
578
  break;
575
579
  }
576
- return _context7.abrupt("return", Buffer.from(_data).toString());
580
+ return _context7.abrupt("return", _data.toString());
577
581
  case 17:
578
582
  if (!(isStr && string !== true)) {
579
583
  _context7.next = 19;
@@ -588,7 +592,7 @@ var AR = /*#__PURE__*/function (_MAR) {
588
592
  }
589
593
  }, _callee7, this);
590
594
  }));
591
- function data(_x9, _x10) {
595
+ function data(_x9, _x10, _x11) {
592
596
  return _data2.apply(this, arguments);
593
597
  }
594
598
  return data;
package/cjs/weavedrive.js CHANGED
@@ -317,9 +317,7 @@ var WeaveDrive = exports["default"] = /*#__PURE__*/_createClass(function WeaveDr
317
317
  dst_ptr = Number(raw_dst_ptr);
318
318
  stream = 0;
319
319
  for (i = 0; i < FS.streams.length; i++) {
320
- if (FS.streams[i].fd === fd) {
321
- stream = FS.streams[i];
322
- }
320
+ if (FS.streams[i].fd === fd) stream = FS.streams[i];
323
321
  }
324
322
  // read block headers
325
323
  if (!stream.path.includes("/block")) {
@@ -357,7 +355,7 @@ var WeaveDrive = exports["default"] = /*#__PURE__*/_createClass(function WeaveDr
357
355
  to = Math.min(stream.node.total_size, stream.position + chunk_download_sz); //console.log("WeaveDrive: fd: ", fd, " Read length: ", to_read, " Reading ahead:", to - to_read - stream.position)
358
356
  // fetch(`/${stream.node.name}`)
359
357
  _context6.next = 21;
360
- return ar.data(stream.node.name);
358
+ return ar.data(stream.node.name, null, log);
361
359
  case 21:
362
360
  data = _context6.sent;
363
361
  // Extract the Range header to determine the start and end of the requested chunk
@@ -0,0 +1 @@
1
+ {"name":"Bob","age":40}
package/esm/aoconnect.js CHANGED
@@ -193,7 +193,6 @@ export const connect = (mem, { log = false, extensions = {} } = {}) => {
193
193
  module: p.module,
194
194
  auth: mu.addr,
195
195
  })
196
-
197
196
  const _t = tags(msg.Tags)
198
197
  res = await _module.handle(null, msg, _env)
199
198
  p.memory = res.Memory
package/esm/tar.js CHANGED
@@ -63,7 +63,7 @@ class AR extends MAR {
63
63
  this.mem.addrmap[owner] = { key: di.owner, address: owner }
64
64
  let data = di.data
65
65
  try {
66
- data = base64url.decode(di.data)
66
+ //data = base64url.decode(di.data)
67
67
  } catch (e) {}
68
68
  let _item = {
69
69
  _data: { size: data_size, type: data_type },
@@ -177,7 +177,7 @@ class AR extends MAR {
177
177
  return this.mem.txs[id]
178
178
  }
179
179
 
180
- async data(id, _string) {
180
+ async data(id, _string, log) {
181
181
  let decode = true
182
182
  let string = _string
183
183
  if (is(Object, _string)) {
@@ -186,7 +186,11 @@ class AR extends MAR {
186
186
  }
187
187
  let tx = this.mem.txs[id]
188
188
  let _data = tx?.data ?? null
189
- if (tx?.format === 2 && _data) _data = Buffer.from(_data, "base64")
189
+ if (tx?.format === 2 && _data) {
190
+ _data = Buffer.from(_data, "base64")
191
+ } else {
192
+ _data = Buffer.from(base64url.decode(_data))
193
+ }
190
194
  let isBuf = is(Uint8Array, _data) || is(ArrayBuffer, _data)
191
195
  let isStr = is(String, _data)
192
196
  if (decode === false) {
@@ -194,7 +198,7 @@ class AR extends MAR {
194
198
  return base64url.encode(_data)
195
199
  } else {
196
200
  if (isBuf && string) {
197
- return Buffer.from(_data).toString()
201
+ return _data.toString()
198
202
  } else if (isStr && string !== true) {
199
203
  return new TextEncoder().encode(_data)
200
204
  }
package/esm/weavedrive.js CHANGED
@@ -122,7 +122,6 @@ export default class WeaveDrive {
122
122
  false,
123
123
  )
124
124
  var stream = FS.open("/tx2/" + id, "r")
125
-
126
125
  return stream
127
126
  },
128
127
  async open(filename) {
@@ -190,9 +189,7 @@ export default class WeaveDrive {
190
189
 
191
190
  var stream = 0
192
191
  for (var i = 0; i < FS.streams.length; i++) {
193
- if (FS.streams[i].fd === fd) {
194
- stream = FS.streams[i]
195
- }
192
+ if (FS.streams[i].fd === fd) stream = FS.streams[i]
196
193
  }
197
194
  // read block headers
198
195
  if (stream.path.includes("/block")) {
@@ -226,8 +223,7 @@ export default class WeaveDrive {
226
223
  //console.log("WeaveDrive: fd: ", fd, " Read length: ", to_read, " Reading ahead:", to - to_read - stream.position)
227
224
 
228
225
  // fetch(`/${stream.node.name}`)
229
- const data = await ar.data(stream.node.name)
230
-
226
+ const data = await ar.data(stream.node.name, null, log)
231
227
  // Extract the Range header to determine the start and end of the requested chunk
232
228
  const start = 0
233
229
  const end = data.length
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",