mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-04 18:29:23 +02:00
chore: add max-params eslint rule
This commit is contained in:
parent
3c2b57cfc5
commit
73a0af4613
17 changed files with 79 additions and 54 deletions
|
@ -27,7 +27,7 @@ export class AdbScrcpyOptions2_0 extends AdbScrcpyOptions<
|
||||||
): Promise<ScrcpyEncoder[]> {
|
): Promise<ScrcpyEncoder[]> {
|
||||||
try {
|
try {
|
||||||
// Similar to `AdbScrcpyOptions1_16.getDisplays`,
|
// Similar to `AdbScrcpyOptions1_16.getDisplays`,
|
||||||
// server start process won't complete and `start `will throw
|
// server start procedure won't complete and `start `will throw
|
||||||
const client = await AdbScrcpyClient.start(
|
const client = await AdbScrcpyClient.start(
|
||||||
adb,
|
adb,
|
||||||
path,
|
path,
|
||||||
|
|
|
@ -38,6 +38,7 @@ export function getBigUint(
|
||||||
* @param littleEndian If `false` or `undefined`, a big-endian value should be written,
|
* @param littleEndian If `false` or `undefined`, a big-endian value should be written,
|
||||||
* otherwise a little-endian value should be written.
|
* otherwise a little-endian value should be written.
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line max-params
|
||||||
export function setBigUint(
|
export function setBigUint(
|
||||||
array: Uint8Array,
|
array: Uint8Array,
|
||||||
byteOffset: number,
|
byteOffset: number,
|
||||||
|
|
|
@ -41,7 +41,9 @@ export class ActivityManager extends AdbCommandBase {
|
||||||
return this.adb.subprocess.spawn(args);
|
return this.adb.subprocess.spawn(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
async startActivity(options: ActivityManagerStartActivityOptions) {
|
async startActivity(
|
||||||
|
options: ActivityManagerStartActivityOptions,
|
||||||
|
): Promise<void> {
|
||||||
let args = buildArguments(
|
let args = buildArguments(
|
||||||
["am", "start-activity", "-W"],
|
["am", "start-activity", "-W"],
|
||||||
options,
|
options,
|
||||||
|
|
|
@ -32,15 +32,15 @@ export interface BugReportZOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BugReport extends AdbCommandBase {
|
export class BugReport extends AdbCommandBase {
|
||||||
static VERSION_REGEX = /(\d+)\.(\d+)/;
|
static VERSION_REGEX: RegExp = /(\d+)\.(\d+)/;
|
||||||
|
|
||||||
static BEGIN_REGEX = /BEGIN:(.*)/;
|
static BEGIN_REGEX: RegExp = /BEGIN:(.*)/;
|
||||||
|
|
||||||
static PROGRESS_REGEX = /PROGRESS:(.*)\/(.*)/;
|
static PROGRESS_REGEX: RegExp = /PROGRESS:(.*)\/(.*)/;
|
||||||
|
|
||||||
static OK_REGEX = /OK:(.*)/;
|
static OK_REGEX: RegExp = /OK:(.*)/;
|
||||||
|
|
||||||
static FAIL_REGEX = /FAIL:(.*)/;
|
static FAIL_REGEX: RegExp = /FAIL:(.*)/;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queries the device's bugreport capabilities.
|
* Queries the device's bugreport capabilities.
|
||||||
|
@ -101,7 +101,7 @@ export class BugReport extends AdbCommandBase {
|
||||||
*
|
*
|
||||||
* Should be `true` for Android version <= 11.
|
* Should be `true` for Android version <= 11.
|
||||||
*/
|
*/
|
||||||
get supportsBugReport() {
|
get supportsBugReport(): boolean {
|
||||||
return this.#supportsBugReport;
|
return this.#supportsBugReport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ export class BugReport extends AdbCommandBase {
|
||||||
*
|
*
|
||||||
* Will be `undefined` if BugReportZ is not supported.
|
* Will be `undefined` if BugReportZ is not supported.
|
||||||
*/
|
*/
|
||||||
get bugReportZVersion() {
|
get bugReportZVersion(): string | undefined {
|
||||||
return this.#bugReportZVersion;
|
return this.#bugReportZVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ export class BugReport extends AdbCommandBase {
|
||||||
*
|
*
|
||||||
* Should be `true` for Android version >= 7.
|
* Should be `true` for Android version >= 7.
|
||||||
*/
|
*/
|
||||||
get supportsBugReportZ() {
|
get supportsBugReportZ(): boolean {
|
||||||
return this.#supportsBugReportZ;
|
return this.#supportsBugReportZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ export class BugReport extends AdbCommandBase {
|
||||||
*
|
*
|
||||||
* Should be `true` for Android version >= 8.
|
* Should be `true` for Android version >= 8.
|
||||||
*/
|
*/
|
||||||
get supportsBugReportZProgress() {
|
get supportsBugReportZProgress(): boolean {
|
||||||
return this.#supportsBugReportZProgress;
|
return this.#supportsBugReportZProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ export class BugReport extends AdbCommandBase {
|
||||||
*
|
*
|
||||||
* Should be `true` for Android version >= 12.
|
* Should be `true` for Android version >= 12.
|
||||||
*/
|
*/
|
||||||
get supportsBugReportZStream() {
|
get supportsBugReportZStream(): boolean {
|
||||||
return this.#supportsBugReportZStream;
|
return this.#supportsBugReportZStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,22 +14,22 @@ import { ConcatStringStream, TextDecoderStream } from "@yume-chan/stream-extra";
|
||||||
|
|
||||||
export class Cmd extends AdbCommandBase {
|
export class Cmd extends AdbCommandBase {
|
||||||
#supportsShellV2: boolean;
|
#supportsShellV2: boolean;
|
||||||
get supportsShellV2() {
|
get supportsShellV2(): boolean {
|
||||||
return this.#supportsShellV2;
|
return this.#supportsShellV2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#supportsCmd: boolean;
|
#supportsCmd: boolean;
|
||||||
get supportsCmd() {
|
get supportsCmd(): boolean {
|
||||||
return this.#supportsCmd;
|
return this.#supportsCmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
#supportsAbb: boolean;
|
#supportsAbb: boolean;
|
||||||
get supportsAbb() {
|
get supportsAbb(): boolean {
|
||||||
return this.#supportsAbb;
|
return this.#supportsAbb;
|
||||||
}
|
}
|
||||||
|
|
||||||
#supportsAbbExec: boolean;
|
#supportsAbbExec: boolean;
|
||||||
get supportsAbbExec() {
|
get supportsAbbExec(): boolean {
|
||||||
return this.#supportsAbbExec;
|
return this.#supportsAbbExec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ export class DumpSys extends AdbCommandBase {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async battery() {
|
async battery(): Promise<DumpSys.Battery.Info> {
|
||||||
const output = await this.adb.subprocess.spawnAndWaitLegacy([
|
const output = await this.adb.subprocess.spawnAndWaitLegacy([
|
||||||
"dumpsys",
|
"dumpsys",
|
||||||
"battery",
|
"battery",
|
||||||
|
|
|
@ -404,12 +404,12 @@ export class Logcat extends AdbCommandBase {
|
||||||
|
|
||||||
// TODO: logcat: Support output format before Android 10
|
// TODO: logcat: Support output format before Android 10
|
||||||
// ref https://android-review.googlesource.com/c/platform/system/core/+/748128
|
// ref https://android-review.googlesource.com/c/platform/system/core/+/748128
|
||||||
static readonly LOG_SIZE_REGEX_10 =
|
static readonly LOG_SIZE_REGEX_10: RegExp =
|
||||||
/(.*): ring buffer is (.*) (.*)B \((.*) (.*)B consumed\), max entry is (.*) B, max payload is (.*) B/;
|
/(.*): ring buffer is (.*) (.*)B \((.*) (.*)B consumed\), max entry is (.*) B, max payload is (.*) B/;
|
||||||
|
|
||||||
// Android 11 added `readable` part
|
// Android 11 added `readable` part
|
||||||
// ref https://android-review.googlesource.com/c/platform/system/core/+/1390940
|
// ref https://android-review.googlesource.com/c/platform/system/core/+/1390940
|
||||||
static readonly LOG_SIZE_REGEX_11 =
|
static readonly LOG_SIZE_REGEX_11: RegExp =
|
||||||
/(.*): ring buffer is (.*) (.*)B \((.*) (.*)B consumed, (.*) (.*)B readable\), max entry is (.*) B, max payload is (.*) B/;
|
/(.*): ring buffer is (.*) (.*)B \((.*) (.*)B consumed, (.*) (.*)B readable\), max entry is (.*) B, max payload is (.*) B/;
|
||||||
|
|
||||||
async getLogSize(ids?: LogId[]): Promise<LogSize[]> {
|
async getLogSize(ids?: LogId[]): Promise<LogSize[]> {
|
||||||
|
@ -471,7 +471,7 @@ export class Logcat extends AdbCommandBase {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
async clear(ids?: LogId[]) {
|
async clear(ids?: LogId[]): Promise<void> {
|
||||||
const args = ["logcat", "-c"];
|
const args = ["logcat", "-c"];
|
||||||
if (ids && ids.length > 0) {
|
if (ids && ids.length > 0) {
|
||||||
args.push("-b", Logcat.joinLogId(ids));
|
args.push("-b", Logcat.joinLogId(ids));
|
||||||
|
|
|
@ -36,7 +36,7 @@ export class OverlayDisplay extends AdbCommandBase {
|
||||||
p.literal("/"),
|
p.literal("/"),
|
||||||
{ name: "density", format: p.digits() },
|
{ name: "density", format: p.digits() },
|
||||||
),
|
),
|
||||||
1,
|
{ min: 1 },
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -81,7 +81,7 @@ export class OverlayDisplay extends AdbCommandBase {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
async set(devices: OverlayDisplayDevice[]) {
|
async set(devices: OverlayDisplayDevice[]): Promise<void> {
|
||||||
await this.#settings.put(
|
await this.#settings.put(
|
||||||
"global",
|
"global",
|
||||||
OverlayDisplay.SETTING_KEY,
|
OverlayDisplay.SETTING_KEY,
|
||||||
|
|
|
@ -533,7 +533,9 @@ export class PackageManager extends AdbCommandBase {
|
||||||
* @param options Options for the install session
|
* @param options Options for the install session
|
||||||
* @returns ID of the new install session
|
* @returns ID of the new install session
|
||||||
*/
|
*/
|
||||||
async sessionCreate(options?: Partial<PackageManagerInstallOptions>) {
|
async sessionCreate(
|
||||||
|
options?: Partial<PackageManagerInstallOptions>,
|
||||||
|
): Promise<number> {
|
||||||
const args = this.#buildInstallArguments("install-create", options);
|
const args = this.#buildInstallArguments("install-create", options);
|
||||||
|
|
||||||
const process = await this.#cmdOrSubprocess(args);
|
const process = await this.#cmdOrSubprocess(args);
|
||||||
|
@ -550,7 +552,11 @@ export class PackageManager extends AdbCommandBase {
|
||||||
return Number.parseInt(sessionIdString[1]!, 10);
|
return Number.parseInt(sessionIdString[1]!, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
async sessionAddSplit(sessionId: number, splitName: string, path: string) {
|
async sessionAddSplit(
|
||||||
|
sessionId: number,
|
||||||
|
splitName: string,
|
||||||
|
path: string,
|
||||||
|
): Promise<void> {
|
||||||
const args: string[] = [
|
const args: string[] = [
|
||||||
"pm",
|
"pm",
|
||||||
"install-write",
|
"install-write",
|
||||||
|
@ -572,7 +578,7 @@ export class PackageManager extends AdbCommandBase {
|
||||||
splitName: string,
|
splitName: string,
|
||||||
size: number,
|
size: number,
|
||||||
stream: ReadableStream<MaybeConsumable<Uint8Array>>,
|
stream: ReadableStream<MaybeConsumable<Uint8Array>>,
|
||||||
) {
|
): Promise<void> {
|
||||||
const args: string[] = [
|
const args: string[] = [
|
||||||
"pm",
|
"pm",
|
||||||
"install-write",
|
"install-write",
|
||||||
|
@ -599,7 +605,7 @@ export class PackageManager extends AdbCommandBase {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async sessionCommit(sessionId: number) {
|
async sessionCommit(sessionId: number): Promise<void> {
|
||||||
const args: string[] = ["pm", "install-commit", sessionId.toString()];
|
const args: string[] = ["pm", "install-commit", sessionId.toString()];
|
||||||
const output = await this.adb.subprocess
|
const output = await this.adb.subprocess
|
||||||
.spawnAndWaitLegacy(args)
|
.spawnAndWaitLegacy(args)
|
||||||
|
@ -609,7 +615,7 @@ export class PackageManager extends AdbCommandBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async sessionAbandon(sessionId: number) {
|
async sessionAbandon(sessionId: number): Promise<void> {
|
||||||
const args: string[] = ["pm", "install-abandon", sessionId.toString()];
|
const args: string[] = ["pm", "install-abandon", sessionId.toString()];
|
||||||
const output = await this.adb.subprocess
|
const output = await this.adb.subprocess
|
||||||
.spawnAndWaitLegacy(args)
|
.spawnAndWaitLegacy(args)
|
||||||
|
@ -624,7 +630,7 @@ export class PackageManagerInstallSession {
|
||||||
static async create(
|
static async create(
|
||||||
packageManager: PackageManager,
|
packageManager: PackageManager,
|
||||||
options?: Partial<PackageManagerInstallOptions>,
|
options?: Partial<PackageManagerInstallOptions>,
|
||||||
) {
|
): Promise<PackageManagerInstallSession> {
|
||||||
const id = await packageManager.sessionCreate(options);
|
const id = await packageManager.sessionCreate(options);
|
||||||
return new PackageManagerInstallSession(packageManager, id);
|
return new PackageManagerInstallSession(packageManager, id);
|
||||||
}
|
}
|
||||||
|
@ -632,7 +638,7 @@ export class PackageManagerInstallSession {
|
||||||
#packageManager: PackageManager;
|
#packageManager: PackageManager;
|
||||||
|
|
||||||
#id: number;
|
#id: number;
|
||||||
get id() {
|
get id(): number {
|
||||||
return this.#id;
|
return this.#id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,7 +647,7 @@ export class PackageManagerInstallSession {
|
||||||
this.#id = id;
|
this.#id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
addSplit(splitName: string, path: string) {
|
addSplit(splitName: string, path: string): Promise<void> {
|
||||||
return this.#packageManager.sessionAddSplit(this.#id, splitName, path);
|
return this.#packageManager.sessionAddSplit(this.#id, splitName, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,7 +655,7 @@ export class PackageManagerInstallSession {
|
||||||
splitName: string,
|
splitName: string,
|
||||||
size: number,
|
size: number,
|
||||||
stream: ReadableStream<MaybeConsumable<Uint8Array>>,
|
stream: ReadableStream<MaybeConsumable<Uint8Array>>,
|
||||||
) {
|
): Promise<void> {
|
||||||
return this.#packageManager.sessionAddSplitStream(
|
return this.#packageManager.sessionAddSplitStream(
|
||||||
this.#id,
|
this.#id,
|
||||||
splitName,
|
splitName,
|
||||||
|
@ -658,11 +664,11 @@ export class PackageManagerInstallSession {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
commit() {
|
commit(): Promise<void> {
|
||||||
return this.#packageManager.sessionCommit(this.#id);
|
return this.#packageManager.sessionCommit(this.#id);
|
||||||
}
|
}
|
||||||
|
|
||||||
abandon() {
|
abandon(): Promise<void> {
|
||||||
return this.#packageManager.sessionAbandon(this.#id);
|
return this.#packageManager.sessionAbandon(this.#id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ export class Settings extends AdbCommandBase {
|
||||||
namespace: SettingsNamespace,
|
namespace: SettingsNamespace,
|
||||||
key: string,
|
key: string,
|
||||||
options?: SettingsOptions,
|
options?: SettingsOptions,
|
||||||
) {
|
): Promise<string> {
|
||||||
const output = await this.base("get", namespace, options, key);
|
const output = await this.base("get", namespace, options, key);
|
||||||
// Remove last \n
|
// Remove last \n
|
||||||
return output.substring(0, output.length - 1);
|
return output.substring(0, output.length - 1);
|
||||||
|
|
|
@ -103,8 +103,7 @@ export const p = {
|
||||||
separated: <T>(
|
separated: <T>(
|
||||||
separator: string,
|
separator: string,
|
||||||
format: Format<T>,
|
format: Format<T>,
|
||||||
min = 0,
|
{ min = 0, max = Infinity }: { min?: number; max?: number } = {},
|
||||||
max = Infinity,
|
|
||||||
): Format<T[]> => ({
|
): Format<T[]> => ({
|
||||||
parse(reader: Reader) {
|
parse(reader: Reader) {
|
||||||
const result: T[] = [];
|
const result: T[] = [];
|
||||||
|
|
|
@ -42,19 +42,19 @@ export class HidMouse {
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
static serializeInputReport(
|
static serializeInputReport(report: {
|
||||||
movementX: number,
|
movementX?: number;
|
||||||
movementY: number,
|
movementY?: number;
|
||||||
buttons: number,
|
buttons?: number;
|
||||||
scrollX: number,
|
scrollX?: number;
|
||||||
scrollY: number,
|
scrollY?: number;
|
||||||
): Uint8Array {
|
}): Uint8Array {
|
||||||
return new Uint8Array([
|
return new Uint8Array([
|
||||||
buttons,
|
report.buttons ?? 0,
|
||||||
movementX,
|
report.movementX ?? 0,
|
||||||
movementY,
|
report.movementY ?? 0,
|
||||||
scrollY,
|
report.scrollY ?? 0,
|
||||||
scrollX,
|
report.scrollX ?? 0,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,17 +70,23 @@ export class WebCodecsVideoDecoder implements ScrcpyVideoDecoder {
|
||||||
* Enable this option may reduce performance.
|
* Enable this option may reduce performance.
|
||||||
* @param canvas Optional render target cavas element or offscreen canvas
|
* @param canvas Optional render target cavas element or offscreen canvas
|
||||||
*/
|
*/
|
||||||
constructor(codec: ScrcpyVideoCodecId, enableCapture: boolean, canvas?: HTMLCanvasElement | OffscreenCanvas) {
|
constructor(
|
||||||
|
codec: ScrcpyVideoCodecId,
|
||||||
|
enableCapture: boolean,
|
||||||
|
canvas?: HTMLCanvasElement | OffscreenCanvas,
|
||||||
|
) {
|
||||||
this.#codec = codec;
|
this.#codec = codec;
|
||||||
|
|
||||||
if (canvas) {
|
if (canvas) {
|
||||||
this.#canvas = canvas
|
this.#canvas = canvas;
|
||||||
} else if (typeof document !== 'undefined') {
|
} else if (typeof document !== "undefined") {
|
||||||
this.#canvas = document.createElement("canvas");
|
this.#canvas = document.createElement("canvas");
|
||||||
} else if (typeof OffscreenCanvas !== 'undefined') {
|
} else if (typeof OffscreenCanvas !== "undefined") {
|
||||||
this.#canvas = new OffscreenCanvas(0, 0);
|
this.#canvas = new OffscreenCanvas(0, 0);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('no canvas input found nor any canvas can be created');
|
throw new Error(
|
||||||
|
"no canvas input found nor any canvas can be created",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -33,7 +33,10 @@ export class WebGLFrameRenderer implements FrameRenderer {
|
||||||
* Whether to allow capturing the canvas content using APIs like `readPixels` and `toDataURL`.
|
* Whether to allow capturing the canvas content using APIs like `readPixels` and `toDataURL`.
|
||||||
* Enable this option may reduce performance.
|
* Enable this option may reduce performance.
|
||||||
*/
|
*/
|
||||||
constructor(canvas: HTMLCanvasElement | OffscreenCanvas, enableCapture: boolean) {
|
constructor(
|
||||||
|
canvas: HTMLCanvasElement | OffscreenCanvas,
|
||||||
|
enableCapture: boolean,
|
||||||
|
) {
|
||||||
const gl =
|
const gl =
|
||||||
canvas.getContext("webgl2", {
|
canvas.getContext("webgl2", {
|
||||||
alpha: false,
|
alpha: false,
|
||||||
|
|
|
@ -169,6 +169,7 @@ export class BufferLikeFieldValue<
|
||||||
> extends StructFieldValue<TDefinition> {
|
> extends StructFieldValue<TDefinition> {
|
||||||
protected array: Uint8Array | undefined;
|
protected array: Uint8Array | undefined;
|
||||||
|
|
||||||
|
// eslint-disable-next-line max-params
|
||||||
constructor(
|
constructor(
|
||||||
definition: TDefinition,
|
definition: TDefinition,
|
||||||
options: Readonly<StructOptions>,
|
options: Readonly<StructOptions>,
|
||||||
|
|
|
@ -81,6 +81,7 @@ export class VariableLengthBufferLikeStructFieldValue<
|
||||||
|
|
||||||
protected lengthFieldValue: VariableLengthBufferLikeFieldLengthValue;
|
protected lengthFieldValue: VariableLengthBufferLikeFieldLengthValue;
|
||||||
|
|
||||||
|
// eslint-disable-next-line max-params
|
||||||
constructor(
|
constructor(
|
||||||
definition: TDefinition,
|
definition: TDefinition,
|
||||||
options: Readonly<StructOptions>,
|
options: Readonly<StructOptions>,
|
||||||
|
|
|
@ -25,6 +25,12 @@ export default tslint.config(
|
||||||
maxBOF: 0,
|
maxBOF: 0,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"max-params": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
max: 4,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
...tslint.configs.recommendedTypeChecked,
|
...tslint.configs.recommendedTypeChecked,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue