@@ -2,7 +2,7 @@ import type { FastifyInstance } from 'fastify';
22import fastifyPlugin from 'fastify-plugin' ;
33import launchEditor from 'launch-editor' ;
44import open from 'open' ;
5- import { parseSourceFilename } from '../../utils/parseSourceFilename .js' ;
5+ import type { Server } from '../../types .js' ;
66
77interface OpenURLRequestBody {
88 url : string ;
@@ -21,7 +21,7 @@ function parseRequestBody<T>(body: unknown): T {
2121
2222async function devtoolsPlugin (
2323 instance : FastifyInstance ,
24- { rootDir } : { rootDir : string }
24+ { delegate } : { delegate : Server . Delegate }
2525) {
2626 // reference implementation in `@react-native-community/cli-server-api`:
2727 // https://github.com/react-native-community/cli/blob/46436a12478464752999d34ed86adf3212348007/packages/cli-server-api/src/openURLMiddleware.ts
@@ -42,7 +42,8 @@ async function devtoolsPlugin(
4242 url : '/open-stack-frame' ,
4343 handler : async ( request , reply ) => {
4444 const body = parseRequestBody < OpenStackFrameRequestBody > ( request . body ) ;
45- const filepath = parseSourceFilename ( body . file , rootDir ) ;
45+ const filepath =
46+ delegate . devTools ?. resolveProjectPath ( body . file ) ?? body . file ;
4647 launchEditor ( `${ filepath } :${ body . lineNumber } ` , process . env . REACT_EDITOR ) ;
4748 reply . send ( 'OK' ) ;
4849 } ,
0 commit comments