summaryrefslogtreecommitdiff
path: root/ext/webidl
diff options
context:
space:
mode:
authorLeo Kettmeir <crowlkats@toaxl.com>2023-05-01 12:47:13 +0200
committerGitHub <noreply@github.com>2023-05-01 10:47:13 +0000
commitb31cf9fde6ad5398c20370c136695db77df6beeb (patch)
tree23ef5cd5d6e9342abefdc37332cc12d9bce3f245 /ext/webidl
parentd856bfd336137e1bcf81a0db9e8ad2b418ba711e (diff)
refactor(webidl): move prefix & context out of converters options bag (#18931)
Diffstat (limited to 'ext/webidl')
-rw-r--r--ext/webidl/00_webidl.js234
-rw-r--r--ext/webidl/internal.d.ts363
2 files changed, 427 insertions, 170 deletions
diff --git a/ext/webidl/00_webidl.js b/ext/webidl/00_webidl.js
index 778874104..71b7982b7 100644
--- a/ext/webidl/00_webidl.js
+++ b/ext/webidl/00_webidl.js
@@ -191,7 +191,7 @@ function createIntegerConversion(bitLength, typeOpts) {
const twoToTheBitLength = MathPow(2, bitLength);
const twoToOneLessThanTheBitLength = MathPow(2, bitLength - 1);
- return (V, opts = {}) => {
+ return (V, prefix = undefined, context = undefined, opts = {}) => {
let x = toNumber(V);
x = censorNegativeZero(x);
@@ -200,8 +200,8 @@ function createIntegerConversion(bitLength, typeOpts) {
throw makeException(
TypeError,
"is not a finite number",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
@@ -211,8 +211,8 @@ function createIntegerConversion(bitLength, typeOpts) {
throw makeException(
TypeError,
`is outside the accepted range of ${lowerBound} to ${upperBound}, inclusive`,
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
@@ -250,7 +250,7 @@ function createLongLongConversion(bitLength, { unsigned }) {
const lowerBound = unsigned ? 0 : NumberMIN_SAFE_INTEGER;
const asBigIntN = unsigned ? BigIntAsUintN : BigIntAsIntN;
- return (V, opts = {}) => {
+ return (V, prefix = undefined, context = undefined, opts = {}) => {
let x = toNumber(V);
x = censorNegativeZero(x);
@@ -259,8 +259,8 @@ function createLongLongConversion(bitLength, { unsigned }) {
throw makeException(
TypeError,
"is not a finite number",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
@@ -270,8 +270,8 @@ function createLongLongConversion(bitLength, { unsigned }) {
throw makeException(
TypeError,
`is outside the accepted range of ${lowerBound} to ${upperBound}, inclusive`,
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
@@ -320,15 +320,15 @@ converters["unsigned long long"] = createLongLongConversion(64, {
unsigned: true,
});
-converters.float = (V, opts) => {
+converters.float = (V, prefix, context, _opts) => {
const x = toNumber(V);
if (!NumberIsFinite(x)) {
throw makeException(
TypeError,
"is not a finite floating-point value",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
@@ -342,15 +342,15 @@ converters.float = (V, opts) => {
throw makeException(
TypeError,
"is outside the range of a single-precision floating-point value",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
return y;
};
-converters["unrestricted float"] = (V, _opts) => {
+converters["unrestricted float"] = (V, _prefix, _context, _opts) => {
const x = toNumber(V);
if (isNaN(x)) {
@@ -364,28 +364,28 @@ converters["unrestricted float"] = (V, _opts) => {
return MathFround(x);
};
-converters.double = (V, opts) => {
+converters.double = (V, prefix, context, _opts) => {
const x = toNumber(V);
if (!NumberIsFinite(x)) {
throw makeException(
TypeError,
"is not a finite floating-point value",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
return x;
};
-converters["unrestricted double"] = (V, _opts) => {
+converters["unrestricted double"] = (V, _prefix, _context, _opts) => {
const x = toNumber(V);
return x;
};
-converters.DOMString = function (V, opts = {}) {
+converters.DOMString = function (V, prefix, context, opts = {}) {
if (typeof V === "string") {
return V;
} else if (V === null && opts.treatNullAsEmptyString) {
@@ -394,8 +394,8 @@ converters.DOMString = function (V, opts = {}) {
throw makeException(
TypeError,
"is a symbol, which cannot be converted to a string",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
@@ -404,21 +404,21 @@ converters.DOMString = function (V, opts = {}) {
// deno-lint-ignore no-control-regex
const IS_BYTE_STRING = new SafeRegExp(/^[\x00-\xFF]*$/);
-converters.ByteString = (V, opts) => {
- const x = converters.DOMString(V, opts);
+converters.ByteString = (V, prefix, context, opts) => {
+ const x = converters.DOMString(V, prefix, context, opts);
if (!RegExpPrototypeTest(IS_BYTE_STRING, x)) {
throw makeException(
TypeError,
"is not a valid ByteString",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
return x;
};
-converters.USVString = (V, opts) => {
- const S = converters.DOMString(V, opts);
+converters.USVString = (V, prefix, context, opts) => {
+ const S = converters.DOMString(V, prefix, context, opts);
const n = S.length;
let U = "";
for (let i = 0; i < n; ++i) {
@@ -444,13 +444,13 @@ converters.USVString = (V, opts) => {
return U;
};
-converters.object = (V, opts) => {
+converters.object = (V, prefix, context, _opts) => {
if (type(V) !== "Object") {
throw makeException(
TypeError,
"is not an object",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
@@ -461,13 +461,13 @@ converters.object = (V, opts) => {
// Neither Function nor VoidFunction is defined with [TreatNonObjectAsNull], so
// handling for that is omitted.
-function convertCallbackFunction(V, opts) {
+function convertCallbackFunction(V, prefix, context, _opts) {
if (typeof V !== "function") {
throw makeException(
TypeError,
"is not a function",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
return V;
@@ -487,34 +487,44 @@ function isSharedArrayBuffer(V) {
return ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V);
}
-converters.ArrayBuffer = (V, opts = {}) => {
+converters.ArrayBuffer = (
+ V,
+ prefix = undefined,
+ context = undefined,
+ opts = {},
+) => {
if (!isNonSharedArrayBuffer(V)) {
if (opts.allowShared && !isSharedArrayBuffer(V)) {
throw makeException(
TypeError,
"is not an ArrayBuffer or SharedArrayBuffer",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
throw makeException(
TypeError,
"is not an ArrayBuffer",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
return V;
};
-converters.DataView = (V, opts = {}) => {
+converters.DataView = (
+ V,
+ prefix = undefined,
+ context = undefined,
+ opts = {},
+) => {
if (!isDataView(V)) {
throw makeException(
TypeError,
"is not a DataView",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
@@ -522,8 +532,8 @@ converters.DataView = (V, opts = {}) => {
throw makeException(
TypeError,
"is backed by a SharedArrayBuffer, which is not allowed",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
@@ -547,13 +557,18 @@ ArrayPrototypeForEach(
const article = RegExpPrototypeTest(new SafeRegExp(/^[AEIOU]/), name)
? "an"
: "a";
- converters[name] = (V, opts = {}) => {
+ converters[name] = (
+ V,
+ prefix = undefined,
+ context = undefined,
+ opts = {},
+ ) => {
if (TypedArrayPrototypeGetSymbolToStringTag(V) !== name) {
throw makeException(
TypeError,
`is not ${article} ${name} object`,
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
if (
@@ -563,8 +578,8 @@ ArrayPrototypeForEach(
throw makeException(
TypeError,
"is a view on a SharedArrayBuffer, which is not allowed",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
@@ -575,13 +590,18 @@ ArrayPrototypeForEach(
// Common definitions
-converters.ArrayBufferView = (V, opts = {}) => {
+converters.ArrayBufferView = (
+ V,
+ prefix = undefined,
+ context = undefined,
+ opts = {},
+) => {
if (!ArrayBufferIsView(V)) {
throw makeException(
TypeError,
"is not a view on an ArrayBuffer or SharedArrayBuffer",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
let buffer;
@@ -594,15 +614,20 @@ converters.ArrayBufferView = (V, opts = {}) => {
throw makeException(
TypeError,
"is a view on a SharedArrayBuffer, which is not allowed",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
return V;
};
-converters.BufferSource = (V, opts = {}) => {
+converters.BufferSource = (
+ V,
+ prefix = undefined,
+ context = undefined,
+ opts = {},
+) => {
if (ArrayBufferIsView(V)) {
let buffer;
if (TypedArrayPrototypeGetSymbolToStringTag(V) !== undefined) {
@@ -614,8 +639,8 @@ converters.BufferSource = (V, opts = {}) => {
throw makeException(
TypeError,
"is a view on a SharedArrayBuffer, which is not allowed",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
@@ -626,8 +651,8 @@ converters.BufferSource = (V, opts = {}) => {
throw makeException(
TypeError,
"is not an ArrayBuffer or a view on one",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
if (
@@ -638,8 +663,8 @@ converters.BufferSource = (V, opts = {}) => {
throw makeException(
TypeError,
"is not an ArrayBuffer, SharedArrayBuffer, or a view on one",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
@@ -744,7 +769,7 @@ function createDictionaryConverter(name, ...dictionaries) {
}
}
- return function (V, opts = {}) {
+ return function (V, prefix = undefined, context = undefined, opts = {}) {
const typeV = type(V);
switch (typeV) {
case "Undefined":
@@ -755,8 +780,8 @@ function createDictionaryConverter(name, ...dictionaries) {
throw makeException(
TypeError,
"can not be converted to a dictionary",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
const esDict = V;
@@ -780,18 +805,23 @@ function createDictionaryConverter(name, ...dictionaries) {
}
if (esMemberValue !== undefined) {
- const context = `'${key}' of '${name}'${
- opts.context ? ` (${opts.context})` : ""
+ const memberContext = `'${key}' of '${name}'${
+ context ? ` (${context})` : ""
}`;
const converter = member.converter;
- const idlMemberValue = converter(esMemberValue, { ...opts, context });
+ const idlMemberValue = converter(
+ esMemberValue,
+ prefix,
+ memberContext,
+ opts,
+ );
idlDict[key] = idlMemberValue;
} else if (member.required) {
throw makeException(
TypeError,
`can not be converted to '${name}' because '${key}' is required in '${name}'.`,
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
}
@@ -804,13 +834,13 @@ function createDictionaryConverter(name, ...dictionaries) {
function createEnumConverter(name, values) {
const E = new SafeSet(values);
- return function (V, opts = {}) {
+ return function (V, prefix = undefined, _context = undefined, _opts = {}) {
const S = String(V);
if (!E.has(S)) {
throw new TypeError(
`${
- opts.prefix ? opts.prefix + ": " : ""
+ prefix ? prefix + ": " : ""
}The provided value '${S}' is not a valid enum value of type ${name}.`,
);
}
@@ -820,7 +850,7 @@ function createEnumConverter(name, values) {
}
function createNullableConverter(converter) {
- return (V, opts = {}) => {
+ return (V, prefix = undefined, context = undefined, opts = {}) => {
// FIXME: If Type(V) is not Object, and the conversion to an IDL value is
// being performed due to V being assigned to an attribute whose type is a
// nullable callback function that is annotated with
@@ -828,19 +858,19 @@ function createNullableConverter(converter) {
// value null.
if (V === null || V === undefined) return null;
- return converter(V, opts);
+ return converter(V, prefix, context, opts);
};
}
// https://heycam.github.io/webidl/#es-sequence
function createSequenceConverter(converter) {
- return function (V, opts = {}) {
+ return function (V, prefix = undefined, context = undefined, opts = {}) {
if (type(V) !== "Object") {
throw makeException(
TypeError,
"can not be converted to sequence.",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
const iter = V?.[SymbolIterator]?.();
@@ -848,8 +878,8 @@ function createSequenceConverter(converter) {
throw makeException(
TypeError,
"can not be converted to sequence.",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
const array = [];
@@ -859,15 +889,17 @@ function createSequenceConverter(converter) {
throw makeException(
TypeError,
"can not be converted to sequence.",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
if (res.done === true) break;
- const val = converter(res.value, {
- ...opts,
- context: `${opts.context}, index ${array.length}`,
- });
+ const val = converter(
+ res.value,
+ prefix,
+ `${context}, index ${array.length}`,
+ opts,
+ );
ArrayPrototypePush(array, val);
}
return array;
@@ -875,13 +907,13 @@ function createSequenceConverter(converter) {
}
function createRecordConverter(keyConverter, valueConverter) {
- return (V, opts) => {
+ return (V, prefix, context, opts) => {
if (type(V) !== "Object") {
throw makeException(
TypeError,
"can not be converted to dictionary.",
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
const result = {};
@@ -891,9 +923,9 @@ function createRecordConverter(keyConverter, valueConverter) {
if (!ObjectPrototypeHasOwnProperty(V, key)) {
continue;
}
- const typedKey = keyConverter(key, opts);
+ const typedKey = keyConverter(key, prefix, context, opts);
const value = V[key];
- const typedValue = valueConverter(value, opts);
+ const typedValue = valueConverter(value, prefix, context, opts);
result[typedKey] = typedValue;
}
return result;
@@ -904,9 +936,9 @@ function createRecordConverter(keyConverter, valueConverter) {
const key = keys[i];
const desc = ObjectGetOwnPropertyDescriptor(V, key);
if (desc !== undefined && desc.enumerable === true) {
- const typedKey = keyConverter(key, opts);
+ const typedKey = keyConverter(key, prefix, context, opts);
const value = V[key];
- const typedValue = valueConverter(value, opts);
+ const typedValue = valueConverter(value, prefix, context, opts);
result[typedKey] = typedValue;
}
}
@@ -915,8 +947,11 @@ function createRecordConverter(keyConverter, valueConverter) {
}
function createPromiseConverter(converter) {
- return (V, opts) =>
- PromisePrototypeThen(PromiseResolve(V), (V) => converter(V, opts));
+ return (V, prefix, context, opts) =>
+ PromisePrototypeThen(
+ PromiseResolve(V),
+ (V) => converter(V, prefix, context, opts),
+ );
}
function invokeCallbackFunction(
@@ -929,10 +964,7 @@ function invokeCallbackFunction(
) {
try {
const rv = ReflectApply(callable, thisArg, args);
- return returnValueConverter(rv, {
- prefix,
- context: "return value",
- });
+ return returnValueConverter(rv, prefix, "return value");
} catch (err) {
if (returnsPromise === true) {
return PromiseReject(err);
@@ -944,13 +976,13 @@ function invokeCallbackFunction(
const brand = Symbol("[[webidl.brand]]");
function createInterfaceConverter(name, prototype) {
- return (V, opts) => {
+ return (V, prefix, context, _opts) => {
if (!ObjectPrototypeIsPrototypeOf(prototype, V) || V[brand] !== brand) {
throw makeException(
TypeError,
`is not of type ${name}.`,
- opts.prefix,
- opts.context,
+ prefix,
+ context,
);
}
return V;
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;
/**