@mcesystems/adb-kit 1.0.1 → 1.0.2
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 +33 -164
- package/dist/index.js.map +4 -4
- package/dist/resources/bin/windows/AdbWinApi.dll +0 -0
- package/dist/resources/bin/windows/AdbWinUsbApi.dll +0 -0
- package/dist/resources/bin/windows/adb.exe +0 -0
- package/dist/resources/licenses/APACHE-2.0.txt +6 -0
- package/dist/types/logic/adbDeviceKit.d.ts +4 -4
- package/dist/types/logic/adbDeviceKit.d.ts.map +1 -1
- package/dist/types/logic/devicesMonitor.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/logic/adbDeviceKit.ts
|
|
2
|
-
import
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
3
|
|
|
4
4
|
// src/utils/adbPath.ts
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
@@ -25,21 +25,21 @@ function getAdbBinaryName() {
|
|
|
25
25
|
return "adb";
|
|
26
26
|
}
|
|
27
27
|
function getAdbBinaryPath() {
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
let
|
|
31
|
-
if (
|
|
32
|
-
|
|
28
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
29
|
+
const __dirname = path.dirname(__filename);
|
|
30
|
+
let packageRoot;
|
|
31
|
+
if (__dirname.includes("dist")) {
|
|
32
|
+
packageRoot = path.resolve(__dirname, "..", "..");
|
|
33
33
|
} else {
|
|
34
|
-
|
|
34
|
+
packageRoot = path.resolve(__dirname, "..", "..");
|
|
35
35
|
}
|
|
36
36
|
const platformDir = getPlatformDir();
|
|
37
37
|
const binaryName = getAdbBinaryName();
|
|
38
|
-
const distPath = path.join(
|
|
38
|
+
const distPath = path.join(packageRoot, "dist", "resources", "bin", platformDir, binaryName);
|
|
39
39
|
if (existsSync(distPath)) {
|
|
40
40
|
return distPath;
|
|
41
41
|
}
|
|
42
|
-
const devPath = path.join(
|
|
42
|
+
const devPath = path.join(packageRoot, "resources", "bin", platformDir, binaryName);
|
|
43
43
|
if (existsSync(devPath)) {
|
|
44
44
|
return devPath;
|
|
45
45
|
}
|
|
@@ -58,7 +58,8 @@ logWarning.color = "214";
|
|
|
58
58
|
logError.color = "160";
|
|
59
59
|
|
|
60
60
|
// src/logic/adbDeviceKit.ts
|
|
61
|
-
var
|
|
61
|
+
var require2 = createRequire(import.meta.url);
|
|
62
|
+
var adbkit = require2("@devicefarmer/adbkit");
|
|
62
63
|
function ensureAdbPathFromResources() {
|
|
63
64
|
const adbPath = getAdbBinaryPath();
|
|
64
65
|
if (adbPath && !process.env.ADB_PATH) {
|
|
@@ -98,7 +99,7 @@ var AdbDeviceKit = class {
|
|
|
98
99
|
constructor(deviceId, port) {
|
|
99
100
|
this.port = port;
|
|
100
101
|
ensureAdbPathFromResources();
|
|
101
|
-
this.client =
|
|
102
|
+
this.client = adbkit.default.createClient();
|
|
102
103
|
this.deviceId = deviceId.split("\\").pop() ?? deviceId;
|
|
103
104
|
logInfo(`Device ID: ${this.deviceId}`);
|
|
104
105
|
this.device = this.client.getDevice(this.deviceId);
|
|
@@ -126,14 +127,14 @@ var AdbDeviceKit = class {
|
|
|
126
127
|
}
|
|
127
128
|
async getAllDeviceProperties() {
|
|
128
129
|
if (!await this.hasUsbDebugging()) {
|
|
129
|
-
|
|
130
|
+
this.waitForUsbDebugging(1e4);
|
|
130
131
|
}
|
|
131
132
|
return this.device.getProperties();
|
|
132
133
|
}
|
|
133
134
|
async getDeviceProperties(properties) {
|
|
134
135
|
logTask(`Getting properties ${properties.join(", ")} for device ${this.deviceId}`);
|
|
135
136
|
if (!await this.hasUsbDebugging()) {
|
|
136
|
-
|
|
137
|
+
this.waitForUsbDebugging(1e4);
|
|
137
138
|
}
|
|
138
139
|
const propertiesValues = await Promise.all(
|
|
139
140
|
properties.map((property) => this.getProperty(this.device, property))
|
|
@@ -143,21 +144,21 @@ var AdbDeviceKit = class {
|
|
|
143
144
|
async installApp(appPath) {
|
|
144
145
|
logTask(`Installing app ${appPath} on device ${this.deviceId}`);
|
|
145
146
|
if (!await this.hasUsbDebugging()) {
|
|
146
|
-
|
|
147
|
+
this.waitForUsbDebugging(1e4);
|
|
147
148
|
}
|
|
148
149
|
await this.device.install(appPath);
|
|
149
150
|
}
|
|
150
151
|
async uninstallApp(packageName) {
|
|
151
152
|
logTask(`Uninstalling app ${packageName} on device ${this.deviceId}`);
|
|
152
153
|
if (!await this.hasUsbDebugging()) {
|
|
153
|
-
|
|
154
|
+
this.waitForUsbDebugging(1e4);
|
|
154
155
|
}
|
|
155
156
|
await this.device.uninstall(packageName);
|
|
156
157
|
}
|
|
157
158
|
async isAppInstalled(packageName) {
|
|
158
159
|
logTask(`Checking if app ${packageName} is installed on device ${this.deviceId}`);
|
|
159
160
|
if (!await this.hasUsbDebugging()) {
|
|
160
|
-
|
|
161
|
+
this.waitForUsbDebugging(1e4);
|
|
161
162
|
}
|
|
162
163
|
return await this.device.isInstalled(packageName);
|
|
163
164
|
}
|
|
@@ -167,10 +168,7 @@ var AdbDeviceKit = class {
|
|
|
167
168
|
*/
|
|
168
169
|
async getClient() {
|
|
169
170
|
if (!this.hasUsbDebugging) {
|
|
170
|
-
|
|
171
|
-
if (!this.hasUsbDebugging) {
|
|
172
|
-
throw new Error("USB debugging is not enabled");
|
|
173
|
-
}
|
|
171
|
+
this.waitForUsbDebugging(1e4);
|
|
174
172
|
}
|
|
175
173
|
return this.client;
|
|
176
174
|
}
|
|
@@ -213,142 +211,10 @@ var AdbDeviceKit = class {
|
|
|
213
211
|
|
|
214
212
|
// src/logic/devicesMonitor.ts
|
|
215
213
|
import EventEmitter from "node:events";
|
|
216
|
-
import
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
import { dirname, join } from "node:path";
|
|
221
|
-
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
222
|
-
function toHexString(value) {
|
|
223
|
-
return value.toString(16).toUpperCase().padStart(4, "0");
|
|
224
|
-
}
|
|
225
|
-
function matchesDevice(device, target) {
|
|
226
|
-
const deviceVid = toHexString(device.vid);
|
|
227
|
-
const devicePid = toHexString(device.pid);
|
|
228
|
-
const targetVid = target.vid.toUpperCase();
|
|
229
|
-
const targetPid = target.pid.toUpperCase();
|
|
230
|
-
return deviceVid === targetVid && devicePid === targetPid;
|
|
231
|
-
}
|
|
232
|
-
function matchesAnyDevice(device, targets) {
|
|
233
|
-
return targets.some((target) => matchesDevice(device, target));
|
|
234
|
-
}
|
|
235
|
-
function shouldNotifyDevice(device, config) {
|
|
236
|
-
if (config.ignoredDevices && config.ignoredDevices.length > 0) {
|
|
237
|
-
if (matchesAnyDevice(device, config.ignoredDevices)) {
|
|
238
|
-
return false;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
if (config.listenOnlyDevices && config.listenOnlyDevices.length > 0) {
|
|
242
|
-
if (!matchesAnyDevice(device, config.listenOnlyDevices)) {
|
|
243
|
-
return false;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
if (config.targetDevices && config.targetDevices.length > 0) {
|
|
247
|
-
if (!matchesAnyDevice(device, config.targetDevices)) {
|
|
248
|
-
return false;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
if (config.logicalPortMap && Object.keys(config.logicalPortMap).length > 0) {
|
|
252
|
-
if (!(device.locationInfo in config.logicalPortMap)) {
|
|
253
|
-
return false;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
return true;
|
|
257
|
-
}
|
|
258
|
-
function applyLogicalPortMapping(device, config) {
|
|
259
|
-
if (config.logicalPortMap && device.locationInfo in config.logicalPortMap) {
|
|
260
|
-
return {
|
|
261
|
-
...device,
|
|
262
|
-
logicalPort: config.logicalPortMap[device.locationInfo]
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
return device;
|
|
266
|
-
}
|
|
267
|
-
var __filename = fileURLToPath2(import.meta.url);
|
|
268
|
-
var __dirname = dirname(__filename);
|
|
269
|
-
var packageRoot = dirname(__dirname);
|
|
270
|
-
function loadNativeAddon() {
|
|
271
|
-
const require2 = createRequire(import.meta.url);
|
|
272
|
-
const addonPath = join(packageRoot, "build", "Release", "@mcesystems+usb-device-listener.node");
|
|
273
|
-
try {
|
|
274
|
-
return require2(addonPath);
|
|
275
|
-
} catch {
|
|
276
|
-
try {
|
|
277
|
-
const nodeGypBuild = require2("node-gyp-build");
|
|
278
|
-
return nodeGypBuild(packageRoot);
|
|
279
|
-
} catch {
|
|
280
|
-
throw new Error(
|
|
281
|
-
`Failed to load native addon. Tried:
|
|
282
|
-
1. Direct path: ${addonPath}
|
|
283
|
-
2. node-gyp-build search
|
|
284
|
-
Make sure the addon is built with 'npm run rebuild' or 'npm run prebuild'`
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
var addon = loadNativeAddon();
|
|
290
|
-
var UsbDeviceListenerImpl = class {
|
|
291
|
-
config = {};
|
|
292
|
-
userAddCallback = null;
|
|
293
|
-
userRemoveCallback = null;
|
|
294
|
-
/**
|
|
295
|
-
* Start listening for USB device events
|
|
296
|
-
*/
|
|
297
|
-
startListening(config) {
|
|
298
|
-
if (typeof config !== "object" || config === null) {
|
|
299
|
-
throw new TypeError("Config must be an object");
|
|
300
|
-
}
|
|
301
|
-
this.config = config;
|
|
302
|
-
addon.startListening();
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Stop listening for USB device events
|
|
306
|
-
*/
|
|
307
|
-
stopListening() {
|
|
308
|
-
addon.stopListening();
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Register callback for device connection events
|
|
312
|
-
*/
|
|
313
|
-
onDeviceAdd(callback) {
|
|
314
|
-
if (typeof callback !== "function") {
|
|
315
|
-
throw new TypeError("Callback must be a function");
|
|
316
|
-
}
|
|
317
|
-
this.userAddCallback = callback;
|
|
318
|
-
addon.onDeviceAdd((device) => {
|
|
319
|
-
if (shouldNotifyDevice(device, this.config)) {
|
|
320
|
-
const enrichedDevice = applyLogicalPortMapping(device, this.config);
|
|
321
|
-
this.userAddCallback?.(enrichedDevice);
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Register callback for device disconnection events
|
|
327
|
-
*/
|
|
328
|
-
onDeviceRemove(callback) {
|
|
329
|
-
if (typeof callback !== "function") {
|
|
330
|
-
throw new TypeError("Callback must be a function");
|
|
331
|
-
}
|
|
332
|
-
this.userRemoveCallback = callback;
|
|
333
|
-
addon.onDeviceRemove((device) => {
|
|
334
|
-
if (shouldNotifyDevice(device, this.config)) {
|
|
335
|
-
const enrichedDevice = applyLogicalPortMapping(device, this.config);
|
|
336
|
-
this.userRemoveCallback?.(enrichedDevice);
|
|
337
|
-
}
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* List all currently connected USB devices
|
|
342
|
-
*/
|
|
343
|
-
listDevices() {
|
|
344
|
-
return addon.listDevices();
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
var usbDeviceListener = new UsbDeviceListenerImpl();
|
|
348
|
-
var index_default = usbDeviceListener;
|
|
349
|
-
|
|
350
|
-
// src/logic/devicesMonitor.ts
|
|
351
|
-
var { Client: Client2 } = adbkit2;
|
|
214
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
215
|
+
import usbDeviceListener from "@mcesystems/usb-device-listener";
|
|
216
|
+
var require3 = createRequire2(import.meta.url);
|
|
217
|
+
var adbkit2 = require3("@devicefarmer/adbkit");
|
|
352
218
|
function ensureAdbPathFromResources2() {
|
|
353
219
|
const adbPath = getAdbBinaryPath();
|
|
354
220
|
if (adbPath && !process.env.ADB_PATH) {
|
|
@@ -365,7 +231,7 @@ var DevicesMonitor = class {
|
|
|
365
231
|
eventEmitter;
|
|
366
232
|
async startTracking() {
|
|
367
233
|
logInfo("Starting devices monitor");
|
|
368
|
-
|
|
234
|
+
usbDeviceListener.startListening(this.config);
|
|
369
235
|
this.eventEmitter = new EventEmitter();
|
|
370
236
|
if (this.identifyAlreadyConnected) {
|
|
371
237
|
await this.connectedDevices();
|
|
@@ -375,16 +241,19 @@ var DevicesMonitor = class {
|
|
|
375
241
|
}, 0);
|
|
376
242
|
}
|
|
377
243
|
}
|
|
378
|
-
|
|
244
|
+
usbDeviceListener.onDeviceAdd((device) => {
|
|
379
245
|
console.log("Device added:", device.deviceId);
|
|
380
246
|
if (!device.logicalPort) {
|
|
381
247
|
return;
|
|
382
248
|
}
|
|
383
|
-
const
|
|
384
|
-
|
|
249
|
+
const existingKit = this.kits.get(device.deviceId);
|
|
250
|
+
const adbDeviceKit = existingKit ?? new AdbDeviceKit(device.deviceId, device.logicalPort);
|
|
251
|
+
if (!existingKit) {
|
|
252
|
+
this.kits.set(device.deviceId, adbDeviceKit);
|
|
253
|
+
}
|
|
385
254
|
this.eventEmitter?.emit("added", adbDeviceKit);
|
|
386
255
|
});
|
|
387
|
-
|
|
256
|
+
usbDeviceListener.onDeviceRemove((device) => {
|
|
388
257
|
if (!device.logicalPort) {
|
|
389
258
|
return;
|
|
390
259
|
}
|
|
@@ -400,14 +269,14 @@ var DevicesMonitor = class {
|
|
|
400
269
|
this.eventEmitter.removeAllListeners();
|
|
401
270
|
this.kits.clear();
|
|
402
271
|
this.eventEmitter = void 0;
|
|
403
|
-
|
|
272
|
+
usbDeviceListener.stopListening();
|
|
404
273
|
}
|
|
405
274
|
async connectedDevices() {
|
|
406
275
|
ensureAdbPathFromResources2();
|
|
407
|
-
const client =
|
|
276
|
+
const client = adbkit2.default.createClient();
|
|
408
277
|
const devicesIds = await client.listDevices().filter((device) => device.type === "device").map((device) => device.id);
|
|
409
278
|
this.kits = new Map(
|
|
410
|
-
await
|
|
279
|
+
await usbDeviceListener.listDevices().map((device) => ({
|
|
411
280
|
id: device.deviceId.split("\\").pop() ?? "",
|
|
412
281
|
port: device.logicalPort ?? 0
|
|
413
282
|
})).filter((device) => devicesIds.includes(device.id)).map((device) => [device.id, new AdbDeviceKit(device.id, device.port)])
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/logic/adbDeviceKit.ts", "../src/utils/adbPath.ts", "../src/utils/debug.ts", "../src/logic/devicesMonitor.ts"
|
|
4
|
-
"sourcesContent": ["import * as adbkit from \"@devicefarmer/adbkit\";\nconst { Client } = adbkit;\nimport type { DeviceClient } from \"@devicefarmer/adbkit\";\nimport type { AdbDevice } from \"../types/adb\";\nimport { getAdbBinaryPath } from \"../utils/adbPath\";\nimport { logInfo, logTask } from \"../utils/debug\";\n\n\n/**\n * Ensures ADB_PATH environment variable is set to use adb from resources\n * @devicefarmer/adbkit uses ADB_PATH environment variable to locate the adb binary\n */\nfunction ensureAdbPathFromResources(): void {\n\tconst adbPath = getAdbBinaryPath();\n\tif (adbPath && !process.env.ADB_PATH) {\n\t\tprocess.env.ADB_PATH = adbPath;\n\t\tlogInfo(`Using ADB from resources: ${adbPath}`);\n\t}\n}\n\nconst deviceProps = {\n\tManufacturer: \"ro.product.manufacturer\",\n\tName: \"ro.product.name\",\n\tModel: \"ro.product.model\",\n\t\"Android Version\": \"ro.build.version.release\",\n\tPlatform: \"ro.board.platform\",\n\tCPU: \"ro.product.cpu.abi\",\n\t\"CPU.abi2\": \"ro.product.cpu.abi2\",\n\tDescription: \"ro.build.description\",\n\tFingerprint: \"ro.build.fingerprint\",\n\tBrand: \"ro.product.brand\",\n\tDevice: \"ro.product.device\",\n\t\"GSM Flexversion\": \"ro.gsm.flexversion\",\n\t\"Locale Language\": \"ro.product.locale.language\",\n\t\"Locale Region\": \"ro.product.locale.region\",\n\t\"Wifi Channels\": \"ro.wifi.channels\",\n\t\"Board Platform\": \"ro.board.platform\",\n\t\"Product Board\": \"ro.product.board\",\n\t\"Display ID\": \"ro.build.display.id\",\n\t\"GSM IMEI\": \"gsm.baseband.imei\",\n\t\"Version Incremental\": \"ro.build.version.incremental\",\n\t\"Version SDK\": \"ro.build.version.sdk\",\n\t\"Version Codename\": \"ro.build.version.codename\",\n\t\"Version Release\": \"ro.build.version.release\",\n\t\"Build Date\": \"ro.build.date\",\n\t\"Build Type\": \"ro.build.type\",\n\t\"Build User\": \"ro.build.user\",\n};\n\nexport type DeviceProperty = keyof typeof deviceProps;\n\nexport class AdbDeviceKit {\n\tprivate client: adbkit.Client;\n\tprivate device: DeviceClient;\n\tprivate deviceId: string;\n\n\tconstructor(\n\t\tdeviceId: string,\n\t\tprivate readonly port: number\n\t) {\n\t\tensureAdbPathFromResources();\n\t\tthis.client = new Client();\n\t\t// Extract only the last part of deviceId after the last backslash\n\t\tthis.deviceId = deviceId.split(\"\\\\\").pop() ?? deviceId;\n\t\tlogInfo(`Device ID: ${this.deviceId}`);\n\t\tthis.device = this.client.getDevice(this.deviceId);\n\t}\n\n\tpublic async listDevices() {\n\t\tconst devices = await this.client.listDevices();\n\t\treturn devices;\n\t}\n\n\tprivate async getProperty(adbDevice: DeviceClient, property: DeviceProperty) {\n\t\ttry {\n\t\t\tlogTask(`Getting property ${property} for device ${this.deviceId}`);\n\t\t\tconst stream = await adbDevice.shell(`getprop ${deviceProps[property]}`);\n\t\t\tlogTask(`Stream: ${stream}`);\n\t\t\t// Read all data from the stream\n\t\t\tconst chunks: Buffer[] = [];\n\t\t\tfor await (const chunk of stream) {\n\t\t\t\tchunks.push(chunk);\n\t\t\t}\n\t\t\t// Convert Buffer chunks to string and trim\n\t\t\treturn Buffer.concat(chunks).toString().trim();\n\t\t} catch {\n\t\t\treturn \"\";\n\t\t}\n\t}\n\n\tpublic async getAllDeviceProperties() {\n\t\tif (!(await this.hasUsbDebugging())) {\n\t\t\tthrow new Error(\"USB debugging is not enabled\");\n\t\t}\n\t\treturn this.device.getProperties();\n\t}\n\n\tpublic async getDeviceProperties(properties: DeviceProperty[]) {\n\t\tlogTask(`Getting properties ${properties.join(\", \")} for device ${this.deviceId}`);\n\t\tif (!(await this.hasUsbDebugging())) {\n\t\t\tthrow new Error(\"USB debugging is not enabled\");\n\t\t}\n\t\tconst propertiesValues = await Promise.all(\n\t\t\tproperties.map((property) => this.getProperty(this.device, property))\n\t\t);\n\t\treturn propertiesValues;\n\t}\n\n\tpublic async installApp(appPath: string) {\n\t\tlogTask(`Installing app ${appPath} on device ${this.deviceId}`);\n\t\tif (!(await this.hasUsbDebugging())) {\n\t\t\tthrow new Error(\"USB debugging is not enabled\");\n\t\t}\n\t\tawait this.device.install(appPath);\n\t}\n\n\tpublic async uninstallApp(packageName: string) {\n\t\tlogTask(`Uninstalling app ${packageName} on device ${this.deviceId}`);\n\t\tif (!(await this.hasUsbDebugging())) {\n\t\t\tthrow new Error(\"USB debugging is not enabled\");\n\t\t}\n\t\tawait this.device.uninstall(packageName);\n\t}\n\n\tpublic async isAppInstalled(packageName: string) {\n\t\tlogTask(`Checking if app ${packageName} is installed on device ${this.deviceId}`);\n\t\tif (!(await this.hasUsbDebugging())) {\n\t\t\tthrow new Error(\"USB debugging is not enabled\");\n\t\t}\n\t\treturn await this.device.isInstalled(packageName);\n\t}\n\n\t/**\n\t * Applications have life of their own, so we need to get the client to use it in other parts of the code.\n\t * @returns The adb client\n\t */\n\tpublic async getClient() {\n\t\tif (!this.hasUsbDebugging) {\n\t\t\tawait this.waitForUsbDebugging(1000);\n\t\t\tif (!this.hasUsbDebugging) {\n\t\t\t\tthrow new Error(\"USB debugging is not enabled\");\n\t\t\t}\n\t\t}\n\t\treturn this.client;\n\t}\n\n\tpublic async hasUsbDebugging() {\n\t\tconst devices = await this.listDevices();\n\t\treturn !!devices.find((device: AdbDevice) => device.id === this.deviceId);\n\t}\n\n\tpublic async waitForUsbDebugging(timeout = 120000) {\n\t\tconst tracker = await this.client.trackDevices();\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timeoutId = setTimeout(() => {\n\t\t\t\treject(new Error(\"Timeout waiting for USB debugging\"));\n\t\t\t}, timeout);\n\n\t\t\ttracker.on(\"remove\", (_: AdbDevice) => {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t});\n\n\t\t\ttracker.on(\"add\", (device: AdbDevice) => {\n\t\t\t\tif (device.type === \"device\") {\n\t\t\t\t\tclearTimeout(timeoutId);\n\t\t\t\t\tresolve(true);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\ttracker.on(\"change\", (device: AdbDevice) => {\n\t\t\t\tif (device.type === \"device\") {\n\t\t\t\t\tclearTimeout(timeoutId);\n\t\t\t\t\tresolve(true);\n\t\t\t\t} else {\n\t\t\t\t\tresolve(false);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\tpublic async getDeviceId() {\n\t\treturn this.deviceId;\n\t}\n\n\tpublic async getPort() {\n\t\treturn this.port;\n\t}\n}\n", "import { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * Get the platform-specific directory name for ADB binaries\n */\nfunction getPlatformDir(): string {\n\tconst platform = process.platform;\n\tif (platform === \"win32\") {\n\t\treturn \"windows\";\n\t}\n\tif (platform === \"darwin\") {\n\t\treturn \"darwin\";\n\t}\n\tif (platform === \"linux\") {\n\t\treturn \"linux\";\n\t}\n\tthrow new Error(`Unsupported platform: ${platform}`);\n}\n\n/**\n * Get the platform-specific ADB binary filename\n */\nfunction getAdbBinaryName(): string {\n\tif (process.platform === \"win32\") {\n\t\treturn \"adb.exe\";\n\t}\n\treturn \"adb\";\n}\n\n/**\n * Resolve the path to the ADB binary\n *\n * This function looks for the ADB binary in the following order:\n * 1. In dist/resources/bin/{platform}/ (production/bundled)\n * 2. In resources/bin/{platform}/ (development)\n * 3. Falls back to system PATH\n *\n * @returns The absolute path to the ADB binary, or null if not found\n */\nexport function getAdbBinaryPath(): string | null {\n\tconst __filename = fileURLToPath(import.meta.url);\n\tconst __dirname = path.dirname(__filename);\n\n\t// Try to find the package root by going up from dist/utils/ or src/utils/\n\t// In production: dist/utils/adbPath.js -> dist -> package root\n\t// In development: src/utils/adbPath.ts -> src -> package root\n\tlet packageRoot: string;\n\tif (__dirname.includes(\"dist\")) {\n\t\tpackageRoot = path.resolve(__dirname, \"..\", \"..\");\n\t} else {\n\t\tpackageRoot = path.resolve(__dirname, \"..\", \"..\");\n\t}\n\n\tconst platformDir = getPlatformDir();\n\tconst binaryName = getAdbBinaryName();\n\n\t// Try dist/resources/bin/{platform}/ (production/bundled)\n\tconst distPath = path.join(packageRoot, \"dist\", \"resources\", \"bin\", platformDir, binaryName);\n\tif (existsSync(distPath)) {\n\t\treturn distPath;\n\t}\n\n\t// Try resources/bin/{platform}/ (development)\n\tconst devPath = path.join(packageRoot, \"resources\", \"bin\", platformDir, binaryName);\n\tif (existsSync(devPath)) {\n\t\treturn devPath;\n\t}\n\n\t// Not found in bundled resources\n\treturn null;\n}\n\n/**\n * Get the directory containing ADB binaries for the current platform\n *\n * @returns The absolute path to the ADB binaries directory, or null if not found\n */\nexport function getAdbBinDirectory(): string | null {\n\tconst __filename = fileURLToPath(import.meta.url);\n\tconst __dirname = path.dirname(__filename);\n\n\tlet packageRoot: string;\n\tif (__dirname.includes(\"dist\")) {\n\t\tpackageRoot = path.resolve(__dirname, \"..\", \"..\");\n\t} else {\n\t\tpackageRoot = path.resolve(__dirname, \"..\", \"..\");\n\t}\n\n\tconst platformDir = getPlatformDir();\n\n\t// Try dist/resources/bin/{platform}/ (production/bundled)\n\tconst distPath = path.join(packageRoot, \"dist\", \"resources\", \"bin\", platformDir);\n\tif (existsSync(distPath)) {\n\t\treturn distPath;\n\t}\n\n\t// Try resources/bin/{platform}/ (development)\n\tconst devPath = path.join(packageRoot, \"resources\", \"bin\", platformDir);\n\tif (existsSync(devPath)) {\n\t\treturn devPath;\n\t}\n\n\t// Not found\n\treturn null;\n}\n\n/**\n * Check if ADB binary is available in bundled resources\n *\n * @returns true if ADB binary is found in resources, false otherwise\n */\nexport function hasBundledAdb(): boolean {\n\treturn getAdbBinaryPath() !== null;\n}\n", "import debug from \"debug\";\n\n\nconst logTask = debug(\"adb-kit:task\");\nconst logInfo = debug(\"adb-kit:info\");\nconst logWarning = debug(\"adb-kit:warning\");\nconst logError = debug(\"adb-kit:error\");\n\nlogTask.color = \"40\"; // Green\nlogInfo.color = \"45\"; // Blue\nlogWarning.color = \"214\"; // Orange/Yellow\nlogError.color = \"160\"; // Red\n\nexport { logTask, logInfo, logWarning, logError };\n", "import EventEmitter from \"node:events\";\nimport type { AdbDevice } from \"@/types/adb\";\nimport { getAdbBinaryPath } from \"@/utils/adbPath\";\nimport { logInfo } from \"@/utils/debug\";\nimport * as adbkit from \"@devicefarmer/adbkit\";\nconst { Client } = adbkit;\nimport usbDeviceListener from \"@mcesystems/usb-device-listener\";\nimport type { DeviceInfo, ListenerConfig } from \"@mcesystems/usb-device-listener\";\nimport { AdbDeviceKit } from \"./adbDeviceKit\";\n\n\n/**\n * Ensures ADB_PATH environment variable is set to use adb from resources\n * @devicefarmer/adbkit uses ADB_PATH environment variable to locate the adb binary\n */\nfunction ensureAdbPathFromResources(): void {\n\tconst adbPath = getAdbBinaryPath();\n\tif (adbPath && !process.env.ADB_PATH) {\n\t\tprocess.env.ADB_PATH = adbPath;\n\t\tlogInfo(`Using ADB from resources: ${adbPath}`);\n\t}\n}\n\nexport class DevicesMonitor {\n\tprivate kits: Map<string, AdbDeviceKit> = new Map();\n\tprivate eventEmitter?: EventEmitter;\n\n\tconstructor(\n\t\tprivate config: ListenerConfig,\n\t\tprivate identifyAlreadyConnected = false\n\t) { }\n\n\tpublic async startTracking(): Promise<EventEmitter> {\n\t\tlogInfo(\"Starting devices monitor\");\n\t\tusbDeviceListener.startListening(this.config);\n\t\tthis.eventEmitter = new EventEmitter();\n\t\tif (this.identifyAlreadyConnected) {\n\t\t\tawait this.connectedDevices();\n\t\t\tfor (const kit of this.kits.values()) {\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis.eventEmitter?.emit(\"added\", kit);\n\t\t\t\t}, 0);\n\t\t\t}\n\t\t}\n\n\t\tusbDeviceListener.onDeviceAdd((device) => {\n\t\t\tconsole.log(\"Device added:\", device.deviceId);\n\t\t\tif (!device.logicalPort) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst adbDeviceKit =\n\t\t\t\tthis.kits.get(device.deviceId) ?? new AdbDeviceKit(device.deviceId, device.logicalPort);\n\t\t\tthis.kits.has(device.deviceId) && this.kits.set(device.deviceId, adbDeviceKit);\n\t\t\tthis.eventEmitter?.emit(\"added\", adbDeviceKit);\n\t\t});\n\n\t\tusbDeviceListener.onDeviceRemove((device) => {\n\t\t\tif (!device.logicalPort) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.kits.delete(device.deviceId);\n\t\t\tthis.eventEmitter?.emit(\"removed\", device.deviceId);\n\t\t});\n\t\treturn this.eventEmitter;\n\t}\n\n\tpublic async stopTracking() {\n\t\tif (!this.eventEmitter) {\n\t\t\treturn;\n\t\t}\n\t\tthis.eventEmitter.removeAllListeners();\n\t\tthis.kits.clear();\n\t\tthis.eventEmitter = undefined;\n\t\tusbDeviceListener.stopListening();\n\t}\n\n\tprivate async connectedDevices() {\n\t\tensureAdbPathFromResources();\n\t\tconst client = new Client();\n\t\tconst devicesIds = await client\n\t\t\t.listDevices()\n\t\t\t.filter((device: AdbDevice) => device.type === \"device\")\n\t\t\t.map((device: AdbDevice) => device.id);\n\t\tthis.kits = new Map(\n\t\t\tawait usbDeviceListener\n\t\t\t\t.listDevices()\n\t\t\t\t.map((device: DeviceInfo) => ({\n\t\t\t\t\tid: device.deviceId.split(\"\\\\\").pop() ?? \"\",\n\t\t\t\t\tport: device.logicalPort ?? 0,\n\t\t\t\t}))\n\t\t\t\t.filter((device) => devicesIds.includes(device.id))\n\t\t\t\t.map((device) => [device.id, new AdbDeviceKit(device.id, device.port)])\n\t\t);\n\n\t\treturn this.kits.values();\n\t}\n}\n", "\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { applyLogicalPortMapping, shouldNotifyDevice } from \"./device-filter\";\nimport type {\n\tDeviceAddCallback,\n\tDeviceInfo,\n\tDeviceRemoveCallback,\n\tListenerConfig,\n\tUsbDeviceListener,\n} from \"./types\";\n\n/**\n * Native addon interface\n * This is the raw C++ addon loaded via N-API\n */\ninterface NativeAddon {\n\tstartListening(): void;\n\tstopListening(): void;\n\tonDeviceAdd(callback: DeviceAddCallback): void;\n\tonDeviceRemove(callback: DeviceRemoveCallback): void;\n\tlistDevices(): DeviceInfo[];\n}\n\n// ESM compatibility: get __dirname equivalent\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\nconst packageRoot = dirname(__dirname);\n\n/**\n * Load native addon\n * In development: uses node-gyp-build to find the addon\n * In production: loads directly from the known build location\n */\nfunction loadNativeAddon(): NativeAddon {\n\tconst require = createRequire(import.meta.url);\n\n\t// Try to load from the known production location first\n\tconst addonPath = join(packageRoot, \"build\", \"Release\", \"@mcesystems+usb-device-listener.node\");\n\n\ttry {\n\t\treturn require(addonPath);\n\t} catch {\n\t\t// Fallback to node-gyp-build for development (if available)\n\t\ttry {\n\t\t\tconst nodeGypBuild = require(\"node-gyp-build\");\n\t\t\treturn nodeGypBuild(packageRoot);\n\t\t} catch {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to load native addon. Tried:\\n 1. Direct path: ${addonPath}\\n 2. node-gyp-build search\\nMake sure the addon is built with 'npm run rebuild' or 'npm run prebuild'`\n\t\t\t);\n\t\t}\n\t}\n}\n\nconst addon = loadNativeAddon();\n\n/**\n * USB Device Listener implementation\n * Provides a type-safe wrapper around the native C++ addon\n */\nclass UsbDeviceListenerImpl implements UsbDeviceListener {\n\tprivate config: ListenerConfig = {};\n\tprivate userAddCallback: DeviceAddCallback | null = null;\n\tprivate userRemoveCallback: DeviceRemoveCallback | null = null;\n\n\t/**\n\t * Start listening for USB device events\n\t */\n\tpublic startListening(config: ListenerConfig): void {\n\t\tif (typeof config !== \"object\" || config === null) {\n\t\t\tthrow new TypeError(\"Config must be an object\");\n\t\t}\n\t\tthis.config = config;\n\t\taddon.startListening();\n\t}\n\n\t/**\n\t * Stop listening for USB device events\n\t */\n\tpublic stopListening(): void {\n\t\taddon.stopListening();\n\t}\n\n\t/**\n\t * Register callback for device connection events\n\t */\n\tpublic onDeviceAdd(callback: DeviceAddCallback): void {\n\t\tif (typeof callback !== \"function\") {\n\t\t\tthrow new TypeError(\"Callback must be a function\");\n\t\t}\n\t\tthis.userAddCallback = callback;\n\n\t\t// Set up internal callback that filters devices\n\t\taddon.onDeviceAdd((device: DeviceInfo) => {\n\t\t\tif (shouldNotifyDevice(device, this.config)) {\n\t\t\t\tconst enrichedDevice = applyLogicalPortMapping(device, this.config);\n\t\t\t\tthis.userAddCallback?.(enrichedDevice);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Register callback for device disconnection events\n\t */\n\tpublic onDeviceRemove(callback: DeviceRemoveCallback): void {\n\t\tif (typeof callback !== \"function\") {\n\t\t\tthrow new TypeError(\"Callback must be a function\");\n\t\t}\n\t\tthis.userRemoveCallback = callback;\n\n\t\t// Set up internal callback that filters devices\n\t\taddon.onDeviceRemove((device: DeviceInfo) => {\n\t\t\tif (shouldNotifyDevice(device, this.config)) {\n\t\t\t\tconst enrichedDevice = applyLogicalPortMapping(device, this.config);\n\t\t\t\tthis.userRemoveCallback?.(enrichedDevice);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * List all currently connected USB devices\n\t */\n\tpublic listDevices(): DeviceInfo[] {\n\t\treturn addon.listDevices();\n\t}\n}\n\n// Export singleton instance\nconst usbDeviceListener: UsbDeviceListener = new UsbDeviceListenerImpl();\n\nexport default usbDeviceListener;\nexport type {\n\tDeviceInfo,\n\tDeviceAddCallback,\n\tDeviceRemoveCallback,\n\tListenerConfig,\n\tTargetDevice,\n\tUsbDeviceListener,\n} from \"./types\";\n", "import type { DeviceInfo, ListenerConfig, TargetDevice } from \"./types\";\n\n/**\n * Convert a decimal VID/PID to uppercase hex string for comparison\n */\nfunction toHexString(value: number): string {\n\treturn value.toString(16).toUpperCase().padStart(4, \"0\");\n}\n\n/**\n * Check if a device matches a target device filter by VID/PID\n */\nfunction matchesDevice(device: DeviceInfo, target: TargetDevice): boolean {\n\tconst deviceVid = toHexString(device.vid);\n\tconst devicePid = toHexString(device.pid);\n\tconst targetVid = target.vid.toUpperCase();\n\tconst targetPid = target.pid.toUpperCase();\n\n\treturn deviceVid === targetVid && devicePid === targetPid;\n}\n\n/**\n * Check if a device matches any device in a list of target devices\n */\nfunction matchesAnyDevice(device: DeviceInfo, targets: TargetDevice[]): boolean {\n\treturn targets.some((target) => matchesDevice(device, target));\n}\n\n/**\n * Determine if a device notification should be sent based on the configuration.\n *\n * Filter priority (highest to lowest):\n * 1. ignoredDevices - if device matches, always return false\n * 2. listenOnlyDevices - if specified, device must match at least one\n * 3. targetDevices - if specified, device must match at least one\n * 4. logicalPortMap - if specified, device location must be in the map\n *\n * @param device - The device information from the native addon\n * @param config - The listener configuration\n * @returns true if the device should trigger a notification, false otherwise\n */\nexport function shouldNotifyDevice(device: DeviceInfo, config: ListenerConfig): boolean {\n\t// Priority 1: Check ignoredDevices (highest priority - always blocks)\n\tif (config.ignoredDevices && config.ignoredDevices.length > 0) {\n\t\tif (matchesAnyDevice(device, config.ignoredDevices)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Priority 2: Check listenOnlyDevices (if specified, device must match)\n\tif (config.listenOnlyDevices && config.listenOnlyDevices.length > 0) {\n\t\tif (!matchesAnyDevice(device, config.listenOnlyDevices)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Priority 3: Check targetDevices (if specified, device must match)\n\tif (config.targetDevices && config.targetDevices.length > 0) {\n\t\tif (!matchesAnyDevice(device, config.targetDevices)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Priority 4: Check logicalPortMap (if specified, device must be mapped)\n\tif (config.logicalPortMap && Object.keys(config.logicalPortMap).length > 0) {\n\t\tif (!(device.locationInfo in config.logicalPortMap)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Apply logical port mapping to a device if configured\n *\n * @param device - The device information from the native addon\n * @param config - The listener configuration\n * @returns Device info with logicalPort set if mapped, otherwise unchanged\n */\nexport function applyLogicalPortMapping(device: DeviceInfo, config: ListenerConfig): DeviceInfo {\n\tif (config.logicalPortMap && device.locationInfo in config.logicalPortMap) {\n\t\treturn {\n\t\t\t...device,\n\t\t\tlogicalPort: config.logicalPortMap[device.locationInfo],\n\t\t};\n\t}\n\treturn device;\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../src/logic/adbDeviceKit.ts", "../src/utils/adbPath.ts", "../src/utils/debug.ts", "../src/logic/devicesMonitor.ts"],
|
|
4
|
+
"sourcesContent": ["import { createRequire } from \"node:module\";\nimport type { Client as AdbClient, DeviceClient } from \"@devicefarmer/adbkit\";\nimport type { AdbDevice } from \"../types/adb\";\nimport { getAdbBinaryPath } from \"../utils/adbPath\";\nimport { logInfo, logTask } from \"../utils/debug\";\n\n\n/**\n * Ensures ADB_PATH environment variable is set to use adb from resources\n * @devicefarmer/adbkit uses ADB_PATH environment variable to locate the adb binary\n */\nconst require = createRequire(import.meta.url);\nconst adbkit = require(\"@devicefarmer/adbkit\");\n\nfunction ensureAdbPathFromResources(): void {\n\tconst adbPath = getAdbBinaryPath();\n\tif (adbPath && !process.env.ADB_PATH) {\n\t\tprocess.env.ADB_PATH = adbPath;\n\t\tlogInfo(`Using ADB from resources: ${adbPath}`);\n\t}\n}\n\nconst deviceProps = {\n\tManufacturer: \"ro.product.manufacturer\",\n\tName: \"ro.product.name\",\n\tModel: \"ro.product.model\",\n\t\"Android Version\": \"ro.build.version.release\",\n\tPlatform: \"ro.board.platform\",\n\tCPU: \"ro.product.cpu.abi\",\n\t\"CPU.abi2\": \"ro.product.cpu.abi2\",\n\tDescription: \"ro.build.description\",\n\tFingerprint: \"ro.build.fingerprint\",\n\tBrand: \"ro.product.brand\",\n\tDevice: \"ro.product.device\",\n\t\"GSM Flexversion\": \"ro.gsm.flexversion\",\n\t\"Locale Language\": \"ro.product.locale.language\",\n\t\"Locale Region\": \"ro.product.locale.region\",\n\t\"Wifi Channels\": \"ro.wifi.channels\",\n\t\"Board Platform\": \"ro.board.platform\",\n\t\"Product Board\": \"ro.product.board\",\n\t\"Display ID\": \"ro.build.display.id\",\n\t\"GSM IMEI\": \"gsm.baseband.imei\",\n\t\"Version Incremental\": \"ro.build.version.incremental\",\n\t\"Version SDK\": \"ro.build.version.sdk\",\n\t\"Version Codename\": \"ro.build.version.codename\",\n\t\"Version Release\": \"ro.build.version.release\",\n\t\"Build Date\": \"ro.build.date\",\n\t\"Build Type\": \"ro.build.type\",\n\t\"Build User\": \"ro.build.user\",\n};\n\nexport type DeviceProperty = keyof typeof deviceProps;\n\nexport class AdbDeviceKit {\n\tprivate client: AdbClient;\n\tprivate device: DeviceClient;\n\tprivate deviceId: string;\n\n\tconstructor(\n\t\tdeviceId: string,\n\t\tprivate readonly port: number\n\t) {\n\t\tensureAdbPathFromResources();\n\t\tthis.client = adbkit.default.createClient();\n\t\t// Extract only the last part of deviceId after the last backslash\n\t\tthis.deviceId = deviceId.split(\"\\\\\").pop() ?? deviceId;\n\t\tlogInfo(`Device ID: ${this.deviceId}`);\n\t\tthis.device = this.client.getDevice(this.deviceId);\n\t}\n\n\tpublic async listDevices() {\n\t\tconst devices = await this.client.listDevices();\n\t\treturn devices;\n\t}\n\n\tprivate async getProperty(adbDevice: DeviceClient, property: DeviceProperty) {\n\t\ttry {\n\t\t\tlogTask(`Getting property ${property} for device ${this.deviceId}`);\n\t\t\tconst stream = await adbDevice.shell(`getprop ${deviceProps[property]}`);\n\t\t\tlogTask(`Stream: ${stream}`);\n\t\t\t// Read all data from the stream\n\t\t\tconst chunks: Buffer[] = [];\n\t\t\tfor await (const chunk of stream) {\n\t\t\t\tchunks.push(chunk);\n\t\t\t}\n\t\t\t// Convert Buffer chunks to string and trim\n\t\t\treturn Buffer.concat(chunks).toString().trim();\n\t\t} catch {\n\t\t\treturn \"\";\n\t\t}\n\t}\n\n\tpublic async getAllDeviceProperties() {\n\t\tif (!(await this.hasUsbDebugging())) {\n\t\t\tthis.waitForUsbDebugging(10000);\n\t\t}\n\t\treturn this.device.getProperties();\n\t}\n\n\tpublic async getDeviceProperties(properties: DeviceProperty[]) {\n\t\tlogTask(`Getting properties ${properties.join(\", \")} for device ${this.deviceId}`);\n\t\tif (!(await this.hasUsbDebugging())) {\n\t\t\tthis.waitForUsbDebugging(10000);\n\t\t}\n\t\tconst propertiesValues = await Promise.all(\n\t\t\tproperties.map((property) => this.getProperty(this.device, property))\n\t\t);\n\t\treturn propertiesValues;\n\t}\n\n\tpublic async installApp(appPath: string) {\n\t\tlogTask(`Installing app ${appPath} on device ${this.deviceId}`);\n\t\tif (!(await this.hasUsbDebugging())) {\n\t\t\tthis.waitForUsbDebugging(10000);\n\t\t}\n\t\tawait this.device.install(appPath);\n\t}\n\n\tpublic async uninstallApp(packageName: string) {\n\t\tlogTask(`Uninstalling app ${packageName} on device ${this.deviceId}`);\n\t\tif (!(await this.hasUsbDebugging())) {\n\t\t\tthis.waitForUsbDebugging(10000);\n\t\t}\n\t\tawait this.device.uninstall(packageName);\n\t}\n\n\tpublic async isAppInstalled(packageName: string) {\n\t\tlogTask(`Checking if app ${packageName} is installed on device ${this.deviceId}`);\n\t\tif (!(await this.hasUsbDebugging())) {\n\t\t\tthis.waitForUsbDebugging(10000);\n\t\t}\n\t\treturn await this.device.isInstalled(packageName);\n\t}\n\n\t/**\n\t * Applications have life of their own, so we need to get the client to use it in other parts of the code.\n\t * @returns The adb client\n\t */\n\tpublic async getClient() {\n\t\tif (!this.hasUsbDebugging) {\n\t\t\tthis.waitForUsbDebugging(10000);\n\t\t}\n\t\treturn this.client;\n\t}\n\n\tpublic async hasUsbDebugging() {\n\t\tconst devices = await this.listDevices();\n\t\treturn !!devices.find((device: AdbDevice) => device.id === this.deviceId);\n\t}\n\n\tpublic async waitForUsbDebugging(timeout = 120000) {\n\t\tconst tracker = await this.client.trackDevices();\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timeoutId = setTimeout(() => {\n\t\t\t\treject(new Error(\"Timeout waiting for USB debugging\"));\n\t\t\t}, timeout);\n\n\t\t\ttracker.on(\"remove\", (_: AdbDevice) => {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t});\n\n\t\t\ttracker.on(\"add\", (device: AdbDevice) => {\n\t\t\t\tif (device.type === \"device\") {\n\t\t\t\t\tclearTimeout(timeoutId);\n\t\t\t\t\tresolve(true);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\ttracker.on(\"change\", (device: AdbDevice) => {\n\t\t\t\tif (device.type === \"device\") {\n\t\t\t\t\tclearTimeout(timeoutId);\n\t\t\t\t\tresolve(true);\n\t\t\t\t} else {\n\t\t\t\t\tresolve(false);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\tpublic async getDeviceId() {\n\t\treturn this.deviceId;\n\t}\n\n\tpublic async getPort() {\n\t\treturn this.port;\n\t}\n}\n", "import { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * Get the platform-specific directory name for ADB binaries\n */\nfunction getPlatformDir(): string {\n\tconst platform = process.platform;\n\tif (platform === \"win32\") {\n\t\treturn \"windows\";\n\t}\n\tif (platform === \"darwin\") {\n\t\treturn \"darwin\";\n\t}\n\tif (platform === \"linux\") {\n\t\treturn \"linux\";\n\t}\n\tthrow new Error(`Unsupported platform: ${platform}`);\n}\n\n/**\n * Get the platform-specific ADB binary filename\n */\nfunction getAdbBinaryName(): string {\n\tif (process.platform === \"win32\") {\n\t\treturn \"adb.exe\";\n\t}\n\treturn \"adb\";\n}\n\n/**\n * Resolve the path to the ADB binary\n *\n * This function looks for the ADB binary in the following order:\n * 1. In dist/resources/bin/{platform}/ (production/bundled)\n * 2. In resources/bin/{platform}/ (development)\n * 3. Falls back to system PATH\n *\n * @returns The absolute path to the ADB binary, or null if not found\n */\nexport function getAdbBinaryPath(): string | null {\n\tconst __filename = fileURLToPath(import.meta.url);\n\tconst __dirname = path.dirname(__filename);\n\n\t// Try to find the package root by going up from dist/utils/ or src/utils/\n\t// In production: dist/utils/adbPath.js -> dist -> package root\n\t// In development: src/utils/adbPath.ts -> src -> package root\n\tlet packageRoot: string;\n\tif (__dirname.includes(\"dist\")) {\n\t\tpackageRoot = path.resolve(__dirname, \"..\", \"..\");\n\t} else {\n\t\tpackageRoot = path.resolve(__dirname, \"..\", \"..\");\n\t}\n\n\tconst platformDir = getPlatformDir();\n\tconst binaryName = getAdbBinaryName();\n\n\t// Try dist/resources/bin/{platform}/ (production/bundled)\n\tconst distPath = path.join(packageRoot, \"dist\", \"resources\", \"bin\", platformDir, binaryName);\n\tif (existsSync(distPath)) {\n\t\treturn distPath;\n\t}\n\n\t// Try resources/bin/{platform}/ (development)\n\tconst devPath = path.join(packageRoot, \"resources\", \"bin\", platformDir, binaryName);\n\tif (existsSync(devPath)) {\n\t\treturn devPath;\n\t}\n\n\t// Not found in bundled resources\n\treturn null;\n}\n\n/**\n * Get the directory containing ADB binaries for the current platform\n *\n * @returns The absolute path to the ADB binaries directory, or null if not found\n */\nexport function getAdbBinDirectory(): string | null {\n\tconst __filename = fileURLToPath(import.meta.url);\n\tconst __dirname = path.dirname(__filename);\n\n\tlet packageRoot: string;\n\tif (__dirname.includes(\"dist\")) {\n\t\tpackageRoot = path.resolve(__dirname, \"..\", \"..\");\n\t} else {\n\t\tpackageRoot = path.resolve(__dirname, \"..\", \"..\");\n\t}\n\n\tconst platformDir = getPlatformDir();\n\n\t// Try dist/resources/bin/{platform}/ (production/bundled)\n\tconst distPath = path.join(packageRoot, \"dist\", \"resources\", \"bin\", platformDir);\n\tif (existsSync(distPath)) {\n\t\treturn distPath;\n\t}\n\n\t// Try resources/bin/{platform}/ (development)\n\tconst devPath = path.join(packageRoot, \"resources\", \"bin\", platformDir);\n\tif (existsSync(devPath)) {\n\t\treturn devPath;\n\t}\n\n\t// Not found\n\treturn null;\n}\n\n/**\n * Check if ADB binary is available in bundled resources\n *\n * @returns true if ADB binary is found in resources, false otherwise\n */\nexport function hasBundledAdb(): boolean {\n\treturn getAdbBinaryPath() !== null;\n}\n", "import debug from \"debug\";\n\n\nconst logTask = debug(\"adb-kit:task\");\nconst logInfo = debug(\"adb-kit:info\");\nconst logWarning = debug(\"adb-kit:warning\");\nconst logError = debug(\"adb-kit:error\");\n\nlogTask.color = \"40\"; // Green\nlogInfo.color = \"45\"; // Blue\nlogWarning.color = \"214\"; // Orange/Yellow\nlogError.color = \"160\"; // Red\n\nexport { logTask, logInfo, logWarning, logError };\n", "import EventEmitter from \"node:events\";\nimport { createRequire } from \"node:module\";\nimport type { AdbDevice } from \"@/types/adb\";\nimport { getAdbBinaryPath } from \"@/utils/adbPath\";\nimport { logInfo } from \"@/utils/debug\";\nimport type { Client as AdbClient } from \"@devicefarmer/adbkit\";\nimport usbDeviceListener from \"@mcesystems/usb-device-listener\";\nimport type { DeviceInfo, ListenerConfig } from \"@mcesystems/usb-device-listener\";\nimport { AdbDeviceKit } from \"./adbDeviceKit\";\n\nconst require = createRequire(import.meta.url);\nconst adbkit = require(\"@devicefarmer/adbkit\");\n\n\n/**\n * Ensures ADB_PATH environment variable is set to use adb from resources\n * @devicefarmer/adbkit uses ADB_PATH environment variable to locate the adb binary\n */\nfunction ensureAdbPathFromResources(): void {\n\tconst adbPath = getAdbBinaryPath();\n\tif (adbPath && !process.env.ADB_PATH) {\n\t\tprocess.env.ADB_PATH = adbPath;\n\t\tlogInfo(`Using ADB from resources: ${adbPath}`);\n\t}\n}\n\nexport class DevicesMonitor {\n\tprivate kits: Map<string, AdbDeviceKit> = new Map();\n\tprivate eventEmitter?: EventEmitter;\n\n\tconstructor(\n\t\tprivate config: ListenerConfig,\n\t\tprivate identifyAlreadyConnected = false\n\t) { }\n\n\tpublic async startTracking(): Promise<EventEmitter> {\n\t\tlogInfo(\"Starting devices monitor\");\n\t\tusbDeviceListener.startListening(this.config);\n\t\tthis.eventEmitter = new EventEmitter();\n\t\tif (this.identifyAlreadyConnected) {\n\t\t\tawait this.connectedDevices();\n\t\t\tfor (const kit of this.kits.values()) {\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis.eventEmitter?.emit(\"added\", kit);\n\t\t\t\t}, 0);\n\t\t\t}\n\t\t}\n\n\t\tusbDeviceListener.onDeviceAdd((device) => {\n\t\t\tconsole.log(\"Device added:\", device.deviceId);\n\t\t\tif (!device.logicalPort) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst existingKit = this.kits.get(device.deviceId);\n\t\t\tconst adbDeviceKit =\n\t\t\t\texistingKit ?? new AdbDeviceKit(device.deviceId, device.logicalPort);\n\t\t\tif (!existingKit) {\n\t\t\t\tthis.kits.set(device.deviceId, adbDeviceKit);\n\t\t\t}\n\t\t\tthis.eventEmitter?.emit(\"added\", adbDeviceKit);\n\t\t});\n\n\t\tusbDeviceListener.onDeviceRemove((device) => {\n\t\t\tif (!device.logicalPort) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.kits.delete(device.deviceId);\n\t\t\tthis.eventEmitter?.emit(\"removed\", device.deviceId);\n\t\t});\n\t\treturn this.eventEmitter;\n\t}\n\n\tpublic async stopTracking() {\n\t\tif (!this.eventEmitter) {\n\t\t\treturn;\n\t\t}\n\t\tthis.eventEmitter.removeAllListeners();\n\t\tthis.kits.clear();\n\t\tthis.eventEmitter = undefined;\n\t\tusbDeviceListener.stopListening();\n\t}\n\n\tprivate async connectedDevices() {\n\t\tensureAdbPathFromResources();\n\t\tconst client: AdbClient = adbkit.default.createClient();\n\t\tconst devicesIds = await client\n\t\t\t.listDevices()\n\t\t\t.filter((device: AdbDevice) => device.type === \"device\")\n\t\t\t.map((device: AdbDevice) => device.id);\n\t\tthis.kits = new Map(\n\t\t\tawait usbDeviceListener\n\t\t\t\t.listDevices()\n\t\t\t\t.map((device: DeviceInfo) => ({\n\t\t\t\t\tid: device.deviceId.split(\"\\\\\").pop() ?? \"\",\n\t\t\t\t\tport: device.logicalPort ?? 0,\n\t\t\t\t}))\n\t\t\t\t.filter((device) => devicesIds.includes(device.id))\n\t\t\t\t.map((device) => [device.id, new AdbDeviceKit(device.id, device.port)])\n\t\t);\n\n\t\treturn this.kits.values();\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,qBAAqB;;;ACA9B,SAAS,kBAAkB;AAC3B,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAK9B,SAAS,iBAAyB;AACjC,QAAM,WAAW,QAAQ;AACzB,MAAI,aAAa,SAAS;AACzB,WAAO;AAAA,EACR;AACA,MAAI,aAAa,UAAU;AAC1B,WAAO;AAAA,EACR;AACA,MAAI,aAAa,SAAS;AACzB,WAAO;AAAA,EACR;AACA,QAAM,IAAI,MAAM,yBAAyB,QAAQ,EAAE;AACpD;AAKA,SAAS,mBAA2B;AACnC,MAAI,QAAQ,aAAa,SAAS;AACjC,WAAO;AAAA,EACR;AACA,SAAO;AACR;AAYO,SAAS,mBAAkC;AACjD,QAAM,aAAa,cAAc,YAAY,GAAG;AAChD,QAAM,YAAY,KAAK,QAAQ,UAAU;AAKzC,MAAI;AACJ,MAAI,UAAU,SAAS,MAAM,GAAG;AAC/B,kBAAc,KAAK,QAAQ,WAAW,MAAM,IAAI;AAAA,EACjD,OAAO;AACN,kBAAc,KAAK,QAAQ,WAAW,MAAM,IAAI;AAAA,EACjD;AAEA,QAAM,cAAc,eAAe;AACnC,QAAM,aAAa,iBAAiB;AAGpC,QAAM,WAAW,KAAK,KAAK,aAAa,QAAQ,aAAa,OAAO,aAAa,UAAU;AAC3F,MAAI,WAAW,QAAQ,GAAG;AACzB,WAAO;AAAA,EACR;AAGA,QAAM,UAAU,KAAK,KAAK,aAAa,a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|
+
"names": ["require", "createRequire", "require", "createRequire", "adbkit", "ensureAdbPathFromResources"]
|
|
7
7
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { Client as AdbClient } from "@devicefarmer/adbkit";
|
|
2
2
|
declare const deviceProps: {
|
|
3
3
|
Manufacturer: string;
|
|
4
4
|
Name: string;
|
|
@@ -34,9 +34,9 @@ export declare class AdbDeviceKit {
|
|
|
34
34
|
private device;
|
|
35
35
|
private deviceId;
|
|
36
36
|
constructor(deviceId: string, port: number);
|
|
37
|
-
listDevices(): Promise<Bluebird<adbkit.Device[]>>;
|
|
37
|
+
listDevices(): Promise<Bluebird<import("@devicefarmer/adbkit").Device[]>>;
|
|
38
38
|
private getProperty;
|
|
39
|
-
getAllDeviceProperties(): Promise<Bluebird<adbkit.Properties>>;
|
|
39
|
+
getAllDeviceProperties(): Promise<Bluebird<import("@devicefarmer/adbkit").Properties>>;
|
|
40
40
|
getDeviceProperties(properties: DeviceProperty[]): Promise<string[]>;
|
|
41
41
|
installApp(appPath: string): Promise<void>;
|
|
42
42
|
uninstallApp(packageName: string): Promise<void>;
|
|
@@ -45,7 +45,7 @@ export declare class AdbDeviceKit {
|
|
|
45
45
|
* Applications have life of their own, so we need to get the client to use it in other parts of the code.
|
|
46
46
|
* @returns The adb client
|
|
47
47
|
*/
|
|
48
|
-
getClient(): Promise<
|
|
48
|
+
getClient(): Promise<AdbClient>;
|
|
49
49
|
hasUsbDebugging(): Promise<boolean>;
|
|
50
50
|
waitForUsbDebugging(timeout?: number): Promise<unknown>;
|
|
51
51
|
getDeviceId(): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adbDeviceKit.d.ts","sourceRoot":"","sources":["../../../src/logic/adbDeviceKit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adbDeviceKit.d.ts","sourceRoot":"","sources":["../../../src/logic/adbDeviceKit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,SAAS,EAAgB,MAAM,sBAAsB,CAAC;AAqB9E,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BhB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,WAAW,CAAC;AAEtD,qBAAa,YAAY;IAOvB,OAAO,CAAC,QAAQ,CAAC,IAAI;IANtB,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,QAAQ,CAAS;gBAGxB,QAAQ,EAAE,MAAM,EACC,IAAI,EAAE,MAAM;IAUjB,WAAW;YAKV,WAAW;IAiBZ,sBAAsB;IAOtB,mBAAmB,CAAC,UAAU,EAAE,cAAc,EAAE;IAWhD,UAAU,CAAC,OAAO,EAAE,MAAM;IAQ1B,YAAY,CAAC,WAAW,EAAE,MAAM;IAQhC,cAAc,CAAC,WAAW,EAAE,MAAM;IAQ/C;;;OAGG;IACU,SAAS;IAOT,eAAe;IAKf,mBAAmB,CAAC,OAAO,SAAS;IA6BpC,WAAW;IAIX,OAAO;CAGpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devicesMonitor.d.ts","sourceRoot":"","sources":["../../../src/logic/devicesMonitor.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,aAAa,CAAC;AAOvC,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"devicesMonitor.d.ts","sourceRoot":"","sources":["../../../src/logic/devicesMonitor.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,aAAa,CAAC;AAOvC,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAmBlF,qBAAa,cAAc;IAKzB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,wBAAwB;IALjC,OAAO,CAAC,IAAI,CAAwC;IACpD,OAAO,CAAC,YAAY,CAAC,CAAe;gBAG3B,MAAM,EAAE,cAAc,EACtB,wBAAwB,UAAQ;IAG5B,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC;IAqCtC,YAAY;YAUX,gBAAgB;CAoB9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcesystems/adb-kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "ADB (Android Debug Bridge) toolkit for device management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@devicefarmer/adbkit": "^3.3.8",
|
|
31
31
|
"debug": "^4.4.3",
|
|
32
|
-
"@mcesystems/usb-device-listener": "1.0.
|
|
32
|
+
"@mcesystems/usb-device-listener": "1.0.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/debug": "^4.1.12",
|