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.1.2 to 9.2.0

lib/constructs/interface-mixin.js

47

lib/constructs/interface.js

@@ -77,3 +77,4 @@ "use strict";

this.requires = new utils.RequiresMap(ctx);
this.mixins = [];
this.implemented = [];
this.included = [];

@@ -390,8 +391,20 @@ this.operations = new Map();

}
throw new Error(`${source} interface not found (used as a mixin for ${this.name})`);
throw new Error(`${source} interface not found (implemented by ${this.name})`);
}
this.mixins.push(source);
this.implemented.push(source);
}
includes(source) {
const mixin = this.ctx.interfaceMixins.get(source);
if (!mixin) {
if (this.ctx.options.suppressErrors) {
return;
}
throw new Error(`${source} interface mixin not found (included in ${this.name})`);
}
this.included.push(source);
}
generateIterator() {

@@ -444,8 +457,8 @@ if (this.iterable && this.iterable.isPair) {

* consequentialInterfaces(seen = new Set([this.name]), root = this.name) {
for (const mixin of this.mixins) {
if (seen.has(mixin)) {
for (const iface of this.implemented) {
if (seen.has(iface)) {
throw new Error(`${root} has a dependency cycle`);
}
seen.add(mixin);
yield* this.ctx.interfaces.get(mixin).allInterfaces(seen);
seen.add(iface);
yield* this.ctx.interfaces.get(iface).allInterfaces(seen);
}

@@ -471,5 +484,8 @@ }

yield* this.idl.members;
for (const mixin of this.consequentialInterfaces(seen, root)) {
yield* this.ctx.interfaces.get(mixin).idl.members;
for (const mixin of this.included) {
yield* this.ctx.interfaceMixins.get(mixin).idl.members;
}
for (const iface of this.consequentialInterfaces(seen, root)) {
yield* this.ctx.interfaces.get(iface).idl.members;
}
}

@@ -489,2 +505,5 @@

* allMembers(seen = new Set([this.name]), root = this.name) {
for (const mixin of this.included) {
yield* this.ctx.interfaceMixins.get(mixin).idl.members;
}
for (const iface of this.allInterfaces(seen, root)) {

@@ -502,4 +521,4 @@ yield* this.ctx.interfaces.get(iface).idl.members;

for (const mixin of this.consequentialInterfaces()) {
this.requires.add(mixin);
for (const iface of this.consequentialInterfaces()) {
this.requires.add(iface);
}

@@ -515,5 +534,5 @@

generateMixins() {
for (const mixin of this.consequentialInterfaces()) {
for (const iface of this.consequentialInterfaces()) {
this.str += `
${mixin}._mixedIntoPredicates.push(module.exports.is);
${iface}._mixedIntoPredicates.push(module.exports.is);
`;

@@ -1242,3 +1261,3 @@ }

const unscopables = Object.create(null);
for (const member of this.idl.members) {
for (const member of this.members()) {
if (utils.getExtAttr(member.extAttrs, "Unscopable")) {

@@ -1245,0 +1264,0 @@ unscopables[member.name] = true;

@@ -31,7 +31,6 @@ "use strict";

for (const arg of idl.arguments) {
if (arg.extAttrs) {
if (!arg.idlType.extAttrs) {
arg.idlType.extAttrs = [];
}
arg.idlType.extAttrs.push(...arg.extAttrs);
if (arg.extAttrs.length) {
// Overwrite rather than push to workaround old webidl2 array-sharing bug
// It's safe as the two cannot coexist.
arg.idlType.extAttrs = [...arg.extAttrs];
}

@@ -38,0 +37,0 @@ }

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

this.interfaces = new Map();
this.interfaceMixins = new Map();
this.dictionaries = new Map();

@@ -25,0 +26,0 @@ this.enumerations = new Map();

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

const Interface = require("./constructs/interface");
const InterfaceMixin = require("./constructs/interface-mixin");
const Dictionary = require("./constructs/dictionary");

@@ -84,3 +85,3 @@ const Enumeration = require("./constructs/enumeration");

this.ctx.initialize();
const { interfaces, dictionaries, enumerations, typedefs } = this.ctx;
const { interfaces, interfaceMixins, dictionaries, enumerations, typedefs } = this.ctx;

@@ -102,3 +103,12 @@ // first we're gathering all full interfaces and ignore partial ones

break;
case "interface mixin":
if (instruction.partial) {
break;
}
obj = new InterfaceMixin(this.ctx, instruction);
interfaceMixins.set(obj.name, obj);
break;
case "implements":
case "includes":
break; // handled later

@@ -129,3 +139,3 @@ case "dictionary":

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

@@ -149,2 +159,15 @@ for (const instruction of file.idl) {

break;
case "interface mixin":
if (!instruction.partial) {
break;
}
if (this.ctx.options.suppressErrors && !interfaceMixins.has(instruction.name)) {
break;
}
oldMembers = interfaceMixins.get(instruction.name).idl.members;
oldMembers.push(...instruction.members);
extAttrs = interfaceMixins.get(instruction.name).idl.extAttrs;
extAttrs.push(...instruction.extAttrs);
break;
case "dictionary":

@@ -168,2 +191,8 @@ if (!instruction.partial) {

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

@@ -170,0 +199,0 @@ }

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

@@ -12,3 +12,3 @@ "main": "lib/transformer.js",

"webidl-conversions": "^4.0.0",
"webidl2": "^9.0.0"
"webidl2": "^10.3.3"
},

@@ -15,0 +15,0 @@ "devDependencies": {

@@ -342,4 +342,5 @@ # JavaScript bindings generator for Web IDL

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

@@ -346,0 +347,0 @@ - Variadic arguments

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