@aiao/rxdb-vue 0.0.11 → 0.0.13

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,20 +1,20 @@
1
- import { isFunction as E, cloneDeep as j } from "@aiao/utils";
2
- import { reactive as P, ref as g, watch as O, markRaw as R, onScopeDispose as V, isRef as w, inject as I, unref as N, provide as k, shallowRef as q, computed as y, onMounted as G, onBeforeUnmount as K } from "vue";
3
- const o = (n, e, c, s) => {
4
- const r = P({
5
- value: c,
1
+ import { isFunction as L, cloneDeep as N } from "@aiao/utils";
2
+ import { reactive as k, ref as y, watch as A, markRaw as B, onScopeDispose as P, isRef as w, inject as V, unref as q, provide as z, shallowRef as G, computed as m, onMounted as T, onBeforeUnmount as _ } from "vue";
3
+ const u = (n, e, f, s) => {
4
+ const r = k({
5
+ value: f,
6
6
  error: void 0,
7
7
  isLoading: !0,
8
8
  isEmpty: void 0,
9
9
  hasValue: !1
10
- }), i = g(void 0);
10
+ }), i = y(void 0);
11
11
  let l = !1;
12
- return O(
13
- [() => n, () => e, () => E(s) ? s() : w(s) ? s.value : s],
14
- ([, , d], [, , h]) => {
15
- l = !1, i.value && (i.value.unsubscribe(), i.value = void 0), (h === void 0 || !r.hasValue) && (r.isLoading = !0);
16
- const v = n[e];
17
- if (!v || typeof v != "function") {
12
+ return A(
13
+ [() => n, () => e, () => L(s) ? s() : w(s) ? s.value : s],
14
+ ([, , g], [, , b]) => {
15
+ l = !1, i.value && (i.value.unsubscribe(), i.value = void 0), (b === void 0 || !r.hasValue) && (r.isLoading = !0);
16
+ const p = n[e];
17
+ if (!p || typeof p != "function") {
18
18
  const t = new Error(`Method "${String(e)}" not found on EntityType`);
19
19
  Promise.resolve().then(() => {
20
20
  l || (r.error = t, r.isLoading = !1);
@@ -22,12 +22,12 @@ const o = (n, e, c, s) => {
22
22
  return;
23
23
  }
24
24
  try {
25
- i.value = v(d).subscribe({
25
+ i.value = p(g).subscribe({
26
26
  next: (t) => {
27
27
  if (l) return;
28
28
  r.isLoading = !1, r.hasValue = !0, r.error = void 0;
29
29
  let a;
30
- Array.isArray(t) ? (a = [...t.map((p) => R(p))], r.isEmpty = t.length === 0) : (a = t != null ? R(t) : t, r.isEmpty = t == null), r.value = a;
30
+ Array.isArray(t) ? (a = [...t.map((h) => B(h))], r.isEmpty = t.length === 0) : (a = t != null ? B(t) : t, r.isEmpty = t == null), r.value = a;
31
31
  },
32
32
  error: (t) => {
33
33
  l || (r.isLoading = !1, r.hasValue = !1, r.error = t, console.error(`RxDB query error in ${String(e)}:`, t));
@@ -41,102 +41,108 @@ const o = (n, e, c, s) => {
41
41
  }
42
42
  },
43
43
  { immediate: !0 }
44
- ), V(() => {
44
+ ), P(() => {
45
45
  l = !0, i.value && (i.value.unsubscribe(), i.value = void 0);
46
46
  }), r;
47
- }, U = (n, e) => o(n, "get", void 0, e), H = (n, e) => o(n, "findOne", void 0, e), T = (n, e) => o(n, "findOneOrFail", void 0, e), W = (n, e) => o(n, "find", [], e), X = (n, e) => o(n, "findByCursor", [], e), Y = (n, e) => o(n, "findAll", [], e), Z = (n, e) => o(n, "count", 0, e), _ = (n, e) => o(n, "findDescendants", [], e), ee = (n, e) => o(n, "countDescendants", 0, e), ne = (n, e) => o(n, "findAncestors", [], e), re = (n, e) => o(n, "countAncestors", 0, e), te = (n, e) => o(n, "findNeighbors", [], e), se = (n, e) => o(n, "countNeighbors", 0, e), oe = (n, e) => o(n, "findPaths", [], e), B = /* @__PURE__ */ Symbol("RxDBProvider");
48
- function $() {
47
+ }, Q = (n, e) => u(n, "get", void 0, e), H = (n, e) => u(n, "findOne", void 0, e), W = (n, e) => u(n, "findOneOrFail", void 0, e), X = (n, e) => u(n, "find", [], e), Y = (n, e) => u(n, "findByCursor", [], e), Z = (n, e) => u(n, "findAll", [], e), ee = (n, e) => u(n, "count", 0, e), ne = (n, e) => u(n, "findDescendants", [], e), re = (n, e) => u(n, "countDescendants", 0, e), te = (n, e) => u(n, "findAncestors", [], e), se = (n, e) => u(n, "countAncestors", 0, e), oe = (n, e) => u(n, "findNeighbors", [], e), ue = (n, e) => u(n, "countNeighbors", 0, e), ie = (n, e) => u(n, "findPaths", [], e), F = /* @__PURE__ */ Symbol("RxDBProvider");
48
+ function K() {
49
49
  return {
50
- provideRxDB: (c) => k(B, c),
50
+ provideRxDB: (f) => z(F, f),
51
51
  injectRxDB: () => {
52
- const c = I(B);
53
- return N(c);
52
+ const f = V(F);
53
+ return q(f);
54
54
  }
55
55
  };
56
56
  }
57
- const { injectRxDB: F, provideRxDB: ie } = $(), ue = () => {
58
- const n = F();
57
+ const { injectRxDB: I, provideRxDB: le } = K(), ae = () => {
58
+ const n = I();
59
59
  if (!n)
60
60
  throw new Error("RxDB instance not found. Make sure to call provideRxDB() in your app setup.");
61
61
  return n;
62
- };
63
- function le(n, e) {
64
- const c = F();
65
- if (!c)
62
+ }, U = 100;
63
+ function ce(n, e) {
64
+ const f = I();
65
+ if (!f)
66
66
  throw new Error("RxDB not provided. Make sure to call provideRxDB() in parent component.");
67
- const s = q([]), r = g(!1), i = g(!0), l = g(!1);
68
- let f = !0;
69
- const d = [], h = y(() => E(e) ? e() : w(e) ? e.value : e), v = y(() => s.value.flat().map((u) => R(u))), t = () => {
67
+ const s = G([]), r = y(!1), i = y(!0), l = y(!1), v = y(!0), g = [], b = m(() => L(e) ? e() : w(e) ? e.value : e), p = m(() => s.value.flat().map((o) => B(o))), t = () => {
70
68
  if (s.value.length === 0) return;
71
- const u = s.value[s.value.length - 1];
72
- if (u.length !== 0)
73
- return u[u.length - 1];
69
+ const o = s.value[s.value.length - 1];
70
+ if (o.length !== 0)
71
+ return o[o.length - 1];
74
72
  }, a = () => {
75
- if (r.value || !i.value || !f)
73
+ if (r.value || !i.value || !v.value)
76
74
  return;
77
75
  r.value = !0;
78
- const u = t(), m = j(h.value);
79
- u && (m.after = u);
80
- const A = s.value.length, L = c.entityManager.getRepository(n).findByCursor(m).subscribe({
81
- next: (b) => {
82
- if (!f) return;
83
- const x = [...s.value];
84
- x[A] = b, s.value = x;
85
- const S = m.limit || 100;
86
- b.length < S && (i.value = !1), r.value = !1;
76
+ const o = t(), d = N(b.value);
77
+ o && (d.after = o);
78
+ const c = s.value.length, D = f.entityManager.getRepository(n).findByCursor(d).subscribe({
79
+ next: (O) => {
80
+ if (!v.value) return;
81
+ const E = [...s.value];
82
+ E[c] = O, s.value = E;
83
+ const C = d.limit ?? U;
84
+ O.length < C && (i.value = !1), r.value = !1;
87
85
  },
88
86
  error: () => {
89
- f && (r.value = !1);
87
+ v.value && (r.value = !1);
90
88
  },
91
89
  complete: () => {
92
- f && (r.value = !1);
90
+ v.value && (r.value = !1);
93
91
  }
94
92
  });
95
- d.push(L);
96
- }, p = () => {
97
- d.forEach((u) => u.unsubscribe()), d.length = 0;
98
- }, C = () => {
99
- if (!f) {
100
- console.warn("Cannot refresh: component is unmounted");
101
- return;
102
- }
103
- p(), s.value = [], r.value = !1, i.value = !0, a();
93
+ g.push(D);
94
+ }, h = () => {
95
+ g.forEach((o) => o.unsubscribe()), g.length = 0;
96
+ }, M = () => {
97
+ v.value && (h(), s.value = [], r.value = !1, i.value = !0, a());
104
98
  };
105
- G(() => {
99
+ T(() => {
106
100
  l.value || (l.value = !0, a());
107
101
  });
108
- const M = y(() => JSON.stringify(h.value)), D = g(null);
109
- return O(M, (u) => {
110
- l.value && D.value && D.value !== u && (p(), s.value = [], r.value = !1, i.value = !0, a()), D.value = u;
111
- }), K(() => {
112
- f = !1, p();
102
+ const S = (o) => {
103
+ const d = (c) => {
104
+ if (c === null || typeof c != "object")
105
+ return c;
106
+ if (Array.isArray(c))
107
+ return c.map(d);
108
+ const x = {};
109
+ for (const D of Object.keys(c).sort())
110
+ x[D] = d(c[D]);
111
+ return x;
112
+ };
113
+ return JSON.stringify(d(o));
114
+ }, j = m(() => S(b.value)), R = y(null);
115
+ return A(j, (o) => {
116
+ l.value && R.value && R.value !== o && (h(), s.value = [], r.value = !1, i.value = !0, a()), R.value = o;
117
+ }), _(() => {
118
+ v.value = !1, h();
113
119
  }), {
114
- value: v,
115
- isEmpty: y(() => v.value.length === 0 && !r.value && l.value),
120
+ value: p,
121
+ isEmpty: m(() => p.value.length === 0 && !r.value && l.value),
116
122
  isLoading: r,
117
123
  hasMore: i,
118
124
  loadMore: a,
119
- refresh: C
125
+ refresh: M
120
126
  };
121
127
  }
122
128
  export {
123
- F as injectRxDB,
124
- $ as makeRxDBDependencyInjector,
125
- ie as provideRxDB,
126
- Z as useCount,
127
- re as useCountAncestors,
128
- ee as useCountDescendants,
129
- se as useCountNeighbors,
130
- W as useFind,
131
- Y as useFindAll,
132
- ne as useFindAncestors,
133
- X as useFindByCursor,
134
- _ as useFindDescendants,
129
+ I as injectRxDB,
130
+ K as makeRxDBDependencyInjector,
131
+ le as provideRxDB,
132
+ ee as useCount,
133
+ se as useCountAncestors,
134
+ re as useCountDescendants,
135
+ ue as useCountNeighbors,
136
+ X as useFind,
137
+ Z as useFindAll,
138
+ te as useFindAncestors,
139
+ Y as useFindByCursor,
140
+ ne as useFindDescendants,
135
141
  H as useFindOne,
136
- T as useFindOneOrFail,
137
- U as useGet,
138
- te as useGraphNeighbors,
139
- oe as useGraphPaths,
140
- le as useInfiniteScroll,
141
- ue as useRxDB
142
+ W as useFindOneOrFail,
143
+ Q as useGet,
144
+ oe as useGraphNeighbors,
145
+ ie as useGraphPaths,
146
+ ce as useInfiniteScroll,
147
+ ae as useRxDB
142
148
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useInfiniteScroll.d.ts","sourceRoot":"","sources":["../src/useInfiniteScroll.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE1D,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,GAAG,EAST,MAAM,KAAK,CAAC;AAGb,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,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AE,MAAM,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,UAAU,EACpD,UAAU,EAAE,CAAC,EACb,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC,GAC9D,sBAAsB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAyJzC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiao/rxdb-vue",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -15,8 +15,8 @@
15
15
  }
16
16
  },
17
17
  "dependencies": {
18
- "@aiao/rxdb": "0.0.11",
19
- "@aiao/utils": "0.0.11"
18
+ "@aiao/utils": "0.0.13",
19
+ "@aiao/rxdb": "0.0.13"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "vue": ">=3.5.0",