zen-code 4.6.0 → 4.6.2
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/{app-CM8R0ZR6.mjs → app-Cynj004J.mjs} +2023 -2068
- package/dist/{checkpoint-1sAx_j1E-DrVPlSLR.mjs → checkpoint-1sAx_j1E-DMtqyBT9.mjs} +4 -5
- package/dist/{checkpoint-DxiUsHMy-Cjy5WGNC.mjs → checkpoint-DxiUsHMy-DqfBiLDW.mjs} +1 -1
- package/dist/cli.mjs +17 -17
- package/dist/{index-ChCbbHFS.mjs → index-BW3-KScB.mjs} +1 -1
- package/dist/{pg-adapter-BFtir1GE-BU2H39HC.mjs → pg-adapter-BFtir1GE-BbUXBpaX.mjs} +6 -8
- package/dist/{queue-Cu_nO_wt-ChzSaooi.mjs → queue-Cu_nO_wt-DVTcONlE.mjs} +1 -1
- package/dist/{shallow-tfhh5rlz.mjs → shallow-BQy_8shO.mjs} +1 -1
- package/dist/{sqlite-adapter-BKOLSdoL-BlGKN04G.mjs → sqlite-adapter-BKOLSdoL-5XOA6_0i.mjs} +1 -1
- package/dist/zen-code.mjs +1 -1
- package/package.json +10 -9
- package/dist/assets/worker-I4QjJYba.js +0 -1
- package/dist/chunk-YWE62C55-DID9N9eS.mjs +0 -193
- package/dist/index-BUGHAUbY.mjs +0 -117
- package/dist/index-C5j-48Ft.mjs +0 -75
- package/dist/index-DS5HVciX.mjs +0 -216
- package/dist/kysely-Bchvsze0.mjs +0 -4316
- package/dist/migrator-BatO36Tk.mjs +0 -592
- package/dist/postgres-dialect-DaHvQ_AZ.mjs +0 -211
- package/dist/sql-CJsUpKEQ.mjs +0 -8106
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { B as f, T as l, c as y, m } from "./app-CM8R0ZR6.mjs";
|
|
1
|
+
import { Kysely as T, sql as r } from "kysely";
|
|
2
|
+
import { B as f, T as l, c as y, m } from "./app-Cynj004J.mjs";
|
|
4
3
|
import "./graphBuilder-mpLrx9tk.mjs";
|
|
5
4
|
const g = ["source", "step", "parents"];
|
|
6
5
|
const E = g;
|
|
@@ -16,11 +15,11 @@ class w extends f {
|
|
|
16
15
|
let n;
|
|
17
16
|
if (globalThis.Bun) {
|
|
18
17
|
console.log("LG | Using BunWorkerDialect " + e);
|
|
19
|
-
const { BunWorkerDialect: o } = await import("
|
|
18
|
+
const { BunWorkerDialect: o } = await import("kysely-bun-worker");
|
|
20
19
|
n = new w(new o({ url: e }));
|
|
21
20
|
} else {
|
|
22
21
|
console.log("LG | Using NodeWasmDialect");
|
|
23
|
-
const { default: o } = await import("node-sqlite3-wasm"), { NodeWasmDialect: s } = await import("
|
|
22
|
+
const { default: o } = await import("node-sqlite3-wasm"), { NodeWasmDialect: s } = await import("kysely-wasm");
|
|
24
23
|
console.log(e);
|
|
25
24
|
const a = new s({
|
|
26
25
|
database: new o.Database(e)
|
package/dist/cli.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import c from "node:path";
|
|
3
|
-
import
|
|
3
|
+
import l from "node:os";
|
|
4
4
|
import o from "node:fs";
|
|
5
5
|
import "node-notifier";
|
|
6
6
|
import "./metadata-XVTVXthy.mjs";
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
return o.existsSync(n) || o.mkdirSync(n, { recursive: !0 }),
|
|
7
|
+
function u(e) {
|
|
8
|
+
const s = e.replace(/^~/, l.homedir()), t = c.resolve(s), n = c.dirname(t);
|
|
9
|
+
return o.existsSync(n) || o.mkdirSync(n, { recursive: !0 }), t;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function m(e, s) {
|
|
12
12
|
if (!o.existsSync(e)) {
|
|
13
13
|
process.env.DATABASE_INIT = "true";
|
|
14
14
|
return;
|
|
@@ -19,23 +19,23 @@ function u(e, t) {
|
|
|
19
19
|
console.warn(`⚠️ Database file is large: ${a.toFixed(2)}MB (limit: ${d.toFixed(2)}MB)`), console.warn(` Path: ${e}`), console.warn(" Set SQLITE_MAX_SIZE_MB to adjust limit");
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
return process.env.SQLITE_DATABASE_URI =
|
|
22
|
+
function p(e) {
|
|
23
|
+
const s = u(e);
|
|
24
|
+
return process.env.SQLITE_DATABASE_URI = s, m(s), s;
|
|
25
25
|
}
|
|
26
26
|
const i = process.argv.slice(2);
|
|
27
|
-
async function
|
|
27
|
+
async function f() {
|
|
28
28
|
const e = i.indexOf("--yolo");
|
|
29
|
-
if (e !== -1 && (process.env.YOLO_MODE = "true", i.splice(e, 1)),
|
|
29
|
+
if (e !== -1 && (process.env.YOLO_MODE = "true", i.splice(e, 1)), globalThis.Bun && p("~/.zen-code/data/sessions.db"), i[0] === "init")
|
|
30
30
|
console.log("Please zen-code and use /m to configure models");
|
|
31
31
|
else if (i[0] === "keyboard")
|
|
32
32
|
import("./zen-keyboard.mjs");
|
|
33
33
|
else if (i[0] === "-p" || i[0] === "--prompt") {
|
|
34
|
-
const
|
|
35
|
-
await s
|
|
34
|
+
const s = i.slice(1).join(" "), { runNonInteractive: t } = await import("./nonInteractive.mjs");
|
|
35
|
+
await t(s, !1);
|
|
36
36
|
} else if (await S()) {
|
|
37
|
-
const { runNonInteractive:
|
|
38
|
-
await
|
|
37
|
+
const { runNonInteractive: t } = await import("./nonInteractive.mjs");
|
|
38
|
+
await t(void 0, !0);
|
|
39
39
|
} else
|
|
40
40
|
await import("./zen-code.mjs");
|
|
41
41
|
}
|
|
@@ -45,13 +45,13 @@ async function S() {
|
|
|
45
45
|
e(!1);
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
const
|
|
49
|
-
|
|
48
|
+
const t = process.stdin.read();
|
|
49
|
+
t ? (process.stdin.unshift(t), e(!0)) : setTimeout(() => {
|
|
50
50
|
const n = process.stdin.read();
|
|
51
51
|
n ? (process.stdin.unshift(n), e(!0)) : e(!1);
|
|
52
52
|
}, 100);
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
f().catch((e) => {
|
|
56
56
|
console.error("❌ 执行失败:", e), process.exit(1);
|
|
57
57
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as C, u as v, c as x, T as $, m as I } from "./app-
|
|
1
|
+
import { B as C, u as v, c as x, T as $, m as I } from "./app-Cynj004J.mjs";
|
|
2
2
|
import "./graphBuilder-mpLrx9tk.mjs";
|
|
3
3
|
import { createClient as O, createCluster as N } from "redis";
|
|
4
4
|
const W = [
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { d as s } from "./postgres-dialect-DaHvQ_AZ.mjs";
|
|
4
|
-
class L {
|
|
1
|
+
import { Kysely as r, PostgresDialect as s, sql as e } from "kysely";
|
|
2
|
+
class i {
|
|
5
3
|
constructor(t) {
|
|
6
|
-
this.pool = t, this.db = new
|
|
4
|
+
this.pool = t, this.db = new r({
|
|
7
5
|
dialect: new s({
|
|
8
6
|
pool: t
|
|
9
7
|
})
|
|
@@ -22,8 +20,8 @@ class L {
|
|
|
22
20
|
dbToJson(t) {
|
|
23
21
|
return t;
|
|
24
22
|
}
|
|
25
|
-
buildJsonQuery(t, a, T,
|
|
26
|
-
return e`${e.ref(a)}->>${e.lit(T)} = ${e.lit(JSON.stringify(
|
|
23
|
+
buildJsonQuery(t, a, T, E) {
|
|
24
|
+
return e`${e.ref(a)}->>${e.lit(T)} = ${e.lit(JSON.stringify(E))}`;
|
|
27
25
|
}
|
|
28
26
|
now() {
|
|
29
27
|
return /* @__PURE__ */ new Date();
|
|
@@ -58,5 +56,5 @@ class L {
|
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
export {
|
|
61
|
-
|
|
59
|
+
i as PostgresAdapter
|
|
62
60
|
};
|
package/dist/zen-code.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zen-code",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/cli.mjs",
|
|
6
6
|
"bin": "./dist/cli.mjs",
|
|
@@ -17,12 +17,17 @@
|
|
|
17
17
|
"@langchain/core": "1.1.15",
|
|
18
18
|
"@langchain/google-genai": "^2.1.18",
|
|
19
19
|
"@langchain/langgraph": "^1.1.0",
|
|
20
|
+
"@langchain/mcp-adapters": "^1.1.1",
|
|
20
21
|
"@langchain/openai": "1.1.3",
|
|
21
22
|
"@langgraph-js/pure-graph": "^3.1.2",
|
|
22
23
|
"chalk": "^5.6.2",
|
|
24
|
+
"diff-match-patch": "^1.0.5",
|
|
23
25
|
"execa": "^9.6.1",
|
|
24
26
|
"extract-zip": "^2.0.1",
|
|
25
27
|
"fs-extra": "^11.3.3",
|
|
28
|
+
"kysely": "^0.28.11",
|
|
29
|
+
"kysely-bun-worker": "^1.2.1",
|
|
30
|
+
"kysely-wasm": "^1.2.1",
|
|
26
31
|
"langchain": "1.1.1",
|
|
27
32
|
"lowdb": "^7.0.1",
|
|
28
33
|
"marked": "^16.4.2",
|
|
@@ -41,7 +46,6 @@
|
|
|
41
46
|
},
|
|
42
47
|
"devDependencies": {
|
|
43
48
|
"@inkjs/ui": "^2.0.0",
|
|
44
|
-
"@langchain/mcp-adapters": "^1.1.1",
|
|
45
49
|
"@langgraph-js/sdk": "^4.6.3",
|
|
46
50
|
"@nanostores/react": "^1.0.0",
|
|
47
51
|
"@tanstack/react-query": "^5.90.21",
|
|
@@ -53,23 +57,20 @@
|
|
|
53
57
|
"@types/node-notifier": "^8.0.5",
|
|
54
58
|
"@types/react": "^19.2.8",
|
|
55
59
|
"@vitejs/plugin-react": "^5.1.2",
|
|
56
|
-
"comlink": "^4.4.2",
|
|
57
|
-
"diff-match-patch": "^1.0.5",
|
|
58
60
|
"happy-dom": "^20.3.9",
|
|
59
61
|
"ink": "^6.6.0",
|
|
60
62
|
"ink-markdown": "^1.0.4",
|
|
61
63
|
"ink-spinner": "^5.0.0",
|
|
62
64
|
"ink-syntax-highlight": "^2.0.2",
|
|
63
|
-
"ink-text-input": "^6.0.0",
|
|
64
65
|
"react": "^19.2.3",
|
|
65
66
|
"vite": "^7.3.1",
|
|
66
67
|
"vite-bundle-analyzer": "^1.3.2",
|
|
67
68
|
"vite-plugin-static-copy": "^3.1.4",
|
|
68
69
|
"vitest": "^4.0.18",
|
|
69
|
-
"@codegraph/agent": "1.0.0",
|
|
70
70
|
"@codegraph/union-client": "1.0.0",
|
|
71
|
-
"
|
|
72
|
-
"@codegraph/config": "1.0.0"
|
|
71
|
+
"@codegraph/agent": "1.0.0",
|
|
72
|
+
"@codegraph/config": "1.0.0",
|
|
73
|
+
"ink-pro": "1.1.0"
|
|
73
74
|
},
|
|
74
75
|
"babel": {
|
|
75
76
|
"presets": [
|
|
@@ -77,7 +78,7 @@
|
|
|
77
78
|
]
|
|
78
79
|
},
|
|
79
80
|
"scripts": {
|
|
80
|
-
"dev": "bun run src/
|
|
81
|
+
"dev": "bun run src/cli.ts",
|
|
81
82
|
"build": "vite build",
|
|
82
83
|
"prepublish": "pnpm build",
|
|
83
84
|
"test": "vitest",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(){"use strict";function u(e){return e==null?void 0:BigInt(e)}function f(e,r){const n=r?"query":"prepare",t=(s,a)=>e[n](s,a);return{db:e,query:(s,a,o)=>{const c=t(a,o);if(c.columnNames.length>0)return{rows:c.all()};{const{changes:i,lastInsertRowid:l}=c.run();return{numAffectedRows:u(i),insertId:u(l),rows:[]}}},close:()=>e.close(),iterator:(s,a,o)=>w(t(a),o)}}async function*w(e,r){if(!("iterate"in e))throw new Error("Streaming not supported, please upgrade to Bun@1.1.31 or later");for(const n of e.iterate(...r||[]))yield n}var g={},v="0",b="1",d="2",h="3",E="4";function k(e,r,n){let t;return async([s,a,o,c])=>{const i=[s,null,null];try{switch(s){case v:{t=await e(a);break}case b:{i[1]=await t.query(a,o,c);break}case d:{await t.close();break}case h:{if(!t.iterator)throw new Error("streamQuery() is not supported.");const l=t.iterator(a,o,c);for await(const q of l)r([s,q,null]);i[0]=E;break}default:}}catch(l){i[2]=l}r(i)}}function p(e,r){const n=k(e,t=>globalThis.postMessage(t),r);globalThis.onmessage=({data:t})=>n(t)}var y=(e,r)=>new g(e,r);function m(e,r){p(async({cache:n,fileName:t,opt:s})=>{const a=await e(t,s);return f(a,n)},r)}m(y)})();
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { D as w, b as y, c as b, a as f, C as o } from "./migrator-BatO36Tk.mjs";
|
|
2
|
-
import { F as g, aS as p, ah as v } from "./sql-CJsUpKEQ.mjs";
|
|
3
|
-
const _ = /"/g;
|
|
4
|
-
class T extends w {
|
|
5
|
-
visitOrAction(e) {
|
|
6
|
-
this.append("or "), this.append(e.action);
|
|
7
|
-
}
|
|
8
|
-
getCurrentParameterPlaceholder() {
|
|
9
|
-
return "?";
|
|
10
|
-
}
|
|
11
|
-
getLeftExplainOptionsWrapper() {
|
|
12
|
-
return "";
|
|
13
|
-
}
|
|
14
|
-
getRightExplainOptionsWrapper() {
|
|
15
|
-
return "";
|
|
16
|
-
}
|
|
17
|
-
getLeftIdentifierWrapper() {
|
|
18
|
-
return '"';
|
|
19
|
-
}
|
|
20
|
-
getRightIdentifierWrapper() {
|
|
21
|
-
return '"';
|
|
22
|
-
}
|
|
23
|
-
getAutoIncrement() {
|
|
24
|
-
return "autoincrement";
|
|
25
|
-
}
|
|
26
|
-
sanitizeIdentifier(e) {
|
|
27
|
-
return e.replace(_, '""');
|
|
28
|
-
}
|
|
29
|
-
visitDefaultInsertValue(e) {
|
|
30
|
-
this.append("null");
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
class k {
|
|
34
|
-
#e;
|
|
35
|
-
constructor(e) {
|
|
36
|
-
this.#e = e;
|
|
37
|
-
}
|
|
38
|
-
async getSchemas() {
|
|
39
|
-
return [];
|
|
40
|
-
}
|
|
41
|
-
async getTables(e = { withInternalKyselyTables: !1 }) {
|
|
42
|
-
return await this.#a(e);
|
|
43
|
-
}
|
|
44
|
-
async getMetadata(e) {
|
|
45
|
-
return {
|
|
46
|
-
tables: await this.getTables(e)
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
#t(e, r) {
|
|
50
|
-
let n = e.selectFrom("sqlite_master").where("type", "in", ["table", "view"]).where("name", "not like", "sqlite_%").select(["name", "sql", "type"]).orderBy("name");
|
|
51
|
-
return r.withInternalKyselyTables || (n = n.where("name", "!=", y).where("name", "!=", b)), n;
|
|
52
|
-
}
|
|
53
|
-
async #a(e) {
|
|
54
|
-
const r = await this.#t(this.#e, e).execute(), n = await this.#e.with("table_list", (i) => this.#t(i, e)).selectFrom([
|
|
55
|
-
"table_list as tl",
|
|
56
|
-
g`pragma_table_info(tl.name)`.as("p")
|
|
57
|
-
]).select([
|
|
58
|
-
"tl.name as table",
|
|
59
|
-
"p.cid",
|
|
60
|
-
"p.name",
|
|
61
|
-
"p.type",
|
|
62
|
-
"p.notnull",
|
|
63
|
-
"p.dflt_value",
|
|
64
|
-
"p.pk"
|
|
65
|
-
]).orderBy("tl.name").orderBy("p.cid").execute(), s = {};
|
|
66
|
-
for (const i of n)
|
|
67
|
-
s[i.table] ??= [], s[i.table].push(i);
|
|
68
|
-
return r.map(({ name: i, sql: m, type: h }) => {
|
|
69
|
-
let l = m?.split(/[\(\),]/)?.find((a) => a.toLowerCase().includes("autoincrement"))?.trimStart()?.split(/\s+/)?.[0]?.replace(/["`]/g, "");
|
|
70
|
-
const u = s[i] ?? [];
|
|
71
|
-
if (!l) {
|
|
72
|
-
const a = u.filter((d) => d.pk > 0);
|
|
73
|
-
a.length === 1 && a[0].type.toLowerCase() === "integer" && (l = a[0].name);
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
name: i,
|
|
77
|
-
isView: h === "view",
|
|
78
|
-
columns: u.map((a) => ({
|
|
79
|
-
name: a.name,
|
|
80
|
-
dataType: a.type,
|
|
81
|
-
isNullable: !a.notnull,
|
|
82
|
-
isAutoIncrementing: a.name === l,
|
|
83
|
-
hasDefaultValue: a.dflt_value != null,
|
|
84
|
-
comment: void 0
|
|
85
|
-
}))
|
|
86
|
-
};
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
class C extends f {
|
|
91
|
-
get supportsTransactionalDdl() {
|
|
92
|
-
return !1;
|
|
93
|
-
}
|
|
94
|
-
get supportsReturning() {
|
|
95
|
-
return !0;
|
|
96
|
-
}
|
|
97
|
-
async acquireMigrationLock(e, r) {
|
|
98
|
-
}
|
|
99
|
-
async releaseMigrationLock(e, r) {
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
var A = class {
|
|
103
|
-
/**
|
|
104
|
-
* Base class that implements {@link Dialect}
|
|
105
|
-
* @param create function that create {@link Driver}
|
|
106
|
-
*/
|
|
107
|
-
constructor(t) {
|
|
108
|
-
this.createDriver = t;
|
|
109
|
-
}
|
|
110
|
-
createDriver;
|
|
111
|
-
createQueryCompiler() {
|
|
112
|
-
return new T();
|
|
113
|
-
}
|
|
114
|
-
createAdapter() {
|
|
115
|
-
return new C();
|
|
116
|
-
}
|
|
117
|
-
createIntrospector(t) {
|
|
118
|
-
return new k(t);
|
|
119
|
-
}
|
|
120
|
-
}, S = class {
|
|
121
|
-
promise;
|
|
122
|
-
resolve;
|
|
123
|
-
async lock() {
|
|
124
|
-
for (; this.promise; )
|
|
125
|
-
await this.promise;
|
|
126
|
-
this.promise = new Promise((t) => {
|
|
127
|
-
this.resolve = t;
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
unlock() {
|
|
131
|
-
const t = this.resolve;
|
|
132
|
-
this.promise = void 0, this.resolve = void 0, t?.();
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
async function c(t, e, r, n, s) {
|
|
136
|
-
await r.executeQuery(
|
|
137
|
-
s(
|
|
138
|
-
p.createWithChildren([
|
|
139
|
-
p.createWithSql(`${t} `),
|
|
140
|
-
v.create(n)
|
|
141
|
-
// ensures savepointName gets sanitized
|
|
142
|
-
]),
|
|
143
|
-
e()
|
|
144
|
-
)
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
var D = class {
|
|
148
|
-
mutex = new S();
|
|
149
|
-
conn;
|
|
150
|
-
savepoint;
|
|
151
|
-
releaseSavepoint;
|
|
152
|
-
rollbackToSavepoint;
|
|
153
|
-
init;
|
|
154
|
-
/**
|
|
155
|
-
* Base abstract class that implements {@link Driver}
|
|
156
|
-
*
|
|
157
|
-
* You **MUST** assign `this.conn` in `init` and implement `destroy` method
|
|
158
|
-
*/
|
|
159
|
-
constructor(t) {
|
|
160
|
-
this.init = () => import("./index-DS5HVciX.mjs").then(({ createQueryId: e }) => {
|
|
161
|
-
e && (this.savepoint = c.bind(null, "savepoint", e), this.releaseSavepoint = c.bind(null, "release", e), this.rollbackToSavepoint = c.bind(null, "rollback to", e));
|
|
162
|
-
}).then(t);
|
|
163
|
-
}
|
|
164
|
-
async acquireConnection() {
|
|
165
|
-
return await this.mutex.lock(), this.conn;
|
|
166
|
-
}
|
|
167
|
-
async beginTransaction(t) {
|
|
168
|
-
await t.executeQuery(o.raw("begin"));
|
|
169
|
-
}
|
|
170
|
-
async commitTransaction(t) {
|
|
171
|
-
await t.executeQuery(o.raw("commit"));
|
|
172
|
-
}
|
|
173
|
-
async rollbackTransaction(t) {
|
|
174
|
-
await t.executeQuery(o.raw("rollback"));
|
|
175
|
-
}
|
|
176
|
-
async releaseConnection() {
|
|
177
|
-
this.mutex.unlock();
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
function q(t) {
|
|
181
|
-
return async (e, r, n) => {
|
|
182
|
-
const s = await t.all(r, n);
|
|
183
|
-
return e || s.length ? { rows: s } : { rows: [], ...await t.run("select 1") };
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
export {
|
|
187
|
-
A as B,
|
|
188
|
-
T as S,
|
|
189
|
-
k as a,
|
|
190
|
-
C as b,
|
|
191
|
-
D as c,
|
|
192
|
-
q as d
|
|
193
|
-
};
|
package/dist/index-BUGHAUbY.mjs
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import "bun:sqlite";
|
|
2
|
-
import { B as f, c as k } from "./chunk-YWE62C55-DID9N9eS.mjs";
|
|
3
|
-
import { aY as m } from "./sql-CJsUpKEQ.mjs";
|
|
4
|
-
import { EventEmitter as p } from "node:events";
|
|
5
|
-
var l = "0", h = "1", w = "2", c = "3", u = "4", y = (e, t) => e.onmessage = ({ data: r }) => t(r), E = class extends k {
|
|
6
|
-
worker;
|
|
7
|
-
mitt;
|
|
8
|
-
constructor(e, t) {
|
|
9
|
-
super(async () => {
|
|
10
|
-
const r = await e();
|
|
11
|
-
this.mitt = r.mitt, this.worker = r.worker, r.handle(
|
|
12
|
-
this.worker,
|
|
13
|
-
([s, ...i]) => this.mitt.emit(s, ...i)
|
|
14
|
-
), this.worker.postMessage([
|
|
15
|
-
l,
|
|
16
|
-
r.data || {}
|
|
17
|
-
]), await new Promise((s, i) => {
|
|
18
|
-
this.mitt.once(l, (a, o) => o ? i(o) : s());
|
|
19
|
-
}), this.conn = new W(this.worker, this.mitt), await t?.(this.conn);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
async destroy() {
|
|
23
|
-
if (this.worker)
|
|
24
|
-
return this.worker.postMessage([w]), new Promise(
|
|
25
|
-
(e, t) => this.mitt?.once(
|
|
26
|
-
w,
|
|
27
|
-
(r, s) => s ? t(s) : e()
|
|
28
|
-
)
|
|
29
|
-
).finally(() => {
|
|
30
|
-
this.worker?.terminate(), this.mitt?.off(), this.mitt = this.worker = void 0;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}, W = class {
|
|
34
|
-
constructor(e, t) {
|
|
35
|
-
this.worker = e, this.mitt = t;
|
|
36
|
-
}
|
|
37
|
-
async *streamQuery({ parameters: e, sql: t, query: r }) {
|
|
38
|
-
this.worker.postMessage([
|
|
39
|
-
c,
|
|
40
|
-
m.is(r),
|
|
41
|
-
t,
|
|
42
|
-
e
|
|
43
|
-
]);
|
|
44
|
-
let s = !1, i, a;
|
|
45
|
-
for (this.mitt.on(c, (o, n) => {
|
|
46
|
-
n ? a(n) : i([{ rows: [o] }, !1]);
|
|
47
|
-
}), this.mitt.on(u, (o, n) => {
|
|
48
|
-
n ? a(n) : i([void 0, !0]);
|
|
49
|
-
}); !s; ) {
|
|
50
|
-
const [o, n] = await new Promise((v, d) => {
|
|
51
|
-
i = v, a = d;
|
|
52
|
-
});
|
|
53
|
-
n ? (s = !0, this.mitt?.off(c), this.mitt?.off(u)) : yield o;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
async executeQuery(e) {
|
|
57
|
-
const { parameters: t, sql: r, query: s } = e;
|
|
58
|
-
return this.worker.postMessage([
|
|
59
|
-
h,
|
|
60
|
-
m.is(s),
|
|
61
|
-
r,
|
|
62
|
-
t
|
|
63
|
-
]), await new Promise((i, a) => {
|
|
64
|
-
this.mitt || a(new Error("kysely instance has been destroyed")), this.mitt.once(h, (o, n) => !n && o ? i(o) : a(n));
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}, q = class extends f {
|
|
68
|
-
/**
|
|
69
|
-
* Dialect for generic SQLite that run SQLs in worker thread
|
|
70
|
-
*
|
|
71
|
-
* @param executor function to create {@link IGenericSqliteWorkerExecutor}
|
|
72
|
-
* @param onCreateConnection optional callback after connection created
|
|
73
|
-
*/
|
|
74
|
-
constructor(e, t) {
|
|
75
|
-
super(() => new E(e, t));
|
|
76
|
-
}
|
|
77
|
-
}, x = class extends p {
|
|
78
|
-
off(e) {
|
|
79
|
-
return this.removeAllListeners(e);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
function S() {
|
|
83
|
-
return new x();
|
|
84
|
-
}
|
|
85
|
-
var B = class extends q {
|
|
86
|
-
/**
|
|
87
|
-
* dialect for `bun:sqlite`, run sql in worker
|
|
88
|
-
*/
|
|
89
|
-
constructor(e) {
|
|
90
|
-
const {
|
|
91
|
-
url: t = ":memory:",
|
|
92
|
-
cacheStatment: r = !1,
|
|
93
|
-
onCreateConnection: s,
|
|
94
|
-
worker: i = new Worker(
|
|
95
|
-
new URL(
|
|
96
|
-
/* @vite-ignore */
|
|
97
|
-
"/assets/worker-I4QjJYba.js",
|
|
98
|
-
import.meta.url
|
|
99
|
-
),
|
|
100
|
-
{ type: "module" }
|
|
101
|
-
),
|
|
102
|
-
dbOptions: a = { create: !0 }
|
|
103
|
-
} = e || {};
|
|
104
|
-
super(
|
|
105
|
-
() => ({
|
|
106
|
-
data: { cache: r, fileName: t, opt: a },
|
|
107
|
-
mitt: S(),
|
|
108
|
-
handle: y,
|
|
109
|
-
worker: i
|
|
110
|
-
}),
|
|
111
|
-
s
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
export {
|
|
116
|
-
B as BunWorkerDialect
|
|
117
|
-
};
|
package/dist/index-C5j-48Ft.mjs
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { B as i, c as o, d as c } from "./chunk-YWE62C55-DID9N9eS.mjs";
|
|
2
|
-
import { aY as a } from "./sql-CJsUpKEQ.mjs";
|
|
3
|
-
var u = class extends o {
|
|
4
|
-
db;
|
|
5
|
-
constructor(t, e) {
|
|
6
|
-
super(async () => {
|
|
7
|
-
this.db = await t(), this.conn = new l(this.db), await e?.(this.conn);
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
async destroy() {
|
|
11
|
-
await this.db?.close();
|
|
12
|
-
}
|
|
13
|
-
}, l = class {
|
|
14
|
-
constructor(t) {
|
|
15
|
-
this.db = t;
|
|
16
|
-
}
|
|
17
|
-
async *streamQuery({ parameters: t, query: e, sql: r }) {
|
|
18
|
-
if (!this.db.iterator)
|
|
19
|
-
throw new Error("streamQuery() is not supported.");
|
|
20
|
-
const s = this.db.iterator(a.is(e), r, t);
|
|
21
|
-
for await (const n of s)
|
|
22
|
-
yield { rows: [n] };
|
|
23
|
-
}
|
|
24
|
-
async executeQuery({ parameters: t, query: e, sql: r }) {
|
|
25
|
-
return await this.db.query(a.is(e), r, t);
|
|
26
|
-
}
|
|
27
|
-
}, d = class extends i {
|
|
28
|
-
/**
|
|
29
|
-
* Dialect for generic SQLite that run SQLs in current thread
|
|
30
|
-
*
|
|
31
|
-
* @param executor function to create {@link IGenericSqlite}
|
|
32
|
-
* @param onCreateConnection optional callback after connection created
|
|
33
|
-
*/
|
|
34
|
-
constructor(t, e) {
|
|
35
|
-
super(() => new u(t, e));
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
async function y(t) {
|
|
39
|
-
return typeof t == "function" ? await t() : t;
|
|
40
|
-
}
|
|
41
|
-
var h = class extends d {
|
|
42
|
-
/**
|
|
43
|
-
* dialect for [node sqlite3 wasm](https://github.com/tndrle/node-sqlite3-wasm)
|
|
44
|
-
*/
|
|
45
|
-
constructor(t) {
|
|
46
|
-
super(
|
|
47
|
-
async () => {
|
|
48
|
-
const e = await y(t.database);
|
|
49
|
-
return {
|
|
50
|
-
db: e,
|
|
51
|
-
close: () => e.close(),
|
|
52
|
-
query: c({
|
|
53
|
-
all: (r, s) => e.all(r, s),
|
|
54
|
-
run: (r) => {
|
|
55
|
-
const { changes: s, lastInsertRowid: n } = e.run(r);
|
|
56
|
-
return {
|
|
57
|
-
insertId: BigInt(n),
|
|
58
|
-
numAffectedRows: BigInt(s)
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}),
|
|
62
|
-
iterator: (r, s, n) => {
|
|
63
|
-
if (!r)
|
|
64
|
-
throw new Error("Only support select query");
|
|
65
|
-
return e.prepare(s).iterate(n);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
},
|
|
69
|
-
t.onCreateConnection
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
export {
|
|
74
|
-
h as NodeWasmDialect
|
|
75
|
-
};
|