function resolveFrame
resolveFrame(
frame: string,
projectRoot: string
):
{ resolved: string; userPath: string | null; sourceText: string | null; }
| null

Attempts to resolve a single stack-frame line to its original source location. Handles Chrome named (at FUNC (URL:L:C)), Chrome anonymous (at [async] URL:L:C), and Firefox/WebKit (FUNC@URL:L:C) formats.

Returns { resolved, userPath, sourceText } when the frame is from a test bundle and the position can be mapped; null otherwise (caller keeps the original frame). userPath and sourceText are non-null only when the resolved source is outside node_modules/.

import * as SourceMap from './source-map.ts';

const decoder = SourceMap.parse('{"sources":["../test/login-test.ts"],"mappings":"AAAA"}', '/proj/tmp');

SourceMap.resolveFrame('    at http://localhost:7357/tests.js:1:1', decoder, '/proj');
// { resolved: '    at test/login-test.ts:1:1', userPath: 'test/login-test.ts:1:1', sourceText: null }
SourceMap.resolveFrame('    at native code', decoder, '/proj'); // null — kept verbatim by the caller

Parameters

frame: string
projectRoot: string

Return Type

{ resolved: string; userPath: string | null; sourceText: string | null; }
| null

Usage

import { resolveFrame } from "lib/utils/source-map.ts";