MCPcopy
hub / github.com/angular/angular / errorFilenameHandler

Function errorFilenameHandler

adev/src/app/editor/error-filename-handler.ts:11–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9import {WebContainer} from '@webcontainer/api';
10
11function errorFilenameHandler() {
12 const originalFetch = window.fetch;
13 window.fetch = async (input, init) => {
14 const url = input.toString();
15 if (url.includes('__open-in-editor')) {
16 const params = new URLSearchParams(url.split('?')[1]);
17 const file = params.get('file');
18 if (file) {
19 const [filepath, line, column] = file.split(':');
20 window.parent.postMessage(
21 {
22 type: 'openFileAtLocation',
23 file: filepath,
24 line: parseInt(line, 10),
25 character: parseInt(column, 10),
26 },
27 '*',
28 );
29 }
30 return new Response(null, {status: 200});
31 }
32 return originalFetch(input, init);
33 };
34}
35
36export async function setupErrorFilenameHandler(webContainer: WebContainer): Promise<void> {
37 await webContainer.setPreviewScript(`(${errorFilenameHandler.toString()})()`);

Callers

nothing calls this directly

Calls 3

toStringMethod · 0.65
getMethod · 0.65
postMessageMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…