@delta-comic/db 0.0.7 → 1.3.0

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 CHANGED
@@ -1,16 +1,20 @@
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";
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-Z-VrDWXW.js";
2
2
  import { useGlobalVar as d } from "@delta-comic/utils";
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) => {
3
+ import { defineMutation as f, useMutation as p, useQuery as m, useQueryCache as h } from "@pinia/colada";
4
+ import { SourcedValue as g, Struct as _, uni as v } from "@delta-comic/model";
5
+ import { computed as y, customRef as b, getCurrentInstance as x, nextTick as S, onMounted as C, readonly as w, ref as T, shallowRef as ee, toRef as E, toValue as D, unref as O, watch as k } from "vue";
6
+ //#region \0rolldown/runtime.js
7
+ var A = Object.defineProperty, j = (e, t) => {
6
8
  let n = {};
7
- for (var r in e) O(n, r, {
9
+ for (var r in e) A(n, r, {
8
10
  get: e[r],
9
11
  enumerable: !0
10
12
  });
11
- return t || O(n, Symbol.toStringTag, { value: "Module" }), n;
13
+ return t || A(n, Symbol.toStringTag, { value: "Module" }), n;
12
14
  };
13
- async function A(e) {
15
+ //#endregion
16
+ //#region lib/migrations/1_initial.ts
17
+ async function te(e) {
14
18
  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
19
  createAt: 0,
16
20
  title: "默认收藏夹",
@@ -22,24 +26,28 @@ async function A(e) {
22
26
  "itemKey"
23
27
  ]).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
28
  }
25
- async function j(e) {
29
+ async function ne(e) {
26
30
  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
31
  }
28
- var M = {
29
- up: A,
30
- down: j
32
+ var re = {
33
+ up: te,
34
+ down: ne
31
35
  };
32
- async function ee(e) {
36
+ //#endregion
37
+ //#region lib/migrations/2_fix-display_name.ts
38
+ async function ie(e) {
33
39
  await e.schema.alterTable("plugin").addColumn("displayName", "text").execute();
34
40
  }
35
- async function te(e) {
41
+ async function ae(e) {
36
42
  await e.schema.alterTable("plugin").dropColumn("displayName").execute();
37
43
  }
38
- var ne = {
39
- up: ee,
40
- down: te
44
+ var oe = {
45
+ up: ie,
46
+ down: ae
41
47
  };
42
- async function re(e) {
48
+ //#endregion
49
+ //#region lib/migrations/3_fix_fvi_foreign_key.ts
50
+ async function se(e) {
43
51
  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
52
  "addTime",
45
53
  "belongTo",
@@ -54,7 +62,7 @@ async function re(e) {
54
62
  "itemKey"
55
63
  ])).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
64
  }
57
- async function ie(e) {
65
+ async function ce(e) {
58
66
  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
67
  "addTime",
60
68
  "belongTo",
@@ -69,109 +77,27 @@ async function ie(e) {
69
77
  "itemKey"
70
78
  ])).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
79
  }
72
- var ae = {
73
- up: re,
74
- down: ie
80
+ var le = {
81
+ up: se,
82
+ down: ce
75
83
  };
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 N(e, t = {}, n) {
84
+ async function M(e, t = {}, n) {
92
85
  return window.__TAURI_INTERNALS__.invoke(e, t, n);
93
86
  }
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 oe = class e {
87
+ //#endregion
88
+ //#region ../../node_modules/.pnpm/@tauri-apps+plugin-sql@2.3.2/node_modules/@tauri-apps/plugin-sql/dist-js/index.js
89
+ var ue = class e {
101
90
  constructor(e) {
102
91
  this.path = e;
103
92
  }
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
- */
119
93
  static async load(t) {
120
- return new e(await N("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
- */
94
+ return new e(await M("plugin:sql|load", { db: t }));
95
+ }
138
96
  static get(t) {
139
97
  return new e(t);
140
98
  }
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
- */
173
99
  async execute(e, t) {
174
- let [n, r] = await N("plugin:sql|execute", {
100
+ let [n, r] = await M("plugin:sql|execute", {
175
101
  db: this.path,
176
102
  query: e,
177
103
  values: t ?? []
@@ -181,74 +107,17 @@ var oe = class e {
181
107
  rowsAffected: n
182
108
  };
183
109
  }
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
- */
202
110
  async select(e, t) {
203
- return await N("plugin:sql|select", {
111
+ return await M("plugin:sql|select", {
204
112
  db: this.path,
205
113
  query: e,
206
114
  values: t ?? []
207
115
  });
208
116
  }
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
- */
220
117
  async close(e) {
221
- return await N("plugin:sql|close", { db: e });
118
+ return await M("plugin:sql|close", { db: e });
222
119
  }
223
- };
224
- function P(e, t, { signal: n, edges: r } = {}) {
225
- let i, a = null, o = r != null && r.includes("leading"), s = r == null || r.includes("trailing"), c = () => {
226
- a !== null && (e.apply(i, a), i = void 0, a = null);
227
- }, l = () => {
228
- s && c(), p();
229
- }, u = null, d = () => {
230
- u != null && clearTimeout(u), u = setTimeout(() => {
231
- u = null, l();
232
- }, t);
233
- }, f = () => {
234
- u !== null && (clearTimeout(u), u = null);
235
- }, p = () => {
236
- f(), i = void 0, a = null;
237
- }, m = () => {
238
- c();
239
- }, h = function(...e) {
240
- if (n?.aborted) return;
241
- i = this, a = e;
242
- let t = u == null;
243
- d(), o && t && c();
244
- };
245
- return h.schedule = d, h.cancel = p, h.flush = m, n?.addEventListener("abort", p, { once: !0 }), h;
246
- }
247
- var se = class {
248
- /**
249
- * Base class that implements {@link Dialect}
250
- * @param create function that create {@link Driver}
251
- */
120
+ }, de = class {
252
121
  constructor(e) {
253
122
  this.createDriver = e;
254
123
  }
@@ -262,7 +131,7 @@ var se = class {
262
131
  createIntrospector(e) {
263
132
  return new a(e);
264
133
  }
265
- }, ce = class {
134
+ }, fe = class {
266
135
  promise;
267
136
  resolve;
268
137
  async lock() {
@@ -276,24 +145,19 @@ var se = class {
276
145
  this.promise = void 0, this.resolve = void 0, e?.();
277
146
  }
278
147
  };
279
- async function F(e, n, i, a, o) {
148
+ async function N(e, n, i, a, o) {
280
149
  await i.executeQuery(o(r.createWithChildren([r.createWithSql(`${e} `), t.create(a)]), n()));
281
150
  }
282
- var le = class {
283
- mutex = new ce();
151
+ var pe = class {
152
+ mutex = new fe();
284
153
  conn;
285
154
  savepoint;
286
155
  releaseSavepoint;
287
156
  rollbackToSavepoint;
288
157
  init;
289
- /**
290
- * Base abstract class that implements {@link Driver}
291
- *
292
- * You **MUST** assign `this.conn` in `init` and implement `destroy` method
293
- */
294
158
  constructor(e) {
295
- this.init = () => import("./esm-CzppQRXP.js").then(({ createQueryId: e }) => {
296
- e && (this.savepoint = F.bind(null, "savepoint", e), this.releaseSavepoint = F.bind(null, "release", e), this.rollbackToSavepoint = F.bind(null, "rollback to", e));
159
+ this.init = () => import("./esm-CCEtNFC9.js").then(({ createQueryId: e }) => {
160
+ e && (this.savepoint = N.bind(null, "savepoint", e), this.releaseSavepoint = N.bind(null, "release", e), this.rollbackToSavepoint = N.bind(null, "rollback to", e));
297
161
  }).then(e);
298
162
  }
299
163
  async acquireConnection() {
@@ -312,7 +176,7 @@ var le = class {
312
176
  this.mutex.unlock();
313
177
  }
314
178
  };
315
- function ue(e) {
179
+ function me(e) {
316
180
  return async (t, n, r) => {
317
181
  let i = await e.all(n, r);
318
182
  return t || i.length ? { rows: i } : {
@@ -321,20 +185,22 @@ function ue(e) {
321
185
  };
322
186
  };
323
187
  }
324
- function I(e) {
188
+ function P(e) {
325
189
  return e == null ? void 0 : BigInt(e);
326
190
  }
327
- var de = class extends le {
191
+ //#endregion
192
+ //#region ../../node_modules/.pnpm/kysely-generic-sqlite@1.2.1_kysely@0.28.13/node_modules/kysely-generic-sqlite/dist/index.js
193
+ var he = class extends pe {
328
194
  db;
329
195
  constructor(e, t) {
330
196
  super(async () => {
331
- this.db = await e(), this.conn = new fe(this.db), await t?.(this.conn);
197
+ this.db = await e(), this.conn = new ge(this.db), await t?.(this.conn);
332
198
  });
333
199
  }
334
200
  async destroy() {
335
201
  await this.db?.close();
336
202
  }
337
- }, fe = class {
203
+ }, ge = class {
338
204
  constructor(e) {
339
205
  this.db = e;
340
206
  }
@@ -346,33 +212,24 @@ var de = class extends le {
346
212
  async executeQuery({ parameters: t, query: n, sql: r }) {
347
213
  return await this.db.query(e.is(n), r, t);
348
214
  }
349
- }, pe = class extends se {
350
- /**
351
- * Dialect for generic SQLite that run SQLs in current thread
352
- *
353
- * @param executor function to create {@link IGenericSqlite}
354
- * @param onCreateConnection optional callback after connection created
355
- */
215
+ }, _e = class extends de {
356
216
  constructor(e, t) {
357
- super(() => new de(e, t));
217
+ super(() => new he(e, t));
358
218
  }
359
- }, L = class extends pe {
360
- /**
361
- * SQLite dialect for Tauri, using [official sql plugin](https://github.com/tauri-apps/plugins-workspace/tree/dev/plugins/sql)
362
- */
219
+ }, ve = class extends _e {
363
220
  constructor(e) {
364
221
  let { database: t, onCreateConnection: n } = e;
365
222
  super(async () => {
366
223
  let e = typeof t == "function" ? await t("sqlite:") : t;
367
224
  return {
368
225
  db: e,
369
- query: ue({
226
+ query: me({
370
227
  all: async (t, n) => await e.select(t, n),
371
228
  run: async (t, n) => {
372
229
  let { rowsAffected: r, lastInsertId: i } = await e.execute(t, n);
373
230
  return {
374
- numAffectedRows: I(r),
375
- insertId: I(i)
231
+ numAffectedRows: P(r),
232
+ insertId: P(i)
376
233
  };
377
234
  }
378
235
  }),
@@ -380,7 +237,7 @@ var de = class extends le {
380
237
  };
381
238
  }, n);
382
239
  }
383
- }, me = class extends s {
240
+ }, ye = class extends s {
384
241
  serializer;
385
242
  constructor(e) {
386
243
  super(), this.serializer = e;
@@ -409,8 +266,8 @@ var de = class extends le {
409
266
  value: this.serializer(e.value)
410
267
  };
411
268
  }
412
- }, he = (e) => {
413
- if (R(e) || typeof e == "string") return e;
269
+ }, be = (e) => {
270
+ if (F(e) || typeof e == "string") return e;
414
271
  if (typeof e == "boolean") return "" + e;
415
272
  if (e instanceof Date) return e.toISOString();
416
273
  try {
@@ -418,34 +275,31 @@ var de = class extends le {
418
275
  } catch {
419
276
  return e;
420
277
  }
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;
278
+ }, xe = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?$/, Se = (e) => {
279
+ if (F(e)) return e;
423
280
  if (typeof e == "string") {
424
281
  if (e === "true") return !0;
425
282
  if (e === "false") return !1;
426
- if (ge.test(e)) return new Date(e);
427
- if (ve(e)) try {
283
+ if (xe.test(e)) return new Date(e);
284
+ if (Ce(e)) try {
428
285
  return JSON.parse(e);
429
286
  } catch {}
430
287
  return e;
431
288
  }
432
289
  };
433
- function ve(e) {
290
+ function Ce(e) {
434
291
  return e.startsWith("{") && e.endsWith("}") || e.startsWith("[") && e.endsWith("]");
435
292
  }
436
- function R(e) {
293
+ function F(e) {
437
294
  return e == null || typeof e == "bigint" || typeof e == "number" || typeof e == "object" && "buffer" in e;
438
295
  }
439
- var ye = class {
296
+ var we = class {
440
297
  transformer;
441
298
  deserializer;
442
299
  skipNodeSet;
443
300
  ctx;
444
- /**
445
- * Base class for {@link SerializePlugin}, without default options
446
- */
447
301
  constructor(e, t, n) {
448
- this.transformer = new me(e), this.deserializer = t, n.length && (this.skipNodeSet = new Set(n), this.ctx = /* @__PURE__ */ new WeakSet());
302
+ this.transformer = new ye(e), this.deserializer = t, n.length && (this.skipNodeSet = new Set(n), this.ctx = /* @__PURE__ */ new WeakSet());
449
303
  }
450
304
  transformQuery({ node: e, queryId: t }) {
451
305
  return this.skipNodeSet?.has(e.kind) ? (this.ctx?.add(t), e) : this.transformer.transformNode(e);
@@ -466,206 +320,411 @@ var ye = class {
466
320
  }
467
321
  return t;
468
322
  }
469
- }, z = class extends ye {
470
- /**
471
- * _**THIS PLUGIN SHOULD BE PLACED AT THE END OF PLUGINS ARRAY !!!**_
472
- *
473
- * reference from https://github.com/koskimas/kysely/pull/138
474
- *
475
- * The following example will return an error when using sqlite dialects, unless using this plugin:
476
- * ```ts
477
- * interface TestTable {
478
- * id: Generated<number>
479
- * person: { name: string; age: number; time: Date } | null
480
- * gender: boolean
481
- * blob: Uint8Array | null
482
- * date: Date
483
- * }
484
- *
485
- * interface Database {
486
- * test: TestTable
487
- * }
488
- *
489
- * const db = new Kysely<Database>({
490
- * dialect: new SqliteDialect({
491
- * database: new Database(':memory:'),
492
- * }),
493
- * plugins: [
494
- * new SerializePlugin(),
495
- * ],
496
- * })
497
- *
498
- * await db.insertInto('test').values({
499
- * gender: true,
500
- * person: { name: 'test', age: 2, time: new Date() },
501
- * blob: Uint8Array.from([1, 2, 3]),
502
- * date: new Date(),
503
- * }).execute()
504
- * ```
505
- *
506
- * You can also provide a custom serializer function:
507
- *
508
- * ```ts
509
- * const db = new Kysely<Database>({
510
- * dialect: new SqliteDialect({
511
- * database: new Database(":memory:"),
512
- * }),
513
- * plugins: [
514
- * new SerializePlugin({
515
- * serializer: (value) => {
516
- * if (value instanceof Date) {
517
- * return formatDatetime(value)
518
- * }
519
- *
520
- * if (value !== null && typeof value === 'object') {
521
- * return JSON.stringify(value)
522
- * }
523
- *
524
- * return value
525
- * }
526
- * }),
527
- * ],
528
- * })
529
- * ```
530
- */
323
+ }, Te = class extends we {
531
324
  constructor(e = {}) {
532
- let { deserializer: t = _e, serializer: n = he, skipNodeKind: r = [] } = e;
325
+ let { deserializer: t = Se, serializer: n = be, skipNodeKind: r = [] } = e;
533
326
  super(n, t, r);
534
327
  }
328
+ }, Ee = /* @__PURE__ */ j({
329
+ CommonQueryKey: () => L,
330
+ countDb: () => De,
331
+ withTransition: () => I
332
+ }), I = async (e, t) => {
333
+ if (t) return await e(t);
334
+ {
335
+ let { db: t } = await import("./index.js");
336
+ return await t.transaction().setAccessMode("read write").setIsolationLevel("read committed").execute(e);
337
+ }
535
338
  };
536
- function B(e) {
339
+ async function De(e) {
340
+ return (await e.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow()).count;
341
+ }
342
+ var L = /* @__PURE__ */ function(e) {
343
+ return e.common = "db", e;
344
+ }({}), Oe = /* @__PURE__ */ j({
345
+ QueryKey: () => R,
346
+ useQuery: () => Me,
347
+ useRemove: () => Ae,
348
+ useToggleEnable: () => je,
349
+ useUpsert: () => ke
350
+ }), R = /* @__PURE__ */ function(e) {
351
+ return e.item = "db:plugin:", e;
352
+ }({}), ke = f(() => {
353
+ let e = h(), t = [L.common, R.item], { mutateAsync: n, ...r } = p({
354
+ mutation: async ({ archives: e, trx: t }) => I(async (t) => {
355
+ await t.replaceInto("plugin").values(e.map((e) => ({
356
+ ...e,
357
+ meta: JSON.stringify(e.meta)
358
+ }))).execute();
359
+ }, t),
360
+ onSettled: () => {
361
+ e.invalidateQueries({ key: t });
362
+ },
363
+ key: t
364
+ });
537
365
  return {
538
- all: e ||= /* @__PURE__ */ new Map(),
539
- on: function(t, n) {
540
- var r = e.get(t);
541
- r ? r.push(n) : e.set(t, [n]);
366
+ ...r,
367
+ upsert: n,
368
+ key: t
369
+ };
370
+ }), Ae = f(() => {
371
+ let e = h(), t = [L.common, R.item], { mutateAsync: n, ...r } = p({
372
+ mutation: async ({ keys: e, trx: t }) => I(async (t) => {
373
+ await t.deleteFrom("plugin").where("plugin.pluginName", "is", e).execute();
374
+ }, t),
375
+ onSettled: () => {
376
+ e.invalidateQueries({ key: t });
377
+ },
378
+ key: t
379
+ });
380
+ return {
381
+ ...r,
382
+ remove: n,
383
+ key: t
384
+ };
385
+ }), je = f(() => {
386
+ let e = h(), t = [L.common, R.item], { mutateAsync: n, ...r } = p({
387
+ mutation: async ({ keys: e, trx: t }) => I(async (t) => {
388
+ for (let n of e) {
389
+ let e = await t.selectFrom("plugin").where("pluginName", "=", n).select("enable").executeTakeFirstOrThrow();
390
+ return t.updateTable("plugin").where("pluginName", "=", n).set({ enable: !e.enable }).execute();
391
+ }
392
+ }, t),
393
+ onSettled: () => {
394
+ e.invalidateQueries({ key: t });
542
395
  },
543
- off: function(t, n) {
544
- var r = e.get(t);
545
- r && (n ? r.splice(r.indexOf(n) >>> 0, 1) : e.set(t, []));
396
+ key: t
397
+ });
398
+ return {
399
+ ...r,
400
+ toggle: n,
401
+ key: t
402
+ };
403
+ }), Me = (e, t = [], n) => m({
404
+ query: async () => {
405
+ let { db: t } = await import("./index.js");
406
+ return await e(t.selectFrom("plugin"));
407
+ },
408
+ key: () => [
409
+ L.common,
410
+ R.item,
411
+ e
412
+ ].concat(t),
413
+ staleTime: 15e3,
414
+ refetchOnMount: "always",
415
+ initialData: n,
416
+ initialDataUpdatedAt: 0
417
+ }), Ne = /* @__PURE__ */ j({
418
+ QueryKey: () => B,
419
+ itemKey: () => z,
420
+ useUpsert: () => V
421
+ }), z = new g("*"), B = /* @__PURE__ */ function(e) {
422
+ return e.item = "db:itemStore:", e;
423
+ }({}), V = f(() => {
424
+ let e = h(), t = [L.common, B.item], { mutateAsync: n, ...r } = p({
425
+ mutation: async ({ item: e, trx: t }) => I(async (t) => {
426
+ let n = z.toString([v.content.ContentPage.contentPages.key.toString(e.contentType), e.id]);
427
+ return await t.replaceInto("itemStore").values({
428
+ item: _.toRaw(e),
429
+ key: n
430
+ }).execute(), n;
431
+ }, t),
432
+ onSettled: () => {
433
+ e.invalidateQueries({ key: t });
546
434
  },
547
- emit: function(t, n) {
548
- var r = e.get(t);
549
- r && r.slice().map(function(e) {
550
- e(n);
551
- }), (r = e.get("*")) && r.slice().map(function(e) {
552
- e(t, n);
435
+ key: t
436
+ });
437
+ return {
438
+ ...r,
439
+ upsert: n,
440
+ key: t
441
+ };
442
+ }), Pe = /* @__PURE__ */ j({
443
+ QueryKey: () => H,
444
+ useCreateCard: () => Le,
445
+ useMoveItem: () => Ie,
446
+ useQueryCard: () => ze,
447
+ useQueryItem: () => Re,
448
+ useUpsertItem: () => Fe
449
+ }), H = /* @__PURE__ */ function(e) {
450
+ return e.item = "db:favouriteItem:", e.card = "db:favouriteCard:", e;
451
+ }({}), Fe = f(() => {
452
+ let e = h(), { key: t, upsert: n } = V(), r = [
453
+ L.common,
454
+ H.item,
455
+ ...t
456
+ ], { mutateAsync: i, ...a } = p({
457
+ mutation: async ({ item: e, belongTos: t, trx: r }) => I(async (r) => {
458
+ let i = await n({
459
+ item: e,
460
+ trx: r
553
461
  });
554
- }
462
+ await r.replaceInto("favouriteItem").values(t.map((e) => ({
463
+ addTime: Date.now(),
464
+ itemKey: i,
465
+ belongTo: e
466
+ }))).execute();
467
+ }, r),
468
+ onSettled: () => {
469
+ e.invalidateQueries({ key: r });
470
+ },
471
+ key: r
472
+ });
473
+ return {
474
+ ...a,
475
+ upsert: i,
476
+ key: r
555
477
  };
556
- }
557
- var be = /* @__PURE__ */ k({
558
- get: () => Se,
559
- getByEnabled: () => xe,
560
- toggleEnable: () => Ce
561
- });
562
- async function xe(e) {
563
- let { db: t } = await import("./index.js");
564
- return t.value.selectFrom("plugin").where("enable", "=", e).selectAll().execute();
565
- }
566
- async function Se(e) {
567
- let { db: t } = await import("./index.js");
568
- return t.value.selectFrom("plugin").where("pluginName", "=", e).selectAll().executeTakeFirstOrThrow();
569
- }
570
- async function Ce(e) {
571
- let { db: t } = await import("./index.js"), n = await t.value.selectFrom("plugin").where("pluginName", "=", e).select("enable").executeTakeFirstOrThrow();
572
- return t.value.updateTable("plugin").where("pluginName", "=", e).set({ enable: !n.enable }).execute();
573
- }
574
- var we = /* @__PURE__ */ k({
575
- key: () => V,
576
- upsert: () => H
577
- });
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
- return await t.value.replaceInto("itemStore").values({
582
- item: E.toRaw(e),
583
- key: n
584
- }).execute(), n;
585
- }
586
- var Te = /* @__PURE__ */ k({
587
- moveItem: () => De,
588
- upsertItem: () => Ee
589
- });
590
- async function Ee(e, ...t) {
591
- let { db: n } = await import("./index.js"), r = await H(e);
592
- for (let e of t) await n.value.replaceInto("favouriteItem").values({
593
- addTime: Date.now(),
594
- itemKey: r,
595
- belongTo: e
596
- }).execute();
597
- }
598
- async function De(e, t, ...n) {
599
- let { db: r } = await import("./index.js");
600
- await r.value.deleteFrom("favouriteItem").where("itemKey", "=", e.id).where("belongTo", "=", t).execute();
601
- for (let t of n) await r.value.replaceInto("favouriteItem").values({
602
- addTime: Date.now(),
603
- itemKey: e.id,
604
- belongTo: t
605
- }).execute();
606
- }
607
- var Oe = /* @__PURE__ */ k({ upsert: () => ke });
608
- async function ke(e) {
609
- let { db: t } = await import("./index.js"), n = await H(e);
610
- await t.value.replaceInto("history").values({
611
- itemKey: n,
612
- timestamp: Date.now(),
613
- ep: E.toRaw(e)
614
- }).execute();
615
- }
616
- var Ae = /* @__PURE__ */ k({
617
- getAll: () => Me,
618
- key: () => je,
619
- upsert: () => Ne
620
- });
621
- const je = new T();
622
- async function Me() {
623
- let { db: e } = await import("./index.js");
624
- return e.value.selectFrom("subscribe").selectAll().execute();
625
- }
626
- async function Ne(e) {
627
- let { db: t } = await import("./index.js");
628
- return t.value.replaceInto("subscribe").values({
629
- type: e.type,
630
- itemKey: e.itemKey,
631
- key: e.key,
632
- plugin: e.plugin,
633
- author: JSON.stringify(e.author)
634
- }).execute();
635
- }
636
- var Pe = /* @__PURE__ */ k({ upsert: () => Fe });
637
- async function Fe(e) {
638
- let { db: t } = await import("./index.js"), n = await H(e);
639
- await t.value.replaceInto("recentView").values({
640
- isViewed: !1,
641
- itemKey: n,
642
- timestamp: Date.now()
643
- }).execute();
644
- }
645
- async function Ie(e) {
646
- 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();
647
- }
648
- async function Le(e) {
649
- await e.schema.dropTable("store").ifExists().execute();
650
- }
651
- var Re = {
652
- up: Ie,
653
- down: Le
654
- }, U = typeof window < "u" && typeof document < "u";
478
+ }), Ie = f(() => {
479
+ let e = h(), t = [H.item], { mutateAsync: n, ...r } = p({
480
+ mutation: async ({ item: e, from: t, aims: n, trx: r }) => I(async (r) => {
481
+ await r.deleteFrom("favouriteItem").where("itemKey", "=", e.id).where("belongTo", "=", t).execute(), await r.replaceInto("favouriteItem").values(n.map((t) => ({
482
+ addTime: Date.now(),
483
+ itemKey: e.id,
484
+ belongTo: t
485
+ }))).execute();
486
+ }, r),
487
+ onSettled: () => {
488
+ e.invalidateQueries({ key: t });
489
+ },
490
+ key: t
491
+ });
492
+ return {
493
+ ...r,
494
+ move: n,
495
+ key: t
496
+ };
497
+ }), Le = f(() => {
498
+ let e = h(), t = [H.card, H.item], { mutateAsync: n, ...r } = p({
499
+ mutation: async ({ card: e, trx: t }) => I(async (t) => {
500
+ await t.replaceInto("favouriteCard").values(e).execute();
501
+ }, t),
502
+ onSettled: () => {
503
+ e.invalidateQueries({ key: t });
504
+ },
505
+ key: t
506
+ });
507
+ return {
508
+ ...r,
509
+ createCard: n,
510
+ key: t
511
+ };
512
+ }), Re = (e, t = [], n) => m({
513
+ query: async () => {
514
+ let { db: t } = await import("./index.js");
515
+ return await e(t.selectFrom("favouriteItem"));
516
+ },
517
+ key: () => [
518
+ H.item,
519
+ H.card,
520
+ e
521
+ ].concat(t),
522
+ staleTime: 15e3,
523
+ initialData: n,
524
+ initialDataUpdatedAt: 0
525
+ }), ze = (e, t = [], n) => m({
526
+ query: async () => {
527
+ let { db: t } = await import("./index.js");
528
+ return await e(t.selectFrom("favouriteCard"));
529
+ },
530
+ key: () => [H.card, e].concat(t),
531
+ staleTime: 15e3,
532
+ refetchOnMount: "always",
533
+ initialData: n,
534
+ initialDataUpdatedAt: 0
535
+ }), Be = /* @__PURE__ */ j({
536
+ QueryKey: () => U,
537
+ useQuery: () => Ue,
538
+ useRemove: () => He,
539
+ useUpsert: () => Ve
540
+ }), U = /* @__PURE__ */ function(e) {
541
+ return e.item = "db:history:", e;
542
+ }({}), Ve = f(() => {
543
+ let e = h(), { key: t, upsert: n } = V(), r = [
544
+ L.common,
545
+ U.item,
546
+ ...t
547
+ ], { mutateAsync: i, ...a } = p({
548
+ mutation: async ({ item: e, trx: t }) => I(async (t) => {
549
+ let r = await n({
550
+ item: e,
551
+ trx: t
552
+ });
553
+ await t.replaceInto("history").values({
554
+ itemKey: r,
555
+ timestamp: Date.now(),
556
+ ep: _.toRaw(e)
557
+ }).execute();
558
+ }, t),
559
+ onSettled: () => {
560
+ e.invalidateQueries({ key: r });
561
+ },
562
+ key: r
563
+ });
564
+ return {
565
+ ...a,
566
+ upsert: i,
567
+ key: r
568
+ };
569
+ }), He = f(() => {
570
+ let e = h(), t = [L.common, U.item], { mutateAsync: n, ...r } = p({
571
+ mutation: ({ keys: e, trx: t }) => I(async (t) => {
572
+ await t.deleteFrom("history").where("history.timestamp", "is", e).execute();
573
+ }, t),
574
+ onSettled: () => {
575
+ e.invalidateQueries({ key: t });
576
+ },
577
+ key: t
578
+ });
579
+ return {
580
+ ...r,
581
+ remove: n,
582
+ key: t
583
+ };
584
+ }), Ue = (e, t = [], n) => m({
585
+ query: async () => {
586
+ let { db: t } = await import("./index.js");
587
+ return await e(t.selectFrom("history"));
588
+ },
589
+ key: () => [
590
+ L.common,
591
+ U.item,
592
+ e
593
+ ].concat(t),
594
+ staleTime: 15e3,
595
+ refetchOnMount: "always",
596
+ initialData: n,
597
+ initialDataUpdatedAt: 0
598
+ }), We = /* @__PURE__ */ j({
599
+ QueryKey: () => W,
600
+ key: () => Ge,
601
+ useQuery: () => Je,
602
+ useRemove: () => qe,
603
+ useUpsert: () => Ke
604
+ }), Ge = new g(), W = /* @__PURE__ */ function(e) {
605
+ return e.item = "db:subscribe:", e;
606
+ }({}), Ke = f(() => {
607
+ let e = h(), t = [L.common, W.item], { mutateAsync: n, ...r } = p({
608
+ mutation: async ({ items: e, trx: t }) => I(async (t) => {
609
+ await t.replaceInto("subscribe").values(e.map((e) => ({
610
+ ...e,
611
+ author: JSON.stringify(e.author)
612
+ }))).execute();
613
+ }, t),
614
+ onSettled: () => {
615
+ e.invalidateQueries({ key: t });
616
+ },
617
+ key: t
618
+ });
619
+ return {
620
+ ...r,
621
+ upsert: n,
622
+ key: t
623
+ };
624
+ }), qe = f(() => {
625
+ let e = h(), t = [L.common, W.item], { mutateAsync: n, ...r } = p({
626
+ mutation: async ({ keys: e, trx: t }) => I(async (t) => {
627
+ await t.deleteFrom("subscribe").where("subscribe.key", "is", e).execute();
628
+ }, t),
629
+ onSettled: () => {
630
+ e.invalidateQueries({ key: t });
631
+ },
632
+ key: t
633
+ });
634
+ return {
635
+ ...r,
636
+ remove: n,
637
+ key: t
638
+ };
639
+ }), Je = (e, t = [], n) => m({
640
+ query: async () => {
641
+ let { db: t } = await import("./index.js");
642
+ return await e(t.selectFrom("subscribe"));
643
+ },
644
+ key: () => [
645
+ L.common,
646
+ W.item,
647
+ e
648
+ ].concat(t),
649
+ staleTime: 15e3,
650
+ refetchOnMount: "always",
651
+ initialData: n,
652
+ initialDataUpdatedAt: 0
653
+ }), Ye = /* @__PURE__ */ j({
654
+ QueryKey: () => G,
655
+ useQuery: () => Qe,
656
+ useRemove: () => Ze,
657
+ useUpsert: () => Xe
658
+ }), G = /* @__PURE__ */ function(e) {
659
+ return e.item = "db:recentView:", e;
660
+ }({}), Xe = f(() => {
661
+ let e = h(), { key: t, upsert: n } = V(), r = [
662
+ L.common,
663
+ G.item,
664
+ ...t
665
+ ], { mutateAsync: i, ...a } = p({
666
+ mutation: async ({ item: e, trx: t }) => I(async (t) => {
667
+ let r = await n({
668
+ item: e,
669
+ trx: t
670
+ });
671
+ await t.replaceInto("recentView").values({
672
+ isViewed: !1,
673
+ itemKey: r,
674
+ timestamp: Date.now()
675
+ }).execute();
676
+ }, t),
677
+ onSettled: () => {
678
+ e.invalidateQueries({ key: r });
679
+ },
680
+ key: r
681
+ });
682
+ return {
683
+ ...a,
684
+ upsert: i,
685
+ key: r
686
+ };
687
+ }), Ze = f(() => {
688
+ let e = h(), t = [L.common, G.item], { mutateAsync: n, ...r } = p({
689
+ mutation: async ({ items: e, trx: t }) => I(async (t) => {
690
+ await t.deleteFrom("recentView").where("recentView.timestamp", "is", e).execute();
691
+ }, t),
692
+ onSettled: () => {
693
+ e.invalidateQueries({ key: t });
694
+ },
695
+ key: t
696
+ });
697
+ return {
698
+ ...r,
699
+ remove: n,
700
+ key: t
701
+ };
702
+ }), Qe = (e, t = [], n) => m({
703
+ query: async () => {
704
+ let { db: t } = await import("./index.js");
705
+ return await e(t.selectFrom("recentView"));
706
+ },
707
+ key: () => [
708
+ L.common,
709
+ G.item,
710
+ e
711
+ ].concat(t),
712
+ staleTime: 15e3,
713
+ refetchOnMount: "always",
714
+ initialData: n,
715
+ initialDataUpdatedAt: 0
716
+ }), K = typeof window < "u" && typeof document < "u";
655
717
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
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);
718
+ var $e = Object.prototype.toString, et = (e) => $e.call(e) === "[object Object]", tt = () => {};
719
+ function nt(...e) {
720
+ if (e.length !== 1) return E(...e);
659
721
  let t = e[0];
660
- return typeof t == "function" ? _(p(() => ({
722
+ return typeof t == "function" ? w(b(() => ({
661
723
  get: t,
662
- set: Ve
663
- }))) : v(t);
724
+ set: tt
725
+ }))) : T(t);
664
726
  }
665
- /**
666
- * @internal
667
- */
668
- function Ue(e, t) {
727
+ function rt(e, t) {
669
728
  function n(...n) {
670
729
  return new Promise((r, i) => {
671
730
  Promise.resolve(e(() => t.apply(this, n), {
@@ -677,15 +736,9 @@ function Ue(e, t) {
677
736
  }
678
737
  return n;
679
738
  }
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");
739
+ var q = (e) => e();
740
+ function it(e = q, t = {}) {
741
+ let { initialState: n = "active" } = t, r = nt(n === "active");
689
742
  function i() {
690
743
  r.value = !1;
691
744
  }
@@ -693,7 +746,7 @@ function We(e = W, t = {}) {
693
746
  r.value = !0;
694
747
  }
695
748
  return {
696
- isActive: _(r),
749
+ isActive: w(r),
697
750
  pause: i,
698
751
  resume: a,
699
752
  eventFilter: (...t) => {
@@ -701,21 +754,20 @@ function We(e = W, t = {}) {
701
754
  }
702
755
  };
703
756
  }
704
- function G(e) {
757
+ function J(e) {
705
758
  return Array.isArray(e) ? e : [e];
706
759
  }
707
- function Ge(e) {
708
- return e || m();
760
+ function at(e) {
761
+ return e || x();
709
762
  }
710
- function Ke(e, t, n = {}) {
711
- let { eventFilter: r = W, ...i } = n;
712
- return w(e, Ue(r, t), i);
763
+ function ot(e, t, n = {}) {
764
+ let { eventFilter: r = q, ...i } = n;
765
+ return k(e, rt(r, t), i);
713
766
  }
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 });
767
+ function st(e, t, n = {}) {
768
+ let { eventFilter: r, initialState: i = "active", ...a } = n, { eventFilter: o, pause: s, resume: c, isActive: l } = it(r, { initialState: i });
717
769
  return {
718
- stop: Ke(e, t, {
770
+ stop: ot(e, t, {
719
771
  ...a,
720
772
  eventFilter: o
721
773
  }),
@@ -724,67 +776,52 @@ function qe(e, t, n = {}) {
724
776
  isActive: l
725
777
  };
726
778
  }
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);
779
+ function ct(e, t = !0, n) {
780
+ at(n) ? C(e, n) : t ? e() : S(e);
736
781
  }
737
- /**
738
- * Shorthand for watching value with {immediate: true}
739
- *
740
- * @see https://vueuse.org/watchImmediate
741
- */
742
- function Ye(e, t, n) {
743
- return w(e, t, {
782
+ function lt(e, t, n) {
783
+ return k(e, t, {
744
784
  ...n,
745
785
  immediate: !0
746
786
  });
747
787
  }
748
- var K = U ? window : void 0;
749
- U && window.document, U && window.navigator, U && window.location;
750
- /**
751
- * Get the dom element of a ref of element or Vue component instance
752
- *
753
- * @param elRef
754
- */
755
- function Xe(e) {
756
- let t = x(e);
788
+ //#endregion
789
+ //#region ../../node_modules/.pnpm/@vueuse+core@14.2.1_vue@3.5.30_typescript@5.9.3_/node_modules/@vueuse/core/dist/index.js
790
+ var Y = K ? window : void 0;
791
+ K && window.document, K && window.navigator, K && window.location;
792
+ function ut(e) {
793
+ let t = D(e);
757
794
  return t?.$el ?? t;
758
795
  }
759
- function q(...e) {
760
- let t = (e, t, n, r) => (e.addEventListener(t, n, r), () => e.removeEventListener(t, n, r)), n = f(() => {
761
- let t = G(x(e[0])).filter((e) => e != null);
796
+ function X(...e) {
797
+ let t = (e, t, n, r) => (e.addEventListener(t, n, r), () => e.removeEventListener(t, n, r)), n = y(() => {
798
+ let t = J(D(e[0])).filter((e) => e != null);
762
799
  return t.every((e) => typeof e != "string") ? t : void 0;
763
800
  });
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])
801
+ return lt(() => [
802
+ n.value?.map((e) => ut(e)) ?? [Y].filter((e) => e != null),
803
+ J(D(n.value ? e[1] : e[0])),
804
+ J(O(n.value ? e[2] : e[1])),
805
+ D(n.value ? e[3] : e[2])
769
806
  ], ([e, n, r, i], a, o) => {
770
807
  if (!e?.length || !n?.length || !r?.length) return;
771
- let s = Be(i) ? { ...i } : i, c = e.flatMap((e) => n.flatMap((n) => r.map((r) => t(e, n, r, s))));
808
+ let s = et(i) ? { ...i } : i, c = e.flatMap((e) => n.flatMap((n) => r.map((r) => t(e, n, r, s))));
772
809
  o(() => {
773
810
  c.forEach((e) => e());
774
811
  });
775
812
  }, { flush: "post" });
776
813
  }
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];
814
+ var Z = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, Q = "__vueuse_ssr_handlers__", dt = /* @__PURE__ */ ft();
815
+ function ft() {
816
+ return Q in Z || (Z[Q] = Z[Q] || {}), Z[Q];
780
817
  }
781
- function $e(e, t) {
782
- return Ze[e] || t;
818
+ function pt(e, t) {
819
+ return dt[e] || t;
783
820
  }
784
- function et(e) {
821
+ function mt(e) {
785
822
  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";
786
823
  }
787
- var tt = {
824
+ var ht = {
788
825
  boolean: {
789
826
  read: (e) => e === "true",
790
827
  write: (e) => String(e)
@@ -817,178 +854,115 @@ var tt = {
817
854
  read: (e) => new Date(e),
818
855
  write: (e) => e.toISOString()
819
856
  }
820
- }, X = "vueuse-storage";
821
- /**
822
- * Reactive LocalStorage/SessionStorage.
823
- *
824
- * @see https://vueuse.org/useStorage
825
- */
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) => {
857
+ }, $ = "vueuse-storage";
858
+ function gt(e, t, n, r = {}) {
859
+ let { flush: i = "pre", deep: a = !0, listenToStorageChanges: o = !0, writeDefaults: s = !0, mergeDefaults: c = !1, shallow: l, window: u = Y, eventFilter: d, onError: f = (e) => {
828
860
  console.error(e);
829
- }, initOnMounted: m } = r, g = (l ? y : v)(typeof t == "function" ? t() : t), _ = f(() => x(e));
861
+ }, initOnMounted: p } = r, m = (l ? ee : T)(typeof t == "function" ? t() : t), h = y(() => D(e));
830
862
  if (!n) try {
831
- n = $e("getDefaultStorage", () => K?.localStorage)();
863
+ n = pt("getDefaultStorage", () => Y?.localStorage)();
832
864
  } catch (e) {
833
- p(e);
865
+ f(e);
834
866
  }
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), {
867
+ if (!n) return m;
868
+ let g = D(t), _ = mt(g), v = r.serializer ?? ht[_], { pause: b, resume: x } = st(m, (e) => E(e), {
837
869
  flush: i,
838
870
  deep: a,
839
871
  eventFilter: d
840
872
  });
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) {
873
+ k(h, () => A(), { flush: i });
874
+ let C = !1;
875
+ u && o && (n instanceof Storage ? X(u, "storage", (e) => {
876
+ p && !C || A(e);
877
+ }, { passive: !0 }) : X(u, $, (e) => {
878
+ p && !C || j(e);
879
+ })), p ? ct(() => {
880
+ C = !0, A();
881
+ }) : A();
882
+ function w(e, t) {
851
883
  if (u) {
852
884
  let r = {
853
- key: _.value,
885
+ key: h.value,
854
886
  oldValue: e,
855
887
  newValue: t,
856
888
  storageArea: n
857
889
  };
858
- u.dispatchEvent(n instanceof Storage ? new StorageEvent("storage", r) : new CustomEvent(X, { detail: r }));
890
+ u.dispatchEvent(n instanceof Storage ? new StorageEvent("storage", r) : new CustomEvent($, { detail: r }));
859
891
  }
860
892
  }
861
- function k(e) {
893
+ function E(e) {
862
894
  try {
863
- let t = n.getItem(_.value);
864
- if (e == null) O(t, null), n.removeItem(_.value);
895
+ let t = n.getItem(h.value);
896
+ if (e == null) w(t, null), n.removeItem(h.value);
865
897
  else {
866
- let r = C.write(e);
867
- t !== r && (n.setItem(_.value, r), O(t, r));
898
+ let r = v.write(e);
899
+ t !== r && (n.setItem(h.value, r), w(t, r));
868
900
  }
869
901
  } catch (e) {
870
- p(e);
902
+ f(e);
871
903
  }
872
904
  }
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;
905
+ function O(e) {
906
+ let t = e ? e.newValue : n.getItem(h.value);
907
+ if (t == null) return s && g != null && n.setItem(h.value, v.write(g)), g;
876
908
  if (!e && c) {
877
- let e = C.read(t);
878
- return typeof c == "function" ? c(e, b) : S === "object" && !Array.isArray(e) ? {
879
- ...b,
909
+ let e = v.read(t);
910
+ return typeof c == "function" ? c(e, g) : _ === "object" && !Array.isArray(e) ? {
911
+ ...g,
880
912
  ...e
881
913
  } : e;
882
914
  } else if (typeof t != "string") return t;
883
- else return C.read(t);
915
+ else return v.read(t);
884
916
  }
885
- function j(e) {
917
+ function A(e) {
886
918
  if (!(e && e.storageArea !== n)) {
887
919
  if (e && e.key == null) {
888
- g.value = b;
920
+ m.value = g;
889
921
  return;
890
922
  }
891
- if (!(e && e.key !== _.value)) {
892
- T();
923
+ if (!(e && e.key !== h.value)) {
924
+ b();
893
925
  try {
894
- let t = C.write(g.value);
895
- (e === void 0 || e?.newValue !== t) && (g.value = A(e));
926
+ let t = v.write(m.value);
927
+ (e === void 0 || e?.newValue !== t) && (m.value = O(e));
896
928
  } catch (e) {
897
- p(e);
929
+ f(e);
898
930
  } finally {
899
- e ? h(E) : E();
931
+ e ? S(x) : x();
900
932
  }
901
933
  }
902
934
  }
903
935
  }
904
- function M(e) {
905
- j(e.detail);
936
+ function j(e) {
937
+ A(e.detail);
906
938
  }
907
- return g;
939
+ return m;
908
940
  }
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);
941
+ function _t(e, t, n = {}) {
942
+ let { window: r = Y } = n;
943
+ return gt(e, t, r?.localStorage, n);
920
944
  }
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: {
926
- close(e) {
927
- return Z.close(e);
928
- },
929
- path: Z.path,
930
- async select(e, t) {
931
- console.debug("sql!", e, t);
932
- let n = await Z.select(e, t);
933
- return ot.test(e) && st(), n;
934
- },
935
- async execute(e, t) {
936
- console.debug("sql!", e, t);
937
- let n = await Z.execute(e, t);
938
- return ot.test(e) && st(), n;
939
- }
940
- } }),
941
- plugins: [new c(), new z()]
942
- }));
943
- return await new o({
944
- db: e.value,
945
- provider: { async getMigrations() {
946
- return it;
947
- } }
948
- }).migrateToLatest(), e;
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);
957
- }, 300);
958
- const ht = d(await (async () => {
959
- let e = y(new u({
960
- dialect: new L({ database: {
961
- close(e) {
962
- return Q.close(e);
963
- },
964
- path: Q.path,
965
- async select(e, t) {
966
- console.debug("sql!", e, t);
967
- let n = await Q.select(e, t);
968
- return pt.test(e) && mt(), n;
969
- },
970
- async execute(e, t) {
971
- console.debug("sql!", e, t);
972
- let n = await Q.execute(e, t);
973
- return pt.test(e) && mt(), n;
974
- }
975
- } }),
976
- plugins: [new c(), new z()]
977
- }));
945
+ //#endregion
946
+ //#region lib/nativeStore/index.ts
947
+ var vt = new g(), yt = (e, t, n) => _t(vt.toString([e, D(t)]), n), bt = /* @__PURE__ */ Object.assign({
948
+ "./migrations/1_initial.ts": re,
949
+ "./migrations/2_fix-display_name.ts": oe,
950
+ "./migrations/3_fix_fvi_foreign_key.ts": le
951
+ });
952
+ console.log("[db] loading");
953
+ var xt = d(await ue.load("sqlite:app.db"), "core/db/raw"), St = d(await (async () => {
954
+ let e = new u({
955
+ dialect: new ve({ database: xt }),
956
+ plugins: [new c(), new Te()]
957
+ });
978
958
  return await new o({
979
- db: e.value,
959
+ db: e,
980
960
  provider: { async getMigrations() {
981
- return dt;
961
+ return bt;
982
962
  } }
983
963
  }).migrateToLatest(), e;
984
964
  })(), "core/db/ins");
985
- let $;
986
- (function(e) {
987
- async function t(e) {
988
- return (await e.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow()).count;
989
- }
990
- e.countDb = t;
991
- })($ ||= {});
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 };
965
+ //#endregion
966
+ export { Ee as DBUtils, Pe as FavouriteDB, Be as HistoryDB, Ne as ItemStoreDB, Oe as PluginArchiveDB, Ye as RecentDB, We as SubscribeDB, St as db, yt as useNativeStore };
993
967
 
994
968
  //# sourceMappingURL=index.js.map