@onekeyfe/hd-transport-electron 1.2.0-alpha.147 → 1.2.0-alpha.149
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.
|
@@ -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.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
|
|
|
@@ -242,7 +242,6 @@ function initializeNoble() {
|
|
|
242
242
|
try {
|
|
243
243
|
noble = require('@stoprocent/noble');
|
|
244
244
|
logger === null || logger === void 0 ? void 0 : logger.info('[NobleBLE] Noble library loaded');
|
|
245
|
-
setupPersistentStateListener();
|
|
246
245
|
yield new Promise((resolve, reject) => {
|
|
247
246
|
if (!noble) {
|
|
248
247
|
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Noble not initialized'));
|
|
@@ -252,6 +251,7 @@ function initializeNoble() {
|
|
|
252
251
|
resolve();
|
|
253
252
|
return;
|
|
254
253
|
}
|
|
254
|
+
setupPersistentStateListener();
|
|
255
255
|
const timeout = setTimeout(() => {
|
|
256
256
|
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Bluetooth initialization timeout'));
|
|
257
257
|
}, BLUETOOTH_INIT_TIMEOUT);
|
|
@@ -407,7 +407,6 @@ function handleDeviceDisconnect(deviceId, webContents) {
|
|
|
407
407
|
});
|
|
408
408
|
cleanupDevice(deviceId, webContents, {
|
|
409
409
|
cleanupConnection: true,
|
|
410
|
-
cleanupDiscoveredCache: true,
|
|
411
410
|
sendDisconnectEvent: true,
|
|
412
411
|
cancelOperations: true,
|
|
413
412
|
reason: 'auto-disconnect',
|
|
@@ -1180,7 +1179,6 @@ function disconnectDevice(deviceId) {
|
|
|
1180
1179
|
});
|
|
1181
1180
|
cleanupDevice(deviceId, undefined, {
|
|
1182
1181
|
cleanupConnection: true,
|
|
1183
|
-
cleanupDiscoveredCache: true,
|
|
1184
1182
|
sendDisconnectEvent: false,
|
|
1185
1183
|
cancelOperations: true,
|
|
1186
1184
|
reason: 'manual-disconnect',
|
|
@@ -1391,6 +1389,10 @@ function setupNobleBleHandlers(webContents) {
|
|
|
1391
1389
|
yield disconnectDevice(deviceId).catch(() => undefined);
|
|
1392
1390
|
}
|
|
1393
1391
|
yield stopScanning().catch(() => undefined);
|
|
1392
|
+
if (noble && persistentStateListener) {
|
|
1393
|
+
noble.removeListener('stateChange', persistentStateListener);
|
|
1394
|
+
persistentStateListener = null;
|
|
1395
|
+
}
|
|
1394
1396
|
cleanupNobleListeners();
|
|
1395
1397
|
discoveredDevices.clear();
|
|
1396
1398
|
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":"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;
|
|
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"}
|
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.149",
|
|
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.149",
|
|
29
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.149",
|
|
30
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.149",
|
|
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": "0c2b72c1edbafb2b738e3eb0b9ecdad8d8b92df7"
|
|
40
40
|
}
|
package/src/noble-ble-handler.ts
CHANGED
|
@@ -256,11 +256,6 @@ async function initializeNoble(): Promise<void> {
|
|
|
256
256
|
noble = require('@stoprocent/noble') as NobleModule;
|
|
257
257
|
logger?.info('[NobleBLE] Noble library loaded');
|
|
258
258
|
|
|
259
|
-
// Register the process-lifetime state listener before any early return:
|
|
260
|
-
// the poweredOn fast path below would otherwise skip it for the whole
|
|
261
|
-
// session, leaving poweredOff cache/state reconciliation dead.
|
|
262
|
-
setupPersistentStateListener();
|
|
263
|
-
|
|
264
259
|
// Wait for Bluetooth to be ready
|
|
265
260
|
await new Promise<void>((resolve, reject) => {
|
|
266
261
|
if (!noble) {
|
|
@@ -273,6 +268,9 @@ async function initializeNoble(): Promise<void> {
|
|
|
273
268
|
return;
|
|
274
269
|
}
|
|
275
270
|
|
|
271
|
+
// Setup persistent state listener before initialization
|
|
272
|
+
setupPersistentStateListener();
|
|
273
|
+
|
|
276
274
|
const timeout = setTimeout(() => {
|
|
277
275
|
reject(
|
|
278
276
|
ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Bluetooth initialization timeout')
|
|
@@ -496,9 +494,6 @@ function handleDeviceDisconnect(deviceId: string, webContents: WebContents): voi
|
|
|
496
494
|
|
|
497
495
|
cleanupDevice(deviceId, webContents, {
|
|
498
496
|
cleanupConnection: true,
|
|
499
|
-
// Same stale-object hazard as manual disconnect: an externally dropped
|
|
500
|
-
// link invalidates the cached peripheral for the next reconnect.
|
|
501
|
-
cleanupDiscoveredCache: true,
|
|
502
497
|
sendDisconnectEvent: true,
|
|
503
498
|
cancelOperations: true,
|
|
504
499
|
reason: 'auto-disconnect',
|
|
@@ -1593,10 +1588,6 @@ async function disconnectDevice(deviceId: string): Promise<void> {
|
|
|
1593
1588
|
});
|
|
1594
1589
|
cleanupDevice(deviceId, undefined, {
|
|
1595
1590
|
cleanupConnection: true,
|
|
1596
|
-
// macOS returns zero GATT services when a previously-disconnected
|
|
1597
|
-
// peripheral object is reconnected; drop the discovery cache so the next
|
|
1598
|
-
// connect resolves a fresh peripheral (direct connect by id, or scan).
|
|
1599
|
-
cleanupDiscoveredCache: true,
|
|
1600
1591
|
sendDisconnectEvent: false,
|
|
1601
1592
|
cancelOperations: true,
|
|
1602
1593
|
reason: 'manual-disconnect',
|
|
@@ -1922,12 +1913,10 @@ export function setupNobleBleHandlers(webContents: WebContents): void {
|
|
|
1922
1913
|
}
|
|
1923
1914
|
|
|
1924
1915
|
await stopScanning().catch(() => undefined);
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
// initializeNoble early-returns once noble is loaded). The null-guard
|
|
1930
|
-
// in setupPersistentStateListener keeps it deduped to one instance.
|
|
1916
|
+
if (noble && persistentStateListener) {
|
|
1917
|
+
noble.removeListener('stateChange', persistentStateListener);
|
|
1918
|
+
persistentStateListener = null;
|
|
1919
|
+
}
|
|
1931
1920
|
cleanupNobleListeners();
|
|
1932
1921
|
discoveredDevices.clear();
|
|
1933
1922
|
safeLog(logger, 'info', 'Noble BLE cleanup completed');
|