Skip to content

Commit

Permalink
display qr code type; refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Maslov committed Oct 13, 2023
1 parent 40f6156 commit b4d266a
Show file tree
Hide file tree
Showing 15 changed files with 226 additions and 19 deletions.
198 changes: 196 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kameroon",
"version": "1.0.1",
"version": "1.0.2",
"private": true,
"dependencies": {
"@maslick/kameroon": "^1.0.2",
Expand All @@ -16,13 +16,15 @@
"react-usestateref": "^1.0.8",
"redux": "^4.2.1",
"styled-components": "4.3.2",
"web-vitals": "^2.1.4"
"web-vitals": "^2.1.4",
"http-server": "^0.13.0"
},
"scripts": {
"start": "HTTPS=true HOST=0.0.0.0 react-scripts start",
"build": "react-scripts build",
"build-sw": "node ./src/sw-build.js",
"build-sw": "node src/sw/sw-build.js",
"test": "react-scripts test",
"http-server": "http-server ./build/ -p 8082 -c-1",
"eject": "react-scripts eject"
},
"eslintConfig": {
Expand Down
8 changes: 6 additions & 2 deletions public/wasm/koder-zbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class KoderZbar {
createBuffer: this.mod.cwrap('createBuffer', 'number', ['number']),
deleteBuffer: this.mod.cwrap('deleteBuffer', '', ['number']),
triggerDecode: this.mod.cwrap('triggerDecode', 'number', ['number', 'number', 'number']),
getScanResults: this.mod.cwrap('getScanResults', 'number', [])
getScanResults: this.mod.cwrap('getScanResults', 'number', []),
getResultType: this.mod.cwrap('getResultType', 'number', []),
};

// return the class
Expand All @@ -26,7 +27,10 @@ class KoderZbar {
const results = [];
if (this.api.triggerDecode(buffer, width, height) > 0) {
const resultAddress = this.api.getScanResults();
results.push(this.mod.UTF8ToString(resultAddress));
results.push({
code: this.mod.UTF8ToString(resultAddress),
type: this.mod.UTF8ToString(this.api.getResultType())
});
this.api.deleteBuffer(resultAddress);
}
if (results.length > 0) return results[0];
Expand Down
5 changes: 4 additions & 1 deletion public/wasm/koder-zxing.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ class KoderZxing {
const result = this.mod.readBarcodeFromPixmap(buffer, width, height, mode, format);
this.mod._free(buffer);
if (result && result.text.length > 0) {
results.push(result.text);
results.push({
code: result.text,
type: result.format
});
}
if (results.length > 0) return results[0];
else return null;
Expand Down
Loading

0 comments on commit b4d266a

Please sign in to comment.