@apisurf/canonui 0.1.2 → 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/dist/bin.js +29 -2
- package/package.json +2 -3
package/dist/bin.js
CHANGED
|
@@ -118,7 +118,34 @@ function shiftHeadings(markdown, by) {
|
|
|
118
118
|
import { dirname, isAbsolute, resolve } from "node:path";
|
|
119
119
|
import { homedir } from "node:os";
|
|
120
120
|
import { existsSync, mkdirSync } from "node:fs";
|
|
121
|
-
|
|
121
|
+
|
|
122
|
+
// ../db/src/driver.ts
|
|
123
|
+
import Database from "libsql";
|
|
124
|
+
function openDatabase(file) {
|
|
125
|
+
const db = new Database(file);
|
|
126
|
+
const prepare2 = db.prepare.bind(db);
|
|
127
|
+
db.prepare = (sql) => {
|
|
128
|
+
const stmt = prepare2(sql);
|
|
129
|
+
const get = stmt.get.bind(stmt);
|
|
130
|
+
const all = stmt.all.bind(stmt);
|
|
131
|
+
const run2 = stmt.run.bind(stmt);
|
|
132
|
+
stmt.get = (...params) => withoutMetadata(get(params));
|
|
133
|
+
stmt.all = (...params) => all(params);
|
|
134
|
+
stmt.run = (...params) => run2(params);
|
|
135
|
+
return stmt;
|
|
136
|
+
};
|
|
137
|
+
db.pragma = (source, options) => {
|
|
138
|
+
const stmt = db.prepare(`PRAGMA ${source}`);
|
|
139
|
+
if (!options?.simple) return stmt.all();
|
|
140
|
+
const row = stmt.get();
|
|
141
|
+
return row && Object.values(row)[0];
|
|
142
|
+
};
|
|
143
|
+
return db;
|
|
144
|
+
}
|
|
145
|
+
function withoutMetadata(row) {
|
|
146
|
+
if (row && typeof row === "object") Reflect.deleteProperty(row, "_metadata");
|
|
147
|
+
return row;
|
|
148
|
+
}
|
|
122
149
|
|
|
123
150
|
// ../db/src/schema.ts
|
|
124
151
|
var MIGRATIONS = [
|
|
@@ -243,7 +270,7 @@ function openDb(options = {}) {
|
|
|
243
270
|
);
|
|
244
271
|
}
|
|
245
272
|
if (!options.mustExist) mkdirSync(dirname(file), { recursive: true });
|
|
246
|
-
const db =
|
|
273
|
+
const db = openDatabase(file);
|
|
247
274
|
db.pragma("journal_mode = WAL");
|
|
248
275
|
db.pragma("synchronous = NORMAL");
|
|
249
276
|
db.pragma("temp_store = MEMORY");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apisurf/canonui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "canonui — build and preview the documents that canon holds: render one into static HTML, or serve it locally.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro",
|
|
@@ -39,13 +39,12 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"astro": "7.2.0",
|
|
42
|
-
"
|
|
42
|
+
"libsql": "0.5.29",
|
|
43
43
|
"marked": "18.0.9",
|
|
44
44
|
"mermaid": "11.16.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@astrojs/check": "0.9.10",
|
|
48
|
-
"@types/better-sqlite3": "7.6.12",
|
|
49
48
|
"@types/node": "22.14.0",
|
|
50
49
|
"tsup": "8.3.5",
|
|
51
50
|
"typescript": "5.6.3",
|