@remotex-labs/xmap 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/cjs/index.js +6 -5
  2. package/dist/cjs/index.js.map +3 -3
  3. package/dist/cjs/package.json +1 -0
  4. package/dist/components/base64.component.js +2 -0
  5. package/dist/components/base64.component.js.map +8 -0
  6. package/dist/components/formatter.component.js +5 -0
  7. package/dist/components/formatter.component.js.map +8 -0
  8. package/dist/components/highlighter.component.js +2 -0
  9. package/dist/components/highlighter.component.js.map +8 -0
  10. package/dist/components/parser.component.js +3 -0
  11. package/dist/components/parser.component.js.map +8 -0
  12. package/dist/esm/index.js +6 -5
  13. package/dist/esm/index.js.map +3 -3
  14. package/dist/esm/package.json +1 -0
  15. package/dist/index.js +2 -0
  16. package/dist/index.js.map +8 -0
  17. package/dist/package.json +1 -0
  18. package/dist/providers/interfaces/mapping.interface.js +2 -0
  19. package/dist/providers/interfaces/mapping.interface.js.map +8 -0
  20. package/dist/{cjs/providers → providers}/mapping.provider.d.ts +5 -1
  21. package/dist/providers/mapping.provider.js +2 -0
  22. package/dist/providers/mapping.provider.js.map +8 -0
  23. package/dist/services/source.service.js +4 -0
  24. package/dist/services/source.service.js.map +8 -0
  25. package/package.json +10 -10
  26. package/dist/esm/components/base64.component.d.ts +0 -26
  27. package/dist/esm/components/formatter.component.d.ts +0 -66
  28. package/dist/esm/components/highlighter.component.d.ts +0 -186
  29. package/dist/esm/components/interfaces/formatter.interface.d.ts +0 -42
  30. package/dist/esm/components/interfaces/highlighter.interface.d.ts +0 -48
  31. package/dist/esm/components/interfaces/parse.interface.d.ts +0 -31
  32. package/dist/esm/components/parser.component.d.ts +0 -11
  33. package/dist/esm/index.d.ts +0 -9
  34. package/dist/esm/providers/interfaces/mapping.interface.d.ts +0 -52
  35. package/dist/esm/providers/mapping.provider.d.ts +0 -229
  36. package/dist/esm/services/interfaces/source.interface.d.ts +0 -53
  37. package/dist/esm/services/source.service.d.ts +0 -217
  38. /package/dist/{cjs/components → components}/base64.component.d.ts +0 -0
  39. /package/dist/{cjs/components → components}/formatter.component.d.ts +0 -0
  40. /package/dist/{cjs/components → components}/highlighter.component.d.ts +0 -0
  41. /package/dist/{cjs/components → components}/interfaces/formatter.interface.d.ts +0 -0
  42. /package/dist/{cjs/components → components}/interfaces/highlighter.interface.d.ts +0 -0
  43. /package/dist/{cjs/components → components}/interfaces/parse.interface.d.ts +0 -0
  44. /package/dist/{cjs/components → components}/parser.component.d.ts +0 -0
  45. /package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
  46. /package/dist/{cjs/providers → providers}/interfaces/mapping.interface.d.ts +0 -0
  47. /package/dist/{cjs/services → services}/interfaces/source.interface.d.ts +0 -0
  48. /package/dist/{cjs/services → services}/source.service.d.ts +0 -0
@@ -0,0 +1,8 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/components/highlighter.component.ts"],
4
+ "sourceRoot": "https://github.com/remotex-lab/xmap/tree/2.0.3/",
5
+ "sourcesContent": ["/**\n * Import will remove at compile time\n */\n\nimport type { HighlightSchemeInterface, HighlightNodeSegmentInterface } from './/interfaces/highlighter.interface.js';\n\n/**\n * Imports\n */\n\nimport * as ts from 'typescript';\nimport { SyntaxKind } from 'typescript';\n\n/**\n * An enum containing ANSI escape sequences for various colors.\n *\n * This enum is primarily intended for terminal output and won't work directly in JavaScript for web development.\n * It defines color codes for various colors and a reset code to return to\n * the default text color.\n *\n * @example\n * ```typescript\n * console.log(`${Colors.red}This the text will be red in the terminal.${Colors.reset}`);\n * ```\n *\n * This functionality is limited to terminal environments.\n * Consider alternative methods\n * for color highlighting in web development contexts, such as CSS classes.\n */\n\nexport const enum Colors {\n reset = '\\x1b[0m',\n gray = '\\x1b[38;5;243m',\n darkGray = '\\x1b[38;5;238m',\n lightCoral = '\\x1b[38;5;203m',\n lightOrange = '\\x1b[38;5;215m',\n oliveGreen = '\\x1b[38;5;149m',\n burntOrange = '\\x1b[38;5;208m',\n lightGoldenrodYellow = '\\x1b[38;5;221m',\n lightYellow = '\\x1b[38;5;230m',\n canaryYellow = '\\x1b[38;5;227m',\n deepOrange = '\\x1b[38;5;166m',\n lightGray = '\\x1b[38;5;252m',\n brightPink = '\\x1b[38;5;197m'\n}\n\n/**\n * Default color scheme for semantic highlighting.\n * This scheme uses red color for all code elements.\n *\n * @example\n * const scheme = defaultScheme;\n * console.log(scheme.typeColor); // Outputs: the red color code\n */\n\n\nconst defaultScheme: HighlightSchemeInterface = {\n enumColor: Colors.burntOrange,\n typeColor: Colors.lightGoldenrodYellow,\n classColor: Colors.lightOrange,\n stringColor: Colors.oliveGreen,\n keywordColor: Colors.lightCoral,\n commentColor: Colors.darkGray,\n functionColor: Colors.lightOrange,\n variableColor: Colors.burntOrange,\n interfaceColor: Colors.lightGoldenrodYellow,\n parameterColor: Colors.deepOrange,\n getAccessorColor: Colors.lightYellow,\n numericLiteralColor: Colors.lightGray,\n methodSignatureColor: Colors.burntOrange,\n regularExpressionColor: Colors.oliveGreen,\n propertyAssignmentColor: Colors.canaryYellow,\n propertyAccessExpressionColor: Colors.lightYellow,\n expressionWithTypeArgumentsColor: Colors.lightOrange\n};\n\n/**\n * Class responsible for applying semantic highlighting to a source code string based on a given color scheme.\n *\n * @class\n *\n * @param sourceFile - The TypeScript AST node representing the source file.\n * @param code - The source code string to be highlighted.\n * @param schema - The color scheme used for highlighting different elements in the code.\n *\n * const highlighter = new CodeHighlighter(sourceFile, code, schema);\n */\n\nexport class CodeHighlighter {\n\n /**\n * A Map of segments where the key is a combination of start and end positions,\n * and the value is an object containing the color and reset code.\n * This structure ensures unique segments and allows for fast lookups and updates.\n *\n * @example\n * this.segments = new Map([\n * ['0-10', { start: 1, end: 11, color: '\\x1b[31m', reset: '\\x1b[0m' }],\n * ['11-20', { start: 12, end: 20, color: '\\x1b[32m', reset: '\\x1b[0m' }]\n * ]);\n */\n\n private segments: Map<string, HighlightNodeSegmentInterface> = new Map();\n\n /**\n * Creates an instance of the CodeHighlighter class.\n *\n * @param sourceFile - The TypeScript AST node representing the source file.\n * @param code - The source code string to be highlighted.\n * @param schema - The color scheme used for highlighting different elements in the code.\n */\n\n constructor(private sourceFile: ts.Node, private code: string, private schema: HighlightSchemeInterface) {\n }\n\n /**\n * Parses a TypeScript AST node and processes its comments to identify segments that need highlighting.\n *\n * @param node - The TypeScript AST node to be parsed.\n */\n\n parseNode(node: ts.Node): void {\n this.processComments(node);\n this.processKeywords(node);\n this.processNode(node);\n }\n\n /**\n * Generates a string with highlighted code segments based on the provided color scheme.\n *\n * This method processes the stored segments, applies the appropriate colors to each segment,\n * and returns the resulting highlighted code as a single string.\n *\n * @returns The highlighted code as a string, with ANSI color codes applied to the segments.\n */\n\n highlight(): string {\n let previousSegmentEnd = 0;\n let parent: HighlightNodeSegmentInterface | undefined;\n\n const result: Array<string> = [];\n const segments = Array.from(\n this.segments.values()\n ).sort((a, b) => a.start - b.start || a.end - b.end);\n\n segments.forEach((segment) => {\n if (parent && segment.start < parent.end) {\n const lastSegment = result.pop();\n if (!lastSegment) return;\n\n const source = this.getSegmentSource(segment.start, segment.end);\n const combinedSource = `${ segment.color }${ source }${ parent.color }`;\n result.push(lastSegment.replace(source, combinedSource));\n\n return;\n }\n\n result.push(this.getSegmentSource(previousSegmentEnd, segment.start));\n result.push(`${ segment.color }${ this.getSegmentSource(segment.start, segment.end) }${ segment.reset }`);\n previousSegmentEnd = segment.end;\n parent = segment;\n });\n\n return result.join('') + this.getSegmentSource(previousSegmentEnd);\n }\n\n /**\n * Extracts a substring from the code based on the specified start and end positions.\n *\n * This method is used to retrieve the source code segment that corresponds to the\n * given start and end positions. It is primarily used for highlighting specific\n * segments of the code.\n *\n * @param start - The starting index of the segment to be extracted.\n * @param end - The ending index of the segment to be extracted.\n * @returns The extracted substring from the code.\n */\n\n private getSegmentSource(start: number, end?: number): string {\n return this.code.slice(start, end);\n }\n\n /**\n * Adds a new segment to the list of segments to be highlighted.\n * The segment is defined by its start and end positions, the color to apply, and an optional reset code.\n *\n * @param start - The starting index of the segment in the code string.\n * @param end - The ending index of the segment in the code string.\n * @param color - The color code to apply to the segment.\n * @param reset - The color reset code to apply after the segment, Defaults to the reset code defined in `Colors.reset`.\n */\n\n private addSegment(start: number, end: number, color: string, reset: string = Colors.reset) {\n const key = `${ start }-${ end }`;\n this.segments.set(key, { start, end, color, reset });\n }\n\n /**\n * Processes comments within a TypeScript AST node and adds segments for highlighting.\n * Extracts trailing and leading comments from the node and adds them as segments using the color defined in `this.colorSchema.comments`.\n *\n * @param node - The TypeScript AST node whose comments are to be processed.\n */\n\n private processComments(node: ts.Node): void {\n const comments = [\n ...ts.getTrailingCommentRanges(this.sourceFile.getFullText(), node.getFullStart()) || [],\n ...ts.getLeadingCommentRanges(this.sourceFile.getFullText(), node.getFullStart()) || []\n ];\n\n comments.forEach(comment => this.addSegment(comment.pos, comment.end, this.schema.commentColor));\n }\n\n /**\n * Processes the keywords within a TypeScript AST node and adds them as segments for highlighting.\n *\n * This method identifies potential keyword tokens within the provided node and adds them to the\n * list of segments with the color defined in `this.schema.keywordColor`.\n * The method considers the current node, its first token, and its last token to determine if they should be highlighted\n * as keywords.\n *\n * The method checks if the node's kind falls within the range of keyword kinds defined by TypeScript.\n * If the node or any of its tokens are identified as keywords, a segment is added to `this.segments`\n * with the start and end positions of the node and the specified color for keywords.\n *\n * @param node - The TypeScript AST node to be processed for keywords.\n */\n\n private processKeywords(node: ts.Node): void {\n if ([\n SyntaxKind.NullKeyword,\n SyntaxKind.VoidKeyword,\n SyntaxKind.StringKeyword,\n SyntaxKind.NumberKeyword,\n SyntaxKind.BooleanKeyword,\n SyntaxKind.UndefinedKeyword\n ].includes(node.kind)) {\n return this.addSegment(node.getStart(), node.getEnd(), this.schema.typeColor);\n }\n\n if (node && node.kind >= ts.SyntaxKind.FirstKeyword && node.kind <= ts.SyntaxKind.LastKeyword) {\n this.addSegment(node.getStart(), node.getEnd(), this.schema.keywordColor);\n }\n }\n\n /**\n * Processes identifiers within a TypeScript AST node and adds them as segments for highlighting\n * based on the node's parent type.\n *\n * This method determines the appropriate color for an identifier based on its parent node's kind.\n * If the parent node matches one of the specified kinds, the identifier is highlighted with a cyan color.\n * Supported parent kinds include various declarations, expressions, and signatures.\n *\n * @param node - The TypeScript AST node representing the identifier to be processed.\n */\n\n private processIdentifier(node: ts.Node): void {\n const end = node.getEnd();\n const start = node.getStart();\n\n switch (node.parent.kind) {\n case ts.SyntaxKind.EnumMember:\n return this.addSegment(start, end, this.schema.enumColor);\n case ts.SyntaxKind.CallExpression:\n case ts.SyntaxKind.EnumDeclaration:\n case ts.SyntaxKind.PropertySignature:\n case ts.SyntaxKind.ModuleDeclaration:\n return this.addSegment(start, end, this.schema.variableColor);\n case ts.SyntaxKind.InterfaceDeclaration:\n return this.addSegment(start, end, this.schema.interfaceColor);\n case ts.SyntaxKind.GetAccessor:\n return this.addSegment(start, end, this.schema.getAccessorColor);\n case ts.SyntaxKind.PropertyAssignment:\n return this.addSegment(start, end, this.schema.propertyAssignmentColor);\n case ts.SyntaxKind.MethodSignature:\n return this.addSegment(start, end, this.schema.methodSignatureColor);\n case ts.SyntaxKind.MethodDeclaration:\n case ts.SyntaxKind.FunctionDeclaration:\n return this.addSegment(start, end, this.schema.functionColor);\n case ts.SyntaxKind.ClassDeclaration:\n return this.addSegment(start, end, this.schema.classColor);\n case ts.SyntaxKind.Parameter:\n return this.addSegment(start, end, this.schema.parameterColor);\n case ts.SyntaxKind.VariableDeclaration:\n return this.addSegment(start, end, this.schema.variableColor);\n case ts.SyntaxKind.PropertyDeclaration:\n return this.addSegment(start, end, this.schema.variableColor);\n case ts.SyntaxKind.PropertyAccessExpression: {\n if (node.parent.getChildAt(0).getText() === node.getText()) {\n return this.addSegment(start, end, this.schema.variableColor);\n }\n\n return this.addSegment(start, end, this.schema.propertyAccessExpressionColor);\n }\n case ts.SyntaxKind.ExpressionWithTypeArguments:\n return this.addSegment(start, end, this.schema.expressionWithTypeArgumentsColor);\n case ts.SyntaxKind.BreakStatement:\n case ts.SyntaxKind.ShorthandPropertyAssignment:\n case ts.SyntaxKind.BindingElement:\n return this.addSegment(start, end, this.schema.variableColor);\n case ts.SyntaxKind.BinaryExpression:\n case ts.SyntaxKind.SwitchStatement:\n case ts.SyntaxKind.TemplateSpan:\n return this.addSegment(start, end, this.schema.variableColor);\n case ts.SyntaxKind.TypeReference:\n case ts.SyntaxKind.TypeAliasDeclaration:\n return this.addSegment(start, end, this.schema.typeColor);\n case ts.SyntaxKind.NewExpression:\n return this.addSegment(start, end, this.schema.variableColor);\n }\n }\n\n /**\n * Processes a TypeScript template expression and adds segments for highlighting its literal parts.\n *\n * This method adds a segment for the head of the template expression with the color specified in `this.schema.stringColor`.\n * It also processes each template span within the expression, adding\n * segments for each span's literal part.\n *\n * @param templateExpression - The TypeScript template expression to be processed.\n */\n\n private processTemplateExpression(templateExpression: ts.TemplateExpression): void {\n const start = templateExpression.head.getStart();\n const end = templateExpression.head.getEnd();\n this.addSegment(start, end, this.schema.stringColor);\n\n templateExpression.templateSpans.forEach(span => {\n const spanStart = span.literal.getStart();\n const spanEnd = span.literal.getEnd();\n this.addSegment(spanStart, spanEnd, this.schema.stringColor);\n });\n }\n\n /**\n * Processes a TypeScript AST node and adds segments for highlighting based on the node's kind.\n *\n * This method identifies the kind of the node and determines the appropriate color for highlighting.\n * It handles various node kinds including string literals, regular expressions, template expressions, and identifiers.\n * Specific methods are invoked for more complex node kinds, such as template expressions and identifiers.\n *\n * @param node - The TypeScript AST node to be processed.\n */\n\n private processNode(node: ts.Node): void {\n const start = node.getStart();\n const end = node.getEnd();\n\n switch (node.kind) {\n case ts.SyntaxKind.TypeParameter:\n return this.addSegment(start, start + (node as ts.TypeParameterDeclaration).name.text.length, this.schema.typeColor);\n case ts.SyntaxKind.TypeReference:\n return this.addSegment(start, end, this.schema.typeColor);\n case ts.SyntaxKind.StringLiteral:\n case ts.SyntaxKind.NoSubstitutionTemplateLiteral:\n return this.addSegment(start, end, this.schema.stringColor);\n case ts.SyntaxKind.RegularExpressionLiteral:\n return this.addSegment(start, end, this.schema.regularExpressionColor);\n case ts.SyntaxKind.TemplateExpression:\n return this.processTemplateExpression(node as ts.TemplateExpression);\n case ts.SyntaxKind.Identifier:\n return this.processIdentifier(node);\n case ts.SyntaxKind.BigIntLiteral:\n case ts.SyntaxKind.NumericLiteral:\n return this.addSegment(start, end, this.schema.numericLiteralColor);\n }\n }\n}\n\n/**\n * Applies semantic highlighting to the provided code string using the specified color scheme.\n *\n * @param code - The source code to be highlighted.\n * @param schema - An optional partial schema defining the color styles for various code elements.\n * Defaults to an empty object, which means no specific highlighting will be applied.\n *\n * @returns A string with the code elements wrapped in the appropriate color styles as specified by the schema.\n *\n * @example\n * const code = 'const x: number = 42;';\n * const schema = {\n * keywordColor: '\\x1b[34m', // Blue\n * stringColor: '\\x1b[32m', // Green\n * numberColor: '\\x1b[31m', // Red\n * reset: '\\x1b[0m' // Reset\n * };\n * const highlightedCode = highlightCode(code, schema);\n * console.log(highlightedCode);\n */\n\nexport function highlightCode(code: string, schema: Partial<HighlightSchemeInterface> = {}) {\n const sourceFile = ts.createSourceFile('temp.ts', code, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);\n const codeHighlighter = new CodeHighlighter(sourceFile, code, Object.assign(defaultScheme, schema));\n\n function walk(node: ts.Node): void {\n codeHighlighter.parseNode(node);\n\n for (let i = 0; i < node.getChildCount(); i++) {\n walk(node.getChildAt(i));\n }\n } ts.forEachChild(sourceFile, walk);\n\n return codeHighlighter.highlight();\n}\n"],
6
+ "mappings": "AAUA,UAAYA,MAAQ,aACpB,OAAS,cAAAC,MAAkB,aAmBpB,IAAWC,OACdA,EAAA,MAAQ,UACRA,EAAA,KAAO,iBACPA,EAAA,SAAW,iBACXA,EAAA,WAAa,iBACbA,EAAA,YAAc,iBACdA,EAAA,WAAa,iBACbA,EAAA,YAAc,iBACdA,EAAA,qBAAuB,iBACvBA,EAAA,YAAc,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C5D,KAAKnB,EAAG,WAAW,cACnB,KAAKA,EAAG,WAAW,8BACf,OAAO,KAAK,WAAWkB,EAAOC,EAAK,KAAK,OAAO,WAAW,EAC9D,KAAKnB,EAAG,WAAW,yBACf,OAAO,KAAK,WAAWkB,EAAOC,EAAK,KAAK,OAAO,sBAAsB,EACzE,KAAKnB,EAAG,WAAW,mBACf,OAAO,KAAK,0BAA0BQ,CAA6B,EACvE,KAAKR,EAAG,WAAW,WACf,OAAO,KAAK,kBAAkBQ,CAAI,EACtC,KAAKR,EAAG,WAAW,cACnB,KAAKA,EAAG,WAAW,eACf,OAAO,KAAK,WAAWkB,EAAOC,EAAK,KAAK,OAAO,mBAAmB,CAC1E,CACJ,CACJ,CAuBO,SAASS,EAActB,EAAcC,EAA4C,CAAC,EAAG,CACxF,MAAMF,EAAaL,EAAG,iBAAiB,UAAWM,EAAMN,EAAG,aAAa,OAAQ,GAAMA,EAAG,WAAW,EAAE,EAChG6B,EAAkB,IAAIzB,EAAgBC,EAAYC,EAAM,OAAO,OAAOH,EAAeI,CAAM,CAAC,EAElG,SAASuB,EAAKtB,EAAqB,CAC/BqB,EAAgB,UAAUrB,CAAI,EAE9B,QAAS,EAAI,EAAG,EAAIA,EAAK,cAAc,EAAG,IACtCsB,EAAKtB,EAAK,WAAW,CAAC,CAAC,CAE/B,CAAE,OAAAR,EAAG,aAAaK,EAAYyB,CAAI,EAE3BD,EAAgB,UAAU,CACrC",
7
+ "names": ["ts", "SyntaxKind", "Colors", "defaultScheme", "CodeHighlighter", "sourceFile", "code", "schema", "node", "previousSegmentEnd", "parent", "result", "a", "b", "segment", "lastSegment", "source", "combinedSource", "start", "end", "color", "reset", "key", "comment", "templateExpression", "span", "spanStart", "spanEnd", "highlightCode", "codeHighlighter", "walk"]
8
+ }
@@ -0,0 +1,3 @@
1
+ function g(o){const u=o.split(`
2
+ `).slice(1),m=/^\s*at\s+(.*?)\s+\((.*?):(\d+):(\d+)\)$|^\s*at\s+(.*?):(\d+):(\d+)$/,f=/eval\s+at\s+([^\s(]+).+\((.+):(\d+):(\d+)\),\s(.+)/,t=[];return u.forEach(n=>{const e=n.match(m);if(!e)return;let a=e.slice(1);e[2]||(a=e.slice(4));const[r,s,p,v]=a,c=parseInt(p,10),l=parseInt(v,10);if(n.includes("eval")){const i=s.match(f)?.slice(1);if(i){const[y,d,h,I,N]=i;t.push({at:r,file:N,line:c,column:l,executor:{at:y,file:d,line:parseInt(h,10),column:parseInt(I,10)}});return}}t.push({at:r||"<anonymous>",file:s,line:c,column:l,executor:null})}),t}export{g as parseErrorStack};
3
+ //# sourceMappingURL=parser.component.js.map
@@ -0,0 +1,8 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/components/parser.component.ts"],
4
+ "sourceRoot": "https://github.com/remotex-lab/xmap/tree/2.0.3/",
5
+ "sourcesContent": ["/**\n * Import will remove at compile time\n */\n\nimport type { StackEntryInterface } from './/interfaces/parse.interface.js';\n\n/**\n * Parses an error stack trace and returns an object with a message and an array of stack entries.\n *\n * @param stackString - The error stack trace.\n * @returns The parsed stack trace object.\n */\n\nexport function parseErrorStack(stackString: string): Array<StackEntryInterface> {\n const lines = stackString.split('\\n').slice(1);\n const regex = /^\\s*at\\s+(.*?)\\s+\\((.*?):(\\d+):(\\d+)\\)$|^\\s*at\\s+(.*?):(\\d+):(\\d+)$/;\n const evalRegex = /eval\\s+at\\s+([^\\s(]+).+\\((.+):(\\d+):(\\d+)\\),\\s(.+)/;\n const stack: Array<StackEntryInterface> = [];\n\n lines.forEach((line) => {\n const match = line.match(regex);\n if (!match) return;\n\n let args: Array<string> = match.slice(1);\n if(!match[2]) {\n args = match.slice(4);\n }\n\n const [ at, file, lineNum, colNum ] = args;\n const lineNumber = parseInt(lineNum, 10);\n const columnNumber = parseInt(colNum, 10);\n\n if (line.includes('eval')) {\n const evalMatch = file.match(evalRegex)?.slice(1);\n if (evalMatch) {\n const [ evalAt, evalFile, evalLineNum, evalColNum, evalAnonFile ] = evalMatch;\n stack.push({\n at,\n file: evalAnonFile,\n line: lineNumber,\n column: columnNumber,\n executor: {\n at: evalAt,\n file: evalFile,\n line: parseInt(evalLineNum, 10),\n column: parseInt(evalColNum, 10)\n }\n });\n\n return;\n }\n }\n\n stack.push({\n at: at || '<anonymous>',\n file,\n line: lineNumber,\n column: columnNumber,\n executor: null\n });\n });\n\n return stack;\n}\n"],
6
+ "mappings": "AAaO,SAASA,EAAgBC,EAAiD,CAC7E,MAAMC,EAAQD,EAAY,MAAM;AAAA,CAAI,EAAE,MAAM,CAAC,EACvCE,EAAQ,sEACRC,EAAY,qDACZC,EAAoC,CAAC,EAE3C,OAAAH,EAAM,QAASI,GAAS,CACpB,MAAMC,EAAQD,EAAK,MAAMH,CAAK,EAC9B,GAAI,CAACI,EAAO,OAEZ,IAAIC,EAAsBD,EAAM,MAAM,CAAC,EACnCA,EAAM,CAAC,IACPC,EAAOD,EAAM,MAAM,CAAC,GAGxB,KAAM,CAAEE,EAAIC,EAAMC,EAASC,CAAO,EAAIJ,EAChCK,EAAa,SAASF,EAAS,EAAE,EACjCG,EAAe,SAASF,EAAQ,EAAE,EAExC,GAAIN,EAAK,SAAS,MAAM,EAAG,CACvB,MAAMS,EAAYL,EAAK,MAAMN,CAAS,GAAG,MAAM,CAAC,EAChD,GAAIW,EAAW,CACX,KAAM,CAAEC,EAAQC,EAAUC,EAAaC,EAAYC,CAAa,EAAIL,EACpEV,EAAM,KAAK,CACP,GAAAI,EACA,KAAMW,EACN,KAAMP,EACN,OAAQC,EACR,SAAU,CACN,GAAIE,EACJ,KAAMC,EACN,KAAM,SAASC,EAAa,EAAE,EAC9B,OAAQ,SAASC,EAAY,EAAE,CACnC,CACJ,CAAC,EAED,MACJ,CACJ,CAEAd,EAAM,KAAK,CACP,GAAII,GAAM,cACV,KAAAC,EACA,KAAMG,EACN,OAAQC,EACR,SAAU,IACd,CAAC,CACL,CAAC,EAEMT,CACX",
7
+ "names": ["parseErrorStack", "stackString", "lines", "regex", "evalRegex", "stack", "line", "match", "args", "at", "file", "lineNum", "colNum", "lineNumber", "columnNumber", "evalMatch", "evalAt", "evalFile", "evalLineNum", "evalColNum", "evalAnonFile"]
8
+ }
package/dist/esm/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  function $(u){let e=u.split(`
2
- `).slice(1),t=/^\s*at\s+(.*?)\s+\((.*?):(\d+):(\d+)\)$|^\s*at\s+(.*?):(\d+):(\d+)$/,n=/eval\s+at\s+([^\s(]+).+\((.+):(\d+):(\d+)\),\s(.+)/,i=[];return e.forEach(r=>{let s=r.match(t);if(!s)return;let a=s.slice(1);s[2]||(a=s.slice(4));let[c,l,d,g]=a,h=parseInt(d,10),m=parseInt(g,10);if(r.includes("eval")){let y=l.match(n)?.slice(1);if(y){let[N,w,E,A,M]=y;i.push({at:c,file:M,line:h,column:m,executor:{at:N,file:w,line:parseInt(E,10),column:parseInt(A,10)}});return}}i.push({at:c||"<anonymous>",file:l,line:h,column:m,executor:null})}),i}var x={},I="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");I.forEach((u,e)=>{x[u]=e});function T(u){let e=u<0,t="",n=e?(-u<<1)+1:u<<1;do{let i=n&31;n>>>=5,t+=I[i|(n>0?32:0)]}while(n>0);return t}function C(u){return u.map(T).join("")}function b(u){let e=[],t=0,n=0;for(let i=0;i<u.length;i++){let r=x[u[i]];if(r===void 0)throw new Error(`Invalid Base64 character: ${u[i]}`);let s=r&32;if(n+=(r&31)<<t,s)t+=5;else{let a=(n&1)===1,c=n>>1;e.push(a?-c:c),n=t=0}}return e}function K(u,e={}){let t=u.split(`
3
- `),n=e.padding??10,i=e.startLine??0;return t.map((r,s)=>{let a=s+i+1,l=`${`${a} | `.padStart(n)}${r}`;return e.action&&a===e.action.triggerLine?e.action.callback(l,n,a):l}).join(`
4
- `)}function F(u,e){let{code:t,line:n,column:i,startLine:r}=u;if(n<r||i<1)throw new Error("Invalid line or column number.");return K(t,{startLine:r,action:{triggerLine:n,callback:(s,a,c)=>{let l="^",d=a-1,g=">";e&&(l=`${e.color}${l}${e.reset}`,d+=e.color.length+e.reset.length,g=`${e.color}>${e.reset}`);let h=" | ".padStart(a)+" ".repeat(i-1)+`${l}`;return s=`${g} ${c} |`.padStart(d)+s.split("|")[1],s+`
5
- ${h}`}}})}import*as o from"typescript";import{SyntaxKind as p}from"typescript";var O=(m=>(m.reset="\x1B[0m",m.gray="\x1B[38;5;243m",m.darkGray="\x1B[38;5;238m",m.lightCoral="\x1B[38;5;203m",m.lightOrange="\x1B[38;5;215m",m.oliveGreen="\x1B[38;5;149m",m.burntOrange="\x1B[38;5;208m",m.lightGoldenrodYellow="\x1B[38;5;221m",m.lightYellow="\x1B[38;5;230m",m.canaryYellow="\x1B[38;5;227m",m.deepOrange="\x1B[38;5;166m",m.lightGray="\x1B[38;5;252m",m.brightPink="\x1B[38;5;197m",m))(O||{}),L={enumColor:"\x1B[38;5;208m",typeColor:"\x1B[38;5;221m",classColor:"\x1B[38;5;215m",stringColor:"\x1B[38;5;149m",keywordColor:"\x1B[38;5;203m",commentColor:"\x1B[38;5;238m",functionColor:"\x1B[38;5;215m",variableColor:"\x1B[38;5;208m",interfaceColor:"\x1B[38;5;221m",parameterColor:"\x1B[38;5;166m",getAccessorColor:"\x1B[38;5;230m",numericLiteralColor:"\x1B[38;5;252m",methodSignatureColor:"\x1B[38;5;208m",regularExpressionColor:"\x1B[38;5;149m",propertyAssignmentColor:"\x1B[38;5;227m",propertyAccessExpressionColor:"\x1B[38;5;230m",expressionWithTypeArgumentsColor:"\x1B[38;5;215m"},S=class{constructor(e,t,n){this.sourceFile=e;this.code=t;this.schema=n}segments=new Map;parseNode(e){this.processComments(e),this.processKeywords(e),this.processNode(e)}highlight(){let e=0,t,n=[];return Array.from(this.segments.values()).sort((r,s)=>r.start-s.start||r.end-s.end).forEach(r=>{if(t&&r.start<t.end){let s=n.pop();if(!s)return;let a=this.getSegmentSource(r.start,r.end),c=`${r.color}${a}${t.color}`;n.push(s.replace(a,c));return}n.push(this.getSegmentSource(e,r.start)),n.push(`${r.color}${this.getSegmentSource(r.start,r.end)}${r.reset}`),e=r.end,t=r}),n.join("")+this.getSegmentSource(e)}getSegmentSource(e,t){return this.code.slice(e,t)}addSegment(e,t,n,i="\x1B[0m"){let r=`${e}-${t}`;this.segments.set(r,{start:e,end:t,color:n,reset:i})}processComments(e){[...o.getTrailingCommentRanges(this.sourceFile.getFullText(),e.getFullStart())||[],...o.getLeadingCommentRanges(this.sourceFile.getFullText(),e.getFullStart())||[]].forEach(n=>this.addSegment(n.pos,n.end,this.schema.commentColor))}processKeywords(e){if([p.NullKeyword,p.VoidKeyword,p.StringKeyword,p.NumberKeyword,p.BooleanKeyword,p.UndefinedKeyword].includes(e.kind))return this.addSegment(e.getStart(),e.getEnd(),this.schema.typeColor);e&&e.kind>=o.SyntaxKind.FirstKeyword&&e.kind<=o.SyntaxKind.LastKeyword&&this.addSegment(e.getStart(),e.getEnd(),this.schema.keywordColor)}processIdentifier(e){let t=e.getEnd(),n=e.getStart();switch(e.parent.kind){case o.SyntaxKind.EnumMember:return this.addSegment(n,t,this.schema.enumColor);case o.SyntaxKind.CallExpression:case o.SyntaxKind.EnumDeclaration:case o.SyntaxKind.PropertySignature:case o.SyntaxKind.ModuleDeclaration:return this.addSegment(n,t,this.schema.variableColor);case o.SyntaxKind.InterfaceDeclaration:return this.addSegment(n,t,this.schema.interfaceColor);case o.SyntaxKind.GetAccessor:return this.addSegment(n,t,this.schema.getAccessorColor);case o.SyntaxKind.PropertyAssignment:return this.addSegment(n,t,this.schema.propertyAssignmentColor);case o.SyntaxKind.MethodSignature:return this.addSegment(n,t,this.schema.methodSignatureColor);case o.SyntaxKind.MethodDeclaration:case o.SyntaxKind.FunctionDeclaration:return this.addSegment(n,t,this.schema.functionColor);case o.SyntaxKind.ClassDeclaration:return this.addSegment(n,t,this.schema.classColor);case o.SyntaxKind.Parameter:return this.addSegment(n,t,this.schema.parameterColor);case o.SyntaxKind.VariableDeclaration:return this.addSegment(n,t,this.schema.variableColor);case o.SyntaxKind.PropertyDeclaration:return this.addSegment(n,t,this.schema.variableColor);case o.SyntaxKind.PropertyAccessExpression:return e.parent.getChildAt(0).getText()===e.getText()?this.addSegment(n,t,this.schema.variableColor):this.addSegment(n,t,this.schema.propertyAccessExpressionColor);case o.SyntaxKind.ExpressionWithTypeArguments:return this.addSegment(n,t,this.schema.expressionWithTypeArgumentsColor);case o.SyntaxKind.BreakStatement:case o.SyntaxKind.ShorthandPropertyAssignment:case o.SyntaxKind.BindingElement:return this.addSegment(n,t,this.schema.variableColor);case o.SyntaxKind.BinaryExpression:case o.SyntaxKind.SwitchStatement:case o.SyntaxKind.TemplateSpan:return this.addSegment(n,t,this.schema.variableColor);case o.SyntaxKind.TypeReference:case o.SyntaxKind.TypeAliasDeclaration:return this.addSegment(n,t,this.schema.typeColor);case o.SyntaxKind.NewExpression:return this.addSegment(n,t,this.schema.variableColor)}}processTemplateExpression(e){let t=e.head.getStart(),n=e.head.getEnd();this.addSegment(t,n,this.schema.stringColor),e.templateSpans.forEach(i=>{let r=i.literal.getStart(),s=i.literal.getEnd();this.addSegment(r,s,this.schema.stringColor)})}processNode(e){let t=e.getStart(),n=e.getEnd();switch(e.kind){case o.SyntaxKind.TypeParameter:return this.addSegment(t,t+e.name.text.length,this.schema.typeColor);case o.SyntaxKind.TypeReference:return this.addSegment(t,n,this.schema.typeColor);case o.SyntaxKind.StringLiteral:case o.SyntaxKind.NoSubstitutionTemplateLiteral:return this.addSegment(t,n,this.schema.stringColor);case o.SyntaxKind.RegularExpressionLiteral:return this.addSegment(t,n,this.schema.regularExpressionColor);case o.SyntaxKind.TemplateExpression:return this.processTemplateExpression(e);case o.SyntaxKind.Identifier:return this.processIdentifier(e);case o.SyntaxKind.BigIntLiteral:case o.SyntaxKind.NumericLiteral:return this.addSegment(t,n,this.schema.numericLiteralColor)}}};function D(u,e={}){let t=o.createSourceFile("temp.ts",u,o.ScriptTarget.Latest,!0,o.ScriptKind.TS),n=new S(t,u,Object.assign(L,e));function i(r){n.parseNode(r);for(let s=0;s<r.getChildCount();s++)i(r.getChildAt(s))}return o.forEachChild(t,i),n.highlight()}var f=class u{mapping=[];constructor(e,t=0,n=0){e=e instanceof u?e.mapping:e,Array.isArray(e)?this.decodeMappingArray(e,t,n):this.decodeMappingString(e,t,n)}encode(){return this.encodeMappings(this.mapping)}decode(e,t=0,n=0){e=e instanceof u?e.mapping:e,Array.isArray(e)?this.decodeMappingArray(e,t,n):this.decodeMappingString(e,t,n)}getSegment(e,t,n=0){let i=this.mapping[e-1];if(!i||i.length===0)return null;let r=0,s=i.length-1,a=null;for(;r<=s;){let c=Math.floor((r+s)/2),l=i[c];if(l.generatedColumn<t)r=c+1,a=n===1?l:a;else if(l.generatedColumn>t)s=c-1,a=n===2?l:a;else return l}return a}getOriginalSegment(e,t,n,i=0){let r=null;for(let s of this.mapping){if(!s)continue;let a=0,c=s.length-1;for(;a<=c;){let l=Math.floor((a+c)/2),d=s[l];if(d.sourceIndex<n||d.line<e)a=l+1;else if(d.sourceIndex>n||d.line>e)c=l-1;else if(d.column<t)a=l+1,r=i===1?d:r;else if(d.column>t)c=l-1,r=i===2?d:r;else return d}}return r}initPositionOffsets(e=0,t=0){return{line:0,column:0,nameIndex:e,sourceIndex:t,generatedLine:0,generatedColumn:0}}validateMappingString(e){return/^[a-zA-Z0-9+/,;]+$/.test(e)}validateSegment(e){if(!Number.isFinite(e.line))throw new Error(`Invalid segment: line must be a finite number, received ${e.line}`);if(!Number.isFinite(e.column))throw new Error(`Invalid segment: column must be a finite number, received ${e.column}`);if(e.nameIndex!==null&&!Number.isFinite(e.nameIndex))throw new Error(`Invalid segment: nameIndex must be a number or null, received ${e.nameIndex}`);if(!Number.isFinite(e.sourceIndex))throw new Error(`Invalid segment: sourceIndex must be a finite number, received ${e.sourceIndex}`);if(!Number.isFinite(e.generatedLine))throw new Error(`Invalid segment: generatedLine must be a finite number, received ${e.generatedLine}`);if(!Number.isFinite(e.generatedColumn))throw new Error(`Invalid segment: generatedColumn must be a finite number, received ${e.generatedColumn}`)}encodeSegment(e,t){let{line:n,column:i,generatedColumn:r,nameIndex:s,sourceIndex:a}=t,c=n-1,l=i-1,d=r-1,g=[d-e.generatedColumn,a!==e.sourceIndex?a-e.sourceIndex:0,c-e.line,l-e.column];return s!=null&&(g[4]=s-e.nameIndex,e.nameIndex=s),e.line=c,e.column=l,e.generatedColumn=d,e.sourceIndex=a,C(g)}encodeMappings(e){let t=this.initPositionOffsets();return e.map(n=>n?(t.generatedColumn=0,n.map(r=>this.encodeSegment(t,r)).join(",")):"").join(";")}decodedSegment(e,t){let[n,i,r,s,a]=t;return e.line+=r,e.column+=s,e.nameIndex+=a??0,e.sourceIndex+=i,e.generatedColumn+=n,{line:e.line+1,column:e.column+1,nameIndex:a!==void 0?e.nameIndex:null,sourceIndex:e.sourceIndex,generatedLine:e.generatedLine+1,generatedColumn:e.generatedColumn+1}}decodeMappingString(e,t,n){if(!this.validateMappingString(e))throw new Error("Invalid Mappings string format: the provided string does not conform to expected VLQ format.");let i=e.split(";"),r=this.mapping.length,s=this.initPositionOffsets(t,n);try{i.forEach((a,c)=>{if(!a){this.mapping.push(null);return}s.generatedColumn=0,s.generatedLine=r+c;let l=a.split(",").map(d=>this.decodedSegment(s,b(d)));this.mapping.push(l)})}catch(a){throw new Error(`Error decoding mappings at frame index ${i.length}: ${a.message}`)}}decodeMappingArray(e,t,n){let i=this.mapping.length;if(!Array.isArray(e))throw new Error("Invalid encoded map: expected an array of frames.");try{e.forEach((r,s)=>{if(!r){this.mapping.push(r);return}if(!Array.isArray(r))throw new Error(`Invalid Mappings array format at frame index ${s}: expected an array, received ${typeof r}.`);let a=r.map(c=>(this.validateSegment(c),{...c,nameIndex:typeof c.nameIndex=="number"?c.nameIndex+t:null,sourceIndex:c.sourceIndex+n,generatedLine:c.generatedLine+i}));this.mapping.push(a)})}catch(r){let s=r instanceof Error?r.message:"Unknown error";throw new Error(`Error decoding mappings: ${s}`)}}};var v=class u{file;mappings;sourceRoot;names;sources;sourcesContent;constructor(e,t=null){typeof e=="string"&&(e=JSON.parse(e)),e=e,this.validateSourceMap(e),this.file=e.file??t,this.names=[...e.names??[]],this.sources=[...e.sources??[]],this.sourceRoot=e.sourceRoot??null,this.sourcesContent=e.sourcesContent?[...e.sourcesContent]:[],this.mappings=new f(e.mappings)}getMapObject(){let e={version:3,names:this.names,sources:this.sources,mappings:this.mappings.encode(),sourcesContent:this.sourcesContent};return this.file&&(e.file=this.file),this.sourceRoot&&(e.sourceRoot=this.sourceRoot),e}concat(...e){if(e.length<1)throw new Error("At least one map must be provided for concatenation.");for(let t of e)this.mappings.decode(t.mappings,this.names.length,this.sources.length),this.names.push(...t.names),this.sources.push(...t.sources),this.sourcesContent.push(...t.sourcesContent??[])}concatNewMap(...e){if(e.length<1)throw new Error("At least one map must be provided for concatenation.");let t=new u(this);for(let n of e)t.mappings.decode(n.mappings,t.names.length,t.sources.length),t.names.push(...n.names),t.sources.push(...n.sources),t.sourcesContent.push(...n.sourcesContent??[]);return t}getPositionByOriginal(e,t,n,i=0){let r=n;if(typeof n=="string"&&(r=this.sources.findIndex(a=>a.includes(n))),r<0)return null;let s=this.mappings.getOriginalSegment(e,t,r,i);return s?{name:this.names[s.nameIndex??-1]??null,line:s.line,column:s.column,source:this.sources[s.sourceIndex],sourceRoot:this.sourceRoot,sourceIndex:s.sourceIndex,generatedLine:s.generatedLine,generatedColumn:s.generatedColumn}:null}getPosition(e,t,n=0){let i=this.mappings.getSegment(e,t,n);return i?{name:this.names[i.nameIndex??-1]??null,line:i.line,column:i.column,source:this.sources[i.sourceIndex],sourceRoot:this.sourceRoot,sourceIndex:i.sourceIndex,generatedLine:i.generatedLine,generatedColumn:i.generatedColumn}:null}getPositionWithContent(e,t,n=0){let i=this.getPosition(e,t,n);return i?{...i,sourcesContent:this.sourcesContent[i.sourceIndex]}:null}getPositionWithCode(e,t,n=0,i){let r=this.getPosition(e,t,n);if(!r||!this.sourcesContent[r.sourceIndex])return null;let s=Object.assign({linesAfter:4,linesBefore:3},i),a=this.sourcesContent[r.sourceIndex].split(`
6
- `),c=Math.min((r.line??1)+s.linesAfter,a.length),l=Math.max((r.line??1)-s.linesBefore,0),d=a.slice(l,Math.min(c+1,a.length)).join(`
2
+ `).slice(1),t=/^\s*at\s+(.*?)\s+\((.*?):(\d+):(\d+)\)$|^\s*at\s+(.*?):(\d+):(\d+)$/,n=/eval\s+at\s+([^\s(]+).+\((.+):(\d+):(\d+)\),\s(.+)/,i=[];return e.forEach(r=>{let o=r.match(t);if(!o)return;let a=o.slice(1);o[2]||(a=o.slice(4));let[c,l,d,g]=a,h=parseInt(d,10),m=parseInt(g,10);if(r.includes("eval")){let y=l.match(n)?.slice(1);if(y){let[N,w,E,A,M]=y;i.push({at:c,file:M,line:h,column:m,executor:{at:N,file:w,line:parseInt(E,10),column:parseInt(A,10)}});return}}i.push({at:c||"<anonymous>",file:l,line:h,column:m,executor:null})}),i}var x={},I="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");I.forEach((u,e)=>{x[u]=e});function T(u){let e=u<0,t="",n=e?(-u<<1)+1:u<<1;do{let i=n&31;n>>>=5,t+=I[i|(n>0?32:0)]}while(n>0);return t}function C(u){return u.map(T).join("")}function b(u){let e=[],t=0,n=0;for(let i=0;i<u.length;i++){let r=x[u[i]];if(r===void 0)throw new Error(`Invalid Base64 character: ${u[i]}`);let o=r&32;if(n+=(r&31)<<t,o)t+=5;else{let a=(n&1)===1,c=n>>1;e.push(a?-c:c),n=t=0}}return e}function K(u,e={}){let t=u.split(`
3
+ `),n=e.padding??10,i=e.startLine??0;return t.map((r,o)=>{let a=o+i+1,l=`${`${a} | `.padStart(n)}${r}`;return e.action&&a===e.action.triggerLine?e.action.callback(l,n,a):l}).join(`
4
+ `)}function F(u,e){let{code:t,line:n,column:i,startLine:r}=u;if(n<r||i<1)throw new Error("Invalid line or column number.");return K(t,{startLine:r,action:{triggerLine:n,callback:(o,a,c)=>{let l="^",d=a-1,g=">";e&&(l=`${e.color}${l}${e.reset}`,d+=e.color.length+e.reset.length,g=`${e.color}>${e.reset}`);let h=" | ".padStart(a)+" ".repeat(i-1)+`${l}`;return o=`${g} ${c} |`.padStart(d)+o.split("|")[1],o+`
5
+ ${h}`}}})}import*as s from"typescript";import{SyntaxKind as p}from"typescript";var O=(m=>(m.reset="\x1B[0m",m.gray="\x1B[38;5;243m",m.darkGray="\x1B[38;5;238m",m.lightCoral="\x1B[38;5;203m",m.lightOrange="\x1B[38;5;215m",m.oliveGreen="\x1B[38;5;149m",m.burntOrange="\x1B[38;5;208m",m.lightGoldenrodYellow="\x1B[38;5;221m",m.lightYellow="\x1B[38;5;230m",m.canaryYellow="\x1B[38;5;227m",m.deepOrange="\x1B[38;5;166m",m.lightGray="\x1B[38;5;252m",m.brightPink="\x1B[38;5;197m",m))(O||{}),L={enumColor:"\x1B[38;5;208m",typeColor:"\x1B[38;5;221m",classColor:"\x1B[38;5;215m",stringColor:"\x1B[38;5;149m",keywordColor:"\x1B[38;5;203m",commentColor:"\x1B[38;5;238m",functionColor:"\x1B[38;5;215m",variableColor:"\x1B[38;5;208m",interfaceColor:"\x1B[38;5;221m",parameterColor:"\x1B[38;5;166m",getAccessorColor:"\x1B[38;5;230m",numericLiteralColor:"\x1B[38;5;252m",methodSignatureColor:"\x1B[38;5;208m",regularExpressionColor:"\x1B[38;5;149m",propertyAssignmentColor:"\x1B[38;5;227m",propertyAccessExpressionColor:"\x1B[38;5;230m",expressionWithTypeArgumentsColor:"\x1B[38;5;215m"},S=class{constructor(e,t,n){this.sourceFile=e;this.code=t;this.schema=n}segments=new Map;parseNode(e){this.processComments(e),this.processKeywords(e),this.processNode(e)}highlight(){let e=0,t,n=[];return Array.from(this.segments.values()).sort((r,o)=>r.start-o.start||r.end-o.end).forEach(r=>{if(t&&r.start<t.end){let o=n.pop();if(!o)return;let a=this.getSegmentSource(r.start,r.end),c=`${r.color}${a}${t.color}`;n.push(o.replace(a,c));return}n.push(this.getSegmentSource(e,r.start)),n.push(`${r.color}${this.getSegmentSource(r.start,r.end)}${r.reset}`),e=r.end,t=r}),n.join("")+this.getSegmentSource(e)}getSegmentSource(e,t){return this.code.slice(e,t)}addSegment(e,t,n,i="\x1B[0m"){let r=`${e}-${t}`;this.segments.set(r,{start:e,end:t,color:n,reset:i})}processComments(e){[...s.getTrailingCommentRanges(this.sourceFile.getFullText(),e.getFullStart())||[],...s.getLeadingCommentRanges(this.sourceFile.getFullText(),e.getFullStart())||[]].forEach(n=>this.addSegment(n.pos,n.end,this.schema.commentColor))}processKeywords(e){if([p.NullKeyword,p.VoidKeyword,p.StringKeyword,p.NumberKeyword,p.BooleanKeyword,p.UndefinedKeyword].includes(e.kind))return this.addSegment(e.getStart(),e.getEnd(),this.schema.typeColor);e&&e.kind>=s.SyntaxKind.FirstKeyword&&e.kind<=s.SyntaxKind.LastKeyword&&this.addSegment(e.getStart(),e.getEnd(),this.schema.keywordColor)}processIdentifier(e){let t=e.getEnd(),n=e.getStart();switch(e.parent.kind){case s.SyntaxKind.EnumMember:return this.addSegment(n,t,this.schema.enumColor);case s.SyntaxKind.CallExpression:case s.SyntaxKind.EnumDeclaration:case s.SyntaxKind.PropertySignature:case s.SyntaxKind.ModuleDeclaration:return this.addSegment(n,t,this.schema.variableColor);case s.SyntaxKind.InterfaceDeclaration:return this.addSegment(n,t,this.schema.interfaceColor);case s.SyntaxKind.GetAccessor:return this.addSegment(n,t,this.schema.getAccessorColor);case s.SyntaxKind.PropertyAssignment:return this.addSegment(n,t,this.schema.propertyAssignmentColor);case s.SyntaxKind.MethodSignature:return this.addSegment(n,t,this.schema.methodSignatureColor);case s.SyntaxKind.MethodDeclaration:case s.SyntaxKind.FunctionDeclaration:return this.addSegment(n,t,this.schema.functionColor);case s.SyntaxKind.ClassDeclaration:return this.addSegment(n,t,this.schema.classColor);case s.SyntaxKind.Parameter:return this.addSegment(n,t,this.schema.parameterColor);case s.SyntaxKind.VariableDeclaration:return this.addSegment(n,t,this.schema.variableColor);case s.SyntaxKind.PropertyDeclaration:return this.addSegment(n,t,this.schema.variableColor);case s.SyntaxKind.PropertyAccessExpression:return e.parent.getChildAt(0).getText()===e.getText()?this.addSegment(n,t,this.schema.variableColor):this.addSegment(n,t,this.schema.propertyAccessExpressionColor);case s.SyntaxKind.ExpressionWithTypeArguments:return this.addSegment(n,t,this.schema.expressionWithTypeArgumentsColor);case s.SyntaxKind.BreakStatement:case s.SyntaxKind.ShorthandPropertyAssignment:case s.SyntaxKind.BindingElement:return this.addSegment(n,t,this.schema.variableColor);case s.SyntaxKind.BinaryExpression:case s.SyntaxKind.SwitchStatement:case s.SyntaxKind.TemplateSpan:return this.addSegment(n,t,this.schema.variableColor);case s.SyntaxKind.TypeReference:case s.SyntaxKind.TypeAliasDeclaration:return this.addSegment(n,t,this.schema.typeColor);case s.SyntaxKind.NewExpression:return this.addSegment(n,t,this.schema.variableColor)}}processTemplateExpression(e){let t=e.head.getStart(),n=e.head.getEnd();this.addSegment(t,n,this.schema.stringColor),e.templateSpans.forEach(i=>{let r=i.literal.getStart(),o=i.literal.getEnd();this.addSegment(r,o,this.schema.stringColor)})}processNode(e){let t=e.getStart(),n=e.getEnd();switch(e.kind){case s.SyntaxKind.TypeParameter:return this.addSegment(t,t+e.name.text.length,this.schema.typeColor);case s.SyntaxKind.TypeReference:return this.addSegment(t,n,this.schema.typeColor);case s.SyntaxKind.StringLiteral:case s.SyntaxKind.NoSubstitutionTemplateLiteral:return this.addSegment(t,n,this.schema.stringColor);case s.SyntaxKind.RegularExpressionLiteral:return this.addSegment(t,n,this.schema.regularExpressionColor);case s.SyntaxKind.TemplateExpression:return this.processTemplateExpression(e);case s.SyntaxKind.Identifier:return this.processIdentifier(e);case s.SyntaxKind.BigIntLiteral:case s.SyntaxKind.NumericLiteral:return this.addSegment(t,n,this.schema.numericLiteralColor)}}};function D(u,e={}){let t=s.createSourceFile("temp.ts",u,s.ScriptTarget.Latest,!0,s.ScriptKind.TS),n=new S(t,u,Object.assign(L,e));function i(r){n.parseNode(r);for(let o=0;o<r.getChildCount();o++)i(r.getChildAt(o))}return s.forEachChild(t,i),n.highlight()}var f=class u{mapping=[];constructor(e,t=0,n=0){e=e instanceof u?e.mapping:e,Array.isArray(e)?this.decodeMappingArray(e,t,n):this.decodeMappingString(e,t,n)}encode(){return this.encodeMappings(this.mapping)}decode(e,t=0,n=0){e=e instanceof u?e.mapping:e,Array.isArray(e)?this.decodeMappingArray(e,t,n):this.decodeMappingString(e,t,n)}getSegment(e,t,n=0){let i=this.mapping[e-1];if(!i||i.length===0)return null;let r=0,o=i.length-1,a=null;for(;r<=o;){let c=Math.floor((r+o)/2),l=i[c];if(l.generatedColumn<t)r=c+1,a=n===1?l:a;else if(l.generatedColumn>t)o=c-1,a=n===2?l:a;else return l}return a}getOriginalSegment(e,t,n,i=0){let r=null;for(let o of this.mapping){if(!o)continue;let a=0,c=o.length-1;for(;a<=c;){let l=Math.floor((a+c)/2),d=o[l];if(d.sourceIndex<n||d.line<e)a=l+1;else if(d.sourceIndex>n||d.line>e)c=l-1;else if(d.column<t)a=l+1,r=i===1?d:r;else if(d.column>t)c=l-1,r=i===2?d:r;else return d}}return r}initPositionOffsets(e=0,t=0){return{line:0,column:0,nameIndex:e,sourceIndex:t,generatedLine:0,generatedColumn:0}}validateMappingString(e){return/^[a-zA-Z0-9+/,;]+$/.test(e)}validateSegment(e){if(!Number.isFinite(e.line))throw new Error(`Invalid segment: line must be a finite number, received ${e.line}`);if(!Number.isFinite(e.column))throw new Error(`Invalid segment: column must be a finite number, received ${e.column}`);if(e.nameIndex!==null&&!Number.isFinite(e.nameIndex))throw new Error(`Invalid segment: nameIndex must be a number or null, received ${e.nameIndex}`);if(!Number.isFinite(e.sourceIndex))throw new Error(`Invalid segment: sourceIndex must be a finite number, received ${e.sourceIndex}`);if(!Number.isFinite(e.generatedLine))throw new Error(`Invalid segment: generatedLine must be a finite number, received ${e.generatedLine}`);if(!Number.isFinite(e.generatedColumn))throw new Error(`Invalid segment: generatedColumn must be a finite number, received ${e.generatedColumn}`)}encodeSegment(e,t){let{line:n,column:i,generatedColumn:r,nameIndex:o,sourceIndex:a}=t,c=n-1,l=i-1,d=r-1,g=[d-e.generatedColumn,a!==e.sourceIndex?a-e.sourceIndex:0,c-e.line,l-e.column];return o!=null&&(g[4]=o-e.nameIndex,e.nameIndex=o),e.line=c,e.column=l,e.generatedColumn=d,e.sourceIndex=a,C(g)}encodeMappings(e){let t=this.initPositionOffsets();return e.map(n=>n?(t.generatedColumn=0,n.map(r=>this.encodeSegment(t,r)).join(",")):"").join(";")}decodedSegment(e,t){let[n,i,r,o,a]=t;return e.line+=r,e.column+=o,e.nameIndex+=a??0,e.sourceIndex+=i,e.generatedColumn+=n,{line:e.line+1,column:e.column+1,nameIndex:a!==void 0?e.nameIndex:null,sourceIndex:e.sourceIndex,generatedLine:e.generatedLine+1,generatedColumn:e.generatedColumn+1}}decodeMappingString(e,t,n){if(!this.validateMappingString(e))throw new Error("Invalid Mappings string format: the provided string does not conform to expected VLQ format.");let i=e.split(";"),r=this.mapping.length,o=this.initPositionOffsets(t,n);try{i.forEach((a,c)=>{if(!a){this.mapping.push(null);return}o.generatedColumn=0,o.generatedLine=r+c;let l=a.split(",").map(d=>this.decodedSegment(o,b(d)));this.mapping.push(l)})}catch(a){throw new Error(`Error decoding mappings at frame index ${i.length}: ${a.message}`)}}decodeMappingArray(e,t,n){let i=this.mapping.length;if(!Array.isArray(e))throw new Error("Invalid encoded map: expected an array of frames.");try{e.forEach((r,o)=>{if(!r){this.mapping.push(r);return}if(!Array.isArray(r))throw new Error(`Invalid Mappings array format at frame index ${o}: expected an array, received ${typeof r}.`);let a=r.map(c=>(this.validateSegment(c),{...c,nameIndex:typeof c.nameIndex=="number"?c.nameIndex+t:null,sourceIndex:c.sourceIndex+n,generatedLine:c.generatedLine+i}));this.mapping.push(a)})}catch(r){let o=r instanceof Error?r.message:"Unknown error";throw new Error(`Error decoding mappings: ${o}`)}}};var v=class u{file;mappings;sourceRoot;names;sources;sourcesContent;constructor(e,t=null){typeof e=="string"&&(e=JSON.parse(e)),e=e,this.validateSourceMap(e),this.file=e.file??t,this.names=[...e.names??[]],this.sources=[...e.sources??[]],this.sourceRoot=e.sourceRoot??null,this.sourcesContent=e.sourcesContent?[...e.sourcesContent]:[],this.mappings=new f(e.mappings)}getMapObject(){let e={version:3,names:this.names,sources:this.sources,mappings:this.mappings.encode(),sourcesContent:this.sourcesContent};return this.file&&(e.file=this.file),this.sourceRoot&&(e.sourceRoot=this.sourceRoot),e}concat(...e){if(e.length<1)throw new Error("At least one map must be provided for concatenation.");for(let t of e)this.mappings.decode(t.mappings,this.names.length,this.sources.length),this.names.push(...t.names),this.sources.push(...t.sources),this.sourcesContent.push(...t.sourcesContent??[])}concatNewMap(...e){if(e.length<1)throw new Error("At least one map must be provided for concatenation.");let t=new u(this);for(let n of e)t.mappings.decode(n.mappings,t.names.length,t.sources.length),t.names.push(...n.names),t.sources.push(...n.sources),t.sourcesContent.push(...n.sourcesContent??[]);return t}getPositionByOriginal(e,t,n,i=0){let r=n;if(typeof n=="string"&&(r=this.sources.findIndex(a=>a.includes(n))),r<0)return null;let o=this.mappings.getOriginalSegment(e,t,r,i);return o?{name:this.names[o.nameIndex??-1]??null,line:o.line,column:o.column,source:this.sources[o.sourceIndex],sourceRoot:this.sourceRoot,sourceIndex:o.sourceIndex,generatedLine:o.generatedLine,generatedColumn:o.generatedColumn}:null}getPosition(e,t,n=0){let i=this.mappings.getSegment(e,t,n);return i?{name:this.names[i.nameIndex??-1]??null,line:i.line,column:i.column,source:this.sources[i.sourceIndex],sourceRoot:this.sourceRoot,sourceIndex:i.sourceIndex,generatedLine:i.generatedLine,generatedColumn:i.generatedColumn}:null}getPositionWithContent(e,t,n=0){let i=this.getPosition(e,t,n);return i?{...i,sourcesContent:this.sourcesContent[i.sourceIndex]}:null}getPositionWithCode(e,t,n=0,i){let r=this.getPosition(e,t,n);if(!r||!this.sourcesContent[r.sourceIndex])return null;let o=Object.assign({linesAfter:4,linesBefore:3},i),a=this.sourcesContent[r.sourceIndex].split(`
6
+ `),c=Math.min((r.line??1)+o.linesAfter,a.length),l=Math.max((r.line??1)-o.linesBefore,0),d=a.slice(l,Math.min(c+1,a.length)).join(`
7
7
  `);return{...r,code:d,endLine:c,startLine:l}}toString(){return JSON.stringify(this.getMapObject())}validateSourceMap(e){if(!["sources","mappings","names"].every(n=>n in e))throw new Error("Missing required keys in SourceMap.")}};export{S as CodeHighlighter,O as Colors,v as SourceService,b as decodeVLQ,C as encodeArrayVLQ,T as encodeVLQ,K as formatCode,F as formatErrorCode,D as highlightCode,$ as parseErrorStack};
8
+ //# sourceMappingURL=index.js.map
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/components/parser.component.ts", "../../src/components/base64.component.ts", "../../src/components/formatter.component.ts", "../../src/components/highlighter.component.ts", "../../src/providers/mapping.provider.ts", "../../src/services/source.service.ts"],
4
- "sourceRoot": "https://github.com/remotex-lab/xmap/tree/2.0.2/",
5
- "sourcesContent": ["/**\n * Import will remove at compile time\n */\n\nimport type { StackEntryInterface } from '@components/interfaces/parse.interface';\n\n/**\n * Parses an error stack trace and returns an object with a message and an array of stack entries.\n *\n * @param stackString - The error stack trace.\n * @returns The parsed stack trace object.\n */\n\nexport function parseErrorStack(stackString: string): Array<StackEntryInterface> {\n const lines = stackString.split('\\n').slice(1);\n const regex = /^\\s*at\\s+(.*?)\\s+\\((.*?):(\\d+):(\\d+)\\)$|^\\s*at\\s+(.*?):(\\d+):(\\d+)$/;\n const evalRegex = /eval\\s+at\\s+([^\\s(]+).+\\((.+):(\\d+):(\\d+)\\),\\s(.+)/;\n const stack: Array<StackEntryInterface> = [];\n\n lines.forEach((line) => {\n const match = line.match(regex);\n if (!match) return;\n\n let args: Array<string> = match.slice(1);\n if(!match[2]) {\n args = match.slice(4);\n }\n\n const [ at, file, lineNum, colNum ] = args;\n const lineNumber = parseInt(lineNum, 10);\n const columnNumber = parseInt(colNum, 10);\n\n if (line.includes('eval')) {\n const evalMatch = file.match(evalRegex)?.slice(1);\n if (evalMatch) {\n const [ evalAt, evalFile, evalLineNum, evalColNum, evalAnonFile ] = evalMatch;\n stack.push({\n at,\n file: evalAnonFile,\n line: lineNumber,\n column: columnNumber,\n executor: {\n at: evalAt,\n file: evalFile,\n line: parseInt(evalLineNum, 10),\n column: parseInt(evalColNum, 10)\n }\n });\n\n return;\n }\n }\n\n stack.push({\n at: at || '<anonymous>',\n file,\n line: lineNumber,\n column: columnNumber,\n executor: null\n });\n });\n\n return stack;\n}\n", "// Bitmask to extract the lower 5 bits (continuation bit removed) - 0b11111\nconst CONTINUATION_BIT_REMOVE = 0x1F;\n\n// Bitmask to set the continuation bit - 0b100000\nconst CONTINUATION_BIT_POSITION = 0x20;\n\n// Mapping of Base64 characters to their indices\nconst base64Map: { [key: string]: number } = {};\n\n// Array of Base64 characters\nconst base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');\n\n// Populate the base64Map with characters and their corresponding indices\nbase64Chars.forEach((char, index) => {\n base64Map[char] = index;\n});\n\n/**\n * Encodes a given number using Variable-Length Quantity (VLQ) encoding.\n * Negative numbers are encoded by converting to a non-negative representation.\n * The continuation bit is used to indicate if more bytes follow.\n *\n * @param value - The number to be encoded.\n * @returns The VLQ encoded string.\n */\n\nexport function encodeVLQ(value: number): string {\n const isNegative = value < 0;\n\n /**\n * Bit Structure Representation:\n *\n * +--------------------------+\n * | C | Value | Sign |\n * +---+---+---+---+---+------+\n * | 1 | 1 | 0 | 0 | 1 | 0 |\n * +---+---+---+---+---+------+\n */\n\n let encoded = '';\n let vlq = isNegative ? ((-value) << 1) + 1 : (value << 1); // Shift left by 1 bit to encode the sign bit\n\n do {\n const digit = vlq & CONTINUATION_BIT_REMOVE; // Extract lower 5 bits\n vlq >>>= 5; // Right shift by 5 bits to process next chunk\n encoded += base64Chars[digit | (vlq > 0 ? CONTINUATION_BIT_POSITION : 0)]; // Combine digit and continuation bit\n } while (vlq > 0);\n\n return encoded;\n}\n\n/**\n * Encodes an array of numbers using VLQ encoding.\n * Each number in the array is individually encoded and the results are concatenated.\n *\n * @param values - The array of numbers to be encoded.\n * @returns The concatenated VLQ encoded string.\n */\n\nexport function encodeArrayVLQ(values: number[]): string {\n return values.map(encodeVLQ).join('');\n}\n\n/**\n * Decodes a VLQ encoded string back into an array of numbers.\n * Each character is decoded using the Base64 map and continuation bits are processed.\n *\n * @param data - The VLQ encoded string.\n * @returns The array of decoded numbers.\n * @throws Error If the string contains invalid Base64 characters.\n */\n\nexport function decodeVLQ(data: string): number[] {\n const result = [];\n let shift = 0;\n let value = 0;\n\n for (let i = 0; i < data.length; i++) {\n const digit = base64Map[data[i]];\n if (digit === undefined) {\n throw new Error(`Invalid Base64 character: ${data[i]}`);\n }\n\n const continuation = digit & CONTINUATION_BIT_POSITION; // Check if continuation bit is set\n value += (digit & CONTINUATION_BIT_REMOVE) << shift; // Add lower 5 bits to value\n if (continuation) {\n shift += 5; // Shift left by 5 for next chunk\n } else {\n const isNegative = (value & 1) === 1; // Check if the number is negative\n const shifted = value >> 1; // Remove the sign bit\n\n result.push(isNegative ? -shifted : shifted); // Convert back to signed integer\n value = shift = 0; // Reset for next number\n }\n }\n\n return result;\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { PositionWithCodeInterface } from '@services/interfaces/source.interface';\nimport type { AnsiOptionInterface, FormatCodeInterface } from '@components/interfaces/formatter.interface';\n\n/**\n * Formats a code snippet with optional line padding and custom actions.\n *\n * This function takes a code string and an options object to format the code snippet.\n * It applies padding to line numbers and can trigger custom actions for specific lines.\n *\n * @param code - The source code | stack to be formatted.\n * @param options - Configuration options for formatting the code.\n * - `padding` (number, optional): Number of characters for line number padding. Defaults to 10.\n * - `startLine` (number, optional): The starting line number for formatting. Defaults to 1.\n * - `action` (object, optional): Custom actions to apply to specific lines.\n * - `triggerLine` (number): The line number where the action should be triggered.\n * - `callback` (function): A callback function to format the line string when `triggerLine` is matched.\n * The callback receives the formatted line string, the padding value, and the current line number as arguments.\n *\n * @returns A formatted string of the code snippet with applied padding and custom actions.\n *\n * @example\n * ```typescript\n * const formattedCode = formatCode(code, {\n * padding: 8,\n * startLine: 5,\n * action: {\n * triggerLine: 7,\n * callback: (lineString, padding, lineNumber) => {\n * return `Custom formatting for line ${lineNumber}: ${lineString}`;\n * }\n * }\n * });\n * console.log(formattedCode);\n * ```\n */\n\nexport function formatCode(code: string, options: FormatCodeInterface = {}): string {\n const lines = code.split('\\n');\n const padding = options.padding ?? 10;\n const startLine = options.startLine ?? 0;\n\n return lines.map((lineContent, index) => {\n const currentLineNumber = index + startLine + 1;\n const prefix = `${ currentLineNumber} | `;\n const string = `${ prefix.padStart(padding) }${ lineContent }`;\n\n if (options.action && currentLineNumber === options.action.triggerLine) {\n return options.action.callback(string, padding, currentLineNumber);\n }\n\n return string;\n }).join('\\n');\n}\n\n/**\n * Formats a code snippet around an error location with special highlighting.\n *\n * This function takes a `sourcePosition` object containing information about the source code\n * and error location, then uses `formatCode` to format and highlight the relevant code snippet.\n *\n * @param sourcePosition - An object containing information about the source code and error location.\n * - `code` (string): The entire source code content.\n * - `line` (number): The line number where the error occurred (1-based indexing).\n * - `column` (number): The column number within the line where the error occurred (1-based indexing).\n * - `startLine` (number, optional): The starting line number of the code snippet (defaults to 1).\n * @param ansiOption - Optional configuration for ANSI color codes.\n * - `color` (string): The ANSI escape sequence to colorize the error marker and prefix (e.g., `'\\x1b[38;5;160m'`).\n * - `reset` (string): The ANSI escape sequence to reset the color (e.g., `'\\x1b[0m'`).\n *\n * @throws Error - If the provided `sourcePosition` object has invalid line or column numbers,\n * or if the error line is outside the boundaries of the provided code content.\n *\n * @returns A formatted string representing the relevant code snippet around the error location,\n * including special highlighting for the error line and column.\n *\n * @example\n * ```typescript\n * const formattedErrorCode = formatErrorCode(sourcePosition);\n * console.log(formattedErrorCode);\n * ```\n */\n\nexport function formatErrorCode(sourcePosition: PositionWithCodeInterface, ansiOption?: AnsiOptionInterface): string {\n const { code, line: errorLine, column: errorColumn, startLine } = sourcePosition;\n\n // Validate line and column numbers\n if (errorLine < startLine || errorColumn < 1) {\n throw new Error('Invalid line or column number.');\n }\n\n return formatCode(code, {\n startLine,\n action: {\n triggerLine: errorLine,\n callback: (lineString, padding, line) => {\n let pointer = '^';\n let ansiPadding = padding - 1; // 1 size of the char we added\n let prefixPointer = '>';\n\n if (ansiOption) {\n pointer = `${ ansiOption.color }${ pointer }${ ansiOption.reset }`;\n ansiPadding += (ansiOption.color.length + ansiOption.reset.length);\n prefixPointer = `${ ansiOption.color }>${ ansiOption.reset }`;\n }\n\n const errorMarker = ' | '.padStart(padding) + ' '.repeat(errorColumn - 1) + `${ pointer }`;\n lineString = `${ prefixPointer } ${ line } |`.padStart(ansiPadding) + lineString.split('|')[1];\n\n return lineString + `\\n${ errorMarker }`;\n }\n }\n });\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { HighlightSchemeInterface, HighlightNodeSegmentInterface } from '@components/interfaces/highlighter.interface';\n\n/**\n * Imports\n */\n\nimport * as ts from 'typescript';\nimport { SyntaxKind } from 'typescript';\n\n/**\n * An enum containing ANSI escape sequences for various colors.\n *\n * This enum is primarily intended for terminal output and won't work directly in JavaScript for web development.\n * It defines color codes for various colors and a reset code to return to\n * the default text color.\n *\n * @example\n * ```typescript\n * console.log(`${Colors.red}This the text will be red in the terminal.${Colors.reset}`);\n * ```\n *\n * This functionality is limited to terminal environments.\n * Consider alternative methods\n * for color highlighting in web development contexts, such as CSS classes.\n */\n\nexport const enum Colors {\n reset = '\\x1b[0m',\n gray = '\\x1b[38;5;243m',\n darkGray = '\\x1b[38;5;238m',\n lightCoral = '\\x1b[38;5;203m',\n lightOrange = '\\x1b[38;5;215m',\n oliveGreen = '\\x1b[38;5;149m',\n burntOrange = '\\x1b[38;5;208m',\n lightGoldenrodYellow = '\\x1b[38;5;221m',\n lightYellow = '\\x1b[38;5;230m',\n canaryYellow = '\\x1b[38;5;227m',\n deepOrange = '\\x1b[38;5;166m',\n lightGray = '\\x1b[38;5;252m',\n brightPink = '\\x1b[38;5;197m'\n}\n\n/**\n * Default color scheme for semantic highlighting.\n * This scheme uses red color for all code elements.\n *\n * @example\n * const scheme = defaultScheme;\n * console.log(scheme.typeColor); // Outputs: the red color code\n */\n\n\nconst defaultScheme: HighlightSchemeInterface = {\n enumColor: Colors.burntOrange,\n typeColor: Colors.lightGoldenrodYellow,\n classColor: Colors.lightOrange,\n stringColor: Colors.oliveGreen,\n keywordColor: Colors.lightCoral,\n commentColor: Colors.darkGray,\n functionColor: Colors.lightOrange,\n variableColor: Colors.burntOrange,\n interfaceColor: Colors.lightGoldenrodYellow,\n parameterColor: Colors.deepOrange,\n getAccessorColor: Colors.lightYellow,\n numericLiteralColor: Colors.lightGray,\n methodSignatureColor: Colors.burntOrange,\n regularExpressionColor: Colors.oliveGreen,\n propertyAssignmentColor: Colors.canaryYellow,\n propertyAccessExpressionColor: Colors.lightYellow,\n expressionWithTypeArgumentsColor: Colors.lightOrange\n};\n\n/**\n * Class responsible for applying semantic highlighting to a source code string based on a given color scheme.\n *\n * @class\n *\n * @param sourceFile - The TypeScript AST node representing the source file.\n * @param code - The source code string to be highlighted.\n * @param schema - The color scheme used for highlighting different elements in the code.\n *\n * const highlighter = new CodeHighlighter(sourceFile, code, schema);\n */\n\nexport class CodeHighlighter {\n\n /**\n * A Map of segments where the key is a combination of start and end positions,\n * and the value is an object containing the color and reset code.\n * This structure ensures unique segments and allows for fast lookups and updates.\n *\n * @example\n * this.segments = new Map([\n * ['0-10', { start: 1, end: 11, color: '\\x1b[31m', reset: '\\x1b[0m' }],\n * ['11-20', { start: 12, end: 20, color: '\\x1b[32m', reset: '\\x1b[0m' }]\n * ]);\n */\n\n private segments: Map<string, HighlightNodeSegmentInterface> = new Map();\n\n /**\n * Creates an instance of the CodeHighlighter class.\n *\n * @param sourceFile - The TypeScript AST node representing the source file.\n * @param code - The source code string to be highlighted.\n * @param schema - The color scheme used for highlighting different elements in the code.\n */\n\n constructor(private sourceFile: ts.Node, private code: string, private schema: HighlightSchemeInterface) {\n }\n\n /**\n * Parses a TypeScript AST node and processes its comments to identify segments that need highlighting.\n *\n * @param node - The TypeScript AST node to be parsed.\n */\n\n parseNode(node: ts.Node): void {\n this.processComments(node);\n this.processKeywords(node);\n this.processNode(node);\n }\n\n /**\n * Generates a string with highlighted code segments based on the provided color scheme.\n *\n * This method processes the stored segments, applies the appropriate colors to each segment,\n * and returns the resulting highlighted code as a single string.\n *\n * @returns The highlighted code as a string, with ANSI color codes applied to the segments.\n */\n\n highlight(): string {\n let previousSegmentEnd = 0;\n let parent: HighlightNodeSegmentInterface | undefined;\n\n const result: Array<string> = [];\n const segments = Array.from(\n this.segments.values()\n ).sort((a, b) => a.start - b.start || a.end - b.end);\n\n segments.forEach((segment) => {\n if (parent && segment.start < parent.end) {\n const lastSegment = result.pop();\n if (!lastSegment) return;\n\n const source = this.getSegmentSource(segment.start, segment.end);\n const combinedSource = `${ segment.color }${ source }${ parent.color }`;\n result.push(lastSegment.replace(source, combinedSource));\n\n return;\n }\n\n result.push(this.getSegmentSource(previousSegmentEnd, segment.start));\n result.push(`${ segment.color }${ this.getSegmentSource(segment.start, segment.end) }${ segment.reset }`);\n previousSegmentEnd = segment.end;\n parent = segment;\n });\n\n return result.join('') + this.getSegmentSource(previousSegmentEnd);\n }\n\n /**\n * Extracts a substring from the code based on the specified start and end positions.\n *\n * This method is used to retrieve the source code segment that corresponds to the\n * given start and end positions. It is primarily used for highlighting specific\n * segments of the code.\n *\n * @param start - The starting index of the segment to be extracted.\n * @param end - The ending index of the segment to be extracted.\n * @returns The extracted substring from the code.\n */\n\n private getSegmentSource(start: number, end?: number): string {\n return this.code.slice(start, end);\n }\n\n /**\n * Adds a new segment to the list of segments to be highlighted.\n * The segment is defined by its start and end positions, the color to apply, and an optional reset code.\n *\n * @param start - The starting index of the segment in the code string.\n * @param end - The ending index of the segment in the code string.\n * @param color - The color code to apply to the segment.\n * @param reset - The color reset code to apply after the segment, Defaults to the reset code defined in `Colors.reset`.\n */\n\n private addSegment(start: number, end: number, color: string, reset: string = Colors.reset) {\n const key = `${ start }-${ end }`;\n this.segments.set(key, { start, end, color, reset });\n }\n\n /**\n * Processes comments within a TypeScript AST node and adds segments for highlighting.\n * Extracts trailing and leading comments from the node and adds them as segments using the color defined in `this.colorSchema.comments`.\n *\n * @param node - The TypeScript AST node whose comments are to be processed.\n */\n\n private processComments(node: ts.Node): void {\n const comments = [\n ...ts.getTrailingCommentRanges(this.sourceFile.getFullText(), node.getFullStart()) || [],\n ...ts.getLeadingCommentRanges(this.sourceFile.getFullText(), node.getFullStart()) || []\n ];\n\n comments.forEach(comment => this.addSegment(comment.pos, comment.end, this.schema.commentColor));\n }\n\n /**\n * Processes the keywords within a TypeScript AST node and adds them as segments for highlighting.\n *\n * This method identifies potential keyword tokens within the provided node and adds them to the\n * list of segments with the color defined in `this.schema.keywordColor`.\n * The method considers the current node, its first token, and its last token to determine if they should be highlighted\n * as keywords.\n *\n * The method checks if the node's kind falls within the range of keyword kinds defined by TypeScript.\n * If the node or any of its tokens are identified as keywords, a segment is added to `this.segments`\n * with the start and end positions of the node and the specified color for keywords.\n *\n * @param node - The TypeScript AST node to be processed for keywords.\n */\n\n private processKeywords(node: ts.Node): void {\n if ([\n SyntaxKind.NullKeyword,\n SyntaxKind.VoidKeyword,\n SyntaxKind.StringKeyword,\n SyntaxKind.NumberKeyword,\n SyntaxKind.BooleanKeyword,\n SyntaxKind.UndefinedKeyword\n ].includes(node.kind)) {\n return this.addSegment(node.getStart(), node.getEnd(), this.schema.typeColor);\n }\n\n if (node && node.kind >= ts.SyntaxKind.FirstKeyword && node.kind <= ts.SyntaxKind.LastKeyword) {\n this.addSegment(node.getStart(), node.getEnd(), this.schema.keywordColor);\n }\n }\n\n /**\n * Processes identifiers within a TypeScript AST node and adds them as segments for highlighting\n * based on the node's parent type.\n *\n * This method determines the appropriate color for an identifier based on its parent node's kind.\n * If the parent node matches one of the specified kinds, the identifier is highlighted with a cyan color.\n * Supported parent kinds include various declarations, expressions, and signatures.\n *\n * @param node - The TypeScript AST node representing the identifier to be processed.\n */\n\n private processIdentifier(node: ts.Node): void {\n const end = node.getEnd();\n const start = node.getStart();\n\n switch (node.parent.kind) {\n case ts.SyntaxKind.EnumMember:\n return this.addSegment(start, end, this.schema.enumColor);\n case ts.SyntaxKind.CallExpression:\n case ts.SyntaxKind.EnumDeclaration:\n case ts.SyntaxKind.PropertySignature:\n case ts.SyntaxKind.ModuleDeclaration:\n return this.addSegment(start, end, this.schema.variableColor);\n case ts.SyntaxKind.InterfaceDeclaration:\n return this.addSegment(start, end, this.schema.interfaceColor);\n case ts.SyntaxKind.GetAccessor:\n return this.addSegment(start, end, this.schema.getAccessorColor);\n case ts.SyntaxKind.PropertyAssignment:\n return this.addSegment(start, end, this.schema.propertyAssignmentColor);\n case ts.SyntaxKind.MethodSignature:\n return this.addSegment(start, end, this.schema.methodSignatureColor);\n case ts.SyntaxKind.MethodDeclaration:\n case ts.SyntaxKind.FunctionDeclaration:\n return this.addSegment(start, end, this.schema.functionColor);\n case ts.SyntaxKind.ClassDeclaration:\n return this.addSegment(start, end, this.schema.classColor);\n case ts.SyntaxKind.Parameter:\n return this.addSegment(start, end, this.schema.parameterColor);\n case ts.SyntaxKind.VariableDeclaration:\n return this.addSegment(start, end, this.schema.variableColor);\n case ts.SyntaxKind.PropertyDeclaration:\n return this.addSegment(start, end, this.schema.variableColor);\n case ts.SyntaxKind.PropertyAccessExpression: {\n if (node.parent.getChildAt(0).getText() === node.getText()) {\n return this.addSegment(start, end, this.schema.variableColor);\n }\n\n return this.addSegment(start, end, this.schema.propertyAccessExpressionColor);\n }\n case ts.SyntaxKind.ExpressionWithTypeArguments:\n return this.addSegment(start, end, this.schema.expressionWithTypeArgumentsColor);\n case ts.SyntaxKind.BreakStatement:\n case ts.SyntaxKind.ShorthandPropertyAssignment:\n case ts.SyntaxKind.BindingElement:\n return this.addSegment(start, end, this.schema.variableColor);\n case ts.SyntaxKind.BinaryExpression:\n case ts.SyntaxKind.SwitchStatement:\n case ts.SyntaxKind.TemplateSpan:\n return this.addSegment(start, end, this.schema.variableColor);\n case ts.SyntaxKind.TypeReference:\n case ts.SyntaxKind.TypeAliasDeclaration:\n return this.addSegment(start, end, this.schema.typeColor);\n case ts.SyntaxKind.NewExpression:\n return this.addSegment(start, end, this.schema.variableColor);\n }\n }\n\n /**\n * Processes a TypeScript template expression and adds segments for highlighting its literal parts.\n *\n * This method adds a segment for the head of the template expression with the color specified in `this.schema.stringColor`.\n * It also processes each template span within the expression, adding\n * segments for each span's literal part.\n *\n * @param templateExpression - The TypeScript template expression to be processed.\n */\n\n private processTemplateExpression(templateExpression: ts.TemplateExpression): void {\n const start = templateExpression.head.getStart();\n const end = templateExpression.head.getEnd();\n this.addSegment(start, end, this.schema.stringColor);\n\n templateExpression.templateSpans.forEach(span => {\n const spanStart = span.literal.getStart();\n const spanEnd = span.literal.getEnd();\n this.addSegment(spanStart, spanEnd, this.schema.stringColor);\n });\n }\n\n /**\n * Processes a TypeScript AST node and adds segments for highlighting based on the node's kind.\n *\n * This method identifies the kind of the node and determines the appropriate color for highlighting.\n * It handles various node kinds including string literals, regular expressions, template expressions, and identifiers.\n * Specific methods are invoked for more complex node kinds, such as template expressions and identifiers.\n *\n * @param node - The TypeScript AST node to be processed.\n */\n\n private processNode(node: ts.Node): void {\n const start = node.getStart();\n const end = node.getEnd();\n\n switch (node.kind) {\n case ts.SyntaxKind.TypeParameter:\n return this.addSegment(start, start + (node as ts.TypeParameterDeclaration).name.text.length, this.schema.typeColor);\n case ts.SyntaxKind.TypeReference:\n return this.addSegment(start, end, this.schema.typeColor);\n case ts.SyntaxKind.StringLiteral:\n case ts.SyntaxKind.NoSubstitutionTemplateLiteral:\n return this.addSegment(start, end, this.schema.stringColor);\n case ts.SyntaxKind.RegularExpressionLiteral:\n return this.addSegment(start, end, this.schema.regularExpressionColor);\n case ts.SyntaxKind.TemplateExpression:\n return this.processTemplateExpression(node as ts.TemplateExpression);\n case ts.SyntaxKind.Identifier:\n return this.processIdentifier(node);\n case ts.SyntaxKind.BigIntLiteral:\n case ts.SyntaxKind.NumericLiteral:\n return this.addSegment(start, end, this.schema.numericLiteralColor);\n }\n }\n}\n\n/**\n * Applies semantic highlighting to the provided code string using the specified color scheme.\n *\n * @param code - The source code to be highlighted.\n * @param schema - An optional partial schema defining the color styles for various code elements.\n * Defaults to an empty object, which means no specific highlighting will be applied.\n *\n * @returns A string with the code elements wrapped in the appropriate color styles as specified by the schema.\n *\n * @example\n * const code = 'const x: number = 42;';\n * const schema = {\n * keywordColor: '\\x1b[34m', // Blue\n * stringColor: '\\x1b[32m', // Green\n * numberColor: '\\x1b[31m', // Red\n * reset: '\\x1b[0m' // Reset\n * };\n * const highlightedCode = highlightCode(code, schema);\n * console.log(highlightedCode);\n */\n\nexport function highlightCode(code: string, schema: Partial<HighlightSchemeInterface> = {}) {\n const sourceFile = ts.createSourceFile('temp.ts', code, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);\n const codeHighlighter = new CodeHighlighter(sourceFile, code, Object.assign(defaultScheme, schema));\n\n function walk(node: ts.Node): void {\n codeHighlighter.parseNode(node);\n\n for (let i = 0; i < node.getChildCount(); i++) {\n walk(node.getChildAt(i));\n }\n } ts.forEachChild(sourceFile, walk);\n\n return codeHighlighter.highlight();\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport {\n Bias,\n type MapType,\n type FrameType,\n type SegmentInterface,\n type SegmentOffsetInterface\n} from './interfaces/mapping.interface';\n\n/**\n * Imports\n */\n\nimport { decodeVLQ, encodeArrayVLQ } from '@components/base64.component';\n\n/**\n * The `MappingProvider` class provides methods to encode and decode mappings\n * from a source map or mapping string to an internal structured representation.\n */\n\nexport class MappingProvider {\n /**\n * The internal mapping representation, where each index represents a frame of segments.\n */\n\n private mapping: MapType = [];\n\n /**\n * Constructor to initialize the `MappingProvider` with a mapping.\n * Can be initialized with either a mapping string or a structured mapping array.\n *\n * @param mapping - The mapping data, either as a string or structured array.\n * @param namesOffset - Optional offset for the names index.\n * @param sourceOffset - Optional offset for the sources index.\n *\n * @example\n * ```ts\n * const provider = new MappingProvider(\";;;AAiBO,SAAS,OAAO;AACnB,UAAQ,IAAI,MAAM;AACtB;;;ACjBA,QAAQ,IAAI,GAAG;AACf,KAAK;\", 0, 0);\n * const provider2 = new MappingProvider([\n * null,\n * [\n * {\n * line: 1,\n * column: 1,\n * nameIndex: null,\n * sourceIndex: 0,\n * generatedLine: 2,\n * generatedColumn: 1\n * }\n * ],\n * null\n * ], 0, 0);\n * ```\n */\n\n constructor(mapping: string, namesOffset?: number, sourceOffset?: number);\n constructor(mapping: MapType, namesOffset?: number, sourceOffset?: number);\n constructor(mapping: MappingProvider, namesOffset?: number, sourceOffset?: number);\n constructor(mapping: MappingProvider| MapType | string, namesOffset = 0, sourcesOffset = 0) {\n mapping = mapping instanceof MappingProvider ? mapping.mapping : mapping;\n if (Array.isArray(mapping)) {\n this.decodeMappingArray(mapping, namesOffset, sourcesOffset);\n } else {\n this.decodeMappingString(mapping, namesOffset, sourcesOffset);\n }\n }\n\n /**\n * Encodes the internal mapping array back into a mapping string.\n *\n * @returns {string} - The encoded mapping string.\n * @example\n * ```ts\n * const encoded = provider.encode();\n * console.log(encoded); // Outputs encoded mapping string\n * ```\n */\n\n encode(): string {\n return this.encodeMappings(this.mapping);\n }\n\n /**\n * Decodes a mapping from either a string or structured array into the internal mapping.\n *\n * @param mapping - The mapping data to decode.\n * @param namesOffset - Offset for the names index.\n * @param sourcesOffset - Offset for the sources index.\n * @example\n * ```ts\n * provider.decode(\";;;AAiBO,SAAS,OAAO;AACnB,UAAQ,IAAI,MAAM;AACtB;;;ACjBA,QAAQ,IAAI,GAAG;AACf,KAAK;\", 0, 0);\n * provider.decode([\n * null,\n * [\n * {\n * line: 1,\n * column: 1,\n * nameIndex: null,\n * sourceIndex: 0,\n * generatedLine: 2,\n * generatedColumn: 1\n * }\n * ],\n * null\n * ], 0, 0);\n * ```\n */\n\n decode(mapping: MappingProvider| MapType | string, namesOffset = 0, sourcesOffset = 0): void {\n mapping = mapping instanceof MappingProvider ? mapping.mapping : mapping;\n if (Array.isArray(mapping)) {\n this.decodeMappingArray(mapping, namesOffset, sourcesOffset);\n } else {\n this.decodeMappingString(mapping, namesOffset, sourcesOffset);\n }\n }\n\n /**\n * Retrieves a segment based on the provided generated line and column,\n * applying the specified bias when the exact match is not found.\n *\n * This method performs a binary search on the segments of the specified\n * generated line to efficiently locate the segment corresponding to\n * the provided generated column. If an exact match is not found,\n * the method returns the closest segment based on the specified bias:\n * - `Bias.BOUND`: No preference for column matching (returns the closest segment).\n * - `Bias.LOWER_BOUND`: Prefers the closest mapping with a lower column value.\n * - `Bias.UPPER_BOUND`: Prefers the closest mapping with a higher column value.\n *\n * @param generatedLine - The line number of the generated code (1-based index).\n * @param generatedColumn - The column number of the generated code (0-based index).\n * @param bias - The bias to use when the line matches, can be one of:\n * - `Bias.BOUND` (default): No preference for column matching.\n * - `Bias.LOWER_BOUND`: Prefer the closest mapping with a lower column value.\n * - `Bias.UPPER_BOUND`: Prefer the closest mapping with a higher column value.\n * @returns The matching segment if found;\n * returns null if no segments exist for the specified generated line\n * or if the generated line is out of bounds.\n *\n * @throws { Error } - Throws an error if the generated line is invalid\n * (out of bounds).\n *\n * @example\n * ```ts\n * const segment = sourceMap.getSegment(5, 10, Bias.UPPER_BOUND);\n * if (segment) {\n * console.log(`Found segment: line ${segment.line}, column ${segment.column}`);\n * } else {\n * console.log('No matching segment found.');\n * }\n * ```\n */\n\n getSegment(generatedLine: number, generatedColumn: number, bias: Bias = Bias.BOUND): SegmentInterface | null {\n const segments = this.mapping[generatedLine - 1];\n if (!segments || segments.length === 0)\n return null;\n\n let low = 0;\n let high = segments.length - 1;\n let closestSegment: SegmentInterface | null = null;\n while (low <= high) {\n const mid = Math.floor((low + high) / 2);\n const segment = segments[mid];\n\n if (segment.generatedColumn < generatedColumn) {\n low = mid + 1;\n closestSegment = bias === Bias.LOWER_BOUND ? segment : closestSegment;\n } else if (segment.generatedColumn > generatedColumn) {\n high = mid - 1;\n closestSegment = bias === Bias.UPPER_BOUND ? segment : closestSegment;\n } else {\n return segment;\n }\n }\n\n return closestSegment;\n }\n\n /**\n * Retrieves the original segment based on the provided line, column, and source index.\n *\n * This method searches for the original segment that corresponds to the specified\n * line, column, and source index. It uses binary search to find the closest segment\n * based on the provided bias.\n *\n * @param line - The line number of the original code (1-based index).\n * @param column - The column number of the original code (0-based index).\n * @param sourceIndex - The index of the source file in the source map.\n * @param bias - The bias to apply when multiple segments match; defaults to `Bias.BOUND`.\n * @returns {SegmentInterface | null} - The matching original segment if found;\n * returns null if no segments exist for the specified line and source index.\n *\n * @example\n * ```ts\n * const originalSegment = sourceMap.getOriginalSegment(3, 5, 0, Bias.LOWER_BOUND);\n * if (originalSegment) {\n * console.log(`Found original segment: line ${originalSegment.line}, column ${originalSegment.column}`);\n * } else {\n * console.log('No matching original segment found.');\n * }\n * ```\n */\n\n getOriginalSegment(line: number, column: number, sourceIndex: number, bias: Bias = Bias.BOUND): SegmentInterface | null {\n let closestSegment: SegmentInterface | null = null;\n for (const segments of this.mapping) {\n if (!segments)\n continue;\n\n let low = 0;\n let high = segments.length - 1;\n while (low <= high) {\n const mid = Math.floor((low + high) / 2);\n const midSegment = segments[mid];\n\n if (midSegment.sourceIndex < sourceIndex || midSegment.line < line) {\n low = mid + 1;\n } else if (midSegment.sourceIndex > sourceIndex || midSegment.line > line) {\n high = mid - 1;\n } else if (midSegment.column < column) {\n low = mid + 1;\n closestSegment = bias === Bias.LOWER_BOUND ? midSegment : closestSegment;\n } else if (midSegment.column > column) {\n high = mid - 1;\n closestSegment = bias === Bias.UPPER_BOUND ? midSegment : closestSegment;\n } else {\n return midSegment;\n }\n }\n }\n\n return closestSegment;\n }\n\n /**\n * Initializes the segment offsets used to track the current decoding position.\n *\n * @param namesOffset - The offset for the names index.\n * @param sourceIndex - The offset for the source index.\n * @returns { SegmentOffsetInterface } - The initialized segment offset.\n */\n\n private initPositionOffsets(namesOffset: number = 0, sourceIndex: number = 0): SegmentOffsetInterface {\n return {\n line: 0,\n column: 0,\n nameIndex: namesOffset,\n sourceIndex: sourceIndex,\n generatedLine: 0,\n generatedColumn: 0\n };\n }\n\n /**\n * Validates the format of an encoded mapping string.\n *\n * @param encodedSourceMap - The encoded source map string to validate.\n * @returns Returns `true` if the format is valid, otherwise `false`.\n */\n\n private validateMappingString(encodedSourceMap: string): boolean {\n // /^(;+)?([a-z0-9+/]{1,10}(,|;+)?)+$/\n return /^[a-zA-Z0-9+/,;]+$/.test(encodedSourceMap);\n }\n\n /**\n * Validates the properties of a segment to ensure they conform to expected types.\n *\n * This method checks that the segment's properties are finite numbers and that\n * the nameIndex, if provided, is either a finite number or null.\n * An error is thrown if any of the properties do not meet the specified criteria.\n *\n * @param segment - The segment object to validate, which must conform to the\n * SegmentInterface structure, including:\n * - line: number (finite)\n * - column: number (finite)\n * - nameIndex: number | null (if not null, must be finite)\n * - sourceIndex: number (finite)\n * - generatedLine: number (finite)\n * - generatedColumn: number (finite)\n *\n * @throws {Error} - Throws an error if any property of the segment is invalid.\n * The error message will specify which property is invalid\n * and the value that was received.\n */\n\n private validateSegment(segment: SegmentInterface): void {\n if (!Number.isFinite(segment.line)) {\n throw new Error(`Invalid segment: line must be a finite number, received ${segment.line}`);\n }\n if (!Number.isFinite(segment.column)) {\n throw new Error(`Invalid segment: column must be a finite number, received ${segment.column}`);\n }\n if (segment.nameIndex !== null && !Number.isFinite(segment.nameIndex)) {\n throw new Error(`Invalid segment: nameIndex must be a number or null, received ${segment.nameIndex}`);\n }\n if (!Number.isFinite(segment.sourceIndex)) {\n throw new Error(`Invalid segment: sourceIndex must be a finite number, received ${segment.sourceIndex}`);\n }\n if (!Number.isFinite(segment.generatedLine)) {\n throw new Error(`Invalid segment: generatedLine must be a finite number, received ${segment.generatedLine}`);\n }\n if (!Number.isFinite(segment.generatedColumn)) {\n throw new Error(`Invalid segment: generatedColumn must be a finite number, received ${segment.generatedColumn}`);\n }\n }\n\n /**\n * Encodes a segment into a VLQ-encoded string based on the segment offsets.\n *\n * @param segmentOffset - The current segment offset.\n * @param segmentObject - The segment to encode.\n * @returns The encoded segment string.\n */\n\n private encodeSegment(segmentOffset: SegmentOffsetInterface, segmentObject: SegmentInterface): string {\n const { line, column, generatedColumn, nameIndex, sourceIndex } = segmentObject;\n const adjustedLine = line - 1;\n const adjustedColumn = column - 1;\n const adjustedGeneratedColumn = generatedColumn - 1;\n\n const segment: Array<number> = [\n adjustedGeneratedColumn - segmentOffset.generatedColumn, // generatedColumn difference\n sourceIndex !== segmentOffset.sourceIndex ? sourceIndex - segmentOffset.sourceIndex : 0, // sourceIndex difference\n adjustedLine - segmentOffset.line, // line difference\n adjustedColumn - segmentOffset.column // column difference\n ];\n\n if (nameIndex !== null && nameIndex !== undefined) {\n segment[4] = nameIndex - segmentOffset.nameIndex; // nameIndex difference\n segmentOffset.nameIndex = nameIndex;\n }\n\n segmentOffset.line = adjustedLine;\n segmentOffset.column = adjustedColumn;\n segmentOffset.generatedColumn = adjustedGeneratedColumn;\n segmentOffset.sourceIndex = sourceIndex;\n\n return encodeArrayVLQ(segment);\n }\n\n /**\n * Encodes the entire mapping array into a VLQ-encoded mapping string.\n *\n * @param map - The mapping array to encode.\n * @returns The encoded mapping string.\n */\n\n private encodeMappings(map: MapType): string {\n const positionOffset = this.initPositionOffsets();\n\n return map.map(frame => {\n if (!frame)\n return '';\n\n positionOffset.generatedColumn = 0;\n const segments = frame.map(segment => this.encodeSegment(positionOffset, segment));\n\n return segments.join(',');\n }).join(';');\n }\n\n /**\n * Decodes a VLQ-encoded segment into a segment object based on the current offset.\n *\n * @param segmentOffset - The current segment offset.\n * @param decodedSegment - The decoded VLQ segment values.\n * @returns The decoded segment object.\n */\n\n private decodedSegment(segmentOffset: SegmentOffsetInterface, decodedSegment: Array<number>): SegmentInterface {\n const [ generatedColumn, sourceIndex, sourceLine, sourceColumn, nameIndex ] = decodedSegment;\n segmentOffset.line += sourceLine;\n segmentOffset.column += sourceColumn;\n segmentOffset.nameIndex += nameIndex ?? 0;\n segmentOffset.sourceIndex += sourceIndex;\n segmentOffset.generatedColumn += generatedColumn;\n\n return {\n line: segmentOffset.line + 1,\n column: segmentOffset.column + 1,\n nameIndex: nameIndex !== undefined ? segmentOffset.nameIndex : null,\n sourceIndex: segmentOffset.sourceIndex,\n generatedLine: segmentOffset.generatedLine + 1,\n generatedColumn: segmentOffset.generatedColumn + 1\n };\n }\n\n /**\n * Decodes a VLQ-encoded mapping string into the internal mapping representation.\n *\n * @param encodedMap - The VLQ-encoded mapping string.\n * @param namesOffset - Offset for the names index.\n * @param sourceOffset - Offset for the sources index.\n * @throws { Error } - Throws an error if the mapping string is invalid.\n */\n\n private decodeMappingString(encodedMap: string, namesOffset: number, sourceOffset: number): void {\n if (!this.validateMappingString(encodedMap))\n throw new Error('Invalid Mappings string format: the provided string does not conform to expected VLQ format.');\n\n const frames = encodedMap.split(';');\n const linesOffset = this.mapping.length;\n const positionOffset = this.initPositionOffsets(namesOffset, sourceOffset);\n try {\n frames.forEach((frame, index) => {\n if (!frame) {\n this.mapping.push(null);\n\n return;\n }\n\n positionOffset.generatedColumn = 0;\n positionOffset.generatedLine = linesOffset + index;\n const segmentsArray: Array<SegmentInterface> = frame.split(',')\n .map(segment => this.decodedSegment(positionOffset, decodeVLQ(segment)));\n\n this.mapping.push(segmentsArray);\n });\n } catch (error) {\n throw new Error(`Error decoding mappings at frame index ${frames.length}: ${(<Error>error).message}`);\n }\n }\n\n /**\n * Decodes a mapping array into the internal mapping representation, adjusting for offsets.\n *\n * This method processes each frame in the provided structured mapping array,\n * validating each segment within the frame and adjusting the indices based on the\n * specified offsets for names and sources. If a frame is invalid or not an array,\n * an error will be thrown.\n *\n * @param encodedMap - The structured mapping array, which should be an array of frames,\n * where each frame is an array of segments. Each segment must conform\n * to the SegmentInterface.\n * @param namesOffset - Offset for the names index, which will be added to each segment's nameIndex.\n * @param sourceOffset - Offset for the sources index, which will be added to each segment's sourceIndex.\n * @throws { Error } - Throws an error if:\n * - The mapping array is invalid (not an array).\n * - Any frame is not an array.\n * - Any segment does not conform to the SegmentInterface.\n */\n\n private decodeMappingArray(encodedMap: MapType, namesOffset: number, sourceOffset: number): void {\n const linesOffset = this.mapping.length;\n if (!Array.isArray(encodedMap))\n throw new Error('Invalid encoded map: expected an array of frames.');\n\n try {\n encodedMap.forEach((frame, index) => {\n if (!frame) {\n this.mapping.push(frame);\n\n return;\n }\n\n if (!Array.isArray(frame))\n throw new Error(`Invalid Mappings array format at frame index ${index}: expected an array, received ${typeof frame}.`);\n\n const segments: FrameType = frame.map(segment => {\n this.validateSegment(segment);\n\n return {\n ...segment,\n nameIndex: (typeof segment.nameIndex === 'number') ? segment.nameIndex + namesOffset : null,\n sourceIndex: segment.sourceIndex + sourceOffset,\n generatedLine: segment.generatedLine + linesOffset\n };\n });\n\n this.mapping.push(segments);\n });\n } catch (error: unknown) {\n const errorMessage = (error instanceof Error) ? error.message : 'Unknown error';\n throw new Error(`Error decoding mappings: ${errorMessage}`);\n }\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type {\n PositionInterface,\n SourceMapInterface,\n SourceOptionsInterface,\n PositionWithCodeInterface,\n PositionWithContentInterface\n} from '@services/interfaces/source.interface';\n\n/**\n * Imports\n */\n\nimport { MappingProvider } from '@providers/mapping.provider';\nimport { Bias } from '@providers/interfaces/mapping.interface';\n\n/**\n * A service for validating and processing source maps.\n * This class allows parsing and manipulation of source maps, providing functionality such as\n * retrieving position mappings between original and generated code, concatenating source maps,\n * and getting code snippets based on mappings.\n *\n * @example\n * ```ts\n * const sourceMapJSON = '{\"version\": 3, \"file\": \"bundle.js\", \"sources\": [\"foo.ts\"], \"names\": [], \"mappings\": \"AAAA\"}';\n * const sourceService = new SourceService(sourceMapJSON);\n *\n * console.log(sourceService.file); // Outputs: 'bundle.js'\n * ```\n */\n\nexport class SourceService {\n /**\n * The name of the generated file (bundle) that this source map applies to.\n *\n * @example\n * ```ts\n * console.log(sourceService.file); // 'bundle.js'\n * ```\n */\n\n readonly file: string | null;\n\n /**\n * A MappingProvider instance of base64 VLQ-encoded mappings.\n */\n\n readonly mappings: MappingProvider;\n\n /**\n * The root URL for the sources, if present in the source map.\n */\n\n readonly sourceRoot: string | null;\n\n /**\n * A list of symbol names used by the \u201Cmappings\u201D entry.\n */\n\n readonly names: Array<string>;\n\n /**\n * An array of source file paths.\n */\n\n readonly sources: Array<string>;\n\n /**\n * An array of source files contents.\n */\n\n readonly sourcesContent: Array<string>;\n\n /**\n * Creates a new instance of the `SourceService` class.\n *\n * This constructor initializes the class using either a `SourceMapInterface` object,\n * a JSON string representing the source map, or an existing `SourceService` instance.\n * It validates the source map and populates its properties such as `file`, `sources`, and `mappings`.\n *\n * @param source - Can be one of the following:\n * - An object conforming to the `SourceMapInterface`.\n * - A JSON string representing the source map.\n * - A `SourceService` instance to copy the properties.\n * @param file - (Optional) A string representing the file name of the generated bundle.\n * Defaults to `null`. It will overwrite any existing `file` property in the source map.\n * @throws {Error} - If the source map does not contain required properties or has an invalid format.\n *\n * @example\n * ```ts\n * const sourceMapJSON = '{\"version\": 3, \"file\": \"bundle.js\", \"sources\": [\"foo.ts\"], \"names\": [], \"mappings\": \"AAAA\"}';\n * const sourceService = new SourceService(sourceMapJSON);\n * ```\n */\n\n constructor(source: SourceService);\n constructor(source: SourceMapInterface | string, file?: string | null);\n constructor(source: SourceService | SourceMapInterface | string, file: string | null = null) {\n if (typeof source === 'string') {\n source = <SourceMapInterface> JSON.parse(source);\n }\n\n source = <SourceMapInterface> source;\n this.validateSourceMap(source);\n this.file = source.file ?? file;\n this.names = [ ...source.names ?? [] ];\n this.sources = [ ...source.sources ?? [] ];\n this.sourceRoot = source.sourceRoot ?? null;\n this.sourcesContent = source.sourcesContent ? [ ...source.sourcesContent ] : [];;\n this.mappings = new MappingProvider(source.mappings);\n }\n\n /**\n * Converts the current source map data into a plain object format.\n *\n * @returns The source map json object.\n *\n * @example\n * ```ts\n * const mapObject = sourceService.getMapObject();\n * console.log(mapObject.file); // 'bundle.js'\n * ```\n */\n\n getMapObject(): SourceMapInterface {\n const sourceMap: SourceMapInterface = {\n version: 3,\n names: this.names,\n sources: this.sources,\n mappings: this.mappings.encode(),\n sourcesContent: this.sourcesContent\n };\n\n if (this.file)\n sourceMap.file = this.file;\n\n if (this.sourceRoot)\n sourceMap.sourceRoot = this.sourceRoot;\n\n return sourceMap;\n }\n\n /**\n * Concatenates one or more source maps to the current source map.\n *\n * This method merges additional source maps into the current source map,\n * updating the `mappings`, `names`, `sources`, and `sourcesContent` arrays.\n *\n * @param maps - An array of `SourceMapInterface` or `SourceService` instances to be concatenated.\n * @throws { Error } If no source maps are provided for concatenation.\n *\n * @example\n * ```ts\n * sourceService.concat(anotherSourceMap);\n * console.log(sourceService.sources); // Updated source paths\n * ```\n */\n\n concat(...maps: Array<SourceMapInterface | SourceService>): void {\n if (maps.length < 1)\n throw new Error('At least one map must be provided for concatenation.');\n\n for (const map of (maps as Array<SourceMapInterface>)) {\n this.mappings.decode(map.mappings, this.names.length, this.sources.length);\n this.names.push(...map.names);\n this.sources.push(...map.sources);\n this.sourcesContent.push(...map.sourcesContent ?? []);\n }\n }\n\n /**\n * Creates a new instance of `SourceService` with concatenated source maps.\n *\n * @param maps - An array of `SourceMapInterface` or `SourceService` instances to be concatenated.\n * @returns { SourceService } A new `SourceService` instance with the concatenated maps.\n * @throws { Error } If no source maps are provided.\n *\n * @example\n * ```ts\n * const newService = sourceService.concatNewMap(anotherSourceMap);\n * console.log(newService.file); // The file from the new source map\n * ```\n */\n\n concatNewMap(...maps: Array<SourceMapInterface | SourceService>): SourceService {\n if (maps.length < 1)\n throw new Error('At least one map must be provided for concatenation.');\n\n const sourceService = new SourceService(this);\n for (const map of (maps as Array<SourceMapInterface>)) {\n sourceService.mappings.decode(map.mappings, sourceService.names.length, sourceService.sources.length);\n sourceService.names.push(...map.names);\n sourceService.sources.push(...map.sources);\n sourceService.sourcesContent.push(...map.sourcesContent ?? []);\n }\n\n return sourceService;\n }\n\n /**\n * Retrieves the position information based on the original source line and column.\n *\n * @param line - The line number in the generated code.\n * @param column - The column number in the generated code.\n * @param sourceIndex - The index or file path of the original source.\n * @param bias - The bias to use when matching positions (`Bias.LOWER_BOUND`, `Bias.UPPER_BOUND`, or `Bias.BOUND`).\n * @returns { PositionInterface | null } The corresponding position in the original source, or `null` if not found.\n *\n * @example\n * ```ts\n * const position = sourceService.getPositionByOriginal(1, 10, 'foo.ts');\n * console.log(position?.line); // The line number in the original source\n * ```\n */\n\n getPositionByOriginal(line: number, column: number, sourceIndex: number | string, bias: Bias = Bias.BOUND): PositionInterface | null {\n let index = <number> sourceIndex;\n if (typeof sourceIndex === 'string')\n index = this.sources.findIndex(str => str.includes(sourceIndex));\n\n if (index < 0)\n return null;\n\n const segment = this.mappings.getOriginalSegment(line, column, index, bias);\n if (!segment)\n return null;\n\n return {\n name: this.names[segment.nameIndex ?? -1] ?? null,\n line: segment.line,\n column: segment.column,\n source: this.sources[segment.sourceIndex],\n sourceRoot: this.sourceRoot,\n sourceIndex: segment.sourceIndex,\n generatedLine: segment.generatedLine,\n generatedColumn: segment.generatedColumn\n };\n }\n\n /**\n * Retrieves the position in the original source code based on a given line and column\n * in the generated code.\n *\n * @param line - Line number in the generated code.\n * @param column - Column number in the generated code.\n * @param bias - The bias to use for matching positions. Defaults to `Bias.BOUND`.\n * @returns {PositionInterface | null} The position in the original source, or null if not found.\n *\n * @example\n * ```ts\n * const position = sourceService.getPosition(2, 15);\n * console.log(position?.source); // The original source file\n * ```\n */\n\n getPosition(line: number, column: number, bias: Bias = Bias.BOUND): PositionInterface | null {\n const segment = this.mappings.getSegment(line, column, bias);\n if (!segment)\n return null;\n\n return {\n name: this.names[segment.nameIndex ?? -1] ?? null,\n line: segment.line,\n column: segment.column,\n source: this.sources[segment.sourceIndex],\n sourceRoot: this.sourceRoot,\n sourceIndex: segment.sourceIndex,\n generatedLine: segment.generatedLine,\n generatedColumn: segment.generatedColumn\n };\n }\n\n /**\n * Retrieves the position and original source content for a given position in the generated code.\n *\n * @param line - Line number in the generated code.\n * @param column - Column number in the generated code.\n * @param bias - Bias used for position matching.\n * @returns { PositionWithContentInterface | null } The position and its associated content, or `null` if not found.\n *\n * @example\n * ```ts\n * const positionWithContent = sourceService.getPositionWithContent(3, 5);\n * console.log(positionWithContent?.sourcesContent); // The source code content\n * ```\n */\n\n getPositionWithContent(line: number, column: number, bias: Bias = Bias.BOUND): PositionWithContentInterface | null {\n const position = this.getPosition(line, column, bias);\n if (!position)\n return null;\n\n return {\n ...position,\n sourcesContent: this.sourcesContent[position.sourceIndex]\n };\n }\n\n /**\n * Retrieves the position and a code snippet from the original source based on the given\n * generated code position, with additional lines of code around the matching line.\n *\n * @param line - Line number in the generated code.\n * @param column - Column number in the generated code.\n * @param bias - Bias used for position matching.\n * @param options - (Optional) Extra options for the amount of surrounding lines to include.\n * @returns { PositionWithCodeInterface | null } The position and code snippet.\n *\n * @example\n * ```ts\n * const positionWithCode = sourceService.getPositionWithCode(4, 8, Bias.BOUND, { linesBefore: 2, linesAfter: 2 });\n * console.log(positionWithCode?.code); // The code snippet from the original source\n * ```\n */\n\n getPositionWithCode(line: number, column: number, bias: Bias = Bias.BOUND, options?: SourceOptionsInterface): PositionWithCodeInterface | null {\n const position = this.getPosition(line, column, bias);\n if (!position || !this.sourcesContent[position.sourceIndex])\n return null;\n\n const settings = Object.assign({\n linesAfter: 4,\n linesBefore: 3\n }, options);\n\n const code = this.sourcesContent[position.sourceIndex].split('\\n');\n const endLine = Math.min( (position.line ?? 1) + settings.linesAfter, code.length);\n const startLine = Math.max((position.line ?? 1) - settings.linesBefore, 0);\n const relevantCode = code.slice(startLine, Math.min(endLine + 1, code.length)).join('\\n');\n\n return {\n ...position,\n code: relevantCode,\n endLine: endLine,\n startLine: startLine\n };\n }\n\n /**\n * Converts the current source map object to a JSON string.\n *\n * @returns A stringified version of the source map object.\n *\n * @example\n * ```ts\n * console.log(sourceService.toString()); // JSON string of the source map\n * ```\n */\n\n toString(): string {\n return JSON.stringify(this.getMapObject());\n }\n\n /**\n * Validates the provided source map object.\n *\n * This method checks whether all required keys are present in the source map object.\n * It throws an error if any required keys are missing.\n *\n * @private\n * @param input - The source map object to be validated.\n * @throws Error If any required key is missing from the source map.\n *\n * @example\n * ```ts\n * const sourceMap = {\n * version: 3,\n * file: 'example.js',\n * names: ['src', 'maps', 'example', 'function', 'line', 'column'],\n * sources: ['source1.js', 'source2.js'],\n * mappings: 'AAAA,SAASA,CAAC,CAAC,CAAC;AAAA,CAAC,CAAC;AAAC,CAAC',\n * };\n * sourceService['validateSource'](sourceMap); // Throws if invalid\n * ```\n */\n\n private validateSourceMap(input: SourceMapInterface): void {\n const requiredKeys: (keyof SourceMapInterface)[] = [ 'sources', 'mappings', 'names' ];\n if (!requiredKeys.every(key => key in input)) {\n throw new Error('Missing required keys in SourceMap.');\n }\n }\n}\n"],
6
- "mappings": "AAaO,SAASA,EAAgBC,EAAiD,CAC7E,IAAMC,EAAQD,EAAY,MAAM;AAAA,CAAI,EAAE,MAAM,CAAC,EACvCE,EAAQ,sEACRC,EAAY,qDACZC,EAAoC,CAAC,EAE3C,OAAAH,EAAM,QAASI,GAAS,CACpB,IAAMC,EAAQD,EAAK,MAAMH,CAAK,EAC9B,GAAI,CAACI,EAAO,OAEZ,IAAIC,EAAsBD,EAAM,MAAM,CAAC,EACnCA,EAAM,CAAC,IACPC,EAAOD,EAAM,MAAM,CAAC,GAGxB,GAAM,CAAEE,EAAIC,EAAMC,EAASC,CAAO,EAAIJ,EAChCK,EAAa,SAASF,EAAS,EAAE,EACjCG,EAAe,SAASF,EAAQ,EAAE,EAExC,GAAIN,EAAK,SAAS,MAAM,EAAG,CACvB,IAAMS,EAAYL,EAAK,MA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AQE,CAAI,EACpD,GAAI,CAACI,GAAY,CAAC,KAAK,eAAeA,EAAS,WAAW,EACtD,OAAO,KAEX,IAAME,EAAW,OAAO,OAAO,CAC3B,WAAY,EACZ,YAAa,CACjB,EAAGD,CAAO,EAEJE,EAAO,KAAK,eAAeH,EAAS,WAAW,EAAE,MAAM;AAAA,CAAI,EAC3DI,EAAU,KAAK,KAAMJ,EAAS,MAAQ,GAAKE,EAAS,WAAYC,EAAK,MAAM,EAC3EE,EAAY,KAAK,KAAKL,EAAS,MAAQ,GAAKE,EAAS,YAAa,CAAC,EACnEI,EAAeH,EAAK,MAAME,EAAW,KAAK,IAAID,EAAU,EAAGD,EAAK,MAAM,CAAC,EAAE,KAAK;AAAA,CAAI,EAExF,MAAO,CACH,GAAGH,EACH,KAAMM,EACN,QAASF,EACT,UAAWC,CACf,CACJ,CAaA,UAAmB,CACf,OAAO,KAAK,UAAU,KAAK,aAAa,CAAC,CAC7C,CAyBQ,kBAAkBE,EAAiC,CAEvD,GAAI,CAD+C,CAAE,UAAW,WAAY,OAAQ,EAClE,MAAMC,GAAOA,KAAOD,CAAK,EACvC,MAAM,IAAI,MAAM,qCAAqC,CAE7D,CACJ",
4
+ "sourceRoot": "https://github.com/remotex-lab/xmap/tree/2.0.3/",
5
+ "sourcesContent": ["/**\n * Import will remove at compile time\n */\n\nimport type { StackEntryInterface } from '@components/interfaces/parse.interface';\n\n/**\n * Parses an error stack trace and returns an object with a message and an array of stack entries.\n *\n * @param stackString - The error stack trace.\n * @returns The parsed stack trace object.\n */\n\nexport function parseErrorStack(stackString: string): Array<StackEntryInterface> {\n const lines = stackString.split('\\n').slice(1);\n const regex = /^\\s*at\\s+(.*?)\\s+\\((.*?):(\\d+):(\\d+)\\)$|^\\s*at\\s+(.*?):(\\d+):(\\d+)$/;\n const evalRegex = /eval\\s+at\\s+([^\\s(]+).+\\((.+):(\\d+):(\\d+)\\),\\s(.+)/;\n const stack: Array<StackEntryInterface> = [];\n\n lines.forEach((line) => {\n const match = line.match(regex);\n if (!match) return;\n\n let args: Array<string> = match.slice(1);\n if(!match[2]) {\n args = match.slice(4);\n }\n\n const [ at, file, lineNum, colNum ] = args;\n const lineNumber = parseInt(lineNum, 10);\n const columnNumber = parseInt(colNum, 10);\n\n if (line.includes('eval')) {\n const evalMatch = file.match(evalRegex)?.slice(1);\n if (evalMatch) {\n const [ evalAt, evalFile, evalLineNum, evalColNum, evalAnonFile ] = evalMatch;\n stack.push({\n at,\n file: evalAnonFile,\n line: lineNumber,\n column: columnNumber,\n executor: {\n at: evalAt,\n file: evalFile,\n line: parseInt(evalLineNum, 10),\n column: parseInt(evalColNum, 10)\n }\n });\n\n return;\n }\n }\n\n stack.push({\n at: at || '<anonymous>',\n file,\n line: lineNumber,\n column: columnNumber,\n executor: null\n });\n });\n\n return stack;\n}\n", "// Bitmask to extract the lower 5 bits (continuation bit removed) - 0b11111\nconst CONTINUATION_BIT_REMOVE = 0x1F;\n\n// Bitmask to set the continuation bit - 0b100000\nconst CONTINUATION_BIT_POSITION = 0x20;\n\n// Mapping of Base64 characters to their indices\nconst base64Map: { [key: string]: number } = {};\n\n// Array of Base64 characters\nconst base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');\n\n// Populate the base64Map with characters and their corresponding indices\nbase64Chars.forEach((char, index) => {\n base64Map[char] = index;\n});\n\n/**\n * Encodes a given number using Variable-Length Quantity (VLQ) encoding.\n * Negative numbers are encoded by converting to a non-negative representation.\n * The continuation bit is used to indicate if more bytes follow.\n *\n * @param value - The number to be encoded.\n * @returns The VLQ encoded string.\n */\n\nexport function encodeVLQ(value: number): string {\n const isNegative = value < 0;\n\n /**\n * Bit Structure Representation:\n *\n * +--------------------------+\n * | C | Value | Sign |\n * +---+---+---+---+---+------+\n * | 1 | 1 | 0 | 0 | 1 | 0 |\n * +---+---+---+---+---+------+\n */\n\n let encoded = '';\n let vlq = isNegative ? ((-value) << 1) + 1 : (value << 1); // Shift left by 1 bit to encode the sign bit\n\n do {\n const digit = vlq & CONTINUATION_BIT_REMOVE; // Extract lower 5 bits\n vlq >>>= 5; // Right shift by 5 bits to process next chunk\n encoded += base64Chars[digit | (vlq > 0 ? CONTINUATION_BIT_POSITION : 0)]; // Combine digit and continuation bit\n } while (vlq > 0);\n\n return encoded;\n}\n\n/**\n * Encodes an array of numbers using VLQ encoding.\n * Each number in the array is individually encoded and the results are concatenated.\n *\n * @param values - The array of numbers to be encoded.\n * @returns The concatenated VLQ encoded string.\n */\n\nexport function encodeArrayVLQ(values: number[]): string {\n return values.map(encodeVLQ).join('');\n}\n\n/**\n * Decodes a VLQ encoded string back into an array of numbers.\n * Each character is decoded using the Base64 map and continuation bits are processed.\n *\n * @param data - The VLQ encoded string.\n * @returns The array of decoded numbers.\n * @throws Error If the string contains invalid Base64 characters.\n */\n\nexport function decodeVLQ(data: string): number[] {\n const result = [];\n let shift = 0;\n let value = 0;\n\n for (let i = 0; i < data.length; i++) {\n const digit = base64Map[data[i]];\n if (digit === undefined) {\n throw new Error(`Invalid Base64 character: ${data[i]}`);\n }\n\n const continuation = digit & CONTINUATION_BIT_POSITION; // Check if continuation bit is set\n value += (digit & CONTINUATION_BIT_REMOVE) << shift; // Add lower 5 bits to value\n if (continuation) {\n shift += 5; // Shift left by 5 for next chunk\n } else {\n const isNegative = (value & 1) === 1; // Check if the number is negative\n const shifted = value >> 1; // Remove the sign bit\n\n result.push(isNegative ? -shifted : shifted); // Convert back to signed integer\n value = shift = 0; // Reset for next number\n }\n }\n\n return result;\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { PositionWithCodeInterface } from '@services/interfaces/source.interface';\nimport type { AnsiOptionInterface, FormatCodeInterface } from '@components/interfaces/formatter.interface';\n\n/**\n * Formats a code snippet with optional line padding and custom actions.\n *\n * This function takes a code string and an options object to format the code snippet.\n * It applies padding to line numbers and can trigger custom actions for specific lines.\n *\n * @param code - The source code | stack to be formatted.\n * @param options - Configuration options for formatting the code.\n * - `padding` (number, optional): Number of characters for line number padding. Defaults to 10.\n * - `startLine` (number, optional): The starting line number for formatting. Defaults to 1.\n * - `action` (object, optional): Custom actions to apply to specific lines.\n * - `triggerLine` (number): The line number where the action should be triggered.\n * - `callback` (function): A callback function to format the line string when `triggerLine` is matched.\n * The callback receives the formatted line string, the padding value, and the current line number as arguments.\n *\n * @returns A formatted string of the code snippet with applied padding and custom actions.\n *\n * @example\n * ```typescript\n * const formattedCode = formatCode(code, {\n * padding: 8,\n * startLine: 5,\n * action: {\n * triggerLine: 7,\n * callback: (lineString, padding, lineNumber) => {\n * return `Custom formatting for line ${lineNumber}: ${lineString}`;\n * }\n * }\n * });\n * console.log(formattedCode);\n * ```\n */\n\nexport function formatCode(code: string, options: FormatCodeInterface = {}): string {\n const lines = code.split('\\n');\n const padding = options.padding ?? 10;\n const startLine = options.startLine ?? 0;\n\n return lines.map((lineContent, index) => {\n const currentLineNumber = index + startLine + 1;\n const prefix = `${ currentLineNumber} | `;\n const string = `${ prefix.padStart(padding) }${ lineContent }`;\n\n if (options.action && currentLineNumber === options.action.triggerLine) {\n return options.action.callback(string, padding, currentLineNumber);\n }\n\n return string;\n }).join('\\n');\n}\n\n/**\n * Formats a code snippet around an error location with special highlighting.\n *\n * This function takes a `sourcePosition` object containing information about the source code\n * and error location, then uses `formatCode` to format and highlight the relevant code snippet.\n *\n * @param sourcePosition - An object containing information about the source code and error location.\n * - `code` (string): The entire source code content.\n * - `line` (number): The line number where the error occurred (1-based indexing).\n * - `column` (number): The column number within the line where the error occurred (1-based indexing).\n * - `startLine` (number, optional): The starting line number of the code snippet (defaults to 1).\n * @param ansiOption - Optional configuration for ANSI color codes.\n * - `color` (string): The ANSI escape sequence to colorize the error marker and prefix (e.g., `'\\x1b[38;5;160m'`).\n * - `reset` (string): The ANSI escape sequence to reset the color (e.g., `'\\x1b[0m'`).\n *\n * @throws Error - If the provided `sourcePosition` object has invalid line or column numbers,\n * or if the error line is outside the boundaries of the provided code content.\n *\n * @returns A formatted string representing the relevant code snippet around the error location,\n * including special highlighting for the error line and column.\n *\n * @example\n * ```typescript\n * const formattedErrorCode = formatErrorCode(sourcePosition);\n * console.log(formattedErrorCode);\n * ```\n */\n\nexport function formatErrorCode(sourcePosition: PositionWithCodeInterface, ansiOption?: AnsiOptionInterface): string {\n const { code, line: errorLine, column: errorColumn, startLine } = sourcePosition;\n\n // Validate line and column numbers\n if (errorLine < startLine || errorColumn < 1) {\n throw new Error('Invalid line or column number.');\n }\n\n return formatCode(code, {\n startLine,\n action: {\n triggerLine: errorLine,\n callback: (lineString, padding, line) => {\n let pointer = '^';\n let ansiPadding = padding - 1; // 1 size of the char we added\n let prefixPointer = '>';\n\n if (ansiOption) {\n pointer = `${ ansiOption.color }${ pointer }${ ansiOption.reset }`;\n ansiPadding += (ansiOption.color.length + ansiOption.reset.length);\n prefixPointer = `${ ansiOption.color }>${ ansiOption.reset }`;\n }\n\n const errorMarker = ' | '.padStart(padding) + ' '.repeat(errorColumn - 1) + `${ pointer }`;\n lineString = `${ prefixPointer } ${ line } |`.padStart(ansiPadding) + lineString.split('|')[1];\n\n return lineString + `\\n${ errorMarker }`;\n }\n }\n });\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { HighlightSchemeInterface, HighlightNodeSegmentInterface } from '@components/interfaces/highlighter.interface';\n\n/**\n * Imports\n */\n\nimport * as ts from 'typescript';\nimport { SyntaxKind } from 'typescript';\n\n/**\n * An enum containing ANSI escape sequences for various colors.\n *\n * This enum is primarily intended for terminal output and won't work directly in JavaScript for web development.\n * It defines color codes for various colors and a reset code to return to\n * the default text color.\n *\n * @example\n * ```typescript\n * console.log(`${Colors.red}This the text will be red in the terminal.${Colors.reset}`);\n * ```\n *\n * This functionality is limited to terminal environments.\n * Consider alternative methods\n * for color highlighting in web development contexts, such as CSS classes.\n */\n\nexport const enum Colors {\n reset = '\\x1b[0m',\n gray = '\\x1b[38;5;243m',\n darkGray = '\\x1b[38;5;238m',\n lightCoral = '\\x1b[38;5;203m',\n lightOrange = '\\x1b[38;5;215m',\n oliveGreen = '\\x1b[38;5;149m',\n burntOrange = '\\x1b[38;5;208m',\n lightGoldenrodYellow = '\\x1b[38;5;221m',\n lightYellow = '\\x1b[38;5;230m',\n canaryYellow = '\\x1b[38;5;227m',\n deepOrange = '\\x1b[38;5;166m',\n lightGray = '\\x1b[38;5;252m',\n brightPink = '\\x1b[38;5;197m'\n}\n\n/**\n * Default color scheme for semantic highlighting.\n * This scheme uses red color for all code elements.\n *\n * @example\n * const scheme = defaultScheme;\n * console.log(scheme.typeColor); // Outputs: the red color code\n */\n\n\nconst defaultScheme: HighlightSchemeInterface = {\n enumColor: Colors.burntOrange,\n typeColor: Colors.lightGoldenrodYellow,\n classColor: Colors.lightOrange,\n stringColor: Colors.oliveGreen,\n keywordColor: Colors.lightCoral,\n commentColor: Colors.darkGray,\n functionColor: Colors.lightOrange,\n variableColor: Colors.burntOrange,\n interfaceColor: Colors.lightGoldenrodYellow,\n parameterColor: Colors.deepOrange,\n getAccessorColor: Colors.lightYellow,\n numericLiteralColor: Colors.lightGray,\n methodSignatureColor: Colors.burntOrange,\n regularExpressionColor: Colors.oliveGreen,\n propertyAssignmentColor: Colors.canaryYellow,\n propertyAccessExpressionColor: Colors.lightYellow,\n expressionWithTypeArgumentsColor: Colors.lightOrange\n};\n\n/**\n * Class responsible for applying semantic highlighting to a source code string based on a given color scheme.\n *\n * @class\n *\n * @param sourceFile - The TypeScript AST node representing the source file.\n * @param code - The source code string to be highlighted.\n * @param schema - The color scheme used for highlighting different elements in the code.\n *\n * const highlighter = new CodeHighlighter(sourceFile, code, schema);\n */\n\nexport class CodeHighlighter {\n\n /**\n * A Map of segments where the key is a combination of start and end positions,\n * and the value is an object containing the color and reset code.\n * This structure ensures unique segments and allows for fast lookups and updates.\n *\n * @example\n * this.segments = new Map([\n * ['0-10', { start: 1, end: 11, color: '\\x1b[31m', reset: '\\x1b[0m' }],\n * ['11-20', { start: 12, end: 20, color: '\\x1b[32m', reset: '\\x1b[0m' }]\n * ]);\n */\n\n private segments: Map<string, HighlightNodeSegmentInterface> = new Map();\n\n /**\n * Creates an instance of the CodeHighlighter class.\n *\n * @param sourceFile - The TypeScript AST node representing the source file.\n * @param code - The source code string to be highlighted.\n * @param schema - The color scheme used for highlighting different elements in the code.\n */\n\n constructor(private sourceFile: ts.Node, private code: string, private schema: HighlightSchemeInterface) {\n }\n\n /**\n * Parses a TypeScript AST node and processes its comments to identify segments that need highlighting.\n *\n * @param node - The TypeScript AST node to be parsed.\n */\n\n parseNode(node: ts.Node): void {\n this.processComments(node);\n this.processKeywords(node);\n this.processNode(node);\n }\n\n /**\n * Generates a string with highlighted code segments based on the provided color scheme.\n *\n * This method processes the stored segments, applies the appropriate colors to each segment,\n * and returns the resulting highlighted code as a single string.\n *\n * @returns The highlighted code as a string, with ANSI color codes applied to the segments.\n */\n\n highlight(): string {\n let previousSegmentEnd = 0;\n let parent: HighlightNodeSegmentInterface | undefined;\n\n const result: Array<string> = [];\n const segments = Array.from(\n this.segments.values()\n ).sort((a, b) => a.start - b.start || a.end - b.end);\n\n segments.forEach((segment) => {\n if (parent && segment.start < parent.end) {\n const lastSegment = result.pop();\n if (!lastSegment) return;\n\n const source = this.getSegmentSource(segment.start, segment.end);\n const combinedSource = `${ segment.color }${ source }${ parent.color }`;\n result.push(lastSegment.replace(source, combinedSource));\n\n return;\n }\n\n result.push(this.getSegmentSource(previousSegmentEnd, segment.start));\n result.push(`${ segment.color }${ this.getSegmentSource(segment.start, segment.end) }${ segment.reset }`);\n previousSegmentEnd = segment.end;\n parent = segment;\n });\n\n return result.join('') + this.getSegmentSource(previousSegmentEnd);\n }\n\n /**\n * Extracts a substring from the code based on the specified start and end positions.\n *\n * This method is used to retrieve the source code segment that corresponds to the\n * given start and end positions. It is primarily used for highlighting specific\n * segments of the code.\n *\n * @param start - The starting index of the segment to be extracted.\n * @param end - The ending index of the segment to be extracted.\n * @returns The extracted substring from the code.\n */\n\n private getSegmentSource(start: number, end?: number): string {\n return this.code.slice(start, end);\n }\n\n /**\n * Adds a new segment to the list of segments to be highlighted.\n * The segment is defined by its start and end positions, the color to apply, and an optional reset code.\n *\n * @param start - The starting index of the segment in the code string.\n * @param end - The ending index of the segment in the code string.\n * @param color - The color code to apply to the segment.\n * @param reset - The color reset code to apply after the segment, Defaults to the reset code defined in `Colors.reset`.\n */\n\n private addSegment(start: number, end: number, color: string, reset: string = Colors.reset) {\n const key = `${ start }-${ end }`;\n this.segments.set(key, { start, end, color, reset });\n }\n\n /**\n * Processes comments within a TypeScript AST node and adds segments for highlighting.\n * Extracts trailing and leading comments from the node and adds them as segments using the color defined in `this.colorSchema.comments`.\n *\n * @param node - The TypeScript AST node whose comments are to be processed.\n */\n\n private processComments(node: ts.Node): void {\n const comments = [\n ...ts.getTrailingCommentRanges(this.sourceFile.getFullText(), node.getFullStart()) || [],\n ...ts.getLeadingCommentRanges(this.sourceFile.getFullText(), node.getFullStart()) || []\n ];\n\n comments.forEach(comment => this.addSegment(comment.pos, comment.end, this.schema.commentColor));\n }\n\n /**\n * Processes the keywords within a TypeScript AST node and adds them as segments for highlighting.\n *\n * This method identifies potential keyword tokens within the provided node and adds them to the\n * list of segments with the color defined in `this.schema.keywordColor`.\n * The method considers the current node, its first token, and its last token to determine if they should be highlighted\n * as keywords.\n *\n * The method checks if the node's kind falls within the range of keyword kinds defined by TypeScript.\n * If the node or any of its tokens are identified as keywords, a segment is added to `this.segments`\n * with the start and end positions of the node and the specified color for keywords.\n *\n * @param node - The TypeScript AST node to be processed for keywords.\n */\n\n private processKeywords(node: ts.Node): void {\n if ([\n SyntaxKind.NullKeyword,\n SyntaxKind.VoidKeyword,\n SyntaxKind.StringKeyword,\n SyntaxKind.NumberKeyword,\n SyntaxKind.BooleanKeyword,\n SyntaxKind.UndefinedKeyword\n ].includes(node.kind)) {\n return this.addSegment(node.getStart(), node.getEnd(), this.schema.typeColor);\n }\n\n if (node && node.kind >= ts.SyntaxKind.FirstKeyword && node.kind <= ts.SyntaxKind.LastKeyword) {\n this.addSegment(node.getStart(), node.getEnd(), this.schema.keywordColor);\n }\n }\n\n /**\n * Processes identifiers within a TypeScript AST node and adds them as segments for highlighting\n * based on the node's parent type.\n *\n * This method determines the appropriate color for an identifier based on its parent node's kind.\n * If the parent node matches one of the specified kinds, the identifier is highlighted with a cyan color.\n * Supported parent kinds include various declarations, expressions, and signatures.\n *\n * @param node - The TypeScript AST node representing the identifier to be processed.\n */\n\n private processIdentifier(node: ts.Node): void {\n const end = node.getEnd();\n const start = node.getStart();\n\n switch (node.parent.kind) {\n case ts.SyntaxKind.EnumMember:\n return this.addSegment(start, end, this.schema.enumColor);\n case ts.SyntaxKind.CallExpression:\n case ts.SyntaxKind.EnumDeclaration:\n case ts.SyntaxKind.PropertySignature:\n case ts.SyntaxKind.ModuleDeclaration:\n return this.addSegment(start, end, this.schema.variableColor);\n case ts.SyntaxKind.InterfaceDeclaration:\n return this.addSegment(start, end, this.schema.interfaceColor);\n case ts.SyntaxKind.GetAccessor:\n return this.addSegment(start, end, this.schema.getAccessorColor);\n case ts.SyntaxKind.PropertyAssignment:\n return this.addSegment(start, end, this.schema.propertyAssignmentColor);\n case ts.SyntaxKind.MethodSignature:\n return this.addSegment(start, end, this.schema.methodSignatureColor);\n case ts.SyntaxKind.MethodDeclaration:\n case ts.SyntaxKind.FunctionDeclaration:\n return this.addSegment(start, end, this.schema.functionColor);\n case ts.SyntaxKind.ClassDeclaration:\n return this.addSegment(start, end, this.schema.classColor);\n case ts.SyntaxKind.Parameter:\n return this.addSegment(start, end, this.schema.parameterColor);\n case ts.SyntaxKind.VariableDeclaration:\n return this.addSegment(start, end, this.schema.variableColor);\n case ts.SyntaxKind.PropertyDeclaration:\n return this.addSegment(start, end, this.schema.variableColor);\n case ts.SyntaxKind.PropertyAccessExpression: {\n if (node.parent.getChildAt(0).getText() === node.getText()) {\n return this.addSegment(start, end, this.schema.variableColor);\n }\n\n return this.addSegment(start, end, this.schema.propertyAccessExpressionColor);\n }\n case ts.SyntaxKind.ExpressionWithTypeArguments:\n return this.addSegment(start, end, this.schema.expressionWithTypeArgumentsColor);\n case ts.SyntaxKind.BreakStatement:\n case ts.SyntaxKind.ShorthandPropertyAssignment:\n case ts.SyntaxKind.BindingElement:\n return this.addSegment(start, end, this.schema.variableColor);\n case ts.SyntaxKind.BinaryExpression:\n case ts.SyntaxKind.SwitchStatement:\n case ts.SyntaxKind.TemplateSpan:\n return this.addSegment(start, end, this.schema.variableColor);\n case ts.SyntaxKind.TypeReference:\n case ts.SyntaxKind.TypeAliasDeclaration:\n return this.addSegment(start, end, this.schema.typeColor);\n case ts.SyntaxKind.NewExpression:\n return this.addSegment(start, end, this.schema.variableColor);\n }\n }\n\n /**\n * Processes a TypeScript template expression and adds segments for highlighting its literal parts.\n *\n * This method adds a segment for the head of the template expression with the color specified in `this.schema.stringColor`.\n * It also processes each template span within the expression, adding\n * segments for each span's literal part.\n *\n * @param templateExpression - The TypeScript template expression to be processed.\n */\n\n private processTemplateExpression(templateExpression: ts.TemplateExpression): void {\n const start = templateExpression.head.getStart();\n const end = templateExpression.head.getEnd();\n this.addSegment(start, end, this.schema.stringColor);\n\n templateExpression.templateSpans.forEach(span => {\n const spanStart = span.literal.getStart();\n const spanEnd = span.literal.getEnd();\n this.addSegment(spanStart, spanEnd, this.schema.stringColor);\n });\n }\n\n /**\n * Processes a TypeScript AST node and adds segments for highlighting based on the node's kind.\n *\n * This method identifies the kind of the node and determines the appropriate color for highlighting.\n * It handles various node kinds including string literals, regular expressions, template expressions, and identifiers.\n * Specific methods are invoked for more complex node kinds, such as template expressions and identifiers.\n *\n * @param node - The TypeScript AST node to be processed.\n */\n\n private processNode(node: ts.Node): void {\n const start = node.getStart();\n const end = node.getEnd();\n\n switch (node.kind) {\n case ts.SyntaxKind.TypeParameter:\n return this.addSegment(start, start + (node as ts.TypeParameterDeclaration).name.text.length, this.schema.typeColor);\n case ts.SyntaxKind.TypeReference:\n return this.addSegment(start, end, this.schema.typeColor);\n case ts.SyntaxKind.StringLiteral:\n case ts.SyntaxKind.NoSubstitutionTemplateLiteral:\n return this.addSegment(start, end, this.schema.stringColor);\n case ts.SyntaxKind.RegularExpressionLiteral:\n return this.addSegment(start, end, this.schema.regularExpressionColor);\n case ts.SyntaxKind.TemplateExpression:\n return this.processTemplateExpression(node as ts.TemplateExpression);\n case ts.SyntaxKind.Identifier:\n return this.processIdentifier(node);\n case ts.SyntaxKind.BigIntLiteral:\n case ts.SyntaxKind.NumericLiteral:\n return this.addSegment(start, end, this.schema.numericLiteralColor);\n }\n }\n}\n\n/**\n * Applies semantic highlighting to the provided code string using the specified color scheme.\n *\n * @param code - The source code to be highlighted.\n * @param schema - An optional partial schema defining the color styles for various code elements.\n * Defaults to an empty object, which means no specific highlighting will be applied.\n *\n * @returns A string with the code elements wrapped in the appropriate color styles as specified by the schema.\n *\n * @example\n * const code = 'const x: number = 42;';\n * const schema = {\n * keywordColor: '\\x1b[34m', // Blue\n * stringColor: '\\x1b[32m', // Green\n * numberColor: '\\x1b[31m', // Red\n * reset: '\\x1b[0m' // Reset\n * };\n * const highlightedCode = highlightCode(code, schema);\n * console.log(highlightedCode);\n */\n\nexport function highlightCode(code: string, schema: Partial<HighlightSchemeInterface> = {}) {\n const sourceFile = ts.createSourceFile('temp.ts', code, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);\n const codeHighlighter = new CodeHighlighter(sourceFile, code, Object.assign(defaultScheme, schema));\n\n function walk(node: ts.Node): void {\n codeHighlighter.parseNode(node);\n\n for (let i = 0; i < node.getChildCount(); i++) {\n walk(node.getChildAt(i));\n }\n } ts.forEachChild(sourceFile, walk);\n\n return codeHighlighter.highlight();\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { MapType, FrameType, SegmentInterface, SegmentOffsetInterface } from './interfaces/mapping.interface';\n\n/**\n * Imports\n */\n\nimport { Bias } from './interfaces/mapping.interface';\nimport { decodeVLQ, encodeArrayVLQ } from '@components/base64.component';\n\n/**\n * The `MappingProvider` class provides methods to encode and decode mappings\n * from a source map or mapping string to an internal structured representation.\n */\n\nexport class MappingProvider {\n /**\n * The internal mapping representation, where each index represents a frame of segments.\n */\n\n private mapping: MapType = [];\n\n /**\n * Constructor to initialize the `MappingProvider` with a mapping.\n * Can be initialized with either a mapping string or a structured mapping array.\n *\n * @param mapping - The mapping data, either as a string or structured array.\n * @param namesOffset - Optional offset for the names index.\n * @param sourceOffset - Optional offset for the sources index.\n *\n * @example\n * ```ts\n * const provider = new MappingProvider(\";;;AAiBO,SAAS,OAAO;AACnB,UAAQ,IAAI,MAAM;AACtB;;;ACjBA,QAAQ,IAAI,GAAG;AACf,KAAK;\", 0, 0);\n * const provider2 = new MappingProvider([\n * null,\n * [\n * {\n * line: 1,\n * column: 1,\n * nameIndex: null,\n * sourceIndex: 0,\n * generatedLine: 2,\n * generatedColumn: 1\n * }\n * ],\n * null\n * ], 0, 0);\n * ```\n */\n\n constructor(mapping: string, namesOffset?: number, sourceOffset?: number);\n constructor(mapping: MapType, namesOffset?: number, sourceOffset?: number);\n constructor(mapping: MappingProvider, namesOffset?: number, sourceOffset?: number);\n constructor(mapping: MappingProvider| MapType | string, namesOffset = 0, sourcesOffset = 0) {\n mapping = mapping instanceof MappingProvider ? mapping.mapping : mapping;\n if (Array.isArray(mapping)) {\n this.decodeMappingArray(mapping, namesOffset, sourcesOffset);\n } else {\n this.decodeMappingString(mapping, namesOffset, sourcesOffset);\n }\n }\n\n /**\n * Encodes the internal mapping array back into a mapping string.\n *\n * @returns {string} - The encoded mapping string.\n * @example\n * ```ts\n * const encoded = provider.encode();\n * console.log(encoded); // Outputs encoded mapping string\n * ```\n */\n\n encode(): string {\n return this.encodeMappings(this.mapping);\n }\n\n /**\n * Decodes a mapping from either a string or structured array into the internal mapping.\n *\n * @param mapping - The mapping data to decode.\n * @param namesOffset - Offset for the names index.\n * @param sourcesOffset - Offset for the sources index.\n * @example\n * ```ts\n * provider.decode(\";;;AAiBO,SAAS,OAAO;AACnB,UAAQ,IAAI,MAAM;AACtB;;;ACjBA,QAAQ,IAAI,GAAG;AACf,KAAK;\", 0, 0);\n * provider.decode([\n * null,\n * [\n * {\n * line: 1,\n * column: 1,\n * nameIndex: null,\n * sourceIndex: 0,\n * generatedLine: 2,\n * generatedColumn: 1\n * }\n * ],\n * null\n * ], 0, 0);\n * ```\n */\n\n decode(mapping: MappingProvider| MapType | string, namesOffset = 0, sourcesOffset = 0): void {\n mapping = mapping instanceof MappingProvider ? mapping.mapping : mapping;\n if (Array.isArray(mapping)) {\n this.decodeMappingArray(mapping, namesOffset, sourcesOffset);\n } else {\n this.decodeMappingString(mapping, namesOffset, sourcesOffset);\n }\n }\n\n /**\n * Retrieves a segment based on the provided generated line and column,\n * applying the specified bias when the exact match is not found.\n *\n * This method performs a binary search on the segments of the specified\n * generated line to efficiently locate the segment corresponding to\n * the provided generated column. If an exact match is not found,\n * the method returns the closest segment based on the specified bias:\n * - `Bias.BOUND`: No preference for column matching (returns the closest segment).\n * - `Bias.LOWER_BOUND`: Prefers the closest mapping with a lower column value.\n * - `Bias.UPPER_BOUND`: Prefers the closest mapping with a higher column value.\n *\n * @param generatedLine - The line number of the generated code (1-based index).\n * @param generatedColumn - The column number of the generated code (0-based index).\n * @param bias - The bias to use when the line matches, can be one of:\n * - `Bias.BOUND` (default): No preference for column matching.\n * - `Bias.LOWER_BOUND`: Prefer the closest mapping with a lower column value.\n * - `Bias.UPPER_BOUND`: Prefer the closest mapping with a higher column value.\n * @returns The matching segment if found;\n * returns null if no segments exist for the specified generated line\n * or if the generated line is out of bounds.\n *\n * @throws { Error } - Throws an error if the generated line is invalid\n * (out of bounds).\n *\n * @example\n * ```ts\n * const segment = sourceMap.getSegment(5, 10, Bias.UPPER_BOUND);\n * if (segment) {\n * console.log(`Found segment: line ${segment.line}, column ${segment.column}`);\n * } else {\n * console.log('No matching segment found.');\n * }\n * ```\n */\n\n getSegment(generatedLine: number, generatedColumn: number, bias: Bias = Bias.BOUND): SegmentInterface | null {\n const segments = this.mapping[generatedLine - 1];\n if (!segments || segments.length === 0)\n return null;\n\n let low = 0;\n let high = segments.length - 1;\n let closestSegment: SegmentInterface | null = null;\n while (low <= high) {\n const mid = Math.floor((low + high) / 2);\n const segment = segments[mid];\n\n if (segment.generatedColumn < generatedColumn) {\n low = mid + 1;\n closestSegment = bias === Bias.LOWER_BOUND ? segment : closestSegment;\n } else if (segment.generatedColumn > generatedColumn) {\n high = mid - 1;\n closestSegment = bias === Bias.UPPER_BOUND ? segment : closestSegment;\n } else {\n return segment;\n }\n }\n\n return closestSegment;\n }\n\n /**\n * Retrieves the original segment based on the provided line, column, and source index.\n *\n * This method searches for the original segment that corresponds to the specified\n * line, column, and source index. It uses binary search to find the closest segment\n * based on the provided bias.\n *\n * @param line - The line number of the original code (1-based index).\n * @param column - The column number of the original code (0-based index).\n * @param sourceIndex - The index of the source file in the source map.\n * @param bias - The bias to apply when multiple segments match; defaults to `Bias.BOUND`.\n * @returns {SegmentInterface | null} - The matching original segment if found;\n * returns null if no segments exist for the specified line and source index.\n *\n * @example\n * ```ts\n * const originalSegment = sourceMap.getOriginalSegment(3, 5, 0, Bias.LOWER_BOUND);\n * if (originalSegment) {\n * console.log(`Found original segment: line ${originalSegment.line}, column ${originalSegment.column}`);\n * } else {\n * console.log('No matching original segment found.');\n * }\n * ```\n */\n\n getOriginalSegment(line: number, column: number, sourceIndex: number, bias: Bias = Bias.BOUND): SegmentInterface | null {\n let closestSegment: SegmentInterface | null = null;\n for (const segments of this.mapping) {\n if (!segments)\n continue;\n\n let low = 0;\n let high = segments.length - 1;\n while (low <= high) {\n const mid = Math.floor((low + high) / 2);\n const midSegment = segments[mid];\n\n if (midSegment.sourceIndex < sourceIndex || midSegment.line < line) {\n low = mid + 1;\n } else if (midSegment.sourceIndex > sourceIndex || midSegment.line > line) {\n high = mid - 1;\n } else if (midSegment.column < column) {\n low = mid + 1;\n closestSegment = bias === Bias.LOWER_BOUND ? midSegment : closestSegment;\n } else if (midSegment.column > column) {\n high = mid - 1;\n closestSegment = bias === Bias.UPPER_BOUND ? midSegment : closestSegment;\n } else {\n return midSegment;\n }\n }\n }\n\n return closestSegment;\n }\n\n /**\n * Initializes the segment offsets used to track the current decoding position.\n *\n * @param namesOffset - The offset for the names index.\n * @param sourceIndex - The offset for the source index.\n * @returns { SegmentOffsetInterface } - The initialized segment offset.\n */\n\n private initPositionOffsets(namesOffset: number = 0, sourceIndex: number = 0): SegmentOffsetInterface {\n return {\n line: 0,\n column: 0,\n nameIndex: namesOffset,\n sourceIndex: sourceIndex,\n generatedLine: 0,\n generatedColumn: 0\n };\n }\n\n /**\n * Validates the format of an encoded mapping string.\n *\n * @param encodedSourceMap - The encoded source map string to validate.\n * @returns Returns `true` if the format is valid, otherwise `false`.\n */\n\n private validateMappingString(encodedSourceMap: string): boolean {\n // /^(;+)?([a-z0-9+/]{1,10}(,|;+)?)+$/\n return /^[a-zA-Z0-9+/,;]+$/.test(encodedSourceMap);\n }\n\n /**\n * Validates the properties of a segment to ensure they conform to expected types.\n *\n * This method checks that the segment's properties are finite numbers and that\n * the nameIndex, if provided, is either a finite number or null.\n * An error is thrown if any of the properties do not meet the specified criteria.\n *\n * @param segment - The segment object to validate, which must conform to the\n * SegmentInterface structure, including:\n * - line: number (finite)\n * - column: number (finite)\n * - nameIndex: number | null (if not null, must be finite)\n * - sourceIndex: number (finite)\n * - generatedLine: number (finite)\n * - generatedColumn: number (finite)\n *\n * @throws {Error} - Throws an error if any property of the segment is invalid.\n * The error message will specify which property is invalid\n * and the value that was received.\n */\n\n private validateSegment(segment: SegmentInterface): void {\n if (!Number.isFinite(segment.line)) {\n throw new Error(`Invalid segment: line must be a finite number, received ${segment.line}`);\n }\n if (!Number.isFinite(segment.column)) {\n throw new Error(`Invalid segment: column must be a finite number, received ${segment.column}`);\n }\n if (segment.nameIndex !== null && !Number.isFinite(segment.nameIndex)) {\n throw new Error(`Invalid segment: nameIndex must be a number or null, received ${segment.nameIndex}`);\n }\n if (!Number.isFinite(segment.sourceIndex)) {\n throw new Error(`Invalid segment: sourceIndex must be a finite number, received ${segment.sourceIndex}`);\n }\n if (!Number.isFinite(segment.generatedLine)) {\n throw new Error(`Invalid segment: generatedLine must be a finite number, received ${segment.generatedLine}`);\n }\n if (!Number.isFinite(segment.generatedColumn)) {\n throw new Error(`Invalid segment: generatedColumn must be a finite number, received ${segment.generatedColumn}`);\n }\n }\n\n /**\n * Encodes a segment into a VLQ-encoded string based on the segment offsets.\n *\n * @param segmentOffset - The current segment offset.\n * @param segmentObject - The segment to encode.\n * @returns The encoded segment string.\n */\n\n private encodeSegment(segmentOffset: SegmentOffsetInterface, segmentObject: SegmentInterface): string {\n const { line, column, generatedColumn, nameIndex, sourceIndex } = segmentObject;\n const adjustedLine = line - 1;\n const adjustedColumn = column - 1;\n const adjustedGeneratedColumn = generatedColumn - 1;\n\n const segment: Array<number> = [\n adjustedGeneratedColumn - segmentOffset.generatedColumn, // generatedColumn difference\n sourceIndex !== segmentOffset.sourceIndex ? sourceIndex - segmentOffset.sourceIndex : 0, // sourceIndex difference\n adjustedLine - segmentOffset.line, // line difference\n adjustedColumn - segmentOffset.column // column difference\n ];\n\n if (nameIndex !== null && nameIndex !== undefined) {\n segment[4] = nameIndex - segmentOffset.nameIndex; // nameIndex difference\n segmentOffset.nameIndex = nameIndex;\n }\n\n segmentOffset.line = adjustedLine;\n segmentOffset.column = adjustedColumn;\n segmentOffset.generatedColumn = adjustedGeneratedColumn;\n segmentOffset.sourceIndex = sourceIndex;\n\n return encodeArrayVLQ(segment);\n }\n\n /**\n * Encodes the entire mapping array into a VLQ-encoded mapping string.\n *\n * @param map - The mapping array to encode.\n * @returns The encoded mapping string.\n */\n\n private encodeMappings(map: MapType): string {\n const positionOffset = this.initPositionOffsets();\n\n return map.map(frame => {\n if (!frame)\n return '';\n\n positionOffset.generatedColumn = 0;\n const segments = frame.map(segment => this.encodeSegment(positionOffset, segment));\n\n return segments.join(',');\n }).join(';');\n }\n\n /**\n * Decodes a VLQ-encoded segment into a segment object based on the current offset.\n *\n * @param segmentOffset - The current segment offset.\n * @param decodedSegment - The decoded VLQ segment values.\n * @returns The decoded segment object.\n */\n\n private decodedSegment(segmentOffset: SegmentOffsetInterface, decodedSegment: Array<number>): SegmentInterface {\n const [ generatedColumn, sourceIndex, sourceLine, sourceColumn, nameIndex ] = decodedSegment;\n segmentOffset.line += sourceLine;\n segmentOffset.column += sourceColumn;\n segmentOffset.nameIndex += nameIndex ?? 0;\n segmentOffset.sourceIndex += sourceIndex;\n segmentOffset.generatedColumn += generatedColumn;\n\n return {\n line: segmentOffset.line + 1,\n column: segmentOffset.column + 1,\n nameIndex: nameIndex !== undefined ? segmentOffset.nameIndex : null,\n sourceIndex: segmentOffset.sourceIndex,\n generatedLine: segmentOffset.generatedLine + 1,\n generatedColumn: segmentOffset.generatedColumn + 1\n };\n }\n\n /**\n * Decodes a VLQ-encoded mapping string into the internal mapping representation.\n *\n * @param encodedMap - The VLQ-encoded mapping string.\n * @param namesOffset - Offset for the names index.\n * @param sourceOffset - Offset for the sources index.\n * @throws { Error } - Throws an error if the mapping string is invalid.\n */\n\n private decodeMappingString(encodedMap: string, namesOffset: number, sourceOffset: number): void {\n if (!this.validateMappingString(encodedMap))\n throw new Error('Invalid Mappings string format: the provided string does not conform to expected VLQ format.');\n\n const frames = encodedMap.split(';');\n const linesOffset = this.mapping.length;\n const positionOffset = this.initPositionOffsets(namesOffset, sourceOffset);\n try {\n frames.forEach((frame, index) => {\n if (!frame) {\n this.mapping.push(null);\n\n return;\n }\n\n positionOffset.generatedColumn = 0;\n positionOffset.generatedLine = linesOffset + index;\n const segmentsArray: Array<SegmentInterface> = frame.split(',')\n .map(segment => this.decodedSegment(positionOffset, decodeVLQ(segment)));\n\n this.mapping.push(segmentsArray);\n });\n } catch (error) {\n throw new Error(`Error decoding mappings at frame index ${frames.length}: ${(<Error>error).message}`);\n }\n }\n\n /**\n * Decodes a mapping array into the internal mapping representation, adjusting for offsets.\n *\n * This method processes each frame in the provided structured mapping array,\n * validating each segment within the frame and adjusting the indices based on the\n * specified offsets for names and sources. If a frame is invalid or not an array,\n * an error will be thrown.\n *\n * @param encodedMap - The structured mapping array, which should be an array of frames,\n * where each frame is an array of segments. Each segment must conform\n * to the SegmentInterface.\n * @param namesOffset - Offset for the names index, which will be added to each segment's nameIndex.\n * @param sourceOffset - Offset for the sources index, which will be added to each segment's sourceIndex.\n * @throws { Error } - Throws an error if:\n * - The mapping array is invalid (not an array).\n * - Any frame is not an array.\n * - Any segment does not conform to the SegmentInterface.\n */\n\n private decodeMappingArray(encodedMap: MapType, namesOffset: number, sourceOffset: number): void {\n const linesOffset = this.mapping.length;\n if (!Array.isArray(encodedMap))\n throw new Error('Invalid encoded map: expected an array of frames.');\n\n try {\n encodedMap.forEach((frame, index) => {\n if (!frame) {\n this.mapping.push(frame);\n\n return;\n }\n\n if (!Array.isArray(frame))\n throw new Error(`Invalid Mappings array format at frame index ${index}: expected an array, received ${typeof frame}.`);\n\n const segments: FrameType = frame.map(segment => {\n this.validateSegment(segment);\n\n return {\n ...segment,\n nameIndex: (typeof segment.nameIndex === 'number') ? segment.nameIndex + namesOffset : null,\n sourceIndex: segment.sourceIndex + sourceOffset,\n generatedLine: segment.generatedLine + linesOffset\n };\n });\n\n this.mapping.push(segments);\n });\n } catch (error: unknown) {\n const errorMessage = (error instanceof Error) ? error.message : 'Unknown error';\n throw new Error(`Error decoding mappings: ${errorMessage}`);\n }\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type {\n PositionInterface,\n SourceMapInterface,\n SourceOptionsInterface,\n PositionWithCodeInterface,\n PositionWithContentInterface\n} from '@services/interfaces/source.interface';\n\n/**\n * Imports\n */\n\nimport { MappingProvider } from '@providers/mapping.provider';\nimport { Bias } from '@providers/interfaces/mapping.interface';\n\n/**\n * A service for validating and processing source maps.\n * This class allows parsing and manipulation of source maps, providing functionality such as\n * retrieving position mappings between original and generated code, concatenating source maps,\n * and getting code snippets based on mappings.\n *\n * @example\n * ```ts\n * const sourceMapJSON = '{\"version\": 3, \"file\": \"bundle.js\", \"sources\": [\"foo.ts\"], \"names\": [], \"mappings\": \"AAAA\"}';\n * const sourceService = new SourceService(sourceMapJSON);\n *\n * console.log(sourceService.file); // Outputs: 'bundle.js'\n * ```\n */\n\nexport class SourceService {\n /**\n * The name of the generated file (bundle) that this source map applies to.\n *\n * @example\n * ```ts\n * console.log(sourceService.file); // 'bundle.js'\n * ```\n */\n\n readonly file: string | null;\n\n /**\n * A MappingProvider instance of base64 VLQ-encoded mappings.\n */\n\n readonly mappings: MappingProvider;\n\n /**\n * The root URL for the sources, if present in the source map.\n */\n\n readonly sourceRoot: string | null;\n\n /**\n * A list of symbol names used by the \u201Cmappings\u201D entry.\n */\n\n readonly names: Array<string>;\n\n /**\n * An array of source file paths.\n */\n\n readonly sources: Array<string>;\n\n /**\n * An array of source files contents.\n */\n\n readonly sourcesContent: Array<string>;\n\n /**\n * Creates a new instance of the `SourceService` class.\n *\n * This constructor initializes the class using either a `SourceMapInterface` object,\n * a JSON string representing the source map, or an existing `SourceService` instance.\n * It validates the source map and populates its properties such as `file`, `sources`, and `mappings`.\n *\n * @param source - Can be one of the following:\n * - An object conforming to the `SourceMapInterface`.\n * - A JSON string representing the source map.\n * - A `SourceService` instance to copy the properties.\n * @param file - (Optional) A string representing the file name of the generated bundle.\n * Defaults to `null`. It will overwrite any existing `file` property in the source map.\n * @throws {Error} - If the source map does not contain required properties or has an invalid format.\n *\n * @example\n * ```ts\n * const sourceMapJSON = '{\"version\": 3, \"file\": \"bundle.js\", \"sources\": [\"foo.ts\"], \"names\": [], \"mappings\": \"AAAA\"}';\n * const sourceService = new SourceService(sourceMapJSON);\n * ```\n */\n\n constructor(source: SourceService);\n constructor(source: SourceMapInterface | string, file?: string | null);\n constructor(source: SourceService | SourceMapInterface | string, file: string | null = null) {\n if (typeof source === 'string') {\n source = <SourceMapInterface> JSON.parse(source);\n }\n\n source = <SourceMapInterface> source;\n this.validateSourceMap(source);\n this.file = source.file ?? file;\n this.names = [ ...source.names ?? [] ];\n this.sources = [ ...source.sources ?? [] ];\n this.sourceRoot = source.sourceRoot ?? null;\n this.sourcesContent = source.sourcesContent ? [ ...source.sourcesContent ] : [];;\n this.mappings = new MappingProvider(source.mappings);\n }\n\n /**\n * Converts the current source map data into a plain object format.\n *\n * @returns The source map json object.\n *\n * @example\n * ```ts\n * const mapObject = sourceService.getMapObject();\n * console.log(mapObject.file); // 'bundle.js'\n * ```\n */\n\n getMapObject(): SourceMapInterface {\n const sourceMap: SourceMapInterface = {\n version: 3,\n names: this.names,\n sources: this.sources,\n mappings: this.mappings.encode(),\n sourcesContent: this.sourcesContent\n };\n\n if (this.file)\n sourceMap.file = this.file;\n\n if (this.sourceRoot)\n sourceMap.sourceRoot = this.sourceRoot;\n\n return sourceMap;\n }\n\n /**\n * Concatenates one or more source maps to the current source map.\n *\n * This method merges additional source maps into the current source map,\n * updating the `mappings`, `names`, `sources`, and `sourcesContent` arrays.\n *\n * @param maps - An array of `SourceMapInterface` or `SourceService` instances to be concatenated.\n * @throws { Error } If no source maps are provided for concatenation.\n *\n * @example\n * ```ts\n * sourceService.concat(anotherSourceMap);\n * console.log(sourceService.sources); // Updated source paths\n * ```\n */\n\n concat(...maps: Array<SourceMapInterface | SourceService>): void {\n if (maps.length < 1)\n throw new Error('At least one map must be provided for concatenation.');\n\n for (const map of (maps as Array<SourceMapInterface>)) {\n this.mappings.decode(map.mappings, this.names.length, this.sources.length);\n this.names.push(...map.names);\n this.sources.push(...map.sources);\n this.sourcesContent.push(...map.sourcesContent ?? []);\n }\n }\n\n /**\n * Creates a new instance of `SourceService` with concatenated source maps.\n *\n * @param maps - An array of `SourceMapInterface` or `SourceService` instances to be concatenated.\n * @returns { SourceService } A new `SourceService` instance with the concatenated maps.\n * @throws { Error } If no source maps are provided.\n *\n * @example\n * ```ts\n * const newService = sourceService.concatNewMap(anotherSourceMap);\n * console.log(newService.file); // The file from the new source map\n * ```\n */\n\n concatNewMap(...maps: Array<SourceMapInterface | SourceService>): SourceService {\n if (maps.length < 1)\n throw new Error('At least one map must be provided for concatenation.');\n\n const sourceService = new SourceService(this);\n for (const map of (maps as Array<SourceMapInterface>)) {\n sourceService.mappings.decode(map.mappings, sourceService.names.length, sourceService.sources.length);\n sourceService.names.push(...map.names);\n sourceService.sources.push(...map.sources);\n sourceService.sourcesContent.push(...map.sourcesContent ?? []);\n }\n\n return sourceService;\n }\n\n /**\n * Retrieves the position information based on the original source line and column.\n *\n * @param line - The line number in the generated code.\n * @param column - The column number in the generated code.\n * @param sourceIndex - The index or file path of the original source.\n * @param bias - The bias to use when matching positions (`Bias.LOWER_BOUND`, `Bias.UPPER_BOUND`, or `Bias.BOUND`).\n * @returns { PositionInterface | null } The corresponding position in the original source, or `null` if not found.\n *\n * @example\n * ```ts\n * const position = sourceService.getPositionByOriginal(1, 10, 'foo.ts');\n * console.log(position?.line); // The line number in the original source\n * ```\n */\n\n getPositionByOriginal(line: number, column: number, sourceIndex: number | string, bias: Bias = Bias.BOUND): PositionInterface | null {\n let index = <number> sourceIndex;\n if (typeof sourceIndex === 'string')\n index = this.sources.findIndex(str => str.includes(sourceIndex));\n\n if (index < 0)\n return null;\n\n const segment = this.mappings.getOriginalSegment(line, column, index, bias);\n if (!segment)\n return null;\n\n return {\n name: this.names[segment.nameIndex ?? -1] ?? null,\n line: segment.line,\n column: segment.column,\n source: this.sources[segment.sourceIndex],\n sourceRoot: this.sourceRoot,\n sourceIndex: segment.sourceIndex,\n generatedLine: segment.generatedLine,\n generatedColumn: segment.generatedColumn\n };\n }\n\n /**\n * Retrieves the position in the original source code based on a given line and column\n * in the generated code.\n *\n * @param line - Line number in the generated code.\n * @param column - Column number in the generated code.\n * @param bias - The bias to use for matching positions. Defaults to `Bias.BOUND`.\n * @returns {PositionInterface | null} The position in the original source, or null if not found.\n *\n * @example\n * ```ts\n * const position = sourceService.getPosition(2, 15);\n * console.log(position?.source); // The original source file\n * ```\n */\n\n getPosition(line: number, column: number, bias: Bias = Bias.BOUND): PositionInterface | null {\n const segment = this.mappings.getSegment(line, column, bias);\n if (!segment)\n return null;\n\n return {\n name: this.names[segment.nameIndex ?? -1] ?? null,\n line: segment.line,\n column: segment.column,\n source: this.sources[segment.sourceIndex],\n sourceRoot: this.sourceRoot,\n sourceIndex: segment.sourceIndex,\n generatedLine: segment.generatedLine,\n generatedColumn: segment.generatedColumn\n };\n }\n\n /**\n * Retrieves the position and original source content for a given position in the generated code.\n *\n * @param line - Line number in the generated code.\n * @param column - Column number in the generated code.\n * @param bias - Bias used for position matching.\n * @returns { PositionWithContentInterface | null } The position and its associated content, or `null` if not found.\n *\n * @example\n * ```ts\n * const positionWithContent = sourceService.getPositionWithContent(3, 5);\n * console.log(positionWithContent?.sourcesContent); // The source code content\n * ```\n */\n\n getPositionWithContent(line: number, column: number, bias: Bias = Bias.BOUND): PositionWithContentInterface | null {\n const position = this.getPosition(line, column, bias);\n if (!position)\n return null;\n\n return {\n ...position,\n sourcesContent: this.sourcesContent[position.sourceIndex]\n };\n }\n\n /**\n * Retrieves the position and a code snippet from the original source based on the given\n * generated code position, with additional lines of code around the matching line.\n *\n * @param line - Line number in the generated code.\n * @param column - Column number in the generated code.\n * @param bias - Bias used for position matching.\n * @param options - (Optional) Extra options for the amount of surrounding lines to include.\n * @returns { PositionWithCodeInterface | null } The position and code snippet.\n *\n * @example\n * ```ts\n * const positionWithCode = sourceService.getPositionWithCode(4, 8, Bias.BOUND, { linesBefore: 2, linesAfter: 2 });\n * console.log(positionWithCode?.code); // The code snippet from the original source\n * ```\n */\n\n getPositionWithCode(line: number, column: number, bias: Bias = Bias.BOUND, options?: SourceOptionsInterface): PositionWithCodeInterface | null {\n const position = this.getPosition(line, column, bias);\n if (!position || !this.sourcesContent[position.sourceIndex])\n return null;\n\n const settings = Object.assign({\n linesAfter: 4,\n linesBefore: 3\n }, options);\n\n const code = this.sourcesContent[position.sourceIndex].split('\\n');\n const endLine = Math.min( (position.line ?? 1) + settings.linesAfter, code.length);\n const startLine = Math.max((position.line ?? 1) - settings.linesBefore, 0);\n const relevantCode = code.slice(startLine, Math.min(endLine + 1, code.length)).join('\\n');\n\n return {\n ...position,\n code: relevantCode,\n endLine: endLine,\n startLine: startLine\n };\n }\n\n /**\n * Converts the current source map object to a JSON string.\n *\n * @returns A stringified version of the source map object.\n *\n * @example\n * ```ts\n * console.log(sourceService.toString()); // JSON string of the source map\n * ```\n */\n\n toString(): string {\n return JSON.stringify(this.getMapObject());\n }\n\n /**\n * Validates the provided source map object.\n *\n * This method checks whether all required keys are present in the source map object.\n * It throws an error if any required keys are missing.\n *\n * @private\n * @param input - The source map object to be validated.\n * @throws Error If any required key is missing from the source map.\n *\n * @example\n * ```ts\n * const sourceMap = {\n * version: 3,\n * file: 'example.js',\n * names: ['src', 'maps', 'example', 'function', 'line', 'column'],\n * sources: ['source1.js', 'source2.js'],\n * mappings: 'AAAA,SAASA,CAAC,CAAC,CAAC;AAAA,CAAC,CAAC;AAAC,CAAC',\n * };\n * sourceService['validateSource'](sourceMap); // Throws if invalid\n * ```\n */\n\n private validateSourceMap(input: SourceMapInterface): void {\n const requiredKeys: (keyof SourceMapInterface)[] = [ 'sources', 'mappings', 'names' ];\n if (!requiredKeys.every(key => key in input)) {\n throw new Error('Missing required keys in SourceMap.');\n }\n }\n}\n"],
6
+ "mappings": "AAaO,SAASA,EAAgBC,EAAiD,CAC7E,IAAMC,EAAQD,EAAY,MAAM;AAAA,CAAI,EAAE,MAAM,CAAC,EACvCE,EAAQ,sEACRC,EAAY,qDACZC,EAAoC,CAAC,EAE3C,OAAAH,EAAM,QAASI,GAAS,CACpB,IAAMC,EAAQD,EAAK,MAAMH,CAAK,EAC9B,GAAI,CAACI,EAAO,OAEZ,IAAIC,EAAsBD,EAAM,MAAM,CAAC,EACnCA,EAAM,CAAC,IACPC,EAAOD,EAAM,MAAM,CAAC,GAGxB,GAAM,CAAEE,EAAIC,EAAMC,EAASC,CAAO,EAAIJ,EAChCK,EAAa,SAASF,EAAS,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D,EALW,IAMf,CAmBA,oBAAoBP,EAAcC,EAAgBE,IAAyBK,EAAoE,CAC3I,IAAMD,EAAW,KAAK,YAAYP,EAAMC,EAAQE,CAAI,EACpD,GAAI,CAACI,GAAY,CAAC,KAAK,eAAeA,EAAS,WAAW,EACtD,OAAO,KAEX,IAAME,EAAW,OAAO,OAAO,CAC3B,WAAY,EACZ,YAAa,CACjB,EAAGD,CAAO,EAEJE,EAAO,KAAK,eAAeH,EAAS,WAAW,EAAE,MAAM;AAAA,CAAI,EAC3DI,EAAU,KAAK,KAAMJ,EAAS,MAAQ,GAAKE,EAAS,WAAYC,EAAK,MAAM,EAC3EE,EAAY,KAAK,KAAKL,EAAS,MAAQ,GAAKE,EAAS,YAAa,CAAC,EACnEI,EAAeH,EAAK,MAAME,EAAW,KAAK,IAAID,EAAU,EAAGD,EAAK,MAAM,CAAC,EAAE,KAAK;AAAA,CAAI,EAExF,MAAO,CACH,GAAGH,EACH,KAAMM,EACN,QAASF,EACT,UAAWC,CACf,CACJ,CAaA,UAAmB,CACf,OAAO,KAAK,UAAU,KAAK,aAAa,CAAC,CAC7C,CAyBQ,kBAAkBE,EAAiC,CAEvD,GAAI,CAD+C,CAAE,UAAW,WAAY,OAAQ,EAClE,MAAMC,GAAOA,KAAOD,CAAK,EACvC,MAAM,IAAI,MAAM,qCAAqC,CAE7D,CACJ",
7
7
  "names": ["parseErrorStack", "stackString", "lines", "regex", "evalRegex", "stack", "line", "match", "args", "at", "file", "lineNum", "colNum", "lineNumber", "columnNumber", "evalMatch", "evalAt", "evalFile", "evalLineNum", "evalColNum", "evalAnonFile", "base64Map", "base64Chars", "char", "index", "encodeVLQ", "value", "isNegative", "encoded", "vlq", "digit", "encodeArrayVLQ", "values", "decodeVLQ", "data", "result", "shift", "continuation", "shifted", "formatCode", "code", "options", "lines", "padding", "startLine", "lineContent", "index", "currentLineNumber", "string", "formatErrorCode", "sourcePosition", "ansiOption", "errorLine", "errorColumn", "lineString", "line", "pointer", "ansiPadding", "prefixPointer", "errorMarker", "ts", "SyntaxKind", "Colors", "defaultScheme", "CodeHighlighter", "sourceFile", "code", "schema", "node", "previousSegmentEnd", "parent", "result", "a", "b", "segment", "lastSegment", "source", "combinedSource", "start", "end", "color", "reset", "key", "comment", "templateExpression", "span", "spanStart", "spanEnd", "highlightCode", "codeHighlighter", "walk", "i", "MappingProvider", "_MappingProvider", "mapping", "namesOffset", "sourcesOffset", "generatedLine", "generatedColumn", "bias", "segments", "low", "high", "closestSegment", "mid", "segment", "line", "column", "sourceIndex", "midSegment", "encodedSourceMap", "segmentOffset", "segmentObject", "nameIndex", "adjustedLine", "adjustedColumn", "adjustedGeneratedColumn", "encodeArrayVLQ", "map", "positionOffset", "frame", "decodedSegment", "sourceLine", "sourceColumn", "encodedMap", "sourceOffset", "frames", "linesOffset", "index", "segmentsArray", "decodeVLQ", "error", "errorMessage", "SourceService", "_SourceService", "source", "file", "MappingProvider", "sourceMap", "maps", "map", "sourceService", "line", "column", "sourceIndex", "bias", "index", "str", "segment", "position", "options", "settings", "code", "endLine", "startLine", "relevantCode", "input", "key"]
8
8
  }
@@ -0,0 +1 @@
1
+ {"type": "module"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export*from"./components/parser.component.js";export*from"./components/base64.component.js";export*from"./components/formatter.component.js";export*from"./components/highlighter.component.js";export*from"./services/source.service.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,8 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourceRoot": "https://github.com/remotex-lab/xmap/tree/2.0.3/",
5
+ "sourcesContent": ["// export components interfaces\nexport type * from './components/interfaces/parse.interface.js';\nexport type * from './components/interfaces/formatter.interface.js';\nexport type * from './components/interfaces/highlighter.interface.js';\n\n// export services interfaces\nexport type * from './services/interfaces/source.interface.js';\n\n// Export components\nexport * from './components/parser.component.js';\nexport * from './components/base64.component.js';\nexport * from './components/formatter.component.js';\nexport * from './components/highlighter.component.js';\n\n// export service\nexport * from './services/source.service.js';\n"],
6
+ "mappings": "AASA,WAAc,mCACd,WAAc,mCACd,WAAc,sCACd,WAAc,wCAGd,WAAc",
7
+ "names": []
8
+ }
@@ -0,0 +1 @@
1
+ {"type": "module"}
@@ -0,0 +1,2 @@
1
+ var n=(e=>(e[e.BOUND=0]="BOUND",e[e.LOWER_BOUND=1]="LOWER_BOUND",e[e.UPPER_BOUND=2]="UPPER_BOUND",e))(n||{});export{n as Bias};
2
+ //# sourceMappingURL=mapping.interface.js.map
@@ -0,0 +1,8 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/providers/interfaces/mapping.interface.ts"],
4
+ "sourceRoot": "https://github.com/remotex-lab/xmap/tree/2.0.3/",
5
+ "sourcesContent": ["/**\n * Represents a mapping segment that corresponds to a position in the source map.\n *\n * @property line - The original line number in the source file.\n * @property column - The original column number in the source file.\n * @property nameIndex - The index of the symbol name in the source map, or `null` if there is no associated name.\n * @property sourceIndex - The index of the source file in the source map.\n * @property generatedLine - The line number in the generated code.\n * @property generatedColumn - The column number in the generated code.\n */\n\nexport interface SegmentInterface {\n line: number;\n column: number;\n nameIndex: number | null;\n sourceIndex: number;\n generatedLine: number;\n generatedColumn: number;\n}\n\n/**\n * Extends the `SegmentInterface` to represent an offset segment used during mapping calculations.\n * The main difference is that `nameIndex` is always a number.\n *\n * @augments { SegmentInterface }\n * @property nameIndex - The index of the symbol name in the source map (cannot be null in this context).\n */\n\nexport interface SegmentOffsetInterface extends SegmentInterface {\n nameIndex: number;\n}\n\n/**\n * Represents the bias used when searching for segments in the source map.\n * This enum is useful for determining the preferred matching behavior\n * when the exact line and column cannot be found.\n *\n * @property BOUND - No preference for column matching; returns the first match found.\n * @property LOWER_BOUND - Prefer the closest mapping with a lower column value.\n * @property UPPER_BOUND - Prefer the closest mapping with a higher column value.\n */\n\nexport const enum Bias {\n BOUND,\n LOWER_BOUND,\n UPPER_BOUND\n}\n\n/**\n * A type alias for a frame in the source map, representing an array of segments.\n * Each frame consists of multiple mapping segments for a given line in the generated code.\n */\n\nexport type FrameType = Array<SegmentInterface>;\n\n/**\n * A type alias for the source map, where each entry represents a frame of mappings.\n * A frame can either be an array of segments (frame) or `null` if the line has no mappings (represented by a semicolon in the mapping string).\n */\n\nexport type MapType = Array<null | FrameType>;\n"],
6
+ "mappings": "AA0CO,IAAWA,OACdA,IAAA,iBACAA,IAAA,6BACAA,IAAA,6BAHcA,OAAA",
7
+ "names": ["Bias"]
8
+ }