@fedify/sqlite 2.0.0-dev.1604 → 2.0.0-dev.1641

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.
@@ -1,8 +1,8 @@
1
1
 
2
2
 
3
3
 
4
- import { Temporal } from "@js-temporal/polyfill";
5
-
4
+ import { Temporal } from "@js-temporal/polyfill";
5
+
6
6
  import { __commonJS } from "../../../../../../_virtual/rolldown_runtime.js";
7
7
 
8
8
  //#region ../../node_modules/.pnpm/jsbi@4.3.2/node_modules/jsbi/dist/jsbi-cjs.js
@@ -0,0 +1,42 @@
1
+
2
+ const { Temporal } = require("@js-temporal/polyfill");
3
+
4
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
5
+ const bun_sqlite = require_rolldown_runtime.__toESM(require("bun:sqlite"));
6
+
7
+ //#region src/sqlite.bun.ts
8
+ var SqliteDatabase = class {
9
+ constructor(db) {
10
+ this.db = db;
11
+ }
12
+ prepare(sql) {
13
+ return new SqliteStatement(this.db.query(sql));
14
+ }
15
+ exec(sql) {
16
+ this.db.exec(sql);
17
+ }
18
+ close() {
19
+ this.db.close(false);
20
+ }
21
+ };
22
+ var SqliteStatement = class {
23
+ constructor(stmt) {
24
+ this.stmt = stmt;
25
+ }
26
+ run(...params) {
27
+ return this.stmt.run(...params);
28
+ }
29
+ get(...params) {
30
+ const result = this.stmt.get(...params);
31
+ if (result === null) return void 0;
32
+ return result;
33
+ }
34
+ all(...params) {
35
+ return this.stmt.all(...params);
36
+ }
37
+ };
38
+
39
+ //#endregion
40
+ exports.PlatformDatabase = bun_sqlite.Database;
41
+ exports.SqliteDatabase = SqliteDatabase;
42
+ exports.SqliteStatement = SqliteStatement;
@@ -0,0 +1,23 @@
1
+ import { SqliteDatabaseAdapter, SqliteStatementAdapter } from "./adapter.cjs";
2
+ import { Database, Statement } from "bun:sqlite";
3
+
4
+ //#region src/sqlite.bun.d.ts
5
+ declare class SqliteDatabase implements SqliteDatabaseAdapter {
6
+ private readonly db;
7
+ constructor(db: Database);
8
+ prepare(sql: string): SqliteStatementAdapter;
9
+ exec(sql: string): void;
10
+ close(): void;
11
+ }
12
+ declare class SqliteStatement implements SqliteStatementAdapter {
13
+ private readonly stmt;
14
+ constructor(stmt: Statement);
15
+ run(...params: unknown[]): {
16
+ changes: number;
17
+ lastInsertRowid: number;
18
+ };
19
+ get(...params: unknown[]): unknown | undefined;
20
+ all(...params: unknown[]): unknown[];
21
+ }
22
+ //#endregion
23
+ export { Database as PlatformDatabase, Statement as PlatformStatement, SqliteDatabase, SqliteStatement };
@@ -1,6 +1,6 @@
1
1
 
2
- import { Temporal } from "@js-temporal/polyfill";
3
-
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+
4
4
  import { Database } from "bun:sqlite";
5
5
 
6
6
  //#region src/sqlite.bun.ts
@@ -0,0 +1,44 @@
1
+
2
+ const { Temporal } = require("@js-temporal/polyfill");
3
+
4
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
5
+ const node_sqlite = require_rolldown_runtime.__toESM(require("node:sqlite"));
6
+
7
+ //#region src/sqlite.node.ts
8
+ var SqliteDatabase = class {
9
+ constructor(db) {
10
+ this.db = db;
11
+ }
12
+ prepare(sql) {
13
+ return new SqliteStatement(this.db.prepare(sql));
14
+ }
15
+ exec(sql) {
16
+ this.db.exec(sql);
17
+ }
18
+ close() {
19
+ this.db.close();
20
+ }
21
+ };
22
+ var SqliteStatement = class {
23
+ constructor(stmt) {
24
+ this.stmt = stmt;
25
+ }
26
+ run(...params) {
27
+ const result = this.stmt.run(...params);
28
+ return {
29
+ changes: Number(result.changes),
30
+ lastInsertRowid: Number(result.lastInsertRowid)
31
+ };
32
+ }
33
+ get(...params) {
34
+ return this.stmt.get(...params);
35
+ }
36
+ all(...params) {
37
+ return this.stmt.all(...params);
38
+ }
39
+ };
40
+
41
+ //#endregion
42
+ exports.PlatformDatabase = node_sqlite.DatabaseSync;
43
+ exports.SqliteDatabase = SqliteDatabase;
44
+ exports.SqliteStatement = SqliteStatement;
@@ -0,0 +1,23 @@
1
+ import { SqliteDatabaseAdapter, SqliteStatementAdapter } from "./adapter.cjs";
2
+ import { DatabaseSync, StatementSync } from "node:sqlite";
3
+
4
+ //#region src/sqlite.node.d.ts
5
+ declare class SqliteDatabase implements SqliteDatabaseAdapter {
6
+ private readonly db;
7
+ constructor(db: DatabaseSync);
8
+ prepare(sql: string): SqliteStatementAdapter;
9
+ exec(sql: string): void;
10
+ close(): void;
11
+ }
12
+ declare class SqliteStatement implements SqliteStatementAdapter {
13
+ private readonly stmt;
14
+ constructor(stmt: StatementSync);
15
+ run(...params: unknown[]): {
16
+ changes: number;
17
+ lastInsertRowid: number;
18
+ };
19
+ get(...params: unknown[]): unknown | undefined;
20
+ all(...params: unknown[]): unknown[];
21
+ }
22
+ //#endregion
23
+ export { DatabaseSync as PlatformDatabase, StatementSync as PlatformStatement, SqliteDatabase, SqliteStatement };
@@ -1,6 +1,6 @@
1
1
 
2
- import { Temporal } from "@js-temporal/polyfill";
3
-
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+
4
4
  import { DatabaseSync } from "node:sqlite";
5
5
 
6
6
  //#region src/sqlite.node.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/sqlite",
3
- "version": "2.0.0-dev.1604+23a1ea67",
3
+ "version": "2.0.0-dev.1641+6b0c942c",
4
4
  "description": "SQLite drivers for Fedify",
5
5
  "keywords": [
6
6
  "fedify",
@@ -22,18 +22,28 @@
22
22
  "https://github.com/sponsors/dahlia"
23
23
  ],
24
24
  "type": "module",
25
- "main": "./dist/mod.js",
25
+ "main": "./dist/mod.cjs",
26
26
  "module": "./dist/mod.js",
27
27
  "types": "./dist/mod.d.ts",
28
28
  "exports": {
29
29
  ".": {
30
- "types": "./dist/mod.d.ts",
30
+ "types": {
31
+ "import": "./dist/mod.d.ts",
32
+ "require": "./dist/mod.d.cts",
33
+ "default": "./dist/mod.d.ts"
34
+ },
31
35
  "import": "./dist/mod.js",
36
+ "require": "./dist/mod.cjs",
32
37
  "default": "./dist/mod.js"
33
38
  },
34
39
  "./kv": {
35
- "types": "./dist/kv.d.ts",
40
+ "types": {
41
+ "import": "./dist/kv.d.ts",
42
+ "require": "./dist/kv.d.cts",
43
+ "default": "./dist/kv.d.ts"
44
+ },
36
45
  "import": "./dist/kv.js",
46
+ "require": "./dist/kv.cjs",
37
47
  "default": "./dist/kv.js"
38
48
  },
39
49
  "./package.json": "./package.json"
@@ -51,7 +61,7 @@
51
61
  "es-toolkit": "^1.31.0"
52
62
  },
53
63
  "peerDependencies": {
54
- "@fedify/fedify": "^2.0.0-dev.1604+23a1ea67"
64
+ "@fedify/fedify": "^2.0.0-dev.1641+6b0c942c"
55
65
  },
56
66
  "devDependencies": {
57
67
  "@js-temporal/polyfill": "^0.5.1",
package/tsdown.config.ts CHANGED
@@ -4,6 +4,7 @@ export default defineConfig({
4
4
  entry: ["src/mod.ts", "src/kv.ts", "src/sqlite.node.ts", "src/sqlite.bun.ts"],
5
5
  dts: true,
6
6
  unbundle: true,
7
+ format: ["esm", "cjs"],
7
8
  platform: "node",
8
9
  inputOptions: {
9
10
  onwarn(warning, defaultHandler) {
@@ -16,9 +17,16 @@ export default defineConfig({
16
17
  defaultHandler(warning);
17
18
  },
18
19
  },
19
- outputOptions: {
20
- intro: `
21
- import { Temporal } from "@js-temporal/polyfill";
22
- `,
20
+ outputOptions(outputOptions, format) {
21
+ if (format === "cjs") {
22
+ outputOptions.intro = `
23
+ const { Temporal } = require("@js-temporal/polyfill");
24
+ `;
25
+ } else {
26
+ outputOptions.intro = `
27
+ import { Temporal } from "@js-temporal/polyfill";
28
+ `;
29
+ }
30
+ return outputOptions;
23
31
  },
24
32
  });