mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-06-28 23:31:33 +00:00
feat: Update Libp2p to latest version. Add standalone bundled JS Client (#239)
This commit is contained in:
23
packages/core/src/marine/deps-loader/common.ts
Normal file
23
packages/core/src/marine/deps-loader/common.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { BlobWorker } from 'threads';
|
||||
import { fromBase64, toUint8Array } from 'js-base64';
|
||||
import type { WorkerImplementation } from 'threads/dist/types/master';
|
||||
import { LazyLoader } from '../../interfaces/index.js';
|
||||
import { Buffer } from 'buffer';
|
||||
|
||||
export class InlinedWorkerLoader extends LazyLoader<WorkerImplementation> {
|
||||
constructor(b64script: string) {
|
||||
super(() => {
|
||||
const script = fromBase64(b64script);
|
||||
return BlobWorker.fromText(script);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class InlinedWasmLoader extends LazyLoader<Buffer> {
|
||||
constructor(b64wasm: string) {
|
||||
super(() => {
|
||||
const wasm = toUint8Array(b64wasm);
|
||||
return Buffer.from(wasm);
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user