ruvector 0.1.94 → 0.1.96
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/bin/cli.js +0 -819
- package/bin/mcp-server.js +1 -512
- package/dist/core/index.d.ts +0 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -4
- package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm_cjs.js +127 -0
- package/package.json +1 -2
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CommonJS-compatible WASM loader for Node.js
|
|
3
|
+
*
|
|
4
|
+
* This file provides a way to load the WASM module without requiring
|
|
5
|
+
* the --experimental-wasm-modules flag by manually loading the WASM bytes.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* const wasm = require('./ruvector_onnx_embeddings_wasm_cjs.js');
|
|
9
|
+
* await wasm.init(); // or wasm.initSync(wasmBytes)
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
|
|
15
|
+
// Re-export everything from the JS bindings
|
|
16
|
+
const bindings = require('./ruvector_onnx_embeddings_wasm_bg.js');
|
|
17
|
+
|
|
18
|
+
// Track initialization state
|
|
19
|
+
let initialized = false;
|
|
20
|
+
let initPromise = null;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Initialize the WASM module asynchronously
|
|
24
|
+
* Automatically loads the .wasm file from the same directory
|
|
25
|
+
*/
|
|
26
|
+
async function init(wasmInput) {
|
|
27
|
+
if (initialized) return bindings;
|
|
28
|
+
|
|
29
|
+
if (initPromise) {
|
|
30
|
+
await initPromise;
|
|
31
|
+
return bindings;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
initPromise = (async () => {
|
|
35
|
+
let wasmBytes;
|
|
36
|
+
|
|
37
|
+
if (wasmInput instanceof WebAssembly.Module) {
|
|
38
|
+
// Already compiled module
|
|
39
|
+
const instance = await WebAssembly.instantiate(wasmInput, getImports());
|
|
40
|
+
bindings.__wbg_set_wasm(instance.exports);
|
|
41
|
+
finishInit();
|
|
42
|
+
return;
|
|
43
|
+
} else if (wasmInput instanceof ArrayBuffer || wasmInput instanceof Uint8Array) {
|
|
44
|
+
// Raw bytes provided
|
|
45
|
+
wasmBytes = wasmInput;
|
|
46
|
+
} else if (typeof wasmInput === 'string') {
|
|
47
|
+
// Path to WASM file
|
|
48
|
+
wasmBytes = fs.readFileSync(wasmInput);
|
|
49
|
+
} else {
|
|
50
|
+
// Auto-detect WASM file location
|
|
51
|
+
const wasmPath = path.join(__dirname, 'ruvector_onnx_embeddings_wasm_bg.wasm');
|
|
52
|
+
wasmBytes = fs.readFileSync(wasmPath);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const wasmModule = await WebAssembly.compile(wasmBytes);
|
|
56
|
+
const instance = await WebAssembly.instantiate(wasmModule, getImports());
|
|
57
|
+
|
|
58
|
+
bindings.__wbg_set_wasm(instance.exports);
|
|
59
|
+
finishInit();
|
|
60
|
+
})();
|
|
61
|
+
|
|
62
|
+
await initPromise;
|
|
63
|
+
return bindings;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Initialize the WASM module synchronously
|
|
68
|
+
* Requires the WASM bytes to be provided
|
|
69
|
+
*/
|
|
70
|
+
function initSync(wasmBytes) {
|
|
71
|
+
if (initialized) return bindings;
|
|
72
|
+
|
|
73
|
+
if (!wasmBytes) {
|
|
74
|
+
const wasmPath = path.join(__dirname, 'ruvector_onnx_embeddings_wasm_bg.wasm');
|
|
75
|
+
wasmBytes = fs.readFileSync(wasmPath);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
79
|
+
const instance = new WebAssembly.Instance(wasmModule, getImports());
|
|
80
|
+
|
|
81
|
+
bindings.__wbg_set_wasm(instance.exports);
|
|
82
|
+
finishInit();
|
|
83
|
+
|
|
84
|
+
return bindings;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Get the WASM import object
|
|
89
|
+
*/
|
|
90
|
+
function getImports() {
|
|
91
|
+
return {
|
|
92
|
+
'./ruvector_onnx_embeddings_wasm_bg.js': bindings,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Finalize initialization
|
|
98
|
+
*/
|
|
99
|
+
function finishInit() {
|
|
100
|
+
if (typeof bindings.__wbindgen_init_externref_table === 'function') {
|
|
101
|
+
bindings.__wbindgen_init_externref_table();
|
|
102
|
+
}
|
|
103
|
+
initialized = true;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Check if initialized
|
|
108
|
+
*/
|
|
109
|
+
function isInitialized() {
|
|
110
|
+
return initialized;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Export init functions and all bindings
|
|
114
|
+
module.exports = {
|
|
115
|
+
init,
|
|
116
|
+
initSync,
|
|
117
|
+
isInitialized,
|
|
118
|
+
default: init,
|
|
119
|
+
// Re-export all bindings
|
|
120
|
+
WasmEmbedder: bindings.WasmEmbedder,
|
|
121
|
+
WasmEmbedderConfig: bindings.WasmEmbedderConfig,
|
|
122
|
+
PoolingStrategy: bindings.PoolingStrategy,
|
|
123
|
+
cosineSimilarity: bindings.cosineSimilarity,
|
|
124
|
+
normalizeL2: bindings.normalizeL2,
|
|
125
|
+
simd_available: bindings.simd_available,
|
|
126
|
+
version: bindings.version,
|
|
127
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ruvector",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.96",
|
|
4
4
|
"description": "High-performance vector database for Node.js with automatic native/WASM fallback",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -60,7 +60,6 @@
|
|
|
60
60
|
"@ruvector/core": "^0.1.25",
|
|
61
61
|
"@ruvector/gnn": "^0.1.22",
|
|
62
62
|
"@ruvector/sona": "^0.1.4",
|
|
63
|
-
"@xenova/transformers": "^2.17.2",
|
|
64
63
|
"chalk": "^4.1.2",
|
|
65
64
|
"commander": "^11.1.0",
|
|
66
65
|
"ora": "^5.4.1"
|