feat: Update Libp2p to latest version. Add standalone bundled JS Client (#239)

This commit is contained in:
Pavel
2023-02-06 15:18:04 +03:00
committed by GitHub
parent 267ebb687f
commit a1265f4d7a
158 changed files with 3854 additions and 5236 deletions

View 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);
});
}
}