[MKT-652]: update/multi-format client-side compression service #1744
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.
### Summary
This PR performs a major update to the file compression system It includes a full cleanup of legacy dependencies and a highly aggressive compression strategy.
Key Changes
Removed bloat: Deleted heavy libraries like xlsx, docx, mammoth, and tesseract.js that were not contributing to the compression logic, significantly reducing the final bundle size.
Core Updates: Updated @ffmpeg/ffmpeg to the latest WASM-based version and integrated pdfjs-dist for advanced document processing.
Bug Fix: Resolved the "Element type is invalid" error by refactoring the internal State sub-component into a stable renderState function.
Logic Unification: Merged file validation logic (size and extension checks) into a single reusable function to ensure consistency across drag-and-drop and manual uploads.
Performance: Implemented useMemo for text formatting to prevent unnecessary re-computations during UI interactions.
Hybrid PDF Engine: Implemented a dual strategy that attempts structural optimization first, falling back to aggressive page rasterization (DPI scaling + JPEG quality reduction) to force size reduction.
Deep Office Compression: Modern Office files (.docx, .pptx, .xlsx) are now treated as containers. The service extracts internal media assets, compresses them individually, and rebuilds the document.
FFmpeg Integration: Video transcoding is now handled via WebAssembly with an ultrafast preset to optimize processing time within the browser.
Failsafe Logic: Added a size-comparison check that prevents the system from ever returning a file larger than the original upload.