Skip to content

Commit

Permalink
fixes after advice
Browse files Browse the repository at this point in the history
  • Loading branch information
filip131311 committed Oct 24, 2024
1 parent 4ae25c0 commit 198c91c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
9 changes: 0 additions & 9 deletions packages/vscode-extension/lib/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ global.__RNIDE_onDebuggerReady = function () {
global.__fbDisableExceptionsManager = true;
};

try{
// if debugger is already connected it will run "__RNIDE_onDebuggerReady"
// if not it will run "__RNIDE_onDebuggerReady" on execution context creation
global.__RNIDE_onRuntimeLoaded(""); // the argument is required by CDP
}catch(e){
// we ignore the error here because it means, debugger was not connected yet.
}


// We add log this trace to diagnose issues with loading runtime in the IDE
// The first argument is "__RNIDE_INTERNAL" so we can filter it out in
// debug adapter and avoid exposing as part of application logs
Expand Down
20 changes: 4 additions & 16 deletions packages/vscode-extension/src/debugging/DebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,27 +137,15 @@ export class DebugAdapter extends DebugSession {
const threadName = context.name;
this.sendEvent(new ThreadEvent("started", threadId));
this.threads.push(new Thread(threadId, threadName));
this.sendCDPMessage("Runtime.evaluate", {
expression: "__RNIDE_onDebuggerReady()",
});
// because in the debugger shipped with RN 76 an newer execution context
// is created before runtime is loaded, we inject the __RNIDE_onRuntimeLoaded
// binding in order to alow runtime triggering __RNIDE_onDebuggerReady()
// after debugger was already connected.
this.sendCDPMessage("Runtime.addBinding", {
name: "__RNIDE_onRuntimeLoaded",
});

break;
case "Runtime.bindingCalled":
if ((message.params.name = "__RNIDE_onRuntimeLoaded")) {
case "Debugger.scriptParsed":
const sourceMapURL = message.params.sourceMapURL;

if (message.params.url) {
this.sendCDPMessage("Runtime.evaluate", {
expression: "__RNIDE_onDebuggerReady()",
});
}
break;
case "Debugger.scriptParsed":
const sourceMapURL = message.params.sourceMapURL;

if (sourceMapURL?.startsWith("data:")) {
const base64Data = sourceMapURL.split(",")[1];
Expand Down

0 comments on commit 198c91c

Please sign in to comment.