[WIP] Refactor code structure for improved maintainability#261
Draft
[WIP] Refactor code structure for improved maintainability#261
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Created src/utils/errorUtils.ts with extractErrorMessage() helper - Created src/constants/pdf.ts with all magic numbers and constants - Updated all files to use new utilities, eliminating 12+ duplicate error patterns - Updated loader.ts, parser.ts, extractor.ts, tableExtractor.ts, readPdf.ts - All 133 tests passing, build successful, linter clean
- Created src/pdf/images/imagePngEncoder.ts (89 lines) - encodePixelsToPNG() - PNG encoding logic - processImageData() - Image data processing - Created src/pdf/images/imageExtractor.ts (154 lines) - retrieveImageData() - Image retrieval from PDF.js - extractImagesFromPage() - Single page image extraction - extractImages() - Multi-page image extraction - Updated src/pdf/extractor.ts (467→242 lines, 52% reduction) - Removed duplicate image code - Imports and re-exports from image modules - Maintains backward compatibility All 133 tests passing, build successful
Copilot stopped work on behalf of
shtse8 due to an error
February 5, 2026 03:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactoring Plan: Code Quality & Maintainability Improvements
Phase 1: Extract Utilities ✅ COMPLETE
src/utils/errorUtils.tsfor error message extraction (eliminates 12+ duplicates)src/constants/pdf.tsfor magic numbers and constantsPhase 2: Refactor PDF Extraction Layer ✅ COMPLETE (Part A)
src/pdf/extractor.ts(467→242 lines, 52% reduction):src/pdf/images/imagePngEncoder.ts(89 lines)encodePixelsToPNG()- Handles RGB/RGBA/Grayscale to PNG conversionprocessImageData()- Processes raw PDF.js image datasrc/pdf/images/imageExtractor.ts(154 lines)retrieveImageData()- Multi-strategy image retrieval (commonObjs/sync/async)extractImagesFromPage()- Single page image extractionextractImages()- Multi-page sequential extractionSummary of Improvements
Code Organization:
Maintainability:
Quality Assurance:
Remaining Work (Optional)
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.