]> zoso.dev Git - libnemo.git/commitdiff
No way to import in worker besides as modules, so start figuring out workarounds.
authorChris Duncan <chris@zoso.dev>
Sat, 23 Nov 2024 09:47:53 +0000 (01:47 -0800)
committerChris Duncan <chris@zoso.dev>
Sat, 23 Nov 2024 09:47:53 +0000 (01:47 -0800)
src/lib/workers/ckdBlake2b.ts

index 166d7ab75ae4f33330e49e9d0d23d67e42fd6f3a..a9662404bfbe93493a06a8857bc0b3416a1e6453 100644 (file)
@@ -1,12 +1,15 @@
 // SPDX-FileCopyrightText: 2024 Chris Duncan <chris@zoso.dev>
 // SPDX-License-Identifier: GPL-3.0-or-later
 
+import blake2b from 'blake2b'
+
 async function ckdBlake2b () {
-       const { default: blake2b } = await import('blake2b')
+       let blake2b: any
 
        let addEventListener = globalThis.addEventListener
        let postMessage = globalThis.postMessage
        if (addEventListener == null || postMessage == null) {
+               blake2b = (await import('blake2b')).default
                const { isMainThread, parentPort } = await import('node:worker_threads')
                if (!isMainThread && parentPort) {
                        addEventListener = Object.getPrototypeOf(parentPort).addListener.bind(parentPort)