@delta-comic/db 0.0.8 → 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-YHRn16YB.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,25 +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
- async function N(e, t = {}, n) {
84
+ async function M(e, t = {}, n) {
77
85
  return window.__TAURI_INTERNALS__.invoke(e, t, n);
78
86
  }
79
- 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 {
80
90
  constructor(e) {
81
91
  this.path = e;
82
92
  }
83
93
  static async load(t) {
84
- return new e(await N("plugin:sql|load", { db: t }));
94
+ return new e(await M("plugin:sql|load", { db: t }));
85
95
  }
86
96
  static get(t) {
87
97
  return new e(t);
88
98
  }
89
99
  async execute(e, t) {
90
- let [n, r] = await N("plugin:sql|execute", {
100
+ let [n, r] = await M("plugin:sql|execute", {
91
101
  db: this.path,
92
102
  query: e,
93
103
  values: t ?? []
@@ -98,40 +108,16 @@ var oe = class e {
98
108
  };
99
109
  }
100
110
  async select(e, t) {
101
- return await N("plugin:sql|select", {
111
+ return await M("plugin:sql|select", {
102
112
  db: this.path,
103
113
  query: e,
104
114
  values: t ?? []
105
115
  });
106
116
  }
107
117
  async close(e) {
108
- return await N("plugin:sql|close", { db: e });
118
+ return await M("plugin:sql|close", { db: e });
109
119
  }
110
- };
111
- function P(e, t, { signal: n, edges: r } = {}) {
112
- let i, a = null, o = r != null && r.includes("leading"), s = r == null || r.includes("trailing"), c = () => {
113
- a !== null && (e.apply(i, a), i = void 0, a = null);
114
- }, l = () => {
115
- s && c(), p();
116
- }, u = null, d = () => {
117
- u != null && clearTimeout(u), u = setTimeout(() => {
118
- u = null, l();
119
- }, t);
120
- }, f = () => {
121
- u !== null && (clearTimeout(u), u = null);
122
- }, p = () => {
123
- f(), i = void 0, a = null;
124
- }, m = () => {
125
- c();
126
- }, h = function(...e) {
127
- if (n?.aborted) return;
128
- i = this, a = e;
129
- let t = u == null;
130
- d(), o && t && c();
131
- };
132
- return h.schedule = d, h.cancel = p, h.flush = m, n?.addEventListener("abort", p, { once: !0 }), h;
133
- }
134
- var se = class {
120
+ }, de = class {
135
121
  constructor(e) {
136
122
  this.createDriver = e;
137
123
  }
@@ -145,7 +131,7 @@ var se = class {
145
131
  createIntrospector(e) {
146
132
  return new a(e);
147
133
  }
148
- }, ce = class {
134
+ }, fe = class {
149
135
  promise;
150
136
  resolve;
151
137
  async lock() {
@@ -159,19 +145,19 @@ var se = class {
159
145
  this.promise = void 0, this.resolve = void 0, e?.();
160
146
  }
161
147
  };
162
- async function F(e, n, i, a, o) {
148
+ async function N(e, n, i, a, o) {
163
149
  await i.executeQuery(o(r.createWithChildren([r.createWithSql(`${e} `), t.create(a)]), n()));
164
150
  }
165
- var le = class {
166
- mutex = new ce();
151
+ var pe = class {
152
+ mutex = new fe();
167
153
  conn;
168
154
  savepoint;
169
155
  releaseSavepoint;
170
156
  rollbackToSavepoint;
171
157
  init;
172
158
  constructor(e) {
173
- this.init = () => import("./esm-BGcGAQ5-.js").then(({ createQueryId: e }) => {
174
- 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));
175
161
  }).then(e);
176
162
  }
177
163
  async acquireConnection() {
@@ -190,7 +176,7 @@ var le = class {
190
176
  this.mutex.unlock();
191
177
  }
192
178
  };
193
- function ue(e) {
179
+ function me(e) {
194
180
  return async (t, n, r) => {
195
181
  let i = await e.all(n, r);
196
182
  return t || i.length ? { rows: i } : {
@@ -199,20 +185,22 @@ function ue(e) {
199
185
  };
200
186
  };
201
187
  }
202
- function I(e) {
188
+ function P(e) {
203
189
  return e == null ? void 0 : BigInt(e);
204
190
  }
205
- 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 {
206
194
  db;
207
195
  constructor(e, t) {
208
196
  super(async () => {
209
- 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);
210
198
  });
211
199
  }
212
200
  async destroy() {
213
201
  await this.db?.close();
214
202
  }
215
- }, fe = class {
203
+ }, ge = class {
216
204
  constructor(e) {
217
205
  this.db = e;
218
206
  }
@@ -224,24 +212,24 @@ var de = class extends le {
224
212
  async executeQuery({ parameters: t, query: n, sql: r }) {
225
213
  return await this.db.query(e.is(n), r, t);
226
214
  }
227
- }, pe = class extends se {
215
+ }, _e = class extends de {
228
216
  constructor(e, t) {
229
- super(() => new de(e, t));
217
+ super(() => new he(e, t));
230
218
  }
231
- }, L = class extends pe {
219
+ }, ve = class extends _e {
232
220
  constructor(e) {
233
221
  let { database: t, onCreateConnection: n } = e;
234
222
  super(async () => {
235
223
  let e = typeof t == "function" ? await t("sqlite:") : t;
236
224
  return {
237
225
  db: e,
238
- query: ue({
226
+ query: me({
239
227
  all: async (t, n) => await e.select(t, n),
240
228
  run: async (t, n) => {
241
229
  let { rowsAffected: r, lastInsertId: i } = await e.execute(t, n);
242
230
  return {
243
- numAffectedRows: I(r),
244
- insertId: I(i)
231
+ numAffectedRows: P(r),
232
+ insertId: P(i)
245
233
  };
246
234
  }
247
235
  }),
@@ -249,7 +237,7 @@ var de = class extends le {
249
237
  };
250
238
  }, n);
251
239
  }
252
- }, me = class extends s {
240
+ }, ye = class extends s {
253
241
  serializer;
254
242
  constructor(e) {
255
243
  super(), this.serializer = e;
@@ -278,8 +266,8 @@ var de = class extends le {
278
266
  value: this.serializer(e.value)
279
267
  };
280
268
  }
281
- }, he = (e) => {
282
- if (R(e) || typeof e == "string") return e;
269
+ }, be = (e) => {
270
+ if (F(e) || typeof e == "string") return e;
283
271
  if (typeof e == "boolean") return "" + e;
284
272
  if (e instanceof Date) return e.toISOString();
285
273
  try {
@@ -287,31 +275,31 @@ var de = class extends le {
287
275
  } catch {
288
276
  return e;
289
277
  }
290
- }, ge = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?$/, _e = (e) => {
291
- 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;
292
280
  if (typeof e == "string") {
293
281
  if (e === "true") return !0;
294
282
  if (e === "false") return !1;
295
- if (ge.test(e)) return new Date(e);
296
- if (ve(e)) try {
283
+ if (xe.test(e)) return new Date(e);
284
+ if (Ce(e)) try {
297
285
  return JSON.parse(e);
298
286
  } catch {}
299
287
  return e;
300
288
  }
301
289
  };
302
- function ve(e) {
290
+ function Ce(e) {
303
291
  return e.startsWith("{") && e.endsWith("}") || e.startsWith("[") && e.endsWith("]");
304
292
  }
305
- function R(e) {
293
+ function F(e) {
306
294
  return e == null || typeof e == "bigint" || typeof e == "number" || typeof e == "object" && "buffer" in e;
307
295
  }
308
- var ye = class {
296
+ var we = class {
309
297
  transformer;
310
298
  deserializer;
311
299
  skipNodeSet;
312
300
  ctx;
313
301
  constructor(e, t, n) {
314
- this.transformer = new me(e), this.deserializer = t, n.length && (this.skipNodeSet = new Set(n), this.ctx = new WeakSet());
302
+ this.transformer = new ye(e), this.deserializer = t, n.length && (this.skipNodeSet = new Set(n), this.ctx = /* @__PURE__ */ new WeakSet());
315
303
  }
316
304
  transformQuery({ node: e, queryId: t }) {
317
305
  return this.skipNodeSet?.has(e.kind) ? (this.ctx?.add(t), e) : this.transformer.transformNode(e);
@@ -332,142 +320,411 @@ var ye = class {
332
320
  }
333
321
  return t;
334
322
  }
335
- }, z = class extends ye {
323
+ }, Te = class extends we {
336
324
  constructor(e = {}) {
337
- let { deserializer: t = _e, serializer: n = he, skipNodeKind: r = [] } = e;
325
+ let { deserializer: t = Se, serializer: n = be, skipNodeKind: r = [] } = e;
338
326
  super(n, t, r);
339
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
+ }
340
338
  };
341
- 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
+ });
342
365
  return {
343
- all: e ||= new Map(),
344
- on: function(t, n) {
345
- var r = e.get(t);
346
- 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 });
347
377
  },
348
- off: function(t, n) {
349
- var r = e.get(t);
350
- r && (n ? r.splice(r.indexOf(n) >>> 0, 1) : e.set(t, []));
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 });
395
+ },
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 });
351
434
  },
352
- emit: function(t, n) {
353
- var r = e.get(t);
354
- r && r.slice().map(function(e) {
355
- e(n);
356
- }), (r = e.get("*")) && r.slice().map(function(e) {
357
- 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
358
461
  });
359
- }
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
360
477
  };
361
- }
362
- var be = k({
363
- get: () => Se,
364
- getByEnabled: () => xe,
365
- toggleEnable: () => Ce
366
- });
367
- async function xe(e) {
368
- let { db: t } = await import("./index.js");
369
- return t.value.selectFrom("plugin").where("enable", "=", e).selectAll().execute();
370
- }
371
- async function Se(e) {
372
- let { db: t } = await import("./index.js");
373
- return t.value.selectFrom("plugin").where("pluginName", "=", e).selectAll().executeTakeFirstOrThrow();
374
- }
375
- async function Ce(e) {
376
- let { db: t } = await import("./index.js"), n = await t.value.selectFrom("plugin").where("pluginName", "=", e).select("enable").executeTakeFirstOrThrow();
377
- return t.value.updateTable("plugin").where("pluginName", "=", e).set({ enable: !n.enable }).execute();
378
- }
379
- var we = k({
380
- key: () => V,
381
- upsert: () => H
382
- });
383
- const V = new T("*");
384
- async function H(e) {
385
- let { db: t } = await import("./index.js"), n = V.toString([D.content.ContentPage.contentPage.toString(e.contentType), e.id]);
386
- return await t.value.replaceInto("itemStore").values({
387
- item: E.toRaw(e),
388
- key: n
389
- }).execute(), n;
390
- }
391
- var Te = k({
392
- moveItem: () => De,
393
- upsertItem: () => Ee
394
- });
395
- async function Ee(e, ...t) {
396
- let { db: n } = await import("./index.js"), r = await H(e);
397
- for (let e of t) await n.value.replaceInto("favouriteItem").values({
398
- addTime: Date.now(),
399
- itemKey: r,
400
- belongTo: e
401
- }).execute();
402
- }
403
- async function De(e, t, ...n) {
404
- let { db: r } = await import("./index.js");
405
- await r.value.deleteFrom("favouriteItem").where("itemKey", "=", e.id).where("belongTo", "=", t).execute();
406
- for (let t of n) await r.value.replaceInto("favouriteItem").values({
407
- addTime: Date.now(),
408
- itemKey: e.id,
409
- belongTo: t
410
- }).execute();
411
- }
412
- var Oe = k({ upsert: () => ke });
413
- async function ke(e) {
414
- let { db: t } = await import("./index.js"), n = await H(e);
415
- await t.value.replaceInto("history").values({
416
- itemKey: n,
417
- timestamp: Date.now(),
418
- ep: E.toRaw(e)
419
- }).execute();
420
- }
421
- var Ae = k({
422
- getAll: () => Me,
423
- key: () => je,
424
- upsert: () => Ne
425
- });
426
- const je = new T();
427
- async function Me() {
428
- let { db: e } = await import("./index.js");
429
- return e.value.selectFrom("subscribe").selectAll().execute();
430
- }
431
- async function Ne(e) {
432
- let { db: t } = await import("./index.js");
433
- return t.value.replaceInto("subscribe").values({
434
- type: e.type,
435
- itemKey: e.itemKey,
436
- key: e.key,
437
- plugin: e.plugin,
438
- author: JSON.stringify(e.author)
439
- }).execute();
440
- }
441
- var Pe = k({ upsert: () => Fe });
442
- async function Fe(e) {
443
- let { db: t } = await import("./index.js"), n = await H(e);
444
- await t.value.replaceInto("recentView").values({
445
- isViewed: !1,
446
- itemKey: n,
447
- timestamp: Date.now()
448
- }).execute();
449
- }
450
- async function Ie(e) {
451
- 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();
452
- }
453
- async function Le(e) {
454
- await e.schema.dropTable("store").ifExists().execute();
455
- }
456
- var Re = {
457
- up: Ie,
458
- down: Le
459
- }, 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";
460
717
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
461
- var ze = Object.prototype.toString, Be = (e) => ze.call(e) === "[object Object]", Ve = () => {};
462
- function He(...e) {
463
- 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);
464
721
  let t = e[0];
465
- return typeof t == "function" ? _(p(() => ({
722
+ return typeof t == "function" ? w(b(() => ({
466
723
  get: t,
467
- set: Ve
468
- }))) : v(t);
724
+ set: tt
725
+ }))) : T(t);
469
726
  }
470
- function Ue(e, t) {
727
+ function rt(e, t) {
471
728
  function n(...n) {
472
729
  return new Promise((r, i) => {
473
730
  Promise.resolve(e(() => t.apply(this, n), {
@@ -479,9 +736,9 @@ function Ue(e, t) {
479
736
  }
480
737
  return n;
481
738
  }
482
- var W = (e) => e();
483
- function We(e = W, t = {}) {
484
- 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");
485
742
  function i() {
486
743
  r.value = !1;
487
744
  }
@@ -489,7 +746,7 @@ function We(e = W, t = {}) {
489
746
  r.value = !0;
490
747
  }
491
748
  return {
492
- isActive: _(r),
749
+ isActive: w(r),
493
750
  pause: i,
494
751
  resume: a,
495
752
  eventFilter: (...t) => {
@@ -497,20 +754,20 @@ function We(e = W, t = {}) {
497
754
  }
498
755
  };
499
756
  }
500
- function G(e) {
757
+ function J(e) {
501
758
  return Array.isArray(e) ? e : [e];
502
759
  }
503
- function Ge(e) {
504
- return e || m();
760
+ function at(e) {
761
+ return e || x();
505
762
  }
506
- function Ke(e, t, n = {}) {
507
- let { eventFilter: r = W, ...i } = n;
508
- 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);
509
766
  }
510
- function qe(e, t, n = {}) {
511
- 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 });
512
769
  return {
513
- stop: Ke(e, t, {
770
+ stop: ot(e, t, {
514
771
  ...a,
515
772
  eventFilter: o
516
773
  }),
@@ -519,50 +776,52 @@ function qe(e, t, n = {}) {
519
776
  isActive: l
520
777
  };
521
778
  }
522
- function Je(e, t = !0, n) {
523
- 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);
524
781
  }
525
- function Ye(e, t, n) {
526
- return w(e, t, {
782
+ function lt(e, t, n) {
783
+ return k(e, t, {
527
784
  ...n,
528
785
  immediate: !0
529
786
  });
530
787
  }
531
- var K = U ? window : void 0;
532
- U && window.document, U && window.navigator, U && window.location;
533
- function Xe(e) {
534
- 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);
535
794
  return t?.$el ?? t;
536
795
  }
537
- function q(...e) {
538
- let t = (e, t, n, r) => (e.addEventListener(t, n, r), () => e.removeEventListener(t, n, r)), n = f(() => {
539
- 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);
540
799
  return t.every((e) => typeof e != "string") ? t : void 0;
541
800
  });
542
- return Ye(() => [
543
- n.value?.map((e) => Xe(e)) ?? [K].filter((e) => e != null),
544
- G(x(n.value ? e[1] : e[0])),
545
- G(C(n.value ? e[2] : e[1])),
546
- 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])
547
806
  ], ([e, n, r, i], a, o) => {
548
807
  if (!e?.length || !n?.length || !r?.length) return;
549
- 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))));
550
809
  o(() => {
551
810
  c.forEach((e) => e());
552
811
  });
553
812
  }, { flush: "post" });
554
813
  }
555
- var J = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, Y = "__vueuse_ssr_handlers__", Ze = Qe();
556
- function Qe() {
557
- 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];
558
817
  }
559
- function $e(e, t) {
560
- return Ze[e] || t;
818
+ function pt(e, t) {
819
+ return dt[e] || t;
561
820
  }
562
- function et(e) {
821
+ function mt(e) {
563
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";
564
823
  }
565
- var tt = {
824
+ var ht = {
566
825
  boolean: {
567
826
  read: (e) => e === "true",
568
827
  write: (e) => String(e)
@@ -595,165 +854,115 @@ var tt = {
595
854
  read: (e) => new Date(e),
596
855
  write: (e) => e.toISOString()
597
856
  }
598
- }, X = "vueuse-storage";
599
- function nt(e, t, n, r = {}) {
600
- 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) => {
601
860
  console.error(e);
602
- }, 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));
603
862
  if (!n) try {
604
- n = $e("getDefaultStorage", () => K?.localStorage)();
863
+ n = pt("getDefaultStorage", () => Y?.localStorage)();
605
864
  } catch (e) {
606
- p(e);
865
+ f(e);
607
866
  }
608
- if (!n) return g;
609
- 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), {
610
869
  flush: i,
611
870
  deep: a,
612
871
  eventFilter: d
613
872
  });
614
- w(_, () => j(), { flush: i });
615
- let D = !1;
616
- u && o && (n instanceof Storage ? q(u, "storage", (e) => {
617
- m && !D || j(e);
618
- }, { passive: !0 }) : q(u, X, (e) => {
619
- m && !D || M(e);
620
- })), m ? Je(() => {
621
- D = !0, j();
622
- }) : j();
623
- 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) {
624
883
  if (u) {
625
884
  let r = {
626
- key: _.value,
885
+ key: h.value,
627
886
  oldValue: e,
628
887
  newValue: t,
629
888
  storageArea: n
630
889
  };
631
- 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 }));
632
891
  }
633
892
  }
634
- function k(e) {
893
+ function E(e) {
635
894
  try {
636
- let t = n.getItem(_.value);
637
- 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);
638
897
  else {
639
- let r = C.write(e);
640
- 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));
641
900
  }
642
901
  } catch (e) {
643
- p(e);
902
+ f(e);
644
903
  }
645
904
  }
646
- function A(e) {
647
- let t = e ? e.newValue : n.getItem(_.value);
648
- 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;
649
908
  if (!e && c) {
650
- let e = C.read(t);
651
- return typeof c == "function" ? c(e, b) : S === "object" && !Array.isArray(e) ? {
652
- ...b,
909
+ let e = v.read(t);
910
+ return typeof c == "function" ? c(e, g) : _ === "object" && !Array.isArray(e) ? {
911
+ ...g,
653
912
  ...e
654
913
  } : e;
655
914
  } else if (typeof t != "string") return t;
656
- else return C.read(t);
915
+ else return v.read(t);
657
916
  }
658
- function j(e) {
917
+ function A(e) {
659
918
  if (!(e && e.storageArea !== n)) {
660
919
  if (e && e.key == null) {
661
- g.value = b;
920
+ m.value = g;
662
921
  return;
663
922
  }
664
- if (!(e && e.key !== _.value)) {
665
- T();
923
+ if (!(e && e.key !== h.value)) {
924
+ b();
666
925
  try {
667
- let t = C.write(g.value);
668
- (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));
669
928
  } catch (e) {
670
- p(e);
929
+ f(e);
671
930
  } finally {
672
- e ? h(E) : E();
931
+ e ? S(x) : x();
673
932
  }
674
933
  }
675
934
  }
676
935
  }
677
- function M(e) {
678
- j(e.detail);
936
+ function j(e) {
937
+ A(e.detail);
679
938
  }
680
- return g;
939
+ return m;
681
940
  }
682
- function rt(e, t, n = {}) {
683
- let { window: r = K } = n;
684
- 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);
685
944
  }
686
- var it = 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(() => {
687
- console.debug("[db sync] db changed"), at.emit("onChange"), S(ct);
688
- }, 300), ct = d(await (async () => {
689
- let e = y(new u({
690
- dialect: new L({ database: {
691
- close(e) {
692
- return Z.close(e);
693
- },
694
- path: Z.path,
695
- async select(e, t) {
696
- console.debug("sql!", e, t);
697
- let n = await Z.select(e, t);
698
- return ot.test(e) && st(), n;
699
- },
700
- async execute(e, t) {
701
- console.debug("sql!", e, t);
702
- let n = await Z.execute(e, t);
703
- return ot.test(e) && st(), n;
704
- }
705
- } }),
706
- plugins: [new c(), new z()]
707
- }));
708
- return await new o({
709
- db: e.value,
710
- provider: { async getMigrations() {
711
- return it;
712
- } }
713
- }).migrateToLatest(), e;
714
- })(), "core/store/ins"), lt = new T();
715
- const ut = (e, t, n) => rt(lt.toString([e, x(t)]), n);
716
- var dt = Object.assign({
717
- "./migrations/1_initial.ts": M,
718
- "./migrations/2_fix-display_name.ts": ne,
719
- "./migrations/3_fix_fvi_foreign_key.ts": ae
720
- }), 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(() => {
721
- console.debug("[db sync] db changed"), ft.emit("onChange"), S(ht);
722
- }, 300);
723
- const ht = d(await (async () => {
724
- let e = y(new u({
725
- dialect: new L({ database: {
726
- close(e) {
727
- return Q.close(e);
728
- },
729
- path: Q.path,
730
- async select(e, t) {
731
- console.debug("sql!", e, t);
732
- let n = await Q.select(e, t);
733
- return pt.test(e) && mt(), n;
734
- },
735
- async execute(e, t) {
736
- console.debug("sql!", e, t);
737
- let n = await Q.execute(e, t);
738
- return pt.test(e) && mt(), n;
739
- }
740
- } }),
741
- plugins: [new c(), new z()]
742
- }));
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
+ });
743
958
  return await new o({
744
- db: e.value,
959
+ db: e,
745
960
  provider: { async getMigrations() {
746
- return dt;
961
+ return bt;
747
962
  } }
748
963
  }).migrateToLatest(), e;
749
964
  })(), "core/db/ins");
750
- let $;
751
- (function(e) {
752
- async function t(e) {
753
- return (await e.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow()).count;
754
- }
755
- e.countDb = t;
756
- })($ ||= {});
757
- 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 };
758
967
 
759
968
  //# sourceMappingURL=index.js.map