mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-03 17:59:50 +02:00
feat: convert to Node.js compatible ES Module
This commit is contained in:
parent
730aac8da2
commit
d9212b4dac
94 changed files with 429 additions and 466 deletions
|
@ -42,6 +42,6 @@
|
||||||
"@types/react": "17.0.27",
|
"@types/react": "17.0.27",
|
||||||
"eslint": "8.8.0",
|
"eslint": "8.8.0",
|
||||||
"eslint-config-next": "12.1.0",
|
"eslint-config-next": "12.1.0",
|
||||||
"typescript": "^4.6.2"
|
"typescript": "next"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"module": "esm/index.js",
|
"main": "esm/index.js",
|
||||||
"types": "esm/index.d.ts",
|
"types": "esm/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "build-ts-package",
|
"build": "build-ts-package",
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
"prepublishOnly": "npm run build"
|
"prepublishOnly": "npm run build"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^4.6.2",
|
"typescript": "next",
|
||||||
"@types/jest": "^27.4.0",
|
"@types/jest": "^27.4.0",
|
||||||
"@yume-chan/ts-package-builder": "^1.0.0"
|
"@yume-chan/ts-package-builder": "^1.0.0"
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"module": "esm/index.js",
|
"main": "esm/index.js",
|
||||||
"types": "esm/index.d.ts",
|
"types": "esm/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "build-ts-package",
|
"build": "build-ts-package",
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"typescript": "^4.6.2",
|
"typescript": "next",
|
||||||
"@yume-chan/ts-package-builder": "^1.0.0"
|
"@yume-chan/ts-package-builder": "^1.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
export * from './backend';
|
export * from './backend.js';
|
||||||
export { AdbWebUsbBackend as default } from './backend';
|
export { AdbWebUsbBackend as default } from './backend.js';
|
||||||
export * from './watcher';
|
export * from './watcher.js';
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"module": "esm/index.js",
|
"main": "esm/index.js",
|
||||||
"types": "esm/index.d.ts",
|
"types": "esm/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "build-ts-package",
|
"build": "build-ts-package",
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"typescript": "^4.6.2",
|
"typescript": "next",
|
||||||
"@yume-chan/ts-package-builder": "^1.0.0"
|
"@yume-chan/ts-package-builder": "^1.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"module": "esm/index.js",
|
"main": "esm/index.js",
|
||||||
"types": "esm/index.d.ts",
|
"types": "esm/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "build-ts-package",
|
"build": "build-ts-package",
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
"prepublishOnly": "npm run build"
|
"prepublishOnly": "npm run build"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^4.6.2",
|
"typescript": "next",
|
||||||
"@yume-chan/ts-package-builder": "^1.0.0"
|
"@yume-chan/ts-package-builder": "^1.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"module": "esm/index.js",
|
"main": "esm/index.js",
|
||||||
"types": "esm/index.d.ts",
|
"types": "esm/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "build-ts-package",
|
"build": "build-ts-package",
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"typescript": "^4.6.2",
|
"typescript": "next",
|
||||||
"@yume-chan/ts-package-builder": "^1.0.0"
|
"@yume-chan/ts-package-builder": "^1.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { PromiseResolver } from '@yume-chan/async';
|
import { PromiseResolver } from '@yume-chan/async';
|
||||||
import { AdbAuthenticationHandler, AdbDefaultAuthenticators, type AdbCredentialStore } from './auth';
|
import { AdbAuthenticationHandler, AdbDefaultAuthenticators, type AdbCredentialStore } from './auth.js';
|
||||||
import { AdbPower, AdbReverseCommand, AdbSubprocess, AdbSync, AdbTcpIpCommand, escapeArg, framebuffer, install, type AdbFrameBuffer } from './commands';
|
import { AdbPower, AdbReverseCommand, AdbSubprocess, AdbSync, AdbTcpIpCommand, escapeArg, framebuffer, install, type AdbFrameBuffer } from './commands/index.js';
|
||||||
import { AdbFeatures } from './features';
|
import { AdbFeatures } from './features.js';
|
||||||
import { AdbCommand, AdbPacket, AdbPacketSerializeStream, calculateChecksum, type AdbPacketCore, type AdbPacketInit } from './packet';
|
import { AdbCommand, AdbPacket, AdbPacketSerializeStream, calculateChecksum, type AdbPacketCore, type AdbPacketInit } from './packet.js';
|
||||||
import { AdbPacketDispatcher, AdbSocket } from './socket';
|
import { AdbPacketDispatcher, AdbSocket } from './socket/index.js';
|
||||||
import { AbortController, DecodeUtf8Stream, GatherStringStream, pipeFrom, StructDeserializeStream, WritableStream, type ReadableWritablePair } from "./stream";
|
import { AbortController, DecodeUtf8Stream, GatherStringStream, pipeFrom, StructDeserializeStream, WritableStream, type ReadableWritablePair } from "./stream/index.js";
|
||||||
import { decodeUtf8, encodeUtf8 } from "./utils";
|
import { decodeUtf8, encodeUtf8 } from "./utils/index.js";
|
||||||
|
|
||||||
export enum AdbPropKey {
|
export enum AdbPropKey {
|
||||||
Product = 'ro.product.name',
|
Product = 'ro.product.name',
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { PromiseResolver } from '@yume-chan/async';
|
import { PromiseResolver } from '@yume-chan/async';
|
||||||
import type { Disposable } from '@yume-chan/event';
|
import type { Disposable } from '@yume-chan/event';
|
||||||
import type { ValueOrPromise } from '@yume-chan/struct';
|
import type { ValueOrPromise } from '@yume-chan/struct';
|
||||||
import { calculatePublicKey, calculatePublicKeyLength, sign } from './crypto';
|
import { calculatePublicKey, calculatePublicKeyLength, sign } from './crypto.js';
|
||||||
import { AdbCommand, AdbPacket, type AdbPacketCore } from './packet';
|
import { AdbCommand, AdbPacket, type AdbPacketCore } from './packet.js';
|
||||||
import { calculateBase64EncodedLength, encodeBase64 } from './utils';
|
import { calculateBase64EncodedLength, encodeBase64 } from './utils/index.js';
|
||||||
|
|
||||||
export type AdbKeyIterable = Iterable<Uint8Array> | AsyncIterable<Uint8Array>;
|
export type AdbKeyIterable = Iterable<Uint8Array> | AsyncIterable<Uint8Array>;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type { ValueOrPromise } from '@yume-chan/struct';
|
import type { ValueOrPromise } from '@yume-chan/struct';
|
||||||
import type { ReadableWritablePair } from "./stream";
|
import type { ReadableWritablePair } from "./stream/index.js";
|
||||||
|
|
||||||
export interface AdbBackend {
|
export interface AdbBackend {
|
||||||
readonly serial: string;
|
readonly serial: string;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { AutoDisposable } from '@yume-chan/event';
|
import { AutoDisposable } from '@yume-chan/event';
|
||||||
import type { Adb } from '../adb';
|
import type { Adb } from '../adb.js';
|
||||||
|
|
||||||
export class AdbCommandBase extends AutoDisposable {
|
export class AdbCommandBase extends AutoDisposable {
|
||||||
protected adb: Adb;
|
protected adb: Adb;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import Struct from "@yume-chan/struct";
|
import Struct from "@yume-chan/struct";
|
||||||
import type { Adb } from '../adb';
|
import type { Adb } from '../adb.js';
|
||||||
import { AdbBufferedStream } from '../stream';
|
import { AdbBufferedStream } from '../stream/index.js';
|
||||||
|
|
||||||
const Version =
|
const Version =
|
||||||
new Struct({ littleEndian: true })
|
new Struct({ littleEndian: true })
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
export * from './base';
|
export * from './base.js';
|
||||||
export * from './framebuffer';
|
export * from './framebuffer.js';
|
||||||
export * from './install';
|
export * from './install.js';
|
||||||
export * from './power';
|
export * from './power.js';
|
||||||
export * from './reverse';
|
export * from './reverse.js';
|
||||||
export * from './subprocess';
|
export * from './subprocess/index.js';
|
||||||
export * from './sync';
|
export * from './sync/index.js';
|
||||||
export * from './tcpip';
|
export * from './tcpip.js';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type { Adb } from "../adb";
|
import type { Adb } from "../adb.js";
|
||||||
import { WrapWritableStream, WritableStream } from "../stream";
|
import { WrapWritableStream, WritableStream } from "../stream/index.js";
|
||||||
import { escapeArg } from "./subprocess";
|
import { escapeArg } from "./subprocess/index.js";
|
||||||
import type { AdbSync } from "./sync";
|
import type { AdbSync } from "./sync/index.js";
|
||||||
|
|
||||||
export function install(
|
export function install(
|
||||||
adb: Adb,
|
adb: Adb,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// cspell: ignore keyevent
|
// cspell: ignore keyevent
|
||||||
// cspell: ignore longpress
|
// cspell: ignore longpress
|
||||||
|
|
||||||
import { AdbCommandBase } from "./base";
|
import { AdbCommandBase } from "./base.js";
|
||||||
|
|
||||||
export class AdbPower extends AdbCommandBase {
|
export class AdbPower extends AdbCommandBase {
|
||||||
public reboot(name: string = '') {
|
public reboot(name: string = '') {
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
import { AutoDisposable } from '@yume-chan/event';
|
import { AutoDisposable } from '@yume-chan/event';
|
||||||
import Struct from '@yume-chan/struct';
|
import Struct from '@yume-chan/struct';
|
||||||
import type { AdbPacket } from '../packet';
|
import type { AdbPacket } from '../packet.js';
|
||||||
import type { AdbIncomingSocketEventArgs, AdbPacketDispatcher, AdbSocket } from '../socket';
|
import type { AdbIncomingSocketEventArgs, AdbPacketDispatcher, AdbSocket } from '../socket/index.js';
|
||||||
import { AdbBufferedStream } from '../stream';
|
import { AdbBufferedStream } from '../stream/index.js';
|
||||||
import { decodeUtf8 } from "../utils";
|
import { decodeUtf8 } from "../utils/index.js";
|
||||||
|
|
||||||
export interface AdbReverseHandler {
|
export interface AdbReverseHandler {
|
||||||
onSocket(packet: AdbPacket, socket: AdbSocket): void;
|
onSocket(packet: AdbPacket, socket: AdbSocket): void;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import type { Adb } from '../../adb';
|
import type { Adb } from '../../adb.js';
|
||||||
import { DecodeUtf8Stream, GatherStringStream } from "../../stream";
|
import { DecodeUtf8Stream, GatherStringStream } from "../../stream/index.js";
|
||||||
import { AdbNoneSubprocessProtocol } from './legacy';
|
import { AdbNoneSubprocessProtocol } from './legacy.js';
|
||||||
import { AdbShellSubprocessProtocol } from './protocol';
|
import { AdbShellSubprocessProtocol } from './protocol.js';
|
||||||
import type { AdbSubprocessProtocol, AdbSubprocessProtocolConstructor } from './types';
|
import type { AdbSubprocessProtocol, AdbSubprocessProtocolConstructor } from './types.js';
|
||||||
|
|
||||||
export * from './legacy';
|
export * from './legacy.js';
|
||||||
export * from './protocol';
|
export * from './protocol.js';
|
||||||
export * from './types';
|
export * from './types.js';
|
||||||
export * from './utils';
|
export * from './utils.js';
|
||||||
|
|
||||||
export interface AdbSubprocessOptions {
|
export interface AdbSubprocessOptions {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type { Adb } from "../../adb";
|
import type { Adb } from "../../adb.js";
|
||||||
import type { AdbSocket } from "../../socket";
|
import type { AdbSocket } from "../../socket/index.js";
|
||||||
import { DuplexStreamFactory, type ReadableStream } from "../../stream";
|
import { DuplexStreamFactory, type ReadableStream } from "../../stream/index.js";
|
||||||
import type { AdbSubprocessProtocol } from "./types";
|
import type { AdbSubprocessProtocol } from "./types.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The legacy shell
|
* The legacy shell
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { PromiseResolver } from "@yume-chan/async";
|
import { PromiseResolver } from "@yume-chan/async";
|
||||||
import Struct, { placeholder, type StructValueType } from "@yume-chan/struct";
|
import Struct, { placeholder, type StructValueType } from "@yume-chan/struct";
|
||||||
import type { Adb } from "../../adb";
|
import type { Adb } from "../../adb.js";
|
||||||
import { AdbFeatures } from "../../features";
|
import { AdbFeatures } from "../../features.js";
|
||||||
import type { AdbSocket } from "../../socket";
|
import type { AdbSocket } from "../../socket/index.js";
|
||||||
import { PushReadableStream, ReadableStream, StructDeserializeStream, StructSerializeStream, TransformStream, WritableStream, WritableStreamDefaultWriter, type PushReadableStreamController } from "../../stream";
|
import { PushReadableStream, ReadableStream, StructDeserializeStream, StructSerializeStream, TransformStream, WritableStream, WritableStreamDefaultWriter, type PushReadableStreamController } from "../../stream/index.js";
|
||||||
import { encodeUtf8 } from "../../utils";
|
import { encodeUtf8 } from "../../utils/index.js";
|
||||||
import type { AdbSubprocessProtocol } from "./types";
|
import type { AdbSubprocessProtocol } from "./types.js";
|
||||||
|
|
||||||
export enum AdbShellProtocolId {
|
export enum AdbShellProtocolId {
|
||||||
Stdin,
|
Stdin,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type { ValueOrPromise } from "@yume-chan/struct";
|
import type { ValueOrPromise } from "@yume-chan/struct";
|
||||||
import type { Adb } from "../../adb";
|
import type { Adb } from "../../adb.js";
|
||||||
import type { AdbSocket } from "../../socket";
|
import type { AdbSocket } from "../../socket/index.js";
|
||||||
import type { ReadableStream, WritableStream } from "../../stream";
|
import type { ReadableStream, WritableStream } from "../../stream/index.js";
|
||||||
|
|
||||||
export interface AdbSubprocessProtocol {
|
export interface AdbSubprocessProtocol {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
export * from './list';
|
export * from './list.js';
|
||||||
export * from './pull';
|
export * from './pull.js';
|
||||||
export * from './request';
|
export * from './request.js';
|
||||||
export * from './response';
|
export * from './response.js';
|
||||||
export * from './push';
|
export * from './push.js';
|
||||||
export * from './stat';
|
export * from './stat.js';
|
||||||
export * from './sync';
|
export * from './sync.js';
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import Struct from '@yume-chan/struct';
|
import Struct from '@yume-chan/struct';
|
||||||
import type { AdbBufferedStream, WritableStreamDefaultWriter } from '../../stream';
|
import type { AdbBufferedStream, WritableStreamDefaultWriter } from '../../stream/index.js';
|
||||||
import { AdbSyncRequestId, adbSyncWriteRequest } from './request';
|
import { AdbSyncRequestId, adbSyncWriteRequest } from './request.js';
|
||||||
import { AdbSyncDoneResponse, adbSyncReadResponse, AdbSyncResponseId } from './response';
|
import { AdbSyncDoneResponse, adbSyncReadResponse, AdbSyncResponseId } from './response.js';
|
||||||
import { AdbSyncLstatResponse } from './stat';
|
import { AdbSyncLstatResponse } from './stat.js';
|
||||||
|
|
||||||
export const AdbSyncEntryResponse =
|
export const AdbSyncEntryResponse =
|
||||||
new Struct({ littleEndian: true })
|
new Struct({ littleEndian: true })
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Struct from '@yume-chan/struct';
|
import Struct from '@yume-chan/struct';
|
||||||
import { AdbBufferedStream, ReadableStream, WritableStreamDefaultWriter } from '../../stream';
|
import { AdbBufferedStream, ReadableStream, WritableStreamDefaultWriter } from '../../stream/index.js';
|
||||||
import { AdbSyncRequestId, adbSyncWriteRequest } from './request';
|
import { AdbSyncRequestId, adbSyncWriteRequest } from './request.js';
|
||||||
import { AdbSyncDoneResponse, adbSyncReadResponse, AdbSyncResponseId } from './response';
|
import { AdbSyncDoneResponse, adbSyncReadResponse, AdbSyncResponseId } from './response.js';
|
||||||
|
|
||||||
export const AdbSyncDataResponse =
|
export const AdbSyncDataResponse =
|
||||||
new Struct({ littleEndian: true })
|
new Struct({ littleEndian: true })
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import Struct from '@yume-chan/struct';
|
import Struct from '@yume-chan/struct';
|
||||||
import { AdbBufferedStream, ChunkStream, pipeFrom, WritableStream, WritableStreamDefaultWriter } from '../../stream';
|
import { AdbBufferedStream, ChunkStream, pipeFrom, WritableStream, WritableStreamDefaultWriter } from '../../stream/index.js';
|
||||||
import { AdbSyncRequestId, adbSyncWriteRequest } from './request';
|
import { AdbSyncRequestId, adbSyncWriteRequest } from './request.js';
|
||||||
import { adbSyncReadResponse, AdbSyncResponseId } from './response';
|
import { adbSyncReadResponse, AdbSyncResponseId } from './response.js';
|
||||||
import { LinuxFileType } from './stat';
|
import { LinuxFileType } from './stat.js';
|
||||||
|
|
||||||
export const AdbSyncOkResponse =
|
export const AdbSyncOkResponse =
|
||||||
new Struct({ littleEndian: true })
|
new Struct({ littleEndian: true })
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import Struct from '@yume-chan/struct';
|
import Struct from '@yume-chan/struct';
|
||||||
import type { WritableStreamDefaultWriter } from "../../stream";
|
import type { WritableStreamDefaultWriter } from "../../stream/index.js";
|
||||||
import { encodeUtf8 } from "../../utils";
|
import { encodeUtf8 } from "../../utils/index.js";
|
||||||
|
|
||||||
export enum AdbSyncRequestId {
|
export enum AdbSyncRequestId {
|
||||||
List = 'LIST',
|
List = 'LIST',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import Struct, { type StructAsyncDeserializeStream, type StructLike, type StructValueType } from '@yume-chan/struct';
|
import Struct, { type StructAsyncDeserializeStream, type StructLike, type StructValueType } from '@yume-chan/struct';
|
||||||
import type { AdbBufferedStream } from '../../stream';
|
import type { AdbBufferedStream } from '../../stream/index.js';
|
||||||
import { decodeUtf8 } from "../../utils";
|
import { decodeUtf8 } from "../../utils/index.js";
|
||||||
|
|
||||||
export enum AdbSyncResponseId {
|
export enum AdbSyncResponseId {
|
||||||
Entry = 'DENT',
|
Entry = 'DENT',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Struct, { placeholder } from '@yume-chan/struct';
|
import Struct, { placeholder } from '@yume-chan/struct';
|
||||||
import type { AdbBufferedStream, WritableStreamDefaultWriter } from '../../stream';
|
import type { AdbBufferedStream, WritableStreamDefaultWriter } from '../../stream/index.js';
|
||||||
import { AdbSyncRequestId, adbSyncWriteRequest } from './request';
|
import { AdbSyncRequestId, adbSyncWriteRequest } from './request.js';
|
||||||
import { adbSyncReadResponse, AdbSyncResponseId } from './response';
|
import { adbSyncReadResponse, AdbSyncResponseId } from './response.js';
|
||||||
|
|
||||||
// https://github.com/python/cpython/blob/4e581d64b8aff3e2eda99b12f080c877bb78dfca/Lib/stat.py#L36
|
// https://github.com/python/cpython/blob/4e581d64b8aff3e2eda99b12f080c877bb78dfca/Lib/stat.py#L36
|
||||||
export enum LinuxFileType {
|
export enum LinuxFileType {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { AutoDisposable } from '@yume-chan/event';
|
import { AutoDisposable } from '@yume-chan/event';
|
||||||
import type { Adb } from '../../adb';
|
import type { Adb } from '../../adb.js';
|
||||||
import { AdbFeatures } from '../../features';
|
import { AdbFeatures } from '../../features.js';
|
||||||
import type { AdbSocket } from '../../socket';
|
import type { AdbSocket } from '../../socket/index.js';
|
||||||
import { AdbBufferedStream, ReadableStream, WrapReadableStream, WrapWritableStream, WritableStream, WritableStreamDefaultWriter } from '../../stream';
|
import { AdbBufferedStream, ReadableStream, WrapReadableStream, WrapWritableStream, WritableStream, WritableStreamDefaultWriter } from '../../stream/index.js';
|
||||||
import { AutoResetEvent } from '../../utils';
|
import { AutoResetEvent } from '../../utils/index.js';
|
||||||
import { AdbSyncEntryResponse, adbSyncOpenDir } from './list';
|
import { AdbSyncEntryResponse, adbSyncOpenDir } from './list.js';
|
||||||
import { adbSyncPull } from './pull';
|
import { adbSyncPull } from './pull.js';
|
||||||
import { adbSyncPush } from './push';
|
import { adbSyncPush } from './push.js';
|
||||||
import { adbSyncLstat, adbSyncStat } from './stat';
|
import { adbSyncLstat, adbSyncStat } from './stat.js';
|
||||||
|
|
||||||
export class AdbSync extends AutoDisposable {
|
export class AdbSync extends AutoDisposable {
|
||||||
protected adb: Adb;
|
protected adb: Adb;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { AdbCommandBase } from './base';
|
import { AdbCommandBase } from './base.js';
|
||||||
|
|
||||||
export class AdbTcpIpCommand extends AdbCommandBase {
|
export class AdbTcpIpCommand extends AdbCommandBase {
|
||||||
public async setPort(port: number): Promise<void> {
|
public async setPort(port: number): Promise<void> {
|
||||||
|
|
|
@ -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 BigInt0 = BigInt(0);
|
||||||
const BigInt1 = BigInt(1);
|
const BigInt1 = BigInt(1);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Struct from '@yume-chan/struct';
|
import Struct from '@yume-chan/struct';
|
||||||
import { TransformStream } from "./stream";
|
import { TransformStream } from "./stream/index.js";
|
||||||
|
|
||||||
export enum AdbCommand {
|
export enum AdbCommand {
|
||||||
Auth = 0x48545541, // 'AUTH'
|
Auth = 0x48545541, // 'AUTH'
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { AsyncOperationManager } from '@yume-chan/async';
|
import { AsyncOperationManager } from '@yume-chan/async';
|
||||||
import { AutoDisposable, EventEmitter } from '@yume-chan/event';
|
import { AutoDisposable, EventEmitter } from '@yume-chan/event';
|
||||||
import { AdbCommand, AdbPacket, calculateChecksum, type AdbPacketCore, type AdbPacketInit } from '../packet';
|
import { AdbCommand, AdbPacket, calculateChecksum, type AdbPacketCore, type AdbPacketInit } from '../packet.js';
|
||||||
import { AbortController, WritableStream, WritableStreamDefaultWriter, type ReadableWritablePair } from '../stream';
|
import { AbortController, WritableStream, WritableStreamDefaultWriter, type ReadableWritablePair } from '../stream/index.js';
|
||||||
import { decodeUtf8, encodeUtf8 } from '../utils';
|
import { decodeUtf8, encodeUtf8 } from '../utils/index.js';
|
||||||
import { AdbSocket } from './socket';
|
import { AdbSocket } from './socket.js';
|
||||||
|
|
||||||
export interface AdbIncomingSocketEventArgs {
|
export interface AdbIncomingSocketEventArgs {
|
||||||
handled: boolean;
|
handled: boolean;
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
export * from './socket';
|
export * from './socket.js';
|
||||||
export * from './dispatcher';
|
export * from './dispatcher.js';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { PromiseResolver } from "@yume-chan/async";
|
import { PromiseResolver } from "@yume-chan/async";
|
||||||
import { AdbCommand } from '../packet';
|
import { AdbCommand } from '../packet.js';
|
||||||
import { ChunkStream, DuplexStreamFactory, pipeFrom, ReadableStream, WritableStream, type PushReadableStreamController } from '../stream';
|
import { ChunkStream, DuplexStreamFactory, pipeFrom, ReadableStream, WritableStream, type PushReadableStreamController } from '../stream/index.js';
|
||||||
import type { AdbPacketDispatcher } from './dispatcher';
|
import type { AdbPacketDispatcher } from './dispatcher.js';
|
||||||
|
|
||||||
export interface AdbSocketInfo {
|
export interface AdbSocketInfo {
|
||||||
localId: number;
|
localId: number;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type { StructAsyncDeserializeStream } from '@yume-chan/struct';
|
import type { StructAsyncDeserializeStream } from '@yume-chan/struct';
|
||||||
import type { AdbSocket, AdbSocketInfo } from '../socket';
|
import type { AdbSocket, AdbSocketInfo } from '../socket/index.js';
|
||||||
import type { ReadableStream, ReadableStreamDefaultReader } from './detect';
|
import type { ReadableStream, ReadableStreamDefaultReader } from './detect.js';
|
||||||
import { PushReadableStream } from "./transform";
|
import { PushReadableStream } from "./transform.js";
|
||||||
|
|
||||||
export class BufferedStreamEndedError extends Error {
|
export class BufferedStreamEndedError extends Error {
|
||||||
public constructor() {
|
public constructor() {
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
export * from './buffered';
|
export * from './buffered.js';
|
||||||
export * from './detect';
|
export * from './detect.js';
|
||||||
export * from './transform';
|
export * from './transform.js';
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { PromiseResolver } from "@yume-chan/async";
|
import { PromiseResolver } from "@yume-chan/async";
|
||||||
import type Struct from "@yume-chan/struct";
|
import type Struct from "@yume-chan/struct";
|
||||||
import type { StructValueType } from "@yume-chan/struct";
|
import type { StructValueType } from "@yume-chan/struct";
|
||||||
import { decodeUtf8 } from "../utils";
|
import { decodeUtf8 } from "../utils/index.js";
|
||||||
import { BufferedStream, BufferedStreamEndedError } from "./buffered";
|
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";
|
import { AbortController, AbortSignal, ReadableStream, ReadableStreamDefaultReader, TransformStream, WritableStream, WritableStreamDefaultWriter, type QueuingStrategy, type ReadableStreamController, type ReadableWritablePair, type UnderlyingSink, type UnderlyingSource } from "./detect.js";
|
||||||
|
|
||||||
export interface DuplexStreamFactoryOptions {
|
export interface DuplexStreamFactoryOptions {
|
||||||
preventCloseReadableStreams?: boolean | undefined;
|
preventCloseReadableStreams?: boolean | undefined;
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
export * from './auto-reset-event';
|
export * from './auto-reset-event.js';
|
||||||
export * from './base64';
|
export * from './base64.js';
|
||||||
export * from './encoding';
|
export * from './encoding.js';
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"module": "esm/index.js",
|
"main": "esm/index.js",
|
||||||
"types": "esm/index.d.ts",
|
"types": "esm/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "build-ts-package",
|
"build": "build-ts-package",
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
"prepublishOnly": "npm run build"
|
"prepublishOnly": "npm run build"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^4.6.2",
|
"typescript": "next",
|
||||||
"@yume-chan/ts-package-builder": "^1.0.0"
|
"@yume-chan/ts-package-builder": "^1.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
// cspell: ignore sysui
|
// cspell: ignore sysui
|
||||||
|
|
||||||
import { Adb, AdbCommandBase } from '@yume-chan/adb';
|
import { Adb, AdbCommandBase } from '@yume-chan/adb';
|
||||||
import { Settings } from "./settings";
|
import { Settings } from "./settings.js";
|
||||||
|
|
||||||
export enum DemoModeSignalStrength {
|
export enum DemoModeSignalStrength {
|
||||||
Hidden = 'null',
|
Hidden = 'null',
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
export * from './bug-report';
|
export * from './bug-report.js';
|
||||||
export * from './demo-mode';
|
export * from './demo-mode.js';
|
||||||
export * from './settings';
|
export * from './settings.js';
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"module": "esm/index.js",
|
"main": "esm/index.js",
|
||||||
"types": "esm/index.d.ts",
|
"types": "esm/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "build-ts-package",
|
"build": "build-ts-package",
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"typescript": "^4.6.2",
|
"typescript": "next",
|
||||||
"@yume-chan/ts-package-builder": "^1.0.0"
|
"@yume-chan/ts-package-builder": "^1.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 =
|
export const getBigInt64 =
|
||||||
'getBigInt64' in DataView.prototype ?
|
'getBigInt64' in DataView.prototype ?
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
export * from './pure';
|
export * from './pure.js';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getBigInt64, getBigUint64, setBigInt64, setBigUint64 } from './pure';
|
import { getBigInt64, getBigUint64, setBigInt64, setBigUint64 } from './pure.js';
|
||||||
|
|
||||||
if (!('getBigInt64' in DataView)) {
|
if (!('getBigInt64' in DataView)) {
|
||||||
DataView.prototype.getBigInt64 = function (byteOffset, littleEndian) {
|
DataView.prototype.getBigInt64 = function (byteOffset, littleEndian) {
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"module": "esm/index.js",
|
"main": "esm/index.js",
|
||||||
"types": "esm/index.d.ts",
|
"types": "esm/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "build-ts-package",
|
"build": "build-ts-package",
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"typescript": "^4.6.2",
|
"typescript": "next",
|
||||||
"@yume-chan/ts-package-builder": "^1.0.0"
|
"@yume-chan/ts-package-builder": "^1.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { AutoDisposable, Disposable } from './disposable';
|
import { AutoDisposable, Disposable } from './disposable.js';
|
||||||
|
|
||||||
describe('Event', () => {
|
describe('Event', () => {
|
||||||
describe('AutoDisposable', () => {
|
describe('AutoDisposable', () => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type { Disposable } from './disposable';
|
import type { Disposable } from './disposable.js';
|
||||||
import type { EventListener, RemoveEventListener } from './event';
|
import type { EventListener, RemoveEventListener } from './event.js';
|
||||||
|
|
||||||
export interface EventListenerInfo<TEvent, TResult = unknown> {
|
export interface EventListenerInfo<TEvent, TResult = unknown> {
|
||||||
listener: EventListener<TEvent, any, any, TResult>;
|
listener: EventListener<TEvent, any, any, TResult>;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { Disposable } from './disposable';
|
import type { Disposable } from './disposable.js';
|
||||||
|
|
||||||
export interface EventListener<TEvent, TThis, TArgs extends unknown[], TResult> {
|
export interface EventListener<TEvent, TThis, TArgs extends unknown[], TResult> {
|
||||||
(this: TThis, e: TEvent, ...args: TArgs): TResult;
|
(this: TThis, e: TEvent, ...args: TArgs): TResult;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export * from './disposable';
|
export * from './disposable.js';
|
||||||
export * from './event';
|
export * from './event.js';
|
||||||
export * from './event-emitter';
|
export * from './event-emitter.js';
|
||||||
export * from './utils';
|
export * from './utils.js';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { PromiseResolver } from '@yume-chan/async';
|
import { PromiseResolver } from '@yume-chan/async';
|
||||||
import type { Event } from './event';
|
import type { Event } from './event.js';
|
||||||
|
|
||||||
export async function once<T>(event: Event<T, any>): Promise<T> {
|
export async function once<T>(event: Event<T, any>): Promise<T> {
|
||||||
const resolver = new PromiseResolver<T>();
|
const resolver = new PromiseResolver<T>();
|
||||||
|
|
|
@ -48,7 +48,8 @@ Scrcpy server has no backward compatibility on options input format. Currently t
|
||||||
| --------- | ------------------- |
|
| --------- | ------------------- |
|
||||||
| 1.16~1.17 | `ScrcpyOptions1_16` |
|
| 1.16~1.17 | `ScrcpyOptions1_16` |
|
||||||
| 1.18~1.20 | `ScrcpyOptions1_18` |
|
| 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.
|
You must use the correct type according to the server version.
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
"fetch-scrcpy-server": "scripts/fetch-server.cjs"
|
"fetch-scrcpy-server": "scripts/fetch-server.cjs"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"module": "esm/index.js",
|
"main": "esm/index.js",
|
||||||
"types": "esm/index.d.ts",
|
"types": "esm/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "build-ts-package",
|
"build": "build-ts-package",
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
"gh-release-fetch": "^2.0.4",
|
"gh-release-fetch": "^2.0.4",
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"tinyh264": "^0.0.7",
|
"tinyh264": "^0.0.7",
|
||||||
"typescript": "^4.6.2",
|
"typescript": "next",
|
||||||
"yuv-buffer": "^1.0.0",
|
"yuv-buffer": "^1.0.0",
|
||||||
"yuv-canvas": "^1.2.7"
|
"yuv-canvas": "^1.2.7"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { Adb, AdbBufferedStream, AdbNoneSubprocessProtocol, AdbSocket, DecodeUtf8Stream, InspectStream, ReadableStream, TransformStream, WritableStreamDefaultWriter, type AdbSubprocessProtocol } from '@yume-chan/adb';
|
import { Adb, AdbBufferedStream, AdbNoneSubprocessProtocol, AdbSocket, DecodeUtf8Stream, InspectStream, ReadableStream, TransformStream, WritableStreamDefaultWriter, type AdbSubprocessProtocol } from '@yume-chan/adb';
|
||||||
import { EventEmitter } from '@yume-chan/event';
|
import { EventEmitter } from '@yume-chan/event';
|
||||||
import Struct from '@yume-chan/struct';
|
import Struct from '@yume-chan/struct';
|
||||||
import { AndroidMotionEventAction, ScrcpyControlMessageType, ScrcpyInjectKeyCodeControlMessage, ScrcpyInjectTextControlMessage, ScrcpyInjectTouchControlMessage, type AndroidKeyEventAction } from './message';
|
import { AndroidMotionEventAction, ScrcpyControlMessageType, ScrcpyInjectKeyCodeControlMessage, ScrcpyInjectTextControlMessage, ScrcpyInjectTouchControlMessage, type AndroidKeyEventAction } from './message.js';
|
||||||
import type { ScrcpyInjectScrollControlMessage1_22, ScrcpyOptions, VideoStreamPacket } from "./options";
|
import type { ScrcpyInjectScrollControlMessage1_22, ScrcpyOptions, VideoStreamPacket } from "./options/index.js";
|
||||||
|
|
||||||
function* splitLines(text: string): Generator<string, void, void> {
|
function* splitLines(text: string): Generator<string, void, void> {
|
||||||
let start = 0;
|
let start = 0;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Adb, AdbBufferedStream, AdbSocket } from "@yume-chan/adb";
|
import { Adb, AdbBufferedStream, AdbSocket } from "@yume-chan/adb";
|
||||||
import type { Disposable } from "@yume-chan/event";
|
import type { Disposable } from "@yume-chan/event";
|
||||||
import type { ValueOrPromise } from "@yume-chan/struct";
|
import type { ValueOrPromise } from "@yume-chan/struct";
|
||||||
import { delay } from "./utils";
|
import { delay } from "./utils.js";
|
||||||
|
|
||||||
export interface ScrcpyClientConnectionOptions {
|
export interface ScrcpyClientConnectionOptions {
|
||||||
control: boolean;
|
control: boolean;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type { WritableStream } from '@yume-chan/adb';
|
import type { WritableStream } from '@yume-chan/adb';
|
||||||
import type { Disposable } from "@yume-chan/event";
|
import type { Disposable } from "@yume-chan/event";
|
||||||
import type { AndroidCodecLevel, AndroidCodecProfile } from "../codec";
|
import type { AndroidCodecLevel, AndroidCodecProfile } from "../codec.js";
|
||||||
import type { VideoStreamPacket } from "../options";
|
import type { VideoStreamPacket } from "../options/index.js";
|
||||||
|
|
||||||
export interface H264Configuration {
|
export interface H264Configuration {
|
||||||
profileIndex: number;
|
profileIndex: number;
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
export * from './common';
|
export * from './common.js';
|
||||||
export * from './tinyh264';
|
export * from './tinyh264/index.js';
|
||||||
export * from './web-codecs';
|
export * from './web-codecs/index.js';
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { WritableStream } from "@yume-chan/adb";
|
import { WritableStream } from "@yume-chan/adb";
|
||||||
import { PromiseResolver } from "@yume-chan/async";
|
import { PromiseResolver } from "@yume-chan/async";
|
||||||
import { AndroidCodecLevel, AndroidCodecProfile } from "../../codec";
|
import { AndroidCodecLevel, AndroidCodecProfile } from "../../codec.js";
|
||||||
import type { VideoStreamPacket } from "../../options";
|
import type { VideoStreamPacket } from "../../options/index.js";
|
||||||
import type { H264Configuration, H264Decoder } from '../common';
|
import type { H264Configuration, H264Decoder } from "../common.js";
|
||||||
import { createTinyH264Wrapper, type TinyH264Wrapper } from "./wrapper";
|
import { createTinyH264Wrapper, type TinyH264Wrapper } from "./wrapper.js";
|
||||||
|
|
||||||
let cachedInitializePromise: Promise<{ YuvBuffer: typeof import('yuv-buffer'), YuvCanvas: typeof import('yuv-canvas').default; }> | undefined;
|
let cachedInitializePromise: Promise<{ YuvBuffer: typeof import('yuv-buffer'), YuvCanvas: typeof import('yuv-canvas').default; }> | undefined;
|
||||||
function initialize() {
|
function initialize() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type { VideoStreamPacket } from "../../options";
|
import type { VideoStreamPacket } from "../../options/index.js";
|
||||||
import type { H264Configuration, H264Decoder } from "../common";
|
import type { H264Configuration, H264Decoder } from "../common.js";
|
||||||
|
|
||||||
function toHex(value: number) {
|
function toHex(value: number) {
|
||||||
return value.toString(16).padStart(2, '0').toUpperCase();
|
return value.toString(16).padStart(2, '0').toUpperCase();
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
export * from './client';
|
export * from './client.js';
|
||||||
export * from './codec';
|
export * from './codec.js';
|
||||||
export * from './connection';
|
export * from './connection.js';
|
||||||
export * from './decoder';
|
export * from './decoder/index.js';
|
||||||
export * from './message';
|
export * from './message.js';
|
||||||
export * from './options';
|
export * from './options/index.js';
|
||||||
export * from './push-server';
|
export * from './push-server.js';
|
||||||
export * from './utils';
|
export * from './utils.js';
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { BufferedStreamEndedError, ReadableStream, TransformStream, type Adb, type AdbBufferedStream } from "@yume-chan/adb";
|
import { BufferedStreamEndedError, ReadableStream, TransformStream, type Adb, type AdbBufferedStream } from "@yume-chan/adb";
|
||||||
import Struct, { placeholder } from "@yume-chan/struct";
|
import Struct, { placeholder } from "@yume-chan/struct";
|
||||||
import type { AndroidCodecLevel, AndroidCodecProfile } from "../../codec";
|
import type { AndroidCodecLevel, AndroidCodecProfile } from "../../codec.js";
|
||||||
import { ScrcpyClientConnection, ScrcpyClientForwardConnection, ScrcpyClientReverseConnection, type ScrcpyClientConnectionOptions } from "../../connection";
|
import { ScrcpyClientConnection, ScrcpyClientForwardConnection, ScrcpyClientReverseConnection, type ScrcpyClientConnectionOptions } from "../../connection.js";
|
||||||
import { AndroidKeyEventAction, ScrcpyControlMessageType } from "../../message";
|
import { AndroidKeyEventAction, ScrcpyControlMessageType } from "../../message.js";
|
||||||
import type { ScrcpyBackOrScreenOnEvent1_18 } from "../1_18";
|
import type { ScrcpyBackOrScreenOnEvent1_18 } from "../1_18.js";
|
||||||
import type { ScrcpyInjectScrollControlMessage1_22 } from "../1_22";
|
import type { ScrcpyInjectScrollControlMessage1_22 } from "../1_22.js";
|
||||||
import { toScrcpyOptionValue, type ScrcpyOptions, type ScrcpyOptionValue, type VideoStreamPacket } from "../common";
|
import { toScrcpyOptionValue, type ScrcpyOptions, type ScrcpyOptionValue, type VideoStreamPacket } from "../common.js";
|
||||||
import { parse_sequence_parameter_set } from "./sps";
|
import { parse_sequence_parameter_set } from "./sps.js";
|
||||||
|
|
||||||
export enum ScrcpyLogLevel {
|
export enum ScrcpyLogLevel {
|
||||||
Verbose = 'verbose',
|
Verbose = 'verbose',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import Struct, { placeholder } from "@yume-chan/struct";
|
import Struct, { placeholder } from "@yume-chan/struct";
|
||||||
import type { AndroidKeyEventAction } from "../message";
|
import type { AndroidKeyEventAction } from "../message.js";
|
||||||
import { ScrcpyBackOrScreenOnEvent1_16, ScrcpyOptions1_16, type ScrcpyOptionsInit1_16 } from "./1_16";
|
import { ScrcpyBackOrScreenOnEvent1_16, ScrcpyOptions1_16, type ScrcpyOptionsInit1_16 } from "./1_16/index.js";
|
||||||
|
|
||||||
export interface ScrcpyOptionsInit1_18 extends ScrcpyOptionsInit1_16 {
|
export interface ScrcpyOptionsInit1_18 extends ScrcpyOptionsInit1_16 {
|
||||||
powerOffOnClose: boolean;
|
powerOffOnClose: boolean;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// cspell: ignore autosync
|
// cspell: ignore autosync
|
||||||
|
|
||||||
import { ScrcpyOptions1_18, type ScrcpyOptionsInit1_18 } from './1_18';
|
import { ScrcpyOptions1_18, type ScrcpyOptionsInit1_18 } from './1_18.js';
|
||||||
import { toScrcpyOptionValue } from "./common";
|
import { toScrcpyOptionValue } from "./common.js";
|
||||||
|
|
||||||
export interface ScrcpyOptionsInit1_21 extends ScrcpyOptionsInit1_18 {
|
export interface ScrcpyOptionsInit1_21 extends ScrcpyOptionsInit1_18 {
|
||||||
clipboardAutosync?: boolean;
|
clipboardAutosync?: boolean;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import type { Adb } from "@yume-chan/adb";
|
import type { Adb } from "@yume-chan/adb";
|
||||||
import Struct from "@yume-chan/struct";
|
import Struct from "@yume-chan/struct";
|
||||||
import { ScrcpyClientForwardConnection, ScrcpyClientReverseConnection, type ScrcpyClientConnection, type ScrcpyClientConnectionOptions } from "../connection";
|
import { ScrcpyClientForwardConnection, ScrcpyClientReverseConnection, type ScrcpyClientConnection, type ScrcpyClientConnectionOptions } from "../connection.js";
|
||||||
import { ScrcpyInjectScrollControlMessage1_16 } from "./1_16";
|
import { ScrcpyInjectScrollControlMessage1_16 } from "./1_16/index.js";
|
||||||
import { ScrcpyOptions1_21, type ScrcpyOptionsInit1_21 } from "./1_21";
|
import { ScrcpyOptions1_21, type ScrcpyOptionsInit1_21 } from "./1_21.js";
|
||||||
|
|
||||||
export interface ScrcpyOptionsInit1_22 extends ScrcpyOptionsInit1_21 {
|
export interface ScrcpyOptionsInit1_22 extends ScrcpyOptionsInit1_21 {
|
||||||
downsizeOnError: boolean;
|
downsizeOnError: boolean;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import type { Adb, AdbBufferedStream, ReadableStream } from "@yume-chan/adb";
|
import type { Adb, AdbBufferedStream, ReadableStream } from "@yume-chan/adb";
|
||||||
import type { ScrcpyClientConnection } from "../connection";
|
import type { ScrcpyClientConnection } from "../connection.js";
|
||||||
import type { H264Configuration } from "../decoder";
|
import type { H264Configuration } from "../decoder/index.js";
|
||||||
import type { ScrcpyBackOrScreenOnEvent1_18 } from "./1_18";
|
import type { ScrcpyBackOrScreenOnEvent1_18 } from "./1_18.js";
|
||||||
import type { ScrcpyInjectScrollControlMessage1_22 } from "./1_22";
|
import type { ScrcpyInjectScrollControlMessage1_22 } from "./1_22.js";
|
||||||
|
|
||||||
export const DEFAULT_SERVER_PATH = '/data/local/tmp/scrcpy-server.jar';
|
export const DEFAULT_SERVER_PATH = '/data/local/tmp/scrcpy-server.jar';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
export * from './1_16';
|
export * from './1_16/index.js';
|
||||||
export * from './1_18';
|
export * from './1_18.js';
|
||||||
export * from './1_21';
|
export * from './1_21.js';
|
||||||
export * from './1_22';
|
export * from './1_22.js';
|
||||||
export * from './common';
|
export * from './common.js';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Adb, AdbSync, WrapWritableStream, WritableStream } from "@yume-chan/adb";
|
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 {
|
export interface PushServerOptions {
|
||||||
path?: string;
|
path?: string;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"module": "esm/index.js",
|
"main": "esm/index.js",
|
||||||
"types": "esm/index.d.ts",
|
"types": "esm/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "build-ts-package",
|
"build": "build-ts-package",
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"typescript": "^4.6.2",
|
"typescript": "next",
|
||||||
"@yume-chan/ts-package-builder": "^1.0.0",
|
"@yume-chan/ts-package-builder": "^1.0.0",
|
||||||
"@types/jest": "^27.4.0",
|
"@types/jest": "^27.4.0",
|
||||||
"@types/bluebird": "^3.5.36"
|
"@types/bluebird": "^3.5.36"
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import type { ValueOrPromise } from '../utils';
|
import type { ValueOrPromise } from '../utils.js';
|
||||||
import { StructFieldDefinition } from './definition';
|
import { StructFieldDefinition } from './definition.js';
|
||||||
import type { StructFieldValue } from './field-value';
|
import type { StructFieldValue } from './field-value.js';
|
||||||
import type { StructOptions } from './options';
|
import type { StructOptions } from './options.js';
|
||||||
import type { StructAsyncDeserializeStream, StructDeserializeStream } from './stream';
|
import type { StructAsyncDeserializeStream, StructDeserializeStream } from './stream.js';
|
||||||
import type { StructValue } from './struct-value';
|
import type { StructValue } from './struct-value.js';
|
||||||
|
|
||||||
describe('StructFieldDefinition', () => {
|
describe('StructFieldDefinition', () => {
|
||||||
describe('.constructor', () => {
|
describe('.constructor', () => {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
// cspell: ignore Syncbird
|
// cspell: ignore Syncbird
|
||||||
|
|
||||||
import type { StructAsyncDeserializeStream, StructDeserializeStream } from './stream';
|
import type { StructAsyncDeserializeStream, StructDeserializeStream } from "./stream.js";
|
||||||
import type { StructFieldValue } from './field-value';
|
import type { StructFieldValue } from "./field-value.js";
|
||||||
import type { StructValue } from './struct-value';
|
import type { StructValue } from "./struct-value.js";
|
||||||
import type { StructOptions } from "./options";
|
import type { StructOptions } from "./options.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A field definition defines how to deserialize a field.
|
* A field definition defines how to deserialize a field.
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import type { ValueOrPromise } from '../utils';
|
import type { ValueOrPromise } from "../utils.js";
|
||||||
import { StructFieldDefinition } from './definition';
|
import { StructFieldDefinition } from "./definition.js";
|
||||||
import { StructFieldValue } from './field-value';
|
import { StructFieldValue } from "./field-value.js";
|
||||||
import type { StructOptions } from './options';
|
import type { StructOptions } from "./options.js";
|
||||||
import type { StructAsyncDeserializeStream, StructDeserializeStream } from './stream';
|
import type { StructAsyncDeserializeStream, StructDeserializeStream } from "./stream.js";
|
||||||
import type { StructValue } from './struct-value';
|
import type { StructValue } from "./struct-value.js";
|
||||||
|
|
||||||
describe('StructFieldValue', () => {
|
describe('StructFieldValue', () => {
|
||||||
describe('.constructor', () => {
|
describe('.constructor', () => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type { StructFieldDefinition } from './definition';
|
import type { StructFieldDefinition } from "./definition.js";
|
||||||
import type { StructOptions } from './options';
|
import type { StructOptions } from "./options.js";
|
||||||
import type { StructValue } from './struct-value';
|
import type { StructValue } from "./struct-value.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A field value defines how to serialize a field.
|
* A field value defines how to serialize a field.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
export * from './definition';
|
export * from './definition.js';
|
||||||
export * from './field-value';
|
export * from './field-value.js';
|
||||||
export * from './options';
|
export * from './options.js';
|
||||||
export * from './stream';
|
export * from './stream.js';
|
||||||
export * from './struct-value';
|
export * from './struct-value.js';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { StructDefaultOptions } from './options';
|
import { StructDefaultOptions } from './options.js';
|
||||||
|
|
||||||
describe('StructDefaultOptions', () => {
|
describe('StructDefaultOptions', () => {
|
||||||
describe('.littleEndian', () => {
|
describe('.littleEndian', () => {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { StructValue } from './struct-value';
|
import { StructValue } from "./struct-value.js";
|
||||||
|
|
||||||
describe('StructValue', () => {
|
describe('StructValue', () => {
|
||||||
describe('.constructor', () => {
|
describe('.constructor', () => {
|
||||||
|
|
|
@ -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.
|
* A struct value is a map between keys in a struct and their field values.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import Struct from './index';
|
import Struct from './index.js';
|
||||||
|
|
||||||
describe('Struct', () => {
|
describe('Struct', () => {
|
||||||
describe("Index", () => {
|
describe("Index", () => {
|
||||||
|
|
|
@ -10,8 +10,8 @@ declare global {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export * from './basic';
|
export * from './basic/index.js';
|
||||||
export * from './struct';
|
export * from './struct.js';
|
||||||
export { Struct as default } from './struct';
|
export { Struct as default } from './struct.js';
|
||||||
export * from './types';
|
export * from './types/index.js';
|
||||||
export * from './utils';
|
export * from './utils.js';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { StructAsyncDeserializeStream, StructDefaultOptions, StructDeserializeStream, StructFieldDefinition, StructFieldValue, StructOptions, StructValue } from './basic';
|
import { StructAsyncDeserializeStream, StructDefaultOptions, StructDeserializeStream, StructFieldDefinition, StructFieldValue, StructOptions, StructValue } from './basic/index.js';
|
||||||
import { Struct } from './struct';
|
import { Struct } from './struct.js';
|
||||||
import { ArrayBufferFieldType, BigIntFieldDefinition, BigIntFieldType, FixedLengthArrayBufferLikeFieldDefinition, NumberFieldDefinition, NumberFieldType, StringFieldType, ArrayBufferViewFieldType, VariableLengthArrayBufferLikeFieldDefinition } from './types';
|
import { ArrayBufferFieldType, BigIntFieldDefinition, BigIntFieldType, FixedLengthArrayBufferLikeFieldDefinition, NumberFieldDefinition, NumberFieldType, StringFieldType, ArrayBufferViewFieldType, VariableLengthArrayBufferLikeFieldDefinition } from './types/index.js';
|
||||||
import { ValueOrPromise } from './utils';
|
import { ValueOrPromise } from './utils.js';
|
||||||
|
|
||||||
class MockDeserializationStream implements StructDeserializeStream {
|
class MockDeserializationStream implements StructDeserializeStream {
|
||||||
public buffer = new ArrayBuffer(0);
|
public buffer = new ArrayBuffer(0);
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
// cspell: ignore Syncbird
|
// cspell: ignore Syncbird
|
||||||
|
|
||||||
import type { StructAsyncDeserializeStream, StructDeserializeStream, StructFieldDefinition, StructFieldValue, StructOptions } from './basic';
|
import type { StructAsyncDeserializeStream, StructDeserializeStream, StructFieldDefinition, StructFieldValue, StructOptions } from './basic/index.js';
|
||||||
import { StructDefaultOptions, StructValue } from './basic';
|
import { StructDefaultOptions, StructValue } from './basic/index.js';
|
||||||
import { Syncbird } from "./syncbird";
|
import { Syncbird } from "./syncbird.js";
|
||||||
import { BigIntFieldDefinition, BigIntFieldType, BufferFieldSubType, FixedLengthBufferLikeFieldDefinition, NumberFieldDefinition, NumberFieldType, StringBufferFieldSubType, Uint8ArrayBufferFieldSubType, VariableLengthBufferLikeFieldDefinition, type FixedLengthBufferLikeFieldOptions, type LengthField, type VariableLengthBufferLikeFieldOptions } from './types';
|
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";
|
import type { Evaluate, Identity, Overwrite, ValueOrPromise } from "./utils.js";
|
||||||
|
|
||||||
export interface StructLike<TValue> {
|
export interface StructLike<TValue> {
|
||||||
deserialize(stream: StructDeserializeStream | StructAsyncDeserializeStream): Promise<TValue>;
|
deserialize(stream: StructDeserializeStream | StructAsyncDeserializeStream): Promise<TValue>;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
// cspell: ignore syncbird
|
// cspell: ignore syncbird
|
||||||
|
|
||||||
import { getBigInt64, getBigUint64, setBigInt64, setBigUint64 } from '@yume-chan/dataview-bigint-polyfill/esm/fallback';
|
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";
|
import { StructFieldDefinition, StructFieldValue, StructValue, type StructAsyncDeserializeStream, type StructDeserializeStream, type StructOptions } from "../basic/index.js";
|
||||||
import { Syncbird } from "../syncbird";
|
import { Syncbird } from "../syncbird.js";
|
||||||
import type { ValueOrPromise } from "../utils";
|
import type { ValueOrPromise } from "../utils.js";
|
||||||
|
|
||||||
type DataViewBigInt64Getter = (dataView: DataView, byteOffset: number, littleEndian: boolean | undefined) => bigint;
|
type DataViewBigInt64Getter = (dataView: DataView, byteOffset: number, littleEndian: boolean | undefined) => bigint;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { StructDefaultOptions, StructDeserializeStream, StructValue } from '../../basic';
|
import { StructDefaultOptions, StructDeserializeStream, StructValue } from '../../basic/index.js';
|
||||||
import { BufferFieldSubType, BufferLikeFieldDefinition, StringBufferFieldSubType, Uint8ArrayBufferFieldSubType } from './base';
|
import { BufferFieldSubType, BufferLikeFieldDefinition, StringBufferFieldSubType, Uint8ArrayBufferFieldSubType } from './base.js';
|
||||||
|
|
||||||
class MockDeserializationStream implements StructDeserializeStream {
|
class MockDeserializationStream implements StructDeserializeStream {
|
||||||
public array = new Uint8Array(0);
|
public array = new Uint8Array(0);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// cspell: ignore syncbird
|
// cspell: ignore syncbird
|
||||||
|
|
||||||
import { StructFieldDefinition, StructFieldValue, StructValue, type StructAsyncDeserializeStream, type StructDeserializeStream, type StructOptions } from '../../basic';
|
import { StructFieldDefinition, StructFieldValue, StructValue, type StructAsyncDeserializeStream, type StructDeserializeStream, type StructOptions } from '../../basic/index.js';
|
||||||
import { Syncbird } from "../../syncbird";
|
import { Syncbird } from "../../syncbird.js";
|
||||||
import { decodeUtf8, encodeUtf8, type ValueOrPromise } from "../../utils";
|
import { decodeUtf8, encodeUtf8, type ValueOrPromise } from "../../utils.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for all types that
|
* Base class for all types that
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { Uint8ArrayBufferFieldSubType } from './base';
|
import { Uint8ArrayBufferFieldSubType } from "./base.js";
|
||||||
import { FixedLengthBufferLikeFieldDefinition } from './fixed-length';
|
import { FixedLengthBufferLikeFieldDefinition } from "./fixed-length.js";
|
||||||
|
|
||||||
describe('Types', () => {
|
describe("Types", () => {
|
||||||
describe('FixedLengthArrayBufferLikeFieldDefinition', () => {
|
describe("FixedLengthArrayBufferLikeFieldDefinition", () => {
|
||||||
describe('#getSize', () => {
|
describe("#getSize", () => {
|
||||||
it('should return size in its options', () => {
|
it("should return size in its options", () => {
|
||||||
const definition = new FixedLengthBufferLikeFieldDefinition(
|
const definition = new FixedLengthBufferLikeFieldDefinition(
|
||||||
Uint8ArrayBufferFieldSubType.Instance,
|
Uint8ArrayBufferFieldSubType.Instance,
|
||||||
{ length: 10 },
|
{ length: 10 },
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { BufferLikeFieldDefinition, type BufferFieldSubType } from './base';
|
import { BufferLikeFieldDefinition, type BufferFieldSubType } from "./base.js";
|
||||||
|
|
||||||
export interface FixedLengthBufferLikeFieldOptions {
|
export interface FixedLengthBufferLikeFieldOptions {
|
||||||
length: number;
|
length: number;
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
export * from './base';
|
export * from "./base.js";
|
||||||
export * from './fixed-length';
|
export * from "./fixed-length.js";
|
||||||
export * from './variable-length';
|
export * from "./variable-length.js";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { StructDefaultOptions, StructFieldValue, StructValue } from '../../basic';
|
import { StructDefaultOptions, StructFieldValue, StructValue } from "../../basic/index.js";
|
||||||
import { BufferFieldSubType, Uint8ArrayBufferFieldSubType } from './base';
|
import { BufferFieldSubType, Uint8ArrayBufferFieldSubType } from "./base.js";
|
||||||
import { VariableLengthBufferLikeFieldDefinition, VariableLengthBufferLikeFieldLengthValue, VariableLengthBufferLikeStructFieldValue } from './variable-length';
|
import { VariableLengthBufferLikeFieldDefinition, VariableLengthBufferLikeFieldLengthValue, VariableLengthBufferLikeStructFieldValue } from "./variable-length.js";
|
||||||
|
|
||||||
class MockOriginalFieldValue extends StructFieldValue {
|
class MockOriginalFieldValue extends StructFieldValue {
|
||||||
public constructor() {
|
public constructor() {
|
||||||
|
@ -20,8 +20,8 @@ class MockOriginalFieldValue extends StructFieldValue {
|
||||||
public serialize = jest.fn((dataView: DataView, offset: number): void => { });
|
public serialize = jest.fn((dataView: DataView, offset: number): void => { });
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Types', () => {
|
describe("Types", () => {
|
||||||
describe('VariableLengthArrayBufferLikeFieldLengthValue', () => {
|
describe("VariableLengthArrayBufferLikeFieldLengthValue", () => {
|
||||||
class MockArrayBufferFieldValue extends StructFieldValue {
|
class MockArrayBufferFieldValue extends StructFieldValue {
|
||||||
public constructor() {
|
public constructor() {
|
||||||
super({ options: {} } as any, {} as any, {} as any, {});
|
super({ options: {} } as any, {} as any, {} as any, {});
|
||||||
|
@ -32,12 +32,12 @@ describe('Types', () => {
|
||||||
public override getSize = jest.fn(() => this.size);
|
public override getSize = jest.fn(() => this.size);
|
||||||
|
|
||||||
public serialize(dataView: DataView, offset: number): void {
|
public serialize(dataView: DataView, offset: number): void {
|
||||||
throw new Error('Method not implemented.');
|
throw new Error("Method not implemented.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('#getSize', () => {
|
describe("#getSize", () => {
|
||||||
it('should return size of its original field value', () => {
|
it("should return size of its original field value", () => {
|
||||||
const mockOriginalFieldValue = new MockOriginalFieldValue();
|
const mockOriginalFieldValue = new MockOriginalFieldValue();
|
||||||
const mockArrayBufferFieldValue = new MockArrayBufferFieldValue();
|
const mockArrayBufferFieldValue = new MockArrayBufferFieldValue();
|
||||||
const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue(
|
const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue(
|
||||||
|
@ -56,8 +56,8 @@ describe('Types', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#get', () => {
|
describe("#get", () => {
|
||||||
it('should return size of its `arrayBufferField`', async () => {
|
it("should return size of its `arrayBufferField`", async () => {
|
||||||
const mockOriginalFieldValue = new MockOriginalFieldValue();
|
const mockOriginalFieldValue = new MockOriginalFieldValue();
|
||||||
const mockArrayBufferFieldValue = new MockArrayBufferFieldValue();
|
const mockArrayBufferFieldValue = new MockArrayBufferFieldValue();
|
||||||
const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue(
|
const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue(
|
||||||
|
@ -79,7 +79,7 @@ describe('Types', () => {
|
||||||
expect(mockOriginalFieldValue.get).toBeCalledTimes(1);
|
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 mockOriginalFieldValue = new MockOriginalFieldValue();
|
||||||
const mockArrayBufferFieldValue = new MockArrayBufferFieldValue();
|
const mockArrayBufferFieldValue = new MockArrayBufferFieldValue();
|
||||||
const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue(
|
const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue(
|
||||||
|
@ -87,23 +87,23 @@ describe('Types', () => {
|
||||||
mockArrayBufferFieldValue,
|
mockArrayBufferFieldValue,
|
||||||
);
|
);
|
||||||
|
|
||||||
mockOriginalFieldValue.value = '0';
|
mockOriginalFieldValue.value = "0";
|
||||||
mockArrayBufferFieldValue.size = 0;
|
mockArrayBufferFieldValue.size = 0;
|
||||||
expect(lengthFieldValue.get()).toBe('0');
|
expect(lengthFieldValue.get()).toBe("0");
|
||||||
expect(mockArrayBufferFieldValue.getSize).toBeCalledTimes(1);
|
expect(mockArrayBufferFieldValue.getSize).toBeCalledTimes(1);
|
||||||
expect(mockOriginalFieldValue.get).toBeCalledTimes(1);
|
expect(mockOriginalFieldValue.get).toBeCalledTimes(1);
|
||||||
|
|
||||||
mockArrayBufferFieldValue.getSize.mockClear();
|
mockArrayBufferFieldValue.getSize.mockClear();
|
||||||
mockOriginalFieldValue.get.mockClear();
|
mockOriginalFieldValue.get.mockClear();
|
||||||
mockArrayBufferFieldValue.size = 100;
|
mockArrayBufferFieldValue.size = 100;
|
||||||
expect(lengthFieldValue.get()).toBe('100');
|
expect(lengthFieldValue.get()).toBe("100");
|
||||||
expect(mockArrayBufferFieldValue.getSize).toBeCalledTimes(1);
|
expect(mockArrayBufferFieldValue.getSize).toBeCalledTimes(1);
|
||||||
expect(mockOriginalFieldValue.get).toBeCalledTimes(1);
|
expect(mockOriginalFieldValue.get).toBeCalledTimes(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#set', () => {
|
describe("#set", () => {
|
||||||
it('should does nothing', async () => {
|
it("should does nothing", async () => {
|
||||||
const mockOriginalFieldValue = new MockOriginalFieldValue();
|
const mockOriginalFieldValue = new MockOriginalFieldValue();
|
||||||
const mockArrayBufferFieldValue = new MockArrayBufferFieldValue();
|
const mockArrayBufferFieldValue = new MockArrayBufferFieldValue();
|
||||||
const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue(
|
const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue(
|
||||||
|
@ -120,8 +120,8 @@ describe('Types', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#serialize', () => {
|
describe("#serialize", () => {
|
||||||
it('should call `serialize` of its `originalField`', async () => {
|
it("should call `serialize` of its `originalField`", async () => {
|
||||||
const mockOriginalFieldValue = new MockOriginalFieldValue();
|
const mockOriginalFieldValue = new MockOriginalFieldValue();
|
||||||
const mockArrayBufferFieldValue = new MockArrayBufferFieldValue();
|
const mockArrayBufferFieldValue = new MockArrayBufferFieldValue();
|
||||||
const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue(
|
const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue(
|
||||||
|
@ -152,7 +152,7 @@ describe('Types', () => {
|
||||||
expect(mockOriginalFieldValue.serialize).toBeCalledWith(dataView, offset);
|
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 mockOriginalFieldValue = new MockOriginalFieldValue();
|
||||||
const mockArrayBufferFieldValue = new MockArrayBufferFieldValue();
|
const mockArrayBufferFieldValue = new MockArrayBufferFieldValue();
|
||||||
const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue(
|
const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue(
|
||||||
|
@ -163,13 +163,13 @@ describe('Types', () => {
|
||||||
let dataView = 0 as any;
|
let dataView = 0 as any;
|
||||||
let offset = 1 as any;
|
let offset = 1 as any;
|
||||||
|
|
||||||
mockOriginalFieldValue.value = '10';
|
mockOriginalFieldValue.value = "10";
|
||||||
mockArrayBufferFieldValue.size = 0;
|
mockArrayBufferFieldValue.size = 0;
|
||||||
lengthFieldValue.serialize(dataView, offset);
|
lengthFieldValue.serialize(dataView, offset);
|
||||||
expect(mockOriginalFieldValue.get).toBeCalledTimes(1);
|
expect(mockOriginalFieldValue.get).toBeCalledTimes(1);
|
||||||
expect(mockOriginalFieldValue.get).toReturnWith('10');
|
expect(mockOriginalFieldValue.get).toReturnWith("10");
|
||||||
expect(mockOriginalFieldValue.set).toBeCalledTimes(1);
|
expect(mockOriginalFieldValue.set).toBeCalledTimes(1);
|
||||||
expect(mockOriginalFieldValue.set).toBeCalledWith('0');
|
expect(mockOriginalFieldValue.set).toBeCalledWith("0");
|
||||||
expect(mockOriginalFieldValue.serialize).toBeCalledTimes(1);
|
expect(mockOriginalFieldValue.serialize).toBeCalledTimes(1);
|
||||||
expect(mockOriginalFieldValue.serialize).toBeCalledWith(dataView, offset);
|
expect(mockOriginalFieldValue.serialize).toBeCalledWith(dataView, offset);
|
||||||
|
|
||||||
|
@ -178,12 +178,12 @@ describe('Types', () => {
|
||||||
mockArrayBufferFieldValue.size = 100;
|
mockArrayBufferFieldValue.size = 100;
|
||||||
lengthFieldValue.serialize(dataView, offset);
|
lengthFieldValue.serialize(dataView, offset);
|
||||||
expect(mockOriginalFieldValue.set).toBeCalledTimes(1);
|
expect(mockOriginalFieldValue.set).toBeCalledTimes(1);
|
||||||
expect(mockOriginalFieldValue.set).toBeCalledWith('100');
|
expect(mockOriginalFieldValue.set).toBeCalledWith("100");
|
||||||
expect(mockOriginalFieldValue.serialize).toBeCalledTimes(1);
|
expect(mockOriginalFieldValue.serialize).toBeCalledTimes(1);
|
||||||
expect(mockOriginalFieldValue.serialize).toBeCalledWith(dataView, offset);
|
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 mockOriginalFieldValue = new MockOriginalFieldValue();
|
||||||
const mockArrayBufferFieldValue = new MockArrayBufferFieldValue();
|
const mockArrayBufferFieldValue = new MockArrayBufferFieldValue();
|
||||||
const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue(
|
const lengthFieldValue = new VariableLengthBufferLikeFieldLengthValue(
|
||||||
|
@ -197,13 +197,13 @@ describe('Types', () => {
|
||||||
let dataView = 0 as any;
|
let dataView = 0 as any;
|
||||||
let offset = 1 as any;
|
let offset = 1 as any;
|
||||||
|
|
||||||
mockOriginalFieldValue.value = '10';
|
mockOriginalFieldValue.value = "10";
|
||||||
mockArrayBufferFieldValue.size = 0;
|
mockArrayBufferFieldValue.size = 0;
|
||||||
lengthFieldValue.serialize(dataView, offset);
|
lengthFieldValue.serialize(dataView, offset);
|
||||||
expect(mockOriginalFieldValue.get).toBeCalledTimes(1);
|
expect(mockOriginalFieldValue.get).toBeCalledTimes(1);
|
||||||
expect(mockOriginalFieldValue.get).toReturnWith('10');
|
expect(mockOriginalFieldValue.get).toReturnWith("10");
|
||||||
expect(mockOriginalFieldValue.set).toBeCalledTimes(1);
|
expect(mockOriginalFieldValue.set).toBeCalledTimes(1);
|
||||||
expect(mockOriginalFieldValue.set).toBeCalledWith('0');
|
expect(mockOriginalFieldValue.set).toBeCalledWith("0");
|
||||||
expect(mockOriginalFieldValue.serialize).toBeCalledTimes(1);
|
expect(mockOriginalFieldValue.serialize).toBeCalledTimes(1);
|
||||||
expect(mockOriginalFieldValue.serialize).toBeCalledWith(dataView, offset);
|
expect(mockOriginalFieldValue.serialize).toBeCalledWith(dataView, offset);
|
||||||
|
|
||||||
|
@ -219,12 +219,12 @@ describe('Types', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('VariableLengthArrayBufferLikeStructFieldValue', () => {
|
describe("VariableLengthArrayBufferLikeStructFieldValue", () => {
|
||||||
describe('.constructor', () => {
|
describe(".constructor", () => {
|
||||||
it('should forward parameters', () => {
|
it("should forward parameters", () => {
|
||||||
const struct = new StructValue();
|
const struct = new StructValue();
|
||||||
|
|
||||||
const lengthField = 'foo';
|
const lengthField = "foo";
|
||||||
const originalLengthFieldValue = new MockOriginalFieldValue();
|
const originalLengthFieldValue = new MockOriginalFieldValue();
|
||||||
struct.set(lengthField, originalLengthFieldValue);
|
struct.set(lengthField, originalLengthFieldValue);
|
||||||
|
|
||||||
|
@ -242,18 +242,18 @@ describe('Types', () => {
|
||||||
value,
|
value,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('definition', arrayBufferFieldDefinition);
|
expect(arrayBufferFieldValue).toHaveProperty("definition", arrayBufferFieldDefinition);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('options', StructDefaultOptions);
|
expect(arrayBufferFieldValue).toHaveProperty("options", StructDefaultOptions);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('struct', struct);
|
expect(arrayBufferFieldValue).toHaveProperty("struct", struct);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('value', value);
|
expect(arrayBufferFieldValue).toHaveProperty("value", value);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('arrayBuffer', undefined);
|
expect(arrayBufferFieldValue).toHaveProperty("arrayBuffer", undefined);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('length', undefined);
|
expect(arrayBufferFieldValue).toHaveProperty("length", undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should forward parameters with `arrayBuffer`', () => {
|
it("should forward parameters with `arrayBuffer`", () => {
|
||||||
const struct = new StructValue();
|
const struct = new StructValue();
|
||||||
|
|
||||||
const lengthField = 'foo';
|
const lengthField = "foo";
|
||||||
const originalLengthFieldValue = new MockOriginalFieldValue();
|
const originalLengthFieldValue = new MockOriginalFieldValue();
|
||||||
struct.set(lengthField, originalLengthFieldValue);
|
struct.set(lengthField, originalLengthFieldValue);
|
||||||
|
|
||||||
|
@ -272,18 +272,18 @@ describe('Types', () => {
|
||||||
value,
|
value,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('definition', arrayBufferFieldDefinition);
|
expect(arrayBufferFieldValue).toHaveProperty("definition", arrayBufferFieldDefinition);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('options', StructDefaultOptions);
|
expect(arrayBufferFieldValue).toHaveProperty("options", StructDefaultOptions);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('struct', struct);
|
expect(arrayBufferFieldValue).toHaveProperty("struct", struct);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('value', value);
|
expect(arrayBufferFieldValue).toHaveProperty("value", value);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('array', value);
|
expect(arrayBufferFieldValue).toHaveProperty("array", value);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('length', 100);
|
expect(arrayBufferFieldValue).toHaveProperty("length", 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should replace `lengthField` on `struct`', () => {
|
it("should replace `lengthField` on `struct`", () => {
|
||||||
const struct = new StructValue();
|
const struct = new StructValue();
|
||||||
|
|
||||||
const lengthField = 'foo';
|
const lengthField = "foo";
|
||||||
const originalLengthFieldValue = new MockOriginalFieldValue();
|
const originalLengthFieldValue = new MockOriginalFieldValue();
|
||||||
struct.set(lengthField, originalLengthFieldValue);
|
struct.set(lengthField, originalLengthFieldValue);
|
||||||
|
|
||||||
|
@ -301,12 +301,12 @@ describe('Types', () => {
|
||||||
value,
|
value,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(arrayBufferFieldValue['lengthFieldValue']).toBeInstanceOf(StructFieldValue);
|
expect(arrayBufferFieldValue["lengthFieldValue"]).toBeInstanceOf(StructFieldValue);
|
||||||
expect(struct.fieldValues[lengthField]).toBe(arrayBufferFieldValue['lengthFieldValue']);
|
expect(struct.fieldValues[lengthField]).toBe(arrayBufferFieldValue["lengthFieldValue"]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#getSize', () => {
|
describe("#getSize", () => {
|
||||||
class MockArrayBufferFieldType extends BufferFieldSubType<Uint8Array> {
|
class MockArrayBufferFieldType extends BufferFieldSubType<Uint8Array> {
|
||||||
public override toBuffer = jest.fn((value: Uint8Array): Uint8Array => {
|
public override toBuffer = jest.fn((value: Uint8Array): Uint8Array => {
|
||||||
return value;
|
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 struct = new StructValue();
|
||||||
|
|
||||||
const lengthField = 'foo';
|
const lengthField = "foo";
|
||||||
const originalLengthFieldValue = new MockOriginalFieldValue();
|
const originalLengthFieldValue = new MockOriginalFieldValue();
|
||||||
struct.set(lengthField, originalLengthFieldValue);
|
struct.set(lengthField, originalLengthFieldValue);
|
||||||
|
|
||||||
|
@ -352,10 +352,10 @@ describe('Types', () => {
|
||||||
expect(arrayBufferFieldType.getSize).toBeCalledTimes(0);
|
expect(arrayBufferFieldType.getSize).toBeCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call `getSize` of its `type`', () => {
|
it("should call `getSize` of its `type`", () => {
|
||||||
const struct = new StructValue();
|
const struct = new StructValue();
|
||||||
|
|
||||||
const lengthField = 'foo';
|
const lengthField = "foo";
|
||||||
const originalLengthFieldValue = new MockOriginalFieldValue();
|
const originalLengthFieldValue = new MockOriginalFieldValue();
|
||||||
struct.set(lengthField, originalLengthFieldValue);
|
struct.set(lengthField, originalLengthFieldValue);
|
||||||
|
|
||||||
|
@ -379,14 +379,14 @@ describe('Types', () => {
|
||||||
expect(arrayBufferFieldType.toValue).toBeCalledTimes(0);
|
expect(arrayBufferFieldType.toValue).toBeCalledTimes(0);
|
||||||
expect(arrayBufferFieldType.toBuffer).toBeCalledTimes(0);
|
expect(arrayBufferFieldType.toBuffer).toBeCalledTimes(0);
|
||||||
expect(arrayBufferFieldType.getSize).toBeCalledTimes(1);
|
expect(arrayBufferFieldType.getSize).toBeCalledTimes(1);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('arrayBuffer', undefined);
|
expect(arrayBufferFieldValue).toHaveProperty("arrayBuffer", undefined);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('length', 100);
|
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 struct = new StructValue();
|
||||||
|
|
||||||
const lengthField = 'foo';
|
const lengthField = "foo";
|
||||||
const originalLengthFieldValue = new MockOriginalFieldValue();
|
const originalLengthFieldValue = new MockOriginalFieldValue();
|
||||||
struct.set(lengthField, originalLengthFieldValue);
|
struct.set(lengthField, originalLengthFieldValue);
|
||||||
|
|
||||||
|
@ -410,16 +410,16 @@ describe('Types', () => {
|
||||||
expect(arrayBufferFieldType.toValue).toBeCalledTimes(0);
|
expect(arrayBufferFieldType.toValue).toBeCalledTimes(0);
|
||||||
expect(arrayBufferFieldType.toBuffer).toBeCalledTimes(1);
|
expect(arrayBufferFieldType.toBuffer).toBeCalledTimes(1);
|
||||||
expect(arrayBufferFieldType.getSize).toBeCalledTimes(1);
|
expect(arrayBufferFieldType.getSize).toBeCalledTimes(1);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('arrayBuffer', value);
|
expect(arrayBufferFieldValue).toHaveProperty("arrayBuffer", value);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('length', 100);
|
expect(arrayBufferFieldValue).toHaveProperty("length", 100);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#set', () => {
|
describe("#set", () => {
|
||||||
it('should call `ArrayBufferLikeFieldValue#set`', () => {
|
it("should call `ArrayBufferLikeFieldValue#set`", () => {
|
||||||
const struct = new StructValue();
|
const struct = new StructValue();
|
||||||
|
|
||||||
const lengthField = 'foo';
|
const lengthField = "foo";
|
||||||
const originalLengthFieldValue = new MockOriginalFieldValue();
|
const originalLengthFieldValue = new MockOriginalFieldValue();
|
||||||
struct.set(lengthField, originalLengthFieldValue);
|
struct.set(lengthField, originalLengthFieldValue);
|
||||||
|
|
||||||
|
@ -441,13 +441,13 @@ describe('Types', () => {
|
||||||
const newValue = new ArrayBuffer(100);
|
const newValue = new ArrayBuffer(100);
|
||||||
arrayBufferFieldValue.set(newValue);
|
arrayBufferFieldValue.set(newValue);
|
||||||
expect(arrayBufferFieldValue.get()).toBe(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 struct = new StructValue();
|
||||||
|
|
||||||
const lengthField = 'foo';
|
const lengthField = "foo";
|
||||||
const originalLengthFieldValue = new MockOriginalFieldValue();
|
const originalLengthFieldValue = new MockOriginalFieldValue();
|
||||||
struct.set(lengthField, originalLengthFieldValue);
|
struct.set(lengthField, originalLengthFieldValue);
|
||||||
|
|
||||||
|
@ -468,27 +468,27 @@ describe('Types', () => {
|
||||||
|
|
||||||
const newValue = new ArrayBuffer(100);
|
const newValue = new ArrayBuffer(100);
|
||||||
arrayBufferFieldValue.set(newValue);
|
arrayBufferFieldValue.set(newValue);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('length', undefined);
|
expect(arrayBufferFieldValue).toHaveProperty("length", undefined);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('VariableLengthArrayBufferLikeFieldDefinition', () => {
|
describe("VariableLengthArrayBufferLikeFieldDefinition", () => {
|
||||||
describe('#getSize', () => {
|
describe("#getSize", () => {
|
||||||
it('should always return `0`', () => {
|
it("should always return `0`", () => {
|
||||||
const definition = new VariableLengthBufferLikeFieldDefinition(
|
const definition = new VariableLengthBufferLikeFieldDefinition(
|
||||||
Uint8ArrayBufferFieldSubType.Instance,
|
Uint8ArrayBufferFieldSubType.Instance,
|
||||||
{ lengthField: 'foo' },
|
{ lengthField: "foo" },
|
||||||
);
|
);
|
||||||
expect(definition.getSize()).toBe(0);
|
expect(definition.getSize()).toBe(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#getDeserializeSize', () => {
|
describe("#getDeserializeSize", () => {
|
||||||
it('should return value of its `lengthField`', async () => {
|
it("should return value of its `lengthField`", async () => {
|
||||||
const struct = new StructValue();
|
const struct = new StructValue();
|
||||||
|
|
||||||
const lengthField = 'foo';
|
const lengthField = "foo";
|
||||||
const originalLengthFieldValue = new MockOriginalFieldValue();
|
const originalLengthFieldValue = new MockOriginalFieldValue();
|
||||||
struct.set(lengthField, originalLengthFieldValue);
|
struct.set(lengthField, originalLengthFieldValue);
|
||||||
|
|
||||||
|
@ -498,19 +498,19 @@ describe('Types', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
originalLengthFieldValue.value = 0;
|
originalLengthFieldValue.value = 0;
|
||||||
expect(definition['getDeserializeSize'](struct)).toBe(0);
|
expect(definition["getDeserializeSize"](struct)).toBe(0);
|
||||||
expect(originalLengthFieldValue.get).toBeCalledTimes(1);
|
expect(originalLengthFieldValue.get).toBeCalledTimes(1);
|
||||||
|
|
||||||
originalLengthFieldValue.get.mockClear();
|
originalLengthFieldValue.get.mockClear();
|
||||||
originalLengthFieldValue.value = 100;
|
originalLengthFieldValue.value = 100;
|
||||||
expect(definition['getDeserializeSize'](struct)).toBe(100);
|
expect(definition["getDeserializeSize"](struct)).toBe(100);
|
||||||
expect(originalLengthFieldValue.get).toBeCalledTimes(1);
|
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 struct = new StructValue();
|
||||||
|
|
||||||
const lengthField = 'foo';
|
const lengthField = "foo";
|
||||||
const originalLengthFieldValue = new MockOriginalFieldValue();
|
const originalLengthFieldValue = new MockOriginalFieldValue();
|
||||||
struct.set(lengthField, originalLengthFieldValue);
|
struct.set(lengthField, originalLengthFieldValue);
|
||||||
|
|
||||||
|
@ -519,20 +519,20 @@ describe('Types', () => {
|
||||||
{ lengthField },
|
{ lengthField },
|
||||||
);
|
);
|
||||||
|
|
||||||
originalLengthFieldValue.value = '0';
|
originalLengthFieldValue.value = "0";
|
||||||
expect(definition['getDeserializeSize'](struct)).toBe(0);
|
expect(definition["getDeserializeSize"](struct)).toBe(0);
|
||||||
expect(originalLengthFieldValue.get).toBeCalledTimes(1);
|
expect(originalLengthFieldValue.get).toBeCalledTimes(1);
|
||||||
|
|
||||||
originalLengthFieldValue.get.mockClear();
|
originalLengthFieldValue.get.mockClear();
|
||||||
originalLengthFieldValue.value = '100';
|
originalLengthFieldValue.value = "100";
|
||||||
expect(definition['getDeserializeSize'](struct)).toBe(100);
|
expect(definition["getDeserializeSize"](struct)).toBe(100);
|
||||||
expect(originalLengthFieldValue.get).toBeCalledTimes(1);
|
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 struct = new StructValue();
|
||||||
|
|
||||||
const lengthField = 'foo';
|
const lengthField = "foo";
|
||||||
const originalLengthFieldValue = new MockOriginalFieldValue();
|
const originalLengthFieldValue = new MockOriginalFieldValue();
|
||||||
struct.set(lengthField, originalLengthFieldValue);
|
struct.set(lengthField, originalLengthFieldValue);
|
||||||
|
|
||||||
|
@ -542,22 +542,22 @@ describe('Types', () => {
|
||||||
{ lengthField, lengthFieldBase: base },
|
{ lengthField, lengthFieldBase: base },
|
||||||
);
|
);
|
||||||
|
|
||||||
originalLengthFieldValue.value = '0';
|
originalLengthFieldValue.value = "0";
|
||||||
expect(definition['getDeserializeSize'](struct)).toBe(0);
|
expect(definition["getDeserializeSize"](struct)).toBe(0);
|
||||||
expect(originalLengthFieldValue.get).toBeCalledTimes(1);
|
expect(originalLengthFieldValue.get).toBeCalledTimes(1);
|
||||||
|
|
||||||
originalLengthFieldValue.get.mockClear();
|
originalLengthFieldValue.get.mockClear();
|
||||||
originalLengthFieldValue.value = '100';
|
originalLengthFieldValue.value = "100";
|
||||||
expect(definition['getDeserializeSize'](struct)).toBe(Number.parseInt('100', base));
|
expect(definition["getDeserializeSize"](struct)).toBe(Number.parseInt("100", base));
|
||||||
expect(originalLengthFieldValue.get).toBeCalledTimes(1);
|
expect(originalLengthFieldValue.get).toBeCalledTimes(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#create', () => {
|
describe("#create", () => {
|
||||||
it('should create a `VariableLengthArrayBufferLikeFieldValue`', () => {
|
it("should create a `VariableLengthArrayBufferLikeFieldValue`", () => {
|
||||||
const struct = new StructValue();
|
const struct = new StructValue();
|
||||||
|
|
||||||
const lengthField = 'foo';
|
const lengthField = "foo";
|
||||||
const originalLengthFieldValue = new MockOriginalFieldValue();
|
const originalLengthFieldValue = new MockOriginalFieldValue();
|
||||||
struct.set(lengthField, originalLengthFieldValue);
|
struct.set(lengthField, originalLengthFieldValue);
|
||||||
|
|
||||||
|
@ -573,18 +573,18 @@ describe('Types', () => {
|
||||||
value,
|
value,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('definition', definition);
|
expect(arrayBufferFieldValue).toHaveProperty("definition", definition);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('options', StructDefaultOptions);
|
expect(arrayBufferFieldValue).toHaveProperty("options", StructDefaultOptions);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('struct', struct);
|
expect(arrayBufferFieldValue).toHaveProperty("struct", struct);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('value', value);
|
expect(arrayBufferFieldValue).toHaveProperty("value", value);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('arrayBuffer', undefined);
|
expect(arrayBufferFieldValue).toHaveProperty("arrayBuffer", undefined);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('length', 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 struct = new StructValue();
|
||||||
|
|
||||||
const lengthField = 'foo';
|
const lengthField = "foo";
|
||||||
const originalLengthFieldValue = new MockOriginalFieldValue();
|
const originalLengthFieldValue = new MockOriginalFieldValue();
|
||||||
struct.set(lengthField, originalLengthFieldValue);
|
struct.set(lengthField, originalLengthFieldValue);
|
||||||
|
|
||||||
|
@ -601,12 +601,12 @@ describe('Types', () => {
|
||||||
value,
|
value,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('definition', definition);
|
expect(arrayBufferFieldValue).toHaveProperty("definition", definition);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('options', StructDefaultOptions);
|
expect(arrayBufferFieldValue).toHaveProperty("options", StructDefaultOptions);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('struct', struct);
|
expect(arrayBufferFieldValue).toHaveProperty("struct", struct);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('value', value);
|
expect(arrayBufferFieldValue).toHaveProperty("value", value);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('arrayBuffer', value);
|
expect(arrayBufferFieldValue).toHaveProperty("arrayBuffer", value);
|
||||||
expect(arrayBufferFieldValue).toHaveProperty('length', 100);
|
expect(arrayBufferFieldValue).toHaveProperty("length", 100);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { StructFieldValue, type StructFieldDefinition, type StructOptions, type StructValue } from '../../basic';
|
import { StructFieldValue, type StructFieldDefinition, type StructOptions, type StructValue } from '../../basic/index.js';
|
||||||
import type { KeysOfType } from '../../utils';
|
import type { KeysOfType } from '../../utils.js';
|
||||||
import { BufferLikeFieldDefinition, BufferLikeFieldValue, type BufferFieldSubType } from './base';
|
import { BufferLikeFieldDefinition, BufferLikeFieldValue, type BufferFieldSubType } from './base.js';
|
||||||
|
|
||||||
export type LengthField<TFields> = KeysOfType<TFields, number | string>;
|
export type LengthField<TFields> = KeysOfType<TFields, number | string>;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
export * from './bigint';
|
export * from "./bigint.js";
|
||||||
export * from './buffer';
|
export * from "./buffer/index.js";
|
||||||
export * from './number';
|
export * from "./number.js";
|
||||||
|
|
|
@ -1,83 +1,67 @@
|
||||||
import { StructDefaultOptions, StructDeserializeStream, StructValue } from '../basic';
|
import { StructDefaultOptions, StructDeserializeStream, StructValue } from "../basic/index.js";
|
||||||
import { NumberFieldDefinition, NumberFieldType } from './number';
|
import { NumberFieldDefinition, NumberFieldType } from "./number.js";
|
||||||
|
|
||||||
describe('Types', () => {
|
describe("Types", () => {
|
||||||
describe('Number', () => {
|
describe("Number", () => {
|
||||||
describe('NumberFieldType', () => {
|
describe("NumberFieldType", () => {
|
||||||
it('Int8 validation', () => {
|
it("Int8 validation", () => {
|
||||||
const key = 'Int8';
|
const key = "Int8";
|
||||||
expect(NumberFieldType[key]).toHaveProperty('size', 1);
|
expect(NumberFieldType[key]).toHaveProperty("size", 1);
|
||||||
expect(NumberFieldType[key]).toHaveProperty('dataViewGetter', 'get' + key);
|
expect(NumberFieldType[key]).toHaveProperty("dataViewGetter", "get" + key);
|
||||||
expect(NumberFieldType[key]).toHaveProperty('dataViewSetter', 'set' + key);
|
expect(NumberFieldType[key]).toHaveProperty("dataViewSetter", "set" + key);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Uint8 validation', () => {
|
it("Uint8 validation", () => {
|
||||||
const key = 'Uint8';
|
const key = "Uint8";
|
||||||
expect(NumberFieldType[key]).toHaveProperty('size', 1);
|
expect(NumberFieldType[key]).toHaveProperty("size", 1);
|
||||||
expect(NumberFieldType[key]).toHaveProperty('dataViewGetter', 'get' + key);
|
expect(NumberFieldType[key]).toHaveProperty("dataViewGetter", "get" + key);
|
||||||
expect(NumberFieldType[key]).toHaveProperty('dataViewSetter', 'set' + key);
|
expect(NumberFieldType[key]).toHaveProperty("dataViewSetter", "set" + key);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Int16 validation', () => {
|
it("Int16 validation", () => {
|
||||||
const key = 'Int16';
|
const key = "Int16";
|
||||||
expect(NumberFieldType[key]).toHaveProperty('size', 2);
|
expect(NumberFieldType[key]).toHaveProperty("size", 2);
|
||||||
expect(NumberFieldType[key]).toHaveProperty('dataViewGetter', 'get' + key);
|
expect(NumberFieldType[key]).toHaveProperty("dataViewGetter", "get" + key);
|
||||||
expect(NumberFieldType[key]).toHaveProperty('dataViewSetter', 'set' + key);
|
expect(NumberFieldType[key]).toHaveProperty("dataViewSetter", "set" + key);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Uint16 validation', () => {
|
it("Uint16 validation", () => {
|
||||||
const key = 'Uint16';
|
const key = "Uint16";
|
||||||
expect(NumberFieldType[key]).toHaveProperty('size', 2);
|
expect(NumberFieldType[key]).toHaveProperty("size", 2);
|
||||||
expect(NumberFieldType[key]).toHaveProperty('dataViewGetter', 'get' + key);
|
expect(NumberFieldType[key]).toHaveProperty("dataViewGetter", "get" + key);
|
||||||
expect(NumberFieldType[key]).toHaveProperty('dataViewSetter', 'set' + key);
|
expect(NumberFieldType[key]).toHaveProperty("dataViewSetter", "set" + key);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Int32 validation', () => {
|
it("Int32 validation", () => {
|
||||||
const key = 'Int32';
|
const key = "Int32";
|
||||||
expect(NumberFieldType[key]).toHaveProperty('size', 4);
|
expect(NumberFieldType[key]).toHaveProperty("size", 4);
|
||||||
expect(NumberFieldType[key]).toHaveProperty('dataViewGetter', 'get' + key);
|
expect(NumberFieldType[key]).toHaveProperty("dataViewGetter", "get" + key);
|
||||||
expect(NumberFieldType[key]).toHaveProperty('dataViewSetter', 'set' + key);
|
expect(NumberFieldType[key]).toHaveProperty("dataViewSetter", "set" + key);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Uint32 validation', () => {
|
it("Uint32 validation", () => {
|
||||||
const key = 'Uint32';
|
const key = "Uint32";
|
||||||
expect(NumberFieldType[key]).toHaveProperty('size', 4);
|
expect(NumberFieldType[key]).toHaveProperty("size", 4);
|
||||||
expect(NumberFieldType[key]).toHaveProperty('dataViewGetter', 'get' + key);
|
expect(NumberFieldType[key]).toHaveProperty("dataViewGetter", "get" + key);
|
||||||
expect(NumberFieldType[key]).toHaveProperty('dataViewSetter', 'set' + 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);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('NumberFieldDefinition', () => {
|
describe("NumberFieldDefinition", () => {
|
||||||
describe('#getSize', () => {
|
describe("#getSize", () => {
|
||||||
it('should return size of its type', () => {
|
it("should return size of its type", () => {
|
||||||
expect(new NumberFieldDefinition(NumberFieldType.Int8).getSize()).toBe(1);
|
expect(new NumberFieldDefinition(NumberFieldType.Int8).getSize()).toBe(1);
|
||||||
expect(new NumberFieldDefinition(NumberFieldType.Uint8).getSize()).toBe(1);
|
expect(new NumberFieldDefinition(NumberFieldType.Uint8).getSize()).toBe(1);
|
||||||
expect(new NumberFieldDefinition(NumberFieldType.Int16).getSize()).toBe(2);
|
expect(new NumberFieldDefinition(NumberFieldType.Int16).getSize()).toBe(2);
|
||||||
expect(new NumberFieldDefinition(NumberFieldType.Uint16).getSize()).toBe(2);
|
expect(new NumberFieldDefinition(NumberFieldType.Uint16).getSize()).toBe(2);
|
||||||
expect(new NumberFieldDefinition(NumberFieldType.Int32).getSize()).toBe(4);
|
expect(new NumberFieldDefinition(NumberFieldType.Int32).getSize()).toBe(4);
|
||||||
expect(new NumberFieldDefinition(NumberFieldType.Uint32).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', () => {
|
describe("#deserialize", () => {
|
||||||
it('should deserialize Uint8', async () => {
|
it("should deserialize Uint8", async () => {
|
||||||
const read = jest.fn((length: number) => new Uint8Array([1, 2, 3, 4]).buffer);
|
const read = jest.fn((length: number) => new Uint8Array([1, 2, 3, 4]));
|
||||||
const stream: StructDeserializeStream = { read };
|
const stream: StructDeserializeStream = { read };
|
||||||
|
|
||||||
const definition = new NumberFieldDefinition(NumberFieldType.Uint8);
|
const definition = new NumberFieldDefinition(NumberFieldType.Uint8);
|
||||||
|
@ -93,8 +77,8 @@ describe('Types', () => {
|
||||||
expect(read).lastCalledWith(NumberFieldType.Uint8.size);
|
expect(read).lastCalledWith(NumberFieldType.Uint8.size);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should deserialize Uint16', async () => {
|
it("should deserialize Uint16", async () => {
|
||||||
const read = jest.fn((length: number) => new Uint8Array([1, 2, 3, 4]).buffer);
|
const read = jest.fn((length: number) => new Uint8Array([1, 2, 3, 4]));
|
||||||
const stream: StructDeserializeStream = { read };
|
const stream: StructDeserializeStream = { read };
|
||||||
|
|
||||||
const definition = new NumberFieldDefinition(NumberFieldType.Uint16);
|
const definition = new NumberFieldDefinition(NumberFieldType.Uint16);
|
||||||
|
@ -110,8 +94,8 @@ describe('Types', () => {
|
||||||
expect(read).lastCalledWith(NumberFieldType.Uint16.size);
|
expect(read).lastCalledWith(NumberFieldType.Uint16.size);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should deserialize Uint16LE', async () => {
|
it("should deserialize Uint16LE", async () => {
|
||||||
const read = jest.fn((length: number) => new Uint8Array([1, 2, 3, 4]).buffer);
|
const read = jest.fn((length: number) => new Uint8Array([1, 2, 3, 4]));
|
||||||
const stream: StructDeserializeStream = { read };
|
const stream: StructDeserializeStream = { read };
|
||||||
|
|
||||||
const definition = new NumberFieldDefinition(NumberFieldType.Uint16);
|
const definition = new NumberFieldDefinition(NumberFieldType.Uint16);
|
||||||
|
@ -129,9 +113,9 @@ describe('Types', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('NumberFieldValue', () => {
|
describe("NumberFieldValue", () => {
|
||||||
describe('#getSize', () => {
|
describe("#getSize", () => {
|
||||||
it('should return size of its definition', () => {
|
it("should return size of its definition", () => {
|
||||||
const struct = new StructValue();
|
const struct = new StructValue();
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
|
@ -193,31 +177,11 @@ describe('Types', () => {
|
||||||
)
|
)
|
||||||
.getSize()
|
.getSize()
|
||||||
).toBe(4);
|
).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', () => {
|
describe("#serialize", () => {
|
||||||
it('should serialize uint8', () => {
|
it("should serialize uint8", () => {
|
||||||
const definition = new NumberFieldDefinition(NumberFieldType.Int8);
|
const definition = new NumberFieldDefinition(NumberFieldType.Int8);
|
||||||
const struct = new StructValue();
|
const struct = new StructValue();
|
||||||
const value = definition.create(
|
const value = definition.create(
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// cspell: ignore syncbird
|
// cspell: ignore syncbird
|
||||||
|
|
||||||
import { StructFieldDefinition, StructFieldValue, StructValue, type StructAsyncDeserializeStream, type StructDeserializeStream, type StructOptions } from '../basic';
|
import { StructFieldDefinition, StructFieldValue, StructValue, type StructAsyncDeserializeStream, type StructDeserializeStream, type StructOptions } from '../basic/index.js';
|
||||||
import { Syncbird } from "../syncbird";
|
import { Syncbird } from "../syncbird.js";
|
||||||
import type { ValueOrPromise } from "../utils";
|
import type { ValueOrPromise } from "../utils.js";
|
||||||
|
|
||||||
export type DataViewGetters =
|
export type DataViewGetters =
|
||||||
{ [TKey in keyof DataView]: TKey extends `get${string}` ? TKey : never }[keyof DataView];
|
{ [TKey in keyof DataView]: TKey extends `get${string}` ? TKey : never }[keyof DataView];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { placeholder } from './utils';
|
import { placeholder } from './utils.js';
|
||||||
|
|
||||||
describe('placeholder', () => {
|
describe('placeholder', () => {
|
||||||
it('should return `undefined`', () => {
|
it('should return `undefined`', () => {
|
||||||
|
|
|
@ -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 |
|
| Module | Output Directory | Excluded Files | Excluded Types |
|
||||||
| ------------------ | ---------------- | -------------- | -------------- |
|
| ------------------ | ---------------- | -------------- | -------------- |
|
||||||
| CommonJS | `cjs` | - | - |
|
|
||||||
| ESModule | `esm` | `*.spec.ts` | `@types/jest` |
|
| ESModule | `esm` | `*.spec.ts` | `@types/jest` |
|
||||||
| Declaration (d.ts) | `dts` | `*.spec.ts` | `@types/jest` |
|
| Declaration (d.ts) | `dts` | `*.spec.ts` | `@types/jest` |
|
||||||
|
|
||||||
|
@ -91,8 +90,7 @@ Example `package.json`:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"main": "cjs/index.js",
|
"main": "esm/index.js",
|
||||||
"module": "esm/index.js",
|
|
||||||
"types": "dts/index.d.ts",
|
"types": "dts/index.d.ts",
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"composite": true,
|
"composite": true,
|
||||||
/* Basic Options */
|
/* Basic Options */
|
||||||
"target": "ESNext", // /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
"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. */
|
"lib": [ // /* Specify library files to be included in the compilation. */
|
||||||
"ESNext"
|
"ESNext"
|
||||||
],
|
],
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
"noUncheckedIndexedAccess": true,
|
"noUncheckedIndexedAccess": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
/* Module Resolution Options */
|
/* 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. */
|
// "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'. */
|
// "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. */
|
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue