@delta-comic/db 0.0.6 → 0.0.7
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/index.js +283 -196
- package/dist/index.js.map +1 -1
- package/dist/lib/nativeStore/index.d.ts +1 -1
- package/dist/pack.tgz +0 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
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
2
|
import { useGlobalVar as d } from "@delta-comic/utils";
|
|
3
|
-
import { computed as f,
|
|
4
|
-
import { SourcedValue as
|
|
5
|
-
var
|
|
3
|
+
import { computed as f, customRef as p, getCurrentInstance as m, nextTick as h, onMounted as g, readonly as _, ref as v, shallowRef as y, toRef as b, toValue as x, triggerRef as S, unref as C, watch as w } from "vue";
|
|
4
|
+
import { SourcedValue as T, Struct as E, uni as D } from "@delta-comic/model";
|
|
5
|
+
var O = Object.defineProperty, k = (e, t) => {
|
|
6
6
|
let n = {};
|
|
7
|
-
for (var r in e)
|
|
7
|
+
for (var r in e) O(n, r, {
|
|
8
8
|
get: e[r],
|
|
9
9
|
enumerable: !0
|
|
10
10
|
});
|
|
11
|
-
return t ||
|
|
11
|
+
return t || O(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
12
12
|
};
|
|
13
|
-
async function
|
|
13
|
+
async function A(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 ee(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 j(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 M = {
|
|
29
|
+
up: A,
|
|
30
|
+
down: j
|
|
31
31
|
};
|
|
32
|
-
async function
|
|
32
|
+
async function ee(e) {
|
|
33
33
|
await e.schema.alterTable("plugin").addColumn("displayName", "text").execute();
|
|
34
34
|
}
|
|
35
|
-
async function
|
|
35
|
+
async function te(e) {
|
|
36
36
|
await e.schema.alterTable("plugin").dropColumn("displayName").execute();
|
|
37
37
|
}
|
|
38
|
-
var
|
|
39
|
-
up:
|
|
40
|
-
down:
|
|
38
|
+
var ne = {
|
|
39
|
+
up: ee,
|
|
40
|
+
down: te
|
|
41
41
|
};
|
|
42
|
-
async function
|
|
42
|
+
async function re(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 oe(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 ie(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,9 +69,9 @@ async function T(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 ae = {
|
|
73
|
+
up: re,
|
|
74
|
+
down: ie
|
|
75
75
|
};
|
|
76
76
|
/**
|
|
77
77
|
* Sends a message to the backend.
|
|
@@ -88,7 +88,7 @@ var se = {
|
|
|
88
88
|
*
|
|
89
89
|
* @since 1.0.0
|
|
90
90
|
*/
|
|
91
|
-
async function
|
|
91
|
+
async function N(e, t = {}, n) {
|
|
92
92
|
return window.__TAURI_INTERNALS__.invoke(e, t, n);
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
@@ -97,7 +97,7 @@ async function E(e, t = {}, n) {
|
|
|
97
97
|
* The `Database` class serves as the primary interface for
|
|
98
98
|
* communicating with the rust side of the sql plugin.
|
|
99
99
|
*/
|
|
100
|
-
var
|
|
100
|
+
var oe = class e {
|
|
101
101
|
constructor(e) {
|
|
102
102
|
this.path = e;
|
|
103
103
|
}
|
|
@@ -117,7 +117,7 @@ var D = class e {
|
|
|
117
117
|
* ```
|
|
118
118
|
*/
|
|
119
119
|
static async load(t) {
|
|
120
|
-
return new e(await
|
|
120
|
+
return new e(await N("plugin:sql|load", { db: t }));
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
123
|
* **get**
|
|
@@ -171,7 +171,7 @@ var D = class e {
|
|
|
171
171
|
* ```
|
|
172
172
|
*/
|
|
173
173
|
async execute(e, t) {
|
|
174
|
-
let [n, r] = await
|
|
174
|
+
let [n, r] = await N("plugin:sql|execute", {
|
|
175
175
|
db: this.path,
|
|
176
176
|
query: e,
|
|
177
177
|
values: t ?? []
|
|
@@ -200,7 +200,7 @@ var D = class e {
|
|
|
200
200
|
* ```
|
|
201
201
|
*/
|
|
202
202
|
async select(e, t) {
|
|
203
|
-
return await
|
|
203
|
+
return await N("plugin:sql|select", {
|
|
204
204
|
db: this.path,
|
|
205
205
|
query: e,
|
|
206
206
|
values: t ?? []
|
|
@@ -218,10 +218,10 @@ var D = class e {
|
|
|
218
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
219
|
*/
|
|
220
220
|
async close(e) {
|
|
221
|
-
return await
|
|
221
|
+
return await N("plugin:sql|close", { db: e });
|
|
222
222
|
}
|
|
223
223
|
};
|
|
224
|
-
function
|
|
224
|
+
function P(e, t, { signal: n, edges: r } = {}) {
|
|
225
225
|
let i, a = null, o = r != null && r.includes("leading"), s = r == null || r.includes("trailing"), c = () => {
|
|
226
226
|
a !== null && (e.apply(i, a), i = void 0, a = null);
|
|
227
227
|
}, l = () => {
|
|
@@ -244,7 +244,7 @@ function O(e, t, { signal: n, edges: r } = {}) {
|
|
|
244
244
|
};
|
|
245
245
|
return h.schedule = d, h.cancel = p, h.flush = m, n?.addEventListener("abort", p, { once: !0 }), h;
|
|
246
246
|
}
|
|
247
|
-
var
|
|
247
|
+
var se = class {
|
|
248
248
|
/**
|
|
249
249
|
* Base class that implements {@link Dialect}
|
|
250
250
|
* @param create function that create {@link Driver}
|
|
@@ -262,7 +262,7 @@ var ce = class {
|
|
|
262
262
|
createIntrospector(e) {
|
|
263
263
|
return new a(e);
|
|
264
264
|
}
|
|
265
|
-
},
|
|
265
|
+
}, ce = class {
|
|
266
266
|
promise;
|
|
267
267
|
resolve;
|
|
268
268
|
async lock() {
|
|
@@ -276,11 +276,11 @@ var ce = class {
|
|
|
276
276
|
this.promise = void 0, this.resolve = void 0, e?.();
|
|
277
277
|
}
|
|
278
278
|
};
|
|
279
|
-
async function
|
|
279
|
+
async function F(e, n, i, a, o) {
|
|
280
280
|
await i.executeQuery(o(r.createWithChildren([r.createWithSql(`${e} `), t.create(a)]), n()));
|
|
281
281
|
}
|
|
282
|
-
var
|
|
283
|
-
mutex = new
|
|
282
|
+
var le = class {
|
|
283
|
+
mutex = new ce();
|
|
284
284
|
conn;
|
|
285
285
|
savepoint;
|
|
286
286
|
releaseSavepoint;
|
|
@@ -293,7 +293,7 @@ var ue = class {
|
|
|
293
293
|
*/
|
|
294
294
|
constructor(e) {
|
|
295
295
|
this.init = () => import("./esm-CzppQRXP.js").then(({ createQueryId: e }) => {
|
|
296
|
-
e && (this.savepoint =
|
|
296
|
+
e && (this.savepoint = F.bind(null, "savepoint", e), this.releaseSavepoint = F.bind(null, "release", e), this.rollbackToSavepoint = F.bind(null, "rollback to", e));
|
|
297
297
|
}).then(e);
|
|
298
298
|
}
|
|
299
299
|
async acquireConnection() {
|
|
@@ -312,7 +312,7 @@ var ue = class {
|
|
|
312
312
|
this.mutex.unlock();
|
|
313
313
|
}
|
|
314
314
|
};
|
|
315
|
-
function
|
|
315
|
+
function ue(e) {
|
|
316
316
|
return async (t, n, r) => {
|
|
317
317
|
let i = await e.all(n, r);
|
|
318
318
|
return t || i.length ? { rows: i } : {
|
|
@@ -321,20 +321,20 @@ function de(e) {
|
|
|
321
321
|
};
|
|
322
322
|
};
|
|
323
323
|
}
|
|
324
|
-
function
|
|
324
|
+
function I(e) {
|
|
325
325
|
return e == null ? void 0 : BigInt(e);
|
|
326
326
|
}
|
|
327
|
-
var
|
|
327
|
+
var de = class extends le {
|
|
328
328
|
db;
|
|
329
329
|
constructor(e, t) {
|
|
330
330
|
super(async () => {
|
|
331
|
-
this.db = await e(), this.conn = new
|
|
331
|
+
this.db = await e(), this.conn = new fe(this.db), await t?.(this.conn);
|
|
332
332
|
});
|
|
333
333
|
}
|
|
334
334
|
async destroy() {
|
|
335
335
|
await this.db?.close();
|
|
336
336
|
}
|
|
337
|
-
},
|
|
337
|
+
}, fe = class {
|
|
338
338
|
constructor(e) {
|
|
339
339
|
this.db = e;
|
|
340
340
|
}
|
|
@@ -346,7 +346,7 @@ var fe = class extends ue {
|
|
|
346
346
|
async executeQuery({ parameters: t, query: n, sql: r }) {
|
|
347
347
|
return await this.db.query(e.is(n), r, t);
|
|
348
348
|
}
|
|
349
|
-
},
|
|
349
|
+
}, pe = class extends se {
|
|
350
350
|
/**
|
|
351
351
|
* Dialect for generic SQLite that run SQLs in current thread
|
|
352
352
|
*
|
|
@@ -354,9 +354,9 @@ var fe = class extends ue {
|
|
|
354
354
|
* @param onCreateConnection optional callback after connection created
|
|
355
355
|
*/
|
|
356
356
|
constructor(e, t) {
|
|
357
|
-
super(() => new
|
|
357
|
+
super(() => new de(e, t));
|
|
358
358
|
}
|
|
359
|
-
},
|
|
359
|
+
}, L = class extends pe {
|
|
360
360
|
/**
|
|
361
361
|
* SQLite dialect for Tauri, using [official sql plugin](https://github.com/tauri-apps/plugins-workspace/tree/dev/plugins/sql)
|
|
362
362
|
*/
|
|
@@ -366,13 +366,13 @@ var fe = class extends ue {
|
|
|
366
366
|
let e = typeof t == "function" ? await t("sqlite:") : t;
|
|
367
367
|
return {
|
|
368
368
|
db: e,
|
|
369
|
-
query:
|
|
369
|
+
query: ue({
|
|
370
370
|
all: async (t, n) => await e.select(t, n),
|
|
371
371
|
run: async (t, n) => {
|
|
372
372
|
let { rowsAffected: r, lastInsertId: i } = await e.execute(t, n);
|
|
373
373
|
return {
|
|
374
|
-
numAffectedRows:
|
|
375
|
-
insertId:
|
|
374
|
+
numAffectedRows: I(r),
|
|
375
|
+
insertId: I(i)
|
|
376
376
|
};
|
|
377
377
|
}
|
|
378
378
|
}),
|
|
@@ -380,7 +380,7 @@ var fe = class extends ue {
|
|
|
380
380
|
};
|
|
381
381
|
}, n);
|
|
382
382
|
}
|
|
383
|
-
},
|
|
383
|
+
}, me = class extends s {
|
|
384
384
|
serializer;
|
|
385
385
|
constructor(e) {
|
|
386
386
|
super(), this.serializer = e;
|
|
@@ -409,8 +409,8 @@ var fe = class extends ue {
|
|
|
409
409
|
value: this.serializer(e.value)
|
|
410
410
|
};
|
|
411
411
|
}
|
|
412
|
-
},
|
|
413
|
-
if (
|
|
412
|
+
}, he = (e) => {
|
|
413
|
+
if (R(e) || typeof e == "string") return e;
|
|
414
414
|
if (typeof e == "boolean") return "" + e;
|
|
415
415
|
if (e instanceof Date) return e.toISOString();
|
|
416
416
|
try {
|
|
@@ -418,25 +418,25 @@ var fe = class extends ue {
|
|
|
418
418
|
} catch {
|
|
419
419
|
return e;
|
|
420
420
|
}
|
|
421
|
-
},
|
|
422
|
-
if (
|
|
421
|
+
}, ge = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?$/, _e = (e) => {
|
|
422
|
+
if (R(e)) return e;
|
|
423
423
|
if (typeof e == "string") {
|
|
424
424
|
if (e === "true") return !0;
|
|
425
425
|
if (e === "false") return !1;
|
|
426
|
-
if (
|
|
427
|
-
if (
|
|
426
|
+
if (ge.test(e)) return new Date(e);
|
|
427
|
+
if (ve(e)) try {
|
|
428
428
|
return JSON.parse(e);
|
|
429
429
|
} catch {}
|
|
430
430
|
return e;
|
|
431
431
|
}
|
|
432
432
|
};
|
|
433
|
-
function
|
|
433
|
+
function ve(e) {
|
|
434
434
|
return e.startsWith("{") && e.endsWith("}") || e.startsWith("[") && e.endsWith("]");
|
|
435
435
|
}
|
|
436
|
-
function
|
|
436
|
+
function R(e) {
|
|
437
437
|
return e == null || typeof e == "bigint" || typeof e == "number" || typeof e == "object" && "buffer" in e;
|
|
438
438
|
}
|
|
439
|
-
var
|
|
439
|
+
var ye = class {
|
|
440
440
|
transformer;
|
|
441
441
|
deserializer;
|
|
442
442
|
skipNodeSet;
|
|
@@ -445,7 +445,7 @@ var N = class {
|
|
|
445
445
|
* Base class for {@link SerializePlugin}, without default options
|
|
446
446
|
*/
|
|
447
447
|
constructor(e, t, n) {
|
|
448
|
-
this.transformer = new
|
|
448
|
+
this.transformer = new me(e), this.deserializer = t, n.length && (this.skipNodeSet = new Set(n), this.ctx = /* @__PURE__ */ new WeakSet());
|
|
449
449
|
}
|
|
450
450
|
transformQuery({ node: e, queryId: t }) {
|
|
451
451
|
return this.skipNodeSet?.has(e.kind) ? (this.ctx?.add(t), e) : this.transformer.transformNode(e);
|
|
@@ -466,7 +466,7 @@ var N = class {
|
|
|
466
466
|
}
|
|
467
467
|
return t;
|
|
468
468
|
}
|
|
469
|
-
},
|
|
469
|
+
}, z = class extends ye {
|
|
470
470
|
/**
|
|
471
471
|
* _**THIS PLUGIN SHOULD BE PLACED AT THE END OF PLUGINS ARRAY !!!**_
|
|
472
472
|
*
|
|
@@ -529,11 +529,11 @@ var N = class {
|
|
|
529
529
|
* ```
|
|
530
530
|
*/
|
|
531
531
|
constructor(e = {}) {
|
|
532
|
-
let { deserializer: t =
|
|
532
|
+
let { deserializer: t = _e, serializer: n = he, skipNodeKind: r = [] } = e;
|
|
533
533
|
super(n, t, r);
|
|
534
534
|
}
|
|
535
535
|
};
|
|
536
|
-
function
|
|
536
|
+
function B(e) {
|
|
537
537
|
return {
|
|
538
538
|
all: e ||= /* @__PURE__ */ new Map(),
|
|
539
539
|
on: function(t, n) {
|
|
@@ -554,7 +554,7 @@ function F(e) {
|
|
|
554
554
|
}
|
|
555
555
|
};
|
|
556
556
|
}
|
|
557
|
-
var be = /* @__PURE__ */
|
|
557
|
+
var be = /* @__PURE__ */ k({
|
|
558
558
|
get: () => Se,
|
|
559
559
|
getByEnabled: () => xe,
|
|
560
560
|
toggleEnable: () => Ce
|
|
@@ -571,24 +571,24 @@ async function Ce(e) {
|
|
|
571
571
|
let { db: t } = await import("./index.js"), n = await t.value.selectFrom("plugin").where("pluginName", "=", e).select("enable").executeTakeFirstOrThrow();
|
|
572
572
|
return t.value.updateTable("plugin").where("pluginName", "=", e).set({ enable: !n.enable }).execute();
|
|
573
573
|
}
|
|
574
|
-
var we = /* @__PURE__ */
|
|
575
|
-
key: () =>
|
|
576
|
-
upsert: () =>
|
|
574
|
+
var we = /* @__PURE__ */ k({
|
|
575
|
+
key: () => V,
|
|
576
|
+
upsert: () => H
|
|
577
577
|
});
|
|
578
|
-
const
|
|
579
|
-
async function
|
|
580
|
-
let { db: t } = await import("./index.js"), n =
|
|
578
|
+
const V = new T("*");
|
|
579
|
+
async function H(e) {
|
|
580
|
+
let { db: t } = await import("./index.js"), n = V.toString([D.content.ContentPage.contentPage.toString(e.contentType), e.id]);
|
|
581
581
|
return await t.value.replaceInto("itemStore").values({
|
|
582
|
-
item:
|
|
582
|
+
item: E.toRaw(e),
|
|
583
583
|
key: n
|
|
584
584
|
}).execute(), n;
|
|
585
585
|
}
|
|
586
|
-
var Te = /* @__PURE__ */
|
|
586
|
+
var Te = /* @__PURE__ */ k({
|
|
587
587
|
moveItem: () => De,
|
|
588
588
|
upsertItem: () => Ee
|
|
589
589
|
});
|
|
590
590
|
async function Ee(e, ...t) {
|
|
591
|
-
let { db: n } = await import("./index.js"), r = await
|
|
591
|
+
let { db: n } = await import("./index.js"), r = await H(e);
|
|
592
592
|
for (let e of t) await n.value.replaceInto("favouriteItem").values({
|
|
593
593
|
addTime: Date.now(),
|
|
594
594
|
itemKey: r,
|
|
@@ -604,21 +604,21 @@ async function De(e, t, ...n) {
|
|
|
604
604
|
belongTo: t
|
|
605
605
|
}).execute();
|
|
606
606
|
}
|
|
607
|
-
var Oe = /* @__PURE__ */
|
|
607
|
+
var Oe = /* @__PURE__ */ k({ upsert: () => ke });
|
|
608
608
|
async function ke(e) {
|
|
609
|
-
let { db: t } = await import("./index.js"), n = await
|
|
609
|
+
let { db: t } = await import("./index.js"), n = await H(e);
|
|
610
610
|
await t.value.replaceInto("history").values({
|
|
611
611
|
itemKey: n,
|
|
612
612
|
timestamp: Date.now(),
|
|
613
|
-
ep:
|
|
613
|
+
ep: E.toRaw(e)
|
|
614
614
|
}).execute();
|
|
615
615
|
}
|
|
616
|
-
var Ae = /* @__PURE__ */
|
|
616
|
+
var Ae = /* @__PURE__ */ k({
|
|
617
617
|
getAll: () => Me,
|
|
618
618
|
key: () => je,
|
|
619
619
|
upsert: () => Ne
|
|
620
620
|
});
|
|
621
|
-
const je = new
|
|
621
|
+
const je = new T();
|
|
622
622
|
async function Me() {
|
|
623
623
|
let { db: e } = await import("./index.js");
|
|
624
624
|
return e.value.selectFrom("subscribe").selectAll().execute();
|
|
@@ -633,9 +633,9 @@ async function Ne(e) {
|
|
|
633
633
|
author: JSON.stringify(e.author)
|
|
634
634
|
}).execute();
|
|
635
635
|
}
|
|
636
|
-
var Pe = /* @__PURE__ */
|
|
636
|
+
var Pe = /* @__PURE__ */ k({ upsert: () => Fe });
|
|
637
637
|
async function Fe(e) {
|
|
638
|
-
let { db: t } = await import("./index.js"), n = await
|
|
638
|
+
let { db: t } = await import("./index.js"), n = await H(e);
|
|
639
639
|
await t.value.replaceInto("recentView").values({
|
|
640
640
|
isViewed: !1,
|
|
641
641
|
itemKey: n,
|
|
@@ -651,13 +651,21 @@ async function Le(e) {
|
|
|
651
651
|
var Re = {
|
|
652
652
|
up: Ie,
|
|
653
653
|
down: Le
|
|
654
|
-
},
|
|
654
|
+
}, U = typeof window < "u" && typeof document < "u";
|
|
655
655
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
656
|
-
var ze = Object.prototype.toString, Be = (e) => ze.call(e) === "[object Object]";
|
|
656
|
+
var ze = Object.prototype.toString, Be = (e) => ze.call(e) === "[object Object]", Ve = () => {};
|
|
657
|
+
function He(...e) {
|
|
658
|
+
if (e.length !== 1) return b(...e);
|
|
659
|
+
let t = e[0];
|
|
660
|
+
return typeof t == "function" ? _(p(() => ({
|
|
661
|
+
get: t,
|
|
662
|
+
set: Ve
|
|
663
|
+
}))) : v(t);
|
|
664
|
+
}
|
|
657
665
|
/**
|
|
658
666
|
* @internal
|
|
659
667
|
*/
|
|
660
|
-
function
|
|
668
|
+
function Ue(e, t) {
|
|
661
669
|
function n(...n) {
|
|
662
670
|
return new Promise((r, i) => {
|
|
663
671
|
Promise.resolve(e(() => t.apply(this, n), {
|
|
@@ -669,46 +677,95 @@ function Ve(e, t) {
|
|
|
669
677
|
}
|
|
670
678
|
return n;
|
|
671
679
|
}
|
|
672
|
-
var
|
|
673
|
-
|
|
680
|
+
var W = (e) => e();
|
|
681
|
+
/**
|
|
682
|
+
* EventFilter that gives extra controls to pause and resume the filter
|
|
683
|
+
*
|
|
684
|
+
* @param extendFilter Extra filter to apply when the PausableFilter is active, default to none
|
|
685
|
+
* @param options Options to configure the filter
|
|
686
|
+
*/
|
|
687
|
+
function We(e = W, t = {}) {
|
|
688
|
+
let { initialState: n = "active" } = t, r = He(n === "active");
|
|
689
|
+
function i() {
|
|
690
|
+
r.value = !1;
|
|
691
|
+
}
|
|
692
|
+
function a() {
|
|
693
|
+
r.value = !0;
|
|
694
|
+
}
|
|
695
|
+
return {
|
|
696
|
+
isActive: _(r),
|
|
697
|
+
pause: i,
|
|
698
|
+
resume: a,
|
|
699
|
+
eventFilter: (...t) => {
|
|
700
|
+
r.value && e(...t);
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
function G(e) {
|
|
674
705
|
return Array.isArray(e) ? e : [e];
|
|
675
706
|
}
|
|
676
|
-
function
|
|
677
|
-
|
|
678
|
-
|
|
707
|
+
function Ge(e) {
|
|
708
|
+
return e || m();
|
|
709
|
+
}
|
|
710
|
+
function Ke(e, t, n = {}) {
|
|
711
|
+
let { eventFilter: r = W, ...i } = n;
|
|
712
|
+
return w(e, Ue(r, t), i);
|
|
713
|
+
}
|
|
714
|
+
/** @deprecated Use Vue's built-in `watch` instead. This function will be removed in future version. */
|
|
715
|
+
function qe(e, t, n = {}) {
|
|
716
|
+
let { eventFilter: r, initialState: i = "active", ...a } = n, { eventFilter: o, pause: s, resume: c, isActive: l } = We(r, { initialState: i });
|
|
717
|
+
return {
|
|
718
|
+
stop: Ke(e, t, {
|
|
719
|
+
...a,
|
|
720
|
+
eventFilter: o
|
|
721
|
+
}),
|
|
722
|
+
pause: s,
|
|
723
|
+
resume: c,
|
|
724
|
+
isActive: l
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Call onMounted() if it's inside a component lifecycle, if not, just call the function
|
|
729
|
+
*
|
|
730
|
+
* @param fn
|
|
731
|
+
* @param sync if set to false, it will run in the nextTick() of Vue
|
|
732
|
+
* @param target
|
|
733
|
+
*/
|
|
734
|
+
function Je(e, t = !0, n) {
|
|
735
|
+
Ge(n) ? g(e, n) : t ? e() : h(e);
|
|
679
736
|
}
|
|
680
737
|
/**
|
|
681
738
|
* Shorthand for watching value with {immediate: true}
|
|
682
739
|
*
|
|
683
740
|
* @see https://vueuse.org/watchImmediate
|
|
684
741
|
*/
|
|
685
|
-
function
|
|
686
|
-
return
|
|
742
|
+
function Ye(e, t, n) {
|
|
743
|
+
return w(e, t, {
|
|
687
744
|
...n,
|
|
688
745
|
immediate: !0
|
|
689
746
|
});
|
|
690
747
|
}
|
|
691
|
-
var
|
|
692
|
-
|
|
748
|
+
var K = U ? window : void 0;
|
|
749
|
+
U && window.document, U && window.navigator, U && window.location;
|
|
693
750
|
/**
|
|
694
751
|
* Get the dom element of a ref of element or Vue component instance
|
|
695
752
|
*
|
|
696
753
|
* @param elRef
|
|
697
754
|
*/
|
|
698
|
-
function
|
|
699
|
-
let t =
|
|
755
|
+
function Xe(e) {
|
|
756
|
+
let t = x(e);
|
|
700
757
|
return t?.$el ?? t;
|
|
701
758
|
}
|
|
702
|
-
function
|
|
759
|
+
function q(...e) {
|
|
703
760
|
let t = (e, t, n, r) => (e.addEventListener(t, n, r), () => e.removeEventListener(t, n, r)), n = f(() => {
|
|
704
|
-
let t =
|
|
761
|
+
let t = G(x(e[0])).filter((e) => e != null);
|
|
705
762
|
return t.every((e) => typeof e != "string") ? t : void 0;
|
|
706
763
|
});
|
|
707
|
-
return
|
|
708
|
-
n.value?.map((e) =>
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
764
|
+
return Ye(() => [
|
|
765
|
+
n.value?.map((e) => Xe(e)) ?? [K].filter((e) => e != null),
|
|
766
|
+
G(x(n.value ? e[1] : e[0])),
|
|
767
|
+
G(C(n.value ? e[2] : e[1])),
|
|
768
|
+
x(n.value ? e[3] : e[2])
|
|
712
769
|
], ([e, n, r, i], a, o) => {
|
|
713
770
|
if (!e?.length || !n?.length || !r?.length) return;
|
|
714
771
|
let s = Be(i) ? { ...i } : i, c = e.flatMap((e) => n.flatMap((n) => r.map((r) => t(e, n, r, s))));
|
|
@@ -717,17 +774,17 @@ function Ke(...e) {
|
|
|
717
774
|
});
|
|
718
775
|
}, { flush: "post" });
|
|
719
776
|
}
|
|
720
|
-
var
|
|
721
|
-
function
|
|
722
|
-
return
|
|
777
|
+
var J = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, Y = "__vueuse_ssr_handlers__", Ze = /* @__PURE__ */ Qe();
|
|
778
|
+
function Qe() {
|
|
779
|
+
return Y in J || (J[Y] = J[Y] || {}), J[Y];
|
|
723
780
|
}
|
|
724
|
-
function
|
|
725
|
-
return
|
|
781
|
+
function $e(e, t) {
|
|
782
|
+
return Ze[e] || t;
|
|
726
783
|
}
|
|
727
|
-
function
|
|
784
|
+
function et(e) {
|
|
728
785
|
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";
|
|
729
786
|
}
|
|
730
|
-
var
|
|
787
|
+
var tt = {
|
|
731
788
|
boolean: {
|
|
732
789
|
read: (e) => e === "true",
|
|
733
790
|
write: (e) => String(e)
|
|
@@ -760,138 +817,168 @@ var Ze = {
|
|
|
760
817
|
read: (e) => new Date(e),
|
|
761
818
|
write: (e) => e.toISOString()
|
|
762
819
|
}
|
|
763
|
-
};
|
|
820
|
+
}, X = "vueuse-storage";
|
|
764
821
|
/**
|
|
765
|
-
* Reactive
|
|
822
|
+
* Reactive LocalStorage/SessionStorage.
|
|
766
823
|
*
|
|
767
|
-
* @see https://vueuse.org/
|
|
768
|
-
* @param key
|
|
769
|
-
* @param initialValue
|
|
770
|
-
* @param storage
|
|
771
|
-
* @param options
|
|
824
|
+
* @see https://vueuse.org/useStorage
|
|
772
825
|
*/
|
|
773
|
-
function
|
|
774
|
-
let { flush: i = "pre", deep: a = !0, listenToStorageChanges: o = !0, writeDefaults: s = !0, mergeDefaults: c = !1, shallow: l, window: u =
|
|
826
|
+
function nt(e, t, n, r = {}) {
|
|
827
|
+
let { flush: i = "pre", deep: a = !0, listenToStorageChanges: o = !0, writeDefaults: s = !0, mergeDefaults: c = !1, shallow: l, window: u = K, eventFilter: d, onError: p = (e) => {
|
|
775
828
|
console.error(e);
|
|
776
|
-
},
|
|
829
|
+
}, initOnMounted: m } = r, g = (l ? y : v)(typeof t == "function" ? t() : t), _ = f(() => x(e));
|
|
777
830
|
if (!n) try {
|
|
778
|
-
n =
|
|
831
|
+
n = $e("getDefaultStorage", () => K?.localStorage)();
|
|
779
832
|
} catch (e) {
|
|
780
|
-
|
|
781
|
-
}
|
|
782
|
-
async function x(t) {
|
|
783
|
-
if (!(!n || t && t.key !== e)) try {
|
|
784
|
-
let r = t ? t.newValue : await n.getItem(e);
|
|
785
|
-
if (r == null) y.value = _, s && _ !== null && await n.setItem(e, await b.write(_));
|
|
786
|
-
else if (c) {
|
|
787
|
-
let e = await b.read(r);
|
|
788
|
-
typeof c == "function" ? y.value = c(e, _) : v === "object" && !Array.isArray(e) ? y.value = {
|
|
789
|
-
..._,
|
|
790
|
-
...e
|
|
791
|
-
} : y.value = e;
|
|
792
|
-
} else y.value = await b.read(r);
|
|
793
|
-
} catch (e) {
|
|
794
|
-
f(e);
|
|
795
|
-
}
|
|
833
|
+
p(e);
|
|
796
834
|
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
835
|
+
if (!n) return g;
|
|
836
|
+
let b = x(t), S = et(b), C = r.serializer ?? tt[S], { pause: T, resume: E } = qe(g, (e) => k(e), {
|
|
837
|
+
flush: i,
|
|
838
|
+
deep: a,
|
|
839
|
+
eventFilter: d
|
|
801
840
|
});
|
|
802
|
-
|
|
841
|
+
w(_, () => j(), { flush: i });
|
|
842
|
+
let D = !1;
|
|
843
|
+
u && o && (n instanceof Storage ? q(u, "storage", (e) => {
|
|
844
|
+
m && !D || j(e);
|
|
845
|
+
}, { passive: !0 }) : q(u, X, (e) => {
|
|
846
|
+
m && !D || M(e);
|
|
847
|
+
})), m ? Je(() => {
|
|
848
|
+
D = !0, j();
|
|
849
|
+
}) : j();
|
|
850
|
+
function O(e, t) {
|
|
851
|
+
if (u) {
|
|
852
|
+
let r = {
|
|
853
|
+
key: _.value,
|
|
854
|
+
oldValue: e,
|
|
855
|
+
newValue: t,
|
|
856
|
+
storageArea: n
|
|
857
|
+
};
|
|
858
|
+
u.dispatchEvent(n instanceof Storage ? new StorageEvent("storage", r) : new CustomEvent(X, { detail: r }));
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
function k(e) {
|
|
803
862
|
try {
|
|
804
|
-
|
|
863
|
+
let t = n.getItem(_.value);
|
|
864
|
+
if (e == null) O(t, null), n.removeItem(_.value);
|
|
865
|
+
else {
|
|
866
|
+
let r = C.write(e);
|
|
867
|
+
t !== r && (n.setItem(_.value, r), O(t, r));
|
|
868
|
+
}
|
|
805
869
|
} catch (e) {
|
|
806
|
-
|
|
870
|
+
p(e);
|
|
807
871
|
}
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
872
|
+
}
|
|
873
|
+
function A(e) {
|
|
874
|
+
let t = e ? e.newValue : n.getItem(_.value);
|
|
875
|
+
if (t == null) return s && b != null && n.setItem(_.value, C.write(b)), b;
|
|
876
|
+
if (!e && c) {
|
|
877
|
+
let e = C.read(t);
|
|
878
|
+
return typeof c == "function" ? c(e, b) : S === "object" && !Array.isArray(e) ? {
|
|
879
|
+
...b,
|
|
880
|
+
...e
|
|
881
|
+
} : e;
|
|
882
|
+
} else if (typeof t != "string") return t;
|
|
883
|
+
else return C.read(t);
|
|
884
|
+
}
|
|
885
|
+
function j(e) {
|
|
886
|
+
if (!(e && e.storageArea !== n)) {
|
|
887
|
+
if (e && e.key == null) {
|
|
888
|
+
g.value = b;
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
if (!(e && e.key !== _.value)) {
|
|
892
|
+
T();
|
|
893
|
+
try {
|
|
894
|
+
let t = C.write(g.value);
|
|
895
|
+
(e === void 0 || e?.newValue !== t) && (g.value = A(e));
|
|
896
|
+
} catch (e) {
|
|
897
|
+
p(e);
|
|
898
|
+
} finally {
|
|
899
|
+
e ? h(E) : E();
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
function M(e) {
|
|
905
|
+
j(e.detail);
|
|
906
|
+
}
|
|
907
|
+
return g;
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Reactive LocalStorage.
|
|
911
|
+
*
|
|
912
|
+
* @see https://vueuse.org/useLocalStorage
|
|
913
|
+
* @param key
|
|
914
|
+
* @param initialValue
|
|
915
|
+
* @param options
|
|
916
|
+
*/
|
|
917
|
+
function rt(e, t, n = {}) {
|
|
918
|
+
let { window: r = K } = n;
|
|
919
|
+
return nt(e, t, r?.localStorage, n);
|
|
920
|
+
}
|
|
921
|
+
var it = /* @__PURE__ */ Object.assign({ "./migrations/1_initial.ts": Re }), Z = d(await oe.load("sqlite:native_store.db"), "core/store/raw"), at = B(), ot = /\b(INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|ALTER)\b/i, st = P(() => {
|
|
922
|
+
console.debug("[db sync] db changed"), at.emit("onChange"), S(ct);
|
|
923
|
+
}, 300), ct = d(await (async () => {
|
|
924
|
+
let e = y(new u({
|
|
925
|
+
dialect: new L({ database: {
|
|
822
926
|
close(e) {
|
|
823
|
-
return
|
|
927
|
+
return Z.close(e);
|
|
824
928
|
},
|
|
825
|
-
path:
|
|
929
|
+
path: Z.path,
|
|
826
930
|
async select(e, t) {
|
|
827
931
|
console.debug("sql!", e, t);
|
|
828
|
-
let n = await
|
|
829
|
-
return
|
|
932
|
+
let n = await Z.select(e, t);
|
|
933
|
+
return ot.test(e) && st(), n;
|
|
830
934
|
},
|
|
831
935
|
async execute(e, t) {
|
|
832
936
|
console.debug("sql!", e, t);
|
|
833
|
-
let n = await
|
|
834
|
-
return
|
|
937
|
+
let n = await Z.execute(e, t);
|
|
938
|
+
return ot.test(e) && st(), n;
|
|
835
939
|
}
|
|
836
940
|
} }),
|
|
837
|
-
plugins: [new c(), new
|
|
941
|
+
plugins: [new c(), new z()]
|
|
838
942
|
}));
|
|
839
943
|
return await new o({
|
|
840
944
|
db: e.value,
|
|
841
945
|
provider: { async getMigrations() {
|
|
842
|
-
return
|
|
946
|
+
return it;
|
|
843
947
|
} }
|
|
844
948
|
}).migrateToLatest(), e;
|
|
845
|
-
})(), "core/store/ins"),
|
|
846
|
-
const
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
return (await q.value.selectFrom("store").selectAll().where("namespace", "=", t).where("name", "=", n).executeTakeFirst())?.item ?? null;
|
|
854
|
-
},
|
|
855
|
-
async setItem(e, t) {
|
|
856
|
-
let [n, r] = J.toJSON(e);
|
|
857
|
-
await q.value.replaceInto("store").values({
|
|
858
|
-
namespace: n,
|
|
859
|
-
name: r,
|
|
860
|
-
item: t
|
|
861
|
-
}).execute();
|
|
862
|
-
}
|
|
863
|
-
});
|
|
864
|
-
var tt = /* @__PURE__ */ Object.assign({
|
|
865
|
-
"./migrations/1_initial.ts": ne,
|
|
866
|
-
"./migrations/2_fix-display_name.ts": ae,
|
|
867
|
-
"./migrations/3_fix_fvi_foreign_key.ts": se
|
|
868
|
-
}), Y = d(await D.load("sqlite:app.db"), "core/db/raw"), nt = F(), X = /\b(INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|ALTER)\b/i, Z = O(() => {
|
|
869
|
-
console.debug("[db sync] db changed"), nt.emit("onChange"), _(Q);
|
|
949
|
+
})(), "core/store/ins"), lt = new T();
|
|
950
|
+
const ut = (e, t, n) => rt(lt.toString([e, x(t)]), n);
|
|
951
|
+
var dt = /* @__PURE__ */ Object.assign({
|
|
952
|
+
"./migrations/1_initial.ts": M,
|
|
953
|
+
"./migrations/2_fix-display_name.ts": ne,
|
|
954
|
+
"./migrations/3_fix_fvi_foreign_key.ts": ae
|
|
955
|
+
}), Q = d(await oe.load("sqlite:app.db"), "core/db/raw"), ft = B(), pt = /\b(INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|ALTER)\b/i, mt = P(() => {
|
|
956
|
+
console.debug("[db sync] db changed"), ft.emit("onChange"), S(ht);
|
|
870
957
|
}, 300);
|
|
871
|
-
const
|
|
872
|
-
let e =
|
|
873
|
-
dialect: new
|
|
958
|
+
const ht = d(await (async () => {
|
|
959
|
+
let e = y(new u({
|
|
960
|
+
dialect: new L({ database: {
|
|
874
961
|
close(e) {
|
|
875
|
-
return
|
|
962
|
+
return Q.close(e);
|
|
876
963
|
},
|
|
877
|
-
path:
|
|
964
|
+
path: Q.path,
|
|
878
965
|
async select(e, t) {
|
|
879
966
|
console.debug("sql!", e, t);
|
|
880
|
-
let n = await
|
|
881
|
-
return
|
|
967
|
+
let n = await Q.select(e, t);
|
|
968
|
+
return pt.test(e) && mt(), n;
|
|
882
969
|
},
|
|
883
970
|
async execute(e, t) {
|
|
884
971
|
console.debug("sql!", e, t);
|
|
885
|
-
let n = await
|
|
886
|
-
return
|
|
972
|
+
let n = await Q.execute(e, t);
|
|
973
|
+
return pt.test(e) && mt(), n;
|
|
887
974
|
}
|
|
888
975
|
} }),
|
|
889
|
-
plugins: [new c(), new
|
|
976
|
+
plugins: [new c(), new z()]
|
|
890
977
|
}));
|
|
891
978
|
return await new o({
|
|
892
979
|
db: e.value,
|
|
893
980
|
provider: { async getMigrations() {
|
|
894
|
-
return
|
|
981
|
+
return dt;
|
|
895
982
|
} }
|
|
896
983
|
}).migrateToLatest(), e;
|
|
897
984
|
})(), "core/db/ins");
|
|
@@ -902,6 +989,6 @@ let $;
|
|
|
902
989
|
}
|
|
903
990
|
e.countDb = t;
|
|
904
991
|
})($ ||= {});
|
|
905
|
-
export { $ as DBUtils, Te as FavouriteDB, Oe as HistoryDB, we as ItemStoreDB, be as PluginArchiveDB, Pe as RecentDB, Ae as SubscribeDB,
|
|
992
|
+
export { $ as DBUtils, Te as FavouriteDB, Oe as HistoryDB, we as ItemStoreDB, be as PluginArchiveDB, Pe as RecentDB, Ae as SubscribeDB, ht as db, ut as useNativeStore };
|
|
906
993
|
|
|
907
994
|
//# sourceMappingURL=index.js.map
|