@onekeyfe/hd-transport-react-native 0.1.6 → 0.1.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,IAAI,aAAa,EAC3B,MAAM,EAEN,cAAc,EAEf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,SAAiC,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAkB,QAAQ,EAA6B,MAAM,qBAAqB,CAAC;AAa1F,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAmBjE,MAAM,CAAC,OAAO,OAAO,uBAAuB;IAC1C,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;IAEzC,SAAS,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAEnE,UAAU,UAAS;IAEnB,OAAO,UAAS;IAEhB,WAAW,SAAQ;IAEnB,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;gBAE5B,OAAO,EAAE,gBAAgB;IAIrC,IAAI;IAEJ,SAAS,CAAC,UAAU,EAAE,GAAG;IAMzB,MAAM;IAIN,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC;IAYjC,SAAS;IAoET,OAAO,CAAC,KAAK,EAAE,eAAe;;;IA8JpC,sBAAsB,CAAC,cAAc,EAAE,cAAc;IAmD/C,OAAO,CAAC,IAAI,EAAE,MAAM;IAcpB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IA+EpE,IAAI;IAIJ,MAAM;CAOP"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,IAAI,aAAa,EAC3B,MAAM,EAEN,cAAc,EAEf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,SAAiC,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAkB,QAAQ,EAA6B,MAAM,qBAAqB,CAAC;AAa1F,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAmBjE,MAAM,CAAC,OAAO,OAAO,uBAAuB;IAC1C,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;IAEzC,SAAS,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAEnE,UAAU,UAAS;IAEnB,OAAO,UAAS;IAEhB,WAAW,SAAQ;IAEnB,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;gBAE5B,OAAO,EAAE,gBAAgB;IAIrC,IAAI;IAEJ,SAAS,CAAC,UAAU,EAAE,GAAG;IAMzB,MAAM;IAIN,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC;IAYjC,SAAS;IAsET,OAAO,CAAC,KAAK,EAAE,eAAe;;;IA+JpC,sBAAsB,CAAC,cAAc,EAAE,cAAc;IA4D/C,OAAO,CAAC,IAAI,EAAE,MAAM;IAcpB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IA+EpE,IAAI;IAIJ,MAAM;CAOP"}
package/dist/index.js CHANGED
@@ -226,6 +226,9 @@ class ReactNativeBleTransport {
226
226
  if ([reactNativeBlePlx.BleErrorCode.BluetoothPoweredOff, reactNativeBlePlx.BleErrorCode.BluetoothInUnknownState].includes(error.errorCode)) {
227
227
  reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BlePermissionError));
228
228
  }
229
+ else if (error.errorCode === reactNativeBlePlx.BleErrorCode.BluetoothUnauthorized) {
230
+ reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleLocationError));
231
+ }
229
232
  else {
230
233
  reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleScanError, (_a = error.reason) !== null && _a !== void 0 ? _a : ''));
231
234
  }
@@ -381,9 +384,10 @@ class ReactNativeBleTransport {
381
384
  const transport = new BleTransport(device, writeCharacteristic, notifyCharacteristic);
382
385
  transport.nofitySubscription = this._monitorCharacteristic(transport.notifyCharacteristic);
383
386
  transportCache[uuid] = transport;
384
- device.onDisconnected(() => {
387
+ const disconnectSubscription = device.onDisconnected(() => {
385
388
  console.log('device disconnect: ', device === null || device === void 0 ? void 0 : device.id);
386
389
  this.release(uuid);
390
+ disconnectSubscription === null || disconnectSubscription === void 0 ? void 0 : disconnectSubscription.remove();
387
391
  });
388
392
  return { uuid };
389
393
  });
@@ -392,9 +396,13 @@ class ReactNativeBleTransport {
392
396
  let bufferLength = 0;
393
397
  let buffer$1 = [];
394
398
  const subscription = characteristic.monitor((error, c) => {
395
- var _a, _b;
399
+ var _a, _b, _c;
396
400
  if (error) {
397
401
  console.log(`error monitor ${characteristic.uuid}, deviceId: ${characteristic.deviceID}: ${error}`);
402
+ if (this.runPromise) {
403
+ this.runPromise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleCharacteristicNotifyError, (_a = error.reason) !== null && _a !== void 0 ? _a : error.message));
404
+ console.log('@onekey/hd-ble-sdk: monitor notify error, and has unreleased Promise');
405
+ }
398
406
  return;
399
407
  }
400
408
  if (!c) {
@@ -413,12 +421,12 @@ class ReactNativeBleTransport {
413
421
  const value = buffer.Buffer.from(buffer$1);
414
422
  bufferLength = 0;
415
423
  buffer$1 = [];
416
- (_a = this.runPromise) === null || _a === void 0 ? void 0 : _a.resolve(value.toString('hex'));
424
+ (_b = this.runPromise) === null || _b === void 0 ? void 0 : _b.resolve(value.toString('hex'));
417
425
  }
418
426
  }
419
427
  catch (error) {
420
428
  console.log('monitor data error: ', error);
421
- (_b = this.runPromise) === null || _b === void 0 ? void 0 : _b.reject(error);
429
+ (_c = this.runPromise) === null || _c === void 0 ? void 0 : _c.reject(error);
422
430
  }
423
431
  });
424
432
  return () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-react-native",
3
- "version": "0.1.6",
3
+ "version": "0.1.9",
4
4
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -20,10 +20,10 @@
20
20
  "lint:fix": "eslint . --fix"
21
21
  },
22
22
  "dependencies": {
23
- "@onekeyfe/hd-shared": "^0.1.6",
24
- "@onekeyfe/hd-transport": "^0.1.6",
23
+ "@onekeyfe/hd-shared": "^0.1.9",
24
+ "@onekeyfe/hd-transport": "^0.1.9",
25
25
  "react-native-ble-manager": "^8.1.0",
26
26
  "react-native-ble-plx": "^2.0.3"
27
27
  },
28
- "gitHead": "ebe2789fa24cbfb798c9be445678e71e67e33d71"
28
+ "gitHead": "6abdc58c1614920bf941d7e56f2768aa76f56932"
29
29
  }
package/src/index.ts CHANGED
@@ -110,6 +110,8 @@ export default class ReactNativeBleTransport {
110
110
  )
111
111
  ) {
112
112
  reject(ERRORS.TypedError(HardwareErrorCode.BlePermissionError));
113
+ } else if (error.errorCode === BleErrorCode.BluetoothUnauthorized) {
114
+ reject(ERRORS.TypedError(HardwareErrorCode.BleLocationError));
113
115
  } else {
114
116
  reject(ERRORS.TypedError(HardwareErrorCode.BleScanError, error.reason ?? ''));
115
117
  }
@@ -300,9 +302,10 @@ export default class ReactNativeBleTransport {
300
302
  transport.nofitySubscription = this._monitorCharacteristic(transport.notifyCharacteristic);
301
303
  transportCache[uuid] = transport;
302
304
 
303
- device.onDisconnected(() => {
305
+ const disconnectSubscription = device.onDisconnected(() => {
304
306
  console.log('device disconnect: ', device?.id);
305
307
  this.release(uuid);
308
+ disconnectSubscription?.remove();
306
309
  });
307
310
 
308
311
  return { uuid };
@@ -318,6 +321,15 @@ export default class ReactNativeBleTransport {
318
321
  error as unknown as string
319
322
  }`
320
323
  );
324
+ if (this.runPromise) {
325
+ this.runPromise.reject(
326
+ ERRORS.TypedError(
327
+ HardwareErrorCode.BleCharacteristicNotifyError,
328
+ error.reason ?? error.message
329
+ )
330
+ );
331
+ console.log('@onekey/hd-ble-sdk: monitor notify error, and has unreleased Promise');
332
+ }
321
333
  return;
322
334
  }
323
335