-
Notifications
You must be signed in to change notification settings - Fork 73
Replace jsunzip with modern libraries (fflate + pako) #506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Remove custom TINF gzip implementation in favor of maintained library - Part of broader effort to replace jsunzip with standard libraries - Maintains existing ungzip() API and error handling - All existing gzip tests continue to pass 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove custom JSUnzip implementation in favor of maintained library - Use fflate's unzipSync for synchronous ZIP handling - Add comprehensive ZIP tests with sample files - Maintains existing unzipDiscImage() and unzipRomImage() APIs - All existing functionality continues to work - Fix lint-staged to only run prettier on supported file types 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Delete custom jsunzip implementation (628 lines) - Update lib/README to remove jsunzip reference - All tests continue to pass with new fflate/pako implementation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Should lay a tiny bit of groundwork for #505 (though not directly in this form) |
- Optimize Uint8Array usage to avoid unnecessary buffer copying - Update test-zip.js to use vitest expect API for consistency - Fix path handling to use path.join for cross-platform compatibility 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR replaces the custom jsunzip implementation with maintained libraries and updates related tests and docs.
- Swap out custom ZIP/GZIP code for
fflate.unzipSyncandpako.ungzipinsrc/utils.js - Remove the legacy
src/lib/jsunzip.jsfile and references - Add comprehensive ZIP tests covering SSD/ROM, mixed archives, and error cases
Reviewed Changes
Copilot reviewed 5 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils.js | Replaced jsunzip logic with fflate and pako calls |
| src/lib/jsunzip.js | Deleted legacy JSUnzip library |
| tests/unit/test-zip.js | Added new ZIP unit tests for various archive scenarios |
| src/lib/README | Removed jsunzip reference |
| package.json | Added fflate and pako dependencies, updated formatting rules |
Comments suppressed due to low confidence (1)
tests/unit/test-zip.js:49
- [nitpick] The comment says this ZIP is incompatible but the test loads
test-ssd.zip, which actually contains a valid SSD file; please update the comment to match the test data.
// Create a simple ZIP with incompatible file
|
|
||
| function unzipImage(data, knownExtensions) { | ||
| const unzip = new jsunzip.JSUnzip(); | ||
| console.log("Attempting to unzip"); |
Copilot
AI
Jul 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider removing or replacing this debug console.log with a proper logger or debug-level logging to avoid polluting production output.
| const match = filename.match(/.*\.([a-z]+)/i); | ||
| if (!match || !knownExtensions[match[1].toLowerCase()]) { | ||
| console.log("Skipping file", f); | ||
| console.log("Skipping file", filename); |
Copilot
AI
Jul 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This debug console.log could be removed or switched to a debug logger to keep production logs clean.
| } | ||
| if (uncompressed) { | ||
| console.log("Ignoring", f, "as already found a file"); | ||
| console.log("Ignoring", filename, "as already found a file"); |
Copilot
AI
Jul 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider removing or demoting this console log to a debug channel to prevent excessive log output in production.
| throw new Error("Failed to uncompress file '" + loadedFile + "' - " + uncompressed.error); | ||
| } | ||
|
|
||
| console.log("Unzipped '" + loadedFile + "'"); |
Copilot
AI
Jul 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This final console.log is useful for debugging but might be noisy in a production environment; consider using a configurable logger.
Summary
unzipSyncAPI)src/lib/jsunzip.jsfile completelyunzipDiscImage(),unzipRomImage(),ungzip()Technical Decisions
Testing
Files Changed
src/utils.js: Updated compression/decompression functionspackage.json: Added fflate and pako dependenciessrc/lib/jsunzip.js: Removed (628 lines deleted)src/lib/README: Updated to remove jsunzip referencetests/unit/test-zip.js: New comprehensive ZIP teststests/unit/zip/directory🤖 Generated with Claude Code