@mcesystems/adb-kit 1.0.96 → 1.0.98
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/README.md +230 -230
- package/dist/index.js +38 -4
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +38 -4
- package/dist/index.mjs.map +3 -3
- package/dist/resources/bin/darwin/adb +0 -0
- package/dist/resources/licenses/APACHE-2.0.txt +6 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic/adbDeviceKit.d.ts +2 -9
- package/dist/types/logic/adbDeviceKit.d.ts.map +1 -1
- package/dist/types/utils/debug.d.ts +7 -0
- package/dist/types/utils/debug.d.ts.map +1 -0
- package/package.json +3 -4
- package/scripts/README.md +183 -183
package/dist/index.mjs
CHANGED
|
@@ -31490,8 +31490,8 @@ var AdbDeviceKit = class {
|
|
|
31490
31490
|
return client;
|
|
31491
31491
|
}
|
|
31492
31492
|
async listDevices() {
|
|
31493
|
-
const
|
|
31494
|
-
return
|
|
31493
|
+
const allDevices = await this.client.listDevices();
|
|
31494
|
+
return allDevices.filter((device) => device.type === "device");
|
|
31495
31495
|
}
|
|
31496
31496
|
async getProperty(adbDevice, property) {
|
|
31497
31497
|
try {
|
|
@@ -31550,6 +31550,38 @@ var AdbDeviceKit = class {
|
|
|
31550
31550
|
matchesDeviceId(device) {
|
|
31551
31551
|
return device.id === this.deviceId || device.id.endsWith(this.deviceId);
|
|
31552
31552
|
}
|
|
31553
|
+
/**
|
|
31554
|
+
* Waits for USB debugging to be authorized (e.g. user enables and allows on device).
|
|
31555
|
+
* Returns a promise that resolves when the device is ready, or false on timeout.
|
|
31556
|
+
* Subscribe to events for progress (off, needs always allow, authorized).
|
|
31557
|
+
*/
|
|
31558
|
+
waitForUsbDebugging(timeoutMs = 12e4, _numberOfAllowedAttempts) {
|
|
31559
|
+
const events = new UsbDebuggingEventEmitter();
|
|
31560
|
+
let cleanupRef = null;
|
|
31561
|
+
const promise = new Promise((resolve, reject) => {
|
|
31562
|
+
let settled = false;
|
|
31563
|
+
const done = (value) => {
|
|
31564
|
+
if (settled) return;
|
|
31565
|
+
settled = true;
|
|
31566
|
+
clearTimeout(timeout2);
|
|
31567
|
+
cleanupRef?.();
|
|
31568
|
+
cleanupRef = null;
|
|
31569
|
+
resolve(value);
|
|
31570
|
+
};
|
|
31571
|
+
const timeout2 = setTimeout(() => done(false), timeoutMs);
|
|
31572
|
+
events.once(USB_DEBUGGING_EVENT_AUTHORIZED, () => done(true));
|
|
31573
|
+
this.trackUsbDebuggingStatus(events).then((c) => {
|
|
31574
|
+
cleanupRef = c;
|
|
31575
|
+
}).catch((err) => {
|
|
31576
|
+
if (!settled) {
|
|
31577
|
+
settled = true;
|
|
31578
|
+
clearTimeout(timeout2);
|
|
31579
|
+
reject(err);
|
|
31580
|
+
}
|
|
31581
|
+
});
|
|
31582
|
+
});
|
|
31583
|
+
return { promise, events };
|
|
31584
|
+
}
|
|
31553
31585
|
async trackUsbDebuggingStatus(eventEmitter) {
|
|
31554
31586
|
const device = (await this.client.listDevices()).find(
|
|
31555
31587
|
(device2) => device2.id === this.deviceId
|
|
@@ -31574,7 +31606,7 @@ var AdbDeviceKit = class {
|
|
|
31574
31606
|
logError("Device removed from tracker");
|
|
31575
31607
|
eventEmitter.emit(USB_DEBUGGING_EVENT_OFF, { deviceId: this.deviceId });
|
|
31576
31608
|
});
|
|
31577
|
-
|
|
31609
|
+
const handleDeviceChange = (device2) => {
|
|
31578
31610
|
if (!this.matchesDeviceId(device2)) return;
|
|
31579
31611
|
if (device2.type === "unauthorized") {
|
|
31580
31612
|
logDetail("Device needs 'Always allow' authorization");
|
|
@@ -31588,7 +31620,9 @@ var AdbDeviceKit = class {
|
|
|
31588
31620
|
logDetail("Device removed from tracker");
|
|
31589
31621
|
eventEmitter.emit(USB_DEBUGGING_EVENT_OFF, { deviceId: this.deviceId });
|
|
31590
31622
|
}
|
|
31591
|
-
}
|
|
31623
|
+
};
|
|
31624
|
+
tracker.on("add", handleDeviceChange);
|
|
31625
|
+
tracker.on("change", handleDeviceChange);
|
|
31592
31626
|
return () => tracker.end();
|
|
31593
31627
|
}
|
|
31594
31628
|
async startPortForward(serviceName) {
|