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 { import type { AdbBackend } from "@yume-chan/adb";
AdbPacket, import { AdbPacket, AdbPacketSerializeStream } from "@yume-chan/adb";
AdbPacketSerializeStream, import type { ReadableStream, WritableStream } from "@yume-chan/stream-extra";
type AdbBackend,
} from "@yume-chan/adb";
import { import {
StructDeserializeStream, StructDeserializeStream,
WrapReadableStream, WrapReadableStream,
WrapWritableStream, WrapWritableStream,
pipeFrom, pipeFrom,
type ReadableStream,
type WritableStream,
} from "@yume-chan/stream-extra"; } from "@yume-chan/stream-extra";
declare global { declare global {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,7 @@
import { type ReadableWritablePair } from "@yume-chan/stream-extra"; import type { ReadableWritablePair } from "@yume-chan/stream-extra";
import { type ValueOrPromise } from "@yume-chan/struct"; 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 { export interface AdbBackend {
readonly serial: string; readonly serial: string;

View file

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

View file

@ -1,7 +1,7 @@
import { BufferedReadableStream } from "@yume-chan/stream-extra"; import { BufferedReadableStream } from "@yume-chan/stream-extra";
import Struct from "@yume-chan/struct"; 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"); const Version = new Struct({ littleEndian: true }).uint32("version");

View file

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

View file

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

View file

@ -2,11 +2,13 @@ import { DecodeUtf8Stream, GatherStringStream } from "@yume-chan/stream-extra";
import { AdbCommandBase } from "../base.js"; import { AdbCommandBase } from "../base.js";
import type {
AdbSubprocessProtocol,
AdbSubprocessProtocolConstructor,
} from "./protocols/index.js";
import { import {
AdbSubprocessNoneProtocol, AdbSubprocessNoneProtocol,
AdbSubprocessShellProtocol, AdbSubprocessShellProtocol,
type AdbSubprocessProtocol,
type AdbSubprocessProtocolConstructor,
} from "./protocols/index.js"; } from "./protocols/index.js";
export interface AdbSubprocessOptions { 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 { Adb } from "../../../adb.js";
import { type AdbSocket } from "../../../socket/index.js"; import type { AdbSocket } from "../../../socket/index.js";
import { type AdbSubprocessProtocol } from "./types.js"; import type { AdbSubprocessProtocol } from "./types.js";
/** /**
* The legacy shell * 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 { import {
PushReadableStream, PushReadableStream,
StructDeserializeStream, StructDeserializeStream,
@ -6,18 +11,16 @@ import {
TransformStream, TransformStream,
WritableStream, WritableStream,
pipeFrom, pipeFrom,
type PushReadableStreamController,
type ReadableStream,
type WritableStreamDefaultWriter,
} from "@yume-chan/stream-extra"; } 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 { 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 { encodeUtf8 } from "../../../utils/index.js";
import { type AdbSubprocessProtocol } from "./types.js"; import type { AdbSubprocessProtocol } from "./types.js";
export enum AdbShellProtocolId { export enum AdbShellProtocolId {
Stdin, Stdin,

View file

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

View file

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

View file

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

View file

@ -1,10 +1,8 @@
import { import type {
ChunkStream, BufferedReadableStream,
WritableStream, WritableStreamDefaultWriter,
pipeFrom,
type BufferedReadableStream,
type WritableStreamDefaultWriter,
} from "@yume-chan/stream-extra"; } from "@yume-chan/stream-extra";
import { ChunkStream, WritableStream, pipeFrom } from "@yume-chan/stream-extra";
import Struct from "@yume-chan/struct"; import Struct from "@yume-chan/struct";
import { AdbSyncRequestId, adbSyncWriteRequest } from "./request.js"; 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 Struct from "@yume-chan/struct";
import { encodeUtf8 } from "../../utils/index.js"; import { encodeUtf8 } from "../../utils/index.js";

View file

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

View file

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

View file

@ -1,20 +1,23 @@
import { AutoDisposable } from "@yume-chan/event"; import { AutoDisposable } from "@yume-chan/event";
import type {
ReadableStream,
WritableStream,
WritableStreamDefaultWriter,
} from "@yume-chan/stream-extra";
import { import {
BufferedReadableStream, BufferedReadableStream,
WrapReadableStream, WrapReadableStream,
WrapWritableStream, WrapWritableStream,
type ReadableStream,
type WritableStream,
type WritableStreamDefaultWriter,
} from "@yume-chan/stream-extra"; } from "@yume-chan/stream-extra";
import { type Adb } from "../../adb.js"; import type { Adb } from "../../adb.js";
import { AdbFeatures } from "../../features.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 { AutoResetEvent } from "../../utils/index.js";
import { escapeArg } from "../subprocess/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 { adbSyncPull } from "./pull.js";
import { adbSyncPush } from "./push.js"; import { adbSyncPush } from "./push.js";
import { adbSyncLstat, adbSyncStat } from "./stat.js"; import { adbSyncLstat, adbSyncStat } from "./stat.js";

View file

@ -1,22 +1,19 @@
import { AsyncOperationManager, PromiseResolver } from "@yume-chan/async"; import { AsyncOperationManager, PromiseResolver } from "@yume-chan/async";
import { type RemoveEventListener } from "@yume-chan/event"; import type { RemoveEventListener } from "@yume-chan/event";
import { import type {
AbortController, ReadableWritablePair,
WritableStream, WritableStreamDefaultWriter,
type ReadableWritablePair,
type WritableStreamDefaultWriter,
} from "@yume-chan/stream-extra"; } 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 { import type { AdbPacketData, AdbPacketInit } from "../packet.js";
AdbCommand, import { AdbCommand, calculateChecksum } from "../packet.js";
calculateChecksum,
type AdbPacketData,
type AdbPacketInit,
} from "../packet.js";
import { decodeUtf8, encodeUtf8 } from "../utils/index.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 { export interface AdbPacketDispatcherOptions {
calculateChecksum: boolean; calculateChecksum: boolean;

View file

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

View file

@ -1,5 +1,5 @@
import { PromiseResolver } from "@yume-chan/async"; 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 { export class AutoResetEvent implements Disposable {
private _set: boolean; private _set: boolean;

View file

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

View file

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

View file

@ -4,7 +4,8 @@
// cspell: ignore systemui // cspell: ignore systemui
// cspell: ignore sysui // 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"; import { Settings } from "./settings.js";

View file

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

View file

@ -1,6 +1,7 @@
import { describe, expect, it } from "@jest/globals"; 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; const LENGTH = 128;

View file

@ -1,6 +1,7 @@
import { describe, expect, it, jest } from "@jest/globals"; 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("Event", () => {
describe("AutoDisposable", () => { describe("AutoDisposable", () => {

View file

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

View file

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

View file

@ -1,10 +1,13 @@
import type { Adb, AdbSubprocessProtocol, AdbSync } from "@yume-chan/adb";
import { import {
AdbReverseNotSupportedError, AdbReverseNotSupportedError,
AdbSubprocessNoneProtocol, AdbSubprocessNoneProtocol,
type Adb,
type AdbSubprocessProtocol,
type AdbSync,
} from "@yume-chan/adb"; } from "@yume-chan/adb";
import type {
ReadableStreamDefaultController,
ReadableStreamDefaultReader,
ReadableWritablePair,
} from "@yume-chan/stream-extra";
import { import {
AbortController, AbortController,
DecodeUtf8Stream, DecodeUtf8Stream,
@ -13,24 +16,19 @@ import {
SplitStringStream, SplitStringStream,
WrapWritableStream, WrapWritableStream,
WritableStream, WritableStream,
type ReadableStreamDefaultController,
type ReadableStreamDefaultReader,
type ReadableWritablePair,
} from "@yume-chan/stream-extra"; } from "@yume-chan/stream-extra";
import { ScrcpyControlMessageSerializer } from "../control/index.js"; import { ScrcpyControlMessageSerializer } from "../control/index.js";
import { import type { ScrcpyDeviceMessage } from "../device-message/index.js";
ScrcpyDeviceMessageDeserializeStream, import { ScrcpyDeviceMessageDeserializeStream } from "../device-message/index.js";
type ScrcpyDeviceMessage, import type {
} from "../device-message/index.js"; ScrcpyOptionsInit1_16,
import { ScrcpyVideoStreamPacket,
DEFAULT_SERVER_PATH,
type ScrcpyOptionsInit1_16,
type ScrcpyVideoStreamPacket,
} from "../options/index.js"; } from "../options/index.js";
import { DEFAULT_SERVER_PATH } from "../options/index.js";
import { type AdbScrcpyConnection } from "./connection.js"; import type { AdbScrcpyConnection } from "./connection.js";
import { type AdbScrcpyOptions } from "./options/index.js"; import type { AdbScrcpyOptions } from "./options/index.js";
class ArrayToStream<T> extends ReadableStream<T> { class ArrayToStream<T> extends ReadableStream<T> {
private array!: 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 { delay } from "@yume-chan/async";
import { type Disposable } from "@yume-chan/event"; import type { Disposable } from "@yume-chan/event";
import { import type {
TransformStream, ReadableStream,
type ReadableStream, ReadableStreamDefaultReader,
type ReadableStreamDefaultReader, ReadableWritablePair,
type ReadableWritablePair,
} from "@yume-chan/stream-extra"; } 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 { export interface AdbScrcpyConnectionOptions {
control: boolean; 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 { import {
AdbScrcpyForwardConnection, AdbScrcpyForwardConnection,
AdbScrcpyReverseConnection, AdbScrcpyReverseConnection,
type AdbScrcpyConnection,
type AdbScrcpyConnectionOptions,
} from "../connection.js"; } from "../connection.js";
import { AdbScrcpyOptionsBase } from "./types.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 { import {
AdbScrcpyForwardConnection, AdbScrcpyForwardConnection,
AdbScrcpyReverseConnection, AdbScrcpyReverseConnection,
type AdbScrcpyConnection,
} from "../connection.js"; } from "../connection.js";
import { AdbScrcpyOptions1_16 } from "./1_16.js"; import { AdbScrcpyOptions1_16 } from "./1_16.js";

View file

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

View file

@ -1,7 +1,5 @@
import { import type { ScrcpyInjectTouchControlMessage } from "./inject-touch.js";
AndroidMotionEventAction, import { AndroidMotionEventAction } from "./inject-touch.js";
type ScrcpyInjectTouchControlMessage,
} from "./inject-touch.js";
import { ScrcpyControlMessageType } from "./type.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 = export type ScrcpyInjectScrollControlMessage =
ScrcpyInjectScrollControlMessage1_25; ScrcpyInjectScrollControlMessage1_25;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,12 +2,11 @@
import Struct from "@yume-chan/struct"; import Struct from "@yume-chan/struct";
import { import type { ScrcpySetClipboardControlMessage } from "../control/index.js";
ScrcpyControlMessageType, import { ScrcpyControlMessageType } from "../control/index.js";
type ScrcpySetClipboardControlMessage,
} 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"; import { toScrcpyOptionValue } from "./types.js";
export interface ScrcpyOptionsInit1_21 extends ScrcpyOptionsInit1_18 { export interface ScrcpyOptionsInit1_21 extends ScrcpyOptionsInit1_18 {

View file

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

View file

@ -1,10 +1,8 @@
import { TransformStream } from "@yume-chan/stream-extra"; import { TransformStream } from "@yume-chan/stream-extra";
import { import type { ScrcpyOptionsInit1_22 } from "./1_22/options.js";
ScrcpyOptions1_22, import { ScrcpyOptions1_22 } from "./1_22/options.js";
type ScrcpyOptionsInit1_22, import type { ScrcpyVideoStreamPacket } from "./types.js";
} from "./1_22/options.js";
import { type ScrcpyVideoStreamPacket } from "./types.js";
export interface ScrcpyOptionsInit1_23 extends ScrcpyOptionsInit1_22 { export interface ScrcpyOptionsInit1_23 extends ScrcpyOptionsInit1_22 {
cleanup: boolean; 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 { export interface ScrcpyOptionsInit1_24 extends ScrcpyOptionsInit1_23 {
powerOn: boolean; powerOn: boolean;
} }
export class ScrcpyOptions1_24<T extends ScrcpyOptionsInit1_24 = ScrcpyOptionsInit1_24> export class ScrcpyOptions1_24<
extends ScrcpyOptions1_23<T> { T extends ScrcpyOptionsInit1_24 = ScrcpyOptionsInit1_24
> extends ScrcpyOptions1_23<T> {
public constructor(init: Partial<ScrcpyOptionsInit1_24>) { public constructor(init: Partial<ScrcpyOptionsInit1_24>) {
super(init); super(init);
} }

View file

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

View file

@ -3,12 +3,9 @@ import Struct, {
NumberFieldType, NumberFieldType,
} from "@yume-chan/struct"; } from "@yume-chan/struct";
import { import type { ScrcpyInjectScrollControlMessage } from "../../control/index.js";
clamp, import { clamp, ScrcpyControlMessageType } from "../../control/index.js";
ScrcpyControlMessageType, import type { ScrcpyScrollController } from "../1_16/index.js";
type ScrcpyInjectScrollControlMessage,
} from "../../control/index.js";
import { type ScrcpyScrollController } from "../1_16/index.js";
export const ScrcpyFloatToInt16NumberType: NumberFieldType = { export const ScrcpyFloatToInt16NumberType: NumberFieldType = {
size: 2, 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 { import type {
type ScrcpyBackOrScreenOnControlMessage, ScrcpyBackOrScreenOnControlMessage,
type ScrcpyControlMessageType, ScrcpyControlMessageType,
type ScrcpySetClipboardControlMessage, ScrcpySetClipboardControlMessage,
} from "../control/index.js"; } 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"; 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 { import {
BufferedReadableStream, BufferedReadableStream,
BufferedReadableStreamEndedError, BufferedReadableStreamEndedError,
} from "./buffered.js"; } from "./buffered.js";
import { import type { PushReadableStreamController } from "./push-readable.js";
PushReadableStream, import { PushReadableStream } from "./push-readable.js";
type PushReadableStreamController, import type { ReadableWritablePair } from "./stream.js";
} from "./push-readable.js"; import { ReadableStream, WritableStream } from "./stream.js";
import {
ReadableStream,
WritableStream,
type ReadableWritablePair,
} from "./stream.js";
// TODO: BufferedTransformStream: find better implementation // TODO: BufferedTransformStream: find better implementation
export class BufferedTransformStream<T> export class BufferedTransformStream<T>

View file

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

View file

@ -1,12 +1,12 @@
import { PromiseResolver } from "@yume-chan/async"; import { PromiseResolver } from "@yume-chan/async";
import { type ValueOrPromise } from "@yume-chan/struct"; import type { ValueOrPromise } from "@yume-chan/struct";
import { import type {
WritableStream, ReadableStream,
type ReadableStream, ReadableStreamDefaultController,
type ReadableStreamDefaultController, WritableStreamDefaultWriter,
type WritableStreamDefaultWriter,
} from "./stream.js"; } from "./stream.js";
import { WritableStream } from "./stream.js";
import { WrapReadableStream } from "./wrap-readable.js"; import { WrapReadableStream } from "./wrap-readable.js";
export interface DuplexStreamFactoryOptions { 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`. * 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. * @param pair A `TransformStream` that converts chunks.
* @returns `pair`'s `writable` stream. * @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 writer = pair.writable.getWriter();
const pipe = pair.readable const pipe = pair.readable.pipeTo(writable);
.pipeTo(writable);
return new WritableStream<T>({ return new WritableStream<T>({
async write(chunk) { async write(chunk) {
await writer.ready; await writer.ready;
@ -21,6 +24,6 @@ export function pipeFrom<W, T>(writable: WritableStream<W>, pair: ReadableWritab
async close() { async close() {
await writer.close(); await writer.close();
await pipe; await pipe;
} },
}); });
} }

View file

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

View file

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

View file

@ -1,5 +1,5 @@
import type Struct from "@yume-chan/struct"; 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"; 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 { import type {
ReadableStream, ReadableStreamDefaultController,
type ReadableStreamDefaultController, ReadableStreamDefaultReader,
type ReadableStreamDefaultReader,
} from "./stream.js"; } from "./stream.js";
import { ReadableStream } from "./stream.js";
export type WrapReadableStreamStart<T> = ( export type WrapReadableStreamStart<T> = (
controller: ReadableStreamDefaultController<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< export type WrapWritableStreamStart<T> = () => ValueOrPromise<
WritableStream<T> WritableStream<T>

View file

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

View file

@ -1,10 +1,10 @@
import { type StructFieldValue } from "./field-value.js"; import type { StructFieldValue } from "./field-value.js";
import { type StructOptions } from "./options.js"; import type { StructOptions } from "./options.js";
import { import type {
type StructAsyncDeserializeStream, StructAsyncDeserializeStream,
type StructDeserializeStream, StructDeserializeStream,
} from "./stream.js"; } 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. * A field definition defines how to deserialize a field.

View file

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

View file

@ -1,6 +1,6 @@
import { type StructFieldDefinition } from "./definition.js"; import type { StructFieldDefinition } from "./definition.js";
import { type StructOptions } from "./options.js"; import type { StructOptions } from "./options.js";
import { type StructValue } from "./struct-value.js"; import type { StructValue } from "./struct-value.js";
/** /**
* A field value defines how to serialize a field. * 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 // 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"); export const STRUCT_VALUE_SYMBOL = Symbol("struct-value");

View file

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

View file

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

View file

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

View file

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

View file

@ -1,13 +1,13 @@
import { import type {
StructFieldDefinition, StructAsyncDeserializeStream,
StructFieldValue, StructDeserializeStream,
type StructAsyncDeserializeStream, StructOptions,
type StructDeserializeStream, StructValue,
type StructOptions,
type StructValue,
} from "../../basic/index.js"; } from "../../basic/index.js";
import { StructFieldDefinition, StructFieldValue } from "../../basic/index.js";
import { SyncPromise } from "../../sync-promise.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 * 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 { export interface FixedLengthBufferLikeFieldOptions {
length: number; length: number;

View file

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

View file

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

View file

@ -1,13 +1,12 @@
import { import type {
StructFieldDefinition, StructAsyncDeserializeStream,
StructFieldValue, StructDeserializeStream,
type StructAsyncDeserializeStream, StructOptions,
type StructDeserializeStream, StructValue,
type StructOptions,
type StructValue,
} from "../basic/index.js"; } from "../basic/index.js";
import { StructFieldDefinition, StructFieldValue } from "../basic/index.js";
import { SyncPromise } from "../sync-promise.js"; import { SyncPromise } from "../sync-promise.js";
import { type ValueOrPromise } from "../utils.js"; import type { ValueOrPromise } from "../utils.js";
export interface NumberFieldType { export interface NumberFieldType {
signed: boolean; 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-cycle": "error",
"import/no-duplicates": "error", "import/no-duplicates": ["error", { "prefer-inline": false }],
"import/order": [ "import/order": [
"error", "error",
{ {