Socket
Socket
Sign inDemoInstall

webidl2

Package Overview
Dependencies
Maintainers
4
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webidl2 - npm Package Compare versions

Comparing version 22.0.0 to 22.1.0

lib/productions/argument.js

2

dist/webidl2.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.WebIDL2=t():e.WebIDL2=t()}(this,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var s=t[r]={i:r,l:!1,exports:{}};return e[r].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)n.d(r,s,function(t){return e[t]}.bind(null,s));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";function r(e){return e.startsWith("_")?e.slice(1):e}function s(e,{parser:t,allowDangler:n,listName:r="list"}){const s=t(e);if(!s)return[];s.tokens.separator=e.consume(",");const a=[s];for(;s.tokens.separator;){const s=t(e);if(!s){n||e.error(`Trailing comma in ${r}`);break}if(s.tokens.separator=e.consume(","),a.push(s),!s.tokens.separator)break}return a}function a(e){return e.consume("true","false","Infinity","-Infinity","NaN","decimal","integer")}function i({type:e,value:t}){switch(e){case"true":case"false":return{type:"boolean",value:"true"===e};case"Infinity":case"-Infinity":return{type:"Infinity",negative:e.startsWith("-")};case"[":return{type:"sequence",value:[]};case"decimal":case"integer":return{type:"number",value:t};case"string":return{type:"string",value:t.slice(1,-1)};default:return{type:e}}}function o(e,t,n,r,s){function a(n){return n>0?e.slice(t,t+n):e.slice(Math.max(t+n,0),t)}function i(n,{precedes:r}={}){const s=n.map(e=>e.trivia+e.value).join(""),a=e[t];return"eof"===a.type?s:r?s+a.trivia:s.slice(a.trivia.length)}const o="eof"!==e[t].type?e[t].line:e.length>1?e[t-1].line:1,u=function(e){const t=e.split("\n");return t[t.length-1]}(i(a(-5),{precedes:!0})),c=a(5),l=i(c),p=u+l.split("\n")[0]+"\n"+(" ".repeat(u.length)+"^ "+r);return{message:`${s} error at line ${o}${n?`, ${"Syntax"===s?"since":"inside"} \`${n.partial?"partial ":""}${n.type} ${n.name}\``:""}:\n${p}`,line:o,input:l,tokens:c}}function u(e,t,n,r){return o(e,t.index,n,r,"Validation").message}n.r(t);const c={decimal:/-?(?=[0-9]*\.|[0-9]+[eE])(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][-+]?[0-9]+)?|[0-9]+[Ee][-+]?[0-9]+)/y,integer:/-?(0([Xx][0-9A-Fa-f]+|[0-7]*)|[1-9][0-9]*)/y,identifier:/[_-]?[A-Za-z][0-9A-Z_a-z-]*/y,string:/"[^"]*"/y,whitespace:/[\t\n\r ]+/y,comment:/((\/(\/.*|\*([^*]|\*[^\/])*\*\/)[\t\n\r ]*)+)/y,other:/[^\t\n\r 0-9A-Za-z]/y},l=["ByteString","DOMString","USVString"],p=["attribute","callback","const","deleter","dictionary","enum","getter","includes","inherit","interface","iterable","maplike","namespace","partial","required","setlike","setter","static","stringifier","typedef","unrestricted"],d=["-Infinity","FrozenArray","Infinity","NaN","Promise","boolean","byte","double","false","float","implements","legacyiterable","long","mixin","null","octet","optional","or","readonly","record","sequence","short","true","unsigned","void"].concat(p,l),f=["(",")",",","...",":",";","<","=",">","?","[","]","{","}"];class m{constructor(e){this.source=function(e){const t=[];let n=0,r="",s=1,a=0;for(;n<e.length;){const o=e.charAt(n);let u=-1;if(/[\t\n\r ]/.test(o)?u=i("whitespace",{noFlushTrivia:!0}):"/"===o&&(u=i("comment",{noFlushTrivia:!0})),-1!==u){const e=t.pop().value;s+=(e.match(/\n/g)||[]).length,r+=e,a-=1}else if(/[-0-9.A-Z_a-z]/.test(o)){if(-1===(u=i("decimal"))&&(u=i("integer")),-1===u){u=i("identifier");const e=t[t.length-1];-1!==u&&d.includes(e.value)&&(e.type=e.value)}}else'"'===o&&(u=i("string"));for(const i of f)if(e.startsWith(i,n)){t.push({type:i,value:i,trivia:r,line:s,index:a}),r="",u=n+=i.length;break}if(-1===u&&(u=i("other")),-1===u)throw new Error("Token stream not progressing");n=u,a+=1}return t.push({type:"eof",value:"",trivia:r}),t;function i(i,{noFlushTrivia:o}={}){const u=c[i];u.lastIndex=n;const l=u.exec(e);return l?(t.push({type:i,value:l[0],trivia:r,line:s,index:a}),o||(r=""),u.lastIndex):-1}}(e),this.position=0}error(e){throw new y(function(e,t,n,r){return o(e,t,n,r,"Syntax")}(this.source,this.position,this.current,e))}probe(e){return this.source.length>this.position&&this.source[this.position].type===e}consume(...e){for(const t of e){if(!this.probe(t))continue;const e=this.source[this.position];return this.position++,e}}unconsume(e){this.position=e}}class y extends Error{constructor({message:e,line:t,input:n,tokens:r}){super(e),this.name="WebIDLParseError",this.line=t,this.input=n,this.tokens=r}}class k extends Array{constructor({source:e,tokens:t}){super(),Object.defineProperties(this,{source:{value:e},tokens:{value:t}})}}class g{constructor({source:e,tokens:t}){Object.defineProperties(this,{source:{value:e},tokens:{value:t}})}toJSON(){const e={type:void 0,name:void 0,inheritance:void 0};let t=this;for(;t!==Object.prototype;){const n=Object.getOwnPropertyDescriptors(t);for(const[t,r]of Object.entries(n))(r.enumerable||r.get)&&(e[t]=this[t]);t=Object.getPrototypeOf(t)}return e}}class b extends g{static parser(e,t){return()=>{const n=e.consume(t);if(n)return new b({source:e.source,tokens:{value:n}})}}get value(){return this.tokens.value.value}}class h extends g{static parse(e){const t=e.consume("=");if(!t)return null;const n=a(e)||e.consume("string","null","[")||e.error("No value for default"),r=[n];if("["===n.type){const t=e.consume("]")||e.error("Default sequence value must be empty");r.push(t)}return new h({source:e.source,tokens:{assign:t},expression:r})}constructor({source:e,tokens:t,expression:n}){super({source:e,tokens:t}),Object.defineProperty(this,"expression",{value:n})}get type(){return i(this.expression[0]).type}get value(){return i(this.expression[0]).value}get negative(){return i(this.expression[0]).negative}}class v extends b{static parse(e){const t=e.consume("string");if(t)return new v({source:e.source,tokens:{value:t}})}get type(){return"enum-value"}get value(){return super.value.slice(1,-1)}}class x extends g{static parse(e){const t={};if(t.base=e.consume("enum"),!t.base)return;t.name=e.consume("identifier")||e.error("No name for enum");const n=e.current=new x({source:e.source,tokens:t});return t.open=e.consume("{")||e.error("Bodyless enum"),n.values=s(e,{parser:v.parse,allowDangler:!0,listName:"enumeration"}),e.probe("string")&&e.error("No comma between enum values"),t.close=e.consume("}")||e.error("Unexpected value in enum"),n.values.length||e.error("No value in enum"),t.termination=e.consume(";")||e.error("No semicolon after enum"),n}get type(){return"enum"}get name(){return r(this.tokens.name.value)}}class w extends g{static parse(e){const t=e.consume("identifier");if(!t)return;const n={target:t};if(n.includes=e.consume("includes"),n.includes)return n.mixin=e.consume("identifier")||e.error("Incomplete includes statement"),n.termination=e.consume(";")||e.error("No terminating ; for includes statement"),new w({source:e.source,tokens:n});e.unconsume(t.index)}get type(){return"includes"}get target(){return r(this.tokens.target.value)}get includes(){return r(this.tokens.mixin.value)}}function T(e,t){const n=e.source,o="decimal",u="integer",c="identifier",d="string";function f(t){e.error(t)}function m(t){return e.probe(t)}function y(...t){return e.consume(...t)}function v(t){return e.unconsume(t)}function T(){const e=function(){const e=y("unsigned"),t=y("short","long");if(t){const r=y("long");return new A({source:n,tokens:{prefix:e,base:t,postfix:r}})}e&&f("Failed to parse integer type")}()||function(){const e=y("unrestricted"),t=y("float","double");if(t)return new A({source:n,tokens:{prefix:e,base:t}});e&&f("Failed to parse float type")}();if(e)return e;const t=y("boolean","byte","octet");return t?new A({source:n,tokens:{base:t}}):void 0}function N(e){const t=y("?");t&&(e.tokens.nullable=t),m("?")&&f("Can't nullable more than once")}class A extends g{constructor({source:e,tokens:t}){super({source:e,tokens:t}),Object.defineProperty(this,"subtype",{value:[]}),this.extAttrs=[]}get generic(){return""}get nullable(){return!!this.tokens.nullable}get union(){return!1}get idlType(){if(this.subtype.length)return this.subtype;return r([this.tokens.prefix,this.tokens.base,this.tokens.postfix].filter(e=>e).map(e=>e.value).join(" "))}}class $ extends A{static parse(e){const t=y("FrozenArray","Promise","sequence","record");if(!t)return;const r=new $({source:n,tokens:{base:t}});switch(r.tokens.open=y("<")||f(`No opening bracket after ${t.type}`),t.type){case"Promise":{m("[")&&f("Promise type cannot have extended attribute");const t=D(e)||f("Missing Promise subtype");r.subtype.push(t);break}case"sequence":case"FrozenArray":{const n=O(e)||f(`Missing ${t.type} subtype`);r.subtype.push(n);break}case"record":{m("[")&&f("Record key cannot have extended attribute");const t=y(...l)||f(`Record key must be one of: ${l.join(", ")}`),s=new A({source:n,tokens:{base:t}});s.tokens.separator=y(",")||f("Missing comma after record key type"),s.type=e;const a=O(e)||f("Error parsing generic type record");r.subtype.push(s,a);break}}return r.idlType||f(`Error parsing generic type ${t.type}`),r.tokens.close=y(">")||f(`Missing closing bracket after ${t.type}`),r}get generic(){return this.tokens.base.value}}class j extends A{static parse(e){const t={};if(t.open=y("("),!t.open)return;const r=new j({source:n,tokens:t});for(r.type=e||null;;){const e=O()||f("No type after open parenthesis or 'or' in union type");"any"===e.idlType&&f("Type `any` cannot be included in a union type"),r.subtype.push(e);const t=y("or");if(!t)break;e.tokens.separator=t}return r.idlType.length<2&&f("At least two types are expected in a union type but found less"),t.close=y(")")||f("Unterminated union type"),N(r),r}get union(){return!0}}function M(e){return function(e){let t=$.parse(e)||T();if(!t){const e=y(c,...l);if(!e)return;t=new A({source:n,tokens:{base:e}}),m("<")&&f(`Unsupported generic type ${e.value}`)}return"Promise"===t.generic&&m("?")&&f("Promise type cannot be nullable"),t.type=e||null,N(t),t.nullable&&"any"===t.idlType&&f("Type `any` cannot be made nullable"),t}(e)||j.parse(e)}function O(e){const t=S.parse(),n=M(e);return n&&(n.extAttrs=t),n}class P extends g{static parse(){const t=e.position,r={},s=new P({source:n,tokens:r});return s.extAttrs=S.parse(),r.optional=y("optional"),s.idlType=O("argument-type"),s.idlType?(r.optional||(r.variadic=y("...")),r.name=y(c,...p),r.name?(s.default=r.optional?h.parse(e):null,s):v(t)):v(t)}get optional(){return!!this.tokens.optional}get variadic(){return!!this.tokens.variadic}get name(){return r(this.tokens.name.value)}}function I(){return s(e,{parser:P.parse,listName:"arguments list"})}class q extends g{static parse(){const t={assign:y("=")},r=new q({source:n,tokens:t});return t.assign&&(t.secondaryName=y(c,o,u,d)),t.open=y("("),t.open?(r.list="identifier-list"===r.rhsType?function(){const t=s(e,{parser:b.parser(e,c),listName:"identifier list"});return t.length||f("Expected identifiers but none found"),t}():I(),t.close=y(")")||f("Unexpected token in extended attribute argument list")):r.hasRhs&&!t.secondaryName&&f("No right hand side to extended attribute assignment"),r}get rhsType(){return this.tokens.assign?this.tokens.secondaryName?this.tokens.secondaryName.type:"identifier-list":null}}class U extends g{static parse(){const e=y(c);if(e)return new U({tokens:{name:e},params:q.parse()})}constructor({source:e,tokens:t,params:n}){super({source:e,tokens:t}),Object.defineProperty(this,"params",{value:n})}get type(){return"extended-attribute"}get name(){return this.tokens.name.value}get rhs(){const{rhsType:e,tokens:t,list:n}=this.params;return e?{type:e,value:"identifier-list"===e?n:t.secondaryName.value}:null}get arguments(){const{rhsType:e,list:t}=this.params;return t&&"identifier-list"!==e?t:[]}}class S extends k{static parse(){const t={};if(t.open=y("["),!t.open)return[];const r=new S({source:n,tokens:t});return r.push(...s(e,{parser:U.parse,listName:"extended attribute"})),t.close=y("]")||f("Unexpected form of extended attribute"),r.length||f("Found an empty extended attribute"),m("[")&&f("Illegal double extended attribute lists, consider merging them"),r}}class E extends g{static parse(){const t={};if(t.base=y("const"),!t.base)return;let r=T();if(!r){const e=y(c)||f("No type for const");r=new A({source:n,tokens:{base:e}})}m("?")&&f("Unexpected nullable constant type"),r.type="const-type",t.name=y(c)||f("No name for const"),t.assign=y("=")||f("No value assignment for const"),t.value=a(e)||f("No value for const"),t.termination=y(";")||f("Unterminated const");const s=new E({source:n,tokens:t});return s.idlType=r,s}get type(){return"const"}get name(){return r(this.tokens.name.value)}get value(){return i(this.tokens.value)}}class _ extends g{static parse(t){const r={base:t},s=new _({source:n,tokens:r});return r.name=y(c)||f("No name for callback"),e.current=s,r.assign=y("=")||f("No assignment in callback"),s.idlType=D()||f("Missing return type"),r.open=y("(")||f("No arguments in callback"),s.arguments=I(),r.close=y(")")||f("Unterminated callback"),r.termination=y(";")||f("Unterminated callback"),s}get type(){return"callback"}get name(){return r(this.tokens.name.value)}}class F extends g{static parse({special:t,noInherit:r=!1,readonly:s=!1}={}){const a=e.position,i={special:t},o=new F({source:n,tokens:i});if(t||r||(i.special=y("inherit")),"inherit"===o.special&&m("readonly")&&f("Inherited attributes cannot be read-only"),i.readonly=y("readonly"),s&&!i.readonly&&m("attribute")&&f("Attributes must be readonly in this context"),i.base=y("attribute"),i.base){switch(o.idlType=O("attribute-type")||f("No type in attribute"),o.idlType.generic){case"sequence":case"record":f(`Attributes cannot accept ${o.idlType.generic} types`)}return i.name=y(c,"required")||f("No name in attribute"),i.termination=y(";")||f("Unterminated attribute"),o}v(a)}get type(){return"attribute"}get special(){return this.tokens.special?this.tokens.special.value:""}get readonly(){return!!this.tokens.readonly}get name(){return r(this.tokens.name.value)}}function D(e){const t=M(e||"return-type");if(t)return t;const r=y("void");if(r){const e=new A({source:n,tokens:{base:r}});return e.type="return-type",e}}class z extends g{static parse({special:e,regular:t}={}){const r={special:e},s=new z({source:n,tokens:r});return e&&"stringifier"===e.value&&(r.termination=y(";"),r.termination)?(s.arguments=[],s):(e||t||(r.special=y("getter","setter","deleter")),s.idlType=D()||f("Missing return type"),r.name=y(c),r.open=y("(")||f("Invalid operation"),s.arguments=I(),r.close=y(")")||f("Unterminated operation"),r.termination=y(";")||f("Unterminated attribute"),s)}get type(){return"operation"}get name(){const{name:e}=this.tokens;return e?r(e.value):""}get special(){return this.tokens.special?this.tokens.special.value:""}}function W(){const e=y("static");if(e)return F.parse({special:e})||z.parse({special:e})||f("No body in static member")}function R(){const e=y("stringifier");if(e)return F.parse({special:e})||z.parse({special:e})||f("Unterminated stringifier")}class Z extends g{static parse(){const t=e.position,r={},s=new Z({source:n,tokens:r});if(r.readonly=y("readonly"),r.base=r.readonly?y("maplike","setlike"):y("iterable","maplike","setlike"),!r.base)return void v(t);const{type:a}=s,i="maplike"===a,o=i||"iterable"===a;r.open=y("<")||f(`Error parsing ${a} declaration`);const u=O()||f(`Error parsing ${a} declaration`);return s.idlType=[u],o&&(u.tokens.separator=y(","),u.tokens.separator?s.idlType.push(O()):i&&f(`Missing second type argument in ${a} declaration`)),r.close=y(">")||f(`Unterminated ${a} declaration`),r.termination=y(";")||f(`Missing semicolon after ${a} declaration`),s}get type(){return this.tokens.base.value}get readonly(){return!!this.tokens.readonly}}class B extends g{static parse(t,{type:n,inheritable:r,allowedMembers:s}){const{tokens:a}=t;for(a.name=y(c)||f("No name for interface"),e.current=t,r&&Object.assign(a,function(){const e=y(":");return e?{colon:e,inheritance:y(c)||f("No type in inheritance")}:{}}()),a.open=y("{")||f(`Bodyless ${n}`),t.members=[];;){if(a.close=y("}"),a.close)return a.termination=y(";")||f(`Missing semicolon after ${n}`),t;const e=S.parse();let r;for(const[e,...t]of s)if(r=e(...t))break;r||f("Unknown member"),r.extAttrs=e,t.members.push(r)}}get partial(){return!!this.tokens.partial}get name(){return r(this.tokens.name.value)}get inheritance(){return this.tokens.inheritance?r(this.tokens.inheritance.value):null}}class L extends B{static parse(e,{callback:t=null,partial:r=null}={}){const s={callback:t,partial:r,base:e};return B.parse(new L({source:n,tokens:s}),{type:"interface",inheritable:!r,allowedMembers:[[E.parse],[W],[R],[Z.parse],[F.parse],[z.parse]]})}get type(){return this.tokens.callback?"callback interface":"interface"}}class V extends B{static parse(e,{partial:t}={}){const r={partial:t,base:e};if(r.mixin=y("mixin"),r.mixin)return B.parse(new V({source:n,tokens:r}),{type:"interface mixin",allowedMembers:[[E.parse],[R],[F.parse,{noInherit:!0}],[z.parse,{regular:!0}]]})}get type(){return"interface mixin"}}function C(e){const t=y("interface");if(t)return V.parse(t,e)||L.parse(t,e)||f("Interface has no proper body")}class J extends B{static parse({partial:e}={}){const t={partial:e};if(t.base=y("namespace"),t.base)return B.parse(new J({source:n,tokens:t}),{type:"namespace",allowedMembers:[[F.parse,{noInherit:!0,readonly:!0}],[z.parse,{regular:!0}]]})}get type(){return"namespace"}}class X extends B{static parse({partial:e}={}){const t={partial:e};if(t.base=y("dictionary"),t.base)return B.parse(new X({source:n,tokens:t}),{type:"dictionary",inheritable:!e,allowedMembers:[[G.parse]]})}get type(){return"dictionary"}}class G extends g{static parse(){const t={},r=new G({source:n,tokens:t});return r.extAttrs=S.parse(),t.required=y("required"),r.idlType=O("dictionary-type")||f("No type for dictionary member"),t.name=y(c)||f("No name for dictionary member"),r.default=h.parse(e),t.required&&r.default&&f("Required member must not have a default"),t.termination=y(";")||f("Unterminated dictionary member"),r}get type(){return"field"}get name(){return r(this.tokens.name.value)}get required(){return!!this.tokens.required}}class H extends g{static parse(){const t={},r=new H({source:n,tokens:t});if(t.base=y("typedef"),t.base)return r.idlType=O("typedef-type")||f("No type in typedef"),t.name=y(c)||f("No name in typedef"),e.current=r,t.termination=y(";")||f("Unterminated typedef"),r}get type(){return"typedef"}get name(){return r(this.tokens.name.value)}}function K(){return function(){const e=y("callback");if(!e)return;const t=y("interface");return t?L.parse(t,{callback:e}):_.parse(e)}()||C()||function(){const e=y("partial");if(e)return X.parse({partial:e})||C({partial:e})||J.parse({partial:e})||f("Partial doesn't apply to anything")}()||X.parse()||x.parse(e)||H.parse()||w.parse(e)||J.parse()}const Q=function(){if(!n.length)return[];const e=[];for(;;){const t=S.parse(),n=K();if(!n){t.length&&f("Stray extended attributes");break}n.extAttrs=t,e.push(n)}const r=y("eof");return t.concrete&&e.push(r),e}();return e.position<n.length&&f("Unrecognised tokens"),Q}function N(e,t={}){return T(new m(e),t)}function A(e){return e}const $={wrap:e=>e.join(""),trivia:A,name:A,reference:A,type:A,generic:A,inheritance:A,definition:A,extendedAttribute:A,extendedAttributeReference:A};function j(e,{templates:t=$}={}){function n(e,{unescaped:n,context:r}){return n||(n=e.startsWith("_")?e.slice(1):e),t.reference(e,n,r)}function r(e,n=A,...r){if(!e)return"";const s=n(e.value,...r);return t.wrap([t.trivia(e.trivia),s])}function s(e,t){return r(e,n,{context:t})}function a(e,n){return r(e,t.name,n)}function i(e){if(e.union||e.generic)return t.wrap([r(e.tokens.base,t.generic),r(e.tokens.open),...e.subtype.map(o),r(e.tokens.close)]);const s=e.tokens.prefix||e.tokens.base,a=e.tokens.prefix?[e.tokens.prefix.value,t.trivia(e.tokens.base.trivia)]:[],i=n(t.wrap([...a,e.tokens.base.value,r(e.tokens.postfix)]),{unescaped:e.idlType,context:e});return t.wrap([t.trivia(s.trivia),i])}function o(e){return t.wrap([p(e.extAttrs),i(e),r(e.tokens.nullable),r(e.tokens.separator)])}function u(e){return e?t.wrap([r(e.tokens.assign),...e.expression.map(e=>r(e))]):""}function c(e){return t.wrap([p(e.extAttrs),r(e.tokens.optional),t.type(o(e.idlType)),r(e.tokens.variadic),a(e.tokens.name,{data:e}),u(e.default),r(e.tokens.separator)])}function l(e){const{rhsType:n}=e.params;return t.wrap([t.trivia(e.tokens.name.trivia),t.extendedAttribute(t.wrap([t.extendedAttributeReference(e.name),r(e.params.tokens.assign),s(e.params.tokens.secondaryName,e),r(e.params.tokens.open),...e.params.list?e.params.list.map("identifier-list"===n?n=>(function(e,n){return t.wrap([s(e.tokens.value,n),r(e.tokens.separator)])})(n,e):c):[],r(e.params.tokens.close)])),r(e.tokens.separator)])}function p(e){return e.length?t.wrap([r(e.tokens.open),...e.map(l),r(e.tokens.close)]):""}function d(e){return t.definition(t.wrap([p(e.extAttrs),r(e.tokens.callback),r(e.tokens.partial),r(e.tokens.base),r(e.tokens.mixin),a(e.tokens.name,{data:e}),(s=e,s.tokens.inheritance?t.wrap([r(s.tokens.colon),t.trivia(s.tokens.inheritance.trivia),t.inheritance(n(s.tokens.inheritance.value,{context:s}))]):""),r(e.tokens.open),y(e.members,e),r(e.tokens.close),r(e.tokens.termination)]),{data:e});var s}function f(e,n){return t.definition(t.wrap([p(e.extAttrs),r(e.tokens.readonly),r(e.tokens.base,t.generic),r(e.tokens.open),t.wrap(e.idlType.map(o)),r(e.tokens.close),r(e.tokens.termination)]),{data:e,parent:n})}t=Object.assign({},$,t);const m={interface:d,"interface mixin":d,namespace:d,operation:function(e,n){const s=e.idlType?[t.type(o(e.idlType)),a(e.tokens.name,{data:e,parent:n}),r(e.tokens.open),t.wrap(e.arguments.map(c)),r(e.tokens.close)]:[];return t.definition(t.wrap([p(e.extAttrs),r(e.tokens.special),...s,r(e.tokens.termination)]),{data:e,parent:n})},attribute:function(e,n){return t.definition(t.wrap([p(e.extAttrs),r(e.tokens.special),r(e.tokens.readonly),r(e.tokens.base),t.type(o(e.idlType)),a(e.tokens.name,{data:e,parent:n}),r(e.tokens.termination)]),{data:e,parent:n})},dictionary:d,field:function(e,n){return t.definition(t.wrap([p(e.extAttrs),r(e.tokens.required),t.type(o(e.idlType)),a(e.tokens.name,{data:e,parent:n}),u(e.default),r(e.tokens.termination)]),{data:e,parent:n})},const:function(e,n){return t.definition(t.wrap([p(e.extAttrs),r(e.tokens.base),t.type(o(e.idlType)),a(e.tokens.name,{data:e,parent:n}),r(e.tokens.assign),r(e.tokens.value),r(e.tokens.termination)]),{data:e,parent:n})},typedef:function(e){return t.definition(t.wrap([p(e.extAttrs),r(e.tokens.base),t.type(o(e.idlType)),a(e.tokens.name,{data:e}),r(e.tokens.termination)]),{data:e})},includes:function(e){return t.definition(t.wrap([p(e.extAttrs),s(e.tokens.target,e),r(e.tokens.includes),s(e.tokens.mixin,e),r(e.tokens.termination)]),{data:e})},callback:function(e){return t.definition(t.wrap([p(e.extAttrs),r(e.tokens.base),a(e.tokens.name,{data:e}),r(e.tokens.assign),t.type(o(e.idlType)),r(e.tokens.open),...e.arguments.map(c),r(e.tokens.close),r(e.tokens.termination)]),{data:e})},enum:function(e){return t.definition(t.wrap([p(e.extAttrs),r(e.tokens.base),a(e.tokens.name,{data:e}),r(e.tokens.open),y(e.values,e),r(e.tokens.close),r(e.tokens.termination)]),{data:e})},"enum-value":function(e,n){return t.wrap([t.trivia(e.tokens.value.trivia),t.definition(t.wrap(['"',t.name(e.value,{data:e,parent:n}),'"']),{data:e,parent:n}),r(e.tokens.separator)])},iterable:f,legacyiterable:f,maplike:f,setlike:f,"callback interface":d,eof:function(e){return t.trivia(e.trivia)}};function y(e,n){if(!e)return;const r=e.map(e=>(function(e,t){if(!m[e.type])throw new Error(`Type "${e.type}" is unsupported`);return m[e.type](e,t)})(e,n));return t.wrap(r)}return y(e)}function*M({unique:e,duplicates:t}){for(const n of t){const{name:t}=n,r=`The name "${t}" of type "${e.get(t).type}" was already seen`;yield u(n.source,n.tokens.name,n,r)}}function*O(e){const t=[...e.unique.values()].filter(e=>"interface"===e.type),n=function(){const t=new Map,n=e.all.filter(e=>"includes"===e.type);for(const r of n){const n=t.get(r.target),s=e.unique.get(r.includes);s&&(n?n.push(s):t.set(r.target,[s]))}return t}();for(const e of t)yield*r(e);function*r(t){const r=new Set(a(t).map(e=>e.name)),i=e.partials.get(t.name)||[],o=n.get(t.name)||[];for(const e of[...i,...o]){const n=a(e);yield*s(n,r,e,t);for(const e of n)r.add(e.name)}}function*s(e,t,n,r){for(const s of e){const{name:e}=s;if(e&&t.has(e)){const t=`The operation "${e}" has already been defined for the base interface "${r.name}" either in itself or in a mixin`;yield u(n.source,s.tokens.name,n,t)}}}function a(e){return e.members.filter(({type:e})=>"operation"===e)}}function P(e){const t=function(e){const t=new Map,n=new Set,r=new Map;for(const s of e)if(s.partial){const e=r.get(s.name);e?e.push(s):r.set(s.name,[s])}else s.name&&(t.has(s.name)?n.add(s):t.set(s.name,s));return{all:e,unique:t,partials:r,duplicates:n}}(e);return[...M(t),...O(t)]}n.d(t,"parse",function(){return N}),n.d(t,"write",function(){return j}),n.d(t,"validate",function(){return P})}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.WebIDL2=t():e.WebIDL2=t()}(this,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var s=t[r]={i:r,l:!1,exports:{}};return e[r].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)n.d(r,s,function(t){return e[t]}.bind(null,s));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);class r{constructor({source:e,tokens:t}){Object.defineProperties(this,{source:{value:e},tokens:{value:t}})}toJSON(){const e={type:void 0,name:void 0,inheritance:void 0};let t=this;for(;t!==Object.prototype;){const n=Object.getOwnPropertyDescriptors(t);for(const[t,r]of Object.entries(n))(r.enumerable||r.get)&&(e[t]=this[t]);t=Object.getPrototypeOf(t)}return e}}function s(e,t,n,r,s){function o(n){return n>0?e.slice(t,t+n):e.slice(Math.max(t+n,0),t)}function i(n,{precedes:r}={}){const s=n.map(e=>e.trivia+e.value).join(""),o=e[t];return"eof"===o.type?s:r?s+o.trivia:s.slice(o.trivia.length)}const a="eof"!==e[t].type?e[t].line:e.length>1?e[t-1].line:1,u=function(e){const t=e.split("\n");return t[t.length-1]}(i(o(-5),{precedes:!0})),c=o(5),p=i(c),l=u+p.split("\n")[0]+"\n"+(" ".repeat(u.length)+"^ "+r);return{message:`${s} error at line ${a}${n?`, ${"Syntax"===s?"since":"inside"} \`${n.partial?"partial ":""}${n.type} ${n.name}\``:""}:\n${l}`,line:a,input:p,tokens:c}}function o(e,t,n,r){return s(e,t.index,n,r,"Validation").message}const i={decimal:/-?(?=[0-9]*\.|[0-9]+[eE])(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][-+]?[0-9]+)?|[0-9]+[Ee][-+]?[0-9]+)/y,integer:/-?(0([Xx][0-9A-Fa-f]+|[0-7]*)|[1-9][0-9]*)/y,identifier:/[_-]?[A-Za-z][0-9A-Z_a-z-]*/y,string:/"[^"]*"/y,whitespace:/[\t\n\r ]+/y,comment:/((\/(\/.*|\*([^*]|\*[^\/])*\*\/)[\t\n\r ]*)+)/y,other:/[^\t\n\r 0-9A-Za-z]/y},a=["ByteString","DOMString","USVString"],u=["attribute","callback","const","deleter","dictionary","enum","getter","includes","inherit","interface","iterable","maplike","namespace","partial","required","setlike","setter","static","stringifier","typedef","unrestricted"],c=["-Infinity","FrozenArray","Infinity","NaN","Promise","boolean","byte","double","false","float","implements","legacyiterable","long","mixin","null","octet","optional","or","readonly","record","sequence","short","true","unsigned","void"].concat(u,a),p=["(",")",",","...",":",";","<","=",">","?","[","]","{","}"];class l{constructor(e){this.source=function(e){const t=[];let n=0,r="",s=1,o=0;for(;n<e.length;){const i=e.charAt(n);let u=-1;if(/[\t\n\r ]/.test(i)?u=a("whitespace",{noFlushTrivia:!0}):"/"===i&&(u=a("comment",{noFlushTrivia:!0})),-1!==u){const e=t.pop().value;s+=(e.match(/\n/g)||[]).length,r+=e,o-=1}else if(/[-0-9.A-Z_a-z]/.test(i)){if(-1===(u=a("decimal"))&&(u=a("integer")),-1===u){u=a("identifier");const e=t[t.length-1];-1!==u&&c.includes(e.value)&&(e.type=e.value)}}else'"'===i&&(u=a("string"));for(const i of p)if(e.startsWith(i,n)){t.push({type:i,value:i,trivia:r,line:s,index:o}),r="",u=n+=i.length;break}if(-1===u&&(u=a("other")),-1===u)throw new Error("Token stream not progressing");n=u,o+=1}return t.push({type:"eof",value:"",trivia:r}),t;function a(a,{noFlushTrivia:u}={}){const c=i[a];c.lastIndex=n;const p=c.exec(e);return p?(t.push({type:a,value:p[0],trivia:r,line:s,index:o}),u||(r=""),c.lastIndex):-1}}(e),this.position=0}error(e){throw new d(function(e,t,n,r){return s(e,t,n,r,"Syntax")}(this.source,this.position,this.current,e))}probe(e){return this.source.length>this.position&&this.source[this.position].type===e}consume(...e){for(const t of e){if(!this.probe(t))continue;const e=this.source[this.position];return this.position++,e}}unconsume(e){this.position=e}}class d extends Error{constructor({message:e,line:t,input:n,tokens:r}){super(e),this.name="WebIDLParseError",this.line=t,this.input=n,this.tokens=r}}function f(e,t){const n=e.consume("?");n&&(t.tokens.nullable=n),e.probe("?")&&e.error("Can't nullable more than once")}function m(e,t){let n=function(e,t){const n=e.consume("FrozenArray","Promise","sequence","record");if(!n)return;const r=new y({source:e.source,tokens:{base:n}});switch(r.tokens.open=e.consume("<")||e.error(`No opening bracket after ${n.type}`),n.type){case"Promise":{e.probe("[")&&e.error("Promise type cannot have extended attribute");const n=P(e,t)||e.error("Missing Promise subtype");r.subtype.push(n);break}case"sequence":case"FrozenArray":{const s=O(e,t)||e.error(`Missing ${n.type} subtype`);r.subtype.push(s);break}case"record":{e.probe("[")&&e.error("Record key cannot have extended attribute");const n=e.consume(...a)||e.error(`Record key must be one of: ${a.join(", ")}`),s=new y({source:e.source,tokens:{base:n}});s.tokens.separator=e.consume(",")||e.error("Missing comma after record key type"),s.type=t;const o=O(e,t)||e.error("Error parsing generic type record");r.subtype.push(s,o);break}}return r.idlType||e.error(`Error parsing generic type ${n.type}`),r.tokens.close=e.consume(">")||e.error(`Missing closing bracket after ${n.type}`),r}(e,t)||j(e);if(!n){const t=e.consume("identifier",...a);if(!t)return;n=new y({source:e.source,tokens:{base:t}}),e.probe("<")&&e.error(`Unsupported generic type ${t.value}`)}return"Promise"===n.generic&&e.probe("?")&&e.error("Promise type cannot be nullable"),n.type=t||null,f(e,n),n.nullable&&"any"===n.idlType&&e.error("Type `any` cannot be made nullable"),n}class y extends r{static parse(e,t){return m(e,t)||function(e,t){const n={};if(n.open=e.consume("("),!n.open)return;const r=new y({source:e.source,tokens:n});for(r.type=t||null;;){const t=O(e)||e.error("No type after open parenthesis or 'or' in union type");"any"===t.idlType&&e.error("Type `any` cannot be included in a union type"),r.subtype.push(t);const n=e.consume("or");if(!n)break;t.tokens.separator=n}return r.idlType.length<2&&e.error("At least two types are expected in a union type but found less"),n.close=e.consume(")")||e.error("Unterminated union type"),f(e,r),r}(e,t)}constructor({source:e,tokens:t}){super({source:e,tokens:t}),Object.defineProperty(this,"subtype",{value:[]}),this.extAttrs=[]}get generic(){return this.subtype.length&&this.tokens.base?this.tokens.base.value:""}get nullable(){return Boolean(this.tokens.nullable)}get union(){return Boolean(this.subtype.length)&&!this.tokens.base}get idlType(){if(this.subtype.length)return this.subtype;return T([this.tokens.prefix,this.tokens.base,this.tokens.postfix].filter(e=>e).map(e=>e.value).join(" "))}}class k extends r{static parse(e){const t=e.consume("=");if(!t)return null;const n=A(e)||e.consume("string","null","[","{")||e.error("No value for default"),r=[n];if("["===n.type){const t=e.consume("]")||e.error("Default sequence value must be empty");r.push(t)}else if("{"===n.type){const t=e.consume("}")||e.error("Default dictionary value must be empty");r.push(t)}return new k({source:e.source,tokens:{assign:t},expression:r})}constructor({source:e,tokens:t,expression:n}){super({source:e,tokens:t}),Object.defineProperty(this,"expression",{value:n})}get type(){return $(this.expression[0]).type}get value(){return $(this.expression[0]).value}get negative(){return $(this.expression[0]).negative}}class b extends Array{constructor({source:e,tokens:t}){super(),Object.defineProperties(this,{source:{value:e},tokens:{value:t}})}}class g extends r{static parse(e){const t={assign:e.consume("=")},n=new g({source:e.source,tokens:t});return t.assign&&(t.secondaryName=e.consume("identifier","decimal","integer","string")),t.open=e.consume("("),t.open?(n.list="identifier-list"===n.rhsType?function(e){const t=N(e,{parser:w.parser(e,"identifier"),listName:"identifier list"});t.length||e.error("Expected identifiers but none found");return t}(e):M(e),t.close=e.consume(")")||e.error("Unexpected token in extended attribute argument list")):n.hasRhs&&!t.secondaryName&&e.error("No right hand side to extended attribute assignment"),n}get rhsType(){return this.tokens.assign?this.tokens.secondaryName?this.tokens.secondaryName.type:"identifier-list":null}}class h extends r{static parse(e){const t=e.consume("identifier");if(t)return new h({tokens:{name:t},params:g.parse(e)})}constructor({source:e,tokens:t,params:n}){super({source:e,tokens:t}),Object.defineProperty(this,"params",{value:n})}get type(){return"extended-attribute"}get name(){return this.tokens.name.value}get rhs(){const{rhsType:e,tokens:t,list:n}=this.params;return e?{type:e,value:"identifier-list"===e?n:t.secondaryName.value}:null}get arguments(){const{rhsType:e,list:t}=this.params;return t&&"identifier-list"!==e?t:[]}}class v extends b{static parse(e){const t={};if(t.open=e.consume("["),!t.open)return[];const n=new v({source:e.source,tokens:t});return n.push(...N(e,{parser:h.parse,listName:"extended attribute"})),t.close=e.consume("]")||e.error("Unexpected closing token of extended attribute"),n.length||e.error("Found an empty extended attribute"),e.probe("[")&&e.error("Illegal double extended attribute lists, consider merging them"),n}}class x extends r{static parse(e){const t=e.position,n={},r=new x({source:e.source,tokens:n});return r.extAttrs=v.parse(e),n.optional=e.consume("optional"),r.idlType=O(e,"argument-type"),r.idlType?(n.optional||(n.variadic=e.consume("...")),n.name=e.consume("identifier",...u),n.name?(r.default=n.optional?k.parse(e):null,r):e.unconsume(t)):e.unconsume(t)}get optional(){return!!this.tokens.optional}get variadic(){return!!this.tokens.variadic}get name(){return T(this.tokens.name.value)}}class w extends r{static parser(e,t){return()=>{const n=e.consume(t);if(n)return new w({source:e.source,tokens:{value:n}})}}get value(){return this.tokens.value.value}}function T(e){return e.startsWith("_")?e.slice(1):e}function N(e,{parser:t,allowDangler:n,listName:r="list"}){const s=t(e);if(!s)return[];s.tokens.separator=e.consume(",");const o=[s];for(;s.tokens.separator;){const s=t(e);if(!s){n||e.error(`Trailing comma in ${r}`);break}if(s.tokens.separator=e.consume(","),o.push(s),!s.tokens.separator)break}return o}function A(e){return e.consume("true","false","Infinity","-Infinity","NaN","decimal","integer")}function $({type:e,value:t}){switch(e){case"true":case"false":return{type:"boolean",value:"true"===e};case"Infinity":case"-Infinity":return{type:"Infinity",negative:e.startsWith("-")};case"[":return{type:"sequence",value:[]};case"{":return{type:"dictionary"};case"decimal":case"integer":return{type:"number",value:t};case"string":return{type:"string",value:t.slice(1,-1)};default:return{type:e}}}function j(e){const{source:t}=e,n=function(){const n=e.consume("unsigned"),r=e.consume("short","long");if(r){const s=e.consume("long");return new y({source:t,tokens:{prefix:n,base:r,postfix:s}})}n&&e.error("Failed to parse integer type")}()||function(){const n=e.consume("unrestricted"),r=e.consume("float","double");if(r)return new y({source:t,tokens:{prefix:n,base:r}});n&&e.error("Failed to parse float type")}();if(n)return n;const r=e.consume("boolean","byte","octet");return r?new y({source:t,tokens:{base:r}}):void 0}function M(e){return N(e,{parser:x.parse,listName:"arguments list"})}function O(e,t){const n=v.parse(e),r=y.parse(e,t);return r&&(r.extAttrs=n),r}function P(e,t){const n=y.parse(e,t||"return-type");if(n)return n;const r=e.consume("void");if(r){const t=new y({source:e.source,tokens:{base:r}});return t.type="return-type",t}}class I extends w{static parse(e){const t=e.consume("string");if(t)return new I({source:e.source,tokens:{value:t}})}get type(){return"enum-value"}get value(){return super.value.slice(1,-1)}}class q extends r{static parse(e){const t={};if(t.base=e.consume("enum"),!t.base)return;t.name=e.consume("identifier")||e.error("No name for enum");const n=e.current=new q({source:e.source,tokens:t});return t.open=e.consume("{")||e.error("Bodyless enum"),n.values=N(e,{parser:I.parse,allowDangler:!0,listName:"enumeration"}),e.probe("string")&&e.error("No comma between enum values"),t.close=e.consume("}")||e.error("Unexpected value in enum"),n.values.length||e.error("No value in enum"),t.termination=e.consume(";")||e.error("No semicolon after enum"),n}get type(){return"enum"}get name(){return T(this.tokens.name.value)}}class U extends r{static parse(e){const t=e.consume("identifier");if(!t)return;const n={target:t};if(n.includes=e.consume("includes"),n.includes)return n.mixin=e.consume("identifier")||e.error("Incomplete includes statement"),n.termination=e.consume(";")||e.error("No terminating ; for includes statement"),new U({source:e.source,tokens:n});e.unconsume(t.index)}get type(){return"includes"}get target(){return T(this.tokens.target.value)}get includes(){return T(this.tokens.mixin.value)}}function S(e,t){const n=e.source,s="identifier";function o(t){e.error(t)}function i(t){return e.probe(t)}function a(...t){return e.consume(...t)}function u(t){return e.unconsume(t)}class c extends r{static parse(){const t={};if(t.base=a("const"),!t.base)return;let r=j(e);if(!r){const e=a(s)||o("No type for const");r=new y({source:n,tokens:{base:e}})}i("?")&&o("Unexpected nullable constant type"),r.type="const-type",t.name=a(s)||o("No name for const"),t.assign=a("=")||o("No value assignment for const"),t.value=A(e)||o("No value for const"),t.termination=a(";")||o("Unterminated const");const u=new c({source:n,tokens:t});return u.idlType=r,u}get type(){return"const"}get name(){return T(this.tokens.name.value)}get value(){return $(this.tokens.value)}}class p extends r{static parse(t){const r={base:t},i=new p({source:n,tokens:r});return r.name=a(s)||o("No name for callback"),e.current=i,r.assign=a("=")||o("No assignment in callback"),i.idlType=P(e)||o("Missing return type"),r.open=a("(")||o("No arguments in callback"),i.arguments=M(e),r.close=a(")")||o("Unterminated callback"),r.termination=a(";")||o("Unterminated callback"),i}get type(){return"callback"}get name(){return T(this.tokens.name.value)}}class l extends r{static parse({special:t,noInherit:r=!1,readonly:c=!1}={}){const p=e.position,d={special:t},f=new l({source:n,tokens:d});if(t||r||(d.special=a("inherit")),"inherit"===f.special&&i("readonly")&&o("Inherited attributes cannot be read-only"),d.readonly=a("readonly"),c&&!d.readonly&&i("attribute")&&o("Attributes must be readonly in this context"),d.base=a("attribute"),d.base){switch(f.idlType=O(e,"attribute-type")||o("No type in attribute"),f.idlType.generic){case"sequence":case"record":o(`Attributes cannot accept ${f.idlType.generic} types`)}return d.name=a(s,"required")||o("No name in attribute"),d.termination=a(";")||o("Unterminated attribute"),f}u(p)}get type(){return"attribute"}get special(){return this.tokens.special?this.tokens.special.value:""}get readonly(){return!!this.tokens.readonly}get name(){return T(this.tokens.name.value)}}class d extends r{static parse({special:t,regular:r}={}){const i={special:t},u=new d({source:n,tokens:i});return t&&"stringifier"===t.value&&(i.termination=a(";"),i.termination)?(u.arguments=[],u):(t||r||(i.special=a("getter","setter","deleter")),u.idlType=P(e)||o("Missing return type"),i.name=a(s),i.open=a("(")||o("Invalid operation"),u.arguments=M(e),i.close=a(")")||o("Unterminated operation"),i.termination=a(";")||o("Unterminated attribute"),u)}get type(){return"operation"}get name(){const{name:e}=this.tokens;return e?T(e.value):""}get special(){return this.tokens.special?this.tokens.special.value:""}}function f(){const e=a("static");if(e)return l.parse({special:e})||d.parse({special:e})||o("No body in static member")}function m(){const e=a("stringifier");if(e)return l.parse({special:e})||d.parse({special:e})||o("Unterminated stringifier")}class b extends r{static parse(){const t=e.position,r={},s=new b({source:n,tokens:r});if(r.readonly=a("readonly"),r.base=r.readonly?a("maplike","setlike"):a("iterable","maplike","setlike"),!r.base)return void u(t);const{type:i}=s,c="maplike"===i,p=c||"iterable"===i;r.open=a("<")||o(`Error parsing ${i} declaration`);const l=O(e)||o(`Error parsing ${i} declaration`);return s.idlType=[l],p&&(l.tokens.separator=a(","),l.tokens.separator?s.idlType.push(O(e)):c&&o(`Missing second type argument in ${i} declaration`)),r.close=a(">")||o(`Unterminated ${i} declaration`),r.termination=a(";")||o(`Missing semicolon after ${i} declaration`),s}get type(){return this.tokens.base.value}get readonly(){return!!this.tokens.readonly}}class g extends r{static parse(t,{type:n,inheritable:r,allowedMembers:i}){const{tokens:u}=t;for(u.name=a(s)||o("No name for interface"),e.current=t,r&&Object.assign(u,function(){const e=a(":");return e?{colon:e,inheritance:a(s)||o("No type in inheritance")}:{}}()),u.open=a("{")||o(`Bodyless ${n}`),t.members=[];;){if(u.close=a("}"),u.close)return u.termination=a(";")||o(`Missing semicolon after ${n}`),t;const r=v.parse(e);let s;for(const[e,...t]of i)if(s=e(...t))break;s||o("Unknown member"),s.extAttrs=r,t.members.push(s)}}get partial(){return!!this.tokens.partial}get name(){return T(this.tokens.name.value)}get inheritance(){return this.tokens.inheritance?T(this.tokens.inheritance.value):null}}class h extends g{static parse(e,{callback:t=null,partial:r=null}={}){const s={callback:t,partial:r,base:e};return g.parse(new h({source:n,tokens:s}),{type:"interface",inheritable:!r,allowedMembers:[[c.parse],[f],[m],[b.parse],[l.parse],[d.parse]]})}get type(){return this.tokens.callback?"callback interface":"interface"}}class x extends g{static parse(e,{partial:t}={}){const r={partial:t,base:e};if(r.mixin=a("mixin"),r.mixin)return g.parse(new x({source:n,tokens:r}),{type:"interface mixin",allowedMembers:[[c.parse],[m],[l.parse,{noInherit:!0}],[d.parse,{regular:!0}]]})}get type(){return"interface mixin"}}function w(e){const t=a("interface");if(t)return x.parse(t,e)||h.parse(t,e)||o("Interface has no proper body")}class N extends g{static parse({partial:e}={}){const t={partial:e};if(t.base=a("namespace"),t.base)return g.parse(new N({source:n,tokens:t}),{type:"namespace",allowedMembers:[[l.parse,{noInherit:!0,readonly:!0}],[d.parse,{regular:!0}]]})}get type(){return"namespace"}}class I extends g{static parse({partial:e}={}){const t={partial:e};if(t.base=a("dictionary"),t.base)return g.parse(new I({source:n,tokens:t}),{type:"dictionary",inheritable:!e,allowedMembers:[[S.parse]]})}get type(){return"dictionary"}}class S extends r{static parse(){const t={},r=new S({source:n,tokens:t});return r.extAttrs=v.parse(e),t.required=a("required"),r.idlType=O(e,"dictionary-type")||o("No type for dictionary member"),t.name=a(s)||o("No name for dictionary member"),r.default=k.parse(e),t.required&&r.default&&o("Required member must not have a default"),t.termination=a(";")||o("Unterminated dictionary member"),r}get type(){return"field"}get name(){return T(this.tokens.name.value)}get required(){return!!this.tokens.required}}class E extends r{static parse(){const t={},r=new E({source:n,tokens:t});if(t.base=a("typedef"),t.base)return r.idlType=O(e,"typedef-type")||o("No type in typedef"),t.name=a(s)||o("No name in typedef"),e.current=r,t.termination=a(";")||o("Unterminated typedef"),r}get type(){return"typedef"}get name(){return T(this.tokens.name.value)}}function _(){return function(){const e=a("callback");if(!e)return;const t=a("interface");return t?h.parse(t,{callback:e}):p.parse(e)}()||w()||function(){const e=a("partial");if(e)return I.parse({partial:e})||w({partial:e})||N.parse({partial:e})||o("Partial doesn't apply to anything")}()||I.parse()||q.parse(e)||E.parse()||U.parse(e)||N.parse()}const F=function(){if(!n.length)return[];const r=[];for(;;){const t=v.parse(e),n=_();if(!n){t.length&&o("Stray extended attributes");break}n.extAttrs=t,r.push(n)}const s=a("eof");return t.concrete&&r.push(s),r}();return e.position<n.length&&o("Unrecognised tokens"),F}function E(e,t={}){return S(new l(e),t)}function _(e){return e}const F={wrap:e=>e.join(""),trivia:_,name:_,reference:_,type:_,generic:_,inheritance:_,definition:_,extendedAttribute:_,extendedAttributeReference:_};function D(e,{templates:t=F}={}){function n(e,{unescaped:n,context:r}){return n||(n=e.startsWith("_")?e.slice(1):e),t.reference(e,n,r)}function r(e,n=_,...r){if(!e)return"";const s=n(e.value,...r);return t.wrap([t.trivia(e.trivia),s])}function s(e,t){return r(e,n,{context:t})}function o(e,n){return r(e,t.name,n)}function i(e){if(e.union||e.generic)return t.wrap([r(e.tokens.base,t.generic),r(e.tokens.open),...e.subtype.map(a),r(e.tokens.close)]);const s=e.tokens.prefix||e.tokens.base,o=e.tokens.prefix?[e.tokens.prefix.value,t.trivia(e.tokens.base.trivia)]:[],i=n(t.wrap([...o,e.tokens.base.value,r(e.tokens.postfix)]),{unescaped:e.idlType,context:e});return t.wrap([t.trivia(s.trivia),i])}function a(e){return t.wrap([l(e.extAttrs),i(e),r(e.tokens.nullable),r(e.tokens.separator)])}function u(e){return e?t.wrap([r(e.tokens.assign),...e.expression.map(e=>r(e))]):""}function c(e){return t.wrap([l(e.extAttrs),r(e.tokens.optional),t.type(a(e.idlType)),r(e.tokens.variadic),o(e.tokens.name,{data:e}),u(e.default),r(e.tokens.separator)])}function p(e){const{rhsType:n}=e.params;return t.wrap([t.trivia(e.tokens.name.trivia),t.extendedAttribute(t.wrap([t.extendedAttributeReference(e.name),r(e.params.tokens.assign),s(e.params.tokens.secondaryName,e),r(e.params.tokens.open),...e.params.list?e.params.list.map("identifier-list"===n?n=>(function(e,n){return t.wrap([s(e.tokens.value,n),r(e.tokens.separator)])})(n,e):c):[],r(e.params.tokens.close)])),r(e.tokens.separator)])}function l(e){return e.length?t.wrap([r(e.tokens.open),...e.map(p),r(e.tokens.close)]):""}function d(e){return t.definition(t.wrap([l(e.extAttrs),r(e.tokens.callback),r(e.tokens.partial),r(e.tokens.base),r(e.tokens.mixin),o(e.tokens.name,{data:e}),(s=e,s.tokens.inheritance?t.wrap([r(s.tokens.colon),t.trivia(s.tokens.inheritance.trivia),t.inheritance(n(s.tokens.inheritance.value,{context:s}))]):""),r(e.tokens.open),y(e.members,e),r(e.tokens.close),r(e.tokens.termination)]),{data:e});var s}function f(e,n){return t.definition(t.wrap([l(e.extAttrs),r(e.tokens.readonly),r(e.tokens.base,t.generic),r(e.tokens.open),t.wrap(e.idlType.map(a)),r(e.tokens.close),r(e.tokens.termination)]),{data:e,parent:n})}t=Object.assign({},F,t);const m={interface:d,"interface mixin":d,namespace:d,operation:function(e,n){const s=e.idlType?[t.type(a(e.idlType)),o(e.tokens.name,{data:e,parent:n}),r(e.tokens.open),t.wrap(e.arguments.map(c)),r(e.tokens.close)]:[];return t.definition(t.wrap([l(e.extAttrs),r(e.tokens.special),...s,r(e.tokens.termination)]),{data:e,parent:n})},attribute:function(e,n){return t.definition(t.wrap([l(e.extAttrs),r(e.tokens.special),r(e.tokens.readonly),r(e.tokens.base),t.type(a(e.idlType)),o(e.tokens.name,{data:e,parent:n}),r(e.tokens.termination)]),{data:e,parent:n})},dictionary:d,field:function(e,n){return t.definition(t.wrap([l(e.extAttrs),r(e.tokens.required),t.type(a(e.idlType)),o(e.tokens.name,{data:e,parent:n}),u(e.default),r(e.tokens.termination)]),{data:e,parent:n})},const:function(e,n){return t.definition(t.wrap([l(e.extAttrs),r(e.tokens.base),t.type(a(e.idlType)),o(e.tokens.name,{data:e,parent:n}),r(e.tokens.assign),r(e.tokens.value),r(e.tokens.termination)]),{data:e,parent:n})},typedef:function(e){return t.definition(t.wrap([l(e.extAttrs),r(e.tokens.base),t.type(a(e.idlType)),o(e.tokens.name,{data:e}),r(e.tokens.termination)]),{data:e})},includes:function(e){return t.definition(t.wrap([l(e.extAttrs),s(e.tokens.target,e),r(e.tokens.includes),s(e.tokens.mixin,e),r(e.tokens.termination)]),{data:e})},callback:function(e){return t.definition(t.wrap([l(e.extAttrs),r(e.tokens.base),o(e.tokens.name,{data:e}),r(e.tokens.assign),t.type(a(e.idlType)),r(e.tokens.open),...e.arguments.map(c),r(e.tokens.close),r(e.tokens.termination)]),{data:e})},enum:function(e){return t.definition(t.wrap([l(e.extAttrs),r(e.tokens.base),o(e.tokens.name,{data:e}),r(e.tokens.open),y(e.values,e),r(e.tokens.close),r(e.tokens.termination)]),{data:e})},"enum-value":function(e,n){return t.wrap([t.trivia(e.tokens.value.trivia),t.definition(t.wrap(['"',t.name(e.value,{data:e,parent:n}),'"']),{data:e,parent:n}),r(e.tokens.separator)])},iterable:f,legacyiterable:f,maplike:f,setlike:f,"callback interface":d,eof:function(e){return t.trivia(e.trivia)}};function y(e,n){if(!e)return;const r=e.map(e=>(function(e,t){if(!m[e.type])throw new Error(`Type "${e.type}" is unsupported`);return m[e.type](e,t)})(e,n));return t.wrap(r)}return y(e)}function*z({unique:e,duplicates:t}){for(const n of t){const{name:t}=n,r=`The name "${t}" of type "${e.get(t).type}" was already seen`;yield o(n.source,n.tokens.name,n,r)}}function*W(e){const t=[...e.unique.values()].filter(e=>"interface"===e.type),n=function(){const t=new Map,n=e.all.filter(e=>"includes"===e.type);for(const r of n){const n=t.get(r.target),s=e.unique.get(r.includes);s&&(n?n.push(s):t.set(r.target,[s]))}return t}();for(const e of t)yield*r(e);function*r(t){const r=new Set(i(t).map(e=>e.name)),o=e.partials.get(t.name)||[],a=n.get(t.name)||[];for(const e of[...o,...a]){const n=i(e);yield*s(n,r,e,t);for(const e of n)r.add(e.name)}}function*s(e,t,n,r){for(const s of e){const{name:e}=s;if(e&&t.has(e)){const t=`The operation "${e}" has already been defined for the base interface "${r.name}" either in itself or in a mixin`;yield o(n.source,s.tokens.name,n,t)}}}function i(e){return e.members.filter(({type:e})=>"operation"===e)}}function R(e){const t=function(e){const t=new Map,n=new Set,r=new Map;for(const s of e)if(s.partial){const e=r.get(s.name);e?e.push(s):r.set(s.name,[s])}else s.name&&(t.has(s.name)?n.add(s):t.set(s.name,s));return{all:e,unique:t,partials:r,duplicates:n}}(e);return[...z(t),...W(t)]}n.d(t,"parse",function(){return E}),n.d(t,"write",function(){return D}),n.d(t,"validate",function(){return R})}])});
//# sourceMappingURL=webidl2.js.map

@@ -13,3 +13,3 @@ import { Base } from "./base.js";

}
const def = const_value(tokeniser) || tokeniser.consume("string", "null", "[") || tokeniser.error("No value for default");
const def = const_value(tokeniser) || tokeniser.consume("string", "null", "[", "{") || tokeniser.error("No value for default");
const expression = [def];

@@ -19,2 +19,5 @@ if (def.type === "[") {

expression.push(close);
} else if (def.type === "{") {
const close = tokeniser.consume("}") || tokeniser.error("Default dictionary value must be empty");
expression.push(close);
}

@@ -21,0 +24,0 @@ return new Default({ source: tokeniser.source, tokens: { assign }, expression });

@@ -0,1 +1,6 @@

import { Type } from "./type.js";
import { Argument } from "./argument.js";
import { Token } from "./token.js";
import { ExtendedAttributes } from "./extended-attributes.js";
/**

@@ -60,5 +65,7 @@ * @param {string} identifier

return { type: "sequence", value: [] };
case "{":
return { type: "dictionary" };
case "decimal":
case "integer":
return { type: "number", value };
return { type: "number", value };
case "string":

@@ -70,1 +77,79 @@ return { type: "string", value: value.slice(1, -1) };

}
/**
* @param {import("../tokeniser").Tokeniser} tokeniser
*/
export function primitive_type(tokeniser) {
function integer_type() {
const prefix = tokeniser.consume("unsigned");
const base = tokeniser.consume("short", "long");
if (base) {
const postfix = tokeniser.consume("long");
return new Type({ source, tokens: { prefix, base, postfix } });
}
if (prefix) tokeniser.error("Failed to parse integer type");
}
function decimal_type() {
const prefix = tokeniser.consume("unrestricted");
const base = tokeniser.consume("float", "double");
if (base) {
return new Type({ source, tokens: { prefix, base } });
}
if (prefix) tokeniser.error("Failed to parse float type");
}
const { source } = tokeniser;
const num_type = integer_type(tokeniser) || decimal_type(tokeniser);
if (num_type) return num_type;
const base = tokeniser.consume("boolean", "byte", "octet");
if (base) {
return new Type({ source, tokens: { base } });
}
}
/**
* @param {import("../tokeniser").Tokeniser} tokeniser
*/
export function identifiers(tokeniser) {
const ids = list(tokeniser, { parser: Token.parser(tokeniser, "identifier"), listName: "identifier list" });
if (!ids.length) {
tokeniser.error("Expected identifiers but none found");
}
return ids;
}
/**
* @param {import("../tokeniser").Tokeniser} tokeniser
*/
export function argument_list(tokeniser) {
return list(tokeniser, { parser: Argument.parse, listName: "arguments list" });
}
/**
* @param {import("../tokeniser").Tokeniser} tokeniser
* @param {string} typeName
*/
export function type_with_extended_attributes(tokeniser, typeName) {
const extAttrs = ExtendedAttributes.parse(tokeniser);
const ret = Type.parse(tokeniser, typeName);
if (ret) ret.extAttrs = extAttrs;
return ret;
}
/**
* @param {import("../tokeniser").Tokeniser} tokeniser
* @param {string} typeName
*/
export function return_type(tokeniser, typeName) {
const typ = Type.parse(tokeniser, typeName || "return-type");
if (typ) {
return typ;
}
const voidToken = tokeniser.consume("void");
if (voidToken) {
const ret = new Type({ source: tokeniser.source, tokens: { base: voidToken } });
ret.type = "return-type";
return ret;
}
}
"use strict";
import { const_data, const_value, list, unescape } from "./productions/helpers.js";
import { argumentNameKeywords, stringTypes, Tokeniser } from "./tokeniser.js";
import { ArrayBase } from "./productions/array-base.js";
import { const_data, const_value, unescape, primitive_type, argument_list, type_with_extended_attributes, return_type } from "./productions/helpers.js";
import { Tokeniser } from "./tokeniser.js";
import { Base } from "./productions/base.js";
import { Token } from "./productions/token.js";
import { Default } from "./productions/default.js";
import { Enum } from "./productions/enum.js";
import { Includes } from "./productions/includes.js";
import { Type } from "./productions/type.js";
import { ExtendedAttributes } from "./productions/extended-attributes.js";

@@ -20,6 +20,3 @@ /**

const DECIMAL = "decimal";
const INT = "integer";
const ID = "identifier";
const STR = "string";

@@ -42,305 +39,2 @@ function error(str) {

function integer_type() {
const prefix = consume("unsigned");
const base = consume("short", "long");
if (base) {
const postfix = consume("long");
return new Type({ source, tokens: { prefix, base, postfix } });
}
if (prefix) error("Failed to parse integer type");
}
function float_type() {
const prefix = consume("unrestricted");
const base = consume("float", "double");
if (base) {
return new Type({ source, tokens: { prefix, base } });
}
if (prefix) error("Failed to parse float type");
}
function primitive_type() {
const num_type = integer_type() || float_type();
if (num_type) return num_type;
const base = consume("boolean", "byte", "octet");
if (base) {
return new Type({ source, tokens: { base } });
}
}
function type_suffix(obj) {
const nullable = consume("?");
if (nullable) {
obj.tokens.nullable = nullable;
}
if (probe("?")) error("Can't nullable more than once");
}
class Type extends Base {
constructor({ source, tokens }) {
super({ source, tokens });
Object.defineProperty(this, "subtype", { value: [] });
this.extAttrs = [];
}
get generic() {
return "";
}
get nullable() {
return !!this.tokens.nullable;
}
get union() {
return false;
}
get idlType() {
if (this.subtype.length) {
return this.subtype;
}
// Adding prefixes/postfixes for "unrestricted float", etc.
const name = [
this.tokens.prefix,
this.tokens.base,
this.tokens.postfix
].filter(t => t).map(t => t.value).join(" ");
return unescape(name);
}
}
class GenericType extends Type {
static parse(typeName) {
const base = consume("FrozenArray", "Promise", "sequence", "record");
if (!base) {
return;
}
const ret = new GenericType({ source, tokens: { base } });
ret.tokens.open = consume("<") || error(`No opening bracket after ${base.type}`);
switch (base.type) {
case "Promise": {
if (probe("[")) error("Promise type cannot have extended attribute");
const subtype = return_type(typeName) || error("Missing Promise subtype");
ret.subtype.push(subtype);
break;
}
case "sequence":
case "FrozenArray": {
const subtype = type_with_extended_attributes(typeName) || error(`Missing ${base.type} subtype`);
ret.subtype.push(subtype);
break;
}
case "record": {
if (probe("[")) error("Record key cannot have extended attribute");
const keyType = consume(...stringTypes) || error(`Record key must be one of: ${stringTypes.join(", ")}`);
const keyIdlType = new Type({ source, tokens: { base: keyType }});
keyIdlType.tokens.separator = consume(",") || error("Missing comma after record key type");
keyIdlType.type = typeName;
const valueType = type_with_extended_attributes(typeName) || error("Error parsing generic type record");
ret.subtype.push(keyIdlType, valueType);
break;
}
}
if (!ret.idlType) error(`Error parsing generic type ${base.type}`);
ret.tokens.close = consume(">") || error(`Missing closing bracket after ${base.type}`);
return ret;
}
get generic() {
return this.tokens.base.value;
}
}
function single_type(typeName) {
let ret = GenericType.parse(typeName) || primitive_type();
if (!ret) {
const base = consume(ID, ...stringTypes);
if (!base) {
return;
}
ret = new Type({ source, tokens: { base } });
if (probe("<")) error(`Unsupported generic type ${base.value}`);
}
if (ret.generic === "Promise" && probe("?")) {
error("Promise type cannot be nullable");
}
ret.type = typeName || null;
type_suffix(ret);
if (ret.nullable && ret.idlType === "any") error("Type `any` cannot be made nullable");
return ret;
}
class UnionType extends Type {
static parse(type) {
const tokens = {};
tokens.open = consume("(");
if (!tokens.open) return;
const ret = new UnionType({ source, tokens });
ret.type = type || null;
while (true) {
const typ = type_with_extended_attributes() || error("No type after open parenthesis or 'or' in union type");
if (typ.idlType === "any") error("Type `any` cannot be included in a union type");
ret.subtype.push(typ);
const or = consume("or");
if (or) {
typ.tokens.separator = or;
}
else break;
}
if (ret.idlType.length < 2) {
error("At least two types are expected in a union type but found less");
}
tokens.close = consume(")") || error("Unterminated union type");
type_suffix(ret);
return ret;
}
get union() {
return true;
}
}
function type(typeName) {
return single_type(typeName) || UnionType.parse(typeName);
}
function type_with_extended_attributes(typeName) {
const extAttrs = ExtendedAttributes.parse();
const ret = type(typeName);
if (ret) ret.extAttrs = extAttrs;
return ret;
}
class Argument extends Base {
static parse() {
const start_position = tokeniser.position;
const tokens = {};
const ret = new Argument({ source, tokens });
ret.extAttrs = ExtendedAttributes.parse();
tokens.optional = consume("optional");
ret.idlType = type_with_extended_attributes("argument-type");
if (!ret.idlType) {
return unconsume(start_position);
}
if (!tokens.optional) {
tokens.variadic = consume("...");
}
tokens.name = consume(ID, ...argumentNameKeywords);
if (!tokens.name) {
return unconsume(start_position);
}
ret.default = tokens.optional ? Default.parse(tokeniser) : null;
return ret;
}
get optional() {
return !!this.tokens.optional;
}
get variadic() {
return !!this.tokens.variadic;
}
get name() {
return unescape(this.tokens.name.value);
}
}
function argument_list() {
return list(tokeniser, { parser: Argument.parse, listName: "arguments list" });
}
function identifiers() {
const ids = list(tokeniser, { parser: Token.parser(tokeniser, ID), listName: "identifier list" });
if (!ids.length) {
error("Expected identifiers but none found");
}
return ids;
}
class ExtendedAttributeParameters extends Base {
static parse() {
const tokens = { assign: consume("=") };
const ret = new ExtendedAttributeParameters({ source, tokens });
if (tokens.assign) {
tokens.secondaryName = consume(ID, DECIMAL, INT, STR);
}
tokens.open = consume("(");
if (tokens.open) {
ret.list = ret.rhsType === "identifier-list" ?
// [Exposed=(Window,Worker)]
identifiers() :
// [NamedConstructor=Audio(DOMString src)] or [Constructor(DOMString str)]
argument_list();
tokens.close = consume(")") || error("Unexpected token in extended attribute argument list");
} else if (ret.hasRhs && !tokens.secondaryName) {
error("No right hand side to extended attribute assignment");
}
return ret;
}
get rhsType() {
return !this.tokens.assign ? null :
!this.tokens.secondaryName ? "identifier-list" :
this.tokens.secondaryName.type;
}
}
class SimpleExtendedAttribute extends Base {
static parse() {
const name = consume(ID);
if (name) {
return new SimpleExtendedAttribute({
tokens: { name },
params: ExtendedAttributeParameters.parse()
});
}
}
constructor({ source, tokens, params }) {
super({ source, tokens });
Object.defineProperty(this, "params", { value: params });
}
get type() {
return "extended-attribute";
}
get name() {
return this.tokens.name.value;
}
get rhs() {
const { rhsType: type, tokens, list } = this.params;
if (!type) {
return null;
}
const value = type === "identifier-list" ? list : tokens.secondaryName.value;
return { type, value };
}
get arguments() {
const { rhsType, list } = this.params;
if (!list || rhsType === "identifier-list") {
return [];
}
return list;
}
}
// Note: we parse something simpler than the official syntax. It's all that ever
// seems to be used
class ExtendedAttributes extends ArrayBase {
static parse() {
const tokens = {};
tokens.open = consume("[");
if (!tokens.open) return [];
const ret = new ExtendedAttributes({ source, tokens });
ret.push(...list(tokeniser, {
parser: SimpleExtendedAttribute.parse,
listName: "extended attribute"
}));
tokens.close = consume("]") || error("Unexpected form of extended attribute");
if (!ret.length) {
error("Found an empty extended attribute");
}
if (probe("[")) {
error("Illegal double extended attribute lists, consider merging them");
}
return ret;
}
}
class Constant extends Base {

@@ -353,3 +47,3 @@ static parse() {

}
let idlType = primitive_type();
let idlType = primitive_type(tokeniser);
if (!idlType) {

@@ -390,5 +84,5 @@ const base = consume(ID) || error("No type for const");

tokens.assign = consume("=") || error("No assignment in callback");
ret.idlType = return_type() || error("Missing return type");
ret.idlType = return_type(tokeniser) || error("Missing return type");
tokens.open = consume("(") || error("No arguments in callback");
ret.arguments = argument_list();
ret.arguments = argument_list(tokeniser);
tokens.close = consume(")") || error("Unterminated callback");

@@ -437,3 +131,3 @@ tokens.termination = consume(";") || error("Unterminated callback");

}
ret.idlType = type_with_extended_attributes("attribute-type") || error("No type in attribute");
ret.idlType = type_with_extended_attributes(tokeniser, "attribute-type") || error("No type in attribute");
switch (ret.idlType.generic) {

@@ -465,15 +159,2 @@ case "sequence":

function return_type(typeName) {
const typ = type(typeName || "return-type");
if (typ) {
return typ;
}
const voidToken = consume("void");
if (voidToken) {
const ret = new Type({ source, tokens: { base: voidToken } });
ret.type = "return-type";
return ret;
}
}
class Operation extends Base {

@@ -493,6 +174,6 @@ static parse({ special, regular } = {}) {

}
ret.idlType = return_type() || error("Missing return type");
ret.idlType = return_type(tokeniser) || error("Missing return type");
tokens.name = consume(ID);
tokens.open = consume("(") || error("Invalid operation");
ret.arguments = argument_list();
ret.arguments = argument_list(tokeniser);
tokens.close = consume(")") || error("Unterminated operation");

@@ -558,3 +239,3 @@ tokens.termination = consume(";") || error("Unterminated attribute");

tokens.open = consume("<") || error(`Error parsing ${type} declaration`);
const first = type_with_extended_attributes() || error(`Error parsing ${type} declaration`);
const first = type_with_extended_attributes(tokeniser) || error(`Error parsing ${type} declaration`);
ret.idlType = [first];

@@ -564,3 +245,3 @@ if (secondTypeAllowed) {

if (first.tokens.separator) {
ret.idlType.push(type_with_extended_attributes());
ret.idlType.push(type_with_extended_attributes(tokeniser));
}

@@ -609,3 +290,3 @@ else if (secondTypeRequired)

}
const ea = ExtendedAttributes.parse();
const ea = ExtendedAttributes.parse(tokeniser);
let mem;

@@ -752,5 +433,5 @@ for (const [parser, ...args] of allowedMembers) {

const ret = new Field({ source, tokens });
ret.extAttrs = ExtendedAttributes.parse();
ret.extAttrs = ExtendedAttributes.parse(tokeniser);
tokens.required = consume("required");
ret.idlType = type_with_extended_attributes("dictionary-type") || error("No type for dictionary member");
ret.idlType = type_with_extended_attributes(tokeniser, "dictionary-type") || error("No type for dictionary member");
tokens.name = consume(ID) || error("No name for dictionary member");

@@ -782,3 +463,3 @@ ret.default = Default.parse(tokeniser);

}
ret.idlType = type_with_extended_attributes("typedef-type") || error("No type in typedef");
ret.idlType = type_with_extended_attributes(tokeniser, "typedef-type") || error("No type in typedef");
tokens.name = consume(ID) || error("No name in typedef");

@@ -813,3 +494,3 @@ tokeniser.current = ret;

while (true) {
const ea = ExtendedAttributes.parse();
const ea = ExtendedAttributes.parse(tokeniser);
const def = definition();

@@ -816,0 +497,0 @@ if (!def) {

{
"name": "webidl2",
"description": "A WebIDL Parser",
"version": "22.0.0",
"version": "22.1.0",
"contributors": [

@@ -14,8 +14,8 @@ "Robin Berjon <robin@berjon.com> (https://berjon.com)",

"devDependencies": {
"eslint": "^5.9.0",
"expect": "23.6.0",
"eslint": "^5.16.0",
"expect": "^24.8.0",
"jsondiffpatch": "0.3.11",
"mocha": "5.2.0",
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0"
"webpack": "^4.33.0",
"webpack-cli": "^3.3.2"
},

@@ -22,0 +22,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

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