Comparing version 1.26.1 to 1.26.2
@@ -1,3 +0,7 @@ | ||
## 23 January 2020 | ||
## 3 February 2020 | ||
### [1.26.2](https://github.com/artdecocode/typal/compare/v1.26.1...v1.26.2) | ||
- [fix] Try to fix EOLs. | ||
### [1.26.1](https://github.com/artdecocode/typal/compare/v1.26.0...v1.26.1) | ||
@@ -4,0 +8,0 @@ |
#!/usr/bin/env node | ||
const fs = require('fs'); | ||
const os = require('os'); | ||
const stream = require('stream'); | ||
const os = require('os'); | ||
const path = require('path'); | ||
@@ -84,3 +84,3 @@ var aa = "function" == typeof Object.defineProperties ? Object.defineProperty : function(a, 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"}}, q = function(a = {}, b = process.argv) { | ||
let [, , ...c] = b; | ||
@@ -97,13 +97,13 @@ const d = fa(c); | ||
try { | ||
const m = l.short, n = l.boolean, p = l.number, r = l.command, q = l.multiple; | ||
if (r && q && d.length) { | ||
const m = l.short, n = l.boolean, p = l.number, t = l.command, r = l.multiple; | ||
if (t && r && d.length) { | ||
k = d; | ||
} else { | ||
if (r && d.length) { | ||
if (t && d.length) { | ||
k = d[0]; | ||
} else { | ||
const t = ea(c, h, m, n, p); | ||
({value:k} = t); | ||
const u = t.index, v = t.length; | ||
void 0 !== u && v && e.push({index:u, length:v}); | ||
const u = ea(c, h, m, n, p); | ||
({value:k} = u); | ||
const v = u.index, w = u.length; | ||
void 0 !== v && w && e.push({index:v, length:w}); | ||
} | ||
@@ -125,3 +125,3 @@ } | ||
return a; | ||
}(ha), y = w.source, z = w.output, ja = w.closure, ka = w.useNamespace, la = w.externs, ma = w.types, na = w.template, oa = w.migrate, pa = w.help, qa = w.version; | ||
}(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:{}}) { | ||
@@ -131,3 +131,3 @@ const {usage:b = {}, description:c, line:d, example:e} = a; | ||
const f = Object.values(b), [g] = a.reduce(([k = 0, m = 0], n) => { | ||
const p = b[n].split("\n").reduce((r, q) => q.length > r ? q.length : r, 0); | ||
const p = b[n].split("\n").reduce((t, r) => r.length > t ? r.length : t, 0); | ||
p > m && (m = p); | ||
@@ -143,6 +143,6 @@ n.length > k && (k = n.length); | ||
m = h(m, g); | ||
const [p, ...r] = n; | ||
const [p, ...t] = n; | ||
m = `${m}\t${p}`; | ||
const q = h("", g); | ||
n = r.map(t => `${q}\t${t}`); | ||
const r = h("", g); | ||
n = t.map(u => `${r}\t${u}`); | ||
return [...k, m, ...n]; | ||
@@ -173,4 +173,4 @@ }, []).map(k => `\t${k}`); | ||
}; | ||
const Ba = os.homedir; | ||
const Ca = /\s+at.*(?:\(|\s)(.*)\)?/, Da = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/, Ea = Ba(), D = 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)); | ||
@@ -191,7 +191,7 @@ return a.replace(/\\/g, "/").split("\n").filter(f => { | ||
e = [`Error: ${h}`, ...null !== e && a === e || c ? [b] : [g, b]].join("\n"); | ||
e = D(e); | ||
e = E(e); | ||
return Object.assign(f ? d : Error(), {message:h, stack:e}); | ||
}; | ||
} | ||
;function E(a) { | ||
;function F(a) { | ||
var {stack:b} = Error(); | ||
@@ -210,3 +210,3 @@ const c = Aa(arguments); | ||
constructor(a) { | ||
const {binary:b = !1, rs:c = null, ...d} = a || {}, {R:e = E(!0), proxyError:f} = a || {}, g = (h, l) => e(l); | ||
const {binary:b = !1, rs:c = null, ...d} = a || {}, {R:e = F(!0), proxyError:f} = a || {}, g = (h, l) => e(l); | ||
super(d); | ||
@@ -225,3 +225,3 @@ this.b = []; | ||
} else { | ||
const m = D(k.stack); | ||
const m = E(k.stack); | ||
k.stack = m; | ||
@@ -243,15 +243,15 @@ f && g`${k}`; | ||
} | ||
const F = async a => { | ||
({f:a} = new Ha({rs:a, R:E(!0)})); | ||
const G = async a => { | ||
({f:a} = new Ha({rs:a, R:F(!0)})); | ||
return await a; | ||
}; | ||
async function G(a) { | ||
async function H(a) { | ||
a = sa(a); | ||
return await F(a); | ||
return await G(a); | ||
} | ||
;async function H(a, b) { | ||
;async function I(a, b) { | ||
if (!a) { | ||
throw Error("No path is given."); | ||
} | ||
const c = E(!0), d = ta(a); | ||
const c = F(!0), d = ta(a); | ||
await new Promise((e, f) => { | ||
@@ -264,4 +264,4 @@ d.on("error", g => { | ||
} | ||
;async function I(a, b, c) { | ||
const d = E(!0); | ||
;async function J(a, b, c) { | ||
const d = F(!0); | ||
if ("function" != typeof a) { | ||
@@ -280,11 +280,11 @@ throw Error("Function must be passed."); | ||
} | ||
;const Ia = path.dirname, J = path.join, Ja = path.relative, Ka = path.resolve; | ||
async function La(a, b) { | ||
;const Ia = path.dirname, Ja = 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 = Ja(a, c); | ||
return {lstat:await J(A, d), path:d, relativePath:c}; | ||
}); | ||
return await Promise.all(b); | ||
} | ||
const Ma = a => a.lstat.isDirectory(), Na = a => !a.lstat.isDirectory(); | ||
const Na = a => a.lstat.isDirectory(), Oa = a => !a.lstat.isDirectory(); | ||
async function K(a) { | ||
@@ -295,3 +295,3 @@ if (!a) { | ||
const {ignore:b = []} = {}; | ||
if (!(await I(A, a)).isDirectory()) { | ||
if (!(await J(A, a)).isDirectory()) { | ||
var c = Error("Path is not a directory"); | ||
@@ -301,6 +301,6 @@ c.code = "ENOTDIR"; | ||
} | ||
c = await I(va, a); | ||
var d = await La(a, c); | ||
c = d.filter(Ma); | ||
d = d.filter(Na).reduce((e, f) => { | ||
c = await J(va, 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; | ||
@@ -310,3 +310,3 @@ return {...e, [f.relativePath]:{type:g}}; | ||
c = await c.reduce(async(e, {path:f, relativePath:g}) => { | ||
const h = Ja(a, f); | ||
const h = Ka(a, f); | ||
if (b.includes(h)) { | ||
@@ -325,7 +325,7 @@ return e; | ||
const {type:g} = a[f]; | ||
"File" == g ? c.push(J(b, f)) : "Directory" == g && d.push(f); | ||
"File" == g ? c.push(Ja(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 = L(h, Ja(b, g)); | ||
return [...f, ...g]; | ||
@@ -335,3 +335,3 @@ }, []); | ||
}; | ||
function Oa(a) { | ||
function Pa(a) { | ||
if ("object" != typeof a) { | ||
@@ -344,3 +344,3 @@ return !1; | ||
} | ||
const Pa = (a, b) => { | ||
const Qa = (a, b) => { | ||
if (!(b instanceof Error)) { | ||
@@ -359,5 +359,5 @@ throw b; | ||
}; | ||
function Qa(a, b) { | ||
function Ra(a, b) { | ||
function c() { | ||
return b.filter(Oa).reduce((d, {re:e, replacement:f}) => { | ||
return b.filter(Pa).reduce((d, {re:e, replacement:f}) => { | ||
if (this.j) { | ||
@@ -376,3 +376,3 @@ return d; | ||
} catch (k) { | ||
Pa(g, k); | ||
Qa(g, k); | ||
} | ||
@@ -388,8 +388,8 @@ }); | ||
} | ||
;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}; | ||
;const Sa = a => new RegExp(`%%_RESTREAM_${a.toUpperCase()}_REPLACEMENT_(\\d+)_%%`, "g"), Ta = (a, b) => `%%_RESTREAM_${a.toUpperCase()}_REPLACEMENT_${b}_%%`, Ua = () => { | ||
var a = {S:/^\/\*\*? (documentary|typal) (.+?) externs (.*?)\*\/\r?\n(?:([^\r\n][\s\S]+?\r?\n))?$/mg}; | ||
return Object.keys(a).reduce((b, c) => { | ||
{ | ||
var d = a[c]; | ||
const {getReplacement:e = Sa, getRegex:f = Ra} = {}, g = f(c); | ||
const {getReplacement:e = Ta, getRegex:f = Sa} = {}, g = f(c); | ||
d = {name:c, re:d, regExp:g, getReplacement:e, map:{}, lastIndex:0}; | ||
@@ -399,3 +399,3 @@ } | ||
}, {}); | ||
}, Ua = a => { | ||
}, Va = a => { | ||
var b = []; | ||
@@ -406,5 +406,5 @@ const c = a.map; | ||
delete c[e]; | ||
return Qa(d, Array.isArray(b) ? b : [b]); | ||
return Ra(d, Array.isArray(b) ? b : [b]); | ||
}}; | ||
}, Va = a => { | ||
}, Wa = a => { | ||
const b = a.map, c = a.getReplacement, d = a.name; | ||
@@ -418,9 +418,9 @@ return {re:a.re, replacement(e) { | ||
}; | ||
async function Wa(a, b) { | ||
return Xa(a, b); | ||
async function Xa(a, b) { | ||
return Ya(a, b); | ||
} | ||
class Ya extends B { | ||
class Za extends B { | ||
constructor(a, b) { | ||
super(b); | ||
this.g = (Array.isArray(a) ? a : [a]).filter(Oa); | ||
this.g = (Array.isArray(a) ? a : [a]).filter(Pa); | ||
this.j = !1; | ||
@@ -430,5 +430,5 @@ this.h = b; | ||
async replace(a, b) { | ||
const c = new Ya(this.g, this.h); | ||
const c = new Za(this.g, this.h); | ||
b && Object.assign(c, b); | ||
a = await Wa(c, a); | ||
a = await Xa(c, a); | ||
c.j && (this.j = !0); | ||
@@ -461,3 +461,3 @@ b && Object.keys(b).forEach(d => { | ||
} catch (k) { | ||
Pa(f, k); | ||
Qa(f, k); | ||
} | ||
@@ -470,3 +470,3 @@ }); | ||
} catch (h) { | ||
Pa(f, h); | ||
Qa(f, h); | ||
} | ||
@@ -486,12 +486,12 @@ } else { | ||
} catch (d) { | ||
a = D(d.stack), d.stack = a, c(d); | ||
a = E(d.stack), d.stack = a, c(d); | ||
} | ||
} | ||
} | ||
async function Xa(a, b) { | ||
async function Ya(a, b) { | ||
b instanceof wa ? b.pipe(a) : a.end(b); | ||
return await F(a); | ||
return await G(a); | ||
} | ||
;function Za() { | ||
var a = $a; | ||
;function $a() { | ||
var a = ab; | ||
let b = ""; | ||
@@ -507,3 +507,3 @@ const c = new B({transform(d, e, f) { | ||
} | ||
;const ab = (a, b, c, d) => { | ||
;const bb = (a, b, c, d) => { | ||
if (!a) { | ||
@@ -518,7 +518,7 @@ throw Error("The name of the property is not given"); | ||
return `${a}=${b}`; | ||
}, bb = ({number:a, L:b, boolean:c, type:d}) => b ? "string" : a ? "number" : c ? "boolean" : d ? d : "*", cb = a => `${/[^\w\d._]/.test(a) ? `(${a})` : a}|undefined`, M = a => a ? `/** | ||
}, 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", P = a => ` * @suppress {nonStandardJsDocs} | ||
${a}`, db = (a, b, c) => { | ||
` : "/**\n */\n", N = a => ` * @suppress {nonStandardJsDocs} | ||
${a}`, eb = (a, b, c) => { | ||
a = `${a ? "" : "var "}${a ? `${a}.` : ""}${b}`; | ||
@@ -537,7 +537,7 @@ c && (a += ` = ${c}`); | ||
} | ||
var c = a.substr(0, b).lastIndexOf("\n"); | ||
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("\n"); | ||
c = a.split(C); | ||
if (c.filter(e => /\S/.test(e)).find(e => !e.startsWith(d))) { | ||
@@ -548,9 +548,9 @@ return a.trim(); | ||
const e = new RegExp(`^ {${b}}`); | ||
return c.map(f => f.replace(e, "")).join("\n"); | ||
return c.map(f => f.replace(e, "")).join(C); | ||
} | ||
}, eb = (a, b, c = null) => { | ||
}, fb = (a, b, c = null) => { | ||
const {async:d, "void":e, "return":f = e ? "void" : "", ...g} = a; | ||
({args:a = ""} = a); | ||
a || (a = b.map(({I:h, name:l}) => "this" == l ? `${l}: ${h}` : l.startsWith("...") ? `...${h}` : h).join(",")); | ||
b = f.replace(/\n\s*/g, " "); | ||
b = f.replace(/\r?\n\s*/g, " "); | ||
d && b ? b = `!Promise<${b}>` : d && (b = "!Promise"); | ||
@@ -563,5 +563,5 @@ c = `function(${"constructor" == g.name ? `new: ${c}, ` : ""}${a})`; | ||
const c = a.example; | ||
c && c.startsWith(".") && b && (a.example = Ka(Ia(b), c)); | ||
c && c.startsWith(".") && b && (a.example = La(Ia(b), c)); | ||
} | ||
;function fb(a, b, c) { | ||
;function gb(a, b, c) { | ||
const d = []; | ||
@@ -581,11 +581,11 @@ b.replace(a, (e, ...f) => { | ||
} | ||
;const gb = new RegExp(`${/([^\s>=/]+)/.source}(?:\\s*=\\s*${/(?:"([\s\S]*?)"|'([\s\S]*?)')/.source})?`, "g"), hb = new RegExp(`(?:\\s+((?:${gb.source}\\s*)*))`); | ||
;const hb = new RegExp(`${/([^\s>=/]+)/.source}(?:\\s*=\\s*${/(?:"([\s\S]*?)"|'([\s\S]*?)')/.source})?`, "g"), ib = new RegExp(`(?:\\s+((?:${hb.source}\\s*)*))`); | ||
const S = (a, b) => { | ||
a = (Array.isArray(a) ? a : [a]).join("|"); | ||
return fb(new RegExp(`<(${a})${hb.source}?(?:${/\s*\/>/.source}|${/>([\s\S]+?)?<\/\1>/.source})`, "g"), b, "t a v v1 v2 c".split(" ")).map(({t:c, a:d = "", c:e = ""}) => { | ||
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 = ib(d); | ||
d = jb(d); | ||
return {content:e, props:d, tag:c}; | ||
}); | ||
}, ib = a => fb(gb, a, ["key", "val", "def", "f"]).reduce((b, {key:c, val:d}) => { | ||
}, jb = a => gb(hb, a, ["key", "val", "def", "f"]).reduce((b, {key:c, val:d}) => { | ||
if (void 0 === d) { | ||
@@ -597,3 +597,3 @@ return b[c] = !0, b; | ||
}, {}); | ||
const jb = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => { | ||
const kb = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => { | ||
switch(b) { | ||
@@ -615,3 +615,3 @@ case "function": | ||
}); | ||
function kb(a) { | ||
function lb(a) { | ||
let b = 0; | ||
@@ -773,7 +773,7 @@ const c = (e = 1) => a[b + e], d = (e = !0, f = []) => { | ||
} | ||
;function lb(a) { | ||
a = jb(a); | ||
return kb(a); | ||
;function mb(a) { | ||
a = kb(a); | ||
return lb(a); | ||
} | ||
;function mb(a, b, {name:c, string:d, "boolean":e, opt:f, number:g, type:h}, l) { | ||
;function nb(a, b, {name:c, string:d, "boolean":e, opt:f, number:g, type:h}, l) { | ||
if (!c) { | ||
@@ -784,3 +784,3 @@ throw Error("Argument does not have a name."); | ||
b && (a.description = Q(b)); | ||
b = bb({number:g, L:d, boolean:e, type:h}); | ||
b = cb({number:g, L:d, boolean:e, type:h}); | ||
l && (b = b.replace(new RegExp(`([!?])?${l}\\.`, "g"), "$1")); | ||
@@ -791,3 +791,3 @@ b.endsWith("=") && (b = b.replace(/=$/, ""), f = !0); | ||
} | ||
class nb { | ||
class ob { | ||
constructor() { | ||
@@ -803,8 +803,8 @@ this.name = null; | ||
} | ||
const ob = (a, b) => { | ||
const pb = (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 = S("arg", e), e = e.map(({content:f, props:g}) => { | ||
const h = new nb; | ||
mb(h, f, g, b); | ||
const h = new ob; | ||
nb(h, f, g, b); | ||
return h; | ||
@@ -863,3 +863,3 @@ })); | ||
} | ||
;const U = (a, b = !1) => a.split("\n").map((c, d) => { | ||
;const U = (a, b = !1) => a.split(C).map((c, d) => { | ||
if (b && !d) { | ||
@@ -871,4 +871,4 @@ return c; | ||
return d + c; | ||
}).join("\n"), pb = a => { | ||
const b = a.replace(/^\s*\n/gm, "").split("\n").reduce((c, d) => { | ||
}).join(C), qb = a => { | ||
const b = a.replace(/^\s*\r?\n/gm, "").split(C).reduce((c, d) => { | ||
[{length:d = 0} = {}] = /^\s*/.exec(d) || []; | ||
@@ -879,3 +879,3 @@ return d < c ? d : c; | ||
}; | ||
function qb(a, b = "") { | ||
function rb(a, b = "") { | ||
const c = b.split(/\s*,\s*/); | ||
@@ -885,3 +885,3 @@ return a.split(/\s*,\s*/).map(d => { | ||
if (d = /\/\* start example \*\/\r?\n([\s\S]+?)\r?\n\s*\/\* end example \*\//.exec(d)) { | ||
[, d] = d, e = pb(d); | ||
[, d] = d, e = qb(d); | ||
} | ||
@@ -896,3 +896,3 @@ c.forEach(f => { | ||
} | ||
function rb(a, {O:b = !0, T:c = !0} = {}) { | ||
function sb(a, {O:b = !0, T:c = !0} = {}) { | ||
const d = []; | ||
@@ -902,11 +902,11 @@ b && d.push(" * @example"); | ||
let f = [], g = [], h = "", l; | ||
e = e.split("\n").reduce((k, m) => { | ||
e = e.split(C).reduce((k, m) => { | ||
m.startsWith("///") ? (l = "comment", f.push(m)) : (l = "block", g.push(m)); | ||
h || (h = l); | ||
l != h && ("block" == l ? (k.push(f.join("\n")), f = []) : (k.push(g.join("\n")), g = []), h = l); | ||
l != h && ("block" == l ? (k.push(f.join(C)), f = []) : (k.push(g.join(C)), g = []), h = l); | ||
return k; | ||
}, []); | ||
f.length ? e.push(f.join("\n")) : g.length && e.push(g.join("\n")); | ||
f.length ? e.push(f.join(C)) : g.length && e.push(g.join(C)); | ||
e = e.reduce((k, m) => { | ||
m.startsWith("///") ? (m = m.replace(/^\/\/\/\s+/gm, ""), k.push(...m.split("\n"))) : (k.push("```js"), k.push(...m.split("\n")), k.push("```")); | ||
m.startsWith("///") ? (m = m.replace(/^\/\/\/\s+/gm, ""), k.push(...m.split(C))) : (k.push("```js"), k.push(...m.split(C)), k.push("```")); | ||
return k; | ||
@@ -919,25 +919,25 @@ }, []); | ||
} | ||
function sb(a, b, c = new RegExp(`([!?])?${b}\\.`, "g")) { | ||
function tb(a, b, c = new RegExp(`([!?])?${b}\\.`, "g")) { | ||
b && (a.f && (a.f = a.f.replace(c, "$1")), a.type = a.type.replace(c, "$1")); | ||
} | ||
function tb(a, b = !1) { | ||
function ub(a, b = !1) { | ||
return b ? a.closureType : a.isParsedFunction ? a.toTypeScriptFunction(T) : a.type; | ||
} | ||
function ub(a, b = null, c = !1, d = !1) { | ||
function vb(a, b = null, c = !1, d = !1) { | ||
if (!a.name) { | ||
throw Error("Property does not have a name. Has it been constructed using fromXML?"); | ||
} | ||
b = ab(a.name, a.optional ? a.default : null, a.type, b); | ||
b = bb(a.name, a.optional ? a.default : null, a.type, b); | ||
b = a.optional ? `[${b}]` : b; | ||
var e = a.m; | ||
e = e ? ` ${e}` : ""; | ||
c = `{${tb(a, c)}} ${b}${e}`; | ||
d && (a = rb(a.examples, {O:!1, T:!1}).join("\n").replace(/\*/g, "\uff0a")) && (c += `\n${a}`); | ||
c = `{${ub(a, c)}} ${b}${e}`; | ||
d && (a = sb(a.examples, {O:!1, T:!1}).join(C).replace(/\*/g, "\uff0a")) && (c += `${C}${a}`); | ||
return c; | ||
} | ||
function vb(a, b = !1) { | ||
a = ub(a, null, b, !0); | ||
function wb(a, b = !1) { | ||
a = vb(a, null, b, !0); | ||
return ` * @prop ${U(a, !0)}`; | ||
} | ||
function wb(a, b) { | ||
function xb(a, b) { | ||
const c = [], {function:{args:d, return:e, variableArgs:f, this:g}} = a.parsed; | ||
@@ -949,3 +949,3 @@ d.map(h => T(h)).forEach((h, l) => { | ||
if (f) { | ||
const {M:h, X:l} = xb(a.args || []), k = [h, l].filter(Boolean).join(" "); | ||
const {M:h, X:l} = yb(a.args || []), k = [h, l].filter(Boolean).join(" "); | ||
c.push(` * @param {...${T(f)}} ${k}`); | ||
@@ -963,3 +963,3 @@ } | ||
} | ||
function yb(a) { | ||
function zb(a) { | ||
if (a.isParsedFunction) { | ||
@@ -971,3 +971,3 @@ const {function:{args:b, variableArgs:c}} = a.parsed, d = b.map((e, f) => { | ||
if (c) { | ||
const {M:e} = xb(a.args || []); | ||
const {M:e} = yb(a.args || []); | ||
d.push(`...${e}`); | ||
@@ -982,9 +982,9 @@ } | ||
var e = a.m; | ||
e && (e = U(e), d.push(...e.split("\n"))); | ||
!a.optional && a.isParsedFunction ? (e = wb(a, c), d.push(...e)) : d.push(` * @type {${a.optional ? cb(a.closureType) : a.closureType}}`); | ||
c && a.examples.length && (a = rb(a.examples), d.push(...a)); | ||
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}}`); | ||
c && a.examples.length && (a = sb(a.examples), d.push(...a)); | ||
b && (d = d.map(f => `${b}${f}`)); | ||
return d.join("\n"); | ||
return d.join(C); | ||
} | ||
function zb(a, b) { | ||
function Ab(a, b) { | ||
const c = Object.assign(Object.create(Object.getPrototypeOf(a)), a); | ||
@@ -995,3 +995,3 @@ c.description = `An alias for \`${a.name}\`.`; | ||
} | ||
class Ab { | ||
class Bb { | ||
constructor(a = null) { | ||
@@ -1046,3 +1046,3 @@ this.h = this.description = this.name = null; | ||
} | ||
b(a, {name:b, string:c, "boolean":d, opt:e, number:f, type:g, "default":h, closure:l, alias:k, aliases:m, example:n, "example-override":p = "", noParams:r, "static":q, initial:t, "template-no-return":u}) { | ||
b(a, {name:b, string:c, "boolean":d, opt:e, number:f, type:g, "default":h, closure:l, alias:k, aliases:m, example:n, "example-override":p = "", noParams:t, "static":r, initial:u, "template-no-return":v}) { | ||
if (!b) { | ||
@@ -1053,7 +1053,7 @@ throw Error("Property does not have a name."); | ||
a && (this.description = Q(a)); | ||
a = bb({number:f, L:c, boolean:d, type:g}); | ||
r && (this.s = r); | ||
a = cb({number:f, L:c, boolean:d, type:g}); | ||
t && (this.s = t); | ||
l && (this.f = l); | ||
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) { | ||
@@ -1064,5 +1064,5 @@ this.optional = !0; | ||
m && (this.aliases = m.split(/\s*,\s*/)); | ||
q && (this.g = !0); | ||
n && (this.examples = qb(n, p)); | ||
u && (this.u = !0); | ||
r && (this.g = !0); | ||
n && (this.examples = rb(n, p)); | ||
v && (this.u = !0); | ||
} | ||
@@ -1077,3 +1077,3 @@ get type() { | ||
try { | ||
this.parsed = lb(this.closureType), this.isParsedFunction && !this.args && (this.args = []); | ||
this.parsed = mb(this.closureType), this.isParsedFunction && !this.args && (this.args = []); | ||
} catch (b) { | ||
@@ -1086,3 +1086,3 @@ this.parsed = null; | ||
let a = this.description || ""; | ||
return `${a}${this.hasDefault ? `${/``` */.test(this.description) ? "\n" : a ? " " : ""}Default \`${this.default}\`.` : ""}`; | ||
return `${a}${this.hasDefault ? `${/``` */.test(this.description) ? C : a ? " " : ""}Default \`${this.default}\`.` : ""}`; | ||
} | ||
@@ -1098,8 +1098,8 @@ get l() { | ||
C(a, b = "", c = !1) { | ||
a = ub(this, a, c); | ||
const [d, ...e] = a.split("\n"); | ||
return [`@param ${d}`, ...e].map(f => `${b} * ${f}`).join("\n"); | ||
a = vb(this, a, c); | ||
const [d, ...e] = a.split(C); | ||
return [`@param ${d}`, ...e].map(f => `${b} * ${f}`).join(C); | ||
} | ||
} | ||
const xb = a => { | ||
const yb = a => { | ||
let b = "args"; | ||
@@ -1110,3 +1110,3 @@ const {name:c = "", description:d} = a[a.length - 1] || {}; | ||
}; | ||
class W extends Ab { | ||
class W extends Bb { | ||
constructor(...a) { | ||
@@ -1124,5 +1124,5 @@ super(...a); | ||
} | ||
;function Bb(a, b, c, d) { | ||
;function Cb(a, b, c, d) { | ||
var e = S("prop", a).map(({content:l, props:k}) => { | ||
const m = new Ab; | ||
const m = new Bb; | ||
R(k, c); | ||
@@ -1134,8 +1134,8 @@ m.b(l, k); | ||
m = "static" == m; | ||
const {J:n, F:p} = ob(l, b); | ||
const {J:n, F:p} = pb(l, b); | ||
l = new W(p); | ||
const {W:r, H:q} = eb(k, p, d); | ||
r.type = q; | ||
R(r, c); | ||
l.b(n, r); | ||
const {W:t, H:r} = fb(k, p, d); | ||
t.type = r; | ||
R(t, c); | ||
l.b(n, t); | ||
m && (l.g = !0); | ||
@@ -1151,3 +1151,3 @@ return l; | ||
} | ||
;const Cb = (a, b, c = {}) => { | ||
;const Db = (a, b, c = {}) => { | ||
let d; | ||
@@ -1158,3 +1158,3 @@ if ("object" == typeof b) { | ||
try { | ||
(d = lb(b)) || console.log("Could not parse %s", b); | ||
(d = mb(b)) || console.log("Could not parse %s", b); | ||
} catch (e) { | ||
@@ -1195,8 +1195,8 @@ console.log("Could not parse %s", b), console.error(e.message); | ||
return `${g}: ${h}`; | ||
}), e += d.join(", "), e += " }") : a.application ? (e += Db(a.name, b, f, c) + "<", d = a.application.map(g => X(g, b, c)), e += d.join(", "), e += ">") : a.union ? (e = e + f + "(", f = a.union.map(g => X(g, b, c)), e += f.join(d ? " \\| " : " | "), e += ")") : e += Db("any" == a.name ? "*" : a.name, b, f, c); | ||
}), e += d.join(", "), e += " }") : a.application ? (e += Eb(a.name, b, f, c) + "<", d = a.application.map(g => X(g, b, c)), e += d.join(", "), e += ">") : a.union ? (e = e + f + "(", f = a.union.map(g => X(g, b, c)), e += f.join(d ? " \\| " : " | "), e += ")") : e += Eb("any" == a.name ? "*" : a.name, b, f, c); | ||
} | ||
return e; | ||
}, Db = (a, b, c = "", d = {}) => { | ||
}, Eb = (a, b, c = "", d = {}) => { | ||
const {flatten:e = !1, nameProcess:f, link:g = ({link:k}) => `#${k}`} = d; | ||
d = Eb(b, a); | ||
d = Fb(b, a); | ||
c = `${c}${a}`; | ||
@@ -1211,3 +1211,3 @@ if (!d) { | ||
return l ? `<a href="${h}" title="${l.replace(/"/g, """)}">${b}</a>` : `[${b}](${h})`; | ||
}, Eb = (a, b) => { | ||
}, Fb = (a, b) => { | ||
a = a.filter(({fullName:d}) => d == b); | ||
@@ -1220,3 +1220,3 @@ if (a.length) { | ||
}; | ||
function Fb(a, b = [], c = [], d = {}) { | ||
function Gb(a, b = [], c = [], d = {}) { | ||
const {narrow:e = !1, preprocessDesc:f} = d; | ||
@@ -1228,8 +1228,8 @@ if (!b.length) { | ||
let k; | ||
const m = n => Cb(c, n, {...l, nameProcess:d.nameProcess ? p => d.nameProcess(p, k) : void 0}); | ||
const m = n => Db(c, n, {...l, nameProcess:d.nameProcess ? p => d.nameProcess(p, k) : void 0}); | ||
a = b.map((n, p) => { | ||
k = 0 < (p + 1) % 2; | ||
p = n.args && n.isParsedFunction ? n.toTypeScriptFunction(m) : m(n.parsed || n.type); | ||
const r = g || n.optional ? n.name : `${n.name}*`, q = n.hasDefault ? `\`${n.default}\`` : "-", t = f ? f(n.description) : n.description; | ||
return {prop:n, typeName:p, name:r, de:Gb(t, !e), d:q, Z:k}; | ||
const t = g || n.optional ? n.name : `${n.name}*`, r = n.hasDefault ? `\`${n.default}\`` : "-", u = f ? f(n.description) : n.description; | ||
return {prop:n, typeName:p, name:t, de:Hb(u, !e), d:r, Z:k}; | ||
}); | ||
@@ -1239,3 +1239,3 @@ if (e) { | ||
} | ||
a = a.map(({name:n, typeName:p, de:r, d:q, prop:t}) => [t.optional ? n : `__${n}__`, `<em>${p}</em>`, r, ...h ? [q] : []]); | ||
a = a.map(({name:n, typeName:p, de:t, d:r, prop:u}) => [u.optional ? n : `__${n}__`, `<em>${p}</em>`, t, ...h ? [r] : []]); | ||
b = ["Name", ...e ? ["Type & Description"] : ["Type", "Description"], ...h ? [g ? "Initial" : "Default"] : []]; | ||
@@ -1248,3 +1248,3 @@ return ` | ||
} | ||
const Gb = (a = "", b = !0) => { | ||
const Hb = (a = "", b = !0) => { | ||
null === a && (a = ""); | ||
@@ -1254,3 +1254,3 @@ b && (a = a.replace(/\|/g, "\\|")); | ||
}; | ||
const Hb = (a, b, c = {}) => { | ||
const Ib = (a, b, c = {}) => { | ||
function d(e) { | ||
@@ -1260,3 +1260,3 @@ e.replace(/^!?/, ""); | ||
} | ||
return a.split(/,\s*/).map(e => Cb(b, e, {flatten:!0, ...c, nameProcess:c.nameProcess ? f => { | ||
return a.split(/,\s*/).map(e => Db(b, e, {flatten:!0, ...c, nameProcess:c.nameProcess ? f => { | ||
f = c.nameProcess(f); | ||
@@ -1266,9 +1266,9 @@ return /[_*~>]/.test(f) ? `<code>${f}</code>` : d(f); | ||
}; | ||
function Ib(a) { | ||
function Jb(a) { | ||
var b = a.h(); | ||
b = M(b.join("\n")); | ||
b += db(a.namespace, a.name, Jb(a)); | ||
b = M(b.join(C)); | ||
b += eb(a.namespace, a.name, Kb(a)); | ||
const c = a.properties.reduce((d, e) => { | ||
d.push(e); | ||
const f = e.aliases.map(g => zb(e, g)); | ||
const f = e.aliases.map(g => Ab(e, g)); | ||
d.push(...f); | ||
@@ -1279,13 +1279,13 @@ return d; | ||
e = M(e); | ||
e += db(`${a.fullName}${d.static ? "" : ".prototype"}`, d.name); | ||
return e += yb(d); | ||
e += eb(`${a.fullName}${d.static ? "" : ".prototype"}`, d.name); | ||
return e += zb(d); | ||
}); | ||
return [b, ...c].join("\n"); | ||
return [b, ...c].join(C); | ||
} | ||
function Kb(a, b = !1) { | ||
function Lb(a, b = !1) { | ||
const c = `${a.extends ? "$" : ""}${a.name}`; | ||
return b ? `${a.ns}${c}` : c; | ||
} | ||
function Lb(a, b = !1, c = !1, d = b) { | ||
d = ` * @typedef {${(b ? a.closureType : a.type) || a.s()}}${` ${Kb(a, d)}${a.l}`}`; | ||
function Mb(a, b = !1, c = !1, d = b) { | ||
d = ` * @typedef {${(b ? a.closureType : a.type) || a.s()}}${` ${Lb(a, d)}${a.l}`}`; | ||
a = (a.properties ? a.properties.reduce((e, f) => { | ||
@@ -1296,11 +1296,11 @@ if (f.g) { | ||
e.push(f); | ||
const g = f.aliases.map(h => zb(f, h)); | ||
const g = f.aliases.map(h => Ab(f, h)); | ||
e.push(...g); | ||
return e; | ||
}, []) : []).filter(e => e instanceof W ? !e.isConstructor : !0).map(e => vb(e, b)); | ||
a = [d, ...a].join("\n"); | ||
b && !c && (a = P(a)); | ||
}, []) : []).filter(e => e instanceof W ? !e.isConstructor : !0).map(e => wb(e, b)); | ||
a = [d, ...a].join(C); | ||
b && !c && (a = N(a)); | ||
return a = M(a); | ||
} | ||
function Jb(a) { | ||
function Kb(a) { | ||
return a.args ? `function(${a.args.filter(({name:b}) => "this" != b).map(({name:b}) => b).join(", ")}) {}` : null; | ||
@@ -1324,3 +1324,3 @@ } | ||
} | ||
b(a, {name:b, type:c, desc:d, noToc:e, spread:f, noExpand:g, link:h, closure:l, constructor:k, "extends":m, "interface":n, record:p, example:r, "example-override":q}, t, u = null) { | ||
b(a, {name:b, type:c, desc:d, noToc:e, spread:f, noExpand:g, link:h, closure:l, constructor:k, "extends":m, "interface":n, record:p, example:t, "example-override":r}, u, v = null) { | ||
if (!b) { | ||
@@ -1341,9 +1341,9 @@ throw Error("Type does not have a name."); | ||
m && (this.extends = m); | ||
t && (this.namespace = t); | ||
u && (this.namespace = u); | ||
if (a) { | ||
const {properties:v, constructor:x} = Bb(a, u, this.file, this.fullName); | ||
x && (this.args = x.args); | ||
this.properties = v; | ||
const {properties:w, constructor:y} = Cb(a, v, this.file, this.fullName); | ||
y && (this.args = y.args); | ||
this.properties = w; | ||
} | ||
r && (a = {example:r}, R(a, this.file), this.examples = qb(a.example, q)); | ||
t && (a = {example:t}, R(a, this.file), this.examples = rb(a.example, r)); | ||
} | ||
@@ -1365,6 +1365,6 @@ get u() { | ||
g(a = !1, b = !1, c = a) { | ||
const d = !!this.extends, e = Lb(this, a, b, c), f = []; | ||
const d = !!this.extends, e = Mb(this, a, b, c), f = []; | ||
if (this.namespace && a) { | ||
var g = ` * @typedef {${this.fullName}} ${this.name}${this.l}`; | ||
a && !b && (g = P(g)); | ||
a && !b && (g = N(g)); | ||
g = M(g); | ||
@@ -1375,3 +1375,3 @@ f.push(g); | ||
} | ||
d && (c = ` * @typedef {${Kb(this, c)} & ${this.extends.split(/,\s*/).join(" & ")}} ${c ? this.fullName : this.name}${this.l}`, a && !b && (c = P(c)), c = M(c), f.push(c)); | ||
d && (c = ` * @typedef {${Lb(this, c)} & ${this.extends.split(/,\s*/).join(" & ")}} ${c ? this.fullName : this.name}${this.l}`, a && !b && (c = N(c)), c = M(c), f.push(c)); | ||
f.push(e); | ||
@@ -1412,3 +1412,3 @@ return f.join(""); | ||
b && d.push(` * @${this.U}`); | ||
c && this.examples.length && (b = rb(this.examples), d.push(...b)); | ||
c && this.examples.length && (b = sb(this.examples), d.push(...b)); | ||
a && (d = d.map(f => `${a}${f}`)); | ||
@@ -1427,6 +1427,6 @@ return d; | ||
d = this.description ? ` ${this.description}` : ""; | ||
const h = this.spread ? Mb(this.properties) : e || f ? this.fullName : this.name; | ||
const h = this.spread ? Nb(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(l => l.C(a, c, e, f)) : []; | ||
return [b, ...g].join("\n"); | ||
return [b, ...g].join(C); | ||
} | ||
@@ -1436,4 +1436,4 @@ toMarkdown(a = [], b = {}) { | ||
var f = this.type ? `\`${this.type}\`` : "", g = f; | ||
this.link ? g = `[${f}](${this.link})` : !this.import && this.type && (g = Cb(a, this.type, b), f = g != this.type, g = Nb(g, f)); | ||
f = Nb(this.fullName); | ||
this.link ? g = `[${f}](${this.link})` : !this.import && this.type && (g = Db(a, this.type, b), f = g != this.type, g = Ob(g, f)); | ||
f = Ob(this.fullName); | ||
f = this.import ? `[${f}](l-type)` : this.noToc ? `[${f}](l-type)` : `[${f}](t-type)`; | ||
@@ -1444,3 +1444,3 @@ const h = this.description ? `: ${this.description}` : ""; | ||
if (this.extends) { | ||
const k = Hb(this.extends, a, b), m = ` extends ${k}`; | ||
const k = Ib(this.extends, a, b), m = ` extends ${k}`; | ||
l = l || /_/.test(k); | ||
@@ -1453,7 +1453,7 @@ g = (l ? g + "<strong>" : g + "__") + (f + m); | ||
g = (l ? g + "</strong>" : g + "__") + h; | ||
a = Fb(this, this.properties, a, b); | ||
a = Gb(this, this.properties, a, b); | ||
return {LINE:g, table:a, displayInDetails:e}; | ||
} | ||
} | ||
const Nb = (a, b = !1) => `${b ? "<code>" : "`"}${a}${b ? "</code>" : "`"}`, Mb = (a = [], b = !1) => { | ||
const Ob = (a, b = !1) => `${b ? "<code>" : "`"}${a}${b ? "</code>" : "`"}`, Nb = (a = [], b = !1) => { | ||
a = a.reduce((c, d) => { | ||
@@ -1468,7 +1468,7 @@ c.push(d); | ||
let e = c.name, f = d; | ||
c.optional && !b ? e = `${c.name}?` : c.optional && b && (f = `(${cb(d)})`); | ||
c.optional && !b ? e = `${c.name}?` : c.optional && b && (f = `(${db(d)})`); | ||
return `${e}: ${f}`; | ||
}).join(", ")} }`; | ||
}; | ||
class Ob extends Y { | ||
class Pb extends Y { | ||
constructor() { | ||
@@ -1493,7 +1493,7 @@ super(); | ||
} | ||
;function Pb(a, b) { | ||
;function Qb(a, b) { | ||
b = b.reduce((c, d) => ({...c, [d.fullName]:d}), {}); | ||
a.A = {...a.A, ...b}; | ||
} | ||
class Qb extends Ya { | ||
class Rb extends Za { | ||
constructor(a, b = {}) { | ||
@@ -1503,3 +1503,3 @@ super(a); | ||
this.on("types", c => { | ||
Pb(this, c); | ||
Qb(this, c); | ||
}); | ||
@@ -1519,3 +1519,3 @@ this.on("namespace", c => { | ||
static get Import() { | ||
return Ob; | ||
return Pb; | ||
} | ||
@@ -1526,3 +1526,3 @@ get types() { | ||
} | ||
;class Rb extends Y { | ||
;class Sb extends Y { | ||
constructor() { | ||
@@ -1542,3 +1542,3 @@ super(); | ||
super.b("", d, ...e); | ||
c && (this.f = c.replace(/\n\s*/g, " ")); | ||
c && (this.f = c.replace(/\r?\n\s*/g, " ")); | ||
b && (this.async = !0); | ||
@@ -1565,9 +1565,9 @@ } | ||
} | ||
;const Sb = (a, b) => { | ||
;const Tb = (a, b) => { | ||
const c = new RegExp(`([!?])?${a}\\.`, "g"); | ||
b.properties.forEach(d => { | ||
sb(d, a, c); | ||
tb(d, a, c); | ||
}); | ||
b.m(a); | ||
}, Tb = (a, b) => { | ||
}, Ub = (a, b) => { | ||
var {args:c = []} = a, d = c.map(({I:f}) => f).join(", "); | ||
@@ -1581,5 +1581,5 @@ let e = `new: ${a.fullName}`; | ||
c.examples = a.examples; | ||
sb(c, b); | ||
tb(c, b); | ||
a.properties.unshift(c); | ||
}, Vb = (a, b, c = null) => { | ||
}, Wb = (a, b, c = null) => { | ||
a = S("types", a); | ||
@@ -1593,5 +1593,5 @@ if (!a.length) { | ||
"record" == p && (p = "type", n.record = !0); | ||
const {alias:r, aliases:q, ...t} = n; | ||
c && R(t, c); | ||
var u = r ? [r] : q ? q.split(/, */) : []; | ||
const {alias:t, aliases:r, ...u} = n; | ||
c && R(u, c); | ||
var v = t ? [t] : r ? r.split(/, */) : []; | ||
switch(p) { | ||
@@ -1603,14 +1603,14 @@ case "type": | ||
k.push(p); | ||
u.forEach(v => { | ||
const x = new Y; | ||
c && (x.file = c); | ||
x.b(m, {...t, name:v}, g, b); | ||
k.push(x); | ||
v.forEach(w => { | ||
const y = new Y; | ||
c && (y.file = c); | ||
y.b(m, {...u, name:w}, g, b); | ||
k.push(y); | ||
}); | ||
break; | ||
case "interface": | ||
n = Ub({content:m, props:n, ns:g, B:b, location:c}); | ||
n.forEach(v => { | ||
v.properties.some(({isConstructor:x}) => x) || Tb(v, b); | ||
v.isInterface = !0; | ||
n = Vb({content:m, props:n, ns:g, B:b, location:c}); | ||
n.forEach(w => { | ||
w.properties.some(({isConstructor:y}) => y) || Ub(w, b); | ||
w.isInterface = !0; | ||
}); | ||
@@ -1620,6 +1620,6 @@ k.push(...n); | ||
case "constructor": | ||
n = Ub({content:m, props:n, ns:g, B:b, location:c}); | ||
n.forEach(v => { | ||
v.properties.some(({isConstructor:x}) => x) || Tb(v, b); | ||
v.isConstructor = !0; | ||
n = Vb({content:m, props:n, ns:g, B:b, location:c}); | ||
n.forEach(w => { | ||
w.properties.some(({isConstructor:y}) => y) || Ub(w, b); | ||
w.isConstructor = !0; | ||
}); | ||
@@ -1629,14 +1629,14 @@ k.push(...n); | ||
case "method": | ||
n = Ub({content:m, props:n, ns:g, B:b, isMethod:!0, location:c}); | ||
n = Vb({content:m, props:n, ns:g, B:b, isMethod:!0, location:c}); | ||
k.push(...n); | ||
break; | ||
case "import": | ||
u = new Ob, u.b(m, n, n.ns || n.from, b), h.push(u); | ||
v = new Pb, v.b(m, n, n.ns || n.from, b), h.push(v); | ||
} | ||
return k; | ||
}, []); | ||
b && l.forEach(k => Sb(b, k)); | ||
b && l.forEach(k => Tb(b, k)); | ||
return {namespace:f, types:l, imports:h, embeds:a}; | ||
}, Wb = (a, b, c, d, e = !1, f = null) => { | ||
const g = e ? new Rb : new Y; | ||
}, Xb = (a, b, c, d, e = !1, f = null) => { | ||
const g = e ? new Sb : new Y; | ||
g.file = f; | ||
@@ -1646,14 +1646,14 @@ f = a.search(/<(prop|function|fn|static) /); | ||
1 != f && (h = a.slice(0, f), l = a.slice(f)); | ||
const {F:k, J:m} = ob(h, d); | ||
const {F:k, J:m} = pb(h, d); | ||
g.b(e ? m : l, b, c, d); | ||
({H:a} = eb(b, k)); | ||
({H:a} = fb(b, k)); | ||
e && (g.closureType = a); | ||
g.args || (g.args = k); | ||
return g; | ||
}, Ub = ({content:a, props:b, ns:c, B:d, isMethod:e = !1, location:f = null}) => { | ||
}, Vb = ({content:a, props:b, ns:c, B:d, isMethod:e = !1, location:f = null}) => { | ||
const g = [], {alias:h, aliases:l, ...k} = b; | ||
b = Wb(a, b, c, d, e, f); | ||
b = Xb(a, b, c, d, e, f); | ||
g.push(b); | ||
(h ? [h] : l ? l.split(/, */) : []).forEach(m => { | ||
m = Wb(a, {...k, name:m}, c, d, e, f); | ||
m = Xb(a, {...k, name:m}, c, d, e, f); | ||
m.description = `${m.description}${m.description ? " " : ""}Alias of \`${k.name}\`.`; | ||
@@ -1663,9 +1663,9 @@ g.push(m); | ||
return g; | ||
}, Xb = async(a, b = []) => { | ||
const c = await G(a); | ||
}, Yb = async(a, b = []) => { | ||
const c = await H(a); | ||
let d, e, f, g; | ||
try { | ||
({namespace:d = null, types:e, imports:f, embeds:g} = Vb(c, void 0, a)); | ||
({namespace:d = null, types:e, imports:f, embeds:g} = Wb(c, void 0, a)); | ||
} catch (h) { | ||
throw h.message = `Error while reading ${a}\n${h.message}`, h; | ||
throw h.message = `Error while reading ${a}${C}${h.message}`, h; | ||
} | ||
@@ -1676,18 +1676,18 @@ e = e.filter(({fullName:h}) => b.includes(h) ? !1 : !0); | ||
}; | ||
const Yb = (a, b, c) => { | ||
const Zb = (a, b, c) => { | ||
b = b.map(d => d.g(!0, c)); | ||
a = a.map(d => { | ||
d = d.g(); | ||
return M(c ? d : P(d)); | ||
return M(c ? d : N(d)); | ||
}); | ||
return [...b, ...a].join(""); | ||
}, Zb = (a, b, c, d = !1) => { | ||
}, $b = (a, b, c, d = !1) => { | ||
a = [...a.map(e => { | ||
{ | ||
let f; | ||
e.closureType ? f = ` * @typedef {${e.closureType}}` : e.u || (f = ` * @typedef {${Mb(e.properties, !0)}}`); | ||
f ? (e.description && (f = ` * ${e.description}\n${f}`), f = M(f), e = f += db(e.namespace, e.name)) : e = Ib(e); | ||
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); | ||
} | ||
return e; | ||
})].join("\n"); | ||
})].join(C); | ||
return `${!b || d || c.includes(b) ? "" : `/** @const */ | ||
@@ -1697,42 +1697,42 @@ var ${b} = {} | ||
}; | ||
async function $b(a, b, c) { | ||
async function ac(a, b, c) { | ||
const [d, ...e] = c.split(/\s+/); | ||
var f = e.includes("closure"); | ||
const g = e.includes("externs"), h = e.includes("noSuppress"), l = e.includes("skipNsDecl"), k = e.includes("namespace"), m = e.includes("noEmbed") || e.includes("no-embed"); | ||
let n = e.find(q => q.startsWith("ignore:")); | ||
let n = e.find(r => r.startsWith("ignore:")); | ||
n = n ? n.replace("ignore:", "").split(",") : []; | ||
let {o:p, w:r} = this.f; | ||
let {o:p, w:t} = this.f; | ||
f && (p = !0); | ||
g && (r = !0); | ||
g && (t = !0); | ||
try { | ||
this.i("Detected type marker: %s", c); | ||
const {types:q, imports:t, namespace:u, embeds:v} = await Xb(d, n); | ||
this.emit("types", q); | ||
this.emit("types", t); | ||
const {types:r, imports:u, namespace:v, embeds:w} = await Yb(d, n); | ||
this.emit("types", r); | ||
this.emit("types", u); | ||
f = []; | ||
m || (f = await Promise.all(v.map(async({src:C, path:gc = C, ignore:N = n.join(","), namespace:hc = k, o:ic = p, w:jc = r, "no-suppress":kc = h}) => { | ||
C = [gc]; | ||
N && C.push(`ignore:${N}`); | ||
hc && C.push("namespace"); | ||
ic && C.push("closure"); | ||
jc && C.push("ext"); | ||
kc && C.push("noSuppress"); | ||
N = C.join(" "); | ||
return await $b.call(this, `\n /* typal-embed ${N} */\n`, "typal-embed", N); | ||
m || (f = await Promise.all(w.map(async({src:D, path:hc = D, ignore:O = n.join(","), namespace:ic = k, o:jc = p, w:kc = t, "no-suppress":lc = h}) => { | ||
D = [hc]; | ||
O && D.push(`ignore:${O}`); | ||
ic && D.push("namespace"); | ||
jc && D.push("closure"); | ||
kc && D.push("ext"); | ||
lc && D.push("noSuppress"); | ||
O = D.join(" "); | ||
return await ac.call(this, `${C} /* typal-embed ${O} */${C}`, "typal-embed", O); | ||
}))); | ||
let x = f.join(""), O; | ||
p ? O = Yb(t, q, h) : r ? (O = Zb(q, u, this.b, l) + "\n", u && this.emit("namespace", u)) : k ? (u && this.emit("namespace", u), O = ac(t, q, !0)) : O = ac(t, q); | ||
return `/* ${b} ${c} */\n${O}${x}`; | ||
} catch (q) { | ||
return this.i("(%s) Could not process typedef-js: %s", c, q.message), process.env.b && console.error(q.stack), a; | ||
let y = f.join(""), P; | ||
p ? P = Zb(u, r, h) : t ? (P = $b(r, v, this.b, l) + C, v && this.emit("namespace", v)) : k ? (v && this.emit("namespace", v), P = bc(u, r, !0)) : P = bc(u, r); | ||
return `/* ${b} ${c} */${C}${P}${y}`; | ||
} catch (r) { | ||
return this.i("(%s) Could not process typedef-js: %s", c, r.message), process.env.b && console.error(r.stack), a; | ||
} | ||
} | ||
const bc = {re:/^\/\*\*? (documentary|typal) (.+?) \*\/\n(?:([^\n][\s\S]+?\n))?$/mg, replacement:$b}, ac = (a, b, c = !1) => { | ||
const cc = {re:/^\/\*\*? (documentary|typal) (.+?) \*\/\r?\n(?:([^\n][\s\S]+?\r?\n))?$/mg, replacement:ac}, bc = (a, b, c = !1) => { | ||
b = b.map(d => d.g(!1, !1, c)); | ||
a = a.map(d => d.g(c)).map(M).join(""); | ||
b = b.join(""); | ||
return `${a}${b}`.replace(cc, " * @typedef"); | ||
}, cc = / \*\/\n\/\*\*\n \* @typedef/g; | ||
const ec = {re:/( *) \* @param {(.+?)} (\[)?([^\s\]]+)\]?(?: .+)?((?:\n(?: +)\* @param {(?:.+?)} \[?\4\]?(?:(?!\n\s*\*(?:\/|\s*@))[\s\S])*)*)/gm, replacement:dc}; | ||
function dc(a, b, c, d, e, f, g) { | ||
return `${a}${b}`.replace(dc, " * @typedef"); | ||
}, dc = / \*\/\r?\n\/\*\*\r?\n \* @typedef/g; | ||
const fc = {re:/( *) \* @param {(.+?)} (\[)?([^\s\]]+)\]?(?: .+)?((?:\r?\n(?: +)\* @param {(?:.+?)} \[?\4\]?(?:(?!\r?\n\s*\*(?:\/|\s*@))[\s\S])*)*)/gm, replacement:ec}; | ||
function ec(a, b, c, d, e, f, g) { | ||
const h = this.f.o, l = this.f.D; | ||
@@ -1744,14 +1744,14 @@ let k; | ||
{ | ||
let q = n = 0; | ||
for (; q < g;) { | ||
q += this.lines[n].length, n++; | ||
let r = n = 0; | ||
for (; r < g;) { | ||
r += this.lines[n].length, n++; | ||
} | ||
n = {line:n, P:b.length + 11}; | ||
} | ||
const {line:p, P:r} = n; | ||
this.i("%s:%s:%s", this.file, p, r); | ||
const {line:p, P:t} = n; | ||
this.i("%s:%s:%s", this.file, p, t); | ||
} | ||
}; | ||
try { | ||
k = lb(c); | ||
k = mb(c); | ||
} catch (n) { | ||
@@ -1768,3 +1768,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 || l ? p == k.name : n == k.name); | ||
return !c || c instanceof Qb.Import ? a : c.C(e, d, b, k.nullable, h, l); | ||
return !c || c instanceof Rb.Import ? a : c.C(e, d, b, k.nullable, h, l); | ||
} | ||
@@ -1777,3 +1777,3 @@ const Z = (a, b, c, d, e) => { | ||
let h = b.includes(f); | ||
h || (h = fc.includes(f)); | ||
h || (h = gc.includes(f)); | ||
if (h) { | ||
@@ -1797,10 +1797,10 @@ return !0; | ||
} | ||
}, fc = "String Boolean Object Date Number Symbol Buffer Function".split(" "); | ||
var lc = (a, b = !1) => { | ||
var {S:c} = Ta(); | ||
const d = Va(c); | ||
c = Ua(c); | ||
return new Qb(b ? [bc] : [bc, d, ec, c], a); | ||
}, gc = "String Boolean Object Date Number Symbol Buffer Function".split(" "); | ||
var mc = (a, b = !1) => { | ||
var {S:c} = Ua(); | ||
const d = Wa(c); | ||
c = Va(c); | ||
return new Rb(b ? [cc] : [cc, d, fc, c], a); | ||
}; | ||
const mc = /( *) \* @(fnType|methodType) {(.+?)}/gm, nc = (a, b, c, d, e, f, g = d) => `/** | ||
const nc = /( *) \* @(fnType|methodType) {(.+?)}/gm, oc = (a, b, c, d, e, f, g = d) => `/** | ||
${a} | ||
@@ -1811,3 +1811,3 @@ */ | ||
}`; | ||
class oc extends Ya { | ||
class pc extends Za { | ||
constructor(a, b) { | ||
@@ -1822,17 +1822,17 @@ super([{re:/\/\*\*\s+( *) \* @constructor {(.+?)}[\s\S]+?(class\s+.+?\s+extends\s+(.+?)\s*){\s*}/gm, replacement(c, d, e, f, g) { | ||
var n = k.aliases; | ||
const p = k.static, r = k.async; | ||
let q = V(k, "", !0); | ||
q = pc(q, e); | ||
const t = k.args.map(({name:u}) => u).join(", "); | ||
k = nc(q, p, r, m, t, g); | ||
n = n.map(u => nc(q + `\n * @alias ${m} An alias for **${m}**.`, p, r, u, t, g, m)); | ||
return [k, ...n].join("\n"); | ||
const p = k.static, t = k.async; | ||
let r = V(k, "", !0); | ||
r = qc(r, e); | ||
const u = k.args.map(({name:v}) => v).join(", "); | ||
k = oc(r, p, t, m, u, g); | ||
n = n.map(v => oc(r + `${C} * @alias ${m} An alias for **${m}**.`, p, t, v, u, g, m)); | ||
return [k, ...n].join(C); | ||
}); | ||
const h = d.properties.find(k => k instanceof W && k.isConstructor), l = h.args.map(({name:k}) => k).join(", "); | ||
c = [`/** | ||
${pc(V(h, "", !0), e)} | ||
${qc(V(h, "", !0), e)} | ||
*/ | ||
constructor(${l}) { | ||
super(${l}) | ||
}`, ...c].join("\n").replace(/^/gm, " "); | ||
}`, ...c].join(C).replace(/^/gm, " "); | ||
f = `${f}{ | ||
@@ -1843,5 +1843,5 @@ ${c} | ||
${U(d.description)} | ||
*/\n` + f); | ||
*/${C}` + f); | ||
return f; | ||
}}, {re:mc, async replacement(c, d, e, f) { | ||
}}, {re:nc, async replacement(c, d, e, f) { | ||
const g = f.split("."); | ||
@@ -1867,3 +1867,3 @@ let h, l; | ||
if ("constructor" == l || "methodType" == e) { | ||
return f.h(d, !1, !0).join("\n"); | ||
return f.h(d, !1, !0).join(C); | ||
} | ||
@@ -1875,9 +1875,9 @@ e = f.properties.find(({name:k}) => k == l); | ||
} | ||
const pc = (a, b) => a.replace(`\n * @return {${b}}`, "").replace(`\n * @return {!${b}}`, "").replace(`\n * @return {?${b}}`, ""); | ||
const qc = async a => a ? (await Promise.all(a.split(",").map(async b => { | ||
const qc = (a, b) => a.replace(`${C} * @return {${b}}`, "").replace(`${C} * @return {!${b}}`, "").replace(`${C} * @return {?${b}}`, ""); | ||
const rc = async a => a ? (await Promise.all(a.split(",").map(async b => { | ||
var c = []; | ||
const d = await I(A, b); | ||
const d = await J(A, b); | ||
d.isFile() ? c = [b] : d.isDirectory() && (c = await K(b), c = L(c.content, b), c = c.filter(e => e.endsWith(".xml"))); | ||
return c; | ||
}))).reduce((b, c) => [...b, ...c], []) : [], rc = 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], []) : [], sc = async a => (await Promise.all(a.map(async b => ({...await Yb(b), location:b})))).reduce((b, {imports:c, types:d}) => { | ||
b.push(...c); | ||
@@ -1887,59 +1887,59 @@ b.push(...d); | ||
}, []); | ||
async function sc() { | ||
const a = await qc(ma), b = await rc(a); | ||
await Promise.all(y.map(async c => { | ||
var d = await I(A, c); | ||
async function tc() { | ||
const a = await rc(ma), b = await sc(a); | ||
await Promise.all(x.map(async c => { | ||
var d = await J(A, c); | ||
let e; | ||
d.isFile() ? e = [c] : d.isDirectory() && (d = await K(c), e = L(d.content, c)); | ||
await tc(e, b, na); | ||
await uc(e, b, na); | ||
})); | ||
} | ||
const tc = async(a, b = [], c = null) => { | ||
const uc = async(a, b = [], c = null) => { | ||
await Promise.all(a.map(async d => { | ||
var e = await G(d); | ||
const f = new oc(b, d); | ||
var e = await H(d); | ||
const f = new pc(b, d); | ||
f.end(e); | ||
e = await F(f); | ||
"-" == c ? console.log(e) : c ? await H(c, e) : await H(d, e); | ||
e = await G(f); | ||
"-" == c ? console.log(e) : c ? await I(c, e) : await I(d, e); | ||
})); | ||
}; | ||
var vc = async() => { | ||
const {o:a = !1, D:b = !1, w:c = !1, V:d, types:e} = {o:ja, w:la, V:z, types:ma, D:ka}, f = await qc(e); | ||
await Promise.all(y.map(async g => { | ||
var h = await I(A, g); | ||
var wc = async() => { | ||
const {o:a = !1, D:b = !1, w:c = !1, V:d, types:e} = {o:ja, w:la, V:z, types:ma, D:ka}, f = await rc(e); | ||
await Promise.all(x.map(async g => { | ||
var h = await J(A, g); | ||
let l; | ||
h.isFile() ? l = [g] : h.isDirectory() && (h = await K(g), l = L(h.content, g)); | ||
await uc(l, a, c, d, f, b); | ||
await vc(l, a, c, d, f, b); | ||
})); | ||
}; | ||
const uc = async(a, b = !1, c = !1, d = "", e = [], f = !1) => { | ||
const vc = async(a, b = !1, c = !1, d = "", e = [], f = !1) => { | ||
const g = []; | ||
await Promise.all(e.map(async h => { | ||
h = await G(h); | ||
const {types:l, imports:k} = Vb(h); | ||
h = await H(h); | ||
const {types:l, imports:k} = Wb(h); | ||
g.push(l, k); | ||
})); | ||
await Promise.all(a.map(async h => { | ||
var l = await G(h); | ||
const k = lc({o:b, w:c, D:f}, c); | ||
var l = await H(h); | ||
const k = mc({o:b, w:c, D:f}, c); | ||
g.forEach(m => k.emit("types", m)); | ||
k.file = h; | ||
k.i = console.error; | ||
k.lines = l.split("\n"); | ||
k.lines = l.split(C); | ||
k.end(l); | ||
l = await F(k); | ||
"-" == d ? console.log(l) : d ? await H(d, l) : await H(h, l); | ||
l = await G(k); | ||
"-" == d ? console.log(l) : d ? await I(d, l) : await I(h, l); | ||
})); | ||
}; | ||
const wc = a => { | ||
const xc = a => { | ||
let b; | ||
"true" == a ? b = !0 : "false" == a ? b = !1 : /^\d+$/.test(a) && (b = parseInt(a, 10)); | ||
return void 0 !== b ? b : a; | ||
}, xc = /^ \* @prop {(.+?)} (\[)?(.+?)(?:=(["'])?(.+?)\4)?(?:])?(?: (.+?))?(?: Default `(.+?)`.)?$/gm, yc = "type opt name quote defaultValue description Default".split(" "), $a = new RegExp(`^ \\* @typedef {(.+?)} (.+?)(?: (.+))?\\n((?:${/ \* @prop(?:erty)? .+\n/.source})*)`, "gm"), zc = (a, b, c, d) => { | ||
}, 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) => { | ||
d = d.length; | ||
a = a && "Object" != a ? ` type="${a}"` : ""; | ||
c = c ? ` desc="${c}"` : ""; | ||
return `${" ".repeat(2)}<type name="${b}"${a}${c}${d ? "" : " /"}>\n`; | ||
return `${" ".repeat(2)}<type name="${b}"${a}${c}${d ? "" : " /"}>${C}`; | ||
}; | ||
class Ac extends B { | ||
class Bc extends B { | ||
constructor() { | ||
@@ -1949,3 +1949,3 @@ super({writableObjectMode:!0}); | ||
_transform({type:a, name:b, description:c, properties:d}, e, f) { | ||
a = a && a.startsWith("import") ? Bc(a, b) : zc(a, b, c, d); | ||
a = a && a.startsWith("import") ? Cc(a, b) : Ac(a, b, c, d); | ||
this.push(a); | ||
@@ -1960,11 +1960,11 @@ d.forEach(({type:g, name:h, default:l, description:k, optional:m}) => { | ||
const p = " ".repeat(6); | ||
h = `${n}<prop${m}${g} name="${h}"${l}${k ? `>\n${p}${k}\n${n}</prop>` : "/>"}\n`; | ||
h = `${n}<prop${m}${g} name="${h}"${l}${k ? `>${C}${p}${k}${C}${n}</prop>` : "/>"}${C}`; | ||
} | ||
this.push(h); | ||
}); | ||
d.length && this.push(" </type>\n"); | ||
d.length && this.push(` </type>${C}`); | ||
f(); | ||
} | ||
} | ||
const Bc = (a, b) => { | ||
const Cc = (a, b) => { | ||
const c = /import\((['"])(.+?)\1\)/.exec(a); | ||
@@ -1975,5 +1975,5 @@ if (!c) { | ||
[, , a] = c; | ||
return `${" ".repeat(2)}<import name="${b}" from="${a}" />\n`; | ||
return `${" ".repeat(2)}<import name="${b}" from="${a}" />${C}`; | ||
}; | ||
class Cc extends B { | ||
class Dc extends B { | ||
constructor() { | ||
@@ -1983,11 +1983,11 @@ super({objectMode:!0}); | ||
_transform([, a, b, c, d], e, f) { | ||
d = fb(xc, d, yc).map(g => { | ||
d = gb(yc, d, zc).map(g => { | ||
const {defaultValue:h, Default:l, opt:k, name:m, type:n, ...p} = g; | ||
g = {...p, name:m, type:n, ...h ? {defaultValue:wc(h)} : {}, ...l ? {v:wc(l)} : {}, ...k ? {optional:!0} : {}}; | ||
g = {...p, name:m, type:n, ...h ? {defaultValue:xc(h)} : {}, ...l ? {v:xc(l)} : {}, ...k ? {optional:!0} : {}}; | ||
if (h || l) { | ||
if (h) { | ||
h !== l && void 0 !== g.v && (r = ab(m, l, n), console.error("%s[%s] does not match Default `%s`.", b, r, g.v)); | ||
h !== l && void 0 !== g.v && (t = bb(m, l, n), console.error("%s[%s] does not match Default `%s`.", b, t, g.v)); | ||
} else { | ||
var r = ab(m, l, n); | ||
console.error("%s[%s] got from Default.", b, r); | ||
var t = bb(m, l, n); | ||
console.error("%s[%s] got from Default.", b, t); | ||
} | ||
@@ -2004,4 +2004,4 @@ g.default = "defaultValue" in g ? g.defaultValue : g.v; | ||
} | ||
async function Dc(a) { | ||
const b = Za(), c = new Cc, d = new Ac; | ||
async function Ec(a) { | ||
const b = $a(), c = new Dc, d = new Bc; | ||
b.pipe(c).pipe(d); | ||
@@ -2022,10 +2022,10 @@ b.end(a); | ||
return `<types> | ||
${(await F(d)).trim()} | ||
${(await G(d)).trim()} | ||
</types>`; | ||
} | ||
;var Ec = async() => { | ||
await Promise.all(y.map(async a => { | ||
a = await G(a); | ||
a = await Dc(a); | ||
z ? await H(z, a) : console.log(a); | ||
;var Fc = async() => { | ||
await Promise.all(x.map(async a => { | ||
a = await H(a); | ||
a = await Ec(a); | ||
z ? await I(z, a) : console.log(a); | ||
})); | ||
@@ -2062,3 +2062,3 @@ }; | ||
try { | ||
return oa ? await Ec() : na ? await sc() : await vc(); | ||
return oa ? await Fc() : na ? await tc() : await wc(); | ||
} catch (a) { | ||
@@ -2065,0 +2065,0 @@ process.env.DEBUG ? console.log(a.stack) : console.log(a.message); |
#!/usr/bin/env node | ||
const os = require('os'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const stream = require('stream'); | ||
const os = require('os'); | ||
const stream = require('stream'); | ||
var w = "function" == typeof Object.defineProperties ? Object.defineProperty : function(a, b, d) { | ||
@@ -42,3 +42,4 @@ a != Array.prototype && a != Object.prototype && (a[b] = d.value); | ||
}); | ||
function B(a, b, d) { | ||
const B = os.EOL, C = os.homedir; | ||
function D(a, b, d) { | ||
const c = []; | ||
@@ -58,11 +59,11 @@ b.replace(a, (e, ...g) => { | ||
} | ||
;const C = new RegExp(`${/([^\s>=/]+)/.source}(?:\\s*=\\s*${/(?:"([\s\S]*?)"|'([\s\S]*?)')/.source})?`, "g"), D = new RegExp(`(?:\\s+((?:${C.source}\\s*)*))`); | ||
const F = (a, b) => { | ||
;const E = new RegExp(`${/([^\s>=/]+)/.source}(?:\\s*=\\s*${/(?:"([\s\S]*?)"|'([\s\S]*?)')/.source})?`, "g"), F = new RegExp(`(?:\\s+((?:${E.source}\\s*)*))`); | ||
const G = (a, b) => { | ||
a = (Array.isArray(a) ? a : [a]).join("|"); | ||
return B(new RegExp(`<(${a})${D.source}?(?:${/\s*\/>/.source}|${/>([\s\S]+?)?<\/\1>/.source})`, "g"), b, "t a v v1 v2 c".split(" ")).map(({t:d, a:c = "", c:e = ""}) => { | ||
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 = ""}) => { | ||
c = c.replace(/\/$/, "").trim(); | ||
c = E(c); | ||
c = aa(c); | ||
return {content:e, props:c, tag:d}; | ||
}); | ||
}, E = a => B(C, a, ["key", "val", "def", "f"]).reduce((b, {key:d, val:c}) => { | ||
}, aa = a => D(E, a, ["key", "val", "def", "f"]).reduce((b, {key:d, val:c}) => { | ||
if (void 0 === c) { | ||
@@ -74,3 +75,3 @@ return b[d] = !0, b; | ||
}, {}); | ||
const G = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => { | ||
const ba = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => { | ||
switch(b) { | ||
@@ -92,3 +93,3 @@ case "function": | ||
}); | ||
function aa(a) { | ||
function ca(a) { | ||
let b = 0; | ||
@@ -251,6 +252,6 @@ const d = (e = 1) => a[b + e], c = (e = !0, g = []) => { | ||
;function H(a) { | ||
a = G(a); | ||
return aa(a); | ||
a = ba(a); | ||
return ca(a); | ||
} | ||
;const ba = path.dirname, ca = path.resolve; | ||
;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 => { | ||
@@ -266,7 +267,7 @@ a = a.trimRight(); | ||
} | ||
var d = a.substr(0, b).lastIndexOf("\n"); | ||
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("\n"); | ||
d = a.split(B); | ||
if (d.filter(e => /\S/.test(e)).find(e => !e.startsWith(c))) { | ||
@@ -277,3 +278,3 @@ return a.trim(); | ||
const e = new RegExp(`^ {${b}}`); | ||
return d.map(g => g.replace(e, "")).join("\n"); | ||
return d.map(g => g.replace(e, "")).join(B); | ||
} | ||
@@ -284,3 +285,3 @@ }, K = (a, b, d = null) => { | ||
a || (a = b.map(({s:k, name:h}) => "this" == h ? `${h}: ${k}` : h.startsWith("...") ? `...${k}` : k).join(",")); | ||
b = g.replace(/\n\s*/g, " "); | ||
b = g.replace(/\r?\n\s*/g, " "); | ||
c && b ? b = `!Promise<${b}>` : c && (b = "!Promise"); | ||
@@ -293,5 +294,5 @@ d = `function(${"constructor" == f.name ? `new: ${d}, ` : ""}${a})`; | ||
const d = a.example; | ||
d && d.startsWith(".") && b && (a.example = ca(ba(b), d)); | ||
d && d.startsWith(".") && b && (a.example = ea(da(b), d)); | ||
} | ||
;function da(a, b, {name:d, string:c, "boolean":e, opt:g, number:f, type:k}, h) { | ||
;function fa(a, b, {name:d, string:c, "boolean":e, opt:g, number:f, type:k}, h) { | ||
if (!d) { | ||
@@ -308,3 +309,3 @@ throw Error("Argument does not have a name."); | ||
} | ||
class ea { | ||
class ha { | ||
constructor() { | ||
@@ -323,5 +324,5 @@ this.name = null; | ||
var e = []; | ||
-1 != d && (d += 6, e = a.slice(0, d), c = a.slice(d), e = F("arg", e), e = e.map(({content:g, props:f}) => { | ||
const k = new ea; | ||
da(k, g, f, b); | ||
-1 != d && (d += 6, e = a.slice(0, d), c = a.slice(d), e = G("arg", e), e = e.map(({content:g, props:f}) => { | ||
const k = new ha; | ||
fa(k, g, f, b); | ||
return k; | ||
@@ -331,5 +332,5 @@ })); | ||
}; | ||
const fa = fs.readFileSync; | ||
const ha = a => { | ||
const b = a.replace(/^\s*\n/gm, "").split("\n").reduce((d, c) => { | ||
const ia = fs.readFileSync; | ||
const ja = a => { | ||
const b = a.replace(/^\s*\r?\n/gm, "").split(B).reduce((d, c) => { | ||
[{length:c = 0} = {}] = /^\s*/.exec(c) || []; | ||
@@ -343,5 +344,5 @@ return c < d ? c : d; | ||
return a.split(/\s*,\s*/).map(c => { | ||
let e = c = fa(c, "utf8"); | ||
let e = c = ia(c, "utf8"); | ||
if (c = /\/\* start example \*\/\r?\n([\s\S]+?)\r?\n\s*\/\* end example \*\//.exec(c)) { | ||
[, c] = c, e = ha(c); | ||
[, c] = c, e = ja(c); | ||
} | ||
@@ -463,4 +464,4 @@ d.forEach(g => { | ||
} | ||
;function ia(a, b, d, c) { | ||
var e = F("prop", a).map(({content:h, props:l}) => { | ||
;function ka(a, b, d, c) { | ||
var e = G("prop", a).map(({content:h, props:l}) => { | ||
const n = new P; | ||
@@ -471,3 +472,3 @@ L(l, d); | ||
}); | ||
a = F(["function", "fn", "static"], a).map(({content:h, props:l, tag:n}) => { | ||
a = G(["function", "fn", "static"], a).map(({content:h, props:l, tag:n}) => { | ||
n = "static" == n; | ||
@@ -537,3 +538,3 @@ const {w:m, j:p} = M(h, b); | ||
const {flatten:e = !1, nameProcess:g, link:f = ({link:l}) => `#${l}`} = c; | ||
c = ja(b, a); | ||
c = la(b, a); | ||
d = `${d}${a}`; | ||
@@ -548,3 +549,3 @@ if (!c) { | ||
return h ? `<a href="${k}" title="${h.replace(/"/g, """)}">${b}</a>` : `[${b}](${k})`; | ||
}, ja = (a, b) => { | ||
}, la = (a, b) => { | ||
a = a.filter(({fullName:c}) => c == b); | ||
@@ -557,3 +558,3 @@ if (a.length) { | ||
}; | ||
function ka(a, b = [], d = [], c = {}) { | ||
function ma(a, b = [], d = [], c = {}) { | ||
const {narrow:e = !1, preprocessDesc:g} = c; | ||
@@ -570,3 +571,3 @@ if (!b.length) { | ||
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:la(t, !e), d:r, G:l}; | ||
return {prop:m, typeName:p, name:q, de:na(t, !e), d:r, G:l}; | ||
}); | ||
@@ -584,3 +585,3 @@ if (e) { | ||
} | ||
const la = (a = "", b = !0) => { | ||
const na = (a = "", b = !0) => { | ||
null === a && (a = ""); | ||
@@ -590,3 +591,3 @@ b && (a = a.replace(/\|/g, "\\|")); | ||
}; | ||
const ma = (a, b, d = {}) => { | ||
const oa = (a, b, d = {}) => { | ||
function c(e) { | ||
@@ -635,3 +636,3 @@ e.replace(/^!?/, ""); | ||
if (a) { | ||
const {properties:u, constructor:v} = ia(a, z, this.f, this.fullName); | ||
const {properties:u, constructor:v} = ka(a, z, this.f, this.fullName); | ||
v && (this.args = v.args); | ||
@@ -666,3 +667,3 @@ this.properties = u; | ||
if (this.extends) { | ||
const l = ma(this.extends, a, b), n = ` extends ${l}`; | ||
const l = oa(this.extends, a, b), n = ` extends ${l}`; | ||
h = h || /_/.test(l); | ||
@@ -675,3 +676,3 @@ f = (h ? f + "<strong>" : f + "__") + (g + n); | ||
f = (h ? f + "</strong>" : f + "__") + k; | ||
a = ka(this, this.properties, a, b); | ||
a = ma(this, this.properties, a, b); | ||
return {LINE:f, table:a, displayInDetails:e}; | ||
@@ -693,3 +694,3 @@ } | ||
super.b("", c, ...e); | ||
d && (this.g = d.replace(/\n\s*/g, " ")); | ||
d && (this.g = d.replace(/\r?\n\s*/g, " ")); | ||
b && (this.async = !0); | ||
@@ -705,3 +706,3 @@ } | ||
} | ||
;class na extends U { | ||
;class pa extends U { | ||
constructor() { | ||
@@ -723,5 +724,4 @@ super(); | ||
} | ||
;const oa = os.homedir; | ||
oa(); | ||
const pa = (a, b) => { | ||
;C(); | ||
const qa = (a, b) => { | ||
const d = new RegExp(`([!?])?${a}\\.`, "g"); | ||
@@ -787,3 +787,3 @@ b.properties.forEach(c => { | ||
module.exports = {_Type:U, _Property:P, _Method:W, _parseFile:(a, b, d = null) => { | ||
a = F("types", a); | ||
a = G("types", a); | ||
if (!a.length) { | ||
@@ -793,4 +793,4 @@ 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; | ||
a = F(["embed"], c).map(({props:l}) => l); | ||
const k = [], h = F("type interface constructor method import record".split(" "), c).reduce((l, {content:n, props:m, tag:p}) => { | ||
a = G(["embed"], c).map(({props:l}) => l); | ||
const k = [], h = G("type interface constructor method import record".split(" "), c).reduce((l, {content:n, props:m, tag:p}) => { | ||
"record" == p && (p = "type", m.record = !0); | ||
@@ -834,7 +834,7 @@ const {alias:q, aliases:r, ...t} = m; | ||
case "import": | ||
z = new na, z.b(n, m, m.ns || m.from, b), k.push(z); | ||
z = new pa, z.b(n, m, m.ns || m.from, b), k.push(z); | ||
} | ||
return l; | ||
}, []); | ||
b && h.forEach(l => pa(b, l)); | ||
b && h.forEach(l => qa(b, l)); | ||
return {namespace:g, types:h, imports:k, embeds:a}; | ||
@@ -841,0 +841,0 @@ }, _getLinks:S}; |
{ | ||
"name": "typal", | ||
"version": "1.26.1", | ||
"version": "1.26.2", | ||
"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.", | ||
@@ -16,4 +16,4 @@ "main": "compile/index.js", | ||
"dev": "alanode src/bin/typal", | ||
"doc": "NODE_DEBUG=doc doc -o README.md", | ||
"wiki": "DEPACK_MAX_COLUMNS=80 NODE_DEBUG=doc doc wiki -W wiki.git -n _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", | ||
@@ -76,6 +76,6 @@ "lib": "depack src/depack -c -o compile/typal.js -a -p -s --source_map_include_content", | ||
"@wrote/read": "^1.0.4", | ||
"@wrote/read-dir-structure": "^1.3.0", | ||
"@wrote/read-dir-structure": "^1.3.1", | ||
"@wrote/write": "^1.0.4", | ||
"@zoroaster/mask": "^2.4.0", | ||
"alamode": "^3.3.1", | ||
"alamode": "^3.3.2", | ||
"argufy": "^1.7.5", | ||
@@ -95,3 +95,3 @@ "catchment": "^3.3.0", | ||
"yarn-s": "1.2.3", | ||
"zoroaster": "^4.1.2" | ||
"zoroaster": "^4.2.0" | ||
}, | ||
@@ -98,0 +98,0 @@ "srcDependencies": { |
@@ -10,2 +10,3 @@ import read from '@wrote/read' | ||
import { getTypes } from './template' | ||
import { EOL } from 'os' | ||
@@ -58,3 +59,3 @@ /** | ||
js.LOG = console.error | ||
js.lines = content.split('\n') | ||
js.lines = content.split(EOL) | ||
js.end(content) | ||
@@ -61,0 +62,0 @@ const res = await collect(js) |
import Type from '../Type' // eslint-disable-line | ||
import Import from '../Import' // eslint-disable-line | ||
import { makeBlock, addSuppress } from '../' | ||
import { EOL } from 'os' | ||
@@ -57,3 +58,3 @@ // import { builtinModules } from 'module' | ||
const blocks = [...tblocks, ...iblocks] | ||
.join('\n') | ||
.join(EOL) | ||
const n = namespace && !skipNsDecl && !currentNamespaces.includes(namespace) ? `/** @const */ | ||
@@ -60,0 +61,0 @@ var ${namespace} = {} |
@@ -6,2 +6,3 @@ import { Transform } from 'stream' | ||
import { getNameWithDefault } from './' | ||
import { EOL } from 'os' | ||
@@ -17,6 +18,6 @@ const getVal = (val) => { | ||
export const propExtractRe = /^ \* @prop {(.+?)} (\[)?(.+?)(?:=(["'])?(.+?)\4)?(?:])?(?: (.+?))?(?: Default `(.+?)`.)?$/gm | ||
const propRe = / \* @prop(?:erty)? .+\n/ | ||
const propRe = / \* @prop(?:erty)? .+\r?\n/ | ||
const keys = ['type', 'opt', 'name', 'quote', 'defaultValue', 'description', 'Default'] | ||
const typedefRe = new RegExp(`^ \\* @typedef {(.+?)} (.+?)(?: (.+))?\\n((?:${propRe.source})*)`, 'gm') | ||
const typedefRe = new RegExp(`^ \\* @typedef {(.+?)} (.+?)(?: (.+))?\\r?\\n((?:${propRe.source})*)`, 'gm') | ||
@@ -28,3 +29,3 @@ const makeType = (type, name, description, properties) => { | ||
const i = ' '.repeat(2) | ||
const t = `${i}<type name="${name}"${tt}${d}${hasProps ? '' : ' /'}>\n` | ||
const t = `${i}<type name="${name}"${tt}${d}${hasProps ? '' : ' /'}>${EOL}` | ||
return t | ||
@@ -40,4 +41,4 @@ } | ||
const ii = ' '.repeat(6) | ||
const desc = description ? `>\n${ii}${description}\n${i}</prop>` : '/>' | ||
const p = `${i}<prop${o}${t} name="${name}"${def}${desc}\n` | ||
const desc = description ? `>${EOL}${ii}${description}${EOL}${i}</prop>` : '/>' | ||
const p = `${i}<prop${o}${t} name="${name}"${def}${desc}${EOL}` | ||
return p | ||
@@ -65,3 +66,3 @@ } | ||
}) | ||
if (properties.length) this.push(' </type>\n') | ||
if (properties.length) this.push(` </type>${EOL}`) | ||
next() | ||
@@ -76,3 +77,3 @@ } | ||
const i = ' '.repeat(2) | ||
return `${i}<import name="${name}" from="${from}" />\n` | ||
return `${i}<import name="${name}" from="${from}" />${EOL}` | ||
} | ||
@@ -79,0 +80,0 @@ |
import { resolve, dirname } from 'path' | ||
import { EOL } from 'os' | ||
@@ -109,3 +110,3 @@ /** | ||
const s = d.substr(0, i) | ||
let n = s.lastIndexOf('\n') | ||
let n = s.lastIndexOf(EOL) | ||
// remove everything before first /n | ||
@@ -119,3 +120,3 @@ if (n == -1) n = 0 | ||
const w = ' '.repeat(ws) | ||
const dd = d.split('\n') | ||
const dd = d.split(EOL) | ||
const a = dd.filter(b => /\S/.test(b)) | ||
@@ -128,3 +129,3 @@ const notWithSpace = a.find(b => { | ||
const re = new RegExp(`^ {${ws}}`) | ||
return dd.map(b => b.replace(re, '')).join('\n') | ||
return dd.map(b => b.replace(re, '')).join(EOL) | ||
} else return d.trim() | ||
@@ -152,3 +153,3 @@ } | ||
let r = ret.replace(/\n\s*/g, ' ') | ||
let r = ret.replace(/\r?\n\s*/g, ' ') | ||
if (async && r) r = `!Promise<${r}>` | ||
@@ -155,0 +156,0 @@ else if (async) r = '!Promise' |
@@ -8,3 +8,3 @@ import { makeMarkers, makeCutRule, makePasteRule } from 'restream' | ||
const { externsTypedef } = makeMarkers({ | ||
externsTypedef: /^\/\*\*? (documentary|typal) (.+?) externs (.*?)\*\/\n(?:([^\n][\s\S]+?\n))?$/mg, | ||
externsTypedef: /^\/\*\*? (documentary|typal) (.+?) externs (.*?)\*\/\r?\n(?:([^\r\n][\s\S]+?\r?\n))?$/mg, | ||
}) | ||
@@ -11,0 +11,0 @@ // to exclude @params in externs block from JSDoc warnings |
@@ -29,3 +29,3 @@ import Type from './Type' | ||
super.fromXML('', props, ...args) | ||
if (methodReturn) this._methodReturn = methodReturn.replace(/\n\s*/g, ' ') | ||
if (methodReturn) this._methodReturn = methodReturn.replace(/\r?\n\s*/g, ' ') | ||
if (methodAsync) this.async = true | ||
@@ -32,0 +32,0 @@ } |
@@ -9,2 +9,3 @@ import extractTags from 'rexml' | ||
import Fn from './Fn' | ||
import { EOL } from 'os' | ||
@@ -234,3 +235,3 @@ /** | ||
} catch (err) { | ||
err.message = `Error while reading ${path}\n${err.message}` | ||
err.message = `Error while reading ${path}${EOL}${err.message}` | ||
throw err | ||
@@ -237,0 +238,0 @@ } |
@@ -6,2 +6,3 @@ import parse from '@typedefs/parser' | ||
import { readFileSync } from 'fs' | ||
import { EOL } from 'os' | ||
@@ -13,3 +14,3 @@ /** | ||
export const indentWithAster = (string, skipFirst = false) => { | ||
const d = string.split('\n').map((l, i) => { | ||
const d = string.split(EOL).map((l, i) => { | ||
if (skipFirst && !i) return l | ||
@@ -20,3 +21,3 @@ let s = ' *' | ||
return s | ||
}).join('\n') | ||
}).join(EOL) | ||
return d | ||
@@ -28,5 +29,5 @@ } | ||
const s = boundExample | ||
.replace(/^\s*\n/gm, '') // remove empty lines | ||
.replace(/^\s*\r?\n/gm, '') // remove empty lines | ||
const minLength = s | ||
.split('\n') | ||
.split(EOL) | ||
.reduce((acc, current) => { | ||
@@ -268,5 +269,5 @@ const [{ length = 0 } = {}] = /^\s*/.exec(current) || [] | ||
}) | ||
const e = exampleLines.join('\n') | ||
const e = exampleLines.join(EOL) | ||
.replace(/\*/g, '*') | ||
if (e) s += `\n${e}` | ||
if (e) s += `${EOL}${e}` | ||
} | ||
@@ -277,3 +278,3 @@ return s | ||
let s = this.description || '' | ||
const d = this.hasDefault ? `${/``` */.test(this.description) ? '\n' : | ||
const d = this.hasDefault ? `${/``` */.test(this.description) ? EOL : | ||
(s ? ' ' : '')}Default \`${this.default}\`.` : '' | ||
@@ -377,3 +378,3 @@ return `${s}${d}` | ||
const d = indentWithAster(descriptionWithDefault) | ||
pp.push(...d.split('\n')) | ||
pp.push(...d.split(EOL)) | ||
} | ||
@@ -392,3 +393,3 @@ if (!this.optional && this.isParsedFunction) { | ||
if (ws) pp = pp.map(p => `${ws}${p}`) | ||
return pp.join('\n') | ||
return pp.join(EOL) | ||
} | ||
@@ -402,3 +403,3 @@ /** | ||
examples.forEach((example) => { | ||
const exampleLines = example.split('\n') | ||
const exampleLines = example.split(EOL) | ||
let currentComment = [], currentBlock = [] | ||
@@ -417,6 +418,6 @@ let state = '', newState | ||
if (newState == 'block') { | ||
acc.push(currentComment.join('\n')) | ||
acc.push(currentComment.join(EOL)) | ||
currentComment = [] | ||
} else { | ||
acc.push(currentBlock.join('\n')) | ||
acc.push(currentBlock.join(EOL)) | ||
currentBlock = [] | ||
@@ -429,5 +430,5 @@ } | ||
if (currentComment.length) { | ||
eg.push(currentComment.join('\n')) | ||
eg.push(currentComment.join(EOL)) | ||
} else if (currentBlock.length) { | ||
eg.push(currentBlock.join('\n')) | ||
eg.push(currentBlock.join(EOL)) | ||
} | ||
@@ -437,6 +438,6 @@ eg = eg.reduce((acc, e) => { | ||
e = e.replace(/^\/\/\/\s+/gm, '') | ||
acc.push(...e.split('\n')) | ||
acc.push(...e.split(EOL)) | ||
} else { | ||
acc.push('```js') | ||
acc.push(...e.split('\n')) | ||
acc.push(...e.split(EOL)) | ||
acc.push('```') | ||
@@ -453,5 +454,5 @@ } | ||
const s = this.toJSDoc(parentParam, closure, useNamespace) | ||
const [firstLine, ...rest] = s.split('\n') | ||
const [firstLine, ...rest] = s.split(EOL) | ||
const m = [`@param ${firstLine}`, ...rest].map(l => `${ws} * ${l}`) | ||
const p = m.join('\n') | ||
const p = m.join(EOL) | ||
return p | ||
@@ -458,0 +459,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import { EOL } from 'os' | ||
import { Replaceable } from 'restream' | ||
@@ -44,7 +45,7 @@ import Type from './Type' // eslint-disable-line | ||
const t = aliases.map((al) => { | ||
const alJsdoc = jsdoc + `\n * @alias ${name} An alias for **${name}**.` | ||
const alJsdoc = jsdoc + `${EOL} * @alias ${name} An alias for **${name}**.` | ||
return makeMethod(alJsdoc, Static, Async, al, ja, ext, name) | ||
}) | ||
const strings = [s, ...t] | ||
return strings.join('\n') | ||
return strings.join(EOL) | ||
}) | ||
@@ -61,3 +62,3 @@ const constr = type.properties.find((prop) => { | ||
}` | ||
const s = [c, ...tt].join('\n').replace(/^/gm, ' ') | ||
const s = [c, ...tt].join(EOL).replace(/^/gm, ' ') | ||
let res = `${cl}{ | ||
@@ -69,3 +70,3 @@ ${s} | ||
${indentWithAster(type.description)} | ||
*/\n` + res | ||
*/${EOL}` + res | ||
} | ||
@@ -98,3 +99,3 @@ return res | ||
const lines = type.toHeading(ws, false, true) | ||
return lines.join('\n') | ||
return lines.join(EOL) | ||
} | ||
@@ -123,5 +124,5 @@ const fn = type.properties.find(({ name }) => { | ||
return jsdoc | ||
.replace(`\n * @return {${type}}`, '') | ||
.replace(`\n * @return {!${type}}`, '') | ||
.replace(`\n * @return {?${type}}`, '') | ||
.replace(`${EOL} * @return {${type}}`, '') | ||
.replace(`${EOL} * @return {!${type}}`, '') | ||
.replace(`${EOL} * @return {?${type}}`, '') | ||
} |
@@ -0,1 +1,2 @@ | ||
import { EOL } from 'os' | ||
import extractProperties from './extract-props' | ||
@@ -159,3 +160,3 @@ import Property, { indentWithAster } from '../Property' | ||
if (s) { | ||
if (this.description) s = ` * ${this.description}\n${s}` | ||
if (this.description) s = ` * ${this.description}${EOL}${s}` | ||
s = makeBlock(s) | ||
@@ -219,3 +220,3 @@ s = s + getExternDeclaration(this.namespace, this.name) | ||
}) | ||
let typedef = [s, ...p].join('\n') | ||
let typedef = [s, ...p].join(EOL) | ||
if (closure && !noSuppress) typedef = addSuppress(typedef) | ||
@@ -336,3 +337,3 @@ typedef = makeBlock(typedef) | ||
// if (this.closureType) pp.push(` * @type {${this.closureType}}`) // todo <arg>new</arg> | ||
let s = makeBlock(pp.join('\n')) | ||
let s = makeBlock(pp.join(EOL)) | ||
s = s + getExternDeclaration(this.namespace, this.name, this.toExternsAssignment()) | ||
@@ -359,3 +360,3 @@ /** @type {!Array<!(Property|Fn)>} */ | ||
}) | ||
const j = [s, ...t].join('\n') | ||
const j = [s, ...t].join(EOL) | ||
return j | ||
@@ -394,3 +395,3 @@ } | ||
}) : [] | ||
const st = [s, ...p].join('\n') | ||
const st = [s, ...p].join(EOL) | ||
return st | ||
@@ -397,0 +398,0 @@ } |
@@ -8,3 +8,3 @@ import parser from '@typedefs/parser' | ||
*/ | ||
export const jsDocRe = /( *) \* @param {(.+?)} (\[)?([^\s\]]+)\]?(?: .+)?((?:\n(?: +)\* @param {(?:.+?)} \[?\4\]?(?:(?!\n\s*\*(?:\/|\s*@))[\s\S])*)*)/gm | ||
export const jsDocRe = /( *) \* @param {(.+?)} (\[)?([^\s\]]+)\]?(?: .+)?((?:\r?\n(?: +)\* @param {(?:.+?)} \[?\4\]?(?:(?!\r?\n\s*\*(?:\/|\s*@))[\s\S])*)*)/gm | ||
@@ -11,0 +11,0 @@ /** |
@@ -5,2 +5,3 @@ import { makeBlock } from '../' | ||
import Import from '../Import' // eslint-disable-line | ||
import { EOL } from 'os' | ||
import { readTypesFile } from '../parse' | ||
@@ -12,3 +13,3 @@ import { closureJoinTypes, externsJoinTypes } from '../closure' | ||
*/ | ||
export const typedefJsRe = /^\/\*\*? (documentary|typal) (.+?) \*\/\n(?:([^\n][\s\S]+?\n))?$/mg | ||
export const typedefJsRe = /^\/\*\*? (documentary|typal) (.+?) \*\/\r?\n(?:([^\n][\s\S]+?\r?\n))?$/mg | ||
@@ -60,3 +61,3 @@ /** | ||
const l = a.join(' ') | ||
const s = `\n /* typal-embed ${l} */\n` | ||
const s = `${EOL} /* typal-embed ${l} */${EOL}` | ||
const e = await replacement.call(this, s, 'typal-embed', l) | ||
@@ -71,3 +72,3 @@ return e | ||
} else if (externs) { | ||
block = externsJoinTypes(types, namespace, this.namespaces, skipNsDecl) + '\n' | ||
block = externsJoinTypes(types, namespace, this.namespaces, skipNsDecl) + EOL | ||
if (namespace) this.emit('namespace', namespace) | ||
@@ -81,3 +82,3 @@ } else if (useNamespace) { | ||
const typedef = `/* ${docOrTypal} ${location} */\n${block}${bem}` | ||
const typedef = `/* ${docOrTypal} ${location} */${EOL}${block}${bem}` | ||
return typedef | ||
@@ -117,3 +118,3 @@ } catch (e) { | ||
const m = / \*\/\n\/\*\*\n \* @typedef/g | ||
const m = / \*\/\r?\n\/\*\*\r?\n \* @typedef/g | ||
@@ -120,0 +121,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
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
520358
6216