@onekeyfe/hwk-keystone-adapter 1.2.8-alpha.13 → 1.2.8-alpha.52

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.mjs CHANGED
@@ -687,8 +687,12 @@ var KeystoneAdapter = class _KeystoneAdapter {
687
687
  message: "Keystone operation has ended",
688
688
  params: { operationId: operation.operationId, reason }
689
689
  });
690
- this._jobQueue.cancelActiveAndPending(operation.operationId, ended);
691
- this._uiRegistry.cancel(void 0, void 0, operation.operationId);
690
+ const queueKey = keystoneQueueKey(operation.operationId);
691
+ const ownsRunningCall = this._jobQueue.getActiveJob()?.deviceId === queueKey;
692
+ this._jobQueue.cancelActiveAndPending(queueKey, ended);
693
+ if (ownsRunningCall) {
694
+ this._uiRegistry.cancel(void 0, void 0, operation.operationId);
695
+ }
692
696
  }
693
697
  }
694
698
  this.emitter.emit(SDK.OPERATION_ENDED, {
@@ -1879,7 +1883,18 @@ var KeystoneAdapter = class _KeystoneAdapter {
1879
1883
  signal.addEventListener("abort", onAbort, { once: true });
1880
1884
  const pending = this._usbConnectTail.then(async () => {
1881
1885
  _KeystoneAdapter._throwIfAborted(signal);
1882
- return this._connectUsbExclusive(connector, expected, searchTargetId, signal);
1886
+ if (this._unsettledUsbOperations.size > 0) {
1887
+ return failure(
1888
+ HardwareErrorCode2.DeviceBusyInternal,
1889
+ "Keystone USB is still finishing an earlier request"
1890
+ );
1891
+ }
1892
+ const releaseConnect = this._retainUsbOperation("connect");
1893
+ try {
1894
+ return await this._connectUsbExclusive(connector, expected, searchTargetId, signal);
1895
+ } finally {
1896
+ releaseConnect();
1897
+ }
1883
1898
  });
1884
1899
  const settled = pending.finally(() => {
1885
1900
  signal.removeEventListener("abort", onAbort);