@onekeyfe/hd-ble-sdk 1.2.0-alpha.2 → 1.2.0-alpha.20

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.
@@ -0,0 +1,15 @@
1
+ import { readFileSync } from 'fs';
2
+ import { resolve } from 'path';
3
+
4
+ describe('hd-ble-sdk device state events', () => {
5
+ test('forwards DEVICE.STATE to React Native SDK consumers', () => {
6
+ const source = readFileSync(resolve(__dirname, '../src/index.ts'), 'utf8');
7
+ const deviceEventHandler = source.slice(
8
+ source.indexOf('case DEVICE_EVENT:'),
9
+ source.indexOf('case IFRAME.CALLBACK:'),
10
+ );
11
+
12
+ expect(deviceEventHandler).toContain('DEVICE.STATE');
13
+ expect(deviceEventHandler).toContain('eventEmitter.emit(message.type, message.payload)');
14
+ });
15
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,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;AAgJpE,QAAA,MAAM,cAAc,qCASlB,CAAC;AAEH,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,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;AA0JpE,QAAA,MAAM,cAAc,qCAUlB,CAAC;AAEH,eAAe,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -539,6 +539,9 @@ const cancel = (connectId) => {
539
539
  return;
540
540
  _core.handleMessage({ event: HardwareSdk.IFRAME.CANCEL, type: HardwareSdk.IFRAME.CANCEL, payload: { connectId } });
541
541
  };
542
+ const cancelOperation = (operationId) => {
543
+ _core === null || _core === void 0 ? void 0 : _core.cancelOperation(operationId);
544
+ };
542
545
  function handleMessage(message) {
543
546
  var _a;
544
547
  const { event, type } = message;
@@ -571,7 +574,13 @@ function handleMessage(message) {
571
574
  eventEmitter.emit(message.event, message);
572
575
  break;
573
576
  case HardwareSdk.DEVICE_EVENT:
574
- if ([HardwareSdk.DEVICE.CONNECT, HardwareSdk.DEVICE.DISCONNECT, HardwareSdk.DEVICE.FEATURES, HardwareSdk.DEVICE.SUPPORT_FEATURES].includes(message.type)) {
577
+ if ([
578
+ HardwareSdk.DEVICE.CONNECT,
579
+ HardwareSdk.DEVICE.DISCONNECT,
580
+ HardwareSdk.DEVICE.FEATURES,
581
+ HardwareSdk.DEVICE.STATE,
582
+ HardwareSdk.DEVICE.SUPPORT_FEATURES,
583
+ ].includes(message.type)) {
575
584
  eventEmitter.emit(message.type, message.payload);
576
585
  }
577
586
  break;
@@ -647,6 +656,7 @@ const HardwareBleSdk = HardwareSdk__default["default"]({
647
656
  init,
648
657
  call,
649
658
  cancel,
659
+ cancelOperation,
650
660
  dispose,
651
661
  uiResponse,
652
662
  updateSettings,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-ble-sdk",
3
- "version": "1.2.0-alpha.2",
3
+ "version": "1.2.0-alpha.20",
4
4
  "author": "OneKey",
5
5
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
6
6
  "license": "ISC",
@@ -20,9 +20,9 @@
20
20
  "lint:fix": "eslint . --fix"
21
21
  },
22
22
  "dependencies": {
23
- "@onekeyfe/hd-core": "1.2.0-alpha.2",
24
- "@onekeyfe/hd-shared": "1.2.0-alpha.2",
25
- "@onekeyfe/hd-transport-react-native": "1.2.0-alpha.2"
23
+ "@onekeyfe/hd-core": "1.2.0-alpha.20",
24
+ "@onekeyfe/hd-shared": "1.2.0-alpha.20",
25
+ "@onekeyfe/hd-transport-react-native": "1.2.0-alpha.20"
26
26
  },
27
- "gitHead": "6c183b7f7027f4b4d3db4f427f6360351a6c6680"
27
+ "gitHead": "5fbc1ada90fd3cfda7e5ef08be368cb452018733"
28
28
  }
package/src/index.ts CHANGED
@@ -50,6 +50,10 @@ const cancel = (connectId?: string) => {
50
50
  _core.handleMessage({ event: IFRAME.CANCEL, type: IFRAME.CANCEL, payload: { connectId } });
51
51
  };
52
52
 
53
+ const cancelOperation = (operationId: string) => {
54
+ _core?.cancelOperation(operationId);
55
+ };
56
+
53
57
  function handleMessage(message: CoreMessage) {
54
58
  const { event, type } = message;
55
59
  if (!_core) {
@@ -84,7 +88,13 @@ function handleMessage(message: CoreMessage) {
84
88
  case DEVICE_EVENT:
85
89
  if (
86
90
  (
87
- [DEVICE.CONNECT, DEVICE.DISCONNECT, DEVICE.FEATURES, DEVICE.SUPPORT_FEATURES] as string[]
91
+ [
92
+ DEVICE.CONNECT,
93
+ DEVICE.DISCONNECT,
94
+ DEVICE.FEATURES,
95
+ DEVICE.STATE,
96
+ DEVICE.SUPPORT_FEATURES,
97
+ ] as string[]
88
98
  ).includes(message.type)
89
99
  ) {
90
100
  eventEmitter.emit(message.type, message.payload);
@@ -179,6 +189,7 @@ const HardwareBleSdk = HardwareSdk({
179
189
  init,
180
190
  call,
181
191
  cancel,
192
+ cancelOperation,
182
193
  dispose,
183
194
  uiResponse,
184
195
  updateSettings,