@onekeyfe/hd-transport-react-native 1.0.7-alpha.3 → 1.0.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 +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -16
- package/package.json +5 -5
- package/src/index.ts +2 -20
package/dist/index.d.ts
CHANGED
|
@@ -27,11 +27,10 @@ declare class ReactNativeBleTransport {
|
|
|
27
27
|
listen(): void;
|
|
28
28
|
getPlxManager(): Promise<BleManager>;
|
|
29
29
|
enumerate(): Promise<Device[]>;
|
|
30
|
-
refreshCache(deviceId: string): Promise<void>;
|
|
31
30
|
acquire(input: BleAcquireInput): Promise<{
|
|
32
31
|
uuid: string;
|
|
33
32
|
}>;
|
|
34
|
-
_monitorCharacteristic(characteristic: Characteristic
|
|
33
|
+
_monitorCharacteristic(characteristic: Characteristic): () => void;
|
|
35
34
|
release(uuid: string): Promise<boolean>;
|
|
36
35
|
call(uuid: string, name: string, data: Record<string, unknown>): Promise<transport.MessageFromOneKey | undefined>;
|
|
37
36
|
stop(): void;
|
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,gCAAgC,CAAC;AAExC,OAAO,SAAkD,MAAM,wBAAwB,CAAC;AACxF,OAAO,EAAkB,QAAQ,EAA6B,MAAM,qBAAqB,CAAC;AAC1F,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AAavC,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,SAA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OAAO,EAAE,YAAY;IAKvC,SAAS,CAAC,UAAU,EAAE,GAAG;IAMzB,MAAM;IAIN,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC;IAYjC,SAAS;IA6FT,OAAO,CAAC,KAAK,EAAE,eAAe;;;IAwMpC,sBAAsB,CAAC,cAAc,EAAE,cAAc;IAkE/C,OAAO,CAAC,IAAI,EAAE,MAAM;IAepB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IA+FpE,IAAI;IAIJ,MAAM;CAOP"}
|
package/dist/index.js
CHANGED
|
@@ -287,18 +287,6 @@ class ReactNativeBleTransport {
|
|
|
287
287
|
}));
|
|
288
288
|
});
|
|
289
289
|
}
|
|
290
|
-
refreshCache(deviceId) {
|
|
291
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
292
|
-
try {
|
|
293
|
-
const blePlxManager = yield this.getPlxManager();
|
|
294
|
-
yield blePlxManager.refreshGatt(deviceId);
|
|
295
|
-
yield new Promise(resolve => setTimeout(resolve, 500));
|
|
296
|
-
}
|
|
297
|
-
catch (error) {
|
|
298
|
-
console.log('refreshCache error: ', error);
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
290
|
acquire(input) {
|
|
303
291
|
var _a, _b, _c;
|
|
304
292
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -386,7 +374,6 @@ class ReactNativeBleTransport {
|
|
|
386
374
|
}
|
|
387
375
|
}
|
|
388
376
|
}
|
|
389
|
-
this.refreshCache(uuid);
|
|
390
377
|
if (reactNative.Platform.OS === 'android') {
|
|
391
378
|
const bondedDevices = yield getBondedDevices();
|
|
392
379
|
const hasBonded = !!bondedDevices.find(bondedDevice => bondedDevice.id === (device === null || device === void 0 ? void 0 : device.id));
|
|
@@ -449,7 +436,7 @@ class ReactNativeBleTransport {
|
|
|
449
436
|
throw hdShared.ERRORS.TypedError('BLECharacteristicNotNotifiable: notify characteristic not notifiable');
|
|
450
437
|
}
|
|
451
438
|
const transport = new BleTransport(device, writeCharacteristic, notifyCharacteristic);
|
|
452
|
-
transport.nofitySubscription = this._monitorCharacteristic(transport.notifyCharacteristic
|
|
439
|
+
transport.nofitySubscription = this._monitorCharacteristic(transport.notifyCharacteristic);
|
|
453
440
|
transportCache[uuid] = transport;
|
|
454
441
|
(_c = this.emitter) === null || _c === void 0 ? void 0 : _c.emit('device-connect', {
|
|
455
442
|
name: device.name,
|
|
@@ -470,7 +457,7 @@ class ReactNativeBleTransport {
|
|
|
470
457
|
return { uuid };
|
|
471
458
|
});
|
|
472
459
|
}
|
|
473
|
-
_monitorCharacteristic(characteristic
|
|
460
|
+
_monitorCharacteristic(characteristic) {
|
|
474
461
|
let bufferLength = 0;
|
|
475
462
|
let buffer$1 = [];
|
|
476
463
|
const subscription = characteristic.monitor((error, c) => {
|
|
@@ -485,7 +472,6 @@ class ReactNativeBleTransport {
|
|
|
485
472
|
if ((_b = error.reason) === null || _b === void 0 ? void 0 : _b.includes('Encryption is insufficient')) {
|
|
486
473
|
ERROR = hdShared.HardwareErrorCode.BleDeviceBondError;
|
|
487
474
|
}
|
|
488
|
-
this.refreshCache(deviceId);
|
|
489
475
|
this.runPromise.reject(hdShared.ERRORS.TypedError(ERROR, (_c = error.reason) !== null && _c !== void 0 ? _c : error.message));
|
|
490
476
|
this.Log.debug(': monitor notify error, and has unreleased Promise');
|
|
491
477
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport-react-native",
|
|
3
|
-
"version": "1.0.7
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"lint:fix": "eslint . --fix"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@onekeyfe/hd-shared": "^1.0.7
|
|
23
|
-
"@onekeyfe/hd-transport": "^1.0.7
|
|
24
|
-
"@onekeyfe/react-native-ble-plx": "
|
|
22
|
+
"@onekeyfe/hd-shared": "^1.0.7",
|
|
23
|
+
"@onekeyfe/hd-transport": "^1.0.7",
|
|
24
|
+
"@onekeyfe/react-native-ble-plx": "3.0.0",
|
|
25
25
|
"react-native-ble-manager": "^8.1.0"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "8b08f905e7426fac23b5cf9ec55eb336278f0e3b"
|
|
28
28
|
}
|
package/src/index.ts
CHANGED
|
@@ -183,18 +183,6 @@ export default class ReactNativeBleTransport {
|
|
|
183
183
|
});
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
async refreshCache(deviceId: string) {
|
|
187
|
-
try {
|
|
188
|
-
const blePlxManager = await this.getPlxManager();
|
|
189
|
-
// @ts-expect-error
|
|
190
|
-
await blePlxManager.refreshGatt(deviceId);
|
|
191
|
-
// eslint-disable-next-line no-promise-executor-return
|
|
192
|
-
await new Promise(resolve => setTimeout(resolve, 500));
|
|
193
|
-
} catch (error) {
|
|
194
|
-
console.log('refreshCache error: ', error);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
186
|
async acquire(input: BleAcquireInput) {
|
|
199
187
|
const { uuid, forceCleanRunPromise } = input;
|
|
200
188
|
|
|
@@ -298,8 +286,6 @@ export default class ReactNativeBleTransport {
|
|
|
298
286
|
}
|
|
299
287
|
}
|
|
300
288
|
|
|
301
|
-
this.refreshCache(uuid);
|
|
302
|
-
|
|
303
289
|
// check device is bonded
|
|
304
290
|
if (Platform.OS === 'android') {
|
|
305
291
|
const bondedDevices = await getBondedDevices();
|
|
@@ -374,10 +360,7 @@ export default class ReactNativeBleTransport {
|
|
|
374
360
|
}
|
|
375
361
|
|
|
376
362
|
const transport = new BleTransport(device, writeCharacteristic, notifyCharacteristic);
|
|
377
|
-
transport.nofitySubscription = this._monitorCharacteristic(
|
|
378
|
-
transport.notifyCharacteristic,
|
|
379
|
-
device.id
|
|
380
|
-
);
|
|
363
|
+
transport.nofitySubscription = this._monitorCharacteristic(transport.notifyCharacteristic);
|
|
381
364
|
transportCache[uuid] = transport;
|
|
382
365
|
|
|
383
366
|
this.emitter?.emit('device-connect', {
|
|
@@ -400,7 +383,7 @@ export default class ReactNativeBleTransport {
|
|
|
400
383
|
return { uuid };
|
|
401
384
|
}
|
|
402
385
|
|
|
403
|
-
_monitorCharacteristic(characteristic: Characteristic
|
|
386
|
+
_monitorCharacteristic(characteristic: Characteristic) {
|
|
404
387
|
let bufferLength = 0;
|
|
405
388
|
let buffer: any[] = [];
|
|
406
389
|
const subscription = characteristic.monitor((error, c) => {
|
|
@@ -422,7 +405,6 @@ export default class ReactNativeBleTransport {
|
|
|
422
405
|
if (error.reason?.includes('Encryption is insufficient')) {
|
|
423
406
|
ERROR = HardwareErrorCode.BleDeviceBondError;
|
|
424
407
|
}
|
|
425
|
-
this.refreshCache(deviceId);
|
|
426
408
|
this.runPromise.reject(ERRORS.TypedError(ERROR, error.reason ?? error.message));
|
|
427
409
|
this.Log.debug(': monitor notify error, and has unreleased Promise');
|
|
428
410
|
}
|