@remotex-labs/xmap 1.1.0 → 2.0.1
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.
- package/README.md +206 -143
- package/dist/{components → cjs/components}/formatter.component.d.ts +2 -2
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/index.js.map +8 -0
- package/dist/cjs/providers/interfaces/mapping.interface.d.ts +52 -0
- package/dist/cjs/providers/mapping.provider.d.ts +229 -0
- package/dist/cjs/services/interfaces/source.interface.d.ts +53 -0
- package/dist/cjs/services/source.service.d.ts +217 -0
- package/dist/esm/components/base64.component.d.ts +26 -0
- package/dist/esm/components/formatter.component.d.ts +66 -0
- package/dist/esm/components/highlighter.component.d.ts +186 -0
- package/dist/esm/components/interfaces/formatter.interface.d.ts +42 -0
- package/dist/esm/components/interfaces/highlighter.interface.d.ts +48 -0
- package/dist/esm/components/interfaces/parse.interface.d.ts +31 -0
- package/dist/esm/components/parser.component.d.ts +11 -0
- package/dist/esm/index.d.ts +9 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +8 -0
- package/dist/esm/providers/interfaces/mapping.interface.d.ts +52 -0
- package/dist/esm/providers/mapping.provider.d.ts +229 -0
- package/dist/esm/services/interfaces/source.interface.d.ts +53 -0
- package/dist/esm/services/source.service.d.ts +217 -0
- package/package.json +24 -9
- package/dist/index.js +0 -9
- package/dist/index.js.map +0 -7
- package/dist/services/interfaces/source.interface.d.ts +0 -252
- package/dist/services/source.service.d.ts +0 -478
- /package/dist/{components → cjs/components}/base64.component.d.ts +0 -0
- /package/dist/{components → cjs/components}/highlighter.component.d.ts +0 -0
- /package/dist/{components → cjs/components}/interfaces/formatter.interface.d.ts +0 -0
- /package/dist/{components → cjs/components}/interfaces/highlighter.interface.d.ts +0 -0
- /package/dist/{components → cjs/components}/interfaces/parse.interface.d.ts +0 -0
- /package/dist/{components → cjs/components}/parser.component.d.ts +0 -0
- /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
package/dist/index.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts", "../src/components/parser.component.ts", "../src/components/base64.component.ts", "../src/components/formatter.component.ts", "../src/components/highlighter.component.ts", "../src/services/source.service.ts"],
|
|
4
|
-
"sourcesContent": ["// export components interfaces\nexport type * from '@components/interfaces/parse.interface';\nexport type * from '@components/interfaces/formatter.interface';\nexport type * from '@components/interfaces/highlighter.interface';\n\n// export services interfaces\nexport type * from '@services/interfaces/source.interface';\n\n// Export components\nexport * from '@components/parser.component';\nexport * from '@components/base64.component';\nexport * from '@components/formatter.component';\nexport * from '@components/highlighter.component';\n\n// export service\nexport * from '@services/source.service';\n", "/**\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 { PositionSourceInterface } 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: PositionSourceInterface, 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 {\n MappingInterface,\n PositionInterface,\n SourceMapInterface,\n ShiftSegmentInterface,\n SourceOptionsInterface,\n PositionSourceInterface,\n ThresholdSegmentInterface\n} from '@services/interfaces/source.interface';\n\n/**\n * Imports\n */\n\nimport { Bias } from '@services/interfaces/source.interface';\nimport { decodeVLQ, encodeArrayVLQ } from '@components/base64.component';\n\n/**\n * A service for validating and processing source maps.\n */\n\nexport class SourceService {\n /**\n * The name of the generated file (bundle) that this source map applies to.\n */\n\n readonly file: string | null;\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 private readonly names: Array<string>;\n\n /**\n * An array of source file paths.\n */\n\n private readonly sources: Array<string>;\n\n /**\n * A string of base64 VLQ-encoded mappings.\n */\n\n private readonly mappings: Array<MappingInterface>;\n\n /**\n * An array of source files contents.\n */\n\n private readonly sourcesContent: Array<string>;\n\n /**\n * Creates a new instance of the SourceService class.\n *\n * This constructor initializes a `SourceService` instance using the provided source map object.\n * It performs validation to ensure that the source map contains all required properties.\n *\n * @param source - An object conforming to the `SourceMapInterface` representing the source map to be validated and processed.\n * @throws Error If any required property is missing from the source map object.\n */\n\n constructor(source: SourceMapInterface) {\n this.validateSourceMap(source);\n\n this.file = source.file ?? null;\n this.names = source.names ?? [];\n this.sources = source.sources ?? [];\n this.mappings = [];\n this.sourceRoot = source.sourceRoot ?? null;\n this.sourcesContent = source.sourcesContent ?? [];\n this.decodeMappings(source.mappings);\n }\n\n /**\n * Returns a plain object representation of the source map data.\n *\n * This method constructs and returns an object that includes key properties of the source map:\n * - `version`: The version of the source map specification (typically 3).\n * - `file`: The name of the generated file (optional).\n * - `names`: An array of function or variable names extracted from the original source code.\n * - `sources`: An array of file paths for the source files referenced in the mappings.\n * - `sourceRoot`: An optional root URL for resolving source file paths.\n * - `mappings`: A base64 VLQ-encoded string representing the source map mappings, generated by `encodeMappings`.\n * - `sourcesContent`: An optional array containing the content of the source files. This property may not be present in all source maps.\n *\n * @returns A plain object conforming to the `SourceMapInterface` structure,\n * representing the source map data.\n */\n\n getMapObject(): SourceMapInterface {\n const sourceMap: SourceMapInterface = {\n version: 3,\n names: this.names,\n sources: this.sources,\n mappings: this.encodeMappings(this.mappings),\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 * Retrieves the source code snippet from the original source based on the specified\n * file index, line number, and column number. This method provides context for the\n * specified location in the source code, useful for debugging or inspection purposes.\n *\n * This method can accept both string and numeric file indices. If a string is provided,\n * it will search for the corresponding index in the list of source file names. If the\n * index is not found or if an invalid location is provided, it will return null.\n *\n * @param fileIndex - The index of the source file (as a number) or the name of the\n * source file (as a string) from which to retrieve the code.\n * If a string is provided, the method will search through the\n * available sources to find the corresponding index.\n * @param line - The line number in the original source file from which to retrieve\n * the code snippet.\n * @param column - The column number in the original source file that indicates the\n * specific position for the code snippet.\n * @param options - Optional settings that can customize the behavior of the method:\n * - `bias`: Specifies the bias for the mapping retrieval (default is `Bias.LOWER_BOUND`).\n * - `linesAfter`: The number of lines to include after the specified line (default is 4).\n * - `linesBefore`: The number of lines to include before the specified line (default is 3).\n *\n * @returns A `PositionSourceInterface` object containing:\n * - `code`: A snippet of the original source code surrounding the specified line and column.\n * - `line`: The line number in the original source code.\n * - `column`: The column number in the original source code.\n * - `startLine`: The starting line number of the returned source code snippet.\n * - `endLine`: The ending line number of the returned source code snippet.\n * - `name`: The name of the function or variable at the matched position, if available.\n * - `source`: The file name of the original source.\n * - `sourceRoot`: The root directory of the original source file.\n *\n * @returns Null if no valid source file is found or if no matching position is found\n * in the source file.\n *\n * @example\n * ```typescript\n * const sourceCode = getSourceCodeByLocation('app.js', 10, 15);\n * if (sourceCode) {\n * console.log(sourceCode);\n * // {\n * // code: 'function example() {...}',\n * // line: 10,\n * // column: 15,\n * // startLine: 7,\n * // endLine: 11,\n * // name: 'example',\n * // source: 'app.js',\n * // sourceRoot: '/src'\n * // }\n * }\n * ```\n */\n\n getSourceCodeByLocation(fileIndex: string, line: number, column: number, options?: SourceOptionsInterface): PositionSourceInterface | null;\n getSourceCodeByLocation(fileIndex: number, line: number, column: number, options?: SourceOptionsInterface): PositionSourceInterface | null;\n getSourceCodeByLocation(fileIndex: number | string, line: number, column: number, options?: SourceOptionsInterface): PositionSourceInterface | null {\n let index = <number> fileIndex;\n if (typeof fileIndex === 'string')\n index = this.sources.findIndex(str => str.includes(fileIndex));\n\n if (index < 0)\n return null;\n\n const settings = Object.assign({\n bias: Bias.LOWER_BOUND,\n linesAfter: 4,\n linesBefore: 3\n }, options);\n\n const map = this.retrieveMapping(line, column, settings.bias, index, 'sourceLine', 'sourceColumn');\n \n return this.getPositionWithSource(map, settings);\n }\n\n /**\n * Retrieves the original source location and optional source code snippet for a given line and column in the generated code.\n *\n * This function uses the source map to locate the corresponding position in the original source code. Depending on the `options` provided,\n * it can include a snippet of the original source code surrounding the located position, offering context for debugging purposes.\n *\n * @param line - The line number in the generated code.\n * @param column - The column number in the generated code.\n * @param options - Optional settings for retrieving the source position and context:\n * - `linesBefore` (default: 3): Number of lines before the matched source line to include in the returned snippet.\n * - `linesAfter` (default: 4): Number of lines after the matched source line to include in the returned snippet.\n * - `includeSourceContent` (default: false): When true, includes a snippet of the source code in the result.\n * - `bias` (optional): Determines how to resolve ambiguous mappings (e.g., when there are multiple possible matches for the line/column).\n *\n * @returns An object containing detailed source information, including:\n * - `line`: The line number in the original source code.\n * - `column`: The column number in the original source code.\n * - `startLine`: The starting line number of the returned source code snippet.\n * - `endLine`: The ending line number of the returned source code snippet.\n * - `name`: The name of the function or variable at the matched position, if available.\n * - `source`: The file name of the original source.\n * - `sourceRoot`: The root directory of the original source file.\n * - `code` (if `includeSourceContent` is true): A snippet of the original source code surrounding the specified line and column.\n *\n * @returns Null if no matching source position is found.\n *\n * @example\n * ```typescript\n * const position = getSourcePosition(10, 5, { linesBefore: 2, linesAfter: 2, includeSourceContent: true });\n * console.log(position);\n * // {\n * // line: 7,\n * // column: 15,\n * // startLine: 5,\n * // endLine: 9,\n * // name: 'myFunction',\n * // source: 'app.js',\n * // sourceRoot: '/src',\n * // code: 'function myFunction() {...}'\n * // }\n * ```\n */\n\n getSourcePosition(line: number, column: number, options?: SourceOptionsInterface): PositionSourceInterface | null {\n const settings = Object.assign({\n bias: Bias.LOWER_BOUND,\n linesAfter: 4,\n linesBefore: 3\n }, options);\n\n const map = this.retrieveMapping(line, column, settings.bias);\n \n return this.getPositionWithSource(map, settings);\n }\n\n /**\n * Retrieves the position information in the original source code for a given line and column in the generated code.\n *\n * This function locates the corresponding position in the original source code based on the provided line and column in the generated code.\n * It uses the specified bias to determine the best match when multiple mappings are possible.\n *\n * @param line - The line number in the generated code.\n * @param column - The column number in the generated code.\n * @param bias - Optional parameter specifying how to handle cases where only the line number matches:\n * - `Bias.LOWER_BOUND` (default): If the line number matches but the column is less, returns the closest mapping with a lower column.\n * - `Bias.UPPER_BOUND`: If the line number matches but the column is greater, returns the closest mapping with a higher column.\n * - `Bias.BOUND`: If the line number matches but the column doesn't, returns null.\n *\n * @returns A `PositionInterface` object representing the position in the original source code, including:\n * - `line`: The line number in the original source code.\n * - `column`: The column number in the original source code.\n * - `name`: The function or variable name at the source position, if available.\n * - `source`: The file name of the original source code.\n * - `sourceRoot`: The root path of the original source code.\n * Returns `null` if no matching position is found.\n *\n * @example\n * ```typescript\n * const position = getPosition(10, 5, Bias.LOWER_BOUND);\n * console.log(position);\n * // {\n * // line: 7,\n * // column: 15,\n * // name: 'myFunction',\n * // source: 'app.js',\n * // sourceRoot: '/src'\n * // }\n * ```\n */\n\n getPosition(line: number, column: number, bias: Bias = Bias.LOWER_BOUND): PositionInterface | null {\n const map = this.retrieveMapping(line, column, bias);\n if (!map) {\n return map;\n }\n\n return {\n line: map.sourceLine,\n name: this.names[map.nameIndex ?? -1] ?? null,\n column: map.sourceColumn,\n source: this.sources[map.fileIndex],\n sourceRoot: this.sourceRoot\n };\n }\n\n /**\n * Merges multiple source maps into this source map object.\n * The order of the provided source maps must correspond to the order in which the source files were concatenated.\n *\n * This method appends the names, sources, and source contents from each provided source map to the current source map.\n * It also adjusts the mappings to account for the concatenation of the source files.\n *\n * @param maps - An array of `SourceMapInterface` instances representing the source maps to be merged.\n * @throws Error If no source maps are provided for concatenation.\n *\n * @example\n * // Merging two source maps\n * const map1: SourceMapInterface = { /* ... *\\/ };\n * const map2: SourceMapInterface = { /* ... *\\/ };\n * sourceMapService.concat(map1, map2);\n */\n\n concat(...maps: Array<SourceMapInterface>): void {\n if (maps.length < 1) {\n throw new Error('At least one map must be provided for concatenation.');\n }\n\n for (const map of maps) {\n this.names.push(...map.names);\n this.sources.push(...map.sources);\n this.sourcesContent.push(...map.sourcesContent);\n\n const lastSegment = this.mappings[this.mappings.length - 1];\n const lines = this.sourcesContent[lastSegment.fileIndex].split('\\n').length;\n\n this.decodeMappings(maps[0].mappings, {\n nameIndex: this.names.length - 1,\n fileIndex: this.sources.length - 1,\n generatedLine: lines < 2 ? 2 : lines\n });\n }\n }\n\n /**\n * Converts the source map object to a JSON string representation.\n *\n * This method performs the following steps:\n * 1. Creates a plain object representation of the source map using the `getMapObject` method.\n * 2. Converts the plain object to a JSON string using `JSON.stringify`.\n *\n * @returns A JSON string representation of the source map.\n *\n * @example\n * const sourceMapString = sourceMapService.toString();\n * // sourceMapString contains the JSON string representation of the source map.\n */\n\n toString(): string {\n return JSON.stringify(this.getMapObject());\n }\n\n /**\n * Retrieves the position information in the original source code along with a snippet\n * of the surrounding source code based on the provided mapping.\n *\n * This method takes a mapping object that represents a position in the generated code\n * and locates the corresponding position in the original source code. It extracts a\n * relevant code snippet surrounding the identified position, providing context for\n * debugging or inspection purposes.\n *\n * @param map - A `MappingInterface` object representing the mapping from the generated\n * code to the original source code. If the mapping is null or invalid,\n * the method will return null.\n * @param settings - An object containing configuration options for retrieving the\n * surrounding code snippet, including:\n * - `linesAfter`: The number of lines to include after the specified line (default is 4).\n * - `linesBefore`: The number of lines to include before the specified line (default is 3).\n *\n * @returns An object containing detailed source information, including:\n * - `line`: The line number in the original source code.\n * - `column`: The column number in the original source code.\n * - `startLine`: The starting line number of the returned source code snippet.\n * - `endLine`: The ending line number of the returned source code snippet.\n * - `name`: The name of the function or variable at the matched position, if available.\n * - `source`: The file name of the original source.\n * - `sourceRoot`: The root directory of the original source file.\n * - `code`: A snippet of the original source code surrounding the specified line and column.\n *\n * @returns Null if no valid mapping is provided or if no matching source position is found.\n *\n * @example\n * ```typescript\n * const positionInfo = getPositionWithSource(mapping, { linesAfter: 4, linesBefore: 3 });\n * if (positionInfo) {\n * console.log(positionInfo);\n * // {\n * // code: 'function myFunction() {...}',\n * // line: 7,\n * // column: 15,\n * // startLine: 5,\n * // endLine: 9,\n * // name: 'myFunction',\n * // source: 'app.js',\n * // sourceRoot: '/src'\n * // }\n * }\n * ```\n */\n\n private getPositionWithSource(map: MappingInterface | null, settings: Required<SourceOptionsInterface>): PositionSourceInterface | null {\n if (!map || isNaN(map.fileIndex)) {\n return null;\n }\n\n const code = this.sourcesContent[map.fileIndex].split('\\n');\n const endLine = (map.sourceLine ?? 1) + settings.linesAfter;\n const startLine = Math.max((map.sourceLine ?? 1) - settings.linesBefore, 0);\n const relevantCode = code.slice(startLine, Math.min(endLine + 1, code.length)).join('\\n');\n\n return {\n code: relevantCode,\n line: map.sourceLine,\n name:this.names[map.nameIndex ?? -1] ?? null,\n column: map.sourceColumn,\n endLine: endLine,\n startLine: startLine,\n source: this.sources[map.fileIndex],\n sourceRoot: this.sourceRoot\n };\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 * 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 * sourcesContent: ['console.log(\"Hello world\");', 'console.log(\"Another file\");']\n * };\n *\n * try {\n * validateSourceMap(sourceMap);\n * console.log('Source map is valid.');\n * } catch (error) {\n * console.error('Invalid source map:', error.message);\n * }\n */\n\n private validateSourceMap(input: SourceMapInterface): void {\n const requiredKeys: (keyof SourceMapInterface)[] = [ 'version', 'sources', 'sourcesContent', 'mappings', 'names' ];\n if (!requiredKeys.every(key => key in input)) {\n throw new Error('Missing required keys in SourceMap.');\n }\n }\n\n /**\n * Decodes and processes the base64 VLQ-encoded mappings from a source map.\n *\n * This method interprets the encoded mappings from the `mappings` property of a source map. It adjusts\n * the shift state for both generated and original positions in the source code, and processes each\n * decoded mapping segment using the `decodedSegment` method.\n *\n * The decoding process involves:\n * 1. Parsing the base64 VLQ-encoded mappings.\n * 2. Adjusting the shift state based on the provided `thresholdSegment` or default values.\n * 3. Handling each decoded mapping segment with the `decodedSegment` method.\n *\n * @param encodedMappings - A string representing the encoded mappings in base64 VLQ format. This string\n * is typically found in the `mappings` property of a source map.\n * @param thresholdSegment - Optional. An object containing offset information that adjusts the starting\n * point for decoding. This can include offsets for line, column, or file index.\n * If not provided, default values are used.\n * @throws Error - Throws an error if the decoding process encounters an issue, such as an invalid\n * encoding or unexpected format.\n *\n * @example\n * const encodedMappings = 'AAAA,CAAC,CAAC,CAAC,CAAC;AAAA,CAAC,CAAC,CAAC,CAAC';\n * const threshold = {\n * fileIndex: 0,\n * nameIndex: 0,\n * sourceLine: 1,\n * sourceColumn: 1,\n * generatedLine: 1,\n * generatedColumn: 1\n * };\n * try {\n * decodeMappings(encodedMappings, threshold);\n * } catch (error) {\n * console.error('Failed to decode mappings:', error.message);\n * }\n */\n\n private decodeMappings(encodedMappings: string, thresholdSegment?: ThresholdSegmentInterface): void {\n // Note: Line and column numbers in source maps start at 1,\n // unlike arrays which start at 0. Therefore, the initial shift for lines is set to 1.\n const shift = Object.assign({\n fileIndex: 0,\n nameIndex: 0,\n sourceLine: 1,\n sourceColumn: 1,\n generatedLine: 1,\n generatedColumn: 1\n }, thresholdSegment);\n\n try {\n for (const [ generatedLine, stringSegments ] of encodedMappings.split(';').entries()) {\n if (!stringSegments) continue;\n shift.generatedColumn = 1;\n const segments = stringSegments.split(',');\n\n for (const segment of segments) {\n if (segment.length < 4) continue;\n const decodedSegment = decodeVLQ(segment);\n\n this.decodedSegment(shift, decodedSegment, generatedLine + shift.generatedLine);\n }\n }\n } catch (error) {\n throw new Error(`Error decoding mappings: ${ (<Error>error).message }`);\n }\n }\n\n /**\n * Processes a decoded VLQ segment and updates the mapping information.\n *\n * This method adjusts the current mapping state based on the decoded VLQ segment and the current\n * line in the generated code. It then updates the internal mappings list with the new information.\n *\n * The decoding process involves:\n * 1. Extracting the mapping details from the `decodedSegment` array.\n * 2. Updating the shift values for file index, name index, source line, source column, and generated column.\n * 3. Adding the processed mapping to the internal `mappings` array.\n *\n * @param shift - The current state of mapping information. This object tracks the cumulative state\n * of file index, name index, source line, source column, and generated column.\n * @param decodedSegment - An array representing the decoded VLQ segment, containing:\n * - `generatedColumn`: The column number in the generated code.\n * - `fileIndex`: The index in the sources array.\n * - `sourceLine`: The line number in the original source code.\n * - `sourceColumn`: The column number in the original source code.\n * - `nameIndex`: The index in the names array.\n * @param generatedLine - The line index in the generated code where this segment applies.\n *\n * @example\n * const shift = {\n * fileIndex: 0,\n * nameIndex: 0,\n * sourceLine: 1,\n * sourceColumn: 1,\n * generatedLine: 1,\n * generatedColumn: 1\n * };\n * const decodedSegment = [2, 1, 3, 4, 5];\n * const generatedLine = 1;\n * this.decodedSegment(shift, decodedSegment, generatedLine);\n *\n * @see ShiftSegmentInterface for details on the `shift` parameter.\n * @see SourceMapInterface for details on the mapping properties.\n */\n\n private decodedSegment(shift: ShiftSegmentInterface, decodedSegment: Array<number>, generatedLine: number): void {\n const [ generatedColumn, fileIndex, sourceLine, sourceColumn, nameIndex ] = decodedSegment;\n shift.fileIndex += fileIndex;\n shift.nameIndex += nameIndex ?? 0;\n shift.sourceLine += sourceLine;\n shift.sourceColumn += sourceColumn;\n shift.generatedColumn += generatedColumn;\n\n this.mappings.push({\n nameIndex: (nameIndex !== undefined) ? shift.nameIndex : null,\n fileIndex: shift.fileIndex,\n sourceLine: shift.sourceLine,\n sourceColumn: shift.sourceColumn,\n generatedLine: generatedLine,\n generatedColumn: shift.generatedColumn\n });\n }\n\n /**\n * Encodes an array of mappings into a VLQ-encoded string representation.\n *\n * This method converts an array of `MappingInterface` objects into a base64 VLQ-encoded string,\n * which is used in source maps to represent the mapping between generated and original source code positions.\n *\n * The encoding process involves:\n * 1. Initializing the shift state to track the current line and column in the generated code.\n * 2. Iterating through the mappings to group them by line number and encode each segment.\n * 3. Concatenating encoded segments with the appropriate separator characters (`,` and `;`).\n *\n * @param mappings - An array of `MappingInterface` objects representing the mappings to encode. Each mapping object contains:\n * - `nameIndex`: The index in the names array.\n * - `fileIndex`: The index in the sources array.\n * - `sourceLine`: The line number in the original source code.\n * - `sourceColumn`: The column number in the original source code.\n * - `generatedLine`: The line number in the generated code.\n * - `generatedColumn`: The column number in the generated code.\n * @returns A VLQ-encoded string representing the mappings, with segments separated by commas and lines by semicolons.\n *\n * @example\n * const mappings = [\n * { nameIndex: 0, fileIndex: 1, sourceLine: 2, sourceColumn: 3, generatedLine: 1, generatedColumn: 4 },\n * { nameIndex: 1, fileIndex: 1, sourceLine: 3, sourceColumn: 4, generatedLine: 2, generatedColumn: 5 }\n * ];\n * const encodedMappings = this.encodeMappings(mappings);\n * console.log(encodedMappings); // Outputs the VLQ-encoded string\n *\n * @see MappingInterface for details on the mapping properties.\n */\n\n private encodeMappings(mappings: Array<MappingInterface>): string {\n let resultMapping = '';\n let segments: Array<string> = [];\n\n const shift = {\n fileIndex: 0,\n nameIndex: 0,\n sourceLine: 1,\n sourceColumn: 1,\n generatedLine: 1,\n generatedColumn: 1\n };\n\n shift.generatedLine = mappings[0].generatedLine;\n resultMapping += ';'.repeat(shift.generatedLine - 1);\n\n for (const map of mappings) {\n if (map.generatedLine !== shift.generatedLine) {\n resultMapping += segments.join(',');\n resultMapping += ';'.repeat(Math.max(1, map.generatedLine - shift.generatedLine));\n\n segments = [];\n shift.generatedLine = map.generatedLine;\n shift.generatedColumn = 1;\n }\n\n this.encodeSegment(map, segments, shift);\n }\n\n return resultMapping + segments.join(',') + ';';\n }\n\n /**\n * Encodes a single segment of the mappings into VLQ format.\n *\n * This method processes a `MappingInterface` object and updates the list of encoded segments. It calculates the differences\n * between the current and previous mapping states, then encodes these differences using VLQ (Variable-Length Quantity) encoding.\n * The encoded segment is added to the provided `segments` array.\n *\n * The encoding process involves:\n * 1. Calculating the delta values for the file index, source line, source column, and generated column.\n * 2. Updating the `shift` state to reflect the current mapping information.\n * 3. Encoding the segment using VLQ and adding it to the `segments` array.\n *\n * @param map - The `MappingInterface` object representing a single mapping to encode. This object contains:\n * - `nameIndex`: The index in the names array.\n * - `fileIndex`: The index in the sources array.\n * - `sourceLine`: The line number in the original source code.\n * - `sourceColumn`: The column number in the original source code.\n * - `generatedColumn`: The column number in the generated code.\n * @param segments - An array of encoded segments that will be updated with the new encoded segment.\n * @param shift - The current state of the mapping information, including the latest file index, name index, source line,\n * source column, and generated column. This state is updated as new mappings are processed.\n *\n * @example\n * const map: MappingInterface = { nameIndex: 0, fileIndex: 1, sourceLine: 2, sourceColumn: 3, generatedLine: 1, generatedColumn: 4 };\n * const segments: Array<string> = [];\n * const shift: ShiftSegmentInterface = { fileIndex: 0, nameIndex: 0, sourceLine: 1, sourceColumn: 1, generatedLine: 1, generatedColumn: 1 };\n * this.encodeSegment(map, segments, shift);\n * console.log(segments); // Outputs the encoded VLQ segment\n *\n * @see MappingInterface for details on the mapping properties.\n * @see encodeArrayVLQ for the encoding function used.\n */\n\n\n\n private encodeSegment(map: MappingInterface, segments: Array<string>, shift: ShiftSegmentInterface): void {\n const segment: Array<number> = [];\n const sourceIndex = map.fileIndex;\n\n segment[1] = 0;\n segment[2] = map.sourceLine - shift.sourceLine;\n segment[3] = map.sourceColumn - shift.sourceColumn;\n segment[0] = map.generatedColumn - shift.generatedColumn;\n\n if (sourceIndex !== shift.fileIndex) {\n segment[1] = sourceIndex - shift.fileIndex;\n shift.fileIndex = sourceIndex;\n }\n\n if (map.nameIndex) {\n const nameIndex = map.nameIndex;\n segment[4] = nameIndex - shift.nameIndex;\n shift.nameIndex = nameIndex;\n }\n\n shift.sourceLine = map.sourceLine;\n shift.sourceColumn = map.sourceColumn;\n shift.generatedColumn = map.generatedColumn;\n segments.push(encodeArrayVLQ(segment));\n }\n\n /**\n * Determines whether a mapping should be skipped based on the specified file index.\n *\n * This function checks if the given mapping's file index matches the provided file index.\n * If the file index is not -1 (which indicates that filtering is desired),\n * the function returns true if the mapping's file index does not match the specified file index.\n *\n * @param mapping - The mapping object to evaluate.\n * @param fileIndex - The file index to compare against the mapping's file index.\n * A value of -1 indicates that no filtering should occur.\n *\n * @returns True if the mapping should be skipped, otherwise false.\n */\n\n private shouldSkipMapping(mapping: MappingInterface, fileIndex: number): boolean {\n return fileIndex !== -1 && mapping.fileIndex !== fileIndex;\n }\n\n /**\n * Retrieves the closest mapping from the mappings array based on the specified line and column.\n *\n * This function performs a binary search to find the mapping that corresponds to the given line and column\n * parameters. It takes into account the specified bias for the column in case of a tie in the line number,\n * and can also filter results by a specific file index if provided.\n *\n * @param line - The target line number to search for in the mappings.\n * @param column - The target column number to search for in the mappings.\n * @param bias - The bias to use when the line matches; it can be:\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 * @param fileIndex - The index of the file to filter the mappings by. If set to -1, no filtering is applied.\n * @param lineKey - The key to access the line number in the mapping object.\n * Can be either 'generatedLine' or 'sourceLine'.\n * @param columnKey - The key to access the column number in the mapping object.\n * Can be either 'generatedColumn' or 'sourceColumn'.\n *\n * @returns The closest matching MappingInterface object, or null if no matching mapping is found.\n */\n\n private retrieveMapping(\n line: number,\n column: number,\n bias: Bias = Bias.BOUND,\n fileIndex: number = -1,\n lineKey: 'generatedLine' | 'sourceLine' = 'generatedLine',\n columnKey: 'generatedColumn' | 'sourceColumn' = 'generatedColumn'\n ): MappingInterface | null {\n let startIndex = 0;\n let endIndex = this.mappings.length - 1;\n let closestMapping: MappingInterface | null = null;\n\n while (startIndex <= endIndex) {\n const middleIndex = Math.floor((startIndex + endIndex) / 2);\n const currentMapping = this.mappings[middleIndex];\n\n if (this.shouldSkipMapping(currentMapping, fileIndex)) {\n startIndex = middleIndex + 1;\n continue;\n }\n\n const currentLine = currentMapping[lineKey];\n const currentColumn = currentMapping[columnKey];\n\n if (currentLine < line) {\n startIndex = middleIndex + 1;\n } else if (currentLine > line) {\n endIndex = middleIndex - 1;\n } else {\n // Handle column bias when line matches\n if (currentColumn < column) {\n closestMapping = bias === Bias.LOWER_BOUND ? currentMapping : closestMapping;\n startIndex = middleIndex + 1;\n } else if (currentColumn > column) {\n closestMapping = bias === Bias.UPPER_BOUND ? currentMapping : closestMapping;\n endIndex = middleIndex - 1;\n } else {\n return currentMapping; // Exact match found\n }\n }\n }\n\n // Return the closest mapping if it matches the specified line\n return closestMapping && closestMapping[lineKey] === line ? closestMapping : null;\n }\n}\n"],
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,WAAAC,EAAA,kBAAAC,EAAA,cAAAC,EAAA,mBAAAC,EAAA,cAAAC,EAAA,eAAAC,EAAA,oBAAAC,EAAA,kBAAAC,EAAA,oBAAAC,IAAA,eAAAC,EAAAZ,GCaO,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,MAAMN,CAAS,GAAG,MAAM,CAAC,EAChD,GAAIW,EAAW,CACX,GAAM,CAAEC,EAAQC,EAAUC,EAAaC,EAAYC,CAAa,EAAIL,EACpEV,EAAM,KAAK,CACP,GAAAI,E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C,EAAaG,EAAc,EAC3B,QACJ,CAEA,IAAME,EAAcD,EAAeN,CAAO,EACpCQ,EAAgBF,EAAeL,CAAS,EAE9C,GAAIM,EAAc1C,EACdqC,EAAaG,EAAc,UACpBE,EAAc1C,EACrBsC,EAAWE,EAAc,UAGrBG,EAAgB1C,EAChBsC,EAAiBhC,IAAS,EAAmBkC,EAAiBF,EAC9DF,EAAaG,EAAc,UACpBG,EAAgB1C,EACvBsC,EAAiBhC,IAAS,EAAmBkC,EAAiBF,EAC9DD,EAAWE,EAAc,MAEzB,QAAOC,CAGnB,CAGA,OAAOF,GAAkBA,EAAeJ,CAAO,IAAMnC,EAAOuC,EAAiB,IACjF,CACJ",
|
|
6
|
-
"names": ["src_exports", "__export", "CodeHighlighter", "Colors", "SourceService", "decodeVLQ", "encodeArrayVLQ", "encodeVLQ", "formatCode", "formatErrorCode", "highlightCode", "parseErrorStack", "__toCommonJS", "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", "i", "continuation", "shifted", "formatCode", "code", "options", "lines", "padding", "startLine", "lineContent", "index", "currentLineNumber", "string", "formatErrorCode", "sourcePosition", "ansiOption", "errorLine", "errorColumn", "lineString", "line", "pointer", "ansiPadding", "prefixPointer", "errorMarker", "ts", "import_typescript", "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", "SourceService", "source", "sourceMap", "fileIndex", "line", "column", "options", "index", "str", "settings", "map", "bias", "maps", "lastSegment", "lines", "code", "endLine", "startLine", "input", "key", "encodedMappings", "thresholdSegment", "shift", "generatedLine", "stringSegments", "segments", "segment", "decodedSegment", "decodeVLQ", "error", "generatedColumn", "sourceLine", "sourceColumn", "nameIndex", "mappings", "resultMapping", "sourceIndex", "encodeArrayVLQ", "mapping", "lineKey", "columnKey", "startIndex", "endIndex", "closestMapping", "middleIndex", "currentMapping", "currentLine", "currentColumn"]
|
|
7
|
-
}
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Interface representing a source map object, which is used to map
|
|
3
|
-
* transformed or compiled code back to its original source.
|
|
4
|
-
* This is typically used in debugging to trace errors or logs in the
|
|
5
|
-
* compiled code back to the original source code.
|
|
6
|
-
*/
|
|
7
|
-
export interface SourceMapInterface {
|
|
8
|
-
/**
|
|
9
|
-
* The version of the source map specification.
|
|
10
|
-
* This field is a required number that indicates which version of the source map format is used.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* 3
|
|
14
|
-
*/
|
|
15
|
-
version: number;
|
|
16
|
-
/**
|
|
17
|
-
* The name of the generated file (bundle) that this source map applies to.
|
|
18
|
-
* This field is optional, and it might not always be present in the source map.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* "bundle.js"
|
|
22
|
-
*/
|
|
23
|
-
file?: string | null;
|
|
24
|
-
/**
|
|
25
|
-
* A VLQ (Variable-Length Quantity) encoded string representing the mapping information
|
|
26
|
-
* between the transformed code and the original source code. This field is mandatory
|
|
27
|
-
* and stores the actual mapping data in a compact format.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* "AAAA,QAASA,IAAIC;..."
|
|
31
|
-
*/
|
|
32
|
-
mappings: string;
|
|
33
|
-
/**
|
|
34
|
-
* A list of variable or function names used in the transformed code,
|
|
35
|
-
* corresponding to their references in the source code.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ["myFunction", "myVariable", "otherSymbol"]
|
|
39
|
-
*/
|
|
40
|
-
names: Array<string>;
|
|
41
|
-
/**
|
|
42
|
-
* An array of source file paths. Each path corresponds to a source file that was part of the original code,
|
|
43
|
-
* allowing for a reverse mapping to the source files.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ["src/file1.ts", "src/file2.ts"]
|
|
47
|
-
*/
|
|
48
|
-
sources: Array<string>;
|
|
49
|
-
/**
|
|
50
|
-
* An array of the contents of the source files, corresponding to the paths in the `sources` array.
|
|
51
|
-
* If available, this field allows viewing the original source code within the source map file.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ["function myFunction() {...}", "const myVariable = 10;"]
|
|
55
|
-
*/
|
|
56
|
-
sourcesContent: Array<string>;
|
|
57
|
-
/**
|
|
58
|
-
* An optional prefix that is added to the source file paths in the `sources` array.
|
|
59
|
-
* This is useful when the paths in the `sources` field are relative and need to be resolved
|
|
60
|
-
* against a common root directory. It helps organize and locate the original source files.
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* "/source/root"
|
|
64
|
-
*/
|
|
65
|
-
sourceRoot?: string | null;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Interface representing a mapping between generated and original source code.
|
|
69
|
-
* This is used to connect positions in the compiled/generated code to their
|
|
70
|
-
* corresponding positions in the original source code, allowing for debugging
|
|
71
|
-
* and error tracking.
|
|
72
|
-
*/
|
|
73
|
-
export interface MappingInterface {
|
|
74
|
-
/**
|
|
75
|
-
* The index in the `names` array that refers to a symbol (such as a function or variable name)
|
|
76
|
-
* in the original source. If there is no corresponding name, this will be `null`.
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* 3
|
|
80
|
-
*/
|
|
81
|
-
nameIndex: number | null;
|
|
82
|
-
/**
|
|
83
|
-
* The index in the `sources` array that refers to the file in which the original code is located.
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* 1
|
|
87
|
-
*/
|
|
88
|
-
fileIndex: number;
|
|
89
|
-
/**
|
|
90
|
-
* The line number in the original source code (1-based index).
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
* 25
|
|
94
|
-
*/
|
|
95
|
-
sourceLine: number;
|
|
96
|
-
/**
|
|
97
|
-
* The column number in the original source code (0-based index).
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* 12
|
|
101
|
-
*/
|
|
102
|
-
sourceColumn: number;
|
|
103
|
-
/**
|
|
104
|
-
* The line number in the generated (compiled/transpiled) code (1-based index).
|
|
105
|
-
*
|
|
106
|
-
* @example
|
|
107
|
-
* 32
|
|
108
|
-
*/
|
|
109
|
-
generatedLine: number;
|
|
110
|
-
/**
|
|
111
|
-
* The column number in the generated (compiled/transpiled) code (0-based index).
|
|
112
|
-
*
|
|
113
|
-
* @example
|
|
114
|
-
* 8
|
|
115
|
-
*/
|
|
116
|
-
generatedColumn: number;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Internal interface used to track the current state during decoding and encoding mappings.
|
|
120
|
-
* This interface keeps track of the current mapping segment and is primarily used in the
|
|
121
|
-
* process of transforming source maps. Not intended for external use.
|
|
122
|
-
*/
|
|
123
|
-
export interface ShiftSegmentInterface {
|
|
124
|
-
/**
|
|
125
|
-
* The index of the source file in the `sources` array.
|
|
126
|
-
*/
|
|
127
|
-
fileIndex: number;
|
|
128
|
-
/**
|
|
129
|
-
* The index of the name in the `names` array. May be `null` if there is no associated name.
|
|
130
|
-
*/
|
|
131
|
-
nameIndex: number;
|
|
132
|
-
/**
|
|
133
|
-
* The line number in the original source code.
|
|
134
|
-
*/
|
|
135
|
-
sourceLine: number;
|
|
136
|
-
/**
|
|
137
|
-
* The column number in the original source code.
|
|
138
|
-
*/
|
|
139
|
-
sourceColumn: number;
|
|
140
|
-
/**
|
|
141
|
-
* The line number in the generated code.
|
|
142
|
-
*/
|
|
143
|
-
generatedLine: number;
|
|
144
|
-
/**
|
|
145
|
-
* The column number in the generated code.
|
|
146
|
-
*/
|
|
147
|
-
generatedColumn: number;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Internal interface used to track offsets during source map concatenation.
|
|
151
|
-
* This interface helps handle transitions between different source maps
|
|
152
|
-
* and offsets. Not intended for external use.
|
|
153
|
-
*/
|
|
154
|
-
export interface ThresholdSegmentInterface {
|
|
155
|
-
/**
|
|
156
|
-
* Optional index of the source file in the `sources` array, used for tracking offsets.
|
|
157
|
-
*/
|
|
158
|
-
fileIndex?: number;
|
|
159
|
-
/**
|
|
160
|
-
* Optional index of the name in the `names` array, used for tracking name offsets.
|
|
161
|
-
*/
|
|
162
|
-
nameIndex?: number;
|
|
163
|
-
/**
|
|
164
|
-
* Optional line number in the generated code, used for tracking line offsets.
|
|
165
|
-
*/
|
|
166
|
-
generatedLine?: number;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Interface representing a position in the source code.
|
|
170
|
-
* This is used to pinpoint an exact location in the source code (line, column),
|
|
171
|
-
* along with the name and the file path (source) where the position occurs.
|
|
172
|
-
*/
|
|
173
|
-
export interface PositionInterface {
|
|
174
|
-
/**
|
|
175
|
-
* The line number in the source code (1-based index).
|
|
176
|
-
*/
|
|
177
|
-
line: number;
|
|
178
|
-
/**
|
|
179
|
-
* The column number in the source code (0-based index).
|
|
180
|
-
*/
|
|
181
|
-
column: number;
|
|
182
|
-
/**
|
|
183
|
-
* The name associated with this position, if any.
|
|
184
|
-
* If no name is associated, this will be `null`.
|
|
185
|
-
*/
|
|
186
|
-
name: string | null;
|
|
187
|
-
/**
|
|
188
|
-
* The path or name of the source file.
|
|
189
|
-
*/
|
|
190
|
-
source: string;
|
|
191
|
-
/**
|
|
192
|
-
* The root URL for the sources, if present in the source map.
|
|
193
|
-
*/
|
|
194
|
-
sourceRoot: string | null;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Interface representing a position in the source code with additional context.
|
|
198
|
-
* Extends `PositionInterface` by adding the actual code snippet and range information.
|
|
199
|
-
*/
|
|
200
|
-
export interface PositionSourceInterface extends PositionInterface {
|
|
201
|
-
/**
|
|
202
|
-
* A snippet of the actual code at this position.
|
|
203
|
-
*/
|
|
204
|
-
code: string;
|
|
205
|
-
/**
|
|
206
|
-
* The ending line number (1-based index) of the code range.
|
|
207
|
-
*/
|
|
208
|
-
endLine: number;
|
|
209
|
-
/**
|
|
210
|
-
* The starting line number (0-based index) of the code range.
|
|
211
|
-
*/
|
|
212
|
-
startLine: number;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Interface representing options for retrieving source positions.
|
|
216
|
-
* This interface defines options that can modify how source positions
|
|
217
|
-
* are retrieved, including bias settings and surrounding line context.
|
|
218
|
-
*/
|
|
219
|
-
export interface SourceOptionsInterface {
|
|
220
|
-
/**
|
|
221
|
-
* The bias option for controlling how mappings are searched.
|
|
222
|
-
* This determines how to handle ambiguities in the source map (e.g., when multiple mappings exist).
|
|
223
|
-
*/
|
|
224
|
-
bias?: Bias;
|
|
225
|
-
/**
|
|
226
|
-
* The number of lines after the target position to include for additional context.
|
|
227
|
-
*/
|
|
228
|
-
linesAfter?: number;
|
|
229
|
-
/**
|
|
230
|
-
* The number of lines before the target position to include for additional context.
|
|
231
|
-
*/
|
|
232
|
-
linesBefore?: number;
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Enumeration representing bias options for searching in mappings.
|
|
236
|
-
* This can control whether the search favors the closest lower-bound or upper-bound
|
|
237
|
-
* mapping when looking for a corresponding position in the source map.
|
|
238
|
-
*/
|
|
239
|
-
export declare const enum Bias {
|
|
240
|
-
/**
|
|
241
|
-
* No specific bias is applied when searching for a mapping.
|
|
242
|
-
*/
|
|
243
|
-
BOUND = 0,
|
|
244
|
-
/**
|
|
245
|
-
* Search for the closest lower-bound mapping.
|
|
246
|
-
*/
|
|
247
|
-
LOWER_BOUND = 1,
|
|
248
|
-
/**
|
|
249
|
-
* Search for the closest upper-bound mapping.
|
|
250
|
-
*/
|
|
251
|
-
UPPER_BOUND = 2
|
|
252
|
-
}
|