MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / remapFrame

Function remapFrame

packages/core/inspector_modules.ts:138–180  ·  view source on GitHub ↗
(file: string, line: number, column: number)

Source from the content-addressed store, hash-verified

136}
137
138function 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
182function remapStack(raw: string): string {
183 const lines = raw.split('\n');

Callers 1

remapStackFunction · 0.85

Calls 4

loadAndExtractMapFunction · 0.85
getConsumerFunction · 0.85
replaceMethod · 0.80
existsMethod · 0.45

Tested by

no test coverage detected