@aiao/rxdb-vue 0.0.10 → 0.0.12

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/hooks.d.ts CHANGED
@@ -55,6 +55,14 @@ export declare const useFindOneOrFail: <T extends EntityType>(EntityType: T, opt
55
55
  * @returns A reactive resource object containing an array of entities
56
56
  */
57
57
  export declare const useFind: <T extends EntityType>(EntityType: T, options: UseOptions<EntityStaticType<T, "findOptions">>) => RxDBResource<InstanceType<T>[]>;
58
+ /**
59
+ * 使用游标分页查找实体
60
+ *
61
+ * @param EntityType 实体类
62
+ * @param options 游标分页选项(where, orderBy, limit, after, before)
63
+ * @returns 包含实体数组的响应式资源对象
64
+ */
65
+ export declare const useFindByCursor: <T extends EntityType>(EntityType: T, options: UseOptions<EntityStaticType<T, "findByCursorOptions">>) => RxDBResource<InstanceType<T>[]>;
58
66
  /**
59
67
  * Find all entities
60
68
  *
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG1D,OAAO,EAAE,WAAW,EAAiD,GAAG,EAAS,MAAM,KAAK,CAAC;AAE7F,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAE7D,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IAClC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IACtC;;O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,EAAE,sBAAsB,CAAC,CAAC,KAC/D,YAAY,CAAC,MAAM,CAA4E,CAAC;AAEnG;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,UAAU,EAChD,YAAY,CAAC,EACb,SAAS,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,KAC3D,YAAY,CAAC,GAAG,EAAE,CAAuE,CAAC"}
package/dist/index.js CHANGED
@@ -1,149 +1,148 @@
1
- import { isFunction as O } from "@aiao/utils";
2
- import { reactive as N, ref as p, watch as E, markRaw as D, onScopeDispose as P, isRef as M, provide as j, inject as k, unref as C, computed as m, onMounted as V, onBeforeUnmount as q } from "vue";
3
- const i = (n, e, c, s) => {
4
- const r = N({
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
- }), o = p(void 0);
11
- let a = !1;
12
- return E(
13
- [() => n, () => e, () => O(s) ? s() : M(s) ? s.value : s],
14
- ([, , g], [, , h]) => {
15
- a = !1, o.value && (o.value.unsubscribe(), o.value = void 0), (h === void 0 || !r.hasValue) && (r.isLoading = !0);
16
- const v = n[e];
17
- if (!v || typeof v != "function") {
10
+ }), i = y(void 0);
11
+ let l = !1;
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
- a || (r.error = t, r.isLoading = !1);
20
+ l || (r.error = t, r.isLoading = !1);
21
21
  });
22
22
  return;
23
23
  }
24
24
  try {
25
- o.value = v(g).subscribe({
25
+ i.value = p(g).subscribe({
26
26
  next: (t) => {
27
- if (a) return;
27
+ if (l) return;
28
28
  r.isLoading = !1, r.hasValue = !0, r.error = void 0;
29
- let l;
30
- Array.isArray(t) ? (l = [...t.map((y) => D(y))], r.isEmpty = t.length === 0) : (l = t != null ? D(t) : t, r.isEmpty = t == null), r.value = l;
29
+ let 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
- a || (r.isLoading = !1, r.hasValue = !1, r.error = t, console.error(`RxDB query error in ${String(e)}:`, t));
33
+ l || (r.isLoading = !1, r.hasValue = !1, r.error = t, console.error(`RxDB query error in ${String(e)}:`, t));
34
34
  }
35
35
  });
36
36
  } catch (t) {
37
- const l = t instanceof Error ? t : new Error(String(t));
37
+ const a = t instanceof Error ? t : new Error(String(t));
38
38
  Promise.resolve().then(() => {
39
- a || (r.isLoading = !1, r.error = l);
39
+ l || (r.isLoading = !1, r.error = a);
40
40
  });
41
41
  }
42
42
  },
43
43
  { immediate: !0 }
44
44
  ), P(() => {
45
- a = !0, o.value && (o.value.unsubscribe(), o.value = void 0);
45
+ l = !0, i.value && (i.value.unsubscribe(), i.value = void 0);
46
46
  }), r;
47
- }, T = (n, e) => i(n, "get", void 0, e), $ = (n, e) => i(n, "findOne", void 0, e), z = (n, e) => i(n, "findOneOrFail", void 0, e), Q = (n, e) => i(n, "find", [], e), U = (n, e) => i(n, "findAll", [], e), H = (n, e) => i(n, "count", 0, e), W = (n, e) => i(n, "findDescendants", [], e), X = (n, e) => i(n, "countDescendants", 0, e), Y = (n, e) => i(n, "findAncestors", [], e), Z = (n, e) => i(n, "countAncestors", 0, e), _ = (n, e) => i(n, "findNeighbors", [], e), ee = (n, e) => i(n, "countNeighbors", 0, e), ne = (n, e) => i(n, "findPaths", [], e), B = /* @__PURE__ */ Symbol("RxDBProvider");
48
- function I() {
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) => j(B, c),
50
+ provideRxDB: (f) => z(F, f),
51
51
  injectRxDB: () => {
52
- const c = k(B);
53
- return C(c);
52
+ const f = V(F);
53
+ return q(f);
54
54
  }
55
55
  };
56
56
  }
57
- const { injectRxDB: S, provideRxDB: re } = I(), te = () => {
58
- const n = S();
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 se(n, e) {
64
- const c = S();
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 = p([]), r = p(!1), o = p(!0), a = p(!1);
68
- let f = !0;
69
- const g = [], h = m(() => O(e) ? e() : M(e) ? e.value : e), v = m(() => s.value.flat().map((u) => D(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];
74
- }, l = () => {
75
- if (r.value || !o.value || !f)
69
+ const o = s.value[s.value.length - 1];
70
+ if (o.length !== 0)
71
+ return o[o.length - 1];
72
+ }, a = () => {
73
+ if (r.value || !i.value || !v.value)
76
74
  return;
77
75
  r.value = !0;
78
- const u = t(), d = JSON.parse(JSON.stringify(h.value));
79
- u && (d.after = u);
80
- const F = s.value.length, A = c.entityManager.getRepository(n).findByCursor(d).subscribe({
81
- next: (x) => {
82
- if (!f) return;
83
- const R = [...s.value];
84
- R[F] = x, s.value = R;
85
- const L = d.limit || 100;
86
- x.length < L && (o.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
- g.push(A);
96
- }, y = () => {
97
- g.forEach((u) => u.unsubscribe()), g.length = 0;
98
- }, w = () => {
99
- queueMicrotask(() => {
100
- y(), s.value = [], r.value = !1, o.value = !0, setTimeout(() => l(), 0);
101
- });
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());
102
98
  };
103
- V(() => {
104
- a.value || (a.value = !0, Promise.resolve().then(() => {
105
- f && l();
106
- }));
99
+ T(() => {
100
+ l.value || (l.value = !0, a());
107
101
  });
108
- const b = p(JSON.stringify(h.value));
109
- return E(
110
- () => h.value,
111
- (u) => {
112
- const d = JSON.stringify(u);
113
- a.value && b.value !== d && (b.value = d, queueMicrotask(() => {
114
- y(), s.value = [], r.value = !1, o.value = !0, setTimeout(() => l(), 0);
115
- }));
116
- },
117
- { deep: !0 }
118
- ), q(() => {
119
- f = !1, y();
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();
120
119
  }), {
121
- value: v,
122
- // 优化:移除不必要的 as any 断言,因为 allItems 类型已兼容
123
- isEmpty: m(() => v.value.length === 0 && !r.value && a.value),
120
+ value: p,
121
+ isEmpty: m(() => p.value.length === 0 && !r.value && l.value),
124
122
  isLoading: r,
125
- hasMore: o,
126
- loadMore: l,
127
- refresh: w
123
+ hasMore: i,
124
+ loadMore: a,
125
+ refresh: M
128
126
  };
129
127
  }
130
128
  export {
131
- S as injectRxDB,
132
- I as makeRxDBDependencyInjector,
133
- re as provideRxDB,
134
- H as useCount,
135
- Z as useCountAncestors,
136
- X as useCountDescendants,
137
- ee as useCountNeighbors,
138
- Q as useFind,
139
- U as useFindAll,
140
- Y as useFindAncestors,
141
- W as useFindDescendants,
142
- $ as useFindOne,
143
- z as useFindOneOrFail,
144
- T as useGet,
145
- _ as useGraphNeighbors,
146
- ne as useGraphPaths,
147
- se as useInfiniteScroll,
148
- te as useRxDB
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,
141
+ H as useFindOne,
142
+ W as useFindOneOrFail,
143
+ Q as useGet,
144
+ oe as useGraphNeighbors,
145
+ ie as useGraphPaths,
146
+ ce as useInfiniteScroll,
147
+ ae as useRxDB
149
148
  };
@@ -1,6 +1,6 @@
1
1
  import { EntityStaticType, EntityType } from '../../rxdb/src/index.ts';
2
2
  import { ComputedRef, Ref } from 'vue';
3
- type UseOptions<T> = T | (() => T);
3
+ type UseOptions<T> = T | (() => T) | Ref<T> | ComputedRef<T>;
4
4
  export interface InfiniteScrollResource<T> {
5
5
  value: ComputedRef<T[]>;
6
6
  isEmpty: ComputedRef<boolean>;
@@ -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,EAAE,KAAK,WAAW,EAAE,KAAK,GAAG,EAAoE,MAAM,KAAK,CAAC;AAGnH,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAEnC,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC,KAAK,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC;IACxB,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC9B,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACxB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACtB,QAAQ,EAAE,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,CAoJzC"}
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;AAKb,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAE7D,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC,KAAK,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC;IACxB,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC9B,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACxB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACtB,QAAQ,EAAE,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.10",
3
+ "version": "0.0.12",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -15,8 +15,12 @@
15
15
  }
16
16
  },
17
17
  "dependencies": {
18
- "@aiao/rxdb": "0.0.10",
19
- "@aiao/utils": "0.0.10"
18
+ "@aiao/utils": "0.0.12",
19
+ "@aiao/rxdb": "0.0.12"
20
+ },
21
+ "peerDependencies": {
22
+ "vue": ">=3.5.0",
23
+ "rxjs": "^7.8.0"
20
24
  },
21
25
  "files": [
22
26
  "dist",