Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typal

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typal - npm Package Compare versions

Comparing version 1.9.2 to 1.10.0

14

build/lib/typedef/rule.js

@@ -23,2 +23,6 @@ let read = require('@wrote/read'); if (read && read.__esModule) read = read.default;

const noSuppress = args.includes('noSuppress')
let ignore = args.find((a) => {
return a.startsWith('ignore:')
})
ignore = ignore ? ignore.replace('ignore:', '').split(',') : []

@@ -32,3 +36,11 @@ let { closure, externs } = this.conf // for closure, suppress typedef

const xml = await read(loc)
const { namespace = null, types, imports } = parseFile(xml)
let { namespace = null, types, imports } = parseFile(xml)
types = types.filter(({ fullName }) => {
if (ignore.includes(fullName)) return false
return true
})
imports = imports.filter(({ fullName }) => {
if (ignore.includes(fullName)) return false
return true
})

@@ -35,0 +47,0 @@ this.emit('types', types) // remember types for js-replace-stream

## 30 April 2019
### [1.10.0](https://github.com/artdecocode/typal/compare/v1.9.2...v1.10.0)
- [feature] Ignore types from the marker.
### [1.9.2](https://github.com/artdecocode/typal/compare/v1.9.1...v1.9.2)

@@ -4,0 +8,0 @@

183

depack/bin/typal.js

@@ -7,3 +7,3 @@ #!/usr/bin/env node

const path = require('path');
const t = (a, b, c, d, e) => {
const u = (a, b, c, d, e) => {
d = void 0 === d ? !1 : d;

@@ -37,3 +37,3 @@ e = void 0 === e ? !1 : e;

}, ba = () => {
var a = u;
var a = v;
return Object.keys(a).reduce((b, c) => {

@@ -52,4 +52,4 @@ const d = a[c];

};
const u = {source:{description:"The path to the source file or directory with files to embed types into.", command:!0, multiple:!0}, output:{description:"The destination where to save output.\nIf not passed, the file will be overwritten.\nIf `-` is passed, prints to stdout.", short:"o"}, closure:{description:"Whether to generate types in _Closure_ mode.", boolean:!0, short:"c"}, 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"}, 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) {
const v = {source:{description:"The path to the source file or directory with files to embed types into.", command:!0, multiple:!0}, output:{description:"The destination where to save output.\nIf not passed, the file will be overwritten.\nIf `-` is passed, prints to stdout.", short:"o"}, closure:{description:"Whether to generate types in _Closure_ mode.", boolean:!0, short:"c"}, 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"}, 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"}}, x = function(a, b) {
a = void 0 === a ? {} : a;

@@ -71,7 +71,7 @@ b = void 0 === b ? process.argv : b;

if ("string" == typeof h) {
({value:k, argv:e} = t(e, f, h));
({value:k, argv:e} = u(e, f, h));
} else {
try {
const {short:l, boolean:m, number:n, command:p, multiple:q} = h;
p && q && c.length ? (k = c, d = !0) : p && c.length ? (k = c[0], d = !0) : {value:k, argv:e} = t(e, f, l, m, n);
p && q && c.length ? (k = c, d = !0) : p && c.length ? (k = c[0], d = !0) : {value:k, argv:e} = u(e, f, l, m, n);
} catch (l) {

@@ -83,3 +83,3 @@ return Object.assign({}, {j:e}, g);

}, {j:b});
}(u), x = w.source, y = w.output, ca = w.closure, da = w.externs, ea = w.types, fa = w.migrate, ha = w.help, ia = w.version;
}(v), y = x.source, z = x.output, ca = x.closure, da = x.externs, ea = x.types, fa = x.migrate, ha = x.help, ia = x.version;
function ja(a = {usage:{}}) {

@@ -103,3 +103,3 @@ const {usage:b = {}, description:c, line:d, example:e} = a;

const r = h("", g);
n = q.map(v => `${r}\t${v}`);
n = q.map(t => `${r}\t${t}`);
return [...l, m, ...n];

@@ -117,6 +117,6 @@ }, []).map(l => `\t${l}`);

}
;const {createReadStream:ka, createWriteStream:la, lstat:z, readdir:ma} = fs;
;const {createReadStream:ka, createWriteStream:la, lstat:A, readdir:ma} = fs;
var na = stream;
const {Transform:A, Writable:oa} = stream;
const B = (a, b = 0, c = !1) => {
const {Transform:B, Writable:oa} = stream;
const C = (a, b = 0, c = !1) => {
if (0 === b && !c) {

@@ -127,3 +127,3 @@ return a;

return c ? a[a.length - 1] : a.slice(b).join("\n");
}, pa = (a, b = !1) => B(a, 2 + (b ? 1 : 0)), C = a => {
}, pa = (a, b = !1) => C(a, 2 + (b ? 1 : 0)), D = a => {
({callee:{caller:a}} = a);

@@ -133,6 +133,6 @@ return a;

const {homedir:qa} = os;
const D = /\s+at.*(?:\(|\s)(.*)\)?/, ra = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/, sa = qa(), E = a => {
const E = /\s+at.*(?:\(|\s)(.*)\)?/, ra = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/, sa = qa(), F = a => {
const {pretty:b = !1, ignoredModules:c = ["pirates"]} = {}, d = c.join("|"), e = new RegExp(ra.source.replace("IGNORED_MODULES", d));
return a.replace(/\\/g, "/").split("\n").filter(f => {
f = f.match(D);
f = f.match(E);
if (null === f || !f[1]) {

@@ -143,16 +143,16 @@ 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(D, (g, h) => g.replace(h, h.replace(sa, "~"))) : f).join("\n");
}).filter(f => f.trim()).map(f => b ? f.replace(E, (g, h) => g.replace(h, h.replace(sa, "~"))) : f).join("\n");
};
function ta(a, b, c = !1) {
return function(d) {
var e = C(arguments), {stack:f} = Error();
const g = B(f, 2, !0), h = (f = d instanceof Error) ? d.message : d;
var e = D(arguments), {stack:f} = Error();
const g = C(f, 2, !0), h = (f = d instanceof Error) ? d.message : d;
e = [`Error: ${h}`, ...null !== e && a === e || c ? [b] : [g, b]].join("\n");
e = E(e);
e = F(e);
return Object.assign(f ? d : Error(), {message:h, stack:e});
};
}
;function F(a) {
;function G(a) {
var {stack:b} = Error();
const c = C(arguments);
const c = D(arguments);
b = pa(b, a);

@@ -172,3 +172,3 @@ return ta(c, b, a);

b = (delete c.binary, delete c.rs, c);
const {J:f = F(!0), proxyError:g} = a || {}, h = (k, l) => f(l);
const {J:f = G(!0), proxyError:g} = a || {}, h = (k, l) => f(l);
super(b);

@@ -187,3 +187,3 @@ this.a = [];

} else {
const n = E(m.stack);
const n = F(m.stack);
m.stack = n;

@@ -201,20 +201,20 @@ g && h`${m}`;

}
get f() {
get g() {
return this.H;
}
}
const G = async a => {
const H = async a => {
var b = void 0 === b ? {} : b;
({f:a} = new va(Object.assign({}, {rs:a}, b, {J:F(!0)})));
({g:a} = new va(Object.assign({}, {rs:a}, b, {J:G(!0)})));
return await a;
};
async function H(a) {
async function I(a) {
a = ka(a);
return await G(a);
return await H(a);
}
;async function I(a, b) {
;async function J(a, b) {
if (!a) {
throw Error("No path is given.");
}
const c = F(!0), d = la(a);
const c = G(!0), d = la(a);
await new Promise((e, f) => {

@@ -233,3 +233,3 @@ d.on("error", g => {

async function L(a, b, c) {
const d = F(!0);
const d = G(!0);
if ("function" !== typeof a) {

@@ -255,3 +255,3 @@ throw Error("Function must be passed.");

const d = M(a, c);
return {lstat:await L(z, d), path:d, relativePath:c};
return {lstat:await L(A, d), path:d, relativePath:c};
});

@@ -265,3 +265,3 @@ return await Promise.all(b);

}
if (!(await L(z, a)).isDirectory()) {
if (!(await L(A, a)).isDirectory()) {
throw a = Error("Path is not a directory"), a.code = "ENOTDIR", a;

@@ -551,3 +551,3 @@ }

}
;function V(a, b, {name:c, type:d, desc:e, noToc:f, spread:g, noExpand:h, "import":k, link:l, closure:m, constructor:n, "extends":p, "interface":q, record:r}, v) {
;function V(a, b, {name:c, type:d, desc:e, noToc:f, spread:g, noExpand:h, "import":k, link:l, closure:m, constructor:n, "extends":p, "interface":q, record:r}, t) {
if (!c) {

@@ -567,10 +567,10 @@ throw Error("Type does not have a name.");

!0 === q && (a.a = q);
!0 === r && (a.f = r);
!0 === r && (a.g = r);
p && (a.extends = p);
b && (a.c = T("prop", b).map(({content:J, v:Ta}) => {
b && (a.f = T("prop", b).map(({content:w, v:Ta}) => {
const Y = new Ja;
Ha(Y, J, Ta);
Ha(Y, w, Ta);
return Y;
}));
v && (a.i = v);
t && (a.i = t);
}

@@ -587,3 +587,3 @@ function Ka(a) {

b += R(a.i, a.name);
const c = a.c.map(d => {
const c = a.f.map(d => {
var e = [];

@@ -601,3 +601,3 @@ if (d.description) {

`;
return e += R(`${a.g}.prototype`, d.name);
return e += R(`${a.c}.prototype`, d.name);
});

@@ -612,3 +612,3 @@ return [b, ...c].join("\n");

var d = ` * @typedef {${(b ? a.b : a.type) || "Object"}}${` ${W(a, b)}${a.description ? ` ${a.description}` : ""}`}`;
a = a.c ? a.c.map(e => Ia(e, b)) : [];
a = a.f ? a.f.map(e => Ia(e, b)) : [];
d = [d, ...a].join("\n");

@@ -624,3 +624,3 @@ b && !c && (d = Q(d));

if (a.i && b) {
let h = ` * @typedef {${a.g}} ${a.name}${d}`;
let h = ` * @typedef {${a.c}} ${a.name}${d}`;
b && !c && (h = Q(h));

@@ -633,3 +633,3 @@ h = `/**

}
e && (a = ` * @typedef {${a.extends} & ${W(a, b)}} ${b ? a.g : a.name}${d}`, b && !c && (a = Q(a)), a = `/**
e && (a = ` * @typedef {${a.extends} & ${W(a, b)}} ${b ? a.c : a.name}${d}`, b && !c && (a = Q(a)), a = `/**
${a}

@@ -645,9 +645,9 @@ */

this.link = this.m = this.import = this.o = this.G = this.description = this.b = this.type = null;
this.c = [];
this.f = [];
this.i = null;
this.f = this.a = this.isConstructor = !1;
this.g = this.a = this.isConstructor = !1;
this.extends = null;
}
get K() {
return this.isConstructor || this.a || this.f;
return this.isConstructor || this.a || this.g;
}

@@ -661,3 +661,3 @@ get C() {

}
if (this.f) {
if (this.g) {
return "record";

@@ -670,3 +670,3 @@ }

}
get g() {
get c() {
return `${this.l}${this.name}`;

@@ -678,5 +678,5 @@ }

d = this.description ? ` ${this.description}` : "";
const g = this.o ? Na(this.c) : e ? this.g : this.name;
const g = this.o ? Na(this.f) : e ? this.c : this.name;
b = `${c || ""} * @param {${f}${g}} ${b ? `[${a}]` : a}${d}`;
f = this.c && !this.m ? this.c.map(h => h.F(a, c, e)) : [];
f = this.f && !this.m ? this.f.map(h => h.F(a, c, e)) : [];
return [b, ...f].join("\n");

@@ -716,5 +716,5 @@ }

b instanceof na ? b.pipe(a) : a.end(b);
return await G(a);
return await H(a);
}
class Ra extends A {
class Ra extends B {
constructor(a, b) {

@@ -783,3 +783,3 @@ super(b);

} catch (d) {
a = E(d.stack), d.stack = a, c(d);
a = F(d.stack), d.stack = a, c(d);
}

@@ -791,3 +791,3 @@ }

let b = "";
const c = new A({transform(d, e, f) {
const c = new B({transform(d, e, f) {
let g;

@@ -809,3 +809,3 @@ for (b += d.toString(); (d = a.exec(b)) && (c.push(d), g = d, a.global);) {

function Wa(a, b = !0) {
return ` * @typedef {import('${a.from}').${a.name}} ${b ? a.g : a.name}`;
return ` * @typedef {import('${a.from}').${a.name}} ${b ? a.c : a.name}`;
}

@@ -817,3 +817,3 @@ class Xa {

}
get g() {
get c() {
return `${this.l}.${this.name}`;

@@ -823,3 +823,3 @@ }

;function Ya(a, b) {
b = b.reduce((c, d) => Object.assign({}, c, {[d.g]:d}), {});
b = b.reduce((c, d) => Object.assign({}, c, {[d.c]:d}), {});
a.w = Object.assign({}, a.w, b);

@@ -836,6 +836,6 @@ }

this.on("namespace", c => {
this.f.includes(c) || this.f.push(c);
this.g.includes(c) || this.g.push(c);
});
this.o = b;
this.f = [];
this.g = [];
this.h = console.log;

@@ -891,3 +891,3 @@ this.file = null;

let e;
d.b ? e = ` * @typedef {${d.b}}` : d.K || (e = ` * @typedef {${Na(d.c, !0)}}`);
d.b ? e = ` * @typedef {${d.b}}` : d.K || (e = ` * @typedef {${Na(d.f, !0)}}`);
e ? (d.description && (e = ` * ${d.description}\n${e}`), e = `/**

@@ -906,15 +906,20 @@ ${e}

const [d, ...e] = c.split(/\s+/), f = e.includes("closure"), g = e.includes("externs"), h = e.includes("noSuppress");
let {u:k, B:l} = this.o;
f && (k = !0);
g && (l = !0);
let k = e.find(n => n.startsWith("ignore:"));
k = k ? k.replace("ignore:", "").split(",") : [];
let {u:l, B:m} = this.o;
f && (l = !0);
g && (m = !0);
try {
this.h("Detected type marker: %s", c);
const m = await H(d), {i:n = null, types:p, imports:q} = $a(m);
this.emit("types", p);
const n = await I(d);
let {i:p = null, types:q, imports:r} = $a(n);
q = q.filter(({c:w}) => k.includes(w) ? !1 : !0);
r = r.filter(({c:w}) => k.includes(w) ? !1 : !0);
this.emit("types", q);
let r;
k ? r = ab(q, p, h) : l ? (r = bb(p, n, this.f) + "\n", n && this.emit("namespace", n)) : r = cb(q, p);
return `/* ${b} ${c} */\n${r}`;
} catch (m) {
return this.h("(%s) Could not process typedef-js: %s", c, m.message), a;
this.emit("types", r);
let t;
l ? t = ab(r, q, h) : m ? (t = bb(q, p, this.g) + "\n", p && this.emit("namespace", p)) : t = cb(r, q);
return `/* ${b} ${c} */\n${t}`;
} catch (n) {
return this.h("(%s) Could not process typedef-js: %s", c, n.message), a;
}

@@ -953,7 +958,7 @@ }}, cb = (a, b) => {

}
const l = Object.values(this.types).map(({name:m, g:n}) => h ? n : m);
const l = Object.values(this.types).map(({name:m, c:n}) => h ? n : m);
if (!Z(k, l, this.h, c, f)) {
return a;
}
c = Object.values(this.types).find(({name:m, g:n}) => h ? n == k.name : m == k.name);
c = Object.values(this.types).find(({name:m, c:n}) => h ? n == k.name : m == k.name);
return c instanceof Za.a ? a : c.F(e, d, b, k.nullable, h);

@@ -986,5 +991,5 @@ }

var ib = async() => {
const {u:a = !1, B:b = !1, D:c, types:d} = {u:ca, B:da, D:y, types:ea};
await Promise.all(x.map(async e => {
var f = await L(z, e);
const {u:a = !1, B:b = !1, D:c, types:d} = {u:ca, B:da, D:z, types:ea};
await Promise.all(y.map(async e => {
var f = await L(A, e);
let g;

@@ -998,3 +1003,3 @@ f.isFile() ? g = [e] : f.isDirectory() && (f = await N(e), g = O(f.content, e));

e && await Promise.all(e.split(",").map(async g => {
g = await H(g);
g = await I(g);
const {types:h, imports:k} = $a(g);

@@ -1004,3 +1009,3 @@ f.push(h, k);

await Promise.all(a.map(async g => {
var h = await H(g);
var h = await I(g);
const k = new Za([db, gb], {u:b, B:c});

@@ -1012,4 +1017,4 @@ f.forEach(l => k.emit("types", l));

k.end(h);
h = await G(k);
"-" == d ? console.log(h) : d ? await I(d, h) : await I(g, h);
h = await H(k);
"-" == d ? console.log(h) : d ? await J(d, h) : await J(g, h);
}));

@@ -1043,3 +1048,3 @@ };

};
class ob extends A {
class ob extends B {
constructor() {

@@ -1049,3 +1054,3 @@ super({writableObjectMode:!0});

_transform(a, b, c) {
var {type:d, name:e, description:f, c:g} = a;
var {type:d, name:e, description:f, f:g} = a;
a = d && d.startsWith("import") ? pb(d, e) : nb(d, e, f, g);

@@ -1060,4 +1065,4 @@ this.push(a);

q = p && !q ? " opt" : "";
const v = " ".repeat(4), J = " ".repeat(6);
h = `${v}<prop${q}${h} name="${l}"${r}${n ? `>\n${J}${n}\n${v}</prop>` : "/>"}\n`;
const t = " ".repeat(4), w = " ".repeat(6);
h = `${t}<prop${q}${h} name="${l}"${r}${n ? `>\n${w}${n}\n${t}</prop>` : "/>"}\n`;
}

@@ -1078,3 +1083,3 @@ this.push(h);

};
class qb extends A {
class qb extends B {
constructor() {

@@ -1098,3 +1103,3 @@ super({objectMode:!0});

});
this.push({type:d, name:e, description:f, c:a});
this.push({type:d, name:e, description:f, f:a});
c();

@@ -1120,11 +1125,11 @@ }

return `<types>
${(await G(d)).trim()}
${(await H(d)).trim()}
</types>`;
}
;var sb = async() => {
const {D:a} = {D:y};
await Promise.all(x.map(async b => {
b = await H(b);
const {D:a} = {D:z};
await Promise.all(y.map(async b => {
b = await I(b);
b = await rb(b);
a ? await I(a, b) : console.log(b);
a ? await J(a, b) : console.log(b);
}));

@@ -1131,0 +1136,0 @@ };

{
"name": "typal",
"version": "1.9.2",
"version": "1.10.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.",

@@ -5,0 +5,0 @@ "main": "build/index.js",

@@ -764,3 +764,3 @@ # Typal

/* typal types/index.xml [closure|externs] [noSuppress] */
/* typal types/index.xml [closure|externs] [noSuppress] [ignore:_ns.Type,Type] */
_ // remember new line!

@@ -772,2 +772,3 @@ ```

- <kbd>noSuppress</kbd>: don't add `@suppress` annotations (see the [files](#keeping-types-in-separate-file) section below).
- <kbd>ignore:_nsType,Type</kbd>: the types to ignore when placing JSDoc into JS files. This can be useful, for example, when the package is built with _Depack_ and has no dependencies, but depends on imported types from other packages. Therefore, these imported types need to be vendored using a separate file, and then imported from there, rather than from their original source file. See [`@zoroaster/mask/types/vendor.js`](https://github.com/contexttesting/mask/blob/master/types/vendor.js) and [`@zoroaster/mask/types/index.js`](https://github.com/contexttesting/mask/blob/master/types/index.js) for a practical application.

@@ -774,0 +775,0 @@ <p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/6.svg?sanitize=true" width="25"></a></p>

@@ -23,2 +23,6 @@ import read from '@wrote/read'

const noSuppress = args.includes('noSuppress')
let ignore = args.find((a) => {
return a.startsWith('ignore:')
})
ignore = ignore ? ignore.replace('ignore:', '').split(',') : []

@@ -32,3 +36,11 @@ let { closure, externs } = this.conf // for closure, suppress typedef

const xml = await read(loc)
const { namespace = null, types, imports } = parseFile(xml)
let { namespace = null, types, imports } = parseFile(xml)
types = types.filter(({ fullName }) => {
if (ignore.includes(fullName)) return false
return true
})
imports = imports.filter(({ fullName }) => {
if (ignore.includes(fullName)) return false
return true
})

@@ -35,0 +47,0 @@ this.emit('types', types) // remember types for js-replace-stream

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc