Skip to content
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

Version Packages #193

Merged
merged 3 commits into from
Jan 5, 2025
Merged

Version Packages #193

merged 3 commits into from
Jan 5, 2025

Conversation

Sec-ant
Copy link
Owner

@Sec-ant Sec-ant commented Jan 5, 2025

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

Releases

[email protected]

This release introduces a major refactoring of the underlying Embind APIs and read / write functions. Key changes include a new set of default reader options, enhanced writer capabilities backed by zint, and updated APIs for reading and writing barcodes. These changes break backward compatibility, so we are upgrading to the next major version.

Breaking Changes

Consolidated Reader Function

readBarcodes(...) replaces both readBarcodesFromImageFile(...) and readBarcodesFromImageData(...). The new function can accept either a Blob or an ImageData as its input.

Note

The v1 reader functions readBarcodesFromImageFile and readBarcodesFromImageData are still kept for a smooth migration experience, but marked as deprecated.

Updated Reader Options

A few reader options have changed their default values. This change is to align with the latest ZXing C++ library and provide a more consistent experience across different platforms:

  1. tryCode39ExtendedMode is now true by default. It was previously false.
  2. eanAddOnSymbol is now "Ignore" by default. It was previously "Read".
  3. textMode is now "HRI" by default. It was previously "Plain".

Some deprecated options have been removed, see zxing-cpp#704 for more details:

  1. validateCode39CheckSum is now removed. The Code39 symbol has a valid checksum if the third character of the symbologyIdentifier is an odd digit.
  2. validateITFCheckSum is now removed. The ITF symbol has a valid checksum if the third character of the symbologyIdentifier is a '1'.
  3. returnCodabarStartEnd is now removed. The detected results of Codabar symbols now always include the start and end characters.

eccLevel in Read Result Renamed to ecLevel

In ReadResult, the eccLevel field has been renamed to ecLevel. It now holds strings like "L", "M", "Q", or "H" or stringified numeric percentage values for error correction levels. An empty string indicates that the error correction level is not applicable.

Note

The eccLevel field is still kept for a smooth migration experience, but marked as deprecated.

Renamed & Enhanced Writer Function

writeBarcode(...) replaces writeBarcodeToImageFile(...). This function is now powered by the new zint backend which supports all available formats that are currently supported by the reader. It accepts either a string text or an Uint8Array binary data as its input for barcode generation, and provides new output formats (e.g. SVG, UTF-8) in addition to the an image file blob.

The WriterOptions object has also been updated completely.

Note

The final shape of the writeBarcode function is still under discussion. The current implementation is subject to change.

.wasm Module Initialization / Caching Overhaul

prepareZXingModule(...) replaces both setZXingModuleOverrides(...) and getZXingModuleOverrides(...). The new function provides a more flexible way to initialize the ZXing module with custom options.

Note

The v1 module initialization functions setZXingModuleOverrides and getZXingModuleOverrides are still kept for a smooth migration experience, but marked as deprecated.

purgeZXingModule now only clears the relevant module cache from where it is imported. It no longer resets the global module cache.

Redefined BarcodeFormat-Family Types

None is removed from the BarcodeFormat union type. New types like LinearBarcodeFormat, MatrixBarcodeFormat and LooseBarcodeFormat are introduced. See barcodeFormat.ts for more details.

New Features & Enhancements

More Barcode Formats Supported in Writer

The new writeBarcode function supports more barcode formats than the previous writeBarcodeToImageFile. All barcode formats supported by the reader are now supported by the writer.

New tryDenoise Option for Reading Barcodes

The new tryDenoise option in ReaderOptions allows you to enable or disable the denoising algorithm when reading barcodes. This is an experimental feature. By default, it is set to false.

Bug Fixes

Fix TS moduleResolution: node Subpath Exports Resolution

The subpath export types are now compatible with TypeScript's moduleResolution: node strategy by using the types-versions-wildcards strategy. This package now passes all the arethetypeswrong checks.

Summary by CodeRabbit

  • Breaking Changes

    • Major refactoring of barcode reading and writing functions
    • Consolidated reader functions into readBarcodes()
    • Updated module initialization with prepareZXingModule()
    • Renamed eccLevel to ecLevel
  • New Features

    • Added support for more barcode formats
    • Introduced experimental tryDenoise option
    • Enhanced writer function with SVG and UTF-8 support
  • Improvements

    • Updated reader options to align with ZXing C++ library
    • Improved type resolution and TypeScript compatibility
    • Fixed size issue of the zxing_writer.wasm file

Copy link

coderabbitai bot commented Jan 5, 2025

Walkthrough

This pull request represents a major version 2.0.0 release of the zxing-wasm library, introducing significant refactoring of Embind APIs and barcode read/write functions. The changes consolidate reader and writer functions, update reader options, rename certain fields, and introduce new initialization and module management approaches. The release marks a substantial evolution of the library's functionality and API design.

Changes

File Change Summary
.changeset/* Deleted changeset files documenting version 2.0.0 release details
CHANGELOG.md Updated with comprehensive details of version 2.0.0 breaking changes
package.json Version updated from 2.0.0-beta.4 to 2.0.0

Sequence Diagram

sequenceDiagram
    participant User
    participant ZXingModule
    participant BarcodeReader
    participant BarcodeWriter

    User->>ZXingModule: prepareZXingModule(...)
    ZXingModule-->>User: Module initialized

    User->>BarcodeReader: readBarcodes(input)
    BarcodeReader-->>User: ReadResult with ecLevel

    User->>BarcodeWriter: writeBarcode(options)
    BarcodeWriter-->>User: Generated barcode
Loading

Possibly related PRs

Poem

🐰 Hop, hop, through barcode lands so bright,
APIs refactored with pure delight!
From beta's cage to version two,
ZXing-wasm, a rabbit's breakthrough!
Decoding magic, now sleek and clean,
A library's journey, forever keen! 🔍


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
CHANGELOG.md (3)

51-51: Consider clarifying the implementation status

The phrase "under discussion" could be more specific. Consider rewording to clarify the current status and potential changes, e.g., "The API design of the writeBarcode function is being finalized."

- > The final shape of the `writeBarcode` function is still under discussion. The current implementation is subject to change.
+ > The API design of the `writeBarcode` function is being finalized. The current implementation is subject to change.
🧰 Tools
🪛 LanguageTool

[style] ~51-~51: ‘under discussion’ might be wordy. Consider a shorter alternative.
Context: ...of the writeBarcode function is still under discussion. The current implementation is subject ...

(EN_WORDINESS_PREMIUM_UNDER_DISCUSSION)


69-71: Consider adding more details about the denoising algorithm

While the experimental status is clearly marked, it would be helpful to provide more information about:

  1. The type of noise this algorithm addresses
  2. Expected performance impact
  3. Use cases where it might be beneficial

75-78: Consider consistent list formatting

For better readability, consider using consistent bullet points throughout:

- 615a321: - Add `DXFilmEdge` writing support.
-   - Fix subpath exports TS compatibility with types-versions-wildcards strategy. Check [this](https://github.com/andrewbranch/example-subpath-exports-ts-compat/tree/main/examples/node_modules/types-versions-wildcards) for more information.
-   - Add types to `.wasm` subpath exports.
-   - Add `ImageData` ambient type export.
+ 615a321:
+   - Add `DXFilmEdge` writing support
+   - Fix subpath exports TS compatibility with types-versions-wildcards strategy. Check [this](https://github.com/andrewbranch/example-subpath-exports-ts-compat/tree/main/examples/node_modules/types-versions-wildcards) for more information
+   - Add types to `.wasm` subpath exports
+   - Add `ImageData` ambient type export
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 775de46 and e2461ad.

📒 Files selected for processing (8)
  • .changeset/healthy-mugs-dress.md (0 hunks)
  • .changeset/nice-needles-guess.md (0 hunks)
  • .changeset/plenty-files-thank.md (0 hunks)
  • .changeset/pre.json (0 hunks)
  • .changeset/stupid-rules-travel.md (0 hunks)
  • .changeset/wise-planes-reply.md (0 hunks)
  • CHANGELOG.md (1 hunks)
  • package.json (1 hunks)
💤 Files with no reviewable changes (6)
  • .changeset/wise-planes-reply.md
  • .changeset/healthy-mugs-dress.md
  • .changeset/plenty-files-thank.md
  • .changeset/pre.json
  • .changeset/stupid-rules-travel.md
  • .changeset/nice-needles-guess.md
✅ Files skipped from review due to trivial changes (1)
  • package.json
🧰 Additional context used
🪛 LanguageTool
CHANGELOG.md

[style] ~51-~51: ‘under discussion’ might be wordy. Consider a shorter alternative.
Context: ...of the writeBarcode function is still under discussion. The current implementation is subject ...

(EN_WORDINESS_PREMIUM_UNDER_DISCUSSION)

🔇 Additional comments (2)
CHANGELOG.md (2)

3-10: Well-structured version announcement!

The introduction clearly communicates the scope and impact of this major release, with proper references to external dependencies.


Line range hint 86-392: Well-maintained version history!

The beta releases and previous versions are properly documented with consistent formatting and clear traceability to changes.

🧰 Tools
🪛 LanguageTool

[style] ~51-~51: ‘under discussion’ might be wordy. Consider a shorter alternative.
Context: ...of the writeBarcode function is still under discussion. The current implementation is subject ...

(EN_WORDINESS_PREMIUM_UNDER_DISCUSSION)

Copy link

pkg-pr-new bot commented Jan 5, 2025

Open in Stackblitz

npm i https://pkg.pr.new/zxing-wasm@193

commit: a002af7

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
CHANGELOG.md (3)

41-41: Fix grammar and improve conciseness

There are two minor issues in the text:

  1. Line 41: Remove the duplicate determiner "the" in "...in addition to the an image file blob"
  2. Line 47: Consider replacing "under discussion" with "in review" or "pending finalization" for better conciseness
-...in addition to the an image file blob.
+...in addition to an image file blob.

-The final shape of the `writeBarcode` function is still under discussion.
+The final shape of the `writeBarcode` function is still in review.

Also applies to: 47-47

🧰 Tools
🪛 LanguageTool

[grammar] ~41-~41: Two determiners in a row. Choose either “the” or “an”.
Context: ...ormats (e.g. SVG, UTF-8) in addition to the an image file blob. The WriterOptions o...

(DT_DT)


7-62: Consider enhancing migration documentation

The breaking changes are well documented, but developers would benefit from a dedicated migration guide with code examples showing how to transition from v1 to v2. This is particularly important for:

  1. Transitioning from separate read functions to the unified readBarcodes
  2. Updating code that relies on the changed default values
  3. Migrating from the old module initialization to prepareZXingModule

Would you like me to help create a migration guide with code examples that demonstrates these transitions?

🧰 Tools
🪛 LanguageTool

[grammar] ~41-~41: Two determiners in a row. Choose either “the” or “an”.
Context: ...ormats (e.g. SVG, UTF-8) in addition to the an image file blob. The WriterOptions o...

(DT_DT)


[style] ~47-~47: ‘under discussion’ might be wordy. Consider a shorter alternative.
Context: ...of the writeBarcode function is still under discussion. The current implementation is subject ...

(EN_WORDINESS_PREMIUM_UNDER_DISCUSSION)


69-71: Enhance visibility of experimental features

Consider making the experimental status of the tryDenoise option more prominent, perhaps by:

  1. Adding a warning box similar to the NOTE boxes used elsewhere
  2. Including information about potential impacts on performance or accuracy
  3. Adding examples of scenarios where denoising might be beneficial
#### New `tryDenoise` Option for Reading Barcodes

+> [!WARNING]
+> The `tryDenoise` option is experimental and may impact performance or accuracy.
+
The new `tryDenoise` option in `ReaderOptions` allows you to enable or disable the denoising algorithm when reading barcodes. This is an experimental feature. By default, it is set to `false`.
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e2461ad and 75d80cf.

📒 Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
CHANGELOG.md

[grammar] ~41-~41: Two determiners in a row. Choose either “the” or “an”.
Context: ...ormats (e.g. SVG, UTF-8) in addition to the an image file blob. The WriterOptions o...

(DT_DT)


[style] ~47-~47: ‘under discussion’ might be wordy. Consider a shorter alternative.
Context: ...of the writeBarcode function is still under discussion. The current implementation is subject ...

(EN_WORDINESS_PREMIUM_UNDER_DISCUSSION)

🔇 Additional comments (1)
CHANGELOG.md (1)

73-78: LGTM! Well-documented bug fix

The TypeScript compatibility fix is well-documented with clear explanations and helpful references to external resources.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
CHANGELOG.md (4)

7-62: Enhance breaking changes documentation with migration examples

The breaking changes section is comprehensive but could be more actionable for users upgrading from v1.x to v2.0.0.

Consider adding:

  1. A migration guide with code examples showing before/after changes for each breaking change
  2. Clear deprecation warnings that users will encounter if using old APIs
  3. A compatibility matrix showing which features are:
    • Removed completely
    • Deprecated but functional
    • New replacements

63-72: Expand documentation for new features

The new features section would benefit from additional details to help users understand and adopt these features effectively.

Consider adding:

  1. A complete list of newly supported barcode formats
  2. Technical details about the denoising algorithm:
    • How it works
    • Performance implications
    • Use cases where it's most effective
  3. Code examples demonstrating these new features

73-78: Add context for TypeScript compatibility fix

The TypeScript module resolution fix would benefit from additional context to help users understand if they're affected.

Consider adding:

  1. Symptoms users might have encountered with the old behavior
  2. Required changes in tsconfig.json, if any
  3. Example configurations for different TypeScript environments

1-78: Enhance changelog structure for better navigation

The changelog is well-documented but could be more user-friendly with some structural improvements.

Consider adding:

  1. A table of contents at the top with anchor links to each section
  2. A version comparison table highlighting key differences between v1.x and v2.0.0
  3. A "Quick Start" section for users wanting to immediately upgrade
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 75d80cf and a002af7.

📒 Files selected for processing (1)
  • CHANGELOG.md (1 hunks)

@Sec-ant Sec-ant merged commit 52c215c into main Jan 5, 2025
7 checks passed
@Sec-ant Sec-ant deleted the changeset-release/main branch January 5, 2025 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant