@onekeyfe/hd-transport-electron 1.2.0-alpha.155 → 1.2.0-alpha.157
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-b37d926c.js → index-fe6d3919.js} +1 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.js +1 -1
- package/dist/{noble-ble-handler-e8b87173.js → noble-ble-handler-c88e98df.js} +2 -4
- package/dist/noble-ble-handler.d.ts.map +1 -1
- package/dist/types/desktop-api.d.ts +0 -2
- package/dist/types/desktop-api.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/noble-ble-handler.ts +0 -14
- package/src/types/desktop-api.ts +1 -11
|
@@ -32,7 +32,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
32
32
|
|
|
33
33
|
function initNobleBleSupport(webContents) {
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const { setupNobleBleHandlers } = yield Promise.resolve().then(function () { return require('./noble-ble-handler-
|
|
35
|
+
const { setupNobleBleHandlers } = yield Promise.resolve().then(function () { return require('./noble-ble-handler-c88e98df.js'); });
|
|
36
36
|
setupNobleBleHandlers(webContents);
|
|
37
37
|
});
|
|
38
38
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { WebContents } from 'electron';
|
|
2
2
|
import { Characteristic, Peripheral } from '@stoprocent/noble';
|
|
3
3
|
import { OneKeyDeviceInfoBase } from '@onekeyfe/hd-transport';
|
|
4
|
-
import { EBleDisconnectReason } from '@onekeyfe/hd-shared';
|
|
5
4
|
|
|
6
5
|
interface DeviceInfo extends OneKeyDeviceInfoBase {
|
|
7
6
|
id: string;
|
|
@@ -32,7 +31,6 @@ interface Logger {
|
|
|
32
31
|
* Desktop API types for Electron preload script
|
|
33
32
|
* These types define the core interface for Noble BLE communication
|
|
34
33
|
*/
|
|
35
|
-
|
|
36
34
|
interface NobleBleWriteOptions {
|
|
37
35
|
pacingDelayMs?: number;
|
|
38
36
|
}
|
|
@@ -57,16 +55,9 @@ interface NobleBleAPI {
|
|
|
57
55
|
id: string;
|
|
58
56
|
mtu: number;
|
|
59
57
|
}) => void) => () => void;
|
|
60
|
-
/**
|
|
61
|
-
* Fires whenever a BLE link drops. `reason` distinguishes a real peripheral
|
|
62
|
-
* drop from the main process freeing an idle link on its keep-alive timer;
|
|
63
|
-
* it is optional so an older host bridge that omits it still type-checks
|
|
64
|
-
* (absent is treated as a real drop by consumers).
|
|
65
|
-
*/
|
|
66
58
|
onDeviceDisconnected: (callback: (device: {
|
|
67
59
|
id: string;
|
|
68
60
|
name: string;
|
|
69
|
-
reason?: EBleDisconnectReason;
|
|
70
61
|
}) => void) => () => void;
|
|
71
62
|
checkAvailability: () => Promise<{
|
|
72
63
|
available: boolean;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-fe6d3919.js');
|
|
4
4
|
var hdShared = require('@onekeyfe/hd-shared');
|
|
5
5
|
var pRetry = require('p-retry');
|
|
6
6
|
|
|
@@ -341,7 +341,6 @@ function armIdleDisconnect(deviceId, ms = BLE_IDLE_DISCONNECT_MS, reason = 'idle
|
|
|
341
341
|
broadcastToAllWebContents(hdShared.EOneKeyBleMessageKeys.BLE_DEVICE_DISCONNECTED, {
|
|
342
342
|
id: deviceId,
|
|
343
343
|
name: deviceName,
|
|
344
|
-
reason: hdShared.EBleDisconnectReason.IdleKeepAlive,
|
|
345
344
|
});
|
|
346
345
|
})
|
|
347
346
|
.catch(error => {
|
|
@@ -357,7 +356,7 @@ function armIdleDisconnect(deviceId, ms = BLE_IDLE_DISCONNECT_MS, reason = 'idle
|
|
|
357
356
|
}
|
|
358
357
|
function cleanupDevice(deviceId, webContents, options = {}) {
|
|
359
358
|
var _a;
|
|
360
|
-
const { cleanupConnection = true, cleanupDiscoveredCache = false, sendDisconnectEvent = false, cancelOperations = true, reason = 'unknown',
|
|
359
|
+
const { cleanupConnection = true, cleanupDiscoveredCache = false, sendDisconnectEvent = false, cancelOperations = true, reason = 'unknown', } = options;
|
|
361
360
|
logger === null || logger === void 0 ? void 0 : logger.info('[NobleBLE] Starting device cleanup', {
|
|
362
361
|
deviceId,
|
|
363
362
|
reason,
|
|
@@ -394,7 +393,6 @@ function cleanupDevice(deviceId, webContents, options = {}) {
|
|
|
394
393
|
broadcastToAllWebContents(hdShared.EOneKeyBleMessageKeys.BLE_DEVICE_DISCONNECTED, {
|
|
395
394
|
id: deviceId,
|
|
396
395
|
name: deviceName,
|
|
397
|
-
reason: disconnectReason,
|
|
398
396
|
});
|
|
399
397
|
}
|
|
400
398
|
logger === null || logger === void 0 ? void 0 : logger.info('[NobleBLE] Device cleanup completed', { deviceId, reason });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noble-ble-handler.d.ts","sourceRoot":"","sources":["../src/noble-ble-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"noble-ble-handler.d.ts","sourceRoot":"","sources":["../src/noble-ble-handler.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAA+B,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AA0EhE,wBAAgB,+BAA+B,CAAC,OAAO,CAAC,EAAE,oBAAoB,UAI7E;AA8lDD,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAgMpE"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { EBleDisconnectReason } from '@onekeyfe/hd-shared';
|
|
2
1
|
export interface NobleBleWriteOptions {
|
|
3
2
|
pacingDelayMs?: number;
|
|
4
3
|
}
|
|
@@ -26,7 +25,6 @@ export interface NobleBleAPI {
|
|
|
26
25
|
onDeviceDisconnected: (callback: (device: {
|
|
27
26
|
id: string;
|
|
28
27
|
name: string;
|
|
29
|
-
reason?: EBleDisconnectReason;
|
|
30
28
|
}) => void) => () => void;
|
|
31
29
|
checkAvailability: () => Promise<{
|
|
32
30
|
available: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desktop-api.d.ts","sourceRoot":"","sources":["../../src/types/desktop-api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"desktop-api.d.ts","sourceRoot":"","sources":["../../src/types/desktop-api.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,oBAAoB;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC,CAAC;IACzD,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IACxF,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAGzC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrF,cAAc,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;IACnF,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;IACvF,oBAAoB,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;IAC/F,iBAAiB,EAAE,MAAM,OAAO,CAAC;QAC/B,SAAS,EAAE,OAAO,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,OAAO,CAAC;QACrB,WAAW,EAAE,OAAO,CAAC;KACtB,CAAC,CAAC;CACJ;AAGD,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,WAAW,CAAC;CACxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport-electron",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.157",
|
|
4
4
|
"author": "OneKey",
|
|
5
5
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"electron-log": ">=4.0.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-core": "1.2.0-alpha.
|
|
29
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
30
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
28
|
+
"@onekeyfe/hd-core": "1.2.0-alpha.157",
|
|
29
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.157",
|
|
30
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.157",
|
|
31
31
|
"@stoprocent/noble": "2.3.16",
|
|
32
32
|
"p-retry": "^4.6.2"
|
|
33
33
|
},
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"electron": "^25.0.0",
|
|
37
37
|
"typescript": "^5.3.3"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "1e9aaf5fbf64562504ebc22dc34fb22220ba0b0b"
|
|
40
40
|
}
|
package/src/noble-ble-handler.ts
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
/* eslint-disable @typescript-eslint/no-var-requires, import/no-extraneous-dependencies */
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
|
-
EBleDisconnectReason,
|
|
10
9
|
EOneKeyBleMessageKeys,
|
|
11
10
|
ERRORS,
|
|
12
11
|
HardwareErrorCode,
|
|
@@ -337,12 +336,6 @@ interface DeviceCleanupOptions {
|
|
|
337
336
|
cleanupDiscoveredCache?: boolean;
|
|
338
337
|
/** Whether to send disconnect event */
|
|
339
338
|
sendDisconnectEvent?: boolean;
|
|
340
|
-
/**
|
|
341
|
-
* Why the link went down, forwarded to renderers on BLE_DEVICE_DISCONNECTED.
|
|
342
|
-
* Defaults to a real peripheral drop; the keep-alive path overrides it so
|
|
343
|
-
* consumers can tell an internal idle release from a device that left.
|
|
344
|
-
*/
|
|
345
|
-
disconnectReason?: EBleDisconnectReason;
|
|
346
339
|
/** Whether to cancel ongoing operations */
|
|
347
340
|
cancelOperations?: boolean;
|
|
348
341
|
/** Cleanup reason (for logging) */
|
|
@@ -401,14 +394,9 @@ function armIdleDisconnect(
|
|
|
401
394
|
const pending = disconnectDevice(deviceId)
|
|
402
395
|
.then(() => {
|
|
403
396
|
// A call is still in flight here; it must reject, not hang.
|
|
404
|
-
// Both 'idle' and 'busy-backstop' report IdleKeepAlive on purpose:
|
|
405
|
-
// we reclaimed the link ourselves and have no evidence the device
|
|
406
|
-
// left, so consumers must not mark it disconnected. The in-flight
|
|
407
|
-
// call still fails, via the renderer dropping its device state.
|
|
408
397
|
broadcastToAllWebContents(EOneKeyBleMessageKeys.BLE_DEVICE_DISCONNECTED, {
|
|
409
398
|
id: deviceId,
|
|
410
399
|
name: deviceName,
|
|
411
|
-
reason: EBleDisconnectReason.IdleKeepAlive,
|
|
412
400
|
});
|
|
413
401
|
})
|
|
414
402
|
.catch(error => {
|
|
@@ -438,7 +426,6 @@ function cleanupDevice(
|
|
|
438
426
|
sendDisconnectEvent = false,
|
|
439
427
|
cancelOperations = true,
|
|
440
428
|
reason = 'unknown',
|
|
441
|
-
disconnectReason = EBleDisconnectReason.DeviceDisconnected,
|
|
442
429
|
} = options;
|
|
443
430
|
|
|
444
431
|
logger?.info('[NobleBLE] Starting device cleanup', {
|
|
@@ -488,7 +475,6 @@ function cleanupDevice(
|
|
|
488
475
|
broadcastToAllWebContents(EOneKeyBleMessageKeys.BLE_DEVICE_DISCONNECTED, {
|
|
489
476
|
id: deviceId,
|
|
490
477
|
name: deviceName,
|
|
491
|
-
reason: disconnectReason,
|
|
492
478
|
});
|
|
493
479
|
}
|
|
494
480
|
|
package/src/types/desktop-api.ts
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
* These types define the core interface for Noble BLE communication
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { EBleDisconnectReason } from '@onekeyfe/hd-shared';
|
|
7
|
-
|
|
8
6
|
// Noble BLE API interface - core BLE functionality
|
|
9
7
|
export interface NobleBleWriteOptions {
|
|
10
8
|
pacingDelayMs?: number;
|
|
@@ -23,15 +21,7 @@ export interface NobleBleAPI {
|
|
|
23
21
|
write: (uuid: string, data: string, options?: NobleBleWriteOptions) => Promise<void>;
|
|
24
22
|
onNotification: (callback: (deviceId: string, data: string) => void) => () => void;
|
|
25
23
|
onMtuChanged?: (callback: (device: { id: string; mtu: number }) => void) => () => void;
|
|
26
|
-
|
|
27
|
-
* Fires whenever a BLE link drops. `reason` distinguishes a real peripheral
|
|
28
|
-
* drop from the main process freeing an idle link on its keep-alive timer;
|
|
29
|
-
* it is optional so an older host bridge that omits it still type-checks
|
|
30
|
-
* (absent is treated as a real drop by consumers).
|
|
31
|
-
*/
|
|
32
|
-
onDeviceDisconnected: (
|
|
33
|
-
callback: (device: { id: string; name: string; reason?: EBleDisconnectReason }) => void
|
|
34
|
-
) => () => void;
|
|
24
|
+
onDeviceDisconnected: (callback: (device: { id: string; name: string }) => void) => () => void;
|
|
35
25
|
checkAvailability: () => Promise<{
|
|
36
26
|
available: boolean;
|
|
37
27
|
state: string;
|