Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typal

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typal - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

5

CHANGELOG.md
## 21 April 2020
### [2.0.3](https://gitlab.com/artdeco/typal/compare/v2.0.2...v2.0.3)
- [feature] Automatically add suppresses for Luxes.
- [fix] Fix `constructor` method when extending without props.
### [2.0.2](https://gitlab.com/artdeco/typal/compare/v2.0.1...v2.0.2)

@@ -4,0 +9,0 @@

45

compile/bin/typal.js

@@ -10,4 +10,4 @@ #!/usr/bin/env node

boolean:!0,short:"u"},externs:{description:"Whether to generate externs for _GCC_.",boolean:!0,short:"e"},types:{description:"Comma-separated location of files to read types from.",short:"t"},template:{description:"Scans the input file for `@type` comment in functions' JSDoc, and inserts the annotations from types' files.",short:"T"},migrate:{description:"Extracts types from JavaScript source code and saves them\ninto the types.xml file specified in the output option.",boolean:!0,short:"m"},help:{description:"Print the help information and exit.",
boolean:!0,short:"h"},version:{description:"Show the version's number and exit.",boolean:!0,short:"v"}},r=function(a={},b=process.argv){let [,,...c]=b;const d=fa(c);c=c.slice(d.length);a=Object.entries(a).reduce((f,[h,k])=>{f[h]="string"==typeof k?{short:k}:k;return f},{});const e=[];a=Object.entries(a).reduce((f,[h,k])=>{let l;try{const m=k.short,n=k.boolean,p=k.number,q=k.command,t=k.multiple;if(q&&t&&d.length)l=d;else if(q&&d.length)l=d[0];else{const u=ea(c,h,m,n,p);({value:l}=u);const v=u.index,
w=u.length;void 0!==v&&w&&e.push({index:v,length:w})}}catch(m){return f}return void 0===l?f:{...f,[h]:l}},{});let g=c;e.forEach(({index:f,length:h})=>{Array.from({length:h}).forEach((k,l)=>{g[f+l]=null})});g=g.filter(f=>null!==f);Object.assign(a,{$:g});return a}(ha),x=r.source,ja=r.output,ka=r.closure,la=r.useNamespace,ma=r.externs,na=r.types,oa=r.template,pa=r.migrate,qa=r.version;function ra(a={usage:{}}){const {usage:b={},description:c,line:d,example:e}=a;a=Object.keys(b);const g=Object.values(b),[f]=a.reduce(([l=0,m=0],n)=>{const p=b[n].split("\n").reduce((q,t)=>t.length>q?t.length:q,0);p>m&&(m=p);n.length>l&&(l=n.length);return[l,m]},[]),h=(l,m)=>{m=" ".repeat(m-l.length);return`${l}${m}`};a=a.reduce((l,m,n)=>{n=g[n].split("\n");m=h(m,f);const [p,...q]=n;m=`${m}\t${p}`;const t=h("",f);n=q.map(u=>`${t}\t${u}`);return[...l,m,...n]},[]).map(l=>`\t${l}`);const k=[c,` ${d||
boolean:!0,short:"h"},version:{description:"Show the version's number and exit.",boolean:!0,short:"v"}},p=function(a={},b=process.argv){let [,,...c]=b;const d=fa(c);c=c.slice(d.length);a=Object.entries(a).reduce((f,[h,k])=>{f[h]="string"==typeof k?{short:k}:k;return f},{});const e=[];a=Object.entries(a).reduce((f,[h,k])=>{let l;try{const m=k.short,n=k.boolean,q=k.number,r=k.command,t=k.multiple;if(r&&t&&d.length)l=d;else if(r&&d.length)l=d[0];else{const u=ea(c,h,m,n,q);({value:l}=u);const v=u.index,
w=u.length;void 0!==v&&w&&e.push({index:v,length:w})}}catch(m){return f}return void 0===l?f:{...f,[h]:l}},{});let g=c;e.forEach(({index:f,length:h})=>{Array.from({length:h}).forEach((k,l)=>{g[f+l]=null})});g=g.filter(f=>null!==f);Object.assign(a,{$:g});return a}(ha),x=p.source,ja=p.output,ka=p.closure,la=p.useNamespace,ma=p.externs,na=p.types,oa=p.template,pa=p.migrate,qa=p.version;function ra(a={usage:{}}){const {usage:b={},description:c,line:d,example:e}=a;a=Object.keys(b);const g=Object.values(b),[f]=a.reduce(([l=0,m=0],n)=>{const q=b[n].split("\n").reduce((r,t)=>t.length>r?t.length:r,0);q>m&&(m=q);n.length>l&&(l=n.length);return[l,m]},[]),h=(l,m)=>{m=" ".repeat(m-l.length);return`${l}${m}`};a=a.reduce((l,m,n)=>{n=g[n].split("\n");m=h(m,f);const [q,...r]=n;m=`${m}\t${q}`;const t=h("",f);n=r.map(u=>`${t}\t${u}`);return[...l,m,...n]},[]).map(l=>`\t${l}`);const k=[c,` ${d||
""}`].filter(l=>l?l.trim():l).join("\n\n");a=`${k?`${k}\n`:""}

@@ -40,14 +40,14 @@ ${a.join("\n")}

function Bb(a){if(a.isParsedFunction){const {function:{args:b,variableArgs:c}}=a.parsed,d=b.map((e,g)=>{({name:e=`arg${g}`}=a.m[g]||{});return e});if(c){const {O:e}=Ab(a.args||[]);d.push(`...${e}`)}return` = function(${d.join(", ")}) {}`}return a.type.startsWith("function(")?" = function() {}":""}function Cb(a,b){const c=Object.assign(Object.create(Object.getPrototypeOf(a)),a);c.description=`An alias for \`${a.name}\`.`;c.name=b;return c}
class Db{constructor(a=null){this.h=this.description=this.name=null;this.closureType="";this.default=this.f=null;this.optional=!1;this.aliases=[];this.u=!1;this.parsed=null;this.args=a;this.g=!1;this.examples=[];this.v=!1}toTypeScriptFunction(a){if(!this.parsed)throw Error("The property was not parsed.");let {function:{new:b,args:c,return:d,this:e,variableArgs:g}}=this.parsed;b&&(d=b);var f=c.map(k=>a(k)).map((k,l)=>{const {optional:m}=c[l];let {name:n=`arg${l}`,optional:p=m}=this.m[l]||{};return`${`${n}${p?
"?":""}`}: ${k}`});if(e){var h=a(e);f.unshift(`this: ${h}`)}if(g){h=a(g);let k="...args";try{k=`${this.args[this.args.length-1].name}`}catch(l){}f.push(`${k}: ${h}[]`)}f=f.join(", ");h=d?a(d):"?";f=`(${f}) => ${h}`;b&&(f="new "+f);return f}get static(){return this.g}get hasDefault(){return null!==this.default}b(a,{name:b,string:c,"boolean":d,opt:e,number:g,type:f,"default":h,closure:k,alias:l,aliases:m,example:n,"example-override":p="",noParams:q,"static":t,initial:u,"template-no-return":v}){if(!b)throw Error("Property does not have a name.");
this.name=b;a&&(this.description=M(a));a=db({number:g,N:c,boolean:d,type:f});q&&(this.u=q);k&&(this.f=k);this.type=a;void 0!==h?this.default=h:void 0!==u&&(this.default=u);if(e||void 0!==h)this.optional=!0;l&&(this.aliases=[l]);m&&(this.aliases=m.split(/\s*,\s*/));t&&(this.g=!0);n&&(this.examples=tb(n,p));v&&(this.v=!0)}get type(){return this.h||"*"}set type(a){this.h=a||null;this.closureType=this.f||this.h||"";if(!this.u)try{this.parsed=ob(this.closureType),this.isParsedFunction&&!this.args&&(this.args=
class Db{constructor(a=null){this.h=this.description=this.name=null;this.closureType="";this.default=this.f=null;this.optional=!1;this.aliases=[];this.u=!1;this.parsed=null;this.args=a;this.g=!1;this.examples=[];this.v=!1}toTypeScriptFunction(a){if(!this.parsed)throw Error("The property was not parsed.");let {function:{new:b,args:c,return:d,this:e,variableArgs:g}}=this.parsed;b&&(d=b);var f=c.map(k=>a(k)).map((k,l)=>{const {optional:m}=c[l];let {name:n=`arg${l}`,optional:q=m}=this.m[l]||{};return`${`${n}${q?
"?":""}`}: ${k}`});if(e){var h=a(e);f.unshift(`this: ${h}`)}if(g){h=a(g);let k="...args";try{k=`${this.args[this.args.length-1].name}`}catch(l){}f.push(`${k}: ${h}[]`)}f=f.join(", ");h=d?a(d):"?";f=`(${f}) => ${h}`;b&&(f="new "+f);return f}get static(){return this.g}get hasDefault(){return null!==this.default}b(a,{name:b,string:c,"boolean":d,opt:e,number:g,type:f,"default":h,closure:k,alias:l,aliases:m,example:n,"example-override":q="",noParams:r,"static":t,initial:u,"template-no-return":v}){if(!b)throw Error("Property does not have a name.");
this.name=b;a&&(this.description=M(a));a=db({number:g,N:c,boolean:d,type:f});r&&(this.u=r);k&&(this.f=k);this.type=a;void 0!==h?this.default=h:void 0!==u&&(this.default=u);if(e||void 0!==h)this.optional=!0;l&&(this.aliases=[l]);m&&(this.aliases=m.split(/\s*,\s*/));t&&(this.g=!0);n&&(this.examples=tb(n,q));v&&(this.v=!0)}get type(){return this.h||"*"}set type(a){this.h=a||null;this.closureType=this.f||this.h||"";if(!this.u)try{this.parsed=ob(this.closureType),this.isParsedFunction&&!this.args&&(this.args=
[])}catch(b){this.parsed=null}}get o(){let a=this.description||"";return`${a}${this.hasDefault?`${/``` */.test(this.description)?B:a?" ":""}Default \`${this.default}\`.`:""}`}get m(){var a=this.args;this.args&&this.args[0]&&"this"==this.args[0].name&&([,...a]=this.args);return a}get isParsedFunction(){return!!this.parsed&&"function"==this.parsed.name}j(a="",b=!1){let c=[];var d=this.o;d&&(d=T(d),c.push(...d.split(B)));!this.optional&&this.isParsedFunction?(d=zb(this,b),c.push(...d)):c.push(` * @type {${this.optional?
eb(this.closureType):this.closureType}}`);b&&this.examples.length&&(b=ub(this.examples),c.push(...b));a&&(c=c.map(e=>`${a}${e}`));return c.join(B)}D(a,b="",c=!1){a=xb(this,a,c);const [d,...e]=a.split(B);return[`@param ${d}`,...e].map(g=>`${b} * ${g}`).join(B)}}const Ab=a=>{let b="args";const {name:c="",description:d}=a[a.length-1]||{};c.startsWith("...")&&(b=c.replace("...",""));return{O:b,Z:d}};class U extends Db{constructor(...a){super(...a);this.isConstructor=this.async=!1;this.return=""}b(a,b){super.b(a,b);"constructor"==b.name&&(this.isConstructor=!0);this.async=b.async;this.return=b.return}};function Eb(a,b,c,d){var e=P("prop",a).map(({content:k,props:l})=>{const m=new Db;N(l,c);m.b(k,l);return m});a=P(["function","fn","static"],a).map(({content:k,props:l,tag:m})=>{m="static"==m;const {K:n,G:p}=rb(k,b);k=new U(p);const {X:q,I:t}=hb(l,p,d);q.type=t;N(q,c);k.b(n,q);m&&(k.g=!0);return k});e=[...e,...a];const {H:g,M:f,n:h}=e.reduce((k,l)=>{l.isConstructor?k.H.push(l):l.static?k.M.push(l):k.n.push(l);return k},{H:[],M:[],n:[]});return{constructor:g[0]||null,properties:[...g,...f,...h]}};const Fb=(a,b,c={})=>{let d;if("object"==typeof b)d=b;else try{(d=ob(b))||console.log("Could not parse %s",b)}catch(e){console.log("Could not parse %s",b),console.error(e.message)}return d?V(d,a,c):b},V=(a,b,c={})=>{if(""==a.name&&a.nullable)return"?";var {escapePipe:d=!0}=c;let e="";var g="";a.nullable?g="?":!1===a.nullable&&(g="!");if(a.function){e=e+g+(a.name+"(");const f=[];a.function.this&&(d="this: "+V(a.function.this,b,c),f.push(d));a.function.new&&(d="new: "+V(a.function.new,b,c),f.push(d));
eb(this.closureType):this.closureType}}`);b&&this.examples.length&&(b=ub(this.examples),c.push(...b));a&&(c=c.map(e=>`${a}${e}`));return c.join(B)}D(a,b="",c=!1){a=xb(this,a,c);const [d,...e]=a.split(B);return[`@param ${d}`,...e].map(g=>`${b} * ${g}`).join(B)}}const Ab=a=>{let b="args";const {name:c="",description:d}=a[a.length-1]||{};c.startsWith("...")&&(b=c.replace("...",""));return{O:b,Z:d}};class U extends Db{constructor(...a){super(...a);this.isConstructor=this.async=!1;this.return=""}b(a,b){super.b(a,b);"constructor"==b.name&&(this.isConstructor=!0);this.async=b.async;this.return=b.return}};function Eb(a,b,c,d){var e=P("prop",a).map(({content:k,props:l})=>{const m=new Db;N(l,c);m.b(k,l);return m});a=P(["function","fn","static"],a).map(({content:k,props:l,tag:m})=>{m="static"==m;const {K:n,G:q}=rb(k,b);k=new U(q);const {X:r,I:t}=hb(l,q,d);r.type=t;N(r,c);k.b(n,r);m&&(k.g=!0);return k});e=[...e,...a];const {H:g,M:f,n:h}=e.reduce((k,l)=>{l.isConstructor?k.H.push(l):l.static?k.M.push(l):k.n.push(l);return k},{H:[],M:[],n:[]});return{constructor:g[0]||null,properties:[...g,...f,...h]}};const Fb=(a,b,c={})=>{let d;if("object"==typeof b)d=b;else try{(d=ob(b))||console.log("Could not parse %s",b)}catch(e){console.log("Could not parse %s",b),console.error(e.message)}return d?V(d,a,c):b},V=(a,b,c={})=>{if(""==a.name&&a.nullable)return"?";var {escapePipe:d=!0}=c;let e="";var g="";a.nullable?g="?":!1===a.nullable&&(g="!");if(a.function){e=e+g+(a.name+"(");const f=[];a.function.this&&(d="this: "+V(a.function.this,b,c),f.push(d));a.function.new&&(d="new: "+V(a.function.new,b,c),f.push(d));
a.function.args.forEach(h=>{let k=V(h,b,c);h.optional&&(k+="=");f.push(k)});a.function.variableArgs&&(d="..."+V(a.function.variableArgs,b,c),f.push(d));d=f.join(", ");e+=d+")";a.function.return&&(e+=": "+V(a.function.return,b,c))}else a.record?(e+="{ ",d=Object.keys(a.record).map(f=>{var h=a.record[f];if(!h)return f;h=V(h,b,c);return`${f}: ${h}`}),e+=d.join(", "),e+=" }"):a.application?(e+=Gb(a.name,b,g,c)+"<",d=a.application.map(f=>V(f,b,c)),e+=d.join(", "),e+=">"):a.union?(e=e+g+"(",g=a.union.map(f=>
V(f,b,c)),e+=g.join(d?" \\| ":" | "),e+=")"):e+=Gb("any"==a.name?"*":a.name,b,g,c);return e},Gb=(a,b,c="",d={})=>{const {flatten:e=!1,nameProcess:g,link:f=({link:l})=>`#${l}`}=d;d=Hb(b,a);c=`${c}${a}`;if(!d)return c;let {link:h,type:{description:k}}=d;e&&((b=b.find(({fullName:l})=>l==a))&&b.link&&(h=b.link),!k&&b.description&&(k=b.description),"function"==typeof e&&e(a));d.link==h&&(h=f(d));b=g?g(c):c;return k?`<a href="${h}" title="${k.replace(/"/g,"&quot;")}">${b}</a>`:`[${b}](${h})`},Hb=(a,b)=>
{a=a.filter(({fullName:d})=>d==b);if(a.length){var c=a.find(({import:d})=>d||!1);a=a.find(({import:d})=>!d)||c;return{link:`${"type"}-${a.fullName.replace(/<\/?code>/g,"").replace(/<\/?strong>/g,"").replace(/<br\/>/g,"").replace(/&nbsp;/g,"").replace(/[^\w-\d ]/g,"").toLowerCase().replace(/[, ]/g,"-")}`,type:a}}};function Ib(a,b=[],c=[],d={}){const {narrow:e=!1,preprocessDesc:g}=d;if(!b.length)return"";const f=a.isConstructor||a.isInterface,h=b.some(({hasDefault:n})=>n),k={escapePipe:!e,...d};let l;const m=n=>Fb(c,n,{...k,nameProcess:d.nameProcess?p=>d.nameProcess(p,l):void 0});a=b.map((n,p)=>{l=0<(p+1)%2;p=n.args&&n.isParsedFunction?n.toTypeScriptFunction(m):m(n.parsed||n.type);const q=f||n.optional?n.name:`${n.name}*`,t=n.hasDefault?`\`${n.default}\``:"-",u=g?g(n.description):n.description;return{prop:n,
typeName:p,name:q,de:Jb(u,!e),d:t,aa:l}});if(e)return{props:a,anyHaveDefault:h,constr:f};a=a.map(({name:n,typeName:p,de:q,d:t,prop:u})=>[u.optional?n:`__${n}__`,`<em>${p}</em>`,q,...h?[t]:[]]);b=["Name",...e?["Type & Description"]:["Type","Description"],...h?[f?"Initial":"Default"]:[]];return["","","```table",JSON.stringify([b,...a],null,2).replace(/\n/g,B),"```"].join(B)}const Jb=(a="",b=!0)=>{null===a&&(a="");b&&(a=a.replace(/\|/g,"\\|"));return a.replace(/</g,"&lt;").replace(/>/g,"&gt;")};const Kb=(a,b,c={})=>{function d(e){e.replace(/^!?/,"");return`\`${e}\``}return a.split(/,\s*/).map(e=>Fb(b,e,{flatten:!0,...c,nameProcess:c.nameProcess?g=>{g=c.nameProcess(g);return/[_*~>]/.test(g)?`<code>${g}</code>`:d(g)}:d})).join(", ")};function Lb(a){var b=a.h();b=K(b.join(B));b+=fb(a.namespace,a.name,Mb(a));const c=a.properties.reduce((d,e)=>{d.push(e);const g=e.aliases.map(f=>Cb(e,f));d.push(...g);return d},[]).filter(d=>d instanceof U&&d.isConstructor?!1:!0).map(d=>{let e=d.j();e=K(e);e+=fb(`${a.fullName}${d.static?"":".prototype"}`,d.name);return e+=Bb(d)});return[b,...c].join(B)}function Nb(a,b=!1){const c=`${a.extends?"$":""}${a.name}`;return b?`${a.ns}${c}`:c}
{a=a.filter(({fullName:d})=>d==b);if(a.length){var c=a.find(({import:d})=>d||!1);a=a.find(({import:d})=>!d)||c;return{link:`${"type"}-${a.fullName.replace(/<\/?code>/g,"").replace(/<\/?strong>/g,"").replace(/<br\/>/g,"").replace(/&nbsp;/g,"").replace(/[^\w-\d ]/g,"").toLowerCase().replace(/[, ]/g,"-")}`,type:a}}};function Ib(a,b=[],c=[],d={}){const {narrow:e=!1,preprocessDesc:g}=d;if(!b.length)return"";const f=a.isConstructor||a.isInterface,h=b.some(({hasDefault:n})=>n),k={escapePipe:!e,...d};let l;const m=n=>Fb(c,n,{...k,nameProcess:d.nameProcess?q=>d.nameProcess(q,l):void 0});a=b.map((n,q)=>{l=0<(q+1)%2;q=n.args&&n.isParsedFunction?n.toTypeScriptFunction(m):m(n.parsed||n.type);const r=f||n.optional?n.name:`${n.name}*`,t=n.hasDefault?`\`${n.default}\``:"-",u=g?g(n.description):n.description;return{prop:n,
typeName:q,name:r,de:Jb(u,!e),d:t,aa:l}});if(e)return{props:a,anyHaveDefault:h,constr:f};a=a.map(({name:n,typeName:q,de:r,d:t,prop:u})=>[u.optional?n:`__${n}__`,`<em>${q}</em>`,r,...h?[t]:[]]);b=["Name",...e?["Type & Description"]:["Type","Description"],...h?[f?"Initial":"Default"]:[]];return["","","```table",JSON.stringify([b,...a],null,2).replace(/\n/g,B),"```"].join(B)}const Jb=(a="",b=!0)=>{null===a&&(a="");b&&(a=a.replace(/\|/g,"\\|"));return a.replace(/</g,"&lt;").replace(/>/g,"&gt;")};const Kb=(a,b,c={})=>{function d(e){e.replace(/^!?/,"");return`\`${e}\``}return a.split(/,\s*/).map(e=>Fb(b,e,{flatten:!0,...c,nameProcess:c.nameProcess?g=>{g=c.nameProcess(g);return/[_*~>]/.test(g)?`<code>${g}</code>`:d(g)}:d})).join(", ")};function Lb(a){var b=a.h();b=K(b.join(B));b+=fb(a.namespace,a.name,Mb(a));const c=a.properties.reduce((d,e)=>{d.push(e);const g=e.aliases.map(f=>Cb(e,f));d.push(...g);return d},[]).filter(d=>d instanceof U&&d.isConstructor?!1:!0).map(d=>{let e=d.j();e=K(e);e+=fb(`${a.fullName}${d.static?"":".prototype"}`,d.name);return e+=Bb(d)});return[b,...c].join(B)}function Nb(a,b=!1){const c=`${a.extends?"$":""}${a.name}`;return b?`${a.ns}${c}`:c}
function Ob(a,b=!1,c=!1,d=b){d=` * @typedef {${(b?a.closureType:a.type)||a.u()}}${` ${Nb(a,d)}${a.m}`}`;a=(a.properties?a.properties.reduce((e,g)=>{if(g.g)return e;e.push(g);const f=g.aliases.map(h=>Cb(g,h));e.push(...f);return e},[]):[]).filter(e=>e instanceof U?!e.isConstructor:!0).map(e=>yb(e,b));a=[d,...a].join(B);b&&!c&&(a=L(a));return a=K(a)}function Mb(a){return a.args?`function(${a.args.filter(({name:b})=>"this"!=b).map(({name:b})=>b).join(", ")}) {}`:null}
class W{constructor(){this.name="";this.description=this.closureType=this.type=null;this.noExpand=this.spread=this.noToc=!1;this.link=null;this.properties=[];this.namespace=null;this.isRecord=this.isInterface=this.isConstructor=!1;this.args=this.extends=null;this.examples=[];this.file=null}get import(){return!1}b(a,{name:b,type:c,desc:d,noToc:e,spread:g,noExpand:f,link:h,closure:k,constructor:l,"extends":m,"interface":n,record:p,example:q,"example-override":t},u,v=null){if(!b)throw Error("Type does not have a name.");
this.name=b;c&&(this.type=c);k?this.closureType=k:this.closureType=this.type;d&&(this.description=M(d));this.noToc=!!e;this.spread=!!g;this.noExpand=!!f;h&&(this.link=h);!0===l&&(this.isConstructor=l);!0===n&&(this.isInterface=n);!0===p&&(this.isRecord=p);m&&(this.extends=m);u&&(this.namespace=u);if(a){const {properties:w,constructor:y}=Eb(a,v,this.file,this.fullName);y&&(this.args=y.args);this.properties=w}q&&(a={example:q},N(a,this.file),this.examples=tb(a.example,t))}get L(){return this.isConstructor||
class W{constructor(){this.name="";this.description=this.closureType=this.type=null;this.noExpand=this.spread=this.noToc=!1;this.link=null;this.properties=[];this.namespace=null;this.isRecord=this.isInterface=this.isConstructor=!1;this.args=this.extends=null;this.examples=[];this.file=null}get import(){return!1}b(a,{name:b,type:c,desc:d,noToc:e,spread:g,noExpand:f,link:h,closure:k,constructor:l,"extends":m,"interface":n,record:q,example:r,"example-override":t},u,v=null){if(!b)throw Error("Type does not have a name.");
this.name=b;c&&(this.type=c);k?this.closureType=k:this.closureType=this.type;d&&(this.description=M(d));this.noToc=!!e;this.spread=!!g;this.noExpand=!!f;h&&(this.link=h);!0===l&&(this.isConstructor=l);!0===n&&(this.isInterface=n);!0===q&&(this.isRecord=q);m&&(this.extends=m);u&&(this.namespace=u);if(a){const {properties:w,constructor:y}=Eb(a,v,this.file,this.fullName);y&&(this.args=y.args);this.properties=w}r&&(a={example:r},N(a,this.file),this.examples=tb(a.example,t))}get L(){return this.isConstructor||
this.isInterface||this.isRecord}j(){let a;this.closureType?a=` * @typedef {${this.closureType}}`:this.L||(a=` * @typedef {${Pb(this.properties,!0)}}`);return a?(this.description&&(a=` * ${this.description}${B}${a}`),a=K(a),a+=fb(this.namespace,this.name)):Lb(this)}u(){return"Object"}o(a,b=new RegExp(`([!?])?${a}\\.`,"g")){this.type&&(this.type=this.type.replace(b,"$1"));this.extends&&(this.extends=this.extends.replace(b,"$1"));return b}get m(){return`${this.tag?` \`\uff20${this.tag}\``:""}${this.description?

@@ -61,26 +61,27 @@ ` ${this.description}`:""}`}g(a=!1,b=!1,c=a){const d=!!this.extends,e=Ob(this,a,b,c),g=[];if(this.namespace&&a){var f=` * @typedef {${this.fullName}} ${this.name}${this.m}`;a&&!b&&(f=L(f));f=K(f);g.push(f)}else this.namespace&&c&&(f=` * @typedef {${this.fullName}} ${this.name}${this.m}`,f=K(f),g.push(f));d&&(c=` * @typedef {${Nb(this,c)} & ${this.extends.split(/,\s*/).join(" & ")}} ${c?this.fullName:this.name}${this.m}`,a&&!b&&(c=L(c)),c=K(c),g.push(c));g.push(e);return g.join("")}get Y(){const a=

type:b,optional:c})=>`${a}${c?"?":""}: ${b}`).join(", ")}) => ${this.v}`}o(a){a=super.o(a);this.f&&(this.f=this.f.replace(a,"$1"))}};const Vb=(a,b)=>{const c=new RegExp(`([!?])?${a}\\.`,"g");b.properties.forEach(d=>{vb(d,a,c)});b.o(a)},Wb=(a,b)=>{var {args:c=[]}=a,d=c.map(({J:g})=>g).join(", ");let e=`new: ${a.fullName}`;d.length&&(e=`${e}, `);d=`function(${e}${d})`;c=new U(c);c.isConstructor=!0;c.b("Constructor method.",{type:d,name:"constructor"});c.examples=a.examples;vb(c,b);a.properties.unshift(c)},Yb=(a,b,c=null)=>{a=P("types",a);if(!a.length)throw Error("XML file should contain root types element.");const [{content:d,props:{namespace:e,
ns:g=e}}]=a,f=b==g?void 0:g;a=P(["embed"],d).map(({props:l})=>l);const h=[],k=P("type interface constructor method import record".split(" "),d).reduce((l,{content:m,props:n,tag:p})=>{"record"==p&&(p="type",n.record=!0);const {alias:q,aliases:t,...u}=n;c&&N(u,c);var v=q?[q]:t?t.split(/, */):[];switch(p){case "type":p=new W;c&&(p.file=c);p.b(m,n,f,b);l.push(p);v.forEach(w=>{const y=new W;c&&(y.file=c);y.b(m,{...u,name:w},f,b);l.push(y)});break;case "interface":n=Xb({content:m,props:n,ns:f,C:b,location:c});
ns:g=e}}]=a,f=b==g?void 0:g;a=P(["embed"],d).map(({props:l})=>l);const h=[],k=P("type interface constructor method import record".split(" "),d).reduce((l,{content:m,props:n,tag:q})=>{"record"==q&&(q="type",n.record=!0);const {alias:r,aliases:t,...u}=n;c&&N(u,c);var v=r?[r]:t?t.split(/, */):[];switch(q){case "type":q=new W;c&&(q.file=c);q.b(m,n,f,b);l.push(q);v.forEach(w=>{const y=new W;c&&(y.file=c);y.b(m,{...u,name:w},f,b);l.push(y)});break;case "interface":n=Xb({content:m,props:n,ns:f,C:b,location:c});
n.forEach(w=>{w.properties.some(({isConstructor:y})=>y)||Wb(w,b);w.isInterface=!0});l.push(...n);break;case "constructor":n=Xb({content:m,props:n,ns:f,C:b,location:c});n.forEach(w=>{w.properties.some(({isConstructor:y})=>y)||Wb(w,b);w.isConstructor=!0});l.push(...n);break;case "method":n=Xb({content:m,props:n,ns:f,C:b,isMethod:!0,location:c});l.push(...n);break;case "import":v=new Rb,v.b(m,n,n.ns||n.from,b),h.push(v)}return l},[]);b&&k.forEach(l=>Vb(b,l));return{namespace:g,types:k,imports:h,embeds:a}},
Zb=(a,b,c,d,e=!1,g=null)=>{const f=e?new Ub:new W;f.file=g;g=a.search(/<(prop|function|fn|static) /);let h="",k=a;1!=g&&(h=a.slice(0,g),k=a.slice(g));const {G:l,K:m}=rb(h,d);f.b(e?m:k,b,c,d);({I:a}=hb(b,l));e&&(f.closureType=a);f.args||(f.args=l);return f},Xb=({content:a,props:b,ns:c,C:d,isMethod:e=!1,location:g=null})=>{const f=[],{alias:h,aliases:k,...l}=b;b=Zb(a,b,c,d,e,g);f.push(b);(h?[h]:k?k.split(/, */):[]).forEach(m=>{m=Zb(a,{...l,name:m},c,d,e,g);m.description=`${m.description}${m.description?
" ":""}Alias of \`${l.name}\`.`;f.push(m)});return f},$b=()=>{Object.keys(X).forEach(a=>{delete X[a]});Object.keys(Y).forEach(a=>{delete Y[a]})},X={},Y={},bc=async a=>{var b=Y[a];b?b=await b:(b=F(a),Y[a]=b,b=await b);return ac(b,a,[])},cc=(a,b=[])=>{a in X||(X[a]=ua(a,"utf8"));return ac(X[a],a,b)},ac=(a,b,c)=>{let d,e,g,f;try{({namespace:d=null,types:e,imports:g,embeds:f}=Yb(a,void 0,b))}catch(h){throw h.message=`Error while reading ${b}${B}${h.message}`,h;}e=e.filter(({fullName:h})=>c.includes(h)?
!1:!0);g=g.filter(({fullName:h})=>c.includes(h)?!1:!0);return{types:e,imports:g,namespace:d,embeds:f}};const dc=(a,b,c)=>{b=b.map(d=>d.g(!0,c));a=a.map(d=>{d=d.g();return K(c?d:L(d))});return[...b,...a].join("")},ec=(a,b,c,d=!1)=>{a=a.map(e=>e.j());a=O(...a,...[]);return`${!b||d||c.includes(b)?"":["/** @const */",`var ${b} = {}`,""].join(B)}${a}`};function fc(a,b,c){const [d,...e]=c.split(/\s+/);var g=e.includes("closure");const f=e.includes("externs"),h=e.includes("noSuppress"),k=e.includes("skipNsDecl"),l=e.includes("namespace"),m=e.includes("noEmbed")||e.includes("no-embed");let n=e.find(t=>t.startsWith("ignore:"));n=n?n.replace("ignore:","").split(","):[];let {s:p,A:q}=this.f;g&&(p=!0);f&&(q=!0);try{this.i("Detected type marker: %s",c);const {types:t,imports:u,namespace:v,embeds:w}=cc(d,n);this.emit("types",t);this.emit("types",u);g=[];
!m&&w.length&&(g=w.map(({src:E,path:nc=E,ignore:Q=n.join(","),namespace:oc=l,s:pc=p,A:qc=q,"no-suppress":rc=h})=>{E=[nc];Q&&E.push(`ignore:${Q}`);oc&&E.push("namespace");pc&&E.push("closure");qc&&E.push("ext");rc&&E.push("noSuppress");Q=E.join(" ");return fc.call(this,`${B} /* typal-embed ${Q} */${B}`,"typal-embed",Q)}));let y=g.join(""),R;p?R=dc(u,t,h):q?(R=ec(t,v,this.b,k)+B,v&&this.emit("namespace",v)):l?(v&&this.emit("namespace",v),R=gc(u,t,!0)):R=gc(u,t);return`/* ${b} ${c} */${B}${R}${y}`}catch(t){return this.i("(%s) Could not process typedef-js: %s",
!1:!0);g=g.filter(({fullName:h})=>c.includes(h)?!1:!0);return{types:e,imports:g,namespace:d,embeds:f}};const dc=(a,b,c)=>{b=b.map(d=>d.g(!0,c));a=a.map(d=>{d=d.g();return K(c?d:L(d))});return[...b,...a].join("")},ec=(a,b,c,d=!1)=>{a=a.map(e=>e.j());a=O(...a,...[]);return`${!b||d||c.includes(b)?"":["/** @const */",`var ${b} = {}`,""].join(B)}${a}`};function fc(a,b,c){const [d,...e]=c.split(/\s+/);var g=e.includes("closure");const f=e.includes("externs"),h=e.includes("noSuppress"),k=e.includes("skipNsDecl"),l=e.includes("namespace"),m=e.includes("noEmbed")||e.includes("no-embed");let n=e.find(t=>t.startsWith("ignore:"));n=n?n.replace("ignore:","").split(","):[];let {s:q,A:r}=this.f;g&&(q=!0);f&&(r=!0);try{this.i("Detected type marker: %s",c);const {types:t,imports:u,namespace:v,embeds:w}=cc(d,n);this.emit("types",t);this.emit("types",u);g=[];
!m&&w.length&&(g=w.map(({src:E,path:nc=E,ignore:Q=n.join(","),namespace:oc=l,s:pc=q,A:qc=r,"no-suppress":rc=h})=>{E=[nc];Q&&E.push(`ignore:${Q}`);oc&&E.push("namespace");pc&&E.push("closure");qc&&E.push("ext");rc&&E.push("noSuppress");Q=E.join(" ");return fc.call(this,`${B} /* typal-embed ${Q} */${B}`,"typal-embed",Q)}));let y=g.join(""),R;q?R=dc(u,t,h):r?(R=ec(t,v,this.b,k)+B,v&&this.emit("namespace",v)):l?(v&&this.emit("namespace",v),R=gc(u,t,!0)):R=gc(u,t);return`/* ${b} ${c} */${B}${R}${y}`}catch(t){return this.i("(%s) Could not process typedef-js: %s",
c,t.message),process.env.b&&console.error(t.stack),a}}const hc={re:/^\/\*\*? (documentary|typal) (.+?) \*\/\r?\n(?:((?!\r?\n)[\s\S]+?\r?\n))?$/mg,replacement:fc},gc=(a,b,c=!1)=>{b=b.map(d=>d.g(!1,!1,c));a=a.map(d=>d.g(c)).map(K).join("");b=b.join("");return`${a}${b}`.replace(ic," * @typedef")},ic=/ \*\/\r?\n\/\*\*\r?\n \* @typedef/g;const kc={re:/( *) \* @param {(.+?)} (\[)?([^\s\]]+)\]?(?: .+)?((?:\r?\n(?: +)\* @param {(?:.+?)} \[?\4\]?(?:(?!\r?\n\s*\*(?:\/|\s*@))[\s\S])*)*)/gm,replacement:jc};
function jc(a,b,c,d,e,g,f){const h=this.f.s,k=this.f.F;let l;g=()=>{if(this.lines&&this.file){var n;{let t=n=0;for(;t<f;)t+=this.lines[n].length,n++;n={line:n,S:b.length+11}}const {line:p,S:q}=n;this.i("%s:%s:%s",this.file,p,q)}};try{l=ob(c)}catch(n){return this.i("Error while parsing the type %s",c),this.i(process.env.DEBUG?n.stack:n.message),g(),a}if(!l)return this.i("Could not parse the type %s",c),g(),a;const m=Object.values(this.types).map(({name:n,fullName:p})=>h||k?p:n);if(!Z(l,m,this.i,c,
g))return a;c=Object.values(this.types).find(({name:n,fullName:p})=>h||k?p==l.name:n==l.name);return!c||c instanceof Tb.Import?a:c.D(e,d,b,l.nullable,h,k)}
function jc(a,b,c,d,e,g,f){const h=this.f.s,k=this.f.F;let l;g=()=>{if(this.lines&&this.file){var n;{let t=n=0;for(;t<f;)t+=this.lines[n].length,n++;n={line:n,S:b.length+11}}const {line:q,S:r}=n;this.i("%s:%s:%s",this.file,q,r)}};try{l=ob(c)}catch(n){return this.i("Error while parsing the type %s",c),this.i(process.env.DEBUG?n.stack:n.message),g(),a}if(!l)return this.i("Could not parse the type %s",c),g(),a;const m=Object.values(this.types).map(({name:n,fullName:q})=>h||k?q:n);if(!Z(l,m,this.i,c,
g))return a;c=Object.values(this.types).find(({name:n,fullName:q})=>h||k?q==l.name:n==l.name);return!c||c instanceof Tb.Import?a:c.D(e,d,b,l.nullable,h,k)}
const Z=(a,b,c,d,e)=>{if(a){var g=a.name;if(!g||!"string number boolean null undefined symbol any".split(" ").includes(g)){if(g&&!a.application&&!a.function){let h=b.includes(g);h||(h=lc.includes(g));if(h)return!0;c("Type %s%s was not found.",g,d!=g?` in ${d}`:"");e()}var f=[b,c,d,e];a.application?a.application.forEach(h=>{Z(h,...f)}):a.record?Object.keys(a.record).forEach(h=>{Z(a.record[h],...f)}):a.union?a.union.forEach(h=>{Z(h,...f)}):a.function&&(Z(a.function.this,...f),Z(a.function.new,...f),
a.function.args.forEach(h=>{Z(h,...f)}),Z(a.function.variableArgs,...f),Z(a.function.return,...f))}}},lc="String Boolean Object Date Number Symbol Buffer Function RegExp".split(" ");var mc=(a,b=!1)=>{$b();var {U:c}=Ua();const d=Wa(c);c=Va(c);return new Tb(b?[hc]:[hc,d,kc,c],a)};const sc=/( *) \* @(fnType|methodType) {(.+?)}/gm,tc=(a,b,c,d,e,g,f=d)=>{c=`${b?"static ":""}${c?"async ":""}${d}(${e}) {`;return O("/**",a," */",...null===g?[`${c} }`]:[c,` return ${`${b?g:"super"}.${f}`}(${e})`,"}"])};
function uc(a,b,c){return a.map(d=>{const e=d.name;var g=d.aliases;const f=d.static,h=d.async;let k=d.j("",!0);k=vc(k,c);const l=d.args.map(({name:m})=>m).join(", ");d=tc(k,f,h,e,l,b);g=g.map(m=>tc(k+`${B} * @alias ${e} An alias for **${e}**.`,f,h,m,l,b,e));return[d,...g].join(B)})}function wc(a){return a.map(b=>{const c=b.name,d=b.default,e=b.type;return["/**",b.j("",!0)," */",`this.${c}${d?` = ${bb(e,d,"'")}`:""}`].join(B)})}
const xc=(a,b)=>({re:/(\/\*\*[\s\S]+?)( *\* *@implements {(.+?)})[\s\S]+?((?:export\s+(?:default\s+)?)?class\s+(\S+).*?){\s*}/gm,replacement(c,d,e,g,f,h){const k=a.find(({fullName:q})=>q==g);if(!k)return console.error("Type %s in %s not found",g,b),c;c=k.properties.filter(q=>q instanceof U&&!q.isConstructor);var l=k.properties.filter(q=>q instanceof Db&&!(q instanceof U));c=uc(c,null,g);l=wc(l).map(q=>q.replace(/(^|(?:\r?\n))/g,"$1 "));const m=k.properties.find(q=>q instanceof U&&q.isConstructor),
n=m.args.map(({name:q})=>q).join(", "),p=0<l.length;h=O("/**",vc(m.j("",!0),g)," */",`constructor(${n}) {${p||k.extends?"":" }"}`,...k.extends?[" super([arguments])"]:[],...l,p?"}"+B+"/**":"/**"," * Sets the implementation on the interface.",` * @param {!${h}} Implementation`," */","static __implement(Implementation) {"," Object.defineProperties(",` ${h}.prototype,`," Object.getOwnPropertyDescriptors(Implementation)"," )","}",...c);h=h.replace(/(^|(?:\r?\n))/g,"$1 ");return O(d.trimRight(),
...k.description?[T(k.description)]:[],e," */",`${f}{`,h,"}")}});
const xc=(a,b)=>({re:/(\/\*\*[\s\S]+?)( *\* *@implements {(.+?)})[\s\S]+?((?:export\s+(?:default\s+)?)?class\s+(\S+).*?){\s*}/gm,replacement(c,d,e,g,f,h){this.isInterface=!0;const k=a.find(({fullName:r})=>r==g);if(!k)return console.error("Type %s in %s not found",g,b),c;c=k.properties.filter(r=>r instanceof U&&!r.isConstructor);var l=k.properties.filter(r=>r instanceof Db&&!(r instanceof U));c=uc(c,null,g);l=wc(l).map(r=>r.replace(/(^|(?:\r?\n))/g,"$1 "));const m=k.properties.find(r=>r instanceof
U&&r.isConstructor),n=m.args.map(({name:r})=>r).join(", "),q=0<l.length;h=O("/**",vc(m.j("",!0),g)," */",`constructor(${n}) {${q||k.extends?"":" }"}`,...k.extends?[" super([arguments])"]:[],...l,q||k.extends?"}"+B+"/**":"/**"," * Sets the implementation on the interface.",` * @param {!${h}} Implementation`," */","static __implement(Implementation) {"," Object.defineProperties(",` ${h}.prototype,`," Object.getOwnPropertyDescriptors(Implementation)"," )","}",...c);h=h.replace(/(^|(?:\r?\n))/g,
"$1 ");return O(d.trimRight(),...k.description?[T(k.description)]:[],e," */",`${f}{`,h,"}")}});
class yc extends Za{constructor(a,b){super([{re:/\/\*\*(?:\s+( *) \*)? @constructor {(.+?)}[\s\S]+?(class\s+.+?\s+extends\s+(.+?)\s*){\s*}/gm,replacement(c,d,e,g,f){d=a.find(({fullName:k})=>k==e);if(!d)return console.error("Type %s in %s not found",e,b),c;c=d.properties.filter(k=>k instanceof U&&!k.isConstructor);f=uc(c,f,e);c=d.properties.find(k=>k instanceof U&&k.isConstructor);const h=c.args.map(({name:k})=>k).join(", ");f=O("/**",vc(c.j("",!0),e)," */",`constructor(${h}) {`,` super(${h})`,"}",
...f);f=f.replace(/(^|(?:\r?\n))/g,"$1 ");return O(...d.description?["/**",T(d.description)," */"]:[],`${g}{`,f,"}")}},xc(a,b),{re:sc,async replacement(c,d,e,g){const f=g.split(".");let h,k;if("methodType"==e)h=g;else if(2==f.length)[h,k]=f;else if(3==f.length)h=`${f[0]}.${f[1]}`,k=f[2];else throw Error("The @fnType should consist of _namespace.Type.propName or Type.propName");g=a.find(({fullName:l})=>l==h);if(!g)return console.error("Type %s in %s not found",h,b),c;if("constructor"==k||"methodType"==
e)return g.h(d,!1,!0).join(B);e=g.properties.find(({name:l})=>l==k);return e?e.parsed?e.j(d,!0):(console.error("Property %s of type %s in %s wasn't parsed, possibly parser bug.",k,h,b),c):(console.error("Property %s of type %s in %s not found",k,h,b),c)}}])}}const vc=(a,b)=>a.replace(`${B} * @return {${b}}`,"").replace(`${B} * @return {!${b}}`,"").replace(`${B} * @return {?${b}}`,"");const zc=async a=>a?(await Promise.all(a.split(",").map(async b=>{var c=[];const d=await H(z,b);d.isFile()?c=[b]:d.isDirectory()&&(c=await I(b),c=J(c.content,b),c=c.filter(e=>e.endsWith(".xml")));return c}))).reduce((b,c)=>[...b,...c],[]):[],Ac=async a=>(await Promise.all(a.map(async b=>({...await bc(b),location:b})))).reduce((b,{imports:c,types:d})=>{b.push(...c);b.push(...d);return b},[]);
e)return g.h(d,!1,!0).join(B);e=g.properties.find(({name:l})=>l==k);return e?e.parsed?e.j(d,!0):(console.error("Property %s of type %s in %s wasn't parsed, possibly parser bug.",k,h,b),c):(console.error("Property %s of type %s in %s not found",k,h,b),c)}},{re:/ \* @typedef {import\(.+?} .+/gm,replacement(c,d,e){return!this.isInterface||e.substr(0,d).trim().endsWith("@suppress {nonStandardJsDocs}")?c:` * @suppress {nonStandardJsDocs}${B}${c}`}},{re:/ \* @typedef {import\(.+?} .+\r?\n \* @suppress/gm,
replacement(c){if(!this.isInterface)return c;const [d,e]=c.split(/\r?\n/);return[d," */","/**",e].join(B)}}]);this.isInterface=!1}}const vc=(a,b)=>a.replace(`${B} * @return {${b}}`,"").replace(`${B} * @return {!${b}}`,"").replace(`${B} * @return {?${b}}`,"");const zc=async a=>a?(await Promise.all(a.split(",").map(async b=>{var c=[];const d=await H(z,b);d.isFile()?c=[b]:d.isDirectory()&&(c=await I(b),c=J(c.content,b),c=c.filter(e=>e.endsWith(".xml")));return c}))).reduce((b,c)=>[...b,...c],[]):[],Ac=async a=>(await Promise.all(a.map(async b=>({...await bc(b),location:b})))).reduce((b,{imports:c,types:d})=>{b.push(...c);b.push(...d);return b},[]);
async function Bc(){$b();const a=await zc(na),b=await Ac(a);await Promise.all(x.map(async c=>{var d=await H(z,c);let e;d.isFile()?e=[c]:d.isDirectory()&&(d=await I(c),e=J(d.content,c));await Cc(e,b,oa)}))}const Cc=async(a,b=[],c=null)=>{await Promise.all(a.map(async d=>{var e=await F(d);const g=new yc(b,d);g.end(e);e=await D(g);"-"==c?console.log(e):c?await G(c,e):await G(d,e)}))};var Ec=async()=>{const {s:a=!1,F:b=!1,A:c=!1,W:d,types:e}={s:ka,A:ma,W:ja,types:na,F:la},g=await zc(e);await Promise.all(x.map(async f=>{var h=await H(z,f);let k;h.isFile()?k=[f]:h.isDirectory()&&(h=await I(f),k=J(h.content,f));await Dc(k,a,c,d,g,b)}))};
const Dc=async(a,b=!1,c=!1,d="",e=[],g=!1)=>{const f=[];await Promise.all(e.map(async h=>{h=await F(h);const {types:k,imports:l}=Yb(h);f.push(k,l)}));await Promise.all(a.map(async h=>{var k=await F(h);const l=mc({s:b,A:c,F:g},c);f.forEach(m=>l.emit("types",m));l.file=h;l.i=console.error;l.lines=k.split(B);l.end(k);k=await D(l);"-"==d?console.log(k):d?await G(d,k):await G(h,k)}))};const Fc=a=>{let b;"true"==a?b=!0:"false"==a?b=!1:/^\d+$/.test(a)&&(b=parseInt(a,10));return void 0!==b?b:a},Gc=/^ \* @prop {(.+?)} (\[)?(.+?)(?:=(["'])?(.+?)\4)?(?:])?(?: (.+?))?(?: Default `(.+?)`.)?$/gm,Hc="type opt name quote defaultValue description Default".split(" "),ab=new RegExp(`^ \\* @typedef {(.+?)} (.+?)(?: (.+))?\\r?\\n((?:${/ \* @prop(?:erty)? .+\r?\n/.source})*)`,"gm"),Ic=(a,b,c,d)=>{d=d.length;a=a&&"Object"!=a?` type="${a}"`:"";c=c?` desc="${c}"`:"";return`${" ".repeat(2)}<type name="${b}"${a}${c}${d?
"":" /"}>${B}`};
class Jc extends A{constructor(){super({writableObjectMode:!0})}_transform({type:a,name:b,description:c,properties:d},e,g){a=a&&a.startsWith("import")?Kc(a,b):Ic(a,b,c,d);this.push(a);d.forEach(({type:f,name:h,default:k,description:l,optional:m})=>{{f=["string","number","boolean"].includes(f)?` ${f}`:` type="${f}"`;var n=void 0!==k;k=n?` default="${k}"`:"";m=m&&!n?" opt":"";n=" ".repeat(4);const p=" ".repeat(6);h=`${n}<prop${m}${f} name="${h}"${k}${l?`>${B}${p}${l}${B}${n}</prop>`:"/>"}${B}`}this.push(h)});
class Jc extends A{constructor(){super({writableObjectMode:!0})}_transform({type:a,name:b,description:c,properties:d},e,g){a=a&&a.startsWith("import")?Kc(a,b):Ic(a,b,c,d);this.push(a);d.forEach(({type:f,name:h,default:k,description:l,optional:m})=>{{f=["string","number","boolean"].includes(f)?` ${f}`:` type="${f}"`;var n=void 0!==k;k=n?` default="${k}"`:"";m=m&&!n?" opt":"";n=" ".repeat(4);const q=" ".repeat(6);h=`${n}<prop${m}${f} name="${h}"${k}${l?`>${B}${q}${l}${B}${n}</prop>`:"/>"}${B}`}this.push(h)});
d.length&&this.push(` </type>${B}`);g()}}const Kc=(a,b)=>{const c=/import\((['"])(.+?)\1\)/.exec(a);if(!c)throw Error(`Could not extract package from "${a}"`);[,,a]=c;return`${" ".repeat(2)}<import name="${b}" from="${a}" />${B}`};
class Lc extends A{constructor(){super({objectMode:!0})}_transform([,a,b,c,d],e,g){d=ib(Gc,d,Hc).map(f=>{const {defaultValue:h,Default:k,opt:l,name:m,type:n,...p}=f;f={...p,name:m,type:n,...h?{defaultValue:Fc(h)}:{},...k?{w:Fc(k)}:{},...l?{optional:!0}:{}};if(h||k){if(h)h!==k&&void 0!==f.w&&(q=cb(m,k,n),console.error("%s[%s] does not match Default `%s`.",b,q,f.w));else{var q=cb(m,k,n);console.error("%s[%s] got from Default.",b,q)}f.default="defaultValue"in f?f.defaultValue:f.w;delete f.defaultValue;
class Lc extends A{constructor(){super({objectMode:!0})}_transform([,a,b,c,d],e,g){d=ib(Gc,d,Hc).map(f=>{const {defaultValue:h,Default:k,opt:l,name:m,type:n,...q}=f;f={...q,name:m,type:n,...h?{defaultValue:Fc(h)}:{},...k?{w:Fc(k)}:{},...l?{optional:!0}:{}};if(h||k){if(h)h!==k&&void 0!==f.w&&(r=cb(m,k,n),console.error("%s[%s] does not match Default `%s`.",b,r,f.w));else{var r=cb(m,k,n);console.error("%s[%s] got from Default.",b,r)}f.default="defaultValue"in f?f.defaultValue:f.w;delete f.defaultValue;
delete f.w}return f});this.push({type:a,name:b,description:c,properties:d});g()}}async function Mc(a){const b=$a(),c=new Lc,d=new Jc;b.pipe(c).pipe(d);b.end(a);b.on("error",e=>{console.error("Error in Transform");d.emit("error",e)});c.on("error",e=>{console.error("Error in RegexTransform");d.emit("error",e)});d.on("error",e=>{console.error("Error in XML");d.emit("error",e)});return["<types>",` ${(await D(d)).trim()}`,"</types>"].join(B)};var Nc=async()=>{await Promise.all(x.map(async a=>{a=await F(a);a=await Mc(a);ja?await G(ja,a):console.log(a)}))};/*

@@ -106,2 +107,2 @@

*/
if(r.help){const a=ia();console.log(ra({usage:a,description:"Embeds and maintains Closure-compatible types JSDoc in\nJavaScript source code from an external types.xml file.",line:"typal source [--closure|externs] [--migrate] [-o output] [-hv]",example:"typal src/index.js -c"}));process.exit()}else qa&&(console.log(require("../../package.json").version),process.exit());(async()=>{try{return pa?await Nc():oa?await Bc():await Ec()}catch(a){process.env.DEBUG?console.log(a.stack):console.log(a.message)}})();
if(p.help){const a=ia();console.log(ra({usage:a,description:"Embeds and maintains Closure-compatible types JSDoc in\nJavaScript source code from an external types.xml file.",line:"typal source [--closure|externs] [--migrate] [-o output] [-hv]",example:"typal src/index.js -c"}));process.exit()}else qa&&(console.log(require("../../package.json").version),process.exit());(async()=>{try{return pa?await Nc():oa?await Bc():await Ec()}catch(a){process.env.DEBUG?console.log(a.stack):console.log(a.message)}})();
{
"name": "typal",
"version": "2.0.2",
"version": "2.0.3",
"description": "Organises TypeDefs By Placing Them Into Types.Xml File To Be Embedded Into Source Code Compatible With VSCode And Google Closure Compiler, Generates Externs And Allows To Place Documentation In README Markdown.",

@@ -5,0 +5,0 @@ "main": "compile/index.js",

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