Comparing version 1.24.13 to 1.24.14
## 18 December 2019 | ||
### [1.24.14](https://github.com/artdecocode/typal/compare/v1.24.13...v1.24.14) | ||
- [feature] Arguments for interfaces/constructors in externs. | ||
### [1.24.13](https://github.com/artdecocode/typal/compare/v1.24.12...v1.24.13) | ||
@@ -4,0 +8,0 @@ |
@@ -56,3 +56,3 @@ #!/usr/bin/env node | ||
return b; | ||
}, ia = () => { | ||
}, ha = () => { | ||
var a = fa; | ||
@@ -74,3 +74,3 @@ return Object.keys(a).reduce((b, c) => { | ||
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"}}, w = function(a = {}, b = process.argv) { | ||
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 [, , ...c] = b; | ||
@@ -87,3 +87,3 @@ const d = ea(c); | ||
try { | ||
const {short:m, boolean:n, number:p, command:q, multiple:r} = k; | ||
const m = k.short, n = k.boolean, p = k.number, q = k.command, r = k.multiple; | ||
if (q && r && d.length) { | ||
@@ -95,6 +95,6 @@ l = d; | ||
} else { | ||
const t = da(c, h, m, n, p); | ||
({value:l} = t); | ||
const {index:u, length:v} = t; | ||
void 0 !== u && v && e.push({index:u, length:v}); | ||
const u = da(c, h, m, n, p); | ||
({value:l} = u); | ||
const t = u.index, w = u.length; | ||
void 0 !== t && w && e.push({index:t, length:w}); | ||
} | ||
@@ -116,4 +116,4 @@ } | ||
return a; | ||
}(fa), y = w.source, ja = w.output, ka = w.closure, la = w.useNamespace, ma = w.externs, na = w.types, oa = w.template, pa = w.migrate, qa = w.help, ra = w.version; | ||
function sa(a = {usage:{}}) { | ||
}(fa), x = v.source, y = v.output, ia = v.closure, ja = v.useNamespace, ka = v.externs, la = v.types, ma = v.template, na = v.migrate, oa = v.help, pa = v.version; | ||
function qa(a = {usage:{}}) { | ||
const {usage:b = {}, description:c, line:d, example:e} = a; | ||
@@ -136,3 +136,3 @@ a = Object.keys(b); | ||
const r = h("", g); | ||
n = q.map(t => `${r}\t${t}`); | ||
n = q.map(u => `${r}\t${u}`); | ||
return [...l, m, ...n]; | ||
@@ -150,6 +150,6 @@ }, []).map(l => `\t${l}`); | ||
} | ||
;const {createReadStream:ta, createWriteStream:ua, lstat:A, readFileSync:va, readdir:wa} = fs; | ||
var xa = stream; | ||
const {Transform:B, Writable:ya} = stream; | ||
const za = (a, b = 0, c = !1) => { | ||
;const ra = fs.createReadStream, sa = fs.createWriteStream, z = fs.lstat, ta = fs.readFileSync, ua = fs.readdir; | ||
var va = stream; | ||
const A = stream.Transform, wa = stream.Writable; | ||
const xa = (a, b = 0, c = !1) => { | ||
if (0 === b && !c) { | ||
@@ -160,11 +160,11 @@ return a; | ||
return c ? a[a.length - 1] : a.slice(b).join("\n"); | ||
}, Aa = (a, b = !1) => za(a, 2 + (b ? 1 : 0)), Ba = a => { | ||
}, ya = (a, b = !1) => xa(a, 2 + (b ? 1 : 0)), za = a => { | ||
({callee:{caller:a}} = a); | ||
return a; | ||
}; | ||
const {homedir:Ca} = os; | ||
const Da = /\s+at.*(?:\(|\s)(.*)\)?/, Ea = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/, Fa = Ca(), C = a => { | ||
const {pretty:b = !1, ignoredModules:c = ["pirates"]} = {}, d = c.join("|"), e = new RegExp(Ea.source.replace("IGNORED_MODULES", d)); | ||
const Aa = os.homedir; | ||
const Ca = /\s+at.*(?:\(|\s)(.*)\)?/, Da = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/, Ea = Aa(), B = 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(Da); | ||
f = f.match(Ca); | ||
if (null === f || !f[1]) { | ||
@@ -175,20 +175,20 @@ 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(Da, (g, h) => g.replace(h, h.replace(Fa, "~"))) : 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 Ga(a, b, c = !1) { | ||
function Fa(a, b, c = !1) { | ||
return function(d) { | ||
var e = Ba(arguments), {stack:f} = Error(); | ||
const g = za(f, 2, !0), h = (f = d instanceof Error) ? d.message : d; | ||
var e = za(arguments), {stack:f} = Error(); | ||
const g = xa(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); | ||
e = B(e); | ||
return Object.assign(f ? d : Error(), {message:h, stack:e}); | ||
}; | ||
} | ||
;function D(a) { | ||
;function C(a) { | ||
var {stack:b} = Error(); | ||
const c = Ba(arguments); | ||
b = Aa(b, a); | ||
return Ga(c, b, a); | ||
const c = za(arguments); | ||
b = ya(b, a); | ||
return Fa(c, b, a); | ||
} | ||
;const Ia = (a, b) => { | ||
;const Ga = (a, b) => { | ||
b.once("error", c => { | ||
@@ -199,8 +199,8 @@ a.emit("error", c); | ||
}; | ||
class Ja extends ya { | ||
class Ha extends wa { | ||
constructor(a) { | ||
const {binary:b = !1, rs:c = null, ...d} = a || {}, {S:e = D(!0), proxyError:f} = a || {}, g = (h, k) => e(k); | ||
const {binary:b = !1, rs:c = null, ...d} = a || {}, {R:e = C(!0), proxyError:f} = a || {}, g = (h, k) => e(k); | ||
super(d); | ||
this.b = []; | ||
this.O = new Promise((h, k) => { | ||
this.N = new Promise((h, k) => { | ||
this.on("finish", () => { | ||
@@ -216,3 +216,3 @@ let l; | ||
} else { | ||
const m = C(l.stack); | ||
const m = B(l.stack); | ||
l.stack = m; | ||
@@ -223,3 +223,3 @@ f && g`${l}`; | ||
}); | ||
c && Ia(this, c).pipe(this); | ||
c && Ga(this, c).pipe(this); | ||
}); | ||
@@ -232,18 +232,18 @@ } | ||
get f() { | ||
return this.O; | ||
return this.N; | ||
} | ||
} | ||
const E = async a => { | ||
({f:a} = new Ja({rs:a, S:D(!0)})); | ||
const D = async a => { | ||
({f:a} = new Ha({rs:a, R:C(!0)})); | ||
return await a; | ||
}; | ||
async function F(a) { | ||
a = ta(a); | ||
return await E(a); | ||
async function E(a) { | ||
a = ra(a); | ||
return await D(a); | ||
} | ||
;async function H(a, b) { | ||
;async function F(a, b) { | ||
if (!a) { | ||
throw Error("No path is given."); | ||
} | ||
const c = D(!0), d = ua(a); | ||
const c = C(!0), d = sa(a); | ||
await new Promise((e, f) => { | ||
@@ -256,3 +256,3 @@ d.on("error", g => { | ||
} | ||
;function Ka(a, b) { | ||
;function Ia(a, b) { | ||
if (b > a - 2) { | ||
@@ -262,8 +262,8 @@ throw Error("Function does not accept that many arguments."); | ||
} | ||
async function I(a, b, c) { | ||
const d = D(!0); | ||
async function G(a, b, c) { | ||
const d = C(!0); | ||
if ("function" !== typeof a) { | ||
throw Error("Function must be passed."); | ||
} | ||
const {length:e} = a; | ||
const e = a.length; | ||
if (!e) { | ||
@@ -276,17 +276,17 @@ throw Error("Function does not accept any arguments."); | ||
Array.isArray(b) ? (b.forEach((l, m) => { | ||
Ka(e, m); | ||
}), k = [...b, h]) : 1 < Array.from(arguments).length && (Ka(e, 0), k = [b, h]); | ||
Ia(e, m); | ||
}), k = [...b, h]) : 1 < Array.from(arguments).length && (Ia(e, 0), k = [b, h]); | ||
a(...k); | ||
}); | ||
} | ||
;const {dirname:La, join:J, relative:Ma, resolve:Na} = path; | ||
async function Oa(a, b) { | ||
;const Ja = path.dirname, H = path.join, Ka = path.relative, La = path.resolve; | ||
async function Ma(a, b) { | ||
b = b.map(async c => { | ||
const d = J(a, c); | ||
return {lstat:await I(A, d), path:d, relativePath:c}; | ||
const d = H(a, c); | ||
return {lstat:await G(z, d), path:d, relativePath:c}; | ||
}); | ||
return await Promise.all(b); | ||
} | ||
const Pa = a => a.lstat.isDirectory(), Qa = a => !a.lstat.isDirectory(); | ||
async function K(a) { | ||
const Na = a => a.lstat.isDirectory(), Oa = a => !a.lstat.isDirectory(); | ||
async function I(a) { | ||
if (!a) { | ||
@@ -296,3 +296,3 @@ throw Error("Please specify a path to the directory"); | ||
const {ignore:b = []} = {}; | ||
if (!(await I(A, a)).isDirectory()) { | ||
if (!(await G(z, a)).isDirectory()) { | ||
var c = Error("Path is not a directory"); | ||
@@ -302,6 +302,6 @@ c.code = "ENOTDIR"; | ||
} | ||
c = await I(wa, a); | ||
var d = await Oa(a, c); | ||
c = d.filter(Pa); | ||
d = d.filter(Qa).reduce((e, f) => { | ||
c = await G(ua, a); | ||
var d = await Ma(a, c); | ||
c = d.filter(Na); | ||
d = d.filter(Oa).reduce((e, f) => { | ||
var g = f.lstat.isDirectory() ? "Directory" : f.lstat.isFile() ? "File" : f.lstat.isSymbolicLink() ? "SymbolicLink" : void 0; | ||
@@ -311,3 +311,3 @@ return {...e, [f.relativePath]:{type:g}}; | ||
c = await c.reduce(async(e, {path:f, relativePath:g}) => { | ||
const h = Ma(a, f); | ||
const h = Ka(a, f); | ||
if (b.includes(h)) { | ||
@@ -317,3 +317,3 @@ return e; | ||
e = await e; | ||
f = await K(f); | ||
f = await I(f); | ||
return {...e, [g]:f}; | ||
@@ -323,11 +323,11 @@ }, {}); | ||
} | ||
const L = (a, b) => { | ||
const J = (a, b) => { | ||
let c = [], d = []; | ||
Object.keys(a).forEach(f => { | ||
const {type:g} = a[f]; | ||
"File" == g ? c.push(J(b, f)) : "Directory" == g && d.push(f); | ||
"File" == g ? c.push(H(b, f)) : "Directory" == g && d.push(f); | ||
}); | ||
const e = d.reduce((f, g) => { | ||
const {content:h} = a[g]; | ||
g = L(h, J(b, g)); | ||
g = J(h, H(b, g)); | ||
return [...f, ...g]; | ||
@@ -337,12 +337,11 @@ }, []); | ||
}; | ||
function Ra(a) { | ||
function Pa(a) { | ||
if ("object" != typeof a) { | ||
return !1; | ||
} | ||
const {re:b, replacement:c} = a; | ||
a = b instanceof RegExp; | ||
const d = -1 != ["string", "function"].indexOf(typeof c); | ||
return a && d; | ||
const b = a.re instanceof RegExp; | ||
a = -1 != ["string", "function"].indexOf(typeof a.replacement); | ||
return b && a; | ||
} | ||
const M = (a, b) => { | ||
const K = (a, b) => { | ||
if (!(b instanceof Error)) { | ||
@@ -361,5 +360,5 @@ throw b; | ||
}; | ||
function Sa(a, b) { | ||
function Qa(a, b) { | ||
function c() { | ||
return b.filter(Ra).reduce((d, {re:e, replacement:f}) => { | ||
return b.filter(Pa).reduce((d, {re:e, replacement:f}) => { | ||
if (this.j) { | ||
@@ -378,3 +377,3 @@ return d; | ||
} catch (l) { | ||
M(g, l); | ||
K(g, l); | ||
} | ||
@@ -390,8 +389,8 @@ }); | ||
} | ||
;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}; | ||
;const Ra = a => new RegExp(`%%_RESTREAM_${a.toUpperCase()}_REPLACEMENT_(\\d+)_%%`, "g"), Sa = (a, b) => `%%_RESTREAM_${a.toUpperCase()}_REPLACEMENT_${b}_%%`, Ta = () => { | ||
var a = {S:/^\/\*\*? (documentary|typal) (.+?) externs (.*?)\*\/\n(?:([^\n][\s\S]+?\n))?$/mg}; | ||
return Object.keys(a).reduce((b, c) => { | ||
{ | ||
var d = a[c]; | ||
const {getReplacement:e = Ua, getRegex:f = Ta} = {}, g = f(c); | ||
const {getReplacement:e = Sa, getRegex:f = Ra} = {}, g = f(c); | ||
d = {name:c, re:d, regExp:g, getReplacement:e, map:{}, lastIndex:0}; | ||
@@ -401,26 +400,26 @@ } | ||
}, {}); | ||
}, Wa = a => { | ||
}, Ua = a => { | ||
var 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]); | ||
const c = a.map; | ||
return {re:a.regExp, replacement(d, e) { | ||
d = c[e]; | ||
delete c[e]; | ||
return Qa(d, Array.isArray(b) ? b : [b]); | ||
}}; | ||
}, Xa = a => { | ||
const {re:b, map:c, getReplacement:d, name:e} = a; | ||
return {re:b, replacement(f) { | ||
const {lastIndex:g} = a; | ||
c[g] = f; | ||
}, Va = a => { | ||
const b = a.map, c = a.getReplacement, d = a.name; | ||
return {re:a.re, replacement(e) { | ||
const f = a.lastIndex; | ||
b[f] = e; | ||
a.lastIndex += 1; | ||
return d(e, g); | ||
return c(d, f); | ||
}}; | ||
}; | ||
async function Ya(a, b) { | ||
return Za(a, b); | ||
async function Wa(a, b) { | ||
return Xa(a, b); | ||
} | ||
class N extends B { | ||
class L extends A { | ||
constructor(a, b) { | ||
super(b); | ||
this.f = (Array.isArray(a) ? a : [a]).filter(Ra); | ||
this.g = (Array.isArray(a) ? a : [a]).filter(Pa); | ||
this.j = !1; | ||
@@ -430,5 +429,5 @@ this.h = b; | ||
async replace(a, b) { | ||
const c = new N(this.f, this.h); | ||
const c = new L(this.g, this.h); | ||
b && Object.assign(c, b); | ||
a = await Ya(c, a); | ||
a = await Wa(c, a); | ||
c.j && (this.j = !0); | ||
@@ -441,3 +440,3 @@ b && Object.keys(b).forEach(d => { | ||
async reduce(a) { | ||
return await this.f.reduce(async(b, {re:c, replacement:d}) => { | ||
return await this.g.reduce(async(b, {re:c, replacement:d}) => { | ||
b = await b; | ||
@@ -462,3 +461,3 @@ if (this.j) { | ||
} catch (l) { | ||
M(f, l); | ||
K(f, l); | ||
} | ||
@@ -471,3 +470,3 @@ }); | ||
} catch (h) { | ||
M(f, h); | ||
K(f, h); | ||
} | ||
@@ -487,14 +486,14 @@ } else { | ||
} catch (d) { | ||
a = C(d.stack), d.stack = a, c(d); | ||
a = B(d.stack), d.stack = a, c(d); | ||
} | ||
} | ||
} | ||
async function Za(a, b) { | ||
b instanceof xa ? b.pipe(a) : a.end(b); | ||
return await E(a); | ||
async function Xa(a, b) { | ||
b instanceof va ? b.pipe(a) : a.end(b); | ||
return await D(a); | ||
} | ||
;function $a() { | ||
var a = ab; | ||
;function Ya() { | ||
var a = Za; | ||
let b = ""; | ||
const c = new B({transform(d, e, f) { | ||
const c = new A({transform(d, e, f) { | ||
let g; | ||
@@ -508,3 +507,3 @@ for (b += d.toString(); (d = a.exec(b)) && (c.push(d), g = d, a.global);) { | ||
} | ||
;const bb = (a, b, c, d) => { | ||
;const M = (a, b, c, d) => { | ||
if (!a) { | ||
@@ -519,11 +518,11 @@ throw Error("The name of the property is not given"); | ||
return `${a}=${b}`; | ||
}, 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 = ({number:a, L:b, boolean:c, type:d}) => b ? "string" : a ? "number" : c ? "boolean" : d ? d : "*", ab = a => `${/[^\w\d._]/.test(a) ? `(${a})` : a}|undefined`, N = a => a ? `/** | ||
${a} | ||
*/ | ||
` : "/**\n */\n", P = a => ` * @suppress {nonStandardJsDocs} | ||
${a}`, eb = (a, b, c) => { | ||
` : "/**\n */\n", O = a => ` * @suppress {nonStandardJsDocs} | ||
${a}`, bb = (a, b, c) => { | ||
a = `${a ? "" : "var "}${a ? `${a}.` : ""}${b}`; | ||
c && (a += ` = ${c}`); | ||
return a; | ||
}, Q = a => { | ||
}, P = a => { | ||
a = a.trimRight(); | ||
@@ -550,6 +549,6 @@ var b = /\S/.exec(a); | ||
} | ||
}, fb = (a, b, c = null) => { | ||
}, cb = (a, b, c = null) => { | ||
const {async:d, "void":e, "return":f = e ? "void" : "", ...g} = a; | ||
({args:a = ""} = a); | ||
a || (a = b.map(({J: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, " "); | ||
@@ -560,35 +559,9 @@ d && b ? b = `!Promise<${b}>` : d && (b = "!Promise"); | ||
b && (c += `: ${b}`); | ||
return {W:{...g, async:d}, I:c}; | ||
return {W:{...g, async:d}, H: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 = c[k]; | ||
if (!k || void 0 === h) { | ||
return g; | ||
} | ||
g[k] = h; | ||
return g; | ||
}, {}); | ||
d.push(e); | ||
}); | ||
return d; | ||
function Q(a, b) { | ||
const c = a.example; | ||
c && c.startsWith(".") && b && (a.example = La(Ja(b), c)); | ||
} | ||
;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 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}; | ||
}); | ||
}, 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[c] = "true" == d ? !0 : "false" == d ? !1 : /^\d+$/.test(d) ? parseInt(d, 10) : d; | ||
return b; | ||
}, {}); | ||
const kb = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => { | ||
;const db = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => { | ||
switch(b) { | ||
@@ -610,3 +583,3 @@ case "function": | ||
}); | ||
function lb(a) { | ||
function eb(a) { | ||
let b = 0; | ||
@@ -768,7 +741,37 @@ const c = (e = 1) => a[b + e], d = (e = !0, f = []) => { | ||
} | ||
;function mb(a) { | ||
a = kb(a); | ||
return lb(a); | ||
;function fb(a) { | ||
a = db(a); | ||
return eb(a); | ||
} | ||
;function nb(a, b, {name:c, string:d, "boolean":e, opt:f, number:g, type:h}, k) { | ||
;function gb(a, b, c) { | ||
const d = []; | ||
b.replace(a, (e, ...f) => { | ||
e = f.slice(0, f.length - 2).reduce((g, h, k) => { | ||
k = c[k]; | ||
if (!k || void 0 === h) { | ||
return g; | ||
} | ||
g[k] = h; | ||
return g; | ||
}, {}); | ||
d.push(e); | ||
}); | ||
return d; | ||
} | ||
;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 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}; | ||
}); | ||
}, 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[c] = "true" == d ? !0 : "false" == d ? !1 : /^\d+$/.test(d) ? parseInt(d, 10) : d; | ||
return b; | ||
}, {}); | ||
function kb(a, b, {name:c, string:d, "boolean":e, opt:f, number:g, type:h}, k) { | ||
if (!c) { | ||
@@ -778,4 +781,4 @@ throw Error("Argument does not have a name."); | ||
a.name = c; | ||
b && (a.description = Q(b)); | ||
b = cb({number:g, M:d, boolean:e, type:h}); | ||
b && (a.description = P(b)); | ||
b = $a({number:g, L:d, boolean:e, type:h}); | ||
k && (b = b.replace(new RegExp(`([!?])?${k}\\.`, "g"), "$1")); | ||
@@ -786,3 +789,3 @@ b.endsWith("=") && (b = b.replace(/=$/, ""), f = !0); | ||
} | ||
class ob { | ||
class lb { | ||
constructor() { | ||
@@ -794,15 +797,15 @@ this.name = null; | ||
} | ||
get J() { | ||
get I() { | ||
return this.optional ? `${this.type}=` : this.type; | ||
} | ||
} | ||
const pb = (a, b) => { | ||
const mb = (a, b) => { | ||
let c = a.lastIndexOf("</arg>"), d = a; | ||
var e = []; | ||
-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); | ||
const h = new lb; | ||
kb(h, f, g, b); | ||
return h; | ||
})); | ||
return {K:d, G:e}; | ||
return {J:d, F:e}; | ||
}; | ||
@@ -865,3 +868,3 @@ function S(a) { | ||
return d + c; | ||
}).join("\n"), qb = a => { | ||
}).join("\n"), nb = a => { | ||
const b = a.replace(/^\s*\n/gm, "").split("\n").reduce((c, d) => { | ||
@@ -873,8 +876,8 @@ [{length:d = 0} = {}] = /^\s*/.exec(d) || []; | ||
}; | ||
function rb(a, b = "") { | ||
function ob(a, b = "") { | ||
const c = b.split(/\s*,\s*/); | ||
return a.split(/\s*,\s*/).map(d => { | ||
let e = d = va(d, "utf8"); | ||
let e = d = ta(d, "utf8"); | ||
if (d = /\/\* start example \*\/\r?\n([\s\S]+?)\r?\n\s*\/\* end example \*\//.exec(d)) { | ||
[, d] = d, e = qb(d); | ||
[, d] = d, e = nb(d); | ||
} | ||
@@ -889,3 +892,3 @@ c.forEach(f => { | ||
} | ||
function sb(a, {P:b = !0, U:c = !0} = {}) { | ||
function pb(a, {O:b = !0, T:c = !0} = {}) { | ||
const d = []; | ||
@@ -911,25 +914,25 @@ b && d.push(" * @example"); | ||
} | ||
function tb(a, b, c = new RegExp(`([!?])?${b}\\.`, "g")) { | ||
function qb(a, b, c = new RegExp(`([!?])?${b}\\.`, "g")) { | ||
b && (a.type = a.type.replace(c, "$1")); | ||
} | ||
function ub(a, b = !1) { | ||
function rb(a, b = !1) { | ||
return b ? a.closureType : a.isParsedFunction ? a.toTypeScriptFunction(S) : a.type; | ||
} | ||
function vb(a, b = null, c = !1, d = !1) { | ||
function sb(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 = bb(a.name, a.optional ? a.default : null, a.type, b); | ||
b = M(a.name, a.optional ? a.default : null, a.type, b); | ||
b = a.optional ? `[${b}]` : b; | ||
var {m:e} = a; | ||
var e = a.m; | ||
e = e ? ` ${e}` : ""; | ||
c = `{${ub(a, c)}} ${b}${e}`; | ||
d && (a = sb(a.examples, {P:!1, U:!1}).join("\n").replace(/\*/g, "\uff0a")) && (c += `\n${a}`); | ||
c = `{${rb(a, c)}} ${b}${e}`; | ||
d && (a = pb(a.examples, {O:!1, T:!1}).join("\n").replace(/\*/g, "\uff0a")) && (c += `\n${a}`); | ||
return c; | ||
} | ||
function wb(a, b = !1) { | ||
a = vb(a, null, b, !0); | ||
function tb(a, b = !1) { | ||
a = sb(a, null, b, !0); | ||
return ` * @prop ${T(a, !0)}`; | ||
} | ||
function xb(a, b) { | ||
function ub(a, b) { | ||
const c = [], {function:{args:d, return:e, variableArgs:f, this:g}} = a.parsed; | ||
@@ -941,3 +944,3 @@ d.map(h => S(h)).forEach((h, k) => { | ||
if (f) { | ||
const {N:h, X:k} = yb(a.args || []), l = [h, k].filter(Boolean).join(" "); | ||
const {M:h, X:k} = vb(a.args || []), l = [h, k].filter(Boolean).join(" "); | ||
c.push(` * @param {...${S(f)}} ${l}`); | ||
@@ -955,3 +958,3 @@ } | ||
} | ||
function zb(a) { | ||
function wb(a) { | ||
if (a.isParsedFunction) { | ||
@@ -963,3 +966,3 @@ const {function:{args:b, variableArgs:c}} = a.parsed, d = b.map((e, f) => { | ||
if (c) { | ||
const {N:e} = yb(a.args || []); | ||
const {M:e} = vb(a.args || []); | ||
d.push(`...${e}`); | ||
@@ -973,10 +976,10 @@ } | ||
let d = []; | ||
var {m:e} = a; | ||
var e = a.m; | ||
e && (e = T(e), d.push(...e.split("\n"))); | ||
!a.optional && a.isParsedFunction ? (e = xb(a, c), d.push(...e)) : d.push(` * @type {${a.optional ? db(a.closureType) : a.closureType}}`); | ||
c && a.examples.length && (a = sb(a.examples), d.push(...a)); | ||
!a.optional && a.isParsedFunction ? (e = ub(a, c), d.push(...e)) : d.push(` * @type {${a.optional ? ab(a.closureType) : a.closureType}}`); | ||
c && a.examples.length && (a = pb(a.examples), d.push(...a)); | ||
b && (d = d.map(f => `${b}${f}`)); | ||
return d.join("\n"); | ||
} | ||
function Ab(a, b) { | ||
function xb(a, b) { | ||
const c = Object.assign(Object.create(Object.getPrototypeOf(a)), a); | ||
@@ -987,3 +990,3 @@ c.description = `An alias for \`${a.name}\`.`; | ||
} | ||
class Bb { | ||
class yb { | ||
constructor(a = null) { | ||
@@ -1035,3 +1038,3 @@ this.g = this.description = this.name = null; | ||
} | ||
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, "template-no-return":u}) { | ||
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:u, "template-no-return":t}) { | ||
if (!b) { | ||
@@ -1041,8 +1044,8 @@ throw Error("Property does not have a name."); | ||
this.name = b; | ||
a && (this.description = Q(a)); | ||
a = cb({number:f, M:c, boolean:d, type:g}); | ||
a && (this.description = P(a)); | ||
a = $a({number:f, L:c, boolean:d, type:g}); | ||
q && (this.o = q); | ||
k && (this.h = k); | ||
this.type = a; | ||
void 0 !== h ? this.default = h : void 0 !== t && (this.default = t); | ||
void 0 !== h ? this.default = h : void 0 !== u && (this.default = u); | ||
if (e || void 0 !== h) { | ||
@@ -1054,4 +1057,4 @@ this.optional = !0; | ||
r && (this.f = !0); | ||
n && (this.examples = rb(n, p)); | ||
u && (this.s = !0); | ||
n && (this.examples = ob(n, p)); | ||
t && (this.s = !0); | ||
} | ||
@@ -1066,3 +1069,3 @@ get type() { | ||
try { | ||
this.parsed = mb(this.closureType), this.isParsedFunction && !this.args && (this.args = []); | ||
this.parsed = fb(this.closureType), this.isParsedFunction && !this.args && (this.args = []); | ||
} catch (b) { | ||
@@ -1085,4 +1088,4 @@ this.parsed = null; | ||
} | ||
D(a, b = "", c = !1) { | ||
a = vb(this, a, c); | ||
C(a, b = "", c = !1) { | ||
a = sb(this, a, c); | ||
const [d, ...e] = a.split("\n"); | ||
@@ -1092,9 +1095,9 @@ return [`@param ${d}`, ...e].map(f => `${b} * ${f}`).join("\n"); | ||
} | ||
const yb = a => { | ||
const vb = a => { | ||
let b = "args"; | ||
const {name:c = "", description:d} = a[a.length - 1] || {}; | ||
c.startsWith("...") && (b = c.replace("...", "")); | ||
return {N:b, X:d}; | ||
return {M:b, X:d}; | ||
}; | ||
class V extends Bb { | ||
class V extends yb { | ||
constructor(...a) { | ||
@@ -1116,3 +1119,3 @@ super(...a); | ||
try { | ||
(d = mb(b)) || console.log("Could not parse %s", b); | ||
(d = fb(b)) || console.log("Could not parse %s", b); | ||
} catch (e) { | ||
@@ -1153,8 +1156,8 @@ console.log("Could not parse %s", b), console.error(e.message); | ||
return `${g}: ${h}`; | ||
}), 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); | ||
}), e += d.join(", "), e += " }") : a.application ? (e += zb(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 += zb("any" == a.name ? "*" : a.name, b, f, c); | ||
} | ||
return e; | ||
}, Cb = (a, b, c = "", d = {}) => { | ||
}, zb = (a, b, c = "", d = {}) => { | ||
const {flatten:e = !1, nameProcess:f, link:g = ({link:l}) => `#${l}`} = d; | ||
d = Db(b, a); | ||
d = Ab(b, a); | ||
c = `${c}${a}`; | ||
@@ -1169,3 +1172,3 @@ if (!d) { | ||
return k ? `<a href="${h}" title="${k.replace(/"/g, """)}">${b}</a>` : `[${b}](${h})`; | ||
}, Db = (a, b) => { | ||
}, Ab = (a, b) => { | ||
a = a.filter(({fullName:d}) => d == b); | ||
@@ -1178,3 +1181,3 @@ if (a.length) { | ||
}; | ||
function Eb(a, b = [], c = [], d = {}) { | ||
function Bb(a, b = [], c = [], d = {}) { | ||
const {narrow:e = !1, flatten:f = !1, preprocessDesc:g, link:h} = d; | ||
@@ -1188,4 +1191,4 @@ if (!b.length) { | ||
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:Fb(u, !e), d:t}; | ||
const r = k || p.optional ? p.name : `${p.name}*`, u = p.hasDefault ? `\`${p.default}\`` : "-", t = g ? g(p.description) : p.description; | ||
return {prop:p, typeName:q, name:r, de:Cb(t, !e), d:u}; | ||
}); | ||
@@ -1195,3 +1198,3 @@ if (e) { | ||
} | ||
a = a.map(({name:p, typeName:q, de:r, d:t, prop:u}) => [u.optional ? p : `__${p}__`, `<em>${q}</em>`, r, ...l ? [t] : []]); | ||
a = a.map(({name:p, typeName:q, de:r, d:u, prop:t}) => [t.optional ? p : `__${p}__`, `<em>${q}</em>`, r, ...l ? [u] : []]); | ||
b = ["Name", ...e ? ["Type & Description"] : ["Type", "Description"], ...l ? [k ? "Initial" : "Default"] : []]; | ||
@@ -1204,3 +1207,3 @@ return ` | ||
} | ||
const Fb = (a = "", b = !0) => { | ||
const Cb = (a = "", b = !0) => { | ||
null === a && (a = ""); | ||
@@ -1210,13 +1213,34 @@ b && (a = a.replace(/\|/g, "\\|")); | ||
}; | ||
function Gb(a, b) { | ||
const c = a.example; | ||
c && c.startsWith(".") && b && (a.example = Na(La(b), c)); | ||
function Db(a, b, c, d) { | ||
var e = R("prop", a).map(({content:k, props:l}) => { | ||
const m = new yb; | ||
Q(l, c); | ||
m.b(k, l); | ||
return m; | ||
}); | ||
a = R(["function", "fn", "static"], a).map(({content:k, props:l, tag:m}) => { | ||
m = "static" == m; | ||
const {J:n, F:p} = mb(k, b); | ||
k = new V(p); | ||
const {W:q, H:r} = cb(l, p, d); | ||
q.type = r; | ||
Q(q, c); | ||
k.b(n, q); | ||
m && (k.f = !0); | ||
return k; | ||
}); | ||
e = [...e, ...a]; | ||
const {G:f, K:g, n:h} = e.reduce((k, l) => { | ||
l.isConstructor ? k.G.push(l) : l.static ? k.K.push(l) : k.n.push(l); | ||
return k; | ||
}, {G:[], K:[], n:[]}); | ||
return {constructor:f[0] || null, properties:[...f, ...g, ...h]}; | ||
} | ||
function Hb(a) { | ||
;function Eb(a) { | ||
var b = a.h(); | ||
b = O(b.join("\n")); | ||
b += eb(a.namespace, a.name, Ib(a)); | ||
b = N(b.join("\n")); | ||
b += bb(a.namespace, a.name, Fb(a)); | ||
const c = a.properties.reduce((d, e) => { | ||
d.push(e); | ||
const f = e.aliases.map(g => Ab(e, g)); | ||
const f = e.aliases.map(g => xb(e, g)); | ||
d.push(...f); | ||
@@ -1226,14 +1250,14 @@ return d; | ||
let e = U(d); | ||
e = O(e); | ||
e += eb(`${a.fullName}${d.static ? "" : ".prototype"}`, d.name); | ||
return e += zb(d); | ||
e = N(e); | ||
e += bb(`${a.fullName}${d.static ? "" : ".prototype"}`, d.name); | ||
return e += wb(d); | ||
}); | ||
return [b, ...c].join("\n"); | ||
} | ||
function Jb(a, b = !1) { | ||
function Gb(a, b = !1) { | ||
const c = `${a.extends ? "$" : ""}${a.name}`; | ||
return b ? `${a.ns}${c}` : c; | ||
} | ||
function Kb(a, b = !1, c = !1, d = b) { | ||
d = ` * @typedef {${(b ? a.closureType : a.type) || a.o()}}${` ${Jb(a, d)}${a.l}`}`; | ||
function Hb(a, b = !1, c = !1, d = b) { | ||
d = ` * @typedef {${(b ? a.closureType : a.type) || a.o()}}${` ${Gb(a, d)}${a.l}`}`; | ||
a = (a.properties ? a.properties.reduce((e, f) => { | ||
@@ -1244,11 +1268,11 @@ if (f.f) { | ||
e.push(f); | ||
const g = f.aliases.map(h => Ab(f, h)); | ||
const g = f.aliases.map(h => xb(f, h)); | ||
e.push(...g); | ||
return e; | ||
}, []) : []).filter(e => e instanceof V ? !e.isConstructor : !0).map(e => wb(e, b)); | ||
}, []) : []).filter(e => e instanceof V ? !e.isConstructor : !0).map(e => tb(e, b)); | ||
a = [d, ...a].join("\n"); | ||
b && !c && (a = P(a)); | ||
return a = O(a); | ||
b && !c && (a = O(a)); | ||
return a = N(a); | ||
} | ||
function Ib(a) { | ||
function Fb(a) { | ||
return a.args ? `function(${a.args.filter(({name:b}) => "this" != b).map(({name:b}) => b).join(", ")}) {}` : null; | ||
@@ -1272,3 +1296,3 @@ } | ||
} | ||
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) { | ||
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}, u, t = null) { | ||
if (!b) { | ||
@@ -1280,3 +1304,3 @@ throw Error("Type does not have a name."); | ||
k ? this.closureType = k : this.closureType = this.type; | ||
d && (this.description = Q(d)); | ||
d && (this.description = P(d)); | ||
this.noToc = !!e; | ||
@@ -1290,29 +1314,9 @@ this.spread = !!f; | ||
m && (this.extends = m); | ||
t && (this.namespace = t); | ||
u && (this.namespace = u); | ||
if (a) { | ||
b = R("prop", a).map(({content:x, props:z}) => { | ||
const G = new Bb; | ||
Gb(z, this.file); | ||
G.b(x, z); | ||
return G; | ||
}); | ||
a = R(["function", "fn", "static"], a).map(({content:x, props:z, tag:G}) => { | ||
G = "static" == G; | ||
const {K:$b, G:Ha} = pb(x, u); | ||
x = new V(Ha); | ||
const {W:ha, I:ac} = fb(z, Ha, this.fullName); | ||
ha.type = ac; | ||
Gb(ha, this.file); | ||
x.b($b, ha); | ||
G && (x.f = !0); | ||
return x; | ||
}); | ||
a = [...b, ...a]; | ||
const {H:v, L:bc, n:cc} = a.reduce((x, z) => { | ||
z.isConstructor ? x.H.push(z) : z.static ? x.L.push(z) : x.n.push(z); | ||
return x; | ||
}, {H:[], L:[], n:[]}); | ||
this.properties = [...v, ...bc, ...cc]; | ||
const {properties:w, constructor:Ba} = Db(a, t, this.file, this.fullName); | ||
Ba && (this.args = Ba.args); | ||
this.properties = w; | ||
} | ||
q && (q = q.startsWith(".") && this.file ? Na(La(this.file), q) : q, this.examples = rb(q, r)); | ||
q && (a = {example:q}, Q(a, this.file), this.examples = ob(a.example, r)); | ||
} | ||
@@ -1334,16 +1338,16 @@ get s() { | ||
g(a = !1, b = !1, c = a) { | ||
const d = !!this.extends, e = Kb(this, a, b, c), f = []; | ||
const d = !!this.extends, e = Hb(this, a, b, c), f = []; | ||
if (this.namespace && a) { | ||
var g = ` * @typedef {${this.fullName}} ${this.name}${this.l}`; | ||
a && !b && (g = P(g)); | ||
g = O(g); | ||
a && !b && (g = O(g)); | ||
g = N(g); | ||
f.push(g); | ||
} else { | ||
this.namespace && c && (g = ` * @typedef {${this.fullName}} ${this.name}${this.l}`, g = O(g), f.push(g)); | ||
this.namespace && c && (g = ` * @typedef {${this.fullName}} ${this.name}${this.l}`, g = N(g), f.push(g)); | ||
} | ||
d && (c = ` * @typedef {${this.extends.split(/,\s*/).join(" & ")} & ${Jb(this, c)}} ${c ? this.fullName : this.name}${this.l}`, a && !b && (c = P(c)), c = O(c), f.push(c)); | ||
d && (c = ` * @typedef {${this.extends.split(/,\s*/).join(" & ")} & ${Gb(this, c)}} ${c ? this.fullName : this.name}${this.l}`, a && !b && (c = O(c)), c = N(c), f.push(c)); | ||
f.push(e); | ||
return f.join(""); | ||
} | ||
get V() { | ||
get U() { | ||
const a = this.tag; | ||
@@ -1361,21 +1365,23 @@ if (!a) { | ||
this.description && d.push(` * ${this.description}`); | ||
this.extends && this.extends.split(/,\s*/).forEach(e => { | ||
d.push(` * @extends {${e}}`); | ||
const e = this.properties[0]; | ||
e instanceof V && e.isConstructor && e.description && d.push(T(e.description)); | ||
this.extends && this.extends.split(/,\s*/).forEach(f => { | ||
d.push(` * @extends {${f}}`); | ||
}); | ||
this.args && this.args.forEach(e => { | ||
let {name:f, description:g, optional:h, type:k} = e; | ||
e = g ? ` ${g}` : ""; | ||
if (f.startsWith("...")) { | ||
f = f.slice(3), k = `...${k}`; | ||
this.args && this.args.forEach(f => { | ||
let {name:g, description:h, optional:k, type:l} = f; | ||
f = h ? ` ${h}` : ""; | ||
if (g.startsWith("...")) { | ||
g = g.slice(3), l = `...${l}`; | ||
} else { | ||
if ("this" == f) { | ||
d.push(` * @this {${k}}${e}`); | ||
if ("this" == g) { | ||
d.push(` * @this {${l}}${f}`); | ||
return; | ||
} | ||
} | ||
d.push(` * @param {${k}${h ? "=" : ""}} ${h ? `[${f}]` : f}${e}`); | ||
d.push(` * @param {${l}${k ? "=" : ""}} ${k ? `[${g}]` : g}${f}`); | ||
}); | ||
b && d.push(` * @${this.V}`); | ||
c && this.examples.length && (b = sb(this.examples), d.push(...b)); | ||
a && (d = d.map(e => `${a}${e}`)); | ||
b && d.push(` * @${this.U}`); | ||
c && this.examples.length && (b = pb(this.examples), d.push(...b)); | ||
a && (d = d.map(f => `${a}${f}`)); | ||
return d; | ||
@@ -1389,9 +1395,9 @@ } | ||
} | ||
D(a, b, c, d, e = !1, f = !1) { | ||
C(a, b, c, d, e = !1, f = !1) { | ||
var g = ""; | ||
!0 === d ? g = "?" : !1 === d && (g = "!"); | ||
d = this.description ? ` ${this.description}` : ""; | ||
const h = this.spread ? Lb(this.properties) : e || f ? this.fullName : this.name; | ||
const h = this.spread ? Ib(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.D(a, c, e, f)) : []; | ||
g = this.properties && !this.noExpand ? this.properties.map(k => k.C(a, c, e, f)) : []; | ||
return [b, ...g].join("\n"); | ||
@@ -1402,4 +1408,4 @@ } | ||
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 = Mb(g, f)); | ||
f = Mb(this.fullName); | ||
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); | ||
f = this.import ? `[${f}](l-type)` : this.noToc ? `[${f}](l-type)` : `[${f}](t-type)`; | ||
@@ -1410,3 +1416,3 @@ const h = this.description ? `: ${this.description}` : ""; | ||
if (this.extends) { | ||
const l = Nb(this.extends, a, b), m = ` extends ${l}`; | ||
const l = Kb(this.extends, a, b), m = ` extends ${l}`; | ||
k = k || /_/.test(l); | ||
@@ -1419,7 +1425,7 @@ g = (k ? g + "<strong>" : g + "__") + (f + m); | ||
g = (k ? g + "</strong>" : g + "__") + h; | ||
a = Eb(this, this.properties, a, b); | ||
a = Bb(this, this.properties, a, b); | ||
return {LINE:g, table:a, displayInDetails:e}; | ||
} | ||
} | ||
const Mb = (a, b = !1) => `${b ? "<code>" : "`"}${a}${b ? "</code>" : "`"}`, Lb = (a = [], b = !1) => { | ||
const Jb = (a, b = !1) => `${b ? "<code>" : "`"}${a}${b ? "</code>" : "`"}`, Ib = (a = [], b = !1) => { | ||
a = a.reduce((c, d) => { | ||
@@ -1434,6 +1440,6 @@ c.push(d); | ||
let e = c.name, f = d; | ||
c.optional && !b ? e = `${c.name}?` : c.optional && b && (f = `(${db(d)})`); | ||
c.optional && !b ? e = `${c.name}?` : c.optional && b && (f = `(${ab(d)})`); | ||
return `${e}: ${f}`; | ||
}).join(", ")} }`; | ||
}, Nb = (a, b, c) => a.split(/,\s*/).map(d => { | ||
}, Kb = (a, b, c) => a.split(/,\s*/).map(d => { | ||
let e = `\`${d}\``; | ||
@@ -1444,3 +1450,3 @@ var f = b.find(({fullName:g}) => g == d); | ||
}).join(", "); | ||
class Ob extends Y { | ||
class Lb extends Y { | ||
constructor() { | ||
@@ -1458,3 +1464,3 @@ super(); | ||
this.from = b; | ||
this.description = Q(a); | ||
this.description = P(a); | ||
super.b("", {...d, noToc:!0, name:c, type:`import('${b}').${c}`}, e != f ? e : null); | ||
@@ -1466,12 +1472,12 @@ } | ||
} | ||
;function Pb(a, b) { | ||
;function Mb(a, b) { | ||
b = b.reduce((c, d) => ({...c, [d.fullName]:d}), {}); | ||
a.A = {...a.A, ...b}; | ||
a.w = {...a.w, ...b}; | ||
} | ||
class Qb extends N { | ||
class Nb extends L { | ||
constructor(a, b = {}) { | ||
super(a); | ||
this.A = {}; | ||
this.w = {}; | ||
this.on("types", c => { | ||
Pb(this, c); | ||
Mb(this, c); | ||
}); | ||
@@ -1481,3 +1487,3 @@ this.on("namespace", c => { | ||
}); | ||
this.g = b; | ||
this.f = b; | ||
this.b = []; | ||
@@ -1492,9 +1498,9 @@ this.i = console.log; | ||
static get Import() { | ||
return Ob; | ||
return Lb; | ||
} | ||
get types() { | ||
return this.A; | ||
return this.w; | ||
} | ||
} | ||
;class Rb extends Y { | ||
;class Ob extends Y { | ||
constructor() { | ||
@@ -1512,3 +1518,3 @@ super(); | ||
b(a, {async:b, "return":c, ...d}, ...e) { | ||
this.description = Q(a); | ||
this.description = P(a); | ||
super.b("", d, ...e); | ||
@@ -1537,11 +1543,11 @@ c && (this.f = c.replace(/\n\s*/g, " ")); | ||
} | ||
;const Sb = (a, b) => { | ||
;const Pb = (a, b) => { | ||
const c = new RegExp(`([!?])?${a}\\.`, "g"); | ||
b.properties.forEach(d => { | ||
tb(d, a, c); | ||
qb(d, a, c); | ||
}); | ||
b.m(a); | ||
}, Tb = (a, b) => { | ||
}, Qb = (a, b) => { | ||
var {args:c = []} = a; | ||
const d = `function(${c.map(({J:e}) => e).join(", ")}): ${a.fullName}`; | ||
const d = `function(${c.map(({I:e}) => e).join(", ")}): ${a.fullName}`; | ||
c = new V(c); | ||
@@ -1551,5 +1557,5 @@ c.isConstructor = !0; | ||
c.examples = a.examples; | ||
tb(c, b); | ||
qb(c, b); | ||
a.properties.unshift(c); | ||
}, Vb = (a, b, c = null) => { | ||
}, Sb = (a, b, c = null) => { | ||
a = R("types", a); | ||
@@ -1562,4 +1568,4 @@ if (!a.length) { | ||
const {alias:p, aliases:q, ...r} = m; | ||
c && Gb(r, c); | ||
var t = p ? [p] : q ? q.split(/, */) : []; | ||
c && Q(r, c); | ||
var u = p ? [p] : q ? q.split(/, */) : []; | ||
switch(n) { | ||
@@ -1571,14 +1577,14 @@ case "type": | ||
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); | ||
u.forEach(t => { | ||
const w = new Y; | ||
c && (w.file = c); | ||
w.b(l, {...r, name:t}, g, b); | ||
k.push(w); | ||
}); | ||
break; | ||
case "interface": | ||
m = Ub({content:l, props:m, ns:g, C:b, location:c}); | ||
m.forEach(u => { | ||
u.properties.some(({isConstructor:v}) => v) || Tb(u, b); | ||
u.isInterface = !0; | ||
m = Rb({content:l, props:m, ns:g, B:b, location:c}); | ||
m.forEach(t => { | ||
t.properties.some(({isConstructor:w}) => w) || Qb(t, b); | ||
t.isInterface = !0; | ||
}); | ||
@@ -1588,6 +1594,6 @@ k.push(...m); | ||
case "constructor": | ||
m = Ub({content:l, props:m, ns:g, C:b, location:c}); | ||
m.forEach(u => { | ||
u.properties.some(({isConstructor:v}) => v) || Tb(u, b); | ||
u.isConstructor = !0; | ||
m = Rb({content:l, props:m, ns:g, B:b, location:c}); | ||
m.forEach(t => { | ||
t.properties.some(({isConstructor:w}) => w) || Qb(t, b); | ||
t.isConstructor = !0; | ||
}); | ||
@@ -1597,14 +1603,14 @@ k.push(...m); | ||
case "method": | ||
m = Ub({content:l, props:m, ns:g, C:b, isMethod:!0, location:c}); | ||
m = Rb({content:l, props:m, ns:g, B:b, isMethod:!0, location:c}); | ||
k.push(...m); | ||
break; | ||
case "import": | ||
t = new Ob, t.b(l, m, m.ns || m.from, b), h.push(t); | ||
u = new Lb, u.b(l, m, m.ns || m.from, b), h.push(u); | ||
} | ||
return k; | ||
}, []); | ||
b && a.forEach(k => Sb(b, k)); | ||
b && a.forEach(k => Pb(b, k)); | ||
return {namespace:f, types:a, imports:h}; | ||
}, Wb = (a, b, c, d, e = !1, f = null) => { | ||
const g = e ? new Rb : new Y; | ||
}, Tb = (a, b, c, d, e = !1, f = null) => { | ||
const g = e ? new Ob : new Y; | ||
g.file = f; | ||
@@ -1614,14 +1620,14 @@ f = a.search(/<(prop|function|fn|static) /); | ||
1 != f && (h = a.slice(0, f), k = a.slice(f)); | ||
const {G:l, K:m} = pb(h, d); | ||
const {F:l, J:m} = mb(h, d); | ||
g.b(e ? m : k, b, c, d); | ||
({I:a} = fb(b, l)); | ||
({H:a} = cb(b, l)); | ||
e && (g.closureType = a); | ||
g.args = l; | ||
g.args || (g.args = l); | ||
return g; | ||
}, Ub = ({content:a, props:b, ns:c, C:d, isMethod:e = !1, location:f = null}) => { | ||
}, Rb = ({content:a, props:b, ns:c, B:d, isMethod:e = !1, location:f = null}) => { | ||
const g = [], {alias:h, aliases:k, ...l} = b; | ||
b = Wb(a, b, c, d, e, f); | ||
b = Tb(a, b, c, d, e, f); | ||
g.push(b); | ||
(h ? [h] : k ? k.split(/, */) : []).forEach(m => { | ||
m = Wb(a, {...l, name:m}, c, d, e, f); | ||
m = Tb(a, {...l, name:m}, c, d, e, f); | ||
m.description = `${m.description}${m.description ? " " : ""}Alias of \`${l.name}\`.`; | ||
@@ -1631,7 +1637,7 @@ g.push(m); | ||
return g; | ||
}, Xb = async(a, b = []) => { | ||
const c = await F(a); | ||
}, Ub = async(a, b = []) => { | ||
const c = await E(a); | ||
let d, e, f; | ||
try { | ||
({namespace:d = null, types:e, imports:f} = Vb(c, void 0, a)); | ||
({namespace:d = null, types:e, imports:f} = Sb(c, void 0, a)); | ||
} catch (g) { | ||
@@ -1644,15 +1650,15 @@ throw g.message = `Error while reading ${a}\n${g.message}`, g; | ||
}; | ||
const Yb = (a, b, c) => { | ||
const Vb = (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 N(c ? d : O(d)); | ||
}); | ||
return [...b, ...a].join(""); | ||
}, Zb = (a, b, c, d = !1) => { | ||
}, Wb = (a, b, c, d = !1) => { | ||
a = [...a.map(e => { | ||
{ | ||
let f; | ||
e.closureType ? f = ` * @typedef {${e.closureType}}` : e.s || (f = ` * @typedef {${Lb(e.properties, !0)}}`); | ||
f ? (e.description && (f = ` * ${e.description}\n${f}`), f = O(f), e = f += eb(e.namespace, e.name)) : e = Hb(e); | ||
e.closureType ? f = ` * @typedef {${e.closureType}}` : e.s || (f = ` * @typedef {${Ib(e.properties, !0)}}`); | ||
f ? (e.description && (f = ` * ${e.description}\n${f}`), f = N(f), e = f += bb(e.namespace, e.name)) : e = Eb(e); | ||
} | ||
@@ -1665,7 +1671,7 @@ return e; | ||
}; | ||
const ec = {re:/^\/\*\*? (documentary|typal) (.+?) \*\/\n(?:([^\n][\s\S]+?\n))?$/mg, replacement:async function(a, b, c) { | ||
const Yb = {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:")); | ||
m = m ? m.replace("ignore:", "").split(",") : []; | ||
let {w:n, B:p} = this.g; | ||
let {v:n, A:p} = this.f; | ||
f && (n = !0); | ||
@@ -1675,20 +1681,20 @@ g && (p = !0); | ||
this.i("Detected type marker: %s", c); | ||
const {types:q, imports:r, namespace:t} = await Xb(d, m); | ||
const {types:q, imports:r, namespace:u} = await Ub(d, m); | ||
this.emit("types", q); | ||
this.emit("types", r); | ||
let u; | ||
n ? u = Yb(r, q, h) : p ? (u = Zb(q, t, this.b, k) + "\n", t && this.emit("namespace", t)) : l ? (t && this.emit("namespace", t), u = dc(r, q, !0)) : u = dc(r, q); | ||
return `/* ${b} ${c} */\n${u}`; | ||
let t; | ||
n ? t = Vb(r, q, h) : p ? (t = Wb(q, u, this.b, k) + "\n", u && this.emit("namespace", u)) : l ? (u && this.emit("namespace", u), t = Xb(r, q, !0)) : t = Xb(r, q); | ||
return `/* ${b} ${c} */\n${t}`; | ||
} catch (q) { | ||
return this.i("(%s) Could not process typedef-js: %s", c, q.message), process.env.b && console.error(q.stack), a; | ||
} | ||
}}, dc = (a, b, c = !1) => { | ||
}}, Xb = (a, b, c = !1) => { | ||
b = b.map(d => d.g(!1, !1, c)); | ||
a = a.map(d => d.g(c)).map(O).join(""); | ||
a = a.map(d => d.g(c)).map(N).join(""); | ||
b = b.join(""); | ||
return `${a}${b}`.replace(fc, " * @typedef"); | ||
}, fc = / \*\/\n\/\*\*\n \* @typedef/g; | ||
const hc = {re:/( *) \* @param {(.+?)} (\[)?([^\s\]]+)\]?(?: .+)?((?:\n(?: +)\* @param {(?:.+?)} \[?\4\]?(?:(?!\n\s*\*(?:\/|\s*@))[\s\S])*)*)/gm, replacement:gc}; | ||
function gc(a, b, c, d, e, f, g) { | ||
const {w:h, F:k} = this.g; | ||
return `${a}${b}`.replace(Zb, " * @typedef"); | ||
}, Zb = / \*\/\n\/\*\*\n \* @typedef/g; | ||
const ac = {re:/( *) \* @param {(.+?)} (\[)?([^\s\]]+)\]?(?: .+)?((?:\n(?: +)\* @param {(?:.+?)} \[?\4\]?(?:(?!\n\s*\*(?:\/|\s*@))[\s\S])*)*)/gm, replacement:$b}; | ||
function $b(a, b, c, d, e, f, g) { | ||
const h = this.f.v, k = this.f.D; | ||
let l; | ||
@@ -1703,5 +1709,5 @@ f = () => { | ||
} | ||
n = {line:n, R:b.length + 11}; | ||
n = {line:n, P:b.length + 11}; | ||
} | ||
const {line:p, R:q} = n; | ||
const {line:p, P:q} = n; | ||
this.i("%s:%s:%s", this.file, p, q); | ||
@@ -1711,3 +1717,3 @@ } | ||
try { | ||
l = mb(c); | ||
l = fb(c); | ||
} catch (n) { | ||
@@ -1724,3 +1730,3 @@ return this.i("Error while parsing the type %s", c), this.i(process.env.DEBUG ? n.stack : n.message), f(), a; | ||
c = Object.values(this.types).find(({name:n, fullName:p}) => h || k ? p == l.name : n == l.name); | ||
return !c || c instanceof Qb.Import ? a : c.D(e, d, b, l.nullable, h, k); | ||
return !c || c instanceof Nb.Import ? a : c.C(e, d, b, l.nullable, h, k); | ||
} | ||
@@ -1733,3 +1739,3 @@ const Z = (a, b, c, d, e) => { | ||
let h = b.includes(f); | ||
h || (h = ic.includes(f)); | ||
h || (h = bc.includes(f)); | ||
if (h) { | ||
@@ -1753,10 +1759,10 @@ return !0; | ||
} | ||
}, ic = "String Boolean Object Date Number Symbol Buffer Function".split(" "); | ||
var jc = (a, b = !1) => { | ||
var {T:c} = Va(); | ||
const d = Xa(c); | ||
c = Wa(c); | ||
return new Qb(b ? [ec] : [ec, d, hc, c], a); | ||
}, bc = "String Boolean Object Date Number Symbol Buffer Function".split(" "); | ||
var cc = (a, b = !1) => { | ||
var {S:c} = Ta(); | ||
const d = Va(c); | ||
c = Ua(c); | ||
return new Nb(b ? [Yb] : [Yb, d, ac, c], a); | ||
}; | ||
const kc = /( *) \* @(fnType|methodType) {(.+?)}/gm, lc = (a, b, c, d, e, f, g = d) => `/** | ||
const dc = /( *) \* @(fnType|methodType) {(.+?)}/gm, ec = (a, b, c, d, e, f, g = d) => `/** | ||
${a} | ||
@@ -1767,3 +1773,3 @@ */ | ||
}`; | ||
class mc extends N { | ||
class fc extends L { | ||
constructor(a, b) { | ||
@@ -1776,13 +1782,15 @@ super([{re:/\/\*\*\s+( *) \* @constructor {(.+?)}[\s\S]+?(class\s+.+?\s+extends\s+(.+?)\s*){\s*}/gm, replacement(c, d, e, f, g) { | ||
c = d.properties.filter(l => l instanceof V && !l.isConstructor).map(l => { | ||
const {name:m, aliases:n, static:p, async:q} = l; | ||
const m = l.name; | ||
var n = l.aliases; | ||
const p = l.static, q = l.async; | ||
let r = U(l, "", !0); | ||
r = nc(r, e); | ||
const t = l.args.map(({name:v}) => v).join(", "); | ||
l = lc(r, p, q, m, t, g); | ||
const u = n.map(v => lc(r + `\n * @alias ${m} An alias for **${m}**.`, p, q, v, t, g, m)); | ||
return [l, ...u].join("\n"); | ||
r = gc(r, e); | ||
const u = l.args.map(({name:t}) => t).join(", "); | ||
l = ec(r, p, q, m, u, g); | ||
n = n.map(t => ec(r + `\n * @alias ${m} An alias for **${m}**.`, p, q, t, u, g, m)); | ||
return [l, ...n].join("\n"); | ||
}); | ||
const h = d.properties.find(l => l instanceof V && l.isConstructor), k = h.args.map(({name:l}) => l).join(", "); | ||
c = [`/** | ||
${nc(U(h, "", !0), e)} | ||
${gc(U(h, "", !0), e)} | ||
*/ | ||
@@ -1799,3 +1807,3 @@ constructor(${k}) { | ||
return f; | ||
}}, {re:kc, async replacement(c, d, e, f) { | ||
}}, {re:dc, async replacement(c, d, e, f) { | ||
const g = f.split("."); | ||
@@ -1828,9 +1836,9 @@ let h, k; | ||
} | ||
const nc = (a, b) => a.replace(`\n * @return {${b}}`, "").replace(`\n * @return {!${b}}`, "").replace(`\n * @return {?${b}}`, ""); | ||
const oc = async a => a ? (await Promise.all(a.split(",").map(async b => { | ||
const gc = (a, b) => a.replace(`\n * @return {${b}}`, "").replace(`\n * @return {!${b}}`, "").replace(`\n * @return {?${b}}`, ""); | ||
const hc = async a => a ? (await Promise.all(a.split(",").map(async b => { | ||
var c = []; | ||
const d = await I(A, b); | ||
d.isFile() ? c = [b] : d.isDirectory() && (c = await K(b), c = L(c.content, b), c = c.filter(e => e.endsWith(".xml"))); | ||
const d = await G(z, b); | ||
d.isFile() ? c = [b] : d.isDirectory() && (c = await I(b), c = J(c.content, b), c = c.filter(e => e.endsWith(".xml"))); | ||
return c; | ||
}))).reduce((b, c) => [...b, ...c], []) : [], pc = async a => (await Promise.all(a.map(async b => ({...await Xb(b), location:b})))).reduce((b, {imports:c, types:d}) => { | ||
}))).reduce((b, c) => [...b, ...c], []) : [], ic = async a => (await Promise.all(a.map(async b => ({...await Ub(b), location:b})))).reduce((b, {imports:c, types:d}) => { | ||
b.push(...c); | ||
@@ -1840,39 +1848,39 @@ b.push(...d); | ||
}, []); | ||
async function qc() { | ||
const {u:a, types:b} = {u:oa, types:na}, c = await oc(b), d = await pc(c); | ||
await Promise.all(y.map(async e => { | ||
var f = await I(A, e); | ||
let g; | ||
f.isFile() ? g = [e] : f.isDirectory() && (f = await K(e), g = L(f.content, e)); | ||
await rc(g, d, a); | ||
async function jc() { | ||
const a = await hc(la), b = await ic(a); | ||
await Promise.all(x.map(async c => { | ||
var d = await G(z, c); | ||
let e; | ||
d.isFile() ? e = [c] : d.isDirectory() && (d = await I(c), e = J(d.content, c)); | ||
await kc(e, b, ma); | ||
})); | ||
} | ||
const rc = async(a, b = [], c = null) => { | ||
const kc = async(a, b = [], c = null) => { | ||
await Promise.all(a.map(async d => { | ||
var e = await F(d); | ||
const f = new mc(b, d); | ||
var e = await E(d); | ||
const f = new fc(b, d); | ||
f.end(e); | ||
e = await E(f); | ||
"-" == c ? console.log(e) : c ? await H(c, e) : await H(d, e); | ||
e = await D(f); | ||
"-" == c ? console.log(e) : c ? await F(c, e) : await F(d, e); | ||
})); | ||
}; | ||
var tc = async() => { | ||
const {w:a = !1, F:b = !1, B:c = !1, u:d, types:e} = {w:ka, B:ma, u:ja, types:na, F:la}, f = await oc(e); | ||
await Promise.all(y.map(async g => { | ||
var h = await I(A, g); | ||
var mc = async() => { | ||
const {v:a = !1, D:b = !1, A:c = !1, V:d, types:e} = {v:ia, A:ka, V:y, types:la, D:ja}, f = await hc(e); | ||
await Promise.all(x.map(async g => { | ||
var h = await G(z, g); | ||
let k; | ||
h.isFile() ? k = [g] : h.isDirectory() && (h = await K(g), k = L(h.content, g)); | ||
await sc(k, a, c, d, f, b); | ||
h.isFile() ? k = [g] : h.isDirectory() && (h = await I(g), k = J(h.content, g)); | ||
await lc(k, a, c, d, f, b); | ||
})); | ||
}; | ||
const sc = async(a, b = !1, c = !1, d = "", e = [], f = !1) => { | ||
const lc = async(a, b = !1, c = !1, d = "", e = [], f = !1) => { | ||
const g = []; | ||
await Promise.all(e.map(async h => { | ||
h = await F(h); | ||
const {types:k, imports:l} = Vb(h); | ||
h = await E(h); | ||
const {types:k, imports:l} = Sb(h); | ||
g.push(k, l); | ||
})); | ||
await Promise.all(a.map(async h => { | ||
var k = await F(h); | ||
const l = jc({w:b, B:c, F:f}, c); | ||
var k = await E(h); | ||
const l = cc({v:b, A:c, D:f}, c); | ||
g.forEach(m => l.emit("types", m)); | ||
@@ -1883,11 +1891,11 @@ l.file = h; | ||
l.end(k); | ||
k = await E(l); | ||
"-" == d ? console.log(k) : d ? await H(d, k) : await H(h, k); | ||
k = await D(l); | ||
"-" == d ? console.log(k) : d ? await F(d, k) : await F(h, k); | ||
})); | ||
}; | ||
const uc = a => { | ||
const nc = a => { | ||
let b; | ||
"true" == a ? b = !0 : "false" == a ? b = !1 : /^\d+$/.test(a) && (b = parseInt(a, 10)); | ||
return void 0 !== b ? b : a; | ||
}, vc = /^ \* @prop {(.+?)} (\[)?(.+?)(?:=(["'])?(.+?)\4)?(?:])?(?: (.+?))?(?: Default `(.+?)`.)?$/gm, wc = "type opt name quote defaultValue description Default".split(" "), ab = new RegExp(`^ \\* @typedef {(.+?)} (.+?)(?: (.+))?\\n((?:${/ \* @prop(?:erty)? .+\n/.source})*)`, "gm"), xc = (a, b, c, d) => { | ||
}, oc = /^ \* @prop {(.+?)} (\[)?(.+?)(?:=(["'])?(.+?)\4)?(?:])?(?: (.+?))?(?: Default `(.+?)`.)?$/gm, pc = "type opt name quote defaultValue description Default".split(" "), Za = new RegExp(`^ \\* @typedef {(.+?)} (.+?)(?: (.+))?\\n((?:${/ \* @prop(?:erty)? .+\n/.source})*)`, "gm"), qc = (a, b, c, d) => { | ||
d = d.length; | ||
@@ -1898,3 +1906,3 @@ a = a && "Object" != a ? ` type="${a}"` : ""; | ||
}; | ||
class yc extends B { | ||
class rc extends A { | ||
constructor() { | ||
@@ -1904,3 +1912,3 @@ super({writableObjectMode:!0}); | ||
_transform({type:a, name:b, description:c, properties:d}, e, f) { | ||
a = a && a.startsWith("import") ? zc(a, b) : xc(a, b, c, d); | ||
a = a && a.startsWith("import") ? sc(a, b) : qc(a, b, c, d); | ||
this.push(a); | ||
@@ -1923,3 +1931,3 @@ d.forEach(({type:g, name:h, default:k, description:l, optional:m}) => { | ||
} | ||
const zc = (a, b) => { | ||
const sc = (a, b) => { | ||
const c = /import\((['"])(.+?)\1\)/.exec(a); | ||
@@ -1932,3 +1940,3 @@ if (!c) { | ||
}; | ||
class Ac extends B { | ||
class tc extends A { | ||
constructor() { | ||
@@ -1938,15 +1946,15 @@ super({objectMode:!0}); | ||
_transform([, a, b, c, d], e, f) { | ||
d = gb(vc, d, wc).map(g => { | ||
d = gb(oc, d, pc).map(g => { | ||
const {defaultValue:h, Default:k, opt:l, name:m, type:n, ...p} = g; | ||
g = {...p, name:m, type:n, ...h ? {defaultValue:uc(h)} : {}, ...k ? {v:uc(k)} : {}, ...l ? {optional:!0} : {}}; | ||
g = {...p, name:m, type:n, ...h ? {defaultValue:nc(h)} : {}, ...k ? {u:nc(k)} : {}, ...l ? {optional:!0} : {}}; | ||
if (h || k) { | ||
if (h) { | ||
h !== k && void 0 !== g.v && (q = bb(m, k, n), console.error("%s[%s] does not match Default `%s`.", b, q, g.v)); | ||
h !== k && void 0 !== g.u && (q = M(m, k, n), console.error("%s[%s] does not match Default `%s`.", b, q, g.u)); | ||
} else { | ||
var q = bb(m, k, n); | ||
var q = M(m, k, n); | ||
console.error("%s[%s] got from Default.", b, q); | ||
} | ||
g.default = "defaultValue" in g ? g.defaultValue : g.v; | ||
g.default = "defaultValue" in g ? g.defaultValue : g.u; | ||
delete g.defaultValue; | ||
delete g.v; | ||
delete g.u; | ||
} | ||
@@ -1959,4 +1967,4 @@ return g; | ||
} | ||
async function Bc(a) { | ||
const b = $a(), c = new Ac, d = new yc; | ||
async function uc(a) { | ||
const b = Ya(), c = new tc, d = new rc; | ||
b.pipe(c).pipe(d); | ||
@@ -1977,23 +1985,22 @@ b.end(a); | ||
return `<types> | ||
${(await E(d)).trim()} | ||
${(await D(d)).trim()} | ||
</types>`; | ||
} | ||
;var Cc = async() => { | ||
const {u:a} = {u:ja}; | ||
await Promise.all(y.map(async b => { | ||
b = await F(b); | ||
b = await Bc(b); | ||
a ? await H(a, b) : console.log(b); | ||
;var vc = async() => { | ||
await Promise.all(x.map(async a => { | ||
a = await E(a); | ||
a = await uc(a); | ||
y ? await F(y, a) : console.log(a); | ||
})); | ||
}; | ||
if (qa) { | ||
const a = ia(); | ||
console.log(sa({usage:a, description:"Embeds and maintains Closure-compatible types JSDoc in\nJavaScript source code from an external types.xml file.", line:"typal source [--closure|externs] [--migrate] [-o output] [-hv]", example:"typal src/index.js -c"})); | ||
if (oa) { | ||
const a = ha(); | ||
console.log(qa({usage:a, description:"Embeds and maintains Closure-compatible types JSDoc in\nJavaScript source code from an external types.xml file.", line:"typal source [--closure|externs] [--migrate] [-o output] [-hv]", example:"typal src/index.js -c"})); | ||
process.exit(); | ||
} else { | ||
ra && (console.log(require("../../package.json").version), process.exit()); | ||
pa && (console.log(require("../../package.json").version), process.exit()); | ||
} | ||
(async() => { | ||
try { | ||
return pa ? await Cc() : oa ? await qc() : await tc(); | ||
return na ? await vc() : ma ? await jc() : await mc(); | ||
} catch (a) { | ||
@@ -2000,0 +2007,0 @@ process.env.DEBUG ? console.log(a.stack) : console.log(a.message); |
#!/usr/bin/env node | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const stream = require('stream'); | ||
const os = require('os'); | ||
var x = "function" == typeof Object.defineProperties ? Object.defineProperty : function(a, b, d) { | ||
a != Array.prototype && a != Object.prototype && (a[b] = d.value); | ||
}, aa = "undefined" != typeof window && window === this ? this : "undefined" != typeof global && null != global ? global : this; | ||
function ba(a, b) { | ||
var v = "function" == typeof Object.defineProperties ? Object.defineProperty : function(a, b, c) { | ||
a != Array.prototype && a != Object.prototype && (a[b] = c.value); | ||
}, x = "undefined" != typeof window && window === this ? this : "undefined" != typeof global && null != global ? global : this; | ||
function y(a, b) { | ||
if (b) { | ||
var d = aa; | ||
var c = x; | ||
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 && x(d, a, {configurable:!0, writable:!0, value:b}); | ||
d = c[a]; | ||
b = b(d); | ||
b != d && null != b && v(c, a, {configurable:!0, writable:!0, value:b}); | ||
} | ||
} | ||
ba("String.prototype.trimRight", function(a) { | ||
y("String.prototype.trimRight", function(a) { | ||
function b() { | ||
@@ -31,33 +31,3 @@ return this.replace(/[\s\xa0]+$/, ""); | ||
}); | ||
function z(a, b, d) { | ||
const c = []; | ||
b.replace(a, (e, ...g) => { | ||
e = g.slice(0, g.length - 2).reduce((f, k, h) => { | ||
h = d[h]; | ||
if (!h || void 0 === k) { | ||
return f; | ||
} | ||
f[h] = k; | ||
return f; | ||
}, {}); | ||
c.push(e); | ||
}); | ||
return c; | ||
} | ||
;const B = new RegExp(`${/([^\s>=/]+)/.source}(?:\\s*=\\s*${/(?:"([\s\S]*?)"|'([\s\S]*?)')/.source})?`, "g"), ca = new RegExp(`(?:\\s+((?:${B.source}\\s*)*))`); | ||
const C = (a, b) => { | ||
a = (Array.isArray(a) ? a : [a]).join("|"); | ||
return z(new RegExp(`<(${a})${ca.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 = da(c); | ||
return {content:e, props:c, tag:d}; | ||
}); | ||
}, da = a => z(B, a, ["key", "val", "def", "f"]).reduce((b, {key:d, val:c}) => { | ||
if (void 0 === c) { | ||
return b[d] = !0, b; | ||
} | ||
b[d] = "true" == c ? !0 : "false" == c ? !1 : /^\d+$/.test(c) ? parseInt(c, 10) : c; | ||
return b; | ||
}, {}); | ||
const ea = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => { | ||
const z = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => { | ||
switch(b) { | ||
@@ -79,5 +49,5 @@ case "function": | ||
}); | ||
function fa(a) { | ||
function A(a) { | ||
let b = 0; | ||
const d = (e = 1) => a[b + e], c = (e = !0, g = []) => { | ||
const c = (e = 1) => a[b + e], d = (e = !0, g = []) => { | ||
var f = {}; | ||
@@ -95,3 +65,3 @@ let k = a[b]; | ||
b++; | ||
f = {...c(!0, []), ...f}; | ||
f = {...d(!0, []), ...f}; | ||
if (")" != a[b]) { | ||
@@ -115,6 +85,6 @@ throw Error("Expecting closing )"); | ||
try { | ||
var m = c(); | ||
var m = d(); | ||
e[h] = m; | ||
} catch (q) { | ||
throw q.message += `(when parsing ${h} property)`, q; | ||
} catch (p) { | ||
throw p.message += `(when parsing ${h} property)`, p; | ||
} | ||
@@ -162,3 +132,3 @@ } | ||
b++; | ||
h.this = c(); | ||
h.this = d(); | ||
} else { | ||
@@ -171,9 +141,9 @@ if ("new" == a[b]) { | ||
b++; | ||
h.new = c(); | ||
h.new = d(); | ||
} else { | ||
if ("." == a[b] && "." == d() && "." == d(2)) { | ||
if ("." == a[b] && "." == c() && "." == c(2)) { | ||
b++; | ||
b++; | ||
b++; | ||
l = c(); | ||
l = d(); | ||
if (")" != a[b]) { | ||
@@ -184,3 +154,3 @@ throw Error("Variable args must come last"); | ||
} else { | ||
l = c(), h.args.push(l), "=" == a[b] && (l.optional = !0, b++); | ||
l = d(), h.args.push(l), "=" == a[b] && (l.optional = !0, b++); | ||
} | ||
@@ -200,6 +170,6 @@ } | ||
b++; | ||
":" == a[b] && (b++, l = c(), void 0 == l.name && l.nullable && (l.name = ""), h.return = l); | ||
":" == a[b] && (b++, l = d(), void 0 == l.name && l.nullable && (l.name = ""), h.return = l); | ||
m.function = h; | ||
} else { | ||
if ("<" == a[b] || (h = "." == a[b] && "<" == d())) { | ||
if ("<" == a[b] || (h = "." == a[b] && "<" == c())) { | ||
b++; | ||
@@ -209,3 +179,3 @@ h && b++; | ||
for (h = []; ">" != a[b];) { | ||
l = c(); | ||
l = d(); | ||
h.push(l); | ||
@@ -228,3 +198,3 @@ if (">" == a[b]) { | ||
b++; | ||
({name:m} = c(!1)); | ||
({name:m} = d(!1)); | ||
if (!m) { | ||
@@ -239,13 +209,14 @@ throw Error("Expected to see the name after ."); | ||
for (g.push(f); "|" == a[b];) { | ||
b++, f = c(!0, g), f.union !== g && g.push(f); | ||
b++, f = d(!0, g), f.union !== g && g.push(f); | ||
} | ||
return {union:g}; | ||
}; | ||
return c(); | ||
return d(); | ||
} | ||
;function D(a) { | ||
a = ea(a); | ||
return fa(a); | ||
;function B(a) { | ||
a = z(a); | ||
return A(a); | ||
} | ||
;const E = ({A:a, C:b, l:d, type:c}) => b ? "string" : a ? "number" : d ? "boolean" : c ? c : "*", F = a => { | ||
;const C = path.dirname, D = path.resolve; | ||
const E = ({A:a, C:b, l:c, type:d}) => b ? "string" : a ? "number" : c ? "boolean" : d ? d : "*", F = a => { | ||
a = a.trimRight(); | ||
@@ -260,8 +231,8 @@ var b = /\S/.exec(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(); | ||
@@ -271,22 +242,56 @@ } | ||
const e = new RegExp(`^ {${b}}`); | ||
return d.map(g => g.replace(e, "")).join("\n"); | ||
return c.map(g => g.replace(e, "")).join("\n"); | ||
} | ||
}, H = (a, b, d = null) => { | ||
const {async:c, "void":e, "return":g = e ? "void" : "", ...f} = a; | ||
}, G = (a, b, c = null) => { | ||
const {async:d, "void":e, "return":g = e ? "void" : "", ...f} = a; | ||
({args:a = ""} = a); | ||
a || (a = b.map(({s:k, name:h}) => "this" == h ? `${h}: ${k}` : h.startsWith("...") ? `...${k}` : k).join(",")); | ||
b = g.replace(/\n\s*/g, " "); | ||
c && b ? b = `!Promise<${b}>` : c && (b = "!Promise"); | ||
!b && "constructor" == f.name && d && (b = d); | ||
d = `function(${a})`; | ||
b && (d += `: ${b}`); | ||
return {F:{...f, async:c}, o:d}; | ||
d && b ? b = `!Promise<${b}>` : d && (b = "!Promise"); | ||
!b && "constructor" == f.name && c && (b = c); | ||
c = `function(${a})`; | ||
b && (c += `: ${b}`); | ||
return {F:{...f, async:d}, o:c}; | ||
}; | ||
function ha(a, b, {name:d, string:c, "boolean":e, opt:g, number:f, type:k}, h) { | ||
if (!d) { | ||
function H(a, b) { | ||
const c = a.example; | ||
c && c.startsWith(".") && b && (a.example = D(C(b), c)); | ||
} | ||
;function I(a, b, c) { | ||
const d = []; | ||
b.replace(a, (e, ...g) => { | ||
e = g.slice(0, g.length - 2).reduce((f, k, h) => { | ||
h = c[h]; | ||
if (!h || void 0 === k) { | ||
return f; | ||
} | ||
f[h] = k; | ||
return f; | ||
}, {}); | ||
d.push(e); | ||
}); | ||
return d; | ||
} | ||
;const J = new RegExp(`${/([^\s>=/]+)/.source}(?:\\s*=\\s*${/(?:"([\s\S]*?)"|'([\s\S]*?)')/.source})?`, "g"), aa = new RegExp(`(?:\\s+((?:${J.source}\\s*)*))`); | ||
const K = (a, b) => { | ||
a = (Array.isArray(a) ? a : [a]).join("|"); | ||
return I(new RegExp(`<(${a})${aa.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 = ba(d); | ||
return {content:e, props:d, tag:c}; | ||
}); | ||
}, ba = a => I(J, a, ["key", "val", "def", "f"]).reduce((b, {key:c, val:d}) => { | ||
if (void 0 === d) { | ||
return b[c] = !0, b; | ||
} | ||
b[c] = "true" == d ? !0 : "false" == d ? !1 : /^\d+$/.test(d) ? parseInt(d, 10) : d; | ||
return b; | ||
}, {}); | ||
function ca(a, b, {name:c, string:d, "boolean":e, opt:g, number:f, type:k}, h) { | ||
if (!c) { | ||
throw Error("Argument does not have a name."); | ||
} | ||
a.name = d; | ||
a.name = c; | ||
b && (a.description = F(b)); | ||
b = E({A:f, C:c, l:e, type:k}); | ||
b = E({A:f, C:d, l:e, type:k}); | ||
h && (b = b.replace(new RegExp(`([!?])?${h}\\.`, "g"), "$1")); | ||
@@ -297,3 +302,3 @@ b.endsWith("=") && (b = b.replace(/=$/, ""), g = !0); | ||
} | ||
class ia { | ||
class da { | ||
constructor() { | ||
@@ -309,28 +314,28 @@ this.name = null; | ||
} | ||
const I = (a, b) => { | ||
let d = a.lastIndexOf("</arg>"), c = a; | ||
const L = (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 = C("arg", e), e = e.map(({content:g, props:f}) => { | ||
const k = new ia; | ||
ha(k, g, f, b); | ||
-1 != c && (c += 6, e = a.slice(0, c), d = a.slice(c), e = K("arg", e), e = e.map(({content:g, props:f}) => { | ||
const k = new da; | ||
ca(k, g, f, b); | ||
return k; | ||
})); | ||
return {w:c, j:e}; | ||
return {w:d, j:e}; | ||
}; | ||
const {readFileSync:ja} = fs; | ||
const ka = a => { | ||
const b = a.replace(/^\s*\n/gm, "").split("\n").reduce((d, c) => { | ||
[{length:c = 0} = {}] = /^\s*/.exec(c) || []; | ||
return c < d ? c : d; | ||
const ea = fs.readFileSync; | ||
const fa = 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 J(a, b = "") { | ||
const d = b.split(/\s*,\s*/); | ||
return a.split(/\s*,\s*/).map(c => { | ||
let e = c = ja(c, "utf8"); | ||
if (c = /\/\* start example \*\/\r?\n([\s\S]+?)\r?\n\s*\/\* end example \*\//.exec(c)) { | ||
[, c] = c, e = ka(c); | ||
function M(a, b = "") { | ||
const c = b.split(/\s*,\s*/); | ||
return a.split(/\s*,\s*/).map(d => { | ||
let e = d = ea(d, "utf8"); | ||
if (d = /\/\* start example \*\/\r?\n([\s\S]+?)\r?\n\s*\/\* end example \*\//.exec(d)) { | ||
[, d] = d, e = fa(d); | ||
} | ||
d.forEach(g => { | ||
c.forEach(g => { | ||
const [f, k] = g.split(/\s*=>\s*/); | ||
@@ -343,6 +348,6 @@ e = e.replace(`'${f}'`, `'${k}'`); | ||
} | ||
function K(a, b, d = new RegExp(`([!?])?${b}\\.`, "g")) { | ||
b && (a.type = a.type.replace(d, "$1")); | ||
function N(a, b, c = new RegExp(`([!?])?${b}\\.`, "g")) { | ||
b && (a.type = a.type.replace(c, "$1")); | ||
} | ||
class L { | ||
class P { | ||
constructor(a = null) { | ||
@@ -364,10 +369,10 @@ 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 g = b.map(k => a(k)).map((k, h) => { | ||
const {optional:m} = b[h]; | ||
let {name:l = `arg${h}`, optional:q = m} = this.D[h] || {}; | ||
return `${`${l}${q ? "?" : ""}`}: ${k}`; | ||
let {name:l = `arg${h}`, optional:p = m} = this.D[h] || {}; | ||
return `${`${l}${p ? "?" : ""}`}: ${k}`; | ||
}); | ||
if (c) { | ||
var f = a(c); | ||
if (d) { | ||
var f = a(d); | ||
g.unshift(`this: ${f}`); | ||
@@ -385,3 +390,3 @@ } | ||
g = g.join(", "); | ||
f = d ? a(d) : "?"; | ||
f = c ? a(c) : "?"; | ||
return `(${g}) => ${f}`; | ||
@@ -395,3 +400,3 @@ } | ||
} | ||
b(a, {name:b, string:d, "boolean":c, opt:e, number:g, type:f, "default":k, closure:h, alias:m, aliases:l, example:q, "example-override":n = "", noParams:p, "static":v, initial:t}) { | ||
b(a, {name:b, string:c, "boolean":d, opt:e, number:g, type:f, "default":k, closure:h, alias:m, aliases:l, example:p, "example-override":n = "", noParams:q, "static":u, initial:t}) { | ||
if (!b) { | ||
@@ -402,4 +407,4 @@ throw Error("Property does not have a name."); | ||
a && (this.description = F(a)); | ||
a = E({A:g, C:d, l:c, type:f}); | ||
p && (this.v = p); | ||
a = E({A:g, C:c, l:d, type:f}); | ||
q && (this.v = q); | ||
h && (this.u = h); | ||
@@ -413,4 +418,4 @@ this.type = a; | ||
l && (this.aliases = l.split(/\s*,\s*/)); | ||
v && (this.f = !0); | ||
q && (this.examples = J(q, n)); | ||
u && (this.f = !0); | ||
p && (this.examples = M(p, n)); | ||
} | ||
@@ -425,3 +430,3 @@ get type() { | ||
try { | ||
this.parsed = D(this.h), this.isParsedFunction && !this.args && (this.args = []); | ||
this.parsed = B(this.h), this.isParsedFunction && !this.args && (this.args = []); | ||
} catch (b) { | ||
@@ -441,3 +446,3 @@ this.parsed = null; | ||
} | ||
;class M extends L { | ||
;class Q extends P { | ||
constructor(...a) { | ||
@@ -453,9 +458,9 @@ super(...a); | ||
} | ||
;const O = (a, b, d = {}) => { | ||
let c; | ||
;const S = (a, b, c = {}) => { | ||
let d; | ||
if ("object" == typeof b) { | ||
c = b; | ||
d = b; | ||
} else { | ||
try { | ||
(c = D(b)) || console.log("Could not parse %s", b); | ||
(d = B(b)) || console.log("Could not parse %s", b); | ||
} catch (e) { | ||
@@ -465,8 +470,8 @@ console.log("Could not parse %s", b), console.error(e.message); | ||
} | ||
return c ? N(c, a, d) : b; | ||
}, N = (a, b, d = {}) => { | ||
return d ? R(d, a, c) : b; | ||
}, R = (a, b, c = {}) => { | ||
if ("" == a.name && a.nullable) { | ||
return "?"; | ||
} | ||
var {escapePipe:c = !0} = d; | ||
var {escapePipe:d = !0} = c; | ||
let e = ""; | ||
@@ -478,15 +483,15 @@ var g = ""; | ||
const f = []; | ||
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.this && (d = "this: " + R(a.function.this, b, c), f.push(d)); | ||
a.function.new && (d = "new: " + R(a.function.new, b, c), f.push(d)); | ||
a.function.args.forEach(k => { | ||
let h = N(k, b, d); | ||
let h = R(k, b, c); | ||
k.optional && (h += "="); | ||
f.push(h); | ||
}); | ||
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)); | ||
a.function.variableArgs && (d = "..." + R(a.function.variableArgs, b, c), f.push(d)); | ||
d = f.join(", "); | ||
e += d + ")"; | ||
a.function.return && (e += ": " + R(a.function.return, b, c)); | ||
} else { | ||
a.record ? (e += "{ ", c = Object.keys(a.record).map(f => { | ||
a.record ? (e += "{ ", d = Object.keys(a.record).map(f => { | ||
var k = a.record[f]; | ||
@@ -496,38 +501,38 @@ if (!k) { | ||
} | ||
k = N(k, b, d); | ||
k = R(k, b, c); | ||
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); | ||
}), e += d.join(", "), e += " }") : a.application ? (e += T(a.name, b, g, c) + "<", d = a.application.map(f => R(f, b, c)), e += d.join(", "), e += ">") : a.union ? (e = e + g + "(", g = a.union.map(f => R(f, b, c)), e += g.join(d ? " \\| " : " | "), e += ")") : e += T("any" == a.name ? "*" : a.name, b, g, c); | ||
} | ||
return e; | ||
}, P = (a, b, d = "", c = {}) => { | ||
const {flatten:e = !1, nameProcess:g, link:f = ({link:m}) => `#${m}`} = c; | ||
c = la(b, a); | ||
d = `${d}${a}`; | ||
if (!c) { | ||
return d; | ||
}, T = (a, b, c = "", d = {}) => { | ||
const {flatten:e = !1, nameProcess:g, link:f = ({link:m}) => `#${m}`} = d; | ||
d = ha(b, a); | ||
c = `${c}${a}`; | ||
if (!d) { | ||
return c; | ||
} | ||
let {link:k, type:{description:h}} = c; | ||
k = f(c); | ||
let {link:k, type:{description:h}} = d; | ||
k = f(d); | ||
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; | ||
b = g ? g(c) : c; | ||
return h ? `<a href="${k}" title="${h.replace(/"/g, """)}">${b}</a>` : `[${b}](${k})`; | ||
}, la = (a, b) => { | ||
a = a.filter(({fullName:c}) => c == b); | ||
}, ha = (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 ma(a, b = [], d = [], c = {}) { | ||
const {narrow:e = !1, flatten:g = !1, preprocessDesc:f, link:k} = c; | ||
function ia(a, b = [], c = [], d = {}) { | ||
const {narrow:e = !1, flatten:g = !1, preprocessDesc:f, link:k} = d; | ||
if (!b.length) { | ||
return ""; | ||
} | ||
const h = a.isConstructor || a.isInterface, m = b.some(({hasDefault:n}) => n), l = {flatten:g, escapePipe:!e, link:k}, q = n => O(d, n, l); | ||
const h = a.isConstructor || a.isInterface, m = b.some(({hasDefault:n}) => n), l = {flatten:g, escapePipe:!e, link:k}, p = n => S(c, n, l); | ||
a = b.map(n => { | ||
let p; | ||
n.args && n.isParsedFunction ? (p = n.toTypeScriptFunction(q), n.isConstructor && (p = `new ${p}`)) : p = O(d, n.parsed || n.type, l); | ||
const v = h || n.optional ? n.name : `${n.name}*`, t = n.hasDefault ? `\`${n.default}\`` : "-", r = f ? f(n.description) : n.description; | ||
return {prop:n, typeName:p, name:v, de:na(r, !e), d:t}; | ||
let q; | ||
n.args && n.isParsedFunction ? (q = n.toTypeScriptFunction(p), n.isConstructor && (q = `new ${q}`)) : q = S(c, n.parsed || n.type, l); | ||
const u = h || n.optional ? n.name : `${n.name}*`, t = n.hasDefault ? `\`${n.default}\`` : "-", r = f ? f(n.description) : n.description; | ||
return {prop:n, typeName:q, name:u, de:ja(r, !e), d:t}; | ||
}); | ||
@@ -537,3 +542,3 @@ if (e) { | ||
} | ||
a = a.map(({name:n, typeName:p, de:v, d:t, prop:r}) => [r.optional ? n : `__${n}__`, `<em>${p}</em>`, v, ...m ? [t] : []]); | ||
a = a.map(({name:n, typeName:q, de:u, d:t, prop:r}) => [r.optional ? n : `__${n}__`, `<em>${q}</em>`, u, ...m ? [t] : []]); | ||
b = ["Name", ...e ? ["Type & Description"] : ["Type", "Description"], ...m ? [h ? "Initial" : "Default"] : []]; | ||
@@ -546,3 +551,3 @@ return ` | ||
} | ||
const na = (a = "", b = !0) => { | ||
const ja = (a = "", b = !0) => { | ||
null === a && (a = ""); | ||
@@ -552,8 +557,28 @@ b && (a = a.replace(/\|/g, "\\|")); | ||
}; | ||
const {dirname:Q, resolve:R} = path; | ||
function S(a, b) { | ||
const d = a.example; | ||
d && d.startsWith(".") && b && (a.example = R(Q(b), d)); | ||
function ka(a, b, c, d) { | ||
var e = K("prop", a).map(({content:h, props:m}) => { | ||
const l = new P; | ||
H(m, c); | ||
l.b(h, m); | ||
return l; | ||
}); | ||
a = K(["function", "fn", "static"], a).map(({content:h, props:m, tag:l}) => { | ||
l = "static" == l; | ||
const {w:p, j:n} = L(h, b); | ||
h = new Q(n); | ||
const {F:q, o:u} = G(m, n, d); | ||
q.type = u; | ||
H(q, c); | ||
h.b(p, q); | ||
l && (h.f = !0); | ||
return h; | ||
}); | ||
e = [...e, ...a]; | ||
const {m:g, B:f, n:k} = e.reduce((h, m) => { | ||
m.isConstructor ? h.m.push(m) : m.static ? h.B.push(m) : h.n.push(m); | ||
return h; | ||
}, {m:[], B:[], n:[]}); | ||
return {constructor:g[0] || null, properties:[...g, ...f, ...k]}; | ||
} | ||
class T { | ||
;class U { | ||
constructor() { | ||
@@ -574,3 +599,3 @@ this.name = ""; | ||
} | ||
b(a, {name:b, type:d, desc:c, noToc:e, spread:g, noExpand:f, link:k, closure:h, constructor:m, "extends":l, "interface":q, record:n, example:p, "example-override":v}, t, r = null) { | ||
b(a, {name:b, type:c, desc:d, noToc:e, spread:g, noExpand:f, link:k, closure:h, constructor:m, "extends":l, "interface":p, record:n, example:q, "example-override":u}, t, r = null) { | ||
if (!b) { | ||
@@ -580,5 +605,5 @@ throw Error("Type does not have a name."); | ||
this.name = b; | ||
d && (this.type = d); | ||
c && (this.type = c); | ||
h ? this.closureType = h : this.closureType = this.type; | ||
c && (this.description = F(c)); | ||
d && (this.description = F(d)); | ||
this.noToc = !!e; | ||
@@ -589,3 +614,3 @@ this.spread = !!g; | ||
!0 === m && (this.isConstructor = m); | ||
!0 === q && (this.isInterface = q); | ||
!0 === p && (this.isInterface = p); | ||
!0 === n && (this.isRecord = n); | ||
@@ -595,27 +620,7 @@ l && (this.extends = l); | ||
if (a) { | ||
b = C("prop", a).map(({content:u, props:w}) => { | ||
const A = new L; | ||
S(w, this.f); | ||
A.b(u, w); | ||
return A; | ||
}); | ||
a = C(["function", "fn", "static"], a).map(({content:u, props:w, tag:A}) => { | ||
A = "static" == A; | ||
const {w:oa, j:U} = I(u, r); | ||
u = new M(U); | ||
const {F:G, o:pa} = H(w, U, this.fullName); | ||
G.type = pa; | ||
S(G, this.f); | ||
u.b(oa, G); | ||
A && (u.f = !0); | ||
return u; | ||
}); | ||
a = [...b, ...a]; | ||
const {m:y, B:qa, n:ra} = a.reduce((u, w) => { | ||
w.isConstructor ? u.m.push(w) : w.static ? u.B.push(w) : u.n.push(w); | ||
return u; | ||
}, {m:[], B:[], n:[]}); | ||
this.properties = [...y, ...qa, ...ra]; | ||
const {properties:w, constructor:O} = ka(a, r, this.f, this.fullName); | ||
O && (this.args = O.args); | ||
this.properties = w; | ||
} | ||
p && (p = p.startsWith(".") && this.f ? R(Q(this.f), p) : p, this.examples = J(p, v)); | ||
q && (a = {example:q}, H(a, this.f), this.examples = M(a.example, u)); | ||
} | ||
@@ -637,5 +642,5 @@ h(a, b = new RegExp(`([!?])?${a}\\.`, "g")) { | ||
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 g = this.type ? `\`${this.type}\`` : "", 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)); | ||
this.link ? f = `[${g}](${this.link})` : !this.import && this.type && (f = S(a, this.type, b), g = f != this.type, f = V(f, g)); | ||
g = V(this.fullName); | ||
@@ -647,6 +652,6 @@ g = this.import ? `[${g}](l-type)` : this.noToc ? `[${g}](l-type)` : `[${g}](t-type)`; | ||
if (this.extends) { | ||
const m = sa(this.extends, a, b), l = ` extends ${m}`; | ||
const m = la(this.extends, a, b), l = ` extends ${m}`; | ||
h = h || /_/.test(m); | ||
f = (h ? f + "<strong>" : f + "__") + (g + l); | ||
"function" == typeof d && d(this.extends); | ||
"function" == typeof c && c(this.extends); | ||
} else { | ||
@@ -656,13 +661,13 @@ f = (h ? f + "<strong>" : f + "__") + g; | ||
f = (h ? f + "</strong>" : f + "__") + k; | ||
a = ma(this, this.properties, a, b); | ||
a = ia(this, this.properties, a, b); | ||
return {LINE:f, table:a, displayInDetails:e}; | ||
} | ||
} | ||
const V = (a, b = !1) => `${b ? "<code>" : "`"}${a}${b ? "</code>" : "`"}`, sa = (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 = O(b, c, {...d, nameProcess:f => `\`${f}\``}), c != g && (e = g)); | ||
const V = (a, b = !1) => `${b ? "<code>" : "`"}${a}${b ? "</code>" : "`"}`, la = (a, b, c) => a.split(/,\s*/).map(d => { | ||
let e = `\`${d}\``; | ||
var g = b.find(({fullName:f}) => f == d); | ||
g && g.link ? (e = "<a ", g.description && (e += `title="${g.description}" `), e += `href="${g.link}">\`${d}\`</a>`) : (g = S(b, d, {...c, nameProcess:f => `\`${f}\``}), d != g && (e = g)); | ||
return e; | ||
}).join(", "); | ||
class W extends T { | ||
class W extends U { | ||
constructor() { | ||
@@ -676,6 +681,6 @@ super(); | ||
} | ||
b(a, {async:b, "return":d, ...c}, ...e) { | ||
b(a, {async:b, "return":c, ...d}, ...e) { | ||
this.description = F(a); | ||
super.b("", c, ...e); | ||
d && (this.g = d.replace(/\n\s*/g, " ")); | ||
super.b("", d, ...e); | ||
c && (this.g = c.replace(/\n\s*/g, " ")); | ||
b && (this.async = !0); | ||
@@ -691,3 +696,3 @@ } | ||
} | ||
;class ta extends T { | ||
;class ma extends U { | ||
constructor() { | ||
@@ -700,3 +705,3 @@ super(); | ||
} | ||
b(a, {from:b, name:d, ...c}, e, g) { | ||
b(a, {from:b, name:c, ...d}, e, g) { | ||
if (!b) { | ||
@@ -707,24 +712,24 @@ throw Error("From attribute of import is not given."); | ||
this.description = F(a); | ||
super.b("", {...c, noToc:!0, name:d, type:`import('${b}').${d}`}, e != g ? e : null); | ||
super.b("", {...d, noToc:!0, name:c, type:`import('${b}').${c}`}, e != g ? e : null); | ||
} | ||
} | ||
;const {homedir:ua} = os; | ||
ua(); | ||
const va = (a, b) => { | ||
const d = new RegExp(`([!?])?${a}\\.`, "g"); | ||
b.properties.forEach(c => { | ||
K(c, a, d); | ||
;const na = os.homedir; | ||
na(); | ||
const oa = (a, b) => { | ||
const c = new RegExp(`([!?])?${a}\\.`, "g"); | ||
b.properties.forEach(d => { | ||
N(d, a, c); | ||
}); | ||
b.h(a); | ||
}, X = (a, b) => { | ||
var {args:d = []} = a; | ||
const 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; | ||
K(d, b); | ||
a.properties.unshift(d); | ||
}, Y = (a, b, d, c, e = !1, g = null) => { | ||
const f = e ? new W : new T; | ||
var {args:c = []} = a; | ||
const d = `function(${c.map(({s:e}) => e).join(", ")}): ${a.fullName}`; | ||
c = new Q(c); | ||
c.isConstructor = !0; | ||
c.b("Constructor method.", {type:d, name:"constructor"}); | ||
c.examples = a.examples; | ||
N(c, b); | ||
a.properties.unshift(c); | ||
}, Y = (a, b, c, d, e = !1, g = null) => { | ||
const f = e ? new W : new U; | ||
f.f = g; | ||
@@ -734,14 +739,14 @@ g = a.search(/<(prop|function|fn|static) /); | ||
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)); | ||
const {j:m, w:l} = L(k, d); | ||
f.b(e ? l : h, b, c, d); | ||
({o:a} = G(b, m)); | ||
e && (f.closureType = a); | ||
f.args = m; | ||
f.args || (f.args = m); | ||
return f; | ||
}, Z = ({content:a, props:b, ns:d, i:c, isMethod:e = !1, location:g = null}) => { | ||
}, Z = ({content:a, props:b, ns:c, i:d, isMethod:e = !1, location:g = null}) => { | ||
const f = [], {alias:k, aliases:h, ...m} = b; | ||
b = Y(a, b, d, c, e, g); | ||
b = Y(a, b, c, d, e, g); | ||
f.push(b); | ||
(k ? [k] : h ? h.split(/, */) : []).forEach(l => { | ||
l = Y(a, {...m, name:l}, d, c, e, g); | ||
l = Y(a, {...m, name:l}, c, d, e, g); | ||
l.description = `${l.description}${l.description ? " " : ""}Alias of \`${m.name}\`.`; | ||
@@ -752,29 +757,29 @@ f.push(l); | ||
}; | ||
module.exports = {_Type:T, _Property:L, _Method:W, _parseFile:(a, b, d = null) => { | ||
a = C("types", a); | ||
module.exports = {_Type:U, _Property:P, _Method:W, _parseFile:(a, b, c = null) => { | ||
a = K("types", a); | ||
if (!a.length) { | ||
throw Error("XML file should contain root types element."); | ||
} | ||
const [{content:c, props:{namespace:e, ns:g = e}}] = a, f = b == g ? void 0 : g, k = []; | ||
a = C(["type", "interface", "constructor", "method", "import"], c).reduce((h, {content:m, props:l, tag:q}) => { | ||
const {alias:n, aliases:p, ...v} = l; | ||
d && S(v, d); | ||
var t = n ? [n] : p ? p.split(/, */) : []; | ||
switch(q) { | ||
const [{content:d, props:{namespace:e, ns:g = e}}] = a, f = b == g ? void 0 : g, k = []; | ||
a = K(["type", "interface", "constructor", "method", "import"], d).reduce((h, {content:m, props:l, tag:p}) => { | ||
const {alias:n, aliases:q, ...u} = l; | ||
c && H(u, c); | ||
var t = n ? [n] : q ? q.split(/, */) : []; | ||
switch(p) { | ||
case "type": | ||
q = new T; | ||
d && (q.f = d); | ||
q.b(m, l, f, b); | ||
h.push(q); | ||
p = new U; | ||
c && (p.f = c); | ||
p.b(m, l, f, b); | ||
h.push(p); | ||
t.forEach(r => { | ||
const y = new T; | ||
d && (y.f = d); | ||
y.b(m, {...v, name:r}, f, b); | ||
h.push(y); | ||
const w = new U; | ||
c && (w.f = c); | ||
w.b(m, {...u, name:r}, f, b); | ||
h.push(w); | ||
}); | ||
break; | ||
case "interface": | ||
l = Z({content:m, props:l, ns:f, i:b, location:d}); | ||
l = Z({content:m, props:l, ns:f, i:b, location:c}); | ||
l.forEach(r => { | ||
r.properties.some(({isConstructor:y}) => y) || X(r, b); | ||
r.properties.some(({isConstructor:w}) => w) || X(r, b); | ||
r.isInterface = !0; | ||
@@ -785,5 +790,5 @@ }); | ||
case "constructor": | ||
l = Z({content:m, props:l, ns:f, i:b, location:d}); | ||
l = Z({content:m, props:l, ns:f, i:b, location:c}); | ||
l.forEach(r => { | ||
r.properties.some(({isConstructor:y}) => y) || X(r, b); | ||
r.properties.some(({isConstructor:w}) => w) || X(r, b); | ||
r.isConstructor = !0; | ||
@@ -794,15 +799,15 @@ }); | ||
case "method": | ||
l = Z({content:m, props:l, ns:f, i:b, isMethod:!0, location:d}); | ||
l = Z({content:m, props:l, ns:f, i:b, isMethod:!0, location:c}); | ||
h.push(...l); | ||
break; | ||
case "import": | ||
t = new ta, t.b(m, l, l.ns || l.from, b), k.push(t); | ||
t = new ma, t.b(m, l, l.ns || l.from, b), k.push(t); | ||
} | ||
return h; | ||
}, []); | ||
b && a.forEach(h => va(b, h)); | ||
b && a.forEach(h => oa(b, h)); | ||
return {namespace:g, types:a, imports:k}; | ||
}, _getLinks:O}; | ||
}, _getLinks:S}; | ||
//# sourceMappingURL=typal.js.map |
{ | ||
"name": "typal", | ||
"version": "1.24.13", | ||
"version": "1.24.14", | ||
"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", |
@@ -0,1 +1,3 @@ | ||
import { resolve, dirname } from 'path' | ||
/** | ||
@@ -157,1 +159,12 @@ * Return a name of a property with its default value, and surrounded by square brackets if default is given. If type is boolean or number, the default value is not surrounded by "". | ||
} | ||
/** | ||
* When the location is given, resolve relative example paths. | ||
* @param {!Object} props | ||
* @param {string|null} file | ||
*/ | ||
export function updateExampleProp(props, file) { | ||
const e = props['example'] | ||
if (e && e.startsWith('.') && file) | ||
props['example'] = resolve(dirname(file), e) | ||
} |
@@ -7,3 +7,3 @@ import extractTags from 'rexml' | ||
import Arg, { extractArgs } from './Arg' // eslint-disable-line | ||
import { toType } from './' | ||
import { toType, updateExampleProp } from './' | ||
import Fn from './Fn' | ||
@@ -73,3 +73,3 @@ import { dirname, resolve } from 'path' | ||
const { 'alias': alias, 'aliases': aliases, ...restProps } = props | ||
if (location) Type.updateExampleProp(restProps, location) | ||
if (location) updateExampleProp(restProps, location) | ||
const als = alias ? [alias] : (aliases ? aliases.split(/, */) : []) | ||
@@ -179,3 +179,3 @@ | ||
type.setAssignment(argsArgs) | ||
if (!type.args) type.setAssignment(argsArgs) | ||
@@ -182,0 +182,0 @@ return type |
@@ -1,10 +0,9 @@ | ||
import extractTags from 'rexml' | ||
import Property from './Property' | ||
import Property, { indentWithAster } from './Property' | ||
import Fn from './Fn' | ||
import { addSuppress, makeBlock, getExternDeclaration, makeOptional, toType } from './' | ||
import { addSuppress, makeBlock, getExternDeclaration, makeOptional, updateExampleProp } from './' | ||
import { trimD } from './' | ||
import Arg, { extractArgs } from './Arg' // eslint-disable-line | ||
import Arg from './Arg' // eslint-disable-line | ||
import { getLinks } from './get-links' | ||
import makePropsTable from './make-props-table' | ||
import { resolve, dirname } from 'path' | ||
import extractProperties from './extract-props' | ||
@@ -97,12 +96,2 @@ /** | ||
/** | ||
* When the location is given, resolve relative example paths. | ||
* @param {!Object} props | ||
* @param {string|null} file | ||
*/ | ||
static updateExampleProp(props, file) { | ||
const e = props['example'] | ||
if (e && e.startsWith('.') && file) | ||
props['example'] = resolve(dirname(file), e) | ||
} | ||
/** | ||
* Create type from the xml content and properties parsed with `rexml`. | ||
@@ -134,37 +123,12 @@ */ | ||
if (content) { | ||
const ps = extractTags('prop', content) | ||
const props = ps.map(({ content: c, props: p }) => { | ||
const pr = new Property() | ||
Type.updateExampleProp(p, this.file) | ||
pr.fromXML(c, p) | ||
return pr | ||
}) | ||
const functions = extractTags(['function', 'fn', 'static'], content) | ||
const fnProps = functions.map(({ content: c, props: p, tag }) => { | ||
const isStatic = tag == 'static' | ||
const { newContent, argsArgs } = extractArgs(c, rootNamespace) | ||
const pr = new Fn(argsArgs) | ||
const { rest, fnType } = toType(p, argsArgs, this.fullName) | ||
rest['type'] = fnType | ||
Type.updateExampleProp(rest, this.file) | ||
pr.fromXML(newContent, rest) | ||
if (isStatic) pr._static = true | ||
return pr | ||
}) | ||
const all = [...props, ...fnProps] | ||
const { c, s, n } = all.reduce((acc, p) => { | ||
if (p.isConstructor) acc.c.push(p) | ||
else if (p.static) acc.s.push(p) | ||
else acc.n.push(p) | ||
return acc | ||
}, { c: [], s: [], n: [] }) | ||
this.properties = [...c, ...s, ...n] | ||
const { properties, constructor } = extractProperties(content, rootNamespace, this.file, this.fullName) | ||
if (constructor) { | ||
this.args = constructor.args | ||
} | ||
this.properties = properties | ||
} | ||
if (example) { | ||
const e = (example.startsWith('.') && this.file) ? resolve(dirname(this.file), example) : example | ||
this.examples = Property.readExamples(e, exampleOverride) | ||
const e = { 'example': example } | ||
updateExampleProp(e, this.file) | ||
this.examples = Property.readExamples(e['example'], exampleOverride) | ||
} | ||
@@ -322,2 +286,6 @@ } | ||
if (this.description) lines.push(` * ${this.description}`) | ||
const constructor = this.properties[0] | ||
if (constructor instanceof Fn && constructor.isConstructor && constructor.description) { | ||
lines.push(indentWithAster(constructor.description)) | ||
} | ||
if (this.extends) { | ||
@@ -362,3 +330,3 @@ this.extends.split(/,\s*/).forEach((e) => { | ||
/** | ||
* Only used in externs. | ||
* Only used in externs for `@constructor` / `@interface` annotations. | ||
*/ | ||
@@ -365,0 +333,0 @@ toPrototype() { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
475574
41
5990
1