@scanly/engine-jsqr 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/package.json +27 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DecoderEngine, EngineDecodeOptions, EngineOutcome, NormalizedFrame } from "@scanly/core";
|
|
2
|
+
export declare class JsQrEngine implements DecoderEngine {
|
|
3
|
+
readonly id = "jsqr";
|
|
4
|
+
readonly version = "1.4.0";
|
|
5
|
+
readonly capabilities: {
|
|
6
|
+
formats: "qr_code"[];
|
|
7
|
+
formatClasses: "matrix"[];
|
|
8
|
+
supportsMultiple: boolean;
|
|
9
|
+
returnsRawBytes: boolean;
|
|
10
|
+
supportsRawBytes: boolean;
|
|
11
|
+
returnsCornerPoints: boolean;
|
|
12
|
+
threadSafe: boolean;
|
|
13
|
+
estimatedScratchBytesPerPixel: number;
|
|
14
|
+
copiesInputBuffer: boolean;
|
|
15
|
+
supportsGs1: boolean;
|
|
16
|
+
supportsOrientation: boolean;
|
|
17
|
+
supportsInversion: boolean;
|
|
18
|
+
runtimeKinds: readonly ["browser", "worker", "node"];
|
|
19
|
+
executionModel: "javascript";
|
|
20
|
+
};
|
|
21
|
+
decode(frame: NormalizedFrame, options: EngineDecodeOptions): Promise<EngineOutcome>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGvG,qBAAa,UAAW,YAAW,aAAa;IAC9C,QAAQ,CAAC,EAAE,UAAU;IACrB,QAAQ,CAAC,OAAO,WAAW;IAC3B,QAAQ,CAAC,YAAY;;;;;;;;;;;;;;;MAAga;IAC/a,MAAM,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;CAuB3F"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import jsQR from "jsqr";
|
|
2
|
+
export class JsQrEngine {
|
|
3
|
+
id = "jsqr";
|
|
4
|
+
version = "1.4.0";
|
|
5
|
+
capabilities = { formats: ["qr_code"], formatClasses: ["matrix"], supportsMultiple: false, returnsRawBytes: true, supportsRawBytes: true, returnsCornerPoints: true, threadSafe: true, estimatedScratchBytesPerPixel: 5, copiesInputBuffer: false, supportsGs1: false, supportsOrientation: false, supportsInversion: true, runtimeKinds: ["browser", "worker", "node"], executionModel: "javascript" };
|
|
6
|
+
async decode(frame, options) {
|
|
7
|
+
const started = Date.now();
|
|
8
|
+
if (options.signal?.aborted)
|
|
9
|
+
return { ok: false, category: "cancelled", message: "Decode cancelled.", elapsedMs: 0 };
|
|
10
|
+
if (!options.formats.includes("qr_code"))
|
|
11
|
+
return { ok: false, category: "unsupported-format", message: "jsQR supports QR Code Model 2 only.", elapsedMs: 0 };
|
|
12
|
+
if (frame.pixelFormat !== "rgba8888" || frame.rowStride !== frame.width * 4)
|
|
13
|
+
return { ok: false, category: "invalid-input", message: "jsQR adapter requires tightly packed RGBA8888 input.", elapsedMs: Date.now() - started };
|
|
14
|
+
const data = frame.data instanceof Uint8ClampedArray ? frame.data : new Uint8ClampedArray(frame.data.buffer, frame.data.byteOffset, frame.data.byteLength);
|
|
15
|
+
let decoded = null;
|
|
16
|
+
try {
|
|
17
|
+
decoded = jsQR(data, frame.width, frame.height, { inversionAttempts: options.inversion === "inverted" ? "dontInvert" : "attemptBoth" });
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
return { ok: false, category: "execution", message: error instanceof Error ? error.message : "jsQR execution failed.", elapsedMs: Date.now() - started };
|
|
21
|
+
}
|
|
22
|
+
const elapsedMs = Date.now() - started;
|
|
23
|
+
if (!decoded?.data)
|
|
24
|
+
return { ok: false, category: "not-found", message: "No QR code found.", elapsedMs };
|
|
25
|
+
const { topLeftCorner, topRightCorner, bottomRightCorner, bottomLeftCorner } = decoded.location;
|
|
26
|
+
return { ok: true, results: [{
|
|
27
|
+
text: decoded.data,
|
|
28
|
+
rawBytes: Uint8Array.from(decoded.binaryData),
|
|
29
|
+
format: "qr_code",
|
|
30
|
+
cornerPoints: [topLeftCorner, topRightCorner, bottomRightCorner, bottomLeftCorner],
|
|
31
|
+
elapsedMs,
|
|
32
|
+
}] };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,OAAO,UAAU;IACZ,EAAE,GAAG,MAAM,CAAC;IACZ,OAAO,GAAG,OAAO,CAAC;IAClB,YAAY,GAAG,EAAE,OAAO,EAAE,CAAC,SAAkB,CAAC,EAAE,aAAa,EAAE,CAAC,QAAiB,CAAC,EAAE,gBAAgB,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,6BAA6B,EAAE,CAAC,EAAE,iBAAiB,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAU,EAAE,cAAc,EAAE,YAAqB,EAAE,CAAC;IACrb,KAAK,CAAC,MAAM,CAAC,KAAsB,EAAE,OAA4B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,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;QAC3J,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC;QACvC,IAAI,CAAC,OAAO,EAAE,IAAI;YAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,CAAC;QACzG,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC;QAChG,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oBAC3B,IAAI,EAAE,OAAO,CAAC,IAAI;oBAClB,QAAQ,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;oBAC7C,MAAM,EAAE,SAAS;oBACjB,YAAY,EAAE,CAAC,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,gBAAgB,CAAC;oBAClF,SAAS;iBACV,CAAC,EAAE,CAAC;IACP,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@scanly/engine-jsqr",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "jsQR engine plugin for Scanly",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc -p tsconfig.build.json"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@scanly/core": "2.0.0",
|
|
25
|
+
"jsqr": "^1.4.0"
|
|
26
|
+
}
|
|
27
|
+
}
|