/** * VS Code Theme Bridge * * Maps VS Code CSS custom properties to Plannotator's CSS variable system. * Used by the cookie proxy to inject a theme listener into the webview iframe, * and by the panel manager to read+send theme tokens from the wrapper page. */ // Each VS Code CSS variable can map to multiple Plannotator variables // (e.g., editor foreground → foreground, card-foreground, popover-foreground). const TOKEN_PAIRS: [string, string][] = [ ["--vscode-editor-background", "--background"], ["--vscode-editor-foreground", "--foreground"], ["--vscode-sideBar-background", "--card"], ["--vscode-editor-foreground", "--card-foreground"], ["--vscode-editorWidget-background", "--popover"], ["--vscode-editor-foreground", "--popover-foreground"], ["--vscode-button-background", "--primary"], ["--vscode-button-foreground", "--primary-foreground"], ["--vscode-input-background", "--input"], ["--vscode-panel-border", "--border"], ["--vscode-focusBorder", "--ring"], ["--vscode-errorForeground", "--destructive"], ["--vscode-testing-iconPassed", "--success"], ["--vscode-editorWarning-foreground", "--warning"], ["--vscode-textLink-foreground", "--accent"], ["--vscode-descriptionForeground", "--muted-foreground"], ]; /** VS Code variable names the wrapper page needs to read */ export const VSCODE_VARS = [...new Set(TOKEN_PAIRS.map(([v]) => v))]; /** * Returns inline JS for the wrapper page (panel-manager.ts). * Reads VS Code CSS variables and posts them to the iframe. */ export function buildWrapperThemeScript(): string { const varsJson = JSON.stringify(VSCODE_VARS); return ``; } /** * Returns inline JS injected into the iframe HTML (via cookie proxy). * Listens for theme messages from the wrapper and applies CSS overrides. */ export function buildThemeListenerScript(): string { const pairsJson = JSON.stringify(TOKEN_PAIRS); return ``; }