UNPKG

@onmax_/core

Version:

Nimiq's Rust-to-WASM web client (patched for Cloudflare Workers logging fix)

31 lines (26 loc) 1.05 kB
import * as Comlink from 'comlink'; import { Address, CryptoUtils, Transaction } from './main-wasm/index.js'; import { clientFactory } from '../launcher/browser/client-proxy.mjs'; import { cryptoUtilsWorkerFactory } from '../launcher/browser/cryptoutils-worker-proxy.mjs'; import { setupMainThreadTransferHandlers } from '../launcher/browser/transfer-handlers.mjs'; setupMainThreadTransferHandlers(Comlink, { Address, Transaction, }); const Client = clientFactory( () => new Worker(new URL('./worker.js', import.meta.url), { type : 'module' }), worker => Comlink.wrap(worker), ); const CryptoUtilsWorker = cryptoUtilsWorkerFactory( () => new Worker(new URL('./crypto.js', import.meta.url), { type : 'module' }), worker => Comlink.wrap(worker), ); for (const propName in CryptoUtilsWorker) { const prop = CryptoUtilsWorker[propName]; if (typeof prop === 'function') { CryptoUtils[propName] = prop; } } export * from './main-wasm/index.js'; export { Client }; export * from '../lib/bundler/index.mjs';