diff --git a/src/adapters/websocket-hook.js b/src/adapters/websocket-hook.js index 80aa5bac..1ecd0749 100644 --- a/src/adapters/websocket-hook.js +++ b/src/adapters/websocket-hook.js @@ -1,11 +1,12 @@ import { injectFuncAsListener } from "~utils/event" import { sendBLiveMessage } from "~utils/messaging" -import wasmUrl from "raw:~assets/brotli-dec.wasm" +import wasmBase64 from "data-base64:~assets/brotli-dec.wasm" import init from 'brotli-dec-wasm/pkg/index' +import { base64ToArrayBuffer } from "~utils/misc" var decompress = null -const loadWasm = init(wasmUrl).then(output => { +const loadWasm = init(base64ToArrayBuffer(wasmBase64.split('data:application/wasm;base64,')[1])).then(output => { decompress = output.decompress console.info('wasm loaded.') }) diff --git a/src/utils/misc.ts b/src/utils/misc.ts index 58470a58..7646c23d 100644 --- a/src/utils/misc.ts +++ b/src/utils/misc.ts @@ -86,4 +86,13 @@ export function randomRange(min: number, max: number): number { export function randomNumber(length: number = 20): number { return Math.round(Math.random() * (10 ** length)) +} + +export function base64ToArrayBuffer(base64: string): ArrayBuffer { + const binaryString = atob(base64) + const bytes = new Uint8Array(binaryString.length) + for (var i = 0; i < binaryString.length; i++) { + bytes[i] = binaryString.charCodeAt(i) + } + return bytes.buffer } \ No newline at end of file