@@ -114,6 +114,33 @@ export function isPluginDisable(meta: {
114
114
return false
115
115
}
116
116
117
+ export function setRouteMap ( filePath : string ) : string {
118
+ let routeMap = globalThis . TurboConsoleRouteMap
119
+
120
+ if ( typeof routeMap === 'undefined' )
121
+ routeMap = new Map < string , string > ( )
122
+
123
+ if ( routeMap . has ( filePath ) )
124
+ return routeMap . get ( filePath ) !
125
+
126
+ function getRandomString ( ) {
127
+ const randomString = Math . random ( ) . toString ( 20 ) . substring ( 2 , 6 )
128
+
129
+ for ( const [ _ , value ] of routeMap ) {
130
+ if ( value === randomString )
131
+ return getRandomString ( )
132
+ }
133
+
134
+ return randomString
135
+ }
136
+
137
+ const randomString = getRandomString ( )
138
+ routeMap . set ( filePath , randomString )
139
+ globalThis . TurboConsoleRouteMap = routeMap
140
+
141
+ return randomString
142
+ }
143
+
117
144
export function genConsoleString ( genContext : GenContext ) {
118
145
const { options, originalColumn, originalLine, argType, id } = genContext
119
146
let { argsName } = genContext
@@ -126,6 +153,9 @@ export function genConsoleString(genContext: GenContext) {
126
153
const fileName = getExtendedPath ( filePath , extendedPathFileNames )
127
154
const fileType = extname ( filePath )
128
155
156
+ const relativePath = relative ( cwd ( ) , filePath )
157
+ const routeMapString = setRouteMap ( relativePath )
158
+
129
159
// Parsing escaped unicode symbols
130
160
try {
131
161
argsName = JSON . parse ( `"${ argsName } "` )
@@ -139,9 +169,9 @@ export function genConsoleString(genContext: GenContext) {
139
169
140
170
// not output when argtype is string or number
141
171
const lineInfo = `%c🚀 ${ fileName } \u00B7${ originalLine } ${ [ 'StringLiteral' , 'NumericLiteral' ] . includes ( argType ) ? '' : ` ~ ${ argsName } ` } `
142
- const codePosition = `${ relative ( cwd ( ) , filePath ) } : ${ originalLine } : ${ ( originalColumn || 0 ) + 1 } `
172
+ const codePosition = `${ routeMapString } , ${ originalLine } , ${ ( originalColumn || 0 ) + 1 } `
143
173
144
- const launchEditorString = `%c🔦 http://localhost:${ port } #${ Buffer . from ( codePosition , 'utf-8' ) . toString ( 'base64' ) } `
174
+ const launchEditorString = `%c🔦 http://localhost:${ port } #${ codePosition } `
145
175
146
176
let consoleString = ''
147
177
0 commit comments