@onekeyfe/hd-transport-electron 1.2.0-alpha.158 → 1.2.0-alpha.159
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-2ec67577.js → index-b37d926c.js} +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/dist/{noble-ble-handler-7c14645d.js → noble-ble-handler-e8b87173.js} +9 -18
- package/dist/noble-ble-handler.d.ts.map +1 -1
- package/dist/types/noble-extended.d.ts +0 -1
- package/dist/types/noble-extended.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/noble-ble-handler.ts +10 -48
- package/src/types/noble-extended.ts +0 -1
|
@@ -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-e8b87173.js'); });
|
|
36
36
|
setupNobleBleHandlers(webContents);
|
|
37
37
|
});
|
|
38
38
|
}
|
package/dist/index.d.ts
CHANGED
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-b37d926c.js');
|
|
4
4
|
var hdShared = require('@onekeyfe/hd-shared');
|
|
5
5
|
var pRetry = require('p-retry');
|
|
6
6
|
|
|
@@ -116,8 +116,7 @@ const DEVICE_SCAN_TIMEOUT = 5000;
|
|
|
116
116
|
const DEVICE_CHECK_INTERVAL = 500;
|
|
117
117
|
const SERVICE_DISCOVERY_TIMEOUT = 10000;
|
|
118
118
|
const BLE_CLEANUP_TIMEOUT = 250;
|
|
119
|
-
const
|
|
120
|
-
const BLE_IDLE_DISCONNECT_MS = 20000;
|
|
119
|
+
const BLE_IDLE_DISCONNECT_MS = 3 * 60000;
|
|
121
120
|
const BLE_BUSY_BACKSTOP_MS = 10 * 60000;
|
|
122
121
|
const BLE_PACKET_SIZE_FALLBACK = 192;
|
|
123
122
|
const BLE_PACKET_SIZE_MAXIMUM = 244;
|
|
@@ -243,7 +242,6 @@ function initializeNoble() {
|
|
|
243
242
|
try {
|
|
244
243
|
noble = require('@stoprocent/noble');
|
|
245
244
|
logger === null || logger === void 0 ? void 0 : logger.info('[NobleBLE] Noble library loaded');
|
|
246
|
-
setupPersistentStateListener();
|
|
247
245
|
yield new Promise((resolve, reject) => {
|
|
248
246
|
if (!noble) {
|
|
249
247
|
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Noble not initialized'));
|
|
@@ -253,6 +251,7 @@ function initializeNoble() {
|
|
|
253
251
|
resolve();
|
|
254
252
|
return;
|
|
255
253
|
}
|
|
254
|
+
setupPersistentStateListener();
|
|
256
255
|
const timeout = setTimeout(() => {
|
|
257
256
|
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Bluetooth initialization timeout'));
|
|
258
257
|
}, BLUETOOTH_INIT_TIMEOUT);
|
|
@@ -337,14 +336,7 @@ function armIdleDisconnect(deviceId, ms = BLE_IDLE_DISCONNECT_MS, reason = 'idle
|
|
|
337
336
|
logger === null || logger === void 0 ? void 0 : logger.info('[NobleBLE] Keep-alive timeout, disconnecting device', { deviceId, reason });
|
|
338
337
|
const peripheral = connectedDevices.get(deviceId);
|
|
339
338
|
const deviceName = ((_a = peripheral === null || peripheral === void 0 ? void 0 : peripheral.advertisement) === null || _a === void 0 ? void 0 : _a.localName) || 'Unknown Device';
|
|
340
|
-
const pending =
|
|
341
|
-
.catch(error => {
|
|
342
|
-
logger === null || logger === void 0 ? void 0 : logger.warn('[NobleBLE] Keep-alive unsubscribe failed, disconnecting anyway', {
|
|
343
|
-
deviceId,
|
|
344
|
-
error: error instanceof Error ? error.message : String(error),
|
|
345
|
-
});
|
|
346
|
-
})
|
|
347
|
-
.then(() => disconnectDevice(deviceId))
|
|
339
|
+
const pending = disconnectDevice(deviceId)
|
|
348
340
|
.then(() => {
|
|
349
341
|
broadcastToAllWebContents(hdShared.EOneKeyBleMessageKeys.BLE_DEVICE_DISCONNECTED, {
|
|
350
342
|
id: deviceId,
|
|
@@ -417,7 +409,6 @@ function handleDeviceDisconnect(deviceId, webContents) {
|
|
|
417
409
|
});
|
|
418
410
|
cleanupDevice(deviceId, webContents, {
|
|
419
411
|
cleanupConnection: true,
|
|
420
|
-
cleanupDiscoveredCache: true,
|
|
421
412
|
sendDisconnectEvent: true,
|
|
422
413
|
cancelOperations: true,
|
|
423
414
|
reason: 'auto-disconnect',
|
|
@@ -1185,15 +1176,11 @@ function disconnectDevice(deviceId) {
|
|
|
1185
1176
|
deviceDisconnectListeners.delete(deviceId);
|
|
1186
1177
|
}
|
|
1187
1178
|
yield runBleCallbackOperation(callback => peripheral.disconnect(() => callback()), {
|
|
1188
|
-
timeoutMs:
|
|
1179
|
+
timeoutMs: BLE_CLEANUP_TIMEOUT,
|
|
1189
1180
|
timeoutBehavior: 'resolve',
|
|
1190
1181
|
});
|
|
1191
|
-
if (peripheral.state === 'connected') {
|
|
1192
|
-
logger === null || logger === void 0 ? void 0 : logger.warn('[NobleBLE] Physical disconnect did not confirm in time', { deviceId });
|
|
1193
|
-
}
|
|
1194
1182
|
cleanupDevice(deviceId, undefined, {
|
|
1195
1183
|
cleanupConnection: true,
|
|
1196
|
-
cleanupDiscoveredCache: true,
|
|
1197
1184
|
sendDisconnectEvent: false,
|
|
1198
1185
|
cancelOperations: true,
|
|
1199
1186
|
reason: 'manual-disconnect',
|
|
@@ -1404,6 +1391,10 @@ function setupNobleBleHandlers(webContents) {
|
|
|
1404
1391
|
yield disconnectDevice(deviceId).catch(() => undefined);
|
|
1405
1392
|
}
|
|
1406
1393
|
yield stopScanning().catch(() => undefined);
|
|
1394
|
+
if (noble && persistentStateListener) {
|
|
1395
|
+
noble.removeListener('stateChange', persistentStateListener);
|
|
1396
|
+
persistentStateListener = null;
|
|
1397
|
+
}
|
|
1407
1398
|
cleanupNobleListeners();
|
|
1408
1399
|
discoveredDevices.clear();
|
|
1409
1400
|
safeLog(logger, 'info', 'Noble BLE cleanup completed');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noble-ble-handler.d.ts","sourceRoot":"","sources":["../src/noble-ble-handler.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAA+B,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"noble-ble-handler.d.ts","sourceRoot":"","sources":["../src/noble-ble-handler.ts"],"names":[],"mappings":"AA+BA,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;AA2mDD,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAgMpE"}
|
|
@@ -22,7 +22,6 @@ export interface NobleModule {
|
|
|
22
22
|
export interface Logger {
|
|
23
23
|
info(message: string, ...args: any[]): void;
|
|
24
24
|
debug(message: string, ...args: any[]): void;
|
|
25
|
-
warn(message: string, ...args: any[]): void;
|
|
26
25
|
error(message: string, ...args: any[]): void;
|
|
27
26
|
}
|
|
28
27
|
export declare function safeLog(logger: Logger | null, level: 'info' | 'debug' | 'error', message: string, ...args: any[]): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noble-extended.d.ts","sourceRoot":"","sources":["../../src/types/noble-extended.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAm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AAW,MAAM;IACrB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC5C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC7C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC9C;AAGD,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,EACjC,OAAO,EAAE,MAAM,EACf,GAAG,IAAI,EAAE,GAAG,EAAE,GACb,IAAI,CAMN"}
|
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.159",
|
|
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.159",
|
|
29
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.159",
|
|
30
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.159",
|
|
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": "302f9ff916b3769cdb0cf79d58d09a87eeac68c2"
|
|
40
40
|
}
|
package/src/noble-ble-handler.ts
CHANGED
|
@@ -90,18 +90,8 @@ const DEVICE_SCAN_TIMEOUT = 5000; // 5 seconds for device scanning
|
|
|
90
90
|
const DEVICE_CHECK_INTERVAL = 500; // 500ms interval for periodic device checks
|
|
91
91
|
const SERVICE_DISCOVERY_TIMEOUT = 10000; // 10 seconds for service discovery
|
|
92
92
|
const BLE_CLEANUP_TIMEOUT = 250;
|
|
93
|
-
// A physical teardown must actually reach the OS before the device can return
|
|
94
|
-
// to a clean state; 250ms routinely declared success while CoreBluetooth was
|
|
95
|
-
// still disconnecting, leaving no trace when the teardown never completed.
|
|
96
|
-
const BLE_DISCONNECT_CONFIRM_TIMEOUT_MS = 3000;
|
|
97
93
|
// Renderer release is logical only; this timer physically frees the device.
|
|
98
|
-
|
|
99
|
-
// after sitting idle for minutes (field logs 2026-08-19: every deaf window
|
|
100
|
-
// followed a 3-minute-idle disconnect, while disconnects right after traffic
|
|
101
|
-
// have never produced one across 6.5.0's per-call teardown history). A hot
|
|
102
|
-
// disconnect ~20s after the last operation stays inside the proven-safe
|
|
103
|
-
// pattern and also shrinks the window in which phones cannot see the device.
|
|
104
|
-
const BLE_IDLE_DISCONNECT_MS = 20_000;
|
|
94
|
+
const BLE_IDLE_DISCONNECT_MS = 3 * 60_000;
|
|
105
95
|
// Ceiling while a call is in flight: no outstanding write, but not forever.
|
|
106
96
|
const BLE_BUSY_BACKSTOP_MS = 10 * 60_000;
|
|
107
97
|
|
|
@@ -267,11 +257,6 @@ async function initializeNoble(): Promise<void> {
|
|
|
267
257
|
noble = require('@stoprocent/noble') as NobleModule;
|
|
268
258
|
logger?.info('[NobleBLE] Noble library loaded');
|
|
269
259
|
|
|
270
|
-
// Register the process-lifetime state listener before any early return:
|
|
271
|
-
// the poweredOn fast path below would otherwise skip it for the whole
|
|
272
|
-
// session, leaving poweredOff cache/state reconciliation dead.
|
|
273
|
-
setupPersistentStateListener();
|
|
274
|
-
|
|
275
260
|
// Wait for Bluetooth to be ready
|
|
276
261
|
await new Promise<void>((resolve, reject) => {
|
|
277
262
|
if (!noble) {
|
|
@@ -284,6 +269,9 @@ async function initializeNoble(): Promise<void> {
|
|
|
284
269
|
return;
|
|
285
270
|
}
|
|
286
271
|
|
|
272
|
+
// Setup persistent state listener before initialization
|
|
273
|
+
setupPersistentStateListener();
|
|
274
|
+
|
|
287
275
|
const timeout = setTimeout(() => {
|
|
288
276
|
reject(
|
|
289
277
|
ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Bluetooth initialization timeout')
|
|
@@ -410,21 +398,7 @@ function armIdleDisconnect(
|
|
|
410
398
|
logger?.info('[NobleBLE] Keep-alive timeout, disconnecting device', { deviceId, reason });
|
|
411
399
|
const peripheral = connectedDevices.get(deviceId);
|
|
412
400
|
const deviceName = peripheral?.advertisement?.localName || 'Unknown Device';
|
|
413
|
-
|
|
414
|
-
// teardown path: the 1S leaves its notify session half-open when the
|
|
415
|
-
// link drops without an unsubscribe and then ignores application
|
|
416
|
-
// protocol traffic on NEW links for tens of minutes (field log
|
|
417
|
-
// 2026-08-19: the lone unsubscribe-skipping idle teardown caused a
|
|
418
|
-
// 6-attempt reconnect loop; unsubscribe-first teardowns reconnected
|
|
419
|
-
// instantly).
|
|
420
|
-
const pending = unsubscribeNotifications(deviceId)
|
|
421
|
-
.catch(error => {
|
|
422
|
-
logger?.warn('[NobleBLE] Keep-alive unsubscribe failed, disconnecting anyway', {
|
|
423
|
-
deviceId,
|
|
424
|
-
error: error instanceof Error ? error.message : String(error),
|
|
425
|
-
});
|
|
426
|
-
})
|
|
427
|
-
.then(() => disconnectDevice(deviceId))
|
|
401
|
+
const pending = disconnectDevice(deviceId)
|
|
428
402
|
.then(() => {
|
|
429
403
|
// A call is still in flight here; it must reject, not hang.
|
|
430
404
|
// Both 'idle' and 'busy-backstop' report IdleKeepAlive on purpose:
|
|
@@ -534,9 +508,6 @@ function handleDeviceDisconnect(deviceId: string, webContents: WebContents): voi
|
|
|
534
508
|
|
|
535
509
|
cleanupDevice(deviceId, webContents, {
|
|
536
510
|
cleanupConnection: true,
|
|
537
|
-
// Same stale-object hazard as manual disconnect: an externally dropped
|
|
538
|
-
// link invalidates the cached peripheral for the next reconnect.
|
|
539
|
-
cleanupDiscoveredCache: true,
|
|
540
511
|
sendDisconnectEvent: true,
|
|
541
512
|
cancelOperations: true,
|
|
542
513
|
reason: 'auto-disconnect',
|
|
@@ -1626,18 +1597,11 @@ async function disconnectDevice(deviceId: string): Promise<void> {
|
|
|
1626
1597
|
}
|
|
1627
1598
|
|
|
1628
1599
|
await runBleCallbackOperation(callback => peripheral.disconnect(() => callback()), {
|
|
1629
|
-
timeoutMs:
|
|
1600
|
+
timeoutMs: BLE_CLEANUP_TIMEOUT,
|
|
1630
1601
|
timeoutBehavior: 'resolve',
|
|
1631
1602
|
});
|
|
1632
|
-
if (peripheral.state === 'connected') {
|
|
1633
|
-
logger?.warn('[NobleBLE] Physical disconnect did not confirm in time', { deviceId });
|
|
1634
|
-
}
|
|
1635
1603
|
cleanupDevice(deviceId, undefined, {
|
|
1636
1604
|
cleanupConnection: true,
|
|
1637
|
-
// macOS returns zero GATT services when a previously-disconnected
|
|
1638
|
-
// peripheral object is reconnected; drop the discovery cache so the next
|
|
1639
|
-
// connect resolves a fresh peripheral (direct connect by id, or scan).
|
|
1640
|
-
cleanupDiscoveredCache: true,
|
|
1641
1605
|
sendDisconnectEvent: false,
|
|
1642
1606
|
cancelOperations: true,
|
|
1643
1607
|
reason: 'manual-disconnect',
|
|
@@ -1963,12 +1927,10 @@ export function setupNobleBleHandlers(webContents: WebContents): void {
|
|
|
1963
1927
|
}
|
|
1964
1928
|
|
|
1965
1929
|
await stopScanning().catch(() => undefined);
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
// initializeNoble early-returns once noble is loaded). The null-guard
|
|
1971
|
-
// in setupPersistentStateListener keeps it deduped to one instance.
|
|
1930
|
+
if (noble && persistentStateListener) {
|
|
1931
|
+
noble.removeListener('stateChange', persistentStateListener);
|
|
1932
|
+
persistentStateListener = null;
|
|
1933
|
+
}
|
|
1972
1934
|
cleanupNobleListeners();
|
|
1973
1935
|
discoveredDevices.clear();
|
|
1974
1936
|
safeLog(logger, 'info', 'Noble BLE cleanup completed');
|