chore: prefer top-level type import

Prepare for TypeScript 5.0 verbatimModuleSyntax option
This commit is contained in:
Simon Chan 2023-02-23 15:59:32 +08:00
parent 2c5282bc41
commit 6f1be248fb
81 changed files with 345 additions and 404 deletions

View file

@ -1,15 +1,11 @@
import {
AdbPacket,
AdbPacketSerializeStream,
type AdbBackend,
} from "@yume-chan/adb";
import type { AdbBackend } from "@yume-chan/adb";
import { AdbPacket, AdbPacketSerializeStream } from "@yume-chan/adb";
import type { ReadableStream, WritableStream } from "@yume-chan/stream-extra";
import {
StructDeserializeStream,
WrapReadableStream,
WrapWritableStream,
pipeFrom,
type ReadableStream,
type WritableStream,
} from "@yume-chan/stream-extra";
declare global {

View file

@ -1,21 +1,14 @@
import {
AdbPacketHeader,
AdbPacketSerializeStream,
type AdbBackend,
type AdbPacketData,
type AdbPacketInit,
} from "@yume-chan/adb";
import type { AdbBackend, AdbPacketData, AdbPacketInit } from "@yume-chan/adb";
import { AdbPacketHeader, AdbPacketSerializeStream } from "@yume-chan/adb";
import type { ReadableWritablePair } from "@yume-chan/stream-extra";
import {
DuplexStreamFactory,
ReadableStream,
WritableStream,
pipeFrom,
type ReadableWritablePair,
} from "@yume-chan/stream-extra";
import {
EMPTY_UINT8_ARRAY,
type StructDeserializeStream,
} from "@yume-chan/struct";
import type { StructDeserializeStream } from "@yume-chan/struct";
import { EMPTY_UINT8_ARRAY } from "@yume-chan/struct";
/**
* `classCode`, `subclassCode` and `protocolCode` are required

View file

@ -1,8 +1,5 @@
import {
AdbPacket,
AdbPacketSerializeStream,
type AdbBackend,
} from "@yume-chan/adb";
import type { AdbBackend } from "@yume-chan/adb";
import { AdbPacket, AdbPacketSerializeStream } from "@yume-chan/adb";
import {
DuplexStreamFactory,
ReadableStream,

View file

@ -1,5 +1,6 @@
// cspell: ignore RSASSA
import type { AdbCredentialStore } from "@yume-chan/adb";
import {
calculateBase64EncodedLength,
calculatePublicKey,
@ -7,7 +8,6 @@ import {
decodeBase64,
decodeUtf8,
encodeBase64,
type AdbCredentialStore,
} from "@yume-chan/adb";
export default class AdbWebCredentialStore implements AdbCredentialStore {

View file

@ -1,17 +1,18 @@
import { PromiseResolver } from "@yume-chan/async";
import type { ReadableWritablePair } from "@yume-chan/stream-extra";
import {
AbortController,
DecodeUtf8Stream,
GatherStringStream,
WritableStream,
type ReadableWritablePair,
} from "@yume-chan/stream-extra";
import type { AdbCredentialStore } from "./auth.js";
import {
ADB_DEFAULT_AUTHENTICATORS,
AdbAuthenticationProcessor,
type AdbCredentialStore,
} from "./auth.js";
import type { AdbFrameBuffer } from "./commands/index.js";
import {
AdbPower,
AdbReverseCommand,
@ -21,21 +22,16 @@ import {
escapeArg,
framebuffer,
install,
type AdbFrameBuffer,
} from "./commands/index.js";
import { AdbFeatures } from "./features.js";
import {
AdbCommand,
calculateChecksum,
type AdbPacketData,
type AdbPacketInit,
} from "./packet.js";
import {
AdbPacketDispatcher,
type AdbIncomingSocketHandler,
type AdbSocket,
type Closeable,
import type { AdbPacketData, AdbPacketInit } from "./packet.js";
import { AdbCommand, calculateChecksum } from "./packet.js";
import type {
AdbIncomingSocketHandler,
AdbSocket,
Closeable,
} from "./socket/index.js";
import { AdbPacketDispatcher } from "./socket/index.js";
import { decodeUtf8, encodeUtf8 } from "./utils/index.js";
export enum AdbPropKey {

View file

@ -1,13 +1,14 @@
import { PromiseResolver } from "@yume-chan/async";
import { type Disposable } from "@yume-chan/event";
import { type ValueOrPromise } from "@yume-chan/struct";
import type { Disposable } from "@yume-chan/event";
import type { ValueOrPromise } from "@yume-chan/struct";
import {
calculatePublicKey,
calculatePublicKeyLength,
sign,
} from "./crypto.js";
import { AdbCommand, type AdbPacketData } from "./packet.js";
import type { AdbPacketData } from "./packet.js";
import { AdbCommand } from "./packet.js";
import { calculateBase64EncodedLength, encodeBase64 } from "./utils/index.js";
export type AdbKeyIterable = Iterable<Uint8Array> | AsyncIterable<Uint8Array>;

View file

@ -1,7 +1,7 @@
import { type ReadableWritablePair } from "@yume-chan/stream-extra";
import { type ValueOrPromise } from "@yume-chan/struct";
import type { ReadableWritablePair } from "@yume-chan/stream-extra";
import type { ValueOrPromise } from "@yume-chan/struct";
import { type AdbPacketData, type AdbPacketInit } from "./packet.js";
import type { AdbPacketData, AdbPacketInit } from "./packet.js";
export interface AdbBackend {
readonly serial: string;

View file

@ -1,6 +1,6 @@
import { AutoDisposable } from "@yume-chan/event";
import { type Adb } from "../adb.js";
import type { Adb } from "../adb.js";
export class AdbCommandBase extends AutoDisposable {
protected adb: Adb;

View file

@ -1,7 +1,7 @@
import { BufferedReadableStream } from "@yume-chan/stream-extra";
import Struct from "@yume-chan/struct";
import { type Adb } from "../adb.js";
import type { Adb } from "../adb.js";
const Version = new Struct({ littleEndian: true }).uint32("version");

View file

@ -1,12 +1,10 @@
import {
WrapWritableStream,
type WritableStream,
} from "@yume-chan/stream-extra";
import type { WritableStream } from "@yume-chan/stream-extra";
import { WrapWritableStream } from "@yume-chan/stream-extra";
import { type Adb } from "../adb.js";
import type { Adb } from "../adb.js";
import { escapeArg } from "./subprocess/index.js";
import { type AdbSync } from "./sync/index.js";
import type { AdbSync } from "./sync/index.js";
export function install(adb: Adb): WritableStream<Uint8Array> {
const filename = `/data/local/tmp/${Math.random()

View file

@ -7,11 +7,8 @@ import {
} from "@yume-chan/stream-extra";
import Struct from "@yume-chan/struct";
import { type Adb } from "../adb.js";
import {
type AdbIncomingSocketHandler,
type AdbSocket,
} from "../socket/index.js";
import type { Adb } from "../adb.js";
import type { AdbIncomingSocketHandler, AdbSocket } from "../socket/index.js";
import { decodeUtf8 } from "../utils/index.js";
export interface AdbForwardListener {

View file

@ -2,11 +2,13 @@ import { DecodeUtf8Stream, GatherStringStream } from "@yume-chan/stream-extra";
import { AdbCommandBase } from "../base.js";
import type {
AdbSubprocessProtocol,
AdbSubprocessProtocolConstructor,
} from "./protocols/index.js";
import {
AdbSubprocessNoneProtocol,
AdbSubprocessShellProtocol,
type AdbSubprocessProtocol,
type AdbSubprocessProtocolConstructor,
} from "./protocols/index.js";
export interface AdbSubprocessOptions {

View file

@ -1,9 +1,9 @@
import { DuplexStreamFactory, ReadableStream } from '@yume-chan/stream-extra';
import { DuplexStreamFactory, ReadableStream } from "@yume-chan/stream-extra";
import { type Adb } from "../../../adb.js";
import { type AdbSocket } from "../../../socket/index.js";
import type { Adb } from "../../../adb.js";
import type { AdbSocket } from "../../../socket/index.js";
import { type AdbSubprocessProtocol } from "./types.js";
import type { AdbSubprocessProtocol } from "./types.js";
/**
* The legacy shell

View file

@ -1,4 +1,9 @@
import { PromiseResolver } from '@yume-chan/async';
import { PromiseResolver } from "@yume-chan/async";
import type {
PushReadableStreamController,
ReadableStream,
WritableStreamDefaultWriter,
} from "@yume-chan/stream-extra";
import {
PushReadableStream,
StructDeserializeStream,
@ -6,18 +11,16 @@ import {
TransformStream,
WritableStream,
pipeFrom,
type PushReadableStreamController,
type ReadableStream,
type WritableStreamDefaultWriter,
} from "@yume-chan/stream-extra";
import Struct, { placeholder, type StructValueType } from '@yume-chan/struct';
import type { StructValueType } from "@yume-chan/struct";
import Struct, { placeholder } from "@yume-chan/struct";
import { type Adb } from "../../../adb.js";
import type { Adb } from "../../../adb.js";
import { AdbFeatures } from "../../../features.js";
import { type AdbSocket } from "../../../socket/index.js";
import type { AdbSocket } from "../../../socket/index.js";
import { encodeUtf8 } from "../../../utils/index.js";
import { type AdbSubprocessProtocol } from "./types.js";
import type { AdbSubprocessProtocol } from "./types.js";
export enum AdbShellProtocolId {
Stdin,

View file

@ -1,11 +1,8 @@
import {
type ReadableStream,
type WritableStream,
} from "@yume-chan/stream-extra";
import { type ValueOrPromise } from "@yume-chan/struct";
import type { ReadableStream, WritableStream } from "@yume-chan/stream-extra";
import type { ValueOrPromise } from "@yume-chan/struct";
import { type Adb } from "../../../adb.js";
import { type AdbSocket } from "../../../socket/index.js";
import type { Adb } from "../../../adb.js";
import type { AdbSocket } from "../../../socket/index.js";
export interface AdbSubprocessProtocol {
/**

View file

@ -1,16 +1,13 @@
import {
type BufferedReadableStream,
type WritableStreamDefaultWriter,
import type {
BufferedReadableStream,
WritableStreamDefaultWriter,
} from "@yume-chan/stream-extra";
import Struct from "@yume-chan/struct";
import { AdbSyncRequestId, adbSyncWriteRequest } from "./request.js";
import { AdbSyncResponseId, adbSyncReadResponses } from "./response.js";
import {
AdbSyncLstatResponse,
AdbSyncStatResponse,
type AdbSyncStat,
} from "./stat.js";
import type { AdbSyncStat } from "./stat.js";
import { AdbSyncLstatResponse, AdbSyncStatResponse } from "./stat.js";
export interface AdbSyncEntry extends AdbSyncStat {
name: string;

View file

@ -1,8 +1,8 @@
import {
ReadableStream,
type BufferedReadableStream,
type WritableStreamDefaultWriter,
import type {
BufferedReadableStream,
WritableStreamDefaultWriter,
} from "@yume-chan/stream-extra";
import { ReadableStream } from "@yume-chan/stream-extra";
import Struct from "@yume-chan/struct";
import { AdbSyncRequestId, adbSyncWriteRequest } from "./request.js";

View file

@ -1,10 +1,8 @@
import {
ChunkStream,
WritableStream,
pipeFrom,
type BufferedReadableStream,
type WritableStreamDefaultWriter,
import type {
BufferedReadableStream,
WritableStreamDefaultWriter,
} from "@yume-chan/stream-extra";
import { ChunkStream, WritableStream, pipeFrom } from "@yume-chan/stream-extra";
import Struct from "@yume-chan/struct";
import { AdbSyncRequestId, adbSyncWriteRequest } from "./request.js";

View file

@ -1,4 +1,4 @@
import { type WritableStreamDefaultWriter } from "@yume-chan/stream-extra";
import type { WritableStreamDefaultWriter } from "@yume-chan/stream-extra";
import Struct from "@yume-chan/struct";
import { encodeUtf8 } from "../../utils/index.js";

View file

@ -1,8 +1,6 @@
import { type BufferedReadableStream } from "@yume-chan/stream-extra";
import Struct, {
type StructLike,
type StructValueType,
} from "@yume-chan/struct";
import type { BufferedReadableStream } from "@yume-chan/stream-extra";
import type { StructLike, StructValueType } from "@yume-chan/struct";
import Struct from "@yume-chan/struct";
import { decodeUtf8 } from "../../utils/index.js";

View file

@ -1,6 +1,6 @@
import {
type BufferedReadableStream,
type WritableStreamDefaultWriter,
import type {
BufferedReadableStream,
WritableStreamDefaultWriter,
} from "@yume-chan/stream-extra";
import Struct, { placeholder } from "@yume-chan/struct";

View file

@ -1,20 +1,23 @@
import { AutoDisposable } from "@yume-chan/event";
import type {
ReadableStream,
WritableStream,
WritableStreamDefaultWriter,
} from "@yume-chan/stream-extra";
import {
BufferedReadableStream,
WrapReadableStream,
WrapWritableStream,
type ReadableStream,
type WritableStream,
type WritableStreamDefaultWriter,
} from "@yume-chan/stream-extra";
import { type Adb } from "../../adb.js";
import type { Adb } from "../../adb.js";
import { AdbFeatures } from "../../features.js";
import { type AdbSocket } from "../../socket/index.js";
import type { AdbSocket } from "../../socket/index.js";
import { AutoResetEvent } from "../../utils/index.js";
import { escapeArg } from "../subprocess/index.js";
import { adbSyncOpenDir, type AdbSyncEntry } from "./list.js";
import type { AdbSyncEntry } from "./list.js";
import { adbSyncOpenDir } from "./list.js";
import { adbSyncPull } from "./pull.js";
import { adbSyncPush } from "./push.js";
import { adbSyncLstat, adbSyncStat } from "./stat.js";

View file

@ -1,22 +1,19 @@
import { AsyncOperationManager, PromiseResolver } from "@yume-chan/async";
import { type RemoveEventListener } from "@yume-chan/event";
import {
AbortController,
WritableStream,
type ReadableWritablePair,
type WritableStreamDefaultWriter,
import type { RemoveEventListener } from "@yume-chan/event";
import type {
ReadableWritablePair,
WritableStreamDefaultWriter,
} from "@yume-chan/stream-extra";
import { EMPTY_UINT8_ARRAY, type ValueOrPromise } from "@yume-chan/struct";
import { AbortController, WritableStream } from "@yume-chan/stream-extra";
import type { ValueOrPromise } from "@yume-chan/struct";
import { EMPTY_UINT8_ARRAY } from "@yume-chan/struct";
import {
AdbCommand,
calculateChecksum,
type AdbPacketData,
type AdbPacketInit,
} from "../packet.js";
import type { AdbPacketData, AdbPacketInit } from "../packet.js";
import { AdbCommand, calculateChecksum } from "../packet.js";
import { decodeUtf8, encodeUtf8 } from "../utils/index.js";
import { AdbSocketController, type AdbSocket } from "./socket.js";
import type { AdbSocket } from "./socket.js";
import { AdbSocketController } from "./socket.js";
export interface AdbPacketDispatcherOptions {
calculateChecksum: boolean;

View file

@ -1,19 +1,21 @@
import { PromiseResolver } from "@yume-chan/async";
import { type Disposable } from "@yume-chan/event";
import type { Disposable } from "@yume-chan/event";
import type {
PushReadableStreamController,
ReadableStream,
ReadableWritablePair,
} from "@yume-chan/stream-extra";
import {
ChunkStream,
DuplexStreamFactory,
PushReadableStream,
WritableStream,
pipeFrom,
type PushReadableStreamController,
type ReadableStream,
type ReadableWritablePair,
} from "@yume-chan/stream-extra";
import { AdbCommand } from "../packet.js";
import { type AdbPacketDispatcher, type Closeable } from "./dispatcher.js";
import type { AdbPacketDispatcher, Closeable } from "./dispatcher.js";
export interface AdbSocketInfo {
localId: number;

View file

@ -1,5 +1,5 @@
import { PromiseResolver } from "@yume-chan/async";
import { type Disposable } from "@yume-chan/event";
import type { Disposable } from "@yume-chan/event";
export class AutoResetEvent implements Disposable {
private _set: boolean;

View file

@ -1,5 +1,5 @@
import { PromiseResolver } from "@yume-chan/async";
import { type Disposable } from "@yume-chan/event";
import type { Disposable } from "@yume-chan/event";
interface WaitEntry {
condition: () => boolean;

View file

@ -2,13 +2,13 @@
// cspell: ignore bugreportz
import { AdbCommandBase, AdbSubprocessShellProtocol } from "@yume-chan/adb";
import type { ReadableStream } from "@yume-chan/stream-extra";
import {
DecodeUtf8Stream,
PushReadableStream,
SplitStringStream,
WrapReadableStream,
WritableStream,
type ReadableStream,
} from "@yume-chan/stream-extra";
export interface BugReportZVersion {

View file

@ -4,7 +4,8 @@
// cspell: ignore systemui
// cspell: ignore sysui
import { AdbCommandBase, type Adb } from "@yume-chan/adb";
import type { Adb } from "@yume-chan/adb";
import { AdbCommandBase } from "@yume-chan/adb";
import { Settings } from "./settings.js";

View file

@ -2,18 +2,16 @@
// cspell: ignore usec
import { AdbCommandBase, AdbSubprocessNoneProtocol } from "@yume-chan/adb";
import type { ReadableStream } from "@yume-chan/stream-extra";
import {
BufferedTransformStream,
DecodeUtf8Stream,
SplitStringStream,
WrapReadableStream,
WritableStream,
type ReadableStream,
} from "@yume-chan/stream-extra";
import Struct, {
decodeUtf8,
type StructAsyncDeserializeStream,
} from "@yume-chan/struct";
import type { StructAsyncDeserializeStream } from "@yume-chan/struct";
import Struct, { decodeUtf8 } from "@yume-chan/struct";
// `adb logcat` is an alias to `adb shell logcat`
// so instead of adding to core library, it's implemented here

View file

@ -1,4 +1,5 @@
import { AdbCommandBase, type Adb } from "@yume-chan/adb";
import type { Adb } from "@yume-chan/adb";
import { AdbCommandBase } from "@yume-chan/adb";
import { Settings } from "./settings.js";

View file

@ -1,6 +1,7 @@
import { describe, expect, it } from "@jest/globals";
import { BTree, type BTreeNode } from "./index.js";
import type { BTreeNode } from "./index.js";
import { BTree } from "./index.js";
const LENGTH = 128;

View file

@ -1,6 +1,7 @@
import { describe, expect, it, jest } from "@jest/globals";
import { AutoDisposable, type Disposable } from "./disposable.js";
import type { Disposable } from "./disposable.js";
import { AutoDisposable } from "./disposable.js";
describe("Event", () => {
describe("AutoDisposable", () => {

View file

@ -1,5 +1,5 @@
import { type Disposable } from "./disposable.js";
import { type EventListener, type RemoveEventListener } from "./event.js";
import type { Disposable } from "./disposable.js";
import type { EventListener, RemoveEventListener } from "./event.js";
export interface EventListenerInfo<TEvent, TResult = unknown> {
listener: EventListener<TEvent, unknown, unknown[], TResult>;

View file

@ -1,4 +1,4 @@
import { type Disposable } from "./disposable.js";
import type { Disposable } from "./disposable.js";
export interface EventListener<
TEvent,

View file

@ -1,6 +1,6 @@
import { PromiseResolver } from "@yume-chan/async";
import { type Event } from "./event.js";
import type { Event } from "./event.js";
export async function once<T>(event: Event<T, unknown>): Promise<T> {
const resolver = new PromiseResolver<T>();

View file

@ -1,10 +1,13 @@
import type { Adb, AdbSubprocessProtocol, AdbSync } from "@yume-chan/adb";
import {
AdbReverseNotSupportedError,
AdbSubprocessNoneProtocol,
type Adb,
type AdbSubprocessProtocol,
type AdbSync,
} from "@yume-chan/adb";
import type {
ReadableStreamDefaultController,
ReadableStreamDefaultReader,
ReadableWritablePair,
} from "@yume-chan/stream-extra";
import {
AbortController,
DecodeUtf8Stream,
@ -13,24 +16,19 @@ import {
SplitStringStream,
WrapWritableStream,
WritableStream,
type ReadableStreamDefaultController,
type ReadableStreamDefaultReader,
type ReadableWritablePair,
} from "@yume-chan/stream-extra";
import { ScrcpyControlMessageSerializer } from "../control/index.js";
import {
ScrcpyDeviceMessageDeserializeStream,
type ScrcpyDeviceMessage,
} from "../device-message/index.js";
import {
DEFAULT_SERVER_PATH,
type ScrcpyOptionsInit1_16,
type ScrcpyVideoStreamPacket,
import type { ScrcpyDeviceMessage } from "../device-message/index.js";
import { ScrcpyDeviceMessageDeserializeStream } from "../device-message/index.js";
import type {
ScrcpyOptionsInit1_16,
ScrcpyVideoStreamPacket,
} from "../options/index.js";
import { DEFAULT_SERVER_PATH } from "../options/index.js";
import { type AdbScrcpyConnection } from "./connection.js";
import { type AdbScrcpyOptions } from "./options/index.js";
import type { AdbScrcpyConnection } from "./connection.js";
import type { AdbScrcpyOptions } from "./options/index.js";
class ArrayToStream<T> extends ReadableStream<T> {
private array!: T[];

View file

@ -1,13 +1,14 @@
import { AdbReverseNotSupportedError, type Adb } from "@yume-chan/adb";
import type { Adb } from "@yume-chan/adb";
import { AdbReverseNotSupportedError } from "@yume-chan/adb";
import { delay } from "@yume-chan/async";
import { type Disposable } from "@yume-chan/event";
import {
TransformStream,
type ReadableStream,
type ReadableStreamDefaultReader,
type ReadableWritablePair,
import type { Disposable } from "@yume-chan/event";
import type {
ReadableStream,
ReadableStreamDefaultReader,
ReadableWritablePair,
} from "@yume-chan/stream-extra";
import { type ValueOrPromise } from "@yume-chan/struct";
import { TransformStream } from "@yume-chan/stream-extra";
import type { ValueOrPromise } from "@yume-chan/struct";
export interface AdbScrcpyConnectionOptions {
control: boolean;

View file

@ -1,11 +1,13 @@
import { type Adb } from "@yume-chan/adb";
import type { Adb } from "@yume-chan/adb";
import { type ScrcpyOptionsInit1_16 } from "../../options/index.js";
import type { ScrcpyOptionsInit1_16 } from "../../options/index.js";
import type {
AdbScrcpyConnection,
AdbScrcpyConnectionOptions,
} from "../connection.js";
import {
AdbScrcpyForwardConnection,
AdbScrcpyReverseConnection,
type AdbScrcpyConnection,
type AdbScrcpyConnectionOptions,
} from "../connection.js";
import { AdbScrcpyOptionsBase } from "./types.js";

View file

@ -1,10 +1,10 @@
import { type Adb } from "@yume-chan/adb";
import type { Adb } from "@yume-chan/adb";
import { type ScrcpyOptionsInit1_22 } from "../../options/index.js";
import type { ScrcpyOptionsInit1_22 } from "../../options/index.js";
import type { AdbScrcpyConnection } from "../connection.js";
import {
AdbScrcpyForwardConnection,
AdbScrcpyReverseConnection,
type AdbScrcpyConnection,
} from "../connection.js";
import { AdbScrcpyOptions1_16 } from "./1_16.js";

View file

@ -1,16 +1,16 @@
import { type Adb } from "@yume-chan/adb";
import { type TransformStream } from "@yume-chan/stream-extra";
import type { Adb } from "@yume-chan/adb";
import type { TransformStream } from "@yume-chan/stream-extra";
import {
type ScrcpyBackOrScreenOnControlMessage,
type ScrcpyControlMessageType,
type ScrcpySetClipboardControlMessage,
import type {
ScrcpyBackOrScreenOnControlMessage,
ScrcpyControlMessageType,
ScrcpySetClipboardControlMessage,
} from "../../control/index.js";
import {
type ScrcpyOptions,
type ScrcpyVideoStreamPacket,
import type {
ScrcpyOptions,
ScrcpyVideoStreamPacket,
} from "../../options/index.js";
import { type AdbScrcpyConnection } from "../connection.js";
import type { AdbScrcpyConnection } from "../connection.js";
export interface AdbScrcpyOptions<T extends object> extends ScrcpyOptions<T> {
createConnection(adb: Adb): AdbScrcpyConnection;

View file

@ -1,4 +1,4 @@
import { type ScrcpyBackOrScreenOnControlMessage1_18 } from "../index.js";
import type { ScrcpyBackOrScreenOnControlMessage1_18 } from "../index.js";
export type ScrcpyBackOrScreenOnControlMessage =
ScrcpyBackOrScreenOnControlMessage1_18;

View file

@ -1,7 +1,5 @@
import {
AndroidMotionEventAction,
type ScrcpyInjectTouchControlMessage,
} from "./inject-touch.js";
import type { ScrcpyInjectTouchControlMessage } from "./inject-touch.js";
import { AndroidMotionEventAction } from "./inject-touch.js";
import { ScrcpyControlMessageType } from "./type.js";
/**

View file

@ -1,4 +1,4 @@
import { type ScrcpyInjectScrollControlMessage1_25 } from "../options/index.js";
import type { ScrcpyInjectScrollControlMessage1_25 } from "../options/index.js";
export type ScrcpyInjectScrollControlMessage =
ScrcpyInjectScrollControlMessage1_25;

View file

@ -1,26 +1,22 @@
import {
type WritableStream,
type WritableStreamDefaultWriter,
import type {
WritableStream,
WritableStreamDefaultWriter,
} from "@yume-chan/stream-extra";
import {
type ScrcpyOptions,
type ScrcpyOptionsInit1_16,
type ScrcpyScrollController,
import type {
ScrcpyOptions,
ScrcpyOptionsInit1_16,
ScrcpyScrollController,
} from "../options/index.js";
import {
ScrcpyInjectKeyCodeControlMessage,
type AndroidKeyEventAction,
} from "./inject-keycode.js";
import { type ScrcpyInjectScrollControlMessage } from "./inject-scroll.js";
import type { AndroidKeyEventAction } from "./inject-keycode.js";
import { ScrcpyInjectKeyCodeControlMessage } from "./inject-keycode.js";
import type { ScrcpyInjectScrollControlMessage } from "./inject-scroll.js";
import { ScrcpyInjectTextControlMessage } from "./inject-text.js";
import { ScrcpyInjectTouchControlMessage } from "./inject-touch.js";
import { ScrcpyRotateDeviceControlMessage } from "./rotate-device.js";
import {
ScrcpySetScreenPowerModeControlMessage,
type AndroidScreenPowerMode,
} from "./set-screen-power-mode.js";
import type { AndroidScreenPowerMode } from "./set-screen-power-mode.js";
import { ScrcpySetScreenPowerModeControlMessage } from "./set-screen-power-mode.js";
import { ScrcpyControlMessageType } from "./type.js";
export class ScrcpyControlMessageSerializer {

View file

@ -1,4 +1,4 @@
import { type ScrcpySetClipboardControlMessage1_21 } from "../options/index.js";
import type { ScrcpySetClipboardControlMessage1_21 } from "../options/index.js";
export type ScrcpySetClipboardControlMessage =
ScrcpySetClipboardControlMessage1_21;

View file

@ -1,8 +1,5 @@
import {
type AndroidCodecLevel,
type AndroidCodecProfile,
} from "../../codec.js";
import { type ScrcpyOptionValue } from "../types.js";
import type { AndroidCodecLevel, AndroidCodecProfile } from "../../codec.js";
import type { ScrcpyOptionValue } from "../types.js";
/**
* If the option you need is not in this type,

View file

@ -4,17 +4,16 @@ import {
} from "@yume-chan/stream-extra";
import Struct from "@yume-chan/struct";
import type {
ScrcpyBackOrScreenOnControlMessage,
ScrcpySetClipboardControlMessage,
} from "../../control/index.js";
import {
AndroidKeyEventAction,
ScrcpyControlMessageType,
type ScrcpyBackOrScreenOnControlMessage,
type ScrcpySetClipboardControlMessage,
} from "../../control/index.js";
import {
toScrcpyOptionValue,
type ScrcpyOptions,
type ScrcpyVideoStreamPacket,
} from "../types.js";
import type { ScrcpyOptions, ScrcpyVideoStreamPacket } from "../types.js";
import { toScrcpyOptionValue } from "../types.js";
import { CodecOptions } from "./codec-options.js";
import {
@ -22,10 +21,8 @@ import {
parseSequenceParameterSet,
removeH264Emulation,
} from "./h264-configuration.js";
import {
ScrcpyScrollController1_16,
type ScrcpyScrollController,
} from "./scroll.js";
import type { ScrcpyScrollController } from "./scroll.js";
import { ScrcpyScrollController1_16 } from "./scroll.js";
export enum ScrcpyLogLevel {
Verbose = "verbose",

View file

@ -1,9 +1,7 @@
import Struct from "@yume-chan/struct";
import {
ScrcpyControlMessageType,
type ScrcpyInjectScrollControlMessage,
} from "../../control/index.js";
import type { ScrcpyInjectScrollControlMessage } from "../../control/index.js";
import { ScrcpyControlMessageType } from "../../control/index.js";
export interface ScrcpyScrollController {
serializeScrollMessage(

View file

@ -1,15 +1,15 @@
import Struct, { placeholder } from "@yume-chan/struct";
import {
ScrcpyControlMessageType,
type AndroidKeyEventAction,
type ScrcpyBackOrScreenOnControlMessage,
import type {
AndroidKeyEventAction,
ScrcpyBackOrScreenOnControlMessage,
} from "../control/index.js";
import { ScrcpyControlMessageType } from "../control/index.js";
import type { ScrcpyOptionsInit1_16 } from "./1_16/options.js";
import {
ScrcpyBackOrScreenOnControlMessage1_16,
ScrcpyOptions1_16,
type ScrcpyOptionsInit1_16,
} from "./1_16/options.js";
export interface ScrcpyOptionsInit1_18 extends ScrcpyOptionsInit1_16 {

View file

@ -2,12 +2,11 @@
import Struct from "@yume-chan/struct";
import {
ScrcpyControlMessageType,
type ScrcpySetClipboardControlMessage,
} from "../control/index.js";
import type { ScrcpySetClipboardControlMessage } from "../control/index.js";
import { ScrcpyControlMessageType } from "../control/index.js";
import { ScrcpyOptions1_18, type ScrcpyOptionsInit1_18 } from "./1_18.js";
import type { ScrcpyOptionsInit1_18 } from "./1_18.js";
import { ScrcpyOptions1_18 } from "./1_18.js";
import { toScrcpyOptionValue } from "./types.js";
export interface ScrcpyOptionsInit1_21 extends ScrcpyOptionsInit1_18 {

View file

@ -1,5 +1,6 @@
import { type ScrcpyScrollController } from "../1_16/index.js";
import { ScrcpyOptions1_21, type ScrcpyOptionsInit1_21 } from "../1_21.js";
import type { ScrcpyScrollController } from "../1_16/index.js";
import type { ScrcpyOptionsInit1_21 } from "../1_21.js";
import { ScrcpyOptions1_21 } from "../1_21.js";
import { ScrcpyScrollController1_22 } from "./scroll.js";

View file

@ -1,10 +1,8 @@
import { TransformStream } from "@yume-chan/stream-extra";
import {
ScrcpyOptions1_22,
type ScrcpyOptionsInit1_22,
} from "./1_22/options.js";
import { type ScrcpyVideoStreamPacket } from "./types.js";
import type { ScrcpyOptionsInit1_22 } from "./1_22/options.js";
import { ScrcpyOptions1_22 } from "./1_22/options.js";
import type { ScrcpyVideoStreamPacket } from "./types.js";
export interface ScrcpyOptionsInit1_23 extends ScrcpyOptionsInit1_22 {
cleanup: boolean;

View file

@ -1,11 +1,13 @@
import { ScrcpyOptions1_23, type ScrcpyOptionsInit1_23 } from './1_23.js';
import type { ScrcpyOptionsInit1_23 } from "./1_23.js";
import { ScrcpyOptions1_23 } from "./1_23.js";
export interface ScrcpyOptionsInit1_24 extends ScrcpyOptionsInit1_23 {
powerOn: boolean;
}
export class ScrcpyOptions1_24<T extends ScrcpyOptionsInit1_24 = ScrcpyOptionsInit1_24>
extends ScrcpyOptions1_23<T> {
export class ScrcpyOptions1_24<
T extends ScrcpyOptionsInit1_24 = ScrcpyOptionsInit1_24
> extends ScrcpyOptions1_23<T> {
public constructor(init: Partial<ScrcpyOptionsInit1_24>) {
super(init);
}

View file

@ -1,5 +1,6 @@
import { type ScrcpyScrollController } from "../1_16/index.js";
import { ScrcpyOptions1_24, type ScrcpyOptionsInit1_24 } from "../1_24.js";
import type { ScrcpyScrollController } from "../1_16/index.js";
import type { ScrcpyOptionsInit1_24 } from "../1_24.js";
import { ScrcpyOptions1_24 } from "../1_24.js";
import { ScrcpyScrollController1_25 } from "./scroll.js";

View file

@ -3,12 +3,9 @@ import Struct, {
NumberFieldType,
} from "@yume-chan/struct";
import {
clamp,
ScrcpyControlMessageType,
type ScrcpyInjectScrollControlMessage,
} from "../../control/index.js";
import { type ScrcpyScrollController } from "../1_16/index.js";
import type { ScrcpyInjectScrollControlMessage } from "../../control/index.js";
import { clamp, ScrcpyControlMessageType } from "../../control/index.js";
import type { ScrcpyScrollController } from "../1_16/index.js";
export const ScrcpyFloatToInt16NumberType: NumberFieldType = {
size: 2,

View file

@ -1,12 +1,12 @@
import { type TransformStream } from "@yume-chan/stream-extra";
import type { TransformStream } from "@yume-chan/stream-extra";
import {
type ScrcpyBackOrScreenOnControlMessage,
type ScrcpyControlMessageType,
type ScrcpySetClipboardControlMessage,
import type {
ScrcpyBackOrScreenOnControlMessage,
ScrcpyControlMessageType,
ScrcpySetClipboardControlMessage,
} from "../control/index.js";
import { type ScrcpyScrollController } from "./1_16/scroll.js";
import type { ScrcpyScrollController } from "./1_16/scroll.js";
export const DEFAULT_SERVER_PATH = "/data/local/tmp/scrcpy-server.jar";

View file

@ -1,18 +1,13 @@
import { type ValueOrPromise } from "@yume-chan/struct";
import type { ValueOrPromise } from "@yume-chan/struct";
import {
BufferedReadableStream,
BufferedReadableStreamEndedError,
} from "./buffered.js";
import {
PushReadableStream,
type PushReadableStreamController,
} from "./push-readable.js";
import {
ReadableStream,
WritableStream,
type ReadableWritablePair,
} from "./stream.js";
import type { PushReadableStreamController } from "./push-readable.js";
import { PushReadableStream } from "./push-readable.js";
import type { ReadableWritablePair } from "./stream.js";
import { ReadableStream, WritableStream } from "./stream.js";
// TODO: BufferedTransformStream: find better implementation
export class BufferedTransformStream<T>

View file

@ -1,8 +1,5 @@
import { PushReadableStream } from "./push-readable.js";
import {
type ReadableStream,
type ReadableStreamDefaultReader,
} from "./stream.js";
import type { ReadableStream, ReadableStreamDefaultReader } from "./stream.js";
export class BufferedReadableStreamEndedError extends Error {
public constructor() {

View file

@ -1,12 +1,12 @@
import { PromiseResolver } from "@yume-chan/async";
import { type ValueOrPromise } from "@yume-chan/struct";
import type { ValueOrPromise } from "@yume-chan/struct";
import {
WritableStream,
type ReadableStream,
type ReadableStreamDefaultController,
type WritableStreamDefaultWriter,
import type {
ReadableStream,
ReadableStreamDefaultController,
WritableStreamDefaultWriter,
} from "./stream.js";
import { WritableStream } from "./stream.js";
import { WrapReadableStream } from "./wrap-readable.js";
export interface DuplexStreamFactoryOptions {

View file

@ -1,4 +1,5 @@
import { WritableStream, type ReadableWritablePair } from "./stream.js";
import type { ReadableWritablePair } from "./stream.js";
import { WritableStream } from "./stream.js";
/**
* Pipe `pair.readable` to `writable`, then returns `pair.writable`.
@ -9,10 +10,12 @@ import { WritableStream, type ReadableWritablePair } from "./stream.js";
* @param pair A `TransformStream` that converts chunks.
* @returns `pair`'s `writable` stream.
*/
export function pipeFrom<W, T>(writable: WritableStream<W>, pair: ReadableWritablePair<W, T>) {
export function pipeFrom<W, T>(
writable: WritableStream<W>,
pair: ReadableWritablePair<W, T>
) {
const writer = pair.writable.getWriter();
const pipe = pair.readable
.pipeTo(writable);
const pipe = pair.readable.pipeTo(writable);
return new WritableStream<T>({
async write(chunk) {
await writer.ready;
@ -21,6 +24,6 @@ export function pipeFrom<W, T>(writable: WritableStream<W>, pair: ReadableWritab
async close() {
await writer.close();
await pipe;
}
},
});
}

View file

@ -1,11 +1,7 @@
import { PromiseResolver } from "@yume-chan/async";
import {
AbortController,
ReadableStream,
type AbortSignal,
type QueuingStrategy,
} from "./stream.js";
import type { AbortSignal, QueuingStrategy } from "./stream.js";
import { AbortController, ReadableStream } from "./stream.js";
export interface PushReadableStreamController<T> {
abortSignal: AbortSignal;

View file

@ -1,8 +1,8 @@
import type { AbortSignal } from "web-streams-polyfill";
import {
ReadableStream as ReadableStreamPolyfill,
TransformStream as TransformStreamPolyfill,
WritableStream as WritableStreamPolyfill,
type AbortSignal,
} from "web-streams-polyfill";
export * from "web-streams-polyfill";

View file

@ -1,5 +1,5 @@
import type Struct from "@yume-chan/struct";
import { type StructValueType } from "@yume-chan/struct";
import type { StructValueType } from "@yume-chan/struct";
import { BufferedTransformStream } from "./buffered-transform.js";

View file

@ -1,10 +1,10 @@
import { type ValueOrPromise } from "@yume-chan/struct";
import type { ValueOrPromise } from "@yume-chan/struct";
import {
ReadableStream,
type ReadableStreamDefaultController,
type ReadableStreamDefaultReader,
import type {
ReadableStreamDefaultController,
ReadableStreamDefaultReader,
} from "./stream.js";
import { ReadableStream } from "./stream.js";
export type WrapReadableStreamStart<T> = (
controller: ReadableStreamDefaultController<T>

View file

@ -1,6 +1,7 @@
import { type ValueOrPromise } from "@yume-chan/struct";
import type { ValueOrPromise } from "@yume-chan/struct";
import { WritableStream, type WritableStreamDefaultWriter } from "./stream.js";
import type { WritableStreamDefaultWriter } from "./stream.js";
import { WritableStream } from "./stream.js";
export type WrapWritableStreamStart<T> = () => ValueOrPromise<
WritableStream<T>

View file

@ -1,15 +1,15 @@
import { describe, expect, it } from "@jest/globals";
import { type ValueOrPromise } from "../utils.js";
import type { ValueOrPromise } from "../utils.js";
import { StructFieldDefinition } from "./definition.js";
import { type StructFieldValue } from "./field-value.js";
import { type StructOptions } from "./options.js";
import {
type StructAsyncDeserializeStream,
type StructDeserializeStream,
import type { StructFieldValue } from "./field-value.js";
import type { StructOptions } from "./options.js";
import type {
StructAsyncDeserializeStream,
StructDeserializeStream,
} from "./stream.js";
import { type StructValue } from "./struct-value.js";
import type { StructValue } from "./struct-value.js";
describe("StructFieldDefinition", () => {
describe(".constructor", () => {

View file

@ -1,10 +1,10 @@
import { type StructFieldValue } from "./field-value.js";
import { type StructOptions } from "./options.js";
import {
type StructAsyncDeserializeStream,
type StructDeserializeStream,
import type { StructFieldValue } from "./field-value.js";
import type { StructOptions } from "./options.js";
import type {
StructAsyncDeserializeStream,
StructDeserializeStream,
} from "./stream.js";
import { type StructValue } from "./struct-value.js";
import type { StructValue } from "./struct-value.js";
/**
* A field definition defines how to deserialize a field.

View file

@ -1,15 +1,15 @@
import { describe, expect, it } from "@jest/globals";
import { type ValueOrPromise } from "../utils.js";
import type { ValueOrPromise } from "../utils.js";
import { StructFieldDefinition } from "./definition.js";
import { StructFieldValue } from "./field-value.js";
import { type StructOptions } from "./options.js";
import {
type StructAsyncDeserializeStream,
type StructDeserializeStream,
import type { StructOptions } from "./options.js";
import type {
StructAsyncDeserializeStream,
StructDeserializeStream,
} from "./stream.js";
import { type StructValue } from "./struct-value.js";
import type { StructValue } from "./struct-value.js";
describe("StructFieldValue", () => {
describe(".constructor", () => {

View file

@ -1,6 +1,6 @@
import { type StructFieldDefinition } from "./definition.js";
import { type StructOptions } from "./options.js";
import { type StructValue } from "./struct-value.js";
import type { StructFieldDefinition } from "./definition.js";
import type { StructOptions } from "./options.js";
import type { StructValue } from "./struct-value.js";
/**
* A field value defines how to serialize a field.

View file

@ -1,4 +1,4 @@
import { type ValueOrPromise } from "../utils.js";
import type { ValueOrPromise } from "../utils.js";
// TODO: allow over reading (returning a `Uint8Array`, an `offset` and a `length`) to avoid copying

View file

@ -1,4 +1,4 @@
import { type StructFieldValue } from "./field-value.js";
import type { StructFieldValue } from "./field-value.js";
export const STRUCT_VALUE_SYMBOL = Symbol("struct-value");

View file

@ -1,14 +1,15 @@
import { describe, expect, it, jest } from "@jest/globals";
import {
StructDefaultOptions,
StructFieldDefinition,
type StructAsyncDeserializeStream,
type StructDeserializeStream,
type StructFieldValue,
type StructOptions,
type StructValue,
import type {
StructAsyncDeserializeStream,
StructDeserializeStream,
StructFieldValue,
StructOptions,
StructValue,
} from "./basic/index.js";
import { StructDefaultOptions, StructFieldDefinition } from "./basic/index.js";
import { Struct } from "./struct.js";
import type { ValueOrPromise } from "./utils.js";
import {
BigIntFieldDefinition,
@ -20,9 +21,6 @@ import {
VariableLengthBufferLikeFieldDefinition,
} from "./index.js";
import { Struct } from "./struct.js";
import { type ValueOrPromise } from "./utils.js";
class MockDeserializationStream implements StructDeserializeStream {
public buffer = new Uint8Array(0);

View file

@ -1,14 +1,22 @@
import type {
StructAsyncDeserializeStream,
StructDeserializeStream,
StructFieldDefinition,
StructFieldValue,
StructOptions,
} from "./basic/index.js";
import {
STRUCT_VALUE_SYMBOL,
StructDefaultOptions,
StructValue,
type StructAsyncDeserializeStream,
type StructDeserializeStream,
type StructFieldDefinition,
type StructFieldValue,
type StructOptions,
} from "./basic/index.js";
import { SyncPromise } from "./sync-promise.js";
import type {
BufferFieldSubType,
FixedLengthBufferLikeFieldOptions,
LengthField,
VariableLengthBufferLikeFieldOptions,
} from "./types/index.js";
import {
BigIntFieldDefinition,
BigIntFieldType,
@ -18,17 +26,8 @@ import {
StringBufferFieldSubType,
Uint8ArrayBufferFieldSubType,
VariableLengthBufferLikeFieldDefinition,
type BufferFieldSubType,
type FixedLengthBufferLikeFieldOptions,
type LengthField,
type VariableLengthBufferLikeFieldOptions,
} from "./types/index.js";
import {
type Evaluate,
type Identity,
type Overwrite,
type ValueOrPromise,
} from "./utils.js";
import type { Evaluate, Identity, Overwrite, ValueOrPromise } from "./utils.js";
export interface StructLike<TValue> {
deserialize(

View file

@ -5,16 +5,15 @@ import {
setBigUint64,
} from "@yume-chan/dataview-bigint-polyfill/esm/fallback.js";
import {
StructFieldDefinition,
StructFieldValue,
type StructAsyncDeserializeStream,
type StructDeserializeStream,
type StructOptions,
type StructValue,
import type {
StructAsyncDeserializeStream,
StructDeserializeStream,
StructOptions,
StructValue,
} from "../basic/index.js";
import { StructFieldDefinition, StructFieldValue } from "../basic/index.js";
import { SyncPromise } from "../sync-promise.js";
import { type ValueOrPromise } from "../utils.js";
import type { ValueOrPromise } from "../utils.js";
type DataViewBigInt64Getter = (
dataView: DataView,

View file

@ -1,17 +1,14 @@
import { describe, expect, it, jest } from "@jest/globals";
import {
StructDefaultOptions,
StructValue,
type StructDeserializeStream,
} from "../../basic/index.js";
import type { StructDeserializeStream } from "../../basic/index.js";
import { StructDefaultOptions, StructValue } from "../../basic/index.js";
import type { BufferFieldSubType } from "./base.js";
import {
BufferLikeFieldDefinition,
EMPTY_UINT8_ARRAY,
StringBufferFieldSubType,
Uint8ArrayBufferFieldSubType,
type BufferFieldSubType,
} from "./base.js";
class MockDeserializationStream implements StructDeserializeStream {

View file

@ -1,13 +1,13 @@
import {
StructFieldDefinition,
StructFieldValue,
type StructAsyncDeserializeStream,
type StructDeserializeStream,
type StructOptions,
type StructValue,
import type {
StructAsyncDeserializeStream,
StructDeserializeStream,
StructOptions,
StructValue,
} from "../../basic/index.js";
import { StructFieldDefinition, StructFieldValue } from "../../basic/index.js";
import { SyncPromise } from "../../sync-promise.js";
import { decodeUtf8, encodeUtf8, type ValueOrPromise } from "../../utils.js";
import type { ValueOrPromise } from "../../utils.js";
import { decodeUtf8, encodeUtf8 } from "../../utils.js";
/**
* Base class for all types that

View file

@ -1,4 +1,5 @@
import { BufferLikeFieldDefinition, type BufferFieldSubType } from "./base.js";
import type { BufferFieldSubType } from "./base.js";
import { BufferLikeFieldDefinition } from "./base.js";
export interface FixedLengthBufferLikeFieldOptions {
length: number;

View file

@ -1,16 +1,13 @@
import {
StructFieldValue,
type StructFieldDefinition,
type StructOptions,
type StructValue,
import type {
StructFieldDefinition,
StructOptions,
StructValue,
} from "../../basic/index.js";
import { type KeysOfType } from "../../utils.js";
import { StructFieldValue } from "../../basic/index.js";
import type { KeysOfType } from "../../utils.js";
import {
BufferLikeFieldDefinition,
BufferLikeFieldValue,
type BufferFieldSubType,
} from "./base.js";
import type { BufferFieldSubType } from "./base.js";
import { BufferLikeFieldDefinition, BufferLikeFieldValue } from "./base.js";
export type LengthField<TFields> = KeysOfType<TFields, number | string>;

View file

@ -1,10 +1,7 @@
import { describe, expect, it, jest, test } from "@jest/globals";
import {
StructDefaultOptions,
StructValue,
type StructDeserializeStream,
} from "../basic/index.js";
import type { StructDeserializeStream } from "../basic/index.js";
import { StructDefaultOptions, StructValue } from "../basic/index.js";
import { NumberFieldDefinition, NumberFieldType } from "./number.js";

View file

@ -1,13 +1,12 @@
import {
StructFieldDefinition,
StructFieldValue,
type StructAsyncDeserializeStream,
type StructDeserializeStream,
type StructOptions,
type StructValue,
import type {
StructAsyncDeserializeStream,
StructDeserializeStream,
StructOptions,
StructValue,
} from "../basic/index.js";
import { StructFieldDefinition, StructFieldValue } from "../basic/index.js";
import { SyncPromise } from "../sync-promise.js";
import { type ValueOrPromise } from "../utils.js";
import type { ValueOrPromise } from "../utils.js";
export interface NumberFieldType {
signed: boolean;

View file

@ -19,9 +19,9 @@ module.exports = {
},
],
"import/consistent-type-specifier-style": ["error", "prefer-inline"],
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
"import/no-cycle": "error",
"import/no-duplicates": "error",
"import/no-duplicates": ["error", { "prefer-inline": false }],
"import/order": [
"error",
{