@onekeyfe/hd-ble-sdk 1.2.8-alpha.9 → 1.2.8
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/__tests__/device-state-events.test.ts +2 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -10
- package/package.json +5 -5
- package/src/index.ts +0 -6
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { readFileSync } from 'fs';
|
|
2
2
|
import { resolve } from 'path';
|
|
3
3
|
import EventEmitter from 'events';
|
|
4
|
-
import { CORE_EVENT,
|
|
5
|
-
import {
|
|
4
|
+
import { CORE_EVENT, initCore } from '@onekeyfe/hd-core';
|
|
5
|
+
import { createDeferred } from '@onekeyfe/hd-shared';
|
|
6
6
|
|
|
7
7
|
import sdkExport, { messagePromises } from '../src';
|
|
8
8
|
|
|
@@ -57,17 +57,6 @@ describe('SDK request cleanup', () => {
|
|
|
57
57
|
await sdk.dispose();
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
test.each([
|
|
61
|
-
[HardwareErrorCode.BlePoweredOff, UI_REQUEST.BLUETOOTH_POWERED_OFF],
|
|
62
|
-
[HardwareErrorCode.BleUnsupported, UI_REQUEST.BLUETOOTH_UNSUPPORTED],
|
|
63
|
-
[HardwareErrorCode.BleLocationError, UI_REQUEST.LOCATION_PERMISSION],
|
|
64
|
-
])('emits the adapter UI request for error %s', async (code, type) => {
|
|
65
|
-
const response = { success: false, payload: { code, error: 'Adapter unavailable' } };
|
|
66
|
-
core.handleMessage.mockResolvedValueOnce(response);
|
|
67
|
-
await expect(sdk.call({ method: 'searchDevices' })).resolves.toEqual(response);
|
|
68
|
-
expect(core.handleMessage).toHaveBeenNthCalledWith(2, expect.objectContaining({ type }));
|
|
69
|
-
});
|
|
70
|
-
|
|
71
60
|
test('removes only the completed request when calls settle out of order', async () => {
|
|
72
61
|
const first = createDeferred<unknown>();
|
|
73
62
|
const second = createDeferred<unknown>();
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AASpD,eAAO,MAAM,eAAe,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;CAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AASpD,eAAO,MAAM,eAAe,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;CAAO,CAAC;AA+JpE,QAAA,MAAM,cAAc,qCASlB,CAAC;AAEH,eAAe,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -632,7 +632,7 @@ const init = (settings) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
632
632
|
}
|
|
633
633
|
});
|
|
634
634
|
const call = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
635
|
-
var _b, _c, _d
|
|
635
|
+
var _b, _c, _d;
|
|
636
636
|
const blockLog = HardwareSdk.getLogBlockLabel(params);
|
|
637
637
|
Log.debug('call: ', blockLog !== null && blockLog !== void 0 ? blockLog : params);
|
|
638
638
|
try {
|
|
@@ -640,19 +640,13 @@ const call = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
640
640
|
if (response) {
|
|
641
641
|
Log.debug('response: ', blockLog ? '[REDACTED]' : response);
|
|
642
642
|
if (!response.success) {
|
|
643
|
-
if (((_b = response.payload) === null || _b === void 0 ? void 0 : _b.code) === hdShared.HardwareErrorCode.
|
|
644
|
-
postMessage(HardwareSdk.createUiMessage(HardwareSdk.UI_REQUEST.BLUETOOTH_POWERED_OFF), false);
|
|
645
|
-
}
|
|
646
|
-
if (((_c = response.payload) === null || _c === void 0 ? void 0 : _c.code) === hdShared.HardwareErrorCode.BleUnsupported) {
|
|
647
|
-
postMessage(HardwareSdk.createUiMessage(HardwareSdk.UI_REQUEST.BLUETOOTH_UNSUPPORTED), false);
|
|
648
|
-
}
|
|
649
|
-
if (((_d = response.payload) === null || _d === void 0 ? void 0 : _d.code) === hdShared.HardwareErrorCode.BlePermissionError) {
|
|
643
|
+
if (((_b = response.payload) === null || _b === void 0 ? void 0 : _b.code) === hdShared.HardwareErrorCode.BlePermissionError) {
|
|
650
644
|
postMessage(HardwareSdk.createUiMessage(HardwareSdk.UI_REQUEST.BLUETOOTH_PERMISSION), false);
|
|
651
645
|
}
|
|
652
|
-
if (((
|
|
646
|
+
if (((_c = response.payload) === null || _c === void 0 ? void 0 : _c.code) === hdShared.HardwareErrorCode.BleLocationError) {
|
|
653
647
|
postMessage(HardwareSdk.createUiMessage(HardwareSdk.UI_REQUEST.LOCATION_PERMISSION), false);
|
|
654
648
|
}
|
|
655
|
-
if (((
|
|
649
|
+
if (((_d = response.payload) === null || _d === void 0 ? void 0 : _d.code) === hdShared.HardwareErrorCode.BleLocationServicesDisabled) {
|
|
656
650
|
postMessage(HardwareSdk.createUiMessage(HardwareSdk.UI_REQUEST.LOCATION_SERVICE_PERMISSION), false);
|
|
657
651
|
}
|
|
658
652
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-ble-sdk",
|
|
3
|
-
"version": "1.2.8
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"author": "OneKey",
|
|
5
5
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
6
6
|
"license": "ISC",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"lint:fix": "eslint . --fix"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@onekeyfe/hd-core": "1.2.8
|
|
25
|
-
"@onekeyfe/hd-shared": "1.2.8
|
|
26
|
-
"@onekeyfe/hd-transport-react-native": "1.2.8
|
|
24
|
+
"@onekeyfe/hd-core": "1.2.8",
|
|
25
|
+
"@onekeyfe/hd-shared": "1.2.8",
|
|
26
|
+
"@onekeyfe/hd-transport-react-native": "1.2.8"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "9f016278a7f395bf66b8502815dc63191e162fd3"
|
|
29
29
|
}
|
package/src/index.ts
CHANGED
|
@@ -162,12 +162,6 @@ const call = async (params: any) => {
|
|
|
162
162
|
Log.debug('response: ', blockLog ? '[REDACTED]' : response);
|
|
163
163
|
|
|
164
164
|
if (!response.success) {
|
|
165
|
-
if (response.payload?.code === HardwareErrorCode.BlePoweredOff) {
|
|
166
|
-
postMessage(createUiMessage(UI_REQUEST.BLUETOOTH_POWERED_OFF), false);
|
|
167
|
-
}
|
|
168
|
-
if (response.payload?.code === HardwareErrorCode.BleUnsupported) {
|
|
169
|
-
postMessage(createUiMessage(UI_REQUEST.BLUETOOTH_UNSUPPORTED), false);
|
|
170
|
-
}
|
|
171
165
|
if (response.payload?.code === HardwareErrorCode.BlePermissionError) {
|
|
172
166
|
/**
|
|
173
167
|
* Send message notification when there is no Bluetooth access permission
|