UNPKG

@u4/adbkit

Version:

A Typescript client for the Android Debug Bridge.

56 lines 1.75 kB
"use strict"; /** * utils only used by third party */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const __1 = require("../.."); const path_1 = __importDefault(require("path")); class ThirdUtils { /** * use to debug external apk output * @param duplex process IO * @param name for display only * @returns resolve on stream closed */ static async dumpReadable(duplex, name) { try { const prefix = name + ':'; for (;;) { await __1.Utils.waitforReadable(duplex); const data = await duplex.read(); if (data) { const msg = data.toString(); console.log(prefix, msg.trim()); } } } catch (e) { // End return; } } static get resourceDir() { return path_1.default.join(__dirname, '..', '..', '..', 'bin'); } /** * get fullpath from a ressource file. * @param fileName filename * @returns full path within the ressource folder */ static getResourcePath(fileName) { const fullPath = path_1.default.join(ThirdUtils.resourceDir, fileName); return fullPath; } static async getScreenSize(client) { const str = await client.execOut('wm size', 'utf8'); const m = str.match(/(\d+)x(\d+)/); if (!m) throw Error('can not get device size info'); return { x: Number(m[1]), y: Number(m[2]) }; } } exports.default = ThirdUtils; //# sourceMappingURL=ThirdUtils.js.map