Skip to content

Commit

Permalink
breaking: v2 (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sec-ant authored Dec 25, 2024
1 parent 7fae1da commit 1a77296
Show file tree
Hide file tree
Showing 5,150 changed files with 17,223 additions and 11,163 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
71 changes: 71 additions & 0 deletions .changeset/nice-needles-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
"zxing-wasm": major
---

# V2: Breaking Release - Next Major Version

This release introduces a major refactoring of the underlying Embind APIs and read / write functions. Key changes include transitioning away from [Embind Enums](https://emscripten.org/docs/porting/connecting_cpp_and_javascript/embind.html#enums) toward numeric encoding and decoding, a new set of default reader options, enhanced writer capabilities backed by [`zint`](https://sourceforge.net/projects/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

### Renamed & Consolidated Reader Function

`readBarcodes(...)` replaces both `readBarcodesFromImageFile(...)` and `readBarcodesFromImageData(...)`. The new function unifies code paths for `Blob` and `ImageData` inputs.

> [!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](https://github.com/zxing-cpp/zxing-cpp/discussions/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 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(...)`. The new function is powered by the new [`zint`](https://sourceforge.net/projects/zint/) writer, which supports more barcode formats, supports both `string` and `Uint8Array` inputs for generating barcodes from text or binary data, and provides new output formats (e.g. SVG, UTF-8) in addition to the binary image file output.

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.
### 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.

## 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 except for `DXFilmEdge` 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 and by default, it is set to `false`.
8 changes: 8 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"mode": "pre",
"tag": "beta",
"initialVersions": {
"zxing-wasm": "1.3.4"
},
"changesets": []
}
97 changes: 97 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
language: en-US
tone_instructions: ""
early_access: false
enable_free_tier: true
reviews:
profile: chill
request_changes_workflow: false
high_level_summary: true
high_level_summary_placeholder: "@coderabbitai summary"
auto_title_placeholder: "@coderabbitai"
review_status: true
commit_status: true
collapse_walkthrough: false
changed_files_summary: true
sequence_diagrams: true
assess_linked_issues: true
related_issues: true
related_prs: true
suggested_labels: true
suggested_reviewers: true
poem: true
labeling_instructions: []
path_filters: ["!tests/__snapshots__/**"]
path_instructions: []
abort_on_close: true
auto_review:
enabled: true
auto_incremental_review: true
ignore_title_keywords: []
labels: []
drafts: false
base_branches: []
tools:
shellcheck:
enabled: true
ruff:
enabled: true
markdownlint:
enabled: true
github-checks:
enabled: true
timeout_ms: 90000
languagetool:
enabled: true
enabled_only: false
level: default
biome:
enabled: true
hadolint:
enabled: true
swiftlint:
enabled: true
phpstan:
enabled: true
level: default
golangci-lint:
enabled: true
yamllint:
enabled: true
gitleaks:
enabled: true
checkov:
enabled: true
detekt:
enabled: true
eslint:
enabled: true
rubocop:
enabled: true
buf:
enabled: true
regal:
enabled: true
actionlint:
enabled: true
pmd:
enabled: true
cppcheck:
enabled: true
semgrep:
enabled: true
circleci:
enabled: true
chat:
auto_reply: true
knowledge_base:
opt_out: false
learnings:
scope: auto
issues:
scope: auto
jira:
project_keys: []
linear:
team_keys: []
pull_requests:
scope: auto
2 changes: 1 addition & 1 deletion .github/workflows/preview-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
submodules: recursive

- name: Setup
uses: ./.github/actions/setup
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
submodules: recursive

- name: Setup
uses: ./.github/actions/setup
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
submodules: recursive

- name: Setup
uses: ./.github/actions/setup
Expand Down
Loading

0 comments on commit 1a77296

Please sign in to comment.