@yume-chan/android-bin 0.0.16 → 0.0.18

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/esm/logcat.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // cspell: ignore logcat
2
- import { AdbCommandBase, AdbSubprocessNoneProtocol, BufferedStream, BufferedStreamEndedError, DecodeUtf8Stream, ReadableStream, SplitLineStream, WritableStream } from "@yume-chan/adb";
3
- import Struct from "@yume-chan/struct";
2
+ import { AdbCommandBase, AdbSubprocessNoneProtocol } from "@yume-chan/adb";
3
+ import { BufferedTransformStream, DecodeUtf8Stream, SplitStringStream, WrapReadableStream, WritableStream, } from "@yume-chan/stream-extra";
4
+ import Struct, { decodeUtf8, } from "@yume-chan/struct";
4
5
  // `adb logcat` is an alias to `adb shell logcat`
5
6
  // so instead of adding to core library, it's implemented here
6
7
  // https://cs.android.com/android/platform/superproject/+/master:system/logging/liblog/include/android/log.h;l=141;drc=82b5738732161dbaafb2e2f25cce19cd26b9157d
@@ -15,43 +16,100 @@ export var LogId;
15
16
  LogId[LogId["Stats"] = 5] = "Stats";
16
17
  LogId[LogId["Security"] = 6] = "Security";
17
18
  LogId[LogId["Kernel"] = 7] = "Kernel";
18
- })(LogId || (LogId = {}));
19
- export var LogPriority;
20
- (function (LogPriority) {
21
- LogPriority[LogPriority["Unknown"] = 0] = "Unknown";
22
- LogPriority[LogPriority["Default"] = 1] = "Default";
23
- LogPriority[LogPriority["Verbose"] = 2] = "Verbose";
24
- LogPriority[LogPriority["Info"] = 3] = "Info";
25
- LogPriority[LogPriority["Warn"] = 4] = "Warn";
26
- LogPriority[LogPriority["Error"] = 5] = "Error";
27
- LogPriority[LogPriority["Fatal"] = 6] = "Fatal";
28
- LogPriority[LogPriority["Silent"] = 7] = "Silent";
29
- })(LogPriority || (LogPriority = {}));
19
+ })(LogId = LogId || (LogId = {}));
20
+ // https://cs.android.com/android/platform/superproject/+/master:system/logging/liblog/include/android/log.h;l=73;drc=82b5738732161dbaafb2e2f25cce19cd26b9157d
21
+ export var AndroidLogPriority;
22
+ (function (AndroidLogPriority) {
23
+ AndroidLogPriority[AndroidLogPriority["Unknown"] = 0] = "Unknown";
24
+ AndroidLogPriority[AndroidLogPriority["Default"] = 1] = "Default";
25
+ AndroidLogPriority[AndroidLogPriority["Verbose"] = 2] = "Verbose";
26
+ AndroidLogPriority[AndroidLogPriority["Debug"] = 3] = "Debug";
27
+ AndroidLogPriority[AndroidLogPriority["Info"] = 4] = "Info";
28
+ AndroidLogPriority[AndroidLogPriority["Warn"] = 5] = "Warn";
29
+ AndroidLogPriority[AndroidLogPriority["Error"] = 6] = "Error";
30
+ AndroidLogPriority[AndroidLogPriority["Fatal"] = 7] = "Fatal";
31
+ AndroidLogPriority[AndroidLogPriority["Silent"] = 8] = "Silent";
32
+ })(AndroidLogPriority = AndroidLogPriority || (AndroidLogPriority = {}));
33
+ // https://cs.android.com/android/platform/superproject/+/master:system/logging/liblog/logprint.cpp;l=140;drc=8dbf3b2bb6b6d1652d9797e477b9abd03278bb79
34
+ export const AndroidLogPriorityToCharacter = {
35
+ [AndroidLogPriority.Unknown]: "?",
36
+ [AndroidLogPriority.Default]: "?",
37
+ [AndroidLogPriority.Verbose]: "V",
38
+ [AndroidLogPriority.Debug]: "D",
39
+ [AndroidLogPriority.Info]: "I",
40
+ [AndroidLogPriority.Warn]: "W",
41
+ [AndroidLogPriority.Error]: "E",
42
+ [AndroidLogPriority.Fatal]: "F",
43
+ [AndroidLogPriority.Silent]: "S",
44
+ };
45
+ export var LogcatFormat;
46
+ (function (LogcatFormat) {
47
+ LogcatFormat[LogcatFormat["Brief"] = 0] = "Brief";
48
+ LogcatFormat[LogcatFormat["Process"] = 1] = "Process";
49
+ LogcatFormat[LogcatFormat["Tag"] = 2] = "Tag";
50
+ LogcatFormat[LogcatFormat["Thread"] = 3] = "Thread";
51
+ LogcatFormat[LogcatFormat["Raw"] = 4] = "Raw";
52
+ LogcatFormat[LogcatFormat["Time"] = 5] = "Time";
53
+ LogcatFormat[LogcatFormat["ThreadTime"] = 6] = "ThreadTime";
54
+ LogcatFormat[LogcatFormat["Long"] = 7] = "Long";
55
+ })(LogcatFormat = LogcatFormat || (LogcatFormat = {}));
30
56
  const NANOSECONDS_PER_SECOND = BigInt(1e9);
31
57
  // https://cs.android.com/android/platform/superproject/+/master:system/logging/liblog/include/log/log_read.h;l=39;drc=82b5738732161dbaafb2e2f25cce19cd26b9157d
32
58
  export const LoggerEntry = new Struct({ littleEndian: true })
33
- .uint16('payloadSize')
34
- .uint16('headerSize')
35
- .int32('pid')
36
- .uint32('tid')
37
- .uint32('second')
38
- .uint32('nanoseconds')
39
- .uint32('logId')
40
- .uint32('uid')
59
+ .uint16("payloadSize")
60
+ .uint16("headerSize")
61
+ .int32("pid")
62
+ .uint32("tid")
63
+ .uint32("second")
64
+ .uint32("nanoseconds")
65
+ .uint32("logId")
66
+ .uint32("uid")
41
67
  .extra({
42
68
  get timestamp() {
43
- return BigInt(this.second) * NANOSECONDS_PER_SECOND + BigInt(this.nanoseconds);
69
+ return (BigInt(this.second) * NANOSECONDS_PER_SECOND +
70
+ BigInt(this.nanoseconds));
44
71
  },
45
72
  });
46
- export async function deserializeLogMessage(stream) {
47
- const entry = await LoggerEntry.deserialize(stream);
73
+ // https://cs.android.com/android/platform/superproject/+/master:system/logging/liblog/logprint.cpp;l=1415;drc=8dbf3b2bb6b6d1652d9797e477b9abd03278bb79
74
+ export function formatAndroidLogEntry(entry, format = LogcatFormat.Brief, modifier) {
75
+ const uid = modifier?.uid ? `${entry.uid.toString().padStart(5)}:` : "";
76
+ switch (format) {
77
+ // TODO: implement other formats
78
+ default:
79
+ return `${AndroidLogPriorityToCharacter[entry.priority]}/${entry.tag.padEnd(8)}(${uid}${entry.pid
80
+ .toString()
81
+ .padStart(5)}): ${entry.message}`;
82
+ }
83
+ }
84
+ function findTagEnd(payload) {
85
+ for (const separator of [0, " ".charCodeAt(0), ":".charCodeAt(0)]) {
86
+ const index = payload.indexOf(separator);
87
+ if (index !== -1) {
88
+ return index;
89
+ }
90
+ }
91
+ const index = payload.findIndex((x) => x >= 0x7f);
92
+ if (index !== -1) {
93
+ return index;
94
+ }
95
+ return payload.length;
96
+ }
97
+ export async function deserializeAndroidLogEntry(stream) {
98
+ const entry = (await LoggerEntry.deserialize(stream));
48
99
  if (entry.headerSize !== LoggerEntry.size) {
49
100
  await stream.read(entry.headerSize - LoggerEntry.size);
50
101
  }
51
- const priority = (await stream.read(1))[0];
52
- const payload = await stream.read(entry.payloadSize - 1);
53
- entry.priority = priority;
54
- entry.payload = payload;
102
+ let payload = await stream.read(entry.payloadSize);
103
+ // https://cs.android.com/android/platform/superproject/+/master:system/logging/logcat/logcat.cpp;l=193-194;drc=bbe77d66e7bee8bd1f0bc7e5492b5376b0207ef6
104
+ // TODO: payload for some log IDs are in binary format.
105
+ entry.priority = payload[0];
106
+ payload = payload.subarray(1);
107
+ const tagEnd = findTagEnd(payload);
108
+ entry.tag = decodeUtf8(payload.subarray(0, tagEnd));
109
+ entry.message =
110
+ tagEnd < payload.length - 1
111
+ ? decodeUtf8(payload.subarray(tagEnd + 1))
112
+ : "";
55
113
  return entry;
56
114
  }
57
115
  export class Logcat extends AdbCommandBase {
@@ -63,10 +121,10 @@ export class Logcat extends AdbCommandBase {
63
121
  return LogId[key];
64
122
  }
65
123
  static joinLogId(ids) {
66
- return ids.map(id => Logcat.logIdToName(id)).join(',');
124
+ return ids.map((id) => Logcat.logIdToName(id)).join(",");
67
125
  }
68
126
  static parseSize(value, multiplier) {
69
- const MULTIPLIERS = ['', 'Ki', 'Mi', 'Gi'];
127
+ const MULTIPLIERS = ["", "Ki", "Mi", "Gi"];
70
128
  return value * 1024 ** (MULTIPLIERS.indexOf(multiplier) || 0);
71
129
  }
72
130
  // TODO: logcat: Support output format before Android 10
@@ -77,14 +135,14 @@ export class Logcat extends AdbCommandBase {
77
135
  static LOG_SIZE_REGEX_11 = /(.*): ring buffer is (.*) (.*)B \((.*) (.*)B consumed, (.*) (.*)B readable\), max entry is (.*) B, max payload is (.*) B/;
78
136
  async getLogSize(ids) {
79
137
  const { stdout } = await this.adb.subprocess.spawn([
80
- 'logcat',
81
- '-g',
82
- ...(ids ? ['-b', Logcat.joinLogId(ids)] : [])
138
+ "logcat",
139
+ "-g",
140
+ ...(ids ? ["-b", Logcat.joinLogId(ids)] : []),
83
141
  ]);
84
142
  const result = [];
85
143
  await stdout
86
144
  .pipeThrough(new DecodeUtf8Stream())
87
- .pipeThrough(new SplitLineStream())
145
+ .pipeThrough(new SplitStringStream("\n"))
88
146
  .pipeTo(new WritableStream({
89
147
  write(chunk) {
90
148
  let match = chunk.match(Logcat.LOG_SIZE_REGEX_11);
@@ -114,43 +172,30 @@ export class Logcat extends AdbCommandBase {
114
172
  }
115
173
  async clear(ids) {
116
174
  await this.adb.subprocess.spawnAndWait([
117
- 'logcat',
118
- '-c',
119
- ...(ids ? ['-b', Logcat.joinLogId(ids)] : []),
175
+ "logcat",
176
+ "-c",
177
+ ...(ids ? ["-b", Logcat.joinLogId(ids)] : []),
120
178
  ]);
121
179
  }
122
180
  binary(options) {
123
- let bufferedStream;
124
- return new ReadableStream({
125
- start: async () => {
126
- const { stdout } = await this.adb.subprocess.spawn([
127
- 'logcat',
128
- '-B',
129
- ...(options?.pid ? ['--pid', options.pid.toString()] : []),
130
- ...(options?.ids ? ['-b', Logcat.joinLogId(options.ids)] : [])
131
- ], {
132
- // PERF: None protocol is 150% faster then Shell protocol
133
- protocols: [AdbSubprocessNoneProtocol],
134
- });
135
- bufferedStream = new BufferedStream(stdout);
136
- },
137
- async pull(controller) {
138
- try {
139
- const entry = await deserializeLogMessage(bufferedStream);
140
- controller.enqueue(entry);
141
- }
142
- catch (e) {
143
- if (e instanceof BufferedStreamEndedError) {
144
- controller.close();
145
- return;
146
- }
147
- throw e;
148
- }
149
- },
150
- cancel() {
151
- bufferedStream.close();
152
- },
153
- });
181
+ return new WrapReadableStream(async () => {
182
+ // TODO: make `spawn` return synchronously with streams pending
183
+ // so it's easier to chain them.
184
+ const { stdout } = await this.adb.subprocess.spawn([
185
+ "logcat",
186
+ "-B",
187
+ ...(options?.pid ? ["--pid", options.pid.toString()] : []),
188
+ ...(options?.ids
189
+ ? ["-b", Logcat.joinLogId(options.ids)]
190
+ : []),
191
+ ], {
192
+ // PERF: None protocol is 150% faster then Shell protocol
193
+ protocols: [AdbSubprocessNoneProtocol],
194
+ });
195
+ return stdout;
196
+ }).pipeThrough(new BufferedTransformStream((stream) => {
197
+ return deserializeAndroidLogEntry(stream);
198
+ }));
154
199
  }
155
200
  }
156
201
  //# sourceMappingURL=logcat.js.map
package/esm/logcat.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"logcat.js","sourceRoot":"","sources":["../src/logcat.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,cAAc,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACxL,OAAO,MAAwC,MAAM,mBAAmB,CAAC;AAEzE,iDAAiD;AACjD,8DAA8D;AAE9D,+JAA+J;AAC/J,MAAM,CAAN,IAAY,KAUX;AAVD,WAAY,KAAK;IACb,gCAAQ,CAAA;IACR,iCAAI,CAAA;IACJ,mCAAK,CAAA;IACL,qCAAM,CAAA;IACN,qCAAM,CAAA;IACN,mCAAK,CAAA;IACL,mCAAK,CAAA;IACL,yCAAQ,CAAA;IACR,qCAAM,CAAA;AACV,CAAC,EAVW,KAAK,KAAL,KAAK,QAUhB;AAED,MAAM,CAAN,IAAY,WASX;AATD,WAAY,WAAW;IACnB,mDAAO,CAAA;IACP,mDAAO,CAAA;IACP,mDAAO,CAAA;IACP,6CAAI,CAAA;IACJ,6CAAI,CAAA;IACJ,+CAAK,CAAA;IACL,+CAAK,CAAA;IACL,iDAAM,CAAA;AACV,CAAC,EATW,WAAW,KAAX,W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AC,CAAC,CAAC,EAAE,CAAC;gBAC1D,GAAG,CAAC,OAAO,EAAE,GAAG;oBACZ,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;oBACvC,CAAC,CAAC,EAAE,CAAC;aACZ,EACD;gBACI,yDAAyD;gBACzD,SAAS,EAAE,CAAC,yBAAyB,CAAC;aACzC,CACJ,CAAC;YACF,OAAO,MAAM,CAAC;QAClB,CAAC,CAAC,CAAC,WAAW,CACV,IAAI,uBAAuB,CAAC,CAAC,MAAM,EAAE,EAAE;YACnC,OAAO,0BAA0B,CAAC,MAAM,CAAC,CAAC;QAC9C,CAAC,CAAC,CACL,CAAC;IACN,CAAC"}
package/esm/settings.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AdbCommandBase } from "@yume-chan/adb";
2
- export declare type SettingsNamespace = 'system' | 'secure' | 'global';
3
- export declare type SettingsResetMode = 'untrusted_defaults' | 'untrusted_clear' | 'trusted_defaults';
2
+ export type SettingsNamespace = 'system' | 'secure' | 'global';
3
+ export type SettingsResetMode = 'untrusted_defaults' | 'untrusted_clear' | 'trusted_defaults';
4
4
  export declare class Settings extends AdbCommandBase {
5
5
  base(command: string, namespace: SettingsNamespace, ...args: string[]): Promise<string>;
6
6
  get(namespace: SettingsNamespace, key: string): Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,oBAAY,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE/D,oBAAY,iBAAiB,GAAG,oBAAoB,GAAG,iBAAiB,GAAG,kBAAkB,CAAC;AAG9F,qBAAa,QAAS,SAAQ,cAAc;IAGjC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,GAAG,IA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CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO;IAWjG,KAAK,CAAC,SAAS,EAAE,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAC7E,KAAK,CAAC,SAAS,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAUjF,IAAI,CAAC,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAIrE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yume-chan/android-bin",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "Wrappers for Android built-in executables.",
5
5
  "keywords": [
6
6
  "adb",
@@ -12,7 +12,7 @@
12
12
  "email": "cnsimonchan@live.com",
13
13
  "url": "https://chensi.moe/blog"
14
14
  },
15
- "homepage": "https://github.com/yume-chan/ya-webadb/tree/master/libraries/android-bin#readme",
15
+ "homepage": "https://github.com/yume-chan/ya-webadb/tree/main/libraries/android-bin#readme",
16
16
  "repository": {
17
17
  "type": "git",
18
18
  "url": "git+https://github.com/yume-chan/ya-webadb.git",
@@ -25,17 +25,20 @@
25
25
  "main": "esm/index.js",
26
26
  "types": "esm/index.d.ts",
27
27
  "devDependencies": {
28
- "typescript": "4.7.2",
29
- "@yume-chan/ts-package-builder": "^1.0.0"
28
+ "@yume-chan/eslint-config": "^1.0.0",
29
+ "@yume-chan/tsconfig": "^1.0.0",
30
+ "eslint": "^8.31.0",
31
+ "typescript": "^4.9.4"
30
32
  },
31
33
  "dependencies": {
32
- "@yume-chan/adb": "^0.0.16",
33
- "@yume-chan/struct": "^0.0.16",
34
- "tslib": "^2.3.1"
34
+ "@yume-chan/adb": "^0.0.18",
35
+ "@yume-chan/stream-extra": "^0.0.18",
36
+ "@yume-chan/struct": "^0.0.18",
37
+ "tslib": "^2.4.1"
35
38
  },
36
39
  "scripts": {
37
- "build": "build-ts-package",
38
- "build:watch": "build-ts-package --incremental"
39
- },
40
- "readme": "# `@yume-chan/android-bin`\n\nWrappers for Android built-in executables.\n\nCurrently it's bound to `@yume-chan/adb`, maybe one day it can be used with other executors.\n"
40
+ "build": "tsc -b tsconfig.build.json",
41
+ "build:watch": "tsc -b tsconfig.build.json",
42
+ "lint": "eslint src/**/*.ts --fix"
43
+ }
41
44
  }
package/src/bu.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  import { AdbCommandBase } from "@yume-chan/adb";
5
5
 
6
6
  export interface AdbBackupOptions {
7
- apps: string[] | 'all' | 'all-including-system';
7
+ apps: string[] | "all" | "all-including-system";
8
8
  apks: boolean;
9
9
  obbs: boolean;
10
10
  shared: boolean;
@@ -14,9 +14,13 @@ export interface AdbBackupOptions {
14
14
  }
15
15
 
16
16
  export class AdbBackup extends AdbCommandBase {
17
- async backup(options: AdbBackupOptions): Promise<void> {
17
+ backup(options: AdbBackupOptions): Promise<void> {
18
+ void options;
19
+ throw new Error("Not implemented");
18
20
  }
19
21
 
20
- async restore(options: AdbBackupOptions): Promise<void> {
22
+ restore(options: AdbBackupOptions): Promise<void> {
23
+ void options;
24
+ throw new Error("Not implemented");
21
25
  }
22
26
  }
package/src/bug-report.ts CHANGED
@@ -1,7 +1,15 @@
1
1
  // cspell: ignore bugreport
2
2
  // cspell: ignore bugreportz
3
3
 
4
- import { AdbCommandBase, AdbSubprocessShellProtocol, DecodeUtf8Stream, PushReadableStream, ReadableStream, SplitLineStream, WrapReadableStream, WritableStream } from "@yume-chan/adb";
4
+ import { AdbCommandBase, AdbSubprocessShellProtocol } from "@yume-chan/adb";
5
+ import {
6
+ DecodeUtf8Stream,
7
+ PushReadableStream,
8
+ SplitStringStream,
9
+ WrapReadableStream,
10
+ WritableStream,
11
+ type ReadableStream,
12
+ } from "@yume-chan/stream-extra";
5
13
 
6
14
  export interface BugReportZVersion {
7
15
  major: number;
@@ -33,8 +41,11 @@ export class BugReportZ extends AdbCommandBase {
33
41
  return undefined;
34
42
  }
35
43
 
36
- const { stderr, exitCode } = await this.adb.subprocess.spawnAndWait(['bugreportz', '-v']);
37
- if (exitCode !== 0 || stderr === '') {
44
+ const { stderr, exitCode } = await this.adb.subprocess.spawnAndWait([
45
+ "bugreportz",
46
+ "-v",
47
+ ]);
48
+ if (exitCode !== 0 || stderr === "") {
38
49
  return undefined;
39
50
  }
40
51
 
@@ -67,10 +78,12 @@ export class BugReportZ extends AdbCommandBase {
67
78
  * @param onProgress Progress callback. Only specify this if `supportsProgress` is `true`.
68
79
  * @returns The path of the bugreport file.
69
80
  */
70
- public async generate(onProgress?: (progress: string, total: string) => void): Promise<string> {
81
+ public async generate(
82
+ onProgress?: (progress: string, total: string) => void
83
+ ): Promise<string> {
71
84
  const process = await this.adb.subprocess.spawn([
72
- 'bugreportz',
73
- ...(onProgress ? ['-p'] : []),
85
+ "bugreportz",
86
+ ...(onProgress ? ["-p"] : []),
74
87
  ]);
75
88
 
76
89
  let filename: string | undefined;
@@ -78,40 +91,42 @@ export class BugReportZ extends AdbCommandBase {
78
91
 
79
92
  await process.stdout
80
93
  .pipeThrough(new DecodeUtf8Stream())
81
- .pipeThrough(new SplitLineStream())
82
- .pipeTo(new WritableStream<string>({
83
- write(line) {
84
- // `BEGIN:` and `PROGRESS:` only appear when `-p` is specified.
85
- let match = line.match(BugReportZ.PROGRESS_REGEX);
86
- if (match) {
87
- onProgress?.(match[1]!, match[2]!);
88
- }
89
-
90
- match = line.match(BugReportZ.BEGIN_REGEX);
91
- if (match) {
92
- filename = match[1]!;
93
- }
94
-
95
- match = line.match(BugReportZ.OK_REGEX);
96
- if (match) {
97
- filename = match[1];
98
- }
99
-
100
- match = line.match(BugReportZ.FAIL_REGEX);
101
- if (match) {
102
- // Don't report error now
103
- // We want to gather all output.
104
- error = match[1];
105
- }
106
- }
107
- }));
94
+ .pipeThrough(new SplitStringStream("\n"))
95
+ .pipeTo(
96
+ new WritableStream<string>({
97
+ write(line) {
98
+ // `BEGIN:` and `PROGRESS:` only appear when `-p` is specified.
99
+ let match = line.match(BugReportZ.PROGRESS_REGEX);
100
+ if (match) {
101
+ onProgress?.(match[1]!, match[2]!);
102
+ }
103
+
104
+ match = line.match(BugReportZ.BEGIN_REGEX);
105
+ if (match) {
106
+ filename = match[1]!;
107
+ }
108
+
109
+ match = line.match(BugReportZ.OK_REGEX);
110
+ if (match) {
111
+ filename = match[1];
112
+ }
113
+
114
+ match = line.match(BugReportZ.FAIL_REGEX);
115
+ if (match) {
116
+ // Don't report error now
117
+ // We want to gather all output.
118
+ error = match[1];
119
+ }
120
+ },
121
+ })
122
+ );
108
123
 
109
124
  if (error) {
110
125
  throw new Error(error);
111
126
  }
112
127
 
113
128
  if (!filename) {
114
- throw new Error('bugreportz did not return file name');
129
+ throw new Error("bugreportz did not return file name");
115
130
  }
116
131
 
117
132
  // Design choice: we don't automatically pull the file to avoid more dependency on `@yume-chan/adb`
@@ -124,22 +139,34 @@ export class BugReportZ extends AdbCommandBase {
124
139
 
125
140
  public stream(): ReadableStream<Uint8Array> {
126
141
  return new PushReadableStream(async (controller) => {
127
- const process = await this.adb.subprocess.spawn(['bugreportz', '-s']);
142
+ const process = await this.adb.subprocess.spawn([
143
+ "bugreportz",
144
+ "-s",
145
+ ]);
128
146
  process.stdout
129
- .pipeTo(new WritableStream({
130
- async write(chunk) {
131
- await controller.enqueue(chunk);
132
- },
133
- }));
147
+ .pipeTo(
148
+ new WritableStream({
149
+ async write(chunk) {
150
+ await controller.enqueue(chunk);
151
+ },
152
+ })
153
+ )
154
+ .catch((e) => {
155
+ void e;
156
+ });
134
157
  process.stderr
135
158
  .pipeThrough(new DecodeUtf8Stream())
136
- .pipeTo(new WritableStream({
137
- async write(chunk) {
138
- controller.error(new Error(chunk));
139
- }
140
- }));
159
+ .pipeTo(
160
+ new WritableStream({
161
+ write(chunk) {
162
+ controller.error(new Error(chunk));
163
+ },
164
+ })
165
+ )
166
+ .catch((e) => {
167
+ void e;
168
+ });
141
169
  await process.exit;
142
- controller.close();
143
170
  });
144
171
  }
145
172
  }
@@ -148,7 +175,7 @@ export class BugReportZ extends AdbCommandBase {
148
175
  export class BugReport extends AdbCommandBase {
149
176
  public generate(): ReadableStream<Uint8Array> {
150
177
  return new WrapReadableStream(async () => {
151
- const process = await this.adb.subprocess.spawn(['bugreport']);
178
+ const process = await this.adb.subprocess.spawn(["bugreport"]);
152
179
  return process.stdout;
153
180
  });
154
181
  }