mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 06:15:51 +00:00
fix: highlight.js 按需注册 26 个常用语言,减少 ~80% 语法内存占用
将 `import hljs from 'highlight.js'`(190+ 语言,~5-15MB)改为 `import hljs from 'highlight.js/lib/core'` + 静态导入并注册 26 个 常用语言(TypeScript、Python、Bash、Go、Rust 等)。静态 import 在 Bun --compile 模式下正常工作,避免了 createRequire 的路径问题。 内存从 ~5-15MB 降至 ~1-2MB。添加 7 个测试验证语言注册和 highlight 功能,现有 17 个 color-diff 测试全部通过。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
- [x] #4 空闲重新渲染循环 — **已确认完整**:所有 10 个 useAnimationFrame 调用者均正确传递 null 暂停时钟,keepAlive 机制工作正常
|
||||
- [x] #5 虚拟滚动器保留历史消息拷贝 — 确认已实现 ✅
|
||||
- [x] #6 管道模式超宽行过度分配 — 确认已实现 ✅
|
||||
- [ ] #7 语言语法按需加载 — 已知限制:Bun --compile 兼容性导致回退为静态导入(~5-15MB),无法简单修复
|
||||
- [x] #7 语言语法按需加载 — **已修复**:改用 highlight.js/lib/core + 静态注册 26 个常用语言,从 190+ 语言降至 ~25,内存减少 ~80%
|
||||
- [x] #8 NO_FLICKER 模式流状态泄漏 — **已修复**:StreamingToolExecutor.discard() 现在完整释放 tools 数组、中止 siblingAbortController、清理 turnSpan,7 tests
|
||||
- [x] #9 Remote Control 权限条目保留 — **已修复**:pendingPermissionHandlers 提升至 useEffect 作用域,cleanup 时显式 clear(),8 tests
|
||||
- [x] #10 MCP HTTP/SSE 缓冲区累积 — 确认已实现 ✅
|
||||
@@ -290,7 +290,7 @@ reset(width: number, height: number, screen: Screen): void {
|
||||
|
||||
## 7. 语言语法按需加载 (v2.1.108)
|
||||
|
||||
**状态:已回退为静态导入**
|
||||
**状态:已修复**
|
||||
|
||||
**CHANGELOG 描述**:Reduced memory footprint for file reads, edits, and syntax highlighting by loading language grammars on demand
|
||||
|
||||
@@ -569,8 +569,7 @@ if (snipResult !== undefined) {
|
||||
## 总结
|
||||
|
||||
```
|
||||
确认已实现 (11): #1 图片 #2 /usage #3 进度消息 #4 空闲渲染 #5 虚拟滚动器 #6 管道输出 #8 NO_FLICKER #9 RC权限 #10 MCP缓冲区 #11 LRU缓存键 #12 snipCompact
|
||||
已知限制 (1): #7 语法加载(Bun --compile 兼容性,已回退为静态导入,~5-15MB)
|
||||
确认已实现 (12): #1 图片 #2 /usage #3 进度消息 #4 空闲渲染 #5 虚拟滚动器 #6 管道输出 #7 语法加载 #8 NO_FLICKER #9 RC权限 #10 MCP缓冲区 #11 LRU缓存键 #12 snipCompact
|
||||
|
||||
### 测试覆盖
|
||||
|
||||
@@ -580,8 +579,9 @@ if (snipResult !== undefined) {
|
||||
| #12 snipProjection | `src/services/compact/__tests__/snipProjection.test.ts` | 11 |
|
||||
| #8 StreamingToolExecutor | `src/services/tools/__tests__/StreamingToolExecutor.test.ts` | 7 |
|
||||
| #9 RC 权限 | `src/hooks/__tests__/replBridgePermissionHandlers.test.ts` | 8 |
|
||||
| #11 FileStateCache | `src/utils/__tests__/fileStateCache.test.ts` | 16+6 |
|
||||
| **总计** | **5 个测试文件** | **65** |
|
||||
| #11 FileStateCache | `src/utils/__tests__/fileStateCache.test.ts` | 22 |
|
||||
| #7 语言注册 | `packages/color-diff-napi/src/__tests__/language-registration.test.ts` | 7 |
|
||||
| **总计** | **6 个测试文件** | **72** |
|
||||
```
|
||||
|
||||
### 需要关注的优先级
|
||||
|
||||
Reference in New Issue
Block a user