@photostructure/sqlite-vec 0.0.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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/dist/sqlite3 ADDED
Binary file
package/dist/test-unit ADDED
Binary file
package/dist/vec0.so ADDED
Binary file
package/index.cjs ADDED
@@ -0,0 +1,74 @@
1
+ const { join } = require("node:path");
2
+ const { arch, platform } = require("node:process");
3
+ const { readdirSync, statSync } = require("node:fs");
4
+
5
+ const ENTRYPOINT_BASE_NAME = "vec0";
6
+
7
+ function extensionSuffix(platform) {
8
+ if (platform === "win32") return "dll";
9
+ if (platform === "darwin") return "dylib";
10
+ return "so";
11
+ }
12
+
13
+ /**
14
+ * Detect if running on musl libc (Alpine Linux, etc.)
15
+ * Uses detect-libc's primary heuristic: check for musl dynamic linker
16
+ */
17
+ function isMusl() {
18
+ if (platform !== "linux") return false;
19
+ try {
20
+ const files = readdirSync("/lib");
21
+ return files.some((f) => f.startsWith("ld-musl-"));
22
+ } catch {
23
+ return false;
24
+ }
25
+ }
26
+
27
+ /**
28
+ * When running inside an Electron app packaged with ASAR, native extensions
29
+ * are unpacked to app.asar.unpacked/. Replace the path segment so
30
+ * db.loadExtension() can find the real file on disk.
31
+ * Outside Electron this is a no-op (paths never contain "app.asar").
32
+ */
33
+ function asarUnpack(filePath) {
34
+ return filePath.replace("app.asar", "app.asar.unpacked");
35
+ }
36
+
37
+ function getLoadablePath() {
38
+ // Platform-specific subdirectory (e.g., darwin-arm64, linux-x64, linux-x64-musl)
39
+ const platformDir =
40
+ platform === "linux" && isMusl()
41
+ ? `${platform}-${arch}-musl`
42
+ : `${platform}-${arch}`;
43
+ const loadablePath = join(
44
+ __dirname,
45
+ "dist",
46
+ platformDir,
47
+ `${ENTRYPOINT_BASE_NAME}.${extensionSuffix(platform)}`
48
+ );
49
+
50
+ if (!statSync(loadablePath, { throwIfNoEntry: false })) {
51
+ const supported = [
52
+ "darwin-x64",
53
+ "darwin-arm64",
54
+ "linux-x64",
55
+ "linux-x64-musl",
56
+ "linux-arm64",
57
+ "linux-arm64-musl",
58
+ "win32-x64",
59
+ "win32-arm64",
60
+ ];
61
+ throw new Error(
62
+ `Loadable extension for sqlite-vec not found for ${platformDir} at ${loadablePath}. ` +
63
+ `Supported platforms: ${supported.join(", ")}.`
64
+ );
65
+ }
66
+
67
+ return asarUnpack(loadablePath);
68
+ }
69
+
70
+ function load(db) {
71
+ db.loadExtension(getLoadablePath());
72
+ }
73
+
74
+ module.exports = { getLoadablePath, load };
package/index.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Returns the full path to the sqlite-vec loadable extension bundled with this package
3
+ */
4
+ export declare function getLoadablePath(): string;
5
+
6
+ interface Db {
7
+ loadExtension(file: string, entrypoint?: string | undefined): void;
8
+ }
9
+
10
+ /**
11
+ * Load the sqlite-vec extension into a SQLite database connection
12
+ */
13
+ export declare function load(db: Db): void;
package/index.mjs ADDED
@@ -0,0 +1,75 @@
1
+ import { join } from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import { arch, platform } from "node:process";
4
+ import { readdirSync, statSync } from "node:fs";
5
+
6
+ const ENTRYPOINT_BASE_NAME = "vec0";
7
+
8
+ function extensionSuffix(platform) {
9
+ if (platform === "win32") return "dll";
10
+ if (platform === "darwin") return "dylib";
11
+ return "so";
12
+ }
13
+
14
+ /**
15
+ * Detect if running on musl libc (Alpine Linux, etc.)
16
+ * Uses detect-libc's primary heuristic: check for musl dynamic linker
17
+ */
18
+ function isMusl() {
19
+ if (platform !== "linux") return false;
20
+ try {
21
+ const files = readdirSync("/lib");
22
+ return files.some((f) => f.startsWith("ld-musl-"));
23
+ } catch {
24
+ return false;
25
+ }
26
+ }
27
+
28
+ /**
29
+ * When running inside an Electron app packaged with ASAR, native extensions
30
+ * are unpacked to app.asar.unpacked/. Replace the path segment so
31
+ * db.loadExtension() can find the real file on disk.
32
+ * Outside Electron this is a no-op (paths never contain "app.asar").
33
+ */
34
+ function asarUnpack(filePath) {
35
+ return filePath.replace("app.asar", "app.asar.unpacked");
36
+ }
37
+
38
+ function getLoadablePath() {
39
+ // Platform-specific subdirectory (e.g., darwin-arm64, linux-x64, linux-x64-musl)
40
+ const platformDir =
41
+ platform === "linux" && isMusl()
42
+ ? `${platform}-${arch}-musl`
43
+ : `${platform}-${arch}`;
44
+ const loadablePath = join(
45
+ fileURLToPath(new URL(".", import.meta.url)),
46
+ "dist",
47
+ platformDir,
48
+ `${ENTRYPOINT_BASE_NAME}.${extensionSuffix(platform)}`
49
+ );
50
+
51
+ if (!statSync(loadablePath, { throwIfNoEntry: false })) {
52
+ const supported = [
53
+ "darwin-x64",
54
+ "darwin-arm64",
55
+ "linux-x64",
56
+ "linux-x64-musl",
57
+ "linux-arm64",
58
+ "linux-arm64-musl",
59
+ "win32-x64",
60
+ "win32-arm64",
61
+ ];
62
+ throw new Error(
63
+ `Loadable extension for sqlite-vec not found for ${platformDir} at ${loadablePath}. ` +
64
+ `Supported platforms: ${supported.join(", ")}.`
65
+ );
66
+ }
67
+
68
+ return asarUnpack(loadablePath);
69
+ }
70
+
71
+ function load(db) {
72
+ db.loadExtension(getLoadablePath());
73
+ }
74
+
75
+ export { getLoadablePath, load };
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@photostructure/sqlite-vec",
3
+ "version": "0.0.1",
4
+ "description": "A vector search SQLite extension that runs anywhere - PhotoStructure's production-ready fork",
5
+ "main": "./index.cjs",
6
+ "module": "./index.mjs",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "require": "./index.cjs",
11
+ "import": "./index.mjs",
12
+ "types": "./index.d.ts"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "test": "echo \"Error: no test specified\" && exit 1"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/photostructure/sqlite-vec.git"
21
+ },
22
+ "keywords": [
23
+ "sqlite",
24
+ "vector",
25
+ "search",
26
+ "embedding",
27
+ "similarity"
28
+ ],
29
+ "author": "Alex Garcia <alex@alex.garcia>",
30
+ "contributors": [
31
+ "Vlad Lasky",
32
+ "Matthew McEachen"
33
+ ],
34
+ "license": "(MIT OR Apache-2.0)",
35
+ "bugs": {
36
+ "url": "https://github.com/photostructure/sqlite-vec/issues"
37
+ },
38
+ "homepage": "https://github.com/photostructure/sqlite-vec#readme",
39
+ "engines": {
40
+ "node": ">=14.0.0"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "os": [
46
+ "darwin",
47
+ "linux",
48
+ "win32"
49
+ ],
50
+ "files": [
51
+ "index.cjs",
52
+ "index.mjs",
53
+ "index.d.ts",
54
+ "dist/"
55
+ ]
56
+ }