2020-01-29 14:20:11 +01:00
let wasm ;
let cachedTextDecoder = new TextDecoder ( 'utf-8' , { ignoreBOM : true , fatal : true } ) ;
cachedTextDecoder . decode ( ) ;
let cachegetUint8Memory0 = null ;
function getUint8Memory0 ( ) {
if ( cachegetUint8Memory0 === null || cachegetUint8Memory0 . buffer !== wasm . memory . buffer ) {
cachegetUint8Memory0 = new Uint8Array ( wasm . memory . buffer ) ;
}
return cachegetUint8Memory0 ;
}
function getStringFromWasm0 ( ptr , len ) {
return cachedTextDecoder . decode ( getUint8Memory0 ( ) . subarray ( ptr , ptr + len ) ) ;
}
const heap = new Array ( 32 ) ;
heap . fill ( undefined ) ;
heap . push ( undefined , null , true , false ) ;
let heap _next = heap . length ;
function addHeapObject ( obj ) {
if ( heap _next === heap . length ) heap . push ( heap . length + 1 ) ;
const idx = heap _next ;
heap _next = heap [ idx ] ;
heap [ idx ] = obj ;
return idx ;
}
function getObject ( idx ) { return heap [ idx ] ; }
function dropObject ( idx ) {
if ( idx < 36 ) return ;
heap [ idx ] = heap _next ;
heap _next = idx ;
}
function takeObject ( idx ) {
const ret = getObject ( idx ) ;
dropObject ( idx ) ;
return ret ;
}
let WASM _VECTOR _LEN = 0 ;
function passArray8ToWasm0 ( arg , malloc ) {
const ptr = malloc ( arg . length * 1 ) ;
getUint8Memory0 ( ) . set ( arg , ptr / 1 ) ;
WASM _VECTOR _LEN = arg . length ;
return ptr ;
}
let cachegetInt32Memory0 = null ;
function getInt32Memory0 ( ) {
if ( cachegetInt32Memory0 === null || cachegetInt32Memory0 . buffer !== wasm . memory . buffer ) {
cachegetInt32Memory0 = new Int32Array ( wasm . memory . buffer ) ;
}
return cachegetInt32Memory0 ;
}
function getArrayU8FromWasm0 ( ptr , len ) {
return getUint8Memory0 ( ) . subarray ( ptr / 1 , ptr / 1 + len ) ;
}
/ * *
* @ param { Uint8Array } params
2020-03-11 11:08:01 +01:00
* @ param { Uint8Array } entropy
2020-01-29 14:20:11 +01:00
* @ returns { Uint8Array }
* /
2020-03-11 11:08:01 +01:00
export function contribute ( params , entropy ) {
2020-01-29 14:20:11 +01:00
var ptr0 = passArray8ToWasm0 ( params , wasm . _ _wbindgen _malloc ) ;
var len0 = WASM _VECTOR _LEN ;
2020-03-11 11:08:01 +01:00
var ptr1 = passArray8ToWasm0 ( entropy , wasm . _ _wbindgen _malloc ) ;
var len1 = WASM _VECTOR _LEN ;
wasm . contribute ( 8 , ptr0 , len0 , ptr1 , len1 ) ;
2020-01-29 14:20:11 +01:00
var r0 = getInt32Memory0 ( ) [ 8 / 4 + 0 ] ;
var r1 = getInt32Memory0 ( ) [ 8 / 4 + 1 ] ;
2020-03-11 11:08:01 +01:00
var v2 = getArrayU8FromWasm0 ( r0 , r1 ) . slice ( ) ;
2020-01-29 14:20:11 +01:00
wasm . _ _wbindgen _free ( r0 , r1 * 1 ) ;
2020-03-11 11:08:01 +01:00
return v2 ;
2020-01-29 14:20:11 +01:00
}
let cachedTextEncoder = new TextEncoder ( 'utf-8' ) ;
const encodeString = ( typeof cachedTextEncoder . encodeInto === 'function'
? function ( arg , view ) {
return cachedTextEncoder . encodeInto ( arg , view ) ;
}
: function ( arg , view ) {
const buf = cachedTextEncoder . encode ( arg ) ;
view . set ( buf ) ;
return {
read : arg . length ,
written : buf . length
} ;
} ) ;
function passStringToWasm0 ( arg , malloc , realloc ) {
if ( realloc === undefined ) {
const buf = cachedTextEncoder . encode ( arg ) ;
const ptr = malloc ( buf . length ) ;
getUint8Memory0 ( ) . subarray ( ptr , ptr + buf . length ) . set ( buf ) ;
WASM _VECTOR _LEN = buf . length ;
return ptr ;
}
let len = arg . length ;
let ptr = malloc ( len ) ;
const mem = getUint8Memory0 ( ) ;
let offset = 0 ;
for ( ; offset < len ; offset ++ ) {
const code = arg . charCodeAt ( offset ) ;
if ( code > 0x7F ) break ;
mem [ ptr + offset ] = code ;
}
if ( offset !== len ) {
if ( offset !== 0 ) {
arg = arg . slice ( offset ) ;
}
ptr = realloc ( ptr , len , len = offset + arg . length * 3 ) ;
const view = getUint8Memory0 ( ) . subarray ( ptr + offset , ptr + len ) ;
const ret = encodeString ( arg , view ) ;
offset += ret . written ;
}
WASM _VECTOR _LEN = offset ;
return ptr ;
}
function init ( module ) {
if ( typeof module === 'undefined' ) {
module = import . meta . url . replace ( /\.js$/ , '_bg.wasm' ) ;
}
let result ;
const imports = { } ;
imports . wbg = { } ;
imports . wbg . _ _wbindgen _string _new = function ( arg0 , arg1 ) {
var ret = getStringFromWasm0 ( arg0 , arg1 ) ;
return addHeapObject ( ret ) ;
} ;
imports . wbg . _ _wbindgen _object _drop _ref = function ( arg0 ) {
takeObject ( arg0 ) ;
} ;
imports . wbg . _ _wbg _new _59cb74e423758ede = function ( ) {
var ret = new Error ( ) ;
return addHeapObject ( ret ) ;
} ;
imports . wbg . _ _wbg _stack _558ba5917b466edd = function ( arg0 , arg1 ) {
var ret = getObject ( arg1 ) . stack ;
var ptr0 = passStringToWasm0 ( ret , wasm . _ _wbindgen _malloc , wasm . _ _wbindgen _realloc ) ;
var len0 = WASM _VECTOR _LEN ;
getInt32Memory0 ( ) [ arg0 / 4 + 1 ] = len0 ;
getInt32Memory0 ( ) [ arg0 / 4 + 0 ] = ptr0 ;
} ;
imports . wbg . _ _wbg _error _4bb6c2a97407129a = function ( arg0 , arg1 ) {
try {
console . error ( getStringFromWasm0 ( arg0 , arg1 ) ) ;
} finally {
wasm . _ _wbindgen _free ( arg0 , arg1 ) ;
}
} ;
imports . wbg . _ _widl _f _log _1 _ = function ( arg0 ) {
console . log ( getObject ( arg0 ) ) ;
} ;
imports . wbg . _ _wbindgen _throw = function ( arg0 , arg1 ) {
throw new Error ( getStringFromWasm0 ( arg0 , arg1 ) ) ;
} ;
imports . wbg . _ _wbindgen _rethrow = function ( arg0 ) {
throw takeObject ( arg0 ) ;
} ;
if ( ( typeof URL === 'function' && module instanceof URL ) || typeof module === 'string' || ( typeof Request === 'function' && module instanceof Request ) ) {
const response = fetch ( module ) ;
if ( typeof WebAssembly . instantiateStreaming === 'function' ) {
result = WebAssembly . instantiateStreaming ( response , imports )
. catch ( e => {
return response
. then ( r => {
if ( r . headers . get ( 'Content-Type' ) != 'application/wasm' ) {
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 ) ;
return r . arrayBuffer ( ) ;
} else {
throw e ;
}
} )
. then ( bytes => WebAssembly . instantiate ( bytes , imports ) ) ;
} ) ;
} else {
result = response
. then ( r => r . arrayBuffer ( ) )
. then ( bytes => WebAssembly . instantiate ( bytes , imports ) ) ;
}
} else {
result = WebAssembly . instantiate ( module , imports )
. then ( result => {
if ( result instanceof WebAssembly . Instance ) {
return { instance : result , module } ;
} else {
return result ;
}
} ) ;
}
return result . then ( ( { instance , module } ) => {
wasm = instance . exports ;
init . _ _wbindgen _wasm _module = module ;
return wasm ;
} ) ;
}
export default init ;