diff --git a/bun.lock b/bun.lock index 94f6e7085..63b5c9aeb 100644 --- a/bun.lock +++ b/bun.lock @@ -5,7 +5,7 @@ "": { "name": "com.foxdebug.acode", "dependencies": { - "@acode.app/canvas-view": "^0.0.9", + "@acode.app/canvas-view": "^0.0.10", "@codemirror/autocomplete": "^6.20.3", "@codemirror/commands": "^6.11.0", "@codemirror/lang-angular": "^0.1.4", @@ -160,7 +160,7 @@ "tar": "^7.5.22", }, "packages": { - "@acode.app/canvas-view": ["@acode.app/canvas-view@0.0.9", "", { "dependencies": { "@codemirror/language": "^6.13.1", "@codemirror/state": "^6.7.6", "@codemirror/view": "^6.43.14", "@lezer/common": "^1.5.5", "@lezer/highlight": "^1.2.5", "style-mod": "^4.1.2" }, "peerDependencies": { "@codemirror/autocomplete": "^6.0.0" }, "optionalPeers": ["@codemirror/autocomplete"] }, "sha512-L2mRVnW93Aoy3+cik1EyMBI56Qy8fxOE7NY12PumXQ1ULAvjUXuqzsmDLQo0qiRGzEVf/7k01VdmqgZHvfIXwg=="], + "@acode.app/canvas-view": ["@acode.app/canvas-view@0.0.10", "", { "dependencies": { "@codemirror/language": "^6.13.1", "@codemirror/state": "^6.7.6", "@codemirror/view": "^6.43.14", "@lezer/common": "^1.5.5", "@lezer/highlight": "^1.2.5", "style-mod": "^4.1.2" }, "peerDependencies": { "@codemirror/autocomplete": "^6.0.0" }, "optionalPeers": ["@codemirror/autocomplete"] }, "sha512-lYPwVGoBDFkX0eVl0aOpIJZKx54k+AyEO8L5HIvnb/1kDHBTxGlU/LbAkI4m0cMLbVbkoeOdXAsEjQz9q/8mUA=="], "@babel/code-frame": ["@babel/code-frame@8.0.0", "", { "dependencies": { "@babel/helper-validator-identifier": "^8.0.0", "js-tokens": "^10.0.0" } }, "sha512-dYYg153EyN2Ekbqw2zAsbd6/JR+9N2SEoC7YV2GyyqMM7x9bLDTjBD6XBhSMLH0wtIVyJj03jWNriQhaN+eoCw=="], diff --git a/package-lock.json b/package-lock.json index f9947d89b..8cba1623b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.13.5", "license": "MIT", "dependencies": { - "@acode.app/canvas-view": "^0.0.9", + "@acode.app/canvas-view": "^0.0.10", "@codemirror/autocomplete": "^6.20.3", "@codemirror/commands": "^6.11.0", "@codemirror/lang-angular": "^0.1.4", @@ -172,9 +172,9 @@ } }, "node_modules/@acode.app/canvas-view": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/@acode.app/canvas-view/-/canvas-view-0.0.9.tgz", - "integrity": "sha512-L2mRVnW93Aoy3+cik1EyMBI56Qy8fxOE7NY12PumXQ1ULAvjUXuqzsmDLQo0qiRGzEVf/7k01VdmqgZHvfIXwg==", + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/@acode.app/canvas-view/-/canvas-view-0.0.10.tgz", + "integrity": "sha512-lYPwVGoBDFkX0eVl0aOpIJZKx54k+AyEO8L5HIvnb/1kDHBTxGlU/LbAkI4m0cMLbVbkoeOdXAsEjQz9q/8mUA==", "license": "MIT", "dependencies": { "@codemirror/language": "^6.13.1", diff --git a/package.json b/package.json index c052de7c0..85581582d 100644 --- a/package.json +++ b/package.json @@ -125,7 +125,7 @@ "ws": "^8.21.3" }, "dependencies": { - "@acode.app/canvas-view": "^0.0.9", + "@acode.app/canvas-view": "^0.0.10", "@codemirror/autocomplete": "^6.20.3", "@codemirror/commands": "^6.11.0", "@codemirror/lang-angular": "^0.1.4", diff --git a/src/cm/canvasOptions.ts b/src/cm/canvasOptions.ts index 1f363ae4e..b25c5051d 100644 --- a/src/cm/canvasOptions.ts +++ b/src/cm/canvasOptions.ts @@ -6,11 +6,9 @@ import { parseColor, type TokenStyleSpec, } from "@acode.app/canvas-view"; -import { HighlightStyle } from "@codemirror/language"; -import { oneDark } from "@codemirror/theme-one-dark"; import { tags as t } from "@lezer/highlight"; import { getRainbowBracketColors } from "cm/rainbowBrackets"; -import { getThemeById, getThemeConfig, getThemeExtensions } from "cm/themes"; +import { getThemeById, getThemeConfig } from "cm/themes"; /** * Maps Acode's editor settings and themes to @acode.app/canvas-view options. @@ -70,175 +68,6 @@ function clampSetting( return Math.min(Math.max(Math.round(number), min), max); } -/** - * Find the HighlightStyle a theme passes to `syntaxHighlighting()`, by - * walking its extension tree (arrays, precedence wrappers, compartments, - * `facet.of(value)` providers). Returns null for themes that compute their - * highlighter (`themeType`) or don't have one. - */ -export function findHighlightStyle( - extension: unknown, - seen = new Set(), -): HighlightStyle | null { - if (!extension || typeof extension !== "object" || seen.has(extension)) { - return null; - } - seen.add(extension); - if (extension instanceof HighlightStyle) return extension; - if (Array.isArray(extension)) { - for (const item of extension) { - const found = findHighlightStyle(item, seen); - if (found) return found; - } - return null; - } - const node = extension as { - value?: unknown; - inner?: unknown; - extension?: unknown; - }; - return ( - findHighlightStyle(node.value, seen) || - findHighlightStyle(node.inner, seen) || - findHighlightStyle(node.extension, seen) - ); -} - -/** - * Editor surface colors a theme's own `EditorView.theme` rules set, for - * the canvas renderer, which doesn't draw from CSS. Plugin themes are often - * registered with only background, foreground and syntax colors in their - * config, and style the active line, gutter and cursor in CSS. - * Parsed from the style modules' rule strings when the canvas theme is - * built (theme changes): no DOM is read, nothing runs per frame. - */ -interface RuleColors { - activeLine?: string; - activeLineBorder?: string; - activeLineBorderWidth?: number; - activeLineGutter?: string; - gutterBackground?: string; - gutterForeground?: string; - gutterActiveForeground?: string; - selection?: string; - cursor?: string; -} - -function collectStyleRules( - extension: unknown, - rules: string[], - seen = new Set(), -): string[] { - if (!extension || typeof extension !== "object" || seen.has(extension)) { - return rules; - } - seen.add(extension); - if (Array.isArray(extension)) { - for (const item of extension) collectStyleRules(item, rules, seen); - return rules; - } - const node = extension as { - getRules?: () => unknown; - value?: unknown; - inner?: unknown; - extension?: unknown; - }; - // A StyleModule (style-mod): one "selectors {declarations}" rule per line. - if (typeof node.getRules === "function") { - const text = node.getRules(); - if (typeof text === "string") rules.push(...text.split("\n")); - return rules; - } - collectStyleRules(node.value, rules, seen); - collectStyleRules(node.inner, rules, seen); - collectStyleRules(node.extension, rules, seen); - return rules; -} - -const COLOR_TOKEN = - /(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\([^)]*\)|#[0-9a-f]{3,8}\b|\b(?!inset\b)[a-z]+\b/i; - -/** A color in a CSS value ("2px solid #333" -> "#333"); null for var(). */ -function colorIn(value: string): string | null { - if (/var\(/.test(value)) return null; - const m = COLOR_TOKEN.exec( - value.replace(/\b(?:solid|dashed|dotted|double|none)\b/g, ""), - ); - if ( - !m || - /^(?:transparent|currentcolor|inherit|initial|unset)$/i.test(m[0]) - ) { - return m && /^transparent$/i.test(m[0]) ? "transparent" : null; - } - return m[0]; -} - -/** An inset box-shadow without offset or blur as a frame (`0 0 0 2px #333 inset`). */ -function insetFrame(value: string): { color: string; width: number } | null { - const first = value.split(/,(?![^(]*\))/)[0]; - if (!/\binset\b/.test(first)) return null; - const color = colorIn(first.replace(/\binset\b/, "")); - const lengths = ( - first.replace(COLOR_TOKEN, " ").match(/-?\d*\.?\d+(?:px)?\b/g) ?? [] - ).map(Number.parseFloat); - const [x = 0, y = 0, blur = 0, spread = 0] = lengths; - if (!color || color === "transparent" || x || y || blur || !(spread > 0)) { - return null; - } - return { color, width: spread }; -} - -export function themeRuleColors(extension: unknown): RuleColors { - const found: RuleColors = {}; - let focusedSelection: string | undefined; - for (const rule of collectStyleRules(extension, [])) { - const m = /^([^{]+)\{([^}]*)\}\s*$/.exec(rule); - if (!m) continue; - const decls = new Map(); - for (const decl of m[2].split(/;(?![^(]*\))/)) { - const i = decl.indexOf(":"); - if (i > 0) decls.set(decl.slice(0, i).trim(), decl.slice(i + 1).trim()); - } - const bg = decls.get("background-color") ?? decls.get("background"); - const bgColor = bg ? colorIn(bg) : null; - for (const sel of m[1].split(",").map((s) => s.trim())) { - // Only the element itself, not states or descendants of it. - if (/:(?:hover|active|focus)|::/.test(sel)) continue; - if (/\.cm-activeLine$/.test(sel)) { - if (bgColor) found.activeLine = bgColor; - const frame = decls.has("box-shadow") - ? insetFrame(decls.get("box-shadow") as string) - : null; - if (frame) { - found.activeLineBorder = frame.color; - found.activeLineBorderWidth = frame.width; - } - } else if (/\.cm-gutters$/.test(sel)) { - if (bgColor) found.gutterBackground = bgColor; - const color = decls.get("color"); - if (color && colorIn(color)) - found.gutterForeground = colorIn(color) as string; - } else if (/\.cm-activeLineGutter$/.test(sel)) { - if (bgColor) found.activeLineGutter = bgColor; - const color = decls.get("color"); - if (color && colorIn(color)) - found.gutterActiveForeground = colorIn(color) as string; - } else if (/\.cm-cursor(?:-primary)?$/.test(sel)) { - const border = - decls.get("border-left-color") ?? decls.get("border-left"); - const color = border ? colorIn(border) : null; - if (color && color !== "transparent") found.cursor = color; - } else if (/\.cm-selectionBackground$/.test(sel) && bgColor) { - // The focused rule is what a focused editor shows. - if (/\.cm-focused\b/.test(sel)) focusedSelection = bgColor; - else found.selection ??= bgColor; - } - } - } - if (focusedSelection) found.selection = focusedSelection; - return found; -} - /** Token colors from a theme config, for themes without a HighlightStyle. */ function highlightFromConfig(config: ThemeConfig): TokenStyleSpec[] { const color = (key: string) => @@ -265,88 +94,57 @@ function highlightFromConfig(config: ThemeConfig): TokenStyleSpec[] { return specs.filter((spec) => spec.color); } -/** - * Decoration colors the canvas draws natively, as the themes' CSS has them: - * selection matches use the theme's `selectionMatch`, else its selection. - */ -function themeClasses(config: ThemeConfig): CanvasThemeSpec["classes"] { - const classes: NonNullable = {}; - if (config.matchingBracket) { - classes["cm-matchingBracket"] = { background: config.matchingBracket }; - } - const selectionMatch = config.selectionMatch || config.selection; - if (selectionMatch) { - classes["cm-selectionMatch"] = { background: selectionMatch }; - } - return Object.keys(classes).length ? classes : undefined; -} +/** What `CanvasView`'s `theme` option and `setTheme` take. */ +export type CanvasThemeSource = NonNullable; /** - * The canvas theme for an Acode editor theme: colors from its config, syntax - * colors from the HighlightStyle in its extensions. The theme's - * EditorView.theme stays in the state, where it styles the DOM UI (tooltips, - * panels, autocomplete). - */ -/** - * The canvas theme spec with the active line frame, which canvas-view - * releases before it ignore (the line is then drawn without one). + * The canvas theme for an Acode editor theme. canvas-view resolves the + * colors itself from the theme's own CSS (the `EditorView.theme` and + * highlight style in the state: background, text, cursor, selection, active + * line fill or frame, gutter, line numbers, matching brackets, selection + * matches), like the DOM editor shows them, and again when the theme + * compartment changes. The CSS is the only source for those: a theme's + * config doesn't override it, so both renderers draw a theme the same. + * This adds what the CSS doesn't say: Acode's own scrollbars, a + * see-through canvas over a picture, the gutter border and config-only + * syntax colors. */ -type FramedThemeSpec = CanvasThemeSpec & { - activeLineBorder?: string; - activeLineBorderWidth?: number; -}; - export function getCanvasTheme( themeId: string, seeThrough = false, -): CanvasThemeSpec { +): CanvasThemeSource { // Resolve ids like getThemeExtensions does ("one-dark" -> "one_dark"). const theme = getThemeById(themeId) || getThemeById(String(themeId).replace(/-/g, "_")); const config = (theme?.config || getThemeConfig(themeId) || {}) as ThemeConfig; - const extensions = getThemeExtensions(themeId, [oneDark]); - const highlight = - findHighlightStyle(extensions) || highlightFromConfig(config); - // What the config leaves out, from the theme's own CSS rules. - const rules = themeRuleColors(extensions); - const background = config.background || "#282c34"; - const foreground = config.foreground || "#abb2bf"; - // The config's active line replaces the rules' (fill and frame). - const framed = !config.activeLine && rules.activeLineBorder; - const activeLine = config.activeLine ?? rules.activeLine; - const spec: FramedThemeSpec = { - dark: config.dark !== false, - // With a picture behind the editor, the canvas is see-through. The - // editor element keeps the theme's CSS background under the picture, - // and sticky lines take it from there. - background: seeThrough ? "transparent" : background, - foreground, - selection: config.selection ?? rules.selection, - cursor: config.cursor ?? rules.cursor, - activeLine: - seeThrough && !framed - ? translucentActiveLine(activeLine, foreground) - : (activeLine ?? (framed ? "transparent" : undefined)), - activeLineBorder: framed ? rules.activeLineBorder : undefined, - activeLineBorderWidth: framed ? rules.activeLineBorderWidth : undefined, - // Like the DOM themes, which give the active gutter line no background. - activeLineGutter: seeThrough - ? "transparent" - : (rules.activeLineGutter ?? background), - gutterBackground: seeThrough ? undefined : rules.gutterBackground, - gutterForeground: config.lineNumber ?? rules.gutterForeground, - gutterActiveForeground: - config.lineNumberActive ?? rules.gutterActiveForeground, - // A line between the gutter and the code, only when the theme asks. - gutterBorder: config.gutterBorder, - // Acode draws its own (draggable) scrollbars over the editor. - scrollbar: "transparent", - highlight, - classes: themeClasses(config), + // Only used for a theme without a highlight style in its extensions. + const highlight = highlightFromConfig(config); + return (css: CanvasThemeSpec): CanvasThemeSpec => { + const framed = !!css.activeLineBorder; + return { + ...css, + ...(highlight.length ? { highlight } : null), + // With a picture behind the editor, the canvas is see-through. The + // editor element keeps the theme's CSS background under the + // picture, and sticky lines take it from there. + background: seeThrough ? "transparent" : css.background, + activeLine: + seeThrough && !framed + ? translucentActiveLine(css.activeLine, css.foreground) + : css.activeLine, + // Like the DOM themes, which give the active gutter line no background. + activeLineGutter: seeThrough + ? "transparent" + : (css.activeLineGutter ?? css.background), + gutterBackground: seeThrough ? undefined : css.gutterBackground, + // A line between the gutter and the code, when the theme asks. + gutterBorder: config.gutterBorder ?? css.gutterBorder, + // Acode draws its own (draggable) scrollbars over the editor. + scrollbar: "transparent", + }; }; - return spec; } /** diff --git a/tests/unit/canvasOptions.test.ts b/tests/unit/canvasOptions.test.ts index 02ef530c9..bd679190e 100644 --- a/tests/unit/canvasOptions.test.ts +++ b/tests/unit/canvasOptions.test.ts @@ -1,40 +1,72 @@ // @vitest-environment happy-dom +import { cssThemeSpec, parseColor, themeCSSOf } from "@acode.app/canvas-view"; import { HighlightStyle, syntaxHighlighting } from "@codemirror/language"; -import { Compartment, Prec } from "@codemirror/state"; +import { EditorState } from "@codemirror/state"; +import { oneDark } from "@codemirror/theme-one-dark"; import { EditorView } from "@codemirror/view"; import { tags as t } from "@lezer/highlight"; import { - findHighlightStyle, fontSizeToPx, getCanvasDisplayOptions, getCanvasFont, getCanvasTheme, - themeRuleColors, } from "cm/canvasOptions"; -import { addTheme, getThemeConfig, getThemes, removeTheme } from "cm/themes"; +import { + addTheme, + getThemeConfig, + getThemeExtensions, + getThemes, + removeTheme, +} from "cm/themes"; import { describe, expect, it } from "vitest"; +/** Whether an extension tree holds a HighlightStyle. */ +function findHighlighters( + extension: unknown, + seen = new Set(), +): boolean { + if (!extension || typeof extension !== "object" || seen.has(extension)) { + return false; + } + seen.add(extension); + if (extension instanceof HighlightStyle) return true; + if (Array.isArray(extension)) { + return extension.some((item) => findHighlighters(item, seen)); + } + const node = extension as Record; + return ( + findHighlighters(node.value, seen) || + findHighlighters(node.inner, seen) || + findHighlighters(node.extension, seen) + ); +} + describe("canvas renderer theme bridge", () => { - it("finds the HighlightStyle inside wrapped theme extensions", () => { - const style = HighlightStyle.define([{ tag: t.keyword, color: "#f00" }]); - const compartment = new Compartment(); - const extension = [ - [], - compartment.of(Prec.high([syntaxHighlighting(style)])), - ]; - expect(findHighlightStyle(extension)).toBe(style); - expect(findHighlightStyle([])).toBeNull(); - }); + // What a canvas view draws a theme with: canvas-view resolves the + // theme's CSS from the state, and Acode's theme function adjusts it. + const specFor = (id: string, seeThrough = false) => { + const state = EditorState.create({ + extensions: getThemeExtensions(id, [oneDark]), + }); + return { + spec: getCanvasTheme(id, seeThrough)(cssThemeSpec(state)), + css: themeCSSOf(state), + }; + }; it("gives every built-in theme syntax colors and its config colors", () => { for (const theme of getThemes()) { - const spec = getCanvasTheme(theme.id); + const { spec } = specFor(theme.id); const config = getThemeConfig(theme.id); expect(spec.background, theme.id).toBe(config.background); expect(spec.foreground, theme.id).toBe(config.foreground); expect(spec.dark, theme.id).toBe(config.dark !== false); - expect(spec.highlight, theme.id).toBeInstanceOf(HighlightStyle); + // Syntax colors come from the highlight style in the state. + expect( + findHighlighters(getThemeExtensions(theme.id, [oneDark])), + theme.id, + ).toBe(true); // Acode's own scrollbars are used instead of the canvas thumbs. expect(spec.scrollbar).toBe("transparent"); } @@ -42,16 +74,18 @@ describe("canvas renderer theme bridge", () => { it("maps the theme's line number and bracket colors", () => { const config = getThemeConfig("dracula"); - expect(getCanvasTheme("dracula")).toMatchObject({ + const { spec, css } = specFor("dracula"); + expect(spec).toMatchObject({ selection: config.selection, cursor: config.cursor, gutterForeground: config.lineNumber, gutterActiveForeground: config.lineNumberActive, - classes: { - "cm-matchingBracket": { background: config.matchingBracket }, - "cm-selectionMatch": { background: config.selection }, - }, }); + // Decoration classes are resolved from the theme's CSS by the view. + expect(css.mark("cm-matchingBracket")?.background).toBe( + config.matchingBracket, + ); + expect(css.mark("cm-selectionMatch")?.background).toBe(config.selection); }); // A plugin theme with only text colors in its config, and the rest in @@ -81,24 +115,99 @@ describe("canvas renderer theme bridge", () => { { dark: true }, ); - it("reads surface colors from a theme's own rules", () => { - expect(themeRuleColors([cssOnlyTheme()])).toEqual({ - cursor: "#aeafad", - selection: "#2e3135", - activeLine: "transparent", - activeLineBorder: "#282828", - activeLineBorderWidth: 2, - gutterBackground: "#111113", - gutterForeground: "#696e77", - activeLineGutter: "transparent", - gutterActiveForeground: "#c6c6c6", - }); - // Shadows that aren't a plain frame, and var() colors, are left alone. - const other = EditorView.theme({ - ".cm-activeLine": { boxShadow: "0 2px 4px #000 inset" }, - ".cm-cursor": { borderLeftColor: "var(--cursor)" }, - }); - expect(themeRuleColors([other])).toEqual({}); + it("every built-in theme's CSS agrees with its config", () => { + const norm = (v: unknown) => + typeof v === "string" ? v.toLowerCase().replace(/\s+/g, "") : v; + for (const theme of getThemes()) { + const config = getThemeConfig(theme.id); + const state = EditorState.create({ + extensions: getThemeExtensions(theme.id, [oneDark]), + }); + const css = cssThemeSpec(state); + for (const [key, value] of [ + ["background", config.background], + ["foreground", config.foreground], + ["selection", config.selection], + ["cursor", config.cursor], + ["activeLine", config.activeLine], + ["gutterForeground", config.lineNumber], + ["gutterActiveForeground", config.lineNumberActive], + ] as const) { + if (value == null) continue; + expect(norm(css[key]), `${theme.id} ${key}`).toBe(norm(value)); + } + } + }); + + it("draws syntax colors from the theme's highlight style over its config", () => { + const style = HighlightStyle.define([{ tag: t.keyword, color: "#ff0000" }]); + const config = { + name: "canvas-test-syntax-theme", + dark: true, + background: "#111113", + foreground: "#bbbbbb", + keyword: "#00ff00", + }; + addTheme( + "canvas-test-syntax-theme", + "Syntax theme test", + true, + () => [ + EditorView.theme( + { "&": { backgroundColor: "#111113" } }, + { dark: true }, + ), + syntaxHighlighting(style), + ], + config, + ); + try { + const state = EditorState.create({ + extensions: getThemeExtensions("canvas-test-syntax-theme", [oneDark]), + }); + // With a highlight style in the state, the canvas colors tokens from + // its CSS; the config's colors are only a fallback. + const keyword = style.style([t.keyword]) as string; + expect(themeCSSOf(state).token(keyword)?.color).toBe( + parseColor("#ff0000"), + ); + } finally { + removeTheme("canvas-test-syntax-theme"); + } + // Without one, the canvas theme's own highlight has the config's colors. + addTheme( + "canvas-test-syntax-theme", + "Syntax theme test", + true, + () => [ + EditorView.theme( + { "&": { backgroundColor: "#111113" } }, + { dark: true }, + ), + ], + config, + ); + try { + const { spec } = specFor("canvas-test-syntax-theme"); + const highlight = spec.highlight as readonly { + tag: unknown; + color?: string; + }[]; + expect( + highlight.find((s) => + ([] as unknown[]).concat(s.tag).includes(t.keyword), + )?.color, + ).toBe("#00ff00"); + } finally { + removeTheme("canvas-test-syntax-theme"); + } + }); + + it("keeps a see-through canvas over a picture", () => { + const { spec } = specFor("dracula", true); + expect(spec.background).toBe("transparent"); + expect(spec.activeLineGutter).toBe("transparent"); + expect(spec.gutterBackground).toBeUndefined(); }); it("draws a plugin theme's CSS-only surfaces on the canvas", () => { @@ -115,7 +224,7 @@ describe("canvas renderer theme bridge", () => { }, ); try { - expect(getCanvasTheme("canvas-test-css-theme")).toMatchObject({ + expect(specFor("canvas-test-css-theme").spec).toMatchObject({ background: "#111113", cursor: "#aeafad", selection: "#2e3135", @@ -126,7 +235,8 @@ describe("canvas renderer theme bridge", () => { gutterForeground: "#696e77", gutterActiveForeground: "#c6c6c6", }); - // The config's own colors win over the rules. + // The CSS is what the DOM editor shows: a config that disagrees + // with it doesn't change the canvas. removeTheme("canvas-test-css-theme"); addTheme( "canvas-test-css-theme", @@ -142,9 +252,12 @@ describe("canvas renderer theme bridge", () => { cursor: "#ff0000", }, ); - const spec = getCanvasTheme("canvas-test-css-theme"); - expect(spec).toMatchObject({ activeLine: "#202020", cursor: "#ff0000" }); - expect(spec.activeLineBorder).toBeUndefined(); + const { spec } = specFor("canvas-test-css-theme"); + expect(spec).toMatchObject({ + activeLine: "transparent", + activeLineBorder: "#282828", + cursor: "#aeafad", + }); } finally { removeTheme("canvas-test-css-theme"); }