Deduplicate ANSI subsystem shared logic into ansi-shared package
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- typescript
- Lĩnh vực
- build-system, tooling
Hướng nghiên cứu
Start by comparing the paired files in packages/lua-runtime/src/ and lua-learning-website/src/components/AnsiGraphicsEditor/, then inspect packages/ansi-shared/src/index.ts and the existing package build configuration. Extract the listed types, rendering, compositing, and cell utilities, rewire both consumers, remove the ANSI exclusions from .jscpd.json, and run the existing tests plus npm run duplicates.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
The ANSI subsystem has intentionally duplicated code between packages/lua-runtime/src/ (runtime) and lua-learning-website/src/components/AnsiGraphicsEditor/ (editor). This duplication is currently suppressed in jscpd via ignore patterns, but the shared logic can be extracted into the existing packages/ansi-shared/ package — eliminating drift risk and removing the need for jscpd exclusions.
Pairs with Extractable Shared Logic
1. Core Types (~60% overlap)
- Runtime:
packages/lua-runtime/src/screenTypes.ts - Editor:
lua-learning-website/src/components/AnsiGraphicsEditor/types.ts - Shared:
RGBColor,AnsiCell,AnsiGrid,Rect,TextAlign,ANSI_COLS,ANSI_ROWS,DEFAULT_FG,DEFAULT_BG,DEFAULT_CELL,TRANSPARENT_HALF,TRANSPARENT_BG,HALF_BLOCK,isGroupLayer(),isDrawableLayer() - Stays separate: Editor-only types (
BrushMode,ScaleMode,DrawTool,BorderStyle,LayerState, richerLayerhierarchy). Runtime-only simplifiedLayerDatatypes.
2. Text Layer Rendering (~85% identical)
- Runtime:
packages/lua-runtime/src/textLayerGrid.ts - Editor:
lua-learning-website/src/components/AnsiGraphicsEditor/textLayerGrid.ts - Shared:
wrapText(),buildRawIndexMap(),justifyLine(),renderTextLayerGrid()— identical implementations - Stays separate: Editor-only
cursorPosToVisual()function
3. Compositing Core (4 identical functions)
- Runtime:
packages/lua-runtime/src/screenCompositor.ts - Editor:
lua-learning-website/src/components/AnsiGraphicsEditor/layerUtils.ts - Shared:
hiddenGroupIds(),visibleDrawableLayers(),compositeCellCore(),compositeGrid() - Stays separate: 47 editor-only functions (layer manipulation, creation, cloning, display ordering). Requires abstract layer interface to bridge
LayerData(runtime) andLayer(editor) types.
4. Cell Comparison Utility
- Runtime:
packages/lua-runtime/src/ansiStringRenderer.ts→cellsEqual() - Editor:
lua-learning-website/src/components/AnsiGraphicsEditor/terminalBuffer.ts→cellsEqual() - Shared: Identical
cellsEqual()function - Note: The rest of these two files are fundamentally different (stateless ANSI string generation vs. stateful double buffer) and should NOT be merged.
NOT in Scope
serialization.ts— editor-only, no runtime counterpart (not actually duplicated)packages/export/src/runtime/**— architecturally different execution model (single-threaded direct draw vs. multi-threaded command queue), cannot be deduplicatedterminalBuffer.ts/ansiStringRenderer.tsbeyondcellsEqual()— fundamentally different abstractions
Implementation Approach
The packages/ansi-shared/ package already exists (currently contains only playbackEngine.ts). New shared modules:
ansi-shared/src/screenTypes.ts— Core types + constantsansi-shared/src/textRendering.ts— Text wrapping and grid renderingansi-shared/src/compositing.ts— Layer compositing with abstract interfacesansi-shared/src/cellUtils.ts—cellsEqual()utility- Update
ansi-shared/src/index.ts— Export all new modules
Both lua-runtime and the editor import from @lua-learning/ansi-shared instead of maintaining their own copies. The compositing module will need abstract interfaces (e.g., HasVisibility & HasId) that both LayerData and Layer satisfy.
Acceptance Criteria
- Shared types, text rendering, compositing, and
cellsEquallive inansi-shared -
packages/lua-runtime/src/imports shared code from@lua-learning/ansi-shared -
lua-learning-website/src/components/AnsiGraphicsEditor/imports shared code from@lua-learning/ansi-shared - No copy-pasted logic remains between the paired files (only side-specific extensions)
- jscpd ANSI exclusions removed from
.jscpd.json(no longer needed) - All existing tests pass
-
npm run duplicatesshows reduced clone count with no new ANSI cross-package hits - Build order respected:
ansi-sharedbuilds beforelua-runtimeandlua-learning-website
Complexity
Medium (~6-8 tasks). Mostly mechanical extraction + import rewiring, but the compositing abstract interface requires care.
- Ngôn ngữ chính
- TypeScript
- Star
- 1
- Fork
- 0
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của jcollard/LuaInTheWeb
-
tech-debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
jcollard/LuaInTheWeb#752 ·
-
tech-debt
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
jcollard/LuaInTheWeb#690 ·
-
tech-debt
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
jcollard/LuaInTheWeb#590 ·
-
tech-debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
jcollard/LuaInTheWeb#518 ·
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
jcollard/LuaInTheWeb#235 ·
Tất cả issue của jcollard/LuaInTheWeb
Issue tương tự
-
[Bug]: Circular app layout navigation and help icons are shifted upward in the official demoĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
cloudscape-design/components#5184 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
JarX-Concepts/react-native-platform-components#130 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
fix(api): optimize-for-web /preview outer catches miss asDecoderOutOfMemory on V8 OOM and SIGKILLĐang mởarea: backend bug priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
snapotter-hq/SnapOtter#3773 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ai-driven-qa ux-audit
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
linagora/twake-contacts-frontend#386 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
git: README should state plainly that without --repository every reachable repository is in scopeĐang mởdocumentation server-git v2
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 84/100
modelcontextprotocol/servers#5225 ·
Maintainer thường phản hồi trong vòng 1 ngày