Файли
openidea/src/features/debugger/ui/sessionTabs.ts
T
ntbang0901 fdf29989ec feat(debugger): debug JavaScript that runs in the browser (#3294)
Code running in a browser could not be debugged: js-debug was only started for Node.js and launch.json entries of type chrome / msedge were skipped on import. A JavaScript Debug run configuration (URL, Chrome or Edge, web root) now opens the page with js-debug attached, so breakpoints in the page's sources are hit through source maps with the usual stepping, variables, evaluate and console. Each project gets its own browser profile under the IDE's local data, a project has one debugged browser of a kind (starting again reuses it), launch.json chrome / msedge launches import as this configuration, child sessions named about:blank take their parent's name, and Vue, Svelte, Astro and HTML files take breakpoints. Not yet available in remote projects.

Co-authored-by: ntbang0901 <[email protected]>
2026-11-14 13:49:21 +08:00

28 рядки
1.0 KiB
TypeScript

import { isBrowserLaunch } from "../browser";
import type { DebugSession } from "../state";
export interface SessionTab {
session: DebugSession;
/** The session the tab's close button ends: the tab's own, or the launch it stands for. */
owner: number;
/** Shown as a child of another tab's session. */
child: boolean;
}
/**
* One tab per debug session, except that a browser launch is one tab: js-debug runs it as an
* empty session for the launch and a child for the page, and only the page has anything to show.
*/
export function sessionTabs(sessions: readonly DebugSession[]): SessionTab[] {
const parents = new Set(sessions.map((s) => s.parent));
const launches = new Set(
sessions.filter((s) => s.parent == null && isBrowserLaunch(s.launch) && parents.has(s.id)).map((s) => s.id),
);
return sessions
.filter((s) => !launches.has(s.id))
.map((s) => {
const page = s.parent != null && launches.has(s.parent);
return { session: s, owner: page ? s.parent! : s.id, child: s.parent != null && !page };
});
}