From 828c7ad578a787de720d5f18262f6bcda24573e7 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sun, 1 May 2022 14:38:28 +0100 Subject: [PATCH] web/lukegbcom: move ee-qrcode.worker to lib directory ...otherwise nextjs complains and fails the build. --- web/lukegbcom/lib/ee-qrcode.worker.js | 15 +++++++++++++++ web/lukegbcom/pages/tools/ee-qrcode.js | 2 +- web/lukegbcom/pages/tools/ee-qrcode.worker.js | 13 ------------- 3 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 web/lukegbcom/lib/ee-qrcode.worker.js delete mode 100644 web/lukegbcom/pages/tools/ee-qrcode.worker.js diff --git a/web/lukegbcom/lib/ee-qrcode.worker.js b/web/lukegbcom/lib/ee-qrcode.worker.js new file mode 100644 index 0000000000..a2d9fbe08a --- /dev/null +++ b/web/lukegbcom/lib/ee-qrcode.worker.js @@ -0,0 +1,15 @@ +import { scanImageData } from 'zbar.wasm' + +if (typeof importScripts === "function") { + self.addEventListener('message', async e => { + const symbols = await scanImageData(e.data.imageData) + self.postMessage({ + response: symbols.map((sym, n) => ({ + index: n, + typeName: sym.typeName, + value: sym.decode(), + points: sym.points, + })) + }) + }) +} diff --git a/web/lukegbcom/pages/tools/ee-qrcode.js b/web/lukegbcom/pages/tools/ee-qrcode.js index 3d29cbe9c3..1db0e91568 100644 --- a/web/lukegbcom/pages/tools/ee-qrcode.js +++ b/web/lukegbcom/pages/tools/ee-qrcode.js @@ -41,7 +41,7 @@ async function startCapture(video, canvas, captureType) { function scanImage(imageData) { if (scannerWorker === null) { - scannerWorker = new Worker(new URL('./ee-qrcode.worker.js', import.meta.url)) + scannerWorker = new Worker(new URL('../../lib/ee-qrcode.worker.js', import.meta.url)) } return new Promise(resolve => { diff --git a/web/lukegbcom/pages/tools/ee-qrcode.worker.js b/web/lukegbcom/pages/tools/ee-qrcode.worker.js deleted file mode 100644 index c205c0fe49..0000000000 --- a/web/lukegbcom/pages/tools/ee-qrcode.worker.js +++ /dev/null @@ -1,13 +0,0 @@ -import { scanImageData } from 'zbar.wasm' - -self.addEventListener('message', async e => { - const symbols = await scanImageData(e.data.imageData) - self.postMessage({ - response: symbols.map((sym, n) => ({ - index: n, - typeName: sym.typeName, - value: sym.decode(), - points: sym.points, - })) - }) -})