Comparing version 0.0.48 to 0.0.49
@@ -29,2 +29,3 @@ export declare enum NodeType { | ||
enableLink: boolean; | ||
disableErrorLogging: boolean; | ||
} | ||
@@ -31,0 +32,0 @@ declare class SequenceGraph { |
@@ -58,2 +58,3 @@ "use strict"; | ||
this.enableLink = false; | ||
this.disableErrorLogging = false; | ||
} | ||
@@ -60,0 +61,0 @@ } |
{ | ||
"name": "ts2uml", | ||
"version": "0.0.48", | ||
"version": "0.0.49", | ||
"description": "typescript workflow to uml sequence", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -24,4 +24,4 @@ "use strict"; | ||
function parseSequence(node) { | ||
return `\n${node.type === model_1.NodeType.Request ? node.source : node.reciever} ${getSequenceDirection(node)} ${node.type === model_1.NodeType.Request ? node.reciever : node.source}: ${(0, model_1.fntoReadable)((0, model_1.expand)(node.type == model_1.NodeType.Request ? node.recMethod : node.srcMethod || node.recMethod))}`; | ||
return `\n${node.type === model_1.NodeType.Request ? node.source : node.reciever} ${getSequenceDirection(node)} ${node.type === model_1.NodeType.Request ? node.reciever : node.source}: ${(0, model_1.fntoReadable)((0, model_1.expand)(node.recMethod))}`; | ||
} | ||
exports.parseSequence = parseSequence; |
@@ -29,12 +29,2 @@ "use strict"; | ||
blockDepth -= (line.match(/}/g) || []).length; | ||
// Skip processing if we're inside a nested block | ||
if (blockDepth < 0) { | ||
gothrough = false; | ||
continue; | ||
} | ||
; | ||
if (!gothrough) { | ||
gothrough = true; | ||
continue; | ||
} | ||
// Match class declaration, considering possible keywords like 'export' | ||
@@ -46,5 +36,11 @@ const classMatch = line.match(/(?:export\s+)?(?:abstract\s+)?class\s+(\w+)/); | ||
} | ||
// Skip processing if we're inside a nested block | ||
if (blockDepth !== 1) { | ||
gothrough = false; | ||
continue; | ||
} | ||
; | ||
// Match method or function declaration | ||
const methodOrFunctionMatch = line.match(/(?:async\s+)?(?:function\s+)?(?:public\s+|private\s+|protected\s+|static\s+)?\*?\s*(\w+)\s*(?:\((?:[^)]*)\))\s*(?:=>)?{/); | ||
if (!currentMethodName && methodOrFunctionMatch) { | ||
const methodOrFunctionMatch = line.match(/(?:async\s+)?(?:function\s+)?(?:public\s+|private\s+|protected\s+|static\s+)?\*?\s*(\w+)\s*(<[^>]+>)?\s*\(([^)]*)\)\s*(?:=>\s*(?:\{[^}]*\}|[^;]*))?/); | ||
if (!currentMethodName && methodOrFunctionMatch && !["if", "for"].includes(methodOrFunctionMatch[1])) { | ||
currentMethodName = methodOrFunctionMatch[1]; | ||
@@ -54,5 +50,6 @@ } | ||
// Adjust for cases where blockDepth might not return to 0 due to unbalanced braces | ||
if (blockDepth !== 0) { | ||
if (blockDepth < 0) { | ||
console.warn("Warning: Unbalanced braces detected. The results might not be accurate."); | ||
} | ||
console.log(currentClassName, " --> ", currentMethodName); | ||
return { className: currentClassName, method: currentMethodName }; | ||
@@ -59,0 +56,0 @@ } |
@@ -113,3 +113,5 @@ "use strict"; | ||
try { | ||
const result = originalMethod.call(this, ...args); | ||
const result = originalMethod.call(this, ...args).catch((e) => { | ||
handleException(requestId, e, previous, current, startTime, modifier, args); | ||
}); | ||
if (requestId) { | ||
@@ -121,9 +123,16 @@ handleResponse(result, previous.className, previous.method, current.className, current.method, startTime, modifier); | ||
catch (e) { | ||
if (requestId) { | ||
handleResponse(e, previous.className, previous.method, current.className, current.method, startTime, modifier); | ||
(0, sequence_diagram_1._getSequence)(); | ||
} | ||
throw e; | ||
handleException(requestId, e, previous, current, startTime, modifier, args); | ||
} | ||
} | ||
function handleException(requestId, e, previous, current, startTime, modifier, args) { | ||
if (requestId) { | ||
handleResponse(e, previous.className, previous.method, current.className, current.method, startTime, modifier); | ||
(0, sequence_diagram_1._getSequence)(); | ||
} | ||
if (!model_1.umlConfig.disableErrorLogging) { | ||
// print me proper error message with method name and arguments and stack trace | ||
console.error(requestId + `: Error in ${current.className}.${current.method} with arguments ${JSON.stringify(args)} and the stack trace ${e.stack}`); | ||
} | ||
throw e; | ||
} | ||
function handleResponse(result, prevClassName, prevMethod, className, method, startTime, modifier) { | ||
@@ -130,0 +139,0 @@ const nodes = model_1._graphs.graphs[model_1._graphs._getRequestId()] || []; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45269
942