mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-05 02:39:26 +02:00
feat: move more things to stream
This commit is contained in:
parent
68774620c3
commit
7f94da06e7
25 changed files with 478 additions and 398 deletions
|
@ -6,7 +6,7 @@ import { AdbChildProcess, AdbFrameBuffer, AdbPower, AdbReverseCommand, AdbSync,
|
|||
import { AdbFeatures } from './features';
|
||||
import { AdbCommand } from './packet';
|
||||
import { AdbLogger, AdbPacketDispatcher, AdbSocket } from './socket';
|
||||
import { decodeUtf8 } from "./utils";
|
||||
import { decodeUtf8, ReadableStream } from "./utils";
|
||||
|
||||
export enum AdbPropKey {
|
||||
Product = 'ro.product.name',
|
||||
|
@ -208,7 +208,7 @@ export class Adb {
|
|||
}
|
||||
|
||||
public async install(
|
||||
apk: ArrayLike<number> | ArrayBufferLike | AsyncIterable<ArrayBuffer>,
|
||||
apk: ReadableStream<ArrayBuffer>,
|
||||
onProgress?: (uploaded: number) => void,
|
||||
): Promise<void> {
|
||||
return await install(this, apk, onProgress);
|
||||
|
@ -229,13 +229,11 @@ export class Adb {
|
|||
|
||||
public async createSocketAndReadAll(service: string): Promise<string> {
|
||||
const socket = await this.createSocket(service);
|
||||
const resolver = new PromiseResolver<string>();
|
||||
let result = '';
|
||||
socket.onData(buffer => {
|
||||
result += decodeUtf8(buffer);
|
||||
});
|
||||
socket.onClose(() => resolver.resolve(result));
|
||||
return resolver.promise;
|
||||
for await (const chunk of socket.readable) {
|
||||
result += decodeUtf8(chunk);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public async dispose(): Promise<void> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue