@onekeyfe/hd-transport-electron 1.2.0-alpha.150 → 1.2.0-alpha.151

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-c88e98df.js'); });
35
+ const { setupNobleBleHandlers } = yield Promise.resolve().then(function () { return require('./noble-ble-handler-efd3df55.js'); });
36
36
  setupNobleBleHandlers(webContents);
37
37
  });
38
38
  }
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-fe6d3919.js');
5
+ var index = require('./index-70b4a97d.js');
6
6
 
7
7
 
8
8
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-fe6d3919.js');
3
+ var index = require('./index-70b4a97d.js');
4
4
  var hdShared = require('@onekeyfe/hd-shared');
5
5
  var pRetry = require('p-retry');
6
6
 
@@ -242,6 +242,7 @@ 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();
245
246
  yield new Promise((resolve, reject) => {
246
247
  if (!noble) {
247
248
  reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Noble not initialized'));
@@ -251,7 +252,6 @@ function initializeNoble() {
251
252
  resolve();
252
253
  return;
253
254
  }
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,6 +407,7 @@ function handleDeviceDisconnect(deviceId, webContents) {
407
407
  });
408
408
  cleanupDevice(deviceId, webContents, {
409
409
  cleanupConnection: true,
410
+ cleanupDiscoveredCache: true,
410
411
  sendDisconnectEvent: true,
411
412
  cancelOperations: true,
412
413
  reason: 'auto-disconnect',
@@ -1179,6 +1180,7 @@ function disconnectDevice(deviceId) {
1179
1180
  });
1180
1181
  cleanupDevice(deviceId, undefined, {
1181
1182
  cleanupConnection: true,
1183
+ cleanupDiscoveredCache: true,
1182
1184
  sendDisconnectEvent: false,
1183
1185
  cancelOperations: true,
1184
1186
  reason: 'manual-disconnect',
@@ -1389,10 +1391,6 @@ function setupNobleBleHandlers(webContents) {
1389
1391
  yield disconnectDevice(deviceId).catch(() => undefined);
1390
1392
  }
1391
1393
  yield stopScanning().catch(() => undefined);
1392
- if (noble && persistentStateListener) {
1393
- noble.removeListener('stateChange', persistentStateListener);
1394
- persistentStateListener = null;
1395
- }
1396
1394
  cleanupNobleListeners();
1397
1395
  discoveredDevices.clear();
1398
1396
  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;AA8lDD,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAgMpE"}
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;AAumDD,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAkMpE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-electron",
3
- "version": "1.2.0-alpha.150",
3
+ "version": "1.2.0-alpha.151",
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.150",
29
- "@onekeyfe/hd-shared": "1.2.0-alpha.150",
30
- "@onekeyfe/hd-transport": "1.2.0-alpha.150",
28
+ "@onekeyfe/hd-core": "1.2.0-alpha.151",
29
+ "@onekeyfe/hd-shared": "1.2.0-alpha.151",
30
+ "@onekeyfe/hd-transport": "1.2.0-alpha.151",
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": "08359528e71933964694eb49793e555635350104"
39
+ "gitHead": "d1fa81c92deb1bfa3903e3963a82edd6384d568a"
40
40
  }
@@ -256,6 +256,11 @@ 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
+
259
264
  // Wait for Bluetooth to be ready
260
265
  await new Promise<void>((resolve, reject) => {
261
266
  if (!noble) {
@@ -268,9 +273,6 @@ async function initializeNoble(): Promise<void> {
268
273
  return;
269
274
  }
270
275
 
271
- // Setup persistent state listener before initialization
272
- setupPersistentStateListener();
273
-
274
276
  const timeout = setTimeout(() => {
275
277
  reject(
276
278
  ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Bluetooth initialization timeout')
@@ -494,6 +496,9 @@ function handleDeviceDisconnect(deviceId: string, webContents: WebContents): voi
494
496
 
495
497
  cleanupDevice(deviceId, webContents, {
496
498
  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,
497
502
  sendDisconnectEvent: true,
498
503
  cancelOperations: true,
499
504
  reason: 'auto-disconnect',
@@ -1588,6 +1593,10 @@ async function disconnectDevice(deviceId: string): Promise<void> {
1588
1593
  });
1589
1594
  cleanupDevice(deviceId, undefined, {
1590
1595
  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,
1591
1600
  sendDisconnectEvent: false,
1592
1601
  cancelOperations: true,
1593
1602
  reason: 'manual-disconnect',
@@ -1913,10 +1922,12 @@ export function setupNobleBleHandlers(webContents: WebContents): void {
1913
1922
  }
1914
1923
 
1915
1924
  await stopScanning().catch(() => undefined);
1916
- if (noble && persistentStateListener) {
1917
- noble.removeListener('stateChange', persistentStateListener);
1918
- persistentStateListener = null;
1919
- }
1925
+ // persistentStateListener is process-lifetime, NOT per-window: this
1926
+ // destroy handler also fires on a renderer soft restart, and removing
1927
+ // the listener here permanently killed poweredOff/poweredOn
1928
+ // reconciliation for the rest of the process (nothing re-registers it:
1929
+ // initializeNoble early-returns once noble is loaded). The null-guard
1930
+ // in setupPersistentStateListener keeps it deduped to one instance.
1920
1931
  cleanupNobleListeners();
1921
1932
  discoveredDevices.clear();
1922
1933
  safeLog(logger, 'info', 'Noble BLE cleanup completed');