Comparing version 1.9.0 to 1.9.1
@@ -44,5 +44,22 @@ let extractTags = require('rexml'); if (extractTags && extractTags.__esModule) extractTags = extractTags.default; | ||
return { namespace, types, imports } | ||
/** | ||
* Imports parsed into types. | ||
*/ | ||
const Imports = imports | ||
.map(({ name, from, desc, link, ns: importNs }) => { | ||
const type = new Type() | ||
type.fromXML('', { | ||
name, | ||
type: `import('${from}').${name}`, | ||
noToc: true, | ||
import: true, | ||
desc, | ||
link, | ||
}, importNs == rootNamespace ? undefined : importNs) | ||
return type | ||
}) | ||
return { namespace, types, imports, Imports } | ||
} | ||
module.exports=parseFile |
let extractTags = require('rexml'); if (extractTags && extractTags.__esModule) extractTags = extractTags.default; | ||
let mismatch = require('mismatch'); if (mismatch && mismatch.__esModule) mismatch = mismatch.default; | ||
let parse = require('@typedefs/parser'); if (parse && parse.__esModule) parse = parse.default; | ||
@@ -4,0 +3,0 @@ const Property = require('./Property'); |
## 30 April 2019 | ||
### [1.9.1](https://github.com/artdecocode/typal/compare/v1.9.0...v1.9.1) | ||
- [fix] Correct the imports with namespace printing and linking (including for the `rootNamespace`); return `Imports` in from the _parse_ method. | ||
### [1.9.0](https://github.com/artdecocode/typal/compare/v1.8.0...v1.9.0) | ||
@@ -4,0 +8,0 @@ |
@@ -71,5 +71,5 @@ #!/usr/bin/env node | ||
try { | ||
const {short:m, boolean:l, number:n, command:p, multiple:q} = h; | ||
p && q && c.length ? (k = c, d = !0) : p && c.length ? (k = c[0], d = !0) : {value:k, argv:e} = t(e, f, m, l, n); | ||
} catch (m) { | ||
const {short:l, boolean:m, number:n, command:p, multiple:q} = h; | ||
p && q && c.length ? (k = c, d = !0) : p && c.length ? (k = c[0], d = !0) : {value:k, argv:e} = t(e, f, l, m, n); | ||
} catch (l) { | ||
return Object.assign({}, {j:e}, g); | ||
@@ -84,21 +84,21 @@ } | ||
a = Object.keys(b); | ||
const f = Object.values(b), [g] = a.reduce(([m = 0, l = 0], n) => { | ||
const f = Object.values(b), [g] = a.reduce(([l = 0, m = 0], n) => { | ||
const p = b[n].split("\n").reduce((q, r) => r.length > q ? r.length : q, 0); | ||
p > l && (l = p); | ||
n.length > m && (m = n.length); | ||
return [m, l]; | ||
}, []), h = (m, l) => { | ||
l = " ".repeat(l - m.length); | ||
return `${m}${l}`; | ||
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((m, l, n) => { | ||
a = a.reduce((l, m, n) => { | ||
n = f[n].split("\n"); | ||
l = h(l, g); | ||
m = h(m, g); | ||
const [p, ...q] = n; | ||
l = `${l}\t${p}`; | ||
m = `${m}\t${p}`; | ||
const r = h("", g); | ||
n = q.map(v => `${r}\t${v}`); | ||
return [...m, l, ...n]; | ||
}, []).map(m => `\t${m}`); | ||
const k = [c, ` ${d || ""}`].filter(m => m ? m.trim() : m).join("\n\n"); | ||
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` : ""} | ||
@@ -127,6 +127,6 @@ ${a.join("\n")} | ||
const {homedir:qa} = os; | ||
const E = /\s+at.*(?:\(|\s)(.*)\)?/, ra = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/, sa = qa(), F = a => { | ||
const D = /\s+at.*(?:\(|\s)(.*)\)?/, ra = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/, sa = qa(), E = a => { | ||
const {pretty:b = !1, ignoredModules:c = ["pirates"]} = {}, d = c.join("|"), e = new RegExp(ra.source.replace("IGNORED_MODULES", d)); | ||
return a.replace(/\\/g, "/").split("\n").filter(f => { | ||
f = f.match(E); | ||
f = f.match(D); | ||
if (null === f || !f[1]) { | ||
@@ -137,3 +137,3 @@ return !0; | ||
return f.includes(".app/Contents/Resources/electron.asar") || f.includes(".app/Contents/Resources/default_app.asar") ? !1 : !e.test(f); | ||
}).filter(f => f.trim()).map(f => b ? f.replace(E, (g, h) => g.replace(h, h.replace(sa, "~"))) : f).join("\n"); | ||
}).filter(f => f.trim()).map(f => b ? f.replace(D, (g, h) => g.replace(h, h.replace(sa, "~"))) : f).join("\n"); | ||
}; | ||
@@ -145,7 +145,7 @@ function ta(a, b, c = !1) { | ||
e = [`Error: ${h}`, ...null !== e && a === e || c ? [b] : [g, b]].join("\n"); | ||
e = F(e); | ||
e = E(e); | ||
return Object.assign(f ? d : Error(), {message:h, stack:e}); | ||
}; | ||
} | ||
;function G(a) { | ||
;function F(a) { | ||
var {stack:b} = Error(); | ||
@@ -167,21 +167,21 @@ const c = C(arguments); | ||
b = (delete c.binary, delete c.rs, c); | ||
const {G:f = G(!0), proxyError:g} = a || {}, h = (k, m) => f(m); | ||
const {J:f = F(!0), proxyError:g} = a || {}, h = (k, l) => f(l); | ||
super(b); | ||
this.a = []; | ||
this.D = new Promise((k, m) => { | ||
this.H = new Promise((k, l) => { | ||
this.on("finish", () => { | ||
let l; | ||
d ? l = Buffer.concat(this.a) : l = this.a.join(""); | ||
k(l); | ||
let m; | ||
d ? m = Buffer.concat(this.a) : m = this.a.join(""); | ||
k(m); | ||
this.a = []; | ||
}); | ||
this.once("error", l => { | ||
if (-1 == l.stack.indexOf("\n")) { | ||
h`${l}`; | ||
this.once("error", m => { | ||
if (-1 == m.stack.indexOf("\n")) { | ||
h`${m}`; | ||
} else { | ||
const n = F(l.stack); | ||
l.stack = n; | ||
g && h`${l}`; | ||
const n = E(m.stack); | ||
m.stack = n; | ||
g && h`${m}`; | ||
} | ||
m(l); | ||
l(m); | ||
}); | ||
@@ -195,20 +195,20 @@ e && ua(this, e).pipe(this); | ||
} | ||
get b() { | ||
return this.D; | ||
get f() { | ||
return this.H; | ||
} | ||
} | ||
const H = async a => { | ||
const G = async a => { | ||
var b = void 0 === b ? {} : b; | ||
({b:a} = new va(Object.assign({}, {rs:a}, b, {G:G(!0)}))); | ||
({f:a} = new va(Object.assign({}, {rs:a}, b, {J:F(!0)}))); | ||
return await a; | ||
}; | ||
async function I(a) { | ||
async function H(a) { | ||
a = ka(a); | ||
return await H(a); | ||
return await G(a); | ||
} | ||
;async function J(a, b) { | ||
;async function I(a, b) { | ||
if (!a) { | ||
throw Error("No path is given."); | ||
} | ||
const c = G(!0), d = la(a); | ||
const c = F(!0), d = la(a); | ||
await new Promise((e, f) => { | ||
@@ -227,3 +227,3 @@ d.on("error", g => { | ||
async function L(a, b, c) { | ||
const d = G(!0); | ||
const d = F(!0); | ||
if ("function" !== typeof a) { | ||
@@ -237,6 +237,6 @@ throw Error("Function must be passed."); | ||
return await new Promise((f, g) => { | ||
const h = (m, l) => m ? (m = d(m), g(m)) : f(c || l); | ||
const h = (l, m) => l ? (l = d(l), g(l)) : f(c || m); | ||
let k = [h]; | ||
Array.isArray(b) ? (b.forEach((m, l) => { | ||
K(e, l); | ||
Array.isArray(b) ? (b.forEach((l, m) => { | ||
K(e, m); | ||
}), k = [...b, h]) : 1 < Array.from(arguments).length && (K(e, 0), k = [b, h]); | ||
@@ -300,3 +300,3 @@ a(...k); | ||
return `${a}=${b}`; | ||
}, za = ({number:a, J:b, boolean:c, type:d}) => b ? "string" : a ? "number" : c ? "boolean" : d ? d : "*", Aa = a => `/** | ||
}, za = ({number:a, L:b, boolean:c, type:d}) => b ? "string" : a ? "number" : c ? "boolean" : d ? d : "*", Aa = a => `/** | ||
${a} | ||
@@ -338,19 +338,3 @@ */ | ||
}; | ||
function Ea(a) { | ||
var b = Fa; | ||
const c = []; | ||
a.replace(Ga, (d, ...e) => { | ||
d = e.slice(0, e.length - 2).reduce((f, g, h) => { | ||
h = b[h]; | ||
if (!h || void 0 === g) { | ||
return f; | ||
} | ||
f[h] = g; | ||
return f; | ||
}, {}); | ||
c.push(d); | ||
}); | ||
return c; | ||
} | ||
;const Ha = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => { | ||
const Ea = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => { | ||
switch(b) { | ||
@@ -372,3 +356,3 @@ case "function": | ||
}); | ||
function Ia(a) { | ||
function Fa(a) { | ||
let b = 0; | ||
@@ -521,7 +505,7 @@ const c = (d, e) => { | ||
} | ||
;function Ja(a) { | ||
a = Ha(a); | ||
return Ia(a); | ||
;function Ga(a) { | ||
a = Ea(a); | ||
return Fa(a); | ||
} | ||
;function Ka(a, b, {name:c, string:d, "boolean":e, opt:f, number:g, type:h, "default":k, closure:m}) { | ||
;function Ha(a, b, {name:c, string:d, "boolean":e, opt:f, number:g, type:h, "default":k, closure:l}) { | ||
if (!c) { | ||
@@ -532,4 +516,4 @@ throw Error("Property does not have a name."); | ||
b && (a.description = b.trim()); | ||
a.type = za({number:g, J:d, boolean:e, type:h}); | ||
m ? a.c = m : a.c = a.type; | ||
a.type = za({number:g, L:d, boolean:e, type:h}); | ||
l ? a.b = l : a.b = a.type; | ||
void 0 !== k && (a.a = !0); | ||
@@ -546,12 +530,12 @@ a.a && (a.default = k); | ||
b = P(a.name, a.default, a.type, b); | ||
return `{${c ? a.c : a.type}} ${a.optional ? `[${b}]` : b}${`${a.description ? ` ${a.description}` : ""}${a.a ? ` Default \`${a.default}\`.` : ""}`}`; | ||
return `{${c ? a.b : a.type}} ${a.optional ? `[${b}]` : b}${`${a.description ? ` ${a.description}` : ""}${a.a ? ` Default \`${a.default}\`.` : ""}`}`; | ||
} | ||
function La(a, b = !1) { | ||
function Ia(a, b = !1) { | ||
return ` * @prop ${U(a, null, b)}`; | ||
} | ||
class Ma { | ||
class Ja { | ||
constructor() { | ||
this.description = this.name = null; | ||
this.type = "*"; | ||
this.c = null; | ||
this.b = null; | ||
this.a = !1; | ||
@@ -561,3 +545,3 @@ this.default = null; | ||
} | ||
C(a, b = "", c = !1) { | ||
F(a, b = "", c = !1) { | ||
a = U(this, a, c); | ||
@@ -567,3 +551,3 @@ return `${b} * @param ${a}`; | ||
} | ||
;function Na(a, b, {name:c, type:d, desc:e, spread:f, noExpand:g, link:h, closure:k, constructor:m, "extends":l, "interface":n, record:p}, q) { | ||
;function V(a, b, {name:c, type:d, desc:e, noToc:f, spread:g, noExpand:h, "import":k, link:l, closure:m, constructor:n, "extends":p, "interface":q, record:r}, v) { | ||
if (!c) { | ||
@@ -574,23 +558,25 @@ throw Error("Type does not have a name."); | ||
d && (a.type = d); | ||
k ? a.c = k : a.c = a.type; | ||
m ? a.b = m : a.b = a.type; | ||
e && (a.description = e.trim()); | ||
a.u = !!f; | ||
a.m = !!g; | ||
h && (a.link = h); | ||
!0 === m && (a.isConstructor = m); | ||
!0 === n && (a.a = n); | ||
!0 === p && (a.b = p); | ||
l && (a.extends = l); | ||
b && (a.f = T("prop", b).map(({content:r, v}) => { | ||
const D = new Ma; | ||
Ka(D, r, v); | ||
return D; | ||
a.G = !!f; | ||
a.o = !!g; | ||
a.m = !!h; | ||
a.import = !!k; | ||
l && (a.link = l); | ||
!0 === n && (a.isConstructor = n); | ||
!0 === q && (a.a = q); | ||
!0 === r && (a.f = r); | ||
p && (a.extends = p); | ||
b && (a.c = T("prop", b).map(({content:J, v:Ta}) => { | ||
const Y = new Ja; | ||
Ha(Y, J, Ta); | ||
return Y; | ||
})); | ||
q && (a.i = q); | ||
v && (a.i = v); | ||
} | ||
function Oa(a) { | ||
function Ka(a) { | ||
var b = []; | ||
a.description && b.push(` * ${a.description}`); | ||
a.extends && b.push(` * @extends {${a.extends}}`); | ||
b.push(` * @${a.H}`); | ||
b.push(` * @${a.C}`); | ||
b = `/** | ||
@@ -601,3 +587,3 @@ ${b.join("\n")} | ||
b += R(a.i, a.name); | ||
const c = a.f.map(d => { | ||
const c = a.c.map(d => { | ||
var e = []; | ||
@@ -609,3 +595,3 @@ if (d.description) { | ||
} | ||
e.push(` * @type {${d.optional ? `(${d.c}|undefined)` : d.c}}`); | ||
e.push(` * @type {${d.optional ? `(${d.b}|undefined)` : d.b}}`); | ||
e = e.join("\n"); | ||
@@ -620,9 +606,9 @@ e = `/** | ||
} | ||
function V(a, b) { | ||
function W(a, b) { | ||
const c = `${a.extends ? "$" : ""}${a.name}`; | ||
return b ? `${a.l}${c}` : c; | ||
} | ||
function Pa(a, b, c) { | ||
var d = ` * @typedef {${(b ? a.c : a.type) || "Object"}}${` ${V(a, b)}${a.description ? ` ${a.description}` : ""}`}`; | ||
a = a.f ? a.f.map(e => La(e, b)) : []; | ||
function La(a, b, c) { | ||
var d = ` * @typedef {${(b ? a.b : a.type) || "Object"}}${` ${W(a, b)}${a.description ? ` ${a.description}` : ""}`}`; | ||
a = a.c ? a.c.map(e => Ia(e, b)) : []; | ||
d = [d, ...a].join("\n"); | ||
@@ -635,4 +621,4 @@ b && !c && (d = Q(d)); | ||
} | ||
function W(a, b = !1, c = !1) { | ||
const d = a.description ? ` ${a.description}` : "", e = !!a.extends, f = Pa(a, b, c), g = []; | ||
function Ma(a, b = !1, c = !1) { | ||
const d = a.description ? ` ${a.description}` : "", e = !!a.extends, f = La(a, b, c), g = []; | ||
if (a.i && b) { | ||
@@ -647,3 +633,3 @@ let h = ` * @typedef {${a.g}} ${a.name}${d}`; | ||
} | ||
e && (a = ` * @typedef {${a.extends} & ${V(a, b)}} ${b ? a.g : a.name}${d}`, b && !c && (a = Q(a)), a = `/** | ||
e && (a = ` * @typedef {${a.extends} & ${W(a, b)}} ${b ? a.g : a.name}${d}`, b && !c && (a = Q(a)), a = `/** | ||
${a} | ||
@@ -658,12 +644,12 @@ */ | ||
this.name = ""; | ||
this.link = this.m = this.u = this.description = this.c = this.type = null; | ||
this.f = []; | ||
this.link = this.m = this.import = this.o = this.G = this.description = this.b = this.type = null; | ||
this.c = []; | ||
this.i = null; | ||
this.b = this.a = this.isConstructor = !1; | ||
this.f = this.a = this.isConstructor = !1; | ||
this.extends = null; | ||
} | ||
get I() { | ||
return this.isConstructor || this.a || this.b; | ||
get K() { | ||
return this.isConstructor || this.a || this.f; | ||
} | ||
get H() { | ||
get C() { | ||
if (this.isConstructor) { | ||
@@ -675,3 +661,3 @@ return "constructor"; | ||
} | ||
if (this.b) { | ||
if (this.f) { | ||
return "record"; | ||
@@ -687,14 +673,14 @@ } | ||
} | ||
C(a, b, c, d, e = !1) { | ||
F(a, b, c, d, e = !1) { | ||
var f = ""; | ||
!0 === d ? f = "?" : !1 === d && (f = "!"); | ||
d = this.description ? ` ${this.description}` : ""; | ||
const g = this.u ? Y(this.f) : e ? this.g : this.name; | ||
const g = this.o ? Na(this.c) : e ? this.g : this.name; | ||
b = `${c || ""} * @param {${f}${g}} ${b ? `[${a}]` : a}${d}`; | ||
f = this.f && !this.m ? this.f.map(h => h.C(a, c, e)) : []; | ||
f = this.c && !this.m ? this.c.map(h => h.F(a, c, e)) : []; | ||
return [b, ...f].join("\n"); | ||
} | ||
} | ||
const Y = (a = [], b = !1) => `{ ${a.map(c => { | ||
const d = b ? c.c : c.type; | ||
const Na = (a = [], b = !1) => `{ ${a.map(c => { | ||
const d = b ? c.b : c.type; | ||
let e = c.name, f = d; | ||
@@ -704,3 +690,3 @@ c.optional && !b ? e = `${c.name}?` : c.optional && b && (f = `(${d}|undefined)`); | ||
}).join(", ")} }`; | ||
function Qa(a) { | ||
function Oa(a) { | ||
if ("object" != typeof a) { | ||
@@ -714,3 +700,3 @@ return !1; | ||
} | ||
const Ra = (a, b) => { | ||
const Pa = (a, b) => { | ||
if (!(b instanceof Error)) { | ||
@@ -729,17 +715,17 @@ throw b; | ||
}; | ||
async function Sa(a, b) { | ||
async function Qa(a, b) { | ||
b instanceof na ? b.pipe(a) : a.end(b); | ||
return await H(a); | ||
return await G(a); | ||
} | ||
class Ta extends A { | ||
class Ra extends A { | ||
constructor(a, b) { | ||
super(b); | ||
this.l = (Array.isArray(a) ? a : [a]).filter(Qa); | ||
this.m = (Array.isArray(a) ? a : [a]).filter(Oa); | ||
this.a = !1; | ||
this.u = b; | ||
this.C = b; | ||
} | ||
async replace(a, b) { | ||
const c = new Ta(this.l, this.u); | ||
const c = new Ra(this.m, this.C); | ||
b && Object.assign(c, b); | ||
a = await Sa(c, a); | ||
a = await Qa(c, a); | ||
c.a && this.brake(); | ||
@@ -755,3 +741,3 @@ b && Object.keys(b).forEach(d => { | ||
async reduce(a) { | ||
return await this.l.reduce(async(b, {re:c, replacement:d}) => { | ||
return await this.m.reduce(async(b, {re:c, replacement:d}) => { | ||
b = await b; | ||
@@ -772,7 +758,7 @@ if (this.a) { | ||
} | ||
const m = d.call(this, h, ...k); | ||
m instanceof Promise && e.push(m); | ||
return m; | ||
} catch (m) { | ||
Ra(f, m); | ||
const l = d.call(this, h, ...k); | ||
l instanceof Promise && e.push(l); | ||
return l; | ||
} catch (l) { | ||
Pa(f, l); | ||
} | ||
@@ -785,3 +771,3 @@ }); | ||
} catch (h) { | ||
Ra(f, h); | ||
Pa(f, h); | ||
} | ||
@@ -801,8 +787,8 @@ } else { | ||
} catch (d) { | ||
a = F(d.stack), d.stack = a, c(d); | ||
a = E(d.stack), d.stack = a, c(d); | ||
} | ||
} | ||
} | ||
;function Ua() { | ||
var a = Va; | ||
;function Sa() { | ||
var a = Ua; | ||
let b = ""; | ||
@@ -818,25 +804,26 @@ const c = new A({transform(d, e, f) { | ||
} | ||
;function Wa(a, {name:b, from:c, link:d, ns:e}) { | ||
;function Va(a, {name:b, from:c, desc:d, link:e, ns:f}) { | ||
a.name = b; | ||
a.a = c; | ||
a.link = d; | ||
a.b = e || a.a; | ||
a.from = c; | ||
a.A = d; | ||
a.link = e; | ||
a.l = f || a.from; | ||
} | ||
function Xa(a, b = !0) { | ||
return ` * @typedef {import('${a.a}').${a.name}} ${b ? a.g : a.name}`; | ||
function Wa(a, b = !0) { | ||
return ` * @typedef {import('${a.from}').${a.name}} ${b ? a.g : a.name}`; | ||
} | ||
class Ya { | ||
class Xa { | ||
constructor() { | ||
this.a = this.name = this.b = ""; | ||
this.link = null; | ||
this.from = this.name = this.l = ""; | ||
this.link = this.A = null; | ||
} | ||
get g() { | ||
return `${this.b}.${this.name}`; | ||
return `${this.l}.${this.name}`; | ||
} | ||
} | ||
;function Za(a, b) { | ||
;function Ya(a, b) { | ||
b = b.reduce((c, d) => Object.assign({}, c, {[d.g]:d}), {}); | ||
a.w = Object.assign({}, a.w, b); | ||
} | ||
class $a extends Ta { | ||
class Za extends Ra { | ||
constructor(a, b) { | ||
@@ -847,9 +834,9 @@ b = void 0 === b ? {} : b; | ||
this.on("types", c => { | ||
Za(this, c); | ||
Ya(this, c); | ||
}); | ||
this.on("namespace", c => { | ||
this.b.includes(c) || this.b.push(c); | ||
this.f.includes(c) || this.f.push(c); | ||
}); | ||
this.m = b; | ||
this.b = []; | ||
this.o = b; | ||
this.f = []; | ||
this.h = console.log; | ||
@@ -863,3 +850,3 @@ this.file = null; | ||
static get a() { | ||
return Ya; | ||
return Xa; | ||
} | ||
@@ -870,3 +857,3 @@ get types() { | ||
} | ||
;const ab = a => { | ||
;const $a = a => { | ||
a = T("types", a); | ||
@@ -877,18 +864,22 @@ if (!a.length) { | ||
const [{content:b, v:{namespace:c, ns:d = c}}] = a, e = void 0 == d ? void 0 : d; | ||
a = T("type", b).map(({content:g, v:h}) => { | ||
const k = new X; | ||
Na(k, g, h, e); | ||
a = T("type", b).map(({content:h, v:k}) => { | ||
const l = new X; | ||
V(l, h, k, e); | ||
return l; | ||
}); | ||
const f = T("import", b).map(({v:h}) => { | ||
const k = new Xa; | ||
Va(k, h); | ||
return k; | ||
}), g = f.map(({name:h, from:k, A:l, link:m, l:n}) => { | ||
const p = new X; | ||
V(p, "", {name:h, type:`import('${k}').${h}`, G:!0, import:!0, A:l, link:m}, void 0 == n ? void 0 : n); | ||
return p; | ||
}); | ||
const f = T("import", b).map(({v:g}) => { | ||
const h = new Ya; | ||
Wa(h, g); | ||
return h; | ||
}); | ||
return {i:d, types:a, imports:f}; | ||
return {i:d, types:a, imports:f, M:g}; | ||
}; | ||
const bb = (a, b, c) => { | ||
b = b.map(d => W(d, !0, c)); | ||
const ab = (a, b, c) => { | ||
b = b.map(d => Ma(d, !0, c)); | ||
a = a.map(d => { | ||
d = Xa(d); | ||
d = Wa(d); | ||
return `/** | ||
@@ -900,11 +891,11 @@ ${c ? d : Q(d)} | ||
return [...b, ...a].join(""); | ||
}, cb = (a, b, c) => { | ||
}, bb = (a, b, c) => { | ||
a = [...a.map(d => { | ||
{ | ||
let e; | ||
d.c ? e = ` * @typedef {${d.c}}` : d.I || (e = ` * @typedef {${Y(d.f, !0)}}`); | ||
d.b ? e = ` * @typedef {${d.b}}` : d.K || (e = ` * @typedef {${Na(d.c, !0)}}`); | ||
e ? (d.description && (e = ` * ${d.description}\n${e}`), e = `/** | ||
${e} | ||
*/ | ||
`, d = e += R(d.i, d.name)) : d = Oa(d); | ||
`, d = e += R(d.i, d.name)) : d = Ka(d); | ||
} | ||
@@ -917,39 +908,39 @@ return d; | ||
}; | ||
const eb = {re:/^\/\*\*? (documentary|typal) (.+?) \*\/\n(?:([^\n][\s\S]+?\n))?$/mg, replacement:async function(a, b, c) { | ||
const db = {re:/^\/\*\*? (documentary|typal) (.+?) \*\/\n(?:([^\n][\s\S]+?\n))?$/mg, replacement:async function(a, b, c) { | ||
const [d, ...e] = c.split(/\s+/), f = e.includes("closure"), g = e.includes("externs"), h = e.includes("noSuppress"); | ||
let {s:k, A:m} = this.m; | ||
let {u:k, B:l} = this.o; | ||
f && (k = !0); | ||
g && (m = !0); | ||
g && (l = !0); | ||
try { | ||
this.h("Detected type marker: %s", c); | ||
const l = await I(d), {i:n = null, types:p, imports:q} = ab(l); | ||
const m = await H(d), {i:n = null, types:p, imports:q} = $a(m); | ||
this.emit("types", p); | ||
this.emit("types", q); | ||
let r; | ||
k ? r = bb(q, p, h) : m ? (r = cb(p, n, this.b) + "\n", n && this.emit("namespace", n)) : r = db(q, p); | ||
k ? r = ab(q, p, h) : l ? (r = bb(p, n, this.f) + "\n", n && this.emit("namespace", n)) : r = cb(q, p); | ||
return `/* ${b} ${c} */\n${r}`; | ||
} catch (l) { | ||
return this.h("(%s) Could not process typedef-js: %s", c, l.message), a; | ||
} catch (m) { | ||
return this.h("(%s) Could not process typedef-js: %s", c, m.message), a; | ||
} | ||
}}, db = (a, b) => { | ||
b = b.map(c => W(c)); | ||
a = a.map(c => Xa(c, !1)).map(Aa).join(""); | ||
}}, cb = (a, b) => { | ||
b = b.map(c => Ma(c)); | ||
a = a.map(c => Wa(c, !1)).map(Aa).join(""); | ||
b = b.join(""); | ||
return `${a}${b}`.replace(fb, " * @typedef"); | ||
}, fb = / \*\/\n\/\*\*\n \* @typedef/g; | ||
const hb = {re:/( *) \* @param {(.+?)} (\[)?([^\s\]]+)\]?(?: .+)?((?:\n(?: +)\* @param {(?:.+?)} \[?\4\]?.*)*)/gm, replacement:gb}; | ||
function gb(a, b, c, d, e, f, g) { | ||
const {s:h} = this.m; | ||
return `${a}${b}`.replace(eb, " * @typedef"); | ||
}, eb = / \*\/\n\/\*\*\n \* @typedef/g; | ||
const gb = {re:/( *) \* @param {(.+?)} (\[)?([^\s\]]+)\]?(?: .+)?((?:\n(?: +)\* @param {(?:.+?)} \[?\4\]?.*)*)/gm, replacement:fb}; | ||
function fb(a, b, c, d, e, f, g) { | ||
const {u:h} = this.o; | ||
let k; | ||
f = () => { | ||
if (this.lines && this.file) { | ||
var l; | ||
var m; | ||
{ | ||
let q = l = 0; | ||
let q = m = 0; | ||
for (; q < g;) { | ||
q += this.lines[l].length, l++; | ||
q += this.lines[m].length, m++; | ||
} | ||
l = {line:l, F:b.length + 11}; | ||
m = {line:m, I:b.length + 11}; | ||
} | ||
const {line:n, F:p} = l; | ||
const {line:n, I:p} = m; | ||
this.h("%s:%s:%s", this.file, n, p); | ||
@@ -959,5 +950,5 @@ } | ||
try { | ||
k = Ja(c); | ||
} catch (l) { | ||
return this.h("Error while parsing the type %s", c), this.h(process.env.DEBUG ? l.stack : l.message), f(), a; | ||
k = Ga(c); | ||
} catch (m) { | ||
return this.h("Error while parsing the type %s", c), this.h(process.env.DEBUG ? m.stack : m.message), f(), a; | ||
} | ||
@@ -967,8 +958,8 @@ if (!k) { | ||
} | ||
const m = Object.values(this.types).map(({name:l, g:n}) => h ? n : l); | ||
if (!Z(k, m, this.h, c, f)) { | ||
const l = Object.values(this.types).map(({name:m, g:n}) => h ? n : m); | ||
if (!Z(k, l, this.h, c, f)) { | ||
return a; | ||
} | ||
c = Object.values(this.types).find(({name:l, g:n}) => h ? n == k.name : l == k.name); | ||
return c instanceof $a.a ? a : c.C(e, d, b, k.nullable, h); | ||
c = Object.values(this.types).find(({name:m, g:n}) => h ? n == k.name : m == k.name); | ||
return c instanceof Za.a ? a : c.F(e, d, b, k.nullable, h); | ||
} | ||
@@ -999,4 +990,4 @@ const Z = (a, b, c, d, e) => { | ||
}; | ||
var jb = async() => { | ||
const {s:a = !1, A:b = !1, B:c, types:d} = {s:ca, A:da, B:y, types:ea}; | ||
var ib = async() => { | ||
const {u:a = !1, B:b = !1, D:c, types:d} = {u:ca, B:da, D:y, types:ea}; | ||
await Promise.all(x.map(async e => { | ||
@@ -1006,16 +997,16 @@ var f = await L(z, e); | ||
f.isFile() ? g = [e] : f.isDirectory() && (f = await N(e), g = O(f.content, e)); | ||
await ib(g, a, b, c, d); | ||
await hb(g, a, b, c, d); | ||
})); | ||
}; | ||
const ib = async(a, b = !1, c = !1, d = null, e = null) => { | ||
const hb = async(a, b = !1, c = !1, d = null, e = null) => { | ||
const f = []; | ||
e && await Promise.all(e.split(",").map(async g => { | ||
g = await I(g); | ||
const {types:h, imports:k} = ab(g); | ||
g = await H(g); | ||
const {types:h, imports:k} = $a(g); | ||
f.push(h, k); | ||
})); | ||
await Promise.all(a.map(async g => { | ||
var h = await I(g); | ||
const k = new $a([eb, hb], {s:b, A:c}); | ||
f.forEach(m => k.emit("types", m)); | ||
var h = await H(g); | ||
const k = new Za([db, gb], {u:b, B:c}); | ||
f.forEach(l => k.emit("types", l)); | ||
k.file = g; | ||
@@ -1025,11 +1016,27 @@ k.h = console.error; | ||
k.end(h); | ||
h = await H(k); | ||
"-" == d ? console.log(h) : d ? await J(d, h) : await J(g, h); | ||
h = await G(k); | ||
"-" == d ? console.log(h) : d ? await I(d, h) : await I(g, h); | ||
})); | ||
}; | ||
const kb = a => { | ||
function jb(a) { | ||
var b = kb; | ||
const c = []; | ||
a.replace(lb, (d, ...e) => { | ||
d = e.slice(0, e.length - 2).reduce((f, g, h) => { | ||
h = b[h]; | ||
if (!h || void 0 === g) { | ||
return f; | ||
} | ||
f[h] = g; | ||
return f; | ||
}, {}); | ||
c.push(d); | ||
}); | ||
return c; | ||
} | ||
;const mb = a => { | ||
let b; | ||
"true" == a ? b = !0 : "false" == a ? b = !1 : /^\d+$/.test(a) && (b = parseInt(a, 10)); | ||
return void 0 !== b ? b : a; | ||
}, Ga = /^ \* @prop {(.+?)} (\[)?(.+?)(?:=(["'])?(.+?)\4)?(?:])?(?: (.+?))?(?: Default `(.+?)`.)?$/gm, Fa = "type opt name quote defaultValue description Default".split(" "), Va = new RegExp(`^ \\* @typedef {(.+?)} (.+?)(?: (.+))?\\n((?:${/ \* @prop(?:erty)? .+\n/.source})*)`, "gm"), lb = (a, b, c, d) => { | ||
}, lb = /^ \* @prop {(.+?)} (\[)?(.+?)(?:=(["'])?(.+?)\4)?(?:])?(?: (.+?))?(?: Default `(.+?)`.)?$/gm, kb = "type opt name quote defaultValue description Default".split(" "), Ua = new RegExp(`^ \\* @typedef {(.+?)} (.+?)(?: (.+))?\\n((?:${/ \* @prop(?:erty)? .+\n/.source})*)`, "gm"), nb = (a, b, c, d) => { | ||
d = d.length; | ||
@@ -1040,3 +1047,3 @@ a = a && "Object" != a ? ` type="${a}"` : ""; | ||
}; | ||
class mb extends A { | ||
class ob extends A { | ||
constructor() { | ||
@@ -1046,14 +1053,14 @@ super({writableObjectMode:!0}); | ||
_transform(a, b, c) { | ||
var {type:d, name:e, description:f, f:g} = a; | ||
a = d && d.startsWith("import") ? nb(d, e) : lb(d, e, f, g); | ||
var {type:d, name:e, description:f, c:g} = a; | ||
a = d && d.startsWith("import") ? pb(d, e) : nb(d, e, f, g); | ||
this.push(a); | ||
g.forEach(h => { | ||
var {type:k, name:m, default:l, description:n, optional:p} = h; | ||
var {type:k, name:l, default:m, description:n, optional:p} = h; | ||
{ | ||
h = ["string", "number", "boolean"].includes(k) ? ` ${k}` : ` type="${k}"`; | ||
var q = void 0 !== l; | ||
const r = q ? ` default="${l}"` : ""; | ||
var q = void 0 !== m; | ||
const r = q ? ` default="${m}"` : ""; | ||
q = p && !q ? " opt" : ""; | ||
const v = " ".repeat(4), D = " ".repeat(6); | ||
h = `${v}<prop${q}${h} name="${m}"${r}${n ? `>\n${D}${n}\n${v}</prop>` : "/>"}\n`; | ||
const v = " ".repeat(4), J = " ".repeat(6); | ||
h = `${v}<prop${q}${h} name="${l}"${r}${n ? `>\n${J}${n}\n${v}</prop>` : "/>"}\n`; | ||
} | ||
@@ -1066,3 +1073,3 @@ this.push(h); | ||
} | ||
const nb = (a, b) => { | ||
const pb = (a, b) => { | ||
const c = /import\((['"])(.+?)\1\)/.exec(a); | ||
@@ -1075,3 +1082,3 @@ if (!c) { | ||
}; | ||
class ob extends A { | ||
class qb extends A { | ||
constructor() { | ||
@@ -1082,5 +1089,5 @@ super({objectMode:!0}); | ||
var [, d, e, f, g] = a; | ||
a = Ea(g).map(h => { | ||
var k = Object.assign({}, h), m = h.defaultValue; | ||
const l = h.Default; | ||
a = jb(g).map(h => { | ||
var k = Object.assign({}, h), l = h.defaultValue; | ||
const m = h.Default; | ||
var n = h.opt; | ||
@@ -1090,14 +1097,14 @@ const p = h.name; | ||
k = (delete k.defaultValue, delete k.Default, delete k.opt, delete k.name, delete k.type, k); | ||
n = Object.assign({}, k, {name:p, type:h}, m ? {defaultValue:kb(m)} : {}, l ? {o:kb(l)} : {}, n ? {optional:!0} : {}); | ||
if (m || l) { | ||
m ? m !== l && void 0 !== n.o && (m = P(p, l, h), console.error("%s[%s] does not match Default `%s`.", e, m, n.o)) : (m = P(p, l, h), console.error("%s[%s] got from Default.", e, m)), n.default = "defaultValue" in n ? n.defaultValue : n.o, delete n.defaultValue, delete n.o; | ||
n = Object.assign({}, k, {name:p, type:h}, l ? {defaultValue:mb(l)} : {}, m ? {s:mb(m)} : {}, n ? {optional:!0} : {}); | ||
if (l || m) { | ||
l ? l !== m && void 0 !== n.s && (l = P(p, m, h), console.error("%s[%s] does not match Default `%s`.", e, l, n.s)) : (l = P(p, m, h), console.error("%s[%s] got from Default.", e, l)), n.default = "defaultValue" in n ? n.defaultValue : n.s, delete n.defaultValue, delete n.s; | ||
} | ||
return n; | ||
}); | ||
this.push({type:d, name:e, description:f, f:a}); | ||
this.push({type:d, name:e, description:f, c:a}); | ||
c(); | ||
} | ||
} | ||
async function pb(a) { | ||
const b = Ua(), c = new ob, d = new mb; | ||
async function rb(a) { | ||
const b = Sa(), c = new qb, d = new ob; | ||
b.pipe(c).pipe(d); | ||
@@ -1118,11 +1125,11 @@ b.end(a); | ||
return `<types> | ||
${(await H(d)).trim()} | ||
${(await G(d)).trim()} | ||
</types>`; | ||
} | ||
;var qb = async() => { | ||
const {B:a} = {B:y}; | ||
;var sb = async() => { | ||
const {D:a} = {D:y}; | ||
await Promise.all(x.map(async b => { | ||
b = await I(b); | ||
b = await pb(b); | ||
a ? await J(a, b) : console.log(b); | ||
b = await H(b); | ||
b = await rb(b); | ||
a ? await I(a, b) : console.log(b); | ||
})); | ||
@@ -1139,3 +1146,3 @@ }; | ||
try { | ||
return fa ? await qb() : await jb(); | ||
return fa ? await sb() : await ib(); | ||
} catch (a) { | ||
@@ -1142,0 +1149,0 @@ process.env.DEBUG ? console.log(a.stack) : console.log(a.message); |
{ | ||
"name": "typal", | ||
"version": "1.9.0", | ||
"version": "1.9.1", | ||
"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": "build/index.js", |
@@ -1454,3 +1454,20 @@ # Typal | ||
desc: undefined, | ||
link: undefined } ] } | ||
link: undefined } ], | ||
Imports: | ||
[ Type { | ||
name: 'ServerResponse', | ||
type: 'import(\'http\').ServerResponse', | ||
closureType: 'import(\'http\').ServerResponse', | ||
description: null, | ||
noToc: true, | ||
spread: false, | ||
import: true, | ||
noExpand: false, | ||
link: null, | ||
properties: [], | ||
namespace: 'http', | ||
isConstructor: false, | ||
isInterface: false, | ||
isRecord: false, | ||
extends: null } ] } | ||
``` | ||
@@ -1550,3 +1567,4 @@ | ||
extends: null } ], | ||
imports: [] } | ||
imports: [], | ||
Imports: [] } | ||
``` | ||
@@ -1553,0 +1571,0 @@ |
@@ -44,5 +44,22 @@ import extractTags from 'rexml' | ||
return { namespace, types, imports } | ||
/** | ||
* Imports parsed into types. | ||
*/ | ||
const Imports = imports | ||
.map(({ name, from, desc, link, ns: importNs }) => { | ||
const type = new Type() | ||
type.fromXML('', { | ||
name, | ||
type: `import('${from}').${name}`, | ||
noToc: true, | ||
import: true, | ||
desc, | ||
link, | ||
}, importNs == rootNamespace ? undefined : importNs) | ||
return type | ||
}) | ||
return { namespace, types, imports, Imports } | ||
} | ||
export default parseFile |
import extractTags from 'rexml' | ||
import mismatch from 'mismatch' | ||
import parse from '@typedefs/parser' | ||
@@ -4,0 +3,0 @@ import Property from './Property' |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
252498
3585
1597