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

tplant

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tplant - npm Package Compare versions

Comparing version 3.1.0 to 3.1.2

4

dist/Components/Class.d.ts

@@ -5,2 +5,3 @@ import { ComponentKind } from '../Models/ComponentKind';

readonly componentKind: ComponentKind;
readonly fileName: string;
isAbstract: boolean;

@@ -11,4 +12,7 @@ isStatic: boolean;

extendsClass: string | undefined;
extendsClassFile: string | undefined;
implementsInterfaces: string[];
implementsInterfacesFiles: string[];
typeParameters: IComponentComposite[];
constructor(name: string, fileName: string);
}

8

dist/Components/Class.js

@@ -10,2 +10,4 @@ "use strict";

return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -22,4 +24,4 @@ function __() { this.constructor = d; }

__extends(Class, _super);
function Class() {
var _this = _super !== null && _super.apply(this, arguments) || this;
function Class(name, fileName) {
var _this = _super.call(this, name) || this;
_this.componentKind = ComponentKind_1.ComponentKind.CLASS;

@@ -31,3 +33,5 @@ _this.isAbstract = false;

_this.implementsInterfaces = [];
_this.implementsInterfacesFiles = [];
_this.typeParameters = [];
_this.fileName = fileName;
return _this;

@@ -34,0 +38,0 @@ }

@@ -10,2 +10,4 @@ "use strict";

return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -12,0 +14,0 @@ function __() { this.constructor = d; }

@@ -10,2 +10,4 @@ "use strict";

return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -12,0 +14,0 @@ function __() { this.constructor = d; }

import { ComponentKind } from '../Models/ComponentKind';
import { IComponentComposite } from '../Models/IComponentComposite';
export declare class File implements IComponentComposite {
import { ComponentComposite, IComponentComposite } from '../Models/IComponentComposite';
export declare class File extends ComponentComposite {
readonly componentKind: ComponentKind;
readonly name: string;
parts: IComponentComposite[];
}
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.File = void 0;
var ComponentKind_1 = require("../Models/ComponentKind");
var File = (function () {
var IComponentComposite_1 = require("../Models/IComponentComposite");
var File = (function (_super) {
__extends(File, _super);
function File() {
this.componentKind = ComponentKind_1.ComponentKind.FILE;
this.name = '';
this.parts = [];
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.componentKind = ComponentKind_1.ComponentKind.FILE;
_this.parts = [];
return _this;
}
return File;
}());
}(IComponentComposite_1.ComponentComposite));
exports.File = File;

@@ -7,3 +7,4 @@ import { ComponentKind } from '../Models/ComponentKind';

extendsInterface: string[];
extendsInterfaceFiles: string[];
typeParameters: IComponentComposite[];
}

@@ -10,2 +10,4 @@ "use strict";

return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -27,2 +29,3 @@ function __() { this.constructor = d; }

_this.extendsInterface = [];
_this.extendsInterfaceFiles = [];
_this.typeParameters = [];

@@ -29,0 +32,0 @@ return _this;

@@ -7,7 +7,10 @@ import { ComponentKind } from '../Models/ComponentKind';

parameters: IComponentComposite[];
typeParameters: IComponentComposite[];
returnType: string;
returnTypeFile: string;
modifier: Modifier;
isAbstract: boolean;
isAsync: boolean;
isOptional: boolean;
isStatic: boolean;
}

@@ -10,2 +10,4 @@ "use strict";

return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -26,5 +28,8 @@ function __() { this.constructor = d; }

_this.parameters = [];
_this.typeParameters = [];
_this.returnType = 'any';
_this.returnTypeFile = '';
_this.modifier = 'public';
_this.isAbstract = false;
_this.isAsync = false;
_this.isOptional = false;

@@ -31,0 +36,0 @@ _this.isStatic = false;

@@ -10,2 +10,4 @@ "use strict";

return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -12,0 +14,0 @@ function __() { this.constructor = d; }

@@ -8,2 +8,3 @@ import { ComponentKind } from '../Models/ComponentKind';

parameterType: string;
parameterTypeFile: string;
}

@@ -10,2 +10,4 @@ "use strict";

return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -28,2 +30,3 @@ function __() { this.constructor = d; }

_this.parameterType = 'any';
_this.parameterTypeFile = '';
return _this;

@@ -30,0 +33,0 @@ }

@@ -10,3 +10,4 @@ import { ComponentKind } from '../Models/ComponentKind';

isOptional: boolean;
isReadonly: boolean;
isStatic: boolean;
}

@@ -10,2 +10,4 @@ "use strict";

return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -29,2 +31,3 @@ function __() { this.constructor = d; }

_this.isOptional = false;
_this.isReadonly = false;
_this.isStatic = false;

@@ -31,0 +34,0 @@ return _this;

@@ -6,2 +6,3 @@ import { ComponentKind } from '../Models/ComponentKind';

constraint: string | undefined;
constraintFile: string | undefined;
}

@@ -10,2 +10,4 @@ "use strict";

return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -12,0 +14,0 @@ function __() { this.constructor = d; }

import ts from 'typescript';
import { Class } from '../Components/Class';
export declare namespace ClassFactory {
function create(classSymbol: ts.Symbol, checker: ts.TypeChecker): Class;
}
export declare function create(fileName: string, classSymbol: ts.Symbol, checker: ts.TypeChecker): Class;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -6,41 +29,43 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.ClassFactory = void 0;
exports.create = void 0;
var typescript_1 = __importDefault(require("typescript"));
var Class_1 = require("../Components/Class");
var ComponentFactory_1 = require("./ComponentFactory");
var ClassFactory;
(function (ClassFactory) {
function create(classSymbol, checker) {
var result = new Class_1.Class(classSymbol.getName());
var classDeclaration = classSymbol.getDeclarations();
if (classDeclaration !== undefined && classDeclaration.length > 0) {
result.isStatic = ComponentFactory_1.ComponentFactory.isStatic(classDeclaration[classDeclaration.length - 1]);
result.isAbstract = ComponentFactory_1.ComponentFactory.isAbstract(classDeclaration[classDeclaration.length - 1]);
var ComponentFactory = __importStar(require("./ComponentFactory"));
function create(fileName, classSymbol, checker) {
var result = new Class_1.Class(classSymbol.getName(), fileName);
var classDeclaration = classSymbol.getDeclarations();
if (classDeclaration !== undefined && classDeclaration.length > 0) {
result.isStatic = ComponentFactory.isModifier(classDeclaration[classDeclaration.length - 1], typescript_1.default.SyntaxKind.StaticKeyword);
result.isAbstract = ComponentFactory.isModifier(classDeclaration[classDeclaration.length - 1], typescript_1.default.SyntaxKind.AbstractKeyword);
}
if (classSymbol.members !== undefined) {
result.constructorMethods = ComponentFactory.serializeConstructors(classSymbol.members, checker);
result.members = ComponentFactory.serializeMethods(classSymbol.members, checker);
result.typeParameters = ComponentFactory.serializeTypeParameters(classSymbol.members, checker);
}
if (classSymbol.exports !== undefined) {
result.members = result.members.concat(ComponentFactory.serializeMethods(classSymbol.exports, checker));
}
if (classSymbol.globalExports !== undefined) {
result.members = result.members.concat(ComponentFactory.serializeMethods(classSymbol.globalExports, checker));
}
if (classDeclaration !== undefined && classDeclaration.length > 0) {
var heritageClauses = classDeclaration[classDeclaration.length - 1].heritageClauses;
if (heritageClauses !== undefined) {
heritageClauses.forEach(function (heritageClause) {
if (heritageClause.token === typescript_1.default.SyntaxKind.ExtendsKeyword) {
var extendsClass = ComponentFactory.getHeritageClauseNames(heritageClause, checker)[0];
result.extendsClass = extendsClass[0];
result.extendsClassFile = extendsClass[1];
}
else if (heritageClause.token === typescript_1.default.SyntaxKind.ImplementsKeyword) {
var implementsInterfaces = ComponentFactory.getHeritageClauseNames(heritageClause, checker);
result.implementsInterfaces = implementsInterfaces.map(function (arr) { return arr[0]; });
result.implementsInterfacesFiles = implementsInterfaces.map(function (arr) { return arr[1]; });
}
});
}
if (classSymbol.members !== undefined) {
result.members = ComponentFactory_1.ComponentFactory.serializeMethods(classSymbol.members, checker);
result.typeParameters = ComponentFactory_1.ComponentFactory.serializeTypeParameters(classSymbol.members, checker);
}
if (classSymbol.exports !== undefined) {
result.members = result.members.concat(ComponentFactory_1.ComponentFactory.serializeMethods(classSymbol.exports, checker));
}
if (classSymbol.globalExports !== undefined) {
result.members = result.members.concat(ComponentFactory_1.ComponentFactory.serializeMethods(classSymbol.globalExports, checker));
}
if (classDeclaration !== undefined && classDeclaration.length > 0) {
var heritageClauses = classDeclaration[classDeclaration.length - 1].heritageClauses;
if (heritageClauses !== undefined) {
heritageClauses.forEach(function (heritageClause) {
if (heritageClause.token === typescript_1.default.SyntaxKind.ExtendsKeyword) {
result.extendsClass = ComponentFactory_1.ComponentFactory.getExtendsHeritageClauseName(heritageClause);
}
else if (heritageClause.token === typescript_1.default.SyntaxKind.ImplementsKeyword) {
result.implementsInterfaces = ComponentFactory_1.ComponentFactory.getImplementsHeritageClauseNames(heritageClause);
}
});
}
}
return result;
}
ClassFactory.create = create;
})(ClassFactory = exports.ClassFactory || (exports.ClassFactory = {}));
return result;
}
exports.create = create;

@@ -7,14 +7,12 @@ import ts from 'typescript';

import { Modifier } from '../Models/Modifier';
export declare namespace ComponentFactory {
function isNodeExported(node: ts.Node): boolean;
function create(node: ts.Node, checker: ts.TypeChecker): IComponentComposite[];
function getExtendsHeritageClauseName(heritageClause: ts.HeritageClause): string;
function getImplementsHeritageClauseNames(heritageClause: ts.HeritageClause): string[];
function getMemberModifier(memberDeclaration: ts.Declaration): Modifier;
function isAbstract(memberDeclaration: ts.Declaration): boolean;
function isStatic(memberDeclaration: ts.Declaration): boolean;
function serializeMethods(memberSymbols: ts.UnderscoreEscapedMap<ts.Symbol>, checker: ts.TypeChecker): (Property | Method)[];
function serializeTypeParameters(memberSymbols: ts.UnderscoreEscapedMap<ts.Symbol>, checker: ts.TypeChecker): TypeParameter[];
function hasInitializer(declaration: ts.ParameterDeclaration): boolean;
function isOptional(declaration: ts.PropertyDeclaration | ts.ParameterDeclaration | ts.MethodDeclaration): boolean;
}
export declare function isNodeExported(node: ts.Node): boolean;
export declare function create(fileName: string, node: ts.Node, checker: ts.TypeChecker): IComponentComposite[];
export declare function getHeritageClauseNames(heritageClause: ts.HeritageClause, checker: ts.TypeChecker): string[][];
export declare function getOriginalFileOriginalType(tsType: ts.Type, checker: ts.TypeChecker): string;
export declare function getMemberModifier(memberDeclaration: ts.Declaration): Modifier;
export declare function isModifier(memberDeclaration: ts.Declaration, modifierKind: ts.SyntaxKind): boolean;
export declare function serializeConstructors(memberSymbols: ts.UnderscoreEscapedMap<ts.Symbol>, checker: ts.TypeChecker): (Property | Method)[];
export declare function serializeMethods(memberSymbols: ts.UnderscoreEscapedMap<ts.Symbol>, checker: ts.TypeChecker): (Property | Method)[];
export declare function serializeTypeParameters(memberSymbols: ts.UnderscoreEscapedMap<ts.Symbol>, checker: ts.TypeChecker): TypeParameter[];
export declare function hasInitializer(declaration: ts.ParameterDeclaration): boolean;
export declare function isOptional(declaration: ts.PropertyDeclaration | ts.ParameterDeclaration | ts.MethodDeclaration): boolean;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -6,186 +29,235 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.ComponentFactory = void 0;
exports.isOptional = exports.hasInitializer = exports.serializeTypeParameters = exports.serializeMethods = exports.serializeConstructors = exports.isModifier = exports.getMemberModifier = exports.getOriginalFileOriginalType = exports.getHeritageClauseNames = exports.create = exports.isNodeExported = void 0;
var typescript_1 = __importDefault(require("typescript"));
var ClassFactory_1 = require("./ClassFactory");
var EnumFactory_1 = require("./EnumFactory");
var InterfaceFactory_1 = require("./InterfaceFactory");
var MethodFactory_1 = require("./MethodFactory");
var NamespaceFactory_1 = require("./NamespaceFactory");
var PropertyFactory_1 = require("./PropertyFactory");
var TypeParameterFactory_1 = require("./TypeParameterFactory");
var ComponentFactory;
(function (ComponentFactory) {
function isNodeExported(node) {
return (node.flags & typescript_1.default.ModifierFlags.Export) !== 0 ||
node.parent.kind === typescript_1.default.SyntaxKind.SourceFile ||
node.parent.kind === typescript_1.default.SyntaxKind.ModuleBlock;
}
ComponentFactory.isNodeExported = isNodeExported;
function create(node, checker) {
var componentComposites = [];
typescript_1.default.forEachChild(node, function (childNode) {
if (!isNodeExported(childNode)) {
var ClassFactory = __importStar(require("./ClassFactory"));
var EnumFactory = __importStar(require("./EnumFactory"));
var InterfaceFactory = __importStar(require("./InterfaceFactory"));
var MethodFactory = __importStar(require("./MethodFactory"));
var NamespaceFactory = __importStar(require("./NamespaceFactory"));
var PropertyFactory = __importStar(require("./PropertyFactory"));
var TypeParameterFactory = __importStar(require("./TypeParameterFactory"));
function isNodeExported(node) {
return (node.flags & typescript_1.default.ModifierFlags.Export) !== 0 ||
node.parent.kind === typescript_1.default.SyntaxKind.SourceFile ||
node.parent.kind === typescript_1.default.SyntaxKind.ModuleBlock;
}
exports.isNodeExported = isNodeExported;
function create(fileName, node, checker) {
var componentComposites = [];
typescript_1.default.forEachChild(node, function (childNode) {
if (!isNodeExported(childNode)) {
return;
}
if (childNode.kind === typescript_1.default.SyntaxKind.ClassDeclaration) {
var currentNode = childNode;
if (currentNode.name === undefined) {
return;
}
if (childNode.kind === typescript_1.default.SyntaxKind.ClassDeclaration) {
var currentNode = childNode;
if (currentNode.name === undefined) {
return;
}
var classSymbol = checker.getSymbolAtLocation(currentNode.name);
if (classSymbol === undefined) {
return;
}
componentComposites.push(ClassFactory_1.ClassFactory.create(classSymbol, checker));
var classSymbol = checker.getSymbolAtLocation(currentNode.name);
if (classSymbol === undefined) {
return;
}
else if (childNode.kind === typescript_1.default.SyntaxKind.InterfaceDeclaration) {
var currentNode = childNode;
var interfaceSymbol = checker.getSymbolAtLocation(currentNode.name);
if (interfaceSymbol === undefined) {
return;
}
componentComposites.push(InterfaceFactory_1.InterfaceFactory.create(interfaceSymbol, checker));
componentComposites.push(ClassFactory.create(fileName, classSymbol, checker));
}
else if (childNode.kind === typescript_1.default.SyntaxKind.InterfaceDeclaration) {
var currentNode = childNode;
var interfaceSymbol = checker.getSymbolAtLocation(currentNode.name);
if (interfaceSymbol === undefined) {
return;
}
else if (childNode.kind === typescript_1.default.SyntaxKind.ModuleDeclaration) {
var currentNode = childNode;
var namespaceSymbol = checker.getSymbolAtLocation(currentNode.name);
if (namespaceSymbol === undefined) {
return;
}
componentComposites.push(NamespaceFactory_1.NamespaceFactory.create(namespaceSymbol, checker));
componentComposites.push(InterfaceFactory.create(interfaceSymbol, checker));
}
else if (childNode.kind === typescript_1.default.SyntaxKind.ModuleDeclaration) {
var currentNode = childNode;
var namespaceSymbol = checker.getSymbolAtLocation(currentNode.name);
if (namespaceSymbol === undefined) {
return;
}
else if (childNode.kind === typescript_1.default.SyntaxKind.EnumDeclaration) {
var currentNode = childNode;
var enumSymbol = checker.getSymbolAtLocation(currentNode.name);
if (enumSymbol === undefined) {
return;
}
componentComposites.push(EnumFactory_1.EnumFactory.create(enumSymbol));
componentComposites.push(NamespaceFactory.create(fileName, namespaceSymbol, checker));
}
else if (childNode.kind === typescript_1.default.SyntaxKind.EnumDeclaration) {
var currentNode = childNode;
var enumSymbol = checker.getSymbolAtLocation(currentNode.name);
if (enumSymbol === undefined) {
return;
}
});
return componentComposites;
}
ComponentFactory.create = create;
function getModifier(modifiers) {
for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) {
var modifier = modifiers_1[_i];
if (modifier.kind === typescript_1.default.SyntaxKind.PrivateKeyword) {
return 'private';
componentComposites.push(EnumFactory.create(enumSymbol));
return;
}
else if (childNode.kind === typescript_1.default.SyntaxKind.FunctionDeclaration) {
var currentNode = childNode;
if (currentNode.name === undefined) {
return;
}
if (modifier.kind === typescript_1.default.SyntaxKind.PublicKeyword) {
return 'public';
var functionSymbol = checker.getSymbolAtLocation(currentNode.name);
if (functionSymbol === undefined) {
return;
}
if (modifier.kind === typescript_1.default.SyntaxKind.ProtectedKeyword) {
return 'protected';
}
componentComposites.push(MethodFactory.create(functionSymbol, currentNode, checker));
}
return 'public';
});
return componentComposites;
}
exports.create = create;
function getModifier(modifiers) {
for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) {
var modifier = modifiers_1[_i];
if (modifier.kind === typescript_1.default.SyntaxKind.PrivateKeyword) {
return 'private';
}
if (modifier.kind === typescript_1.default.SyntaxKind.PublicKeyword) {
return 'public';
}
if (modifier.kind === typescript_1.default.SyntaxKind.ProtectedKeyword) {
return 'protected';
}
}
function getExtendsHeritageClauseName(heritageClause) {
return heritageClause.types[0].expression.text;
return 'public';
}
function getHeritageClauseNames(heritageClause, checker) {
return heritageClause.types.map(function (nodeObject) {
var symbolAtLocation = checker.getSymbolAtLocation(nodeObject.expression);
if (symbolAtLocation !== undefined) {
var ogFile = getOriginalFile(symbolAtLocation, checker);
return [checker.getFullyQualifiedName(symbolAtLocation), ogFile];
}
return ['', ''];
});
}
exports.getHeritageClauseNames = getHeritageClauseNames;
function getOriginalFile(typeSymbol, checker) {
var _a, _b;
var deAliasSymbol;
if ((typeSymbol.flags & typescript_1.default.SymbolFlags.Alias) !== 0) {
deAliasSymbol = checker.getAliasedSymbol(typeSymbol);
}
ComponentFactory.getExtendsHeritageClauseName = getExtendsHeritageClauseName;
function getInterfaceName(nodeObject) {
return nodeObject.expression.text;
else {
deAliasSymbol = typeSymbol;
}
function getImplementsHeritageClauseNames(heritageClause) {
return heritageClause.types.map(getInterfaceName);
return (_b = (_a = deAliasSymbol.declarations) === null || _a === void 0 ? void 0 : _a[0].getSourceFile().fileName) !== null && _b !== void 0 ? _b : '';
}
function getOriginalFileOriginalType(tsType, checker) {
if (tsType === undefined || checker === undefined) {
return '';
}
ComponentFactory.getImplementsHeritageClauseNames = getImplementsHeritageClauseNames;
function isMethod(declaration) {
return declaration.kind === typescript_1.default.SyntaxKind.MethodDeclaration ||
declaration.kind === typescript_1.default.SyntaxKind.MethodSignature;
var deParameterType = tsType;
var typeSymbol = tsType.getSymbol();
while ((typeSymbol === null || typeSymbol === void 0 ? void 0 : typeSymbol.name) === 'Array') {
deParameterType = checker.getTypeArguments(deParameterType)[0];
typeSymbol = deParameterType.getSymbol();
}
function isProperty(declaration) {
return declaration.kind === typescript_1.default.SyntaxKind.PropertySignature ||
declaration.kind === typescript_1.default.SyntaxKind.PropertyDeclaration ||
declaration.kind === typescript_1.default.SyntaxKind.GetAccessor ||
declaration.kind === typescript_1.default.SyntaxKind.SetAccessor ||
declaration.kind === typescript_1.default.SyntaxKind.Parameter;
if (typeSymbol === undefined) {
return '';
}
function isTypeParameter(declaration) {
return declaration.kind === typescript_1.default.SyntaxKind.TypeParameter;
return getOriginalFile(typeSymbol, checker);
}
exports.getOriginalFileOriginalType = getOriginalFileOriginalType;
function isConstructor(declaration) {
return declaration.kind === typescript_1.default.SyntaxKind.Constructor;
}
function isMethod(declaration) {
return declaration.kind === typescript_1.default.SyntaxKind.MethodDeclaration ||
declaration.kind === typescript_1.default.SyntaxKind.MethodSignature;
}
function isProperty(declaration) {
return declaration.kind === typescript_1.default.SyntaxKind.PropertySignature ||
declaration.kind === typescript_1.default.SyntaxKind.PropertyDeclaration ||
declaration.kind === typescript_1.default.SyntaxKind.GetAccessor ||
declaration.kind === typescript_1.default.SyntaxKind.SetAccessor ||
declaration.kind === typescript_1.default.SyntaxKind.Parameter;
}
function isTypeParameter(declaration) {
return declaration.kind === typescript_1.default.SyntaxKind.TypeParameter;
}
function getMemberModifier(memberDeclaration) {
if (!typescript_1.default.canHaveModifiers(memberDeclaration)) {
return 'public';
}
function getMemberModifier(memberDeclaration) {
var memberModifiers = memberDeclaration.modifiers;
if (memberModifiers === undefined) {
return 'public';
}
return getModifier(memberModifiers);
var memberModifiers = typescript_1.default.getModifiers(memberDeclaration);
if (memberModifiers === undefined) {
return 'public';
}
ComponentFactory.getMemberModifier = getMemberModifier;
function isAbstract(memberDeclaration) {
var memberModifiers = memberDeclaration.modifiers;
if (memberModifiers !== undefined) {
for (var _i = 0, memberModifiers_1 = memberModifiers; _i < memberModifiers_1.length; _i++) {
var memberModifier = memberModifiers_1[_i];
if (memberModifier.kind === typescript_1.default.SyntaxKind.AbstractKeyword) {
return true;
}
}
}
return getModifier(memberModifiers);
}
exports.getMemberModifier = getMemberModifier;
function isModifier(memberDeclaration, modifierKind) {
if (!typescript_1.default.canHaveModifiers(memberDeclaration)) {
return false;
}
ComponentFactory.isAbstract = isAbstract;
function isStatic(memberDeclaration) {
var memberModifiers = memberDeclaration.modifiers;
if (memberModifiers !== undefined) {
for (var _i = 0, memberModifiers_2 = memberModifiers; _i < memberModifiers_2.length; _i++) {
var memberModifier = memberModifiers_2[_i];
if (memberModifier.kind === typescript_1.default.SyntaxKind.StaticKeyword) {
return true;
}
var memberModifiers = typescript_1.default.getModifiers(memberDeclaration);
if (memberModifiers !== undefined) {
for (var _i = 0, memberModifiers_1 = memberModifiers; _i < memberModifiers_1.length; _i++) {
var memberModifier = memberModifiers_1[_i];
if (memberModifier.kind === modifierKind) {
return true;
}
}
return false;
}
ComponentFactory.isStatic = isStatic;
function serializeMethods(memberSymbols, checker) {
var result = [];
if (memberSymbols !== undefined) {
memberSymbols.forEach(function (memberSymbol) {
var memberDeclarations = memberSymbol.getDeclarations();
if (memberDeclarations === undefined) {
return;
return false;
}
exports.isModifier = isModifier;
function serializeConstructors(memberSymbols, checker) {
var result = [];
if (memberSymbols !== undefined) {
memberSymbols.forEach(function (memberSymbol) {
var memberDeclarations = memberSymbol.getDeclarations();
if (memberDeclarations === undefined) {
return;
}
memberDeclarations.forEach(function (memberDeclaration) {
if (isConstructor(memberDeclaration)) {
result.push(MethodFactory.create(memberSymbol, memberDeclaration, checker));
}
memberDeclarations.forEach(function (memberDeclaration) {
if (isMethod(memberDeclaration)) {
result.push(MethodFactory_1.MethodFactory.create(memberSymbol, memberDeclaration, checker));
}
else if (isProperty(memberDeclaration)) {
result.push(PropertyFactory_1.PropertyFactory.create(memberSymbol, memberDeclaration, checker));
}
});
});
}
return result;
});
}
ComponentFactory.serializeMethods = serializeMethods;
function serializeTypeParameters(memberSymbols, checker) {
var result = [];
if (memberSymbols !== undefined) {
memberSymbols.forEach(function (memberSymbol) {
var memberDeclarations = memberSymbol.getDeclarations();
if (memberDeclarations === undefined) {
return;
return result;
}
exports.serializeConstructors = serializeConstructors;
function serializeMethods(memberSymbols, checker) {
var result = [];
if (memberSymbols !== undefined) {
memberSymbols.forEach(function (memberSymbol) {
var memberDeclarations = memberSymbol.getDeclarations();
if (memberDeclarations === undefined) {
return;
}
memberDeclarations.forEach(function (memberDeclaration) {
if (isMethod(memberDeclaration)) {
result.push(MethodFactory.create(memberSymbol, memberDeclaration, checker));
}
memberDeclarations.forEach(function (memberDeclaration) {
if (isTypeParameter(memberDeclaration)) {
result.push(TypeParameterFactory_1.TypeParameterFactory.create(memberSymbol, memberDeclaration, checker));
}
});
else if (isProperty(memberDeclaration)) {
result.push(PropertyFactory.create(memberSymbol, memberDeclaration, checker));
}
});
}
return result;
});
}
ComponentFactory.serializeTypeParameters = serializeTypeParameters;
function hasInitializer(declaration) {
return declaration.initializer !== undefined;
return result;
}
exports.serializeMethods = serializeMethods;
function serializeTypeParameters(memberSymbols, checker) {
var result = [];
if (memberSymbols !== undefined) {
memberSymbols.forEach(function (memberSymbol) {
var memberDeclarations = memberSymbol.getDeclarations();
if (memberDeclarations === undefined) {
return;
}
memberDeclarations.forEach(function (memberDeclaration) {
if (isTypeParameter(memberDeclaration)) {
result.push(TypeParameterFactory.create(memberSymbol, memberDeclaration, checker));
}
});
});
}
ComponentFactory.hasInitializer = hasInitializer;
function isOptional(declaration) {
return declaration.questionToken !== undefined;
}
ComponentFactory.isOptional = isOptional;
})(ComponentFactory = exports.ComponentFactory || (exports.ComponentFactory = {}));
return result;
}
exports.serializeTypeParameters = serializeTypeParameters;
function hasInitializer(declaration) {
return declaration.initializer !== undefined;
}
exports.hasInitializer = hasInitializer;
function isOptional(declaration) {
return declaration.questionToken !== undefined;
}
exports.isOptional = isOptional;
import ts from 'typescript';
import { Enum } from '../Components/Enum';
export declare namespace EnumFactory {
function create(enumSymbol: ts.Symbol): Enum;
}
export declare function create(enumSymbol: ts.Symbol): Enum;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -6,33 +29,30 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.EnumFactory = void 0;
exports.create = void 0;
var typescript_1 = __importDefault(require("typescript"));
var Enum_1 = require("../Components/Enum");
var EnumValueFactory_1 = require("./EnumValueFactory");
var EnumFactory;
(function (EnumFactory) {
function create(enumSymbol) {
var result = new Enum_1.Enum(enumSymbol.getName());
if (enumSymbol.exports !== undefined) {
result.values = serializeEnumProperties(enumSymbol.exports);
}
return result;
var EnumValueFactory = __importStar(require("./EnumValueFactory"));
function create(enumSymbol) {
var result = new Enum_1.Enum(enumSymbol.getName());
if (enumSymbol.exports !== undefined) {
result.values = serializeEnumProperties(enumSymbol.exports);
}
EnumFactory.create = create;
function serializeEnumProperties(memberSymbols) {
var result = [];
if (memberSymbols !== undefined) {
memberSymbols.forEach(function (memberSymbol) {
var memberDeclarations = memberSymbol.getDeclarations();
if (memberDeclarations === undefined) {
return;
return result;
}
exports.create = create;
function serializeEnumProperties(memberSymbols) {
var result = [];
if (memberSymbols !== undefined) {
memberSymbols.forEach(function (memberSymbol) {
var memberDeclarations = memberSymbol.getDeclarations();
if (memberDeclarations === undefined) {
return;
}
memberDeclarations.forEach(function (memberDeclaration) {
if (memberDeclaration.kind === typescript_1.default.SyntaxKind.EnumMember) {
result.push(EnumValueFactory.create(memberSymbol));
}
memberDeclarations.forEach(function (memberDeclaration) {
if (memberDeclaration.kind === typescript_1.default.SyntaxKind.EnumMember) {
result.push(EnumValueFactory_1.EnumValueFactory.create(memberSymbol));
}
});
});
}
return result;
});
}
})(EnumFactory = exports.EnumFactory || (exports.EnumFactory = {}));
return result;
}
import ts from 'typescript';
import { EnumValue } from '../Components/EnumValue';
export declare namespace EnumValueFactory {
function create(signature: ts.Symbol): EnumValue;
}
export declare function create(signature: ts.Symbol): EnumValue;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EnumValueFactory = void 0;
exports.create = void 0;
var EnumValue_1 = require("../Components/EnumValue");
var EnumValueFactory;
(function (EnumValueFactory) {
function create(signature) {
return new EnumValue_1.EnumValue(signature.getName());
}
EnumValueFactory.create = create;
})(EnumValueFactory = exports.EnumValueFactory || (exports.EnumValueFactory = {}));
function create(signature) {
return new EnumValue_1.EnumValue(signature.getName());
}
exports.create = create;
import ts from 'typescript';
import { File } from '../Components/File';
export declare namespace FileFactory {
function create(sourceFile: ts.Node, checker: ts.TypeChecker): File;
}
export declare function create(fileName: string, sourceFile: ts.SourceFile, checker: ts.TypeChecker): File;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileFactory = void 0;
exports.create = void 0;
var File_1 = require("../Components/File");
var ComponentFactory_1 = require("./ComponentFactory");
var FileFactory;
(function (FileFactory) {
function create(sourceFile, checker) {
var file = new File_1.File();
file.parts = ComponentFactory_1.ComponentFactory.create(sourceFile, checker);
return file;
}
FileFactory.create = create;
})(FileFactory = exports.FileFactory || (exports.FileFactory = {}));
var ComponentFactory = __importStar(require("./ComponentFactory"));
function create(fileName, sourceFile, checker) {
var file = new File_1.File(sourceFile.fileName);
file.parts = ComponentFactory.create(fileName, sourceFile, checker);
return file;
}
exports.create = create;
import ts from 'typescript';
import { Interface } from '../Components/Interface';
export declare namespace InterfaceFactory {
function create(interfaceSymbol: ts.Symbol, checker: ts.TypeChecker): Interface;
}
export declare function create(interfaceSymbol: ts.Symbol, checker: ts.TypeChecker): Interface;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -6,28 +29,27 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.InterfaceFactory = void 0;
exports.create = void 0;
var typescript_1 = __importDefault(require("typescript"));
var Interface_1 = require("../Components/Interface");
var ComponentFactory_1 = require("./ComponentFactory");
var InterfaceFactory;
(function (InterfaceFactory) {
function create(interfaceSymbol, checker) {
var result = new Interface_1.Interface(interfaceSymbol.getName());
var declaration = interfaceSymbol.getDeclarations();
if (interfaceSymbol.members !== undefined) {
result.members = ComponentFactory_1.ComponentFactory.serializeMethods(interfaceSymbol.members, checker);
result.typeParameters = ComponentFactory_1.ComponentFactory.serializeTypeParameters(interfaceSymbol.members, checker);
var ComponentFactory = __importStar(require("./ComponentFactory"));
function create(interfaceSymbol, checker) {
var result = new Interface_1.Interface(interfaceSymbol.getName());
var declaration = interfaceSymbol.getDeclarations();
if (interfaceSymbol.members !== undefined) {
result.members = ComponentFactory.serializeMethods(interfaceSymbol.members, checker);
result.typeParameters = ComponentFactory.serializeTypeParameters(interfaceSymbol.members, checker);
}
if (declaration !== undefined && declaration.length > 0) {
var heritageClauses = declaration[declaration.length - 1].heritageClauses;
if (heritageClauses !== undefined) {
heritageClauses.forEach(function (heritageClause) {
if (heritageClause.token === typescript_1.default.SyntaxKind.ExtendsKeyword) {
var extendsInterfaces = ComponentFactory.getHeritageClauseNames(heritageClause, checker);
result.extendsInterface = extendsInterfaces.map(function (arr) { return arr[0]; });
result.extendsInterfaceFiles = extendsInterfaces.map(function (arr) { return arr[1]; });
}
});
}
if (declaration !== undefined && declaration.length > 0) {
var heritageClauses = declaration[declaration.length - 1].heritageClauses;
if (heritageClauses !== undefined) {
heritageClauses.forEach(function (heritageClause) {
if (heritageClause.token === typescript_1.default.SyntaxKind.ExtendsKeyword) {
result.extendsInterface = [ComponentFactory_1.ComponentFactory.getExtendsHeritageClauseName(heritageClause)];
}
});
}
}
return result;
}
InterfaceFactory.create = create;
})(InterfaceFactory = exports.InterfaceFactory || (exports.InterfaceFactory = {}));
return result;
}
exports.create = create;
import ts from 'typescript';
import { Method } from '../Components/Method';
export declare namespace MethodFactory {
function create(signature: ts.Symbol, namedDeclaration: ts.NamedDeclaration, checker: ts.TypeChecker): Method;
}
export declare function create(signature: ts.Symbol, namedDeclaration: ts.NamedDeclaration, checker: ts.TypeChecker): Method;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MethodFactory = void 0;
exports.create = void 0;
var typescript_1 = __importDefault(require("typescript"));
var Method_1 = require("../Components/Method");
var ComponentFactory_1 = require("./ComponentFactory");
var ParameterFactory_1 = require("./ParameterFactory");
var MethodFactory;
(function (MethodFactory) {
function create(signature, namedDeclaration, checker) {
var result = new Method_1.Method(signature.getName());
result.modifier = ComponentFactory_1.ComponentFactory.getMemberModifier(namedDeclaration);
result.isAbstract = ComponentFactory_1.ComponentFactory.isAbstract(namedDeclaration);
result.isOptional = ComponentFactory_1.ComponentFactory.isOptional(namedDeclaration);
result.isStatic = ComponentFactory_1.ComponentFactory.isStatic(namedDeclaration);
var methodSignature = checker.getSignatureFromDeclaration(namedDeclaration);
if (methodSignature !== undefined) {
result.returnType = checker.typeToString(methodSignature.getReturnType(), namedDeclaration);
result.parameters = methodSignature.parameters
.map(function (parameter) { return ParameterFactory_1.ParameterFactory.create(parameter, checker); });
var ComponentFactory = __importStar(require("./ComponentFactory"));
var ParameterFactory = __importStar(require("./ParameterFactory"));
var TypeParameterFactory = __importStar(require("./TypeParameterFactory"));
function create(signature, namedDeclaration, checker) {
var result = new Method_1.Method(signature.getName());
result.modifier = ComponentFactory.getMemberModifier(namedDeclaration);
result.isAbstract = ComponentFactory.isModifier(namedDeclaration, typescript_1.default.SyntaxKind.AbstractKeyword);
result.isOptional = ComponentFactory.isOptional(namedDeclaration);
result.isStatic = ComponentFactory.isModifier(namedDeclaration, typescript_1.default.SyntaxKind.StaticKeyword);
result.isAsync = ComponentFactory.isModifier(namedDeclaration, typescript_1.default.SyntaxKind.AsyncKeyword);
var methodSignature = checker.getSignatureFromDeclaration(namedDeclaration);
if (methodSignature !== undefined) {
var returnType = methodSignature.getReturnType();
result.returnType = checker.typeToString(returnType, namedDeclaration);
result.returnTypeFile = ComponentFactory.getOriginalFileOriginalType(returnType, checker);
result.parameters = methodSignature.parameters
.map(function (parameter) { return ParameterFactory.create(parameter, checker); });
if (methodSignature.typeParameters !== undefined) {
result.typeParameters = methodSignature.typeParameters
.map(function (typeParameter) { var _a; return TypeParameterFactory.create(typeParameter.symbol, (_a = typeParameter.symbol.declarations) === null || _a === void 0 ? void 0 : _a[0], checker); });
}
return result;
}
MethodFactory.create = create;
})(MethodFactory = exports.MethodFactory || (exports.MethodFactory = {}));
return result;
}
exports.create = create;
import ts from 'typescript';
import { Namespace } from '../Components/Namespace';
export declare namespace NamespaceFactory {
function create(namespaceSymbol: ts.Symbol, checker: ts.TypeChecker): Namespace;
}
export declare function create(fileName: string, namespaceSymbol: ts.Symbol, checker: ts.TypeChecker): Namespace;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.NamespaceFactory = void 0;
exports.create = void 0;
var typescript_1 = __importDefault(require("typescript"));
var Namespace_1 = require("../Components/Namespace");
var ComponentFactory_1 = require("./ComponentFactory");
var NamespaceFactory;
(function (NamespaceFactory) {
function create(namespaceSymbol, checker) {
var result = new Namespace_1.Namespace(namespaceSymbol.getName());
var namespaceDeclarations = namespaceSymbol.getDeclarations();
if (namespaceDeclarations === undefined) {
var ComponentFactory = __importStar(require("./ComponentFactory"));
function create(fileName, namespaceSymbol, checker) {
var result = new Namespace_1.Namespace(namespaceSymbol.getName());
var namespaceDeclarations = namespaceSymbol.getDeclarations();
if (namespaceDeclarations === undefined) {
return result;
}
var declaration = namespaceDeclarations[namespaceDeclarations.length - 1];
if (declaration === undefined || declaration.body === undefined) {
return result;
}
if (declaration.body.kind === typescript_1.default.SyntaxKind.ModuleDeclaration) {
var childSymbol = checker.getSymbolAtLocation(declaration.body.name);
if (childSymbol !== undefined) {
result.parts = [create(fileName, childSymbol, checker)];
return result;
}
var declaration = namespaceDeclarations[namespaceDeclarations.length - 1];
if (declaration === undefined || declaration.body === undefined || declaration.body.statements === undefined) {
return result;
}
result.parts = ComponentFactory_1.ComponentFactory.create(declaration.body, checker);
}
if (declaration.body.statements === undefined) {
return result;
}
NamespaceFactory.create = create;
})(NamespaceFactory = exports.NamespaceFactory || (exports.NamespaceFactory = {}));
result.parts = ComponentFactory.create(fileName, declaration.body, checker);
return result;
}
exports.create = create;
import ts from 'typescript';
import { Parameter } from '../Components/Parameter';
export declare namespace ParameterFactory {
function create(parameterSymbol: ts.Symbol, checker: ts.TypeChecker): Parameter;
}
export declare function create(parameterSymbol: ts.Symbol, checker: ts.TypeChecker): Parameter;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParameterFactory = void 0;
exports.create = void 0;
var Parameter_1 = require("../Components/Parameter");
var ComponentFactory_1 = require("./ComponentFactory");
var ParameterFactory;
(function (ParameterFactory) {
function create(parameterSymbol, checker) {
var result = new Parameter_1.Parameter(parameterSymbol.getName());
var declarations = parameterSymbol.getDeclarations();
var declaration;
if (declarations !== undefined) {
result.hasInitializer = ComponentFactory_1.ComponentFactory.hasInitializer(declarations[0]);
result.isOptional = ComponentFactory_1.ComponentFactory.isOptional(declarations[0]);
declaration = declarations[0];
}
result.parameterType = checker.typeToString(checker.getTypeOfSymbolAtLocation(parameterSymbol, parameterSymbol.valueDeclaration), declaration);
return result;
var ComponentFactory = __importStar(require("./ComponentFactory"));
function create(parameterSymbol, checker) {
var result = new Parameter_1.Parameter(parameterSymbol.getName());
var declarations = parameterSymbol.getDeclarations();
var declaration;
if (declarations !== undefined) {
result.hasInitializer = ComponentFactory.hasInitializer(declarations[0]);
result.isOptional = ComponentFactory.isOptional(declarations[0]);
declaration = declarations[0];
}
ParameterFactory.create = create;
})(ParameterFactory = exports.ParameterFactory || (exports.ParameterFactory = {}));
if (parameterSymbol.valueDeclaration === undefined) {
throw new Error("unable to determine parameterType");
}
var typeOfSymbol = checker.getTypeOfSymbolAtLocation(parameterSymbol, parameterSymbol.valueDeclaration);
result.parameterType = checker.typeToString(typeOfSymbol, declaration);
result.parameterTypeFile = ComponentFactory.getOriginalFileOriginalType(typeOfSymbol, checker);
return result;
}
exports.create = create;
import ts from 'typescript';
import { Property } from '../Components/Property';
export declare namespace PropertyFactory {
function create(signature: ts.Symbol, namedDeclaration: ts.NamedDeclaration, checker: ts.TypeChecker): Property;
}
export declare function create(signature: ts.Symbol, namedDeclaration: ts.NamedDeclaration, checker: ts.TypeChecker): Property;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PropertyFactory = void 0;
exports.create = void 0;
var typescript_1 = __importDefault(require("typescript"));
var Property_1 = require("../Components/Property");
var ComponentFactory_1 = require("./ComponentFactory");
var PropertyFactory;
(function (PropertyFactory) {
function create(signature, namedDeclaration, checker) {
var result = new Property_1.Property(signature.getName());
result.modifier = ComponentFactory_1.ComponentFactory.getMemberModifier(namedDeclaration);
result.isAbstract = ComponentFactory_1.ComponentFactory.isAbstract(namedDeclaration);
result.isOptional = ComponentFactory_1.ComponentFactory.isOptional(namedDeclaration);
result.isStatic = ComponentFactory_1.ComponentFactory.isStatic(namedDeclaration);
result.returnType = checker.typeToString(checker.getTypeOfSymbolAtLocation(signature, signature.valueDeclaration), namedDeclaration);
return result;
var ComponentFactory = __importStar(require("./ComponentFactory"));
function create(signature, namedDeclaration, checker) {
var result = new Property_1.Property(signature.getName());
result.modifier = ComponentFactory.getMemberModifier(namedDeclaration);
result.isAbstract = ComponentFactory.isModifier(namedDeclaration, typescript_1.default.SyntaxKind.AbstractKeyword);
result.isOptional = ComponentFactory.isOptional(namedDeclaration);
result.isStatic = ComponentFactory.isModifier(namedDeclaration, typescript_1.default.SyntaxKind.StaticKeyword);
result.isReadonly = ComponentFactory.isModifier(namedDeclaration, typescript_1.default.SyntaxKind.ReadonlyKeyword);
if (signature.valueDeclaration === undefined) {
throw new Error("unable to determing returnType");
}
PropertyFactory.create = create;
})(PropertyFactory = exports.PropertyFactory || (exports.PropertyFactory = {}));
result.returnType = checker.typeToString(checker.getTypeOfSymbolAtLocation(signature, signature.valueDeclaration), namedDeclaration);
return result;
}
exports.create = create;
import ts from 'typescript';
import { TypeParameter } from '../Components/TypeParameter';
export declare namespace TypeParameterFactory {
function getConstraint(memberDeclaration: ts.Declaration, checker: ts.TypeChecker): string | undefined;
function create(signature: ts.Symbol, namedDeclaration: ts.NamedDeclaration, checker: ts.TypeChecker): TypeParameter;
}
export declare function getConstraint(memberDeclaration: ts.Declaration, checker: ts.TypeChecker): ts.Type | undefined;
export declare function create(signature: ts.Symbol, namedDeclaration: ts.NamedDeclaration | undefined, checker: ts.TypeChecker): TypeParameter;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -6,21 +29,26 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.TypeParameterFactory = void 0;
exports.create = exports.getConstraint = void 0;
var typescript_1 = __importDefault(require("typescript"));
var TypeParameter_1 = require("../Components/TypeParameter");
var TypeParameterFactory;
(function (TypeParameterFactory) {
function getConstraint(memberDeclaration, checker) {
var effectiveConstraint = typescript_1.default.getEffectiveConstraintOfTypeParameter(memberDeclaration);
if (effectiveConstraint === undefined) {
return;
}
return checker.typeToString(checker.getTypeFromTypeNode(effectiveConstraint));
var ComponentFactory = __importStar(require("./ComponentFactory"));
function getConstraint(memberDeclaration, checker) {
var effectiveConstraint = typescript_1.default.getEffectiveConstraintOfTypeParameter(memberDeclaration);
if (effectiveConstraint === undefined) {
return;
}
TypeParameterFactory.getConstraint = getConstraint;
function create(signature, namedDeclaration, checker) {
var result = new TypeParameter_1.TypeParameter(signature.getName());
result.constraint = getConstraint(namedDeclaration, checker);
return checker.getTypeFromTypeNode(effectiveConstraint);
}
exports.getConstraint = getConstraint;
function create(signature, namedDeclaration, checker) {
var result = new TypeParameter_1.TypeParameter(signature.getName());
if (namedDeclaration === undefined) {
return result;
}
TypeParameterFactory.create = create;
})(TypeParameterFactory = exports.TypeParameterFactory || (exports.TypeParameterFactory = {}));
var constraintType = getConstraint(namedDeclaration, checker);
if (constraintType !== undefined) {
result.constraint = checker.typeToString(constraintType);
result.constraintFile = ComponentFactory.getOriginalFileOriginalType(constraintType, checker);
}
return result;
}
exports.create = create;

@@ -10,2 +10,4 @@ "use strict";

return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -18,3 +20,7 @@ function __() { this.constructor = d; }

if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -52,3 +58,3 @@ if (k2 === undefined) k2 = k;

var firstLine = [];
firstLine.push("class " + comp.name);
firstLine.push("class ".concat(comp.name));
if (comp.name === this.options.targetClass) {

@@ -66,7 +72,7 @@ firstLine.push(':::targetClassDiagram');

if (comp.extendsClass !== undefined) {
result.push(comp.extendsClass + " <|-- " + comp.name);
result.push("".concat(comp.extendsClass, " <|-- ").concat(comp.name));
}
if (!this.options.onlyClasses && comp.implementsInterfaces.length > 0) {
comp.implementsInterfaces.map(function (inter) {
result.push(inter + " <|.. " + comp.name);
result.push("".concat(inter, " <|.. ").concat(comp.name));
});

@@ -76,7 +82,7 @@ }

comp.members.forEach(function (member) {
result.push("" + _this.serialize(member));
result.push("".concat(_this.serialize(member)));
});
result.push('}');
if (comp.isAbstract) {
result.push("<<abstract>> " + comp.name);
result.push("<<abstract>> ".concat(comp.name));
}

@@ -87,3 +93,3 @@ return result.join(os.EOL);

return [
type1 + " ..> \"" + cardinality + "\" " + type2
"".concat(type1, " ..> \"").concat(cardinality, "\" ").concat(type2)
];

@@ -94,3 +100,3 @@ };

var result = [];
var declaration = "class " + comp.name;
var declaration = "class ".concat(comp.name);
if (comp.values.length > 0) {

@@ -101,3 +107,3 @@ declaration += ' {';

comp.values.forEach(function (enumValue) {
result.push("" + _this.serializeEnumValue(enumValue));
result.push("".concat(_this.serializeEnumValue(enumValue)));
});

@@ -107,3 +113,3 @@ if (comp.values.length > 0) {

}
result.push("<<enumeration>> " + comp.name);
result.push("<<enumeration>> ".concat(comp.name));
return result.join(os.EOL);

@@ -115,3 +121,3 @@ };

var firstLine = [];
firstLine.push("class " + comp.name);
firstLine.push("class ".concat(comp.name));
if (comp.typeParameters.length > 0) {

@@ -126,3 +132,3 @@ firstLine.push('~');

comp.extendsInterface.map(function (inter) {
result.push(inter + " <|.. " + comp.name);
result.push("".concat(inter, " <|.. ").concat(comp.name));
});

@@ -135,3 +141,3 @@ }

comp.members.forEach(function (member) {
result.push("" + _this.serialize(member));
result.push("".concat(_this.serialize(member)));
});

@@ -141,3 +147,3 @@ if (comp.members.length > 0) {

}
result.push("<<Interface>> " + comp.name);
result.push("<<Interface>> ".concat(comp.name));
return result.join(os.EOL);

@@ -148,7 +154,7 @@ };

var result = { public: '+', private: '-', protected: '#' }[comp.modifier];
result += comp.name + "(";
result += "".concat(comp.name, "(");
result += comp.parameters
.map(function (parameter) { return _this.serialize(parameter); })
.join(', ');
result += ")" + (comp.isAbstract ? '*' : '') + (comp.isStatic ? '$' : '') + ": " + this.cleanType(comp.returnType);
result += ")".concat((comp.isAbstract ? '*' : '')).concat((comp.isStatic ? '$' : ''), ": ").concat(this.cleanType(comp.returnType));
return result;

@@ -171,6 +177,6 @@ };

MermaidFormat.prototype.serializeParameter = function (comp) {
var result = "" + comp.name + (comp.isOptional || comp.hasInitializer ? '?' : '');
var result = "".concat(comp.name).concat(comp.isOptional || comp.hasInitializer ? '?' : '');
var typeDef = this.cleanType(comp.parameterType);
if (typeDef !== undefined) {
result += ": " + typeDef;
result += ": ".concat(typeDef);
}

@@ -181,7 +187,7 @@ return result;

var result = { public: '+', private: '-', protected: '#' }[comp.modifier];
result += "" + comp.name + (comp.isOptional ? '?' : '') + (comp.isAbstract ? '*' : '') + (comp.isStatic ? '$' : '') + ": " + this.cleanType(comp.returnType);
result += "".concat(comp.name).concat((comp.isOptional ? '?' : '')).concat((comp.isAbstract ? '*' : '')).concat((comp.isStatic ? '$' : ''), ": ").concat(this.cleanType(comp.returnType));
return result;
};
MermaidFormat.prototype.serializeTypeParameter = function (comp) {
return "" + comp.name;
return "".concat(comp.name);
};

@@ -188,0 +194,0 @@ MermaidFormat.prototype.renderFiles = function (files, associations) {

@@ -10,2 +10,4 @@ "use strict";

return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -18,3 +20,7 @@ function __() { this.constructor = d; }

if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -53,3 +59,3 @@ if (k2 === undefined) k2 = k;

return [
type1 + " --> \"" + cardinality + "\" " + type2
"".concat(type1, " --> \"").concat(cardinality, "\" ").concat(type2)
];

@@ -64,3 +70,3 @@ };

}
firstLine.push("class " + comp.name);
firstLine.push("class ".concat(comp.name));
if (comp.typeParameters.length > 0) {

@@ -74,6 +80,6 @@ firstLine.push('<');

if (comp.extendsClass !== undefined) {
firstLine.push(" extends " + comp.extendsClass);
firstLine.push(" extends ".concat(comp.extendsClass));
}
if (!this.options.onlyClasses && comp.implementsInterfaces.length > 0) {
firstLine.push(" implements " + comp.implementsInterfaces.join(', '));
firstLine.push(" implements ".concat(comp.implementsInterfaces.join(', ')));
}

@@ -90,3 +96,3 @@ this.serializeMembers(comp, firstLine, result);

comp.members.forEach(function (member) {
result.push(" " + _this.serialize(member));
result.push(" ".concat(_this.serialize(member)));
});

@@ -100,3 +106,3 @@ if (comp.members.length > 0) {

var result = [];
var declaration = "enum " + comp.name;
var declaration = "enum ".concat(comp.name);
if (comp.values.length > 0) {

@@ -107,3 +113,3 @@ declaration += ' {';

comp.values.forEach(function (enumValue) {
result.push(" " + _this.serializeEnumValue(enumValue));
result.push(" ".concat(_this.serializeEnumValue(enumValue)));
});

@@ -119,3 +125,3 @@ if (comp.values.length > 0) {

var firstLine = [];
firstLine.push("interface " + comp.name);
firstLine.push("interface ".concat(comp.name));
if (comp.typeParameters.length > 0) {

@@ -129,3 +135,3 @@ firstLine.push('<');

if (comp.extendsInterface.length > 0) {
firstLine.push(" extends " + comp.extendsInterface.join(', '));
firstLine.push(" extends ".concat(comp.extendsInterface.join(', ')));
}

@@ -140,7 +146,7 @@ this.serializeMembers(comp, firstLine, result);

result += (comp.isStatic ? '{static} ' : '');
result += comp.name + "(";
result += "".concat(comp.name, "(");
result += comp.parameters
.map(function (parameter) { return _this.serialize(parameter); })
.join(', ');
result += "): " + comp.returnType;
result += "): ".concat(comp.returnType);
return result;

@@ -151,3 +157,3 @@ };

var result = [];
result.push("namespace " + comp.name + " {");
result.push("namespace ".concat(comp.name, " {"));
comp.parts.forEach(function (part) {

@@ -161,3 +167,3 @@ result.push(_this.serialize(part)

PlantUMLFormat.prototype.serializeParameter = function (comp) {
return "" + comp.name + (comp.isOptional || comp.hasInitializer ? '?' : '') + ": " + comp.parameterType;
return "".concat(comp.name).concat(comp.isOptional || comp.hasInitializer ? '?' : '', ": ").concat(comp.parameterType);
};

@@ -168,7 +174,7 @@ PlantUMLFormat.prototype.serializeProperty = function (comp) {

result += (comp.isStatic ? '{static} ' : '');
result += "" + comp.name + (comp.isOptional ? '?' : '') + ": " + comp.returnType;
result += "".concat(comp.name).concat((comp.isOptional ? '?' : ''), ": ").concat(comp.returnType);
return result;
};
PlantUMLFormat.prototype.serializeTypeParameter = function (comp) {
return "" + comp.name + (comp.constraint !== undefined ? " extends " + comp.constraint : '');
return "".concat(comp.name).concat((comp.constraint !== undefined ? " extends ".concat(comp.constraint) : ''));
};

@@ -175,0 +181,0 @@ return PlantUMLFormat;

#!/usr/bin/env node
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -10,12 +33,13 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

var glob_1 = __importDefault(require("glob"));
var http_1 = __importDefault(require("http"));
var os_1 = __importDefault(require("os"));
var path_1 = __importDefault(require("path"));
var typescript_1 = __importDefault(require("typescript"));
var tplant = __importStar(require("./tplant"));
var plantuml_encoder_1 = require("plantuml-encoder");
var typescript_1 = __importDefault(require("typescript"));
var tplant_1 = require("./tplant");
var AVAILABLE_PLANTUML_EXTENSIONS = ['svg', 'png', 'txt'];
var plantuml = require("node-plantuml");
commander_1.default
.version(require('../package').version)
.version("3.1.2")
.option('-i, --input <path>', 'Define the path of the Typescript file')
.option('-e, --exclude <path>', 'File(s) to ignore')
.option('-o, --output <path>', 'Define the path of the output file. If not defined, it\'ll output on the STDOUT')

@@ -35,3 +59,7 @@ .option('-p, --project <path>', 'Compile a project given a valid configuration file.' +

}
glob_1.default(commander_1.default.input, {}, function (err, matches) {
var globOptions = {};
if (commander_1.default.exclude !== undefined) {
globOptions.ignore = commander_1.default.exclude;
}
(0, glob_1.default)(commander_1.default.input, globOptions, function (err, matches) {
if (err !== null) {

@@ -41,3 +69,3 @@ throw err;

var tsConfigFile = findTsConfigFile(commander_1.default.input, commander_1.default.tsconfig);
var plantUMLDocument = tplant_1.tplant.convertToPlant(tplant_1.tplant.generateDocumentation(matches, getCompilerOptions(tsConfigFile)), {
var plantUMLDocument = tplant.convertToPlant(tplant.generateDocumentation(matches, getCompilerOptions(tsConfigFile)), {
associations: commander_1.default.associations,

@@ -91,6 +119,6 @@ onlyInterfaces: commander_1.default.onlyInterfaces,

if (configFile.error !== undefined && configFile.error.category === typescript_1.default.DiagnosticCategory.Error) {
throw new Error("unable to read tsconfig.json file at: " + tsConfigFilePath + ".\n Error: " + typescript_1.default.flattenDiagnosticMessageText(configFile.error.messageText, os_1.default.EOL));
throw new Error("unable to read tsconfig.json file at: ".concat(tsConfigFilePath, ".\n Error: ").concat(typescript_1.default.flattenDiagnosticMessageText(configFile.error.messageText, os_1.default.EOL)));
}
else if (configFile.config === undefined) {
throw new Error("unable to read tsconfig.json file at: " + tsConfigFilePath + ".");
throw new Error("unable to read tsconfig.json file at: ".concat(tsConfigFilePath, "."));
}

@@ -101,3 +129,3 @@ var convertedCompilerOptions = typescript_1.default.convertCompilerOptionsFromJson(configFile.config.compilerOptions, path_1.default.dirname(tsConfigFilePath));

if (error.category === typescript_1.default.DiagnosticCategory.Error) {
throw new Error("unable to read tsconfig.json file at: " + tsConfigFilePath + ".\n Error: " + typescript_1.default.flattenDiagnosticMessageText(error.messageText, os_1.default.EOL));
throw new Error("unable to read tsconfig.json file at: ".concat(tsConfigFilePath, ".\n Error: ").concat(typescript_1.default.flattenDiagnosticMessageText(error.messageText, os_1.default.EOL)));
}

@@ -109,13 +137,6 @@ });

function requestImageFile(output, input, extension) {
http_1.default.get({
host: 'www.plantuml.com',
path: "/plantuml/" + extension + "/" + plantuml_encoder_1.encode(input)
}, function (res) {
var fileStream = fs_1.default.createWriteStream(output);
res.setEncoding('utf-8');
res.pipe(fileStream);
res.on('error', function (err) {
throw err;
});
});
var decode = plantuml.decode((0, plantuml_encoder_1.encode)(input));
var gen = plantuml.generate({ format: extension });
decode.out.pipe(gen.in);
gen.out.pipe(fs_1.default.createWriteStream(output));
}

@@ -16,2 +16,2 @@ "use strict";

ComponentKind[ComponentKind["TYPE_PROPERTY"] = 9] = "TYPE_PROPERTY";
})(ComponentKind = exports.ComponentKind || (exports.ComponentKind = {}));
})(ComponentKind || (exports.ComponentKind = ComponentKind = {}));

@@ -18,3 +18,3 @@ import { Class } from '../Components/Class';

footer(): string[];
addAssociation(type1: string, cardinality: string, type2: string): string[];
abstract addAssociation(type1: string, cardinality: string, type2: string): string[];
serializeFile(file: File): string;

@@ -21,0 +21,0 @@ abstract serializeClass(component: Class): string;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -40,5 +44,2 @@ if (k2 === undefined) k2 = k;

};
Formatter.prototype.addAssociation = function (type1, cardinality, type2) {
return [];
};
Formatter.prototype.serializeFile = function (file) {

@@ -148,5 +149,5 @@ var _this = this;

}
var key = part.name + " " + cardinality + " " + typeName;
var key = "".concat(part.name, " ").concat(cardinality, " ").concat(typeName);
if (typeName !== part.name &&
!outputConstraints.hasOwnProperty(key) && mappedTypes.hasOwnProperty(typeName)) {
!Object.prototype.hasOwnProperty.call(outputConstraints, key) && Object.prototype.hasOwnProperty.call(mappedTypes, typeName)) {
associations.push.apply(associations, _this.addAssociation(part.name, cardinality, typeName));

@@ -153,0 +154,0 @@ outputConstraints[key] = true;

@@ -1,1 +0,1 @@

export declare type Modifier = 'public' | 'private' | 'protected';
export type Modifier = 'public' | 'private' | 'protected';
import ts from 'typescript';
import { IComponentComposite } from './Models/IComponentComposite';
import { ICommandOptions } from './Models/ICommandOptions';
export declare namespace tplant {
function generateDocumentation(fileNames: ReadonlyArray<string>, options?: ts.CompilerOptions): IComponentComposite[];
function convertToPlant(files: IComponentComposite[], options?: ICommandOptions): string;
}
export declare function generateDocumentation(fileNames: ReadonlyArray<string> | string, options?: ts.CompilerOptions): IComponentComposite[];
export declare function convertToPlant(files: IComponentComposite[], options?: ICommandOptions): string;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -6,3 +29,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.tplant = void 0;
exports.convertToPlant = exports.generateDocumentation = void 0;
var typescript_1 = __importDefault(require("typescript"));

@@ -12,108 +35,132 @@ var PlantUMLFormat_1 = require("./Formatter/PlantUMLFormat");

var Class_1 = require("./Components/Class");
var FileFactory_1 = require("./Factories/FileFactory");
var FileFactory = __importStar(require("./Factories/FileFactory"));
var MermaidFormat_1 = require("./Formatter/MermaidFormat");
var tplant;
(function (tplant) {
function generateDocumentation(fileNames, options) {
if (options === void 0) { options = typescript_1.default.getDefaultCompilerOptions(); }
var program = typescript_1.default.createProgram(fileNames, options);
var checker = program.getTypeChecker();
var result = [];
program.getSourceFiles()
.forEach(function (sourceFile) {
if (!sourceFile.isDeclarationFile) {
var file = FileFactory_1.FileFactory.create(sourceFile, checker);
if (file !== undefined) {
result.push(file);
}
}
var DEFAULT_FILE_NAME = 'source.ts';
function generateDocumentation(fileNames, options) {
if (options === void 0) { options = typescript_1.default.getDefaultCompilerOptions(); }
var program;
if (Array.isArray(fileNames)) {
program = typescript_1.default.createProgram(fileNames, options);
}
else {
program = typescript_1.default.createProgram({
rootNames: [DEFAULT_FILE_NAME],
options: options,
host: getCompilerHostForSource(fileNames)
});
return result;
}
tplant.generateDocumentation = generateDocumentation;
function convertToPlant(files, options) {
if (options === void 0) { options = {
associations: false,
onlyInterfaces: false,
format: 'plantuml',
onlyClasses: false
}; }
var formatter;
if (options.format === 'mermaid') {
formatter = new MermaidFormat_1.MermaidFormat(options);
var checker = program.getTypeChecker();
var result = [];
program.getSourceFiles()
.forEach(function (sourceFile) {
if (!sourceFile.isDeclarationFile) {
var file = FileFactory.create(sourceFile.fileName, sourceFile, checker);
if (file !== undefined) {
result.push(file);
}
}
else {
formatter = new PlantUMLFormat_1.PlantUMLFormat(options);
});
return result;
}
exports.generateDocumentation = generateDocumentation;
function getCompilerHostForSource(source) {
var sourceFile = typescript_1.default.createSourceFile(DEFAULT_FILE_NAME, source, typescript_1.default.ScriptTarget.ES2016);
return {
getSourceFile: function () { return sourceFile; },
getDefaultLibFileName: function () { return ""; },
writeFile: function () { return undefined; },
getCurrentDirectory: function () { return ""; },
getCanonicalFileName: function () { return DEFAULT_FILE_NAME; },
useCaseSensitiveFileNames: function () { return false; },
getNewLine: function () { return "\n"; },
fileExists: function () { return true; },
readFile: function () {
throw new Error("NOT IMPLEMENTED");
}
if (options.onlyClasses) {
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
var file = files_1[_i];
file.parts = file.parts
.filter(function (part) { return part.componentKind === ComponentKind_1.ComponentKind.CLASS; });
}
};
}
function convertToPlant(files, options) {
if (options === void 0) { options = {
associations: false,
onlyInterfaces: false,
format: 'plantuml',
onlyClasses: false
}; }
var formatter;
if (options.format === 'mermaid') {
formatter = new MermaidFormat_1.MermaidFormat(options);
}
else {
formatter = new PlantUMLFormat_1.PlantUMLFormat(options);
}
if (options.onlyClasses) {
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
var file = files_1[_i];
file.parts = file.parts
.filter(function (part) { return part.componentKind === ComponentKind_1.ComponentKind.CLASS; });
}
else if (options.onlyInterfaces) {
for (var _a = 0, files_2 = files; _a < files_2.length; _a++) {
var file = files_2[_a];
file.parts = file.parts
.filter(function (part) { return part.componentKind === ComponentKind_1.ComponentKind.INTERFACE; });
}
else if (options.onlyInterfaces) {
for (var _a = 0, files_2 = files; _a < files_2.length; _a++) {
var file = files_2[_a];
file.parts = file.parts
.filter(function (part) { return part.componentKind === ComponentKind_1.ComponentKind.INTERFACE; });
}
}
else if (options.targetClass !== undefined) {
var target = findClass(files, options.targetClass);
var parts = [];
if (target !== undefined) {
parts.push(target);
var parent_1 = target.extendsClass;
while (parent_1 !== undefined) {
var parentClass = findClass(files, parent_1);
parts.push(parentClass);
parts.push.apply(parts, getInterfaces(files, parentClass));
parent_1 = parentClass.extendsClass;
}
parts.push.apply(parts, getInterfaces(files, target));
parts.push.apply(parts, findChildClass(files, target));
}
else if (options.targetClass !== undefined) {
var target = findClass(files, options.targetClass);
var parts = [];
if (target !== undefined) {
parts.push(target);
var parent_1 = target.extendsClass;
while (parent_1 !== undefined) {
var parentClass = findClass(files, parent_1);
parts.push(parentClass);
parts.push.apply(parts, getInterfaces(files, parentClass));
parent_1 = parentClass.extendsClass;
}
parts.push.apply(parts, getInterfaces(files, target));
parts.push.apply(parts, findChildClass(files, target));
return formatter.renderFiles(parts, false);
}
return formatter.renderFiles(files, options.associations);
}
exports.convertToPlant = convertToPlant;
function getInterfaces(files, comp) {
var res = [];
comp.implementsInterfaces.forEach(function (impl) {
var implComponent = findClass(files, impl);
if (implComponent !== undefined) {
res.push(implComponent);
}
});
return res;
}
function findClass(files, name) {
for (var _i = 0, files_3 = files; _i < files_3.length; _i++) {
var file = files_3[_i];
for (var _a = 0, _b = file.parts; _a < _b.length; _a++) {
var part = _b[_a];
if (part.name === name) {
return part;
}
return formatter.renderFiles(parts, false);
}
return formatter.renderFiles(files, options.associations);
}
tplant.convertToPlant = convertToPlant;
function getInterfaces(files, comp) {
var res = [];
comp.implementsInterfaces.forEach(function (impl) {
var implComponent = findClass(files, impl);
if (implComponent !== undefined) {
res.push(implComponent);
return undefined;
}
function findChildClass(files, comp) {
var res = [];
for (var _i = 0, files_4 = files; _i < files_4.length; _i++) {
var file = files_4[_i];
file.parts
.forEach(function (part) {
if (part instanceof Class_1.Class && (part).extendsClass === comp.name) {
res.push(part);
part.implementsInterfaces = [];
res.push.apply(res, findChildClass(files, part));
}
});
return res;
}
function findClass(files, name) {
for (var _i = 0, files_3 = files; _i < files_3.length; _i++) {
var file = files_3[_i];
for (var _a = 0, _b = file.parts; _a < _b.length; _a++) {
var part = _b[_a];
if (part.name === name) {
return part;
}
}
}
return undefined;
}
function findChildClass(files, comp) {
var res = [];
for (var _i = 0, files_4 = files; _i < files_4.length; _i++) {
var file = files_4[_i];
file.parts
.forEach(function (part) {
if (part instanceof Class_1.Class && (part).extendsClass === comp.name) {
res.push(part);
part.implementsInterfaces = [];
res.push.apply(res, findChildClass(files, part));
}
});
}
return res;
}
})(tplant = exports.tplant || (exports.tplant = {}));
return res;
}
{
"name": "tplant",
"version": "3.1.0",
"version": "3.1.2",
"description": "Typescript to PlantUML",

@@ -21,3 +21,3 @@ "keywords": [

},
"license": "ISC",
"license": "GPL-3.0",
"author": "Brian Folts",

@@ -38,4 +38,3 @@ "contributors": [

"build:dev": "tsc --sourceMap -w",
"lint": "tslint -p .",
"lint:fix": "tslint -p . --fix",
"lint": "eslint src --ext .ts",
"prepare": "npm run build",

@@ -48,4 +47,5 @@ "prepublishOnly": "npm test && npm run lint",

"glob": "^7.1.6",
"node-plantuml": "0.9.0",
"plantuml-encoder": "^1.4.0",
"typescript": "^4.0.3"
"typescript": "5.2.2"
},

@@ -56,6 +56,7 @@ "devDependencies": {

"@types/node": "^12.0.0",
"jest": "^27.0.6",
"ts-jest": "^27.0.3",
"tslint": "^5.16.0",
"tslint-microsoft-contrib": "^6.1.1"
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"eslint": "^8.48.0",
"jest": "^29.1.1",
"ts-jest": "^29.1.1"
},

@@ -65,3 +66,6 @@ "jest": {

"testEnvironment": "node"
},
"engines": {
"node": "^16.0.0"
}
}

@@ -72,3 +72,7 @@ # tplant

### Graphviz
For generating images may need to install graphviz or update to most recent version.
# References
https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API
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