@peerbit/riblt 1.1.0 → 1.2.0-2ed894b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/riblt/rateless_iblt_bg.wasm +0 -0
- package/dist/index.d.ts +3 -70
- package/dist/index.js +1 -2
- package/dist/rateless_iblt.d.ts +2 -0
- package/dist/rateless_iblt.js +25 -0
- package/dist/rateless_iblt_bg.wasm +0 -0
- package/dist/rateless_iblt_bg.wasm.d.ts +1 -0
- package/dist/wasm-init.browser.js +3 -1
- package/dist/wasm-init.js +1 -1
- package/package.json +2 -2
- package/src/wasm.rs +6 -0
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -1,72 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
export class DecoderWrapper {
|
|
4
|
-
free(): void;
|
|
5
|
-
add_symbol(symbol: bigint): void;
|
|
6
|
-
try_decode(): void;
|
|
7
|
-
add_coded_symbol(coded_symbol_js: any): void;
|
|
8
|
-
get_local_symbols(): Array<any>;
|
|
9
|
-
get_remote_symbols(): Array<any>;
|
|
10
|
-
constructor();
|
|
11
|
-
reset(): void;
|
|
12
|
-
decoded(): boolean;
|
|
13
|
-
}
|
|
14
|
-
export class EncoderWrapper {
|
|
15
|
-
free(): void;
|
|
16
|
-
add_symbol(symbol: bigint): void;
|
|
17
|
-
to_decoder(): DecoderWrapper;
|
|
18
|
-
produce_next_coded_symbol(): any;
|
|
19
|
-
constructor();
|
|
20
|
-
clone(): EncoderWrapper;
|
|
21
|
-
reset(): void;
|
|
22
|
-
}
|
|
1
|
+
import type { InitOutput } from "./rateless_iblt.js";
|
|
23
2
|
|
|
24
|
-
export
|
|
3
|
+
export { DecoderWrapper, EncoderWrapper, initSync } from "./rateless_iblt.js";
|
|
25
4
|
|
|
26
|
-
export
|
|
27
|
-
readonly memory: WebAssembly.Memory;
|
|
28
|
-
readonly __wbg_decoderwrapper_free: (a: number, b: number) => void;
|
|
29
|
-
readonly __wbg_encoderwrapper_free: (a: number, b: number) => void;
|
|
30
|
-
readonly decoderwrapper_add_coded_symbol: (a: number, b: any) => void;
|
|
31
|
-
readonly decoderwrapper_add_symbol: (a: number, b: bigint) => void;
|
|
32
|
-
readonly decoderwrapper_decoded: (a: number) => number;
|
|
33
|
-
readonly decoderwrapper_get_local_symbols: (a: number) => any;
|
|
34
|
-
readonly decoderwrapper_get_remote_symbols: (a: number) => any;
|
|
35
|
-
readonly decoderwrapper_new: () => number;
|
|
36
|
-
readonly decoderwrapper_reset: (a: number) => void;
|
|
37
|
-
readonly decoderwrapper_try_decode: (a: number) => [number, number];
|
|
38
|
-
readonly encoderwrapper_add_symbol: (a: number, b: bigint) => void;
|
|
39
|
-
readonly encoderwrapper_clone: (a: number) => number;
|
|
40
|
-
readonly encoderwrapper_new: () => number;
|
|
41
|
-
readonly encoderwrapper_produce_next_coded_symbol: (a: number) => any;
|
|
42
|
-
readonly encoderwrapper_reset: (a: number) => void;
|
|
43
|
-
readonly encoderwrapper_to_decoder: (a: number) => number;
|
|
44
|
-
readonly __wbindgen_exn_store: (a: number) => void;
|
|
45
|
-
readonly __externref_table_alloc: () => number;
|
|
46
|
-
readonly __wbindgen_export_2: WebAssembly.Table;
|
|
47
|
-
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
48
|
-
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
49
|
-
readonly __externref_table_dealloc: (a: number) => void;
|
|
50
|
-
readonly __wbindgen_start: () => void;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
54
|
-
/**
|
|
55
|
-
* Instantiates the given `module`, which can either be bytes or
|
|
56
|
-
* a precompiled `WebAssembly.Module`.
|
|
57
|
-
*
|
|
58
|
-
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
59
|
-
*
|
|
60
|
-
* @returns {InitOutput}
|
|
61
|
-
*/
|
|
62
|
-
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
66
|
-
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
67
|
-
*
|
|
68
|
-
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
69
|
-
*
|
|
70
|
-
* @returns {Promise<InitOutput>}
|
|
71
|
-
*/
|
|
72
|
-
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
5
|
+
export declare const ready: Promise<InitOutput>;
|
package/dist/index.js
CHANGED
package/dist/rateless_iblt.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export class EncoderWrapper {
|
|
|
15
15
|
free(): void;
|
|
16
16
|
add_symbol(symbol: bigint): void;
|
|
17
17
|
to_decoder(): DecoderWrapper;
|
|
18
|
+
add_symbols(symbols: BigUint64Array): void;
|
|
18
19
|
produce_next_coded_symbol(): any;
|
|
19
20
|
constructor();
|
|
20
21
|
clone(): EncoderWrapper;
|
|
@@ -36,6 +37,7 @@ export interface InitOutput {
|
|
|
36
37
|
readonly decoderwrapper_reset: (a: number) => void;
|
|
37
38
|
readonly decoderwrapper_try_decode: (a: number) => [number, number];
|
|
38
39
|
readonly encoderwrapper_add_symbol: (a: number, b: bigint) => void;
|
|
40
|
+
readonly encoderwrapper_add_symbols: (a: number, b: number, c: number) => void;
|
|
39
41
|
readonly encoderwrapper_clone: (a: number) => number;
|
|
40
42
|
readonly encoderwrapper_new: () => number;
|
|
41
43
|
readonly encoderwrapper_produce_next_coded_symbol: (a: number) => any;
|
package/dist/rateless_iblt.js
CHANGED
|
@@ -185,6 +185,22 @@ function takeFromExternrefTable0(idx) {
|
|
|
185
185
|
return value;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
+
let cachedBigUint64ArrayMemory0 = null;
|
|
189
|
+
|
|
190
|
+
function getBigUint64ArrayMemory0() {
|
|
191
|
+
if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
|
|
192
|
+
cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
|
|
193
|
+
}
|
|
194
|
+
return cachedBigUint64ArrayMemory0;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function passArray64ToWasm0(arg, malloc) {
|
|
198
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
199
|
+
getBigUint64ArrayMemory0().set(arg, ptr / 8);
|
|
200
|
+
WASM_VECTOR_LEN = arg.length;
|
|
201
|
+
return ptr;
|
|
202
|
+
}
|
|
203
|
+
|
|
188
204
|
const DecoderWrapperFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
189
205
|
? { register: () => {}, unregister: () => {} }
|
|
190
206
|
: new FinalizationRegistry(ptr => wasm.__wbg_decoderwrapper_free(ptr >>> 0, 1));
|
|
@@ -298,6 +314,14 @@ export class EncoderWrapper {
|
|
|
298
314
|
const ret = wasm.encoderwrapper_to_decoder(this.__wbg_ptr);
|
|
299
315
|
return DecoderWrapper.__wrap(ret);
|
|
300
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* @param {BigUint64Array} symbols
|
|
319
|
+
*/
|
|
320
|
+
add_symbols(symbols) {
|
|
321
|
+
const ptr0 = passArray64ToWasm0(symbols, wasm.__wbindgen_malloc);
|
|
322
|
+
const len0 = WASM_VECTOR_LEN;
|
|
323
|
+
wasm.encoderwrapper_add_symbols(this.__wbg_ptr, ptr0, len0);
|
|
324
|
+
}
|
|
301
325
|
/**
|
|
302
326
|
* @returns {any}
|
|
303
327
|
*/
|
|
@@ -437,6 +461,7 @@ function __wbg_init_memory(imports, memory) {
|
|
|
437
461
|
function __wbg_finalize_init(instance, module) {
|
|
438
462
|
wasm = instance.exports;
|
|
439
463
|
__wbg_init.__wbindgen_wasm_module = module;
|
|
464
|
+
cachedBigUint64ArrayMemory0 = null;
|
|
440
465
|
cachedDataViewMemory0 = null;
|
|
441
466
|
cachedUint8ArrayMemory0 = null;
|
|
442
467
|
|
|
Binary file
|
|
@@ -12,6 +12,7 @@ export const decoderwrapper_new: () => number;
|
|
|
12
12
|
export const decoderwrapper_reset: (a: number) => void;
|
|
13
13
|
export const decoderwrapper_try_decode: (a: number) => [number, number];
|
|
14
14
|
export const encoderwrapper_add_symbol: (a: number, b: bigint) => void;
|
|
15
|
+
export const encoderwrapper_add_symbols: (a: number, b: number, c: number) => void;
|
|
15
16
|
export const encoderwrapper_clone: (a: number) => number;
|
|
16
17
|
export const encoderwrapper_new: () => number;
|
|
17
18
|
export const encoderwrapper_produce_next_coded_symbol: (a: number) => any;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// nothing to do since 'fetch' works as expected in the browser
|
|
2
2
|
import init from "./rateless_iblt.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export const ready = init(
|
|
5
|
+
new URL("/peerbit/riblt/rateless_iblt_bg.wasm", import.meta.url),
|
|
6
|
+
);
|
package/dist/wasm-init.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peerbit/riblt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-2ed894b",
|
|
4
4
|
"description": "Riblt",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"./dist/wasm-init.js",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"benchmark": "cargo bench",
|
|
60
60
|
"clean": "cargo clear",
|
|
61
61
|
"cp-src-js": "shx cp -r ./src_js/* ./dist",
|
|
62
|
-
"build": "wasm-pack build --target web --out-dir dist --out-name rateless_iblt && shx rm -rf ./dist/.gitignore && shx rm -rf ./dist/package.json && npm run cp-src-js && shx
|
|
62
|
+
"build": "wasm-pack build --target web --out-dir dist --out-name rateless_iblt && shx rm -rf ./dist/.gitignore && shx rm -rf ./dist/package.json && npm run cp-src-js && shx mkdir -p ./dist/assets/riblt && shx cp ./dist/rateless_iblt_bg.wasm ./dist/assets/riblt/",
|
|
63
63
|
"test": "cargo test && aegir test",
|
|
64
64
|
"lint": "cargo fmt"
|
|
65
65
|
}
|
package/src/wasm.rs
CHANGED
|
@@ -55,6 +55,12 @@ impl EncoderWrapper {
|
|
|
55
55
|
self.encoder.add_symbol(&my_symbol);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
pub fn add_symbols(&mut self, symbols: Vec<u64>) {
|
|
59
|
+
for symbol in symbols.iter() {
|
|
60
|
+
self.encoder.add_symbol(symbol);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
58
64
|
pub fn produce_next_coded_symbol(&mut self) -> JsValue {
|
|
59
65
|
let coded_symbol = self.encoder.produce_next_coded_symbol();
|
|
60
66
|
let symbol_u64 = coded_symbol.symbol;
|