@xelis/sdk 0.10.10 → 0.10.12

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.
@@ -258,22 +258,28 @@ var WSRPC = /** @class */ (function () {
258
258
  var timeoutId = null;
259
259
  var onMessage = function (msgEvent) {
260
260
  if (typeof msgEvent.data === "string") {
261
- var data = (0, parse_json_1.parseJSON)(msgEvent.data);
262
- if (data.error && data.error.message) {
263
- return reject(new Error(data.error.message));
264
- }
265
- if (Array.isArray(data) && data.length > 0 && data[0].id === id) {
266
- //@ts-ignore
267
- return resolve(data);
261
+ var data_1 = (0, parse_json_1.parseJSON)(msgEvent.data);
262
+ var evaluate_data = function () {
263
+ clearTimeout(timeoutId);
264
+ _this.socket && _this.socket.removeEventListener("message", onMessage);
265
+ if (data_1.error && data_1.error.message) {
266
+ reject(new Error(data_1.error.message));
267
+ return;
268
+ }
269
+ return resolve(data_1);
270
+ };
271
+ // this is for batch call we match the id with first item id
272
+ if (Array.isArray(data_1) && data_1.length > 0 && data_1[0].id === id) {
273
+ return evaluate_data();
268
274
  }
269
- if (data.id === id) {
270
- return resolve(data);
275
+ // the msg id is matching so we can evaluate the data
276
+ if (data_1.id === id) {
277
+ return evaluate_data();
271
278
  }
272
- if (data.id === null && id === 0) {
273
- // special case with xswd sending first call will return null id
274
- return resolve(data);
279
+ // special XSWD case - sending first call will return null id
280
+ if (data_1.id === null && id === 0) {
281
+ return evaluate_data();
275
282
  }
276
- reject(new Error("invalid data"));
277
283
  }
278
284
  };
279
285
  _this.socket.addEventListener("message", onMessage);
@@ -252,22 +252,28 @@ var WSRPC = /** @class */ (function () {
252
252
  var timeoutId = null;
253
253
  var onMessage = function (msgEvent) {
254
254
  if (typeof msgEvent.data === "string") {
255
- var data = parseJSON(msgEvent.data);
256
- if (data.error && data.error.message) {
257
- return reject(new Error(data.error.message));
258
- }
259
- if (Array.isArray(data) && data.length > 0 && data[0].id === id) {
260
- //@ts-ignore
261
- return resolve(data);
255
+ var data_1 = parseJSON(msgEvent.data);
256
+ var evaluate_data = function () {
257
+ clearTimeout(timeoutId);
258
+ _this.socket && _this.socket.removeEventListener("message", onMessage);
259
+ if (data_1.error && data_1.error.message) {
260
+ reject(new Error(data_1.error.message));
261
+ return;
262
+ }
263
+ return resolve(data_1);
264
+ };
265
+ // this is for batch call we match the id with first item id
266
+ if (Array.isArray(data_1) && data_1.length > 0 && data_1[0].id === id) {
267
+ return evaluate_data();
262
268
  }
263
- if (data.id === id) {
264
- return resolve(data);
269
+ // the msg id is matching so we can evaluate the data
270
+ if (data_1.id === id) {
271
+ return evaluate_data();
265
272
  }
266
- if (data.id === null && id === 0) {
267
- // special case with xswd sending first call will return null id
268
- return resolve(data);
273
+ // special XSWD case - sending first call will return null id
274
+ if (data_1.id === null && id === 0) {
275
+ return evaluate_data();
269
276
  }
270
- reject(new Error("invalid data"));
271
277
  }
272
278
  };
273
279
  _this.socket.addEventListener("message", onMessage);
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.10.10",
2
+ "version": "0.10.12",
3
3
  "name": "@xelis/sdk",
4
4
  "description": "Xelis software development kit for JS",
5
5
  "exports": {
@@ -27,7 +27,7 @@
27
27
  "copy-css": "copyfiles -u 1 ./src/**/*.css ./dist/cjs && copyfiles -u 1 ./src/**/*.css ./dist/esm",
28
28
  "build": "npm run clean && npm run compile && node create_esm_pkg.js && npm run fix-esm && npm run copy-css",
29
29
  "prepublishOnly": "npm run build",
30
- "publish-dev": "npm publish --tag beta",
30
+ "publish-dev": "npm publish --tag dev",
31
31
  "dev-relayer": "vite ./src/xswd/relayer/test"
32
32
  },
33
33
  "devDependencies": {