新增 src/client/one-dark-palette.ts,作为 one-dark / one-light 两套语法 色系的唯一来源:TerminalView 的 ANSI 16 与 cm-themes 的 CodeMirror 高亮 规则改为从色板常量组装各自的映射(ANSI 槽位 / lezer tag 到色相的映射 仍留在各消费方——两边的角色映射本就不同)。 行为不变的纯重构:每个 hex/rgba 迁移前后逐字节一致(旧新片段在桩 tags 下求值深度比对相等;产物 hex 清单无删除、非色板 hex 计数零变化)。 TerminalView 的 token 兜底色与 cm-themes 的 selection/activeLine rgba 与语法色系无关,保留原处未合并。 chunk 边界:色板为纯常量,被 terminal / editor 两个懒 chunk 各自内联 (每 chunk 约 200B 字面量),不引入跨 chunk import;核心 bundle (client.js / client-registry.js)对该模块零引用(grep 产物验证)。 tests/one-dark-palette.spec.ts 钉住色板字面量防意外漂移。
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
/**
|
|
* Byte-level guard for the shared syntax color families
|
|
* (src/client/one-dark-palette.ts). The terminal's ANSI 16
|
|
* (TerminalView.tsx) and CodeMirror's highlight rules (cm-themes.ts) both
|
|
* assemble from these constants, so an accidental value edit here silently
|
|
* re-themes every code surface in both views. The expected hexes are the
|
|
* exact pre-single-sourcing literals from the two consumers — changing one
|
|
* must be a deliberate, reviewable act.
|
|
*/
|
|
import { describe, expect, it } from 'vitest'
|
|
import { ONE_DARK, ONE_LIGHT } from '../src/client/one-dark-palette.ts'
|
|
|
|
describe('one-dark-palette', () => {
|
|
it('pins the one-dark family (dark scheme) hues', () => {
|
|
expect(ONE_DARK).toEqual({
|
|
black: '#282c34',
|
|
gray: '#abb2bf',
|
|
faintGray: '#5c6370',
|
|
white: '#ffffff',
|
|
red: '#e06c75',
|
|
green: '#98c379',
|
|
yellow: '#e5c07b',
|
|
blue: '#61afef',
|
|
magenta: '#c678dd',
|
|
cyan: '#56b6c2',
|
|
orange: '#d19a66',
|
|
})
|
|
})
|
|
|
|
it('pins the one-light family (light scheme) hues', () => {
|
|
expect(ONE_LIGHT).toEqual({
|
|
black: '#383a42',
|
|
gray: '#a0a1a7',
|
|
faintGray: '#4f525e',
|
|
white: '#ffffff',
|
|
offWhite: '#fafafa',
|
|
red: '#e45649',
|
|
green: '#50a14f',
|
|
yellow: '#c18401',
|
|
blue: '#0184bc',
|
|
magenta: '#a626a4',
|
|
cyan: '#0997b3',
|
|
orange: '#986801',
|
|
link: '#4078f2',
|
|
})
|
|
})
|
|
})
|