@remotex-labs/xmap 1.0.0 → 1.0.2

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/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  function w(l){let e=l.split(`
2
- `).slice(1),n=/^\s*at\s+(.*?)\s+\((.*?):(\d+):(\d+)\)$|^\s*at\s+(.*?):(\d+):(\d+)$/,t=/eval\s+at\s+([^\s(]+).+\((.+):(\d+):(\d+)\),\s(.+)/,r=[];return e.forEach(s=>{let i=s.match(n);if(!i)return;let a=i.slice(1);i[2]||(a=i.slice(4));let[c,m,g,p]=a,h=parseInt(g,10),d=parseInt(p,10);if(s.includes("eval")){let S=m.match(t)?.slice(1);if(S){let[v,L,N,E,K]=S;r.push({at:c,file:K,line:h,column:d,executor:{at:v,file:L,line:parseInt(N,10),column:parseInt(E,10)}});return}}r.push({at:c||"<anonymous>",file:m,line:h,column:d,executor:null})}),r}var x={},y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");y.forEach((l,e)=>{x[l]=e});function A(l){let e=l<0,n="",t=e?(-l<<1)+1:l<<1;do{let r=t&31;t>>>=5,n+=y[r|(t>0?32:0)]}while(t>0);return n}function I(l){return l.map(A).join("")}function C(l){let e=[],n=0,t=0;for(let r=0;r<l.length;r++){let s=x[l[r]];if(s===void 0)throw new Error(`Invalid Base64 character: ${l[r]}`);let i=s&32;if(t+=(s&31)<<n,i)n+=5;else{let a=(t&1)===1,c=t>>1;e.push(a?-c:c),t=n=0}}return e}function M(l,e={}){let n=l.split(`
3
- `),t=e.padding??10,r=e.startLine??0;return n.map((s,i)=>{let a=i+r+1,m=`${`${a} | `.padStart(t)}${s}`;return e.action&&a===e.action.triggerLine?e.action.callback(m,t,a):m}).join(`
4
- `)}function $(l,e){let{code:n,line:t,column:r,startLine:s}=l;if(t<s||r<1)throw new Error("Invalid line or column number.");return M(n,{startLine:s,action:{triggerLine:t,callback:(i,a,c)=>{let m="^",g=a-1,p=">";e&&(m=`${e.color}${m}${e.reset}`,g+=e.color.length+e.reset.length,p=`${e.color}>${e.reset}`);let h=" | ".padStart(a)+" ".repeat(r-1)+`${m}`;return i=`${p} ${c} |`.padStart(g)+i.split("|")[1],i+`
5
- ${h}`}}})}import*as o from"typescript";import{SyntaxKind as u}from"typescript";var O=(d=>(d.reset="\x1B[0m",d.gray="\x1B[38;5;243m",d.darkGray="\x1B[38;5;238m",d.lightCoral="\x1B[38;5;203m",d.lightOrange="\x1B[38;5;215m",d.oliveGreen="\x1B[38;5;149m",d.burntOrange="\x1B[38;5;208m",d.lightGoldenrodYellow="\x1B[38;5;221m",d.lightYellow="\x1B[38;5;230m",d.canaryYellow="\x1B[38;5;227m",d.deepOrange="\x1B[38;5;166m",d.lightGray="\x1B[38;5;252m",d.brightPink="\x1B[38;5;197m",d))(O||{}),T={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"},f=class{constructor(e,n,t){this.sourceFile=e;this.code=n;this.schema=t}segments=new Map;parseNode(e){this.processComments(e),this.processKeywords(e),this.processNode(e)}highlight(){let e=0,n,t=[];return Array.from(this.segments.values()).sort((s,i)=>s.start-i.start||s.end-i.end).forEach(s=>{if(n&&s.start<n.end){let i=t.pop();if(!i)return;let a=this.getSegmentSource(s.start,s.end),c=`${s.color}${a}${n.color}`;t.push(i.replace(a,c));return}t.push(this.getSegmentSource(e,s.start)),t.push(`${s.color}${this.getSegmentSource(s.start,s.end)}${s.reset}`),e=s.end,n=s}),t.join("")+this.getSegmentSource(e)}getSegmentSource(e,n){return this.code.slice(e,n)}addSegment(e,n,t,r="\x1B[0m"){let s=`${e}-${n}`;this.segments.set(s,{start:e,end:n,color:t,reset:r})}processComments(e){[...o.getTrailingCommentRanges(this.sourceFile.getFullText(),e.getFullStart())||[],...o.getLeadingCommentRanges(this.sourceFile.getFullText(),e.getFullStart())||[]].forEach(t=>this.addSegment(t.pos,t.end,this.schema.commentColor))}processKeywords(e){if([u.NullKeyword,u.VoidKeyword,u.StringKeyword,u.NumberKeyword,u.BooleanKeyword,u.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 n=e.getEnd(),t=e.getStart();switch(e.parent.kind){case o.SyntaxKind.EnumMember:return this.addSegment(t,n,this.schema.enumColor);case o.SyntaxKind.CallExpression:case o.SyntaxKind.EnumDeclaration:case o.SyntaxKind.PropertySignature:case o.SyntaxKind.ModuleDeclaration:return this.addSegment(t,n,this.schema.variableColor);case o.SyntaxKind.InterfaceDeclaration:return this.addSegment(t,n,this.schema.interfaceColor);case o.SyntaxKind.GetAccessor:return this.addSegment(t,n,this.schema.getAccessorColor);case o.SyntaxKind.PropertyAssignment:return this.addSegment(t,n,this.schema.propertyAssignmentColor);case o.SyntaxKind.MethodSignature:return this.addSegment(t,n,this.schema.methodSignatureColor);case o.SyntaxKind.MethodDeclaration:case o.SyntaxKind.FunctionDeclaration:return this.addSegment(t,n,this.schema.functionColor);case o.SyntaxKind.ClassDeclaration:return this.addSegment(t,n,this.schema.classColor);case o.SyntaxKind.Parameter:return this.addSegment(t,n,this.schema.parameterColor);case o.SyntaxKind.VariableDeclaration:return this.addSegment(t,n,this.schema.variableColor);case o.SyntaxKind.PropertyDeclaration:return this.addSegment(t,n,this.schema.variableColor);case o.SyntaxKind.PropertyAccessExpression:return e.parent.getChildAt(0).getText()===e.getText()?this.addSegment(t,n,this.schema.variableColor):this.addSegment(t,n,this.schema.propertyAccessExpressionColor);case o.SyntaxKind.ExpressionWithTypeArguments:return this.addSegment(t,n,this.schema.expressionWithTypeArgumentsColor);case o.SyntaxKind.BreakStatement:case o.SyntaxKind.ShorthandPropertyAssignment:case o.SyntaxKind.BindingElement:return this.addSegment(t,n,this.schema.variableColor);case o.SyntaxKind.BinaryExpression:case o.SyntaxKind.SwitchStatement:case o.SyntaxKind.TemplateSpan:return this.addSegment(t,n,this.schema.variableColor);case o.SyntaxKind.TypeReference:case o.SyntaxKind.TypeAliasDeclaration:return this.addSegment(t,n,this.schema.typeColor);case o.SyntaxKind.NewExpression:return this.addSegment(t,n,this.schema.variableColor)}}processTemplateExpression(e){let n=e.head.getStart(),t=e.head.getEnd();this.addSegment(n,t,this.schema.stringColor),e.templateSpans.forEach(r=>{let s=r.literal.getStart(),i=r.literal.getEnd();this.addSegment(s,i,this.schema.stringColor)})}processNode(e){let n=e.getStart(),t=e.getEnd();switch(e.kind){case o.SyntaxKind.TypeParameter:return this.addSegment(n,n+e.name.text.length,this.schema.typeColor);case o.SyntaxKind.TypeReference:return this.addSegment(n,t,this.schema.typeColor);case o.SyntaxKind.StringLiteral:case o.SyntaxKind.NoSubstitutionTemplateLiteral:return this.addSegment(n,t,this.schema.stringColor);case o.SyntaxKind.RegularExpressionLiteral:return this.addSegment(n,t,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(n,t,this.schema.numericLiteralColor)}}};function U(l,e={}){let n=o.createSourceFile("temp.ts",l,o.ScriptTarget.Latest,!0,o.ScriptKind.TS),t=new f(n,l,Object.assign(T,e));function r(s){t.parseNode(s);for(let i=0;i<s.getChildCount();i++)r(s.getChildAt(i))}return o.forEachChild(n,r),t.highlight()}var b=class{names;sources;mappings;sourcesContent;constructor(e){this.validateSourceMap(e),this.names=e.names??[],this.sources=e.sources??[],this.mappings=[],this.sourcesContent=e.sourcesContent??[],this.decodeMappings(e)}getMapObject(){return{version:3,names:this.names,sources:this.sources,mappings:this.encodeMappings(this.mappings),sourcesContent:this.sourcesContent}}getSourcePosition(e,n,t){let r=Object.assign({bias:1,linesAfter:4,linesBefore:3},t),s=this.findMapping(e,n,r.bias);if(!s||isNaN(s.fileIndex))return null;let i=this.sourcesContent[s.fileIndex].split(`
2
+ `).slice(1),n=/^\s*at\s+(.*?)\s+\((.*?):(\d+):(\d+)\)$|^\s*at\s+(.*?):(\d+):(\d+)$/,t=/eval\s+at\s+([^\s(]+).+\((.+):(\d+):(\d+)\),\s(.+)/,r=[];return e.forEach(s=>{let i=s.match(n);if(!i)return;let a=i.slice(1);i[2]||(a=i.slice(4));let[c,u,g,p]=a,h=parseInt(g,10),d=parseInt(p,10);if(s.includes("eval")){let S=u.match(t)?.slice(1);if(S){let[v,L,N,E,K]=S;r.push({at:c,file:K,line:h,column:d,executor:{at:v,file:L,line:parseInt(N,10),column:parseInt(E,10)}});return}}r.push({at:c||"<anonymous>",file:u,line:h,column:d,executor:null})}),r}var x={},y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");y.forEach((l,e)=>{x[l]=e});function A(l){let e=l<0,n="",t=e?(-l<<1)+1:l<<1;do{let r=t&31;t>>>=5,n+=y[r|(t>0?32:0)]}while(t>0);return n}function I(l){return l.map(A).join("")}function C(l){let e=[],n=0,t=0;for(let r=0;r<l.length;r++){let s=x[l[r]];if(s===void 0)throw new Error(`Invalid Base64 character: ${l[r]}`);let i=s&32;if(t+=(s&31)<<n,i)n+=5;else{let a=(t&1)===1,c=t>>1;e.push(a?-c:c),t=n=0}}return e}function M(l,e={}){let n=l.split(`
3
+ `),t=e.padding??10,r=e.startLine??0;return n.map((s,i)=>{let a=i+r+1,u=`${`${a} | `.padStart(t)}${s}`;return e.action&&a===e.action.triggerLine?e.action.callback(u,t,a):u}).join(`
4
+ `)}function k(l,e){let{code:n,line:t,column:r,startLine:s}=l;if(t<s||r<1)throw new Error("Invalid line or column number.");return M(n,{startLine:s,action:{triggerLine:t,callback:(i,a,c)=>{let u="^",g=a-1,p=">";e&&(u=`${e.color}${u}${e.reset}`,g+=e.color.length+e.reset.length,p=`${e.color}>${e.reset}`);let h=" | ".padStart(a)+" ".repeat(r-1)+`${u}`;return i=`${p} ${c} |`.padStart(g)+i.split("|")[1],i+`
5
+ ${h}`}}})}import*as o from"typescript";import{SyntaxKind as m}from"typescript";var O=(d=>(d.reset="\x1B[0m",d.gray="\x1B[38;5;243m",d.darkGray="\x1B[38;5;238m",d.lightCoral="\x1B[38;5;203m",d.lightOrange="\x1B[38;5;215m",d.oliveGreen="\x1B[38;5;149m",d.burntOrange="\x1B[38;5;208m",d.lightGoldenrodYellow="\x1B[38;5;221m",d.lightYellow="\x1B[38;5;230m",d.canaryYellow="\x1B[38;5;227m",d.deepOrange="\x1B[38;5;166m",d.lightGray="\x1B[38;5;252m",d.brightPink="\x1B[38;5;197m",d))(O||{}),T={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"},f=class{constructor(e,n,t){this.sourceFile=e;this.code=n;this.schema=t}segments=new Map;parseNode(e){this.processComments(e),this.processKeywords(e),this.processNode(e)}highlight(){let e=0,n,t=[];return Array.from(this.segments.values()).sort((s,i)=>s.start-i.start||s.end-i.end).forEach(s=>{if(n&&s.start<n.end){let i=t.pop();if(!i)return;let a=this.getSegmentSource(s.start,s.end),c=`${s.color}${a}${n.color}`;t.push(i.replace(a,c));return}t.push(this.getSegmentSource(e,s.start)),t.push(`${s.color}${this.getSegmentSource(s.start,s.end)}${s.reset}`),e=s.end,n=s}),t.join("")+this.getSegmentSource(e)}getSegmentSource(e,n){return this.code.slice(e,n)}addSegment(e,n,t,r="\x1B[0m"){let s=`${e}-${n}`;this.segments.set(s,{start:e,end:n,color:t,reset:r})}processComments(e){[...o.getTrailingCommentRanges(this.sourceFile.getFullText(),e.getFullStart())||[],...o.getLeadingCommentRanges(this.sourceFile.getFullText(),e.getFullStart())||[]].forEach(t=>this.addSegment(t.pos,t.end,this.schema.commentColor))}processKeywords(e){if([m.NullKeyword,m.VoidKeyword,m.StringKeyword,m.NumberKeyword,m.BooleanKeyword,m.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 n=e.getEnd(),t=e.getStart();switch(e.parent.kind){case o.SyntaxKind.EnumMember:return this.addSegment(t,n,this.schema.enumColor);case o.SyntaxKind.CallExpression:case o.SyntaxKind.EnumDeclaration:case o.SyntaxKind.PropertySignature:case o.SyntaxKind.ModuleDeclaration:return this.addSegment(t,n,this.schema.variableColor);case o.SyntaxKind.InterfaceDeclaration:return this.addSegment(t,n,this.schema.interfaceColor);case o.SyntaxKind.GetAccessor:return this.addSegment(t,n,this.schema.getAccessorColor);case o.SyntaxKind.PropertyAssignment:return this.addSegment(t,n,this.schema.propertyAssignmentColor);case o.SyntaxKind.MethodSignature:return this.addSegment(t,n,this.schema.methodSignatureColor);case o.SyntaxKind.MethodDeclaration:case o.SyntaxKind.FunctionDeclaration:return this.addSegment(t,n,this.schema.functionColor);case o.SyntaxKind.ClassDeclaration:return this.addSegment(t,n,this.schema.classColor);case o.SyntaxKind.Parameter:return this.addSegment(t,n,this.schema.parameterColor);case o.SyntaxKind.VariableDeclaration:return this.addSegment(t,n,this.schema.variableColor);case o.SyntaxKind.PropertyDeclaration:return this.addSegment(t,n,this.schema.variableColor);case o.SyntaxKind.PropertyAccessExpression:return e.parent.getChildAt(0).getText()===e.getText()?this.addSegment(t,n,this.schema.variableColor):this.addSegment(t,n,this.schema.propertyAccessExpressionColor);case o.SyntaxKind.ExpressionWithTypeArguments:return this.addSegment(t,n,this.schema.expressionWithTypeArgumentsColor);case o.SyntaxKind.BreakStatement:case o.SyntaxKind.ShorthandPropertyAssignment:case o.SyntaxKind.BindingElement:return this.addSegment(t,n,this.schema.variableColor);case o.SyntaxKind.BinaryExpression:case o.SyntaxKind.SwitchStatement:case o.SyntaxKind.TemplateSpan:return this.addSegment(t,n,this.schema.variableColor);case o.SyntaxKind.TypeReference:case o.SyntaxKind.TypeAliasDeclaration:return this.addSegment(t,n,this.schema.typeColor);case o.SyntaxKind.NewExpression:return this.addSegment(t,n,this.schema.variableColor)}}processTemplateExpression(e){let n=e.head.getStart(),t=e.head.getEnd();this.addSegment(n,t,this.schema.stringColor),e.templateSpans.forEach(r=>{let s=r.literal.getStart(),i=r.literal.getEnd();this.addSegment(s,i,this.schema.stringColor)})}processNode(e){let n=e.getStart(),t=e.getEnd();switch(e.kind){case o.SyntaxKind.TypeParameter:return this.addSegment(n,n+e.name.text.length,this.schema.typeColor);case o.SyntaxKind.TypeReference:return this.addSegment(n,t,this.schema.typeColor);case o.SyntaxKind.StringLiteral:case o.SyntaxKind.NoSubstitutionTemplateLiteral:return this.addSegment(n,t,this.schema.stringColor);case o.SyntaxKind.RegularExpressionLiteral:return this.addSegment(n,t,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(n,t,this.schema.numericLiteralColor)}}};function D(l,e={}){let n=o.createSourceFile("temp.ts",l,o.ScriptTarget.Latest,!0,o.ScriptKind.TS),t=new f(n,l,Object.assign(T,e));function r(s){t.parseNode(s);for(let i=0;i<s.getChildCount();i++)r(s.getChildAt(i))}return o.forEachChild(n,r),t.highlight()}var b=class{file;sourceRoot;names;sources;mappings;sourcesContent;constructor(e){this.validateSourceMap(e),this.file=e.file??null,this.names=e.names??[],this.sources=e.sources??[],this.mappings=[],this.sourceRoot=e.sourceRoot??null,this.sourcesContent=e.sourcesContent??[],this.decodeMappings(e.mappings)}getMapObject(){let e={version:3,names:this.names,sources:this.sources,mappings:this.encodeMappings(this.mappings),sourcesContent:this.sourcesContent};return this.file&&(e.file=this.file),this.sourceRoot&&(e.sourceRoot=this.sourceRoot),e}getSourcePosition(e,n,t){let r=Object.assign({bias:1,linesAfter:4,linesBefore:3},t),s=this.findMapping(e,n,r.bias);if(!s||isNaN(s.fileIndex))return null;let i=this.sourcesContent[s.fileIndex].split(`
6
6
  `),a=(s.sourceLine??1)+r.linesAfter,c=Math.max((s.sourceLine??1)-r.linesBefore,0);return{code:i.slice(c,Math.min(a+1,i.length)).join(`
7
- `),line:s.sourceLine,column:s.sourceColumn,endLine:a,startLine:c,name:this.names[s.nameIndex??-1]??null,source:this.sources[s.fileIndex]}}getPosition(e,n,t=1){let r=this.findMapping(e,n,t);return r&&{line:r.sourceLine,column:r.sourceColumn,name:this.names[r.nameIndex??-1]??null,source:this.sources[r.fileIndex]}}concat(...e){if(e.length<1)throw new Error("At least one map must be provided for concatenation.");for(let n of e){this.names.push(...n.names),this.sources.push(...n.sources),this.sourcesContent.push(...n.sourcesContent);let t=this.mappings[this.mappings.length-1],r=this.sourcesContent[t.fileIndex].split(`
8
- `).length;this.decodeMappings(e[0],{nameIndex:this.names.length-1,fileIndex:this.sources.length-1,generatedLine:r<2?2:r})}}toString(){return JSON.stringify(this.getMapObject())}validateSourceMap(e){if(!["version","sources","sourcesContent","mappings","names"].every(t=>t in e))throw new Error("Missing required keys in SourceMap.")}decodeMappings(e,n){let t=Object.assign({fileIndex:0,nameIndex:0,sourceLine:1,sourceColumn:1,generatedLine:1,generatedColumn:1},n);try{for(let[r,s]of e.mappings.split(";").entries()){if(!s)continue;t.generatedColumn=1;let i=s.split(",");for(let a of i){if(a.length<4)continue;let c=C(a);this.decodedSegment(t,c,r+t.generatedLine)}}}catch(r){throw new Error(`Error decoding mappings: ${r.message}`)}}decodedSegment(e,n,t){let[r,s,i,a,c]=n;e.fileIndex+=s,e.nameIndex+=c??0,e.sourceLine+=i,e.sourceColumn+=a,e.generatedColumn+=r,this.mappings.push({nameIndex:c!==void 0?e.nameIndex:null,fileIndex:e.fileIndex,sourceLine:e.sourceLine,sourceColumn:e.sourceColumn,generatedLine:t,generatedColumn:e.generatedColumn})}encodeMappings(e){let n="",t=[],r={fileIndex:0,nameIndex:0,sourceLine:1,sourceColumn:1,generatedLine:1,generatedColumn:1};r.generatedLine=e[0].generatedLine,n+=";".repeat(r.generatedLine-1);for(let s of e)s.generatedLine!==r.generatedLine&&(n+=t.join(","),n+=";".repeat(Math.max(1,s.generatedLine-r.generatedLine)),t=[],r.generatedLine=s.generatedLine,r.generatedColumn=1),this.encodeSegment(s,t,r);return n+t.join(",")+";"}encodeSegment(e,n,t){let r=[],s=e.fileIndex;if(r[1]=0,r[2]=e.sourceLine-t.sourceLine,r[3]=e.sourceColumn-t.sourceColumn,r[0]=e.generatedColumn-t.generatedColumn,s!==t.fileIndex&&(r[1]=s-t.fileIndex,t.fileIndex=s),e.nameIndex){let i=e.nameIndex;r[4]=i-t.nameIndex,t.nameIndex=i}t.sourceLine=e.sourceLine,t.sourceColumn=e.sourceColumn,t.generatedColumn=e.generatedColumn,n.push(I(r))}findMapping(e,n,t=0){let r=0,s=this.mappings.length-1,i=null;for(;r<=s;){let a=Math.floor((r+s)/2),c=this.mappings[a];if(c.generatedLine<e)r=a+1;else if(c.generatedLine>e)s=a-1;else if(c.generatedColumn<n)r=a+1,t===1&&(i=c);else if(c.generatedColumn>n)s=a-1,t===2&&(i=c);else return c}return i&&i.generatedLine===e?i:null}};export{f as CodeHighlighter,O as Colors,b as SourceService,C as decodeVLQ,I as encodeArrayVLQ,A as encodeVLQ,M as formatCode,$ as formatErrorCode,U as highlightCode,w as parseErrorStack};
7
+ `),line:s.sourceLine,name:this.names[s.nameIndex??-1]??null,column:s.sourceColumn,endLine:a,startLine:c,source:this.sources[s.fileIndex],sourceRoot:this.sourceRoot}}getPosition(e,n,t=1){let r=this.findMapping(e,n,t);return r&&{line:r.sourceLine,name:this.names[r.nameIndex??-1]??null,column:r.sourceColumn,source:this.sources[r.fileIndex],sourceRoot:this.sourceRoot}}concat(...e){if(e.length<1)throw new Error("At least one map must be provided for concatenation.");for(let n of e){this.names.push(...n.names),this.sources.push(...n.sources),this.sourcesContent.push(...n.sourcesContent);let t=this.mappings[this.mappings.length-1],r=this.sourcesContent[t.fileIndex].split(`
8
+ `).length;this.decodeMappings(e[0].mappings,{nameIndex:this.names.length-1,fileIndex:this.sources.length-1,generatedLine:r<2?2:r})}}toString(){return JSON.stringify(this.getMapObject())}validateSourceMap(e){if(!["version","sources","sourcesContent","mappings","names"].every(t=>t in e))throw new Error("Missing required keys in SourceMap.")}decodeMappings(e,n){let t=Object.assign({fileIndex:0,nameIndex:0,sourceLine:1,sourceColumn:1,generatedLine:1,generatedColumn:1},n);try{for(let[r,s]of e.split(";").entries()){if(!s)continue;t.generatedColumn=1;let i=s.split(",");for(let a of i){if(a.length<4)continue;let c=C(a);this.decodedSegment(t,c,r+t.generatedLine)}}}catch(r){throw new Error(`Error decoding mappings: ${r.message}`)}}decodedSegment(e,n,t){let[r,s,i,a,c]=n;e.fileIndex+=s,e.nameIndex+=c??0,e.sourceLine+=i,e.sourceColumn+=a,e.generatedColumn+=r,this.mappings.push({nameIndex:c!==void 0?e.nameIndex:null,fileIndex:e.fileIndex,sourceLine:e.sourceLine,sourceColumn:e.sourceColumn,generatedLine:t,generatedColumn:e.generatedColumn})}encodeMappings(e){let n="",t=[],r={fileIndex:0,nameIndex:0,sourceLine:1,sourceColumn:1,generatedLine:1,generatedColumn:1};r.generatedLine=e[0].generatedLine,n+=";".repeat(r.generatedLine-1);for(let s of e)s.generatedLine!==r.generatedLine&&(n+=t.join(","),n+=";".repeat(Math.max(1,s.generatedLine-r.generatedLine)),t=[],r.generatedLine=s.generatedLine,r.generatedColumn=1),this.encodeSegment(s,t,r);return n+t.join(",")+";"}encodeSegment(e,n,t){let r=[],s=e.fileIndex;if(r[1]=0,r[2]=e.sourceLine-t.sourceLine,r[3]=e.sourceColumn-t.sourceColumn,r[0]=e.generatedColumn-t.generatedColumn,s!==t.fileIndex&&(r[1]=s-t.fileIndex,t.fileIndex=s),e.nameIndex){let i=e.nameIndex;r[4]=i-t.nameIndex,t.nameIndex=i}t.sourceLine=e.sourceLine,t.sourceColumn=e.sourceColumn,t.generatedColumn=e.generatedColumn,n.push(I(r))}findMapping(e,n,t=0){let r=0,s=this.mappings.length-1,i=null;for(;r<=s;){let a=Math.floor((r+s)/2),c=this.mappings[a];if(c.generatedLine<e)r=a+1;else if(c.generatedLine>e)s=a-1;else if(c.generatedColumn<n)r=a+1,t===1&&(i=c);else if(c.generatedColumn>n)s=a-1,t===2&&(i=c);else return c}return i&&i.generatedLine===e?i:null}};export{f as CodeHighlighter,O as Colors,b as SourceService,C as decodeVLQ,I as encodeArrayVLQ,A as encodeVLQ,M as formatCode,k as formatErrorCode,D as highlightCode,w as parseErrorStack};
9
9
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
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/services/source.service.ts"],
4
- "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 { 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 * 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 SourceService instance.\n *\n * @param source - The source map object to be validated.\n * @throws Error If any required key is missing from the source map.\n */\n\n constructor(source: SourceMapInterface) {\n this.validateSourceMap(source);\n\n this.names = source.names ?? [];\n this.sources = source.sources ?? [];\n this.mappings = [];\n this.sourcesContent = source.sourcesContent ?? [];\n this.decodeMappings(source);\n }\n\n /**\n * Returns a plain object representation of the source map data.\n *\n * This method creates a new object containing essential source map properties:\n * - `version`: The version of the source map (typically 3).\n * - `names`: An array of function or variable names from the original source code.\n * - `sources`: An array of source file names referenced in the mappings.\n * - `mappings`: A string representation of the encoded source map mappings. (Generated by `encodeMappings`)\n * - `sourcesContent`: An optional array containing the content of the source files. (May not be present in all source maps)\n *\n * @returns A plain object representing the source map data.\n */\n\n getMapObject(): SourceMapInterface {\n return {\n version: 3,\n names: this.names,\n sources: this.sources,\n mappings: this.encodeMappings(this.mappings),\n sourcesContent: this.sourcesContent\n };\n }\n\n /**\n * Retrieves source code information for a given line and column in the generated code.\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 configuration for retrieving source information.\n * linesBefore (default: 3) - Number of lines before the matching source line to include.\n * linesAfter (default: 4) - Number of lines after the matching source line to include.\n * includeSourceContent (default: false) - Flag to include the relevant source code snippet.\n * @returns An object containing source location information (line, column, name, source)\n * or including source code (code) if the includeSourceContent flag is set.\n * Returns null if no matching mapping is found.\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.findMapping(line, column, settings.bias);\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 column: map.sourceColumn,\n endLine: endLine,\n startLine: startLine,\n name:this.names[map.nameIndex ?? -1] ?? null,\n source: this.sources[map.fileIndex]\n };\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 * @param line - The line number in the generated code.\n * @param column - The column number in the generated code.\n * @param bias - An optional bias value specifying how to handle cases where only the line number matches. Defaults to Bias.LOWER_BOUND.\n * Bias.LOWER_BOUND: If the line number matches but the column is less, return the closest mapping with a lower column.\n * Bias.UPPER_BOUND: If the line number matches but the column is greater, return the closest mapping with a higher column.\n * Bias.BOUND: If the line number matches and the column doesn't, return null (default behavior).\n * @returns A PositionInterface object representing the position in the original source code, or null if no matching position is found.\n */\n\n getPosition(line: number, column: number, bias: Bias = Bias.LOWER_BOUND): PositionInterface | null {\n const map = this.findMapping(line, column, bias);\n if (!map) {\n return map;\n }\n\n return {\n line: map.sourceLine,\n column: map.sourceColumn,\n name: this.names[map.nameIndex ?? -1] ?? null,\n source: this.sources[map.fileIndex]\n };\n }\n\n /**\n * Merges multiple source maps into this source map object.\n * The order of the provided source maps must match the order in which the corresponding source files were concatenated.\n *\n * @param maps - An array of `SourceService` instances representing the source maps to be merged.\n * @throws Error - If no source maps are provided for concatenation.\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], {\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 base64 encoded string representation.\n *\n * This method performs the following steps:\n * 1. Creates a plain object representation of the source map using `getMapObject`.\n * 2. Convert the plain object to a JSON string using `JSON.stringify`.\n * 3. Encodes the JSON string using the `encode` function (assumed to be a base64 encoding function).\n *\n * @returns A string representing the source map.\n */\n\n toString(): string {\n return JSON.stringify(this.getMapObject());\n }\n\n /**\n * Validates the provided source map object.\n *\n * This private method throws an error if any of the required keys are missing from the source map.\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\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 encoded mappings.\n *\n * @param encodedMappings - The source map object to be decoded.\n * @param thresholdSegment\n */\n\n private decodeMappings(encodedMappings: SourceMapInterface, 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.mappings.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 segment and updates the mappings.\n *\n * @param shift - The current state of the mapping information.\n * @param decodedSegment - The decoded VLQ segment.\n * @param generatedLine - The current line index in the generated code.\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 the mappings into a VLQ string.\n *\n * @param mappings - An array of MappingInterface objects to encode.\n * @returns A VLQ-encoded string representing the mappings.\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.\n *\n * @param map - The MappingInterface object representing a single mapping.\n * @param segments - An array of encoded segments.\n * @param shift - The current state of the mapping information.\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 * Performs a binary search on the internal `mappings` array to find a mapping object based on the line and column information.\n * This function utilizes a binary search algorithm to efficiently locate the mapping corresponding to a specific line and column in the generated code.\n *\n * @param targetLine - The line number in the generated code to search for.\n * @param targetColumn - The column number in the generated code to search for.\n * @param bias - An optional bias value specifying how to handle cases where only the line number matches (DEFAULT: Bias.BOUND).\n * Bias.LOWER_BOUND: If the line number matches but the column is less, return the closest mapping with a lower column.\n * Bias.UPPER_BOUND: If the line number matches but the column is greater, return the closest mapping with a higher column.\n * Bias.BOUND: If the line number matches and the column doesn't, return null (default behavior).\n * @returns A MappingInterface object representing the found mapping, or null if no matching mapping is found based on the bias.\n */\n\n private findMapping(targetLine: number, targetColumn: number, bias: Bias = Bias.BOUND): 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 (currentMapping.generatedLine < targetLine) {\n startIndex = middleIndex + 1;\n } else if (currentMapping.generatedLine > targetLine) {\n endIndex = middleIndex - 1;\n } else {\n // The line matches, now we handle the column bias\n if (currentMapping.generatedColumn < targetColumn) {\n startIndex = middleIndex + 1;\n if (bias === Bias.LOWER_BOUND) {\n closestMapping = currentMapping;\n }\n } else if (currentMapping.generatedColumn > targetColumn) {\n endIndex = middleIndex - 1;\n if (bias === Bias.UPPER_BOUND) {\n closestMapping = currentMapping;\n }\n } else {\n return currentMapping;\n }\n }\n }\n\n // If the line doesn't match any mapping, return null\n return closestMapping && closestMapping.generatedLine === targetLine ? closestMapping : null;\n }\n}\n"],
5
- "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,EAA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aACtCI,EAAQ,CAAC,EAAIhB,EAAI,gBAAkBY,EAAM,gBAErCe,IAAgBf,EAAM,YACtBI,EAAQ,CAAC,EAAIW,EAAcf,EAAM,UACjCA,EAAM,UAAYe,GAGlB3B,EAAI,UAAW,CACf,IAAMwB,EAAYxB,EAAI,UACtBgB,EAAQ,CAAC,EAAIQ,EAAYZ,EAAM,UAC/BA,EAAM,UAAYY,CACtB,CAEAZ,EAAM,WAAaZ,EAAI,WACvBY,EAAM,aAAeZ,EAAI,aACzBY,EAAM,gBAAkBZ,EAAI,gBAC5Be,EAAS,KAAKa,EAAeZ,CAAO,CAAC,CACzC,CAeQ,YAAYa,EAAoBC,EAAsB1B,IAAkD,CAC5G,IAAI2B,EAAa,EACbC,EAAW,KAAK,SAAS,OAAS,EAClCC,EAA0C,KAE9C,KAAOF,GAAcC,GAAU,CAC3B,IAAME,EAAc,KAAK,OAAOH,EAAaC,GAAY,CAAC,EACpDG,EAAiB,KAAK,SAASD,CAAW,EAEhD,GAAIC,EAAe,cAAgBN,EAC/BE,EAAaG,EAAc,UACpBC,EAAe,cAAgBN,EACtCG,EAAWE,EAAc,UAGrBC,EAAe,gBAAkBL,EACjCC,EAAaG,EAAc,EACvB9B,IAAS,IACT6B,EAAiBE,WAEdA,EAAe,gBAAkBL,EACxCE,EAAWE,EAAc,EACrB9B,IAAS,IACT6B,EAAiBE,OAGrB,QAAOA,CAGnB,CAGA,OAAOF,GAAkBA,EAAe,gBAAkBJ,EAAaI,EAAiB,IAC5F,CACJ",
6
- "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", "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", "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", "SourceService", "source", "line", "column", "options", "settings", "map", "code", "endLine", "startLine", "bias", "maps", "lastSegment", "lines", "input", "key", "encodedMappings", "thresholdSegment", "shift", "generatedLine", "stringSegments", "segments", "segment", "decodedSegment", "decodeVLQ", "error", "generatedColumn", "fileIndex", "sourceLine", "sourceColumn", "nameIndex", "mappings", "resultMapping", "sourceIndex", "encodeArrayVLQ", "targetLine", "targetColumn", "startIndex", "endIndex", "closestMapping", "middleIndex", "currentMapping"]
4
+ "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 { 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 information about the original source code for a given line and column in the generated code.\n *\n * This method looks up the source code mappings to find the corresponding source location and provides additional context based on the provided options.\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 configuration for retrieving source information.\n * - `linesBefore` (default: 3): Number of lines before the matching source line to include in the context.\n * - `linesAfter` (default: 4): Number of lines after the matching source line to include in the context.\n * - `includeSourceContent` (default: false): Flag indicating whether to include the relevant source code snippet.\n * @returns An object containing source location information including:\n * - `line`: The line number in the original source code.\n * - `column`: The column number in the original source code.\n * - `endLine`: The end line number of the included source code snippet.\n * - `startLine`: The start line number of the included source code snippet.\n * - `name`: The function or variable name at the source position, or null if not available.\n * - `source`: The file name of the source code.\n * - `code` (if `includeSourceContent` is true): A snippet of the source code surrounding the specified line.\n *\n * @returns Null if no matching mapping is found.\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.findMapping(line, column, settings.bias);\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 * Retrieves the position information in the original source code for a given line and column in the generated code.\n *\n * This method locates the corresponding source code position 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 (default behavior).\n * @returns A `PositionInterface` object representing the position in the original source code, or `null` if no matching position is found.\n */\n\n getPosition(line: number, column: number, bias: Bias = Bias.LOWER_BOUND): PositionInterface | null {\n const map = this.findMapping(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 * 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 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 * Performs a binary search on the internal `mappings` array to locate a mapping based on the line and column information.\n * This method efficiently searches for a mapping that corresponds to a specific line and column in the generated code,\n * using binary search for improved performance.\n *\n * The method handles line and column matches and supports optional biasing to refine the search when an exact match is not found:\n * - **Bias.LOWER_BOUND**: 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. This is the default behavior.\n *\n * @param targetLine - The line number in the generated code to search for. This is the primary criterion for the search.\n * @param targetColumn - The column number in the generated code to search for. This is used in conjunction with the line number.\n * @param bias - An optional bias value to handle cases where only the line number matches. It influences how the column mismatch is resolved.\n * - `Bias.LOWER_BOUND`: Return the closest mapping with a lower column if the exact column is not found.\n * - `Bias.UPPER_BOUND`: Return the closest mapping with a higher column if the exact column is not found.\n * - `Bias.BOUND`: Return null if no exact column match is found. (Default behavior)\n * @returns A `MappingInterface` object representing the found mapping if an exact or biased match is found, or null if no appropriate mapping is located.\n *\n * @example\n * const targetLine = 10;\n * const targetColumn = 5;\n * const bias = Bias.UPPER_BOUND;\n * const result = this.findMapping(targetLine, targetColumn, bias);\n * console.log(result); // Outputs the found mapping or null if not found\n */\n\n private findMapping(targetLine: number, targetColumn: number, bias: Bias = Bias.BOUND): 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 (currentMapping.generatedLine < targetLine) {\n startIndex = middleIndex + 1;\n } else if (currentMapping.generatedLine > targetLine) {\n endIndex = middleIndex - 1;\n } else {\n // The line matches, now we handle the column bias\n if (currentMapping.generatedColumn < targetColumn) {\n startIndex = middleIndex + 1;\n if (bias === Bias.LOWER_BOUND) {\n closestMapping = currentMapping;\n }\n } else if (currentMapping.generatedColumn > targetColumn) {\n endIndex = middleIndex - 1;\n if (bias === Bias.UPPER_BOUND) {\n closestMapping = currentMapping;\n }\n } else {\n return currentMapping;\n }\n }\n }\n\n // If the line doesn't match any mapping, return null\n return closestMapping && closestMapping.generatedLine === targetLine ? closestMapping : null;\n }\n}\n"],
5
+ "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,EA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egex", "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", "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", "SourceService", "source", "sourceMap", "line", "column", "options", "settings", "map", "code", "endLine", "startLine", "bias", "maps", "lastSegment", "lines", "input", "key", "encodedMappings", "thresholdSegment", "shift", "generatedLine", "stringSegments", "segments", "segment", "decodedSegment", "decodeVLQ", "error", "generatedColumn", "fileIndex", "sourceLine", "sourceColumn", "nameIndex", "mappings", "resultMapping", "sourceIndex", "encodeArrayVLQ", "targetLine", "targetColumn", "startIndex", "endIndex", "closestMapping", "middleIndex", "currentMapping"]
7
7
  }
@@ -1,112 +1,252 @@
1
1
  /**
2
- * Interface representing a source map object.
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.
3
6
  */
4
7
  export interface SourceMapInterface {
5
8
  /**
6
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
7
14
  */
8
15
  version: number;
9
16
  /**
10
- * The bundle filename
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"
11
22
  */
12
- file?: string;
23
+ file?: string | null;
13
24
  /**
14
- * A string of base64 VLQ-encoded mappings.
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;..."
15
31
  */
16
32
  mappings: string;
17
33
  /**
18
- * A list of symbol names used by the “mappings” entry.
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"]
19
39
  */
20
40
  names: Array<string>;
21
41
  /**
22
- * An array of source file paths.
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"]
23
47
  */
24
48
  sources: Array<string>;
25
49
  /**
26
- * An array of contents of the source files.
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;"]
27
55
  */
28
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;
29
66
  }
30
67
  /**
31
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.
32
72
  */
33
73
  export interface MappingInterface {
34
74
  /**
35
- * The index in names array
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
36
80
  */
37
81
  nameIndex: number | null;
38
82
  /**
39
- * The file index in sources array
83
+ * The index in the `sources` array that refers to the file in which the original code is located.
84
+ *
85
+ * @example
86
+ * 1
40
87
  */
41
88
  fileIndex: number;
42
89
  /**
43
- * The line number in the original source code.
90
+ * The line number in the original source code (1-based index).
91
+ *
92
+ * @example
93
+ * 25
44
94
  */
45
95
  sourceLine: number;
46
96
  /**
47
- * The column number in the original source code.
97
+ * The column number in the original source code (0-based index).
98
+ *
99
+ * @example
100
+ * 12
48
101
  */
49
102
  sourceColumn: number;
50
103
  /**
51
- * The line number in the generated code.
104
+ * The line number in the generated (compiled/transpiled) code (1-based index).
105
+ *
106
+ * @example
107
+ * 32
52
108
  */
53
109
  generatedLine: number;
54
110
  /**
55
- * The column number in the generated code.
111
+ * The column number in the generated (compiled/transpiled) code (0-based index).
112
+ *
113
+ * @example
114
+ * 8
56
115
  */
57
116
  generatedColumn: number;
58
117
  }
59
118
  /**
60
119
  * Internal interface used to track the current state during decoding and encoding mappings.
61
- * This interface is not intended for external use.
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.
62
122
  */
63
123
  export interface ShiftSegmentInterface {
124
+ /**
125
+ * The index of the source file in the `sources` array.
126
+ */
64
127
  fileIndex: number;
128
+ /**
129
+ * The index of the name in the `names` array. May be `null` if there is no associated name.
130
+ */
65
131
  nameIndex: number;
132
+ /**
133
+ * The line number in the original source code.
134
+ */
66
135
  sourceLine: number;
136
+ /**
137
+ * The column number in the original source code.
138
+ */
67
139
  sourceColumn: number;
140
+ /**
141
+ * The line number in the generated code.
142
+ */
68
143
  generatedLine: number;
144
+ /**
145
+ * The column number in the generated code.
146
+ */
69
147
  generatedColumn: number;
70
148
  }
71
149
  /**
72
150
  * Internal interface used to track offsets during source map concatenation.
73
- * This interface is not intended for external use.
151
+ * This interface helps handle transitions between different source maps
152
+ * and offsets. Not intended for external use.
74
153
  */
75
154
  export interface ThresholdSegmentInterface {
155
+ /**
156
+ * Optional index of the source file in the `sources` array, used for tracking offsets.
157
+ */
76
158
  fileIndex?: number;
159
+ /**
160
+ * Optional index of the name in the `names` array, used for tracking name offsets.
161
+ */
77
162
  nameIndex?: number;
163
+ /**
164
+ * Optional line number in the generated code, used for tracking line offsets.
165
+ */
78
166
  generatedLine?: number;
79
167
  }
80
168
  /**
81
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.
82
172
  */
83
173
  export interface PositionInterface {
174
+ /**
175
+ * The line number in the source code (1-based index).
176
+ */
84
177
  line: number;
178
+ /**
179
+ * The column number in the source code (0-based index).
180
+ */
85
181
  column: number;
182
+ /**
183
+ * The name associated with this position, if any.
184
+ * If no name is associated, this will be `null`.
185
+ */
86
186
  name: string | null;
187
+ /**
188
+ * The path or name of the source file.
189
+ */
87
190
  source: string;
191
+ /**
192
+ * The root URL for the sources, if present in the source map.
193
+ */
194
+ sourceRoot: string | null;
88
195
  }
89
196
  /**
90
197
  * Interface representing a position in the source code with additional context.
198
+ * Extends `PositionInterface` by adding the actual code snippet and range information.
91
199
  */
92
200
  export interface PositionSourceInterface extends PositionInterface {
201
+ /**
202
+ * A snippet of the actual code at this position.
203
+ */
93
204
  code: string;
205
+ /**
206
+ * The ending line number (1-based index) of the code range.
207
+ */
94
208
  endLine: number;
209
+ /**
210
+ * The starting line number (0-based index) of the code range.
211
+ */
95
212
  startLine: number;
96
213
  }
97
214
  /**
98
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.
99
218
  */
100
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
+ */
101
224
  bias?: Bias;
225
+ /**
226
+ * The number of lines after the target position to include for additional context.
227
+ */
102
228
  linesAfter?: number;
229
+ /**
230
+ * The number of lines before the target position to include for additional context.
231
+ */
103
232
  linesBefore?: number;
104
233
  }
105
234
  /**
106
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.
107
238
  */
108
239
  export declare const enum Bias {
240
+ /**
241
+ * No specific bias is applied when searching for a mapping.
242
+ */
109
243
  BOUND = 0,
244
+ /**
245
+ * Search for the closest lower-bound mapping.
246
+ */
110
247
  LOWER_BOUND = 1,
248
+ /**
249
+ * Search for the closest upper-bound mapping.
250
+ */
111
251
  UPPER_BOUND = 2
112
252
  }
@@ -10,6 +10,14 @@ import { Bias } from './interfaces/source.interface';
10
10
  * A service for validating and processing source maps.
11
11
  */
12
12
  export declare class SourceService {
13
+ /**
14
+ * The name of the generated file (bundle) that this source map applies to.
15
+ */
16
+ readonly file: string | null;
17
+ /**
18
+ * The root URL for the sources, if present in the source map.
19
+ */
20
+ readonly sourceRoot: string | null;
13
21
  /**
14
22
  * A list of symbol names used by the “mappings” entry.
15
23
  */
@@ -27,121 +35,291 @@ export declare class SourceService {
27
35
  */
28
36
  private readonly sourcesContent;
29
37
  /**
30
- * Creates a new SourceService instance.
38
+ * Creates a new instance of the SourceService class.
31
39
  *
32
- * @param source - The source map object to be validated.
33
- * @throws Error If any required key is missing from the source map.
40
+ * This constructor initializes a `SourceService` instance using the provided source map object.
41
+ * It performs validation to ensure that the source map contains all required properties.
42
+ *
43
+ * @param source - An object conforming to the `SourceMapInterface` representing the source map to be validated and processed.
44
+ * @throws Error If any required property is missing from the source map object.
34
45
  */
35
46
  constructor(source: SourceMapInterface);
36
47
  /**
37
48
  * Returns a plain object representation of the source map data.
38
49
  *
39
- * This method creates a new object containing essential source map properties:
40
- * - `version`: The version of the source map (typically 3).
41
- * - `names`: An array of function or variable names from the original source code.
42
- * - `sources`: An array of source file names referenced in the mappings.
43
- * - `mappings`: A string representation of the encoded source map mappings. (Generated by `encodeMappings`)
44
- * - `sourcesContent`: An optional array containing the content of the source files. (May not be present in all source maps)
50
+ * This method constructs and returns an object that includes key properties of the source map:
51
+ * - `version`: The version of the source map specification (typically 3).
52
+ * - `file`: The name of the generated file (optional).
53
+ * - `names`: An array of function or variable names extracted from the original source code.
54
+ * - `sources`: An array of file paths for the source files referenced in the mappings.
55
+ * - `sourceRoot`: An optional root URL for resolving source file paths.
56
+ * - `mappings`: A base64 VLQ-encoded string representing the source map mappings, generated by `encodeMappings`.
57
+ * - `sourcesContent`: An optional array containing the content of the source files. This property may not be present in all source maps.
45
58
  *
46
- * @returns A plain object representing the source map data.
59
+ * @returns A plain object conforming to the `SourceMapInterface` structure,
60
+ * representing the source map data.
47
61
  */
48
62
  getMapObject(): SourceMapInterface;
49
63
  /**
50
- * Retrieves source code information for a given line and column in the generated code.
64
+ * Retrieves information about the original source code for a given line and column in the generated code.
65
+ *
66
+ * This method looks up the source code mappings to find the corresponding source location and provides additional context based on the provided options.
51
67
  *
52
68
  * @param line - The line number in the generated code.
53
69
  * @param column - The column number in the generated code.
54
70
  * @param options - Optional configuration for retrieving source information.
55
- * linesBefore (default: 3) - Number of lines before the matching source line to include.
56
- * linesAfter (default: 4) - Number of lines after the matching source line to include.
57
- * includeSourceContent (default: false) - Flag to include the relevant source code snippet.
58
- * @returns An object containing source location information (line, column, name, source)
59
- * or including source code (code) if the includeSourceContent flag is set.
60
- * Returns null if no matching mapping is found.
71
+ * - `linesBefore` (default: 3): Number of lines before the matching source line to include in the context.
72
+ * - `linesAfter` (default: 4): Number of lines after the matching source line to include in the context.
73
+ * - `includeSourceContent` (default: false): Flag indicating whether to include the relevant source code snippet.
74
+ * @returns An object containing source location information including:
75
+ * - `line`: The line number in the original source code.
76
+ * - `column`: The column number in the original source code.
77
+ * - `endLine`: The end line number of the included source code snippet.
78
+ * - `startLine`: The start line number of the included source code snippet.
79
+ * - `name`: The function or variable name at the source position, or null if not available.
80
+ * - `source`: The file name of the source code.
81
+ * - `code` (if `includeSourceContent` is true): A snippet of the source code surrounding the specified line.
82
+ *
83
+ * @returns Null if no matching mapping is found.
61
84
  */
62
85
  getSourcePosition(line: number, column: number, options?: SourceOptionsInterface): PositionSourceInterface | null;
63
86
  /**
64
87
  * Retrieves the position information in the original source code for a given line and column in the generated code.
65
88
  *
89
+ * This method locates the corresponding source code position based on the provided line and column in the generated code.
90
+ * It uses the specified bias to determine the best match when multiple mappings are possible.
91
+ *
66
92
  * @param line - The line number in the generated code.
67
93
  * @param column - The column number in the generated code.
68
- * @param bias - An optional bias value specifying how to handle cases where only the line number matches. Defaults to Bias.LOWER_BOUND.
69
- * Bias.LOWER_BOUND: If the line number matches but the column is less, return the closest mapping with a lower column.
70
- * Bias.UPPER_BOUND: If the line number matches but the column is greater, return the closest mapping with a higher column.
71
- * Bias.BOUND: If the line number matches and the column doesn't, return null (default behavior).
72
- * @returns A PositionInterface object representing the position in the original source code, or null if no matching position is found.
94
+ * @param bias - Optional parameter specifying how to handle cases where only the line number matches:
95
+ * - `Bias.LOWER_BOUND` (default): If the line number matches but the column is less, returns the closest mapping with a lower column.
96
+ * - `Bias.UPPER_BOUND`: If the line number matches but the column is greater, returns the closest mapping with a higher column.
97
+ * - `Bias.BOUND`: If the line number matches but the column doesn't, returns null (default behavior).
98
+ * @returns A `PositionInterface` object representing the position in the original source code, or `null` if no matching position is found.
73
99
  */
74
100
  getPosition(line: number, column: number, bias?: Bias): PositionInterface | null;
75
101
  /**
76
102
  * Merges multiple source maps into this source map object.
77
- * The order of the provided source maps must match the order in which the corresponding source files were concatenated.
103
+ * The order of the provided source maps must correspond to the order in which the source files were concatenated.
104
+ *
105
+ * This method appends the names, sources, and source contents from each provided source map to the current source map.
106
+ * It also adjusts the mappings to account for the concatenation of the source files.
78
107
  *
79
- * @param maps - An array of `SourceService` instances representing the source maps to be merged.
80
- * @throws Error - If no source maps are provided for concatenation.
108
+ * @param maps - An array of `SourceMapInterface` instances representing the source maps to be merged.
109
+ * @throws Error If no source maps are provided for concatenation.
110
+ *
111
+ * @example
112
+ * // Merging two source maps
113
+ * const map1: SourceMapInterface = { /* ... *\/ };
114
+ * const map2: SourceMapInterface = { /* ... *\/ };
115
+ * sourceMapService.concat(map1, map2);
81
116
  */
82
117
  concat(...maps: Array<SourceMapInterface>): void;
83
118
  /**
84
- * Converts the source map object to a base64 encoded string representation.
119
+ * Converts the source map object to a JSON string representation.
85
120
  *
86
121
  * This method performs the following steps:
87
- * 1. Creates a plain object representation of the source map using `getMapObject`.
88
- * 2. Convert the plain object to a JSON string using `JSON.stringify`.
89
- * 3. Encodes the JSON string using the `encode` function (assumed to be a base64 encoding function).
122
+ * 1. Creates a plain object representation of the source map using the `getMapObject` method.
123
+ * 2. Converts the plain object to a JSON string using `JSON.stringify`.
124
+ *
125
+ * @returns A JSON string representation of the source map.
90
126
  *
91
- * @returns A string representing the source map.
127
+ * @example
128
+ * const sourceMapString = sourceMapService.toString();
129
+ * // sourceMapString contains the JSON string representation of the source map.
92
130
  */
93
131
  toString(): string;
94
132
  /**
95
133
  * Validates the provided source map object.
96
134
  *
97
- * This private method throws an error if any of the required keys are missing from the source map.
135
+ * This method checks whether all required keys are present in the source map object.
136
+ * It throws an error if any required keys are missing.
98
137
  *
99
138
  * @private
100
139
  * @param input - The source map object to be validated.
101
140
  * @throws Error If any required key is missing from the source map.
141
+ *
142
+ * @example
143
+ * const sourceMap = {
144
+ * version: 3,
145
+ * file: 'example.js',
146
+ * names: ['src', 'maps', 'example', 'function', 'line', 'column'],
147
+ * sources: ['source1.js', 'source2.js'],
148
+ * mappings: 'AAAA,SAASA,CAAC,CAAC,CAAC;AAAA,CAAC,CAAC;AAAC,CAAC',
149
+ * sourcesContent: ['console.log("Hello world");', 'console.log("Another file");']
150
+ * };
151
+ *
152
+ * try {
153
+ * validateSourceMap(sourceMap);
154
+ * console.log('Source map is valid.');
155
+ * } catch (error) {
156
+ * console.error('Invalid source map:', error.message);
157
+ * }
102
158
  */
103
159
  private validateSourceMap;
104
160
  /**
105
- * Decodes and processes the encoded mappings.
161
+ * Decodes and processes the base64 VLQ-encoded mappings from a source map.
162
+ *
163
+ * This method interprets the encoded mappings from the `mappings` property of a source map. It adjusts
164
+ * the shift state for both generated and original positions in the source code, and processes each
165
+ * decoded mapping segment using the `decodedSegment` method.
166
+ *
167
+ * The decoding process involves:
168
+ * 1. Parsing the base64 VLQ-encoded mappings.
169
+ * 2. Adjusting the shift state based on the provided `thresholdSegment` or default values.
170
+ * 3. Handling each decoded mapping segment with the `decodedSegment` method.
106
171
  *
107
- * @param encodedMappings - The source map object to be decoded.
108
- * @param thresholdSegment
172
+ * @param encodedMappings - A string representing the encoded mappings in base64 VLQ format. This string
173
+ * is typically found in the `mappings` property of a source map.
174
+ * @param thresholdSegment - Optional. An object containing offset information that adjusts the starting
175
+ * point for decoding. This can include offsets for line, column, or file index.
176
+ * If not provided, default values are used.
177
+ * @throws Error - Throws an error if the decoding process encounters an issue, such as an invalid
178
+ * encoding or unexpected format.
179
+ *
180
+ * @example
181
+ * const encodedMappings = 'AAAA,CAAC,CAAC,CAAC,CAAC;AAAA,CAAC,CAAC,CAAC,CAAC';
182
+ * const threshold = {
183
+ * fileIndex: 0,
184
+ * nameIndex: 0,
185
+ * sourceLine: 1,
186
+ * sourceColumn: 1,
187
+ * generatedLine: 1,
188
+ * generatedColumn: 1
189
+ * };
190
+ * try {
191
+ * decodeMappings(encodedMappings, threshold);
192
+ * } catch (error) {
193
+ * console.error('Failed to decode mappings:', error.message);
194
+ * }
109
195
  */
110
196
  private decodeMappings;
111
197
  /**
112
- * Processes a decoded segment and updates the mappings.
198
+ * Processes a decoded VLQ segment and updates the mapping information.
199
+ *
200
+ * This method adjusts the current mapping state based on the decoded VLQ segment and the current
201
+ * line in the generated code. It then updates the internal mappings list with the new information.
202
+ *
203
+ * The decoding process involves:
204
+ * 1. Extracting the mapping details from the `decodedSegment` array.
205
+ * 2. Updating the shift values for file index, name index, source line, source column, and generated column.
206
+ * 3. Adding the processed mapping to the internal `mappings` array.
207
+ *
208
+ * @param shift - The current state of mapping information. This object tracks the cumulative state
209
+ * of file index, name index, source line, source column, and generated column.
210
+ * @param decodedSegment - An array representing the decoded VLQ segment, containing:
211
+ * - `generatedColumn`: The column number in the generated code.
212
+ * - `fileIndex`: The index in the sources array.
213
+ * - `sourceLine`: The line number in the original source code.
214
+ * - `sourceColumn`: The column number in the original source code.
215
+ * - `nameIndex`: The index in the names array.
216
+ * @param generatedLine - The line index in the generated code where this segment applies.
113
217
  *
114
- * @param shift - The current state of the mapping information.
115
- * @param decodedSegment - The decoded VLQ segment.
116
- * @param generatedLine - The current line index in the generated code.
218
+ * @example
219
+ * const shift = {
220
+ * fileIndex: 0,
221
+ * nameIndex: 0,
222
+ * sourceLine: 1,
223
+ * sourceColumn: 1,
224
+ * generatedLine: 1,
225
+ * generatedColumn: 1
226
+ * };
227
+ * const decodedSegment = [2, 1, 3, 4, 5];
228
+ * const generatedLine = 1;
229
+ * this.decodedSegment(shift, decodedSegment, generatedLine);
230
+ *
231
+ * @see ShiftSegmentInterface for details on the `shift` parameter.
232
+ * @see SourceMapInterface for details on the mapping properties.
117
233
  */
118
234
  private decodedSegment;
119
235
  /**
120
- * Encodes the mappings into a VLQ string.
236
+ * Encodes an array of mappings into a VLQ-encoded string representation.
237
+ *
238
+ * This method converts an array of `MappingInterface` objects into a base64 VLQ-encoded string,
239
+ * which is used in source maps to represent the mapping between generated and original source code positions.
240
+ *
241
+ * The encoding process involves:
242
+ * 1. Initializing the shift state to track the current line and column in the generated code.
243
+ * 2. Iterating through the mappings to group them by line number and encode each segment.
244
+ * 3. Concatenating encoded segments with the appropriate separator characters (`,` and `;`).
245
+ *
246
+ * @param mappings - An array of `MappingInterface` objects representing the mappings to encode. Each mapping object contains:
247
+ * - `nameIndex`: The index in the names array.
248
+ * - `fileIndex`: The index in the sources array.
249
+ * - `sourceLine`: The line number in the original source code.
250
+ * - `sourceColumn`: The column number in the original source code.
251
+ * - `generatedLine`: The line number in the generated code.
252
+ * - `generatedColumn`: The column number in the generated code.
253
+ * @returns A VLQ-encoded string representing the mappings, with segments separated by commas and lines by semicolons.
121
254
  *
122
- * @param mappings - An array of MappingInterface objects to encode.
123
- * @returns A VLQ-encoded string representing the mappings.
255
+ * @example
256
+ * const mappings = [
257
+ * { nameIndex: 0, fileIndex: 1, sourceLine: 2, sourceColumn: 3, generatedLine: 1, generatedColumn: 4 },
258
+ * { nameIndex: 1, fileIndex: 1, sourceLine: 3, sourceColumn: 4, generatedLine: 2, generatedColumn: 5 }
259
+ * ];
260
+ * const encodedMappings = this.encodeMappings(mappings);
261
+ * console.log(encodedMappings); // Outputs the VLQ-encoded string
262
+ *
263
+ * @see MappingInterface for details on the mapping properties.
124
264
  */
125
265
  private encodeMappings;
126
266
  /**
127
- * Encodes a single segment of the mappings.
267
+ * Encodes a single segment of the mappings into VLQ format.
268
+ *
269
+ * This method processes a `MappingInterface` object and updates the list of encoded segments. It calculates the differences
270
+ * between the current and previous mapping states, then encodes these differences using VLQ (Variable-Length Quantity) encoding.
271
+ * The encoded segment is added to the provided `segments` array.
272
+ *
273
+ * The encoding process involves:
274
+ * 1. Calculating the delta values for the file index, source line, source column, and generated column.
275
+ * 2. Updating the `shift` state to reflect the current mapping information.
276
+ * 3. Encoding the segment using VLQ and adding it to the `segments` array.
277
+ *
278
+ * @param map - The `MappingInterface` object representing a single mapping to encode. This object contains:
279
+ * - `nameIndex`: The index in the names array.
280
+ * - `fileIndex`: The index in the sources array.
281
+ * - `sourceLine`: The line number in the original source code.
282
+ * - `sourceColumn`: The column number in the original source code.
283
+ * - `generatedColumn`: The column number in the generated code.
284
+ * @param segments - An array of encoded segments that will be updated with the new encoded segment.
285
+ * @param shift - The current state of the mapping information, including the latest file index, name index, source line,
286
+ * source column, and generated column. This state is updated as new mappings are processed.
128
287
  *
129
- * @param map - The MappingInterface object representing a single mapping.
130
- * @param segments - An array of encoded segments.
131
- * @param shift - The current state of the mapping information.
288
+ * @example
289
+ * const map: MappingInterface = { nameIndex: 0, fileIndex: 1, sourceLine: 2, sourceColumn: 3, generatedLine: 1, generatedColumn: 4 };
290
+ * const segments: Array<string> = [];
291
+ * const shift: ShiftSegmentInterface = { fileIndex: 0, nameIndex: 0, sourceLine: 1, sourceColumn: 1, generatedLine: 1, generatedColumn: 1 };
292
+ * this.encodeSegment(map, segments, shift);
293
+ * console.log(segments); // Outputs the encoded VLQ segment
294
+ *
295
+ * @see MappingInterface for details on the mapping properties.
296
+ * @see encodeArrayVLQ for the encoding function used.
132
297
  */
133
298
  private encodeSegment;
134
299
  /**
135
- * Performs a binary search on the internal `mappings` array to find a mapping object based on the line and column information.
136
- * This function utilizes a binary search algorithm to efficiently locate the mapping corresponding to a specific line and column in the generated code.
300
+ * Performs a binary search on the internal `mappings` array to locate a mapping based on the line and column information.
301
+ * This method efficiently searches for a mapping that corresponds to a specific line and column in the generated code,
302
+ * using binary search for improved performance.
303
+ *
304
+ * The method handles line and column matches and supports optional biasing to refine the search when an exact match is not found:
305
+ * - **Bias.LOWER_BOUND**: If the line number matches but the column is less, returns the closest mapping with a lower column.
306
+ * - **Bias.UPPER_BOUND**: If the line number matches but the column is greater, returns the closest mapping with a higher column.
307
+ * - **Bias.BOUND**: If the line number matches but the column doesn't, returns null. This is the default behavior.
308
+ *
309
+ * @param targetLine - The line number in the generated code to search for. This is the primary criterion for the search.
310
+ * @param targetColumn - The column number in the generated code to search for. This is used in conjunction with the line number.
311
+ * @param bias - An optional bias value to handle cases where only the line number matches. It influences how the column mismatch is resolved.
312
+ * - `Bias.LOWER_BOUND`: Return the closest mapping with a lower column if the exact column is not found.
313
+ * - `Bias.UPPER_BOUND`: Return the closest mapping with a higher column if the exact column is not found.
314
+ * - `Bias.BOUND`: Return null if no exact column match is found. (Default behavior)
315
+ * @returns A `MappingInterface` object representing the found mapping if an exact or biased match is found, or null if no appropriate mapping is located.
137
316
  *
138
- * @param targetLine - The line number in the generated code to search for.
139
- * @param targetColumn - The column number in the generated code to search for.
140
- * @param bias - An optional bias value specifying how to handle cases where only the line number matches (DEFAULT: Bias.BOUND).
141
- * Bias.LOWER_BOUND: If the line number matches but the column is less, return the closest mapping with a lower column.
142
- * Bias.UPPER_BOUND: If the line number matches but the column is greater, return the closest mapping with a higher column.
143
- * Bias.BOUND: If the line number matches and the column doesn't, return null (default behavior).
144
- * @returns A MappingInterface object representing the found mapping, or null if no matching mapping is found based on the bias.
317
+ * @example
318
+ * const targetLine = 10;
319
+ * const targetColumn = 5;
320
+ * const bias = Bias.UPPER_BOUND;
321
+ * const result = this.findMapping(targetLine, targetColumn, bias);
322
+ * console.log(result); // Outputs the found mapping or null if not found
145
323
  */
146
324
  private findMapping;
147
325
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "Garefild",
7
- "version": "1.0.0",
7
+ "version": "1.0.2",
8
8
  "license": "Mozilla Public License Version 2.0",
9
9
  "description": "A library with a sourcemap parser and TypeScript code formatter for the CLI",
10
10
  "homepage": "https://github.com/remotex-lab/xMap",