mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-02 12:00:03 +02:00
update packages to latest version
This commit is contained in:
6
node_modules/webidl-conversions/README.md
generated
vendored
6
node_modules/webidl-conversions/README.md
generated
vendored
@@ -18,7 +18,7 @@ function doStuff(x, y) {
|
||||
and your function `doStuff` will behave the same as a Web IDL operation declared as
|
||||
|
||||
```webidl
|
||||
void doStuff(boolean x, unsigned long y);
|
||||
undefined doStuff(boolean x, unsigned long y);
|
||||
```
|
||||
|
||||
## API
|
||||
@@ -48,7 +48,7 @@ Specific conversions may also accept other options, the details of which can be
|
||||
Conversions for all of the basic types from the Web IDL specification are implemented:
|
||||
|
||||
- [`any`](https://heycam.github.io/webidl/#es-any)
|
||||
- [`void`](https://heycam.github.io/webidl/#es-void)
|
||||
- [`undefined`](https://heycam.github.io/webidl/#es-undefined)
|
||||
- [`boolean`](https://heycam.github.io/webidl/#es-boolean)
|
||||
- [Integer types](https://heycam.github.io/webidl/#es-integer-types), which can additionally be provided the boolean options `{ clamp, enforceRange }` as a second parameter
|
||||
- [`float`](https://heycam.github.io/webidl/#es-float), [`unrestricted float`](https://heycam.github.io/webidl/#es-unrestricted-float)
|
||||
@@ -63,8 +63,6 @@ Additionally, for convenience, the following derived type definitions are implem
|
||||
- [`ArrayBufferView`](https://heycam.github.io/webidl/#ArrayBufferView), which can additionally be provided with the boolean option `{ allowShared }` as a second parameter
|
||||
- [`BufferSource`](https://heycam.github.io/webidl/#BufferSource)
|
||||
- [`DOMTimeStamp`](https://heycam.github.io/webidl/#DOMTimeStamp)
|
||||
- [`Function`](https://heycam.github.io/webidl/#Function)
|
||||
- [`VoidFunction`](https://heycam.github.io/webidl/#VoidFunction) (although it will not censor the return type)
|
||||
|
||||
Derived types, such as nullable types, promise types, sequences, records, etc. are not handled by this library. You may wish to investigate the [webidl2js](https://github.com/jsdom/webidl2js) project.
|
||||
|
||||
|
687
node_modules/webidl-conversions/lib/index.js
generated
vendored
687
node_modules/webidl-conversions/lib/index.js
generated
vendored
@@ -1,211 +1,178 @@
|
||||
"use strict";
|
||||
|
||||
function makeException(ErrorType, message, opts = {}) {
|
||||
if (opts.globals) {
|
||||
ErrorType = opts.globals[ErrorType.name];
|
||||
}
|
||||
return new ErrorType(`${opts.context ? opts.context : "Value"} ${message}.`);
|
||||
function makeException(ErrorType, message, options) {
|
||||
if (options.globals) {
|
||||
ErrorType = options.globals[ErrorType.name];
|
||||
}
|
||||
return new ErrorType(`${options.context ? options.context : "Value"} ${message}.`);
|
||||
}
|
||||
|
||||
function toNumber(value, opts = {}) {
|
||||
if (!opts.globals) {
|
||||
return +value;
|
||||
}
|
||||
if (typeof value === "bigint") {
|
||||
throw opts.globals.TypeError("Cannot convert a BigInt value to a number");
|
||||
}
|
||||
return opts.globals.Number(value);
|
||||
}
|
||||
|
||||
function type(V) {
|
||||
if (V === null) {
|
||||
return "Null";
|
||||
}
|
||||
switch (typeof V) {
|
||||
case "undefined":
|
||||
return "Undefined";
|
||||
case "boolean":
|
||||
return "Boolean";
|
||||
case "number":
|
||||
return "Number";
|
||||
case "string":
|
||||
return "String";
|
||||
case "symbol":
|
||||
return "Symbol";
|
||||
case "bigint":
|
||||
return "BigInt";
|
||||
case "object":
|
||||
// Falls through
|
||||
case "function":
|
||||
// Falls through
|
||||
default:
|
||||
// Per ES spec, typeof returns an implemention-defined value that is not any of the existing ones for
|
||||
// uncallable non-standard exotic objects. Yet Type() which the Web IDL spec depends on returns Object for
|
||||
// such cases. So treat the default case as an object.
|
||||
return "Object";
|
||||
}
|
||||
function toNumber(value, options) {
|
||||
if (typeof value === "bigint") {
|
||||
throw makeException(TypeError, "is a BigInt which cannot be converted to a number", options);
|
||||
}
|
||||
if (!options.globals) {
|
||||
return Number(value);
|
||||
}
|
||||
return options.globals.Number(value);
|
||||
}
|
||||
|
||||
// Round x to the nearest integer, choosing the even integer if it lies halfway between two.
|
||||
function evenRound(x) {
|
||||
// There are four cases for numbers with fractional part being .5:
|
||||
//
|
||||
// case | x | floor(x) | round(x) | expected | x <> 0 | x % 1 | x & 1 | example
|
||||
// 1 | 2n + 0.5 | 2n | 2n + 1 | 2n | > | 0.5 | 0 | 0.5 -> 0
|
||||
// 2 | 2n + 1.5 | 2n + 1 | 2n + 2 | 2n + 2 | > | 0.5 | 1 | 1.5 -> 2
|
||||
// 3 | -2n - 0.5 | -2n - 1 | -2n | -2n | < | -0.5 | 0 | -0.5 -> 0
|
||||
// 4 | -2n - 1.5 | -2n - 2 | -2n - 1 | -2n - 2 | < | -0.5 | 1 | -1.5 -> -2
|
||||
// (where n is a non-negative integer)
|
||||
//
|
||||
// Branch here for cases 1 and 4
|
||||
if ((x > 0 && (x % 1) === +0.5 && (x & 1) === 0) ||
|
||||
// There are four cases for numbers with fractional part being .5:
|
||||
//
|
||||
// case | x | floor(x) | round(x) | expected | x <> 0 | x % 1 | x & 1 | example
|
||||
// 1 | 2n + 0.5 | 2n | 2n + 1 | 2n | > | 0.5 | 0 | 0.5 -> 0
|
||||
// 2 | 2n + 1.5 | 2n + 1 | 2n + 2 | 2n + 2 | > | 0.5 | 1 | 1.5 -> 2
|
||||
// 3 | -2n - 0.5 | -2n - 1 | -2n | -2n | < | -0.5 | 0 | -0.5 -> 0
|
||||
// 4 | -2n - 1.5 | -2n - 2 | -2n - 1 | -2n - 2 | < | -0.5 | 1 | -1.5 -> -2
|
||||
// (where n is a non-negative integer)
|
||||
//
|
||||
// Branch here for cases 1 and 4
|
||||
if ((x > 0 && (x % 1) === +0.5 && (x & 1) === 0) ||
|
||||
(x < 0 && (x % 1) === -0.5 && (x & 1) === 1)) {
|
||||
return censorNegativeZero(Math.floor(x));
|
||||
}
|
||||
return censorNegativeZero(Math.floor(x));
|
||||
}
|
||||
|
||||
return censorNegativeZero(Math.round(x));
|
||||
return censorNegativeZero(Math.round(x));
|
||||
}
|
||||
|
||||
function integerPart(n) {
|
||||
return censorNegativeZero(Math.trunc(n));
|
||||
return censorNegativeZero(Math.trunc(n));
|
||||
}
|
||||
|
||||
function sign(x) {
|
||||
return x < 0 ? -1 : 1;
|
||||
return x < 0 ? -1 : 1;
|
||||
}
|
||||
|
||||
function modulo(x, y) {
|
||||
// https://tc39.github.io/ecma262/#eqn-modulo
|
||||
// Note that http://stackoverflow.com/a/4467559/3191 does NOT work for large modulos
|
||||
const signMightNotMatch = x % y;
|
||||
if (sign(y) !== sign(signMightNotMatch)) {
|
||||
return signMightNotMatch + y;
|
||||
}
|
||||
return signMightNotMatch;
|
||||
// https://tc39.github.io/ecma262/#eqn-modulo
|
||||
// Note that http://stackoverflow.com/a/4467559/3191 does NOT work for large modulos
|
||||
const signMightNotMatch = x % y;
|
||||
if (sign(y) !== sign(signMightNotMatch)) {
|
||||
return signMightNotMatch + y;
|
||||
}
|
||||
return signMightNotMatch;
|
||||
}
|
||||
|
||||
function censorNegativeZero(x) {
|
||||
return x === 0 ? 0 : x;
|
||||
return x === 0 ? 0 : x;
|
||||
}
|
||||
|
||||
function createIntegerConversion(bitLength, typeOpts) {
|
||||
const isSigned = !typeOpts.unsigned;
|
||||
function createIntegerConversion(bitLength, { unsigned }) {
|
||||
let lowerBound, upperBound;
|
||||
if (unsigned) {
|
||||
lowerBound = 0;
|
||||
upperBound = 2 ** bitLength - 1;
|
||||
} else {
|
||||
lowerBound = -(2 ** (bitLength - 1));
|
||||
upperBound = 2 ** (bitLength - 1) - 1;
|
||||
}
|
||||
|
||||
let lowerBound;
|
||||
let upperBound;
|
||||
if (bitLength === 64) {
|
||||
upperBound = Number.MAX_SAFE_INTEGER;
|
||||
lowerBound = !isSigned ? 0 : Number.MIN_SAFE_INTEGER;
|
||||
} else if (!isSigned) {
|
||||
lowerBound = 0;
|
||||
upperBound = Math.pow(2, bitLength) - 1;
|
||||
} else {
|
||||
lowerBound = -Math.pow(2, bitLength - 1);
|
||||
upperBound = Math.pow(2, bitLength - 1) - 1;
|
||||
const twoToTheBitLength = 2 ** bitLength;
|
||||
const twoToOneLessThanTheBitLength = 2 ** (bitLength - 1);
|
||||
|
||||
return (value, options = {}) => {
|
||||
let x = toNumber(value, options);
|
||||
x = censorNegativeZero(x);
|
||||
|
||||
if (options.enforceRange) {
|
||||
if (!Number.isFinite(x)) {
|
||||
throw makeException(TypeError, "is not a finite number", options);
|
||||
}
|
||||
|
||||
x = integerPart(x);
|
||||
|
||||
if (x < lowerBound || x > upperBound) {
|
||||
throw makeException(
|
||||
TypeError,
|
||||
`is outside the accepted range of ${lowerBound} to ${upperBound}, inclusive`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
const twoToTheBitLength = Math.pow(2, bitLength);
|
||||
const twoToOneLessThanTheBitLength = Math.pow(2, bitLength - 1);
|
||||
if (!Number.isNaN(x) && options.clamp) {
|
||||
x = Math.min(Math.max(x, lowerBound), upperBound);
|
||||
x = evenRound(x);
|
||||
return x;
|
||||
}
|
||||
|
||||
return (V, opts = {}) => {
|
||||
let x = toNumber(V, opts);
|
||||
x = censorNegativeZero(x);
|
||||
if (!Number.isFinite(x) || x === 0) {
|
||||
return 0;
|
||||
}
|
||||
x = integerPart(x);
|
||||
|
||||
if (opts.enforceRange) {
|
||||
if (!Number.isFinite(x)) {
|
||||
throw makeException(TypeError, "is not a finite number", opts);
|
||||
}
|
||||
// Math.pow(2, 64) is not accurately representable in JavaScript, so try to avoid these per-spec operations if
|
||||
// possible. Hopefully it's an optimization for the non-64-bitLength cases too.
|
||||
if (x >= lowerBound && x <= upperBound) {
|
||||
return x;
|
||||
}
|
||||
|
||||
x = integerPart(x);
|
||||
|
||||
if (x < lowerBound || x > upperBound) {
|
||||
throw makeException(TypeError,
|
||||
`is outside the accepted range of ${lowerBound} to ${upperBound}, inclusive`, opts);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
if (!Number.isNaN(x) && opts.clamp) {
|
||||
x = Math.min(Math.max(x, lowerBound), upperBound);
|
||||
x = evenRound(x);
|
||||
return x;
|
||||
}
|
||||
|
||||
if (!Number.isFinite(x) || x === 0) {
|
||||
return 0;
|
||||
}
|
||||
x = integerPart(x);
|
||||
|
||||
// Math.pow(2, 64) is not accurately representable in JavaScript, so try to avoid these per-spec operations if
|
||||
// possible. Hopefully it's an optimization for the non-64-bitLength cases too.
|
||||
if (x >= lowerBound && x <= upperBound) {
|
||||
return x;
|
||||
}
|
||||
|
||||
// These will not work great for bitLength of 64, but oh well. See the README for more details.
|
||||
x = modulo(x, twoToTheBitLength);
|
||||
if (isSigned && x >= twoToOneLessThanTheBitLength) {
|
||||
return x - twoToTheBitLength;
|
||||
}
|
||||
return x;
|
||||
};
|
||||
// These will not work great for bitLength of 64, but oh well. See the README for more details.
|
||||
x = modulo(x, twoToTheBitLength);
|
||||
if (!unsigned && x >= twoToOneLessThanTheBitLength) {
|
||||
return x - twoToTheBitLength;
|
||||
}
|
||||
return x;
|
||||
};
|
||||
}
|
||||
|
||||
function createLongLongConversion(bitLength, { unsigned }) {
|
||||
const upperBound = Number.MAX_SAFE_INTEGER;
|
||||
const lowerBound = unsigned ? 0 : Number.MIN_SAFE_INTEGER;
|
||||
const asBigIntN = unsigned ? BigInt.asUintN : BigInt.asIntN;
|
||||
const upperBound = Number.MAX_SAFE_INTEGER;
|
||||
const lowerBound = unsigned ? 0 : Number.MIN_SAFE_INTEGER;
|
||||
const asBigIntN = unsigned ? BigInt.asUintN : BigInt.asIntN;
|
||||
|
||||
return (V, opts = {}) => {
|
||||
if (opts === undefined) {
|
||||
opts = {};
|
||||
}
|
||||
return (value, options = {}) => {
|
||||
let x = toNumber(value, options);
|
||||
x = censorNegativeZero(x);
|
||||
|
||||
let x = toNumber(V, opts);
|
||||
x = censorNegativeZero(x);
|
||||
if (options.enforceRange) {
|
||||
if (!Number.isFinite(x)) {
|
||||
throw makeException(TypeError, "is not a finite number", options);
|
||||
}
|
||||
|
||||
if (opts.enforceRange) {
|
||||
if (!Number.isFinite(x)) {
|
||||
throw makeException(TypeError, "is not a finite number", opts);
|
||||
}
|
||||
x = integerPart(x);
|
||||
|
||||
x = integerPart(x);
|
||||
if (x < lowerBound || x > upperBound) {
|
||||
throw makeException(
|
||||
TypeError,
|
||||
`is outside the accepted range of ${lowerBound} to ${upperBound}, inclusive`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
if (x < lowerBound || x > upperBound) {
|
||||
throw makeException(TypeError,
|
||||
`is outside the accepted range of ${lowerBound} to ${upperBound}, inclusive`, opts);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
if (!Number.isNaN(x) && options.clamp) {
|
||||
x = Math.min(Math.max(x, lowerBound), upperBound);
|
||||
x = evenRound(x);
|
||||
return x;
|
||||
}
|
||||
|
||||
if (!Number.isNaN(x) && opts.clamp) {
|
||||
x = Math.min(Math.max(x, lowerBound), upperBound);
|
||||
x = evenRound(x);
|
||||
return x;
|
||||
}
|
||||
if (!Number.isFinite(x) || x === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!Number.isFinite(x) || x === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let xBigInt = BigInt(integerPart(x));
|
||||
xBigInt = asBigIntN(bitLength, xBigInt);
|
||||
return Number(xBigInt);
|
||||
};
|
||||
let xBigInt = BigInt(integerPart(x));
|
||||
xBigInt = asBigIntN(bitLength, xBigInt);
|
||||
return Number(xBigInt);
|
||||
};
|
||||
}
|
||||
|
||||
exports.any = V => {
|
||||
return V;
|
||||
exports.any = value => {
|
||||
return value;
|
||||
};
|
||||
|
||||
exports.void = function () {
|
||||
return undefined;
|
||||
exports.undefined = () => {
|
||||
return undefined;
|
||||
};
|
||||
|
||||
exports.boolean = function (val) {
|
||||
return !!val;
|
||||
exports.boolean = value => {
|
||||
return Boolean(value);
|
||||
};
|
||||
|
||||
exports.byte = createIntegerConversion(8, { unsigned: false });
|
||||
@@ -220,195 +187,186 @@ exports["unsigned long"] = createIntegerConversion(32, { unsigned: true });
|
||||
exports["long long"] = createLongLongConversion(64, { unsigned: false });
|
||||
exports["unsigned long long"] = createLongLongConversion(64, { unsigned: true });
|
||||
|
||||
exports.double = (V, opts) => {
|
||||
const x = toNumber(V, opts);
|
||||
exports.double = (value, options = {}) => {
|
||||
const x = toNumber(value, options);
|
||||
|
||||
if (!Number.isFinite(x)) {
|
||||
throw makeException(TypeError, "is not a finite floating-point value", opts);
|
||||
}
|
||||
if (!Number.isFinite(x)) {
|
||||
throw makeException(TypeError, "is not a finite floating-point value", options);
|
||||
}
|
||||
|
||||
return x;
|
||||
};
|
||||
|
||||
exports["unrestricted double"] = (value, options = {}) => {
|
||||
const x = toNumber(value, options);
|
||||
|
||||
return x;
|
||||
};
|
||||
|
||||
exports.float = (value, options = {}) => {
|
||||
const x = toNumber(value, options);
|
||||
|
||||
if (!Number.isFinite(x)) {
|
||||
throw makeException(TypeError, "is not a finite floating-point value", options);
|
||||
}
|
||||
|
||||
if (Object.is(x, -0)) {
|
||||
return x;
|
||||
}
|
||||
|
||||
const y = Math.fround(x);
|
||||
|
||||
if (!Number.isFinite(y)) {
|
||||
throw makeException(TypeError, "is outside the range of a single-precision floating-point value", options);
|
||||
}
|
||||
|
||||
return y;
|
||||
};
|
||||
|
||||
exports["unrestricted double"] = (V, opts) => {
|
||||
const x = toNumber(V, opts);
|
||||
exports["unrestricted float"] = (value, options = {}) => {
|
||||
const x = toNumber(value, options);
|
||||
|
||||
if (isNaN(x)) {
|
||||
return x;
|
||||
};
|
||||
|
||||
exports.float = (V, opts) => {
|
||||
const x = toNumber(V, opts);
|
||||
|
||||
if (!Number.isFinite(x)) {
|
||||
throw makeException(TypeError, "is not a finite floating-point value", opts);
|
||||
}
|
||||
|
||||
if (Object.is(x, -0)) {
|
||||
return x;
|
||||
}
|
||||
|
||||
const y = Math.fround(x);
|
||||
|
||||
if (!Number.isFinite(y)) {
|
||||
throw makeException(TypeError, "is outside the range of a single-precision floating-point value", opts);
|
||||
}
|
||||
|
||||
return y;
|
||||
};
|
||||
|
||||
exports["unrestricted float"] = (V, opts) => {
|
||||
const x = toNumber(V, opts);
|
||||
|
||||
if (isNaN(x)) {
|
||||
return x;
|
||||
}
|
||||
|
||||
if (Object.is(x, -0)) {
|
||||
return x;
|
||||
}
|
||||
|
||||
return Math.fround(x);
|
||||
};
|
||||
|
||||
exports.DOMString = function (V, opts = {}) {
|
||||
if (opts.treatNullAsEmptyString && V === null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (typeof V === "symbol") {
|
||||
throw makeException(TypeError, "is a symbol, which cannot be converted to a string", opts);
|
||||
}
|
||||
|
||||
const StringCtor = opts.globals ? opts.globals.String : String;
|
||||
return StringCtor(V);
|
||||
};
|
||||
|
||||
exports.ByteString = (V, opts) => {
|
||||
const x = exports.DOMString(V, opts);
|
||||
let c;
|
||||
for (let i = 0; (c = x.codePointAt(i)) !== undefined; ++i) {
|
||||
if (c > 255) {
|
||||
throw makeException(TypeError, "is not a valid ByteString", opts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.is(x, -0)) {
|
||||
return x;
|
||||
}
|
||||
|
||||
return Math.fround(x);
|
||||
};
|
||||
|
||||
exports.USVString = (V, opts) => {
|
||||
const S = exports.DOMString(V, opts);
|
||||
const n = S.length;
|
||||
const U = [];
|
||||
for (let i = 0; i < n; ++i) {
|
||||
const c = S.charCodeAt(i);
|
||||
if (c < 0xD800 || c > 0xDFFF) {
|
||||
U.push(String.fromCodePoint(c));
|
||||
} else if (0xDC00 <= c && c <= 0xDFFF) {
|
||||
U.push(String.fromCodePoint(0xFFFD));
|
||||
} else if (i === n - 1) {
|
||||
U.push(String.fromCodePoint(0xFFFD));
|
||||
} else {
|
||||
const d = S.charCodeAt(i + 1);
|
||||
if (0xDC00 <= d && d <= 0xDFFF) {
|
||||
const a = c & 0x3FF;
|
||||
const b = d & 0x3FF;
|
||||
U.push(String.fromCodePoint((2 << 15) + ((2 << 9) * a) + b));
|
||||
++i;
|
||||
} else {
|
||||
U.push(String.fromCodePoint(0xFFFD));
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.DOMString = (value, options = {}) => {
|
||||
if (options.treatNullAsEmptyString && value === null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return U.join("");
|
||||
if (typeof value === "symbol") {
|
||||
throw makeException(TypeError, "is a symbol, which cannot be converted to a string", options);
|
||||
}
|
||||
|
||||
const StringCtor = options.globals ? options.globals.String : String;
|
||||
return StringCtor(value);
|
||||
};
|
||||
|
||||
exports.object = (V, opts) => {
|
||||
if (type(V) !== "Object") {
|
||||
throw makeException(TypeError, "is not an object", opts);
|
||||
exports.ByteString = (value, options = {}) => {
|
||||
const x = exports.DOMString(value, options);
|
||||
let c;
|
||||
for (let i = 0; (c = x.codePointAt(i)) !== undefined; ++i) {
|
||||
if (c > 255) {
|
||||
throw makeException(TypeError, "is not a valid ByteString", options);
|
||||
}
|
||||
}
|
||||
|
||||
return V;
|
||||
return x;
|
||||
};
|
||||
|
||||
// Not exported, but used in Function and VoidFunction.
|
||||
|
||||
// Neither Function nor VoidFunction is defined with [TreatNonObjectAsNull], so
|
||||
// handling for that is omitted.
|
||||
function convertCallbackFunction(V, opts) {
|
||||
if (typeof V !== "function") {
|
||||
throw makeException(TypeError, "is not a function", opts);
|
||||
exports.USVString = (value, options = {}) => {
|
||||
const S = exports.DOMString(value, options);
|
||||
const n = S.length;
|
||||
const U = [];
|
||||
for (let i = 0; i < n; ++i) {
|
||||
const c = S.charCodeAt(i);
|
||||
if (c < 0xD800 || c > 0xDFFF) {
|
||||
U.push(String.fromCodePoint(c));
|
||||
} else if (0xDC00 <= c && c <= 0xDFFF) {
|
||||
U.push(String.fromCodePoint(0xFFFD));
|
||||
} else if (i === n - 1) {
|
||||
U.push(String.fromCodePoint(0xFFFD));
|
||||
} else {
|
||||
const d = S.charCodeAt(i + 1);
|
||||
if (0xDC00 <= d && d <= 0xDFFF) {
|
||||
const a = c & 0x3FF;
|
||||
const b = d & 0x3FF;
|
||||
U.push(String.fromCodePoint((2 << 15) + ((2 << 9) * a) + b));
|
||||
++i;
|
||||
} else {
|
||||
U.push(String.fromCodePoint(0xFFFD));
|
||||
}
|
||||
}
|
||||
return V;
|
||||
}
|
||||
}
|
||||
|
||||
return U.join("");
|
||||
};
|
||||
|
||||
exports.object = (value, options = {}) => {
|
||||
if (value === null || (typeof value !== "object" && typeof value !== "function")) {
|
||||
throw makeException(TypeError, "is not an object", options);
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
const abByteLengthGetter =
|
||||
Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
|
||||
const sabByteLengthGetter =
|
||||
Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength").get;
|
||||
typeof SharedArrayBuffer === "function" ?
|
||||
Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength").get :
|
||||
null;
|
||||
|
||||
function isNonSharedArrayBuffer(V) {
|
||||
try {
|
||||
// This will throw on SharedArrayBuffers, but not detached ArrayBuffers.
|
||||
// (The spec says it should throw, but the spec conflicts with implementations: https://github.com/tc39/ecma262/issues/678)
|
||||
abByteLengthGetter.call(V);
|
||||
function isNonSharedArrayBuffer(value) {
|
||||
try {
|
||||
// This will throw on SharedArrayBuffers, but not detached ArrayBuffers.
|
||||
// (The spec says it should throw, but the spec conflicts with implementations: https://github.com/tc39/ecma262/issues/678)
|
||||
abByteLengthGetter.call(value);
|
||||
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isSharedArrayBuffer(V) {
|
||||
try {
|
||||
sabByteLengthGetter.call(V);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
function isSharedArrayBuffer(value) {
|
||||
try {
|
||||
sabByteLengthGetter.call(value);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isArrayBufferDetached(V) {
|
||||
try {
|
||||
// eslint-disable-next-line no-new
|
||||
new Uint8Array(V);
|
||||
return false;
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
function isArrayBufferDetached(value) {
|
||||
try {
|
||||
// eslint-disable-next-line no-new
|
||||
new Uint8Array(value);
|
||||
return false;
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
exports.ArrayBuffer = (V, opts = {}) => {
|
||||
if (!isNonSharedArrayBuffer(V)) {
|
||||
if (opts.allowShared && !isSharedArrayBuffer(V)) {
|
||||
throw makeException(TypeError, "is not an ArrayBuffer or SharedArrayBuffer", opts);
|
||||
}
|
||||
throw makeException(TypeError, "is not an ArrayBuffer", opts);
|
||||
}
|
||||
if (isArrayBufferDetached(V)) {
|
||||
throw makeException(TypeError, "is a detached ArrayBuffer", opts);
|
||||
exports.ArrayBuffer = (value, options = {}) => {
|
||||
if (!isNonSharedArrayBuffer(value)) {
|
||||
if (options.allowShared && !isSharedArrayBuffer(value)) {
|
||||
throw makeException(TypeError, "is not an ArrayBuffer or SharedArrayBuffer", options);
|
||||
}
|
||||
throw makeException(TypeError, "is not an ArrayBuffer", options);
|
||||
}
|
||||
if (isArrayBufferDetached(value)) {
|
||||
throw makeException(TypeError, "is a detached ArrayBuffer", options);
|
||||
}
|
||||
|
||||
return V;
|
||||
return value;
|
||||
};
|
||||
|
||||
const dvByteLengthGetter =
|
||||
Object.getOwnPropertyDescriptor(DataView.prototype, "byteLength").get;
|
||||
exports.DataView = (V, opts = {}) => {
|
||||
try {
|
||||
dvByteLengthGetter.call(V);
|
||||
} catch (e) {
|
||||
throw makeException(TypeError, "is not a DataView", opts);
|
||||
}
|
||||
exports.DataView = (value, options = {}) => {
|
||||
try {
|
||||
dvByteLengthGetter.call(value);
|
||||
} catch (e) {
|
||||
throw makeException(TypeError, "is not a DataView", options);
|
||||
}
|
||||
|
||||
if (!opts.allowShared && isSharedArrayBuffer(V.buffer)) {
|
||||
throw makeException(TypeError, "is backed by a SharedArrayBuffer, which is not allowed", opts);
|
||||
}
|
||||
if (isArrayBufferDetached(V.buffer)) {
|
||||
throw makeException(TypeError, "is backed by a detached ArrayBuffer", opts);
|
||||
}
|
||||
if (!options.allowShared && isSharedArrayBuffer(value.buffer)) {
|
||||
throw makeException(TypeError, "is backed by a SharedArrayBuffer, which is not allowed", options);
|
||||
}
|
||||
if (isArrayBufferDetached(value.buffer)) {
|
||||
throw makeException(TypeError, "is backed by a detached ArrayBuffer", options);
|
||||
}
|
||||
|
||||
return V;
|
||||
return value;
|
||||
};
|
||||
|
||||
// Returns the unforgeable `TypedArray` constructor name or `undefined`,
|
||||
@@ -416,74 +374,77 @@ exports.DataView = (V, opts = {}) => {
|
||||
//
|
||||
// https://tc39.es/ecma262/#sec-get-%typedarray%.prototype-@@tostringtag
|
||||
const typedArrayNameGetter = Object.getOwnPropertyDescriptor(
|
||||
Object.getPrototypeOf(Uint8Array).prototype,
|
||||
Symbol.toStringTag
|
||||
Object.getPrototypeOf(Uint8Array).prototype,
|
||||
Symbol.toStringTag
|
||||
).get;
|
||||
[
|
||||
Int8Array, Int16Array, Int32Array, Uint8Array,
|
||||
Uint16Array, Uint32Array, Uint8ClampedArray, Float32Array, Float64Array
|
||||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Uint8Array,
|
||||
Uint16Array,
|
||||
Uint32Array,
|
||||
Uint8ClampedArray,
|
||||
Float32Array,
|
||||
Float64Array
|
||||
].forEach(func => {
|
||||
const name = func.name;
|
||||
const article = /^[AEIOU]/.test(name) ? "an" : "a";
|
||||
exports[name] = (V, opts = {}) => {
|
||||
if (!ArrayBuffer.isView(V) || typedArrayNameGetter.call(V) !== name) {
|
||||
throw makeException(TypeError, `is not ${article} ${name} object`, opts);
|
||||
}
|
||||
if (!opts.allowShared && isSharedArrayBuffer(V.buffer)) {
|
||||
throw makeException(TypeError, "is a view on a SharedArrayBuffer, which is not allowed", opts);
|
||||
}
|
||||
if (isArrayBufferDetached(V.buffer)) {
|
||||
throw makeException(TypeError, "is a view on a detached ArrayBuffer", opts);
|
||||
}
|
||||
const { name } = func;
|
||||
const article = /^[AEIOU]/u.test(name) ? "an" : "a";
|
||||
exports[name] = (value, options = {}) => {
|
||||
if (!ArrayBuffer.isView(value) || typedArrayNameGetter.call(value) !== name) {
|
||||
throw makeException(TypeError, `is not ${article} ${name} object`, options);
|
||||
}
|
||||
if (!options.allowShared && isSharedArrayBuffer(value.buffer)) {
|
||||
throw makeException(TypeError, "is a view on a SharedArrayBuffer, which is not allowed", options);
|
||||
}
|
||||
if (isArrayBufferDetached(value.buffer)) {
|
||||
throw makeException(TypeError, "is a view on a detached ArrayBuffer", options);
|
||||
}
|
||||
|
||||
return V;
|
||||
};
|
||||
return value;
|
||||
};
|
||||
});
|
||||
|
||||
// Common definitions
|
||||
|
||||
exports.ArrayBufferView = (V, opts = {}) => {
|
||||
if (!ArrayBuffer.isView(V)) {
|
||||
throw makeException(TypeError, "is not a view on an ArrayBuffer or SharedArrayBuffer", opts);
|
||||
}
|
||||
exports.ArrayBufferView = (value, options = {}) => {
|
||||
if (!ArrayBuffer.isView(value)) {
|
||||
throw makeException(TypeError, "is not a view on an ArrayBuffer or SharedArrayBuffer", options);
|
||||
}
|
||||
|
||||
if (!opts.allowShared && isSharedArrayBuffer(V.buffer)) {
|
||||
throw makeException(TypeError, "is a view on a SharedArrayBuffer, which is not allowed", opts);
|
||||
}
|
||||
if (!options.allowShared && isSharedArrayBuffer(value.buffer)) {
|
||||
throw makeException(TypeError, "is a view on a SharedArrayBuffer, which is not allowed", options);
|
||||
}
|
||||
|
||||
if (isArrayBufferDetached(V.buffer)) {
|
||||
throw makeException(TypeError, "is a view on a detached ArrayBuffer", opts);
|
||||
}
|
||||
return V;
|
||||
if (isArrayBufferDetached(value.buffer)) {
|
||||
throw makeException(TypeError, "is a view on a detached ArrayBuffer", options);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
exports.BufferSource = (V, opts = {}) => {
|
||||
if (ArrayBuffer.isView(V)) {
|
||||
if (!opts.allowShared && isSharedArrayBuffer(V.buffer)) {
|
||||
throw makeException(TypeError, "is a view on a SharedArrayBuffer, which is not allowed", opts);
|
||||
}
|
||||
|
||||
if (isArrayBufferDetached(V.buffer)) {
|
||||
throw makeException(TypeError, "is a view on a detached ArrayBuffer", opts);
|
||||
}
|
||||
return V;
|
||||
exports.BufferSource = (value, options = {}) => {
|
||||
if (ArrayBuffer.isView(value)) {
|
||||
if (!options.allowShared && isSharedArrayBuffer(value.buffer)) {
|
||||
throw makeException(TypeError, "is a view on a SharedArrayBuffer, which is not allowed", options);
|
||||
}
|
||||
|
||||
if (!opts.allowShared && !isNonSharedArrayBuffer(V)) {
|
||||
throw makeException(TypeError, "is not an ArrayBuffer or a view on one", opts);
|
||||
}
|
||||
if (opts.allowShared && !isSharedArrayBuffer(V) && !isNonSharedArrayBuffer(V)) {
|
||||
throw makeException(TypeError, "is not an ArrayBuffer, SharedArrayBufer, or a view on one", opts);
|
||||
}
|
||||
if (isArrayBufferDetached(V)) {
|
||||
throw makeException(TypeError, "is a detached ArrayBuffer", opts);
|
||||
if (isArrayBufferDetached(value.buffer)) {
|
||||
throw makeException(TypeError, "is a view on a detached ArrayBuffer", options);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
return V;
|
||||
if (!options.allowShared && !isNonSharedArrayBuffer(value)) {
|
||||
throw makeException(TypeError, "is not an ArrayBuffer or a view on one", options);
|
||||
}
|
||||
if (options.allowShared && !isSharedArrayBuffer(value) && !isNonSharedArrayBuffer(value)) {
|
||||
throw makeException(TypeError, "is not an ArrayBuffer, SharedArrayBuffer, or a view on one", options);
|
||||
}
|
||||
if (isArrayBufferDetached(value)) {
|
||||
throw makeException(TypeError, "is a detached ArrayBuffer", options);
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
exports.DOMTimeStamp = exports["unsigned long long"];
|
||||
|
||||
exports.Function = convertCallbackFunction;
|
||||
|
||||
exports.VoidFunction = convertCallbackFunction;
|
||||
|
39
node_modules/webidl-conversions/package.json
generated
vendored
39
node_modules/webidl-conversions/package.json
generated
vendored
@@ -1,26 +1,31 @@
|
||||
{
|
||||
"_from": "webidl-conversions@^6.1.0",
|
||||
"_id": "webidl-conversions@6.1.0",
|
||||
"_from": "webidl-conversions@^7.0.0",
|
||||
"_id": "webidl-conversions@7.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==",
|
||||
"_integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==",
|
||||
"_location": "/webidl-conversions",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "webidl-conversions@^6.1.0",
|
||||
"raw": "webidl-conversions@^7.0.0",
|
||||
"name": "webidl-conversions",
|
||||
"escapedName": "webidl-conversions",
|
||||
"rawSpec": "^6.1.0",
|
||||
"rawSpec": "^7.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^6.1.0"
|
||||
"fetchSpec": "^7.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jsdom"
|
||||
"/domexception",
|
||||
"/jsdom",
|
||||
"/whatwg-url"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-6.1.0.tgz",
|
||||
"_shasum": "9111b4d7ea80acd40f5270d666621afa78b69514",
|
||||
"_spec": "webidl-conversions@^6.1.0",
|
||||
"_resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
|
||||
"_scripts_comments": {
|
||||
"test-no-sab": "Node.js internals are broken by deleting SharedArrayBuffer if you run tests on the main thread. Using Mocha's parallel mode avoids this."
|
||||
},
|
||||
"_shasum": "256b4e1882be7debbf01d05f0aa2039778ea080a",
|
||||
"_spec": "webidl-conversions@^7.0.0",
|
||||
"_where": "D:\\Projects\\minifyfromhtml\\node_modules\\jsdom",
|
||||
"author": {
|
||||
"name": "Domenic Denicola",
|
||||
@@ -34,12 +39,13 @@
|
||||
"deprecated": false,
|
||||
"description": "Implements the WebIDL algorithms for converting to and from JavaScript values",
|
||||
"devDependencies": {
|
||||
"eslint": "^6.8.0",
|
||||
"mocha": "^7.1.1",
|
||||
"nyc": "^15.0.0"
|
||||
"@domenic/eslint-config": "^1.3.0",
|
||||
"eslint": "^7.32.0",
|
||||
"mocha": "^9.1.1",
|
||||
"nyc": "^15.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.4"
|
||||
"node": ">=12"
|
||||
},
|
||||
"files": [
|
||||
"lib/"
|
||||
@@ -60,7 +66,8 @@
|
||||
"scripts": {
|
||||
"coverage": "nyc mocha test/*.js",
|
||||
"lint": "eslint .",
|
||||
"test": "mocha test/*.js"
|
||||
"test": "mocha test/*.js",
|
||||
"test-no-sab": "mocha --parallel --jobs 2 --require test/helpers/delete-sab.js test/*.js"
|
||||
},
|
||||
"version": "6.1.0"
|
||||
"version": "7.0.0"
|
||||
}
|
||||
|
Reference in New Issue
Block a user