@onekeyfe/hd-transport-react-native 0.1.6 → 0.1.7
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/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -4
- package/package.json +4 -4
- package/src/index.ts +11 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -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;;;
|
|
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;;;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
|
@@ -381,9 +381,10 @@ class ReactNativeBleTransport {
|
|
|
381
381
|
const transport = new BleTransport(device, writeCharacteristic, notifyCharacteristic);
|
|
382
382
|
transport.nofitySubscription = this._monitorCharacteristic(transport.notifyCharacteristic);
|
|
383
383
|
transportCache[uuid] = transport;
|
|
384
|
-
device.onDisconnected(() => {
|
|
384
|
+
const disconnectSubscription = device.onDisconnected(() => {
|
|
385
385
|
console.log('device disconnect: ', device === null || device === void 0 ? void 0 : device.id);
|
|
386
386
|
this.release(uuid);
|
|
387
|
+
disconnectSubscription === null || disconnectSubscription === void 0 ? void 0 : disconnectSubscription.remove();
|
|
387
388
|
});
|
|
388
389
|
return { uuid };
|
|
389
390
|
});
|
|
@@ -392,9 +393,13 @@ class ReactNativeBleTransport {
|
|
|
392
393
|
let bufferLength = 0;
|
|
393
394
|
let buffer$1 = [];
|
|
394
395
|
const subscription = characteristic.monitor((error, c) => {
|
|
395
|
-
var _a, _b;
|
|
396
|
+
var _a, _b, _c;
|
|
396
397
|
if (error) {
|
|
397
398
|
console.log(`error monitor ${characteristic.uuid}, deviceId: ${characteristic.deviceID}: ${error}`);
|
|
399
|
+
if (this.runPromise) {
|
|
400
|
+
this.runPromise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleCharacteristicNotifyError, (_a = error.reason) !== null && _a !== void 0 ? _a : error.message));
|
|
401
|
+
console.log('@onekey/hd-ble-sdk: monitor notify error, and has unreleased Promise');
|
|
402
|
+
}
|
|
398
403
|
return;
|
|
399
404
|
}
|
|
400
405
|
if (!c) {
|
|
@@ -413,12 +418,12 @@ class ReactNativeBleTransport {
|
|
|
413
418
|
const value = buffer.Buffer.from(buffer$1);
|
|
414
419
|
bufferLength = 0;
|
|
415
420
|
buffer$1 = [];
|
|
416
|
-
(
|
|
421
|
+
(_b = this.runPromise) === null || _b === void 0 ? void 0 : _b.resolve(value.toString('hex'));
|
|
417
422
|
}
|
|
418
423
|
}
|
|
419
424
|
catch (error) {
|
|
420
425
|
console.log('monitor data error: ', error);
|
|
421
|
-
(
|
|
426
|
+
(_c = this.runPromise) === null || _c === void 0 ? void 0 : _c.reject(error);
|
|
422
427
|
}
|
|
423
428
|
});
|
|
424
429
|
return () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport-react-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
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.
|
|
24
|
-
"@onekeyfe/hd-transport": "^0.1.
|
|
23
|
+
"@onekeyfe/hd-shared": "^0.1.7",
|
|
24
|
+
"@onekeyfe/hd-transport": "^0.1.7",
|
|
25
25
|
"react-native-ble-manager": "^8.1.0",
|
|
26
26
|
"react-native-ble-plx": "^2.0.3"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "1d3889d02e41afd60cd0388b6e01d7f2ac7c5399"
|
|
29
29
|
}
|
package/src/index.ts
CHANGED
|
@@ -300,9 +300,10 @@ export default class ReactNativeBleTransport {
|
|
|
300
300
|
transport.nofitySubscription = this._monitorCharacteristic(transport.notifyCharacteristic);
|
|
301
301
|
transportCache[uuid] = transport;
|
|
302
302
|
|
|
303
|
-
device.onDisconnected(() => {
|
|
303
|
+
const disconnectSubscription = device.onDisconnected(() => {
|
|
304
304
|
console.log('device disconnect: ', device?.id);
|
|
305
305
|
this.release(uuid);
|
|
306
|
+
disconnectSubscription?.remove();
|
|
306
307
|
});
|
|
307
308
|
|
|
308
309
|
return { uuid };
|
|
@@ -318,6 +319,15 @@ export default class ReactNativeBleTransport {
|
|
|
318
319
|
error as unknown as string
|
|
319
320
|
}`
|
|
320
321
|
);
|
|
322
|
+
if (this.runPromise) {
|
|
323
|
+
this.runPromise.reject(
|
|
324
|
+
ERRORS.TypedError(
|
|
325
|
+
HardwareErrorCode.BleCharacteristicNotifyError,
|
|
326
|
+
error.reason ?? error.message
|
|
327
|
+
)
|
|
328
|
+
);
|
|
329
|
+
console.log('@onekey/hd-ble-sdk: monitor notify error, and has unreleased Promise');
|
|
330
|
+
}
|
|
321
331
|
return;
|
|
322
332
|
}
|
|
323
333
|
|