Comparing version 1.24.7 to 1.24.8
## 18 December 2019 | ||
### [1.24.8](https://github.com/artdecocode/typal/compare/v1.24.7...v1.24.8) | ||
- [feature] Relative example paths. | ||
### [1.24.7](https://github.com/artdecocode/typal/compare/v1.24.6...v1.24.7) | ||
@@ -4,0 +8,0 @@ |
@@ -7,18 +7,18 @@ #!/usr/bin/env node | ||
const path = require('path'); | ||
var aa = "function" == typeof Object.defineProperties ? Object.defineProperty : function(a, b, d) { | ||
a != Array.prototype && a != Object.prototype && (a[b] = d.value); | ||
var aa = "function" == typeof Object.defineProperties ? Object.defineProperty : function(a, b, c) { | ||
a != Array.prototype && a != Object.prototype && (a[b] = c.value); | ||
}, ba = "undefined" != typeof window && window === this ? this : "undefined" != typeof global && null != global ? global : this; | ||
function ca(a, b) { | ||
if (b) { | ||
var d = ba; | ||
var c = ba; | ||
a = a.split("."); | ||
for (var c = 0; c < a.length - 1; c++) { | ||
var e = a[c]; | ||
e in d || (d[e] = {}); | ||
d = d[e]; | ||
for (var d = 0; d < a.length - 1; d++) { | ||
var e = a[d]; | ||
e in c || (c[e] = {}); | ||
c = c[e]; | ||
} | ||
a = a[a.length - 1]; | ||
c = d[a]; | ||
b = b(c); | ||
b != c && null != b && aa(d, a, {configurable:!0, writable:!0, value:b}); | ||
d = c[a]; | ||
b = b(d); | ||
b != d && null != b && aa(c, a, {configurable:!0, writable:!0, value:b}); | ||
} | ||
@@ -32,4 +32,4 @@ } | ||
}); | ||
const da = (a, b, d, c = !1, e = !1) => { | ||
const f = d ? new RegExp(`^-(${d}|-${b})$`) : new RegExp(`^--${b}$`); | ||
const da = (a, b, c, d = !1, e = !1) => { | ||
const f = c ? new RegExp(`^-(${c}|-${b})$`) : new RegExp(`^--${b}$`); | ||
b = a.findIndex(g => f.test(g)); | ||
@@ -39,19 +39,19 @@ if (-1 == b) { | ||
} | ||
if (c) { | ||
if (d) { | ||
return {value:!0, index:b, length:1}; | ||
} | ||
c = a[b + 1]; | ||
if (!c || "string" == typeof c && c.startsWith("--")) { | ||
d = a[b + 1]; | ||
if (!d || "string" == typeof d && d.startsWith("--")) { | ||
return {argv:a}; | ||
} | ||
e && (c = parseInt(c, 10)); | ||
return {value:c, index:b, length:2}; | ||
e && (d = parseInt(d, 10)); | ||
return {value:d, index:b, length:2}; | ||
}, ea = a => { | ||
const b = []; | ||
for (let d = 0; d < a.length; d++) { | ||
const c = a[d]; | ||
if (c.startsWith("-")) { | ||
for (let c = 0; c < a.length; c++) { | ||
const d = a[c]; | ||
if (d.startsWith("-")) { | ||
break; | ||
} | ||
b.push(c); | ||
b.push(d); | ||
} | ||
@@ -61,12 +61,12 @@ return b; | ||
var a = fa; | ||
return Object.keys(a).reduce((b, d) => { | ||
const c = a[d]; | ||
if ("string" == typeof c) { | ||
return b[`-${c}`] = "", b; | ||
return Object.keys(a).reduce((b, c) => { | ||
const d = a[c]; | ||
if ("string" == typeof d) { | ||
return b[`-${d}`] = "", b; | ||
} | ||
d = c.command ? d : `--${d}`; | ||
c.short && (d = `${d}, -${c.short}`); | ||
let e = c.description; | ||
c.default && (e = `${e}\nDefault: ${c.default}.`); | ||
b[d] = e; | ||
c = d.command ? c : `--${c}`; | ||
d.short && (c = `${c}, -${d.short}`); | ||
let e = d.description; | ||
d.default && (e = `${e}\nDefault: ${d.default}.`); | ||
b[c] = e; | ||
return b; | ||
@@ -77,6 +77,6 @@ }, {}); | ||
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"}}, v = function(a = {}, b = process.argv) { | ||
let [, , ...d] = b; | ||
const c = ea(d); | ||
d = d.slice(c.length); | ||
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"}}, w = function(a = {}, b = process.argv) { | ||
let [, , ...c] = b; | ||
const d = ea(c); | ||
c = c.slice(d.length); | ||
a = Object.entries(a).reduce((g, [h, k]) => { | ||
@@ -91,12 +91,12 @@ g[h] = "string" == typeof k ? {short:k} : k; | ||
const {short:m, boolean:n, number:p, command:q, multiple:r} = k; | ||
if (q && r && c.length) { | ||
l = c; | ||
if (q && r && d.length) { | ||
l = d; | ||
} else { | ||
if (q && c.length) { | ||
l = c[0]; | ||
if (q && d.length) { | ||
l = d[0]; | ||
} else { | ||
const t = da(d, h, m, n, p); | ||
const t = da(c, h, m, n, p); | ||
({value:l} = t); | ||
const {index:u, length:C} = t; | ||
void 0 !== u && C && e.push({index:u, length:C}); | ||
const {index:u, length:v} = t; | ||
void 0 !== u && v && e.push({index:u, length:v}); | ||
} | ||
@@ -109,3 +109,3 @@ } | ||
}, {}); | ||
let f = d; | ||
let f = c; | ||
e.forEach(({index:g, length:h}) => { | ||
@@ -117,7 +117,7 @@ Array.from({length:h}).forEach((k, l) => { | ||
f = f.filter(g => null !== g); | ||
Object.assign(a, {W:f}); | ||
Object.assign(a, {Y:f}); | ||
return a; | ||
}(fa), x = v.source, ia = v.output, ja = v.closure, ka = v.useNamespace, la = v.externs, ma = v.types, na = v.template, oa = v.migrate, pa = v.help, qa = v.version; | ||
}(fa), y = w.source, ia = w.output, ja = w.closure, ka = w.useNamespace, la = w.externs, ma = w.types, na = w.template, oa = w.migrate, pa = w.help, qa = w.version; | ||
function ra(a = {usage:{}}) { | ||
const {usage:b = {}, description:d, line:c, example:e} = a; | ||
const {usage:b = {}, description:c, line:d, example:e} = a; | ||
a = Object.keys(b); | ||
@@ -142,3 +142,3 @@ const f = Object.values(b), [g] = a.reduce(([l = 0, m = 0], n) => { | ||
}, []).map(l => `\t${l}`); | ||
const k = [d, ` ${c || ""}`].filter(l => l ? l.trim() : l).join("\n\n"); | ||
const k = [c, ` ${d || ""}`].filter(l => l ? l.trim() : l).join("\n\n"); | ||
a = `${k ? `${k}\n` : ""} | ||
@@ -153,11 +153,11 @@ ${a.join("\n")} | ||
} | ||
;const {createReadStream:sa, createWriteStream:ta, lstat:y, readFileSync:ua, readdir:va} = fs; | ||
;const {createReadStream:sa, createWriteStream:ta, lstat:z, readFileSync:ua, readdir:va} = fs; | ||
var wa = stream; | ||
const {Transform:z, Writable:xa} = stream; | ||
const ya = (a, b = 0, d = !1) => { | ||
if (0 === b && !d) { | ||
const {Transform:A, Writable:xa} = stream; | ||
const ya = (a, b = 0, c = !1) => { | ||
if (0 === b && !c) { | ||
return a; | ||
} | ||
a = a.split("\n", d ? b + 1 : void 0); | ||
return d ? a[a.length - 1] : a.slice(b).join("\n"); | ||
a = a.split("\n", c ? b + 1 : void 0); | ||
return c ? a[a.length - 1] : a.slice(b).join("\n"); | ||
}, za = (a, b = !1) => ya(a, 2 + (b ? 1 : 0)), Aa = a => { | ||
@@ -168,6 +168,6 @@ ({callee:{caller:a}} = a); | ||
const {homedir:Ba} = os; | ||
const Ea = /\s+at.*(?:\(|\s)(.*)\)?/, Fa = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/, Ga = Ba(), B = a => { | ||
const {pretty:b = !1, ignoredModules:d = ["pirates"]} = {}, c = d.join("|"), e = new RegExp(Fa.source.replace("IGNORED_MODULES", c)); | ||
const Ca = /\s+at.*(?:\(|\s)(.*)\)?/, Da = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/, Ea = Ba(), C = a => { | ||
const {pretty:b = !1, ignoredModules:c = ["pirates"]} = {}, d = c.join("|"), e = new RegExp(Da.source.replace("IGNORED_MODULES", d)); | ||
return a.replace(/\\/g, "/").split("\n").filter(f => { | ||
f = f.match(Ea); | ||
f = f.match(Ca); | ||
if (null === f || !f[1]) { | ||
@@ -178,11 +178,11 @@ 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(Ea, (g, h) => g.replace(h, h.replace(Ga, "~"))) : f).join("\n"); | ||
}).filter(f => f.trim()).map(f => b ? f.replace(Ca, (g, h) => g.replace(h, h.replace(Ea, "~"))) : f).join("\n"); | ||
}; | ||
function Ha(a, b, d = !1) { | ||
return function(c) { | ||
function Ha(a, b, c = !1) { | ||
return function(d) { | ||
var e = Aa(arguments), {stack:f} = Error(); | ||
const g = ya(f, 2, !0), h = (f = c instanceof Error) ? c.message : c; | ||
e = [`Error: ${h}`, ...null !== e && a === e || d ? [b] : [g, b]].join("\n"); | ||
e = B(e); | ||
return Object.assign(f ? c : Error(), {message:h, stack:e}); | ||
const g = ya(f, 2, !0), h = (f = d instanceof Error) ? d.message : d; | ||
e = [`Error: ${h}`, ...null !== e && a === e || c ? [b] : [g, b]].join("\n"); | ||
e = C(e); | ||
return Object.assign(f ? d : Error(), {message:h, stack:e}); | ||
}; | ||
@@ -192,9 +192,9 @@ } | ||
var {stack:b} = Error(); | ||
const d = Aa(arguments); | ||
const c = Aa(arguments); | ||
b = za(b, a); | ||
return Ha(d, b, a); | ||
return Ha(c, b, a); | ||
} | ||
;const Ia = (a, b) => { | ||
b.once("error", d => { | ||
a.emit("error", d); | ||
b.once("error", c => { | ||
a.emit("error", c); | ||
}); | ||
@@ -205,6 +205,6 @@ return b; | ||
constructor(a) { | ||
const {binary:b = !1, rs:d = null, ...c} = a || {}, {P:e = D(!0), proxyError:f} = a || {}, g = (h, k) => e(k); | ||
super(c); | ||
const {binary:b = !1, rs:c = null, ...d} = a || {}, {S:e = D(!0), proxyError:f} = a || {}, g = (h, k) => e(k); | ||
super(d); | ||
this.b = []; | ||
this.M = new Promise((h, k) => { | ||
this.O = new Promise((h, k) => { | ||
this.on("finish", () => { | ||
@@ -220,3 +220,3 @@ let l; | ||
} else { | ||
const m = B(l.stack); | ||
const m = C(l.stack); | ||
l.stack = m; | ||
@@ -227,15 +227,15 @@ f && g`${l}`; | ||
}); | ||
d && Ia(this, d).pipe(this); | ||
c && Ia(this, c).pipe(this); | ||
}); | ||
} | ||
_write(a, b, d) { | ||
_write(a, b, c) { | ||
this.b.push(a); | ||
d(); | ||
c(); | ||
} | ||
get f() { | ||
return this.M; | ||
return this.O; | ||
} | ||
} | ||
const E = async a => { | ||
({f:a} = new Ja({rs:a, P:D(!0)})); | ||
({f:a} = new Ja({rs:a, S:D(!0)})); | ||
return await a; | ||
@@ -251,6 +251,6 @@ }; | ||
} | ||
const d = D(!0), c = ta(a); | ||
const c = D(!0), d = ta(a); | ||
await new Promise((e, f) => { | ||
c.on("error", g => { | ||
g = d(g); | ||
d.on("error", g => { | ||
g = c(g); | ||
f(g); | ||
@@ -265,4 +265,4 @@ }).on("close", e).end(b); | ||
} | ||
async function I(a, b, d) { | ||
const c = D(!0); | ||
async function I(a, b, c) { | ||
const d = D(!0); | ||
if ("function" !== typeof a) { | ||
@@ -276,3 +276,3 @@ throw Error("Function must be passed."); | ||
return await new Promise((f, g) => { | ||
const h = (l, m) => l ? (l = c(l), g(l)) : f(d || m); | ||
const h = (l, m) => l ? (l = d(l), g(l)) : f(c || m); | ||
let k = [h]; | ||
@@ -285,11 +285,11 @@ Array.isArray(b) ? (b.forEach((l, m) => { | ||
} | ||
;const {join:J, relative:La} = path; | ||
async function Ma(a, b) { | ||
b = b.map(async d => { | ||
const c = J(a, d); | ||
return {lstat:await I(y, c), path:c, relativePath:d}; | ||
;const {dirname:La, join:J, relative:Ma, resolve:Na} = path; | ||
async function Oa(a, b) { | ||
b = b.map(async c => { | ||
const d = J(a, c); | ||
return {lstat:await I(z, d), path:d, relativePath:c}; | ||
}); | ||
return await Promise.all(b); | ||
} | ||
const Na = a => a.lstat.isDirectory(), Oa = a => !a.lstat.isDirectory(); | ||
const Pa = a => a.lstat.isDirectory(), Qa = a => !a.lstat.isDirectory(); | ||
async function K(a) { | ||
@@ -300,16 +300,16 @@ if (!a) { | ||
const {ignore:b = []} = {}; | ||
if (!(await I(y, a)).isDirectory()) { | ||
var d = Error("Path is not a directory"); | ||
d.code = "ENOTDIR"; | ||
throw d; | ||
if (!(await I(z, a)).isDirectory()) { | ||
var c = Error("Path is not a directory"); | ||
c.code = "ENOTDIR"; | ||
throw c; | ||
} | ||
d = await I(va, a); | ||
var c = await Ma(a, d); | ||
d = c.filter(Na); | ||
c = c.filter(Oa).reduce((e, f) => { | ||
c = await I(va, a); | ||
var d = await Oa(a, c); | ||
c = d.filter(Pa); | ||
d = d.filter(Qa).reduce((e, f) => { | ||
var g = f.lstat.isDirectory() ? "Directory" : f.lstat.isFile() ? "File" : f.lstat.isSymbolicLink() ? "SymbolicLink" : void 0; | ||
return {...e, [f.relativePath]:{type:g}}; | ||
}, {}); | ||
d = await d.reduce(async(e, {path:f, relativePath:g}) => { | ||
const h = La(a, f); | ||
c = await c.reduce(async(e, {path:f, relativePath:g}) => { | ||
const h = Ma(a, f); | ||
if (b.includes(h)) { | ||
@@ -322,11 +322,11 @@ return e; | ||
}, {}); | ||
return {content:{...c, ...d}, type:"Directory"}; | ||
return {content:{...d, ...c}, type:"Directory"}; | ||
} | ||
const L = (a, b) => { | ||
let d = [], c = []; | ||
let c = [], d = []; | ||
Object.keys(a).forEach(f => { | ||
const {type:g} = a[f]; | ||
"File" == g ? d.push(J(b, f)) : "Directory" == g && c.push(f); | ||
"File" == g ? c.push(J(b, f)) : "Directory" == g && d.push(f); | ||
}); | ||
const e = c.reduce((f, g) => { | ||
const e = d.reduce((f, g) => { | ||
const {content:h} = a[g]; | ||
@@ -336,12 +336,12 @@ g = L(h, J(b, g)); | ||
}, []); | ||
return [...d, ...e]; | ||
return [...c, ...e]; | ||
}; | ||
function Pa(a) { | ||
function Ra(a) { | ||
if ("object" != typeof a) { | ||
return !1; | ||
} | ||
const {re:b, replacement:d} = a; | ||
const {re:b, replacement:c} = a; | ||
a = b instanceof RegExp; | ||
const c = -1 != ["string", "function"].indexOf(typeof d); | ||
return a && c; | ||
const d = -1 != ["string", "function"].indexOf(typeof c); | ||
return a && d; | ||
} | ||
@@ -358,18 +358,18 @@ const M = (a, b) => { | ||
a = b.stack.substr(0, a - 1); | ||
const d = a.lastIndexOf("\n"); | ||
b.stack = a.substr(0, d); | ||
const c = a.lastIndexOf("\n"); | ||
b.stack = a.substr(0, c); | ||
throw b; | ||
}; | ||
function Qa(a, b) { | ||
function d() { | ||
return b.filter(Pa).reduce((c, {re:e, replacement:f}) => { | ||
function Sa(a, b) { | ||
function c() { | ||
return b.filter(Ra).reduce((d, {re:e, replacement:f}) => { | ||
if (this.j) { | ||
return c; | ||
return d; | ||
} | ||
if ("string" == typeof f) { | ||
return c = c.replace(e, f); | ||
return d = d.replace(e, f); | ||
} | ||
{ | ||
let g; | ||
return c.replace(e, (h, ...k) => { | ||
return d.replace(e, (h, ...k) => { | ||
g = Error(); | ||
@@ -385,41 +385,41 @@ try { | ||
} | ||
d.b = () => { | ||
d.j = !0; | ||
c.b = () => { | ||
c.j = !0; | ||
}; | ||
return d.call(d); | ||
return c.call(c); | ||
} | ||
;const Ra = a => new RegExp(`%%_RESTREAM_${a.toUpperCase()}_REPLACEMENT_(\\d+)_%%`, "g"), Sa = (a, b) => `%%_RESTREAM_${a.toUpperCase()}_REPLACEMENT_${b}_%%`, Ta = () => { | ||
var a = {R:/^\/\*\*? (documentary|typal) (.+?) externs (.*?)\*\/\n(?:([^\n][\s\S]+?\n))?$/mg}; | ||
return Object.keys(a).reduce((b, d) => { | ||
;const Ta = a => new RegExp(`%%_RESTREAM_${a.toUpperCase()}_REPLACEMENT_(\\d+)_%%`, "g"), Ua = (a, b) => `%%_RESTREAM_${a.toUpperCase()}_REPLACEMENT_${b}_%%`, Va = () => { | ||
var a = {T:/^\/\*\*? (documentary|typal) (.+?) externs (.*?)\*\/\n(?:([^\n][\s\S]+?\n))?$/mg}; | ||
return Object.keys(a).reduce((b, c) => { | ||
{ | ||
var c = a[d]; | ||
const {getReplacement:e = Sa, getRegex:f = Ra} = {}, g = f(d); | ||
c = {name:d, re:c, regExp:g, getReplacement:e, map:{}, lastIndex:0}; | ||
var d = a[c]; | ||
const {getReplacement:e = Ua, getRegex:f = Ta} = {}, g = f(c); | ||
d = {name:c, re:d, regExp:g, getReplacement:e, map:{}, lastIndex:0}; | ||
} | ||
return {...b, [d]:c}; | ||
return {...b, [c]:d}; | ||
}, {}); | ||
}, Ua = a => { | ||
}, Wa = a => { | ||
var b = []; | ||
const {regExp:d, map:c} = a; | ||
return {re:d, replacement(e, f) { | ||
e = c[f]; | ||
delete c[f]; | ||
return Qa(e, Array.isArray(b) ? b : [b]); | ||
const {regExp:c, map:d} = a; | ||
return {re:c, replacement(e, f) { | ||
e = d[f]; | ||
delete d[f]; | ||
return Sa(e, Array.isArray(b) ? b : [b]); | ||
}}; | ||
}, Va = a => { | ||
const {re:b, map:d, getReplacement:c, name:e} = a; | ||
}, Xa = a => { | ||
const {re:b, map:c, getReplacement:d, name:e} = a; | ||
return {re:b, replacement(f) { | ||
const {lastIndex:g} = a; | ||
d[g] = f; | ||
c[g] = f; | ||
a.lastIndex += 1; | ||
return c(e, g); | ||
return d(e, g); | ||
}}; | ||
}; | ||
async function Wa(a, b) { | ||
return Xa(a, b); | ||
async function Ya(a, b) { | ||
return Za(a, b); | ||
} | ||
class N extends z { | ||
class N extends A { | ||
constructor(a, b) { | ||
super(b); | ||
this.f = (Array.isArray(a) ? a : [a]).filter(Pa); | ||
this.f = (Array.isArray(a) ? a : [a]).filter(Ra); | ||
this.j = !1; | ||
@@ -429,8 +429,8 @@ this.h = b; | ||
async replace(a, b) { | ||
const d = new N(this.f, this.h); | ||
b && Object.assign(d, b); | ||
a = await Wa(d, a); | ||
d.j && (this.j = !0); | ||
b && Object.keys(b).forEach(c => { | ||
b[c] = d[c]; | ||
const c = new N(this.f, this.h); | ||
b && Object.assign(c, b); | ||
a = await Ya(c, a); | ||
c.j && (this.j = !0); | ||
b && Object.keys(b).forEach(d => { | ||
b[d] = c[d]; | ||
}); | ||
@@ -440,3 +440,3 @@ return a; | ||
async reduce(a) { | ||
return await this.f.reduce(async(b, {re:d, replacement:c}) => { | ||
return await this.f.reduce(async(b, {re:c, replacement:d}) => { | ||
b = await b; | ||
@@ -446,8 +446,8 @@ if (this.j) { | ||
} | ||
if ("string" == typeof c) { | ||
b = b.replace(d, c); | ||
if ("string" == typeof d) { | ||
b = b.replace(c, d); | ||
} else { | ||
const e = []; | ||
let f; | ||
const g = b.replace(d, (h, ...k) => { | ||
const g = b.replace(c, (h, ...k) => { | ||
f = Error(); | ||
@@ -458,3 +458,3 @@ try { | ||
} | ||
const l = c.call(this, h, ...k); | ||
const l = d.call(this, h, ...k); | ||
l instanceof Promise && e.push(l); | ||
@@ -469,3 +469,3 @@ return l; | ||
const h = await Promise.all(e); | ||
b = b.replace(d, () => h.shift()); | ||
b = b.replace(c, () => h.shift()); | ||
} catch (h) { | ||
@@ -481,22 +481,22 @@ M(f, h); | ||
} | ||
async _transform(a, b, d) { | ||
async _transform(a, b, c) { | ||
try { | ||
const c = await this.reduce(a); | ||
this.push(c); | ||
d(); | ||
} catch (c) { | ||
a = B(c.stack), c.stack = a, d(c); | ||
const d = await this.reduce(a); | ||
this.push(d); | ||
c(); | ||
} catch (d) { | ||
a = C(d.stack), d.stack = a, c(d); | ||
} | ||
} | ||
} | ||
async function Xa(a, b) { | ||
async function Za(a, b) { | ||
b instanceof wa ? b.pipe(a) : a.end(b); | ||
return await E(a); | ||
} | ||
;function Ya() { | ||
var a = Za; | ||
;function $a() { | ||
var a = ab; | ||
let b = ""; | ||
const d = new z({transform(c, e, f) { | ||
const c = new A({transform(d, e, f) { | ||
let g; | ||
for (b += c.toString(); (c = a.exec(b)) && (d.push(c), g = c, a.global);) { | ||
for (b += d.toString(); (d = a.exec(b)) && (c.push(d), g = d, a.global);) { | ||
} | ||
@@ -506,21 +506,21 @@ g && (b = b.slice(g.index + g[0].length)); | ||
}, objectMode:!0}); | ||
return d; | ||
return c; | ||
} | ||
;const $a = (a, b, d, c) => { | ||
;const bb = (a, b, c, d) => { | ||
if (!a) { | ||
throw Error("The name of the property is not given"); | ||
} | ||
a = `${c ? `${c}.` : ""}${a}`; | ||
a = `${d ? `${d}.` : ""}${a}`; | ||
if (null === b) { | ||
return a; | ||
} | ||
b = Number.isInteger(b) || [!0, !1, "null"].includes(b) || ["number", "boolean"].includes(d) ? b : `"${b}"`; | ||
b = Number.isInteger(b) || [!0, !1, "null"].includes(b) || ["number", "boolean"].includes(c) ? b : `"${b}"`; | ||
return `${a}=${b}`; | ||
}, ab = ({number:a, K:b, boolean:d, type:c}) => b ? "string" : a ? "number" : d ? "boolean" : c ? c : "*", bb = a => `${/[^\w\d._]/.test(a) ? `(${a})` : a}|undefined`, O = a => a ? `/** | ||
}, cb = ({number:a, M:b, boolean:c, type:d}) => b ? "string" : a ? "number" : c ? "boolean" : d ? d : "*", db = a => `${/[^\w\d._]/.test(a) ? `(${a})` : a}|undefined`, O = a => a ? `/** | ||
${a} | ||
*/ | ||
` : "/**\n */\n", P = a => ` * @suppress {nonStandardJsDocs} | ||
${a}`, cb = (a, b, d) => { | ||
${a}`, eb = (a, b, c) => { | ||
a = `${a ? "" : "var "}${a ? `${a}.` : ""}${b}`; | ||
d && (a += ` = ${d}`); | ||
c && (a += ` = ${c}`); | ||
return a; | ||
@@ -537,8 +537,8 @@ }, Q = a => { | ||
} | ||
var d = a.substr(0, b).lastIndexOf("\n"); | ||
-1 == d ? d = 0 : (d++, a = a.substr(d)); | ||
b -= d; | ||
const c = " ".repeat(b); | ||
d = a.split("\n"); | ||
if (d.filter(e => /\S/.test(e)).find(e => !e.startsWith(c))) { | ||
var c = a.substr(0, b).lastIndexOf("\n"); | ||
-1 == c ? c = 0 : (c++, a = a.substr(c)); | ||
b -= c; | ||
const d = " ".repeat(b); | ||
c = a.split("\n"); | ||
if (c.filter(e => /\S/.test(e)).find(e => !e.startsWith(d))) { | ||
return a.trim(); | ||
@@ -548,20 +548,20 @@ } | ||
const e = new RegExp(`^ {${b}}`); | ||
return d.map(f => f.replace(e, "")).join("\n"); | ||
return c.map(f => f.replace(e, "")).join("\n"); | ||
} | ||
}, db = (a, b, d = null) => { | ||
const {async:c, "void":e, "return":f = e ? "void" : "", ...g} = a; | ||
}, fb = (a, b, c = null) => { | ||
const {async:d, "void":e, "return":f = e ? "void" : "", ...g} = a; | ||
({args:a = ""} = a); | ||
a || (a = b.map(({H:h, name:k}) => "this" == k ? `${k}: ${h}` : k.startsWith("...") ? `...${h}` : h).join(",")); | ||
a || (a = b.map(({I:h, name:k}) => "this" == k ? `${k}: ${h}` : k.startsWith("...") ? `...${h}` : h).join(",")); | ||
b = f.replace(/\n\s*/g, " "); | ||
c && b ? b = `!Promise<${b}>` : c && (b = "!Promise"); | ||
!b && "constructor" == g.name && d && (b = d); | ||
d = `function(${a})`; | ||
b && (d += `: ${b}`); | ||
return {U:{...g, async:c}, G:d}; | ||
d && b ? b = `!Promise<${b}>` : d && (b = "!Promise"); | ||
!b && "constructor" == g.name && c && (b = c); | ||
c = `function(${a})`; | ||
b && (c += `: ${b}`); | ||
return {W:{...g, async:d}, H:c}; | ||
}; | ||
function eb(a, b, d) { | ||
const c = []; | ||
function gb(a, b, c) { | ||
const d = []; | ||
b.replace(a, (e, ...f) => { | ||
e = f.slice(0, f.length - 2).reduce((g, h, k) => { | ||
k = d[k]; | ||
k = c[k]; | ||
if (!k || void 0 === h) { | ||
@@ -573,22 +573,22 @@ return g; | ||
}, {}); | ||
c.push(e); | ||
d.push(e); | ||
}); | ||
return c; | ||
return d; | ||
} | ||
;const fb = new RegExp(`${/([^\s>=/]+)/.source}(?:\\s*=\\s*${/(?:"([\s\S]*?)"|'([\s\S]*?)')/.source})?`, "g"), gb = new RegExp(`(?:\\s+((?:${fb.source}\\s*)*))`); | ||
;const hb = new RegExp(`${/([^\s>=/]+)/.source}(?:\\s*=\\s*${/(?:"([\s\S]*?)"|'([\s\S]*?)')/.source})?`, "g"), ib = new RegExp(`(?:\\s+((?:${hb.source}\\s*)*))`); | ||
const R = (a, b) => { | ||
a = (Array.isArray(a) ? a : [a]).join("|"); | ||
return eb(new RegExp(`<(${a})${gb.source}?(?:${/\s*\/>/.source}|${/>([\s\S]+?)?<\/\1>/.source})`, "g"), b, "t a v v1 v2 c".split(" ")).map(({t:d, a:c = "", c:e = ""}) => { | ||
c = c.replace(/\/$/, "").trim(); | ||
c = hb(c); | ||
return {content:e, props:c, tag:d}; | ||
return gb(new RegExp(`<(${a})${ib.source}?(?:${/\s*\/>/.source}|${/>([\s\S]+?)?<\/\1>/.source})`, "g"), b, "t a v v1 v2 c".split(" ")).map(({t:c, a:d = "", c:e = ""}) => { | ||
d = d.replace(/\/$/, "").trim(); | ||
d = jb(d); | ||
return {content:e, props:d, tag:c}; | ||
}); | ||
}, hb = a => eb(fb, a, ["key", "val", "def", "f"]).reduce((b, {key:d, val:c}) => { | ||
if (void 0 === c) { | ||
return b[d] = !0, b; | ||
}, jb = a => gb(hb, a, ["key", "val", "def", "f"]).reduce((b, {key:c, val:d}) => { | ||
if (void 0 === d) { | ||
return b[c] = !0, b; | ||
} | ||
b[d] = "true" == c ? !0 : "false" == c ? !1 : /^\d+$/.test(c) ? parseInt(c, 10) : c; | ||
b[c] = "true" == d ? !0 : "false" == d ? !1 : /^\d+$/.test(d) ? parseInt(d, 10) : d; | ||
return b; | ||
}, {}); | ||
const ib = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => { | ||
const kb = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => { | ||
switch(b) { | ||
@@ -610,5 +610,5 @@ case "function": | ||
}); | ||
function jb(a) { | ||
function lb(a) { | ||
let b = 0; | ||
const d = (e = 1) => a[b + e], c = (e = !0, f = []) => { | ||
const c = (e = 1) => a[b + e], d = (e = !0, f = []) => { | ||
var g = {}; | ||
@@ -626,3 +626,3 @@ let h = a[b]; | ||
b++; | ||
g = {...c(!0, []), ...g}; | ||
g = {...d(!0, []), ...g}; | ||
if (")" != a[b]) { | ||
@@ -646,3 +646,3 @@ throw Error("Expecting closing )"); | ||
try { | ||
var l = c(); | ||
var l = d(); | ||
e[k] = l; | ||
@@ -693,3 +693,3 @@ } catch (n) { | ||
b++; | ||
k.this = c(); | ||
k.this = d(); | ||
} else { | ||
@@ -702,9 +702,9 @@ if ("new" == a[b]) { | ||
b++; | ||
k.new = c(); | ||
k.new = d(); | ||
} else { | ||
if ("." == a[b] && "." == d() && "." == d(2)) { | ||
if ("." == a[b] && "." == c() && "." == c(2)) { | ||
b++; | ||
b++; | ||
b++; | ||
m = c(); | ||
m = d(); | ||
if (")" != a[b]) { | ||
@@ -715,3 +715,3 @@ throw Error("Variable args must come last"); | ||
} else { | ||
m = c(), k.args.push(m), "=" == a[b] && (m.optional = !0, b++); | ||
m = d(), k.args.push(m), "=" == a[b] && (m.optional = !0, b++); | ||
} | ||
@@ -731,6 +731,6 @@ } | ||
b++; | ||
":" == a[b] && (b++, m = c(), void 0 == m.name && m.nullable && (m.name = ""), k.return = m); | ||
":" == a[b] && (b++, m = d(), void 0 == m.name && m.nullable && (m.name = ""), k.return = m); | ||
l.function = k; | ||
} else { | ||
if ("<" == a[b] || (k = "." == a[b] && "<" == d())) { | ||
if ("<" == a[b] || (k = "." == a[b] && "<" == c())) { | ||
b++; | ||
@@ -740,3 +740,3 @@ k && b++; | ||
for (k = []; ">" != a[b];) { | ||
m = c(); | ||
m = d(); | ||
k.push(m); | ||
@@ -759,3 +759,3 @@ if (">" == a[b]) { | ||
b++; | ||
({name:l} = c(!1)); | ||
({name:l} = d(!1)); | ||
if (!l) { | ||
@@ -770,19 +770,19 @@ throw Error("Expected to see the name after ."); | ||
for (f.push(g); "|" == a[b];) { | ||
b++, g = c(!0, f), g.union !== f && f.push(g); | ||
b++, g = d(!0, f), g.union !== f && f.push(g); | ||
} | ||
return {union:f}; | ||
}; | ||
return c(); | ||
return d(); | ||
} | ||
;function kb(a) { | ||
a = ib(a); | ||
return jb(a); | ||
;function mb(a) { | ||
a = kb(a); | ||
return lb(a); | ||
} | ||
;function lb(a, b, {name:d, string:c, "boolean":e, opt:f, number:g, type:h}, k) { | ||
if (!d) { | ||
;function nb(a, b, {name:c, string:d, "boolean":e, opt:f, number:g, type:h}, k) { | ||
if (!c) { | ||
throw Error("Argument does not have a name."); | ||
} | ||
a.name = d; | ||
a.name = c; | ||
b && (a.description = Q(b)); | ||
b = ab({number:g, K:c, boolean:e, type:h}); | ||
b = cb({number:g, M:d, boolean:e, type:h}); | ||
k && (b = b.replace(new RegExp(`([!?])?${k}\\.`, "g"), "$1")); | ||
@@ -793,3 +793,3 @@ b.endsWith("=") && (b = b.replace(/=$/, ""), f = !0); | ||
} | ||
class mb { | ||
class ob { | ||
constructor() { | ||
@@ -801,15 +801,15 @@ this.name = null; | ||
} | ||
get H() { | ||
get I() { | ||
return this.optional ? `${this.type}=` : this.type; | ||
} | ||
} | ||
const nb = (a, b) => { | ||
let d = a.lastIndexOf("</arg>"), c = a; | ||
const pb = (a, b) => { | ||
let c = a.lastIndexOf("</arg>"), d = a; | ||
var e = []; | ||
-1 != d && (d += 6, e = a.slice(0, d), c = a.slice(d), e = R("arg", e), e = e.map(({content:f, props:g}) => { | ||
const h = new mb; | ||
lb(h, f, g, b); | ||
-1 != c && (c += 6, e = a.slice(0, c), d = a.slice(c), e = R("arg", e), e = e.map(({content:f, props:g}) => { | ||
const h = new ob; | ||
nb(h, f, g, b); | ||
return h; | ||
})); | ||
return {I:c, D:e}; | ||
return {K:d, F:e}; | ||
}; | ||
@@ -824,38 +824,38 @@ function S(a) { | ||
b += a.name + "("; | ||
const c = []; | ||
const d = []; | ||
if (a.function.this) { | ||
var d = "this: " + S(a.function.this); | ||
c.push(d); | ||
var c = "this: " + S(a.function.this); | ||
d.push(c); | ||
} | ||
a.function.new && (d = "new: " + S(a.function.new), c.push(d)); | ||
a.function.new && (c = "new: " + S(a.function.new), d.push(c)); | ||
a.function.args.forEach(e => { | ||
let f = S(e); | ||
e.optional && (f += "="); | ||
c.push(f); | ||
d.push(f); | ||
}); | ||
a.function.variableArgs && (d = "..." + S(a.function.variableArgs), c.push(d)); | ||
d = c.join(", "); | ||
b += d + ")"; | ||
a.function.variableArgs && (c = "..." + S(a.function.variableArgs), d.push(c)); | ||
c = d.join(", "); | ||
b += c + ")"; | ||
a.function.return && (b += ": " + S(a.function.return)); | ||
} else { | ||
if (a.record) { | ||
b += "{ ", d = Object.keys(a.record).map(c => { | ||
var e = a.record[c]; | ||
b += "{ ", c = Object.keys(a.record).map(d => { | ||
var e = a.record[d]; | ||
if (!e) { | ||
return c; | ||
return d; | ||
} | ||
e = S(e); | ||
return `${c}: ${e}`; | ||
}), b += d.join(", "), b += " }"; | ||
return `${d}: ${e}`; | ||
}), b += c.join(", "), b += " }"; | ||
} else { | ||
if (a.application) { | ||
if ("Promise" == a.name && !a.application.some(c => "void" != c.name)) { | ||
if ("Promise" == a.name && !a.application.some(d => "void" != d.name)) { | ||
return b + "Promise"; | ||
} | ||
b += a.name + "<"; | ||
d = a.application.map(c => S(c)); | ||
b += d.join(", "); | ||
c = a.application.map(d => S(d)); | ||
b += c.join(", "); | ||
b += ">"; | ||
} else { | ||
a.union ? (b += "(", d = a.union.map(c => S(c)), b += d.join("|"), b += ")") : b += "any" == a.name ? "*" : a.name; | ||
a.union ? (b += "(", c = a.union.map(d => S(d)), b += c.join("|"), b += ")") : b += "any" == a.name ? "*" : a.name; | ||
} | ||
@@ -866,24 +866,24 @@ } | ||
} | ||
;const T = (a, b = !1) => a.split("\n").map((d, c) => { | ||
if (b && !c) { | ||
return d; | ||
;const T = (a, b = !1) => a.split("\n").map((c, d) => { | ||
if (b && !d) { | ||
return c; | ||
} | ||
c = " *"; | ||
d.length && (c += " "); | ||
return c + d; | ||
}).join("\n"), ob = a => { | ||
const b = a.replace(/^\s*\n/gm, "").split("\n").reduce((d, c) => { | ||
[{length:c = 0} = {}] = /^\s*/.exec(c) || []; | ||
return c < d ? c : d; | ||
d = " *"; | ||
c.length && (d += " "); | ||
return d + c; | ||
}).join("\n"), qb = a => { | ||
const b = a.replace(/^\s*\n/gm, "").split("\n").reduce((c, d) => { | ||
[{length:d = 0} = {}] = /^\s*/.exec(d) || []; | ||
return d < c ? d : c; | ||
}, Infinity); | ||
return a.replace(new RegExp(`^ {${b}}`, "gm"), ""); | ||
}; | ||
function pb(a, b = "") { | ||
const d = b.split(/\s*,\s*/); | ||
return a.split(/\s*,\s*/).map(c => { | ||
let e = c = ua(c, "utf8"); | ||
if (c = /\/\* start example \*\/\r?\n([\s\S]+?)\r?\n\s*\/\* end example \*\//.exec(c)) { | ||
[, c] = c, e = ob(c); | ||
function rb(a, b = "") { | ||
const c = b.split(/\s*,\s*/); | ||
return a.split(/\s*,\s*/).map(d => { | ||
let e = d = ua(d, "utf8"); | ||
if (d = /\/\* start example \*\/\r?\n([\s\S]+?)\r?\n\s*\/\* end example \*\//.exec(d)) { | ||
[, d] = d, e = qb(d); | ||
} | ||
d.forEach(f => { | ||
c.forEach(f => { | ||
const [g, h] = f.split(/\s*=>\s*/); | ||
@@ -896,5 +896,5 @@ e = e.replace(`'${g}'`, `'${h}'`); | ||
} | ||
function qb(a, {N:b = !0, S:d = !0} = {}) { | ||
const c = []; | ||
b && c.push(" * @example"); | ||
function sb(a, {P:b = !0, U:c = !0} = {}) { | ||
const d = []; | ||
b && d.push(" * @example"); | ||
a.forEach(e => { | ||
@@ -913,37 +913,37 @@ let f = [], g = [], h = "", k; | ||
}, []); | ||
d && (e = e.map(l => T(l))); | ||
c.push(...e); | ||
c && (e = e.map(l => T(l))); | ||
d.push(...e); | ||
}); | ||
return c; | ||
return d; | ||
} | ||
function rb(a, b, d = new RegExp(`([!?])?${b}\\.`, "g")) { | ||
b && (a.type = a.type.replace(d, "$1")); | ||
function tb(a, b, c = new RegExp(`([!?])?${b}\\.`, "g")) { | ||
b && (a.type = a.type.replace(c, "$1")); | ||
} | ||
function sb(a, b = !1) { | ||
function ub(a, b = !1) { | ||
return b ? a.closureType : a.isParsedFunction ? a.toTypeScriptFunction(S) : a.type; | ||
} | ||
function tb(a, b = null, d = !1, c = !1) { | ||
function vb(a, b = null, c = !1, d = !1) { | ||
if (!a.name) { | ||
throw Error("Property does not have a name. Has it been constructed using fromXML?"); | ||
} | ||
b = $a(a.name, a.optional ? a.default : null, a.type, b); | ||
b = bb(a.name, a.optional ? a.default : null, a.type, b); | ||
b = a.optional ? `[${b}]` : b; | ||
var {m:e} = a; | ||
e = e ? ` ${e}` : ""; | ||
d = `{${sb(a, d)}} ${b}${e}`; | ||
c && (a = qb(a.examples, {N:!1, S:!1}).join("\n").replace(/\*/g, "\uff0a")) && (d += `\n${a}`); | ||
return d; | ||
c = `{${ub(a, c)}} ${b}${e}`; | ||
d && (a = sb(a.examples, {P:!1, U:!1}).join("\n").replace(/\*/g, "\uff0a")) && (c += `\n${a}`); | ||
return c; | ||
} | ||
function ub(a, b = !1) { | ||
a = tb(a, null, b, !0); | ||
function wb(a, b = !1) { | ||
a = vb(a, null, b, !0); | ||
return ` * @prop ${T(a, !0)}`; | ||
} | ||
function vb(a) { | ||
const b = [], {function:{args:d, return:c, variableArgs:e, this:f}} = a.parsed; | ||
d.map(h => S(h)).forEach((h, k) => { | ||
const {optional:l} = d[k], {name:m = `arg${k}`, description:n} = a.args[k] || {}; | ||
function xb(a) { | ||
const b = [], {function:{args:c, return:d, variableArgs:e, this:f}} = a.parsed; | ||
c.map(h => S(h)).forEach((h, k) => { | ||
const {optional:l} = c[k], {name:m = `arg${k}`, description:n} = a.args[k] || {}; | ||
b.push(` * @param {${h}${l ? "=" : ""}} ${l ? `[${m}]` : m}${n ? ` ${n}` : ""}`); | ||
}); | ||
if (e) { | ||
const {L:h, V:k} = wb(a.args || []); | ||
const {N:h, X:k} = yb(a.args || []); | ||
var g = [h, k].filter(Boolean).join(" "); | ||
@@ -953,35 +953,35 @@ b.push(` * @param {...${S(e)}} ${g}`); | ||
f && b.push(` * @this {${S(f)}}`); | ||
c && "void" != c.name && (g = S(c), b.push(` * @return {${g}}`)); | ||
d && "void" != d.name && (g = S(d), b.push(` * @return {${g}}`)); | ||
return b; | ||
} | ||
function xb(a) { | ||
function zb(a) { | ||
if (a.isParsedFunction) { | ||
const {function:{args:b, variableArgs:d}} = a.parsed, c = b.map((e, f) => { | ||
const {function:{args:b, variableArgs:c}} = a.parsed, d = b.map((e, f) => { | ||
({name:e = `arg${f}`} = a.l[f] || {}); | ||
return e; | ||
}); | ||
if (d) { | ||
const {L:e} = wb(a.args || []); | ||
c.push(`...${e}`); | ||
if (c) { | ||
const {N:e} = yb(a.args || []); | ||
d.push(`...${e}`); | ||
} | ||
return ` = function(${c.join(", ")}) {}`; | ||
return ` = function(${d.join(", ")}) {}`; | ||
} | ||
return a.type.startsWith("function(") ? " = function() {}" : ""; | ||
} | ||
function U(a, b = "", d = !1) { | ||
let c = []; | ||
function U(a, b = "", c = !1) { | ||
let d = []; | ||
var {m:e} = a; | ||
e && (e = T(e), c.push(...e.split("\n"))); | ||
!a.optional && a.isParsedFunction ? (e = vb(a), c.push(...e)) : c.push(` * @type {${a.optional ? bb(a.closureType) : a.closureType}}`); | ||
d && a.examples.length && (a = qb(a.examples), c.push(...a)); | ||
b && (c = c.map(f => `${b}${f}`)); | ||
return c.join("\n"); | ||
e && (e = T(e), d.push(...e.split("\n"))); | ||
!a.optional && a.isParsedFunction ? (e = xb(a), d.push(...e)) : d.push(` * @type {${a.optional ? db(a.closureType) : a.closureType}}`); | ||
c && a.examples.length && (a = sb(a.examples), d.push(...a)); | ||
b && (d = d.map(f => `${b}${f}`)); | ||
return d.join("\n"); | ||
} | ||
function yb(a, b) { | ||
const d = Object.assign(Object.create(Object.getPrototypeOf(a)), a); | ||
d.description = `An alias for \`${a.name}\`.`; | ||
d.name = b; | ||
return d; | ||
function Ab(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 zb { | ||
class Bb { | ||
constructor(a = null) { | ||
@@ -1003,3 +1003,3 @@ this.g = this.description = this.name = null; | ||
} | ||
const {function:{args:b, return:d, this:c, variableArgs:e}} = this.parsed; | ||
const {function:{args:b, return:c, this:d, variableArgs:e}} = this.parsed; | ||
var f = b.map(h => a(h)).map((h, k) => { | ||
@@ -1010,4 +1010,4 @@ const {optional:l} = b[k]; | ||
}); | ||
if (c) { | ||
var g = a(c); | ||
if (d) { | ||
var g = a(d); | ||
f.unshift(`this: ${g}`); | ||
@@ -1025,3 +1025,3 @@ } | ||
f = f.join(", "); | ||
g = d ? a(d) : "?"; | ||
g = c ? a(c) : "?"; | ||
return `(${f}) => ${g}`; | ||
@@ -1035,3 +1035,3 @@ } | ||
} | ||
b(a, {name:b, string:d, "boolean":c, opt:e, number:f, type:g, "default":h, closure:k, alias:l, aliases:m, example:n, "example-override":p = "", noParams:q, "static":r, initial:t}) { | ||
b(a, {name:b, string:c, "boolean":d, opt:e, number:f, type:g, "default":h, closure:k, alias:l, aliases:m, example:n, "example-override":p = "", noParams:q, "static":r, initial:t}) { | ||
if (!b) { | ||
@@ -1042,3 +1042,3 @@ throw Error("Property does not have a name."); | ||
a && (this.description = Q(a)); | ||
a = ab({number:f, K:d, boolean:c, type:g}); | ||
a = cb({number:f, M:c, boolean:d, type:g}); | ||
q && (this.o = q); | ||
@@ -1054,3 +1054,3 @@ k && (this.h = k); | ||
r && (this.f = !0); | ||
n && (this.examples = pb(n, p)); | ||
n && (this.examples = rb(n, p)); | ||
} | ||
@@ -1065,3 +1065,3 @@ get type() { | ||
try { | ||
this.parsed = kb(this.closureType), this.isParsedFunction && !this.args && (this.args = []); | ||
this.parsed = mb(this.closureType), this.isParsedFunction && !this.args && (this.args = []); | ||
} catch (b) { | ||
@@ -1084,15 +1084,15 @@ this.parsed = null; | ||
} | ||
B(a, b = "", d = !1) { | ||
a = tb(this, a, d); | ||
const [c, ...e] = a.split("\n"); | ||
return [`@param ${c}`, ...e].map(f => `${b} * ${f}`).join("\n"); | ||
C(a, b = "", c = !1) { | ||
a = vb(this, a, c); | ||
const [d, ...e] = a.split("\n"); | ||
return [`@param ${d}`, ...e].map(f => `${b} * ${f}`).join("\n"); | ||
} | ||
} | ||
const wb = a => { | ||
const yb = a => { | ||
let b = "args"; | ||
const {name:d = "", description:c} = a[a.length - 1] || {}; | ||
d.startsWith("...") && (b = d.replace("...", "")); | ||
return {L:b, V:c}; | ||
const {name:c = "", description:d} = a[a.length - 1] || {}; | ||
c.startsWith("...") && (b = c.replace("...", "")); | ||
return {N:b, X:d}; | ||
}; | ||
class V extends zb { | ||
class V extends Bb { | ||
constructor(...a) { | ||
@@ -1108,9 +1108,9 @@ super(...a); | ||
} | ||
;const X = (a, b, d = {}) => { | ||
let c; | ||
;const X = (a, b, c = {}) => { | ||
let d; | ||
if ("object" == typeof b) { | ||
c = b; | ||
d = b; | ||
} else { | ||
try { | ||
(c = kb(b)) || console.log("Could not parse %s", b); | ||
(d = mb(b)) || console.log("Could not parse %s", b); | ||
} catch (e) { | ||
@@ -1120,8 +1120,8 @@ console.log("Could not parse %s", b), console.error(e.message); | ||
} | ||
return c ? W(c, a, d) : b; | ||
}, W = (a, b, d = {}) => { | ||
return d ? W(d, a, c) : b; | ||
}, W = (a, b, c = {}) => { | ||
if ("" == a.name && a.nullable) { | ||
return "?"; | ||
} | ||
var {escapePipe:c = !0} = d; | ||
var {escapePipe:d = !0} = c; | ||
let e = ""; | ||
@@ -1133,15 +1133,15 @@ var f = ""; | ||
const g = []; | ||
a.function.this && (c = "this: " + W(a.function.this, b, d), g.push(c)); | ||
a.function.new && (c = "new: " + W(a.function.new, b, d), g.push(c)); | ||
a.function.this && (d = "this: " + W(a.function.this, b, c), g.push(d)); | ||
a.function.new && (d = "new: " + W(a.function.new, b, c), g.push(d)); | ||
a.function.args.forEach(h => { | ||
let k = W(h, b, d); | ||
let k = W(h, b, c); | ||
h.optional && (k += "="); | ||
g.push(k); | ||
}); | ||
a.function.variableArgs && (c = "..." + W(a.function.variableArgs, b, d), g.push(c)); | ||
c = g.join(", "); | ||
e += c + ")"; | ||
a.function.return && (e += ": " + W(a.function.return, b, d)); | ||
a.function.variableArgs && (d = "..." + W(a.function.variableArgs, b, c), g.push(d)); | ||
d = g.join(", "); | ||
e += d + ")"; | ||
a.function.return && (e += ": " + W(a.function.return, b, c)); | ||
} else { | ||
a.record ? (e += "{ ", c = Object.keys(a.record).map(g => { | ||
a.record ? (e += "{ ", d = Object.keys(a.record).map(g => { | ||
var h = a.record[g]; | ||
@@ -1151,38 +1151,38 @@ if (!h) { | ||
} | ||
h = W(h, b, d); | ||
h = W(h, b, c); | ||
return `${g}: ${h}`; | ||
}), e += c.join(", "), e += " }") : a.application ? (e += Ab(a.name, b, f, d) + "<", c = a.application.map(g => W(g, b, d)), e += c.join(", "), e += ">") : a.union ? (e = e + f + "(", f = a.union.map(g => W(g, b, d)), e += f.join(c ? " \\| " : " | "), e += ")") : e += Ab("any" == a.name ? "*" : a.name, b, f, d); | ||
}), e += d.join(", "), e += " }") : a.application ? (e += Cb(a.name, b, f, c) + "<", d = a.application.map(g => W(g, b, c)), e += d.join(", "), e += ">") : a.union ? (e = e + f + "(", f = a.union.map(g => W(g, b, c)), e += f.join(d ? " \\| " : " | "), e += ")") : e += Cb("any" == a.name ? "*" : a.name, b, f, c); | ||
} | ||
return e; | ||
}, Ab = (a, b, d = "", c = {}) => { | ||
const {flatten:e = !1, nameProcess:f, link:g = ({link:l}) => `#${l}`} = c; | ||
c = Bb(b, a); | ||
d = `${d}${a}`; | ||
if (!c) { | ||
return d; | ||
}, Cb = (a, b, c = "", d = {}) => { | ||
const {flatten:e = !1, nameProcess:f, link:g = ({link:l}) => `#${l}`} = d; | ||
d = Db(b, a); | ||
c = `${c}${a}`; | ||
if (!d) { | ||
return c; | ||
} | ||
let {link:h, type:{description:k}} = c; | ||
h = g(c); | ||
let {link:h, type:{description:k}} = d; | ||
h = g(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)); | ||
b = f ? f(d) : d; | ||
b = f ? f(c) : c; | ||
return k ? `<a href="${h}" title="${k.replace(/"/g, """)}">${b}</a>` : `[${b}](${h})`; | ||
}, Bb = (a, b) => { | ||
a = a.filter(({fullName:c}) => c == b); | ||
}, Db = (a, b) => { | ||
a = a.filter(({fullName:d}) => d == b); | ||
if (a.length) { | ||
var d = a.find(({import:c}) => c || !1); | ||
a = a.find(({import:c}) => !c) || d; | ||
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(/ /g, "").replace(/[^\w-\d ]/g, "").toLowerCase().replace(/[, ]/g, "-")}`, type:a}; | ||
} | ||
}; | ||
function Cb(a, b = [], d = [], c = {}) { | ||
const {narrow:e = !1, flatten:f = !1, preprocessDesc:g, link:h} = c; | ||
function Eb(a, b = [], c = [], d = {}) { | ||
const {narrow:e = !1, flatten:f = !1, preprocessDesc:g, link:h} = d; | ||
if (!b.length) { | ||
return ""; | ||
} | ||
const k = a.isConstructor || a.isInterface, l = b.some(({hasDefault:p}) => p), m = {flatten:f, escapePipe:!e, link:h}, n = p => X(d, p, m); | ||
const k = a.isConstructor || a.isInterface, l = b.some(({hasDefault:p}) => p), m = {flatten:f, escapePipe:!e, link:h}, n = p => X(c, p, m); | ||
a = b.map(p => { | ||
let q; | ||
p.args && p.isParsedFunction ? (q = p.toTypeScriptFunction(n), p.isConstructor && (q = `new ${q}`)) : q = X(d, p.parsed || p.type, m); | ||
p.args && p.isParsedFunction ? (q = p.toTypeScriptFunction(n), p.isConstructor && (q = `new ${q}`)) : q = X(c, p.parsed || p.type, m); | ||
const r = k || p.optional ? p.name : `${p.name}*`, t = p.hasDefault ? `\`${p.default}\`` : "-", u = g ? g(p.description) : p.description; | ||
return {prop:p, typeName:q, name:r, de:Db(u, !e), d:t}; | ||
return {prop:p, typeName:q, name:r, de:Fb(u, !e), d:t}; | ||
}); | ||
@@ -1200,3 +1200,3 @@ if (e) { | ||
} | ||
const Db = (a = "", b = !0) => { | ||
const Fb = (a = "", b = !0) => { | ||
null === a && (a = ""); | ||
@@ -1206,25 +1206,25 @@ b && (a = a.replace(/\|/g, "\\|")); | ||
}; | ||
function Eb(a) { | ||
var b = a.g(); | ||
function Gb(a) { | ||
var b = a.h(); | ||
b = O(b.join("\n")); | ||
b += cb(a.namespace, a.name, Fb(a)); | ||
const d = a.properties.reduce((c, e) => { | ||
c.push(e); | ||
const f = e.aliases.map(g => yb(e, g)); | ||
c.push(...f); | ||
return c; | ||
}, []).filter(c => c instanceof V && c.isConstructor ? !1 : !0).map(c => { | ||
let e = U(c); | ||
b += eb(a.namespace, a.name, Hb(a)); | ||
const c = a.properties.reduce((d, e) => { | ||
d.push(e); | ||
const f = e.aliases.map(g => Ab(e, g)); | ||
d.push(...f); | ||
return d; | ||
}, []).filter(d => d instanceof V && d.isConstructor ? !1 : !0).map(d => { | ||
let e = U(d); | ||
e = O(e); | ||
e += cb(`${a.fullName}${c.static ? "" : ".prototype"}`, c.name); | ||
return e += xb(c); | ||
e += eb(`${a.fullName}${d.static ? "" : ".prototype"}`, d.name); | ||
return e += zb(d); | ||
}); | ||
return [b, ...d].join("\n"); | ||
return [b, ...c].join("\n"); | ||
} | ||
function Gb(a, b = !1) { | ||
const d = `${a.extends ? "$" : ""}${a.name}`; | ||
return b ? `${a.ns}${d}` : d; | ||
function Ib(a, b = !1) { | ||
const c = `${a.extends ? "$" : ""}${a.name}`; | ||
return b ? `${a.ns}${c}` : c; | ||
} | ||
function Hb(a, b = !1, d = !1, c = b) { | ||
c = ` * @typedef {${(b ? a.closureType : a.type) || a.m()}}${` ${Gb(a, c)}${a.h}`}`; | ||
function Jb(a, b = !1, c = !1, d = b) { | ||
d = ` * @typedef {${(b ? a.closureType : a.type) || a.o()}}${` ${Ib(a, d)}${a.l}`}`; | ||
a = (a.properties ? a.properties.reduce((e, f) => { | ||
@@ -1235,11 +1235,11 @@ if (f.f) { | ||
e.push(f); | ||
const g = f.aliases.map(h => yb(f, h)); | ||
const g = f.aliases.map(h => Ab(f, h)); | ||
e.push(...g); | ||
return e; | ||
}, []) : []).map(e => ub(e, b)); | ||
a = [c, ...a].join("\n"); | ||
b && !d && (a = P(a)); | ||
}, []) : []).map(e => wb(e, b)); | ||
a = [d, ...a].join("\n"); | ||
b && !c && (a = P(a)); | ||
return a = O(a); | ||
} | ||
function Fb(a) { | ||
function Hb(a) { | ||
return a.args ? `function(${a.args.filter(({name:b}) => "this" != b).map(({name:b}) => b).join(", ")}) {}` : null; | ||
@@ -1258,2 +1258,3 @@ } | ||
this.examples = []; | ||
this.file = null; | ||
} | ||
@@ -1263,3 +1264,3 @@ get import() { | ||
} | ||
b(a, {name:b, type:d, desc:c, noToc:e, spread:f, noExpand:g, link:h, closure:k, constructor:l, "extends":m, "interface":n, record:p, example:q, "example-override":r}, t, u = null) { | ||
b(a, {name:b, type:c, desc:d, noToc:e, spread:f, noExpand:g, link:h, closure:k, constructor:l, "extends":m, "interface":n, record:p, example:q, "example-override":r}, t, u = null) { | ||
if (!b) { | ||
@@ -1269,5 +1270,5 @@ throw Error("Type does not have a name."); | ||
this.name = b; | ||
d && (this.type = d); | ||
c && (this.type = c); | ||
k ? this.closureType = k : this.closureType = this.type; | ||
c && (this.description = Q(c)); | ||
d && (this.description = Q(d)); | ||
this.noToc = !!e; | ||
@@ -1283,39 +1284,44 @@ this.spread = !!f; | ||
if (a) { | ||
b = R("prop", a).map(({content:w, props:A}) => { | ||
const F = new zb; | ||
F.b(w, A); | ||
b = R("prop", a).map(({content:x, props:B}) => { | ||
const F = new Bb; | ||
F.b(x, B); | ||
return F; | ||
}); | ||
a = R(["function", "fn", "static"], a).map(({content:w, props:A, tag:F}) => { | ||
a = R(["function", "fn", "static"], a).map(({content:x, props:B, tag:F}) => { | ||
F = "static" == F; | ||
const {I:Xb, D:Ca} = nb(w, u); | ||
w = new V(Ca); | ||
const {U:Da, G:Yb} = db(A, Ca, this.fullName); | ||
Da.type = Yb; | ||
w.b(Xb, Da); | ||
F && (w.f = !0); | ||
return w; | ||
const {K:Zb, F:Fa} = pb(x, u); | ||
x = new V(Fa); | ||
const {W:Ga, H:$b} = fb(B, Fa, this.fullName); | ||
Ga.type = $b; | ||
x.b(Zb, Ga); | ||
F && (x.f = !0); | ||
return x; | ||
}); | ||
a = [...b, ...a]; | ||
const {F:C, J:Zb, n:$b} = a.reduce((w, A) => { | ||
A.isConstructor ? w.F.push(A) : A.static ? w.J.push(A) : w.n.push(A); | ||
return w; | ||
}, {F:[], J:[], n:[]}); | ||
this.properties = [...C, ...Zb, ...$b]; | ||
const {G:v, L:ac, n:bc} = a.reduce((x, B) => { | ||
B.isConstructor ? x.G.push(B) : B.static ? x.L.push(B) : x.n.push(B); | ||
return x; | ||
}, {G:[], L:[], n:[]}); | ||
this.properties = [...v, ...ac, ...bc]; | ||
} | ||
q && (this.examples = pb(q, r)); | ||
q && (q = q.startsWith(".") && this.file ? Na(La(this.file), q) : q, this.examples = rb(q, r)); | ||
} | ||
get o() { | ||
get J() { | ||
return this.isConstructor || this.isInterface || this.isRecord; | ||
} | ||
m() { | ||
o() { | ||
return "Object"; | ||
} | ||
get h() { | ||
m(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 l() { | ||
return `${this.tag ? ` \`\uff20${this.tag}\`` : ""}${this.description ? ` ${this.description}` : ""}`; | ||
} | ||
f(a = !1, b = !1, d = a) { | ||
const c = !!this.extends, e = Hb(this, a, b, d), f = []; | ||
g(a = !1, b = !1, c = a) { | ||
const d = !!this.extends, e = Jb(this, a, b, c), f = []; | ||
if (this.namespace && a) { | ||
var g = ` * @typedef {${this.fullName}} ${this.name}${this.h}`; | ||
var g = ` * @typedef {${this.fullName}} ${this.name}${this.l}`; | ||
a && !b && (g = P(g)); | ||
@@ -1325,9 +1331,9 @@ g = O(g); | ||
} else { | ||
this.namespace && d && (g = ` * @typedef {${this.fullName}} ${this.name}${this.h}`, g = O(g), f.push(g)); | ||
this.namespace && c && (g = ` * @typedef {${this.fullName}} ${this.name}${this.l}`, g = O(g), f.push(g)); | ||
} | ||
c && (d = ` * @typedef {${this.extends.split(/,\s*/).join(" & ")} & ${Gb(this, d)}} ${d ? this.fullName : this.name}${this.h}`, a && !b && (d = P(d)), d = O(d), f.push(d)); | ||
d && (c = ` * @typedef {${this.extends.split(/,\s*/).join(" & ")} & ${Ib(this, c)}} ${c ? this.fullName : this.name}${this.l}`, a && !b && (c = P(c)), c = O(c), f.push(c)); | ||
f.push(e); | ||
return f.join(""); | ||
} | ||
get T() { | ||
get V() { | ||
const a = this.tag; | ||
@@ -1342,7 +1348,7 @@ if (!a) { | ||
} | ||
g(a = "", b = !0, d = !1) { | ||
let c = []; | ||
this.description && c.push(` * ${this.description}`); | ||
h(a = "", b = !0, c = !1) { | ||
let d = []; | ||
this.description && d.push(` * ${this.description}`); | ||
this.extends && this.extends.split(/,\s*/).forEach(e => { | ||
c.push(` * @extends {${e}}`); | ||
d.push(` * @extends {${e}}`); | ||
}); | ||
@@ -1356,12 +1362,12 @@ this.args && this.args.forEach(e => { | ||
if ("this" == f) { | ||
c.push(` * @this {${k}}${e}`); | ||
d.push(` * @this {${k}}${e}`); | ||
return; | ||
} | ||
} | ||
c.push(` * @param {${k}${h ? "=" : ""}} ${h ? `[${f}]` : f}${e}`); | ||
d.push(` * @param {${k}${h ? "=" : ""}} ${h ? `[${f}]` : f}${e}`); | ||
}); | ||
b && c.push(` * @${this.T}`); | ||
d && this.examples.length && (b = qb(this.examples), c.push(...b)); | ||
a && (c = c.map(e => `${a}${e}`)); | ||
return c; | ||
b && d.push(` * @${this.V}`); | ||
c && this.examples.length && (b = sb(this.examples), d.push(...b)); | ||
a && (d = d.map(e => `${a}${e}`)); | ||
return d; | ||
} | ||
@@ -1374,16 +1380,16 @@ get ns() { | ||
} | ||
B(a, b, d, c, e = !1, f = !1) { | ||
C(a, b, c, d, e = !1, f = !1) { | ||
var g = ""; | ||
!0 === c ? g = "?" : !1 === c && (g = "!"); | ||
c = this.description ? ` ${this.description}` : ""; | ||
const h = this.spread ? Ib(this.properties) : e || f ? this.fullName : this.name; | ||
b = `${d || ""} * @param {${g}${h}} ${b ? `[${a}]` : a}${c}`; | ||
g = this.properties && !this.noExpand ? this.properties.map(k => k.B(a, d, e, f)) : []; | ||
!0 === d ? g = "?" : !1 === d && (g = "!"); | ||
d = this.description ? ` ${this.description}` : ""; | ||
const h = this.spread ? Kb(this.properties) : e || f ? this.fullName : this.name; | ||
b = `${c || ""} * @param {${g}${h}} ${b ? `[${a}]` : a}${d}`; | ||
g = this.properties && !this.noExpand ? this.properties.map(k => k.C(a, c, e, f)) : []; | ||
return [b, ...g].join("\n"); | ||
} | ||
toMarkdown(a = [], b = {}) { | ||
const {flatten:d, details:c = []} = b, e = c.includes(this.name); | ||
const {flatten:c, details:d = []} = b, e = d.includes(this.name); | ||
var f = this.type ? `\`${this.type}\`` : "", g = f; | ||
this.link ? g = `[${f}](${this.link})` : !this.import && this.type && (g = X(a, this.type, b), f = g != this.type, g = Jb(g, f)); | ||
f = Jb(this.fullName); | ||
this.link ? g = `[${f}](${this.link})` : !this.import && this.type && (g = X(a, this.type, b), f = g != this.type, g = Lb(g, f)); | ||
f = Lb(this.fullName); | ||
f = this.import ? `[${f}](l-type)` : this.noToc ? `[${f}](l-type)` : `[${f}](t-type)`; | ||
@@ -1394,6 +1400,6 @@ const h = this.description ? `: ${this.description}` : ""; | ||
if (this.extends) { | ||
const l = Kb(this.extends, a, b), m = ` extends ${l}`; | ||
const l = Mb(this.extends, a, b), m = ` extends ${l}`; | ||
k = k || /_/.test(l); | ||
g = (k ? g + "<strong>" : g + "__") + (f + m); | ||
"function" == typeof d && d(this.extends); | ||
"function" == typeof c && c(this.extends); | ||
} else { | ||
@@ -1403,26 +1409,26 @@ g = (k ? g + "<strong>" : g + "__") + f; | ||
g = (k ? g + "</strong>" : g + "__") + h; | ||
a = Cb(this, this.properties, a, b); | ||
a = Eb(this, this.properties, a, b); | ||
return {LINE:g, table:a, displayInDetails:e}; | ||
} | ||
} | ||
const Jb = (a, b = !1) => `${b ? "<code>" : "`"}${a}${b ? "</code>" : "`"}`, Ib = (a = [], b = !1) => { | ||
a = a.reduce((d, c) => { | ||
d.push(c); | ||
const e = c.aliases.map(f => ({...c, name:f})); | ||
d.push(...e); | ||
return d; | ||
const Lb = (a, b = !1) => `${b ? "<code>" : "`"}${a}${b ? "</code>" : "`"}`, Kb = (a = [], b = !1) => { | ||
a = a.reduce((c, d) => { | ||
c.push(d); | ||
const e = d.aliases.map(f => ({...d, name:f})); | ||
c.push(...e); | ||
return c; | ||
}, []); | ||
return `{ ${a.map(d => { | ||
const c = b ? d.closureType : d.type; | ||
let e = d.name, f = c; | ||
d.optional && !b ? e = `${d.name}?` : d.optional && b && (f = `(${bb(c)})`); | ||
return `{ ${a.map(c => { | ||
const d = b ? c.closureType : c.type; | ||
let e = c.name, f = d; | ||
c.optional && !b ? e = `${c.name}?` : c.optional && b && (f = `(${db(d)})`); | ||
return `${e}: ${f}`; | ||
}).join(", ")} }`; | ||
}, Kb = (a, b, d) => a.split(/,\s*/).map(c => { | ||
let e = `\`${c}\``; | ||
var f = b.find(({fullName:g}) => g == c); | ||
f && f.link ? (e = "<a ", f.description && (e += `title="${f.description}" `), e += `href="${f.link}">\`${c}\`</a>`) : (f = X(b, c, {...d, nameProcess:g => `\`${g}\``}), c != f && (e = f)); | ||
}, Mb = (a, b, c) => a.split(/,\s*/).map(d => { | ||
let e = `\`${d}\``; | ||
var f = b.find(({fullName:g}) => g == d); | ||
f && f.link ? (e = "<a ", f.description && (e += `title="${f.description}" `), e += `href="${f.link}">\`${d}\`</a>`) : (f = X(b, d, {...c, nameProcess:g => `\`${g}\``}), d != f && (e = f)); | ||
return e; | ||
}).join(", "); | ||
class Lb extends Y { | ||
class Nb extends Y { | ||
constructor() { | ||
@@ -1435,3 +1441,3 @@ super(); | ||
} | ||
b(a, {from:b, name:d, ...c}, e, f) { | ||
b(a, {from:b, name:c, ...d}, e, f) { | ||
if (!b) { | ||
@@ -1442,21 +1448,21 @@ throw Error("From attribute of import is not given."); | ||
this.description = Q(a); | ||
super.b("", {...c, noToc:!0, name:d, type:`import('${b}').${d}`}, e != f ? e : null); | ||
super.b("", {...d, noToc:!0, name:c, type:`import('${b}').${c}`}, e != f ? e : null); | ||
} | ||
f(a = !0) { | ||
g(a = !0) { | ||
return ` * @typedef {import('${this.from}').${this.name}} ${a ? this.fullName : this.name}`; | ||
} | ||
} | ||
;function Mb(a, b) { | ||
b = b.reduce((d, c) => ({...d, [c.fullName]:c}), {}); | ||
;function Ob(a, b) { | ||
b = b.reduce((c, d) => ({...c, [d.fullName]:d}), {}); | ||
a.w = {...a.w, ...b}; | ||
} | ||
class Nb extends N { | ||
class Pb extends N { | ||
constructor(a, b = {}) { | ||
super(a); | ||
this.w = {}; | ||
this.on("types", d => { | ||
Mb(this, d); | ||
this.on("types", c => { | ||
Ob(this, c); | ||
}); | ||
this.on("namespace", d => { | ||
this.b.includes(d) || this.b.push(d); | ||
this.on("namespace", c => { | ||
this.b.includes(c) || this.b.push(c); | ||
}); | ||
@@ -1473,3 +1479,3 @@ this.g = b; | ||
static get Import() { | ||
return Lb; | ||
return Nb; | ||
} | ||
@@ -1480,9 +1486,9 @@ get types() { | ||
} | ||
;class Ob extends Y { | ||
;class Qb extends Y { | ||
constructor() { | ||
super(); | ||
this.l = null; | ||
this.f = null; | ||
this.async = !1; | ||
} | ||
get o() { | ||
get J() { | ||
return !1; | ||
@@ -1493,35 +1499,45 @@ } | ||
} | ||
b(a, {async:b, "return":d, ...c}, ...e) { | ||
b(a, {async:b, "return":c, ...d}, ...e) { | ||
this.description = Q(a); | ||
super.b("", c, ...e); | ||
d && (this.l = d.replace(/\n\s*/g, " ")); | ||
super.b("", d, ...e); | ||
c && (this.f = c.replace(/\n\s*/g, " ")); | ||
b && (this.async = !0); | ||
} | ||
get return() { | ||
return this.l || "void"; | ||
return this.f || "void"; | ||
} | ||
g(a = "") { | ||
const b = super.g(a, !1); | ||
let d; | ||
this.l && (d = this.return); | ||
this.async && d ? d = `Promise<${d}>` : this.async && (d = "Promise"); | ||
d && b.push(`${a} * @return {${d}}`); | ||
h(a = "") { | ||
const b = super.h(a, !1); | ||
let c; | ||
this.f && (c = this.return); | ||
this.async && c ? c = `Promise<${c}>` : this.async && (c = "Promise"); | ||
c && b.push(`${a} * @return {${c}}`); | ||
return b; | ||
} | ||
m() { | ||
return `(${this.args.map(({name:a, type:b, optional:d}) => `${a}${d ? "?" : ""}: ${b}`).join(", ")}) => ${this.return}`; | ||
o() { | ||
return `(${this.args.map(({name:a, type:b, optional:c}) => `${a}${c ? "?" : ""}: ${b}`).join(", ")}) => ${this.return}`; | ||
} | ||
m(a) { | ||
a = super.m(a); | ||
this.f && (this.f = this.f.replace(a, "$1")); | ||
} | ||
} | ||
;const Pb = a => { | ||
var {args:b = []} = a; | ||
if (b.length) { | ||
var d = `function(${b.map(({H:c}) => c).join(", ")}): ${a.fullName}`; | ||
b = new V(b); | ||
b.isConstructor = !0; | ||
b.b("Constructor method.", {type:d, name:"constructor"}); | ||
b.examples = a.examples; | ||
rb(b, void 0); | ||
a.properties.unshift(b); | ||
;const Rb = (a, b) => { | ||
const c = new RegExp(`([!?])?${a}\\.`, "g"); | ||
b.properties.forEach(d => { | ||
tb(d, a, c); | ||
}); | ||
b.m(a); | ||
}, Sb = (a, b) => { | ||
var {args:c = []} = a; | ||
if (c.length) { | ||
var d = `function(${c.map(({I:e}) => e).join(", ")}): ${a.fullName}`; | ||
c = new V(c); | ||
c.isConstructor = !0; | ||
c.b("Constructor method.", {type:d, name:"constructor"}); | ||
c.examples = a.examples; | ||
tb(c, b); | ||
a.properties.unshift(c); | ||
} | ||
}, Rb = a => { | ||
}, Ub = (a, b, c = null) => { | ||
a = R("types", a); | ||
@@ -1531,68 +1547,75 @@ if (!a.length) { | ||
} | ||
const [{content:b, props:{namespace:d, ns:c = d}}] = a, e = void 0 == c ? void 0 : c, f = []; | ||
a = R(["type", "interface", "constructor", "method", "import"], b).reduce((g, {content:h, props:k, tag:l}) => { | ||
const {alias:m, aliases:n, ...p} = k; | ||
var q = m ? [m] : n ? n.split(/, */) : []; | ||
switch(l) { | ||
const [{content:d, props:{namespace:e, ns:f = e}}] = a, g = b == f ? void 0 : f, h = []; | ||
a = R(["type", "interface", "constructor", "method", "import"], d).reduce((k, {content:l, props:m, tag:n}) => { | ||
const {alias:p, aliases:q, ...r} = m; | ||
var t = r.example; | ||
t && t.startsWith(".") && c && (r.example = Na(La(c), t)); | ||
t = p ? [p] : q ? q.split(/, */) : []; | ||
switch(n) { | ||
case "type": | ||
l = new Y; | ||
l.b(h, k, e, void 0); | ||
g.push(l); | ||
q.forEach(r => { | ||
const t = new Y; | ||
t.b(h, {...p, name:r}, e, void 0); | ||
g.push(t); | ||
n = new Y; | ||
c && (n.file = c); | ||
n.b(l, m, g, b); | ||
k.push(n); | ||
t.forEach(u => { | ||
const v = new Y; | ||
c && (v.file = c); | ||
v.b(l, {...r, name:u}, g, b); | ||
k.push(v); | ||
}); | ||
break; | ||
case "interface": | ||
k = Qb(h, k, e); | ||
k.forEach(r => { | ||
r.properties.some(({isConstructor:t}) => t) || Pb(r); | ||
r.isInterface = !0; | ||
m = Tb({content:l, props:m, ns:g, B:b, location:c}); | ||
m.forEach(u => { | ||
u.properties.some(({isConstructor:v}) => v) || Sb(u, b); | ||
u.isInterface = !0; | ||
}); | ||
g.push(...k); | ||
k.push(...m); | ||
break; | ||
case "constructor": | ||
k = Qb(h, k, e); | ||
k.forEach(r => { | ||
r.properties.some(({isConstructor:t}) => t) || Pb(r); | ||
r.isConstructor = !0; | ||
m = Tb({content:l, props:m, ns:g, B:b, location:c}); | ||
m.forEach(u => { | ||
u.properties.some(({isConstructor:v}) => v) || Sb(u, b); | ||
u.isConstructor = !0; | ||
}); | ||
g.push(...k); | ||
k.push(...m); | ||
break; | ||
case "method": | ||
k = Qb(h, k, e, !0); | ||
g.push(...k); | ||
m = Tb({content:l, props:m, ns:g, B:b, isMethod:!0, location:c}); | ||
k.push(...m); | ||
break; | ||
case "import": | ||
q = new Lb, q.b(h, k, k.ns || k.from, void 0), f.push(q); | ||
n = new Nb, n.b(l, m, m.ns || m.from, b), h.push(n); | ||
} | ||
return g; | ||
return k; | ||
}, []); | ||
return {namespace:c, types:a, imports:f}; | ||
}, Sb = (a, b, d, c = !1) => { | ||
const e = c ? new Ob : new Y, f = a.search(/<(prop|function|fn|static) /); | ||
let g = "", h = a; | ||
1 != f && (g = a.slice(0, f), h = a.slice(f)); | ||
const {D:k, I:l} = nb(g, void 0); | ||
e.b(c ? l : h, b, d, void 0); | ||
({G:a} = db(b, k)); | ||
c && (e.closureType = a); | ||
e.args = k; | ||
return e; | ||
}, Qb = (a, b, d, c = !1) => { | ||
const e = [], {alias:f, aliases:g, ...h} = b; | ||
b = Sb(a, b, d, c); | ||
e.push(b); | ||
(f ? [f] : g ? g.split(/, */) : []).forEach(k => { | ||
k = Sb(a, {...h, name:k}, d, c); | ||
k.description = `${k.description}${k.description ? " " : ""}Alias of \`${h.name}\`.`; | ||
e.push(k); | ||
b && a.forEach(k => Rb(b, k)); | ||
return {namespace:f, types:a, imports:h}; | ||
}, Vb = (a, b, c, d, e = !1, f = null) => { | ||
const g = e ? new Qb : new Y; | ||
g.file = f; | ||
f = a.search(/<(prop|function|fn|static) /); | ||
let h = "", k = a; | ||
1 != f && (h = a.slice(0, f), k = a.slice(f)); | ||
const {F:l, K:m} = pb(h, d); | ||
g.b(e ? m : k, b, c, d); | ||
({H:a} = fb(b, l)); | ||
e && (g.closureType = a); | ||
g.args = l; | ||
return g; | ||
}, Tb = ({content:a, props:b, ns:c, B:d, isMethod:e = !1, location:f = null}) => { | ||
const g = [], {alias:h, aliases:k, ...l} = b; | ||
b = Vb(a, b, c, d, e, f); | ||
g.push(b); | ||
(h ? [h] : k ? k.split(/, */) : []).forEach(m => { | ||
m = Vb(a, {...l, name:m}, c, d, e, f); | ||
m.description = `${m.description}${m.description ? " " : ""}Alias of \`${l.name}\`.`; | ||
g.push(m); | ||
}); | ||
return e; | ||
}, Tb = async(a, b = []) => { | ||
const d = await G(a); | ||
let c, e, f; | ||
return g; | ||
}, Wb = async(a, b = []) => { | ||
const c = await G(a); | ||
let d, e, f; | ||
try { | ||
({namespace:c = null, types:e, imports:f} = Rb(d)); | ||
({namespace:d = null, types:e, imports:f} = Ub(c, void 0, a)); | ||
} catch (g) { | ||
@@ -1603,26 +1626,26 @@ throw g.message = `Error while reading ${a}\n${g.message}`, g; | ||
f = f.filter(({fullName:g}) => b.includes(g) ? !1 : !0); | ||
return {types:e, imports:f, namespace:c}; | ||
return {types:e, imports:f, namespace:d}; | ||
}; | ||
const Ub = (a, b, d) => { | ||
b = b.map(c => c.f(!0, d)); | ||
a = a.map(c => { | ||
c = c.f(); | ||
return O(d ? c : P(c)); | ||
const Xb = (a, b, c) => { | ||
b = b.map(d => d.g(!0, c)); | ||
a = a.map(d => { | ||
d = d.g(); | ||
return O(c ? d : P(d)); | ||
}); | ||
return [...b, ...a].join(""); | ||
}, Vb = (a, b, d, c = !1) => { | ||
}, Yb = (a, b, c, d = !1) => { | ||
a = [...a.map(e => { | ||
{ | ||
let f; | ||
e.closureType ? f = ` * @typedef {${e.closureType}}` : e.o || (f = ` * @typedef {${Ib(e.properties, !0)}}`); | ||
f ? (e.description && (f = ` * ${e.description}\n${f}`), f = O(f), e = f += cb(e.namespace, e.name)) : e = Eb(e); | ||
e.closureType ? f = ` * @typedef {${e.closureType}}` : e.J || (f = ` * @typedef {${Kb(e.properties, !0)}}`); | ||
f ? (e.description && (f = ` * ${e.description}\n${f}`), f = O(f), e = f += eb(e.namespace, e.name)) : e = Gb(e); | ||
} | ||
return e; | ||
})].join("\n"); | ||
return `${!b || c || d.includes(b) ? "" : `/** @const */ | ||
return `${!b || d || c.includes(b) ? "" : `/** @const */ | ||
var ${b} = {} | ||
`}${a}`; | ||
}; | ||
const ac = {re:/^\/\*\*? (documentary|typal) (.+?) \*\/\n(?:([^\n][\s\S]+?\n))?$/mg, replacement:async function(a, b, d) { | ||
const [c, ...e] = d.split(/\s+/), f = e.includes("closure"), g = e.includes("externs"), h = e.includes("noSuppress"), k = e.includes("skipNsDecl"), l = e.includes("namespace"); | ||
const dc = {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"), k = e.includes("skipNsDecl"), l = e.includes("namespace"); | ||
let m = e.find(q => q.startsWith("ignore:")); | ||
@@ -1634,21 +1657,21 @@ m = m ? m.replace("ignore:", "").split(",") : []; | ||
try { | ||
this.i("Detected type marker: %s", d); | ||
const {types:q, imports:r, namespace:t} = await Tb(c, m); | ||
this.i("Detected type marker: %s", c); | ||
const {types:q, imports:r, namespace:t} = await Wb(d, m); | ||
this.emit("types", q); | ||
this.emit("types", r); | ||
let u; | ||
n ? u = Ub(r, q, h) : p ? (u = Vb(q, t, this.b, k) + "\n", t && this.emit("namespace", t)) : l ? (t && this.emit("namespace", t), u = Wb(r, q, !0)) : u = Wb(r, q); | ||
return `/* ${b} ${d} */\n${u}`; | ||
n ? u = Xb(r, q, h) : p ? (u = Yb(q, t, this.b, k) + "\n", t && this.emit("namespace", t)) : l ? (t && this.emit("namespace", t), u = cc(r, q, !0)) : u = cc(r, q); | ||
return `/* ${b} ${c} */\n${u}`; | ||
} catch (q) { | ||
return this.i("(%s) Could not process typedef-js: %s", d, q.message), process.env.b && console.error(q.stack), a; | ||
return this.i("(%s) Could not process typedef-js: %s", c, q.message), process.env.b && console.error(q.stack), a; | ||
} | ||
}}, Wb = (a, b, d = !1) => { | ||
b = b.map(c => c.f(!1, !1, d)); | ||
a = a.map(c => c.f(d)).map(O).join(""); | ||
}}, cc = (a, b, c = !1) => { | ||
b = b.map(d => d.g(!1, !1, c)); | ||
a = a.map(d => d.g(c)).map(O).join(""); | ||
b = b.join(""); | ||
return `${a}${b}`.replace(bc, " * @typedef"); | ||
}, bc = / \*\/\n\/\*\*\n \* @typedef/g; | ||
const dc = {re:/( *) \* @param {(.+?)} (\[)?([^\s\]]+)\]?(?: .+)?((?:\n(?: +)\* @param {(?:.+?)} \[?\4\]?(?:(?!\n\s*\*(?:\/|\s*@))[\s\S])*)*)/gm, replacement:cc}; | ||
function cc(a, b, d, c, e, f, g) { | ||
const {v:h, C:k} = this.g; | ||
return `${a}${b}`.replace(ec, " * @typedef"); | ||
}, ec = / \*\/\n\/\*\*\n \* @typedef/g; | ||
const gc = {re:/( *) \* @param {(.+?)} (\[)?([^\s\]]+)\]?(?: .+)?((?:\n(?: +)\* @param {(?:.+?)} \[?\4\]?(?:(?!\n\s*\*(?:\/|\s*@))[\s\S])*)*)/gm, replacement:fc}; | ||
function fc(a, b, c, d, e, f, g) { | ||
const {v:h, D:k} = this.g; | ||
let l; | ||
@@ -1663,5 +1686,5 @@ f = () => { | ||
} | ||
n = {line:n, O:b.length + 11}; | ||
n = {line:n, R:b.length + 11}; | ||
} | ||
const {line:p, O:q} = n; | ||
const {line:p, R:q} = n; | ||
this.i("%s:%s:%s", this.file, p, q); | ||
@@ -1671,17 +1694,17 @@ } | ||
try { | ||
l = kb(d); | ||
l = mb(c); | ||
} catch (n) { | ||
return this.i("Error while parsing the type %s", d), this.i(process.env.DEBUG ? n.stack : n.message), f(), a; | ||
return this.i("Error while parsing the type %s", c), this.i(process.env.DEBUG ? n.stack : n.message), f(), a; | ||
} | ||
if (!l) { | ||
return this.i("Could not parse the type %s", d), f(), a; | ||
return this.i("Could not parse the type %s", c), f(), a; | ||
} | ||
const m = Object.values(this.types).map(({name:n, fullName:p}) => h || k ? p : n); | ||
if (!Z(l, m, this.i, d, f)) { | ||
if (!Z(l, m, this.i, c, f)) { | ||
return a; | ||
} | ||
d = Object.values(this.types).find(({name:n, fullName:p}) => h || k ? p == l.name : n == l.name); | ||
return !d || d instanceof Nb.Import ? a : d.B(e, c, b, l.nullable, h, k); | ||
c = Object.values(this.types).find(({name:n, fullName:p}) => h || k ? p == l.name : n == l.name); | ||
return !c || c instanceof Pb.Import ? a : c.C(e, d, b, l.nullable, h, k); | ||
} | ||
const Z = (a, b, d, c, e) => { | ||
const Z = (a, b, c, d, e) => { | ||
if (a) { | ||
@@ -1692,10 +1715,10 @@ var f = a.name; | ||
let h = b.includes(f); | ||
h || (h = ec.includes(f)); | ||
h || (h = hc.includes(f)); | ||
if (h) { | ||
return !0; | ||
} | ||
d("Type %s%s was not found.", f, c != f ? ` in ${c}` : ""); | ||
c("Type %s%s was not found.", f, d != f ? ` in ${d}` : ""); | ||
e(); | ||
} | ||
var g = [b, d, c, e]; | ||
var g = [b, c, d, e]; | ||
a.application ? a.application.forEach(h => { | ||
@@ -1712,46 +1735,46 @@ Z(h, ...g); | ||
} | ||
}, ec = "String Boolean Object Date Number Symbol Buffer Function".split(" "); | ||
var fc = (a, b = !1) => { | ||
var {R:d} = Ta(); | ||
const c = Va(d); | ||
d = Ua(d); | ||
return new Nb(b ? [ac] : [ac, c, dc, d], a); | ||
}, hc = "String Boolean Object Date Number Symbol Buffer Function".split(" "); | ||
var ic = (a, b = !1) => { | ||
var {T:c} = Va(); | ||
const d = Xa(c); | ||
c = Wa(c); | ||
return new Pb(b ? [dc] : [dc, d, gc, c], a); | ||
}; | ||
const gc = /( *) \* @(fnType|methodType) {(.+?)}/gm, hc = (a, b, d, c, e, f, g = c) => `/** | ||
const jc = /( *) \* @(fnType|methodType) {(.+?)}/gm, kc = (a, b, c, d, e, f, g = d) => `/** | ||
${a} | ||
*/ | ||
${b ? "static " : ""}${d ? "async " : ""}${c}(${e}) { | ||
${b ? "static " : ""}${c ? "async " : ""}${d}(${e}) { | ||
return ${`${b ? f : "super"}.${g}`}(${e}) | ||
}`; | ||
class ic extends N { | ||
class lc extends N { | ||
constructor(a, b) { | ||
super([{re:/\/\*\*\s+( *) \* @constructor {(.+?)}[\s\S]+?(class\s+.+?\s+extends\s+(.+?)\s*){\s*}/gm, replacement(d, c, e, f, g) { | ||
c = a.find(({fullName:l}) => l == e); | ||
if (!c) { | ||
return console.error("Type %s in %s not found", e, b), d; | ||
super([{re:/\/\*\*\s+( *) \* @constructor {(.+?)}[\s\S]+?(class\s+.+?\s+extends\s+(.+?)\s*){\s*}/gm, replacement(c, d, e, f, g) { | ||
d = a.find(({fullName:l}) => l == e); | ||
if (!d) { | ||
return console.error("Type %s in %s not found", e, b), c; | ||
} | ||
d = c.properties.filter(l => l instanceof V && !l.isConstructor).map(l => { | ||
c = d.properties.filter(l => l instanceof V && !l.isConstructor).map(l => { | ||
const {name:m, aliases:n, static:p, async:q} = l; | ||
let r = U(l, "", !0); | ||
r = jc(r, e); | ||
const t = l.args.map(({name:C}) => C).join(", "); | ||
l = hc(r, p, q, m, t, g); | ||
const u = n.map(C => hc(r + `\n * @alias ${m} An alias for **${m}**.`, p, q, C, t, g, m)); | ||
r = mc(r, e); | ||
const t = l.args.map(({name:v}) => v).join(", "); | ||
l = kc(r, p, q, m, t, g); | ||
const u = n.map(v => kc(r + `\n * @alias ${m} An alias for **${m}**.`, p, q, v, t, g, m)); | ||
return [l, ...u].join("\n"); | ||
}); | ||
const h = c.properties.find(l => l instanceof V && l.isConstructor), k = h.args.map(({name:l}) => l).join(", "); | ||
d = [`/** | ||
${jc(U(h, "", !0), e)} | ||
const h = d.properties.find(l => l instanceof V && l.isConstructor), k = h.args.map(({name:l}) => l).join(", "); | ||
c = [`/** | ||
${mc(U(h, "", !0), e)} | ||
*/ | ||
constructor(${k}) { | ||
super(${k}) | ||
}`, ...d].join("\n").replace(/^/gm, " "); | ||
}`, ...c].join("\n").replace(/^/gm, " "); | ||
f = `${f}{ | ||
${d} | ||
${c} | ||
}`; | ||
c.description && (f = `/** | ||
${T(c.description)} | ||
d.description && (f = `/** | ||
${T(d.description)} | ||
*/\n` + f); | ||
return f; | ||
}}, {re:gc, async replacement(d, c, e, f) { | ||
}}, {re:jc, async replacement(c, d, e, f) { | ||
const g = f.split("."); | ||
@@ -1774,55 +1797,55 @@ let h, k; | ||
if (!f) { | ||
return console.error("Type %s in %s not found", h, b), d; | ||
return console.error("Type %s in %s not found", h, b), c; | ||
} | ||
if ("constructor" == k || "methodType" == e) { | ||
return f.g(c, !1, !0).join("\n"); | ||
return f.h(d, !1, !0).join("\n"); | ||
} | ||
e = f.properties.find(({name:l}) => l == k); | ||
return e ? e.parsed ? U(e, c, !0) : (console.error("Property %s of type %s in %s wasn't parsed, possibly parser bug.", k, h, b), d) : (console.error("Property %s of type %s in %s not found", k, h, b), d); | ||
return e ? e.parsed ? U(e, 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 jc = (a, b) => a.replace(`\n * @return {${b}}`, "").replace(`\n * @return {!${b}}`, "").replace(`\n * @return {?${b}}`, ""); | ||
const kc = async a => a ? (await Promise.all(a.split(",").map(async b => { | ||
var d = []; | ||
const c = await I(y, b); | ||
c.isFile() ? d = [b] : c.isDirectory() && (d = await K(b), d = L(d.content, b), d = d.filter(e => e.endsWith(".xml"))); | ||
return d; | ||
}))).reduce((b, d) => [...b, ...d], []) : [], lc = async a => (await Promise.all(a.map(async b => ({...await Tb(b), location:b})))).reduce((b, {imports:d, types:c}) => { | ||
const mc = (a, b) => a.replace(`\n * @return {${b}}`, "").replace(`\n * @return {!${b}}`, "").replace(`\n * @return {?${b}}`, ""); | ||
const nc = async a => a ? (await Promise.all(a.split(",").map(async b => { | ||
var c = []; | ||
const d = await I(z, b); | ||
d.isFile() ? c = [b] : d.isDirectory() && (c = await K(b), c = L(c.content, b), c = c.filter(e => e.endsWith(".xml"))); | ||
return c; | ||
}))).reduce((b, c) => [...b, ...c], []) : [], oc = async a => (await Promise.all(a.map(async b => ({...await Wb(b), location:b})))).reduce((b, {imports:c, types:d}) => { | ||
b.push(...c); | ||
b.push(...d); | ||
b.push(...c); | ||
return b; | ||
}, []); | ||
async function mc() { | ||
const {s:a, types:b} = {s:na, types:ma}, d = await kc(b), c = await lc(d); | ||
await Promise.all(x.map(async e => { | ||
var f = await I(y, e); | ||
async function pc() { | ||
const {s:a, types:b} = {s:na, types:ma}, c = await nc(b), d = await oc(c); | ||
await Promise.all(y.map(async e => { | ||
var f = await I(z, e); | ||
let g; | ||
f.isFile() ? g = [e] : f.isDirectory() && (f = await K(e), g = L(f.content, e)); | ||
await nc(g, c, a); | ||
await qc(g, d, a); | ||
})); | ||
} | ||
const nc = async(a, b = [], d = null) => { | ||
await Promise.all(a.map(async c => { | ||
var e = await G(c); | ||
const f = new ic(b, c); | ||
const qc = async(a, b = [], c = null) => { | ||
await Promise.all(a.map(async d => { | ||
var e = await G(d); | ||
const f = new lc(b, d); | ||
f.end(e); | ||
e = await E(f); | ||
"-" == d ? console.log(e) : d ? await H(d, e) : await H(c, e); | ||
"-" == c ? console.log(e) : c ? await H(c, e) : await H(d, e); | ||
})); | ||
}; | ||
var pc = async() => { | ||
const {v:a = !1, C:b = !1, A:d = !1, s:c, types:e} = {v:ja, A:la, s:ia, types:ma, C:ka}, f = await kc(e); | ||
await Promise.all(x.map(async g => { | ||
var h = await I(y, g); | ||
var sc = async() => { | ||
const {v:a = !1, D:b = !1, A:c = !1, s:d, types:e} = {v:ja, A:la, s:ia, types:ma, D:ka}, f = await nc(e); | ||
await Promise.all(y.map(async g => { | ||
var h = await I(z, g); | ||
let k; | ||
h.isFile() ? k = [g] : h.isDirectory() && (h = await K(g), k = L(h.content, g)); | ||
await oc(k, a, d, c, f, b); | ||
await rc(k, a, c, d, f, b); | ||
})); | ||
}; | ||
const oc = async(a, b = !1, d = !1, c = "", e = [], f = !1) => { | ||
const rc = async(a, b = !1, c = !1, d = "", e = [], f = !1) => { | ||
const g = []; | ||
await Promise.all(e.map(async h => { | ||
h = await G(h); | ||
const {types:k, imports:l} = Rb(h); | ||
const {types:k, imports:l} = Ub(h); | ||
g.push(k, l); | ||
@@ -1832,3 +1855,3 @@ })); | ||
var k = await G(h); | ||
const l = fc({v:b, A:d, C:f}, d); | ||
const l = ic({v:b, A:c, D:f}, c); | ||
g.forEach(m => l.emit("types", m)); | ||
@@ -1840,23 +1863,23 @@ l.file = h; | ||
k = await E(l); | ||
"-" == c ? console.log(k) : c ? await H(c, k) : await H(h, k); | ||
"-" == d ? console.log(k) : d ? await H(d, k) : await H(h, k); | ||
})); | ||
}; | ||
const qc = a => { | ||
const tc = a => { | ||
let b; | ||
"true" == a ? b = !0 : "false" == a ? b = !1 : /^\d+$/.test(a) && (b = parseInt(a, 10)); | ||
return void 0 !== b ? b : a; | ||
}, rc = /^ \* @prop {(.+?)} (\[)?(.+?)(?:=(["'])?(.+?)\4)?(?:])?(?: (.+?))?(?: Default `(.+?)`.)?$/gm, sc = "type opt name quote defaultValue description Default".split(" "), Za = new RegExp(`^ \\* @typedef {(.+?)} (.+?)(?: (.+))?\\n((?:${/ \* @prop(?:erty)? .+\n/.source})*)`, "gm"), tc = (a, b, d, c) => { | ||
c = c.length; | ||
}, uc = /^ \* @prop {(.+?)} (\[)?(.+?)(?:=(["'])?(.+?)\4)?(?:])?(?: (.+?))?(?: Default `(.+?)`.)?$/gm, vc = "type opt name quote defaultValue description Default".split(" "), ab = new RegExp(`^ \\* @typedef {(.+?)} (.+?)(?: (.+))?\\n((?:${/ \* @prop(?:erty)? .+\n/.source})*)`, "gm"), wc = (a, b, c, d) => { | ||
d = d.length; | ||
a = a && "Object" != a ? ` type="${a}"` : ""; | ||
d = d ? ` desc="${d}"` : ""; | ||
return `${" ".repeat(2)}<type name="${b}"${a}${d}${c ? "" : " /"}>\n`; | ||
c = c ? ` desc="${c}"` : ""; | ||
return `${" ".repeat(2)}<type name="${b}"${a}${c}${d ? "" : " /"}>\n`; | ||
}; | ||
class uc extends z { | ||
class xc extends A { | ||
constructor() { | ||
super({writableObjectMode:!0}); | ||
} | ||
_transform({type:a, name:b, description:d, properties:c}, e, f) { | ||
a = a && a.startsWith("import") ? vc(a, b) : tc(a, b, d, c); | ||
_transform({type:a, name:b, description:c, properties:d}, e, f) { | ||
a = a && a.startsWith("import") ? yc(a, b) : wc(a, b, c, d); | ||
this.push(a); | ||
c.forEach(({type:g, name:h, default:k, description:l, optional:m}) => { | ||
d.forEach(({type:g, name:h, default:k, description:l, optional:m}) => { | ||
{ | ||
@@ -1873,27 +1896,27 @@ g = ["string", "number", "boolean"].includes(g) ? ` ${g}` : ` type="${g}"`; | ||
}); | ||
c.length && this.push(" </type>\n"); | ||
d.length && this.push(" </type>\n"); | ||
f(); | ||
} | ||
} | ||
const vc = (a, b) => { | ||
const d = /import\((['"])(.+?)\1\)/.exec(a); | ||
if (!d) { | ||
const yc = (a, b) => { | ||
const c = /import\((['"])(.+?)\1\)/.exec(a); | ||
if (!c) { | ||
throw Error(`Could not extract package from "${a}"`); | ||
} | ||
[, , a] = d; | ||
[, , a] = c; | ||
return `${" ".repeat(2)}<import name="${b}" from="${a}" />\n`; | ||
}; | ||
class wc extends z { | ||
class zc extends A { | ||
constructor() { | ||
super({objectMode:!0}); | ||
} | ||
_transform([, a, b, d, c], e, f) { | ||
c = eb(rc, c, sc).map(g => { | ||
_transform([, a, b, c, d], e, f) { | ||
d = gb(uc, d, vc).map(g => { | ||
const {defaultValue:h, Default:k, opt:l, name:m, type:n, ...p} = g; | ||
g = {...p, name:m, type:n, ...h ? {defaultValue:qc(h)} : {}, ...k ? {u:qc(k)} : {}, ...l ? {optional:!0} : {}}; | ||
g = {...p, name:m, type:n, ...h ? {defaultValue:tc(h)} : {}, ...k ? {u:tc(k)} : {}, ...l ? {optional:!0} : {}}; | ||
if (h || k) { | ||
if (h) { | ||
h !== k && void 0 !== g.u && (q = $a(m, k, n), console.error("%s[%s] does not match Default `%s`.", b, q, g.u)); | ||
h !== k && void 0 !== g.u && (q = bb(m, k, n), console.error("%s[%s] does not match Default `%s`.", b, q, g.u)); | ||
} else { | ||
var q = $a(m, k, n); | ||
var q = bb(m, k, n); | ||
console.error("%s[%s] got from Default.", b, q); | ||
@@ -1907,31 +1930,31 @@ } | ||
}); | ||
this.push({type:a, name:b, description:d, properties:c}); | ||
this.push({type:a, name:b, description:c, properties:d}); | ||
f(); | ||
} | ||
} | ||
async function xc(a) { | ||
const b = Ya(), d = new wc, c = new uc; | ||
b.pipe(d).pipe(c); | ||
async function Ac(a) { | ||
const b = $a(), c = new zc, d = new xc; | ||
b.pipe(c).pipe(d); | ||
b.end(a); | ||
b.on("error", e => { | ||
console.error("Error in Transform"); | ||
c.emit("error", e); | ||
d.emit("error", e); | ||
}); | ||
d.on("error", e => { | ||
c.on("error", e => { | ||
console.error("Error in RegexTransform"); | ||
c.emit("error", e); | ||
d.emit("error", e); | ||
}); | ||
c.on("error", e => { | ||
d.on("error", e => { | ||
console.error("Error in XML"); | ||
c.emit("error", e); | ||
d.emit("error", e); | ||
}); | ||
return `<types> | ||
${(await E(c)).trim()} | ||
${(await E(d)).trim()} | ||
</types>`; | ||
} | ||
;var yc = async() => { | ||
;var Bc = async() => { | ||
const {s:a} = {s:ia}; | ||
await Promise.all(x.map(async b => { | ||
await Promise.all(y.map(async b => { | ||
b = await G(b); | ||
b = await xc(b); | ||
b = await Ac(b); | ||
a ? await H(a, b) : console.log(b); | ||
@@ -1949,3 +1972,3 @@ })); | ||
try { | ||
return oa ? await yc() : na ? await mc() : await pc(); | ||
return oa ? await Bc() : na ? await pc() : await sc(); | ||
} catch (a) { | ||
@@ -1952,0 +1975,0 @@ process.env.DEBUG ? console.log(a.stack) : console.log(a.message); |
#!/usr/bin/env node | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
@@ -8,6 +9,6 @@ const stream = require('stream'); | ||
a != Array.prototype && a != Object.prototype && (a[b] = d.value); | ||
}, y = "undefined" != typeof window && window === this ? this : "undefined" != typeof global && null != global ? global : this; | ||
function A(a, b) { | ||
}, z = "undefined" != typeof window && window === this ? this : "undefined" != typeof global && null != global ? global : this; | ||
function aa(a, b) { | ||
if (b) { | ||
var d = y; | ||
var d = z; | ||
a = a.split("."); | ||
@@ -25,3 +26,3 @@ for (var c = 0; c < a.length - 1; c++) { | ||
} | ||
A("String.prototype.trimRight", function(a) { | ||
aa("String.prototype.trimRight", function(a) { | ||
function b() { | ||
@@ -35,8 +36,8 @@ return this.replace(/[\s\xa0]+$/, ""); | ||
b.replace(a, (e, ...g) => { | ||
e = g.slice(0, g.length - 2).reduce((f, h, k) => { | ||
k = d[k]; | ||
if (!k || void 0 === h) { | ||
e = g.slice(0, g.length - 2).reduce((f, k, h) => { | ||
h = d[h]; | ||
if (!h || void 0 === k) { | ||
return f; | ||
} | ||
f[k] = h; | ||
f[h] = k; | ||
return f; | ||
@@ -48,8 +49,11 @@ }, {}); | ||
} | ||
;const C = new RegExp(`${/([^\s>=/]+)/.source}(?:\\s*=\\s*${/(?:"([\s\S]*?)"|'([\s\S]*?)')/.source})?`, "g"), D = new RegExp(`(?:\\s+((?:${C.source}\\s*)*))`); | ||
const F = (a, b) => B(new RegExp(`<(${(Array.isArray(a) ? a : [a]).join("|")})${D.source}?(?:${/\s*\/>/.source}|${/>([\s\S]+?)?<\/\1>/.source})`, "g"), b, "t a v v1 v2 c".split(" ")).map(({t:d, a:c = "", c:e = ""}) => { | ||
c = c.replace(/\/$/, "").trim(); | ||
c = E(c); | ||
return {content:e, props:c, tag:d}; | ||
}), E = a => B(C, a, ["key", "val", "def", "f"]).reduce((b, {key:d, val:c}) => { | ||
;const C = new RegExp(`${/([^\s>=/]+)/.source}(?:\\s*=\\s*${/(?:"([\s\S]*?)"|'([\s\S]*?)')/.source})?`, "g"), ba = new RegExp(`(?:\\s+((?:${C.source}\\s*)*))`); | ||
const D = (a, b) => { | ||
a = (Array.isArray(a) ? a : [a]).join("|"); | ||
return B(new RegExp(`<(${a})${ba.source}?(?:${/\s*\/>/.source}|${/>([\s\S]+?)?<\/\1>/.source})`, "g"), b, "t a v v1 v2 c".split(" ")).map(({t:d, a:c = "", c:e = ""}) => { | ||
c = c.replace(/\/$/, "").trim(); | ||
c = ca(c); | ||
return {content:e, props:c, tag:d}; | ||
}); | ||
}, ca = a => B(C, a, ["key", "val", "def", "f"]).reduce((b, {key:d, val:c}) => { | ||
if (void 0 === c) { | ||
@@ -61,3 +65,3 @@ return b[d] = !0, b; | ||
}, {}); | ||
const aa = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => { | ||
const da = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => { | ||
switch(b) { | ||
@@ -79,16 +83,16 @@ case "function": | ||
}); | ||
function ba(a) { | ||
function ea(a) { | ||
let b = 0; | ||
const d = (e = 1) => a[b + e], c = (e = !0, g = []) => { | ||
var f = {}; | ||
let h = a[b]; | ||
if (["nullable", "nonNullable"].includes(h)) { | ||
let k = a[b]; | ||
if (["nullable", "nonNullable"].includes(k)) { | ||
if (!e) { | ||
throw Error(`${h} not allowed after .`); | ||
throw Error(`${k} not allowed after .`); | ||
} | ||
f.nullable = "nullable" === h; | ||
f.nullable = "nullable" === k; | ||
b++; | ||
} | ||
h = a[b]; | ||
if ("(" == h) { | ||
k = a[b]; | ||
if ("(" == k) { | ||
b++; | ||
@@ -104,16 +108,16 @@ f = {...c(!0, []), ...f}; | ||
} else { | ||
if ("{" == h) { | ||
if ("{" == k) { | ||
b++; | ||
g = f; | ||
for (e = {}; "}" != a[b];) { | ||
var k = a[b]; | ||
var h = a[b]; | ||
b++; | ||
e[k] = null; | ||
e[h] = null; | ||
if (":" == a[b]) { | ||
b++; | ||
try { | ||
var l = c(); | ||
e[k] = l; | ||
} catch (q) { | ||
throw q.message += `(when parsing ${k} property)`, q; | ||
var m = c(); | ||
e[h] = m; | ||
} catch (p) { | ||
throw p.message += `(when parsing ${h} property)`, p; | ||
} | ||
@@ -126,3 +130,3 @@ } | ||
if ("," != a[b]) { | ||
throw Error(`Expecting , for record after ${k}`); | ||
throw Error(`Expecting , for record after ${h}`); | ||
} | ||
@@ -135,12 +139,12 @@ b++; | ||
} | ||
if (["nonNullable", "nullable"].includes(h)) { | ||
if (["nonNullable", "nullable"].includes(k)) { | ||
throw Error("Nullability already defined."); | ||
} | ||
if (/[=),:.<>}|]/.test(h)) { | ||
throw Error(`Unexpected token ${h}.`); | ||
if (/[=),:.<>}|]/.test(k)) { | ||
throw Error(`Unexpected token ${k}.`); | ||
} | ||
"|" != a[b] && (f.name = a[b], b++); | ||
if ("function" == h) { | ||
l = f; | ||
k = {return:null, args:[]}; | ||
if ("function" == k) { | ||
m = f; | ||
h = {return:null, args:[]}; | ||
if ("(" != a[b]) { | ||
@@ -150,7 +154,7 @@ throw Error("Expecting opening ("); | ||
b++; | ||
for (var m; ")" != a[b];) { | ||
if (m && "this" == a[b]) { | ||
for (var l; ")" != a[b];) { | ||
if (l && "this" == a[b]) { | ||
throw Error("this must come first in function arguments"); | ||
} | ||
if (m && "new" == a[b]) { | ||
if (l && "new" == a[b]) { | ||
throw Error("new must come first in function arguments"); | ||
@@ -164,3 +168,3 @@ } | ||
b++; | ||
k.this = c(); | ||
h.this = c(); | ||
} else { | ||
@@ -173,3 +177,3 @@ if ("new" == a[b]) { | ||
b++; | ||
k.new = c(); | ||
h.new = c(); | ||
} else { | ||
@@ -180,13 +184,13 @@ if ("." == a[b] && "." == d() && "." == d(2)) { | ||
b++; | ||
m = c(); | ||
l = c(); | ||
if (")" != a[b]) { | ||
throw Error("Variable args must come last"); | ||
} | ||
k.variableArgs = m; | ||
h.variableArgs = l; | ||
} else { | ||
m = c(), k.args.push(m), "=" == a[b] && (m.optional = !0, b++); | ||
l = c(), h.args.push(l), "=" == a[b] && (l.optional = !0, b++); | ||
} | ||
} | ||
} | ||
m = !0; | ||
l = !0; | ||
if (")" == a[b]) { | ||
@@ -202,12 +206,12 @@ break; | ||
b++; | ||
":" == a[b] && (b++, m = c(), void 0 == m.name && m.nullable && (m.name = ""), k.return = m); | ||
l.function = k; | ||
":" == a[b] && (b++, l = c(), void 0 == l.name && l.nullable && (l.name = ""), h.return = l); | ||
m.function = h; | ||
} else { | ||
if ("<" == a[b] || (k = "." == a[b] && "<" == d())) { | ||
if ("<" == a[b] || (h = "." == a[b] && "<" == d())) { | ||
b++; | ||
k && b++; | ||
l = f; | ||
for (k = []; ">" != a[b];) { | ||
m = c(); | ||
k.push(m); | ||
h && b++; | ||
m = f; | ||
for (h = []; ">" != a[b];) { | ||
l = c(); | ||
h.push(l); | ||
if (">" == a[b]) { | ||
@@ -223,3 +227,3 @@ break; | ||
b++; | ||
l.application = k; | ||
m.application = h; | ||
} | ||
@@ -230,7 +234,7 @@ } | ||
b++; | ||
({name:l} = c(!1)); | ||
if (!l) { | ||
({name:m} = c(!1)); | ||
if (!m) { | ||
throw Error("Expected to see the name after ."); | ||
} | ||
f.name += l; | ||
f.name += m; | ||
} | ||
@@ -247,7 +251,7 @@ if ("|" != a[b] || !e) { | ||
} | ||
;function G(a) { | ||
a = aa(a); | ||
return ba(a); | ||
;function E(a) { | ||
a = da(a); | ||
return ea(a); | ||
} | ||
;const H = ({w:a, B:b, i:d, type:c}) => b ? "string" : a ? "number" : d ? "boolean" : c ? c : "*", I = a => { | ||
;const F = ({A:a, C:b, l:d, type:c}) => b ? "string" : a ? "number" : d ? "boolean" : c ? c : "*", G = a => { | ||
a = a.trimRight(); | ||
@@ -274,6 +278,6 @@ var b = /\S/.exec(a); | ||
} | ||
}, J = (a, b, d = null) => { | ||
}, H = (a, b, d = null) => { | ||
const {async:c, "void":e, "return":g = e ? "void" : "", ...f} = a; | ||
({args:a = ""} = a); | ||
a || (a = b.map(({m:h, name:k}) => "this" == k ? `${k}: ${h}` : k.startsWith("...") ? `...${h}` : h).join(",")); | ||
a || (a = b.map(({s:k, name:h}) => "this" == h ? `${h}: ${k}` : h.startsWith("...") ? `...${k}` : k).join(",")); | ||
b = g.replace(/\n\s*/g, " "); | ||
@@ -284,5 +288,5 @@ c && b ? b = `!Promise<${b}>` : c && (b = "!Promise"); | ||
b && (d += `: ${b}`); | ||
return {D:{...f, async:c}, l:d}; | ||
return {F:{...f, async:c}, o:d}; | ||
}; | ||
function ca(a, b, {name:d, string:c, "boolean":e, opt:g, number:f, type:h}, k) { | ||
function fa(a, b, {name:d, string:c, "boolean":e, opt:g, number:f, type:k}, h) { | ||
if (!d) { | ||
@@ -292,5 +296,5 @@ throw Error("Argument does not have a name."); | ||
a.name = d; | ||
b && (a.description = I(b)); | ||
b = H({w:f, B:c, i:e, type:h}); | ||
k && (b = b.replace(new RegExp(`([!?])?${k}\\.`, "g"), "$1")); | ||
b && (a.description = G(b)); | ||
b = F({A:f, C:c, l:e, type:k}); | ||
h && (b = b.replace(new RegExp(`([!?])?${h}\\.`, "g"), "$1")); | ||
b.endsWith("=") && (b = b.replace(/=$/, ""), g = !0); | ||
@@ -300,3 +304,3 @@ a.type = b; | ||
} | ||
class da { | ||
class ha { | ||
constructor() { | ||
@@ -308,18 +312,18 @@ this.name = null; | ||
} | ||
get m() { | ||
get s() { | ||
return this.optional ? `${this.type}=` : this.type; | ||
} | ||
} | ||
const K = (a, b) => { | ||
const I = (a, b) => { | ||
let d = a.lastIndexOf("</arg>"), c = a; | ||
var e = []; | ||
-1 != d && (d += 6, e = a.slice(0, d), c = a.slice(d), e = F("arg", e), e = e.map(({content:g, props:f}) => { | ||
const h = new da; | ||
ca(h, g, f, b); | ||
return h; | ||
-1 != d && (d += 6, e = a.slice(0, d), c = a.slice(d), e = D("arg", e), e = e.map(({content:g, props:f}) => { | ||
const k = new ha; | ||
fa(k, g, f, b); | ||
return k; | ||
})); | ||
return {v:c, h:e}; | ||
return {w:c, j:e}; | ||
}; | ||
const {readFileSync:ea} = fs; | ||
const fa = a => { | ||
const {readFileSync:ia} = fs; | ||
const ja = a => { | ||
const b = a.replace(/^\s*\n/gm, "").split("\n").reduce((d, c) => { | ||
@@ -331,13 +335,13 @@ [{length:c = 0} = {}] = /^\s*/.exec(c) || []; | ||
}; | ||
function L(a, b = "") { | ||
function J(a, b = "") { | ||
const d = b.split(/\s*,\s*/); | ||
return a.split(/\s*,\s*/).map(c => { | ||
let e = c = ea(c, "utf8"); | ||
let e = c = ia(c, "utf8"); | ||
if (c = /\/\* start example \*\/\r?\n([\s\S]+?)\r?\n\s*\/\* end example \*\//.exec(c)) { | ||
[, c] = c, e = fa(c); | ||
[, c] = c, e = ja(c); | ||
} | ||
d.forEach(g => { | ||
const [f, h] = g.split(/\s*=>\s*/); | ||
e = e.replace(`'${f}'`, `'${h}'`); | ||
e = e.replace(`"${f}"`, `"${h}"`); | ||
const [f, k] = g.split(/\s*=>\s*/); | ||
e = e.replace(`'${f}'`, `'${k}'`); | ||
e = e.replace(`"${f}"`, `"${k}"`); | ||
}); | ||
@@ -347,13 +351,13 @@ return e = e.replace(/@/g, "\uff20"); | ||
} | ||
function M(a, b, d = new RegExp(`([!?])?${b}\\.`, "g")) { | ||
function K(a, b, d = new RegExp(`([!?])?${b}\\.`, "g")) { | ||
b && (a.type = a.type.replace(d, "$1")); | ||
} | ||
class N { | ||
class L { | ||
constructor(a = null) { | ||
this.g = this.description = this.name = null; | ||
this.o = ""; | ||
this.default = this.s = null; | ||
this.h = ""; | ||
this.default = this.u = null; | ||
this.optional = !1; | ||
this.aliases = []; | ||
this.u = !1; | ||
this.v = !1; | ||
this.parsed = null; | ||
@@ -369,6 +373,6 @@ this.args = a; | ||
const {function:{args:b, return:d, this:c, variableArgs:e}} = this.parsed; | ||
var g = b.map(h => a(h)).map((h, k) => { | ||
const {optional:l} = b[k]; | ||
let {name:m = `arg${k}`, optional:q = l} = this.C[k] || {}; | ||
return `${`${m}${q ? "?" : ""}`}: ${h}`; | ||
var g = b.map(k => a(k)).map((k, h) => { | ||
const {optional:m} = b[h]; | ||
let {name:l = `arg${h}`, optional:p = m} = this.D[h] || {}; | ||
return `${`${l}${p ? "?" : ""}`}: ${k}`; | ||
}); | ||
@@ -381,8 +385,8 @@ if (c) { | ||
f = a(e); | ||
let h = "...args"; | ||
let k = "...args"; | ||
try { | ||
h = `${this.args[this.args.length - 1].name}`; | ||
} catch (k) { | ||
k = `${this.args[this.args.length - 1].name}`; | ||
} catch (h) { | ||
} | ||
g.push(`${h}: ${f}[]`); | ||
g.push(`${k}: ${f}[]`); | ||
} | ||
@@ -399,3 +403,3 @@ g = g.join(", "); | ||
} | ||
b(a, {name:b, string:d, "boolean":c, opt:e, number:g, type:f, "default":h, closure:k, alias:l, aliases:m, example:q, "example-override":n = "", noParams:r, "static":t, initial:p}) { | ||
b(a, {name:b, string:d, "boolean":c, opt:e, number:g, type:f, "default":k, closure:h, alias:m, aliases:l, example:p, "example-override":n = "", noParams:q, "static":v, initial:r}) { | ||
if (!b) { | ||
@@ -405,15 +409,15 @@ throw Error("Property does not have a name."); | ||
this.name = b; | ||
a && (this.description = I(a)); | ||
a = H({w:g, B:d, i:c, type:f}); | ||
r && (this.u = r); | ||
k && (this.s = k); | ||
a && (this.description = G(a)); | ||
a = F({A:g, C:d, l:c, type:f}); | ||
q && (this.v = q); | ||
h && (this.u = h); | ||
this.type = a; | ||
void 0 !== h ? this.default = h : void 0 !== p && (this.default = p); | ||
if (e || void 0 !== h) { | ||
void 0 !== k ? this.default = k : void 0 !== r && (this.default = r); | ||
if (e || void 0 !== k) { | ||
this.optional = !0; | ||
} | ||
l && (this.aliases = [l]); | ||
m && (this.aliases = m.split(/\s*,\s*/)); | ||
t && (this.f = !0); | ||
q && (this.examples = L(q, n)); | ||
m && (this.aliases = [m]); | ||
l && (this.aliases = l.split(/\s*,\s*/)); | ||
v && (this.f = !0); | ||
p && (this.examples = J(p, n)); | ||
} | ||
@@ -425,6 +429,6 @@ get type() { | ||
this.g = a || null; | ||
this.o = this.s || this.g || ""; | ||
if (!this.u) { | ||
this.h = this.u || this.g || ""; | ||
if (!this.v) { | ||
try { | ||
this.parsed = G(this.o), this.isParsedFunction && !this.args && (this.args = []); | ||
this.parsed = E(this.h), this.isParsedFunction && !this.args && (this.args = []); | ||
} catch (b) { | ||
@@ -435,3 +439,3 @@ this.parsed = null; | ||
} | ||
get C() { | ||
get D() { | ||
var a = this.args; | ||
@@ -445,3 +449,3 @@ this.args && this.args[0] && "this" == this.args[0].name && ([, ...a] = this.args); | ||
} | ||
;class O extends N { | ||
;class M extends L { | ||
constructor(...a) { | ||
@@ -457,3 +461,3 @@ super(...a); | ||
} | ||
;const S = (a, b, d = {}) => { | ||
;const O = (a, b, d = {}) => { | ||
let c; | ||
@@ -464,3 +468,3 @@ if ("object" == typeof b) { | ||
try { | ||
(c = G(b)) || console.log("Could not parse %s", b); | ||
(c = E(b)) || console.log("Could not parse %s", b); | ||
} catch (e) { | ||
@@ -470,4 +474,4 @@ console.log("Could not parse %s", b), console.error(e.message); | ||
} | ||
return c ? R(c, a, d) : b; | ||
}, R = (a, b, d = {}) => { | ||
return c ? N(c, a, d) : b; | ||
}, N = (a, b, d = {}) => { | ||
if ("" == a.name && a.nullable) { | ||
@@ -483,26 +487,27 @@ return "?"; | ||
const f = []; | ||
a.function.this && (c = "this: " + R(a.function.this, b, d), f.push(c)); | ||
a.function.new && (c = "new: " + R(a.function.new, b, d), f.push(c)); | ||
a.function.args.forEach(h => { | ||
let k = R(h, b, d); | ||
h.optional && (k += "="); | ||
f.push(k); | ||
a.function.this && (c = "this: " + N(a.function.this, b, d), f.push(c)); | ||
a.function.new && (c = "new: " + N(a.function.new, b, d), f.push(c)); | ||
a.function.args.forEach(k => { | ||
let h = N(k, b, d); | ||
k.optional && (h += "="); | ||
f.push(h); | ||
}); | ||
a.function.variableArgs && (c = "..." + R(a.function.variableArgs, b, d), f.push(c)); | ||
e += f.join(", ") + ")"; | ||
a.function.return && (e += ": " + R(a.function.return, b, d)); | ||
a.function.variableArgs && (c = "..." + N(a.function.variableArgs, b, d), f.push(c)); | ||
c = f.join(", "); | ||
e += c + ")"; | ||
a.function.return && (e += ": " + N(a.function.return, b, d)); | ||
} else { | ||
a.record ? (e += "{ ", c = Object.keys(a.record).map(f => { | ||
var h = a.record[f]; | ||
if (!h) { | ||
var k = a.record[f]; | ||
if (!k) { | ||
return f; | ||
} | ||
h = R(h, b, d); | ||
return `${f}: ${h}`; | ||
}), e += c.join(", "), e += " }") : a.application ? (e += T(a.name, b, g, d) + "<", c = a.application.map(f => R(f, b, d)), e += c.join(", "), e += ">") : a.union ? (e = e + g + "(", g = a.union.map(f => R(f, b, d)), e += g.join(c ? " \\| " : " | "), e += ")") : e += T("any" == a.name ? "*" : a.name, b, g, d); | ||
k = N(k, b, d); | ||
return `${f}: ${k}`; | ||
}), e += c.join(", "), e += " }") : a.application ? (e += P(a.name, b, g, d) + "<", c = a.application.map(f => N(f, b, d)), e += c.join(", "), e += ">") : a.union ? (e = e + g + "(", g = a.union.map(f => N(f, b, d)), e += g.join(c ? " \\| " : " | "), e += ")") : e += P("any" == a.name ? "*" : a.name, b, g, d); | ||
} | ||
return e; | ||
}, T = (a, b, d = "", c = {}) => { | ||
const {flatten:e = !1, nameProcess:g, link:f = ({link:l}) => `#${l}`} = c; | ||
c = ha(b, a); | ||
}, P = (a, b, d = "", c = {}) => { | ||
const {flatten:e = !1, nameProcess:g, link:f = ({link:m}) => `#${m}`} = c; | ||
c = ka(b, a); | ||
d = `${d}${a}`; | ||
@@ -512,8 +517,8 @@ if (!c) { | ||
} | ||
let {link:h, type:{description:k}} = c; | ||
h = f(c); | ||
e && ((b = b.find(({fullName:l}) => l == a)) && b.link && (h = b.link), !k && b.description && (k = b.description), "function" == typeof e && e(a)); | ||
let {link:k, type:{description:h}} = c; | ||
k = f(c); | ||
e && ((b = b.find(({fullName:m}) => m == a)) && b.link && (k = b.link), !h && b.description && (h = b.description), "function" == typeof e && e(a)); | ||
b = g ? g(d) : d; | ||
return k ? `<a href="${h}" title="${k.replace(/"/g, """)}">${b}</a>` : `[${b}](${h})`; | ||
}, ha = (a, b) => { | ||
return h ? `<a href="${k}" title="${h.replace(/"/g, """)}">${b}</a>` : `[${b}](${k})`; | ||
}, ka = (a, b) => { | ||
a = a.filter(({fullName:c}) => c == b); | ||
@@ -526,19 +531,19 @@ if (a.length) { | ||
}; | ||
function ia(a, b = [], d = [], c = {}) { | ||
const {narrow:e = !1, flatten:g = !1, preprocessDesc:f, link:h} = c; | ||
function la(a, b = [], d = [], c = {}) { | ||
const {narrow:e = !1, flatten:g = !1, preprocessDesc:f, link:k} = c; | ||
if (!b.length) { | ||
return ""; | ||
} | ||
const k = a.isConstructor || a.isInterface, l = b.some(({hasDefault:n}) => n), m = {flatten:g, escapePipe:!e, link:h}, q = n => S(d, n, m); | ||
const h = a.isConstructor || a.isInterface, m = b.some(({hasDefault:n}) => n), l = {flatten:g, escapePipe:!e, link:k}, p = n => O(d, n, l); | ||
a = b.map(n => { | ||
let r; | ||
n.args && n.isParsedFunction ? (r = n.toTypeScriptFunction(q), n.isConstructor && (r = `new ${r}`)) : r = S(d, n.parsed || n.type, m); | ||
const t = k || n.optional ? n.name : `${n.name}*`, p = n.hasDefault ? `\`${n.default}\`` : "-", u = f ? f(n.description) : n.description; | ||
return {prop:n, typeName:r, name:t, de:ja(u, !e), d:p}; | ||
let q; | ||
n.args && n.isParsedFunction ? (q = n.toTypeScriptFunction(p), n.isConstructor && (q = `new ${q}`)) : q = O(d, n.parsed || n.type, l); | ||
const v = h || n.optional ? n.name : `${n.name}*`, r = n.hasDefault ? `\`${n.default}\`` : "-", t = f ? f(n.description) : n.description; | ||
return {prop:n, typeName:q, name:v, de:ma(t, !e), d:r}; | ||
}); | ||
if (e) { | ||
return {props:a, anyHaveDefault:l, constr:k}; | ||
return {props:a, anyHaveDefault:m, constr:h}; | ||
} | ||
a = a.map(({name:n, typeName:r, de:t, d:p, prop:u}) => [u.optional ? n : `__${n}__`, `<em>${r}</em>`, t, ...l ? [p] : []]); | ||
b = ["Name", ...e ? ["Type & Description"] : ["Type", "Description"], ...l ? [k ? "Initial" : "Default"] : []]; | ||
a = a.map(({name:n, typeName:q, de:v, d:r, prop:t}) => [t.optional ? n : `__${n}__`, `<em>${q}</em>`, v, ...m ? [r] : []]); | ||
b = ["Name", ...e ? ["Type & Description"] : ["Type", "Description"], ...m ? [h ? "Initial" : "Default"] : []]; | ||
return ` | ||
@@ -550,3 +555,3 @@ | ||
} | ||
const ja = (a = "", b = !0) => { | ||
const ma = (a = "", b = !0) => { | ||
null === a && (a = ""); | ||
@@ -556,2 +561,3 @@ b && (a = a.replace(/\|/g, "\\|")); | ||
}; | ||
const {dirname:Q, resolve:R} = path; | ||
class U { | ||
@@ -568,2 +574,3 @@ constructor() { | ||
this.examples = []; | ||
this.f = null; | ||
} | ||
@@ -573,3 +580,3 @@ get import() { | ||
} | ||
b(a, {name:b, type:d, desc:c, noToc:e, spread:g, noExpand:f, link:h, closure:k, constructor:l, "extends":m, "interface":q, record:n, example:r, "example-override":t}, p, u = null) { | ||
b(a, {name:b, type:d, desc:c, noToc:e, spread:g, noExpand:f, link:k, closure:h, constructor:m, "extends":l, "interface":p, record:n, example:q, "example-override":v}, r, t = null) { | ||
if (!b) { | ||
@@ -580,39 +587,39 @@ throw Error("Type does not have a name."); | ||
d && (this.type = d); | ||
k ? this.closureType = k : this.closureType = this.type; | ||
c && (this.description = I(c)); | ||
h ? this.closureType = h : this.closureType = this.type; | ||
c && (this.description = G(c)); | ||
this.noToc = !!e; | ||
this.spread = !!g; | ||
this.noExpand = !!f; | ||
h && (this.link = h); | ||
!0 === l && (this.isConstructor = l); | ||
!0 === q && (this.isInterface = q); | ||
k && (this.link = k); | ||
!0 === m && (this.isConstructor = m); | ||
!0 === p && (this.isInterface = p); | ||
!0 === n && (this.isRecord = n); | ||
m && (this.extends = m); | ||
p && (this.namespace = p); | ||
l && (this.extends = l); | ||
r && (this.namespace = r); | ||
if (a) { | ||
b = F("prop", a).map(({content:v, props:x}) => { | ||
const z = new N; | ||
z.b(v, x); | ||
return z; | ||
b = D("prop", a).map(({content:u, props:x}) => { | ||
const A = new L; | ||
A.b(u, x); | ||
return A; | ||
}); | ||
a = F(["function", "fn", "static"], a).map(({content:v, props:x, tag:z}) => { | ||
z = "static" == z; | ||
const {v:ka, h:P} = K(v, u); | ||
v = new O(P); | ||
const {D:Q, l:la} = J(x, P, this.fullName); | ||
Q.type = la; | ||
v.b(ka, Q); | ||
z && (v.f = !0); | ||
return v; | ||
a = D(["function", "fn", "static"], a).map(({content:u, props:x, tag:A}) => { | ||
A = "static" == A; | ||
const {w:na, j:S} = I(u, t); | ||
u = new M(S); | ||
const {F:T, o:oa} = H(x, S, this.fullName); | ||
T.type = oa; | ||
u.b(na, T); | ||
A && (u.f = !0); | ||
return u; | ||
}); | ||
a = [...b, ...a]; | ||
const {j:ma, A:na, n:oa} = a.reduce((v, x) => { | ||
x.isConstructor ? v.j.push(x) : x.static ? v.A.push(x) : v.n.push(x); | ||
return v; | ||
}, {j:[], A:[], n:[]}); | ||
this.properties = [...ma, ...na, ...oa]; | ||
const {m:y, B:pa, n:qa} = a.reduce((u, x) => { | ||
x.isConstructor ? u.m.push(x) : x.static ? u.B.push(x) : u.n.push(x); | ||
return u; | ||
}, {m:[], B:[], n:[]}); | ||
this.properties = [...y, ...pa, ...qa]; | ||
} | ||
r && (this.examples = L(r, t)); | ||
q && (q = q.startsWith(".") && this.f ? R(Q(this.f), q) : q, this.examples = J(q, v)); | ||
} | ||
g(a, b = new RegExp(`([!?])?${a}\\.`, "g")) { | ||
h(a, b = new RegExp(`([!?])?${a}\\.`, "g")) { | ||
this.type && (this.type = this.type.replace(b, "$1")); | ||
@@ -634,25 +641,25 @@ this.extends && (this.extends = this.extends.replace(b, "$1")); | ||
var g = this.type ? `\`${this.type}\`` : "", f = g; | ||
this.link ? f = `[${g}](${this.link})` : !this.import && this.type && (f = S(a, this.type, b), g = f != this.type, f = V(f, g)); | ||
this.link ? f = `[${g}](${this.link})` : !this.import && this.type && (f = O(a, this.type, b), g = f != this.type, f = V(f, g)); | ||
g = V(this.fullName); | ||
g = this.import ? `[${g}](l-type)` : this.noToc ? `[${g}](l-type)` : `[${g}](t-type)`; | ||
const h = this.description ? `: ${this.description}` : ""; | ||
const k = this.description ? `: ${this.description}` : ""; | ||
f = f ? `${f} ` : ""; | ||
let k = /_/.test(g); | ||
let h = /_/.test(g); | ||
if (this.extends) { | ||
const l = pa(this.extends, a, b), m = ` extends ${l}`; | ||
k = k || /_/.test(l); | ||
f = (k ? f + "<strong>" : f + "__") + (g + m); | ||
const m = ra(this.extends, a, b), l = ` extends ${m}`; | ||
h = h || /_/.test(m); | ||
f = (h ? f + "<strong>" : f + "__") + (g + l); | ||
"function" == typeof d && d(this.extends); | ||
} else { | ||
f = (k ? f + "<strong>" : f + "__") + g; | ||
f = (h ? f + "<strong>" : f + "__") + g; | ||
} | ||
f = (k ? f + "</strong>" : f + "__") + h; | ||
a = ia(this, this.properties, a, b); | ||
f = (h ? f + "</strong>" : f + "__") + k; | ||
a = la(this, this.properties, a, b); | ||
return {LINE:f, table:a, displayInDetails:e}; | ||
} | ||
} | ||
const V = (a, b = !1) => `${b ? "<code>" : "`"}${a}${b ? "</code>" : "`"}`, pa = (a, b, d) => a.split(/,\s*/).map(c => { | ||
const V = (a, b = !1) => `${b ? "<code>" : "`"}${a}${b ? "</code>" : "`"}`, ra = (a, b, d) => a.split(/,\s*/).map(c => { | ||
let e = `\`${c}\``; | ||
var g = b.find(({fullName:f}) => f == c); | ||
g && g.link ? (e = "<a ", g.description && (e += `title="${g.description}" `), e += `href="${g.link}">\`${c}\`</a>`) : (g = S(b, c, {...d, nameProcess:f => `\`${f}\``}), c != g && (e = g)); | ||
g && g.link ? (e = "<a ", g.description && (e += `title="${g.description}" `), e += `href="${g.link}">\`${c}\`</a>`) : (g = O(b, c, {...d, nameProcess:f => `\`${f}\``}), c != g && (e = g)); | ||
return e; | ||
@@ -663,3 +670,3 @@ }).join(", "); | ||
super(); | ||
this.f = null; | ||
this.g = null; | ||
this.async = !1; | ||
@@ -671,16 +678,16 @@ } | ||
b(a, {async:b, "return":d, ...c}, ...e) { | ||
this.description = I(a); | ||
this.description = G(a); | ||
super.b("", c, ...e); | ||
d && (this.f = d.replace(/\n\s*/g, " ")); | ||
d && (this.g = d.replace(/\n\s*/g, " ")); | ||
b && (this.async = !0); | ||
} | ||
get return() { | ||
return this.f || "void"; | ||
return this.g || "void"; | ||
} | ||
g(a) { | ||
a = super.g(a); | ||
this.f && (this.f = this.f.replace(a, "$1")); | ||
h(a) { | ||
a = super.h(a); | ||
this.g && (this.g = this.g.replace(a, "$1")); | ||
} | ||
} | ||
;class qa extends U { | ||
;class sa extends U { | ||
constructor() { | ||
@@ -698,71 +705,77 @@ super(); | ||
this.from = b; | ||
this.description = I(a); | ||
this.description = G(a); | ||
super.b("", {...c, noToc:!0, name:d, type:`import('${b}').${d}`}, e != g ? e : null); | ||
} | ||
} | ||
;const {homedir:ra} = os; | ||
ra(); | ||
const sa = (a, b) => { | ||
;const {homedir:ta} = os; | ||
ta(); | ||
const ua = (a, b) => { | ||
const d = new RegExp(`([!?])?${a}\\.`, "g"); | ||
b.properties.forEach(c => { | ||
M(c, a, d); | ||
K(c, a, d); | ||
}); | ||
b.g(a); | ||
b.h(a); | ||
}, X = (a, b) => { | ||
var {args:d = []} = a; | ||
if (d.length) { | ||
var c = `function(${d.map(({m:e}) => e).join(", ")}): ${a.fullName}`; | ||
d = new O(d); | ||
var c = `function(${d.map(({s:e}) => e).join(", ")}): ${a.fullName}`; | ||
d = new M(d); | ||
d.isConstructor = !0; | ||
d.b("Constructor method.", {type:c, name:"constructor"}); | ||
d.examples = a.examples; | ||
M(d, b); | ||
K(d, b); | ||
a.properties.unshift(d); | ||
} | ||
}, Y = (a, b, d, c, e = !1) => { | ||
const g = e ? new W : new U, f = a.search(/<(prop|function|fn|static) /); | ||
let h = "", k = a; | ||
1 != f && (h = a.slice(0, f), k = a.slice(f)); | ||
const {h:l, v:m} = K(h, c); | ||
g.b(e ? m : k, b, d, c); | ||
({l:a} = J(b, l)); | ||
e && (g.closureType = a); | ||
g.args = l; | ||
return g; | ||
}, Z = (a, b, d, c, e = !1) => { | ||
const g = [], {alias:f, aliases:h, ...k} = b; | ||
b = Y(a, b, d, c, e); | ||
g.push(b); | ||
(f ? [f] : h ? h.split(/, */) : []).forEach(l => { | ||
l = Y(a, {...k, name:l}, d, c, e); | ||
l.description = `${l.description}${l.description ? " " : ""}Alias of \`${k.name}\`.`; | ||
g.push(l); | ||
}, Y = (a, b, d, c, e = !1, g = null) => { | ||
const f = e ? new W : new U; | ||
f.f = g; | ||
g = a.search(/<(prop|function|fn|static) /); | ||
let k = "", h = a; | ||
1 != g && (k = a.slice(0, g), h = a.slice(g)); | ||
const {j:m, w:l} = I(k, c); | ||
f.b(e ? l : h, b, d, c); | ||
({o:a} = H(b, m)); | ||
e && (f.closureType = a); | ||
f.args = m; | ||
return f; | ||
}, Z = ({content:a, props:b, ns:d, i:c, isMethod:e = !1, location:g = null}) => { | ||
const f = [], {alias:k, aliases:h, ...m} = b; | ||
b = Y(a, b, d, c, e, g); | ||
f.push(b); | ||
(k ? [k] : h ? h.split(/, */) : []).forEach(l => { | ||
l = Y(a, {...m, name:l}, d, c, e, g); | ||
l.description = `${l.description}${l.description ? " " : ""}Alias of \`${m.name}\`.`; | ||
f.push(l); | ||
}); | ||
return g; | ||
return f; | ||
}; | ||
module.exports = {_Type:U, _Property:N, _Method:W, _parseFile:(a, b) => { | ||
a = F("types", a); | ||
module.exports = {_Type:U, _Property:L, _Method:W, _parseFile:(a, b, d = null) => { | ||
a = D("types", a); | ||
if (!a.length) { | ||
throw Error("XML file should contain root types element."); | ||
} | ||
const [{content:d, props:{namespace:c, ns:e = c}}] = a, g = b == e ? void 0 : e, f = []; | ||
a = F(["type", "interface", "constructor", "method", "import"], d).reduce((h, {content:k, props:l, tag:m}) => { | ||
const {alias:q, aliases:n, ...r} = l; | ||
var t = q ? [q] : n ? n.split(/, */) : []; | ||
switch(m) { | ||
const [{content:c, props:{namespace:e, ns:g = e}}] = a, f = b == g ? void 0 : g, k = []; | ||
a = D(["type", "interface", "constructor", "method", "import"], c).reduce((h, {content:m, props:l, tag:p}) => { | ||
const {alias:n, aliases:q, ...v} = l; | ||
var r = v.example; | ||
r && r.startsWith(".") && d && (v.example = R(Q(d), r)); | ||
r = n ? [n] : q ? q.split(/, */) : []; | ||
switch(p) { | ||
case "type": | ||
m = new U; | ||
m.b(k, l, g, b); | ||
h.push(m); | ||
t.forEach(p => { | ||
const u = new U; | ||
u.b(k, {...r, name:p}, g, b); | ||
h.push(u); | ||
p = new U; | ||
d && (p.f = d); | ||
p.b(m, l, f, b); | ||
h.push(p); | ||
r.forEach(t => { | ||
const y = new U; | ||
d && (y.f = d); | ||
y.b(m, {...v, name:t}, f, b); | ||
h.push(y); | ||
}); | ||
break; | ||
case "interface": | ||
l = Z(k, l, g, b); | ||
l.forEach(p => { | ||
p.properties.some(({isConstructor:u}) => u) || X(p, b); | ||
p.isInterface = !0; | ||
l = Z({content:m, props:l, ns:f, i:b, location:d}); | ||
l.forEach(t => { | ||
t.properties.some(({isConstructor:y}) => y) || X(t, b); | ||
t.isInterface = !0; | ||
}); | ||
@@ -772,6 +785,6 @@ h.push(...l); | ||
case "constructor": | ||
l = Z(k, l, g, b); | ||
l.forEach(p => { | ||
p.properties.some(({isConstructor:u}) => u) || X(p, b); | ||
p.isConstructor = !0; | ||
l = Z({content:m, props:l, ns:f, i:b, location:d}); | ||
l.forEach(t => { | ||
t.properties.some(({isConstructor:y}) => y) || X(t, b); | ||
t.isConstructor = !0; | ||
}); | ||
@@ -781,15 +794,15 @@ h.push(...l); | ||
case "method": | ||
l = Z(k, l, g, b, !0); | ||
l = Z({content:m, props:l, ns:f, i:b, isMethod:!0, location:d}); | ||
h.push(...l); | ||
break; | ||
case "import": | ||
t = new qa, t.b(k, l, l.ns || l.from, b), f.push(t); | ||
p = new sa, p.b(m, l, l.ns || l.from, b), k.push(p); | ||
} | ||
return h; | ||
}, []); | ||
b && a.forEach(h => sa(b, h)); | ||
return {namespace:e, types:a, imports:f}; | ||
}, _getLinks:S}; | ||
b && a.forEach(h => ua(b, h)); | ||
return {namespace:g, types:a, imports:k}; | ||
}, _getLinks:O}; | ||
//# sourceMappingURL=typal.js.map |
{ | ||
"name": "typal", | ||
"version": "1.24.7", | ||
"version": "1.24.8", | ||
"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", |
@@ -9,2 +9,3 @@ import extractTags from 'rexml' | ||
import Fn from './Fn' | ||
import { dirname, resolve } from 'path' | ||
@@ -50,4 +51,5 @@ /** | ||
* @param {string} [rootNamespace] Namespace to ignore in types and properties. | ||
* @param {string|null} [location] The file location. Will be used to update relative example locations. | ||
*/ | ||
const parseFile = (xml, rootNamespace) => { | ||
const parseFile = (xml, rootNamespace, location = null) => { | ||
const root = extractTags('types', xml) | ||
@@ -73,2 +75,5 @@ if (!root.length) | ||
const { 'alias': alias, 'aliases': aliases, ...restProps } = props | ||
const example = restProps['example'] | ||
if (example && example.startsWith('.') && location) | ||
restProps['example'] = resolve(dirname(location), example) | ||
const als = alias ? [alias] : (aliases ? aliases.split(/, */) : []) | ||
@@ -79,2 +84,3 @@ | ||
const type = new Type() | ||
if (location) type.file = location | ||
type.fromXML(content, props, ns, rootNamespace) | ||
@@ -85,2 +91,3 @@ acc.push(type) | ||
const type2 = new Type() | ||
if (location) type2.file = location | ||
type2.fromXML(content, { ...restProps, name }, ns, rootNamespace) | ||
@@ -92,3 +99,3 @@ acc.push(type2) | ||
case 'interface': { | ||
const t = parseTypes(content, props, ns, rootNamespace) | ||
const t = parseTypes({ content, props, ns, rootNamespace, location }) | ||
t.forEach(tt => { | ||
@@ -105,3 +112,3 @@ const hasConsructorProp = tt.properties.some(({ isConstructor }) => { | ||
case 'constructor': { | ||
const t = parseTypes(content, props, ns, rootNamespace) | ||
const t = parseTypes({ content, props, ns, rootNamespace, location }) | ||
t.forEach(tt => { | ||
@@ -118,3 +125,5 @@ const hasConsructorProp = tt.properties.some(({ isConstructor }) => { | ||
case 'method': { | ||
const t = parseTypes(content, props, ns, rootNamespace, true) | ||
const t = parseTypes({ | ||
content, props, ns, rootNamespace, isMethod: true, location, | ||
}) | ||
acc.push(...t) | ||
@@ -151,5 +160,7 @@ break | ||
* @param {boolean} [isMethod] | ||
* @param {string|null} [location] The source XML file location. | ||
*/ | ||
const parseType = (content, props, ns, rootNamespace, isMethod = false) => { | ||
const parseType = (content, props, ns, rootNamespace, isMethod = false, location = null) => { | ||
const type = isMethod ? new Method() : new Type() | ||
type.file = location | ||
const i = content.search(/<(prop|function|fn|static) /) | ||
@@ -186,12 +197,16 @@ let prebody = '', body = content | ||
* will be written with `= function () {}` in externs. | ||
* @param {string} content | ||
* @param {!Object} props | ||
* @param {string} [ns] | ||
* @param {string} [rootNamespace] | ||
* @param {boolean} [isMethod] | ||
* @param {Object} props | ||
* @param {string} props.content | ||
* @param {!Object} props.props | ||
* @param {string} [props.ns] | ||
* @param {string} [props.rootNamespace] | ||
* @param {boolean} [props.isMethod] | ||
* @param {string|null} [props.location] | ||
*/ | ||
const parseTypes = (content, props, ns, rootNamespace, isMethod = false) => { | ||
const parseTypes = ({ | ||
content, props, ns, rootNamespace, isMethod = false, location = null, | ||
}) => { | ||
const acc = [] | ||
const { 'alias': alias, 'aliases': aliases, ...restProps } = props | ||
const type = parseType(content, props, ns, rootNamespace, isMethod) | ||
const type = parseType(content, props, ns, rootNamespace, isMethod, location) | ||
acc.push(type) | ||
@@ -202,3 +217,3 @@ | ||
als.forEach((name) => { | ||
const type2 = parseType(content, { ...restProps, name }, ns, rootNamespace, isMethod) | ||
const type2 = parseType(content, { ...restProps, name }, ns, rootNamespace, isMethod, location) | ||
type2.description = `${type2.description}${type2.description ? ' ' : ''}Alias of \`${restProps.name}\`.` | ||
@@ -220,3 +235,3 @@ acc.push(type2) | ||
try { | ||
({ namespace = null, types, imports } = parseFile(xml)) | ||
({ namespace = null, types, imports } = parseFile(xml, undefined, path)) | ||
} catch (err) { | ||
@@ -223,0 +238,0 @@ err.message = `Error while reading ${path}\n${err.message}` |
@@ -9,2 +9,3 @@ import extractTags from 'rexml' | ||
import makePropsTable from './make-props-table' | ||
import { resolve, dirname } from 'path' | ||
@@ -86,2 +87,8 @@ /** | ||
this.examples = [] | ||
/** | ||
* The location on the disk. | ||
* @type {string|null} | ||
*/ | ||
this.file = null | ||
} | ||
@@ -148,3 +155,6 @@ get import() { | ||
} | ||
if (example) this.examples = Property.readExamples(example, exampleOverride) | ||
if (example) { | ||
const e = (example.startsWith('.') && this.file) ? resolve(dirname(this.file), example) : example | ||
this.examples = Property.readExamples(e, exampleOverride) | ||
} | ||
} | ||
@@ -151,0 +161,0 @@ get shouldPrototype() { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
469764
5922