@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.js CHANGED
@@ -679,8 +679,12 @@ var KeystoneAdapter = class _KeystoneAdapter {
679
679
  message: "Keystone operation has ended",
680
680
  params: { operationId: operation.operationId, reason }
681
681
  });
682
- this._jobQueue.cancelActiveAndPending(operation.operationId, ended);
683
- this._uiRegistry.cancel(void 0, void 0, operation.operationId);
682
+ const queueKey = keystoneQueueKey(operation.operationId);
683
+ const ownsRunningCall = this._jobQueue.getActiveJob()?.deviceId === queueKey;
684
+ this._jobQueue.cancelActiveAndPending(queueKey, ended);
685
+ if (ownsRunningCall) {
686
+ this._uiRegistry.cancel(void 0, void 0, operation.operationId);
687
+ }
684
688
  }
685
689
  }
686
690
  this.emitter.emit(import_hwk_adapter_core3.SDK.OPERATION_ENDED, {
@@ -1871,7 +1875,18 @@ var KeystoneAdapter = class _KeystoneAdapter {
1871
1875
  signal.addEventListener("abort", onAbort, { once: true });
1872
1876
  const pending = this._usbConnectTail.then(async () => {
1873
1877
  _KeystoneAdapter._throwIfAborted(signal);
1874
- return this._connectUsbExclusive(connector, expected, searchTargetId, signal);
1878
+ if (this._unsettledUsbOperations.size > 0) {
1879
+ return (0, import_hwk_adapter_core3.failure)(
1880
+ import_hwk_adapter_core3.HardwareErrorCode.DeviceBusyInternal,
1881
+ "Keystone USB is still finishing an earlier request"
1882
+ );
1883
+ }
1884
+ const releaseConnect = this._retainUsbOperation("connect");
1885
+ try {
1886
+ return await this._connectUsbExclusive(connector, expected, searchTargetId, signal);
1887
+ } finally {
1888
+ releaseConnect();
1889
+ }
1875
1890
  });
1876
1891
  const settled = pending.finally(() => {
1877
1892
  signal.removeEventListener("abort", onAbort);