@mcesystems/adb-kit 1.0.91 → 1.0.93

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
@@ -31479,7 +31479,7 @@ var AdbDeviceKit = class {
31479
31479
  return client;
31480
31480
  }
31481
31481
  async listDevices() {
31482
- const devices = await this.client.listDevices();
31482
+ const devices = await this.client.listDevices().filter((device) => device.type === "device");
31483
31483
  return devices;
31484
31484
  }
31485
31485
  async getProperty(adbDevice, property) {
@@ -31542,13 +31542,23 @@ var AdbDeviceKit = class {
31542
31542
  waitForUsbDebugging(timeout2 = 12e4, _numberOfAllowedAttempts = 5) {
31543
31543
  const events = new EventEmitter();
31544
31544
  const promise = (async () => {
31545
- if (await this.hasUsbDebugging()) {
31545
+ const device = (await this.client.listDevices()).find(
31546
+ (device2) => device2.id === this.deviceId
31547
+ );
31548
+ logDetail(`Device: ${device?.id} (${device?.type})`);
31549
+ if (device?.type === "device") {
31546
31550
  logDetail("USB debugging is already enabled");
31547
31551
  return true;
31548
31552
  }
31549
31553
  const trackingClient = this.createTrackingClient();
31550
31554
  const tracker = await trackingClient.trackDevices();
31551
- events.emit(USB_DEBUGGING_EVENT_OFF);
31555
+ setTimeout(() => {
31556
+ if (device?.type === "unauthorized") {
31557
+ events.emit(USB_DEBUGGING_EVENT_NEEDS_ALWAYS_ALLOW);
31558
+ } else {
31559
+ events.emit(USB_DEBUGGING_EVENT_OFF);
31560
+ }
31561
+ }, 0);
31552
31562
  let settled = false;
31553
31563
  return new Promise((resolve, reject) => {
31554
31564
  const timeoutId = setTimeout(() => {
@@ -31575,14 +31585,14 @@ var AdbDeviceKit = class {
31575
31585
  reject(result.err);
31576
31586
  }
31577
31587
  };
31578
- const handleAddOrChange = (device) => {
31579
- if (!this.matchesDeviceId(device)) return;
31580
- if (device.type === "unauthorized") {
31588
+ const handleAddOrChange = (device2) => {
31589
+ if (!this.matchesDeviceId(device2)) return;
31590
+ if (device2.type === "unauthorized") {
31581
31591
  logDetail("Device needs 'Always allow' authorization");
31582
31592
  events.emit(USB_DEBUGGING_EVENT_NEEDS_ALWAYS_ALLOW);
31583
31593
  return;
31584
31594
  }
31585
- if (device.type === "device") {
31595
+ if (device2.type === "device") {
31586
31596
  logDetail("Device authorized");
31587
31597
  events.emit(USB_DEBUGGING_EVENT_AUTHORIZED);
31588
31598
  settle({ type: "resolve", value: true });