@u4/adbkit
Version:
A Typescript client for the Android Debug Bridge.
60 lines • 2.84 kB
TypeScript
import EventEmitter from 'events';
import Device from '../models/Device';
import HostDevicesCommand from './command/host/HostDevicesCommand';
import HostDevicesWithPathsCommand from './command/host/HostDevicesWithPathsCommand';
import TrackerChangeSet from '../models/TrackerChangeSet';
import { HostTrackDevicesCommand } from './command/host';
/**
* enforce EventEmitter typing
*/
interface IEmissions {
/**
* Emitted when the underlying connection ends.
*/
end: () => void;
/**
* **(device)** Emitted when a new device is connected, once per device. See `client.listDevices()` for details on the device object.
*/
add: (device: Device) => void;
/**
* **(device)** Emitted when a device is unplugged, once per device. This does not include `offline` devices, those devices are connected but unavailable to ADB. See `client.listDevices()` for details on the device object.
*/
remove: (device: Device) => void;
offline: (device: Device) => void;
online: (device: Device) => void;
/**
* **(device)** Emitted when the `type` property of a device changes, once per device. The current value of `type` is the new value. This event usually occurs the type changes from `'device'` to `'offline'` or the other way around. See `client.listDevices()` for details on the device object and the `'offline'` type.
*/
change: (newDevice: Device, oldDevice: Device) => void;
/**
* **(changes)** Emitted once for all changes reported by ADB in a single run. Multiple changes can occur when, for example, a USB hub is connected/unplugged and the device list changes quickly. If you wish to process all changes at once, use this event instead of the once-per-device ones. Keep in mind that the other events will still be emitted, though.
*/
changeSet: (changeSet: TrackerChangeSet) => void;
/**
* **(err)** Emitted if there's an error.
*/
error: (data: Error) => void;
}
/**
* emit event on Device status chage
*/
export default class Tracker extends EventEmitter {
private readonly command;
private deviceMap;
private stoped;
constructor(command: HostDevicesCommand | HostDevicesWithPathsCommand | HostTrackDevicesCommand);
on: <K extends keyof IEmissions>(event: K, listener: IEmissions[K]) => this;
off: <K extends keyof IEmissions>(event: K, listener: IEmissions[K]) => this;
once: <K extends keyof IEmissions>(event: K, listener: IEmissions[K]) => this;
emit: <K extends keyof IEmissions>(event: K, ...args: Parameters<IEmissions[K]>) => boolean;
private readloop;
/**
* should be private but need public for testing
* @param newList updated Device list
* @returns this
*/
update(newList: Device[]): this;
end(): void;
}
export {};
//# sourceMappingURL=tracker.d.ts.map