@onekeyfe/hd-transport-electron 1.2.2-alpha.100 → 1.2.2-alpha.102

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.
@@ -1,2 +1,4 @@
1
+ /// <reference types="node" />
2
+ export declare function resolveNobleAttMtu(reportedMtu: number | null | undefined, platform?: NodeJS.Platform): number | undefined;
1
3
  export declare function resolveBlePacketCapacity(mtu: number | null | undefined, maximumPacketCapacity: number, fallbackPacketCapacity: number): number;
2
4
  //# sourceMappingURL=ble-packet-capacity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ble-packet-capacity.d.ts","sourceRoot":"","sources":["../src/ble-packet-capacity.ts"],"names":[],"mappings":"AAEA,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC9B,qBAAqB,EAAE,MAAM,EAC7B,sBAAsB,EAAE,MAAM,GAC7B,MAAM,CAMR"}
1
+ {"version":3,"file":"ble-packet-capacity.d.ts","sourceRoot":"","sources":["../src/ble-packet-capacity.ts"],"names":[],"mappings":";AAEA,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,MAAM,GAAG,SAAS,CASpB;AAED,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC9B,qBAAqB,EAAE,MAAM,EAC7B,sBAAsB,EAAE,MAAM,GAC7B,MAAM,CAMR"}
@@ -30,12 +30,44 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
30
30
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
31
31
  };
32
32
 
33
+ function isNobleBleIpcErrorResponse(response) {
34
+ var _a;
35
+ if (!response || typeof response !== 'object') {
36
+ return false;
37
+ }
38
+ const candidate = response;
39
+ return (candidate.type === 'NobleBleIpcError' &&
40
+ candidate.success === false &&
41
+ Boolean(candidate.error) &&
42
+ typeof ((_a = candidate.error) === null || _a === void 0 ? void 0 : _a.name) === 'string' &&
43
+ typeof candidate.error.message === 'string' &&
44
+ typeof candidate.error.errorCode === 'number');
45
+ }
46
+ function invokeNobleBleIpc(request) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ const response = yield request;
49
+ if (isNobleBleIpcErrorResponse(response)) {
50
+ return Promise.reject(response.error);
51
+ }
52
+ return response;
53
+ });
54
+ }
55
+
33
56
  function initNobleBleSupport(webContents) {
34
57
  return __awaiter(this, void 0, void 0, function* () {
35
- const { setupNobleBleHandlers } = yield Promise.resolve().then(function () { return require('./noble-ble-handler-e8b87173.js'); });
58
+ const { setupNobleBleHandlers } = yield Promise.resolve().then(function () { return require('./noble-ble-handler-3a1d131d.js'); });
36
59
  setupNobleBleHandlers(webContents);
37
60
  });
38
61
  }
62
+ function disposeNobleBleSupport(releaseNoble) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ const handler = yield Promise.resolve().then(function () { return require('./noble-ble-handler-3a1d131d.js'); });
65
+ yield handler.disposeNobleBleSupport(releaseNoble);
66
+ });
67
+ }
39
68
 
40
69
  exports.__awaiter = __awaiter;
70
+ exports.disposeNobleBleSupport = disposeNobleBleSupport;
41
71
  exports.initNobleBleSupport = initNobleBleSupport;
72
+ exports.invokeNobleBleIpc = invokeNobleBleIpc;
73
+ exports.isNobleBleIpcErrorResponse = isNobleBleIpcErrorResponse;
package/dist/index.d.ts CHANGED
@@ -17,6 +17,7 @@ interface NobleModule {
17
17
  state: string;
18
18
  startScanning(serviceUUIDs: string[], allowDuplicates: boolean, callback?: (error?: Error) => void): void;
19
19
  stopScanning(callback?: () => void): void;
20
+ stop(): void;
20
21
  on(event: 'stateChange', listener: (state: string) => void): void;
21
22
  on(event: 'discover', listener: (peripheral: Peripheral) => void): void;
22
23
  removeListener(event: 'stateChange', listener: (state: string) => void): void;
@@ -25,6 +26,7 @@ interface NobleModule {
25
26
  interface Logger {
26
27
  info(message: string, ...args: any[]): void;
27
28
  debug(message: string, ...args: any[]): void;
29
+ warn(message: string, ...args: any[]): void;
28
30
  error(message: string, ...args: any[]): void;
29
31
  }
30
32
 
@@ -36,6 +38,23 @@ interface Logger {
36
38
  interface NobleBleWriteOptions {
37
39
  pacingDelayMs?: number;
38
40
  }
41
+ type NobleBleIpcErrorPayload = {
42
+ name: string;
43
+ message: string;
44
+ errorCode: number;
45
+ params?: unknown;
46
+ };
47
+ type NobleBleIpcErrorResponse = {
48
+ type: 'NobleBleIpcError';
49
+ success: false;
50
+ error: NobleBleIpcErrorPayload;
51
+ };
52
+ declare function isNobleBleIpcErrorResponse(response: unknown): response is NobleBleIpcErrorResponse;
53
+ /**
54
+ * Keeps structured Noble errors intact across Electron's IPC and contextBridge
55
+ * boundaries. Every preload implementation must use this for Noble invokes.
56
+ */
57
+ declare function invokeNobleBleIpc<T>(request: Promise<T | NobleBleIpcErrorResponse>): Promise<T>;
39
58
  interface NobleBleAPI {
40
59
  enumerate: () => Promise<{
41
60
  id: string;
@@ -80,5 +99,9 @@ interface DesktopAPI {
80
99
  }
81
100
 
82
101
  declare function initNobleBleSupport(webContents: WebContents): Promise<void>;
102
+ /** Terminal process cleanup. A host sharing Noble can defer native stop until all users are idle. */
103
+ declare function disposeNobleBleSupport(releaseNoble?: (noble: {
104
+ stop(): void;
105
+ }) => void): Promise<void>;
83
106
 
84
- export { CharacteristicPair, DesktopAPI, DeviceInfo, Logger, NobleBleAPI, NobleBleWriteOptions, NobleModule, initNobleBleSupport };
107
+ export { CharacteristicPair, DesktopAPI, DeviceInfo, Logger, NobleBleAPI, NobleBleIpcErrorPayload, NobleBleIpcErrorResponse, NobleBleWriteOptions, NobleModule, disposeNobleBleSupport, initNobleBleSupport, invokeNobleBleIpc, isNobleBleIpcErrorResponse };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,cAAc,SAAS,CAAC;AAGxB,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEzF,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,WAAW,iBAGjE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,cAAc,SAAS,CAAC;AAGxB,YAAY,EACV,UAAU,EACV,WAAW,EACX,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAEpF,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,WAAW,iBAGjE;AAGD,wBAAsB,sBAAsB,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE;IAAE,IAAI,IAAI,IAAI,CAAA;CAAE,KAAK,IAAI,iBAG5F"}
package/dist/index.js CHANGED
@@ -2,8 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-b37d926c.js');
5
+ var index = require('./index-8e6acfc1.js');
6
6
 
7
7
 
8
8
 
9
+ exports.disposeNobleBleSupport = index.disposeNobleBleSupport;
9
10
  exports.initNobleBleSupport = index.initNobleBleSupport;
11
+ exports.invokeNobleBleIpc = index.invokeNobleBleIpc;
12
+ exports.isNobleBleIpcErrorResponse = index.isNobleBleIpcErrorResponse;