mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-05 10:49:24 +02:00
fix: improve regex
This commit is contained in:
parent
c95c63f4e0
commit
f266970cf2
4 changed files with 17 additions and 10 deletions
|
@ -366,8 +366,6 @@ export class PackageManager extends AdbCommandBase {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: install: support split apk formats (`adb install-multiple`)
|
|
||||||
|
|
||||||
static parsePackageListItem(
|
static parsePackageListItem(
|
||||||
line: string,
|
line: string,
|
||||||
): PackageManagerListPackagesResult {
|
): PackageManagerListPackagesResult {
|
||||||
|
@ -502,6 +500,16 @@ export class PackageManager extends AdbCommandBase {
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new install session.
|
||||||
|
*
|
||||||
|
* Install sessions are used to install apps with multiple splits, but it can also be used to install a single apk.
|
||||||
|
*
|
||||||
|
* Install sessions was added in Android 5.0 (API level 21).
|
||||||
|
*
|
||||||
|
* @param options Options for the install session
|
||||||
|
* @returns ID of the new install session
|
||||||
|
*/
|
||||||
async sessionCreate(options?: Partial<PackageManagerInstallOptions>) {
|
async sessionCreate(options?: Partial<PackageManagerInstallOptions>) {
|
||||||
const args = this.#buildInstallArguments("install-create", options);
|
const args = this.#buildInstallArguments("install-create", options);
|
||||||
|
|
||||||
|
@ -542,8 +550,6 @@ export class PackageManager extends AdbCommandBase {
|
||||||
size: number,
|
size: number,
|
||||||
stream: ReadableStream<Consumable<Uint8Array>>,
|
stream: ReadableStream<Consumable<Uint8Array>>,
|
||||||
) {
|
) {
|
||||||
// `pm install-write` supports streaming from stdin from at least Android 5
|
|
||||||
// So assume it always works
|
|
||||||
const args: string[] = [
|
const args: string[] = [
|
||||||
"pm",
|
"pm",
|
||||||
"install-write",
|
"install-write",
|
||||||
|
|
|
@ -128,8 +128,7 @@ export class ScrcpyOptions1_16 implements ScrcpyOptions<ScrcpyOptionsInit1_16> {
|
||||||
}
|
}
|
||||||
|
|
||||||
parseDisplay(line: string): ScrcpyDisplay | undefined {
|
parseDisplay(line: string): ScrcpyDisplay | undefined {
|
||||||
const displayIdRegex = /\s+scrcpy --display (\d+)/;
|
const match = line.match(/^\s+scrcpy --display (\d+)$/);
|
||||||
const match = line.match(displayIdRegex);
|
|
||||||
if (match) {
|
if (match) {
|
||||||
return {
|
return {
|
||||||
id: Number.parseInt(match[1]!, 10),
|
id: Number.parseInt(match[1]!, 10),
|
||||||
|
|
|
@ -155,7 +155,7 @@ export class ScrcpyOptions2_0 extends ScrcpyOptionsBase<
|
||||||
|
|
||||||
override parseEncoder(line: string): ScrcpyEncoder | undefined {
|
override parseEncoder(line: string): ScrcpyEncoder | undefined {
|
||||||
let match = line.match(
|
let match = line.match(
|
||||||
/\s+--video-codec=(.*)\s+--video-encoder='(.*)'/,
|
/^\s+--video-codec=(\S+)\s+--video-encoder='([^']+)'$/,
|
||||||
);
|
);
|
||||||
if (match) {
|
if (match) {
|
||||||
return {
|
return {
|
||||||
|
@ -165,7 +165,9 @@ export class ScrcpyOptions2_0 extends ScrcpyOptionsBase<
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
match = line.match(/\s+--audio-codec=(.*)\s+--audio-encoder='(.*)'/);
|
match = line.match(
|
||||||
|
/^\s+--audio-codec=(\S+)\s+--audio-encoder='([^']+)'$/,
|
||||||
|
);
|
||||||
if (match) {
|
if (match) {
|
||||||
return {
|
return {
|
||||||
type: "audio",
|
type: "audio",
|
||||||
|
@ -178,7 +180,7 @@ export class ScrcpyOptions2_0 extends ScrcpyOptionsBase<
|
||||||
}
|
}
|
||||||
|
|
||||||
override parseDisplay(line: string): ScrcpyDisplay | undefined {
|
override parseDisplay(line: string): ScrcpyDisplay | undefined {
|
||||||
const match = line.match(/\s+--display=(\d+)\s+\((.*?)\)/);
|
const match = line.match(/^\s+--display=(\d+)\s+\(([^)]+)\)$/);
|
||||||
if (match) {
|
if (match) {
|
||||||
const display: ScrcpyDisplay = {
|
const display: ScrcpyDisplay = {
|
||||||
id: Number.parseInt(match[1]!, 10),
|
id: Number.parseInt(match[1]!, 10),
|
||||||
|
|
|
@ -49,7 +49,7 @@ export class ScrcpyOptions2_2 extends ScrcpyOptionsBase<
|
||||||
}
|
}
|
||||||
|
|
||||||
override parseDisplay(line: string): ScrcpyDisplay | undefined {
|
override parseDisplay(line: string): ScrcpyDisplay | undefined {
|
||||||
const match = line.match(/\s+--display-id=(\d+)\s+\((.*?)\)/);
|
const match = line.match(/^\s+--display-id=(\d+)\s+\(([^)]+)\)$/);
|
||||||
if (match) {
|
if (match) {
|
||||||
const display: ScrcpyDisplay = {
|
const display: ScrcpyDisplay = {
|
||||||
id: Number.parseInt(match[1]!, 10),
|
id: Number.parseInt(match[1]!, 10),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue