Comparing version 9.0.1 to 9.1.0
@@ -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; |
@@ -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.0.1", | ||
"version": "9.1.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.1" | ||
}, | ||
@@ -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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
140801
20
3391
403
1
+ Addedwebidl2@10.3.3(transitive)
- Removedwebidl2@9.0.0(transitive)
Updatedwebidl2@^10.3.1