File size: 1,836 Bytes
fea495a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { codeFrameColumns } from 'next/dist/compiled/babel/code-frame';
import isInternal from '../../shared/lib/is-internal';
import { ignoreListAnonymousStackFramesIfSandwiched as ignoreListAnonymousStackFramesIfSandwichedGeneric } from '../../server/lib/source-maps';
export function ignoreListAnonymousStackFramesIfSandwiched(responses) {
    ignoreListAnonymousStackFramesIfSandwichedGeneric(responses, (response)=>{
        return response.status === 'fulfilled' && response.value.originalStackFrame !== null && response.value.originalStackFrame.file === '<anonymous>';
    }, (response)=>{
        return response.status === 'fulfilled' && response.value.originalStackFrame !== null && response.value.originalStackFrame.ignored === true;
    }, (response)=>{
        return response.status === 'fulfilled' && response.value.originalStackFrame !== null ? response.value.originalStackFrame.methodName : '';
    }, (response)=>{
        ;
        response.value.originalStackFrame.ignored = true;
    });
}
/**
 * It looks up the code frame of the traced source.
 * @note It ignores Next.js/React internals, as these can often be huge bundled files.
 */ export function getOriginalCodeFrame(frame, source, colors) {
    if (colors === void 0) colors = process.stdout.isTTY;
    if (!source || isInternal(frame.file)) {
        return null;
    }
    var _frame_line1, _frame_column1;
    return codeFrameColumns(source, {
        start: {
            // 1-based, but -1 means start line without highlighting
            line: (_frame_line1 = frame.line1) != null ? _frame_line1 : -1,
            // 1-based, but 0 means whole line without column highlighting
            column: (_frame_column1 = frame.column1) != null ? _frame_column1 : 0
        }
    }, {
        forceColor: colors
    });
}

//# sourceMappingURL=shared.js.map