mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-06 03:50:18 +02:00
refactor(scrcpy): small optimizations
This commit is contained in:
parent
6b23154694
commit
b5f58227fd
11 changed files with 359 additions and 71 deletions
|
@ -55,15 +55,32 @@ export function placeholder<T>(): T {
|
|||
|
||||
// This library can't use `@types/node` or `lib: dom`
|
||||
// because they will pollute the global scope
|
||||
// So `TextEncoder` and `TextDecoder` are not available
|
||||
// So `TextEncoder` and `TextDecoder` types are not available
|
||||
|
||||
// Node.js 8.3 ships `TextEncoder` and `TextDecoder` in `util` module.
|
||||
// But using top level await to load them requires Node.js 14.1.
|
||||
// So there is no point to do that. Let's just assume they exist in global.
|
||||
|
||||
// @ts-expect-error See reason above
|
||||
declare class TextEncoderType {
|
||||
constructor();
|
||||
|
||||
encode(input: string): Uint8Array;
|
||||
}
|
||||
|
||||
declare class TextDecoderType {
|
||||
constructor();
|
||||
|
||||
decode(buffer: ArrayBufferView | ArrayBuffer): string;
|
||||
}
|
||||
|
||||
interface GlobalExtension {
|
||||
TextEncoder: typeof TextEncoderType;
|
||||
TextDecoder: typeof TextDecoderType;
|
||||
}
|
||||
|
||||
const { TextEncoder, TextDecoder } = globalThis as unknown as GlobalExtension;
|
||||
|
||||
const Utf8Encoder = new TextEncoder();
|
||||
// @ts-expect-error See reason above
|
||||
const Utf8Decoder = new TextDecoder();
|
||||
|
||||
export function encodeUtf8(input: string): Uint8Array {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue