mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-03 09:49:24 +02:00
feat(adb): support connect to adb server (#549)
This commit is contained in:
parent
c34eef1d89
commit
3beaad2055
111 changed files with 2926 additions and 1701 deletions
|
@ -38,10 +38,6 @@ import {
|
|||
import type { AdbScrcpyConnection } from "./connection.js";
|
||||
import type { AdbScrcpyOptions } from "./options/index.js";
|
||||
|
||||
const NOOP = () => {
|
||||
// no-op
|
||||
};
|
||||
|
||||
function arrayToStream<T>(array: T[]): ReadableStream<T> {
|
||||
return new PushReadableStream(async (controller) => {
|
||||
for (const item of array) {
|
||||
|
@ -53,13 +49,14 @@ function arrayToStream<T>(array: T[]): ReadableStream<T> {
|
|||
function concatStreams<T>(...streams: ReadableStream<T>[]): ReadableStream<T> {
|
||||
return new PushReadableStream(async (controller) => {
|
||||
for (const stream of streams) {
|
||||
await stream.pipeTo(
|
||||
new WritableStream({
|
||||
async write(chunk) {
|
||||
await controller.enqueue(chunk);
|
||||
},
|
||||
})
|
||||
);
|
||||
const reader = stream.getReader();
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) {
|
||||
break;
|
||||
}
|
||||
await controller.enqueue(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -178,7 +175,13 @@ export class AdbScrcpyClient {
|
|||
preventCancel: true,
|
||||
}
|
||||
)
|
||||
.catch(NOOP);
|
||||
.catch((e) => {
|
||||
if (abortController.signal.aborted) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw e;
|
||||
});
|
||||
|
||||
const streams = await Promise.race([
|
||||
process.exit.then(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue