vectlite 0.1.3
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/LICENSE +21 -0
- package/README.md +75 -0
- package/index.d.ts +182 -0
- package/index.js +284 -0
- package/native/Cargo.toml +23 -0
- package/native/build.rs +3 -0
- package/native/src/lib.rs +1214 -0
- package/native/vectlite-core/Cargo.toml +17 -0
- package/native/vectlite-core/src/lib.rs +3545 -0
- package/package.json +43 -0
- package/scripts/build-addon.mjs +52 -0
- package/scripts/clean-package.mjs +14 -0
- package/scripts/prepare-package.mjs +52 -0
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vectlite",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Embedded vector store for local-first AI applications.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"homepage": "https://github.com/mcsedition-hub/vectlite/tree/main/bindings/node",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/mcsedition-hub/vectlite.git",
|
|
11
|
+
"directory": "bindings/node"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/mcsedition-hub/vectlite/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"vectlite",
|
|
18
|
+
"vector-database",
|
|
19
|
+
"vector-search",
|
|
20
|
+
"embeddings",
|
|
21
|
+
"hnsw",
|
|
22
|
+
"rag",
|
|
23
|
+
"napi-rs"
|
|
24
|
+
],
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"files": [
|
|
27
|
+
"index.js",
|
|
28
|
+
"index.d.ts",
|
|
29
|
+
"README.md",
|
|
30
|
+
"scripts",
|
|
31
|
+
"native"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "node ./scripts/build-addon.mjs",
|
|
35
|
+
"test": "npm run build && node --test tests/smoke.test.cjs",
|
|
36
|
+
"install": "node ./scripts/build-addon.mjs",
|
|
37
|
+
"prepack": "node ./scripts/prepare-package.mjs",
|
|
38
|
+
"postpack": "node ./scripts/clean-package.mjs"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=18"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { copyFileSync, existsSync, mkdirSync } from 'node:fs'
|
|
2
|
+
import { dirname, join, resolve } from 'node:path'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
4
|
+
import { spawnSync } from 'node:child_process'
|
|
5
|
+
|
|
6
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
7
|
+
const packageRoot = resolve(__dirname, '..')
|
|
8
|
+
const repoRoot = resolve(packageRoot, '..', '..')
|
|
9
|
+
const packagedManifest = join(packageRoot, 'native', 'Cargo.toml')
|
|
10
|
+
const usingPackagedNative = existsSync(packagedManifest)
|
|
11
|
+
|
|
12
|
+
const cargoArgs = usingPackagedNative
|
|
13
|
+
? ['build', '--manifest-path', packagedManifest, '--release']
|
|
14
|
+
: ['build', '-p', 'vectlite-node', '--release']
|
|
15
|
+
|
|
16
|
+
const cargoCwd = usingPackagedNative ? packageRoot : repoRoot
|
|
17
|
+
|
|
18
|
+
const result = spawnSync('cargo', cargoArgs, {
|
|
19
|
+
cwd: cargoCwd,
|
|
20
|
+
stdio: 'inherit',
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
if (result.status !== 0) {
|
|
24
|
+
process.exit(result.status ?? 1)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const artifactName = (() => {
|
|
28
|
+
switch (process.platform) {
|
|
29
|
+
case 'darwin':
|
|
30
|
+
return 'libvectlite_node.dylib'
|
|
31
|
+
case 'win32':
|
|
32
|
+
return 'vectlite_node.dll'
|
|
33
|
+
default:
|
|
34
|
+
return 'libvectlite_node.so'
|
|
35
|
+
}
|
|
36
|
+
})()
|
|
37
|
+
|
|
38
|
+
const targetRoot = usingPackagedNative
|
|
39
|
+
? join(packageRoot, 'native', 'target', 'release')
|
|
40
|
+
: join(repoRoot, 'target', 'release')
|
|
41
|
+
|
|
42
|
+
const source = join(targetRoot, artifactName)
|
|
43
|
+
const output = join(packageRoot, 'vectlite.node')
|
|
44
|
+
|
|
45
|
+
if (!existsSync(source)) {
|
|
46
|
+
console.error(`Missing built addon artifact: ${source}`)
|
|
47
|
+
process.exit(1)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
mkdirSync(dirname(output), { recursive: true })
|
|
51
|
+
copyFileSync(source, output)
|
|
52
|
+
console.log(`Copied ${source} -> ${output}`)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { existsSync, rmSync } from 'node:fs'
|
|
2
|
+
import { dirname, join, resolve } from 'node:path'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
4
|
+
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
6
|
+
const packageRoot = resolve(__dirname, '..')
|
|
7
|
+
const nativeRoot = join(packageRoot, 'native')
|
|
8
|
+
const licensePath = join(packageRoot, 'LICENSE')
|
|
9
|
+
|
|
10
|
+
rmSync(nativeRoot, { recursive: true, force: true })
|
|
11
|
+
|
|
12
|
+
if (existsSync(licensePath)) {
|
|
13
|
+
rmSync(licensePath, { force: true })
|
|
14
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
2
|
+
import { dirname, join, resolve } from 'node:path'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
4
|
+
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
6
|
+
const packageRoot = resolve(__dirname, '..')
|
|
7
|
+
const repoRoot = resolve(packageRoot, '..', '..')
|
|
8
|
+
const nativeRoot = join(packageRoot, 'native')
|
|
9
|
+
|
|
10
|
+
const packageJson = JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf8'))
|
|
11
|
+
|
|
12
|
+
function concretizeManifest(manifest, version, edition, license, corePath = null) {
|
|
13
|
+
let output = manifest
|
|
14
|
+
.replace(/^version\.workspace = true$/m, `version = "${version}"`)
|
|
15
|
+
.replace(/^edition\.workspace = true$/m, `edition = "${edition}"`)
|
|
16
|
+
.replace(/^license\.workspace = true$/m, `license = "${license}"`)
|
|
17
|
+
|
|
18
|
+
if (corePath !== null) {
|
|
19
|
+
output = output.replace(
|
|
20
|
+
'vectlite = { package = "vectlite-core", path = "../../crates/vectlite-core" }',
|
|
21
|
+
`vectlite = { package = "vectlite-core", path = "${corePath}" }`,
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return output
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
rmSync(nativeRoot, { recursive: true, force: true })
|
|
29
|
+
mkdirSync(join(nativeRoot, 'vectlite-core'), { recursive: true })
|
|
30
|
+
|
|
31
|
+
const nodeManifest = readFileSync(join(packageRoot, 'Cargo.toml'), 'utf8')
|
|
32
|
+
const coreManifest = readFileSync(join(repoRoot, 'crates', 'vectlite-core', 'Cargo.toml'), 'utf8')
|
|
33
|
+
const nativeBuild = readFileSync(join(packageRoot, 'build.rs'), 'utf8')
|
|
34
|
+
|
|
35
|
+
writeFileSync(
|
|
36
|
+
join(nativeRoot, 'Cargo.toml'),
|
|
37
|
+
concretizeManifest(nodeManifest, packageJson.version, '2024', packageJson.license, './vectlite-core'),
|
|
38
|
+
)
|
|
39
|
+
writeFileSync(
|
|
40
|
+
join(nativeRoot, 'vectlite-core', 'Cargo.toml'),
|
|
41
|
+
concretizeManifest(coreManifest, packageJson.version, '2024', packageJson.license),
|
|
42
|
+
)
|
|
43
|
+
writeFileSync(join(nativeRoot, 'build.rs'), nativeBuild)
|
|
44
|
+
|
|
45
|
+
cpSync(join(packageRoot, 'src'), join(nativeRoot, 'src'), { recursive: true })
|
|
46
|
+
cpSync(join(repoRoot, 'crates', 'vectlite-core', 'src'), join(nativeRoot, 'vectlite-core', 'src'), {
|
|
47
|
+
recursive: true,
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
if (existsSync(join(repoRoot, 'LICENSE'))) {
|
|
51
|
+
cpSync(join(repoRoot, 'LICENSE'), join(packageRoot, 'LICENSE'))
|
|
52
|
+
}
|