diff options
author | Leo Kettmeir <crowlkats@toaxl.com> | 2023-05-01 12:47:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-01 10:47:13 +0000 |
commit | b31cf9fde6ad5398c20370c136695db77df6beeb (patch) | |
tree | 23ef5cd5d6e9342abefdc37332cc12d9bce3f245 /ext/webidl/internal.d.ts | |
parent | d856bfd336137e1bcf81a0db9e8ad2b418ba711e (diff) |
refactor(webidl): move prefix & context out of converters options bag (#18931)
Diffstat (limited to 'ext/webidl/internal.d.ts')
-rw-r--r-- | ext/webidl/internal.d.ts | 363 |
1 files changed, 294 insertions, 69 deletions
diff --git a/ext/webidl/internal.d.ts b/ext/webidl/internal.d.ts index 095e5ab91..cc4422a27 100644 --- a/ext/webidl/internal.d.ts +++ b/ext/webidl/internal.d.ts @@ -5,29 +5,13 @@ /// <reference lib="esnext" /> declare module "ext:deno_webidl/00_webidl.js" { - interface ValueConverterOpts { - /** - * The prefix for error messages created by this converter. - * Examples: - * - `Failed to construct 'Event'` - * - `Failed to execute 'removeEventListener' on 'EventTarget'` - */ - prefix: string; - /** - * The context of this value error messages created by this converter. - * Examples: - * - `Argument 1` - * - `Argument 3` - */ - context: string; - } function makeException( ErrorType: any, message: string, - prefix: string, - context: string, + prefix?: string, + context?: string, ): any; - interface IntConverterOpts extends ValueConverterOpts { + interface IntConverterOpts { /** * Wether to throw if the number is outside of the acceptable values for * this type. @@ -38,13 +22,13 @@ declare module "ext:deno_webidl/00_webidl.js" { */ clamp?: boolean; } - interface StringConverterOpts extends ValueConverterOpts { + interface StringConverterOpts { /** * Wether to treat `null` value as an empty string. */ treatNullAsEmptyString?: boolean; } - interface BufferConverterOpts extends ValueConverterOpts { + interface BufferConverterOpts { /** * Wether to allow `SharedArrayBuffer` (not just `ArrayBuffer`). */ @@ -55,148 +39,322 @@ declare module "ext:deno_webidl/00_webidl.js" { /** * Convert a value into a `boolean` (bool). */ - boolean(v: any, opts?: IntConverterOpts): boolean; + boolean( + v: any, + prefix?: string, + context?: string, + opts?: IntConverterOpts, + ): boolean; /** * Convert a value into a `byte` (int8). */ - byte(v: any, opts?: IntConverterOpts): number; + byte( + v: any, + prefix?: string, + context?: string, + opts?: IntConverterOpts, + ): number; /** * Convert a value into a `octet` (uint8). */ - octet(v: any, opts?: IntConverterOpts): number; + octet( + v: any, + prefix?: string, + context?: string, + opts?: IntConverterOpts, + ): number; /** * Convert a value into a `short` (int16). */ - short(v: any, opts?: IntConverterOpts): number; + short( + v: any, + prefix?: string, + context?: string, + opts?: IntConverterOpts, + ): number; /** * Convert a value into a `unsigned short` (uint16). */ - ["unsigned short"](v: any, opts?: IntConverterOpts): number; + ["unsigned short"]( + v: any, + prefix?: string, + context?: string, + opts?: IntConverterOpts, + ): number; /** * Convert a value into a `long` (int32). */ - long(v: any, opts?: IntConverterOpts): number; + long( + v: any, + prefix?: string, + context?: string, + opts?: IntConverterOpts, + ): number; /** * Convert a value into a `unsigned long` (uint32). */ - ["unsigned long"](v: any, opts?: IntConverterOpts): number; + ["unsigned long"]( + v: any, + prefix?: string, + context?: string, + opts?: IntConverterOpts, + ): number; /** * Convert a value into a `long long` (int64). * **Note this is truncated to a JS number (53 bit precision).** */ - ["long long"](v: any, opts?: IntConverterOpts): number; + ["long long"]( + v: any, + prefix?: string, + context?: string, + opts?: IntConverterOpts, + ): number; /** * Convert a value into a `unsigned long long` (uint64). * **Note this is truncated to a JS number (53 bit precision).** */ - ["unsigned long long"](v: any, opts?: IntConverterOpts): number; + ["unsigned long long"]( + v: any, + prefix?: string, + context?: string, + opts?: IntConverterOpts, + ): number; /** * Convert a value into a `float` (f32). */ - float(v: any, opts?: ValueConverterOpts): number; + float( + v: any, + prefix?: string, + context?: string, + opts?: any, + ): number; /** * Convert a value into a `unrestricted float` (f32, infinity, or NaN). */ - ["unrestricted float"](v: any, opts?: ValueConverterOpts): number; + ["unrestricted float"]( + v: any, + prefix?: string, + context?: string, + opts?: any, + ): number; /** * Convert a value into a `double` (f64). */ - double(v: any, opts?: ValueConverterOpts): number; + double( + v: any, + prefix?: string, + context?: string, + opts?: any, + ): number; /** * Convert a value into a `unrestricted double` (f64, infinity, or NaN). */ - ["unrestricted double"](v: any, opts?: ValueConverterOpts): number; + ["unrestricted double"]( + v: any, + prefix?: string, + context?: string, + opts?: any, + ): number; /** * Convert a value into a `DOMString` (string). */ - DOMString(v: any, opts?: StringConverterOpts): string; + DOMString( + v: any, + prefix?: string, + context?: string, + opts?: StringConverterOpts, + ): string; /** * Convert a value into a `ByteString` (string with only u8 codepoints). */ - ByteString(v: any, opts?: StringConverterOpts): string; + ByteString( + v: any, + prefix?: string, + context?: string, + opts?: StringConverterOpts, + ): string; /** * Convert a value into a `USVString` (string with only valid non * surrogate Unicode code points). */ - USVString(v: any, opts?: StringConverterOpts): string; + USVString( + v: any, + prefix?: string, + context?: string, + opts?: StringConverterOpts, + ): string; /** * Convert a value into an `object` (object). */ - object(v: any, opts?: ValueConverterOpts): object; + object( + v: any, + prefix?: string, + context?: string, + opts?: any, + ): object; /** * Convert a value into an `ArrayBuffer` (ArrayBuffer). */ - ArrayBuffer(v: any, opts?: BufferConverterOpts): ArrayBuffer; + ArrayBuffer( + v: any, + prefix?: string, + context?: string, + opts?: BufferConverterOpts, + ): ArrayBuffer; /** * Convert a value into a `DataView` (ArrayBuffer). */ - DataView(v: any, opts?: BufferConverterOpts): DataView; + DataView( + v: any, + prefix?: string, + context?: string, + opts?: BufferConverterOpts, + ): DataView; /** * Convert a value into a `Int8Array` (Int8Array). */ - Int8Array(v: any, opts?: BufferConverterOpts): Int8Array; + Int8Array( + v: any, + prefix?: string, + context?: string, + opts?: BufferConverterOpts, + ): Int8Array; /** * Convert a value into a `Int16Array` (Int16Array). */ - Int16Array(v: any, opts?: BufferConverterOpts): Int16Array; + Int16Array( + v: any, + prefix?: string, + context?: string, + opts?: BufferConverterOpts, + ): Int16Array; /** * Convert a value into a `Int32Array` (Int32Array). */ - Int32Array(v: any, opts?: BufferConverterOpts): Int32Array; + Int32Array( + v: any, + prefix?: string, + context?: string, + opts?: BufferConverterOpts, + ): Int32Array; /** * Convert a value into a `Uint8Array` (Uint8Array). */ - Uint8Array(v: any, opts?: BufferConverterOpts): Uint8Array; + Uint8Array( + v: any, + prefix?: string, + context?: string, + opts?: BufferConverterOpts, + ): Uint8Array; /** * Convert a value into a `Uint16Array` (Uint16Array). */ - Uint16Array(v: any, opts?: BufferConverterOpts): Uint16Array; + Uint16Array( + v: any, + prefix?: string, + context?: string, + opts?: BufferConverterOpts, + ): Uint16Array; /** * Convert a value into a `Uint32Array` (Uint32Array). */ - Uint32Array(v: any, opts?: BufferConverterOpts): Uint32Array; + Uint32Array( + v: any, + prefix?: string, + context?: string, + opts?: BufferConverterOpts, + ): Uint32Array; /** * Convert a value into a `Uint8ClampedArray` (Uint8ClampedArray). */ Uint8ClampedArray( v: any, + prefix?: string, + context?: string, opts?: BufferConverterOpts, ): Uint8ClampedArray; /** * Convert a value into a `Float32Array` (Float32Array). */ - Float32Array(v: any, opts?: BufferConverterOpts): Float32Array; + Float32Array( + v: any, + prefix?: string, + context?: string, + opts?: BufferConverterOpts, + ): Float32Array; /** * Convert a value into a `Float64Array` (Float64Array). */ - Float64Array(v: any, opts?: BufferConverterOpts): Float64Array; + Float64Array( + v: any, + prefix?: string, + context?: string, + opts?: BufferConverterOpts, + ): Float64Array; /** * Convert a value into an `ArrayBufferView` (ArrayBufferView). */ - ArrayBufferView(v: any, opts?: BufferConverterOpts): ArrayBufferView; + ArrayBufferView( + v: any, + prefix?: string, + context?: string, + opts?: BufferConverterOpts, + ): ArrayBufferView; /** * Convert a value into a `BufferSource` (ArrayBuffer or ArrayBufferView). */ BufferSource( v: any, + prefix?: string, + context?: string, opts?: BufferConverterOpts, ): ArrayBuffer | ArrayBufferView; /** * Convert a value into a `DOMTimeStamp` (u64). Alias for unsigned long long */ - DOMTimeStamp(v: any, opts?: IntConverterOpts): number; + DOMTimeStamp( + v: any, + prefix?: string, + context?: string, + opts?: IntConverterOpts, + ): number; /** * Convert a value into a `Function` ((...args: any[]) => any). */ - Function(v: any, opts?: ValueConverterOpts): (...args: any) => any; + Function( + v: any, + prefix?: string, + context?: string, + opts?: any, + ): (...args: any) => any; /** * Convert a value into a `VoidFunction` (() => void). */ - VoidFunction(v: any, opts?: ValueConverterOpts): () => void; - ["UVString?"](v: any, opts?: ValueConverterOpts): string | null; - ["sequence<double>"](v: any, opts?: ValueConverterOpts): number[]; + VoidFunction( + v: any, + prefix?: string, + context?: string, + opts?: any, + ): () => void; + ["UVString?"]( + v: any, + prefix?: string, + context?: string, + opts?: StringConverterOpts, + ): string | null; + ["sequence<double>"]( + v: any, + prefix?: string, + context?: string, + opts?: any, + ): number[]; - [type: string]: (v: any, opts: ValueConverterOpts) => any; + [type: string]: ( + v: any, + prefix?: string, + context?: string, + opts?: any, + ) => any; }; /** @@ -210,7 +368,12 @@ declare module "ext:deno_webidl/00_webidl.js" { type Dictionary = DictionaryMember[]; interface DictionaryMember { key: string; - converter: (v: any, opts: ValueConverterOpts) => any; + converter: ( + v: any, + prefix?: string, + context?: string, + opts?: any, + ) => any; defaultValue?: any; required?: boolean; } @@ -221,7 +384,12 @@ declare module "ext:deno_webidl/00_webidl.js" { function createDictionaryConverter<T>( name: string, ...dictionaries: Dictionary[] - ): (v: any, opts: ValueConverterOpts) => T; + ): ( + v: any, + prefix?: string, + context?: string, + opts?: any, + ) => T; /** * Create a converter for enums. @@ -229,28 +397,63 @@ declare module "ext:deno_webidl/00_webidl.js" { function createEnumConverter( name: string, values: string[], - ): (v: any, opts: ValueConverterOpts) => string; + ): ( + v: any, + prefix?: string, + context?: string, + opts?: any, + ) => string; /** * Create a converter that makes the contained type nullable. */ function createNullableConverter<T>( - converter: (v: any, opts: ValueConverterOpts) => T, - ): (v: any, opts: ValueConverterOpts) => T | null; + converter: ( + v: any, + prefix?: string, + context?: string, + opts?: any, + ) => T, + ): ( + v: any, + prefix?: string, + context?: string, + opts?: any, + ) => T | null; /** * Create a converter that converts a sequence of the inner type. */ function createSequenceConverter<T>( - converter: (v: any, opts: ValueConverterOpts) => T, - ): (v: any, opts: ValueConverterOpts) => T[]; + converter: ( + v: any, + prefix?: string, + context?: string, + opts?: any, + ) => T, + ): ( + v: any, + prefix?: string, + context?: string, + opts?: any, + ) => T[]; /** * Create a converter that converts a Promise of the inner type. */ function createPromiseConverter<T>( - converter: (v: any, opts: ValueConverterOpts) => T, - ): (v: any, opts: ValueConverterOpts) => Promise<T>; + converter: ( + v: any, + prefix?: string, + context?: string, + opts?: any, + ) => T, + ): ( + v: any, + prefix?: string, + context?: string, + opts?: any, + ) => Promise<T>; /** * Invoke a callback function. @@ -259,7 +462,12 @@ declare module "ext:deno_webidl/00_webidl.js" { callable: (...args: any) => any, args: any[], thisArg: any, - returnValueConverter: (v: any, opts: ValueConverterOpts) => T, + returnValueConverter: ( + v: any, + prefix?: string, + context?: string, + opts?: any, + ) => T, prefix: string, returnsPromise?: boolean, ): T; @@ -290,17 +498,34 @@ declare module "ext:deno_webidl/00_webidl.js" { function createInterfaceConverter( name: string, prototype: any, - ): (v: any, opts: ValueConverterOpts) => any; + ): ( + v: any, + prefix?: string, + context?: string, + opts?: any, + ) => any; function createRecordConverter< K extends string | number | symbol, V, >( - keyConverter: (v: any, opts: ValueConverterOpts) => K, - valueConverter: (v: any, opts: ValueConverterOpts) => V, + keyConverter: ( + v: any, + prefix?: string, + context?: string, + opts?: any, + ) => K, + valueConverter: ( + v: any, + prefix?: string, + context?: string, + opts?: any, + ) => V, ): ( v: Record<K, V>, - opts: ValueConverterOpts, + prefix?: string, + context?: string, + opts?: any, ) => any; /** |