mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-09-24 15:49:09 +00:00
b02d52516c
messageResponse pulled @streamdown/code on first markdown import, so opening a chat with history paid for the full highlighter even when the reply was just prose. Render with CJK only first. When a fence exists and the composer is idle, lazily import the isolated Shiki plugin.
21 lines
981 B
TypeScript
21 lines
981 B
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.match(source, /from ['"]@streamdown\/cjk['"]/);
|
|
assert.match(source, /hasMarkdownCodeFence/);
|
|
assert.match(source, /warmAiCodeHighlighter/);
|
|
assert.match(source, /scheduleWhenAiComposerIdle/);
|
|
});
|
|
|
|
test('Shiki lives in an isolated 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 ['"]@streamdown\/code['"]/);
|
|
assert.match(warmup, /import\('\.\/streamdownCodePlugin'\)/);
|
|
assert.doesNotMatch(warmup, /from ['"]@streamdown\/code['"]/);
|
|
});
|