Files
Netcatty/components/ai-elements/messageResponse.test.ts
T
陈大猫 ac885e2a36 perf(ai): replace full @streamdown/code bundle with fine-grained shiki/core highlighter (#4390)
* perf(ai): replace full @streamdown/code bundle with fine-grained shiki/core highlighter

* fix(deps): preserve peer dependencies in package-lock.json
2026-11-25 22:04:36 +08:00

26 lines
1.3 KiB
TypeScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { readFileSync } from 'node:fs';
test('messageResponse does not statically import Shiki', () => {
const source = readFileSync(new URL('./messageResponse.tsx', import.meta.url), 'utf8');
assert.doesNotMatch(source, /from ['"]@streamdown\/code['"]/);
assert.doesNotMatch(source, /from ['"]shiki(?:\/|['"])/);
assert.match(source, /from ['"]@streamdown\/cjk['"]/);
assert.match(source, /hasMarkdownCodeFence/);
assert.match(source, /warmAiCodeHighlighter/);
assert.match(source, /scheduleWhenAiComposerIdle/);
});
test('Shiki lives in an isolated fine-grained plugin module', () => {
const plugin = readFileSync(new URL('./streamdownCodePlugin.ts', import.meta.url), 'utf8');
const warmup = readFileSync(new URL('./streamdownCodeWarmup.ts', import.meta.url), 'utf8');
assert.match(plugin, /from ['"]shiki\/core['"]/);
assert.match(plugin, /from ['"]shiki\/engine\/javascript['"]/);
assert.doesNotMatch(plugin, /from ['"]@streamdown\/code['"]/);
assert.doesNotMatch(plugin, /from ['"]shiki['"]/);
assert.match(warmup, /import\('\.\/streamdownCodePlugin'\)/);
assert.doesNotMatch(warmup, /from ['"]@streamdown\/code['"]/);
assert.doesNotMatch(warmup, /from ['"]shiki(?:\/|['"])/);
});