Comparing version 1.26.2 to 1.27.0
@@ -0,1 +1,8 @@ | ||
## 7 April 2020 | ||
### [1.27.0](https://gitlab.com/artdeco/typal/compare/v1.26.2...v1.27.0) | ||
- [package] Move to _GitLab_. | ||
- [fix] Fix EOLs and some bugs on Windows. | ||
## 3 February 2020 | ||
@@ -2,0 +9,0 @@ |
@@ -18,3 +18,3 @@ #!/usr/bin/env node | ||
} | ||
return globalThis; | ||
throw Error("Cannot find global object"); | ||
} | ||
@@ -124,4 +124,4 @@ var ca = ba(this); | ||
return a; | ||
}(ha), x = q.source, z = q.output, ja = q.closure, ka = q.useNamespace, la = q.externs, ma = q.types, na = q.template, oa = q.migrate, pa = q.help, qa = q.version; | ||
function ra(a = {usage:{}}) { | ||
}(ha), x = q.source, z = q.output, ja = q.closure, ka = q.useNamespace, la = q.externs, ma = q.types, na = q.template, oa = q.migrate, pa = q.version; | ||
function qa(a = {usage:{}}) { | ||
const {usage:b = {}, description:c, line:d, example:e} = a; | ||
@@ -157,6 +157,6 @@ a = Object.keys(b); | ||
} | ||
;const sa = fs.createReadStream, ta = fs.createWriteStream, A = fs.lstat, ua = fs.readFileSync, va = fs.readdir; | ||
var wa = stream; | ||
const B = stream.Transform, xa = stream.Writable; | ||
const ya = (a, b = 0, c = !1) => { | ||
;const ra = fs.createReadStream, sa = fs.createWriteStream, A = fs.lstat, ta = fs.readFileSync, ua = fs.readdir; | ||
var va = stream; | ||
const B = stream.Transform, wa = stream.Writable; | ||
const xa = (a, b = 0, c = !1) => { | ||
if (0 === b && !c) { | ||
@@ -167,11 +167,11 @@ return a; | ||
return c ? a[a.length - 1] : a.slice(b).join("\n"); | ||
}, za = (a, b = !1) => ya(a, 2 + (b ? 1 : 0)), Aa = a => { | ||
}, ya = (a, b = !1) => xa(a, 2 + (b ? 1 : 0)), za = a => { | ||
({callee:{caller:a}} = a); | ||
return a; | ||
}; | ||
const C = os.EOL, Ba = os.homedir; | ||
const Ca = /\s+at.*(?:\(|\s)(.*)\)?/, Da = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/, Ea = Ba(), E = a => { | ||
const {pretty:b = !1, ignoredModules:c = ["pirates"]} = {}, d = c.join("|"), e = new RegExp(Da.source.replace("IGNORED_MODULES", d)); | ||
const C = os.EOL, Aa = os.homedir; | ||
const Ba = /\s+at.*(?:\(|\s)(.*)\)?/, Ca = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/, E = a => { | ||
const {pretty:b = !1, ignoredModules:c = ["pirates", "@artdeco/pirates"]} = {}, d = c.join("|"), e = new RegExp(Ca.source.replace("IGNORED_MODULES", d)); | ||
return a.replace(/\\/g, "/").split("\n").filter(f => { | ||
f = f.match(Ca); | ||
f = f.match(Ba); | ||
if (null === f || !f[1]) { | ||
@@ -182,8 +182,14 @@ 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(Ca, (g, h) => g.replace(h, h.replace(Ea, "~"))) : f).join("\n"); | ||
}).filter(f => f.trim()).map(f => { | ||
if (b) { | ||
const g = Aa().replace(/\\/g, "/"); | ||
return f.replace(/\s+at.*(?:\(|\s)(.*)\)?/, (h, l) => h.replace(l, l.replace(g, "~"))); | ||
} | ||
return f; | ||
}).join("\n"); | ||
}; | ||
function Fa(a, b, c = !1) { | ||
function Da(a, b, c = !1) { | ||
return function(d) { | ||
var e = Aa(arguments), {stack:f} = Error(); | ||
const g = ya(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"); | ||
@@ -196,7 +202,7 @@ e = E(e); | ||
var {stack:b} = Error(); | ||
const c = Aa(arguments); | ||
b = za(b, a); | ||
return Fa(c, b, a); | ||
const c = za(arguments); | ||
b = ya(b, a); | ||
return Da(c, b, a); | ||
} | ||
;const Ga = (a, b) => { | ||
;const Ea = (a, b) => { | ||
b.once("error", c => { | ||
@@ -207,3 +213,3 @@ a.emit("error", c); | ||
}; | ||
class Ha extends xa { | ||
class Fa extends wa { | ||
constructor(a) { | ||
@@ -230,3 +236,3 @@ const {binary:b = !1, rs:c = null, ...d} = a || {}, {R:e = F(!0), proxyError:f} = a || {}, g = (h, l) => e(l); | ||
}); | ||
c && Ga(this, c).pipe(this); | ||
c && Ea(this, c).pipe(this); | ||
}); | ||
@@ -243,7 +249,7 @@ } | ||
const G = async a => { | ||
({f:a} = new Ha({rs:a, R:F(!0)})); | ||
({f:a} = new Fa({rs:a, R:F(!0)})); | ||
return await a; | ||
}; | ||
async function H(a) { | ||
a = sa(a); | ||
a = ra(a); | ||
return await G(a); | ||
@@ -255,3 +261,3 @@ } | ||
} | ||
const c = F(!0), d = ta(a); | ||
const c = F(!0), d = sa(a); | ||
await new Promise((e, f) => { | ||
@@ -279,6 +285,6 @@ d.on("error", g => { | ||
} | ||
;const Ia = path.dirname, Ja = path.join, Ka = path.relative, La = path.resolve; | ||
async function Ma(a, b) { | ||
;const Ga = path.dirname, Ha = path.join, Ia = path.relative, Ja = path.resolve; | ||
async function Ka(a, b) { | ||
b = b.map(async c => { | ||
const d = Ja(a, c); | ||
const d = Ha(a, c); | ||
return {lstat:await J(A, d), path:d, relativePath:c}; | ||
@@ -288,3 +294,3 @@ }); | ||
} | ||
const Na = a => a.lstat.isDirectory(), Oa = a => !a.lstat.isDirectory(); | ||
const La = a => a.lstat.isDirectory(), Ma = a => !a.lstat.isDirectory(); | ||
async function K(a) { | ||
@@ -300,6 +306,6 @@ if (!a) { | ||
} | ||
c = await J(va, a); | ||
var d = await Ma(a, c); | ||
c = d.filter(Na); | ||
d = d.filter(Oa).reduce((e, f) => { | ||
c = await J(ua, a); | ||
var d = await Ka(a, c); | ||
c = d.filter(La); | ||
d = d.filter(Ma).reduce((e, f) => { | ||
var g = f.lstat.isDirectory() ? "Directory" : f.lstat.isFile() ? "File" : f.lstat.isSymbolicLink() ? "SymbolicLink" : void 0; | ||
@@ -309,3 +315,3 @@ return {...e, [f.relativePath]:{type:g}}; | ||
c = await c.reduce(async(e, {path:f, relativePath:g}) => { | ||
const h = Ka(a, f); | ||
const h = Ia(a, f); | ||
if (b.includes(h)) { | ||
@@ -324,7 +330,7 @@ return e; | ||
const {type:g} = a[f]; | ||
"File" == g ? c.push(Ja(b, f)) : "Directory" == g && d.push(f); | ||
"File" == g ? c.push(Ha(b, f)) : "Directory" == g && d.push(f); | ||
}); | ||
const e = d.reduce((f, g) => { | ||
const {content:h} = a[g]; | ||
g = L(h, Ja(b, g)); | ||
g = L(h, Ha(b, g)); | ||
return [...f, ...g]; | ||
@@ -334,3 +340,3 @@ }, []); | ||
}; | ||
function Pa(a) { | ||
function Na(a) { | ||
if ("object" != typeof a) { | ||
@@ -343,3 +349,3 @@ return !1; | ||
} | ||
const Qa = (a, b) => { | ||
const Oa = (a, b) => { | ||
if (!(b instanceof Error)) { | ||
@@ -358,5 +364,5 @@ throw b; | ||
}; | ||
function Ra(a, b) { | ||
function Pa(a, b) { | ||
function c() { | ||
return b.filter(Pa).reduce((d, {re:e, replacement:f}) => { | ||
return b.filter(Na).reduce((d, {re:e, replacement:f}) => { | ||
if (this.j) { | ||
@@ -375,3 +381,3 @@ return d; | ||
} catch (k) { | ||
Qa(g, k); | ||
Oa(g, k); | ||
} | ||
@@ -387,3 +393,3 @@ }); | ||
} | ||
;const Sa = a => new RegExp(`%%_RESTREAM_${a.toUpperCase()}_REPLACEMENT_(\\d+)_%%`, "g"), Ta = (a, b) => `%%_RESTREAM_${a.toUpperCase()}_REPLACEMENT_${b}_%%`, Ua = () => { | ||
;const Qa = a => new RegExp(`%%_RESTREAM_${a.toUpperCase()}_REPLACEMENT_(\\d+)_%%`, "g"), Ra = (a, b) => `%%_RESTREAM_${a.toUpperCase()}_REPLACEMENT_${b}_%%`, Sa = () => { | ||
var a = {S:/^\/\*\*? (documentary|typal) (.+?) externs (.*?)\*\/\r?\n(?:([^\r\n][\s\S]+?\r?\n))?$/mg}; | ||
@@ -393,3 +399,3 @@ return Object.keys(a).reduce((b, c) => { | ||
var d = a[c]; | ||
const {getReplacement:e = Ta, getRegex:f = Sa} = {}, g = f(c); | ||
const {getReplacement:e = Ra, getRegex:f = Qa} = {}, g = f(c); | ||
d = {name:c, re:d, regExp:g, getReplacement:e, map:{}, lastIndex:0}; | ||
@@ -399,3 +405,3 @@ } | ||
}, {}); | ||
}, Va = a => { | ||
}, Ta = a => { | ||
var b = []; | ||
@@ -406,5 +412,5 @@ const c = a.map; | ||
delete c[e]; | ||
return Ra(d, Array.isArray(b) ? b : [b]); | ||
return Pa(d, Array.isArray(b) ? b : [b]); | ||
}}; | ||
}, Wa = a => { | ||
}, Ua = a => { | ||
const b = a.map, c = a.getReplacement, d = a.name; | ||
@@ -418,9 +424,9 @@ return {re:a.re, replacement(e) { | ||
}; | ||
async function Xa(a, b) { | ||
return Ya(a, b); | ||
async function Va(a, b) { | ||
return Wa(a, b); | ||
} | ||
class Za extends B { | ||
class Xa extends B { | ||
constructor(a, b) { | ||
super(b); | ||
this.g = (Array.isArray(a) ? a : [a]).filter(Pa); | ||
this.g = (Array.isArray(a) ? a : [a]).filter(Na); | ||
this.j = !1; | ||
@@ -430,5 +436,5 @@ this.h = b; | ||
async replace(a, b) { | ||
const c = new Za(this.g, this.h); | ||
const c = new Xa(this.g, this.h); | ||
b && Object.assign(c, b); | ||
a = await Xa(c, a); | ||
a = await Va(c, a); | ||
c.j && (this.j = !0); | ||
@@ -461,3 +467,3 @@ b && Object.keys(b).forEach(d => { | ||
} catch (k) { | ||
Qa(f, k); | ||
Oa(f, k); | ||
} | ||
@@ -470,3 +476,3 @@ }); | ||
} catch (h) { | ||
Qa(f, h); | ||
Oa(f, h); | ||
} | ||
@@ -490,8 +496,8 @@ } else { | ||
} | ||
async function Ya(a, b) { | ||
b instanceof wa ? b.pipe(a) : a.end(b); | ||
async function Wa(a, b) { | ||
b instanceof va ? b.pipe(a) : a.end(b); | ||
return await G(a); | ||
} | ||
;function $a() { | ||
var a = ab; | ||
;function Ya() { | ||
var a = Za; | ||
let b = ""; | ||
@@ -507,3 +513,3 @@ const c = new B({transform(d, e, f) { | ||
} | ||
;const bb = (a, b, c, d) => { | ||
;const $a = (a, b, c, d) => { | ||
if (!a) { | ||
@@ -518,33 +524,20 @@ throw Error("The name of the property is not given"); | ||
return `${a}=${b}`; | ||
}, cb = ({number:a, L:b, boolean:c, type:d}) => b ? "string" : a ? "number" : c ? "boolean" : d ? d : "*", db = a => `${/[^\w\d._]/.test(a) ? `(${a})` : a}|undefined`, M = a => a ? `/** | ||
${a} | ||
*/ | ||
` : "/**\n */\n", N = a => ` * @suppress {nonStandardJsDocs} | ||
${a}`, eb = (a, b, c) => { | ||
}, ab = ({number:a, L:b, boolean:c, type:d}) => b ? "string" : a ? "number" : c ? "boolean" : d ? d : "*", bb = a => `${/[^\w\d._]/.test(a) ? `(${a})` : a}|undefined`, M = a => a ? `/**${C}${a}${C} */${C}` : `/**${C} */${C}`, N = a => ` * @suppress {nonStandardJsDocs}${C}${a}`, cb = (a, b, c) => { | ||
a = `${a ? "" : "var "}${a ? `${a}.` : ""}${b}`; | ||
c && (a += ` = ${c}`); | ||
return a; | ||
}, db = a => { | ||
const b = a.split(/\r?\n/).map(c => { | ||
let d = Infinity; | ||
c.replace(/\S/, (e, f) => { | ||
d = f; | ||
}); | ||
return d; | ||
}).reduce((c, d) => d < c ? d : c, Infinity); | ||
return a.replace(new RegExp(`^ {${b}}`, "gm"), ""); | ||
}, Q = a => { | ||
a = a.trimRight(); | ||
var b = /\S/.exec(a); | ||
if (!b) { | ||
return a; | ||
} | ||
b = b.index; | ||
if (0 == b) { | ||
return a; | ||
} | ||
var c = a.substr(0, b).lastIndexOf(C); | ||
-1 == c ? c = 0 : (c++, a = a.substr(c)); | ||
b -= c; | ||
const d = " ".repeat(b); | ||
c = a.split(C); | ||
if (c.filter(e => /\S/.test(e)).find(e => !e.startsWith(d))) { | ||
return a.trim(); | ||
} | ||
{ | ||
const e = new RegExp(`^ {${b}}`); | ||
return c.map(f => f.replace(e, "")).join(C); | ||
} | ||
}, fb = (a, b, c = null) => { | ||
a = a.replace(/^\s*\r?\n( *\S)/, "$1"); | ||
return db(a); | ||
}, eb = (a, b, c = null) => { | ||
const {async:d, "void":e, "return":f = e ? "void" : "", ...g} = a; | ||
@@ -561,5 +554,6 @@ ({args:a = ""} = a); | ||
const c = a.example; | ||
c && c.startsWith(".") && b && (a.example = La(Ia(b), c)); | ||
c && c.startsWith(".") && b && (a.example = Ja(Ga(b), c)); | ||
} | ||
;function gb(a, b, c) { | ||
const fb = (...a) => a.join(C); | ||
function gb(a, b, c) { | ||
const d = []; | ||
@@ -778,3 +772,3 @@ b.replace(a, (e, ...f) => { | ||
b && (a.description = Q(b)); | ||
b = cb({number:g, L:d, boolean:e, type:h}); | ||
b = ab({number:g, L:d, boolean:e, type:h}); | ||
l && (b = b.replace(new RegExp(`([!?])?${l}\\.`, "g"), "$1")); | ||
@@ -855,3 +849,3 @@ b.endsWith("=") && (b = b.replace(/=$/, ""), f = !0); | ||
} | ||
;const U = (a, b = !1) => a.split(C).map((c, d) => { | ||
;const U = (a, b = !1) => a.split("\n").map((c, d) => { | ||
if (b && !d) { | ||
@@ -861,5 +855,5 @@ return c; | ||
d = " *"; | ||
c.length && (d += " "); | ||
c.length && "\r" != c && (d += " "); | ||
return d + c; | ||
}).join(C), qb = a => { | ||
}).join("\n"), qb = a => { | ||
const b = a.replace(/^\s*\r?\n/gm, "").split(C).reduce((c, d) => { | ||
@@ -874,3 +868,3 @@ [{length:d = 0} = {}] = /^\s*/.exec(d) || []; | ||
return a.split(/\s*,\s*/).map(d => { | ||
let e = d = ua(d, "utf8"); | ||
let e = d = ta(d, "utf8"); | ||
if (d = /\/\* start example \*\/\r?\n([\s\S]+?)\r?\n\s*\/\* end example \*\//.exec(d)) { | ||
@@ -900,3 +894,3 @@ [, d] = d, e = qb(d); | ||
e = e.reduce((k, m) => { | ||
m.startsWith("///") ? (m = m.replace(/^\/\/\/\s+/gm, ""), k.push(...m.split(C))) : (k.push("```js"), k.push(...m.split(C)), k.push("```")); | ||
m.startsWith("///") ? (m = m.replace(/^\/\/\/\s+/gm, ""), k.push(...m.split(/\r?\n/))) : (k.push("```js"), k.push(...m.split(/\r?\n/)), k.push("```")); | ||
return k; | ||
@@ -919,3 +913,3 @@ }, []); | ||
} | ||
b = bb(a.name, a.optional ? a.default : null, a.type, b); | ||
b = $a(a.name, a.optional ? a.default : null, a.type, b); | ||
b = a.optional ? `[${b}]` : b; | ||
@@ -970,3 +964,3 @@ var e = a.m; | ||
e && (e = U(e), d.push(...e.split(C))); | ||
!a.optional && a.isParsedFunction ? (e = xb(a, c), d.push(...e)) : d.push(` * @type {${a.optional ? db(a.closureType) : a.closureType}}`); | ||
!a.optional && a.isParsedFunction ? (e = xb(a, c), d.push(...e)) : d.push(` * @type {${a.optional ? bb(a.closureType) : a.closureType}}`); | ||
c && a.examples.length && (a = sb(a.examples), d.push(...a)); | ||
@@ -1038,3 +1032,3 @@ b && (d = d.map(f => `${b}${f}`)); | ||
a && (this.description = Q(a)); | ||
a = cb({number:f, L:c, boolean:d, type:g}); | ||
a = ab({number:f, L:c, boolean:d, type:g}); | ||
t && (this.s = t); | ||
@@ -1115,3 +1109,3 @@ l && (this.f = l); | ||
l = new W(p); | ||
const {W:t, H:r} = fb(k, p, d); | ||
const {W:t, H:r} = eb(k, p, d); | ||
t.type = r; | ||
@@ -1214,7 +1208,3 @@ R(t, c); | ||
b = ["Name", ...e ? ["Type & Description"] : ["Type", "Description"], ...h ? [g ? "Initial" : "Default"] : []]; | ||
return ` | ||
\`\`\`table | ||
${JSON.stringify([b, ...a], null, 2)} | ||
\`\`\``; | ||
return ["", "", "```table", JSON.stringify([b, ...a], null, 2).replace(/\n/g, C), "```"].join(C); | ||
} | ||
@@ -1224,3 +1214,3 @@ const Hb = (a = "", b = !0) => { | ||
b && (a = a.replace(/\|/g, "\\|")); | ||
return a.replace(/</g, "<").replace(/>/, ">"); | ||
return a.replace(/</g, "<").replace(/>/g, ">"); | ||
}; | ||
@@ -1240,3 +1230,3 @@ const Ib = (a, b, c = {}) => { | ||
b = M(b.join(C)); | ||
b += eb(a.namespace, a.name, Kb(a)); | ||
b += cb(a.namespace, a.name, Kb(a)); | ||
const c = a.properties.reduce((d, e) => { | ||
@@ -1250,3 +1240,3 @@ d.push(e); | ||
e = M(e); | ||
e += eb(`${a.fullName}${d.static ? "" : ".prototype"}`, d.name); | ||
e += cb(`${a.fullName}${d.static ? "" : ".prototype"}`, d.name); | ||
return e += zb(d); | ||
@@ -1429,3 +1419,3 @@ }); | ||
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 = `(${bb(d)})`); | ||
return `${e}: ${f}`; | ||
@@ -1458,3 +1448,3 @@ }).join(", ")} }`; | ||
} | ||
class Rb extends Za { | ||
class Rb extends Xa { | ||
constructor(a, b = {}) { | ||
@@ -1599,3 +1589,3 @@ super(a); | ||
g.b(e ? m : l, b, c, d); | ||
({H:a} = fb(b, k)); | ||
({H:a} = eb(b, k)); | ||
e && (g.closureType = a); | ||
@@ -1634,13 +1624,12 @@ g.args || (g.args = k); | ||
}, $b = (a, b, c, d = !1) => { | ||
a = [...a.map(e => { | ||
a = a.map(e => { | ||
{ | ||
let f; | ||
e.closureType ? f = ` * @typedef {${e.closureType}}` : e.u || (f = ` * @typedef {${Nb(e.properties, !0)}}`); | ||
f ? (e.description && (f = ` * ${e.description}${C}${f}`), f = M(f), e = f += eb(e.namespace, e.name)) : e = Jb(e); | ||
f ? (e.description && (f = ` * ${e.description}${C}${f}`), f = M(f), e = f += cb(e.namespace, e.name)) : e = Jb(e); | ||
} | ||
return e; | ||
})].join(C); | ||
return `${!b || d || c.includes(b) ? "" : `/** @const */ | ||
var ${b} = {} | ||
`}${a}`; | ||
}); | ||
a = fb(...a, ...[]); | ||
return `${!b || d || c.includes(b) ? "" : ["/** @const */", `var ${b} = {}`, ""].join(C)}${a}`; | ||
}; | ||
@@ -1679,3 +1668,3 @@ async function ac(a, b, c) { | ||
} | ||
const cc = {re:/^\/\*\*? (documentary|typal) (.+?) \*\/\r?\n(?:([^\n][\s\S]+?\r?\n))?$/mg, replacement:ac}, bc = (a, b, c = !1) => { | ||
const cc = {re:/^\/\*\*? (documentary|typal) (.+?) \*\/\r?\n(?:((?!\r?\n)[\s\S]+?\r?\n))?$/mg, replacement:ac}, bc = (a, b, c = !1) => { | ||
b = b.map(d => d.g(!1, !1, c)); | ||
@@ -1746,16 +1735,11 @@ a = a.map(d => d.g(c)).map(M).join(""); | ||
var mc = (a, b = !1) => { | ||
var {S:c} = Ua(); | ||
const d = Wa(c); | ||
c = Va(c); | ||
var {S:c} = Sa(); | ||
const d = Ua(c); | ||
c = Ta(c); | ||
return new Rb(b ? [cc] : [cc, d, fc, c], a); | ||
}; | ||
const nc = /( *) \* @(fnType|methodType) {(.+?)}/gm, oc = (a, b, c, d, e, f, g = d) => `/** | ||
${a} | ||
*/ | ||
${b ? "static " : ""}${c ? "async " : ""}${d}(${e}) { | ||
return ${`${b ? f : "super"}.${g}`}(${e}) | ||
}`; | ||
class pc extends Za { | ||
const nc = /( *) \* @(fnType|methodType) {(.+?)}/gm, oc = (a, b, c, d, e, f, g = d) => ["/**", a, " */", `${b ? "static " : ""}${c ? "async " : ""}${d}(${e}) {`, ` return ${`${b ? f : "super"}.${g}`}(${e})`, "}"].join(C); | ||
class pc extends Xa { | ||
constructor(a, b) { | ||
super([{re:/\/\*\*\s+( *) \* @constructor {(.+?)}[\s\S]+?(class\s+.+?\s+extends\s+(.+?)\s*){\s*}/gm, replacement(c, d, e, f, g) { | ||
super([{re:/\/\*\*(?:\s+( *) \*)? @constructor {(.+?)}[\s\S]+?(class\s+.+?\s+extends\s+(.+?)\s*){\s*}/gm, replacement(c, d, e, f, g) { | ||
d = a.find(({fullName:k}) => k == e); | ||
@@ -1777,15 +1761,4 @@ if (!d) { | ||
const h = d.properties.find(k => k instanceof W && k.isConstructor), l = h.args.map(({name:k}) => k).join(", "); | ||
c = [`/** | ||
${qc(V(h, "", !0), e)} | ||
*/ | ||
constructor(${l}) { | ||
super(${l}) | ||
}`, ...c].join(C).replace(/^/gm, " "); | ||
f = `${f}{ | ||
${c} | ||
}`; | ||
d.description && (f = `/** | ||
${U(d.description)} | ||
*/${C}` + f); | ||
return f; | ||
c = fb("/**", qc(V(h, "", !0), e), " */", `constructor(${l}) {`, ` super(${l})`, "}", ...c).replace(/(^|(?:\r?\n))/g, "$1 "); | ||
return fb(...d.description ? ["/**", U(d.description), " */"] : [], `${f}{`, c, "}"); | ||
}}, {re:nc, async replacement(c, d, e, f) { | ||
@@ -1880,3 +1853,3 @@ const g = f.split("."); | ||
return void 0 !== b ? b : a; | ||
}, yc = /^ \* @prop {(.+?)} (\[)?(.+?)(?:=(["'])?(.+?)\4)?(?:])?(?: (.+?))?(?: Default `(.+?)`.)?$/gm, zc = "type opt name quote defaultValue description Default".split(" "), ab = new RegExp(`^ \\* @typedef {(.+?)} (.+?)(?: (.+))?\\r?\\n((?:${/ \* @prop(?:erty)? .+\r?\n/.source})*)`, "gm"), Ac = (a, b, c, d) => { | ||
}, yc = /^ \* @prop {(.+?)} (\[)?(.+?)(?:=(["'])?(.+?)\4)?(?:])?(?: (.+?))?(?: Default `(.+?)`.)?$/gm, zc = "type opt name quote defaultValue description Default".split(" "), Za = new RegExp(`^ \\* @typedef {(.+?)} (.+?)(?: (.+))?\\r?\\n((?:${/ \* @prop(?:erty)? .+\r?\n/.source})*)`, "gm"), Ac = (a, b, c, d) => { | ||
d = d.length; | ||
@@ -1928,5 +1901,5 @@ a = a && "Object" != a ? ` type="${a}"` : ""; | ||
if (h) { | ||
h !== l && void 0 !== g.v && (t = bb(m, l, n), console.error("%s[%s] does not match Default `%s`.", b, t, g.v)); | ||
h !== l && void 0 !== g.v && (t = $a(m, l, n), console.error("%s[%s] does not match Default `%s`.", b, t, g.v)); | ||
} else { | ||
var t = bb(m, l, n); | ||
var t = $a(m, l, n); | ||
console.error("%s[%s] got from Default.", b, t); | ||
@@ -1945,3 +1918,3 @@ } | ||
async function Ec(a) { | ||
const b = $a(), c = new Dc, d = new Bc; | ||
const b = Ya(), c = new Dc, d = new Bc; | ||
b.pipe(c).pipe(d); | ||
@@ -1961,5 +1934,3 @@ b.end(a); | ||
}); | ||
return `<types> | ||
${(await G(d)).trim()} | ||
</types>`; | ||
return ["<types>", ` ${(await G(d)).trim()}`, "</types>"].join(C); | ||
} | ||
@@ -1993,8 +1964,8 @@ ;var Fc = async() => { | ||
*/ | ||
if (pa) { | ||
if (q.help) { | ||
const a = ia(); | ||
console.log(ra({usage:a, description:"Embeds and maintains Closure-compatible types JSDoc in\nJavaScript source code from an external types.xml file.", line:"typal source [--closure|externs] [--migrate] [-o output] [-hv]", example:"typal src/index.js -c"})); | ||
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 { | ||
qa && (console.log(require("../../package.json").version), process.exit()); | ||
pa && (console.log(require("../../package.json").version), process.exit()); | ||
} | ||
@@ -2001,0 +1972,0 @@ (async() => { |
@@ -18,3 +18,3 @@ #!/usr/bin/env node | ||
} | ||
return globalThis; | ||
throw Error("Cannot find global object"); | ||
} | ||
@@ -27,5 +27,5 @@ var y = x(this); | ||
for (var c = 0; c < a.length - 1; c++) { | ||
var e = a[c]; | ||
e in d || (d[e] = {}); | ||
d = d[e]; | ||
var f = a[c]; | ||
f in d || (d[f] = {}); | ||
d = d[f]; | ||
} | ||
@@ -44,27 +44,27 @@ a = a[a.length - 1]; | ||
}); | ||
const B = os.EOL, C = os.homedir; | ||
function D(a, b, d) { | ||
const B = os.EOL; | ||
function C(a, b, d) { | ||
const c = []; | ||
b.replace(a, (e, ...g) => { | ||
e = g.slice(0, g.length - 2).reduce((f, k, h) => { | ||
b.replace(a, (f, ...g) => { | ||
f = g.slice(0, g.length - 2).reduce((e, k, h) => { | ||
h = d[h]; | ||
if (!h || void 0 === k) { | ||
return f; | ||
return e; | ||
} | ||
f[h] = k; | ||
return f; | ||
e[h] = k; | ||
return e; | ||
}, {}); | ||
c.push(e); | ||
c.push(f); | ||
}); | ||
return c; | ||
} | ||
;const E = new RegExp(`${/([^\s>=/]+)/.source}(?:\\s*=\\s*${/(?:"([\s\S]*?)"|'([\s\S]*?)')/.source})?`, "g"), F = new RegExp(`(?:\\s+((?:${E.source}\\s*)*))`); | ||
;const D = new RegExp(`${/([^\s>=/]+)/.source}(?:\\s*=\\s*${/(?:"([\s\S]*?)"|'([\s\S]*?)')/.source})?`, "g"), E = new RegExp(`(?:\\s+((?:${D.source}\\s*)*))`); | ||
const G = (a, b) => { | ||
a = (Array.isArray(a) ? a : [a]).join("|"); | ||
return D(new RegExp(`<(${a})${F.source}?(?:${/\s*\/>/.source}|${/>([\s\S]+?)?<\/\1>/.source})`, "g"), b, "t a v v1 v2 c".split(" ")).map(({t:d, a:c = "", c:e = ""}) => { | ||
return C(new RegExp(`<(${a})${E.source}?(?:${/\s*\/>/.source}|${/>([\s\S]+?)?<\/\1>/.source})`, "g"), b, "t a v v1 v2 c".split(" ")).map(({t:d, a:c = "", c:f = ""}) => { | ||
c = c.replace(/\/$/, "").trim(); | ||
c = aa(c); | ||
return {content:e, props:c, tag:d}; | ||
c = F(c); | ||
return {content:f, props:c, tag:d}; | ||
}); | ||
}, aa = a => D(E, a, ["key", "val", "def", "f"]).reduce((b, {key:d, val:c}) => { | ||
}, F = a => C(D, a, ["key", "val", "def", "f"]).reduce((b, {key:d, val:c}) => { | ||
if (void 0 === c) { | ||
@@ -76,3 +76,3 @@ return b[d] = !0, b; | ||
}, {}); | ||
const ba = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => { | ||
const aa = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => { | ||
switch(b) { | ||
@@ -94,12 +94,12 @@ case "function": | ||
}); | ||
function ca(a) { | ||
function ba(a) { | ||
let b = 0; | ||
const d = (e = 1) => a[b + e], c = (e = !0, g = []) => { | ||
var f = {}; | ||
const d = (f = 1) => a[b + f], c = (f = !0, g = []) => { | ||
var e = {}; | ||
let k = a[b]; | ||
if (["nullable", "nonNullable"].includes(k)) { | ||
if (!e) { | ||
if (!f) { | ||
throw Error(`${k} not allowed after .`); | ||
} | ||
f.nullable = "nullable" === k; | ||
e.nullable = "nullable" === k; | ||
b++; | ||
@@ -110,3 +110,3 @@ } | ||
b++; | ||
f = {...c(!0, []), ...f}; | ||
e = {...c(!0, []), ...e}; | ||
if (")" != a[b]) { | ||
@@ -117,3 +117,3 @@ throw Error("Expecting closing )"); | ||
if ("|" != a[b]) { | ||
return f; | ||
return e; | ||
} | ||
@@ -123,7 +123,7 @@ } else { | ||
b++; | ||
g = f; | ||
for (e = {}; "}" != a[b];) { | ||
g = e; | ||
for (f = {}; "}" != a[b];) { | ||
var h = a[b]; | ||
b++; | ||
e[h] = null; | ||
f[h] = null; | ||
if (":" == a[b]) { | ||
@@ -133,3 +133,3 @@ b++; | ||
var l = c(); | ||
e[h] = l; | ||
f[h] = l; | ||
} catch (m) { | ||
@@ -148,4 +148,4 @@ throw m.message += `(when parsing ${h} property)`, m; | ||
} | ||
g.record = e; | ||
return f; | ||
g.record = f; | ||
return e; | ||
} | ||
@@ -159,5 +159,5 @@ } | ||
} | ||
"|" != a[b] && (f.name = a[b], b++); | ||
"|" != a[b] && (e.name = a[b], b++); | ||
if ("function" == k) { | ||
l = f; | ||
l = e; | ||
h = {return:null, args:[]}; | ||
@@ -222,3 +222,3 @@ if ("(" != a[b]) { | ||
h && b++; | ||
l = f; | ||
l = e; | ||
for (h = []; ">" != a[b];) { | ||
@@ -241,3 +241,3 @@ n = c(); | ||
for (; "." == a[b];) { | ||
f.name += "."; | ||
e.name += "."; | ||
b++; | ||
@@ -248,9 +248,9 @@ ({name:l} = c(!1)); | ||
} | ||
f.name += l; | ||
e.name += l; | ||
} | ||
if ("|" != a[b] || !e) { | ||
return f; | ||
if ("|" != a[b] || !f) { | ||
return e; | ||
} | ||
for (g.push(f); "|" == a[b];) { | ||
b++, f = c(!0, g), f.union !== g && g.push(f); | ||
for (g.push(e); "|" == a[b];) { | ||
b++, e = c(!0, g), e.union !== g && g.push(e); | ||
} | ||
@@ -262,30 +262,21 @@ return {union:g}; | ||
;function H(a) { | ||
a = ba(a); | ||
return ca(a); | ||
a = aa(a); | ||
return ba(a); | ||
} | ||
;const da = path.dirname, ea = path.resolve; | ||
const I = ({A:a, C:b, l:d, type:c}) => b ? "string" : a ? "number" : d ? "boolean" : c ? c : "*", J = a => { | ||
;const ca = path.dirname, da = path.resolve; | ||
const I = ({A:a, C:b, l:d, type:c}) => b ? "string" : a ? "number" : d ? "boolean" : c ? c : "*", ea = a => { | ||
const b = a.split(/\r?\n/).map(d => { | ||
let c = Infinity; | ||
d.replace(/\S/, (f, g) => { | ||
c = g; | ||
}); | ||
return c; | ||
}).reduce((d, c) => c < d ? c : d, Infinity); | ||
return a.replace(new RegExp(`^ {${b}}`, "gm"), ""); | ||
}, J = a => { | ||
a = a.trimRight(); | ||
var b = /\S/.exec(a); | ||
if (!b) { | ||
return a; | ||
} | ||
b = b.index; | ||
if (0 == b) { | ||
return a; | ||
} | ||
var d = a.substr(0, b).lastIndexOf(B); | ||
-1 == d ? d = 0 : (d++, a = a.substr(d)); | ||
b -= d; | ||
const c = " ".repeat(b); | ||
d = a.split(B); | ||
if (d.filter(e => /\S/.test(e)).find(e => !e.startsWith(c))) { | ||
return a.trim(); | ||
} | ||
{ | ||
const e = new RegExp(`^ {${b}}`); | ||
return d.map(g => g.replace(e, "")).join(B); | ||
} | ||
a = a.replace(/^\s*\r?\n( *\S)/, "$1"); | ||
return ea(a); | ||
}, K = (a, b, d = null) => { | ||
const {async:c, "void":e, "return":g = e ? "void" : "", ...f} = a; | ||
const {async:c, "void":f, "return":g = f ? "void" : "", ...e} = a; | ||
({args:a = ""} = a); | ||
@@ -295,11 +286,11 @@ a || (a = b.map(({s:k, name:h}) => "this" == h ? `${h}: ${k}` : h.startsWith("...") ? `...${k}` : k).join(",")); | ||
c && b ? b = `!Promise<${b}>` : c && (b = "!Promise"); | ||
d = `function(${"constructor" == f.name ? `new: ${d}, ` : ""}${a})`; | ||
d = `function(${"constructor" == e.name ? `new: ${d}, ` : ""}${a})`; | ||
b && (d += `: ${b}`); | ||
return {F:{...f, async:c, return:b}, o:d}; | ||
return {F:{...e, async:c, return:b}, o:d}; | ||
}; | ||
function L(a, b) { | ||
const d = a.example; | ||
d && d.startsWith(".") && b && (a.example = ea(da(b), d)); | ||
d && d.startsWith(".") && b && (a.example = da(ca(b), d)); | ||
} | ||
;function fa(a, b, {name:d, string:c, "boolean":e, opt:g, number:f, type:k}, h) { | ||
;function fa(a, b, {name:d, string:c, "boolean":f, opt:g, number:e, type:k}, h) { | ||
if (!d) { | ||
@@ -310,3 +301,3 @@ throw Error("Argument does not have a name."); | ||
b && (a.description = J(b)); | ||
b = I({A:f, C:c, l:e, type:k}); | ||
b = I({A:e, C:c, l:f, type:k}); | ||
h && (b = b.replace(new RegExp(`([!?])?${h}\\.`, "g"), "$1")); | ||
@@ -330,9 +321,9 @@ b.endsWith("=") && (b = b.replace(/=$/, ""), g = !0); | ||
let d = a.lastIndexOf("</arg>"), c = a; | ||
var e = []; | ||
-1 != d && (d += 6, e = a.slice(0, d), c = a.slice(d), e = G("arg", e), e = e.map(({content:g, props:f}) => { | ||
var f = []; | ||
-1 != d && (d += 6, f = a.slice(0, d), c = a.slice(d), f = G("arg", f), f = f.map(({content:g, props:e}) => { | ||
const k = new ha; | ||
fa(k, g, f, b); | ||
fa(k, g, e, b); | ||
return k; | ||
})); | ||
return {w:c, j:e}; | ||
return {w:c, j:f}; | ||
}; | ||
@@ -350,12 +341,12 @@ const ia = fs.readFileSync; | ||
return a.split(/\s*,\s*/).map(c => { | ||
let e = c = ia(c, "utf8"); | ||
let f = c = ia(c, "utf8"); | ||
if (c = /\/\* start example \*\/\r?\n([\s\S]+?)\r?\n\s*\/\* end example \*\//.exec(c)) { | ||
[, c] = c, e = ja(c); | ||
[, c] = c, f = ja(c); | ||
} | ||
d.forEach(g => { | ||
const [f, k] = g.split(/\s*=>\s*/); | ||
e = e.replace(`'${f}'`, `'${k}'`); | ||
e = e.replace(`"${f}"`, `"${k}"`); | ||
const [e, k] = g.split(/\s*=>\s*/); | ||
f = f.replace(`'${e}'`, `'${k}'`); | ||
f = f.replace(`"${e}"`, `"${k}"`); | ||
}); | ||
return e = e.replace(/@/g, "\uff20"); | ||
return f = f.replace(/@/g, "\uff20"); | ||
}); | ||
@@ -383,5 +374,5 @@ } | ||
} | ||
let {function:{new:b, args:d, return:c, this:e, variableArgs:g}} = this.parsed; | ||
let {function:{new:b, args:d, return:c, this:f, variableArgs:g}} = this.parsed; | ||
b && (c = b); | ||
var f = d.map(h => a(h)).map((h, l) => { | ||
var e = d.map(h => a(h)).map((h, l) => { | ||
const {optional:n} = d[l]; | ||
@@ -391,5 +382,5 @@ let {name:m = `arg${l}`, optional:p = n} = this.D[l] || {}; | ||
}); | ||
if (e) { | ||
var k = a(e); | ||
f.unshift(`this: ${k}`); | ||
if (f) { | ||
var k = a(f); | ||
e.unshift(`this: ${k}`); | ||
} | ||
@@ -403,9 +394,9 @@ if (g) { | ||
} | ||
f.push(`${h}: ${k}[]`); | ||
e.push(`${h}: ${k}[]`); | ||
} | ||
f = f.join(", "); | ||
e = e.join(", "); | ||
k = c ? a(c) : "?"; | ||
f = `(${f}) => ${k}`; | ||
b && (f = "new " + f); | ||
return f; | ||
e = `(${e}) => ${k}`; | ||
b && (e = "new " + e); | ||
return e; | ||
} | ||
@@ -418,3 +409,3 @@ get static() { | ||
} | ||
b(a, {name:b, string:d, "boolean":c, opt:e, number:g, type:f, "default":k, closure:h, alias:l, aliases:n, example:m, "example-override":p = "", noParams:q, "static":r, initial:t}) { | ||
b(a, {name:b, string:d, "boolean":c, opt:f, number:g, type:e, "default":k, closure:h, alias:l, aliases:n, example:m, "example-override":p = "", noParams:q, "static":r, initial:t}) { | ||
if (!b) { | ||
@@ -425,3 +416,3 @@ throw Error("Property does not have a name."); | ||
a && (this.description = J(a)); | ||
a = I({A:g, C:d, l:c, type:f}); | ||
a = I({A:g, C:d, l:c, type:e}); | ||
q && (this.v = q); | ||
@@ -431,3 +422,3 @@ h && (this.f = h); | ||
void 0 !== k ? this.default = k : void 0 !== t && (this.default = t); | ||
if (e || void 0 !== k) { | ||
if (f || void 0 !== k) { | ||
this.optional = !0; | ||
@@ -477,3 +468,3 @@ } | ||
;function ka(a, b, d, c) { | ||
var e = G("prop", a).map(({content:h, props:l}) => { | ||
var f = G("prop", a).map(({content:h, props:l}) => { | ||
const n = new P; | ||
@@ -495,8 +486,8 @@ L(l, d); | ||
}); | ||
e = [...e, ...a]; | ||
const {m:g, B:f, n:k} = e.reduce((h, l) => { | ||
f = [...f, ...a]; | ||
const {m:g, B:e, n:k} = f.reduce((h, l) => { | ||
l.isConstructor ? h.m.push(l) : l.static ? h.B.push(l) : h.n.push(l); | ||
return h; | ||
}, {m:[], B:[], n:[]}); | ||
return {constructor:g[0] || null, properties:[...g, ...f, ...k]}; | ||
return {constructor:g[0] || null, properties:[...g, ...e, ...k]}; | ||
} | ||
@@ -510,4 +501,4 @@ ;const S = (a, b, d = {}) => { | ||
(c = H(b)) || console.log("Could not parse %s", b); | ||
} catch (e) { | ||
console.log("Could not parse %s", b), console.error(e.message); | ||
} catch (f) { | ||
console.log("Could not parse %s", b), console.error(f.message); | ||
} | ||
@@ -521,32 +512,32 @@ } | ||
var {escapePipe:c = !0} = d; | ||
let e = ""; | ||
let f = ""; | ||
var g = ""; | ||
a.nullable ? g = "?" : !1 === a.nullable && (g = "!"); | ||
if (a.function) { | ||
e = e + g + (a.name + "("); | ||
const f = []; | ||
a.function.this && (c = "this: " + R(a.function.this, b, d), f.push(c)); | ||
a.function.new && (c = "new: " + R(a.function.new, b, d), f.push(c)); | ||
f = f + g + (a.name + "("); | ||
const e = []; | ||
a.function.this && (c = "this: " + R(a.function.this, b, d), e.push(c)); | ||
a.function.new && (c = "new: " + R(a.function.new, b, d), e.push(c)); | ||
a.function.args.forEach(k => { | ||
let h = R(k, b, d); | ||
k.optional && (h += "="); | ||
f.push(h); | ||
e.push(h); | ||
}); | ||
a.function.variableArgs && (c = "..." + R(a.function.variableArgs, b, d), f.push(c)); | ||
c = f.join(", "); | ||
e += c + ")"; | ||
a.function.return && (e += ": " + R(a.function.return, b, d)); | ||
a.function.variableArgs && (c = "..." + R(a.function.variableArgs, b, d), e.push(c)); | ||
c = e.join(", "); | ||
f += c + ")"; | ||
a.function.return && (f += ": " + R(a.function.return, b, d)); | ||
} else { | ||
a.record ? (e += "{ ", c = Object.keys(a.record).map(f => { | ||
var k = a.record[f]; | ||
a.record ? (f += "{ ", c = Object.keys(a.record).map(e => { | ||
var k = a.record[e]; | ||
if (!k) { | ||
return f; | ||
return e; | ||
} | ||
k = R(k, b, d); | ||
return `${f}: ${k}`; | ||
}), e += c.join(", "), e += " }") : a.application ? (e += T(a.name, b, g, d) + "<", c = a.application.map(f => R(f, b, d)), e += c.join(", "), e += ">") : a.union ? (e = e + g + "(", g = a.union.map(f => R(f, b, d)), e += g.join(c ? " \\| " : " | "), e += ")") : e += T("any" == a.name ? "*" : a.name, b, g, d); | ||
return `${e}: ${k}`; | ||
}), f += c.join(", "), f += " }") : a.application ? (f += T(a.name, b, g, d) + "<", c = a.application.map(e => R(e, b, d)), f += c.join(", "), f += ">") : a.union ? (f = f + g + "(", g = a.union.map(e => R(e, b, d)), f += g.join(c ? " \\| " : " | "), f += ")") : f += T("any" == a.name ? "*" : a.name, b, g, d); | ||
} | ||
return e; | ||
return f; | ||
}, T = (a, b, d = "", c = {}) => { | ||
const {flatten:e = !1, nameProcess:g, link:f = ({link:l}) => `#${l}`} = c; | ||
const {flatten:f = !1, nameProcess:g, link:e = ({link:l}) => `#${l}`} = c; | ||
c = la(b, a); | ||
@@ -558,4 +549,4 @@ d = `${d}${a}`; | ||
let {link:k, type:{description:h}} = c; | ||
e && ((b = b.find(({fullName:l}) => l == a)) && b.link && (k = b.link), !h && b.description && (h = b.description), "function" == typeof e && e(a)); | ||
c.link == k && (k = f(c)); | ||
f && ((b = b.find(({fullName:l}) => l == a)) && b.link && (k = b.link), !h && b.description && (h = b.description), "function" == typeof f && f(a)); | ||
c.link == k && (k = e(c)); | ||
b = g ? g(d) : d; | ||
@@ -572,7 +563,7 @@ return h ? `<a href="${k}" title="${h.replace(/"/g, """)}">${b}</a>` : `[${b}](${k})`; | ||
function ma(a, b = [], d = [], c = {}) { | ||
const {narrow:e = !1, preprocessDesc:g} = c; | ||
const {narrow:f = !1, preprocessDesc:g} = c; | ||
if (!b.length) { | ||
return ""; | ||
} | ||
const f = a.isConstructor || a.isInterface, k = b.some(({hasDefault:m}) => m), h = {escapePipe:!e, ...c}; | ||
const e = a.isConstructor || a.isInterface, k = b.some(({hasDefault:m}) => m), h = {escapePipe:!f, ...c}; | ||
let l; | ||
@@ -583,15 +574,11 @@ const n = m => S(d, m, {...h, nameProcess:c.nameProcess ? p => c.nameProcess(p, l) : void 0}); | ||
p = m.args && m.isParsedFunction ? m.toTypeScriptFunction(n) : n(m.parsed || m.type); | ||
const q = f || m.optional ? m.name : `${m.name}*`, r = m.hasDefault ? `\`${m.default}\`` : "-", t = g ? g(m.description) : m.description; | ||
return {prop:m, typeName:p, name:q, de:na(t, !e), d:r, G:l}; | ||
const q = e || m.optional ? m.name : `${m.name}*`, r = m.hasDefault ? `\`${m.default}\`` : "-", t = g ? g(m.description) : m.description; | ||
return {prop:m, typeName:p, name:q, de:na(t, !f), d:r, G:l}; | ||
}); | ||
if (e) { | ||
return {props:a, anyHaveDefault:k, constr:f}; | ||
if (f) { | ||
return {props:a, anyHaveDefault:k, constr:e}; | ||
} | ||
a = a.map(({name:m, typeName:p, de:q, d:r, prop:t}) => [t.optional ? m : `__${m}__`, `<em>${p}</em>`, q, ...k ? [r] : []]); | ||
b = ["Name", ...e ? ["Type & Description"] : ["Type", "Description"], ...k ? [f ? "Initial" : "Default"] : []]; | ||
return ` | ||
\`\`\`table | ||
${JSON.stringify([b, ...a], null, 2)} | ||
\`\`\``; | ||
b = ["Name", ...f ? ["Type & Description"] : ["Type", "Description"], ...k ? [e ? "Initial" : "Default"] : []]; | ||
return ["", "", "```table", JSON.stringify([b, ...a], null, 2).replace(/\n/g, B), "```"].join(B); | ||
} | ||
@@ -601,10 +588,10 @@ const na = (a = "", b = !0) => { | ||
b && (a = a.replace(/\|/g, "\\|")); | ||
return a.replace(/</g, "<").replace(/>/, ">"); | ||
return a.replace(/</g, "<").replace(/>/g, ">"); | ||
}; | ||
const oa = (a, b, d = {}) => { | ||
function c(e) { | ||
e.replace(/^!?/, ""); | ||
return `\`${e}\``; | ||
function c(f) { | ||
f.replace(/^!?/, ""); | ||
return `\`${f}\``; | ||
} | ||
return a.split(/,\s*/).map(e => S(b, e, {flatten:!0, ...d, nameProcess:d.nameProcess ? g => { | ||
return a.split(/,\s*/).map(f => S(b, f, {flatten:!0, ...d, nameProcess:d.nameProcess ? g => { | ||
g = d.nameProcess(g); | ||
@@ -630,3 +617,3 @@ return /[_*~>]/.test(g) ? `<code>${g}</code>` : c(g); | ||
} | ||
b(a, {name:b, type:d, desc:c, noToc:e, spread:g, noExpand:f, link:k, closure:h, constructor:l, "extends":n, "interface":m, record:p, example:q, "example-override":r}, t, z = null) { | ||
b(a, {name:b, type:d, desc:c, noToc:f, spread:g, noExpand:e, link:k, closure:h, constructor:l, "extends":n, "interface":m, record:p, example:q, "example-override":r}, t, z = null) { | ||
if (!b) { | ||
@@ -639,5 +626,5 @@ throw Error("Type does not have a name."); | ||
c && (this.description = J(c)); | ||
this.noToc = !!e; | ||
this.noToc = !!f; | ||
this.spread = !!g; | ||
this.noExpand = !!f; | ||
this.noExpand = !!e; | ||
k && (this.link = k); | ||
@@ -671,9 +658,9 @@ !0 === l && (this.isConstructor = l); | ||
toMarkdown(a = [], b = {}) { | ||
const {flatten:d, details:c = []} = b, e = c.includes(this.name); | ||
var g = this.type ? `\`${this.type}\`` : "", f = g; | ||
this.link ? f = `[${g}](${this.link})` : !this.import && this.type && (f = S(a, this.type, b), g = f != this.type, f = V(f, g)); | ||
const {flatten:d, details:c = []} = b, f = c.includes(this.name); | ||
var g = this.type ? `\`${this.type}\`` : "", e = g; | ||
this.link ? e = `[${g}](${this.link})` : !this.import && this.type && (e = S(a, this.type, b), g = e != this.type, e = V(e, g)); | ||
g = V(this.fullName); | ||
g = this.import ? `[${g}](l-type)` : this.noToc ? `[${g}](l-type)` : `[${g}](t-type)`; | ||
const k = this.description ? `: ${this.description}` : ""; | ||
f = f ? `${f} ` : ""; | ||
e = e ? `${e} ` : ""; | ||
let h = /_/.test(g); | ||
@@ -683,10 +670,10 @@ if (this.extends) { | ||
h = h || /_/.test(l); | ||
f = (h ? f + "<strong>" : f + "__") + (g + n); | ||
e = (h ? e + "<strong>" : e + "__") + (g + n); | ||
"function" == typeof d && d(this.extends); | ||
} else { | ||
f = (h ? f + "<strong>" : f + "__") + g; | ||
e = (h ? e + "<strong>" : e + "__") + g; | ||
} | ||
f = (h ? f + "</strong>" : f + "__") + k; | ||
e = (h ? e + "</strong>" : e + "__") + k; | ||
a = ma(this, this.properties, a, b); | ||
return {LINE:f, table:a, displayInDetails:e}; | ||
return {LINE:e, table:a, displayInDetails:f}; | ||
} | ||
@@ -704,5 +691,5 @@ } | ||
} | ||
b(a, {async:b, "return":d, ...c}, ...e) { | ||
b(a, {async:b, "return":d, ...c}, ...f) { | ||
this.description = J(a); | ||
super.b("", c, ...e); | ||
super.b("", c, ...f); | ||
d && (this.g = d.replace(/\r?\n\s*/g, " ")); | ||
@@ -727,3 +714,3 @@ b && (this.async = !0); | ||
} | ||
b(a, {from:b, name:d, ...c}, e, g) { | ||
b(a, {from:b, name:d, ...c}, f, g) { | ||
if (!b) { | ||
@@ -734,7 +721,6 @@ throw Error("From attribute of import is not given."); | ||
this.description = J(a); | ||
super.b("", {...c, noToc:!0, name:d, type:`import('${b}').${d}`}, e != g ? e : null); | ||
super.b("", {...c, noToc:!0, name:d, type:`import('${b}').${d}`}, f != g ? f : null); | ||
} | ||
} | ||
;C(); | ||
const qa = (a, b) => { | ||
;const qa = (a, b) => { | ||
const d = new RegExp(`([!?])?${a}\\.`, "g"); | ||
@@ -747,5 +733,5 @@ b.properties.forEach(c => { | ||
var {args:d = []} = a, c = d.map(({s:g}) => g).join(", "); | ||
let e = `new: ${a.fullName}`; | ||
c.length && (e = `${e}, `); | ||
c = `function(${e}${c})`; | ||
let f = `new: ${a.fullName}`; | ||
c.length && (f = `${f}, `); | ||
c = `function(${f}${c})`; | ||
d = new Q(d); | ||
@@ -757,5 +743,5 @@ d.isConstructor = !0; | ||
a.properties.unshift(d); | ||
}, Y = (a, b, d, c, e = !1, g = null) => { | ||
const f = e ? new W : new U; | ||
f.f = g; | ||
}, Y = (a, b, d, c, f = !1, g = null) => { | ||
const e = f ? new W : new U; | ||
e.f = g; | ||
g = a.search(/<(prop|function|fn|static) /); | ||
@@ -765,17 +751,17 @@ let k = "", h = a; | ||
const {j:l, w:n} = M(k, c); | ||
f.b(e ? n : h, b, d, c); | ||
e.b(f ? n : h, b, d, c); | ||
({o:a} = K(b, l)); | ||
e && (f.closureType = a); | ||
f.args || (f.args = l); | ||
return f; | ||
}, Z = ({content:a, props:b, ns:d, i:c, isMethod:e = !1, location:g = null}) => { | ||
const f = [], {alias:k, aliases:h, ...l} = b; | ||
b = Y(a, b, d, c, e, g); | ||
f.push(b); | ||
f && (e.closureType = a); | ||
e.args || (e.args = l); | ||
return e; | ||
}, Z = ({content:a, props:b, ns:d, i:c, isMethod:f = !1, location:g = null}) => { | ||
const e = [], {alias:k, aliases:h, ...l} = b; | ||
b = Y(a, b, d, c, f, g); | ||
e.push(b); | ||
(k ? [k] : h ? h.split(/, */) : []).forEach(n => { | ||
n = Y(a, {...l, name:n}, d, c, e, g); | ||
n = Y(a, {...l, name:n}, d, c, f, g); | ||
n.description = `${n.description}${n.description ? " " : ""}Alias of \`${l.name}\`.`; | ||
f.push(n); | ||
e.push(n); | ||
}); | ||
return f; | ||
return e; | ||
}; | ||
@@ -807,3 +793,3 @@ /* | ||
} | ||
const [{content:c, props:{namespace:e, ns:g = e}}] = a, f = b == g ? void 0 : g; | ||
const [{content:c, props:{namespace:f, ns:g = f}}] = a, e = b == g ? void 0 : g; | ||
a = G(["embed"], c).map(({props:l}) => l); | ||
@@ -819,3 +805,3 @@ const k = [], h = G("type interface constructor method import record".split(" "), c).reduce((l, {content:n, props:m, tag:p}) => { | ||
d && (p.f = d); | ||
p.b(n, m, f, b); | ||
p.b(n, m, e, b); | ||
l.push(p); | ||
@@ -825,3 +811,3 @@ z.forEach(u => { | ||
d && (v.f = d); | ||
v.b(n, {...t, name:u}, f, b); | ||
v.b(n, {...t, name:u}, e, b); | ||
l.push(v); | ||
@@ -831,3 +817,3 @@ }); | ||
case "interface": | ||
m = Z({content:n, props:m, ns:f, i:b, location:d}); | ||
m = Z({content:n, props:m, ns:e, i:b, location:d}); | ||
m.forEach(u => { | ||
@@ -840,3 +826,3 @@ u.properties.some(({isConstructor:v}) => v) || X(u, b); | ||
case "constructor": | ||
m = Z({content:n, props:m, ns:f, i:b, location:d}); | ||
m = Z({content:n, props:m, ns:e, i:b, location:d}); | ||
m.forEach(u => { | ||
@@ -849,3 +835,3 @@ u.properties.some(({isConstructor:v}) => v) || X(u, b); | ||
case "method": | ||
m = Z({content:n, props:m, ns:f, i:b, isMethod:!0, location:d}); | ||
m = Z({content:n, props:m, ns:e, i:b, isMethod:!0, location:d}); | ||
l.push(...m); | ||
@@ -852,0 +838,0 @@ break; |
{ | ||
"name": "typal", | ||
"version": "1.26.2", | ||
"version": "1.27.0", | ||
"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.", | ||
@@ -8,30 +8,3 @@ "main": "compile/index.js", | ||
"scripts": { | ||
"t": "zoroaster -a", | ||
"test": "yarn t test/spec test/mask", | ||
"spec": "yarn t test/spec", | ||
"mask": "yarn t test/mask", | ||
"test-compile": "ALAMODE_ENV=test-compile yarn test", | ||
"test-watch": "yarn test -w", | ||
"lint": "eslint .", | ||
"dev": "alanode src/bin/typal", | ||
"doc": "doc -o README.md -d", | ||
"wiki": "DEPACK_MAX_COLUMNS=80 doc wiki -W wiki.git -n _typal -d", | ||
"compile": "depack src/bin/typal -c -o compile/bin -a -p -s --externs types/externs.js", | ||
"lib": "depack src/depack -c -o compile/typal.js -a -p -s --source_map_include_content", | ||
"c": "yarn-s compile compile-lib", | ||
"template": "yarn dev compile/template.js -T compile/index.js -t types/API.xml", | ||
"depack1": "depack depack/t.js -c -o t/tt.js -a -p", | ||
"depack2": "depack depack/prop/index.js -c -a -p", | ||
"depack-compat": "depack example/restream/compat -c -a -p", | ||
"compat": "yarn dev example/restream/compat.js -c", | ||
"d": "yarn-s d1 externs", | ||
"d1": "yarn dev types/index.js", | ||
"build": "yarn-s d b doc", | ||
"e": "alanode", | ||
"example/": "yarn e example/example.js", | ||
"splendid": "splendid-dev", | ||
"web": "splendid-dev -s", | ||
"typal": "depack/bin/typal.js", | ||
"externs": "yarn dev types/externs.js", | ||
"args": "argufy types/arguments.xml -o src/bin/get-args.js" | ||
"scripts": "scripts" | ||
}, | ||
@@ -49,6 +22,3 @@ "bin": { | ||
"externs": "types/externs.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/artdecocode/typal.git" | ||
}, | ||
"repository": "gitlab:artdeco/typal", | ||
"keywords": [ | ||
@@ -70,7 +40,9 @@ "typal", | ||
"bugs": { | ||
"url": "https://github.com/artdecocode/typal/issues" | ||
"url": "https://gitlab.com/artdeco/issues/-/issues/", | ||
"email": "incoming+artdeco-issues-17934443-issue-@incoming.gitlab.com" | ||
}, | ||
"homepage": "https://www.artd.eco", | ||
"devDependencies": { | ||
"@artdeco/clean-stack": "^1.1.1", | ||
"@artdeco/clean-stack": "^1.2.1", | ||
"@artdeco/scripts.json": "^1.0.1", | ||
"@typedefs/parser": "^1.3.4", | ||
@@ -80,10 +52,10 @@ "@wrote/read": "^1.0.4", | ||
"@wrote/write": "^1.0.4", | ||
"@zoroaster/mask": "^2.4.0", | ||
"alamode": "^3.3.2", | ||
"@zoroaster/mask": "^2.7.2", | ||
"alamode": "^3.7.1", | ||
"argufy": "^1.7.5", | ||
"catchment": "^3.3.0", | ||
"depack": "^1.1.0", | ||
"documentary": "^1.35.10", | ||
"depack": "^1.1.2", | ||
"documentary": "^1.38.1", | ||
"erotic": "^2.1.1", | ||
"erte": "^1.2.0", | ||
"erte": "^1.3.0", | ||
"eslint-config-artdeco": "1.0.1", | ||
@@ -94,6 +66,6 @@ "makepromise": "^3.2.0", | ||
"rexml": "^2.2.2", | ||
"temp-context": "^2.1.3", | ||
"temp-context": "^2.2.0", | ||
"usually": "^1.2.0", | ||
"yarn-s": "1.2.3", | ||
"zoroaster": "^4.2.0" | ||
"zoroaster": "^4.4.0" | ||
}, | ||
@@ -105,3 +77,6 @@ "srcDependencies": { | ||
"rexml": "^2.2.2" | ||
}, | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.com" | ||
} | ||
} |
@@ -0,4 +1,10 @@ | ||
<div align="center"> | ||
# Typal | ||
[![npm version](https://badge.fury.io/js/typal.svg)](https://www.npmjs.com/package/typal) | ||
<a href="https://gitlab.com/artdeco/typal/-/commits/master"> | ||
<img src="https://gitlab.com/artdeco/typal/badges/master/pipeline.svg" alt="Pipeline Badge"> | ||
</a> | ||
</div> | ||
@@ -11,7 +17,8 @@ `typal` Keeps Types In XML files And Converts Them To (1) JavaScript JSDoc, (2) Closure Externs and (3) Markdown Documentation. It is the alternative to TypeScript definitions and utilises the power of JSDoc for excellent developer experience, documentation readability and compiler annotation. It also makes integration between _Google Closure Compiler_ and _VSCode_ easy, using the JSDoc notations that are understood by both at the same time. | ||
yarn add -D typal | ||
npm i typal --save-dev | ||
``` | ||
<p align="center"><a href="#table-of-contents"> | ||
<div align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/0.svg?sanitize=true"> | ||
</a></p> | ||
</a></div> | ||
@@ -35,7 +42,7 @@ ## Table Of Contents | ||
* [`Example`](#type-example) | ||
- [Copyright](#copyright) | ||
- [Copyright & License](#copyright--license) | ||
<p align="center"><a href="#table-of-contents"> | ||
<div align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/1.svg?sanitize=true"> | ||
</a></p> | ||
</a></div> | ||
@@ -56,7 +63,7 @@ ## Purpose | ||
<kbd>🥇🥈🥉[Naïve, JSDoc And Closure Use Cases For Typedefs](../../wiki/3-use-cases)</kbd> | ||
<kbd>🥇🥈🥉[Naïve, JSDoc And Closure Use Cases For Typedefs](https://github.com/artdecocode/typal/wiki/3-Use-Cases)</kbd> | ||
<p align="center"><a href="#table-of-contents"> | ||
<div align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/2.svg?sanitize=true"> | ||
</a></p> | ||
</a></div> | ||
@@ -141,5 +148,5 @@ ## CLI | ||
<p align="center"><a href="#table-of-contents"> | ||
<div align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/3.svg?sanitize=true" width="25"> | ||
</a></p> | ||
</a></div> | ||
@@ -232,5 +239,5 @@ ### _Typal_ Arguments | ||
<p align="center"><a href="#table-of-contents"> | ||
<div align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/4.svg?sanitize=true" width="25"> | ||
</a></p> | ||
</a></div> | ||
@@ -288,5 +295,5 @@ ### Missing Types Warnings | ||
<p align="center"><a href="#table-of-contents"> | ||
<div align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/5.svg?sanitize=true" width="25"> | ||
</a></p> | ||
</a></div> | ||
@@ -368,5 +375,5 @@ ### Keeping Types In Separate File | ||
<p align="center"><a href="#table-of-contents"> | ||
<div align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/6.svg?sanitize=true" width="25"> | ||
</a></p> | ||
</a></div> | ||
@@ -440,5 +447,5 @@ ### Migration | ||
<p align="center"><a href="#table-of-contents"> | ||
<div align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/7.svg?sanitize=true"> | ||
</a></p> | ||
</a></div> | ||
@@ -449,3 +456,3 @@ ## Schema | ||
<kbd>📝 [Typal Schema](../../wiki/Schema)</kbd> | ||
<kbd>📝 [Typal Schema](https://github.com/artdecocode/typal/wiki/Schema)</kbd> | ||
@@ -470,5 +477,5 @@ ```xml | ||
<p align="center"><a href="#table-of-contents"> | ||
<div align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/8.svg?sanitize=true"> | ||
</a></p> | ||
</a></div> | ||
@@ -563,29 +570,25 @@ ## Markdown Documentation | ||
<p align="center"><a href="#table-of-contents"> | ||
<div align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/9.svg?sanitize=true"> | ||
</a></p> | ||
</a></div> | ||
## Copyright | ||
## Copyright & License | ||
GNU Affero General Public License v3.0 | ||
<table> | ||
<tr> | ||
<th> | ||
<a href="https://artd.eco"> | ||
<img width="100" src="https://raw.githubusercontent.com/wrote/wrote/master/images/artdeco.png" | ||
<a href="https://www.artd.eco"> | ||
<img width="100" src="https://gitlab.com/uploads/-/system/group/avatar/7454762/artdeco.png" | ||
alt="Art Deco"> | ||
</a> | ||
</th> | ||
<th>© <a href="https://artd.eco">Art Deco</a> 2019</th> | ||
<th> | ||
<a href="https://www.technation.sucks" title="Tech Nation Visa"> | ||
<img width="100" src="https://raw.githubusercontent.com/idiocc/cookies/master/wiki/arch4.jpg" | ||
alt="Tech Nation Visa"> | ||
</a> | ||
</th> | ||
<th><a href="https://www.technation.sucks">Tech Nation Visa Sucks</a></th> | ||
<th>© <a href="https://www.artd.eco">Art Deco™</a> 2020</th> | ||
<th><a href="LICENSE"><img src=".documentary/agpl-3.0.svg" alt="AGPL-3.0"></a></th> | ||
</tr> | ||
</table> | ||
<p align="center"><a href="#table-of-contents"> | ||
<div align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/-1.svg?sanitize=true"> | ||
</a></p> | ||
</a></div> |
import Type from '../Type' // eslint-disable-line | ||
import Import from '../Import' // eslint-disable-line | ||
import { makeBlock, addSuppress } from '../' | ||
import { EOL } from 'os' | ||
import { makeBlock, addSuppress, JOIN } from '../' | ||
@@ -57,8 +56,8 @@ // import { builtinModules } from 'module' | ||
// }) | ||
const blocks = [...tblocks, ...iblocks] | ||
.join(EOL) | ||
const n = namespace && !skipNsDecl && !currentNamespaces.includes(namespace) ? `/** @const */ | ||
var ${namespace} = {} | ||
` : '' | ||
const blocks = JOIN(...tblocks, ...iblocks) | ||
const n = namespace && !skipNsDecl && !currentNamespaces.includes(namespace) ? JOIN( | ||
'/** @const */', | ||
`var ${namespace} = {}`, | ||
'') : '' | ||
return `${n}${blocks}` | ||
} |
@@ -5,3 +5,3 @@ import { Transform } from 'stream' | ||
import { collect } from 'catchment' | ||
import { getNameWithDefault } from './' | ||
import { getNameWithDefault, JOIN } from './' | ||
import { EOL } from 'os' | ||
@@ -154,6 +154,8 @@ | ||
const data = await collect(xml) | ||
const d = `<types> | ||
${data.trim()} | ||
</types>` | ||
const d = JOIN( | ||
'<types>', | ||
` ${data.trim()}`, | ||
'</types>', | ||
) | ||
return d | ||
} |
@@ -70,14 +70,8 @@ import { resolve, dirname } from 'path' | ||
export const makeBlock = (s) => { | ||
if (!s) return `/** | ||
*/ | ||
` | ||
return `/** | ||
${s} | ||
*/ | ||
` | ||
if (!s) return `/**${EOL} */${EOL}` | ||
return `/**${EOL}${s}${EOL} */${EOL}` | ||
} | ||
export const addSuppress = (line) => { | ||
const m = ` * @suppress {nonStandardJsDocs} | ||
${line}` | ||
const m = ` * @suppress {nonStandardJsDocs}${EOL}${line}` | ||
return m | ||
@@ -99,2 +93,22 @@ } | ||
const getPartial = (boundExample) => { | ||
let s = boundExample | ||
.split(/\r?\n/) | ||
.map((/** @type {string} */ a) => { | ||
let j = Infinity | ||
a.replace(/\S/, (m, i) => { | ||
j = i | ||
}) | ||
return j | ||
}) | ||
const minLength = s | ||
.reduce((acc, l) => { | ||
if (l < acc) return l | ||
return acc | ||
}, Infinity) | ||
const e = boundExample | ||
.replace(new RegExp(`^ {${minLength}}`, 'gm'), '') | ||
return e | ||
} | ||
/** | ||
@@ -106,27 +120,4 @@ * @param {string} d | ||
const m = /\S/.exec(d) | ||
if (!m) return d | ||
const i = m.index | ||
if (i == 0) return d | ||
const s = d.substr(0, i) | ||
let n = s.lastIndexOf(EOL) | ||
// remove everything before first /n | ||
if (n == -1) n = 0 | ||
else { | ||
n++ | ||
d = d.substr(n) | ||
} | ||
const ws = i - n | ||
const w = ' '.repeat(ws) | ||
const dd = d.split(EOL) | ||
const a = dd.filter(b => /\S/.test(b)) | ||
const notWithSpace = a.find(b => { | ||
const res = !b.startsWith(w) | ||
return res | ||
}) | ||
if (!notWithSpace) { | ||
const re = new RegExp(`^ {${ws}}`) | ||
return dd.map(b => b.replace(re, '')).join(EOL) | ||
} else return d.trim() | ||
d = d.replace(/^\s*\r?\n( *\S)/, '$1') | ||
return getPartial(d) | ||
} | ||
@@ -174,2 +165,4 @@ | ||
props['example'] = resolve(dirname(file), e) | ||
} | ||
} | ||
export const JOIN = (...A) => A.join(EOL) |
import { getLinks } from './get-links' | ||
import { EOL } from 'os' | ||
import { JOIN } from './' | ||
@@ -63,7 +65,9 @@ /** | ||
const j = JSON.stringify([h, ...ar], null, 2) | ||
return ` | ||
\`\`\`table | ||
${j} | ||
\`\`\`` | ||
return JOIN( | ||
'', | ||
'', | ||
'```table', | ||
j.replace(/\n/g, EOL), // JSON.stringify prints \n only | ||
'```', | ||
) | ||
} | ||
@@ -78,3 +82,3 @@ | ||
.replace(/</g, '<') | ||
.replace(/>/, '>') | ||
.replace(/>/g, '>') | ||
} | ||
@@ -81,0 +85,0 @@ |
@@ -13,9 +13,9 @@ import parse from '@typedefs/parser' | ||
export const indentWithAster = (string, skipFirst = false) => { | ||
const d = string.split(EOL).map((l, i) => { | ||
const d = string.split('\n').map((l, i) => { | ||
if (skipFirst && !i) return l | ||
let s = ' *' | ||
if (l.length) s += ' ' | ||
if (l.length && l != '\r') s += ' ' | ||
s += l | ||
return s | ||
}).join(EOL) | ||
}).join('\n') | ||
return d | ||
@@ -428,6 +428,6 @@ } | ||
e = e.replace(/^\/\/\/\s+/gm, '') | ||
acc.push(...e.split(EOL)) | ||
acc.push(...e.split(/\r?\n/)) | ||
} else { | ||
acc.push('```js') | ||
acc.push(...e.split(EOL)) | ||
acc.push(...e.split(/\r?\n/)) | ||
acc.push('```') | ||
@@ -434,0 +434,0 @@ } |
@@ -6,2 +6,3 @@ import { EOL } from 'os' | ||
import { indentWithAster } from './Property' | ||
import { JOIN } from './' | ||
@@ -12,8 +13,12 @@ const re = /( *) \* @(fnType|methodType) {(.+?)}/gm | ||
const call = `${Static ? ext : 'super'}.${realName}` | ||
const s = `/** | ||
${jsdoc} | ||
*/ | ||
${Static ? 'static ' : ''}${Async ? 'async ' : ''}${name}(${args}) { | ||
return ${call}(${args}) | ||
}` | ||
const s = JOIN( | ||
'/**', | ||
jsdoc, | ||
' */', | ||
`${Static ? 'static ' : ''}${Async ? 'async ' : ''}${name}(${args}) {`, | ||
` return ${call}(${args})`, | ||
'}', | ||
) | ||
return s | ||
@@ -29,3 +34,3 @@ } | ||
{ | ||
re: /\/\*\*\s+( *) \* @constructor {(.+?)}[\s\S]+?(class\s+.+?\s+extends\s+(.+?)\s*){\s*}/gm, | ||
re: /\/\*\*(?:\s+( *) \*)? @constructor {(.+?)}[\s\S]+?(class\s+.+?\s+extends\s+(.+?)\s*){\s*}/gm, | ||
replacement(match, ws, n, cl, ext) { | ||
@@ -58,17 +63,23 @@ const type = types.find(({ fullName }) => fullName == n) | ||
const constrArgs = constr.args.map(({ name }) => name).join(', ') | ||
const c = `/** | ||
${removeReturnFromJsDoc(constr.toExtern('', true), n)} | ||
*/ | ||
constructor(${constrArgs}) { | ||
super(${constrArgs}) | ||
}` | ||
const s = [c, ...tt].join(EOL).replace(/^/gm, ' ') | ||
let res = `${cl}{ | ||
${s} | ||
}` | ||
if (type.description) { | ||
res = `/** | ||
${indentWithAster(type.description)} | ||
*/${EOL}` + res | ||
} | ||
const s = JOIN( | ||
'/**', | ||
removeReturnFromJsDoc(constr.toExtern('', true), n), | ||
' */', | ||
`constructor(${constrArgs}) {`, | ||
` super(${constrArgs})`, | ||
'}', | ||
...tt, | ||
).replace(/(^|(?:\r?\n))/g, '$1 ') // todo: write about it | ||
let res = JOIN( | ||
...(type.description ? [ | ||
'/**', | ||
indentWithAster(type.description), | ||
' */', | ||
] : []), | ||
`${cl}{`, | ||
s, | ||
'}', | ||
) | ||
return res | ||
@@ -75,0 +86,0 @@ }, |
@@ -12,3 +12,3 @@ import { makeBlock } from '../' | ||
*/ | ||
export const typedefJsRe = /^\/\*\*? (documentary|typal) (.+?) \*\/\r?\n(?:([^\n][\s\S]+?\r?\n))?$/mg | ||
export const typedefJsRe = /^\/\*\*? (documentary|typal) (.+?) \*\/\r?\n(?:((?!\r?\n)[\s\S]+?\r?\n))?$/mg | ||
@@ -15,0 +15,0 @@ /** |
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
583
518271
23
6181
12