Socket
Socket
Sign inDemoInstall

webidl2js

Package Overview
Dependencies
Maintainers
6
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webidl2js - npm Package Compare versions

Comparing version 9.2.2 to 10.0.0

LICENSE.md

16

lib/constructs/interface.js

@@ -384,14 +384,2 @@ "use strict";

implements(source) {
const iface = this.ctx.interfaces.get(source);
if (!iface) {
if (this.ctx.options.suppressErrors) {
return;
}
throw new Error(`${source} interface not found (implemented by ${this.name})`);
}
this.implemented.push(source);
}
includes(source) {

@@ -1261,2 +1249,4 @@ const mixin = this.ctx.interfaceMixins.get(source);

if (Object.keys(unscopables).length > 0) {
// eslint-disable-next-line no-proto
unscopables.__proto__ = null;
this.addProperty("prototype", Symbol.unscopables, JSON.stringify(unscopables), {

@@ -1438,3 +1428,3 @@ writable: false

obj,
utils.getOwnPropertyDescriptors({ ${methods.join(", ")} })
Object.getOwnPropertyDescriptors({ ${methods.join(", ")} })
);

@@ -1441,0 +1431,0 @@ `;

@@ -10,4 +10,4 @@ "use strict";

"implements", "package", "protected", "static", "interface", "private", "public",
"package", "protected", "static", "interface", "private", "public",
"null", "true", "false"]);

@@ -12,27 +12,2 @@ "use strict";

const getOwnPropertyDescriptors = typeof Object.getOwnPropertyDescriptors === "function" ?
Object.getOwnPropertyDescriptors :
// Polyfill exists until we require Node.js v8.x
// https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors
obj => {
if (obj === undefined || obj === null) {
throw new TypeError("Cannot convert undefined or null to object");
}
obj = Object(obj);
const ownKeys = Reflect.ownKeys(obj);
const descriptors = {};
for (const key of ownKeys) {
const descriptor = Reflect.getOwnPropertyDescriptor(obj, key);
if (descriptor !== undefined) {
Reflect.defineProperty(descriptors, key, {
value: descriptor,
writable: true,
enumerable: true,
configurable: true
});
}
}
return descriptors;
};
const wrapperSymbol = Symbol("wrapper");

@@ -106,3 +81,2 @@ const implSymbol = Symbol("impl");

hasOwn,
getOwnPropertyDescriptors,
wrapperSymbol,

@@ -109,0 +83,0 @@ implSymbol,

@@ -5,3 +5,3 @@ "use strict";

get(objName, attrName) {
return `return this.hasAttributeNS(null, "${attrName}");`;
return `return this[impl].hasAttributeNS(null, "${attrName}");`;
},

@@ -11,5 +11,5 @@ set(objName, attrName) {

if (V) {
this.setAttributeNS(null, "${attrName}", "");
this[impl].setAttributeNS(null, "${attrName}", "");
} else {
this.removeAttributeNS(null, "${attrName}");
this[impl].removeAttributeNS(null, "${attrName}");
}

@@ -23,3 +23,3 @@ `;

return `
const value = this.getAttributeNS(null, "${attrName}");
const value = this[impl].getAttributeNS(null, "${attrName}");
return value === null ? "" : value;

@@ -29,3 +29,3 @@ `;

set(objName, attrName) {
return `this.setAttributeNS(null, "${attrName}", V);`;
return `this[impl].setAttributeNS(null, "${attrName}", V);`;
}

@@ -37,3 +37,3 @@ };

return `
const value = parseInt(this.getAttributeNS(null, "${attrName}"));
const value = parseInt(this[impl].getAttributeNS(null, "${attrName}"));
return isNaN(value) || value < -2147483648 || value > 2147483647 ? 0 : value

@@ -43,3 +43,3 @@ `;

set(objName, attrName) {
return `this.setAttributeNS(null, "${attrName}", String(V));`;
return `this[impl].setAttributeNS(null, "${attrName}", String(V));`;
}

@@ -51,3 +51,3 @@ };

return `
const value = parseInt(this.getAttributeNS(null, "${attrName}"));
const value = parseInt(this[impl].getAttributeNS(null, "${attrName}"));
return isNaN(value) || value < 0 || value > 2147483647 ? 0 : value

@@ -57,4 +57,4 @@ `;

set(objName, attrName) {
return `this.setAttributeNS(null, "${attrName}", String(V > 2147483647 ? 0 : V));`;
return `this[impl].setAttributeNS(null, "${attrName}", String(V > 2147483647 ? 0 : V));`;
}
};

@@ -5,3 +5,2 @@ "use strict";

const co = require("co");
const fs = require("pn/fs");

@@ -42,8 +41,8 @@ const webidl = require("webidl2");

* _collectSources() {
const stats = yield Promise.all(this.sources.map(src => fs.stat(src.idlPath)));
async _collectSources() {
const stats = await Promise.all(this.sources.map(src => fs.stat(src.idlPath)));
const files = [];
for (let i = 0; i < stats.length; ++i) {
if (stats[i].isDirectory()) {
const folderContents = yield fs.readdir(this.sources[i].idlPath);
const folderContents = await fs.readdir(this.sources[i].idlPath);
for (const file of folderContents) {

@@ -67,5 +66,5 @@ if (file.endsWith(".webidl")) {

* _readFiles(files) {
async _readFiles(files) {
const zipped = [];
const fileContents = yield Promise.all(files.map(f => fs.readFile(f.idlPath, { encoding: "utf-8" })));
const fileContents = await Promise.all(files.map(f => fs.readFile(f.idlPath, { encoding: "utf-8" })));
for (let i = 0; i < files.length; ++i) {

@@ -112,3 +111,2 @@ zipped.push({

break;
case "implements":
case "includes":

@@ -140,3 +138,3 @@ break; // handled later

// second we add all partial members and handle implements/includes
// second we add all partial members and handle includes
for (const file of parsed) {

@@ -185,8 +183,2 @@ for (const instruction of file.idl) {

break;
case "implements":
if (this.ctx.options.suppressErrors && !interfaces.has(instruction.target)) {
break;
}
interfaces.get(instruction.target).implements(instruction.implements);
break;
case "includes":

@@ -203,5 +195,5 @@ if (this.ctx.options.suppressErrors && !interfaces.has(instruction.target)) {

* _writeFiles(outputDir) {
const utilsText = yield fs.readFile(path.resolve(__dirname, "output/utils.js"));
yield fs.writeFile(this.utilPath, utilsText);
async _writeFiles(outputDir) {
const utilsText = await fs.readFile(path.resolve(__dirname, "output/utils.js"));
await fs.writeFile(this.utilPath, utilsText);

@@ -235,3 +227,3 @@ const { interfaces, dictionaries, enumerations } = this.ctx;

yield fs.writeFile(path.join(outputDir, obj.name + ".js"), source);
await fs.writeFile(path.join(outputDir, obj.name + ".js"), source);
}

@@ -257,3 +249,3 @@

yield fs.writeFile(path.join(outputDir, obj.name + ".js"), source);
await fs.writeFile(path.join(outputDir, obj.name + ".js"), source);
}

@@ -267,3 +259,3 @@

`);
yield fs.writeFile(path.join(outputDir, obj.name + ".js"), source);
await fs.writeFile(path.join(outputDir, obj.name + ".js"), source);
}

@@ -275,7 +267,7 @@ }

printWidth: 120,
parser: "babylon"
parser: "babel"
});
}
generate(outputDir) {
async generate(outputDir) {
if (!this.utilPath) {

@@ -285,8 +277,6 @@ this.utilPath = path.join(outputDir, "utils.js");

return co(function* () {
const sources = yield* this._collectSources();
const contents = yield* this._readFiles(sources);
this._parse(outputDir, contents);
yield* this._writeFiles(outputDir);
}.bind(this));
const sources = await this._collectSources();
const contents = await this._readFiles(sources);
this._parse(outputDir, contents);
await this._writeFiles(outputDir);
}

@@ -293,0 +283,0 @@ }

{
"name": "webidl2js",
"version": "9.2.2",
"version": "10.0.0",
"description": "Auto-generates class structures for WebIDL specifications",

@@ -8,5 +8,4 @@ "main": "lib/transformer.js",

"dependencies": {
"co": "^4.6.0",
"pn": "^1.1.0",
"prettier": "^1.14.0",
"prettier": "^1.18.2",
"webidl-conversions": "^4.0.0",

@@ -16,4 +15,4 @@ "webidl2": "^10.3.3"

"devDependencies": {
"eslint": "^4.13.1",
"jest": "^23.4.2"
"eslint": "^6.5.1",
"jest": "^24.9.0"
},

@@ -28,4 +27,7 @@ "scripts": {

},
"engines": {
"node": ">=8"
},
"author": "Sebastian Mayr <npm@smayr.name>",
"license": "MIT"
}

@@ -162,3 +162,3 @@ # JavaScript bindings generator for Web IDL

Creates a new instance of the wrapper class and corresponding implementation class, passing in the `constructorArgs` array and `privateData` object to the implementation class constructor. Then returns the wrapper class.
Creates a new instance of the wrapper class and corresponding implementation class, passing in the `constructorArgs` array and `privateData` object to the implementation class constructor. Then returns the implementation class.

@@ -345,3 +345,2 @@ This is useful inside implementation class files, where it is easiest to only deal with impls, not wrappers.

- Basic types (via [webidl-conversions][])
- Old-style mixins, i.e. `implements`
- Overload resolution (although [tricky cases are not easy on the implementation class](#overloaded-operations))

@@ -400,3 +399,3 @@ - Variadic arguments

This extended attribute can be applied to named or indexed getters or setters. It says that whether the interface supports a given property name/index can be automatically derived by looking at the return value of its indexed getter/setter: whenever `value` is returned, the name/index is unsupported. Typically, `value` is either `undefined` or `null`.
This extended attribute can be applied to named or indexed getters or setters. It says that whether the interface supports a given property name/index can be automatically derived by looking at the return value of its indexed getter/setter: whenever `value` is returned, the name/index is unsupported. Typically, `value` is either `undefined` or `_null`.

@@ -403,0 +402,0 @@ In practice, this means that the implementation class only needs to implement a single method (the named/indexed getter method), and doesn't need to implement the `[idlUtils.supportsPropertyName]()` or `[idlUtils.supportsPropertyIndex]()` method separately.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc