@mcesystems/adb-kit 1.0.2 → 1.0.4
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
|
@@ -167,9 +167,7 @@ var AdbDeviceKit = class {
|
|
|
167
167
|
* @returns The adb client
|
|
168
168
|
*/
|
|
169
169
|
async getClient() {
|
|
170
|
-
|
|
171
|
-
this.waitForUsbDebugging(1e4);
|
|
172
|
-
}
|
|
170
|
+
await this.waitForUsbDebugging(1e4);
|
|
173
171
|
return this.client;
|
|
174
172
|
}
|
|
175
173
|
async hasUsbDebugging() {
|
|
@@ -177,6 +175,9 @@ var AdbDeviceKit = class {
|
|
|
177
175
|
return !!devices.find((device) => device.id === this.deviceId);
|
|
178
176
|
}
|
|
179
177
|
async waitForUsbDebugging(timeout = 12e4) {
|
|
178
|
+
if (await this.hasUsbDebugging()) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
180
181
|
const tracker = await this.client.trackDevices();
|
|
181
182
|
return new Promise((resolve, reject) => {
|
|
182
183
|
const timeoutId = setTimeout(() => {
|
|
@@ -201,12 +202,16 @@ var AdbDeviceKit = class {
|
|
|
201
202
|
});
|
|
202
203
|
});
|
|
203
204
|
}
|
|
204
|
-
|
|
205
|
+
getDeviceId() {
|
|
205
206
|
return this.deviceId;
|
|
206
207
|
}
|
|
207
|
-
|
|
208
|
+
getPort() {
|
|
208
209
|
return this.port;
|
|
209
210
|
}
|
|
211
|
+
async getDeviceClient() {
|
|
212
|
+
await this.waitForUsbDebugging(1e4);
|
|
213
|
+
return this.device;
|
|
214
|
+
}
|
|
210
215
|
};
|
|
211
216
|
|
|
212
217
|
// src/logic/devicesMonitor.ts
|
|
@@ -258,7 +263,7 @@ var DevicesMonitor = class {
|
|
|
258
263
|
return;
|
|
259
264
|
}
|
|
260
265
|
this.kits.delete(device.deviceId);
|
|
261
|
-
this.eventEmitter?.emit("removed", device.deviceId);
|
|
266
|
+
this.eventEmitter?.emit("removed", device.deviceId, device.logicalPort);
|
|
262
267
|
});
|
|
263
268
|
return this.eventEmitter;
|
|
264
269
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
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,aAAa,OAAO,aAAa,UAAU;AAClF,MAAI,WAAW,OAAO,GAAG;AACxB,WAAO;AAAA,EACR;AAGA,SAAO;AACR;;;ACxEA,OAAO,WAAW;
|
|
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 * 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\tawait this.waitForUsbDebugging(10000);\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\tif (await this.hasUsbDebugging()) {\n\t\t\treturn true;\n\t\t}\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 getDeviceId() {\n\t\treturn this.deviceId;\n\t}\n\n\tpublic getPort() {\n\t\treturn this.port;\n\t}\n\n\tpublic async getDeviceClient() {\n\t\tawait this.waitForUsbDebugging(10000);\n\t\treturn this.device;\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\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 * 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 = existingKit ?? 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, device.logicalPort);\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,SA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AM;AAChB,SAAK,eAAe;AACpB,sBAAkB,cAAc;AAAA,EACjC;AAAA,EAEA,MAAc,mBAAmB;AAChC,IAAAA,4BAA2B;AAC3B,UAAM,SAAoBD,QAAO,QAAQ,aAAa;AACtD,UAAM,aAAa,MAAM,OACvB,YAAY,EACZ,OAAO,CAAC,WAAsB,OAAO,SAAS,QAAQ,EACtD,IAAI,CAAC,WAAsB,OAAO,EAAE;AACtC,SAAK,OAAO,IAAI;AAAA,MACf,MAAM,kBACJ,YAAY,EACZ,IAAI,CAAC,YAAwB;AAAA,QAC7B,IAAI,OAAO,SAAS,MAAM,IAAI,EAAE,IAAI,KAAK;AAAA,QACzC,MAAM,OAAO,eAAe;AAAA,MAC7B,EAAE,EACD,OAAO,CAAC,WAAW,WAAW,SAAS,OAAO,EAAE,CAAC,EACjD,IAAI,CAAC,WAAW,CAAC,OAAO,IAAI,IAAI,aAAa,OAAO,IAAI,OAAO,IAAI,CAAC,CAAC;AAAA,IACxE;AAEA,WAAO,KAAK,KAAK,OAAO;AAAA,EACzB;AACD;",
|
|
6
6
|
"names": ["require", "createRequire", "require", "createRequire", "adbkit", "ensureAdbPathFromResources"]
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Client as AdbClient } from "@devicefarmer/adbkit";
|
|
1
|
+
import type { Client as AdbClient, DeviceClient } from "@devicefarmer/adbkit";
|
|
2
2
|
declare const deviceProps: {
|
|
3
3
|
Manufacturer: string;
|
|
4
4
|
Name: string;
|
|
@@ -48,8 +48,9 @@ export declare class AdbDeviceKit {
|
|
|
48
48
|
getClient(): Promise<AdbClient>;
|
|
49
49
|
hasUsbDebugging(): Promise<boolean>;
|
|
50
50
|
waitForUsbDebugging(timeout?: number): Promise<unknown>;
|
|
51
|
-
getDeviceId():
|
|
52
|
-
getPort():
|
|
51
|
+
getDeviceId(): string;
|
|
52
|
+
getPort(): number;
|
|
53
|
+
getDeviceClient(): Promise<DeviceClient>;
|
|
53
54
|
}
|
|
54
55
|
export {};
|
|
55
56
|
//# sourceMappingURL=adbDeviceKit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adbDeviceKit.d.ts","sourceRoot":"","sources":["../../../src/logic/adbDeviceKit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,SAAS,
|
|
1
|
+
{"version":3,"file":"adbDeviceKit.d.ts","sourceRoot":"","sources":["../../../src/logic/adbDeviceKit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,SAAS,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAoB9E,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;IAKT,eAAe;IAKf,mBAAmB,CAAC,OAAO,SAAS;IAgC1C,WAAW;IAIX,OAAO;IAID,eAAe;CAI5B"}
|
|
@@ -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;AAkBlF,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;IAoCtC,YAAY;YAUX,gBAAgB;CAoB9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../src/utils/debug.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../src/utils/debug.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,QAAA,MAAM,OAAO,gBAAwB,CAAC;AACtC,QAAA,MAAM,OAAO,gBAAwB,CAAC;AACtC,QAAA,MAAM,UAAU,gBAA2B,CAAC;AAC5C,QAAA,MAAM,QAAQ,gBAAyB,CAAC;AAOxC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcesystems/adb-kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
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.4"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/debug": "^4.1.12",
|