git-subtree-dir: vendor/ruvector git-subtree-split: b64c21726f2bb37286d9ee36a7869fef60cc6900
1453 lines
48 KiB
JavaScript
1453 lines
48 KiB
JavaScript
let wasm;
|
|
|
|
function addToExternrefTable0(obj) {
|
|
const idx = wasm.__externref_table_alloc();
|
|
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
return idx;
|
|
}
|
|
|
|
function debugString(val) {
|
|
// primitive types
|
|
const type = typeof val;
|
|
if (type == 'number' || type == 'boolean' || val == null) {
|
|
return `${val}`;
|
|
}
|
|
if (type == 'string') {
|
|
return `"${val}"`;
|
|
}
|
|
if (type == 'symbol') {
|
|
const description = val.description;
|
|
if (description == null) {
|
|
return 'Symbol';
|
|
} else {
|
|
return `Symbol(${description})`;
|
|
}
|
|
}
|
|
if (type == 'function') {
|
|
const name = val.name;
|
|
if (typeof name == 'string' && name.length > 0) {
|
|
return `Function(${name})`;
|
|
} else {
|
|
return 'Function';
|
|
}
|
|
}
|
|
// objects
|
|
if (Array.isArray(val)) {
|
|
const length = val.length;
|
|
let debug = '[';
|
|
if (length > 0) {
|
|
debug += debugString(val[0]);
|
|
}
|
|
for(let i = 1; i < length; i++) {
|
|
debug += ', ' + debugString(val[i]);
|
|
}
|
|
debug += ']';
|
|
return debug;
|
|
}
|
|
// Test for built-in
|
|
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
let className;
|
|
if (builtInMatches && builtInMatches.length > 1) {
|
|
className = builtInMatches[1];
|
|
} else {
|
|
// Failed to match the standard '[object ClassName]'
|
|
return toString.call(val);
|
|
}
|
|
if (className == 'Object') {
|
|
// we're a user defined class or Object
|
|
// JSON.stringify avoids problems with cycles, and is generally much
|
|
// easier than looping through ownProperties of `val`.
|
|
try {
|
|
return 'Object(' + JSON.stringify(val) + ')';
|
|
} catch (_) {
|
|
return 'Object';
|
|
}
|
|
}
|
|
// errors
|
|
if (val instanceof Error) {
|
|
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
}
|
|
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
return className;
|
|
}
|
|
|
|
function getArrayF32FromWasm0(ptr, len) {
|
|
ptr = ptr >>> 0;
|
|
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
}
|
|
|
|
function getArrayU8FromWasm0(ptr, len) {
|
|
ptr = ptr >>> 0;
|
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
}
|
|
|
|
let cachedDataViewMemory0 = null;
|
|
function getDataViewMemory0() {
|
|
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
}
|
|
return cachedDataViewMemory0;
|
|
}
|
|
|
|
let cachedFloat32ArrayMemory0 = null;
|
|
function getFloat32ArrayMemory0() {
|
|
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
}
|
|
return cachedFloat32ArrayMemory0;
|
|
}
|
|
|
|
function getStringFromWasm0(ptr, len) {
|
|
ptr = ptr >>> 0;
|
|
return decodeText(ptr, len);
|
|
}
|
|
|
|
let cachedUint8ArrayMemory0 = null;
|
|
function getUint8ArrayMemory0() {
|
|
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
}
|
|
return cachedUint8ArrayMemory0;
|
|
}
|
|
|
|
function handleError(f, args) {
|
|
try {
|
|
return f.apply(this, args);
|
|
} catch (e) {
|
|
const idx = addToExternrefTable0(e);
|
|
wasm.__wbindgen_exn_store(idx);
|
|
}
|
|
}
|
|
|
|
function isLikeNone(x) {
|
|
return x === undefined || x === null;
|
|
}
|
|
|
|
function passArray8ToWasm0(arg, malloc) {
|
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
WASM_VECTOR_LEN = arg.length;
|
|
return ptr;
|
|
}
|
|
|
|
function passArrayF32ToWasm0(arg, malloc) {
|
|
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
getFloat32ArrayMemory0().set(arg, ptr / 4);
|
|
WASM_VECTOR_LEN = arg.length;
|
|
return ptr;
|
|
}
|
|
|
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
if (realloc === undefined) {
|
|
const buf = cachedTextEncoder.encode(arg);
|
|
const ptr = malloc(buf.length, 1) >>> 0;
|
|
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
WASM_VECTOR_LEN = buf.length;
|
|
return ptr;
|
|
}
|
|
|
|
let len = arg.length;
|
|
let ptr = malloc(len, 1) >>> 0;
|
|
|
|
const mem = getUint8ArrayMemory0();
|
|
|
|
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, 1) >>> 0;
|
|
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
|
|
offset += ret.written;
|
|
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
}
|
|
|
|
WASM_VECTOR_LEN = offset;
|
|
return ptr;
|
|
}
|
|
|
|
function takeFromExternrefTable0(idx) {
|
|
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
wasm.__externref_table_dealloc(idx);
|
|
return value;
|
|
}
|
|
|
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
cachedTextDecoder.decode();
|
|
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
let numBytesDecoded = 0;
|
|
function decodeText(ptr, len) {
|
|
numBytesDecoded += len;
|
|
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
cachedTextDecoder.decode();
|
|
numBytesDecoded = len;
|
|
}
|
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
}
|
|
|
|
const cachedTextEncoder = new TextEncoder();
|
|
|
|
if (!('encodeInto' in cachedTextEncoder)) {
|
|
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
const buf = cachedTextEncoder.encode(arg);
|
|
view.set(buf);
|
|
return {
|
|
read: arg.length,
|
|
written: buf.length
|
|
};
|
|
}
|
|
}
|
|
|
|
let WASM_VECTOR_LEN = 0;
|
|
|
|
const WasmAdaptiveCompressorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
? { register: () => {}, unregister: () => {} }
|
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmadaptivecompressor_free(ptr >>> 0, 1));
|
|
|
|
const WasmCryptoFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
? { register: () => {}, unregister: () => {} }
|
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmcrypto_free(ptr >>> 0, 1));
|
|
|
|
const WasmHnswIndexFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
? { register: () => {}, unregister: () => {} }
|
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmhnswindex_free(ptr >>> 0, 1));
|
|
|
|
const WasmHybridKeyPairFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
? { register: () => {}, unregister: () => {} }
|
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmhybridkeypair_free(ptr >>> 0, 1));
|
|
|
|
const WasmIdentityFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
? { register: () => {}, unregister: () => {} }
|
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmidentity_free(ptr >>> 0, 1));
|
|
|
|
const WasmQuantizerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
? { register: () => {}, unregister: () => {} }
|
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmquantizer_free(ptr >>> 0, 1));
|
|
|
|
const WasmRaftNodeFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
? { register: () => {}, unregister: () => {} }
|
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmraftnode_free(ptr >>> 0, 1));
|
|
|
|
const WasmSemanticMatcherFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
? { register: () => {}, unregister: () => {} }
|
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmsemanticmatcher_free(ptr >>> 0, 1));
|
|
|
|
const WasmSpikingNetworkFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
? { register: () => {}, unregister: () => {} }
|
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmspikingnetwork_free(ptr >>> 0, 1));
|
|
|
|
/**
|
|
* WASM-compatible network-aware adaptive compression
|
|
*/
|
|
export class WasmAdaptiveCompressor {
|
|
__destroy_into_raw() {
|
|
const ptr = this.__wbg_ptr;
|
|
this.__wbg_ptr = 0;
|
|
WasmAdaptiveCompressorFinalization.unregister(this);
|
|
return ptr;
|
|
}
|
|
free() {
|
|
const ptr = this.__destroy_into_raw();
|
|
wasm.__wbg_wasmadaptivecompressor_free(ptr, 0);
|
|
}
|
|
/**
|
|
* Update network metrics (bandwidth in Mbps, latency in ms)
|
|
* @param {number} bandwidth_mbps
|
|
* @param {number} latency_ms
|
|
*/
|
|
updateMetrics(bandwidth_mbps, latency_ms) {
|
|
wasm.wasmadaptivecompressor_updateMetrics(this.__wbg_ptr, bandwidth_mbps, latency_ms);
|
|
}
|
|
/**
|
|
* Create new adaptive compressor
|
|
*/
|
|
constructor() {
|
|
const ret = wasm.wasmadaptivecompressor_new();
|
|
this.__wbg_ptr = ret >>> 0;
|
|
WasmAdaptiveCompressorFinalization.register(this, this.__wbg_ptr, this);
|
|
return this;
|
|
}
|
|
/**
|
|
* Compress vector based on network conditions
|
|
* @param {Float32Array} data
|
|
* @returns {any}
|
|
*/
|
|
compress(data) {
|
|
const ptr0 = passArrayF32ToWasm0(data, wasm.__wbindgen_malloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmadaptivecompressor_compress(this.__wbg_ptr, ptr0, len0);
|
|
return ret;
|
|
}
|
|
/**
|
|
* Get current network condition
|
|
* @returns {string}
|
|
*/
|
|
condition() {
|
|
let deferred1_0;
|
|
let deferred1_1;
|
|
try {
|
|
const ret = wasm.wasmadaptivecompressor_condition(this.__wbg_ptr);
|
|
deferred1_0 = ret[0];
|
|
deferred1_1 = ret[1];
|
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
} finally {
|
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
}
|
|
}
|
|
}
|
|
if (Symbol.dispose) WasmAdaptiveCompressor.prototype[Symbol.dispose] = WasmAdaptiveCompressor.prototype.free;
|
|
|
|
/**
|
|
* WASM-compatible cryptographic utilities
|
|
*/
|
|
export class WasmCrypto {
|
|
__destroy_into_raw() {
|
|
const ptr = this.__wbg_ptr;
|
|
this.__wbg_ptr = 0;
|
|
WasmCryptoFinalization.unregister(this);
|
|
return ptr;
|
|
}
|
|
free() {
|
|
const ptr = this.__destroy_into_raw();
|
|
wasm.__wbg_wasmcrypto_free(ptr, 0);
|
|
}
|
|
/**
|
|
* Generate a local CID for data
|
|
* @param {Uint8Array} data
|
|
* @returns {string}
|
|
*/
|
|
static generateCid(data) {
|
|
let deferred2_0;
|
|
let deferred2_1;
|
|
try {
|
|
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmcrypto_generateCid(ptr0, len0);
|
|
deferred2_0 = ret[0];
|
|
deferred2_1 = ret[1];
|
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
} finally {
|
|
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
}
|
|
}
|
|
/**
|
|
* SHA-256 hash of string as hex
|
|
* @param {string} text
|
|
* @returns {string}
|
|
*/
|
|
static sha256String(text) {
|
|
let deferred2_0;
|
|
let deferred2_1;
|
|
try {
|
|
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmcrypto_sha256String(ptr0, len0);
|
|
deferred2_0 = ret[0];
|
|
deferred2_1 = ret[1];
|
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
} finally {
|
|
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
}
|
|
}
|
|
/**
|
|
* SHA-256 hash as hex string
|
|
* @param {Uint8Array} data
|
|
* @returns {string}
|
|
*/
|
|
static sha256(data) {
|
|
let deferred2_0;
|
|
let deferred2_1;
|
|
try {
|
|
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmcrypto_sha256(ptr0, len0);
|
|
deferred2_0 = ret[0];
|
|
deferred2_1 = ret[1];
|
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
} finally {
|
|
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
}
|
|
}
|
|
/**
|
|
* Decrypt data with AES-256-GCM
|
|
* @param {any} encrypted
|
|
* @param {string} key_hex
|
|
* @returns {Uint8Array}
|
|
*/
|
|
static decrypt(encrypted, key_hex) {
|
|
const ptr0 = passStringToWasm0(key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmcrypto_decrypt(encrypted, ptr0, len0);
|
|
if (ret[3]) {
|
|
throw takeFromExternrefTable0(ret[2]);
|
|
}
|
|
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
return v2;
|
|
}
|
|
/**
|
|
* Encrypt data with AES-256-GCM (key as hex)
|
|
* @param {Uint8Array} data
|
|
* @param {string} key_hex
|
|
* @returns {any}
|
|
*/
|
|
static encrypt(data, key_hex) {
|
|
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ptr1 = passStringToWasm0(key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmcrypto_encrypt(ptr0, len0, ptr1, len1);
|
|
if (ret[2]) {
|
|
throw takeFromExternrefTable0(ret[1]);
|
|
}
|
|
return takeFromExternrefTable0(ret[0]);
|
|
}
|
|
}
|
|
if (Symbol.dispose) WasmCrypto.prototype[Symbol.dispose] = WasmCrypto.prototype.free;
|
|
|
|
/**
|
|
* WASM-compatible HNSW index for fast vector similarity search
|
|
*/
|
|
export class WasmHnswIndex {
|
|
static __wrap(ptr) {
|
|
ptr = ptr >>> 0;
|
|
const obj = Object.create(WasmHnswIndex.prototype);
|
|
obj.__wbg_ptr = ptr;
|
|
WasmHnswIndexFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
return obj;
|
|
}
|
|
__destroy_into_raw() {
|
|
const ptr = this.__wbg_ptr;
|
|
this.__wbg_ptr = 0;
|
|
WasmHnswIndexFinalization.unregister(this);
|
|
return ptr;
|
|
}
|
|
free() {
|
|
const ptr = this.__destroy_into_raw();
|
|
wasm.__wbg_wasmhnswindex_free(ptr, 0);
|
|
}
|
|
/**
|
|
* Create with custom parameters (m = connections per node, ef = search width)
|
|
* @param {number} m
|
|
* @param {number} ef_construction
|
|
* @returns {WasmHnswIndex}
|
|
*/
|
|
static withParams(m, ef_construction) {
|
|
const ret = wasm.wasmhnswindex_withParams(m, ef_construction);
|
|
return WasmHnswIndex.__wrap(ret);
|
|
}
|
|
/**
|
|
* Get number of vectors in index
|
|
* @returns {number}
|
|
*/
|
|
len() {
|
|
const ret = wasm.wasmhnswindex_len(this.__wbg_ptr);
|
|
return ret >>> 0;
|
|
}
|
|
/**
|
|
* Create new HNSW index with default parameters
|
|
*/
|
|
constructor() {
|
|
const ret = wasm.wasmhnswindex_new();
|
|
this.__wbg_ptr = ret >>> 0;
|
|
WasmHnswIndexFinalization.register(this, this.__wbg_ptr, this);
|
|
return this;
|
|
}
|
|
/**
|
|
* Insert a vector with an ID
|
|
* @param {string} id
|
|
* @param {Float32Array} vector
|
|
*/
|
|
insert(id, vector) {
|
|
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ptr1 = passArrayF32ToWasm0(vector, wasm.__wbindgen_malloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
wasm.wasmhnswindex_insert(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
}
|
|
/**
|
|
* Search for k nearest neighbors, returns JSON array of {id, distance}
|
|
* @param {Float32Array} query
|
|
* @param {number} k
|
|
* @returns {any}
|
|
*/
|
|
search(query, k) {
|
|
const ptr0 = passArrayF32ToWasm0(query, wasm.__wbindgen_malloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmhnswindex_search(this.__wbg_ptr, ptr0, len0, k);
|
|
return ret;
|
|
}
|
|
/**
|
|
* Check if index is empty
|
|
* @returns {boolean}
|
|
*/
|
|
isEmpty() {
|
|
const ret = wasm.wasmhnswindex_isEmpty(this.__wbg_ptr);
|
|
return ret !== 0;
|
|
}
|
|
}
|
|
if (Symbol.dispose) WasmHnswIndex.prototype[Symbol.dispose] = WasmHnswIndex.prototype.free;
|
|
|
|
/**
|
|
* WASM-compatible hybrid post-quantum signatures (Ed25519 + Dilithium-style)
|
|
*/
|
|
export class WasmHybridKeyPair {
|
|
__destroy_into_raw() {
|
|
const ptr = this.__wbg_ptr;
|
|
this.__wbg_ptr = 0;
|
|
WasmHybridKeyPairFinalization.unregister(this);
|
|
return ptr;
|
|
}
|
|
free() {
|
|
const ptr = this.__destroy_into_raw();
|
|
wasm.__wbg_wasmhybridkeypair_free(ptr, 0);
|
|
}
|
|
/**
|
|
* Get public key bytes as hex
|
|
* @returns {string}
|
|
*/
|
|
publicKeyHex() {
|
|
let deferred1_0;
|
|
let deferred1_1;
|
|
try {
|
|
const ret = wasm.wasmhybridkeypair_publicKeyHex(this.__wbg_ptr);
|
|
deferred1_0 = ret[0];
|
|
deferred1_1 = ret[1];
|
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
} finally {
|
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
}
|
|
}
|
|
/**
|
|
* Generate new hybrid keypair
|
|
*/
|
|
constructor() {
|
|
const ret = wasm.wasmhybridkeypair_new();
|
|
this.__wbg_ptr = ret >>> 0;
|
|
WasmHybridKeyPairFinalization.register(this, this.__wbg_ptr, this);
|
|
return this;
|
|
}
|
|
/**
|
|
* Sign message with hybrid signature
|
|
* @param {Uint8Array} message
|
|
* @returns {string}
|
|
*/
|
|
sign(message) {
|
|
let deferred2_0;
|
|
let deferred2_1;
|
|
try {
|
|
const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmhybridkeypair_sign(this.__wbg_ptr, ptr0, len0);
|
|
deferred2_0 = ret[0];
|
|
deferred2_1 = ret[1];
|
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
} finally {
|
|
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
}
|
|
}
|
|
/**
|
|
* Verify hybrid signature (pubkey and signature both as JSON)
|
|
* @param {string} public_key_json
|
|
* @param {Uint8Array} message
|
|
* @param {string} signature_json
|
|
* @returns {boolean}
|
|
*/
|
|
static verify(public_key_json, message, signature_json) {
|
|
const ptr0 = passStringToWasm0(public_key_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
const ptr2 = passStringToWasm0(signature_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len2 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmhybridkeypair_verify(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
return ret !== 0;
|
|
}
|
|
}
|
|
if (Symbol.dispose) WasmHybridKeyPair.prototype[Symbol.dispose] = WasmHybridKeyPair.prototype.free;
|
|
|
|
/**
|
|
* WASM-compatible Identity Manager for Ed25519/X25519 cryptography
|
|
*/
|
|
export class WasmIdentity {
|
|
__destroy_into_raw() {
|
|
const ptr = this.__wbg_ptr;
|
|
this.__wbg_ptr = 0;
|
|
WasmIdentityFinalization.unregister(this);
|
|
return ptr;
|
|
}
|
|
free() {
|
|
const ptr = this.__destroy_into_raw();
|
|
wasm.__wbg_wasmidentity_free(ptr, 0);
|
|
}
|
|
/**
|
|
* Sign raw bytes and return signature as hex
|
|
* @param {Uint8Array} data
|
|
* @returns {string}
|
|
*/
|
|
signBytes(data) {
|
|
let deferred2_0;
|
|
let deferred2_1;
|
|
try {
|
|
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmidentity_signBytes(this.__wbg_ptr, ptr0, len0);
|
|
deferred2_0 = ret[0];
|
|
deferred2_1 = ret[1];
|
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
} finally {
|
|
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
}
|
|
}
|
|
/**
|
|
* Generate a random nonce
|
|
* @returns {string}
|
|
*/
|
|
static generateNonce() {
|
|
let deferred1_0;
|
|
let deferred1_1;
|
|
try {
|
|
const ret = wasm.wasmidentity_generateNonce();
|
|
deferred1_0 = ret[0];
|
|
deferred1_1 = ret[1];
|
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
} finally {
|
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
}
|
|
}
|
|
/**
|
|
* Get Ed25519 public key as hex string
|
|
* @returns {string}
|
|
*/
|
|
publicKeyHex() {
|
|
let deferred1_0;
|
|
let deferred1_1;
|
|
try {
|
|
const ret = wasm.wasmidentity_publicKeyHex(this.__wbg_ptr);
|
|
deferred1_0 = ret[0];
|
|
deferred1_1 = ret[1];
|
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
} finally {
|
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
}
|
|
}
|
|
/**
|
|
* Create a signed registration for this identity
|
|
* @param {string} agent_id
|
|
* @param {any} capabilities
|
|
* @returns {any}
|
|
*/
|
|
createRegistration(agent_id, capabilities) {
|
|
const ptr0 = passStringToWasm0(agent_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmidentity_createRegistration(this.__wbg_ptr, ptr0, len0, capabilities);
|
|
if (ret[2]) {
|
|
throw takeFromExternrefTable0(ret[1]);
|
|
}
|
|
return takeFromExternrefTable0(ret[0]);
|
|
}
|
|
/**
|
|
* Get X25519 public key as hex string (for key exchange)
|
|
* @returns {string}
|
|
*/
|
|
x25519PublicKeyHex() {
|
|
let deferred1_0;
|
|
let deferred1_1;
|
|
try {
|
|
const ret = wasm.wasmidentity_x25519PublicKeyHex(this.__wbg_ptr);
|
|
deferred1_0 = ret[0];
|
|
deferred1_1 = ret[1];
|
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
} finally {
|
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
}
|
|
}
|
|
/**
|
|
* Create a new identity with generated keys
|
|
*/
|
|
constructor() {
|
|
const ret = wasm.wasmidentity_new();
|
|
this.__wbg_ptr = ret >>> 0;
|
|
WasmIdentityFinalization.register(this, this.__wbg_ptr, this);
|
|
return this;
|
|
}
|
|
/**
|
|
* Sign a message and return signature as hex
|
|
* @param {string} message
|
|
* @returns {string}
|
|
*/
|
|
sign(message) {
|
|
let deferred2_0;
|
|
let deferred2_1;
|
|
try {
|
|
const ptr0 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmidentity_sign(this.__wbg_ptr, ptr0, len0);
|
|
deferred2_0 = ret[0];
|
|
deferred2_1 = ret[1];
|
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
} finally {
|
|
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
}
|
|
}
|
|
/**
|
|
* Verify a signature (static method)
|
|
* @param {string} public_key_hex
|
|
* @param {string} message
|
|
* @param {string} signature_hex
|
|
* @returns {boolean}
|
|
*/
|
|
static verify(public_key_hex, message, signature_hex) {
|
|
const ptr0 = passStringToWasm0(public_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ptr1 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
const ptr2 = passStringToWasm0(signature_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len2 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmidentity_verify(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
return ret !== 0;
|
|
}
|
|
}
|
|
if (Symbol.dispose) WasmIdentity.prototype[Symbol.dispose] = WasmIdentity.prototype.free;
|
|
|
|
/**
|
|
* WASM-compatible vector quantization utilities
|
|
*/
|
|
export class WasmQuantizer {
|
|
__destroy_into_raw() {
|
|
const ptr = this.__wbg_ptr;
|
|
this.__wbg_ptr = 0;
|
|
WasmQuantizerFinalization.unregister(this);
|
|
return ptr;
|
|
}
|
|
free() {
|
|
const ptr = this.__destroy_into_raw();
|
|
wasm.__wbg_wasmquantizer_free(ptr, 0);
|
|
}
|
|
/**
|
|
* Binary quantize a vector (32x compression)
|
|
* @param {Float32Array} vector
|
|
* @returns {Uint8Array}
|
|
*/
|
|
static binaryQuantize(vector) {
|
|
const ptr0 = passArrayF32ToWasm0(vector, wasm.__wbindgen_malloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmquantizer_binaryQuantize(ptr0, len0);
|
|
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
return v2;
|
|
}
|
|
/**
|
|
* Scalar quantize a vector (4x compression)
|
|
* @param {Float32Array} vector
|
|
* @returns {any}
|
|
*/
|
|
static scalarQuantize(vector) {
|
|
const ptr0 = passArrayF32ToWasm0(vector, wasm.__wbindgen_malloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmquantizer_scalarQuantize(ptr0, len0);
|
|
return ret;
|
|
}
|
|
/**
|
|
* Compute hamming distance between binary quantized vectors
|
|
* @param {Uint8Array} a
|
|
* @param {Uint8Array} b
|
|
* @returns {number}
|
|
*/
|
|
static hammingDistance(a, b) {
|
|
const ptr0 = passArray8ToWasm0(a, wasm.__wbindgen_malloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ptr1 = passArray8ToWasm0(b, wasm.__wbindgen_malloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmquantizer_hammingDistance(ptr0, len0, ptr1, len1);
|
|
return ret >>> 0;
|
|
}
|
|
/**
|
|
* Reconstruct from scalar quantized
|
|
* @param {any} quantized
|
|
* @returns {Float32Array}
|
|
*/
|
|
static scalarDequantize(quantized) {
|
|
const ret = wasm.wasmquantizer_scalarDequantize(quantized);
|
|
if (ret[3]) {
|
|
throw takeFromExternrefTable0(ret[2]);
|
|
}
|
|
var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
return v1;
|
|
}
|
|
}
|
|
if (Symbol.dispose) WasmQuantizer.prototype[Symbol.dispose] = WasmQuantizer.prototype.free;
|
|
|
|
/**
|
|
* WASM-compatible Raft consensus node
|
|
*/
|
|
export class WasmRaftNode {
|
|
__destroy_into_raw() {
|
|
const ptr = this.__wbg_ptr;
|
|
this.__wbg_ptr = 0;
|
|
WasmRaftNodeFinalization.unregister(this);
|
|
return ptr;
|
|
}
|
|
free() {
|
|
const ptr = this.__destroy_into_raw();
|
|
wasm.__wbg_wasmraftnode_free(ptr, 0);
|
|
}
|
|
/**
|
|
* Append entry to log (leader only), returns log index or null
|
|
* @param {Uint8Array} data
|
|
* @returns {any}
|
|
*/
|
|
appendEntry(data) {
|
|
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmraftnode_appendEntry(this.__wbg_ptr, ptr0, len0);
|
|
return ret;
|
|
}
|
|
/**
|
|
* Get log length
|
|
* @returns {number}
|
|
*/
|
|
getLogLength() {
|
|
const ret = wasm.wasmraftnode_getLogLength(this.__wbg_ptr);
|
|
return ret >>> 0;
|
|
}
|
|
/**
|
|
* Start an election (returns vote request as JSON)
|
|
* @returns {any}
|
|
*/
|
|
startElection() {
|
|
const ret = wasm.wasmraftnode_startElection(this.__wbg_ptr);
|
|
return ret;
|
|
}
|
|
/**
|
|
* Get commit index
|
|
* @returns {bigint}
|
|
*/
|
|
getCommitIndex() {
|
|
const ret = wasm.wasmraftnode_getCommitIndex(this.__wbg_ptr);
|
|
return BigInt.asUintN(64, ret);
|
|
}
|
|
/**
|
|
* Handle a vote request (returns vote response as JSON)
|
|
* @param {any} request
|
|
* @returns {any}
|
|
*/
|
|
handleVoteRequest(request) {
|
|
const ret = wasm.wasmraftnode_handleVoteRequest(this.__wbg_ptr, request);
|
|
if (ret[2]) {
|
|
throw takeFromExternrefTable0(ret[1]);
|
|
}
|
|
return takeFromExternrefTable0(ret[0]);
|
|
}
|
|
/**
|
|
* Handle a vote response (returns true if we became leader)
|
|
* @param {any} response
|
|
* @returns {boolean}
|
|
*/
|
|
handleVoteResponse(response) {
|
|
const ret = wasm.wasmraftnode_handleVoteResponse(this.__wbg_ptr, response);
|
|
if (ret[2]) {
|
|
throw takeFromExternrefTable0(ret[1]);
|
|
}
|
|
return ret[0] !== 0;
|
|
}
|
|
/**
|
|
* Create new Raft node with cluster members
|
|
* @param {string} node_id
|
|
* @param {any} members
|
|
*/
|
|
constructor(node_id, members) {
|
|
const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmraftnode_new(ptr0, len0, members);
|
|
if (ret[2]) {
|
|
throw takeFromExternrefTable0(ret[1]);
|
|
}
|
|
this.__wbg_ptr = ret[0] >>> 0;
|
|
WasmRaftNodeFinalization.register(this, this.__wbg_ptr, this);
|
|
return this;
|
|
}
|
|
/**
|
|
* Get current term
|
|
* @returns {bigint}
|
|
*/
|
|
term() {
|
|
const ret = wasm.wasmraftnode_term(this.__wbg_ptr);
|
|
return BigInt.asUintN(64, ret);
|
|
}
|
|
/**
|
|
* Get current state (Follower, Candidate, Leader)
|
|
* @returns {string}
|
|
*/
|
|
state() {
|
|
let deferred1_0;
|
|
let deferred1_1;
|
|
try {
|
|
const ret = wasm.wasmraftnode_state(this.__wbg_ptr);
|
|
deferred1_0 = ret[0];
|
|
deferred1_1 = ret[1];
|
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
} finally {
|
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
}
|
|
}
|
|
/**
|
|
* Check if this node is the leader
|
|
* @returns {boolean}
|
|
*/
|
|
isLeader() {
|
|
const ret = wasm.wasmraftnode_isLeader(this.__wbg_ptr);
|
|
return ret !== 0;
|
|
}
|
|
}
|
|
if (Symbol.dispose) WasmRaftNode.prototype[Symbol.dispose] = WasmRaftNode.prototype.free;
|
|
|
|
/**
|
|
* WASM-compatible semantic task matcher for intelligent agent routing
|
|
*/
|
|
export class WasmSemanticMatcher {
|
|
__destroy_into_raw() {
|
|
const ptr = this.__wbg_ptr;
|
|
this.__wbg_ptr = 0;
|
|
WasmSemanticMatcherFinalization.unregister(this);
|
|
return ptr;
|
|
}
|
|
free() {
|
|
const ptr = this.__destroy_into_raw();
|
|
wasm.__wbg_wasmsemanticmatcher_free(ptr, 0);
|
|
}
|
|
/**
|
|
* Get number of registered agents
|
|
* @returns {number}
|
|
*/
|
|
agentCount() {
|
|
const ret = wasm.wasmsemanticmatcher_agentCount(this.__wbg_ptr);
|
|
return ret >>> 0;
|
|
}
|
|
/**
|
|
* Find best matching agent for a task, returns {agentId, score} or null
|
|
* @param {string} task_description
|
|
* @returns {any}
|
|
*/
|
|
matchAgent(task_description) {
|
|
const ptr0 = passStringToWasm0(task_description, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmsemanticmatcher_matchAgent(this.__wbg_ptr, ptr0, len0);
|
|
return ret;
|
|
}
|
|
/**
|
|
* Register an agent with capability description
|
|
* @param {string} agent_id
|
|
* @param {string} capabilities
|
|
*/
|
|
registerAgent(agent_id, capabilities) {
|
|
const ptr0 = passStringToWasm0(agent_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ptr1 = passStringToWasm0(capabilities, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
wasm.wasmsemanticmatcher_registerAgent(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
}
|
|
/**
|
|
* Create new semantic matcher
|
|
*/
|
|
constructor() {
|
|
const ret = wasm.wasmsemanticmatcher_new();
|
|
this.__wbg_ptr = ret >>> 0;
|
|
WasmSemanticMatcherFinalization.register(this, this.__wbg_ptr, this);
|
|
return this;
|
|
}
|
|
}
|
|
if (Symbol.dispose) WasmSemanticMatcher.prototype[Symbol.dispose] = WasmSemanticMatcher.prototype.free;
|
|
|
|
/**
|
|
* WASM-compatible spiking neural network for temporal pattern recognition
|
|
*/
|
|
export class WasmSpikingNetwork {
|
|
__destroy_into_raw() {
|
|
const ptr = this.__wbg_ptr;
|
|
this.__wbg_ptr = 0;
|
|
WasmSpikingNetworkFinalization.unregister(this);
|
|
return ptr;
|
|
}
|
|
free() {
|
|
const ptr = this.__destroy_into_raw();
|
|
wasm.__wbg_wasmspikingnetwork_free(ptr, 0);
|
|
}
|
|
/**
|
|
* Apply STDP learning rule
|
|
* @param {Uint8Array} pre
|
|
* @param {Uint8Array} post
|
|
* @param {number} learning_rate
|
|
*/
|
|
stdpUpdate(pre, post, learning_rate) {
|
|
const ptr0 = passArray8ToWasm0(pre, wasm.__wbindgen_malloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ptr1 = passArray8ToWasm0(post, wasm.__wbindgen_malloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
wasm.wasmspikingnetwork_stdpUpdate(this.__wbg_ptr, ptr0, len0, ptr1, len1, learning_rate);
|
|
}
|
|
/**
|
|
* Create new spiking network
|
|
* @param {number} input_size
|
|
* @param {number} hidden_size
|
|
* @param {number} output_size
|
|
*/
|
|
constructor(input_size, hidden_size, output_size) {
|
|
const ret = wasm.wasmspikingnetwork_new(input_size, hidden_size, output_size);
|
|
this.__wbg_ptr = ret >>> 0;
|
|
WasmSpikingNetworkFinalization.register(this, this.__wbg_ptr, this);
|
|
return this;
|
|
}
|
|
/**
|
|
* Reset network state
|
|
*/
|
|
reset() {
|
|
wasm.wasmspikingnetwork_reset(this.__wbg_ptr);
|
|
}
|
|
/**
|
|
* Process input spikes and return output spikes
|
|
* @param {Uint8Array} inputs
|
|
* @returns {Uint8Array}
|
|
*/
|
|
forward(inputs) {
|
|
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.wasmspikingnetwork_forward(this.__wbg_ptr, ptr0, len0);
|
|
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
return v2;
|
|
}
|
|
}
|
|
if (Symbol.dispose) WasmSpikingNetwork.prototype[Symbol.dispose] = WasmSpikingNetwork.prototype.free;
|
|
|
|
/**
|
|
* Initialize the WASM module (call once on load)
|
|
*/
|
|
export function init() {
|
|
wasm.init();
|
|
}
|
|
|
|
/**
|
|
* Get library version
|
|
* @returns {string}
|
|
*/
|
|
export function version() {
|
|
let deferred1_0;
|
|
let deferred1_1;
|
|
try {
|
|
const ret = wasm.version();
|
|
deferred1_0 = ret[0];
|
|
deferred1_1 = ret[1];
|
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
} finally {
|
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
}
|
|
}
|
|
|
|
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
|
|
async function __wbg_load(module, imports) {
|
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
try {
|
|
return await WebAssembly.instantiateStreaming(module, imports);
|
|
} catch (e) {
|
|
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
|
|
if (validResponse && module.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);
|
|
|
|
} else {
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
|
|
const bytes = await module.arrayBuffer();
|
|
return await WebAssembly.instantiate(bytes, imports);
|
|
} else {
|
|
const instance = await WebAssembly.instantiate(module, imports);
|
|
|
|
if (instance instanceof WebAssembly.Instance) {
|
|
return { instance, module };
|
|
} else {
|
|
return instance;
|
|
}
|
|
}
|
|
}
|
|
|
|
function __wbg_get_imports() {
|
|
const imports = {};
|
|
imports.wbg = {};
|
|
imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
|
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_Number_2d1dcfcf4ec51736 = function(arg0) {
|
|
const ret = Number(arg0);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
|
|
const ret = String(arg1);
|
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
};
|
|
imports.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d = function(arg0, arg1) {
|
|
const v = arg1;
|
|
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
};
|
|
imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
|
|
const v = arg0;
|
|
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
};
|
|
imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
|
|
const ret = debugString(arg1);
|
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
};
|
|
imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function(arg0, arg1) {
|
|
const ret = arg0 in arg1;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27 = function(arg0) {
|
|
const ret = typeof(arg0) === 'bigint';
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
|
|
const ret = typeof(arg0) === 'function';
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
|
|
const val = arg0;
|
|
const ret = typeof(val) === 'object' && val !== null;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
|
|
const ret = typeof(arg0) === 'string';
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
|
|
const ret = arg0 === undefined;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36 = function(arg0, arg1) {
|
|
const ret = arg0 === arg1;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
|
|
const ret = arg0 == arg1;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
|
|
const obj = arg1;
|
|
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
};
|
|
imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
|
|
const obj = arg1;
|
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
var len1 = WASM_VECTOR_LEN;
|
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
};
|
|
imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
};
|
|
imports.wbg.__wbg_call_3020136f7a2d6e44 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
const ret = arg0.call(arg1, arg2);
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
|
|
const ret = arg0.call(arg1);
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
|
|
const ret = arg0.crypto;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_done_62ea16af4ce34b24 = function(arg0) {
|
|
const ret = arg0.done;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
|
|
let deferred0_0;
|
|
let deferred0_1;
|
|
try {
|
|
deferred0_0 = arg0;
|
|
deferred0_1 = arg1;
|
|
console.error(getStringFromWasm0(arg0, arg1));
|
|
} finally {
|
|
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
}
|
|
};
|
|
imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
|
|
arg0.getRandomValues(arg1);
|
|
}, arguments) };
|
|
imports.wbg.__wbg_getTime_ad1e9878a735af08 = function(arg0) {
|
|
const ret = arg0.getTime();
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
|
|
const ret = arg0[arg1 >>> 0];
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
|
|
const ret = Reflect.get(arg0, arg1);
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
|
|
const ret = arg0[arg1];
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
|
|
let result;
|
|
try {
|
|
result = arg0 instanceof ArrayBuffer;
|
|
} catch (_) {
|
|
result = false;
|
|
}
|
|
const ret = result;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
|
|
let result;
|
|
try {
|
|
result = arg0 instanceof Uint8Array;
|
|
} catch (_) {
|
|
result = false;
|
|
}
|
|
const ret = result;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
|
|
const ret = Array.isArray(arg0);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16 = function(arg0) {
|
|
const ret = Number.isSafeInteger(arg0);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function() {
|
|
const ret = Symbol.iterator;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
|
|
const ret = arg0.length;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
|
|
const ret = arg0.length;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
|
|
const ret = arg0.msCrypto;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_new_0_23cedd11d9b40c9d = function() {
|
|
const ret = new Date();
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
|
|
const ret = new Object();
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_new_25f239778d6112b9 = function() {
|
|
const ret = new Array();
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
|
|
const ret = new Uint8Array(arg0);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
|
|
const ret = new Error();
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) {
|
|
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_new_with_length_aa5eaf41d35235e5 = function(arg0) {
|
|
const ret = new Uint8Array(arg0 >>> 0);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) {
|
|
const ret = arg0.next;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_next_3cfe5c0fe2a4cc53 = function() { return handleError(function (arg0) {
|
|
const ret = arg0.next();
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_node_905d3e251edff8a2 = function(arg0) {
|
|
const ret = arg0.node;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
|
|
const ret = arg0.process;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
|
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
};
|
|
imports.wbg.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
|
|
arg0.randomFillSync(arg1);
|
|
}, arguments) };
|
|
imports.wbg.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
|
|
const ret = module.require;
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
|
|
arg0[arg1] = arg2;
|
|
};
|
|
imports.wbg.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
|
|
arg0[arg1 >>> 0] = arg2;
|
|
};
|
|
imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
|
const ret = arg1.stack;
|
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
};
|
|
imports.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() {
|
|
const ret = typeof global === 'undefined' ? null : global;
|
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
};
|
|
imports.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
|
|
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
};
|
|
imports.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
|
|
const ret = typeof self === 'undefined' ? null : self;
|
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
};
|
|
imports.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() {
|
|
const ret = typeof window === 'undefined' ? null : window;
|
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
};
|
|
imports.wbg.__wbg_subarray_845f2f5bce7d061a = function(arg0, arg1, arg2) {
|
|
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_value_57b7b035e117f7ee = function(arg0) {
|
|
const ret = arg0.value;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_versions_c01dfd4722a88165 = function(arg0) {
|
|
const ret = arg0.versions;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
|
|
// Cast intrinsic for `U64 -> Externref`.
|
|
const ret = BigInt.asUintN(64, arg0);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
|
|
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
// Cast intrinsic for `F64 -> Externref`.
|
|
const ret = arg0;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
const table = wasm.__wbindgen_externrefs;
|
|
const offset = table.grow(4);
|
|
table.set(0, undefined);
|
|
table.set(offset + 0, undefined);
|
|
table.set(offset + 1, null);
|
|
table.set(offset + 2, true);
|
|
table.set(offset + 3, false);
|
|
};
|
|
|
|
return imports;
|
|
}
|
|
|
|
function __wbg_finalize_init(instance, module) {
|
|
wasm = instance.exports;
|
|
__wbg_init.__wbindgen_wasm_module = module;
|
|
cachedDataViewMemory0 = null;
|
|
cachedFloat32ArrayMemory0 = null;
|
|
cachedUint8ArrayMemory0 = null;
|
|
|
|
|
|
wasm.__wbindgen_start();
|
|
return wasm;
|
|
}
|
|
|
|
function initSync(module) {
|
|
if (wasm !== undefined) return wasm;
|
|
|
|
|
|
if (typeof module !== 'undefined') {
|
|
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
({module} = module)
|
|
} else {
|
|
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
}
|
|
}
|
|
|
|
const imports = __wbg_get_imports();
|
|
if (!(module instanceof WebAssembly.Module)) {
|
|
module = new WebAssembly.Module(module);
|
|
}
|
|
const instance = new WebAssembly.Instance(module, imports);
|
|
return __wbg_finalize_init(instance, module);
|
|
}
|
|
|
|
async function __wbg_init(module_or_path) {
|
|
if (wasm !== undefined) return wasm;
|
|
|
|
|
|
if (typeof module_or_path !== 'undefined') {
|
|
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
({module_or_path} = module_or_path)
|
|
} else {
|
|
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
}
|
|
}
|
|
|
|
if (typeof module_or_path === 'undefined') {
|
|
module_or_path = new URL('ruvector_edge_bg.wasm', import.meta.url);
|
|
}
|
|
const imports = __wbg_get_imports();
|
|
|
|
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
module_or_path = fetch(module_or_path);
|
|
}
|
|
|
|
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
|
|
return __wbg_finalize_init(instance, module);
|
|
}
|
|
|
|
export { initSync };
|
|
export default __wbg_init;
|