react-native-nitro-sqlite-vec 9.7.0 → 9.8.1

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.
Files changed (2) hide show
  1. package/README.md +60 -0
  2. package/package.json +23 -3
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # react-native-nitro-sqlite-vec
2
+
3
+ Opt-in [sqlite-vec](https://github.com/asg017/sqlite-vec) support for [`react-native-nitro-sqlite`](https://github.com/margelo/react-native-nitro-sqlite). sqlite-vec is statically linked into the core package's SQLite build, so it does not load an extension at runtime.
4
+
5
+ ## Installation
6
+
7
+ Install both this package and `react-native-nitro-sqlite`, then enable the native build flag.
8
+
9
+ ```bash
10
+ npm install react-native-nitro-sqlite react-native-nitro-sqlite-vec
11
+ ```
12
+
13
+ - **iOS:**
14
+ ```bash
15
+ NITRO_SQLITE_VEC=1 npx pod-install
16
+ ```
17
+ - **Android:** add this to `android/gradle.properties` and rebuild:
18
+ ```properties
19
+ nitroSqliteVec=true
20
+ ```
21
+
22
+ `isVecAvailable()` returns `false` when the native flag was not enabled.
23
+
24
+ ## API
25
+
26
+ ```ts
27
+ import { open } from 'react-native-nitro-sqlite'
28
+ import {
29
+ createVectorTable,
30
+ isVecAvailable,
31
+ knnSearch,
32
+ vecVersion,
33
+ } from 'react-native-nitro-sqlite-vec'
34
+
35
+ const db = open({ name: 'vectors.sqlite' })
36
+
37
+ if (!isVecAvailable(db)) {
38
+ throw new Error('Enable sqlite-vec in the native build first')
39
+ }
40
+
41
+ console.log(vecVersion(db))
42
+ createVectorTable(db, 'embeddings', {
43
+ dimensions: 3,
44
+ type: 'float', // 'float' (default), 'int8', or 'bit'
45
+ distanceMetric: 'L2', // 'L2' (default), 'cosine', or 'L1'
46
+ column: 'embedding', // default
47
+ })
48
+
49
+ db.execute('INSERT INTO embeddings (rowid, embedding) VALUES (?, ?)', [
50
+ 1,
51
+ '[0.1, 0.2, 0.3]',
52
+ ])
53
+
54
+ const matches = knnSearch(db, 'embeddings', [0.1, 0.2, 0.25], 10)
55
+ // [{ rowid: 1, distance: 0.05... }]
56
+ ```
57
+
58
+ `knnSearch()` accepts a JSON vector string or a `number[]` and returns rows containing `rowid`, `distance`, and any selected columns. `createVectorTable()` and `knnSearch()` interpolate table and column identifiers into SQL, so only pass trusted identifiers.
59
+
60
+ For the core SQLite API, see the [repository README](../../README.md).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nitro-sqlite-vec",
3
- "version": "9.7.0",
3
+ "version": "9.8.1",
4
4
  "description": "Vector search (sqlite-vec) for react-native-nitro-sqlite. Native sqlite-vec is statically linked into the core's single sqlite3 — no second SQLite, no runtime extension loading.",
5
5
  "source": "./src/index",
6
6
  "react-native": "./src/index",
@@ -8,13 +8,15 @@
8
8
  "types": "./src/index",
9
9
  "files": [
10
10
  "src",
11
+ "!**/__tests__",
11
12
  "cpp",
12
13
  "RNNitroSqliteVec.podspec",
13
14
  "react-native.config.js",
14
15
  "README.md"
15
16
  ],
16
17
  "scripts": {
17
- "typecheck": "tsc --noEmit",
18
+ "test": "jest",
19
+ "typecheck": "tsc --build",
18
20
  "lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
19
21
  "release": "release-it",
20
22
  "prepublishOnly": "bun typecheck"
@@ -42,9 +44,27 @@
42
44
  "react-native-nitro-sqlite": ">=9.0.0"
43
45
  },
44
46
  "devDependencies": {
45
- "react-native-nitro-sqlite": "9.7.0",
47
+ "react-native-nitro-sqlite": "9.8.1",
46
48
  "typescript": "^5.8.3"
47
49
  },
50
+ "jest": {
51
+ "preset": "@react-native/jest-preset",
52
+ "watchman": false,
53
+ "testMatch": [
54
+ "<rootDir>/src/__tests__/**/*.test.ts"
55
+ ],
56
+ "collectCoverageFrom": [
57
+ "src/index.ts"
58
+ ],
59
+ "coverageThreshold": {
60
+ "global": {
61
+ "branches": 100,
62
+ "functions": 100,
63
+ "lines": 100,
64
+ "statements": 100
65
+ }
66
+ }
67
+ },
48
68
  "release-it": {
49
69
  "npm": {
50
70
  "publish": true,