const start = b.toString().indexOf('{') + 1
const end = b.toString().lastIndexOf('return')
-let worker_threads = ''
-if (typeof window === 'undefined' && typeof self === 'undefined') {
- worker_threads += `import { isMainThread, parentPort } from 'node:worker_threads'\n`
-}
-export const worker = worker_threads + b.toString().substring(start, end)
+export const worker = b.toString().substring(start, end)
// Original source commit: https://github.com/dchest/tweetnacl-js/blob/71df1d6a1d78236ca3e9f6c788786e21f5a651a6/nacl-fast.js\r
\r
const n = () => {\r
- /**\r
- * Polyfill for window methods which do not exist when executing Node.js tests.\r
- */\r
- if (typeof window === 'undefined' && typeof self === 'undefined') {\r
- try {\r
- import('node:worker_threads').then(worker_threads => {\r
- const { isMainThread, parentPort } = worker_threads\r
- if (!isMainThread && parentPort) {\r
- var addEventListener = Object.getPrototypeOf(parentPort).addListener.bind(parentPort)\r
- var postMessage = Object.getPrototypeOf(parentPort).postMessage.bind(parentPort)\r
- }\r
- })\r
- } catch { }\r
- }\r
-\r
/**\r
* Listens for messages from a calling function.\r
*/\r
// SPDX-License-Identifier: GPL-3.0-or-later
const p = async () => {
- /**
- * Polyfill for window methods which do not exist when executing Node.js tests.
- */
- if (typeof window === 'undefined' && typeof self === 'undefined') {
- try {
- import('node:worker_threads').then(worker_threads => {
- const { isMainThread, parentPort } = worker_threads
- if (!isMainThread && parentPort) {
- var addEventListener = Object.getPrototypeOf(parentPort).addListener.bind(parentPort)
- var postMessage = Object.getPrototypeOf(parentPort).postMessage.bind(parentPort)
- }
- })
- } catch (err) { }
- }
-
const SEND_THRESHOLD = '0xfffffff8'
/**
* Listens for messages from a calling function.
* using the `importKey()` method of the SubtleCrypto interface.
*/
async function passkey () {
- /**
- * Polyfill for window methods which do not exist when executing Node.js tests.
- */
- if (globalThis.addEventListener == null || globalThis.postMessage == null) {
- const { isMainThread, parentPort } = await import('node:worker_threads')
- if (!isMainThread && parentPort) {
- var addEventListener = Object.getPrototypeOf(parentPort).addListener.bind(parentPort)
- var postMessage = Object.getPrototypeOf(parentPort).postMessage.bind(parentPort)
- }
- }
-
/**
* Message listener for this Web Worker thread.
*/