<commit_before>import * as vs from "vscode";
import { Event, EventEmitter } from "../../../shared/events";
import { firstNonEditorColumn } from "../../../shared/vscode/utils";
import { DartDebugSessionInformation } from "../../utils/vscode/debug";

const devToolsPageNames: { [key: string]: string } = {
	inspector: "Flutter Widget Inspector",
	memory: "Flutter Memory View",
	performance: "Flutter Performance View",
	timeline: "Flutter Timeline",
};

const pageScript = `
window.addEventListener('message', (event) => {
	const message = event.data;
	const devToolsFrame = document.getElementById('devToolsFrame');
	switch (message.command) {
		case "setUrl":
			const theme = document.body.classList.contains('vscode-light') ? 'light': 'dark';
			const background = getComputedStyle(document.documentElement).getPropertyValue('--vscode-editor-background');
			const url = \`\${message.url}&theme=\${theme}&background=\${background}\`;
			if (devToolsFrame.src !== url)
				devToolsFrame.src = url;
			break;
	}
});
`;

const scriptNonce = Buffer.from(pageScript).toString("base64");
const frameCss = "position: absolute; top: 0; left: 0; width: 100%; height: 100%";
const cssNonce = Buffer.from(frameCss).toString("base64");

export class DevToolsEmbeddedView {
	private readonly panel: vs.WebviewPanel;
	private onDisposeEmitter: EventEmitter<void> = new EventEmitter<void>();
	public readonly onDispose: Event<void> = this.onDisposeEmitter.event;

	constructor(public session: DartDebugSessionInformation, readonly devToolsUri: vs.Uri, readonly page: string) {
		const pageName = devToolsPageNames[page] || "Dart DevTools";<commit_msg>Include foreground colour + add encoding<commit_after>import * as vs from "vscode";
import { Event, EventEmitter } from "../../../shared/events";
import { firstNonEditorColumn } from "../../../shared/vscode/utils";
import { DartDebugSessionInformation } from "../../utils/vscode/debug";

const devToolsPageNames: { [key: string]: string } = {
	inspector: "Flutter Widget Inspector",
	memory: "Flutter Memory View",
	performance: "Flutter Performance View",
	timeline: "Flutter Timeline",
};

const pageScript = `
window.addEventListener('message', (event) => {
	const message = event.data;
	const devToolsFrame = document.getElementById('devToolsFrame');
	switch (message.command) {
		case "setUrl":
			const theme = document.body.classList.contains('vscode-light') ? 'light': 'dark';
			const background = getComputedStyle(document.documentElement).getPropertyValue('--vscode-editor-background');
			const foreground = getComputedStyle(document.documentElement).getPropertyValue('--vscode-editor-foreground');
			const url = \`\${message.url}&theme=\${theme}&background=\${encodeURIComponent(background)}&foreground=\${encodeURIComponent(foreground)}\`;
			if (devToolsFrame.src !== url)
				devToolsFrame.src = url;
			break;
	}
});
`;

const scriptNonce = Buffer.from(pageScript).toString("base64");
const frameCss = "position: absolute; top: 0; left: 0; width: 100%; height: 100%";
const cssNonce = Buffer.from(frameCss).toString("base64");

export class DevToolsEmbeddedView {
	private readonly panel: vs.WebviewPanel;
	private onDisposeEmitter: EventEmitter<void> = new EventEmitter<void>();
	public readonly onDispose: Event<void> = this.onDisposeEmitter.event;

	constructor(public session: DartDebugSessionInformation, readonly devToolsUri: vs.Uri, readonly page: string) {
		const pageName = devToolsPageNames[page] || "Dart DevTools";
{'fraction_non_alphanumeric': 0.15011481056257175, 'fraction_numerical': 0.006888633754305396, 'mean_word_length': 5.6254752851711025, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2641065', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1036, 'n_words': 242}