@@ -152,27 +152,42 @@ export class Frame {
152152 this . _evalAsync = isAsync ;
153153 this . _evalFunc = func ;
154154 }
155-
155+
156156 async _determineSourceInfo ( ) {
157- if ( this . _file === "<anonymous>" ) return ;
158- const [ livelyPath , srcPath ] = this . _file . split ( "/src/" ) ;
159- if ( ! this . _transpiled || ! srcPath ) {
160- this . _sourceLoc = { line : this . _line , column : this . _char , source : this . _file } ;
157+ const sourceMappingURL = this . sourceMapURL ( ) ;
158+ if ( ! sourceMappingURL || ! ( await lively . files . exists ( sourceMappingURL ) ) ) {
159+ if ( this . _file !== "<anonymous>" ) {
160+ this . _sourceLoc = { line : this . _line , column : this . _char , source : this . _file } ;
161+ }
161162 return ;
162- }
163- const sourceMappingURL = livelyPath + "/.transpiled/" + ( "src/" + srcPath ) . replaceAll ( "/" , "_" ) + ".map.json" ;
163+ }
164+
164165 var sourceMap = await sourceMappingURL . fetchJSON ( ) ;
165166 var smc = sourcemap . SourceMapConsumer ( sourceMap ) ;
166167 this . _sourceLoc = smc . originalPositionFor ( {
167168 line : parseInt ( this . _line ) ,
168169 column : parseInt ( this . _char )
169170 } ) ;
170171 }
171-
172+
173+ sourceMapURL ( ) {
174+ if ( this . _file === "<anonymous>" ) return ;
175+
176+ const [ livelyPath , srcPath ] = this . _file . split ( "/src/" ) ;
177+
178+ if ( ! srcPath ) {
179+ return ;
180+ }
181+
182+ const sourceMappingURL = livelyPath + "/.transpiled/" + ( "src/" + srcPath ) . replaceAll ( "/" , "_" ) + ".map.json" ;
183+ return sourceMappingURL ;
184+ }
185+
172186 /*MD ## func MD*/
173187 /**
174188 * returns Bool
175189 */
190+
176191 get async ( ) {
177192 return this . _async || false ;
178193 }
@@ -201,32 +216,32 @@ export class Frame {
201216 get char ( ) {
202217 return this . _char ;
203218 }
204-
219+
205220 async getSourceLocBabelStyle ( ) {
206- if ( ! this . _sourceLoc ) {
221+ if ( ! this . _sourceLoc ) {
207222 await this . _determineSourceInfo ( ) ;
208- if ( ! this . _sourceLoc ) return undefined ;
223+ if ( ! this . _sourceLoc ) return undefined ;
209224 }
210- const location = { line : this . _sourceLoc . line , column : this . _sourceLoc . column } ;
211- return { start : location , end : location , file : this . _sourceLoc . source } ;
225+ const location = { line : this . _sourceLoc . line , column : this . _sourceLoc . column } ;
226+ return { start : location , end : location , file : this . _sourceLoc . source } ;
212227 }
213-
228+
214229 async getSourceLoc ( ) {
215- if ( ! this . _sourceLoc ) {
230+ if ( ! this . _sourceLoc ) {
216231 await this . _determineSourceInfo ( ) ;
217232 }
218233 return this . _sourceLoc ;
219234 }
220-
235+
221236 async getSourceLine ( ) {
222- if ( ! this . _sourceLoc . line ) {
237+ if ( ! this . _sourceLoc . line ) {
223238 await this . _determineSourceInfo ( ) ;
224239 }
225240 return this . _sourceLoc . line ;
226241 }
227-
242+
228243 async getSourceChar ( ) {
229- if ( ! this . _sourceLoc . character ) {
244+ if ( ! this . _sourceLoc . character ) {
230245 await this . _determineSourceInfo ( ) ;
231246 }
232247 return this . _sourceLoc . column ;
0 commit comments