Loading libraries/adb/src/commands/framebuffer.ts +4 −4 Original line number Diff line number Diff line import { BufferedReadableStream } from "@yume-chan/stream-extra"; import type { StructValue } from "@yume-chan/struct"; import { buffer, Struct, StructEmptyError, u32 } from "@yume-chan/struct"; import { buffer, struct, StructEmptyError, u32 } from "@yume-chan/struct"; import type { Adb } from "../adb.js"; const Version = new Struct({ version: u32 }, { littleEndian: true }); const Version = struct({ version: u32 }, { littleEndian: true }); export const AdbFrameBufferV1 = new Struct( export const AdbFrameBufferV1 = struct( { bpp: u32, size: u32, Loading @@ -27,7 +27,7 @@ export const AdbFrameBufferV1 = new Struct( export type AdbFrameBufferV1 = StructValue<typeof AdbFrameBufferV1>; export const AdbFrameBufferV2 = new Struct( export const AdbFrameBufferV2 = struct( { bpp: u32, colorSpace: u32, Loading libraries/adb/src/commands/reverse.ts +18 −16 Original line number Diff line number Diff line Loading @@ -2,10 +2,10 @@ import { BufferedReadableStream } from "@yume-chan/stream-extra"; import { ExactReadableEndedError, Struct, encodeUtf8, ExactReadableEndedError, string, struct, } from "@yume-chan/struct"; import type { Adb, AdbIncomingSocketHandler } from "../adb.js"; Loading @@ -19,7 +19,7 @@ export interface AdbForwardListener { remoteName: string; } const AdbReverseStringResponse = new Struct( const AdbReverseStringResponse = struct( { length: string(4), content: string({ Loading @@ -38,7 +38,6 @@ const AdbReverseStringResponse = new Struct( export class AdbReverseError extends Error { constructor(message: string) { super(message); Object.setPrototypeOf(this, new.target.prototype); } } Loading @@ -50,7 +49,9 @@ export class AdbReverseNotSupportedError extends AdbReverseError { } } const AdbReverseErrorResponse = new Struct(AdbReverseStringResponse.fields, { const AdbReverseErrorResponse = struct( /* #__PURE__ */ (() => AdbReverseStringResponse.fields)(), { littleEndian: true, postDeserialize: (value) => { // https://issuetracker.google.com/issues/37066218 Loading @@ -62,7 +63,8 @@ const AdbReverseErrorResponse = new Struct(AdbReverseStringResponse.fields, { throw new AdbReverseError(value.content); } }, }); }, ); // Like `hexToNumber`, it's much faster than first converting `buffer` to a string function decimalToNumber(buffer: Uint8Array) { Loading libraries/adb/src/commands/subprocess/protocols/shell.ts +2 −2 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ import { WritableStream, } from "@yume-chan/stream-extra"; import type { StructValue } from "@yume-chan/struct"; import { Struct, buffer, u32, u8 } from "@yume-chan/struct"; import { buffer, struct, u32, u8 } from "@yume-chan/struct"; import type { Adb, AdbSocket } from "../../../adb.js"; import { AdbFeature } from "../../../features.js"; Loading @@ -32,7 +32,7 @@ export type AdbShellProtocolId = (typeof AdbShellProtocolId)[keyof typeof AdbShellProtocolId]; // This packet format is used in both directions. export const AdbShellProtocolPacket = new Struct( export const AdbShellProtocolPacket = struct( { id: u8.as<AdbShellProtocolId>(), data: buffer(u32), Loading libraries/adb/src/commands/sync/list.ts +7 −7 Original line number Diff line number Diff line import type { StructValue } from "@yume-chan/struct"; import { Struct, string, u32 } from "@yume-chan/struct"; import { string, struct, u32 } from "@yume-chan/struct"; import { AdbSyncRequestId, adbSyncWriteRequest } from "./request.js"; import { AdbSyncResponseId, adbSyncReadResponses } from "./response.js"; Loading @@ -15,21 +15,21 @@ export interface AdbSyncEntry extends AdbSyncStat { name: string; } export const AdbSyncEntryResponse = new Struct( { export const AdbSyncEntryResponse = struct( /* #__PURE__ */ (() => ({ ...AdbSyncLstatResponse.fields, name: string(u32), }, }))(), { littleEndian: true, extra: AdbSyncLstatResponse.extra }, ); export type AdbSyncEntryResponse = StructValue<typeof AdbSyncEntryResponse>; export const AdbSyncEntry2Response = new Struct( { export const AdbSyncEntry2Response = struct( /* #__PURE__ */ (() => ({ ...AdbSyncStatResponse.fields, name: string(u32), }, }))(), { littleEndian: true, extra: AdbSyncStatResponse.extra }, ); Loading libraries/adb/src/commands/sync/pull.ts +2 −2 Original line number Diff line number Diff line import type { ReadableStream } from "@yume-chan/stream-extra"; import { PushReadableStream } from "@yume-chan/stream-extra"; import type { StructValue } from "@yume-chan/struct"; import { buffer, Struct, u32 } from "@yume-chan/struct"; import { buffer, struct, u32 } from "@yume-chan/struct"; import { AdbSyncRequestId, adbSyncWriteRequest } from "./request.js"; import { adbSyncReadResponses, AdbSyncResponseId } from "./response.js"; import type { AdbSyncSocket } from "./socket.js"; export const AdbSyncDataResponse = new Struct( export const AdbSyncDataResponse = struct( { data: buffer(u32) }, { littleEndian: true }, ); Loading Loading
libraries/adb/src/commands/framebuffer.ts +4 −4 Original line number Diff line number Diff line import { BufferedReadableStream } from "@yume-chan/stream-extra"; import type { StructValue } from "@yume-chan/struct"; import { buffer, Struct, StructEmptyError, u32 } from "@yume-chan/struct"; import { buffer, struct, StructEmptyError, u32 } from "@yume-chan/struct"; import type { Adb } from "../adb.js"; const Version = new Struct({ version: u32 }, { littleEndian: true }); const Version = struct({ version: u32 }, { littleEndian: true }); export const AdbFrameBufferV1 = new Struct( export const AdbFrameBufferV1 = struct( { bpp: u32, size: u32, Loading @@ -27,7 +27,7 @@ export const AdbFrameBufferV1 = new Struct( export type AdbFrameBufferV1 = StructValue<typeof AdbFrameBufferV1>; export const AdbFrameBufferV2 = new Struct( export const AdbFrameBufferV2 = struct( { bpp: u32, colorSpace: u32, Loading
libraries/adb/src/commands/reverse.ts +18 −16 Original line number Diff line number Diff line Loading @@ -2,10 +2,10 @@ import { BufferedReadableStream } from "@yume-chan/stream-extra"; import { ExactReadableEndedError, Struct, encodeUtf8, ExactReadableEndedError, string, struct, } from "@yume-chan/struct"; import type { Adb, AdbIncomingSocketHandler } from "../adb.js"; Loading @@ -19,7 +19,7 @@ export interface AdbForwardListener { remoteName: string; } const AdbReverseStringResponse = new Struct( const AdbReverseStringResponse = struct( { length: string(4), content: string({ Loading @@ -38,7 +38,6 @@ const AdbReverseStringResponse = new Struct( export class AdbReverseError extends Error { constructor(message: string) { super(message); Object.setPrototypeOf(this, new.target.prototype); } } Loading @@ -50,7 +49,9 @@ export class AdbReverseNotSupportedError extends AdbReverseError { } } const AdbReverseErrorResponse = new Struct(AdbReverseStringResponse.fields, { const AdbReverseErrorResponse = struct( /* #__PURE__ */ (() => AdbReverseStringResponse.fields)(), { littleEndian: true, postDeserialize: (value) => { // https://issuetracker.google.com/issues/37066218 Loading @@ -62,7 +63,8 @@ const AdbReverseErrorResponse = new Struct(AdbReverseStringResponse.fields, { throw new AdbReverseError(value.content); } }, }); }, ); // Like `hexToNumber`, it's much faster than first converting `buffer` to a string function decimalToNumber(buffer: Uint8Array) { Loading
libraries/adb/src/commands/subprocess/protocols/shell.ts +2 −2 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ import { WritableStream, } from "@yume-chan/stream-extra"; import type { StructValue } from "@yume-chan/struct"; import { Struct, buffer, u32, u8 } from "@yume-chan/struct"; import { buffer, struct, u32, u8 } from "@yume-chan/struct"; import type { Adb, AdbSocket } from "../../../adb.js"; import { AdbFeature } from "../../../features.js"; Loading @@ -32,7 +32,7 @@ export type AdbShellProtocolId = (typeof AdbShellProtocolId)[keyof typeof AdbShellProtocolId]; // This packet format is used in both directions. export const AdbShellProtocolPacket = new Struct( export const AdbShellProtocolPacket = struct( { id: u8.as<AdbShellProtocolId>(), data: buffer(u32), Loading
libraries/adb/src/commands/sync/list.ts +7 −7 Original line number Diff line number Diff line import type { StructValue } from "@yume-chan/struct"; import { Struct, string, u32 } from "@yume-chan/struct"; import { string, struct, u32 } from "@yume-chan/struct"; import { AdbSyncRequestId, adbSyncWriteRequest } from "./request.js"; import { AdbSyncResponseId, adbSyncReadResponses } from "./response.js"; Loading @@ -15,21 +15,21 @@ export interface AdbSyncEntry extends AdbSyncStat { name: string; } export const AdbSyncEntryResponse = new Struct( { export const AdbSyncEntryResponse = struct( /* #__PURE__ */ (() => ({ ...AdbSyncLstatResponse.fields, name: string(u32), }, }))(), { littleEndian: true, extra: AdbSyncLstatResponse.extra }, ); export type AdbSyncEntryResponse = StructValue<typeof AdbSyncEntryResponse>; export const AdbSyncEntry2Response = new Struct( { export const AdbSyncEntry2Response = struct( /* #__PURE__ */ (() => ({ ...AdbSyncStatResponse.fields, name: string(u32), }, }))(), { littleEndian: true, extra: AdbSyncStatResponse.extra }, ); Loading
libraries/adb/src/commands/sync/pull.ts +2 −2 Original line number Diff line number Diff line import type { ReadableStream } from "@yume-chan/stream-extra"; import { PushReadableStream } from "@yume-chan/stream-extra"; import type { StructValue } from "@yume-chan/struct"; import { buffer, Struct, u32 } from "@yume-chan/struct"; import { buffer, struct, u32 } from "@yume-chan/struct"; import { AdbSyncRequestId, adbSyncWriteRequest } from "./request.js"; import { adbSyncReadResponses, AdbSyncResponseId } from "./response.js"; import type { AdbSyncSocket } from "./socket.js"; export const AdbSyncDataResponse = new Struct( export const AdbSyncDataResponse = struct( { data: buffer(u32) }, { littleEndian: true }, ); Loading