@onekeyfe/hwk-desktop-noble-ble 1.2.10 → 1.2.11-alpha.1

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.
@@ -23,6 +23,12 @@ var THIRD_PARTY_BLE_CHANNELS = {
23
23
  /** push event: main → renderer when device disconnects unexpectedly */
24
24
  disconnected: "$onekey-3p-ble-disconnected"
25
25
  };
26
+ var THIRD_PARTY_BLE_IPC_ERROR_TYPE = "ThirdPartyBleIpcError";
27
+ function isThirdPartyBleIpcErrorResponse(response) {
28
+ if (!response || typeof response !== "object") return false;
29
+ const candidate = response;
30
+ return candidate.type === THIRD_PARTY_BLE_IPC_ERROR_TYPE && candidate.success === false && typeof candidate.error?.message === "string";
31
+ }
26
32
  var THIRD_PARTY_BLE_SCAN_DURATION_MS = 5e3;
27
33
  var THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS = 1e4;
28
34
  var THIRD_PARTY_BLE_DEVICE_TTL_MS = 5e3;
@@ -32,10 +38,12 @@ var THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS = 3e3;
32
38
  export {
33
39
  __require,
34
40
  THIRD_PARTY_BLE_CHANNELS,
41
+ THIRD_PARTY_BLE_IPC_ERROR_TYPE,
42
+ isThirdPartyBleIpcErrorResponse,
35
43
  THIRD_PARTY_BLE_SCAN_DURATION_MS,
36
44
  THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS,
37
45
  THIRD_PARTY_BLE_DEVICE_TTL_MS,
38
46
  THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS,
39
47
  THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS
40
48
  };
41
- //# sourceMappingURL=chunk-ILABAQJY.mjs.map
49
+ //# sourceMappingURL=chunk-O6YS25TV.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["import type { ConnectorSerializedError } from '@onekeyfe/hwk-adapter-core';\n\n/**\n * Renderer/main IPC channels shared by every third-party BLE vendor; prefixed to\n * avoid clashing with the OneKey handler (`$onekey-noble-ble-*`) in one app.\n */\nexport const THIRD_PARTY_BLE_CHANNELS = {\n scan: '$onekey-3p-ble-scan',\n stopScan: '$onekey-3p-ble-stop-scan',\n connect: '$onekey-3p-ble-connect',\n disconnect: '$onekey-3p-ble-disconnect',\n write: '$onekey-3p-ble-write',\n subscribe: '$onekey-3p-ble-subscribe',\n unsubscribe: '$onekey-3p-ble-unsubscribe',\n availability: '$onekey-3p-ble-availability',\n getDevice: '$onekey-3p-ble-get-device',\n readRssi: '$onekey-3p-ble-read-rssi',\n cancelPairing: '$onekey-3p-ble-cancel-pairing',\n /** push event: main → renderer with assembled BLE notification payload */\n notification: '$onekey-3p-ble-notification',\n /** push event: main → renderer when device disconnects unexpectedly */\n disconnected: '$onekey-3p-ble-disconnected',\n} as const;\n\nexport type ThirdPartyBleChannel =\n (typeof THIRD_PARTY_BLE_CHANNELS)[keyof typeof THIRD_PARTY_BLE_CHANNELS];\n\nexport const THIRD_PARTY_BLE_IPC_ERROR_TYPE = 'ThirdPartyBleIpcError';\n\n/** What a handler wrapped by `withThirdPartyBleIpcErrors` returns instead of throwing. */\nexport interface ThirdPartyBleIpcErrorResponse {\n type: typeof THIRD_PARTY_BLE_IPC_ERROR_TYPE;\n success: false;\n error: ConnectorSerializedError;\n}\n\n/** For the preload, which imports this entry: rethrow `response.error` when this matches. */\nexport function isThirdPartyBleIpcErrorResponse(\n response: unknown\n): response is ThirdPartyBleIpcErrorResponse {\n if (!response || typeof response !== 'object') return false;\n const candidate = response as Partial<ThirdPartyBleIpcErrorResponse>;\n return (\n candidate.type === THIRD_PARTY_BLE_IPC_ERROR_TYPE &&\n candidate.success === false &&\n typeof candidate.error?.message === 'string'\n );\n}\n\n/** Reconnect scan window for `connect(id)`. */\nexport const THIRD_PARTY_BLE_SCAN_DURATION_MS = 5_000;\n\n/** Continuous scan auto-stops this long after the last poll (reset, not accumulated). */\nexport const THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS = 10_000;\n\n/** Drop a device from the snapshot if it hasn't re-advertised within this window. */\nexport const THIRD_PARTY_BLE_DEVICE_TTL_MS = 5_000;\n\n/** Time we'll wait for noble to reach `poweredOn` before failing init. */\nexport const THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS = 10_000;\n\n/** Time an availability check waits for a fresh noble to report its first state. */\nexport const THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS = 3_000;\n"],"mappings":";;;;;;;;AAMO,IAAM,2BAA2B;AAAA,EACtC,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,WAAW;AAAA,EACX,aAAa;AAAA,EACb,cAAc;AAAA,EACd,WAAW;AAAA,EACX,UAAU;AAAA,EACV,eAAe;AAAA;AAAA,EAEf,cAAc;AAAA;AAAA,EAEd,cAAc;AAChB;AAKO,IAAM,iCAAiC;AAUvC,SAAS,gCACd,UAC2C;AAC3C,MAAI,CAAC,YAAY,OAAO,aAAa,SAAU,QAAO;AACtD,QAAM,YAAY;AAClB,SACE,UAAU,SAAS,kCACnB,UAAU,YAAY,SACtB,OAAO,UAAU,OAAO,YAAY;AAExC;AAGO,IAAM,mCAAmC;AAGzC,IAAM,oCAAoC;AAG1C,IAAM,gCAAgC;AAGtC,IAAM,sCAAsC;AAG5C,IAAM,0CAA0C;","names":[]}
@@ -1,3 +1,5 @@
1
+ import { ConnectorSerializedError } from '@onekeyfe/hwk-adapter-core';
2
+
1
3
  /**
2
4
  * Renderer/main IPC channels shared by every third-party BLE vendor; prefixed to
3
5
  * avoid clashing with the OneKey handler (`$onekey-noble-ble-*`) in one app.
@@ -20,6 +22,15 @@ declare const THIRD_PARTY_BLE_CHANNELS: {
20
22
  readonly disconnected: "$onekey-3p-ble-disconnected";
21
23
  };
22
24
  type ThirdPartyBleChannel = (typeof THIRD_PARTY_BLE_CHANNELS)[keyof typeof THIRD_PARTY_BLE_CHANNELS];
25
+ declare const THIRD_PARTY_BLE_IPC_ERROR_TYPE = "ThirdPartyBleIpcError";
26
+ /** What a handler wrapped by `withThirdPartyBleIpcErrors` returns instead of throwing. */
27
+ interface ThirdPartyBleIpcErrorResponse {
28
+ type: typeof THIRD_PARTY_BLE_IPC_ERROR_TYPE;
29
+ success: false;
30
+ error: ConnectorSerializedError;
31
+ }
32
+ /** For the preload, which imports this entry: rethrow `response.error` when this matches. */
33
+ declare function isThirdPartyBleIpcErrorResponse(response: unknown): response is ThirdPartyBleIpcErrorResponse;
23
34
  /** Reconnect scan window for `connect(id)`. */
24
35
  declare const THIRD_PARTY_BLE_SCAN_DURATION_MS = 5000;
25
36
  /** Continuous scan auto-stops this long after the last poll (reset, not accumulated). */
@@ -31,4 +42,4 @@ declare const THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS = 10000;
31
42
  /** Time an availability check waits for a fresh noble to report its first state. */
32
43
  declare const THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS = 3000;
33
44
 
34
- export { THIRD_PARTY_BLE_CHANNELS, THIRD_PARTY_BLE_DEVICE_TTL_MS, THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS, THIRD_PARTY_BLE_SCAN_DURATION_MS, THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS, THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS, type ThirdPartyBleChannel };
45
+ export { THIRD_PARTY_BLE_CHANNELS, THIRD_PARTY_BLE_DEVICE_TTL_MS, THIRD_PARTY_BLE_IPC_ERROR_TYPE, THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS, THIRD_PARTY_BLE_SCAN_DURATION_MS, THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS, THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS, type ThirdPartyBleChannel, type ThirdPartyBleIpcErrorResponse, isThirdPartyBleIpcErrorResponse };
@@ -1,3 +1,5 @@
1
+ import { ConnectorSerializedError } from '@onekeyfe/hwk-adapter-core';
2
+
1
3
  /**
2
4
  * Renderer/main IPC channels shared by every third-party BLE vendor; prefixed to
3
5
  * avoid clashing with the OneKey handler (`$onekey-noble-ble-*`) in one app.
@@ -20,6 +22,15 @@ declare const THIRD_PARTY_BLE_CHANNELS: {
20
22
  readonly disconnected: "$onekey-3p-ble-disconnected";
21
23
  };
22
24
  type ThirdPartyBleChannel = (typeof THIRD_PARTY_BLE_CHANNELS)[keyof typeof THIRD_PARTY_BLE_CHANNELS];
25
+ declare const THIRD_PARTY_BLE_IPC_ERROR_TYPE = "ThirdPartyBleIpcError";
26
+ /** What a handler wrapped by `withThirdPartyBleIpcErrors` returns instead of throwing. */
27
+ interface ThirdPartyBleIpcErrorResponse {
28
+ type: typeof THIRD_PARTY_BLE_IPC_ERROR_TYPE;
29
+ success: false;
30
+ error: ConnectorSerializedError;
31
+ }
32
+ /** For the preload, which imports this entry: rethrow `response.error` when this matches. */
33
+ declare function isThirdPartyBleIpcErrorResponse(response: unknown): response is ThirdPartyBleIpcErrorResponse;
23
34
  /** Reconnect scan window for `connect(id)`. */
24
35
  declare const THIRD_PARTY_BLE_SCAN_DURATION_MS = 5000;
25
36
  /** Continuous scan auto-stops this long after the last poll (reset, not accumulated). */
@@ -31,4 +42,4 @@ declare const THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS = 10000;
31
42
  /** Time an availability check waits for a fresh noble to report its first state. */
32
43
  declare const THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS = 3000;
33
44
 
34
- export { THIRD_PARTY_BLE_CHANNELS, THIRD_PARTY_BLE_DEVICE_TTL_MS, THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS, THIRD_PARTY_BLE_SCAN_DURATION_MS, THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS, THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS, type ThirdPartyBleChannel };
45
+ export { THIRD_PARTY_BLE_CHANNELS, THIRD_PARTY_BLE_DEVICE_TTL_MS, THIRD_PARTY_BLE_IPC_ERROR_TYPE, THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS, THIRD_PARTY_BLE_SCAN_DURATION_MS, THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS, THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS, type ThirdPartyBleChannel, type ThirdPartyBleIpcErrorResponse, isThirdPartyBleIpcErrorResponse };
package/dist/constants.js CHANGED
@@ -22,10 +22,12 @@ var constants_exports = {};
22
22
  __export(constants_exports, {
23
23
  THIRD_PARTY_BLE_CHANNELS: () => THIRD_PARTY_BLE_CHANNELS,
24
24
  THIRD_PARTY_BLE_DEVICE_TTL_MS: () => THIRD_PARTY_BLE_DEVICE_TTL_MS,
25
+ THIRD_PARTY_BLE_IPC_ERROR_TYPE: () => THIRD_PARTY_BLE_IPC_ERROR_TYPE,
25
26
  THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS: () => THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS,
26
27
  THIRD_PARTY_BLE_SCAN_DURATION_MS: () => THIRD_PARTY_BLE_SCAN_DURATION_MS,
27
28
  THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS: () => THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS,
28
- THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS: () => THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS
29
+ THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS: () => THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS,
30
+ isThirdPartyBleIpcErrorResponse: () => isThirdPartyBleIpcErrorResponse
29
31
  });
30
32
  module.exports = __toCommonJS(constants_exports);
31
33
  var THIRD_PARTY_BLE_CHANNELS = {
@@ -45,6 +47,12 @@ var THIRD_PARTY_BLE_CHANNELS = {
45
47
  /** push event: main → renderer when device disconnects unexpectedly */
46
48
  disconnected: "$onekey-3p-ble-disconnected"
47
49
  };
50
+ var THIRD_PARTY_BLE_IPC_ERROR_TYPE = "ThirdPartyBleIpcError";
51
+ function isThirdPartyBleIpcErrorResponse(response) {
52
+ if (!response || typeof response !== "object") return false;
53
+ const candidate = response;
54
+ return candidate.type === THIRD_PARTY_BLE_IPC_ERROR_TYPE && candidate.success === false && typeof candidate.error?.message === "string";
55
+ }
48
56
  var THIRD_PARTY_BLE_SCAN_DURATION_MS = 5e3;
49
57
  var THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS = 1e4;
50
58
  var THIRD_PARTY_BLE_DEVICE_TTL_MS = 5e3;
@@ -54,9 +62,11 @@ var THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS = 3e3;
54
62
  0 && (module.exports = {
55
63
  THIRD_PARTY_BLE_CHANNELS,
56
64
  THIRD_PARTY_BLE_DEVICE_TTL_MS,
65
+ THIRD_PARTY_BLE_IPC_ERROR_TYPE,
57
66
  THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS,
58
67
  THIRD_PARTY_BLE_SCAN_DURATION_MS,
59
68
  THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS,
60
- THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS
69
+ THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS,
70
+ isThirdPartyBleIpcErrorResponse
61
71
  });
62
72
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["/**\n * Renderer/main IPC channels shared by every third-party BLE vendor; prefixed to\n * avoid clashing with the OneKey handler (`$onekey-noble-ble-*`) in one app.\n */\nexport const THIRD_PARTY_BLE_CHANNELS = {\n scan: '$onekey-3p-ble-scan',\n stopScan: '$onekey-3p-ble-stop-scan',\n connect: '$onekey-3p-ble-connect',\n disconnect: '$onekey-3p-ble-disconnect',\n write: '$onekey-3p-ble-write',\n subscribe: '$onekey-3p-ble-subscribe',\n unsubscribe: '$onekey-3p-ble-unsubscribe',\n availability: '$onekey-3p-ble-availability',\n getDevice: '$onekey-3p-ble-get-device',\n readRssi: '$onekey-3p-ble-read-rssi',\n cancelPairing: '$onekey-3p-ble-cancel-pairing',\n /** push event: main → renderer with assembled BLE notification payload */\n notification: '$onekey-3p-ble-notification',\n /** push event: main → renderer when device disconnects unexpectedly */\n disconnected: '$onekey-3p-ble-disconnected',\n} as const;\n\nexport type ThirdPartyBleChannel =\n (typeof THIRD_PARTY_BLE_CHANNELS)[keyof typeof THIRD_PARTY_BLE_CHANNELS];\n\n/** Reconnect scan window for `connect(id)`. */\nexport const THIRD_PARTY_BLE_SCAN_DURATION_MS = 5_000;\n\n/** Continuous scan auto-stops this long after the last poll (reset, not accumulated). */\nexport const THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS = 10_000;\n\n/** Drop a device from the snapshot if it hasn't re-advertised within this window. */\nexport const THIRD_PARTY_BLE_DEVICE_TTL_MS = 5_000;\n\n/** Time we'll wait for noble to reach `poweredOn` before failing init. */\nexport const THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS = 10_000;\n\n/** Time an availability check waits for a fresh noble to report its first state. */\nexport const THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS = 3_000;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,IAAM,2BAA2B;AAAA,EACtC,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,WAAW;AAAA,EACX,aAAa;AAAA,EACb,cAAc;AAAA,EACd,WAAW;AAAA,EACX,UAAU;AAAA,EACV,eAAe;AAAA;AAAA,EAEf,cAAc;AAAA;AAAA,EAEd,cAAc;AAChB;AAMO,IAAM,mCAAmC;AAGzC,IAAM,oCAAoC;AAG1C,IAAM,gCAAgC;AAGtC,IAAM,sCAAsC;AAG5C,IAAM,0CAA0C;","names":[]}
1
+ {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["import type { ConnectorSerializedError } from '@onekeyfe/hwk-adapter-core';\n\n/**\n * Renderer/main IPC channels shared by every third-party BLE vendor; prefixed to\n * avoid clashing with the OneKey handler (`$onekey-noble-ble-*`) in one app.\n */\nexport const THIRD_PARTY_BLE_CHANNELS = {\n scan: '$onekey-3p-ble-scan',\n stopScan: '$onekey-3p-ble-stop-scan',\n connect: '$onekey-3p-ble-connect',\n disconnect: '$onekey-3p-ble-disconnect',\n write: '$onekey-3p-ble-write',\n subscribe: '$onekey-3p-ble-subscribe',\n unsubscribe: '$onekey-3p-ble-unsubscribe',\n availability: '$onekey-3p-ble-availability',\n getDevice: '$onekey-3p-ble-get-device',\n readRssi: '$onekey-3p-ble-read-rssi',\n cancelPairing: '$onekey-3p-ble-cancel-pairing',\n /** push event: main → renderer with assembled BLE notification payload */\n notification: '$onekey-3p-ble-notification',\n /** push event: main → renderer when device disconnects unexpectedly */\n disconnected: '$onekey-3p-ble-disconnected',\n} as const;\n\nexport type ThirdPartyBleChannel =\n (typeof THIRD_PARTY_BLE_CHANNELS)[keyof typeof THIRD_PARTY_BLE_CHANNELS];\n\nexport const THIRD_PARTY_BLE_IPC_ERROR_TYPE = 'ThirdPartyBleIpcError';\n\n/** What a handler wrapped by `withThirdPartyBleIpcErrors` returns instead of throwing. */\nexport interface ThirdPartyBleIpcErrorResponse {\n type: typeof THIRD_PARTY_BLE_IPC_ERROR_TYPE;\n success: false;\n error: ConnectorSerializedError;\n}\n\n/** For the preload, which imports this entry: rethrow `response.error` when this matches. */\nexport function isThirdPartyBleIpcErrorResponse(\n response: unknown\n): response is ThirdPartyBleIpcErrorResponse {\n if (!response || typeof response !== 'object') return false;\n const candidate = response as Partial<ThirdPartyBleIpcErrorResponse>;\n return (\n candidate.type === THIRD_PARTY_BLE_IPC_ERROR_TYPE &&\n candidate.success === false &&\n typeof candidate.error?.message === 'string'\n );\n}\n\n/** Reconnect scan window for `connect(id)`. */\nexport const THIRD_PARTY_BLE_SCAN_DURATION_MS = 5_000;\n\n/** Continuous scan auto-stops this long after the last poll (reset, not accumulated). */\nexport const THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS = 10_000;\n\n/** Drop a device from the snapshot if it hasn't re-advertised within this window. */\nexport const THIRD_PARTY_BLE_DEVICE_TTL_MS = 5_000;\n\n/** Time we'll wait for noble to reach `poweredOn` before failing init. */\nexport const THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS = 10_000;\n\n/** Time an availability check waits for a fresh noble to report its first state. */\nexport const THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS = 3_000;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,IAAM,2BAA2B;AAAA,EACtC,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,WAAW;AAAA,EACX,aAAa;AAAA,EACb,cAAc;AAAA,EACd,WAAW;AAAA,EACX,UAAU;AAAA,EACV,eAAe;AAAA;AAAA,EAEf,cAAc;AAAA;AAAA,EAEd,cAAc;AAChB;AAKO,IAAM,iCAAiC;AAUvC,SAAS,gCACd,UAC2C;AAC3C,MAAI,CAAC,YAAY,OAAO,aAAa,SAAU,QAAO;AACtD,QAAM,YAAY;AAClB,SACE,UAAU,SAAS,kCACnB,UAAU,YAAY,SACtB,OAAO,UAAU,OAAO,YAAY;AAExC;AAGO,IAAM,mCAAmC;AAGzC,IAAM,oCAAoC;AAG1C,IAAM,gCAAgC;AAGtC,IAAM,sCAAsC;AAG5C,IAAM,0CAA0C;","names":[]}
@@ -1,17 +1,21 @@
1
1
  import {
2
2
  THIRD_PARTY_BLE_CHANNELS,
3
3
  THIRD_PARTY_BLE_DEVICE_TTL_MS,
4
+ THIRD_PARTY_BLE_IPC_ERROR_TYPE,
4
5
  THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS,
5
6
  THIRD_PARTY_BLE_SCAN_DURATION_MS,
6
7
  THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS,
7
- THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS
8
- } from "./chunk-ILABAQJY.mjs";
8
+ THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS,
9
+ isThirdPartyBleIpcErrorResponse
10
+ } from "./chunk-O6YS25TV.mjs";
9
11
  export {
10
12
  THIRD_PARTY_BLE_CHANNELS,
11
13
  THIRD_PARTY_BLE_DEVICE_TTL_MS,
14
+ THIRD_PARTY_BLE_IPC_ERROR_TYPE,
12
15
  THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS,
13
16
  THIRD_PARTY_BLE_SCAN_DURATION_MS,
14
17
  THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS,
15
- THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS
18
+ THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS,
19
+ isThirdPartyBleIpcErrorResponse
16
20
  };
17
21
  //# sourceMappingURL=constants.mjs.map
package/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ElectronBleConnectOptions, ElectronBleScanOptions } from '@onekeyfe/hwk-adapter-core';
2
- export { THIRD_PARTY_BLE_CHANNELS, THIRD_PARTY_BLE_DEVICE_TTL_MS, THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS, THIRD_PARTY_BLE_SCAN_DURATION_MS, THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS, ThirdPartyBleChannel } from './constants.mjs';
2
+ import { ThirdPartyBleIpcErrorResponse } from './constants.mjs';
3
+ export { THIRD_PARTY_BLE_CHANNELS, THIRD_PARTY_BLE_DEVICE_TTL_MS, THIRD_PARTY_BLE_IPC_ERROR_TYPE, THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS, THIRD_PARTY_BLE_SCAN_DURATION_MS, THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS, ThirdPartyBleChannel, isThirdPartyBleIpcErrorResponse } from './constants.mjs';
3
4
 
4
5
  type BleDebugLogLevel = 'debug' | 'info' | 'warn' | 'error';
5
6
  type BleDebugLogEntry = {
@@ -158,6 +159,8 @@ interface NobleBleHandlerOptions {
158
159
  nobleFactory?: NobleFactory;
159
160
  /** Override the overall connect timeout (tests only; defaults to 31s). */
160
161
  connectTimeoutMs?: number;
162
+ /** Override the subscribe timeout (tests only; defaults to 60s). */
163
+ subscribeTimeoutMs?: number;
161
164
  logger?: BleDebugLogger;
162
165
  /**
163
166
  * Vendors served over IPC, keyed by the `vendor` the renderer sends. Replaces the default map
@@ -170,10 +173,13 @@ declare class NobleBleHandler {
170
173
  private _noble;
171
174
  private readonly _factory;
172
175
  private readonly _connectTimeoutMs;
176
+ private readonly _subscribeTimeoutMs;
173
177
  private readonly _logger?;
174
178
  private readonly _vendors;
175
179
  private readonly _discovered;
176
180
  private readonly _lastSeen;
181
+ private readonly _advertisedUuids;
182
+ private readonly _keptByMemory;
177
183
  private readonly _connected;
178
184
  private _discoverHandler?;
179
185
  private _scanning;
@@ -203,6 +209,7 @@ declare class NobleBleHandler {
203
209
  * packet, and a Safe 7 ADV carries only its name (UUID is in the scan response).
204
210
  */
205
211
  scan(options?: ElectronBleScanOptions): Promise<ThirdPartyBleDeviceInfo[]>;
212
+ private _rememberServiceUuids;
206
213
  /**
207
214
  * In-range devices matching the caller, minus TTL-expired ones. `_discovered`
208
215
  * is only a cache; a missing device can still be reached by `_directConnect`.
@@ -254,6 +261,12 @@ declare class NobleBleHandler {
254
261
  private _connectInner;
255
262
  disconnect(id: string): Promise<void>;
256
263
  subscribe(id: string): Promise<void>;
264
+ private _withSubscribeTimeout;
265
+ /**
266
+ * noble-win reports a failed subscribe only as `status: <AsyncStatus>`. Error (3) on a live
267
+ * link is a device refusing the bond Windows holds; a link already gone fails it the same way.
268
+ */
269
+ private _toSubscribeError;
257
270
  unsubscribe(id: string): Promise<void>;
258
271
  write(id: string, hexData: string): Promise<void>;
259
272
  /** Retire a renderer's handler without stopping a process-wide native manager. */
@@ -297,10 +310,21 @@ interface ThirdPartyBleSupportHandle {
297
310
  stop?(): void;
298
311
  }) => void): Promise<void>;
299
312
  }
313
+ /**
314
+ * Electron IPC keeps only an Error's message; as data, a `createHwkError`'s code and params
315
+ * survive. Only those cross, so the renderer rebuilds exactly what the host threw.
316
+ */
317
+ declare function createThirdPartyBleIpcErrorResponse(error: unknown): ThirdPartyBleIpcErrorResponse;
318
+ /**
319
+ * Handlers registered through this resolve failures as `ThirdPartyBleIpcErrorResponse`.
320
+ * Wrap the `ipcMain` that registers with Electron so inner wrappers still see throws, and
321
+ * pair it with a preload that rethrows `response.error`.
322
+ */
323
+ declare function withThirdPartyBleIpcErrors(ipcMain: IpcMainLike): IpcMainLike;
300
324
  /**
301
325
  * Wire a `NobleBleHandler` to Electron IPC once `BrowserWindow` is ready. Call dispose()
302
326
  * when retiring a renderer and disposeForAppQuit() before Node teardown.
303
327
  */
304
328
  declare function initThirdPartyBleSupport(webContents: WebContentsLike, options?: InitThirdPartyBleSupportOptions): ThirdPartyBleSupportHandle;
305
329
 
306
- export { type BleDebugLogEntry, type BleDebugLogLevel, type BleDebugLogger, DEFAULT_THIRD_PARTY_BLE_VENDORS, type InitThirdPartyBleSupportOptions, type IpcMainLike, NobleBleHandler, type NobleBleHandlerOptions, type ThirdPartyBleApi, type ThirdPartyBleAvailability, type ThirdPartyBleDeviceInfo, type ThirdPartyBleSupportHandle, type ThirdPartyBleVendorProfile, initThirdPartyBleSupport, redactBleDebugLogData };
330
+ export { type BleDebugLogEntry, type BleDebugLogLevel, type BleDebugLogger, DEFAULT_THIRD_PARTY_BLE_VENDORS, type InitThirdPartyBleSupportOptions, type IpcMainLike, NobleBleHandler, type NobleBleHandlerOptions, type ThirdPartyBleApi, type ThirdPartyBleAvailability, type ThirdPartyBleDeviceInfo, ThirdPartyBleIpcErrorResponse, type ThirdPartyBleSupportHandle, type ThirdPartyBleVendorProfile, createThirdPartyBleIpcErrorResponse, initThirdPartyBleSupport, redactBleDebugLogData, withThirdPartyBleIpcErrors };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ElectronBleConnectOptions, ElectronBleScanOptions } from '@onekeyfe/hwk-adapter-core';
2
- export { THIRD_PARTY_BLE_CHANNELS, THIRD_PARTY_BLE_DEVICE_TTL_MS, THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS, THIRD_PARTY_BLE_SCAN_DURATION_MS, THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS, ThirdPartyBleChannel } from './constants.js';
2
+ import { ThirdPartyBleIpcErrorResponse } from './constants.js';
3
+ export { THIRD_PARTY_BLE_CHANNELS, THIRD_PARTY_BLE_DEVICE_TTL_MS, THIRD_PARTY_BLE_IPC_ERROR_TYPE, THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS, THIRD_PARTY_BLE_SCAN_DURATION_MS, THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS, ThirdPartyBleChannel, isThirdPartyBleIpcErrorResponse } from './constants.js';
3
4
 
4
5
  type BleDebugLogLevel = 'debug' | 'info' | 'warn' | 'error';
5
6
  type BleDebugLogEntry = {
@@ -158,6 +159,8 @@ interface NobleBleHandlerOptions {
158
159
  nobleFactory?: NobleFactory;
159
160
  /** Override the overall connect timeout (tests only; defaults to 31s). */
160
161
  connectTimeoutMs?: number;
162
+ /** Override the subscribe timeout (tests only; defaults to 60s). */
163
+ subscribeTimeoutMs?: number;
161
164
  logger?: BleDebugLogger;
162
165
  /**
163
166
  * Vendors served over IPC, keyed by the `vendor` the renderer sends. Replaces the default map
@@ -170,10 +173,13 @@ declare class NobleBleHandler {
170
173
  private _noble;
171
174
  private readonly _factory;
172
175
  private readonly _connectTimeoutMs;
176
+ private readonly _subscribeTimeoutMs;
173
177
  private readonly _logger?;
174
178
  private readonly _vendors;
175
179
  private readonly _discovered;
176
180
  private readonly _lastSeen;
181
+ private readonly _advertisedUuids;
182
+ private readonly _keptByMemory;
177
183
  private readonly _connected;
178
184
  private _discoverHandler?;
179
185
  private _scanning;
@@ -203,6 +209,7 @@ declare class NobleBleHandler {
203
209
  * packet, and a Safe 7 ADV carries only its name (UUID is in the scan response).
204
210
  */
205
211
  scan(options?: ElectronBleScanOptions): Promise<ThirdPartyBleDeviceInfo[]>;
212
+ private _rememberServiceUuids;
206
213
  /**
207
214
  * In-range devices matching the caller, minus TTL-expired ones. `_discovered`
208
215
  * is only a cache; a missing device can still be reached by `_directConnect`.
@@ -254,6 +261,12 @@ declare class NobleBleHandler {
254
261
  private _connectInner;
255
262
  disconnect(id: string): Promise<void>;
256
263
  subscribe(id: string): Promise<void>;
264
+ private _withSubscribeTimeout;
265
+ /**
266
+ * noble-win reports a failed subscribe only as `status: <AsyncStatus>`. Error (3) on a live
267
+ * link is a device refusing the bond Windows holds; a link already gone fails it the same way.
268
+ */
269
+ private _toSubscribeError;
257
270
  unsubscribe(id: string): Promise<void>;
258
271
  write(id: string, hexData: string): Promise<void>;
259
272
  /** Retire a renderer's handler without stopping a process-wide native manager. */
@@ -297,10 +310,21 @@ interface ThirdPartyBleSupportHandle {
297
310
  stop?(): void;
298
311
  }) => void): Promise<void>;
299
312
  }
313
+ /**
314
+ * Electron IPC keeps only an Error's message; as data, a `createHwkError`'s code and params
315
+ * survive. Only those cross, so the renderer rebuilds exactly what the host threw.
316
+ */
317
+ declare function createThirdPartyBleIpcErrorResponse(error: unknown): ThirdPartyBleIpcErrorResponse;
318
+ /**
319
+ * Handlers registered through this resolve failures as `ThirdPartyBleIpcErrorResponse`.
320
+ * Wrap the `ipcMain` that registers with Electron so inner wrappers still see throws, and
321
+ * pair it with a preload that rethrows `response.error`.
322
+ */
323
+ declare function withThirdPartyBleIpcErrors(ipcMain: IpcMainLike): IpcMainLike;
300
324
  /**
301
325
  * Wire a `NobleBleHandler` to Electron IPC once `BrowserWindow` is ready. Call dispose()
302
326
  * when retiring a renderer and disposeForAppQuit() before Node teardown.
303
327
  */
304
328
  declare function initThirdPartyBleSupport(webContents: WebContentsLike, options?: InitThirdPartyBleSupportOptions): ThirdPartyBleSupportHandle;
305
329
 
306
- export { type BleDebugLogEntry, type BleDebugLogLevel, type BleDebugLogger, DEFAULT_THIRD_PARTY_BLE_VENDORS, type InitThirdPartyBleSupportOptions, type IpcMainLike, NobleBleHandler, type NobleBleHandlerOptions, type ThirdPartyBleApi, type ThirdPartyBleAvailability, type ThirdPartyBleDeviceInfo, type ThirdPartyBleSupportHandle, type ThirdPartyBleVendorProfile, initThirdPartyBleSupport, redactBleDebugLogData };
330
+ export { type BleDebugLogEntry, type BleDebugLogLevel, type BleDebugLogger, DEFAULT_THIRD_PARTY_BLE_VENDORS, type InitThirdPartyBleSupportOptions, type IpcMainLike, NobleBleHandler, type NobleBleHandlerOptions, type ThirdPartyBleApi, type ThirdPartyBleAvailability, type ThirdPartyBleDeviceInfo, ThirdPartyBleIpcErrorResponse, type ThirdPartyBleSupportHandle, type ThirdPartyBleVendorProfile, createThirdPartyBleIpcErrorResponse, initThirdPartyBleSupport, redactBleDebugLogData, withThirdPartyBleIpcErrors };