@delta-comic/db 0.0.2 → 0.0.4
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/esm-CzppQRXP.js +2 -0
- package/dist/esm-Di_XcAT-.js +13226 -0
- package/dist/{esm-CT_qsGIx.js.map → esm-Di_XcAT-.js.map} +1 -1
- package/dist/index.js +543 -415
- package/dist/index.js.map +1 -1
- package/dist/lib/index.d.ts +1 -2
- package/dist/lib/nativeStore/index.d.ts +2 -0
- package/dist/lib/nativeStore/migrations/1_initial.d.ts +8 -0
- package/dist/pack.tgz +0 -0
- package/package.json +10 -7
- package/dist/esm-CT_qsGIx.js +0 -7812
- package/dist/esm-EM3zjw1B.js +0 -2
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Pn as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
var
|
|
1
|
+
import { Pn as e, Wr as t, c as n, lr as r, n as i, r as a, s as o, sn as s, t as c, u as l, y as u } from "./esm-Di_XcAT-.js";
|
|
2
|
+
import { useGlobalVar as d } from "@delta-comic/utils";
|
|
3
|
+
import { computed as f, ref as p, shallowRef as m, toRef as h, toValue as g, triggerRef as _, unref as v, watch as y } from "vue";
|
|
4
|
+
import { SourcedValue as b, Struct as x, uni as S } from "@delta-comic/model";
|
|
5
|
+
var C = Object.defineProperty, w = (e, t) => {
|
|
6
6
|
let n = {};
|
|
7
|
-
for (var r in e)
|
|
7
|
+
for (var r in e) C(n, r, {
|
|
8
8
|
get: e[r],
|
|
9
9
|
enumerable: !0
|
|
10
10
|
});
|
|
11
|
-
return t ||
|
|
11
|
+
return t || C(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
12
12
|
};
|
|
13
|
-
async function
|
|
13
|
+
async function T(e) {
|
|
14
14
|
await e.schema.createTable("itemStore").addColumn("key", "text", (e) => e.primaryKey().notNull()).addColumn("item", "text", (e) => e.notNull()).execute(), await e.schema.createIndex("item_store_key").on("itemStore").column("key").execute(), await e.schema.createTable("history").addColumn("ep", "text", (e) => e.notNull()).addColumn("timestamp", "datetime", (e) => e.notNull().primaryKey()).addColumn("itemKey", "text", (e) => e.notNull().unique()).addForeignKeyConstraint("itemKeyForeign", ["itemKey"], "itemStore", ["key"], (e) => e.onDelete("cascade")).execute(), await e.schema.createIndex("history_timestamp").on("history").column("timestamp desc").execute(), await e.schema.createTable("recentView").addColumn("timestamp", "datetime", (e) => e.notNull().primaryKey()).addColumn("itemKey", "text", (e) => e.notNull().unique()).addForeignKeyConstraint("itemKeyForeign", ["itemKey"], "itemStore", ["key"], (e) => e.onDelete("cascade")).addColumn("isViewed", "boolean", (e) => e.notNull()).execute(), await e.schema.createIndex("recent_timestamp").on("recentView").column("timestamp desc").execute(), await e.schema.createTable("favouriteCard").addColumn("createAt", "datetime", (e) => e.notNull().primaryKey()).addColumn("title", "text", (e) => e.notNull()).addColumn("private", "boolean", (e) => e.notNull()).addColumn("description", "text", (e) => e.notNull()).execute(), await e.insertInto("favouriteCard").values({
|
|
15
15
|
createAt: 0,
|
|
16
16
|
title: "默认收藏夹",
|
|
@@ -22,24 +22,24 @@ async function up$2(e) {
|
|
|
22
22
|
"itemKey"
|
|
23
23
|
]).addUniqueConstraint("uniqueKey", ["belongTo", "itemKey"]).addForeignKeyConstraint("itemKeyForeign", ["itemKey"], "itemStore", ["createAt"], (e) => e.onDelete("cascade")).addForeignKeyConstraint("belongToForeign", ["belongTo"], "favouriteCard", ["key"], (e) => e.onDelete("cascade")).execute(), await e.schema.createIndex("favourite_item_belongTo_addTime").on("favouriteItem").column("addTime desc").column("belongTo").execute(), await e.schema.createTable("subscribe").addColumn("itemKey", "text").addForeignKeyConstraint("itemKeyForeign", ["itemKey"], "itemStore", ["key"], (e) => e.onDelete("cascade")).addColumn("author", "text").addColumn("type", "text", (e) => e.notNull()).addColumn("key", "text", (e) => e.notNull()).addColumn("plugin", "text", (e) => e.notNull()).addPrimaryKeyConstraint("primary_key", ["plugin", "key"]).execute(), await e.schema.createIndex("subscribe_key_plugin").on("subscribe").column("key").column("plugin").execute(), await e.schema.createTable("plugin").addColumn("installerName", "text", (e) => e.notNull()).addColumn("loaderName", "text", (e) => e.notNull()).addColumn("pluginName", "text", (e) => e.notNull().primaryKey()).addColumn("meta", "json", (e) => e.notNull()).addColumn("enable", "text", (e) => e.notNull()).addColumn("installInput", "text", (e) => e.notNull()).execute(), await e.schema.createIndex("plugin_enable").on("plugin").column("enable").execute(), await e.schema.createIndex("plugin_pluginName").on("plugin").column("pluginName").execute();
|
|
24
24
|
}
|
|
25
|
-
async function
|
|
25
|
+
async function ee(e) {
|
|
26
26
|
await e.schema.dropTable("itemStore").ifExists().execute(), await e.schema.dropTable("history").ifExists().execute(), await e.schema.dropTable("recentView").ifExists().execute(), await e.schema.dropTable("favouriteCard").ifExists().execute(), await e.schema.dropTable("favouriteItem").ifExists().execute(), await e.schema.dropTable("subscribe").ifExists().execute(), await e.schema.dropTable("plugin").ifExists().execute();
|
|
27
27
|
}
|
|
28
|
-
var
|
|
29
|
-
up:
|
|
30
|
-
down:
|
|
28
|
+
var te = {
|
|
29
|
+
up: T,
|
|
30
|
+
down: ee
|
|
31
31
|
};
|
|
32
|
-
async function
|
|
32
|
+
async function ne(e) {
|
|
33
33
|
await e.schema.alterTable("plugin").addColumn("displayName", "text").execute();
|
|
34
34
|
}
|
|
35
|
-
async function
|
|
35
|
+
async function re(e) {
|
|
36
36
|
await e.schema.alterTable("plugin").dropColumn("displayName").execute();
|
|
37
37
|
}
|
|
38
|
-
var
|
|
39
|
-
up:
|
|
40
|
-
down:
|
|
38
|
+
var ie = {
|
|
39
|
+
up: ne,
|
|
40
|
+
down: re
|
|
41
41
|
};
|
|
42
|
-
async function
|
|
42
|
+
async function ae(e) {
|
|
43
43
|
await e.schema.alterTable("favouriteItem").renameTo("favouriteItem_old").execute(), await e.schema.createTable("favouriteItem").addColumn("addTime", "datetime", (e) => e.notNull()).addColumn("belongTo", "integer", (e) => e.notNull()).addColumn("itemKey", "text", (e) => e.notNull()).addPrimaryKeyConstraint("primary_key", [
|
|
44
44
|
"addTime",
|
|
45
45
|
"belongTo",
|
|
@@ -54,7 +54,7 @@ async function up(e) {
|
|
|
54
54
|
"itemKey"
|
|
55
55
|
])).execute(), await e.schema.dropTable("favouriteItem_old").execute(), await e.schema.createIndex("favourite_item_belongTo_addTime").on("favouriteItem").column("addTime desc").column("belongTo").execute();
|
|
56
56
|
}
|
|
57
|
-
async function
|
|
57
|
+
async function oe(e) {
|
|
58
58
|
await e.schema.alterTable("favouriteItem").renameTo("favouriteItem_new").execute(), await e.schema.createTable("favouriteItem").addColumn("addTime", "datetime", (e) => e.notNull()).addColumn("belongTo", "integer", (e) => e.notNull()).addColumn("itemKey", "text", (e) => e.notNull()).addPrimaryKeyConstraint("primary_key", [
|
|
59
59
|
"addTime",
|
|
60
60
|
"belongTo",
|
|
@@ -69,52 +69,109 @@ async function down(e) {
|
|
|
69
69
|
"itemKey"
|
|
70
70
|
])).execute(), await e.schema.dropTable("favouriteItem_new").execute(), await e.schema.createIndex("favourite_item_belongTo_addTime").on("favouriteItem").column("addTime desc").column("belongTo").execute();
|
|
71
71
|
}
|
|
72
|
-
var
|
|
73
|
-
up,
|
|
74
|
-
down
|
|
72
|
+
var se = {
|
|
73
|
+
up: ae,
|
|
74
|
+
down: oe
|
|
75
75
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
async function
|
|
76
|
+
/**
|
|
77
|
+
* Sends a message to the backend.
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* import { invoke } from '@tauri-apps/api/core';
|
|
81
|
+
* await invoke('login', { user: 'tauri', password: 'poiwe3h4r5ip3yrhtew9ty' });
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @param cmd The command name.
|
|
85
|
+
* @param args The optional arguments to pass to the command.
|
|
86
|
+
* @param options The request options.
|
|
87
|
+
* @return A promise resolving or rejecting to the backend response.
|
|
88
|
+
*
|
|
89
|
+
* @since 1.0.0
|
|
90
|
+
*/
|
|
91
|
+
async function E(e, t = {}, n) {
|
|
92
92
|
return window.__TAURI_INTERNALS__.invoke(e, t, n);
|
|
93
93
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
async close() {
|
|
102
|
-
return invoke("plugin:resources|close", { rid: this.rid });
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
_Resource_rid = /* @__PURE__ */ new WeakMap();
|
|
106
|
-
var Database = class e {
|
|
94
|
+
/**
|
|
95
|
+
* **Database**
|
|
96
|
+
*
|
|
97
|
+
* The `Database` class serves as the primary interface for
|
|
98
|
+
* communicating with the rust side of the sql plugin.
|
|
99
|
+
*/
|
|
100
|
+
var D = class e {
|
|
107
101
|
constructor(e) {
|
|
108
102
|
this.path = e;
|
|
109
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* **load**
|
|
106
|
+
*
|
|
107
|
+
* A static initializer which connects to the underlying database and
|
|
108
|
+
* returns a `Database` instance once a connection to the database is established.
|
|
109
|
+
*
|
|
110
|
+
* # Sqlite
|
|
111
|
+
*
|
|
112
|
+
* The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* const db = await Database.load("sqlite:test.db");
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
110
119
|
static async load(t) {
|
|
111
|
-
return new e(await
|
|
112
|
-
}
|
|
120
|
+
return new e(await E("plugin:sql|load", { db: t }));
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* **get**
|
|
124
|
+
*
|
|
125
|
+
* A static initializer which synchronously returns an instance of
|
|
126
|
+
* the Database class while deferring the actual database connection
|
|
127
|
+
* until the first invocation or selection on the database.
|
|
128
|
+
*
|
|
129
|
+
* # Sqlite
|
|
130
|
+
*
|
|
131
|
+
* The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* const db = Database.get("sqlite:test.db");
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
113
138
|
static get(t) {
|
|
114
139
|
return new e(t);
|
|
115
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* **execute**
|
|
143
|
+
*
|
|
144
|
+
* Passes a SQL expression to the database for execution.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* // for sqlite & postgres
|
|
149
|
+
* // INSERT example
|
|
150
|
+
* const result = await db.execute(
|
|
151
|
+
* "INSERT into todos (id, title, status) VALUES ($1, $2, $3)",
|
|
152
|
+
* [ todos.id, todos.title, todos.status ]
|
|
153
|
+
* );
|
|
154
|
+
* // UPDATE example
|
|
155
|
+
* const result = await db.execute(
|
|
156
|
+
* "UPDATE todos SET title = $1, completed = $2 WHERE id = $3",
|
|
157
|
+
* [ todos.title, todos.status, todos.id ]
|
|
158
|
+
* );
|
|
159
|
+
*
|
|
160
|
+
* // for mysql
|
|
161
|
+
* // INSERT example
|
|
162
|
+
* const result = await db.execute(
|
|
163
|
+
* "INSERT into todos (id, title, status) VALUES (?, ?, ?)",
|
|
164
|
+
* [ todos.id, todos.title, todos.status ]
|
|
165
|
+
* );
|
|
166
|
+
* // UPDATE example
|
|
167
|
+
* const result = await db.execute(
|
|
168
|
+
* "UPDATE todos SET title = ?, completed = ? WHERE id = ?",
|
|
169
|
+
* [ todos.title, todos.status, todos.id ]
|
|
170
|
+
* );
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
116
173
|
async execute(e, t) {
|
|
117
|
-
let [n, r] = await
|
|
174
|
+
let [n, r] = await E("plugin:sql|execute", {
|
|
118
175
|
db: this.path,
|
|
119
176
|
query: e,
|
|
120
177
|
values: t ?? []
|
|
@@ -124,254 +181,47 @@ var Database = class e {
|
|
|
124
181
|
rowsAffected: n
|
|
125
182
|
};
|
|
126
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* **select**
|
|
186
|
+
*
|
|
187
|
+
* Passes in a SELECT query to the database for execution.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```ts
|
|
191
|
+
* // for sqlite & postgres
|
|
192
|
+
* const result = await db.select(
|
|
193
|
+
* "SELECT * from todos WHERE id = $1", [ id ]
|
|
194
|
+
* );
|
|
195
|
+
*
|
|
196
|
+
* // for mysql
|
|
197
|
+
* const result = await db.select(
|
|
198
|
+
* "SELECT * from todos WHERE id = ?", [ id ]
|
|
199
|
+
* );
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
127
202
|
async select(e, t) {
|
|
128
|
-
return await
|
|
203
|
+
return await E("plugin:sql|select", {
|
|
129
204
|
db: this.path,
|
|
130
205
|
query: e,
|
|
131
206
|
values: t ?? []
|
|
132
207
|
});
|
|
133
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* **close**
|
|
211
|
+
*
|
|
212
|
+
* Closes the database connection pool.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```ts
|
|
216
|
+
* const success = await db.close()
|
|
217
|
+
* ```
|
|
218
|
+
* @param db - Optionally state the name of a database if you are managing more than one. Otherwise, all database pools will be in scope.
|
|
219
|
+
*/
|
|
134
220
|
async close(e) {
|
|
135
|
-
return await
|
|
136
|
-
}
|
|
137
|
-
}, TauriEvent;
|
|
138
|
-
(function(e) {
|
|
139
|
-
e.WINDOW_RESIZED = "tauri://resize", e.WINDOW_MOVED = "tauri://move", e.WINDOW_CLOSE_REQUESTED = "tauri://close-requested", e.WINDOW_DESTROYED = "tauri://destroyed", e.WINDOW_FOCUS = "tauri://focus", e.WINDOW_BLUR = "tauri://blur", e.WINDOW_SCALE_FACTOR_CHANGED = "tauri://scale-change", e.WINDOW_THEME_CHANGED = "tauri://theme-changed", e.WINDOW_CREATED = "tauri://window-created", e.WEBVIEW_CREATED = "tauri://webview-created", e.DRAG_ENTER = "tauri://drag-enter", e.DRAG_OVER = "tauri://drag-over", e.DRAG_DROP = "tauri://drag-drop", e.DRAG_LEAVE = "tauri://drag-leave";
|
|
140
|
-
})(TauriEvent ||= {});
|
|
141
|
-
async function _unlisten(e, t) {
|
|
142
|
-
window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(e, t), await invoke("plugin:event|unlisten", {
|
|
143
|
-
event: e,
|
|
144
|
-
eventId: t
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
async function listen(e, t, n) {
|
|
148
|
-
return invoke("plugin:event|listen", {
|
|
149
|
-
event: e,
|
|
150
|
-
target: typeof n?.target == "string" ? {
|
|
151
|
-
kind: "AnyLabel",
|
|
152
|
-
label: n.target
|
|
153
|
-
} : n?.target ?? { kind: "Any" },
|
|
154
|
-
handler: transformCallback(t)
|
|
155
|
-
}).then((t) => async () => _unlisten(e, t));
|
|
156
|
-
}
|
|
157
|
-
var Store = class e extends Resource {
|
|
158
|
-
constructor(e) {
|
|
159
|
-
super(e);
|
|
160
|
-
}
|
|
161
|
-
static async load(t, n) {
|
|
162
|
-
return new e(await invoke("plugin:store|load", {
|
|
163
|
-
path: t,
|
|
164
|
-
options: n
|
|
165
|
-
}));
|
|
166
|
-
}
|
|
167
|
-
static async get(t) {
|
|
168
|
-
return await invoke("plugin:store|get_store", { path: t }).then((t) => t ? new e(t) : null);
|
|
169
|
-
}
|
|
170
|
-
async set(e, t) {
|
|
171
|
-
await invoke("plugin:store|set", {
|
|
172
|
-
rid: this.rid,
|
|
173
|
-
key: e,
|
|
174
|
-
value: t
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
async get(e) {
|
|
178
|
-
let [t, n] = await invoke("plugin:store|get", {
|
|
179
|
-
rid: this.rid,
|
|
180
|
-
key: e
|
|
181
|
-
});
|
|
182
|
-
return n ? t : void 0;
|
|
183
|
-
}
|
|
184
|
-
async has(e) {
|
|
185
|
-
return await invoke("plugin:store|has", {
|
|
186
|
-
rid: this.rid,
|
|
187
|
-
key: e
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
async delete(e) {
|
|
191
|
-
return await invoke("plugin:store|delete", {
|
|
192
|
-
rid: this.rid,
|
|
193
|
-
key: e
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
async clear() {
|
|
197
|
-
await invoke("plugin:store|clear", { rid: this.rid });
|
|
198
|
-
}
|
|
199
|
-
async reset() {
|
|
200
|
-
await invoke("plugin:store|reset", { rid: this.rid });
|
|
201
|
-
}
|
|
202
|
-
async keys() {
|
|
203
|
-
return await invoke("plugin:store|keys", { rid: this.rid });
|
|
204
|
-
}
|
|
205
|
-
async values() {
|
|
206
|
-
return await invoke("plugin:store|values", { rid: this.rid });
|
|
207
|
-
}
|
|
208
|
-
async entries() {
|
|
209
|
-
return await invoke("plugin:store|entries", { rid: this.rid });
|
|
210
|
-
}
|
|
211
|
-
async length() {
|
|
212
|
-
return await invoke("plugin:store|length", { rid: this.rid });
|
|
213
|
-
}
|
|
214
|
-
async reload(e) {
|
|
215
|
-
await invoke("plugin:store|reload", {
|
|
216
|
-
rid: this.rid,
|
|
217
|
-
...e
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
async save() {
|
|
221
|
-
await invoke("plugin:store|save", { rid: this.rid });
|
|
222
|
-
}
|
|
223
|
-
async onKeyChange(e, t) {
|
|
224
|
-
return await listen("store://change", (n) => {
|
|
225
|
-
n.payload.resourceId === this.rid && n.payload.key === e && t(n.payload.exists ? n.payload.value : void 0);
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
async onChange(e) {
|
|
229
|
-
return await listen("store://change", (t) => {
|
|
230
|
-
t.payload.resourceId === this.rid && e(t.payload.key, t.payload.exists ? t.payload.value : void 0);
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
}, isClient = typeof window < "u" && typeof document < "u";
|
|
234
|
-
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
235
|
-
var toString = Object.prototype.toString, isObject = (e) => toString.call(e) === "[object Object]";
|
|
236
|
-
function createFilterWrapper(e, t) {
|
|
237
|
-
function n(...n) {
|
|
238
|
-
return new Promise((r, i) => {
|
|
239
|
-
Promise.resolve(e(() => t.apply(this, n), {
|
|
240
|
-
fn: t,
|
|
241
|
-
thisArg: this,
|
|
242
|
-
args: n
|
|
243
|
-
})).then(r).catch(i);
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
return n;
|
|
247
|
-
}
|
|
248
|
-
var bypassFilter = (e) => e();
|
|
249
|
-
function toArray(e) {
|
|
250
|
-
return Array.isArray(e) ? e : [e];
|
|
251
|
-
}
|
|
252
|
-
function watchWithFilter(e, t, n = {}) {
|
|
253
|
-
let { eventFilter: r = bypassFilter, ...i } = n;
|
|
254
|
-
return watch(e, createFilterWrapper(r, t), i);
|
|
255
|
-
}
|
|
256
|
-
function watchImmediate(e, t, n) {
|
|
257
|
-
return watch(e, t, {
|
|
258
|
-
...n,
|
|
259
|
-
immediate: !0
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
var defaultWindow = isClient ? window : void 0;
|
|
263
|
-
isClient && window.document, isClient && window.navigator, isClient && window.location;
|
|
264
|
-
function unrefElement(e) {
|
|
265
|
-
let t = toValue(e);
|
|
266
|
-
return t?.$el ?? t;
|
|
267
|
-
}
|
|
268
|
-
function useEventListener(...e) {
|
|
269
|
-
let t = (e, t, n, r) => (e.addEventListener(t, n, r), () => e.removeEventListener(t, n, r)), n = computed(() => {
|
|
270
|
-
let t = toArray(toValue(e[0])).filter((e) => e != null);
|
|
271
|
-
return t.every((e) => typeof e != "string") ? t : void 0;
|
|
272
|
-
});
|
|
273
|
-
return watchImmediate(() => [
|
|
274
|
-
n.value?.map((e) => unrefElement(e)) ?? [defaultWindow].filter((e) => e != null),
|
|
275
|
-
toArray(toValue(n.value ? e[1] : e[0])),
|
|
276
|
-
toArray(unref(n.value ? e[2] : e[1])),
|
|
277
|
-
toValue(n.value ? e[3] : e[2])
|
|
278
|
-
], ([e, n, r, i], a, o) => {
|
|
279
|
-
if (!e?.length || !n?.length || !r?.length) return;
|
|
280
|
-
let s = isObject(i) ? { ...i } : i, c = e.flatMap((e) => n.flatMap((n) => r.map((r) => t(e, n, r, s))));
|
|
281
|
-
o(() => {
|
|
282
|
-
c.forEach((e) => e());
|
|
283
|
-
});
|
|
284
|
-
}, { flush: "post" });
|
|
285
|
-
}
|
|
286
|
-
var _global = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, globalKey = "__vueuse_ssr_handlers__", handlers = /* @__PURE__ */ getHandlers();
|
|
287
|
-
function getHandlers() {
|
|
288
|
-
return globalKey in _global || (_global[globalKey] = _global[globalKey] || {}), _global[globalKey];
|
|
289
|
-
}
|
|
290
|
-
function getSSRHandler(e, t) {
|
|
291
|
-
return handlers[e] || t;
|
|
292
|
-
}
|
|
293
|
-
function guessSerializerType(e) {
|
|
294
|
-
return e == null ? "any" : e instanceof Set ? "set" : e instanceof Map ? "map" : e instanceof Date ? "date" : typeof e == "boolean" ? "boolean" : typeof e == "string" ? "string" : typeof e == "object" ? "object" : Number.isNaN(e) ? "any" : "number";
|
|
295
|
-
}
|
|
296
|
-
var StorageSerializers = {
|
|
297
|
-
boolean: {
|
|
298
|
-
read: (e) => e === "true",
|
|
299
|
-
write: (e) => String(e)
|
|
300
|
-
},
|
|
301
|
-
object: {
|
|
302
|
-
read: (e) => JSON.parse(e),
|
|
303
|
-
write: (e) => JSON.stringify(e)
|
|
304
|
-
},
|
|
305
|
-
number: {
|
|
306
|
-
read: (e) => Number.parseFloat(e),
|
|
307
|
-
write: (e) => String(e)
|
|
308
|
-
},
|
|
309
|
-
any: {
|
|
310
|
-
read: (e) => e,
|
|
311
|
-
write: (e) => String(e)
|
|
312
|
-
},
|
|
313
|
-
string: {
|
|
314
|
-
read: (e) => e,
|
|
315
|
-
write: (e) => String(e)
|
|
316
|
-
},
|
|
317
|
-
map: {
|
|
318
|
-
read: (e) => new Map(JSON.parse(e)),
|
|
319
|
-
write: (e) => JSON.stringify(Array.from(e.entries()))
|
|
320
|
-
},
|
|
321
|
-
set: {
|
|
322
|
-
read: (e) => new Set(JSON.parse(e)),
|
|
323
|
-
write: (e) => JSON.stringify(Array.from(e))
|
|
324
|
-
},
|
|
325
|
-
date: {
|
|
326
|
-
read: (e) => new Date(e),
|
|
327
|
-
write: (e) => e.toISOString()
|
|
221
|
+
return await E("plugin:sql|close", { db: e });
|
|
328
222
|
}
|
|
329
223
|
};
|
|
330
|
-
function
|
|
331
|
-
let { flush: i = "pre", deep: a = !0, listenToStorageChanges: o = !0, writeDefaults: s = !0, mergeDefaults: c = !1, shallow: l, window: u = defaultWindow, eventFilter: d, onError: f = (e) => {
|
|
332
|
-
console.error(e);
|
|
333
|
-
}, onReady: p } = r, m = toValue(t), h = guessSerializerType(m), g = (l ? shallowRef : ref)(toValue(t)), _ = r.serializer ?? StorageSerializers[h];
|
|
334
|
-
if (!n) try {
|
|
335
|
-
n = getSSRHandler("getDefaultStorageAsync", () => defaultWindow?.localStorage)();
|
|
336
|
-
} catch (e) {
|
|
337
|
-
f(e);
|
|
338
|
-
}
|
|
339
|
-
async function v(t) {
|
|
340
|
-
if (!(!n || t && t.key !== e)) try {
|
|
341
|
-
let r = t ? t.newValue : await n.getItem(e);
|
|
342
|
-
if (r == null) g.value = m, s && m !== null && await n.setItem(e, await _.write(m));
|
|
343
|
-
else if (c) {
|
|
344
|
-
let e = await _.read(r);
|
|
345
|
-
typeof c == "function" ? g.value = c(e, m) : h === "object" && !Array.isArray(e) ? g.value = {
|
|
346
|
-
...m,
|
|
347
|
-
...e
|
|
348
|
-
} : g.value = e;
|
|
349
|
-
} else g.value = await _.read(r);
|
|
350
|
-
} catch (e) {
|
|
351
|
-
f(e);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
let y = new Promise((e) => {
|
|
355
|
-
v().then(() => {
|
|
356
|
-
p?.(g.value), e(g);
|
|
357
|
-
});
|
|
358
|
-
});
|
|
359
|
-
return u && o && useEventListener(u, "storage", (e) => Promise.resolve().then(() => v(e)), { passive: !0 }), n && watchWithFilter(g, async () => {
|
|
360
|
-
try {
|
|
361
|
-
g.value == null ? await n.removeItem(e) : await n.setItem(e, await _.write(g.value));
|
|
362
|
-
} catch (e) {
|
|
363
|
-
f(e);
|
|
364
|
-
}
|
|
365
|
-
}, {
|
|
366
|
-
flush: i,
|
|
367
|
-
deep: a,
|
|
368
|
-
eventFilter: d
|
|
369
|
-
}), Object.assign(g, {
|
|
370
|
-
then: y.then.bind(y),
|
|
371
|
-
catch: y.catch.bind(y)
|
|
372
|
-
}), g;
|
|
373
|
-
}
|
|
374
|
-
function debounce(e, t, { signal: n, edges: r } = {}) {
|
|
224
|
+
function O(e, t, { signal: n, edges: r } = {}) {
|
|
375
225
|
let i, a = null, o = r != null && r.includes("leading"), s = r == null || r.includes("trailing"), c = () => {
|
|
376
226
|
a !== null && (e.apply(i, a), i = void 0, a = null);
|
|
377
227
|
}, l = () => {
|
|
@@ -394,27 +244,31 @@ function debounce(e, t, { signal: n, edges: r } = {}) {
|
|
|
394
244
|
};
|
|
395
245
|
return h.schedule = d, h.cancel = p, h.flush = m, n?.addEventListener("abort", p, { once: !0 }), h;
|
|
396
246
|
}
|
|
397
|
-
function
|
|
247
|
+
function ce(e) {
|
|
398
248
|
return typeof e == "string";
|
|
399
249
|
}
|
|
400
|
-
function
|
|
250
|
+
function le(e) {
|
|
401
251
|
return e === void 0;
|
|
402
252
|
}
|
|
403
|
-
var
|
|
253
|
+
var ue = class {
|
|
254
|
+
/**
|
|
255
|
+
* Base class that implements {@link Dialect}
|
|
256
|
+
* @param create function that create {@link Driver}
|
|
257
|
+
*/
|
|
404
258
|
constructor(e) {
|
|
405
259
|
this.createDriver = e;
|
|
406
260
|
}
|
|
407
261
|
createDriver;
|
|
408
262
|
createQueryCompiler() {
|
|
409
|
-
return new
|
|
263
|
+
return new n();
|
|
410
264
|
}
|
|
411
265
|
createAdapter() {
|
|
412
|
-
return new
|
|
266
|
+
return new i();
|
|
413
267
|
}
|
|
414
268
|
createIntrospector(e) {
|
|
415
|
-
return new
|
|
269
|
+
return new a(e);
|
|
416
270
|
}
|
|
417
|
-
},
|
|
271
|
+
}, de = class {
|
|
418
272
|
promise;
|
|
419
273
|
resolve;
|
|
420
274
|
async lock() {
|
|
@@ -428,38 +282,43 @@ var BaseSqliteDialect = class {
|
|
|
428
282
|
this.promise = void 0, this.resolve = void 0, e?.();
|
|
429
283
|
}
|
|
430
284
|
};
|
|
431
|
-
async function
|
|
432
|
-
await i.executeQuery(o(
|
|
285
|
+
async function k(e, n, i, a, o) {
|
|
286
|
+
await i.executeQuery(o(r.createWithChildren([r.createWithSql(`${e} `), t.create(a)]), n()));
|
|
433
287
|
}
|
|
434
|
-
var
|
|
435
|
-
mutex = new
|
|
288
|
+
var fe = class {
|
|
289
|
+
mutex = new de();
|
|
436
290
|
conn;
|
|
437
291
|
savepoint;
|
|
438
292
|
releaseSavepoint;
|
|
439
293
|
rollbackToSavepoint;
|
|
440
294
|
init;
|
|
295
|
+
/**
|
|
296
|
+
* Base abstract class that implements {@link Driver}
|
|
297
|
+
*
|
|
298
|
+
* You **MUST** assign `this.conn` in `init` and implement `destroy` method
|
|
299
|
+
*/
|
|
441
300
|
constructor(e) {
|
|
442
|
-
this.init = () => import("./esm-
|
|
443
|
-
e && (this.savepoint =
|
|
301
|
+
this.init = () => import("./esm-CzppQRXP.js").then(({ createQueryId: e }) => {
|
|
302
|
+
e && (this.savepoint = k.bind(null, "savepoint", e), this.releaseSavepoint = k.bind(null, "release", e), this.rollbackToSavepoint = k.bind(null, "rollback to", e));
|
|
444
303
|
}).then(e);
|
|
445
304
|
}
|
|
446
305
|
async acquireConnection() {
|
|
447
306
|
return await this.mutex.lock(), this.conn;
|
|
448
307
|
}
|
|
449
308
|
async beginTransaction(e) {
|
|
450
|
-
await e.executeQuery(
|
|
309
|
+
await e.executeQuery(l.raw("begin"));
|
|
451
310
|
}
|
|
452
311
|
async commitTransaction(e) {
|
|
453
|
-
await e.executeQuery(
|
|
312
|
+
await e.executeQuery(l.raw("commit"));
|
|
454
313
|
}
|
|
455
314
|
async rollbackTransaction(e) {
|
|
456
|
-
await e.executeQuery(
|
|
315
|
+
await e.executeQuery(l.raw("rollback"));
|
|
457
316
|
}
|
|
458
317
|
async releaseConnection() {
|
|
459
318
|
this.mutex.unlock();
|
|
460
319
|
}
|
|
461
320
|
};
|
|
462
|
-
function
|
|
321
|
+
function pe(e) {
|
|
463
322
|
return async (t, n, r) => {
|
|
464
323
|
let i = await e.all(n, r);
|
|
465
324
|
return t || i.length ? { rows: i } : {
|
|
@@ -468,49 +327,58 @@ function buildQueryFn(e) {
|
|
|
468
327
|
};
|
|
469
328
|
};
|
|
470
329
|
}
|
|
471
|
-
function
|
|
330
|
+
function A(e) {
|
|
472
331
|
return e == null ? void 0 : BigInt(e);
|
|
473
332
|
}
|
|
474
|
-
var
|
|
333
|
+
var me = class extends fe {
|
|
475
334
|
db;
|
|
476
335
|
constructor(e, t) {
|
|
477
336
|
super(async () => {
|
|
478
|
-
this.db = await e(), this.conn = new
|
|
337
|
+
this.db = await e(), this.conn = new he(this.db), await t?.(this.conn);
|
|
479
338
|
});
|
|
480
339
|
}
|
|
481
340
|
async destroy() {
|
|
482
341
|
await this.db?.close();
|
|
483
342
|
}
|
|
484
|
-
},
|
|
343
|
+
}, he = class {
|
|
485
344
|
constructor(e) {
|
|
486
345
|
this.db = e;
|
|
487
346
|
}
|
|
488
347
|
async *streamQuery({ parameters: t, query: n, sql: r }) {
|
|
489
348
|
if (!this.db.iterator) throw Error("streamQuery() is not supported.");
|
|
490
|
-
let i = this.db.iterator(
|
|
349
|
+
let i = this.db.iterator(e.is(n), r, t);
|
|
491
350
|
for await (let e of i) yield { rows: [e] };
|
|
492
351
|
}
|
|
493
352
|
async executeQuery({ parameters: t, query: n, sql: r }) {
|
|
494
|
-
return await this.db.query(
|
|
495
|
-
}
|
|
496
|
-
},
|
|
353
|
+
return await this.db.query(e.is(n), r, t);
|
|
354
|
+
}
|
|
355
|
+
}, ge = class extends ue {
|
|
356
|
+
/**
|
|
357
|
+
* Dialect for generic SQLite that run SQLs in current thread
|
|
358
|
+
*
|
|
359
|
+
* @param executor function to create {@link IGenericSqlite}
|
|
360
|
+
* @param onCreateConnection optional callback after connection created
|
|
361
|
+
*/
|
|
497
362
|
constructor(e, t) {
|
|
498
|
-
super(() => new
|
|
363
|
+
super(() => new me(e, t));
|
|
499
364
|
}
|
|
500
|
-
},
|
|
365
|
+
}, j = class extends ge {
|
|
366
|
+
/**
|
|
367
|
+
* SQLite dialect for Tauri, using [official sql plugin](https://github.com/tauri-apps/plugins-workspace/tree/dev/plugins/sql)
|
|
368
|
+
*/
|
|
501
369
|
constructor(e) {
|
|
502
370
|
let { database: t, onCreateConnection: n } = e;
|
|
503
371
|
super(async () => {
|
|
504
372
|
let e = typeof t == "function" ? await t("sqlite:") : t;
|
|
505
373
|
return {
|
|
506
374
|
db: e,
|
|
507
|
-
query:
|
|
375
|
+
query: pe({
|
|
508
376
|
all: async (t, n) => await e.select(t, n),
|
|
509
377
|
run: async (t, n) => {
|
|
510
378
|
let { rowsAffected: r, lastInsertId: i } = await e.execute(t, n);
|
|
511
379
|
return {
|
|
512
|
-
numAffectedRows:
|
|
513
|
-
insertId:
|
|
380
|
+
numAffectedRows: A(r),
|
|
381
|
+
insertId: A(i)
|
|
514
382
|
};
|
|
515
383
|
}
|
|
516
384
|
}),
|
|
@@ -518,7 +386,7 @@ var GenericSqliteDriver = class extends BaseSqliteDriver {
|
|
|
518
386
|
};
|
|
519
387
|
}, n);
|
|
520
388
|
}
|
|
521
|
-
},
|
|
389
|
+
}, _e = class extends s {
|
|
522
390
|
serializer;
|
|
523
391
|
constructor(e) {
|
|
524
392
|
super(), this.serializer = e;
|
|
@@ -547,8 +415,8 @@ var GenericSqliteDriver = class extends BaseSqliteDriver {
|
|
|
547
415
|
value: this.serializer(e.value)
|
|
548
416
|
};
|
|
549
417
|
}
|
|
550
|
-
},
|
|
551
|
-
if (
|
|
418
|
+
}, ve = (e) => {
|
|
419
|
+
if (N(e) || typeof e == "string") return e;
|
|
552
420
|
if (typeof e == "boolean") return "" + e;
|
|
553
421
|
if (e instanceof Date) return e.toISOString();
|
|
554
422
|
try {
|
|
@@ -556,31 +424,34 @@ var GenericSqliteDriver = class extends BaseSqliteDriver {
|
|
|
556
424
|
} catch {
|
|
557
425
|
return e;
|
|
558
426
|
}
|
|
559
|
-
},
|
|
560
|
-
if (
|
|
427
|
+
}, ye = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?$/, be = (e) => {
|
|
428
|
+
if (N(e)) return e;
|
|
561
429
|
if (typeof e == "string") {
|
|
562
430
|
if (e === "true") return !0;
|
|
563
431
|
if (e === "false") return !1;
|
|
564
|
-
if (
|
|
565
|
-
if (
|
|
432
|
+
if (ye.test(e)) return new Date(e);
|
|
433
|
+
if (M(e)) try {
|
|
566
434
|
return JSON.parse(e);
|
|
567
435
|
} catch {}
|
|
568
436
|
return e;
|
|
569
437
|
}
|
|
570
438
|
};
|
|
571
|
-
function
|
|
439
|
+
function M(e) {
|
|
572
440
|
return e.startsWith("{") && e.endsWith("}") || e.startsWith("[") && e.endsWith("]");
|
|
573
441
|
}
|
|
574
|
-
function
|
|
442
|
+
function N(e) {
|
|
575
443
|
return e == null || typeof e == "bigint" || typeof e == "number" || typeof e == "object" && "buffer" in e;
|
|
576
444
|
}
|
|
577
|
-
var
|
|
445
|
+
var xe = class {
|
|
578
446
|
transformer;
|
|
579
447
|
deserializer;
|
|
580
448
|
skipNodeSet;
|
|
581
449
|
ctx;
|
|
450
|
+
/**
|
|
451
|
+
* Base class for {@link SerializePlugin}, without default options
|
|
452
|
+
*/
|
|
582
453
|
constructor(e, t, n) {
|
|
583
|
-
this.transformer = new
|
|
454
|
+
this.transformer = new _e(e), this.deserializer = t, n.length && (this.skipNodeSet = new Set(n), this.ctx = /* @__PURE__ */ new WeakSet());
|
|
584
455
|
}
|
|
585
456
|
transformQuery({ node: e, queryId: t }) {
|
|
586
457
|
return this.skipNodeSet?.has(e.kind) ? (this.ctx?.add(t), e) : this.transformer.transformNode(e);
|
|
@@ -601,13 +472,74 @@ var BaseSerializePlugin = class {
|
|
|
601
472
|
}
|
|
602
473
|
return t;
|
|
603
474
|
}
|
|
604
|
-
},
|
|
475
|
+
}, P = class extends xe {
|
|
476
|
+
/**
|
|
477
|
+
* _**THIS PLUGIN SHOULD BE PLACED AT THE END OF PLUGINS ARRAY !!!**_
|
|
478
|
+
*
|
|
479
|
+
* reference from https://github.com/koskimas/kysely/pull/138
|
|
480
|
+
*
|
|
481
|
+
* The following example will return an error when using sqlite dialects, unless using this plugin:
|
|
482
|
+
* ```ts
|
|
483
|
+
* interface TestTable {
|
|
484
|
+
* id: Generated<number>
|
|
485
|
+
* person: { name: string; age: number; time: Date } | null
|
|
486
|
+
* gender: boolean
|
|
487
|
+
* blob: Uint8Array | null
|
|
488
|
+
* date: Date
|
|
489
|
+
* }
|
|
490
|
+
*
|
|
491
|
+
* interface Database {
|
|
492
|
+
* test: TestTable
|
|
493
|
+
* }
|
|
494
|
+
*
|
|
495
|
+
* const db = new Kysely<Database>({
|
|
496
|
+
* dialect: new SqliteDialect({
|
|
497
|
+
* database: new Database(':memory:'),
|
|
498
|
+
* }),
|
|
499
|
+
* plugins: [
|
|
500
|
+
* new SerializePlugin(),
|
|
501
|
+
* ],
|
|
502
|
+
* })
|
|
503
|
+
*
|
|
504
|
+
* await db.insertInto('test').values({
|
|
505
|
+
* gender: true,
|
|
506
|
+
* person: { name: 'test', age: 2, time: new Date() },
|
|
507
|
+
* blob: Uint8Array.from([1, 2, 3]),
|
|
508
|
+
* date: new Date(),
|
|
509
|
+
* }).execute()
|
|
510
|
+
* ```
|
|
511
|
+
*
|
|
512
|
+
* You can also provide a custom serializer function:
|
|
513
|
+
*
|
|
514
|
+
* ```ts
|
|
515
|
+
* const db = new Kysely<Database>({
|
|
516
|
+
* dialect: new SqliteDialect({
|
|
517
|
+
* database: new Database(":memory:"),
|
|
518
|
+
* }),
|
|
519
|
+
* plugins: [
|
|
520
|
+
* new SerializePlugin({
|
|
521
|
+
* serializer: (value) => {
|
|
522
|
+
* if (value instanceof Date) {
|
|
523
|
+
* return formatDatetime(value)
|
|
524
|
+
* }
|
|
525
|
+
*
|
|
526
|
+
* if (value !== null && typeof value === 'object') {
|
|
527
|
+
* return JSON.stringify(value)
|
|
528
|
+
* }
|
|
529
|
+
*
|
|
530
|
+
* return value
|
|
531
|
+
* }
|
|
532
|
+
* }),
|
|
533
|
+
* ],
|
|
534
|
+
* })
|
|
535
|
+
* ```
|
|
536
|
+
*/
|
|
605
537
|
constructor(e = {}) {
|
|
606
|
-
let { deserializer: t =
|
|
538
|
+
let { deserializer: t = be, serializer: n = ve, skipNodeKind: r = [] } = e;
|
|
607
539
|
super(n, t, r);
|
|
608
540
|
}
|
|
609
541
|
};
|
|
610
|
-
function
|
|
542
|
+
function F(e) {
|
|
611
543
|
return {
|
|
612
544
|
all: e ||= /* @__PURE__ */ new Map(),
|
|
613
545
|
on: function(t, n) {
|
|
@@ -628,48 +560,48 @@ function mitt_default(e) {
|
|
|
628
560
|
}
|
|
629
561
|
};
|
|
630
562
|
}
|
|
631
|
-
var
|
|
632
|
-
get: () =>
|
|
633
|
-
getByEnabled: () =>
|
|
634
|
-
toggleEnable: () =>
|
|
563
|
+
var Se = /* @__PURE__ */ w({
|
|
564
|
+
get: () => we,
|
|
565
|
+
getByEnabled: () => Ce,
|
|
566
|
+
toggleEnable: () => Te
|
|
635
567
|
});
|
|
636
|
-
async function
|
|
568
|
+
async function Ce(e) {
|
|
637
569
|
let { db: t } = await import("./index.js");
|
|
638
570
|
return t.value.selectFrom("plugin").where("enable", "=", e).selectAll().execute();
|
|
639
571
|
}
|
|
640
|
-
async function
|
|
572
|
+
async function we(e) {
|
|
641
573
|
let { db: t } = await import("./index.js");
|
|
642
574
|
return t.value.selectFrom("plugin").where("pluginName", "=", e).selectAll().executeTakeFirstOrThrow();
|
|
643
575
|
}
|
|
644
|
-
async function
|
|
576
|
+
async function Te(e) {
|
|
645
577
|
let { db: t } = await import("./index.js"), n = await t.value.selectFrom("plugin").where("pluginName", "=", e).select("enable").executeTakeFirstOrThrow();
|
|
646
578
|
return t.value.updateTable("plugin").where("pluginName", "=", e).set({ enable: !n.enable }).execute();
|
|
647
579
|
}
|
|
648
|
-
var
|
|
649
|
-
key: () =>
|
|
650
|
-
upsert: () =>
|
|
580
|
+
var Ee = /* @__PURE__ */ w({
|
|
581
|
+
key: () => I,
|
|
582
|
+
upsert: () => L
|
|
651
583
|
});
|
|
652
|
-
const
|
|
653
|
-
async function
|
|
654
|
-
let { db: t } = await import("./index.js"), n =
|
|
584
|
+
const I = new b("*");
|
|
585
|
+
async function L(e) {
|
|
586
|
+
let { db: t } = await import("./index.js"), n = I.toString([S.content.ContentPage.contentPage.toString(e.contentType), e.id]);
|
|
655
587
|
return await t.value.replaceInto("itemStore").values({
|
|
656
|
-
item:
|
|
588
|
+
item: x.toRaw(e),
|
|
657
589
|
key: n
|
|
658
590
|
}).execute(), n;
|
|
659
591
|
}
|
|
660
|
-
var
|
|
661
|
-
moveItem: () =>
|
|
662
|
-
upsertItem: () =>
|
|
592
|
+
var De = /* @__PURE__ */ w({
|
|
593
|
+
moveItem: () => ke,
|
|
594
|
+
upsertItem: () => Oe
|
|
663
595
|
});
|
|
664
|
-
async function
|
|
665
|
-
let { db: n } = await import("./index.js"), r = await
|
|
596
|
+
async function Oe(e, ...t) {
|
|
597
|
+
let { db: n } = await import("./index.js"), r = await L(e);
|
|
666
598
|
for (let e of t) await n.value.replaceInto("favouriteItem").values({
|
|
667
599
|
addTime: Date.now(),
|
|
668
600
|
itemKey: r,
|
|
669
601
|
belongTo: e
|
|
670
602
|
}).execute();
|
|
671
603
|
}
|
|
672
|
-
async function
|
|
604
|
+
async function ke(e, t, ...n) {
|
|
673
605
|
let { db: r } = await import("./index.js");
|
|
674
606
|
await r.value.deleteFrom("favouriteItem").where("itemKey", "=", e.id).where("belongTo", "=", t).execute();
|
|
675
607
|
for (let t of n) await r.value.replaceInto("favouriteItem").values({
|
|
@@ -678,26 +610,26 @@ async function moveItem(e, t, ...n) {
|
|
|
678
610
|
belongTo: t
|
|
679
611
|
}).execute();
|
|
680
612
|
}
|
|
681
|
-
var
|
|
682
|
-
async function
|
|
683
|
-
let { db: t } = await import("./index.js"), n = await
|
|
613
|
+
var Ae = /* @__PURE__ */ w({ upsert: () => je });
|
|
614
|
+
async function je(e) {
|
|
615
|
+
let { db: t } = await import("./index.js"), n = await L(e);
|
|
684
616
|
await t.value.replaceInto("history").values({
|
|
685
617
|
itemKey: n,
|
|
686
618
|
timestamp: Date.now(),
|
|
687
|
-
ep:
|
|
619
|
+
ep: x.toRaw(e)
|
|
688
620
|
}).execute();
|
|
689
621
|
}
|
|
690
|
-
var
|
|
691
|
-
getAll: () =>
|
|
692
|
-
key: () =>
|
|
693
|
-
upsert: () =>
|
|
622
|
+
var Me = /* @__PURE__ */ w({
|
|
623
|
+
getAll: () => Pe,
|
|
624
|
+
key: () => Ne,
|
|
625
|
+
upsert: () => Fe
|
|
694
626
|
});
|
|
695
|
-
const
|
|
696
|
-
async function
|
|
627
|
+
const Ne = new b();
|
|
628
|
+
async function Pe() {
|
|
697
629
|
let { db: e } = await import("./index.js");
|
|
698
630
|
return e.value.selectFrom("subscribe").selectAll().execute();
|
|
699
631
|
}
|
|
700
|
-
async function
|
|
632
|
+
async function Fe(e) {
|
|
701
633
|
let { db: t } = await import("./index.js");
|
|
702
634
|
return t.value.replaceInto("subscribe").values({
|
|
703
635
|
type: e.type,
|
|
@@ -707,79 +639,275 @@ async function upsert$1(e) {
|
|
|
707
639
|
author: JSON.stringify(e.author)
|
|
708
640
|
}).execute();
|
|
709
641
|
}
|
|
710
|
-
var
|
|
711
|
-
async function
|
|
712
|
-
let { db: t } = await import("./index.js"), n = await
|
|
642
|
+
var Ie = /* @__PURE__ */ w({ upsert: () => Le });
|
|
643
|
+
async function Le(e) {
|
|
644
|
+
let { db: t } = await import("./index.js"), n = await L(e);
|
|
713
645
|
await t.value.replaceInto("recentView").values({
|
|
714
646
|
isViewed: !1,
|
|
715
647
|
itemKey: n,
|
|
716
648
|
timestamp: Date.now()
|
|
717
649
|
}).execute();
|
|
718
650
|
}
|
|
719
|
-
|
|
720
|
-
"
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
651
|
+
async function Re(e) {
|
|
652
|
+
await e.schema.createTable("store").addColumn("item", "text", (e) => e.notNull()).addColumn("name", "text", (e) => e.notNull()).addColumn("namespace", "text", (e) => e.notNull()).addPrimaryKeyConstraint("key", ["name", "namespace"]).execute();
|
|
653
|
+
}
|
|
654
|
+
async function R(e) {
|
|
655
|
+
await e.schema.dropTable("store").ifExists().execute();
|
|
656
|
+
}
|
|
657
|
+
var ze = {
|
|
658
|
+
up: Re,
|
|
659
|
+
down: R
|
|
660
|
+
}, z = typeof window < "u" && typeof document < "u";
|
|
661
|
+
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
662
|
+
var Be = Object.prototype.toString, Ve = (e) => Be.call(e) === "[object Object]";
|
|
663
|
+
/**
|
|
664
|
+
* @internal
|
|
665
|
+
*/
|
|
666
|
+
function He(e, t) {
|
|
667
|
+
function n(...n) {
|
|
668
|
+
return new Promise((r, i) => {
|
|
669
|
+
Promise.resolve(e(() => t.apply(this, n), {
|
|
670
|
+
fn: t,
|
|
671
|
+
thisArg: this,
|
|
672
|
+
args: n
|
|
673
|
+
})).then(r).catch(i);
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
return n;
|
|
677
|
+
}
|
|
678
|
+
var Ue = (e) => e();
|
|
679
|
+
function B(e) {
|
|
680
|
+
return Array.isArray(e) ? e : [e];
|
|
681
|
+
}
|
|
682
|
+
function We(e, t, n = {}) {
|
|
683
|
+
let { eventFilter: r = Ue, ...i } = n;
|
|
684
|
+
return y(e, He(r, t), i);
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Shorthand for watching value with {immediate: true}
|
|
688
|
+
*
|
|
689
|
+
* @see https://vueuse.org/watchImmediate
|
|
690
|
+
*/
|
|
691
|
+
function Ge(e, t, n) {
|
|
692
|
+
return y(e, t, {
|
|
693
|
+
...n,
|
|
694
|
+
immediate: !0
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
var V = z ? window : void 0;
|
|
698
|
+
z && window.document, z && window.navigator, z && window.location;
|
|
699
|
+
/**
|
|
700
|
+
* Get the dom element of a ref of element or Vue component instance
|
|
701
|
+
*
|
|
702
|
+
* @param elRef
|
|
703
|
+
*/
|
|
704
|
+
function Ke(e) {
|
|
705
|
+
let t = g(e);
|
|
706
|
+
return t?.$el ?? t;
|
|
707
|
+
}
|
|
708
|
+
function qe(...e) {
|
|
709
|
+
let t = (e, t, n, r) => (e.addEventListener(t, n, r), () => e.removeEventListener(t, n, r)), n = f(() => {
|
|
710
|
+
let t = B(g(e[0])).filter((e) => e != null);
|
|
711
|
+
return t.every((e) => typeof e != "string") ? t : void 0;
|
|
712
|
+
});
|
|
713
|
+
return Ge(() => [
|
|
714
|
+
n.value?.map((e) => Ke(e)) ?? [V].filter((e) => e != null),
|
|
715
|
+
B(g(n.value ? e[1] : e[0])),
|
|
716
|
+
B(v(n.value ? e[2] : e[1])),
|
|
717
|
+
g(n.value ? e[3] : e[2])
|
|
718
|
+
], ([e, n, r, i], a, o) => {
|
|
719
|
+
if (!e?.length || !n?.length || !r?.length) return;
|
|
720
|
+
let s = Ve(i) ? { ...i } : i, c = e.flatMap((e) => n.flatMap((n) => r.map((r) => t(e, n, r, s))));
|
|
721
|
+
o(() => {
|
|
722
|
+
c.forEach((e) => e());
|
|
723
|
+
});
|
|
724
|
+
}, { flush: "post" });
|
|
725
|
+
}
|
|
726
|
+
var H = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, U = "__vueuse_ssr_handlers__", Je = /* @__PURE__ */ Ye();
|
|
727
|
+
function Ye() {
|
|
728
|
+
return U in H || (H[U] = H[U] || {}), H[U];
|
|
729
|
+
}
|
|
730
|
+
function Xe(e, t) {
|
|
731
|
+
return Je[e] || t;
|
|
732
|
+
}
|
|
733
|
+
function Ze(e) {
|
|
734
|
+
return e == null ? "any" : e instanceof Set ? "set" : e instanceof Map ? "map" : e instanceof Date ? "date" : typeof e == "boolean" ? "boolean" : typeof e == "string" ? "string" : typeof e == "object" ? "object" : Number.isNaN(e) ? "any" : "number";
|
|
735
|
+
}
|
|
736
|
+
var Qe = {
|
|
737
|
+
boolean: {
|
|
738
|
+
read: (e) => e === "true",
|
|
739
|
+
write: (e) => String(e)
|
|
740
|
+
},
|
|
741
|
+
object: {
|
|
742
|
+
read: (e) => JSON.parse(e),
|
|
743
|
+
write: (e) => JSON.stringify(e)
|
|
744
|
+
},
|
|
745
|
+
number: {
|
|
746
|
+
read: (e) => Number.parseFloat(e),
|
|
747
|
+
write: (e) => String(e)
|
|
748
|
+
},
|
|
749
|
+
any: {
|
|
750
|
+
read: (e) => e,
|
|
751
|
+
write: (e) => String(e)
|
|
752
|
+
},
|
|
753
|
+
string: {
|
|
754
|
+
read: (e) => e,
|
|
755
|
+
write: (e) => String(e)
|
|
756
|
+
},
|
|
757
|
+
map: {
|
|
758
|
+
read: (e) => new Map(JSON.parse(e)),
|
|
759
|
+
write: (e) => JSON.stringify(Array.from(e.entries()))
|
|
760
|
+
},
|
|
761
|
+
set: {
|
|
762
|
+
read: (e) => new Set(JSON.parse(e)),
|
|
763
|
+
write: (e) => JSON.stringify(Array.from(e))
|
|
764
|
+
},
|
|
765
|
+
date: {
|
|
766
|
+
read: (e) => new Date(e),
|
|
767
|
+
write: (e) => e.toISOString()
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
/**
|
|
771
|
+
* Reactive Storage in with async support.
|
|
772
|
+
*
|
|
773
|
+
* @see https://vueuse.org/useStorageAsync
|
|
774
|
+
* @param key
|
|
775
|
+
* @param initialValue
|
|
776
|
+
* @param storage
|
|
777
|
+
* @param options
|
|
778
|
+
*/
|
|
779
|
+
function $e(e, t, n, r = {}) {
|
|
780
|
+
let { flush: i = "pre", deep: a = !0, listenToStorageChanges: o = !0, writeDefaults: s = !0, mergeDefaults: c = !1, shallow: l, window: u = V, eventFilter: d, onError: f = (e) => {
|
|
781
|
+
console.error(e);
|
|
782
|
+
}, onReady: h } = r, _ = g(t), v = Ze(_), y = (l ? m : p)(g(t)), b = r.serializer ?? Qe[v];
|
|
783
|
+
if (!n) try {
|
|
784
|
+
n = Xe("getDefaultStorageAsync", () => V?.localStorage)();
|
|
785
|
+
} catch (e) {
|
|
786
|
+
f(e);
|
|
787
|
+
}
|
|
788
|
+
async function x(t) {
|
|
789
|
+
if (!(!n || t && t.key !== e)) try {
|
|
790
|
+
let r = t ? t.newValue : await n.getItem(e);
|
|
791
|
+
if (r == null) y.value = _, s && _ !== null && await n.setItem(e, await b.write(_));
|
|
792
|
+
else if (c) {
|
|
793
|
+
let e = await b.read(r);
|
|
794
|
+
typeof c == "function" ? y.value = c(e, _) : v === "object" && !Array.isArray(e) ? y.value = {
|
|
795
|
+
..._,
|
|
796
|
+
...e
|
|
797
|
+
} : y.value = e;
|
|
798
|
+
} else y.value = await b.read(r);
|
|
799
|
+
} catch (e) {
|
|
800
|
+
f(e);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
let S = new Promise((e) => {
|
|
804
|
+
x().then(() => {
|
|
805
|
+
h?.(y.value), e(y);
|
|
806
|
+
});
|
|
807
|
+
});
|
|
808
|
+
return u && o && qe(u, "storage", (e) => Promise.resolve().then(() => x(e)), { passive: !0 }), n && We(y, async () => {
|
|
809
|
+
try {
|
|
810
|
+
y.value == null ? await n.removeItem(e) : await n.setItem(e, await b.write(y.value));
|
|
811
|
+
} catch (e) {
|
|
812
|
+
f(e);
|
|
813
|
+
}
|
|
814
|
+
}, {
|
|
815
|
+
flush: i,
|
|
816
|
+
deep: a,
|
|
817
|
+
eventFilter: d
|
|
818
|
+
}), Object.assign(y, {
|
|
819
|
+
then: S.then.bind(S),
|
|
820
|
+
catch: S.catch.bind(S)
|
|
821
|
+
}), y;
|
|
822
|
+
}
|
|
823
|
+
var et = /* @__PURE__ */ Object.assign({ "./migrations/1_initial.ts": ze }), W = d(await D.load("sqlite:native_store.db"), "core/store/raw"), tt = F(), G = /\b(INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|ALTER)\b/i, K = O(() => {
|
|
824
|
+
console.debug("[db sync] db changed"), tt.emit("onChange"), _(q);
|
|
825
|
+
}, 300), q = d(await (async () => {
|
|
826
|
+
let e = m(new u({
|
|
827
|
+
dialect: new j({ database: {
|
|
828
|
+
close(e) {
|
|
829
|
+
return W.close(e);
|
|
830
|
+
},
|
|
831
|
+
path: W.path,
|
|
832
|
+
async select(e, t) {
|
|
833
|
+
console.debug("sql!", e, t);
|
|
834
|
+
let n = await W.select(e, t);
|
|
835
|
+
return G.test(e) && K(), n;
|
|
836
|
+
},
|
|
837
|
+
async execute(e, t) {
|
|
838
|
+
console.debug("sql!", e, t);
|
|
839
|
+
let n = await W.execute(e, t);
|
|
840
|
+
return G.test(e) && K(), n;
|
|
841
|
+
}
|
|
842
|
+
} }),
|
|
843
|
+
plugins: [new c(), new P()]
|
|
844
|
+
}));
|
|
845
|
+
return await new o({
|
|
846
|
+
db: e.value,
|
|
847
|
+
provider: { async getMigrations() {
|
|
848
|
+
return et;
|
|
849
|
+
} }
|
|
850
|
+
}).migrateToLatest(), e;
|
|
851
|
+
})(), "core/store/ins"), J = new b();
|
|
852
|
+
const nt = (e, t, n) => $e(J.toString([e, h(t).value]), n, {
|
|
853
|
+
async removeItem(e) {
|
|
854
|
+
let [t, n] = J.toJSON(e);
|
|
855
|
+
await q.value.deleteFrom("store").where("namespace", "=", t).where("name", "=", n).execute();
|
|
856
|
+
},
|
|
857
|
+
async getItem(e) {
|
|
858
|
+
let [t, n] = J.toJSON(e);
|
|
859
|
+
return await q.value.selectFrom("store").selectAll().where("namespace", "=", t).where("name", "=", n).executeTakeFirst().then((e) => ce(e) ? e : le(e) ? null : JSON.stringify(e));
|
|
860
|
+
},
|
|
861
|
+
async setItem(e, t) {
|
|
862
|
+
let [n, r] = J.toJSON(e);
|
|
863
|
+
await q.value.replaceInto("store").values({
|
|
864
|
+
namespace: n,
|
|
865
|
+
name: r,
|
|
866
|
+
item: JSON.stringify({ value: t })
|
|
867
|
+
}).execute();
|
|
868
|
+
}
|
|
869
|
+
});
|
|
870
|
+
var rt = /* @__PURE__ */ Object.assign({
|
|
871
|
+
"./migrations/1_initial.ts": te,
|
|
872
|
+
"./migrations/2_fix-display_name.ts": ie,
|
|
873
|
+
"./migrations/3_fix_fvi_foreign_key.ts": se
|
|
874
|
+
}), Y = d(await D.load("sqlite:app.db"), "core/db/raw"), it = F(), X = /\b(INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|ALTER)\b/i, Z = O(() => {
|
|
875
|
+
console.debug("[db sync] db changed"), it.emit("onChange"), _(Q);
|
|
725
876
|
}, 300);
|
|
726
|
-
const
|
|
727
|
-
let e =
|
|
728
|
-
dialect: new
|
|
877
|
+
const Q = d(await (async () => {
|
|
878
|
+
let e = m(new u({
|
|
879
|
+
dialect: new j({ database: {
|
|
729
880
|
close(e) {
|
|
730
|
-
return
|
|
881
|
+
return Y.close(e);
|
|
731
882
|
},
|
|
732
|
-
path:
|
|
883
|
+
path: Y.path,
|
|
733
884
|
async select(e, t) {
|
|
734
885
|
console.debug("sql!", e, t);
|
|
735
|
-
let n = await
|
|
736
|
-
return
|
|
886
|
+
let n = await Y.select(e, t);
|
|
887
|
+
return X.test(e) && Z(), n;
|
|
737
888
|
},
|
|
738
889
|
async execute(e, t) {
|
|
739
890
|
console.debug("sql!", e, t);
|
|
740
|
-
let n = await
|
|
741
|
-
return
|
|
891
|
+
let n = await Y.execute(e, t);
|
|
892
|
+
return X.test(e) && Z(), n;
|
|
742
893
|
}
|
|
743
894
|
} }),
|
|
744
|
-
plugins: [new
|
|
895
|
+
plugins: [new c(), new P()]
|
|
745
896
|
}));
|
|
746
|
-
return await new
|
|
897
|
+
return await new o({
|
|
747
898
|
db: e.value,
|
|
748
899
|
provider: { async getMigrations() {
|
|
749
|
-
return
|
|
900
|
+
return rt;
|
|
750
901
|
} }
|
|
751
902
|
}).migrateToLatest(), e;
|
|
752
903
|
})(), "core/db/ins");
|
|
753
|
-
let
|
|
904
|
+
let $;
|
|
754
905
|
(function(e) {
|
|
755
906
|
async function t(e) {
|
|
756
907
|
return (await e.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow()).count;
|
|
757
908
|
}
|
|
758
909
|
e.countDb = t;
|
|
759
|
-
})(
|
|
760
|
-
|
|
761
|
-
const useNativeStore = (e, t, n) => {
|
|
762
|
-
let r = Store.load(e, { defaults: {} }), i = async () => {
|
|
763
|
-
let e = await r;
|
|
764
|
-
return await e.reload(), Object.assign(e, { async [Symbol.asyncDispose]() {
|
|
765
|
-
await e.save();
|
|
766
|
-
} });
|
|
767
|
-
};
|
|
768
|
-
return useStorageAsync(saveKey.toString([e, toRef(t).value]), n, {
|
|
769
|
-
async removeItem(e) {
|
|
770
|
-
let [, t] = saveKey.toJSON(e), n = await i();
|
|
771
|
-
await n.delete(t), await n[Symbol.asyncDispose]();
|
|
772
|
-
},
|
|
773
|
-
async getItem(e) {
|
|
774
|
-
let [, t] = saveKey.toJSON(e);
|
|
775
|
-
return (await i()).get(t).then((e) => isString(e) ? e : isUndefined(e) ? null : JSON.stringify(e));
|
|
776
|
-
},
|
|
777
|
-
async setItem(e, t) {
|
|
778
|
-
let [, n] = saveKey.toJSON(e), r = await i();
|
|
779
|
-
await r.set(n, t), await r[Symbol.asyncDispose]();
|
|
780
|
-
}
|
|
781
|
-
});
|
|
782
|
-
};
|
|
783
|
-
export { DBUtils, favourite_exports as FavouriteDB, history_exports as HistoryDB, itemStore_exports as ItemStoreDB, plugin_exports as PluginArchiveDB, recentView_exports as RecentDB, subscribe_exports as SubscribeDB, db, useNativeStore };
|
|
910
|
+
})($ ||= {});
|
|
911
|
+
export { $ as DBUtils, De as FavouriteDB, Ae as HistoryDB, Ee as ItemStoreDB, Se as PluginArchiveDB, Ie as RecentDB, Me as SubscribeDB, Q as db, nt as useNativeStore };
|
|
784
912
|
|
|
785
913
|
//# sourceMappingURL=index.js.map
|