Skip to content

Commit

Permalink
feat: support DXFilmEdge writing, with some other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sec-ant committed Dec 29, 2024
1 parent eabbf38 commit 615a321
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 10 deletions.
8 changes: 8 additions & 0 deletions .changeset/stupid-rules-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"zxing-wasm": minor
---

- 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.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@
| `DataBarLimited` || |||
| `DataBarExpanded` || |||
| `DataMatrix` | ||||
| `DXFilmEdge` || || |
| `DXFilmEdge` || || |
| `EAN-8` || |||
| `EAN-13` || |||
| `ITF` || |||
| `MaxiCode` | || ||
| `MaxiCode` | ||   ✅[^1] ||
| `PDF417` | ||||
| `QRCode` | ||||
| `MicroQRCode` | ||||
| `rMQRCode` | ||||
| `UPC-A` || |||
| `UPC-E` || |||

[^1]: Reading support for `MaxiCode` requires a pure monochrome image that contains an unrotated and unskewed code image, along with a sufficient white border surrounding it.

</div>

<!-- Visit [this online demo](https://zxing-wasm-demo.deno.dev/) to quickly explore its basic functions. It works best on the latest Chromium browsers. -->
Expand Down Expand Up @@ -78,7 +80,7 @@ Demo source: https://github.com/Sec-ant/zxing-wasm-demo

## Usage

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.
This package exports three subpaths: `full`, `reader`, and `writer`.

### `zxing-wasm` or `zxing-wasm/full`

Expand Down
8 changes: 8 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
"useIgnoreFile": true,
"defaultBranch": "main"
},
"json": {
"parser": {
"allowTrailingCommas": true
},
"formatter": {
"trailingCommas": "none"
}
},
"overrides": [
{
"include": [
Expand Down
16 changes: 16 additions & 0 deletions copy-files-from-to.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@
{
"from": "./src/full/*.wasm",
"to": "./dist/full/"
},
{
"from": "./src/imageData.d.ts",
"to": "./dist/es/types/"
},
{
"from": "./src/imageData.d.ts",
"to": "./dist/cjs/types/"
},
{
"from": "./src/wasm.d.ts",
"to": "./dist/es/types/"
},
{
"from": "./src/wasm.d.ts",
"to": "./dist/cjs/types/"
}
],
"copyFilesSettings": {
Expand Down
74 changes: 70 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,89 @@
"require": "./dist/cjs/writer/index.js",
"default": "./dist/es/writer/index.js"
},
"./reader/zxing_reader.wasm": "./dist/reader/zxing_reader.wasm",
"./writer/zxing_writer.wasm": "./dist/writer/zxing_writer.wasm",
"./full/zxing_full.wasm": "./dist/full/zxing_full.wasm"
"./full/zxing_full.wasm": {
"import": {
"types": "./dist/es/types/wasm.d.ts",
"default": "./dist/full/zxing_full.wasm"
},
"require": {
"types": "./dist/cjs/types/wasm.d.ts",
"default": "./dist/full/zxing_full.wasm"
},
"default": {
"types": "./dist/es/types/wasm.d.ts",
"default": "./dist/full/zxing_full.wasm"
}
},
"./reader/zxing_reader.wasm": {
"import": {
"types": "./dist/es/types/wasm.d.ts",
"default": "./dist/reader/zxing_reader.wasm"
},
"require": {
"types": "./dist/cjs/types/wasm.d.ts",
"default": "./dist/reader/zxing_reader.wasm"
},
"default": {
"types": "./dist/es/types/wasm.d.ts",
"default": "./dist/reader/zxing_reader.wasm"
}
},
"./writer/zxing_writer.wasm": {
"import": {
"types": "./dist/es/types/wasm.d.ts",
"default": "./dist/writer/zxing_writer.wasm"
},
"require": {
"types": "./dist/cjs/types/wasm.d.ts",
"default": "./dist/writer/zxing_writer.wasm"
},
"default": {
"types": "./dist/es/types/wasm.d.ts",
"default": "./dist/writer/zxing_writer.wasm"
}
},
"./imageData": {
"import": {
"types": "./dist/es/types/imageData.d.ts"
},
"require": {
"types": "./dist/cjs/types/imageData.d.ts"
},
"default": {
"types": "./dist/es/types/imageData.d.ts"
}
}
},
"typesVersions": {
"*": {
"full/zxing_full.wasm": [
"./dist/es/types/wasm.d.ts",
"./dist/cjs/types/wasm.d.ts"
],
"full": [
"./dist/es/full/index.d.ts",
"./dist/cjs/full/index.d.ts"
],
"reader/zxing_reader.wasm": [
"./dist/es/types/wasm.d.ts",
"./dist/cjs/types/wasm.d.ts"
],
"reader": [
"./dist/es/reader/index.d.ts",
"./dist/cjs/reader/index.d.ts"
],
"writer/zxing_writer.wasm": [
"./dist/es/types/wasm.d.ts",
"./dist/cjs/types/wasm.d.ts"
],
"writer": [
"./dist/es/writer/index.d.ts",
"./dist/cjs/writer/index.d.ts"
],
"imageData": [
"./dist/es/types/imageData.d.ts",
"./dist/cjs/types/imageData.d.ts"
]
}
},
Expand Down Expand Up @@ -153,5 +219,5 @@
}
}
},
"packageManager": "[email protected].1+sha512.1acb565e6193efbebda772702950469150cf12bcc764262e7587e71d19dc98a423dff9536e57ea44c49bdf790ff694e83c27be5faa23d67e0c033b583be4bfcf"
"packageManager": "[email protected].2+sha512.93e57b0126f0df74ce6bff29680394c0ba54ec47246b9cf321f0121d8d9bb03f750a705f24edc3c1180853afd7c2c3b94196d0a3d53d3e069d9e2793ef11f321"
}
2 changes: 1 addition & 1 deletion src/bindings/barcodeFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const barcodeFormatsWithMeta = [
["UPC-E", "L"],
["MicroQRCode", "M"],
["rMQRCode", "M"],
["DXFilmEdge", "L", "W-"],
["DXFilmEdge", "L"],
["DataBarLimited", "L"],
] as const;

Expand Down
2 changes: 1 addition & 1 deletion src/bindings/writerOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export interface WriterOptions
*
* Supported values are:
* `"Aztec"`, `"Codabar"`, `"Code39"`, `"Code93"`, `"Code128"`,
* `"DataBar"`, `"DataBarExpanded"`, `"DataBarLimited"`, `"DataMatrix"`,
* `"DataBar"`, `"DataBarExpanded"`, `"DataBarLimited"`, `"DataMatrix"`, `"DXFilmEdge"`,
* `"EAN-8"`, `"EAN-13"`, `"ITF"`, `"MaxiCode"`, `"MicroQRCode"`, `"PDF417"`,
* `"QRCode"`, `"rMQRCode"`, `"UPC-A"`, `"UPC-E"`
*
Expand Down
7 changes: 7 additions & 0 deletions src/wasm.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* This type is intended to be used with the esbuild file loader for wasm files
*
* see https://esbuild.github.io/content-types/#file
*/
declare const wasmFilePath: string;
export default wasmFilePath;

0 comments on commit 615a321

Please sign in to comment.