import { PANEL_PING_TYPE, PANEL_PONG_TYPE } from './plugin-panel-bridge' /** Prepend CSP before any untrusted panel HTML: opaque origins alone still permit CORS fetch/beacons. Parsed CSP survives * DOM removal and later CSP can only tighten it. Open head/html exposes design tokens to plugin CSS. * Shared Electron-free builder keeps desktop and serve wrapping identical. */ export const PLUGIN_PANEL_CSP = "default-src 'none'; connect-src 'none'; script-src 'unsafe-inline'; " + "style-src 'unsafe-inline'; img-src data:; font-src data:; base-uri 'none'; form-action 'none'" /** Renderer fills theme/tokens before mounting srcdoc; main cannot know the active presentation values. */ export const PANEL_SHELL_TOKENS_PLACEHOLDER = '/*__ORCA_PANEL_TOKENS__*/' export const PANEL_SHELL_COLOR_SCHEME_PLACEHOLDER = '__ORCA_COLOR_SCHEME__' /** Expose only curated tokens: freezing all main.css properties would lock refactors. Additions are compatible; * renaming/removing published tokens breaks plugins. */ export const PANEL_DESIGN_TOKEN_ALLOWLIST = [ '--background', '--foreground', '--card', '--card-foreground', '--popover', '--popover-foreground', '--primary', '--primary-foreground', '--secondary', '--secondary-foreground', '--muted', '--muted-foreground', '--accent', '--accent-foreground', '--destructive', '--destructive-foreground', '--border', '--input', '--ring', '--radius' ] as const export function buildPluginPanelShellHtml(pluginHtml: string): string { // The inline ping responder proves the frame's event loop is alive; the // renderer watchdog demotes the panel when pongs stop arriving. const prelude = '\n' + `\n` + '\n' + '\n' + `\n` + `\n` + '\n' + '\n' return prelude + pluginHtml }