New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

martok

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

martok - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

23

dist/martok/declarations/DeclarationGenerator.js

@@ -17,11 +17,22 @@ "use strict";

generateDeclarations(file) {
return lodash_1.default.compact(file.statements.map((value) => this.generateDeclaration(value)));
return lodash_1.default.compact(file.statements.flatMap((value) => this.generateDeclaration(value)));
}
generateDeclaration(node) {
if (!KlassGenerator_1.KlassGenerator.isSupportedDeclaration(node)) {
// throw new Error(`Can't handle type ${node.kind}`);
return undefined;
try {
if (!KlassGenerator_1.KlassGenerator.isSupportedDeclaration(node)) {
// throw new Error(`Can't handle type ${node.kind}`);
return undefined;
}
const value = this.klasses.generate(node);
const result = [
typeof value === "string" ? value : this.printer.print(value),
];
if (this.martok.additionalDeclarations.length) {
result.push(...this.martok.additionalDeclarations);
}
return result;
}
const value = this.klasses.generate(node);
return typeof value === "string" ? value : this.printer.print(value);
finally {
this.martok.clearAdditionalDeclarations();
}
}

@@ -28,0 +39,0 @@ }

@@ -52,2 +52,7 @@ "use strict";

if ((0, typescript_1.isTypeAliasDeclaration)(node)) {
if ((0, typescript_1.isArrayTypeNode)(node.type)) {
const result = this.generate(node.type, Object.assign({ forceName: name }, options));
this.martok.additionalDeclarations.push(`typealias ${name} = List<${result.name}>`);
return result;
}
const typeAsEnum = this.enums.generate(name, node.type);

@@ -54,0 +59,0 @@ if (typeAsEnum)

@@ -69,2 +69,5 @@ "use strict";

}
get additionalDeclarations() {
return this.storage.getStore().additionalDeclarations;
}
writeKotlinFiles(outPath) {

@@ -106,2 +109,3 @@ return __awaiter(this, void 0, void 0, function* () {

externalStatements: [],
additionalDeclarations: [],
};

@@ -128,2 +132,5 @@ return this.storage.run(state, () => (0, lodash_1.default)(this.config.files)

}
clearAdditionalDeclarations() {
this.additionalDeclarations.length = 0;
}
processFile(file) {

@@ -130,0 +137,0 @@ console.log(`Process File: ${file.fileName}...`);

{
"name": "martok",
"version": "1.1.3",
"version": "1.1.4",
"description": "",

@@ -12,3 +12,3 @@ "main": "dist/index.js",

"test": "jest",
"special": "ts-node src/index.ts tests/comparisons/single/tagged3.d.ts -o ./schema/martok --package net.sarazan.martok --datePattern standard",
"special": "ts-node src/index.ts tests/comparisons/single/types.d.ts -o ./schema/martok --package net.sarazan.martok --datePattern standard",
"lint": "eslint . --ext .ts"

@@ -15,0 +15,0 @@ },

@@ -15,14 +15,24 @@ import { Martok } from "../Martok";

return _.compact(
file.statements.map((value) => this.generateDeclaration(value))
file.statements.flatMap((value) => this.generateDeclaration(value))
);
}
private generateDeclaration(node: Statement): string | undefined {
if (!KlassGenerator.isSupportedDeclaration(node)) {
// throw new Error(`Can't handle type ${node.kind}`);
return undefined;
private generateDeclaration(node: Statement): string[] | undefined {
try {
if (!KlassGenerator.isSupportedDeclaration(node)) {
// throw new Error(`Can't handle type ${node.kind}`);
return undefined;
}
const value = this.klasses.generate(node);
const result = [
typeof value === "string" ? value : this.printer.print(value),
];
if (this.martok.additionalDeclarations.length) {
result.push(...this.martok.additionalDeclarations);
}
return result;
} finally {
this.martok.clearAdditionalDeclarations();
}
const value = this.klasses.generate(node);
return typeof value === "string" ? value : this.printer.print(value);
}
}

@@ -92,2 +92,12 @@ import { Martok } from "../Martok";

if (isTypeAliasDeclaration(node)) {
if (isArrayTypeNode(node.type)) {
const result = this.generate(node.type, {
forceName: name,
...options,
});
this.martok.additionalDeclarations.push(
`typealias ${name} = List<${(result as Klass).name}>`
);
return result;
}
const typeAsEnum = this.enums.generate(name, node.type);

@@ -94,0 +104,0 @@ if (typeAsEnum) return typeAsEnum;

@@ -19,2 +19,3 @@ import * as ts from "typescript";

externalStatements: ts.Symbol[];
additionalDeclarations: string[];
};

@@ -40,2 +41,5 @@

}
public get additionalDeclarations(): string[] {
return this.storage.getStore()!.additionalDeclarations;
}

@@ -84,2 +88,3 @@ private readonly storage = new AsyncLocalStorage<MartokState>();

externalStatements: [],
additionalDeclarations: [],
};

@@ -112,2 +117,6 @@ return this.storage.run(state, () =>

public clearAdditionalDeclarations() {
this.additionalDeclarations.length = 0;
}
private processFile(file: SourceFile): MartokOutFile {

@@ -114,0 +123,0 @@ console.log(`Process File: ${file.fileName}...`);

@@ -15,1 +15,6 @@ export type FooLike = Foo;

};
export type SomeArray = { foo: string }[];
export type ContainsArray = {
arr: { foo: string }[];
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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