(file: string, line: number, column: number)
| 136 | } |
| 137 | |
| 138 | function remapFrame(file: string, line: number, column: number) { |
| 139 | /** |
| 140 | * bundlers can use source map files or inline. |
| 141 | * To use source map files, run with `--env.sourceMap=source-map`. |
| 142 | * Notes: |
| 143 | * Starting with @nativescript/webpack 5.0.25, `source-map` files are used by default when using runtimes v9+. |
| 144 | */ |
| 145 | |
| 146 | const appPath = knownFolders.currentApp().path; |
| 147 | let sourceMapFileExt = ''; |
| 148 | if (usingSourceMapFiles) { |
| 149 | sourceMapFileExt = '.map'; |
| 150 | } |
| 151 | const rel = file.replace('file:///app/', ''); |
| 152 | const jsPath = `${appPath}/${rel}`; |
| 153 | let mapPath = `${jsPath}${sourceMapFileExt}`; // default: same name + .map |
| 154 | |
| 155 | // Fallback: if .mjs.map missing, try .js.map |
| 156 | if (!File.exists(mapPath) && rel.endsWith('.mjs')) { |
| 157 | const jsMapFallback = `${appPath}/${rel.replace(/\.mjs$/, '.js.map')}`; |
| 158 | if (File.exists(jsMapFallback)) { |
| 159 | mapPath = jsMapFallback; |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | const sourceMap = loadAndExtractMap(mapPath, jsPath); |
| 164 | |
| 165 | if (!sourceMap) { |
| 166 | return { source: null, line: 0, column: 0 }; |
| 167 | } |
| 168 | |
| 169 | const consumer = getConsumer(mapPath, sourceMap); |
| 170 | if (!consumer) { |
| 171 | return { source: null, line: 0, column: 0 }; |
| 172 | } |
| 173 | |
| 174 | try { |
| 175 | return consumer.originalPositionFor({ line, column }); |
| 176 | } catch (error) { |
| 177 | console.debug && console.debug(`Remap failed for ${file}:${line}:${column}:`, error); |
| 178 | return { source: null, line: 0, column: 0 }; |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | function remapStack(raw: string): string { |
| 183 | const lines = raw.split('\n'); |
no test coverage detected