@peerbit/riblt 1.0.6 → 1.0.7-40ccb58

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.
@@ -158,13 +158,25 @@ function passStringToWasm0(arg, malloc, realloc) {
158
158
  return ptr;
159
159
  }
160
160
 
161
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
161
+ let cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
162
162
 
163
163
  if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
164
164
 
165
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
166
+ let numBytesDecoded = 0;
167
+ function decodeText(ptr, len) {
168
+ numBytesDecoded += len;
169
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
170
+ cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
171
+ cachedTextDecoder.decode();
172
+ numBytesDecoded = len;
173
+ }
174
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
175
+ }
176
+
165
177
  function getStringFromWasm0(ptr, len) {
166
178
  ptr = ptr >>> 0;
167
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
179
+ return decodeText(ptr, len);
168
180
  }
169
181
 
170
182
  function takeFromExternrefTable0(idx) {
@@ -311,6 +323,8 @@ export class EncoderWrapper {
311
323
  }
312
324
  }
313
325
 
326
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
327
+
314
328
  async function __wbg_load(module, imports) {
315
329
  if (typeof Response === 'function' && module instanceof Response) {
316
330
  if (typeof WebAssembly.instantiateStreaming === 'function') {
@@ -318,7 +332,9 @@ async function __wbg_load(module, imports) {
318
332
  return await WebAssembly.instantiateStreaming(module, imports);
319
333
 
320
334
  } catch (e) {
321
- if (module.headers.get('Content-Type') != 'application/wasm') {
335
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
336
+
337
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
322
338
  console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
323
339
 
324
340
  } else {
@@ -345,47 +361,61 @@ async function __wbg_load(module, imports) {
345
361
  function __wbg_get_imports() {
346
362
  const imports = {};
347
363
  imports.wbg = {};
348
- imports.wbg.__wbg_get_bbccf8970793c087 = function() { return handleError(function (arg0, arg1) {
364
+ imports.wbg.__wbg_get_27b4bcbec57323ca = function() { return handleError(function (arg0, arg1) {
349
365
  const ret = Reflect.get(arg0, arg1);
350
366
  return ret;
351
367
  }, arguments) };
352
- imports.wbg.__wbg_new_254fa9eac11932ae = function() {
353
- const ret = new Array();
368
+ imports.wbg.__wbg_new_1930cbb8d9ffc31b = function() {
369
+ const ret = new Object();
354
370
  return ret;
355
371
  };
356
- imports.wbg.__wbg_new_688846f374351c92 = function() {
357
- const ret = new Object();
372
+ imports.wbg.__wbg_new_e969dc3f68d25093 = function() {
373
+ const ret = new Array();
358
374
  return ret;
359
375
  };
360
- imports.wbg.__wbg_push_6edad0df4b546b2c = function(arg0, arg1) {
376
+ imports.wbg.__wbg_push_cd3ac7d5b094565d = function(arg0, arg1) {
361
377
  const ret = arg0.push(arg1);
362
378
  return ret;
363
379
  };
364
- imports.wbg.__wbg_set_4e647025551483bd = function() { return handleError(function (arg0, arg1, arg2) {
380
+ imports.wbg.__wbg_set_b33e7a98099eed58 = function() { return handleError(function (arg0, arg1, arg2) {
365
381
  const ret = Reflect.set(arg0, arg1, arg2);
366
382
  return ret;
367
383
  }, arguments) };
368
- imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {
369
- const ret = arg0;
370
- return ret;
371
- };
372
- imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
373
- const ret = BigInt.asUintN(64, arg0);
374
- return ret;
375
- };
376
- imports.wbg.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
384
+ imports.wbg.__wbg_wbindgenbigintgetasi64_7637cb1a7fb9a81e = function(arg0, arg1) {
377
385
  const v = arg1;
378
386
  const ret = typeof(v) === 'bigint' ? v : undefined;
379
387
  getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
380
388
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
381
389
  };
382
- imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
390
+ imports.wbg.__wbg_wbindgendebugstring_bb652b1bc2061b6d = function(arg0, arg1) {
383
391
  const ret = debugString(arg1);
384
392
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
385
393
  const len1 = WASM_VECTOR_LEN;
386
394
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
387
395
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
388
396
  };
397
+ imports.wbg.__wbg_wbindgenjsvaleq_f27272c0a890df7f = function(arg0, arg1) {
398
+ const ret = arg0 === arg1;
399
+ return ret;
400
+ };
401
+ imports.wbg.__wbg_wbindgenthrow_4c11a24fca429ccf = function(arg0, arg1) {
402
+ throw new Error(getStringFromWasm0(arg0, arg1));
403
+ };
404
+ imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
405
+ // Cast intrinsic for `Ref(String) -> Externref`.
406
+ const ret = getStringFromWasm0(arg0, arg1);
407
+ return ret;
408
+ };
409
+ imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
410
+ // Cast intrinsic for `U64 -> Externref`.
411
+ const ret = BigInt.asUintN(64, arg0);
412
+ return ret;
413
+ };
414
+ imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
415
+ // Cast intrinsic for `I64 -> Externref`.
416
+ const ret = arg0;
417
+ return ret;
418
+ };
389
419
  imports.wbg.__wbindgen_init_externref_table = function() {
390
420
  const table = wasm.__wbindgen_export_2;
391
421
  const offset = table.grow(4);
@@ -396,17 +426,6 @@ function __wbg_get_imports() {
396
426
  table.set(offset + 3, false);
397
427
  ;
398
428
  };
399
- imports.wbg.__wbindgen_jsval_eq = function(arg0, arg1) {
400
- const ret = arg0 === arg1;
401
- return ret;
402
- };
403
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
404
- const ret = getStringFromWasm0(arg0, arg1);
405
- return ret;
406
- };
407
- imports.wbg.__wbindgen_throw = function(arg0, arg1) {
408
- throw new Error(getStringFromWasm0(arg0, arg1));
409
- };
410
429
 
411
430
  return imports;
412
431
  }
Binary file
package/package.json CHANGED
@@ -1,66 +1,66 @@
1
1
  {
2
- "name": "@peerbit/riblt",
3
- "version": "1.0.6",
4
- "description": "Riblt",
5
- "sideEffects": [
6
- "./dist/wasm-init.js",
7
- "./dist/wasm-init.browser.js",
8
- "./dist/index.js"
9
- ],
10
- "type": "module",
11
- "types": "./dist/index.d.ts",
12
- "typesVersions": {
13
- "*": {
14
- "*": [
15
- "*",
16
- "dist/*",
17
- "dist/*/index"
18
- ],
19
- "src/*": [
20
- "*",
21
- "dist/*",
22
- "dist/*/index"
23
- ]
24
- }
25
- },
26
- "files": [
27
- "src",
28
- "dist",
29
- "!dist/test",
30
- "!**/*.tsbuildinfo"
31
- ],
32
- "exports": {
33
- ".": {
34
- "types": "./dist/index.d.ts",
35
- "import": "./dist/index.js"
36
- }
37
- },
38
- "browser": {
39
- "./dist/wasm-init.js": "./dist/wasm-init.browser.js"
40
- },
41
- "eslintConfig": {
42
- "extends": "peerbit",
43
- "parserOptions": {
44
- "project": true,
45
- "sourceType": "module"
46
- },
47
- "ignorePatterns": [
48
- "!.aegir.js",
49
- "test/ts-use",
50
- "*.d.ts"
51
- ]
52
- },
53
- "publishConfig": {
54
- "access": "public"
55
- },
56
- "scripts": {
57
- "benchmark": "cargo bench",
58
- "clean": "cargo clear",
59
- "cp-src-js": "shx cp -r ./src_js/* ./dist",
60
- "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",
61
- "test": "cargo test && aegir test",
62
- "lint": "cargo fmt"
63
- },
64
- "author": "dao.xyz",
65
- "license": "MIT"
2
+ "name": "@peerbit/riblt",
3
+ "version": "1.0.7-40ccb58",
4
+ "description": "Riblt",
5
+ "sideEffects": [
6
+ "./dist/wasm-init.js",
7
+ "./dist/wasm-init.browser.js",
8
+ "./dist/index.js"
9
+ ],
10
+ "type": "module",
11
+ "types": "./dist/index.d.ts",
12
+ "typesVersions": {
13
+ "*": {
14
+ "*": [
15
+ "*",
16
+ "dist/*",
17
+ "dist/*/index"
18
+ ],
19
+ "src/*": [
20
+ "*",
21
+ "dist/*",
22
+ "dist/*/index"
23
+ ]
24
+ }
25
+ },
26
+ "files": [
27
+ "src",
28
+ "dist",
29
+ "!dist/test",
30
+ "!**/*.tsbuildinfo"
31
+ ],
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/index.d.ts",
35
+ "import": "./dist/index.js"
36
+ }
37
+ },
38
+ "browser": {
39
+ "./dist/wasm-init.js": "./dist/wasm-init.browser.js"
40
+ },
41
+ "eslintConfig": {
42
+ "extends": "peerbit",
43
+ "parserOptions": {
44
+ "project": true,
45
+ "sourceType": "module"
46
+ },
47
+ "ignorePatterns": [
48
+ "!.aegir.js",
49
+ "test/ts-use",
50
+ "*.d.ts"
51
+ ]
52
+ },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "scripts": {
57
+ "benchmark": "cargo bench",
58
+ "clean": "cargo clear",
59
+ "cp-src-js": "shx cp -r ./src_js/* ./dist",
60
+ "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",
61
+ "test": "cargo test && aegir test",
62
+ "lint": "cargo fmt"
63
+ },
64
+ "author": "dao.xyz",
65
+ "license": "MIT"
66
66
  }