{"id":15011512,"url":"https://github.com/sec-ant/zxing-wasm","last_synced_at":"2025-04-08T11:09:02.320Z","repository":{"id":151240507,"uuid":"622959982","full_name":"Sec-ant/zxing-wasm","owner":"Sec-ant","description":"ZXing-C++ WebAssembly as an ES/CJS module with types. Read or write barcodes in various JS runtimes: Web, Node.js, Bun, and Deno.","archived":false,"fork":false,"pushed_at":"2025-04-05T12:22:54.000Z","size":2925,"stargazers_count":114,"open_issues_count":8,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-08T11:08:49.906Z","etag":null,"topics":["barcode","bun","deno","esmodule","node","qrcode","typescript","wasm","web","webassembly","zxing","zxing-cpp"],"latest_commit_sha":null,"homepage":"https://zxing-wasm.deno.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sec-ant.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-03T12:15:28.000Z","updated_at":"2025-04-08T03:22:06.000Z","dependencies_parsed_at":"2023-12-25T21:09:59.416Z","dependency_job_id":"b9c57af2-11d5-48b5-b05c-17952e502459","html_url":"https://github.com/Sec-ant/zxing-wasm","commit_stats":{"total_commits":311,"total_committers":7,"mean_commits":44.42857142857143,"dds":0.2861736334405145,"last_synced_commit":"29492eb0101c894f7f85e1d6040b6502d92a02ed"},"previous_names":[],"tags_count":61,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sec-ant%2Fzxing-wasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sec-ant%2Fzxing-wasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sec-ant%2Fzxing-wasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sec-ant%2Fzxing-wasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sec-ant","download_url":"https://codeload.github.com/Sec-ant/zxing-wasm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247829491,"owners_count":21002995,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["barcode","bun","deno","esmodule","node","qrcode","typescript","wasm","web","webassembly","zxing","zxing-cpp"],"created_at":"2024-09-24T19:41:11.117Z","updated_at":"2025-04-08T11:09:02.300Z","avatar_url":"https://github.com/Sec-ant.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable MD041 MD033 --\u003e\n\n\u003e [!NOTE]\n\u003e\n\u003e For the v1 release, please visit the [`channel/v1`](https://www.github.com/Sec-ant/zxing-wasm/tree/channel/v1) branch.\n\n# zxing-wasm\n\n[![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)\n\n[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.\n\n\u003cdiv align=\"center\"\u003e\n\n|  Barcode Format   | Linear Barcode | Matrix Barcode | Reading Support | Writing Support |\n| :---------------: | :------------: | :------------: | :-------------: | :-------------: |\n|      `Aztec`      |                |       ✅       |       ✅        |       ✅        |\n|     `Codabar`     |       ✅       |                |       ✅        |       ✅        |\n|     `Code39`      |       ✅       |                |       ✅        |       ✅        |\n|     `Code93`      |       ✅       |                |       ✅        |       ✅        |\n|     `Code128`     |       ✅       |                |       ✅        |       ✅        |\n|     `DataBar`     |       ✅       |                |       ✅        |       ✅        |\n| `DataBarLimited`  |       ✅       |                |       ✅        |       ✅        |\n| `DataBarExpanded` |       ✅       |                |       ✅        |       ✅        |\n|   `DataMatrix`    |                |       ✅       |       ✅        |       ✅        |\n|   `DXFilmEdge`    |       ✅       |                |       ✅        |       ✅        |\n|      `EAN-8`      |       ✅       |                |       ✅        |       ✅        |\n|     `EAN-13`      |       ✅       |                |       ✅        |       ✅        |\n|       `ITF`       |       ✅       |                |       ✅        |       ✅        |\n|    `MaxiCode`     |                |       ✅       |       ✅[^1]    |       ✅        |\n|     `PDF417`      |                |       ✅       |       ✅        |       ✅        |\n|     `QRCode`      |                |       ✅       |       ✅        |       ✅        |\n|   `MicroQRCode`   |                |       ✅       |       ✅        |       ✅        |\n|    `rMQRCode`     |                |       ✅       |       ✅        |       ✅        |\n|      `UPC-A`      |       ✅       |                |       ✅        |       ✅        |\n|      `UPC-E`      |       ✅       |                |       ✅        |       ✅        |\n\n[^1]: Reading support for `MaxiCode` requires a pure monochrome image that contains an unrotated and unskewed symbol, along with a sufficient white border surrounding it.\n\n\u003c/div\u003e\n\nVisit [this online demo](https://zxing-wasm-demo.deno.dev/) to quickly explore its basic reading functions. It works best on the latest Chromium browsers.\n\n## Build\n\n```bash\ngit clone --recurse-submodules https://github.com/Sec-ant/zxing-wasm\ncd zxing-wasm\n\n# Install pnpm before executing the next command:\n# https://pnpm.io/installation\npnpm i --frozen-lockfile\n\n# Install CMake before executing the next command:\n# https://cmake.org/download/\n# Install Emscripten before executing the next command:\n# https://emscripten.org/docs/getting_started/downloads.html\npnpm build:wasm\n\npnpm build\n```\n\n## Install\n\n```bash\nnpm i zxing-wasm\n```\n\n## Documentation\n\n\u003chttps://zxing-wasm.deno.dev/\u003e\n\n## Demo\n\nDemo page: https://zxing-wasm-demo.deno.dev/\n\nDemo source: https://github.com/Sec-ant/zxing-wasm-demo\n\n## Usage\n\nThis package exports three subpaths: `full`, `reader`, and `writer`.\n\n### `zxing-wasm` or `zxing-wasm/full`\n\nThese two subpaths provide functions to read and write barcodes. The wasm binary size is ~1.30 MB.\n\n```ts\nimport { readBarcodes, writeBarcode } from \"zxing-wasm\";\n```\n\nor\n\n```ts\nimport { readBarcodes, writeBarcode } from \"zxing-wasm/full\";\n```\n\n### `zxing-wasm/reader`\n\nThis subpath only provides a function to read barcodes. The wasm binary size is ~907 KB.\n\n```ts\nimport { readBarcodes } from \"zxing-wasm/reader\";\n```\n\n### `zxing-wasm/writer`\n\nThis subpath only provides a function to write barcodes. The wasm binary size is ~594 KB.\n\n```ts\nimport { writeBarcode } from \"zxing-wasm/writer\";\n```\n\n### IIFE Scripts\n\nApart 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.\n\n\u003e [!NOTE]\n\u003e Replace the `\u003cversion\u003e` with the desired version number.\n\n```html\n\u003c!-- full --\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/zxing-wasm@\u003cversion\u003e/dist/iife/full/index.js\"\u003e\u003c/script\u003e\n\n\u003c!-- reader --\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/zxing-wasm@\u003cversion\u003e/dist/iife/reader/index.js\"\u003e\u003c/script\u003e\n\n\u003c!-- writer --\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/zxing-wasm@\u003cversion\u003e/dist/iife/writer/index.js\"\u003e\u003c/script\u003e\n```\n\n### [`readBarcodes`](https://zxing-wasm.deno.dev/functions/full.readBarcodes.html)\n\n[`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), [`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array), 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.\n\nThe return result of this function is a `Promise` of an array of [`ReadResult`](https://zxing-wasm.deno.dev/interfaces/full.ReadResult.html)s.\n\ne.g.\n\n```ts\nimport { readBarcodes, type ReaderOptions } from \"zxing-wasm/reader\";\n\nconst readerOptions: ReaderOptions = {\n  tryHarder: true,\n  formats: [\"QRCode\"],\n  maxNumberOfSymbols: 1,\n};\n\n/**\n * Read from image file/blob\n */\nconst imageFile = await fetch(\n  \"https://api.qrserver.com/v1/create-qr-code/?size=150x150\u0026data=Hello%20world!\",\n).then((resp) =\u003e resp.blob());\n\nconst imageFileReadResults = await readBarcodes(imageFile, readerOptions);\n\nconsole.log(imageFileReadResults[0].text); // Hello world!\n\n/**\n * Read from image data\n */\nconst imageData = await createImageBitmap(imageFile).then((imageBitmap) =\u003e {\n  const { width, height } = imageBitmap;\n  const context = new OffscreenCanvas(width, height).getContext(\n    \"2d\",\n  ) as OffscreenCanvasRenderingContext2D;\n  context.drawImage(imageBitmap, 0, 0, width, height);\n  return context.getImageData(0, 0, width, height);\n});\n\nconst imageDataReadResults = await readBarcodes(imageData, readerOptions);\n\nconsole.log(imageDataReadResults[0].text); // Hello world!\n```\n\n### [`writeBarcode`](https://zxing-wasm.deno.dev/functions/full.writeBarcode.html)\n\nThe first argument of [`writeBarcode`](https://zxing-wasm.deno.dev/functions/full.writeBarcode.html) is a text string or an [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) of bytes to be encoded, and the optional second argument [`WriterOptions`](https://zxing-wasm.deno.dev/interfaces/full.WriterOptions.html) accepts several writer options.\n\nThe return result of this function is a `Promise` of a [`WriteResult`](https://zxing-wasm.deno.dev/interfaces/full.WriteResult.html).\n\ne.g.\n\n```ts\nimport { writeBarcode, type WriterOptions } from \"zxing-wasm/writer\";\n\nconst writerOptions: WriterOptions = {\n  format: \"QRCode\",\n  scale: 3,\n};\n\nconst writeOutput = await writeBarcode(\"Hello world!\", writerOptions);\n\nconsole.log(writeOutput.svg); // An SVG string.\nconsole.log(writeOutput.utf8); // A multi-line string made up of \" \", \"▀\", \"▄\", \"█\" characters.\nconsole.log(writeOutput.image); // A PNG image blob.\n```\n\n## Configuring `.wasm` Serving\n\n### Serving via Web or CDN\n\nWhen using this package, a `.wasm` binary file needs to be served somewhere, so the runtime can fetch, compile and instantiate the WASM module. To provide a smooth development experience, the serve path is automatically assigned a [jsDelivr CDN](https://fastly.jsdelivr.net/npm/zxing-wasm/) URL upon build.\n\nIf you want to change the serve path to your own server or other CDNs, please use [`prepareZXingModule`](https://zxing-wasm.deno.dev/functions/full.prepareZXingModule.html) and pass an [`overrides`](http://localhost:4173/interfaces/full.PrepareZXingModuleOptions.html#overrides) object with a custom defined [`locateFile`](https://emscripten.org/docs/api_reference/module.html?highlight=locatefile#Module.locateFile) function before reading or writing barcodes. `locateFile` is one of the [Emscripten `Module` attribute hooks](https://emscripten.org/docs/api_reference/module.html#affecting-execution) that can affect the code execution of the `Module` object during its lifecycle.\n\ne.g.\n\n```ts\nimport { prepareZXingModule, writeBarcode } from \"zxing-wasm\";\n\n// Override the locateFile function\nprepareZXingModule({\n  overrides: {\n    locateFile: (path, prefix) =\u003e {\n      if (path.endsWith(\".wasm\")) {\n        return `https://unpkg.com/zxing-wasm@2/dist/full/${path}`;\n      }\n      return prefix + path;\n    },\n  },\n});\n\n// Call read or write functions afterward\nconst writeOutput = await writeBarcode(\"Hello world!\");\n```\n\n\u003e [!NOTE]\n\u003e\n\u003e The default jsDelivr CDN serve path is also achieved by overriding the custom `locateFile` function:\n\u003e\n\u003e ```ts\n\u003e const DEFAULT_MODULE_OVERRIDES: ZXingModuleOverrides = {\n\u003e   locateFile: (path, prefix) =\u003e {\n\u003e     const match = path.match(/_(.+?)\\.wasm$/);\n\u003e     if (match) {\n\u003e       return `https://fastly.jsdelivr.net/npm/zxing-wasm@${ZXING_WASM_VERSION}/dist/${match[1]}/${path}`;\n\u003e     }\n\u003e     return prefix + path;\n\u003e   },\n\u003e };\n\u003e ```\n\u003e\n\u003e However, `overrides` is atomic. If you override other `Module` attributes, you _probably_ should also provide a `locateFile` function to ensure the `.wasm` file is fetched correctly.\n\n### Integrating in Non-Web Runtimes\n\nIf you want to use this library in non-web runtimes (such as Node.js, Bun, Deno, etc.) without setting up a server, there are several possible approaches. Because API support can differ between runtime environments and versions, you may need to adapt these examples or choose alternative methods depending on your specific runtime’s capabilities. Below are some example configurations for Node.js.\n\n1. **Use the [`Module.instantiateWasm`](https://emscripten.org/docs/api_reference/module.html?highligh=instantiateWasm#Module.instantiateWasm) API**\n\n   ```ts\n   import { readFileSync } from \"node:fs\";\n   import { prepareZXingModule } from \"zxing-wasm/reader\";\n\n   const wasmFileBuffer = readFileSync(\"/path/to/the/zxing_reader.wasm\");\n\n   prepareZXingModule({\n     overrides: {\n       instantiateWasm(imports, successCallback) {\n         WebAssembly.instantiate(wasmFileBuffer, imports).then(({ instance }) =\u003e\n           successCallback(instance),\n         );\n         return {};\n       },\n     },\n   });\n   ```\n\n2. **Use the [`Module.wasmBinary`](https://emscripten.org/docs/compiling/WebAssembly.html?highlight=wasmBinary#wasm-files-and-compilation) API**\n\n   ```ts\n   import { readFileSync } from \"node:fs\";\n   import { prepareZXingModule } from \"zxing-wasm/reader\";\n\n   prepareZXingModule({\n     overrides: {\n       wasmBinary: readFileSync(\"/path/to/the/zxing_reader.wasm\")\n         .buffer as ArrayBuffer,\n     },\n   });\n   ```\n\n3. **Use the [`Module.locateFile`](https://emscripten.org/docs/api_reference/module.html?highlight=locatefile#Module.locateFile) API with an Object URL**\n\n   ```ts\n   import { readFileSync } from \"node:fs\";\n   import { prepareZXingModule } from \"zxing-wasm/reader\";\n\n   // Create an Object URL for the .wasm file.\n   const wasmFileUrl = URL.createObjectURL(\n     new Blob([readFileSync(\"/path/to/the/zxing_reader.wasm\")], {\n       type: \"application/wasm\",\n     }),\n   );\n\n   prepareZXingModule({\n     overrides: {\n       locateFile: (path, prefix) =\u003e {\n         if (path.endsWith(\".wasm\")) {\n           return wasmFileUrl;\n         }\n         return prefix + path;\n       },\n       // Call `URL.revokeObjectURL(wasmFileUrl)` after the ZXing module\n       // is fully instantiated to free up memory.\n       postRun: [\n         () =\u003e {\n           URL.revokeObjectURL(wasmFileUrl);\n         },\n       ],\n     },\n   });\n   ```\n\n4. **Use the [`Module.locateFile`](https://emscripten.org/docs/api_reference/module.html?highlight=locatefile#Module.locateFile) API with a Base64-encoded Data URL** _(Not recommended)_\n\n   ```ts\n   import { readFileSync } from \"node:fs\";\n   import { prepareZXingModule } from \"zxing-wasm/reader\";\n\n   const wasmBase64 = readFileSync(\"/path/to/the/zxing_reader.wasm\").toString(\n     \"base64\",\n   );\n   const wasmUrl = `data:application/wasm;base64,${wasmBase64}`;\n\n   prepareZXingModule({\n     overrides: {\n       locateFile: (path, prefix) =\u003e {\n         if (path.endsWith(\".wasm\")) {\n           return wasmUrl;\n         }\n         return prefix + path;\n       },\n     },\n   });\n   ```\n\n\u003e [!NOTE]\n\u003e To use this library in a WeChat mini program \u003cimg src=\"https://github.com/user-attachments/assets/7d8f3337-dd9c-43ec-aab4-8d4e72d32867\" width=\"16\" height=\"16\"\u003e, there are several things to keep in mind:\n\u003e\n\u003e 1. Only the `zxing-wasm` import path is supported; `zxing-wasm/reader` or `zxing-wasm/writer` is not supported.\n\u003e 2. Before using the library, you need to copy/move the `node_modules/zxing-wasm/dist/full/zxing_full.wasm` file into your project directory.\n\u003e 3. You must use `prepareZXingModule` to configure how the `.wasm` file will be fetched, loaded, and compiled before calling `readBarcodes` or `writeBarcode`. This is mandatory, and you can do so with the following code:\n\u003e\n\u003e    ```typescript\n\u003e    prepareZXingModule({\n\u003e      overrides: {\n\u003e        instantiateWasm(imports, successCallback) {\n\u003e          WXWebAssembly.instantiate(\"path/to/zxing_full.wasm\", imports).then(\n\u003e            ({ instance }) =\u003e successCallback(instance),\n\u003e          );\n\u003e          return {};\n\u003e        },\n\u003e      },\n\u003e    });\n\u003e    ```\n\u003e\n\u003e    Note that WeChat mini programs use `WXWebAssembly` instead of the standard `WebAssembly`, and the first argument in `WXWebAssembly.instantiate` should point to the location where the `zxing_full.wasm` file was moved earlier.\n\u003e\n\u003e 4. This library uses a bare minimum `Blob` polyfill in the mini program environment so that no errors will be thrown if you call `writeBarcode`. However, it's recommended to use a full-fledged `Blob` polyfill for not breaking other parts of your program.\n\n\u003e [!IMPORTANT]\n\u003e\n\u003e Each version of this library has a unique corresponding `.wasm` file. If you choose to serve it yourself, please ensure that the `.wasm` file matches the version of the `zxing-wasm` library you are using. Otherwise, you may encounter unexpected errors.\n\nFor convenience, this library provides an exported `ZXING_WASM_VERSION` variable to indicate the resolved version of the `zxing-wasm` you are using:\n\n```ts\nimport { ZXING_WASM_VERSION } from \"zxing-wasm\";\n```\n\nThe commit hash of the `zxing-cpp` submodule is exported as `ZXING_CPP_COMMIT`:\n\n```ts\nimport { ZXING_CPP_COMMIT } from \"zxing-wasm\";\n```\n\nThe SHA-256 hash of the `.wasm` file (in hex format) is also exported as `ZXING_WASM_SHA256`, in case you want to make sure you are serving the exactly same file:\n\n```ts\nimport { ZXING_WASM_SHA256 } from \"zxing-wasm\";\n```\n\nTo acquire the `.wasm` files for customized serving, in addition to finding them by searching in your `node_modules` folder, they can also be downloaded from CDNs like [jsDelivr](https://cdn.jsdelivr.net/npm/zxing-wasm@latest/dist/):\n\n- **`zxing_full.wasm`**:\n\n  ```text\n  https://cdn.jsdelivr.net/npm/zxing-wasm@\u003cversion\u003e/dist/full/zxing_full.wasm\n  ```\n\n- **`zxing_reader.wasm`**:\n\n  ```text\n  https://cdn.jsdelivr.net/npm/zxing-wasm@\u003cversion\u003e/dist/reader/zxing_reader.wasm\n  ```\n\n- **`zxing_writer.wasm`**:\n\n  ```text\n  https://cdn.jsdelivr.net/npm/zxing-wasm@\u003cversion\u003e/dist/writer/zxing_writer.wasm\n  ```\n\n## Controlling `.wasm` Instantiation Timing and Caching\n\nBy default, the `.wasm` binary will not be fetched and instantiated until a `readBarcodes` or `writeBarcode` function is called. This behavior avoids unnecessary network requests and instantiation overhead if you decide to override the default `.wasm` serving path or other settings before using the library. Calling `prepareZXingModule` with `overrides` alone does not change this default behavior:\n\n```ts\nprepareZXingModule({\n  overrides: {\n    /* ... your desired overrides ... */\n  },\n}); // \u003c-- returns void\n```\n\nHowever, if you want to explicitly trigger the download and instantiation of the `.wasm` binary, you can set the [`fireImmediately`](https://zxing-wasm.deno.dev/interfaces/full.PrepareZXingModuleOptions.html#fireimmediately) option to `true`. Doing so also causes `prepareZXingModule` to return a `Promise` that resolves to the underlying Emscripten module. This allows you to `await` the instantiation process:\n\n```ts\nprepareZXingModule({\n  overrides: {\n    /* ... your desired overrides ... */\n  },\n  fireImmediately: true,\n}); // \u003c-- returns a promise\n```\n\nBecause different `overrides` settings can influence how this library locates and instantiates the `.wasm` binary, the library performs an equality check on `overrides` to determine if the `.wasm` binary should be re-fetched and re-instantiated. By default, it is determined by a shallow comparison of the `overrides` object. If you prefer a different method of comparison, you can supply a custom [`equalityFn`](https://zxing-wasm.deno.dev/interfaces/full.PrepareZXingModuleOptions.html#equalityfn):\n\n```ts\nprepareZXingModule({\n  overrides: {\n    /* ... your desired overrides ... */\n  },\n  fireImmediately: true,\n  equalityFn: () =\u003e false, // \u003c-- force re-fetch and re-instantiate\n});\n```\n\n## FAQ\n\n1. **Why are submodules required?**\n\n   The core function of reading / writing barcodes of this library is provided by [zxing-cpp](https://github.com/zxing-cpp/zxing-cpp). It is pinned to a specific commit ID as a submodule, and can be built as `.wasm` files. Additionally, the barcode generation ability is provided by [`zint`](https://sourceforge.net/projects/zint/), which is a submodule inside [zxing-cpp](https://github.com/zxing-cpp/zxing-cpp), so it is necessary to clone the repository with `--recurse-submodules` to ensure that all required submodules are also cloned.\n\n2. **I forgot to clone the repository with `--recurse-submodules`, how should I install the submodules without deleting this repo and cloning it again?**\n\n   In the root of the repo, run:\n\n   ```bash\n   git submodule update --init --recursive\n   ```\n\n3. **Are there any higher level libraries that can be used to simplify the usage of this library?**\n\n   - [barcode-detector](https://github.com/Sec-ant/barcode-detector): A [Barcode Detection API](https://wicg.github.io/shape-detection-api/#barcode-detection-api) polyfill / ponyfill that uses this library under the hood.\n   - [vue-qrcode-reader](https://github.com/gruhn/vue-qrcode-reader): A set of Vue.js components for detecting QR codes and various other barcode formats right in the browser which uses [barcode-detector](https://github.com/Sec-ant/barcode-detector) under the hood.\n   - [@yudiel/react-qr-scanner](https://github.com/yudielcurbelo/react-qr-scanner): A library to scan QR Codes in react which uses [barcode-detector](https://github.com/Sec-ant/barcode-detector) under the hood.\n   - [svelte-qrcode-reader](https://github.com/ollema/svelte-qrcode-reader): A set of Svelte 5 components for detecting and decoding QR-codes which uses [barcode-detector](https://github.com/Sec-ant/barcode-detector) under the hood.\n\n   A React toolkit for scanning barcodes directly based on this library is planned, which aims to provide easy-to-use capabilities for interacting with web cameras.\n\n4. **One of the input types of `readBarcodes` is `ImageData`, which is a `DOM` type. How can I use it in Node.js or other runtimes?**\n\n   The types are duck-typed, so you can use it in Node.js or other runtimes by providing a `DOM`-compatible `ImageData` object in the following shape, where the image data should be in [RGBA format](https://developer.mozilla.org/en-US/docs/Web/API/ImageData/data):\n\n   ```ts\n   interface ImageData {\n     data: Uint8ClampedArray;\n     width: number;\n     height: number;\n   }\n   ```\n\n## Licenses\n\nThis project contains code from multiple sources, each with its own license:\n\n- [zxing-cpp](https://github.com/zxing-cpp/zxing-cpp): [Apache License 2.0](https://github.com/zxing-cpp/zxing-cpp/blob/master/LICENSE)\n- [src/cpp/ZXingWasm.cpp](https://github.com/Sec-ant/zxing-wasm/blob/main/src/cpp/ZXingWasm.cpp): [Apache License 2.0](https://github.com/Sec-ant/zxing-wasm/blob/main/src/cpp/LICENSE)\n- [zint](https://sourceforge.net/projects/zint/): [BSD 3-Clause License](https://sourceforge.net/p/zint/code/ci/master/tree/LICENSE)\n- zxing-wasm specific code: [MIT License](https://github.com/Sec-ant/zxing-wasm/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsec-ant%2Fzxing-wasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsec-ant%2Fzxing-wasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsec-ant%2Fzxing-wasm/lists"}