diff --git a/apps/demo/package.json b/apps/demo/package.json index 072a2fc1..1be63d61 100644 --- a/apps/demo/package.json +++ b/apps/demo/package.json @@ -42,6 +42,6 @@ "@types/react": "17.0.27", "eslint": "8.8.0", "eslint-config-next": "12.1.0", - "typescript": "^4.6.2" + "typescript": "next" } } diff --git a/libraries/adb-backend-direct-sockets/package.json b/libraries/adb-backend-direct-sockets/package.json index 7481f606..2688fc20 100644 --- a/libraries/adb-backend-direct-sockets/package.json +++ b/libraries/adb-backend-direct-sockets/package.json @@ -23,7 +23,7 @@ }, "license": "MIT", "type": "module", - "module": "esm/index.js", + "main": "esm/index.js", "types": "esm/index.d.ts", "scripts": { "build": "build-ts-package", @@ -31,7 +31,7 @@ "prepublishOnly": "npm run build" }, "devDependencies": { - "typescript": "^4.6.2", + "typescript": "next", "@types/jest": "^27.4.0", "@yume-chan/ts-package-builder": "^1.0.0" }, diff --git a/libraries/adb-backend-webusb/package.json b/libraries/adb-backend-webusb/package.json index 76831f62..8d17fa3c 100644 --- a/libraries/adb-backend-webusb/package.json +++ b/libraries/adb-backend-webusb/package.json @@ -22,7 +22,7 @@ "url": "https://github.com/yume-chan/ya-webadb/issues" }, "type": "module", - "module": "esm/index.js", + "main": "esm/index.js", "types": "esm/index.d.ts", "scripts": { "build": "build-ts-package", @@ -37,7 +37,7 @@ }, "devDependencies": { "jest": "^26.6.3", - "typescript": "^4.6.2", + "typescript": "next", "@yume-chan/ts-package-builder": "^1.0.0" } } diff --git a/libraries/adb-backend-webusb/src/index.ts b/libraries/adb-backend-webusb/src/index.ts index 844cdbe7..7eb1fc72 100644 --- a/libraries/adb-backend-webusb/src/index.ts +++ b/libraries/adb-backend-webusb/src/index.ts @@ -1,3 +1,3 @@ -export * from './backend'; -export { AdbWebUsbBackend as default } from './backend'; -export * from './watcher'; +export * from './backend.js'; +export { AdbWebUsbBackend as default } from './backend.js'; +export * from './watcher.js'; diff --git a/libraries/adb-backend-ws/package.json b/libraries/adb-backend-ws/package.json index 897d472a..a00a44cc 100644 --- a/libraries/adb-backend-ws/package.json +++ b/libraries/adb-backend-ws/package.json @@ -23,7 +23,7 @@ "url": "https://github.com/yume-chan/ya-webadb/issues" }, "type": "module", - "module": "esm/index.js", + "main": "esm/index.js", "types": "esm/index.d.ts", "scripts": { "build": "build-ts-package", @@ -31,7 +31,7 @@ }, "devDependencies": { "jest": "^26.6.3", - "typescript": "^4.6.2", + "typescript": "next", "@yume-chan/ts-package-builder": "^1.0.0" }, "dependencies": { diff --git a/libraries/adb-credential-web/package.json b/libraries/adb-credential-web/package.json index 648e7dc7..f684dc16 100644 --- a/libraries/adb-credential-web/package.json +++ b/libraries/adb-credential-web/package.json @@ -21,7 +21,7 @@ "url": "https://github.com/yume-chan/ya-webadb/issues" }, "type": "module", - "module": "esm/index.js", + "main": "esm/index.js", "types": "esm/index.d.ts", "scripts": { "build": "build-ts-package", @@ -29,7 +29,7 @@ "prepublishOnly": "npm run build" }, "devDependencies": { - "typescript": "^4.6.2", + "typescript": "next", "@yume-chan/ts-package-builder": "^1.0.0" }, "dependencies": { diff --git a/libraries/adb/package.json b/libraries/adb/package.json index d6819026..18aee4bc 100644 --- a/libraries/adb/package.json +++ b/libraries/adb/package.json @@ -22,7 +22,7 @@ "url": "https://github.com/yume-chan/ya-webadb/issues" }, "type": "module", - "module": "esm/index.js", + "main": "esm/index.js", "types": "esm/index.d.ts", "scripts": { "build": "build-ts-package", @@ -39,7 +39,7 @@ }, "devDependencies": { "jest": "^26.6.3", - "typescript": "^4.6.2", + "typescript": "next", "@yume-chan/ts-package-builder": "^1.0.0" } } diff --git a/libraries/adb/src/adb.ts b/libraries/adb/src/adb.ts index 13ede430..f570fbbe 100644 --- a/libraries/adb/src/adb.ts +++ b/libraries/adb/src/adb.ts @@ -1,11 +1,11 @@ import { PromiseResolver } from '@yume-chan/async'; -import { AdbAuthenticationHandler, AdbDefaultAuthenticators, type AdbCredentialStore } from './auth'; -import { AdbPower, AdbReverseCommand, AdbSubprocess, AdbSync, AdbTcpIpCommand, escapeArg, framebuffer, install, type AdbFrameBuffer } from './commands'; -import { AdbFeatures } from './features'; -import { AdbCommand, AdbPacket, AdbPacketSerializeStream, calculateChecksum, type AdbPacketCore, type AdbPacketInit } from './packet'; -import { AdbPacketDispatcher, AdbSocket } from './socket'; -import { AbortController, DecodeUtf8Stream, GatherStringStream, pipeFrom, StructDeserializeStream, WritableStream, type ReadableWritablePair } from "./stream"; -import { decodeUtf8, encodeUtf8 } from "./utils"; +import { AdbAuthenticationHandler, AdbDefaultAuthenticators, type AdbCredentialStore } from './auth.js'; +import { AdbPower, AdbReverseCommand, AdbSubprocess, AdbSync, AdbTcpIpCommand, escapeArg, framebuffer, install, type AdbFrameBuffer } from './commands/index.js'; +import { AdbFeatures } from './features.js'; +import { AdbCommand, AdbPacket, AdbPacketSerializeStream, calculateChecksum, type AdbPacketCore, type AdbPacketInit } from './packet.js'; +import { AdbPacketDispatcher, AdbSocket } from './socket/index.js'; +import { AbortController, DecodeUtf8Stream, GatherStringStream, pipeFrom, StructDeserializeStream, WritableStream, type ReadableWritablePair } from "./stream/index.js"; +import { decodeUtf8, encodeUtf8 } from "./utils/index.js"; export enum AdbPropKey { Product = 'ro.product.name', diff --git a/libraries/adb/src/auth.ts b/libraries/adb/src/auth.ts index 7c301623..c6b058ae 100644 --- a/libraries/adb/src/auth.ts +++ b/libraries/adb/src/auth.ts @@ -1,9 +1,9 @@ import { PromiseResolver } from '@yume-chan/async'; import type { Disposable } from '@yume-chan/event'; import type { ValueOrPromise } from '@yume-chan/struct'; -import { calculatePublicKey, calculatePublicKeyLength, sign } from './crypto'; -import { AdbCommand, AdbPacket, type AdbPacketCore } from './packet'; -import { calculateBase64EncodedLength, encodeBase64 } from './utils'; +import { calculatePublicKey, calculatePublicKeyLength, sign } from './crypto.js'; +import { AdbCommand, AdbPacket, type AdbPacketCore } from './packet.js'; +import { calculateBase64EncodedLength, encodeBase64 } from './utils/index.js'; export type AdbKeyIterable = Iterable | AsyncIterable; diff --git a/libraries/adb/src/backend.ts b/libraries/adb/src/backend.ts index 42b3a636..0700747e 100644 --- a/libraries/adb/src/backend.ts +++ b/libraries/adb/src/backend.ts @@ -1,5 +1,5 @@ import type { ValueOrPromise } from '@yume-chan/struct'; -import type { ReadableWritablePair } from "./stream"; +import type { ReadableWritablePair } from "./stream/index.js"; export interface AdbBackend { readonly serial: string; diff --git a/libraries/adb/src/commands/base.ts b/libraries/adb/src/commands/base.ts index 8ba5e758..df413032 100644 --- a/libraries/adb/src/commands/base.ts +++ b/libraries/adb/src/commands/base.ts @@ -1,5 +1,5 @@ import { AutoDisposable } from '@yume-chan/event'; -import type { Adb } from '../adb'; +import type { Adb } from '../adb.js'; export class AdbCommandBase extends AutoDisposable { protected adb: Adb; diff --git a/libraries/adb/src/commands/framebuffer.ts b/libraries/adb/src/commands/framebuffer.ts index 16e311d8..7515b34c 100644 --- a/libraries/adb/src/commands/framebuffer.ts +++ b/libraries/adb/src/commands/framebuffer.ts @@ -1,6 +1,6 @@ import Struct from "@yume-chan/struct"; -import type { Adb } from '../adb'; -import { AdbBufferedStream } from '../stream'; +import type { Adb } from '../adb.js'; +import { AdbBufferedStream } from '../stream/index.js'; const Version = new Struct({ littleEndian: true }) diff --git a/libraries/adb/src/commands/index.ts b/libraries/adb/src/commands/index.ts index 4b5e36c2..22f72e3e 100644 --- a/libraries/adb/src/commands/index.ts +++ b/libraries/adb/src/commands/index.ts @@ -1,8 +1,8 @@ -export * from './base'; -export * from './framebuffer'; -export * from './install'; -export * from './power'; -export * from './reverse'; -export * from './subprocess'; -export * from './sync'; -export * from './tcpip'; +export * from './base.js'; +export * from './framebuffer.js'; +export * from './install.js'; +export * from './power.js'; +export * from './reverse.js'; +export * from './subprocess/index.js'; +export * from './sync/index.js'; +export * from './tcpip.js'; diff --git a/libraries/adb/src/commands/install.ts b/libraries/adb/src/commands/install.ts index 148500b3..7bfb91d5 100644 --- a/libraries/adb/src/commands/install.ts +++ b/libraries/adb/src/commands/install.ts @@ -1,7 +1,7 @@ -import type { Adb } from "../adb"; -import { WrapWritableStream, WritableStream } from "../stream"; -import { escapeArg } from "./subprocess"; -import type { AdbSync } from "./sync"; +import type { Adb } from "../adb.js"; +import { WrapWritableStream, WritableStream } from "../stream/index.js"; +import { escapeArg } from "./subprocess/index.js"; +import type { AdbSync } from "./sync/index.js"; export function install( adb: Adb, diff --git a/libraries/adb/src/commands/power.ts b/libraries/adb/src/commands/power.ts index 4f39e135..696ed345 100644 --- a/libraries/adb/src/commands/power.ts +++ b/libraries/adb/src/commands/power.ts @@ -3,7 +3,7 @@ // cspell: ignore keyevent // cspell: ignore longpress -import { AdbCommandBase } from "./base"; +import { AdbCommandBase } from "./base.js"; export class AdbPower extends AdbCommandBase { public reboot(name: string = '') { diff --git a/libraries/adb/src/commands/reverse.ts b/libraries/adb/src/commands/reverse.ts index 04841db3..d299efdb 100644 --- a/libraries/adb/src/commands/reverse.ts +++ b/libraries/adb/src/commands/reverse.ts @@ -2,10 +2,10 @@ import { AutoDisposable } from '@yume-chan/event'; import Struct from '@yume-chan/struct'; -import type { AdbPacket } from '../packet'; -import type { AdbIncomingSocketEventArgs, AdbPacketDispatcher, AdbSocket } from '../socket'; -import { AdbBufferedStream } from '../stream'; -import { decodeUtf8 } from "../utils"; +import type { AdbPacket } from '../packet.js'; +import type { AdbIncomingSocketEventArgs, AdbPacketDispatcher, AdbSocket } from '../socket/index.js'; +import { AdbBufferedStream } from '../stream/index.js'; +import { decodeUtf8 } from "../utils/index.js"; export interface AdbReverseHandler { onSocket(packet: AdbPacket, socket: AdbSocket): void; diff --git a/libraries/adb/src/commands/subprocess/index.ts b/libraries/adb/src/commands/subprocess/index.ts index 3fdd517f..58cada7c 100644 --- a/libraries/adb/src/commands/subprocess/index.ts +++ b/libraries/adb/src/commands/subprocess/index.ts @@ -1,13 +1,13 @@ -import type { Adb } from '../../adb'; -import { DecodeUtf8Stream, GatherStringStream } from "../../stream"; -import { AdbNoneSubprocessProtocol } from './legacy'; -import { AdbShellSubprocessProtocol } from './protocol'; -import type { AdbSubprocessProtocol, AdbSubprocessProtocolConstructor } from './types'; +import type { Adb } from '../../adb.js'; +import { DecodeUtf8Stream, GatherStringStream } from "../../stream/index.js"; +import { AdbNoneSubprocessProtocol } from './legacy.js'; +import { AdbShellSubprocessProtocol } from './protocol.js'; +import type { AdbSubprocessProtocol, AdbSubprocessProtocolConstructor } from './types.js'; -export * from './legacy'; -export * from './protocol'; -export * from './types'; -export * from './utils'; +export * from './legacy.js'; +export * from './protocol.js'; +export * from './types.js'; +export * from './utils.js'; export interface AdbSubprocessOptions { /** diff --git a/libraries/adb/src/commands/subprocess/legacy.ts b/libraries/adb/src/commands/subprocess/legacy.ts index e07562d8..0fab2827 100644 --- a/libraries/adb/src/commands/subprocess/legacy.ts +++ b/libraries/adb/src/commands/subprocess/legacy.ts @@ -1,7 +1,7 @@ -import type { Adb } from "../../adb"; -import type { AdbSocket } from "../../socket"; -import { DuplexStreamFactory, type ReadableStream } from "../../stream"; -import type { AdbSubprocessProtocol } from "./types"; +import type { Adb } from "../../adb.js"; +import type { AdbSocket } from "../../socket/index.js"; +import { DuplexStreamFactory, type ReadableStream } from "../../stream/index.js"; +import type { AdbSubprocessProtocol } from "./types.js"; /** * The legacy shell diff --git a/libraries/adb/src/commands/subprocess/protocol.ts b/libraries/adb/src/commands/subprocess/protocol.ts index 53064d00..d3bf8a22 100644 --- a/libraries/adb/src/commands/subprocess/protocol.ts +++ b/libraries/adb/src/commands/subprocess/protocol.ts @@ -1,11 +1,11 @@ import { PromiseResolver } from "@yume-chan/async"; import Struct, { placeholder, type StructValueType } from "@yume-chan/struct"; -import type { Adb } from "../../adb"; -import { AdbFeatures } from "../../features"; -import type { AdbSocket } from "../../socket"; -import { PushReadableStream, ReadableStream, StructDeserializeStream, StructSerializeStream, TransformStream, WritableStream, WritableStreamDefaultWriter, type PushReadableStreamController } from "../../stream"; -import { encodeUtf8 } from "../../utils"; -import type { AdbSubprocessProtocol } from "./types"; +import type { Adb } from "../../adb.js"; +import { AdbFeatures } from "../../features.js"; +import type { AdbSocket } from "../../socket/index.js"; +import { PushReadableStream, ReadableStream, StructDeserializeStream, StructSerializeStream, TransformStream, WritableStream, WritableStreamDefaultWriter, type PushReadableStreamController } from "../../stream/index.js"; +import { encodeUtf8 } from "../../utils/index.js"; +import type { AdbSubprocessProtocol } from "./types.js"; export enum AdbShellProtocolId { Stdin, diff --git a/libraries/adb/src/commands/subprocess/types.ts b/libraries/adb/src/commands/subprocess/types.ts index e163fec9..64783e99 100644 --- a/libraries/adb/src/commands/subprocess/types.ts +++ b/libraries/adb/src/commands/subprocess/types.ts @@ -1,7 +1,7 @@ import type { ValueOrPromise } from "@yume-chan/struct"; -import type { Adb } from "../../adb"; -import type { AdbSocket } from "../../socket"; -import type { ReadableStream, WritableStream } from "../../stream"; +import type { Adb } from "../../adb.js"; +import type { AdbSocket } from "../../socket/index.js"; +import type { ReadableStream, WritableStream } from "../../stream/index.js"; export interface AdbSubprocessProtocol { /** diff --git a/libraries/adb/src/commands/sync/index.ts b/libraries/adb/src/commands/sync/index.ts index 5eeac4c9..aa90a681 100644 --- a/libraries/adb/src/commands/sync/index.ts +++ b/libraries/adb/src/commands/sync/index.ts @@ -1,7 +1,7 @@ -export * from './list'; -export * from './pull'; -export * from './request'; -export * from './response'; -export * from './push'; -export * from './stat'; -export * from './sync'; +export * from './list.js'; +export * from './pull.js'; +export * from './request.js'; +export * from './response.js'; +export * from './push.js'; +export * from './stat.js'; +export * from './sync.js'; diff --git a/libraries/adb/src/commands/sync/list.ts b/libraries/adb/src/commands/sync/list.ts index 59d28e8c..507542c8 100644 --- a/libraries/adb/src/commands/sync/list.ts +++ b/libraries/adb/src/commands/sync/list.ts @@ -1,8 +1,8 @@ import Struct from '@yume-chan/struct'; -import type { AdbBufferedStream, WritableStreamDefaultWriter } from '../../stream'; -import { AdbSyncRequestId, adbSyncWriteRequest } from './request'; -import { AdbSyncDoneResponse, adbSyncReadResponse, AdbSyncResponseId } from './response'; -import { AdbSyncLstatResponse } from './stat'; +import type { AdbBufferedStream, WritableStreamDefaultWriter } from '../../stream/index.js'; +import { AdbSyncRequestId, adbSyncWriteRequest } from './request.js'; +import { AdbSyncDoneResponse, adbSyncReadResponse, AdbSyncResponseId } from './response.js'; +import { AdbSyncLstatResponse } from './stat.js'; export const AdbSyncEntryResponse = new Struct({ littleEndian: true }) diff --git a/libraries/adb/src/commands/sync/pull.ts b/libraries/adb/src/commands/sync/pull.ts index 8d3f5c3d..e2b13359 100644 --- a/libraries/adb/src/commands/sync/pull.ts +++ b/libraries/adb/src/commands/sync/pull.ts @@ -1,7 +1,7 @@ import Struct from '@yume-chan/struct'; -import { AdbBufferedStream, ReadableStream, WritableStreamDefaultWriter } from '../../stream'; -import { AdbSyncRequestId, adbSyncWriteRequest } from './request'; -import { AdbSyncDoneResponse, adbSyncReadResponse, AdbSyncResponseId } from './response'; +import { AdbBufferedStream, ReadableStream, WritableStreamDefaultWriter } from '../../stream/index.js'; +import { AdbSyncRequestId, adbSyncWriteRequest } from './request.js'; +import { AdbSyncDoneResponse, adbSyncReadResponse, AdbSyncResponseId } from './response.js'; export const AdbSyncDataResponse = new Struct({ littleEndian: true }) diff --git a/libraries/adb/src/commands/sync/push.ts b/libraries/adb/src/commands/sync/push.ts index bf0c26e8..c68cfad2 100644 --- a/libraries/adb/src/commands/sync/push.ts +++ b/libraries/adb/src/commands/sync/push.ts @@ -1,8 +1,8 @@ import Struct from '@yume-chan/struct'; -import { AdbBufferedStream, ChunkStream, pipeFrom, WritableStream, WritableStreamDefaultWriter } from '../../stream'; -import { AdbSyncRequestId, adbSyncWriteRequest } from './request'; -import { adbSyncReadResponse, AdbSyncResponseId } from './response'; -import { LinuxFileType } from './stat'; +import { AdbBufferedStream, ChunkStream, pipeFrom, WritableStream, WritableStreamDefaultWriter } from '../../stream/index.js'; +import { AdbSyncRequestId, adbSyncWriteRequest } from './request.js'; +import { adbSyncReadResponse, AdbSyncResponseId } from './response.js'; +import { LinuxFileType } from './stat.js'; export const AdbSyncOkResponse = new Struct({ littleEndian: true }) diff --git a/libraries/adb/src/commands/sync/request.ts b/libraries/adb/src/commands/sync/request.ts index 4a37d89b..3be2281c 100644 --- a/libraries/adb/src/commands/sync/request.ts +++ b/libraries/adb/src/commands/sync/request.ts @@ -1,6 +1,6 @@ import Struct from '@yume-chan/struct'; -import type { WritableStreamDefaultWriter } from "../../stream"; -import { encodeUtf8 } from "../../utils"; +import type { WritableStreamDefaultWriter } from "../../stream/index.js"; +import { encodeUtf8 } from "../../utils/index.js"; export enum AdbSyncRequestId { List = 'LIST', diff --git a/libraries/adb/src/commands/sync/response.ts b/libraries/adb/src/commands/sync/response.ts index 7e698a68..7e157d3e 100644 --- a/libraries/adb/src/commands/sync/response.ts +++ b/libraries/adb/src/commands/sync/response.ts @@ -1,6 +1,6 @@ import Struct, { type StructAsyncDeserializeStream, type StructLike, type StructValueType } from '@yume-chan/struct'; -import type { AdbBufferedStream } from '../../stream'; -import { decodeUtf8 } from "../../utils"; +import type { AdbBufferedStream } from '../../stream/index.js'; +import { decodeUtf8 } from "../../utils/index.js"; export enum AdbSyncResponseId { Entry = 'DENT', diff --git a/libraries/adb/src/commands/sync/stat.ts b/libraries/adb/src/commands/sync/stat.ts index b377211c..657cd05c 100644 --- a/libraries/adb/src/commands/sync/stat.ts +++ b/libraries/adb/src/commands/sync/stat.ts @@ -1,7 +1,7 @@ import Struct, { placeholder } from '@yume-chan/struct'; -import type { AdbBufferedStream, WritableStreamDefaultWriter } from '../../stream'; -import { AdbSyncRequestId, adbSyncWriteRequest } from './request'; -import { adbSyncReadResponse, AdbSyncResponseId } from './response'; +import type { AdbBufferedStream, WritableStreamDefaultWriter } from '../../stream/index.js'; +import { AdbSyncRequestId, adbSyncWriteRequest } from './request.js'; +import { adbSyncReadResponse, AdbSyncResponseId } from './response.js'; // https://github.com/python/cpython/blob/4e581d64b8aff3e2eda99b12f080c877bb78dfca/Lib/stat.py#L36 export enum LinuxFileType { diff --git a/libraries/adb/src/commands/sync/sync.ts b/libraries/adb/src/commands/sync/sync.ts index 667e4660..a53ff05f 100644 --- a/libraries/adb/src/commands/sync/sync.ts +++ b/libraries/adb/src/commands/sync/sync.ts @@ -1,13 +1,13 @@ import { AutoDisposable } from '@yume-chan/event'; -import type { Adb } from '../../adb'; -import { AdbFeatures } from '../../features'; -import type { AdbSocket } from '../../socket'; -import { AdbBufferedStream, ReadableStream, WrapReadableStream, WrapWritableStream, WritableStream, WritableStreamDefaultWriter } from '../../stream'; -import { AutoResetEvent } from '../../utils'; -import { AdbSyncEntryResponse, adbSyncOpenDir } from './list'; -import { adbSyncPull } from './pull'; -import { adbSyncPush } from './push'; -import { adbSyncLstat, adbSyncStat } from './stat'; +import type { Adb } from '../../adb.js'; +import { AdbFeatures } from '../../features.js'; +import type { AdbSocket } from '../../socket/index.js'; +import { AdbBufferedStream, ReadableStream, WrapReadableStream, WrapWritableStream, WritableStream, WritableStreamDefaultWriter } from '../../stream/index.js'; +import { AutoResetEvent } from '../../utils/index.js'; +import { AdbSyncEntryResponse, adbSyncOpenDir } from './list.js'; +import { adbSyncPull } from './pull.js'; +import { adbSyncPush } from './push.js'; +import { adbSyncLstat, adbSyncStat } from './stat.js'; export class AdbSync extends AutoDisposable { protected adb: Adb; diff --git a/libraries/adb/src/commands/tcpip.ts b/libraries/adb/src/commands/tcpip.ts index bf11931b..770d14a2 100644 --- a/libraries/adb/src/commands/tcpip.ts +++ b/libraries/adb/src/commands/tcpip.ts @@ -1,4 +1,4 @@ -import { AdbCommandBase } from './base'; +import { AdbCommandBase } from './base.js'; export class AdbTcpIpCommand extends AdbCommandBase { public async setPort(port: number): Promise { diff --git a/libraries/adb/src/crypto.ts b/libraries/adb/src/crypto.ts index 762a869c..4d87e1c4 100644 --- a/libraries/adb/src/crypto.ts +++ b/libraries/adb/src/crypto.ts @@ -1,4 +1,4 @@ -import { getBigUint64, setBigUint64 } from '@yume-chan/dataview-bigint-polyfill/esm/fallback'; +import { getBigUint64, setBigUint64 } from '@yume-chan/dataview-bigint-polyfill/esm/fallback.js'; const BigInt0 = BigInt(0); const BigInt1 = BigInt(1); diff --git a/libraries/adb/src/packet.ts b/libraries/adb/src/packet.ts index 9a925e08..9841d0c1 100644 --- a/libraries/adb/src/packet.ts +++ b/libraries/adb/src/packet.ts @@ -1,5 +1,5 @@ import Struct from '@yume-chan/struct'; -import { TransformStream } from "./stream"; +import { TransformStream } from "./stream/index.js"; export enum AdbCommand { Auth = 0x48545541, // 'AUTH' diff --git a/libraries/adb/src/socket/dispatcher.ts b/libraries/adb/src/socket/dispatcher.ts index 0bc95314..54b79155 100644 --- a/libraries/adb/src/socket/dispatcher.ts +++ b/libraries/adb/src/socket/dispatcher.ts @@ -1,9 +1,9 @@ import { AsyncOperationManager } from '@yume-chan/async'; import { AutoDisposable, EventEmitter } from '@yume-chan/event'; -import { AdbCommand, AdbPacket, calculateChecksum, type AdbPacketCore, type AdbPacketInit } from '../packet'; -import { AbortController, WritableStream, WritableStreamDefaultWriter, type ReadableWritablePair } from '../stream'; -import { decodeUtf8, encodeUtf8 } from '../utils'; -import { AdbSocket } from './socket'; +import { AdbCommand, AdbPacket, calculateChecksum, type AdbPacketCore, type AdbPacketInit } from '../packet.js'; +import { AbortController, WritableStream, WritableStreamDefaultWriter, type ReadableWritablePair } from '../stream/index.js'; +import { decodeUtf8, encodeUtf8 } from '../utils/index.js'; +import { AdbSocket } from './socket.js'; export interface AdbIncomingSocketEventArgs { handled: boolean; diff --git a/libraries/adb/src/socket/index.ts b/libraries/adb/src/socket/index.ts index 70f33249..ecebfbfb 100644 --- a/libraries/adb/src/socket/index.ts +++ b/libraries/adb/src/socket/index.ts @@ -1,2 +1,2 @@ -export * from './socket'; -export * from './dispatcher'; +export * from './socket.js'; +export * from './dispatcher.js'; diff --git a/libraries/adb/src/socket/socket.ts b/libraries/adb/src/socket/socket.ts index c45e7d3b..f94ff97c 100644 --- a/libraries/adb/src/socket/socket.ts +++ b/libraries/adb/src/socket/socket.ts @@ -1,7 +1,7 @@ import { PromiseResolver } from "@yume-chan/async"; -import { AdbCommand } from '../packet'; -import { ChunkStream, DuplexStreamFactory, pipeFrom, ReadableStream, WritableStream, type PushReadableStreamController } from '../stream'; -import type { AdbPacketDispatcher } from './dispatcher'; +import { AdbCommand } from '../packet.js'; +import { ChunkStream, DuplexStreamFactory, pipeFrom, ReadableStream, WritableStream, type PushReadableStreamController } from '../stream/index.js'; +import type { AdbPacketDispatcher } from './dispatcher.js'; export interface AdbSocketInfo { localId: number; diff --git a/libraries/adb/src/stream/buffered.ts b/libraries/adb/src/stream/buffered.ts index c974d283..5f608786 100644 --- a/libraries/adb/src/stream/buffered.ts +++ b/libraries/adb/src/stream/buffered.ts @@ -1,7 +1,7 @@ import type { StructAsyncDeserializeStream } from '@yume-chan/struct'; -import type { AdbSocket, AdbSocketInfo } from '../socket'; -import type { ReadableStream, ReadableStreamDefaultReader } from './detect'; -import { PushReadableStream } from "./transform"; +import type { AdbSocket, AdbSocketInfo } from '../socket/index.js'; +import type { ReadableStream, ReadableStreamDefaultReader } from './detect.js'; +import { PushReadableStream } from "./transform.js"; export class BufferedStreamEndedError extends Error { public constructor() { diff --git a/libraries/adb/src/stream/index.ts b/libraries/adb/src/stream/index.ts index c36e6f31..bba009b6 100644 --- a/libraries/adb/src/stream/index.ts +++ b/libraries/adb/src/stream/index.ts @@ -1,3 +1,3 @@ -export * from './buffered'; -export * from './detect'; -export * from './transform'; +export * from './buffered.js'; +export * from './detect.js'; +export * from './transform.js'; diff --git a/libraries/adb/src/stream/transform.ts b/libraries/adb/src/stream/transform.ts index 3a7d1c71..c1aa854a 100644 --- a/libraries/adb/src/stream/transform.ts +++ b/libraries/adb/src/stream/transform.ts @@ -1,9 +1,9 @@ import { PromiseResolver } from "@yume-chan/async"; import type Struct from "@yume-chan/struct"; import type { StructValueType } from "@yume-chan/struct"; -import { decodeUtf8 } from "../utils"; -import { BufferedStream, BufferedStreamEndedError } from "./buffered"; -import { AbortController, AbortSignal, ReadableStream, ReadableStreamDefaultReader, TransformStream, WritableStream, WritableStreamDefaultWriter, type QueuingStrategy, type ReadableStreamController, type ReadableWritablePair, type UnderlyingSink, type UnderlyingSource } from "./detect"; +import { decodeUtf8 } from "../utils/index.js"; +import { BufferedStream, BufferedStreamEndedError } from "./buffered.js"; +import { AbortController, AbortSignal, ReadableStream, ReadableStreamDefaultReader, TransformStream, WritableStream, WritableStreamDefaultWriter, type QueuingStrategy, type ReadableStreamController, type ReadableWritablePair, type UnderlyingSink, type UnderlyingSource } from "./detect.js"; export interface DuplexStreamFactoryOptions { preventCloseReadableStreams?: boolean | undefined; diff --git a/libraries/adb/src/utils/index.ts b/libraries/adb/src/utils/index.ts index 9f712889..92f6cdbb 100644 --- a/libraries/adb/src/utils/index.ts +++ b/libraries/adb/src/utils/index.ts @@ -1,3 +1,3 @@ -export * from './auto-reset-event'; -export * from './base64'; -export * from './encoding'; +export * from './auto-reset-event.js'; +export * from './base64.js'; +export * from './encoding.js'; diff --git a/libraries/android-bin/package.json b/libraries/android-bin/package.json index 29d278a5..d5204453 100644 --- a/libraries/android-bin/package.json +++ b/libraries/android-bin/package.json @@ -22,7 +22,7 @@ "url": "https://github.com/yume-chan/ya-webadb/issues" }, "type": "module", - "module": "esm/index.js", + "main": "esm/index.js", "types": "esm/index.d.ts", "scripts": { "build": "build-ts-package", @@ -30,7 +30,7 @@ "prepublishOnly": "npm run build" }, "devDependencies": { - "typescript": "^4.6.2", + "typescript": "next", "@yume-chan/ts-package-builder": "^1.0.0" }, "dependencies": { diff --git a/libraries/android-bin/src/demo-mode.ts b/libraries/android-bin/src/demo-mode.ts index 60feecac..1ee4a2d1 100644 --- a/libraries/android-bin/src/demo-mode.ts +++ b/libraries/android-bin/src/demo-mode.ts @@ -5,7 +5,7 @@ // cspell: ignore sysui import { Adb, AdbCommandBase } from '@yume-chan/adb'; -import { Settings } from "./settings"; +import { Settings } from "./settings.js"; export enum DemoModeSignalStrength { Hidden = 'null', diff --git a/libraries/android-bin/src/index.ts b/libraries/android-bin/src/index.ts index b821d730..c9c23c66 100644 --- a/libraries/android-bin/src/index.ts +++ b/libraries/android-bin/src/index.ts @@ -1,3 +1,3 @@ -export * from './bug-report'; -export * from './demo-mode'; -export * from './settings'; +export * from './bug-report.js'; +export * from './demo-mode.js'; +export * from './settings.js'; diff --git a/libraries/dataview-bigint-polyfill/package.json b/libraries/dataview-bigint-polyfill/package.json index 41d5bc77..b702900a 100644 --- a/libraries/dataview-bigint-polyfill/package.json +++ b/libraries/dataview-bigint-polyfill/package.json @@ -26,7 +26,7 @@ "url": "https://github.com/yume-chan/ya-webadb/issues" }, "type": "module", - "module": "esm/index.js", + "main": "esm/index.js", "types": "esm/index.d.ts", "scripts": { "build": "build-ts-package", @@ -39,7 +39,7 @@ }, "devDependencies": { "jest": "^26.6.3", - "typescript": "^4.6.2", + "typescript": "next", "@yume-chan/ts-package-builder": "^1.0.0" } } diff --git a/libraries/dataview-bigint-polyfill/src/fallback.ts b/libraries/dataview-bigint-polyfill/src/fallback.ts index a2052039..b10bfe14 100644 --- a/libraries/dataview-bigint-polyfill/src/fallback.ts +++ b/libraries/dataview-bigint-polyfill/src/fallback.ts @@ -1,4 +1,4 @@ -import { getBigInt64 as fallbackGetBigInt64, getBigUint64 as fallbackGetBigUint64, setBigInt64 as fallbackSetBigInt64, setBigUint64 as fallbackSetBigUint64 } from './pure'; +import { getBigInt64 as fallbackGetBigInt64, getBigUint64 as fallbackGetBigUint64, setBigInt64 as fallbackSetBigInt64, setBigUint64 as fallbackSetBigUint64 } from './pure.js'; export const getBigInt64 = 'getBigInt64' in DataView.prototype ? diff --git a/libraries/dataview-bigint-polyfill/src/index.ts b/libraries/dataview-bigint-polyfill/src/index.ts index d18396b9..76004042 100644 --- a/libraries/dataview-bigint-polyfill/src/index.ts +++ b/libraries/dataview-bigint-polyfill/src/index.ts @@ -1 +1 @@ -export * from './pure'; +export * from './pure.js'; diff --git a/libraries/dataview-bigint-polyfill/src/polyfill.ts b/libraries/dataview-bigint-polyfill/src/polyfill.ts index fc3ee828..4b553cd1 100644 --- a/libraries/dataview-bigint-polyfill/src/polyfill.ts +++ b/libraries/dataview-bigint-polyfill/src/polyfill.ts @@ -1,4 +1,4 @@ -import { getBigInt64, getBigUint64, setBigInt64, setBigUint64 } from './pure'; +import { getBigInt64, getBigUint64, setBigInt64, setBigUint64 } from './pure.js'; if (!('getBigInt64' in DataView)) { DataView.prototype.getBigInt64 = function (byteOffset, littleEndian) { diff --git a/libraries/event/package.json b/libraries/event/package.json index 892b3101..63c6964b 100644 --- a/libraries/event/package.json +++ b/libraries/event/package.json @@ -23,7 +23,7 @@ "url": "https://github.com/yume-chan/ya-webadb/issues" }, "type": "module", - "module": "esm/index.js", + "main": "esm/index.js", "types": "esm/index.d.ts", "scripts": { "build": "build-ts-package", @@ -37,7 +37,7 @@ }, "devDependencies": { "jest": "^26.6.3", - "typescript": "^4.6.2", + "typescript": "next", "@yume-chan/ts-package-builder": "^1.0.0" } } diff --git a/libraries/event/src/disposable.spec.ts b/libraries/event/src/disposable.spec.ts index 45e9a405..eb8e7237 100644 --- a/libraries/event/src/disposable.spec.ts +++ b/libraries/event/src/disposable.spec.ts @@ -1,4 +1,4 @@ -import { AutoDisposable, Disposable } from './disposable'; +import { AutoDisposable, Disposable } from './disposable.js'; describe('Event', () => { describe('AutoDisposable', () => { diff --git a/libraries/event/src/event-emitter.ts b/libraries/event/src/event-emitter.ts index 2dfef082..de773ddf 100644 --- a/libraries/event/src/event-emitter.ts +++ b/libraries/event/src/event-emitter.ts @@ -1,5 +1,5 @@ -import type { Disposable } from './disposable'; -import type { EventListener, RemoveEventListener } from './event'; +import type { Disposable } from './disposable.js'; +import type { EventListener, RemoveEventListener } from './event.js'; export interface EventListenerInfo { listener: EventListener; diff --git a/libraries/event/src/event.ts b/libraries/event/src/event.ts index d9dad6f5..aba0d8f8 100644 --- a/libraries/event/src/event.ts +++ b/libraries/event/src/event.ts @@ -1,4 +1,4 @@ -import type { Disposable } from './disposable'; +import type { Disposable } from './disposable.js'; export interface EventListener { (this: TThis, e: TEvent, ...args: TArgs): TResult; diff --git a/libraries/event/src/index.ts b/libraries/event/src/index.ts index 39fd8e2c..960cabb1 100644 --- a/libraries/event/src/index.ts +++ b/libraries/event/src/index.ts @@ -1,4 +1,4 @@ -export * from './disposable'; -export * from './event'; -export * from './event-emitter'; -export * from './utils'; +export * from './disposable.js'; +export * from './event.js'; +export * from './event-emitter.js'; +export * from './utils.js'; diff --git a/libraries/event/src/utils.ts b/libraries/event/src/utils.ts index 92430bbd..df890994 100644 --- a/libraries/event/src/utils.ts +++ b/libraries/event/src/utils.ts @@ -1,5 +1,5 @@ import { PromiseResolver } from '@yume-chan/async'; -import type { Event } from './event'; +import type { Event } from './event.js'; export async function once(event: Event): Promise { const resolver = new PromiseResolver(); diff --git a/libraries/scrcpy/README.md b/libraries/scrcpy/README.md index a49047c2..bb92b7fd 100644 --- a/libraries/scrcpy/README.md +++ b/libraries/scrcpy/README.md @@ -48,7 +48,8 @@ Scrcpy server has no backward compatibility on options input format. Currently t | --------- | ------------------- | | 1.16~1.17 | `ScrcpyOptions1_16` | | 1.18~1.20 | `ScrcpyOptions1_18` | -| 1.21~1.22 | `ScrcpyOptions1_21` | +| 1.21 | `ScrcpyOptions1_21` | +| 1.22 | `ScrcpyOptions1_22` | You must use the correct type according to the server version. diff --git a/libraries/scrcpy/package.json b/libraries/scrcpy/package.json index 24cf43cc..06c1387e 100644 --- a/libraries/scrcpy/package.json +++ b/libraries/scrcpy/package.json @@ -26,7 +26,7 @@ "fetch-scrcpy-server": "scripts/fetch-server.cjs" }, "type": "module", - "module": "esm/index.js", + "main": "esm/index.js", "types": "esm/index.d.ts", "scripts": { "build": "build-ts-package", @@ -48,7 +48,7 @@ "gh-release-fetch": "^2.0.4", "jest": "^26.6.3", "tinyh264": "^0.0.7", - "typescript": "^4.6.2", + "typescript": "next", "yuv-buffer": "^1.0.0", "yuv-canvas": "^1.2.7" }, diff --git a/libraries/scrcpy/src/client.ts b/libraries/scrcpy/src/client.ts index 23eb8b88..cba064a9 100644 --- a/libraries/scrcpy/src/client.ts +++ b/libraries/scrcpy/src/client.ts @@ -1,8 +1,8 @@ import { Adb, AdbBufferedStream, AdbNoneSubprocessProtocol, AdbSocket, DecodeUtf8Stream, InspectStream, ReadableStream, TransformStream, WritableStreamDefaultWriter, type AdbSubprocessProtocol } from '@yume-chan/adb'; import { EventEmitter } from '@yume-chan/event'; import Struct from '@yume-chan/struct'; -import { AndroidMotionEventAction, ScrcpyControlMessageType, ScrcpyInjectKeyCodeControlMessage, ScrcpyInjectTextControlMessage, ScrcpyInjectTouchControlMessage, type AndroidKeyEventAction } from './message'; -import type { ScrcpyInjectScrollControlMessage1_22, ScrcpyOptions, VideoStreamPacket } from "./options"; +import { AndroidMotionEventAction, ScrcpyControlMessageType, ScrcpyInjectKeyCodeControlMessage, ScrcpyInjectTextControlMessage, ScrcpyInjectTouchControlMessage, type AndroidKeyEventAction } from './message.js'; +import type { ScrcpyInjectScrollControlMessage1_22, ScrcpyOptions, VideoStreamPacket } from "./options/index.js"; function* splitLines(text: string): Generator { let start = 0; diff --git a/libraries/scrcpy/src/connection.ts b/libraries/scrcpy/src/connection.ts index ceea7bba..e40765b2 100644 --- a/libraries/scrcpy/src/connection.ts +++ b/libraries/scrcpy/src/connection.ts @@ -1,7 +1,7 @@ import { Adb, AdbBufferedStream, AdbSocket } from "@yume-chan/adb"; import type { Disposable } from "@yume-chan/event"; import type { ValueOrPromise } from "@yume-chan/struct"; -import { delay } from "./utils"; +import { delay } from "./utils.js"; export interface ScrcpyClientConnectionOptions { control: boolean; diff --git a/libraries/scrcpy/src/decoder/common.ts b/libraries/scrcpy/src/decoder/common.ts index 074b14dd..c0216c7b 100644 --- a/libraries/scrcpy/src/decoder/common.ts +++ b/libraries/scrcpy/src/decoder/common.ts @@ -1,7 +1,7 @@ import type { WritableStream } from '@yume-chan/adb'; import type { Disposable } from "@yume-chan/event"; -import type { AndroidCodecLevel, AndroidCodecProfile } from "../codec"; -import type { VideoStreamPacket } from "../options"; +import type { AndroidCodecLevel, AndroidCodecProfile } from "../codec.js"; +import type { VideoStreamPacket } from "../options/index.js"; export interface H264Configuration { profileIndex: number; diff --git a/libraries/scrcpy/src/decoder/index.ts b/libraries/scrcpy/src/decoder/index.ts index 1c2c8214..f6c7a5ab 100644 --- a/libraries/scrcpy/src/decoder/index.ts +++ b/libraries/scrcpy/src/decoder/index.ts @@ -1,3 +1,3 @@ -export * from './common'; -export * from './tinyh264'; -export * from './web-codecs'; +export * from './common.js'; +export * from './tinyh264/index.js'; +export * from './web-codecs/index.js'; diff --git a/libraries/scrcpy/src/decoder/tinyh264/index.ts b/libraries/scrcpy/src/decoder/tinyh264/index.ts index 3c9b51ce..6d7993eb 100644 --- a/libraries/scrcpy/src/decoder/tinyh264/index.ts +++ b/libraries/scrcpy/src/decoder/tinyh264/index.ts @@ -1,9 +1,9 @@ import { WritableStream } from "@yume-chan/adb"; import { PromiseResolver } from "@yume-chan/async"; -import { AndroidCodecLevel, AndroidCodecProfile } from "../../codec"; -import type { VideoStreamPacket } from "../../options"; -import type { H264Configuration, H264Decoder } from '../common'; -import { createTinyH264Wrapper, type TinyH264Wrapper } from "./wrapper"; +import { AndroidCodecLevel, AndroidCodecProfile } from "../../codec.js"; +import type { VideoStreamPacket } from "../../options/index.js"; +import type { H264Configuration, H264Decoder } from "../common.js"; +import { createTinyH264Wrapper, type TinyH264Wrapper } from "./wrapper.js"; let cachedInitializePromise: Promise<{ YuvBuffer: typeof import('yuv-buffer'), YuvCanvas: typeof import('yuv-canvas').default; }> | undefined; function initialize() { diff --git a/libraries/scrcpy/src/decoder/web-codecs/index.ts b/libraries/scrcpy/src/decoder/web-codecs/index.ts index e6d1c1d8..bda27509 100644 --- a/libraries/scrcpy/src/decoder/web-codecs/index.ts +++ b/libraries/scrcpy/src/decoder/web-codecs/index.ts @@ -1,5 +1,5 @@ -import type { VideoStreamPacket } from "../../options"; -import type { H264Configuration, H264Decoder } from "../common"; +import type { VideoStreamPacket } from "../../options/index.js"; +import type { H264Configuration, H264Decoder } from "../common.js"; function toHex(value: number) { return value.toString(16).padStart(2, '0').toUpperCase(); diff --git a/libraries/scrcpy/src/index.ts b/libraries/scrcpy/src/index.ts index 95680dbb..42121a24 100644 --- a/libraries/scrcpy/src/index.ts +++ b/libraries/scrcpy/src/index.ts @@ -1,8 +1,8 @@ -export * from './client'; -export * from './codec'; -export * from './connection'; -export * from './decoder'; -export * from './message'; -export * from './options'; -export * from './push-server'; -export * from './utils'; +export * from './client.js'; +export * from './codec.js'; +export * from './connection.js'; +export * from './decoder/index.js'; +export * from './message.js'; +export * from './options/index.js'; +export * from './push-server.js'; +export * from './utils.js'; diff --git a/libraries/scrcpy/src/options/1_16/index.ts b/libraries/scrcpy/src/options/1_16/index.ts index dcc477a5..63ced375 100644 --- a/libraries/scrcpy/src/options/1_16/index.ts +++ b/libraries/scrcpy/src/options/1_16/index.ts @@ -1,12 +1,12 @@ import { BufferedStreamEndedError, ReadableStream, TransformStream, type Adb, type AdbBufferedStream } from "@yume-chan/adb"; import Struct, { placeholder } from "@yume-chan/struct"; -import type { AndroidCodecLevel, AndroidCodecProfile } from "../../codec"; -import { ScrcpyClientConnection, ScrcpyClientForwardConnection, ScrcpyClientReverseConnection, type ScrcpyClientConnectionOptions } from "../../connection"; -import { AndroidKeyEventAction, ScrcpyControlMessageType } from "../../message"; -import type { ScrcpyBackOrScreenOnEvent1_18 } from "../1_18"; -import type { ScrcpyInjectScrollControlMessage1_22 } from "../1_22"; -import { toScrcpyOptionValue, type ScrcpyOptions, type ScrcpyOptionValue, type VideoStreamPacket } from "../common"; -import { parse_sequence_parameter_set } from "./sps"; +import type { AndroidCodecLevel, AndroidCodecProfile } from "../../codec.js"; +import { ScrcpyClientConnection, ScrcpyClientForwardConnection, ScrcpyClientReverseConnection, type ScrcpyClientConnectionOptions } from "../../connection.js"; +import { AndroidKeyEventAction, ScrcpyControlMessageType } from "../../message.js"; +import type { ScrcpyBackOrScreenOnEvent1_18 } from "../1_18.js"; +import type { ScrcpyInjectScrollControlMessage1_22 } from "../1_22.js"; +import { toScrcpyOptionValue, type ScrcpyOptions, type ScrcpyOptionValue, type VideoStreamPacket } from "../common.js"; +import { parse_sequence_parameter_set } from "./sps.js"; export enum ScrcpyLogLevel { Verbose = 'verbose', diff --git a/libraries/scrcpy/src/options/1_18.ts b/libraries/scrcpy/src/options/1_18.ts index 2b236533..98bf9935 100644 --- a/libraries/scrcpy/src/options/1_18.ts +++ b/libraries/scrcpy/src/options/1_18.ts @@ -1,6 +1,6 @@ import Struct, { placeholder } from "@yume-chan/struct"; -import type { AndroidKeyEventAction } from "../message"; -import { ScrcpyBackOrScreenOnEvent1_16, ScrcpyOptions1_16, type ScrcpyOptionsInit1_16 } from "./1_16"; +import type { AndroidKeyEventAction } from "../message.js"; +import { ScrcpyBackOrScreenOnEvent1_16, ScrcpyOptions1_16, type ScrcpyOptionsInit1_16 } from "./1_16/index.js"; export interface ScrcpyOptionsInit1_18 extends ScrcpyOptionsInit1_16 { powerOffOnClose: boolean; diff --git a/libraries/scrcpy/src/options/1_21.ts b/libraries/scrcpy/src/options/1_21.ts index 8a970402..77b6519b 100644 --- a/libraries/scrcpy/src/options/1_21.ts +++ b/libraries/scrcpy/src/options/1_21.ts @@ -1,7 +1,7 @@ // cspell: ignore autosync -import { ScrcpyOptions1_18, type ScrcpyOptionsInit1_18 } from './1_18'; -import { toScrcpyOptionValue } from "./common"; +import { ScrcpyOptions1_18, type ScrcpyOptionsInit1_18 } from './1_18.js'; +import { toScrcpyOptionValue } from "./common.js"; export interface ScrcpyOptionsInit1_21 extends ScrcpyOptionsInit1_18 { clipboardAutosync?: boolean; diff --git a/libraries/scrcpy/src/options/1_22.ts b/libraries/scrcpy/src/options/1_22.ts index b30790e1..a57773d5 100644 --- a/libraries/scrcpy/src/options/1_22.ts +++ b/libraries/scrcpy/src/options/1_22.ts @@ -1,8 +1,8 @@ import type { Adb } from "@yume-chan/adb"; import Struct from "@yume-chan/struct"; -import { ScrcpyClientForwardConnection, ScrcpyClientReverseConnection, type ScrcpyClientConnection, type ScrcpyClientConnectionOptions } from "../connection"; -import { ScrcpyInjectScrollControlMessage1_16 } from "./1_16"; -import { ScrcpyOptions1_21, type ScrcpyOptionsInit1_21 } from "./1_21"; +import { ScrcpyClientForwardConnection, ScrcpyClientReverseConnection, type ScrcpyClientConnection, type ScrcpyClientConnectionOptions } from "../connection.js"; +import { ScrcpyInjectScrollControlMessage1_16 } from "./1_16/index.js"; +import { ScrcpyOptions1_21, type ScrcpyOptionsInit1_21 } from "./1_21.js"; export interface ScrcpyOptionsInit1_22 extends ScrcpyOptionsInit1_21 { downsizeOnError: boolean; diff --git a/libraries/scrcpy/src/options/common.ts b/libraries/scrcpy/src/options/common.ts index 0907f3c5..5c01b9b7 100644 --- a/libraries/scrcpy/src/options/common.ts +++ b/libraries/scrcpy/src/options/common.ts @@ -1,8 +1,8 @@ import type { Adb, AdbBufferedStream, ReadableStream } from "@yume-chan/adb"; -import type { ScrcpyClientConnection } from "../connection"; -import type { H264Configuration } from "../decoder"; -import type { ScrcpyBackOrScreenOnEvent1_18 } from "./1_18"; -import type { ScrcpyInjectScrollControlMessage1_22 } from "./1_22"; +import type { ScrcpyClientConnection } from "../connection.js"; +import type { H264Configuration } from "../decoder/index.js"; +import type { ScrcpyBackOrScreenOnEvent1_18 } from "./1_18.js"; +import type { ScrcpyInjectScrollControlMessage1_22 } from "./1_22.js"; export const DEFAULT_SERVER_PATH = '/data/local/tmp/scrcpy-server.jar'; diff --git a/libraries/scrcpy/src/options/index.ts b/libraries/scrcpy/src/options/index.ts index 169bed37..1e5e752b 100644 --- a/libraries/scrcpy/src/options/index.ts +++ b/libraries/scrcpy/src/options/index.ts @@ -1,5 +1,5 @@ -export * from './1_16'; -export * from './1_18'; -export * from './1_21'; -export * from './1_22'; -export * from './common'; +export * from './1_16/index.js'; +export * from './1_18.js'; +export * from './1_21.js'; +export * from './1_22.js'; +export * from './common.js'; diff --git a/libraries/scrcpy/src/push-server.ts b/libraries/scrcpy/src/push-server.ts index 7adc1143..daf874fc 100644 --- a/libraries/scrcpy/src/push-server.ts +++ b/libraries/scrcpy/src/push-server.ts @@ -1,5 +1,5 @@ import { Adb, AdbSync, WrapWritableStream, WritableStream } from "@yume-chan/adb"; -import { DEFAULT_SERVER_PATH } from "./options"; +import { DEFAULT_SERVER_PATH } from "./options/index.js"; export interface PushServerOptions { path?: string; diff --git a/libraries/struct/package.json b/libraries/struct/package.json index aa2263b0..820461a6 100644 --- a/libraries/struct/package.json +++ b/libraries/struct/package.json @@ -24,7 +24,7 @@ "url": "https://github.com/yume-chan/ya-webadb/issues" }, "type": "module", - "module": "esm/index.js", + "main": "esm/index.js", "types": "esm/index.d.ts", "scripts": { "build": "build-ts-package", @@ -39,7 +39,7 @@ }, "devDependencies": { "jest": "^26.6.3", - "typescript": "^4.6.2", + "typescript": "next", "@yume-chan/ts-package-builder": "^1.0.0", "@types/jest": "^27.4.0", "@types/bluebird": "^3.5.36" diff --git a/libraries/struct/src/basic/definition.spec.ts b/libraries/struct/src/basic/definition.spec.ts index 8efb86fa..21851ed4 100644 --- a/libraries/struct/src/basic/definition.spec.ts +++ b/libraries/struct/src/basic/definition.spec.ts @@ -1,9 +1,9 @@ -import type { ValueOrPromise } from '../utils'; -import { StructFieldDefinition } from './definition'; -import type { StructFieldValue } from './field-value'; -import type { StructOptions } from './options'; -import type { StructAsyncDeserializeStream, StructDeserializeStream } from './stream'; -import type { StructValue } from './struct-value'; +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, StructDeserializeStream } from './stream.js'; +import type { StructValue } from './struct-value.js'; describe('StructFieldDefinition', () => { describe('.constructor', () => { diff --git a/libraries/struct/src/basic/definition.ts b/libraries/struct/src/basic/definition.ts index 8fa6a958..799797ab 100644 --- a/libraries/struct/src/basic/definition.ts +++ b/libraries/struct/src/basic/definition.ts @@ -1,9 +1,9 @@ // cspell: ignore Syncbird -import type { StructAsyncDeserializeStream, StructDeserializeStream } from './stream'; -import type { StructFieldValue } from './field-value'; -import type { StructValue } from './struct-value'; -import type { StructOptions } from "./options"; +import type { StructAsyncDeserializeStream, StructDeserializeStream } from "./stream.js"; +import type { StructFieldValue } from "./field-value.js"; +import type { StructValue } from "./struct-value.js"; +import type { StructOptions } from "./options.js"; /** * A field definition defines how to deserialize a field. diff --git a/libraries/struct/src/basic/field-value.spec.ts b/libraries/struct/src/basic/field-value.spec.ts index dcf32115..fd256a7d 100644 --- a/libraries/struct/src/basic/field-value.spec.ts +++ b/libraries/struct/src/basic/field-value.spec.ts @@ -1,9 +1,9 @@ -import type { ValueOrPromise } from '../utils'; -import { StructFieldDefinition } from './definition'; -import { StructFieldValue } from './field-value'; -import type { StructOptions } from './options'; -import type { StructAsyncDeserializeStream, StructDeserializeStream } from './stream'; -import type { StructValue } from './struct-value'; +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, StructDeserializeStream } from "./stream.js"; +import type { StructValue } from "./struct-value.js"; describe('StructFieldValue', () => { describe('.constructor', () => { diff --git a/libraries/struct/src/basic/field-value.ts b/libraries/struct/src/basic/field-value.ts index 3c369ad3..52b379d7 100644 --- a/libraries/struct/src/basic/field-value.ts +++ b/libraries/struct/src/basic/field-value.ts @@ -1,6 +1,6 @@ -import type { StructFieldDefinition } from './definition'; -import type { StructOptions } from './options'; -import type { StructValue } from './struct-value'; +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. diff --git a/libraries/struct/src/basic/index.ts b/libraries/struct/src/basic/index.ts index 8ba6cb7a..e56e3e31 100644 --- a/libraries/struct/src/basic/index.ts +++ b/libraries/struct/src/basic/index.ts @@ -1,5 +1,5 @@ -export * from './definition'; -export * from './field-value'; -export * from './options'; -export * from './stream'; -export * from './struct-value'; +export * from './definition.js'; +export * from './field-value.js'; +export * from './options.js'; +export * from './stream.js'; +export * from './struct-value.js'; diff --git a/libraries/struct/src/basic/options.spec.ts b/libraries/struct/src/basic/options.spec.ts index b0fa1741..d236f40c 100644 --- a/libraries/struct/src/basic/options.spec.ts +++ b/libraries/struct/src/basic/options.spec.ts @@ -1,4 +1,4 @@ -import { StructDefaultOptions } from './options'; +import { StructDefaultOptions } from './options.js'; describe('StructDefaultOptions', () => { describe('.littleEndian', () => { diff --git a/libraries/struct/src/basic/struct-value.spec.ts b/libraries/struct/src/basic/struct-value.spec.ts index 2cb8cb07..54102a24 100644 --- a/libraries/struct/src/basic/struct-value.spec.ts +++ b/libraries/struct/src/basic/struct-value.spec.ts @@ -1,4 +1,4 @@ -import { StructValue } from './struct-value'; +import { StructValue } from "./struct-value.js"; describe('StructValue', () => { describe('.constructor', () => { diff --git a/libraries/struct/src/basic/struct-value.ts b/libraries/struct/src/basic/struct-value.ts index ec669af4..dfdfb957 100644 --- a/libraries/struct/src/basic/struct-value.ts +++ b/libraries/struct/src/basic/struct-value.ts @@ -1,4 +1,4 @@ -import type { StructFieldValue } from './field-value'; +import type { StructFieldValue } from "./field-value.js"; /** * A struct value is a map between keys in a struct and their field values. diff --git a/libraries/struct/src/index.spec.ts b/libraries/struct/src/index.spec.ts index 4f263d9d..edf41fba 100644 --- a/libraries/struct/src/index.spec.ts +++ b/libraries/struct/src/index.spec.ts @@ -1,4 +1,4 @@ -import Struct from './index'; +import Struct from './index.js'; describe('Struct', () => { describe("Index", () => { diff --git a/libraries/struct/src/index.ts b/libraries/struct/src/index.ts index c376b214..61a2a217 100644 --- a/libraries/struct/src/index.ts +++ b/libraries/struct/src/index.ts @@ -10,8 +10,8 @@ declare global { } } -export * from './basic'; -export * from './struct'; -export { Struct as default } from './struct'; -export * from './types'; -export * from './utils'; +export * from './basic/index.js'; +export * from './struct.js'; +export { Struct as default } from './struct.js'; +export * from './types/index.js'; +export * from './utils.js'; diff --git a/libraries/struct/src/struct.spec.ts b/libraries/struct/src/struct.spec.ts index dd380d0e..6f0799e9 100644 --- a/libraries/struct/src/struct.spec.ts +++ b/libraries/struct/src/struct.spec.ts @@ -1,7 +1,7 @@ -import { StructAsyncDeserializeStream, StructDefaultOptions, StructDeserializeStream, StructFieldDefinition, StructFieldValue, StructOptions, StructValue } from './basic'; -import { Struct } from './struct'; -import { ArrayBufferFieldType, BigIntFieldDefinition, BigIntFieldType, FixedLengthArrayBufferLikeFieldDefinition, NumberFieldDefinition, NumberFieldType, StringFieldType, ArrayBufferViewFieldType, VariableLengthArrayBufferLikeFieldDefinition } from './types'; -import { ValueOrPromise } from './utils'; +import { StructAsyncDeserializeStream, StructDefaultOptions, StructDeserializeStream, StructFieldDefinition, StructFieldValue, StructOptions, StructValue } from './basic/index.js'; +import { Struct } from './struct.js'; +import { ArrayBufferFieldType, BigIntFieldDefinition, BigIntFieldType, FixedLengthArrayBufferLikeFieldDefinition, NumberFieldDefinition, NumberFieldType, StringFieldType, ArrayBufferViewFieldType, VariableLengthArrayBufferLikeFieldDefinition } from './types/index.js'; +import { ValueOrPromise } from './utils.js'; class MockDeserializationStream implements StructDeserializeStream { public buffer = new ArrayBuffer(0); diff --git a/libraries/struct/src/struct.ts b/libraries/struct/src/struct.ts index 2f20b6bc..97cb1d59 100644 --- a/libraries/struct/src/struct.ts +++ b/libraries/struct/src/struct.ts @@ -1,10 +1,10 @@ // cspell: ignore Syncbird -import type { StructAsyncDeserializeStream, StructDeserializeStream, StructFieldDefinition, StructFieldValue, StructOptions } from './basic'; -import { StructDefaultOptions, StructValue } from './basic'; -import { Syncbird } from "./syncbird"; -import { BigIntFieldDefinition, BigIntFieldType, BufferFieldSubType, FixedLengthBufferLikeFieldDefinition, NumberFieldDefinition, NumberFieldType, StringBufferFieldSubType, Uint8ArrayBufferFieldSubType, VariableLengthBufferLikeFieldDefinition, type FixedLengthBufferLikeFieldOptions, type LengthField, type VariableLengthBufferLikeFieldOptions } from './types'; -import type { Evaluate, Identity, Overwrite, ValueOrPromise } from "./utils"; +import type { StructAsyncDeserializeStream, StructDeserializeStream, StructFieldDefinition, StructFieldValue, StructOptions } from './basic/index.js'; +import { StructDefaultOptions, StructValue } from './basic/index.js'; +import { Syncbird } from "./syncbird.js"; +import { BigIntFieldDefinition, BigIntFieldType, BufferFieldSubType, FixedLengthBufferLikeFieldDefinition, NumberFieldDefinition, NumberFieldType, StringBufferFieldSubType, Uint8ArrayBufferFieldSubType, VariableLengthBufferLikeFieldDefinition, type FixedLengthBufferLikeFieldOptions, type LengthField, type VariableLengthBufferLikeFieldOptions } from './types/index.js'; +import type { Evaluate, Identity, Overwrite, ValueOrPromise } from "./utils.js"; export interface StructLike { deserialize(stream: StructDeserializeStream | StructAsyncDeserializeStream): Promise; diff --git a/libraries/struct/src/types/bigint.ts b/libraries/struct/src/types/bigint.ts index bdb01295..238735ba 100644 --- a/libraries/struct/src/types/bigint.ts +++ b/libraries/struct/src/types/bigint.ts @@ -1,9 +1,9 @@ // cspell: ignore syncbird -import { getBigInt64, getBigUint64, setBigInt64, setBigUint64 } from '@yume-chan/dataview-bigint-polyfill/esm/fallback'; -import { StructFieldDefinition, StructFieldValue, StructValue, type StructAsyncDeserializeStream, type StructDeserializeStream, type StructOptions } from "../basic"; -import { Syncbird } from "../syncbird"; -import type { ValueOrPromise } from "../utils"; +import { getBigInt64, getBigUint64, setBigInt64, setBigUint64 } from '@yume-chan/dataview-bigint-polyfill/esm/fallback.js'; +import { StructFieldDefinition, StructFieldValue, StructValue, type StructAsyncDeserializeStream, type StructDeserializeStream, type StructOptions } from "../basic/index.js"; +import { Syncbird } from "../syncbird.js"; +import type { ValueOrPromise } from "../utils.js"; type DataViewBigInt64Getter = (dataView: DataView, byteOffset: number, littleEndian: boolean | undefined) => bigint; diff --git a/libraries/struct/src/types/buffer/base.spec.ts b/libraries/struct/src/types/buffer/base.spec.ts index 4539c206..b14a7aab 100644 --- a/libraries/struct/src/types/buffer/base.spec.ts +++ b/libraries/struct/src/types/buffer/base.spec.ts @@ -1,5 +1,5 @@ -import { StructDefaultOptions, StructDeserializeStream, StructValue } from '../../basic'; -import { BufferFieldSubType, BufferLikeFieldDefinition, StringBufferFieldSubType, Uint8ArrayBufferFieldSubType } from './base'; +import { StructDefaultOptions, StructDeserializeStream, StructValue } from '../../basic/index.js'; +import { BufferFieldSubType, BufferLikeFieldDefinition, StringBufferFieldSubType, Uint8ArrayBufferFieldSubType } from './base.js'; class MockDeserializationStream implements StructDeserializeStream { public array = new Uint8Array(0); diff --git a/libraries/struct/src/types/buffer/base.ts b/libraries/struct/src/types/buffer/base.ts index 9d88eb3e..9d6fe82a 100644 --- a/libraries/struct/src/types/buffer/base.ts +++ b/libraries/struct/src/types/buffer/base.ts @@ -1,8 +1,8 @@ // cspell: ignore syncbird -import { StructFieldDefinition, StructFieldValue, StructValue, type StructAsyncDeserializeStream, type StructDeserializeStream, type StructOptions } from '../../basic'; -import { Syncbird } from "../../syncbird"; -import { decodeUtf8, encodeUtf8, type ValueOrPromise } from "../../utils"; +import { StructFieldDefinition, StructFieldValue, StructValue, type StructAsyncDeserializeStream, type StructDeserializeStream, type StructOptions } from '../../basic/index.js'; +import { Syncbird } from "../../syncbird.js"; +import { decodeUtf8, encodeUtf8, type ValueOrPromise } from "../../utils.js"; /** * Base class for all types that diff --git a/libraries/struct/src/types/buffer/fixed-length.spec.ts b/libraries/struct/src/types/buffer/fixed-length.spec.ts index c4e9775d..8ddecc9e 100644 --- a/libraries/struct/src/types/buffer/fixed-length.spec.ts +++ b/libraries/struct/src/types/buffer/fixed-length.spec.ts @@ -1,10 +1,10 @@ -import { Uint8ArrayBufferFieldSubType } from './base'; -import { FixedLengthBufferLikeFieldDefinition } from './fixed-length'; +import { Uint8ArrayBufferFieldSubType } from "./base.js"; +import { FixedLengthBufferLikeFieldDefinition } from "./fixed-length.js"; -describe('Types', () => { - describe('FixedLengthArrayBufferLikeFieldDefinition', () => { - describe('#getSize', () => { - it('should return size in its options', () => { +describe("Types", () => { + describe("FixedLengthArrayBufferLikeFieldDefinition", () => { + describe("#getSize", () => { + it("should return size in its options", () => { const definition = new FixedLengthBufferLikeFieldDefinition( Uint8ArrayBufferFieldSubType.Instance, { length: 10 }, diff --git a/libraries/struct/src/types/buffer/fixed-length.ts b/libraries/struct/src/types/buffer/fixed-length.ts index dbecd75c..ea050fa4 100644 --- a/libraries/struct/src/types/buffer/fixed-length.ts +++ b/libraries/struct/src/types/buffer/fixed-length.ts @@ -1,4 +1,4 @@ -import { BufferLikeFieldDefinition, type BufferFieldSubType } from './base'; +import { BufferLikeFieldDefinition, type BufferFieldSubType } from "./base.js"; export interface FixedLengthBufferLikeFieldOptions { length: number; diff --git a/libraries/struct/src/types/buffer/index.ts b/libraries/struct/src/types/buffer/index.ts index f0528719..8a16c1e4 100644 --- a/libraries/struct/src/types/buffer/index.ts +++ b/libraries/struct/src/types/buffer/index.ts @@ -1,3 +1,3 @@ -export * from './base'; -export * from './fixed-length'; -export * from './variable-length'; +export * from "./base.js"; +export * from "./fixed-length.js"; +export * from "./variable-length.js"; diff --git a/libraries/struct/src/types/buffer/variable-length.spec.ts b/libraries/struct/src/types/buffer/variable-length.spec.ts index 84fae242..d768b4ad 100644 --- a/libraries/struct/src/types/buffer/variable-length.spec.ts +++ b/libraries/struct/src/types/buffer/variable-length.spec.ts @@ -1,6 +1,6 @@ -import { StructDefaultOptions, StructFieldValue, StructValue } from '../../basic'; -import { BufferFieldSubType, Uint8ArrayBufferFieldSubType } from './base'; -import { VariableLengthBufferLikeFieldDefinition, VariableLengthBufferLikeFieldLengthValue, VariableLengthBufferLikeStructFieldValue } from './variable-length'; +import { StructDefaultOptions, StructFieldValue, StructValue } from "../../basic/index.js"; +import { BufferFieldSubType, Uint8ArrayBufferFieldSubType } from "./base.js"; +import { VariableLengthBufferLikeFieldDefinition, VariableLengthBufferLikeFieldLengthValue, VariableLengthBufferLikeStructFieldValue } from "./variable-length.js"; class MockOriginalFieldValue extends StructFieldValue { public constructor() { @@ -20,8 +20,8 @@ class MockOriginalFieldValue extends StructFieldValue { public serialize = jest.fn((dataView: DataView, offset: number): void => { }); } -describe('Types', () => { - describe('VariableLengthArrayBufferLikeFieldLengthValue', () => { +describe("Types", () => { + describe("VariableLengthArrayBufferLikeFieldLengthValue", () => { class MockArrayBufferFieldValue extends StructFieldValue { public constructor() { super({ options: {} } as any, {} as any, {} as any, {}); @@ -32,12 +32,12 @@ describe('Types', () => { public override getSize = jest.fn(() => this.size); public serialize(dataView: DataView, offset: number): void { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } } - describe('#getSize', () => { - it('should return size of its original field value', () => { + describe("#getSize", () => { + it("should return size of its original field value", () => { const mockOriginalFieldValue = new MockOriginalFieldValue(); const mockArrayBufferFieldValue = new MockArrayBufferFieldValue(); const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue( @@ -56,8 +56,8 @@ describe('Types', () => { }); }); - describe('#get', () => { - it('should return size of its `arrayBufferField`', async () => { + describe("#get", () => { + it("should return size of its `arrayBufferField`", async () => { const mockOriginalFieldValue = new MockOriginalFieldValue(); const mockArrayBufferFieldValue = new MockArrayBufferFieldValue(); const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue( @@ -79,7 +79,7 @@ describe('Types', () => { expect(mockOriginalFieldValue.get).toBeCalledTimes(1); }); - it('should return size of its `arrayBufferField` as string', async () => { + it("should return size of its `arrayBufferField` as string", async () => { const mockOriginalFieldValue = new MockOriginalFieldValue(); const mockArrayBufferFieldValue = new MockArrayBufferFieldValue(); const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue( @@ -87,23 +87,23 @@ describe('Types', () => { mockArrayBufferFieldValue, ); - mockOriginalFieldValue.value = '0'; + mockOriginalFieldValue.value = "0"; mockArrayBufferFieldValue.size = 0; - expect(lengthFieldValue.get()).toBe('0'); + expect(lengthFieldValue.get()).toBe("0"); expect(mockArrayBufferFieldValue.getSize).toBeCalledTimes(1); expect(mockOriginalFieldValue.get).toBeCalledTimes(1); mockArrayBufferFieldValue.getSize.mockClear(); mockOriginalFieldValue.get.mockClear(); mockArrayBufferFieldValue.size = 100; - expect(lengthFieldValue.get()).toBe('100'); + expect(lengthFieldValue.get()).toBe("100"); expect(mockArrayBufferFieldValue.getSize).toBeCalledTimes(1); expect(mockOriginalFieldValue.get).toBeCalledTimes(1); }); }); - describe('#set', () => { - it('should does nothing', async () => { + describe("#set", () => { + it("should does nothing", async () => { const mockOriginalFieldValue = new MockOriginalFieldValue(); const mockArrayBufferFieldValue = new MockArrayBufferFieldValue(); const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue( @@ -120,8 +120,8 @@ describe('Types', () => { }); }); - describe('#serialize', () => { - it('should call `serialize` of its `originalField`', async () => { + describe("#serialize", () => { + it("should call `serialize` of its `originalField`", async () => { const mockOriginalFieldValue = new MockOriginalFieldValue(); const mockArrayBufferFieldValue = new MockArrayBufferFieldValue(); const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue( @@ -152,7 +152,7 @@ describe('Types', () => { expect(mockOriginalFieldValue.serialize).toBeCalledWith(dataView, offset); }); - it('should stringify its length if `originalField` is a string', async () => { + it("should stringify its length if `originalField` is a string", async () => { const mockOriginalFieldValue = new MockOriginalFieldValue(); const mockArrayBufferFieldValue = new MockArrayBufferFieldValue(); const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue( @@ -163,13 +163,13 @@ describe('Types', () => { let dataView = 0 as any; let offset = 1 as any; - mockOriginalFieldValue.value = '10'; + mockOriginalFieldValue.value = "10"; mockArrayBufferFieldValue.size = 0; lengthFieldValue.serialize(dataView, offset); expect(mockOriginalFieldValue.get).toBeCalledTimes(1); - expect(mockOriginalFieldValue.get).toReturnWith('10'); + expect(mockOriginalFieldValue.get).toReturnWith("10"); expect(mockOriginalFieldValue.set).toBeCalledTimes(1); - expect(mockOriginalFieldValue.set).toBeCalledWith('0'); + expect(mockOriginalFieldValue.set).toBeCalledWith("0"); expect(mockOriginalFieldValue.serialize).toBeCalledTimes(1); expect(mockOriginalFieldValue.serialize).toBeCalledWith(dataView, offset); @@ -178,12 +178,12 @@ describe('Types', () => { mockArrayBufferFieldValue.size = 100; lengthFieldValue.serialize(dataView, offset); expect(mockOriginalFieldValue.set).toBeCalledTimes(1); - expect(mockOriginalFieldValue.set).toBeCalledWith('100'); + expect(mockOriginalFieldValue.set).toBeCalledWith("100"); expect(mockOriginalFieldValue.serialize).toBeCalledTimes(1); expect(mockOriginalFieldValue.serialize).toBeCalledWith(dataView, offset); }); - it('should stringify its length in specified base if `originalField` is a string', async () => { + it("should stringify its length in specified base if `originalField` is a string", async () => { const mockOriginalFieldValue = new MockOriginalFieldValue(); const mockArrayBufferFieldValue = new MockArrayBufferFieldValue(); const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue( @@ -197,13 +197,13 @@ describe('Types', () => { let dataView = 0 as any; let offset = 1 as any; - mockOriginalFieldValue.value = '10'; + mockOriginalFieldValue.value = "10"; mockArrayBufferFieldValue.size = 0; lengthFieldValue.serialize(dataView, offset); expect(mockOriginalFieldValue.get).toBeCalledTimes(1); - expect(mockOriginalFieldValue.get).toReturnWith('10'); + expect(mockOriginalFieldValue.get).toReturnWith("10"); expect(mockOriginalFieldValue.set).toBeCalledTimes(1); - expect(mockOriginalFieldValue.set).toBeCalledWith('0'); + expect(mockOriginalFieldValue.set).toBeCalledWith("0"); expect(mockOriginalFieldValue.serialize).toBeCalledTimes(1); expect(mockOriginalFieldValue.serialize).toBeCalledWith(dataView, offset); @@ -219,12 +219,12 @@ describe('Types', () => { }); }); - describe('VariableLengthArrayBufferLikeStructFieldValue', () => { - describe('.constructor', () => { - it('should forward parameters', () => { + describe("VariableLengthArrayBufferLikeStructFieldValue", () => { + describe(".constructor", () => { + it("should forward parameters", () => { const struct = new StructValue(); - const lengthField = 'foo'; + const lengthField = "foo"; const originalLengthFieldValue = new MockOriginalFieldValue(); struct.set(lengthField, originalLengthFieldValue); @@ -242,18 +242,18 @@ describe('Types', () => { value, ); - expect(arrayBufferFieldValue).toHaveProperty('definition', arrayBufferFieldDefinition); - expect(arrayBufferFieldValue).toHaveProperty('options', StructDefaultOptions); - expect(arrayBufferFieldValue).toHaveProperty('struct', struct); - expect(arrayBufferFieldValue).toHaveProperty('value', value); - expect(arrayBufferFieldValue).toHaveProperty('arrayBuffer', undefined); - expect(arrayBufferFieldValue).toHaveProperty('length', undefined); + expect(arrayBufferFieldValue).toHaveProperty("definition", arrayBufferFieldDefinition); + expect(arrayBufferFieldValue).toHaveProperty("options", StructDefaultOptions); + expect(arrayBufferFieldValue).toHaveProperty("struct", struct); + expect(arrayBufferFieldValue).toHaveProperty("value", value); + expect(arrayBufferFieldValue).toHaveProperty("arrayBuffer", undefined); + expect(arrayBufferFieldValue).toHaveProperty("length", undefined); }); - it('should forward parameters with `arrayBuffer`', () => { + it("should forward parameters with `arrayBuffer`", () => { const struct = new StructValue(); - const lengthField = 'foo'; + const lengthField = "foo"; const originalLengthFieldValue = new MockOriginalFieldValue(); struct.set(lengthField, originalLengthFieldValue); @@ -272,18 +272,18 @@ describe('Types', () => { value, ); - expect(arrayBufferFieldValue).toHaveProperty('definition', arrayBufferFieldDefinition); - expect(arrayBufferFieldValue).toHaveProperty('options', StructDefaultOptions); - expect(arrayBufferFieldValue).toHaveProperty('struct', struct); - expect(arrayBufferFieldValue).toHaveProperty('value', value); - expect(arrayBufferFieldValue).toHaveProperty('array', value); - expect(arrayBufferFieldValue).toHaveProperty('length', 100); + expect(arrayBufferFieldValue).toHaveProperty("definition", arrayBufferFieldDefinition); + expect(arrayBufferFieldValue).toHaveProperty("options", StructDefaultOptions); + expect(arrayBufferFieldValue).toHaveProperty("struct", struct); + expect(arrayBufferFieldValue).toHaveProperty("value", value); + expect(arrayBufferFieldValue).toHaveProperty("array", value); + expect(arrayBufferFieldValue).toHaveProperty("length", 100); }); - it('should replace `lengthField` on `struct`', () => { + it("should replace `lengthField` on `struct`", () => { const struct = new StructValue(); - const lengthField = 'foo'; + const lengthField = "foo"; const originalLengthFieldValue = new MockOriginalFieldValue(); struct.set(lengthField, originalLengthFieldValue); @@ -301,12 +301,12 @@ describe('Types', () => { value, ); - expect(arrayBufferFieldValue['lengthFieldValue']).toBeInstanceOf(StructFieldValue); - expect(struct.fieldValues[lengthField]).toBe(arrayBufferFieldValue['lengthFieldValue']); + expect(arrayBufferFieldValue["lengthFieldValue"]).toBeInstanceOf(StructFieldValue); + expect(struct.fieldValues[lengthField]).toBe(arrayBufferFieldValue["lengthFieldValue"]); }); }); - describe('#getSize', () => { + describe("#getSize", () => { class MockArrayBufferFieldType extends BufferFieldSubType { public override toBuffer = jest.fn((value: Uint8Array): Uint8Array => { return value; @@ -323,10 +323,10 @@ describe('Types', () => { }); } - it('should return cached size if exist', async () => { + it("should return cached size if exist", async () => { const struct = new StructValue(); - const lengthField = 'foo'; + const lengthField = "foo"; const originalLengthFieldValue = new MockOriginalFieldValue(); struct.set(lengthField, originalLengthFieldValue); @@ -352,10 +352,10 @@ describe('Types', () => { expect(arrayBufferFieldType.getSize).toBeCalledTimes(0); }); - it('should call `getSize` of its `type`', () => { + it("should call `getSize` of its `type`", () => { const struct = new StructValue(); - const lengthField = 'foo'; + const lengthField = "foo"; const originalLengthFieldValue = new MockOriginalFieldValue(); struct.set(lengthField, originalLengthFieldValue); @@ -379,14 +379,14 @@ describe('Types', () => { expect(arrayBufferFieldType.toValue).toBeCalledTimes(0); expect(arrayBufferFieldType.toBuffer).toBeCalledTimes(0); expect(arrayBufferFieldType.getSize).toBeCalledTimes(1); - expect(arrayBufferFieldValue).toHaveProperty('arrayBuffer', undefined); - expect(arrayBufferFieldValue).toHaveProperty('length', 100); + expect(arrayBufferFieldValue).toHaveProperty("arrayBuffer", undefined); + expect(arrayBufferFieldValue).toHaveProperty("length", 100); }); - it('should call `toArrayBuffer` of its `type` if it does not support `getSize`', () => { + it("should call `toArrayBuffer` of its `type` if it does not support `getSize`", () => { const struct = new StructValue(); - const lengthField = 'foo'; + const lengthField = "foo"; const originalLengthFieldValue = new MockOriginalFieldValue(); struct.set(lengthField, originalLengthFieldValue); @@ -410,16 +410,16 @@ describe('Types', () => { expect(arrayBufferFieldType.toValue).toBeCalledTimes(0); expect(arrayBufferFieldType.toBuffer).toBeCalledTimes(1); expect(arrayBufferFieldType.getSize).toBeCalledTimes(1); - expect(arrayBufferFieldValue).toHaveProperty('arrayBuffer', value); - expect(arrayBufferFieldValue).toHaveProperty('length', 100); + expect(arrayBufferFieldValue).toHaveProperty("arrayBuffer", value); + expect(arrayBufferFieldValue).toHaveProperty("length", 100); }); }); - describe('#set', () => { - it('should call `ArrayBufferLikeFieldValue#set`', () => { + describe("#set", () => { + it("should call `ArrayBufferLikeFieldValue#set`", () => { const struct = new StructValue(); - const lengthField = 'foo'; + const lengthField = "foo"; const originalLengthFieldValue = new MockOriginalFieldValue(); struct.set(lengthField, originalLengthFieldValue); @@ -441,13 +441,13 @@ describe('Types', () => { const newValue = new ArrayBuffer(100); arrayBufferFieldValue.set(newValue); expect(arrayBufferFieldValue.get()).toBe(newValue); - expect(arrayBufferFieldValue).toHaveProperty('arrayBuffer', undefined); + expect(arrayBufferFieldValue).toHaveProperty("arrayBuffer", undefined); }); - it('should clear length', () => { + it("should clear length", () => { const struct = new StructValue(); - const lengthField = 'foo'; + const lengthField = "foo"; const originalLengthFieldValue = new MockOriginalFieldValue(); struct.set(lengthField, originalLengthFieldValue); @@ -468,27 +468,27 @@ describe('Types', () => { const newValue = new ArrayBuffer(100); arrayBufferFieldValue.set(newValue); - expect(arrayBufferFieldValue).toHaveProperty('length', undefined); + expect(arrayBufferFieldValue).toHaveProperty("length", undefined); }); }); }); - describe('VariableLengthArrayBufferLikeFieldDefinition', () => { - describe('#getSize', () => { - it('should always return `0`', () => { + describe("VariableLengthArrayBufferLikeFieldDefinition", () => { + describe("#getSize", () => { + it("should always return `0`", () => { const definition = new VariableLengthBufferLikeFieldDefinition( Uint8ArrayBufferFieldSubType.Instance, - { lengthField: 'foo' }, + { lengthField: "foo" }, ); expect(definition.getSize()).toBe(0); }); }); - describe('#getDeserializeSize', () => { - it('should return value of its `lengthField`', async () => { + describe("#getDeserializeSize", () => { + it("should return value of its `lengthField`", async () => { const struct = new StructValue(); - const lengthField = 'foo'; + const lengthField = "foo"; const originalLengthFieldValue = new MockOriginalFieldValue(); struct.set(lengthField, originalLengthFieldValue); @@ -498,19 +498,19 @@ describe('Types', () => { ); originalLengthFieldValue.value = 0; - expect(definition['getDeserializeSize'](struct)).toBe(0); + expect(definition["getDeserializeSize"](struct)).toBe(0); expect(originalLengthFieldValue.get).toBeCalledTimes(1); originalLengthFieldValue.get.mockClear(); originalLengthFieldValue.value = 100; - expect(definition['getDeserializeSize'](struct)).toBe(100); + expect(definition["getDeserializeSize"](struct)).toBe(100); expect(originalLengthFieldValue.get).toBeCalledTimes(1); }); - it('should return value of its `lengthField` as number', async () => { + it("should return value of its `lengthField` as number", async () => { const struct = new StructValue(); - const lengthField = 'foo'; + const lengthField = "foo"; const originalLengthFieldValue = new MockOriginalFieldValue(); struct.set(lengthField, originalLengthFieldValue); @@ -519,20 +519,20 @@ describe('Types', () => { { lengthField }, ); - originalLengthFieldValue.value = '0'; - expect(definition['getDeserializeSize'](struct)).toBe(0); + originalLengthFieldValue.value = "0"; + expect(definition["getDeserializeSize"](struct)).toBe(0); expect(originalLengthFieldValue.get).toBeCalledTimes(1); originalLengthFieldValue.get.mockClear(); - originalLengthFieldValue.value = '100'; - expect(definition['getDeserializeSize'](struct)).toBe(100); + originalLengthFieldValue.value = "100"; + expect(definition["getDeserializeSize"](struct)).toBe(100); expect(originalLengthFieldValue.get).toBeCalledTimes(1); }); - it('should return value of its `lengthField` as number with specified base', async () => { + it("should return value of its `lengthField` as number with specified base", async () => { const struct = new StructValue(); - const lengthField = 'foo'; + const lengthField = "foo"; const originalLengthFieldValue = new MockOriginalFieldValue(); struct.set(lengthField, originalLengthFieldValue); @@ -542,22 +542,22 @@ describe('Types', () => { { lengthField, lengthFieldBase: base }, ); - originalLengthFieldValue.value = '0'; - expect(definition['getDeserializeSize'](struct)).toBe(0); + originalLengthFieldValue.value = "0"; + expect(definition["getDeserializeSize"](struct)).toBe(0); expect(originalLengthFieldValue.get).toBeCalledTimes(1); originalLengthFieldValue.get.mockClear(); - originalLengthFieldValue.value = '100'; - expect(definition['getDeserializeSize'](struct)).toBe(Number.parseInt('100', base)); + originalLengthFieldValue.value = "100"; + expect(definition["getDeserializeSize"](struct)).toBe(Number.parseInt("100", base)); expect(originalLengthFieldValue.get).toBeCalledTimes(1); }); }); - describe('#create', () => { - it('should create a `VariableLengthArrayBufferLikeFieldValue`', () => { + describe("#create", () => { + it("should create a `VariableLengthArrayBufferLikeFieldValue`", () => { const struct = new StructValue(); - const lengthField = 'foo'; + const lengthField = "foo"; const originalLengthFieldValue = new MockOriginalFieldValue(); struct.set(lengthField, originalLengthFieldValue); @@ -573,18 +573,18 @@ describe('Types', () => { value, ); - expect(arrayBufferFieldValue).toHaveProperty('definition', definition); - expect(arrayBufferFieldValue).toHaveProperty('options', StructDefaultOptions); - expect(arrayBufferFieldValue).toHaveProperty('struct', struct); - expect(arrayBufferFieldValue).toHaveProperty('value', value); - expect(arrayBufferFieldValue).toHaveProperty('arrayBuffer', undefined); - expect(arrayBufferFieldValue).toHaveProperty('length', undefined); + expect(arrayBufferFieldValue).toHaveProperty("definition", definition); + expect(arrayBufferFieldValue).toHaveProperty("options", StructDefaultOptions); + expect(arrayBufferFieldValue).toHaveProperty("struct", struct); + expect(arrayBufferFieldValue).toHaveProperty("value", value); + expect(arrayBufferFieldValue).toHaveProperty("arrayBuffer", undefined); + expect(arrayBufferFieldValue).toHaveProperty("length", undefined); }); - it('should create a `VariableLengthArrayBufferLikeFieldValue` with `arrayBuffer`', () => { + it("should create a `VariableLengthArrayBufferLikeFieldValue` with `arrayBuffer`", () => { const struct = new StructValue(); - const lengthField = 'foo'; + const lengthField = "foo"; const originalLengthFieldValue = new MockOriginalFieldValue(); struct.set(lengthField, originalLengthFieldValue); @@ -601,12 +601,12 @@ describe('Types', () => { value, ); - expect(arrayBufferFieldValue).toHaveProperty('definition', definition); - expect(arrayBufferFieldValue).toHaveProperty('options', StructDefaultOptions); - expect(arrayBufferFieldValue).toHaveProperty('struct', struct); - expect(arrayBufferFieldValue).toHaveProperty('value', value); - expect(arrayBufferFieldValue).toHaveProperty('arrayBuffer', value); - expect(arrayBufferFieldValue).toHaveProperty('length', 100); + expect(arrayBufferFieldValue).toHaveProperty("definition", definition); + expect(arrayBufferFieldValue).toHaveProperty("options", StructDefaultOptions); + expect(arrayBufferFieldValue).toHaveProperty("struct", struct); + expect(arrayBufferFieldValue).toHaveProperty("value", value); + expect(arrayBufferFieldValue).toHaveProperty("arrayBuffer", value); + expect(arrayBufferFieldValue).toHaveProperty("length", 100); }); }); }); diff --git a/libraries/struct/src/types/buffer/variable-length.ts b/libraries/struct/src/types/buffer/variable-length.ts index 4f62cce5..5d9bba07 100644 --- a/libraries/struct/src/types/buffer/variable-length.ts +++ b/libraries/struct/src/types/buffer/variable-length.ts @@ -1,6 +1,6 @@ -import { StructFieldValue, type StructFieldDefinition, type StructOptions, type StructValue } from '../../basic'; -import type { KeysOfType } from '../../utils'; -import { BufferLikeFieldDefinition, BufferLikeFieldValue, type BufferFieldSubType } from './base'; +import { StructFieldValue, type StructFieldDefinition, type StructOptions, type StructValue } from '../../basic/index.js'; +import type { KeysOfType } from '../../utils.js'; +import { BufferLikeFieldDefinition, BufferLikeFieldValue, type BufferFieldSubType } from './base.js'; export type LengthField = KeysOfType; diff --git a/libraries/struct/src/types/index.ts b/libraries/struct/src/types/index.ts index 92b40d87..c724c3ab 100644 --- a/libraries/struct/src/types/index.ts +++ b/libraries/struct/src/types/index.ts @@ -1,3 +1,3 @@ -export * from './bigint'; -export * from './buffer'; -export * from './number'; +export * from "./bigint.js"; +export * from "./buffer/index.js"; +export * from "./number.js"; diff --git a/libraries/struct/src/types/number.spec.ts b/libraries/struct/src/types/number.spec.ts index b0eaa571..208a4c50 100644 --- a/libraries/struct/src/types/number.spec.ts +++ b/libraries/struct/src/types/number.spec.ts @@ -1,83 +1,67 @@ -import { StructDefaultOptions, StructDeserializeStream, StructValue } from '../basic'; -import { NumberFieldDefinition, NumberFieldType } from './number'; +import { StructDefaultOptions, StructDeserializeStream, StructValue } from "../basic/index.js"; +import { NumberFieldDefinition, NumberFieldType } from "./number.js"; -describe('Types', () => { - describe('Number', () => { - describe('NumberFieldType', () => { - it('Int8 validation', () => { - const key = 'Int8'; - expect(NumberFieldType[key]).toHaveProperty('size', 1); - expect(NumberFieldType[key]).toHaveProperty('dataViewGetter', 'get' + key); - expect(NumberFieldType[key]).toHaveProperty('dataViewSetter', 'set' + key); +describe("Types", () => { + describe("Number", () => { + describe("NumberFieldType", () => { + it("Int8 validation", () => { + const key = "Int8"; + expect(NumberFieldType[key]).toHaveProperty("size", 1); + expect(NumberFieldType[key]).toHaveProperty("dataViewGetter", "get" + key); + expect(NumberFieldType[key]).toHaveProperty("dataViewSetter", "set" + key); }); - it('Uint8 validation', () => { - const key = 'Uint8'; - expect(NumberFieldType[key]).toHaveProperty('size', 1); - expect(NumberFieldType[key]).toHaveProperty('dataViewGetter', 'get' + key); - expect(NumberFieldType[key]).toHaveProperty('dataViewSetter', 'set' + key); + it("Uint8 validation", () => { + const key = "Uint8"; + expect(NumberFieldType[key]).toHaveProperty("size", 1); + expect(NumberFieldType[key]).toHaveProperty("dataViewGetter", "get" + key); + expect(NumberFieldType[key]).toHaveProperty("dataViewSetter", "set" + key); }); - it('Int16 validation', () => { - const key = 'Int16'; - expect(NumberFieldType[key]).toHaveProperty('size', 2); - expect(NumberFieldType[key]).toHaveProperty('dataViewGetter', 'get' + key); - expect(NumberFieldType[key]).toHaveProperty('dataViewSetter', 'set' + key); + it("Int16 validation", () => { + const key = "Int16"; + expect(NumberFieldType[key]).toHaveProperty("size", 2); + expect(NumberFieldType[key]).toHaveProperty("dataViewGetter", "get" + key); + expect(NumberFieldType[key]).toHaveProperty("dataViewSetter", "set" + key); }); - it('Uint16 validation', () => { - const key = 'Uint16'; - expect(NumberFieldType[key]).toHaveProperty('size', 2); - expect(NumberFieldType[key]).toHaveProperty('dataViewGetter', 'get' + key); - expect(NumberFieldType[key]).toHaveProperty('dataViewSetter', 'set' + key); + it("Uint16 validation", () => { + const key = "Uint16"; + expect(NumberFieldType[key]).toHaveProperty("size", 2); + expect(NumberFieldType[key]).toHaveProperty("dataViewGetter", "get" + key); + expect(NumberFieldType[key]).toHaveProperty("dataViewSetter", "set" + key); }); - it('Int32 validation', () => { - const key = 'Int32'; - expect(NumberFieldType[key]).toHaveProperty('size', 4); - expect(NumberFieldType[key]).toHaveProperty('dataViewGetter', 'get' + key); - expect(NumberFieldType[key]).toHaveProperty('dataViewSetter', 'set' + key); + it("Int32 validation", () => { + const key = "Int32"; + expect(NumberFieldType[key]).toHaveProperty("size", 4); + expect(NumberFieldType[key]).toHaveProperty("dataViewGetter", "get" + key); + expect(NumberFieldType[key]).toHaveProperty("dataViewSetter", "set" + key); }); - it('Uint32 validation', () => { - const key = 'Uint32'; - expect(NumberFieldType[key]).toHaveProperty('size', 4); - expect(NumberFieldType[key]).toHaveProperty('dataViewGetter', 'get' + key); - expect(NumberFieldType[key]).toHaveProperty('dataViewSetter', 'set' + key); - }); - - it('Int64 validation', () => { - const key = 'Int64'; - expect(NumberFieldType[key]).toHaveProperty('size', 8); - expect(NumberFieldType[key]).toHaveProperty('dataViewGetter', 'getBig' + key); - expect(NumberFieldType[key]).toHaveProperty('dataViewSetter', 'setBig' + key); - }); - - it('Uint64 validation', () => { - const key = 'Uint64'; - expect(NumberFieldType[key]).toHaveProperty('size', 8); - expect(NumberFieldType[key]).toHaveProperty('dataViewGetter', 'getBig' + key); - expect(NumberFieldType[key]).toHaveProperty('dataViewSetter', 'setBig' + key); + it("Uint32 validation", () => { + const key = "Uint32"; + expect(NumberFieldType[key]).toHaveProperty("size", 4); + expect(NumberFieldType[key]).toHaveProperty("dataViewGetter", "get" + key); + expect(NumberFieldType[key]).toHaveProperty("dataViewSetter", "set" + key); }); }); - describe('NumberFieldDefinition', () => { - describe('#getSize', () => { - it('should return size of its type', () => { + describe("NumberFieldDefinition", () => { + describe("#getSize", () => { + it("should return size of its type", () => { expect(new NumberFieldDefinition(NumberFieldType.Int8).getSize()).toBe(1); expect(new NumberFieldDefinition(NumberFieldType.Uint8).getSize()).toBe(1); expect(new NumberFieldDefinition(NumberFieldType.Int16).getSize()).toBe(2); expect(new NumberFieldDefinition(NumberFieldType.Uint16).getSize()).toBe(2); expect(new NumberFieldDefinition(NumberFieldType.Int32).getSize()).toBe(4); expect(new NumberFieldDefinition(NumberFieldType.Uint32).getSize()).toBe(4); - expect(new NumberFieldDefinition(NumberFieldType.Int64).getSize()).toBe(8); - expect(new NumberFieldDefinition(NumberFieldType.Uint64).getSize()).toBe(8); }); }); - describe('#deserialize', () => { - it('should deserialize Uint8', async () => { - const read = jest.fn((length: number) => new Uint8Array([1, 2, 3, 4]).buffer); + describe("#deserialize", () => { + it("should deserialize Uint8", async () => { + const read = jest.fn((length: number) => new Uint8Array([1, 2, 3, 4])); const stream: StructDeserializeStream = { read }; const definition = new NumberFieldDefinition(NumberFieldType.Uint8); @@ -93,8 +77,8 @@ describe('Types', () => { expect(read).lastCalledWith(NumberFieldType.Uint8.size); }); - it('should deserialize Uint16', async () => { - const read = jest.fn((length: number) => new Uint8Array([1, 2, 3, 4]).buffer); + it("should deserialize Uint16", async () => { + const read = jest.fn((length: number) => new Uint8Array([1, 2, 3, 4])); const stream: StructDeserializeStream = { read }; const definition = new NumberFieldDefinition(NumberFieldType.Uint16); @@ -110,8 +94,8 @@ describe('Types', () => { expect(read).lastCalledWith(NumberFieldType.Uint16.size); }); - it('should deserialize Uint16LE', async () => { - const read = jest.fn((length: number) => new Uint8Array([1, 2, 3, 4]).buffer); + it("should deserialize Uint16LE", async () => { + const read = jest.fn((length: number) => new Uint8Array([1, 2, 3, 4])); const stream: StructDeserializeStream = { read }; const definition = new NumberFieldDefinition(NumberFieldType.Uint16); @@ -129,9 +113,9 @@ describe('Types', () => { }); }); - describe('NumberFieldValue', () => { - describe('#getSize', () => { - it('should return size of its definition', () => { + describe("NumberFieldValue", () => { + describe("#getSize", () => { + it("should return size of its definition", () => { const struct = new StructValue(); expect( @@ -193,31 +177,11 @@ describe('Types', () => { ) .getSize() ).toBe(4); - - expect( - new NumberFieldDefinition(NumberFieldType.Int64) - .create( - StructDefaultOptions, - struct, - BigInt(100), - ) - .getSize() - ).toBe(8); - - expect( - new NumberFieldDefinition(NumberFieldType.Uint64) - .create( - StructDefaultOptions, - struct, - BigInt(100), - ) - .getSize() - ).toBe(8); }); }); - describe('#serialize', () => { - it('should serialize uint8', () => { + describe("#serialize", () => { + it("should serialize uint8", () => { const definition = new NumberFieldDefinition(NumberFieldType.Int8); const struct = new StructValue(); const value = definition.create( diff --git a/libraries/struct/src/types/number.ts b/libraries/struct/src/types/number.ts index 1d64f8c8..bfc794f0 100644 --- a/libraries/struct/src/types/number.ts +++ b/libraries/struct/src/types/number.ts @@ -1,8 +1,8 @@ // cspell: ignore syncbird -import { StructFieldDefinition, StructFieldValue, StructValue, type StructAsyncDeserializeStream, type StructDeserializeStream, type StructOptions } from '../basic'; -import { Syncbird } from "../syncbird"; -import type { ValueOrPromise } from "../utils"; +import { StructFieldDefinition, StructFieldValue, StructValue, type StructAsyncDeserializeStream, type StructDeserializeStream, type StructOptions } from '../basic/index.js'; +import { Syncbird } from "../syncbird.js"; +import type { ValueOrPromise } from "../utils.js"; export type DataViewGetters = { [TKey in keyof DataView]: TKey extends `get${string}` ? TKey : never }[keyof DataView]; diff --git a/libraries/struct/src/utils.spec.ts b/libraries/struct/src/utils.spec.ts index ee3cb209..566be38c 100644 --- a/libraries/struct/src/utils.spec.ts +++ b/libraries/struct/src/utils.spec.ts @@ -1,4 +1,4 @@ -import { placeholder } from './utils'; +import { placeholder } from './utils.js'; describe('placeholder', () => { it('should return `undefined`', () => { diff --git a/toolchain/ts-package-builder/README.md b/toolchain/ts-package-builder/README.md index dab51766..e44eb1b3 100644 --- a/toolchain/ts-package-builder/README.md +++ b/toolchain/ts-package-builder/README.md @@ -79,11 +79,10 @@ Or add a script to `package.json` } ``` -The builder compiles for both CommonJS and ESModule, also generates source maps, TypeScript declarations, and declaration maps. +The builder outputs Node.js compatible ES Module, with source maps, TypeScript declarations, and declaration maps. | Module | Output Directory | Excluded Files | Excluded Types | | ------------------ | ---------------- | -------------- | -------------- | -| CommonJS | `cjs` | - | - | | ESModule | `esm` | `*.spec.ts` | `@types/jest` | | Declaration (d.ts) | `dts` | `*.spec.ts` | `@types/jest` | @@ -91,8 +90,7 @@ Example `package.json`: ```json { - "main": "cjs/index.js", - "module": "esm/index.js", + "main": "esm/index.js", "types": "dts/index.d.ts", } ``` diff --git a/toolchain/ts-package-builder/tsconfig.base.json b/toolchain/ts-package-builder/tsconfig.base.json index 26eea596..a2b85f37 100644 --- a/toolchain/ts-package-builder/tsconfig.base.json +++ b/toolchain/ts-package-builder/tsconfig.base.json @@ -3,7 +3,7 @@ "composite": true, /* Basic Options */ "target": "ESNext", // /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ - "module": "ESNext", // /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + "module": "Node12", // /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "lib": [ // /* Specify library files to be included in the compilation. */ "ESNext" ], @@ -35,7 +35,7 @@ "noUncheckedIndexedAccess": true, "resolveJsonModule": true, /* Module Resolution Options */ - "moduleResolution": "Node", // /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + "moduleResolution": "Node12", // /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */