diff --git a/.changeset/nice-needles-guess.md b/.changeset/nice-needles-guess.md
new file mode 100644
index 00000000..91534216
--- /dev/null
+++ b/.changeset/nice-needles-guess.md
@@ -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`.
diff --git a/.changeset/pre.json b/.changeset/pre.json
new file mode 100644
index 00000000..95e4a5f6
--- /dev/null
+++ b/.changeset/pre.json
@@ -0,0 +1,8 @@
+{
+ "mode": "pre",
+ "tag": "beta",
+ "initialVersions": {
+ "zxing-wasm": "1.3.4"
+ },
+ "changesets": []
+}
diff --git a/.coderabbit.yaml b/.coderabbit.yaml
new file mode 100644
index 00000000..0d1ce03d
--- /dev/null
+++ b/.coderabbit.yaml
@@ -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
diff --git a/.github/workflows/preview-release.yml b/.github/workflows/preview-release.yml
index 5b9c7579..66d3c15f 100644
--- a/.github/workflows/preview-release.yml
+++ b/.github/workflows/preview-release.yml
@@ -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
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 95189273..eb27c24d 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -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
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 8965566b..44c350d8 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -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
diff --git a/README.md b/README.md
index 035fb877..e22f8da2 100644
--- a/README.md
+++ b/README.md
@@ -2,91 +2,114 @@
[![npm](https://img.shields.io/npm/v/zxing-wasm)](https://www.npmjs.com/package/zxing-wasm/v/latest) [![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/zxing-wasm)](https://www.npmjs.com/package/zxing-wasm/v/latest) [![jsDelivr hits](https://img.shields.io/jsdelivr/npm/hm/zxing-wasm?color=%23ff5627)](https://cdn.jsdelivr.net/npm/zxing-wasm@latest/) [![deploy status](https://github.com/Sec-ant/zxing-wasm/actions/workflows/deploy.yml/badge.svg)](https://github.com/Sec-ant/zxing-wasm/actions/workflows/deploy.yml)
-[ZXing-C++](https://github.com/zxing-cpp/zxing-cpp) WebAssembly as an ES/CJS module with types. Read or write barcodes in various JS runtimes: web, node, bun and deno.
-
-Visit [this online demo](https://zxing-wasm-demo.deno.dev/) to quickly explore its basic functions. It works best on the latest chromium browsers.
+[ZXing-C++](https://github.com/zxing-cpp/zxing-cpp) WebAssembly as an ES/CJS module with types. Read or write barcodes in various JS runtimes: Web, Node.js, Bun, and Deno.
+
+
+
+| Barcode Format | Linear Barcode | Matrix Barcode | Reading Support | Writing Support |
+| :---------------: | :------------: | :------------: | :-------------: | :-------------: |
+| `Aztec` | | ✅ | ✅ | ✅ |
+| `Codabar` | ✅ | | ✅ | ✅ |
+| `Code39` | ✅ | | ✅ | ✅ |
+| `Code93` | ✅ | | ✅ | ✅ |
+| `Code128` | ✅ | | ✅ | ✅ |
+| `DataBar` | ✅ | | ✅ | ✅ |
+| `DataBarLimited` | ✅ | | ✅ | ✅ |
+| `DataBarExpanded` | ✅ | | ✅ | ✅ |
+| `DataMatrix` | | ✅ | ✅ | ✅ |
+| `DXFilmEdge` | ✅ | | ✅ | |
+| `EAN-8` | ✅ | | ✅ | ✅ |
+| `EAN-13` | ✅ | | ✅ | ✅ |
+| `ITF` | ✅ | | ✅ | ✅ |
+| `MaxiCode` | | ✅ | ✅ | ✅ |
+| `PDF417` | | ✅ | ✅ | ✅ |
+| `QRCode` | | ✅ | ✅ | ✅ |
+| `MicroQRCode` | | ✅ | ✅ | ✅ |
+| `rMQRCode` | | ✅ | ✅ | ✅ |
+| `UPC-A` | ✅ | | ✅ | ✅ |
+| `UPC-E` | ✅ | | ✅ | ✅ |
+
+
+
+
## Build
```bash
git clone --recurse-submodules https://github.com/Sec-ant/zxing-wasm
cd zxing-wasm
-# install pnpm first:
+
+# Install pnpm before executing the next command:
# https://pnpm.io/installation
pnpm i --frozen-lockfile
-# install cmake first:
+
+# Install CMake before executing the next command:
# https://cmake.org/download/
pnpm cmake
-# install emscripten first:
+
+# Install Emscripten before executing the next command:
# https://emscripten.org/docs/getting_started/downloads.html
pnpm build:wasm
+
pnpm build
```
## Install
-```
+```bash
npm i zxing-wasm
```
## Documentation
-https://zxing-wasm.deno.dev/
+
-## Demo
+
## Usage
-This package exports 3 subpaths: `full`, `reader` and `writer`. You can choose whichever fits your needs. If you use TypeScript, you should set [`moduleResolution`](https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution) to [`bundler`](https://www.typescriptlang.org/docs/handbook/modules/reference.html#bundler), [`node16` or `nodenext`](https://www.typescriptlang.org/docs/handbook/modules/reference.html#node16-nodenext-1) in your `tsconfig.json` file to properly resolve the exported module.
+This package exports three subpaths: `full`, `reader`, and `writer`. You can choose the one that fits your needs. If you use TypeScript, you should set [`moduleResolution`](https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution) to [`bundler`](https://www.typescriptlang.org/docs/handbook/modules/reference.html#bundler), [`node16`, or `nodenext`](https://www.typescriptlang.org/docs/handbook/modules/reference.html#node16-nodenext-1) in your `tsconfig.json` file to properly resolve the exported module.
### `zxing-wasm` or `zxing-wasm/full`
-These 2 subpaths include functions to both read and write barcodes. The wasm binary size is ~1.19 MB.
+These two subpaths provide functions to read and write barcodes. The wasm binary size is ~1.30 MB.
```ts
-import {
- readBarcodesFromImageFile,
- readBarcodesFromImageData,
- writeBarcodeToImageFile,
-} from "zxing-wasm";
+import { readBarcodes, writeBarcode } from "zxing-wasm";
```
or
```ts
-import {
- readBarcodesFromImageFile,
- readBarcodesFromImageData,
- writeBarcodeToImageFile,
-} from "zxing-wasm/full";
+import { readBarcodes, writeBarcode } from "zxing-wasm/full";
```
### `zxing-wasm/reader`
-This subpath only includes functions to read barcodes. The wasm binary size is ~917 KB.
+This subpath only provides a function to read barcodes. The wasm binary size is ~906 KB.
```ts
-import {
- readBarcodesFromImageFile,
- readBarcodesFromImageData,
-} from "zxing-wasm/reader";
+import { readBarcodes } from "zxing-wasm/reader";
```
### `zxing-wasm/writer`
-This subpath only includes a function to write barcodes. The wasm binary size is ~366 KB.
+This subpath only provides a function to write barcodes. The wasm binary size is ~1.17 MB.
```ts
-import { writeBarcodeToImageFile } from "zxing-wasm/writer";
+import { writeBarcode } from "zxing-wasm/writer";
```
### IIFE Scripts
-Apart from ES and CJS modules, this package also ships IIFE scripts. The registered global variable is named `ZXingWASM`.
+Apart from ES and CJS modules, this package also ships IIFE scripts. The registered global variable is named `ZXingWASM`, where you can access all the exported functions and variables under it.
+
+> [!NOTE]
+> Replace the `` with the desired version number.
```html
@@ -99,26 +122,16 @@ Apart from ES and CJS modules, this package also ships IIFE scripts. The registe
```
-### [`readBarcodesFromImageFile`](https://zxing-wasm.deno.dev/functions/full.readBarcodesFromImageFile.html) and [`readBarcodesFromImageData`](https://zxing-wasm.deno.dev/functions/full.readBarcodesFromImageData.html)
-
-These 2 functions are for reading barcodes.
+### [`readBarcodes`](https://zxing-wasm.deno.dev/functions/full.readBarcodes.html)
-[`readBarcodesFromImageFile`](https://zxing-wasm.deno.dev/functions/full.readBarcodesFromImageFile.html) accepts an image [`Blob`](https://developer.mozilla.org/docs/Web/API/Blob) or an image [`File`](https://developer.mozilla.org/docs/Web/API/File) as the first input. They're encoded images, e.g. `.png` `.jpg` files.
+[`readBarcodes`](https://zxing-wasm.deno.dev/functions/full.readBarcodes.html) accepts an image [`Blob`](https://developer.mozilla.org/docs/Web/API/Blob), image [`File`](https://developer.mozilla.org/docs/Web/API/File), or an [`ImageData`](https://developer.mozilla.org/docs/Web/API/ImageData) as its first argument, and various options are supported in [`ReaderOptions`](https://zxing-wasm.deno.dev/interfaces/full.ReaderOptions.html) as an optional second argument.
-[`readBarcodesFromImageData`](https://zxing-wasm.deno.dev/functions/full.readBarcodesFromImageData.html) accepts an [`ImageData`](https://developer.mozilla.org/docs/Web/API/ImageData) as the first input. They're raw pixels that usually acquired from [`