potluckdb 0.0.0-reserved.0 → 0.8.0-dev.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.
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ class SqliteError extends Error {
4
+ constructor(message, code) {
5
+ if (typeof code !== 'string') {
6
+ throw new TypeError('Expected second argument to be a string');
7
+ }
8
+
9
+ super('' + message);
10
+ this.code = code;
11
+
12
+ if (typeof Error.captureStackTrace === 'function') {
13
+ Error.captureStackTrace(this, SqliteError);
14
+ }
15
+ }
16
+ }
17
+
18
+ Object.defineProperty(SqliteError.prototype, 'name', {
19
+ value: 'SqliteError',
20
+ writable: true,
21
+ enumerable: false,
22
+ configurable: true,
23
+ });
24
+
25
+ module.exports = SqliteError;
package/lib/targets.js ADDED
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+ const fs = require('fs');
3
+
4
+ // The platforms PotluckDB ships, named like the core archives
5
+ // (potluckdb-sqlite-<version>-<target>). Each one is an npm package,
6
+ // @potluckdb/<target>, that holds potluckdb.node for that platform.
7
+ // `entrypoint` is better-sqlite3's name for the same platform (see lib/linux-x64.js).
8
+ const TARGETS = {
9
+ 'linux-x64-gnu': { os: 'linux', cpu: 'x64', libc: 'glibc', entrypoint: 'linux-x64', runsOn: 'glibc 2.28 or later' },
10
+ 'linux-arm64-gnu': { os: 'linux', cpu: 'arm64', libc: 'glibc', entrypoint: 'linux-arm64', runsOn: 'glibc 2.28 or later' },
11
+ 'linux-x64-musl': { os: 'linux', cpu: 'x64', libc: 'musl', entrypoint: 'linuxmusl-x64', runsOn: 'musl systems such as Alpine' },
12
+ 'linux-arm64-musl': { os: 'linux', cpu: 'arm64', libc: 'musl', entrypoint: 'linuxmusl-arm64', runsOn: 'musl systems such as Alpine' },
13
+ 'macos-arm64': { os: 'darwin', cpu: 'arm64', entrypoint: 'darwin-arm64', runsOn: 'macOS 11 or later' },
14
+ 'macos-x64': { os: 'darwin', cpu: 'x64', entrypoint: 'darwin-x64', runsOn: 'macOS 11 or later' },
15
+ 'windows-x64': { os: 'win32', cpu: 'x64', entrypoint: 'win32-x64', runsOn: 'Windows 10 or later' },
16
+ 'windows-arm64': { os: 'win32', cpu: 'arm64', entrypoint: 'win32-arm64', runsOn: 'Windows 11' },
17
+ };
18
+
19
+ function isMusl() {
20
+ // Node.js reports the glibc version it runs on, and none on musl.
21
+ try {
22
+ const report = process.report.getReport();
23
+ const header = (typeof report === 'string' ? JSON.parse(report) : report).header;
24
+ if (header) return !header.glibcVersionRuntime;
25
+ } catch (_) {
26
+ // A runtime without that report (some Bun and Deno versions).
27
+ }
28
+ try {
29
+ return fs.readFileSync('/usr/bin/ldd', 'latin1').includes('musl');
30
+ } catch (_) {
31
+ return false;
32
+ }
33
+ }
34
+
35
+ // The target for this process, or null if PotluckDB doesn't ship one.
36
+ function currentTarget() {
37
+ const { platform, arch } = process;
38
+ const libc = platform === 'linux' ? (isMusl() ? 'musl' : 'glibc') : undefined;
39
+ for (const [name, t] of Object.entries(TARGETS)) {
40
+ if (t.os === platform && t.cpu === arch && t.libc === libc) return name;
41
+ }
42
+ return null;
43
+ }
44
+
45
+ exports.TARGETS = TARGETS;
46
+ exports.currentTarget = currentTarget;
package/lib/util.js ADDED
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ exports.getBooleanOption = (options, key) => {
4
+ let value = false;
5
+ if (key in options && typeof (value = options[key]) !== 'boolean') {
6
+ throw new TypeError(`Expected the "${key}" option to be a boolean`);
7
+ }
8
+ return value;
9
+ };
10
+
11
+ exports.cppdb = Symbol();
12
+ exports.inspect = Symbol.for('nodejs.util.inspect.custom');
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+ module.exports = require('./database')(() => require('@potluckdb/windows-arm64/potluckdb.node'), false);
3
+ module.exports.SqliteError = require('./sqlite-error');
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+ module.exports = require('./database')(() => require('@potluckdb/windows-x64/potluckdb.node'), false);
3
+ module.exports.SqliteError = require('./sqlite-error');
package/package.json CHANGED
@@ -1,7 +1,90 @@
1
1
  {
2
2
  "name": "potluckdb",
3
- "version": "0.0.0-reserved.0",
4
- "description": "Reserved for PotluckDB. Pre-releases: npm install potluckdb@next",
3
+ "version": "0.8.0-dev.3",
4
+ "description": "PotluckDB for Node.js: a drop-in replacement for better-sqlite3 that runs on PotluckDB's build of SQLite.",
5
+ "keywords": [
6
+ "potluckdb",
7
+ "sqlite",
8
+ "sqlite3",
9
+ "better-sqlite3",
10
+ "database",
11
+ "local-first",
12
+ "sync"
13
+ ],
14
+ "homepage": "https://github.com/potluckdb/potluckdb/tree/main/node#readme",
15
+ "bugs": "https://github.com/potluckdb/potluckdb/issues",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/potluckdb/potluckdb.git",
19
+ "directory": "node"
20
+ },
5
21
  "license": "Apache-2.0",
6
- "repository": { "type": "git", "url": "git+https://github.com/potluckdb/potluckdb.git", "directory": "node" }
22
+ "main": "lib/index.js",
23
+ "types": "index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "import": {
27
+ "types": "./index.d.mts",
28
+ "default": "./index.mjs"
29
+ },
30
+ "default": {
31
+ "types": "./index.d.ts",
32
+ "default": "./lib/index.js"
33
+ }
34
+ },
35
+ "./linux-x64": {
36
+ "types": "./index.d.ts",
37
+ "default": "./lib/linux-x64.js"
38
+ },
39
+ "./linux-arm64": {
40
+ "types": "./index.d.ts",
41
+ "default": "./lib/linux-arm64.js"
42
+ },
43
+ "./linuxmusl-x64": {
44
+ "types": "./index.d.ts",
45
+ "default": "./lib/linuxmusl-x64.js"
46
+ },
47
+ "./linuxmusl-arm64": {
48
+ "types": "./index.d.ts",
49
+ "default": "./lib/linuxmusl-arm64.js"
50
+ },
51
+ "./darwin-x64": {
52
+ "types": "./index.d.ts",
53
+ "default": "./lib/darwin-x64.js"
54
+ },
55
+ "./darwin-arm64": {
56
+ "types": "./index.d.ts",
57
+ "default": "./lib/darwin-arm64.js"
58
+ },
59
+ "./win32-x64": {
60
+ "types": "./index.d.ts",
61
+ "default": "./lib/win32-x64.js"
62
+ },
63
+ "./win32-arm64": {
64
+ "types": "./index.d.ts",
65
+ "default": "./lib/win32-arm64.js"
66
+ },
67
+ "./package.json": "./package.json"
68
+ },
69
+ "files": [
70
+ "lib/",
71
+ "index.d.ts",
72
+ "index.d.mts",
73
+ "index.mjs",
74
+ "THIRD_PARTY_NOTICES.md"
75
+ ],
76
+ "engines": {
77
+ "node": ">=20"
78
+ },
79
+ "gypfile": false,
80
+ "optionalDependencies": {
81
+ "@potluckdb/linux-x64-gnu": "0.8.0-dev.3",
82
+ "@potluckdb/linux-arm64-gnu": "0.8.0-dev.3",
83
+ "@potluckdb/linux-x64-musl": "0.8.0-dev.3",
84
+ "@potluckdb/linux-arm64-musl": "0.8.0-dev.3",
85
+ "@potluckdb/macos-arm64": "0.8.0-dev.3",
86
+ "@potluckdb/macos-x64": "0.8.0-dev.3",
87
+ "@potluckdb/windows-x64": "0.8.0-dev.3",
88
+ "@potluckdb/windows-arm64": "0.8.0-dev.3"
89
+ }
7
90
  }