Squashed 'vendor/ruvector/' content from commit b64c2172
git-subtree-dir: vendor/ruvector git-subtree-split: b64c21726f2bb37286d9ee36a7869fef60cc6900
This commit is contained in:
45
npm/packages/core/index.js
Normal file
45
npm/packages/core/index.js
Normal file
@@ -0,0 +1,45 @@
|
||||
const { platform, arch } = process;
|
||||
|
||||
// Platform mapping
|
||||
const platformMap = {
|
||||
'linux': {
|
||||
'x64': 'ruvector-core-linux-x64-gnu',
|
||||
'arm64': 'ruvector-core-linux-arm64-gnu'
|
||||
},
|
||||
'darwin': {
|
||||
'x64': 'ruvector-core-darwin-x64',
|
||||
'arm64': 'ruvector-core-darwin-arm64'
|
||||
},
|
||||
'win32': {
|
||||
'x64': 'ruvector-core-win32-x64-msvc'
|
||||
}
|
||||
};
|
||||
|
||||
function loadNativeModule() {
|
||||
const platformPackage = platformMap[platform]?.[arch];
|
||||
|
||||
if (!platformPackage) {
|
||||
throw new Error(
|
||||
`Unsupported platform: ${platform}-${arch}\n` +
|
||||
`Ruvector native module is available for:\n` +
|
||||
`- Linux (x64, ARM64)\n` +
|
||||
`- macOS (x64, ARM64)\n` +
|
||||
`- Windows (x64)`
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
return require(platformPackage);
|
||||
} catch (error) {
|
||||
if (error.code === 'MODULE_NOT_FOUND') {
|
||||
throw new Error(
|
||||
`Native module not found for ${platform}-${arch}\n` +
|
||||
`Please install: npm install ${platformPackage}\n` +
|
||||
`Or reinstall ruvector-core to get optional dependencies`
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = loadNativeModule();
|
||||
Reference in New Issue
Block a user