@sna-sdk/core 0.9.10 → 0.9.12
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/dist/db/schema.js +5 -3
- package/dist/electron/index.cjs +2377 -26
- package/dist/electron/index.d.ts +31 -1
- package/dist/electron/index.js +80 -0
- package/dist/node/index.cjs +338 -18
- package/dist/node/index.d.ts +2 -0
- package/dist/server/standalone.js +5 -3
- package/package.json +1 -1
package/dist/db/schema.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
|
-
|
|
4
|
+
function getDbPath() {
|
|
5
|
+
return process.env.SNA_DB_PATH ?? path.join(process.cwd(), "data/sna.db");
|
|
6
|
+
}
|
|
5
7
|
const NATIVE_DIR = path.join(process.cwd(), ".sna/native");
|
|
6
8
|
let _db = null;
|
|
7
9
|
function loadBetterSqlite3() {
|
|
@@ -24,10 +26,10 @@ function loadBetterSqlite3() {
|
|
|
24
26
|
function getDb() {
|
|
25
27
|
if (!_db) {
|
|
26
28
|
const BetterSqlite3 = loadBetterSqlite3();
|
|
27
|
-
const dir = path.dirname(
|
|
29
|
+
const dir = path.dirname(getDbPath());
|
|
28
30
|
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
29
31
|
const nativeBinding = process.env.SNA_SQLITE_NATIVE_BINDING || void 0;
|
|
30
|
-
_db = nativeBinding ? new BetterSqlite3(
|
|
32
|
+
_db = nativeBinding ? new BetterSqlite3(getDbPath(), { nativeBinding }) : new BetterSqlite3(getDbPath());
|
|
31
33
|
_db.pragma("journal_mode = WAL");
|
|
32
34
|
initSchema(_db);
|
|
33
35
|
}
|