From a2339d381078d64f3385226b57e4299e68df4510 Mon Sep 17 00:00:00 2001 From: Ze-Zheng Wu Date: Mon, 18 Mar 2024 10:54:04 +0800 Subject: [PATCH] chore: bump zxing-cpp to b58682b --- .changeset/popular-dryers-hear.md | 5 ++ biome.json | 7 +- package-lock.json | 106 +++++++++++++++--------------- package.json | 12 ++-- src/cpp/.clang-format | 2 +- src/cpp/CMakeLists.txt | 14 ++-- src/cpp/ZXingWasm.cpp | 79 +++++----------------- zxing-cpp | 2 +- 8 files changed, 92 insertions(+), 135 deletions(-) create mode 100644 .changeset/popular-dryers-hear.md diff --git a/.changeset/popular-dryers-hear.md b/.changeset/popular-dryers-hear.md new file mode 100644 index 00000000..03170dcd --- /dev/null +++ b/.changeset/popular-dryers-hear.md @@ -0,0 +1,5 @@ +--- +"zxing-wasm": patch +--- + +Bump zxing-cpp to [`b58682b`](https://github.com/zxing-cpp/zxing-cpp/commit/b58682b90ff082cee8d946c73f8852574478fb09). diff --git a/biome.json b/biome.json index 5b62104a..a6a63c25 100644 --- a/biome.json +++ b/biome.json @@ -2,17 +2,12 @@ "$schema": "./node_modules/@biomejs/biome/configuration_schema.json", "files": { "ignoreUnknown": true, - "ignore": ["zxing-cpp", "docs", "dist", "build"] - }, - "organizeImports": { - "enabled": true + "ignore": ["zxing-cpp"] }, "formatter": { - "enabled": true, "indentStyle": "space" }, "linter": { - "enabled": true, "rules": { "recommended": true, "suspicious": { diff --git a/package-lock.json b/package-lock.json index ab3f3962..f2d52e6d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,21 +14,21 @@ "devDependencies": { "@babel/core": "^7.24.0", "@babel/types": "^7.24.0", - "@biomejs/biome": "1.6.0", + "@biomejs/biome": "1.6.1", "@changesets/cli": "^2.27.1", "@types/babel__core": "^7.20.5", - "@types/node": "^20.11.25", + "@types/node": "^20.11.28", "concurrently": "^8.2.2", "copy-files-from-to": "^3.9.1", "lint-staged": "^15.2.2", - "npm-check-updates": "^16.14.15", + "npm-check-updates": "^16.14.17", "prettier": "^3.2.5", "rimraf": "^5.0.5", - "simple-git-hooks": "^2.10.0", + "simple-git-hooks": "^2.11.0", "tsx": "^4.7.1", - "typedoc": "^0.25.11", + "typedoc": "^0.25.12", "typescript": "^5.4.2", - "vite": "^5.1.5", + "vite": "^5.1.6", "vite-plugin-babel": "^1.2.0" } }, @@ -521,9 +521,9 @@ } }, "node_modules/@biomejs/biome": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.6.0.tgz", - "integrity": "sha512-hvP8K1+CV8qc9eNdXtPwzScVxFSHB448CPKSqX6+8IW8G7bbhBVKGC80BowExJN5+vu+kzsj4xkWa780MAOlJw==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.6.1.tgz", + "integrity": "sha512-SILQvA2S0XeaOuu1bivv6fQmMo7zMfr2xqDEN+Sz78pGbAKZnGmg0emsXjQWoBY/RVm9kPCgX+aGEpZZTYaM7w==", "dev": true, "hasInstallScript": true, "bin": { @@ -537,20 +537,20 @@ "url": "https://opencollective.com/biome" }, "optionalDependencies": { - "@biomejs/cli-darwin-arm64": "1.6.0", - "@biomejs/cli-darwin-x64": "1.6.0", - "@biomejs/cli-linux-arm64": "1.6.0", - "@biomejs/cli-linux-arm64-musl": "1.6.0", - "@biomejs/cli-linux-x64": "1.6.0", - "@biomejs/cli-linux-x64-musl": "1.6.0", - "@biomejs/cli-win32-arm64": "1.6.0", - "@biomejs/cli-win32-x64": "1.6.0" + "@biomejs/cli-darwin-arm64": "1.6.1", + "@biomejs/cli-darwin-x64": "1.6.1", + "@biomejs/cli-linux-arm64": "1.6.1", + "@biomejs/cli-linux-arm64-musl": "1.6.1", + "@biomejs/cli-linux-x64": "1.6.1", + "@biomejs/cli-linux-x64-musl": "1.6.1", + "@biomejs/cli-win32-arm64": "1.6.1", + "@biomejs/cli-win32-x64": "1.6.1" } }, "node_modules/@biomejs/cli-darwin-arm64": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.6.0.tgz", - "integrity": "sha512-K1Fjqye5pt+Ua+seC7V/2bFjfnqOaEOcQbBQSiiefB/VPNOb6lA5NFIfJ1PskTA3JrMXE1k7iqKQn56qrKFS6A==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.6.1.tgz", + "integrity": "sha512-KlvY00iB9T/vFi4m/GXxEyYkYnYy6aw06uapzUIIdiMMj7I/pmZu7CsZlzWdekVD0j+SsQbxdZMsb0wPhnRSsg==", "cpu": [ "arm64" ], @@ -564,9 +564,9 @@ } }, "node_modules/@biomejs/cli-darwin-x64": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.6.0.tgz", - "integrity": "sha512-CjEALu6vN9RbcfhaBDoj481mesUIsUjxgQn+/kiMCea+Paypqslhez1I7OwRBJnkzz+Pa+PXdABd7S30eyy6+Q==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.6.1.tgz", + "integrity": "sha512-jP4E8TXaQX5e3nvRJSzB+qicZrdIDCrjR0sSb1DaDTx4JPZH5WXq/BlTqAyWi3IijM+IYMjWqAAK4kOHsSCzxw==", "cpu": [ "x64" ], @@ -580,9 +580,9 @@ } }, "node_modules/@biomejs/cli-linux-arm64": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.6.0.tgz", - "integrity": "sha512-32LVrC7dAgQT39YZ0ieO/VzzpAflozs9mW5K0oKNef7S4ocCdk89E98eXApxOdei0JTf3vfseDCl1AUIp6MwJw==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.6.1.tgz", + "integrity": "sha512-nxD1UyX3bWSl/RSKlib/JsOmt+652/9yieogdSC/UTLgVCZYOF7u8L/LK7kAa0Y4nA8zSPavAQTgko7mHC2ObA==", "cpu": [ "arm64" ], @@ -596,9 +596,9 @@ } }, "node_modules/@biomejs/cli-linux-arm64-musl": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.6.0.tgz", - "integrity": "sha512-prww6AUuJ+IO/GziN3WjtGM/DNOVuPFxqWrK97wKTZygEDdA+o1qHUN2HeCkSyk084xnzbMSbls5xscAKAn43A==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.6.1.tgz", + "integrity": "sha512-YdkDgFecdHJg7PJxAMaZIixVWGB6St4yH08BHagO0fEhNNiY8cAKEVo2mcXlsnEiTMpeSEAY9VxLUrVT3IVxpw==", "cpu": [ "arm64" ], @@ -612,9 +612,9 @@ } }, "node_modules/@biomejs/cli-linux-x64": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.6.0.tgz", - "integrity": "sha512-b6mWu9Cu4w5B3K46wq9SlxKEZEEL6II/6HFNAuZ4YL8mOeQ0FTMU+wNMJFKkmkSE2zvim3xwW3PknmbLKbe3Mg==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.6.1.tgz", + "integrity": "sha512-BYAzenlMF3QdngjNFw9QVBXKGNzeecqwF3pwDgUGEvU7OJpn1/lyVkJVxYPtVGRNdjQ9e6l/s8NjKuBpW/ZR4Q==", "cpu": [ "x64" ], @@ -628,9 +628,9 @@ } }, "node_modules/@biomejs/cli-linux-x64-musl": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.6.0.tgz", - "integrity": "sha512-NwitWeUKCy8G/rr+rgHPYirnrsOjJEJBWODdaRzweeFNcJjvO6de6AmNdSJzsewzLEaxjOWyoXU03MdzbGz/6Q==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.6.1.tgz", + "integrity": "sha512-aSISIDmxq04NNy7tm4x9rBk2vH0ub2VDIE4outEmdC2LBtEJoINiphlZagx/FvjbsqUfygent9QUSn0oREnAXg==", "cpu": [ "x64" ], @@ -644,9 +644,9 @@ } }, "node_modules/@biomejs/cli-win32-arm64": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.6.0.tgz", - "integrity": "sha512-DlNOL6mG+76iZS1gL/UiuMme7jnt+auzo2+u0aUq6UXYsb75juchwlnVLy2UV5CQjVBRB8+RM+KVoXRZ8NlBjQ==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.6.1.tgz", + "integrity": "sha512-/eCHQKZ1kEawUpkSuXq4urtxMsD1P1678OPG3zNKt3ru16AqqspLdO3jzBe3k74xCPYnQ36e9Yqc97Mo0qgPtg==", "cpu": [ "arm64" ], @@ -660,9 +660,9 @@ } }, "node_modules/@biomejs/cli-win32-x64": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.6.0.tgz", - "integrity": "sha512-sXBcXIOGuG8/XcHqmnkhLIs0oy6Dp+TkH4Alr4WH/P8mNsp5GcStI/ZwbEiEoxA0P3Fi+oUppQ6srxaY2rSCHg==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.6.1.tgz", + "integrity": "sha512-5TUZbzBwnDLFxLVGEPsorNi6eC2Gt+z4Oei9Qvq0M/4c4/mjZ96ABgwao/tMxf4ZBr/qyy2YdvF+gX9Rc+xC0A==", "cpu": [ "x64" ], @@ -2034,9 +2034,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.11.25", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.25.tgz", - "integrity": "sha512-TBHyJxk2b7HceLVGFcpAUjsa5zIdsPWlR6XHfyGzd0SFu+/NFgQgMAl96MSDZgQDvJAvV6BKsFOrt6zIL09JDw==", + "version": "20.11.28", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.28.tgz", + "integrity": "sha512-M/GPWVS2wLkSkNHVeLkrF2fD5Lx5UC4PxA0uZcKc6QqbIQUJyW1jVjueJYi1z8n0I5PxYrtpnPnWglE+y9A0KA==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -3713,9 +3713,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.4", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz", - "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==", + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", "dev": true, "funding": [ { @@ -6281,9 +6281,9 @@ } }, "node_modules/npm-check-updates": { - "version": "16.14.15", - "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-16.14.15.tgz", - "integrity": "sha512-WH0wJ9j6CP7Azl+LLCxWAYqroT2IX02kRIzgK/fg0rPpMbETgHITWBdOPtrv521xmA3JMgeNsQ62zvVtS/nCmQ==", + "version": "16.14.17", + "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-16.14.17.tgz", + "integrity": "sha512-ElnDdXKe60f8S6RhzFeaGuH2TFJmt2cU2HjLdowldabdm27nWFCxV2ebeP3xGbQkzp2+RPDQNdW9HqU1lcY8ag==", "dev": true, "dependencies": { "chalk": "^5.3.0", @@ -7906,9 +7906,9 @@ } }, "node_modules/simple-git-hooks": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/simple-git-hooks/-/simple-git-hooks-2.10.0.tgz", - "integrity": "sha512-TtCytVYfV77pILCkzVxpOSgYKHQyaO7fBI/iwG5bLGb0dIo/v/K1Y1IZ5DN40RQu6WNNJiN0gkuRvSYjxOhFog==", + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/simple-git-hooks/-/simple-git-hooks-2.11.0.tgz", + "integrity": "sha512-Wab2uzjGJEL8Kx+2UY8waUSfkiolt2RbaAJWvPCjaAEXrrKoS7JqPk4STiIVl/yt3asZRUzFoK2ryhwvgh5rYw==", "dev": true, "hasInstallScript": true, "bin": { diff --git a/package.json b/package.json index 9cf4c50d..e64a7c21 100644 --- a/package.json +++ b/package.json @@ -98,21 +98,21 @@ "devDependencies": { "@babel/core": "^7.24.0", "@babel/types": "^7.24.0", - "@biomejs/biome": "1.6.0", + "@biomejs/biome": "1.6.1", "@changesets/cli": "^2.27.1", "@types/babel__core": "^7.20.5", - "@types/node": "^20.11.25", + "@types/node": "^20.11.28", "concurrently": "^8.2.2", "copy-files-from-to": "^3.9.1", "lint-staged": "^15.2.2", - "npm-check-updates": "^16.14.15", + "npm-check-updates": "^16.14.17", "prettier": "^3.2.5", "rimraf": "^5.0.5", - "simple-git-hooks": "^2.10.0", + "simple-git-hooks": "^2.11.0", "tsx": "^4.7.1", - "typedoc": "^0.25.11", + "typedoc": "^0.25.12", "typescript": "^5.4.2", - "vite": "^5.1.5", + "vite": "^5.1.6", "vite-plugin-babel": "^1.2.0" }, "dependencies": { diff --git a/src/cpp/.clang-format b/src/cpp/.clang-format index 063a5421..ef36b72e 100644 --- a/src/cpp/.clang-format +++ b/src/cpp/.clang-format @@ -1,4 +1,4 @@ -ColumnLimit: 80 +ColumnLimit: 120 PenaltyReturnTypeOnItsOwnLine: 200 ContinuationIndentWidth: 2 IndentWidth: 2 diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index 690bd6d3..ba00cde8 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -10,11 +10,11 @@ zxing_add_package_stb() set(CMAKE_CXX_STANDARD 20) # Build options -option(BUILD_WRITERS "Build with writer support (encoders)" ON) -option(BUILD_READERS "Build with reader support (decoders)" ON) +option(ZXING_WRITERS "Build with writer support (encoders)" ON) +option(ZXING_READERS "Build with reader support (decoders)" ON) # Build environment -set(BUILD_EMSCRIPTEN_ENVIRONMENT "web,worker" CACHE STRING "Optimize build for given emscripten runtime environment (web/node/shell/worker)") +set(ZXING_EMSCRIPTEN_ENVIRONMENT "web,worker" CACHE STRING "Optimize build for given emscripten runtime environment (web/node/shell/worker)") # Default build type if(NOT CMAKE_BUILD_TYPE) @@ -29,7 +29,7 @@ add_definitions("-s DISABLE_EXCEPTION_CATCHING=0") # Set linker flags set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} \ -lembind \ - -s ENVIRONMENT=${BUILD_EMSCRIPTEN_ENVIRONMENT} \ + -s ENVIRONMENT=${ZXING_EMSCRIPTEN_ENVIRONMENT} \ -s DISABLE_EXCEPTION_CATCHING=0 \ -s FILESYSTEM=0 \ -s EXPORT_ES6=1 \ @@ -43,7 +43,7 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} \ ) # Build targets -if(BUILD_READERS AND BUILD_WRITERS) +if(ZXING_READERS AND ZXING_WRITERS) add_executable(zxing_full ZXingWasm.cpp) target_compile_definitions(zxing_full PRIVATE READER WRITER) target_link_libraries(zxing_full ZXing::ZXing stb::stb) @@ -51,7 +51,7 @@ if(BUILD_READERS AND BUILD_WRITERS) RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../full") endif() -if(BUILD_READERS) +if(ZXING_READERS) add_executable(zxing_reader ZXingWasm.cpp) target_compile_definitions(zxing_reader PRIVATE READER) target_link_libraries(zxing_reader ZXing::ZXing stb::stb) @@ -59,7 +59,7 @@ if(BUILD_READERS) RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../reader") endif() -if(BUILD_WRITERS) +if(ZXING_WRITERS) add_executable(zxing_writer ZXingWasm.cpp) target_compile_definitions(zxing_writer PRIVATE WRITER) target_link_libraries(zxing_writer ZXing::ZXing stb::stb) diff --git a/src/cpp/ZXingWasm.cpp b/src/cpp/ZXingWasm.cpp index fab6660e..7c639db8 100644 --- a/src/cpp/ZXingWasm.cpp +++ b/src/cpp/ZXingWasm.cpp @@ -75,17 +75,13 @@ struct JsReadResult { using JsReadResults = std::vector; -JsReadResults readBarcodes( - ZXing::ImageView imageView, const JsReaderOptions &jsReaderOptions -) { +JsReadResults readBarcodes(ZXing::ImageView imageView, const JsReaderOptions &jsReaderOptions) { thread_local const val Uint8Array = val::global("Uint8Array"); try { ZXing::ReaderOptions readerOptions; - readerOptions.setFormats( - ZXing::BarcodeFormatsFromString(jsReaderOptions.formats) - ); + readerOptions.setFormats(ZXing::BarcodeFormatsFromString(jsReaderOptions.formats)); readerOptions.setTryHarder(jsReaderOptions.tryHarder); readerOptions.setTryRotate(jsReaderOptions.tryRotate); readerOptions.setTryInvert(jsReaderOptions.tryInvert); @@ -96,14 +92,10 @@ JsReadResults readBarcodes( readerOptions.setDownscaleFactor(jsReaderOptions.downscaleFactor); readerOptions.setMinLineCount(jsReaderOptions.minLineCount); readerOptions.setMaxNumberOfSymbols(jsReaderOptions.maxNumberOfSymbols); - readerOptions.setTryCode39ExtendedMode(jsReaderOptions.tryCode39ExtendedMode - ); - readerOptions.setValidateCode39CheckSum( - jsReaderOptions.validateCode39CheckSum - ); + readerOptions.setTryCode39ExtendedMode(jsReaderOptions.tryCode39ExtendedMode); + readerOptions.setValidateCode39CheckSum(jsReaderOptions.validateCode39CheckSum); readerOptions.setValidateITFCheckSum(jsReaderOptions.validateITFCheckSum); - readerOptions.setReturnCodabarStartEnd(jsReaderOptions.returnCodabarStartEnd - ); + readerOptions.setReturnCodabarStartEnd(jsReaderOptions.returnCodabarStartEnd); readerOptions.setReturnErrors(jsReaderOptions.returnErrors); readerOptions.setEanAddOnSymbol(jsReaderOptions.eanAddOnSymbol); readerOptions.setTextMode(jsReaderOptions.textMode); @@ -121,12 +113,8 @@ JsReadResults readBarcodes( {.isValid = result.isValid(), .error = ZXing::ToString(result.error()), .format = ZXing::ToString(result.format()), - .bytes = std::move( - Uint8Array.new_(typed_memory_view(bytes.size(), bytes.data())) - ), - .bytesECI = std::move( - Uint8Array.new_(typed_memory_view(bytesECI.size(), bytesECI.data())) - ), + .bytes = std::move(Uint8Array.new_(typed_memory_view(bytes.size(), bytes.data()))), + .bytesECI = std::move(Uint8Array.new_(typed_memory_view(bytesECI.size(), bytesECI.data()))), .text = result.text(), .eccLevel = result.ecLevel(), .contentType = result.contentType(), @@ -146,56 +134,33 @@ JsReadResults readBarcodes( } return jsResults; } catch (const std::exception &e) { - return { - {.error = e.what(), - .bytes = std::move(Uint8Array.new_()), - .bytesECI = std::move(Uint8Array.new_())} - }; + return {{.error = e.what(), .bytes = std::move(Uint8Array.new_()), .bytesECI = std::move(Uint8Array.new_())}}; } catch (...) { - return { - {.error = "Unknown error", - .bytes = std::move(Uint8Array.new_()), - .bytesECI = std::move(Uint8Array.new_())} + return {{.error = "Unknown error", .bytes = std::move(Uint8Array.new_()), .bytesECI = std::move(Uint8Array.new_())} }; } return {}; } -JsReadResults readBarcodesFromImage( - int bufferPtr, int bufferLength, const JsReaderOptions &jsReaderOptions -) { +JsReadResults readBarcodesFromImage(int bufferPtr, int bufferLength, const JsReaderOptions &jsReaderOptions) { int width, height, channels; std::unique_ptr buffer( stbi_load_from_memory( - reinterpret_cast(bufferPtr), - bufferLength, - &width, - &height, - &channels, - 1 + reinterpret_cast(bufferPtr), bufferLength, &width, &height, &channels, 1 ), stbi_image_free ); if (buffer == nullptr) { return {}; } - return readBarcodes( - {buffer.get(), width, height, ZXing::ImageFormat::Lum}, jsReaderOptions - ); + return readBarcodes({buffer.get(), width, height, ZXing::ImageFormat::Lum}, jsReaderOptions); } JsReadResults readBarcodesFromPixmap( - int bufferPtr, - int imgWidth, - int imgHeight, - const JsReaderOptions &jsReaderOptions + int bufferPtr, int imgWidth, int imgHeight, const JsReaderOptions &jsReaderOptions ) { return readBarcodes( - {reinterpret_cast(bufferPtr), - imgWidth, - imgHeight, - ZXing::ImageFormat::RGBA}, - jsReaderOptions + {reinterpret_cast(bufferPtr), imgWidth, imgHeight, ZXing::ImageFormat::RGBA}, jsReaderOptions ); } @@ -217,9 +182,7 @@ struct JsWriteResult { std::string error; }; -JsWriteResult writeBarcodeToImage( - std::wstring text, const JsWriterOptions &jsWriterOptions -) { +JsWriteResult writeBarcodeToImage(std::wstring text, const JsWriterOptions &jsWriterOptions) { try { auto format = ZXing::BarcodeFormatFromString(jsWriterOptions.format); if (format == ZXing::BarcodeFormat::None) { @@ -243,14 +206,10 @@ JsWriteResult writeBarcodeToImage( writer.setEccLevel(eccLevel); } - auto buffer = ZXing::ToMatrix( - writer.encode(text, jsWriterOptions.width, jsWriterOptions.height) - ); + auto buffer = ZXing::ToMatrix(writer.encode(text, jsWriterOptions.width, jsWriterOptions.height)); int len; - uint8_t *bytes = stbi_write_png_to_mem( - buffer.data(), 0, buffer.width(), buffer.height(), 1, &len - ); + uint8_t *bytes = stbi_write_png_to_mem(buffer.data(), 0, buffer.width(), buffer.height(), 1, &len); if (bytes == nullptr) { return {.error = "Unknown error"}; @@ -302,9 +261,7 @@ EMSCRIPTEN_BINDINGS(ZXingWasm) { .value("ISO15434", ZXing::ContentType::ISO15434) .value("UnknownECI", ZXing::ContentType::UnknownECI); - value_object("Point") - .field("x", &ZXing::PointI::x) - .field("y", &ZXing::PointI::y); + value_object("Point").field("x", &ZXing::PointI::x).field("y", &ZXing::PointI::y); value_object("Position") .field("topLeft", emscripten::index<0>()) diff --git a/zxing-cpp b/zxing-cpp index b3aff4a9..b58682b9 160000 --- a/zxing-cpp +++ b/zxing-cpp @@ -1 +1 @@ -Subproject commit b3aff4a98b03e056a244ca385a8221c50d67e352 +Subproject commit b58682b90ff082cee8d946c73f8852574478fb09