@aiao/rxdb-plugin-workspace 0.0.15 → 0.0.17

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/README.md CHANGED
@@ -1,6 +1,28 @@
1
- # rxdb-plugin-workspace(未完成)
1
+ # @aiao/rxdb-plugin-workspace
2
2
 
3
- 把创建的所有对象暂存到 indexedDB 中,方便后续恢复。 帮助用户管理暂存的对象,包括恢复和删除。
3
+ > ⚠️ **开发中** - 此包尚未完成
4
4
 
5
- 1. 如果这个对象保存了,就从 indexedDB 删除;
6
- 2. 如果这个对象没有保存,用户可以选择恢复这个对象,或者删除它。
5
+ RxDB 工作区插件,提供暂存对象管理功能。
6
+
7
+ ## 功能特性
8
+
9
+ - **对象暂存**: 将创建的对象暂存到 IndexedDB
10
+ - **恢复管理**: 方便恢复未保存的对象
11
+ - **自动清理**: 保存后自动从暂存区移除
12
+
13
+ ## 使用场景
14
+
15
+ 1. 如果对象已保存,从 IndexedDB 删除
16
+ 2. 如果对象未保存,用户可以选择恢复或删除
17
+
18
+ ## 安装
19
+
20
+ ```bash
21
+ npm install @aiao/rxdb-plugin-workspace @aiao/rxdb
22
+ # 或
23
+ pnpm add @aiao/rxdb-plugin-workspace @aiao/rxdb
24
+ ```
25
+
26
+ ## 相关包
27
+
28
+ - [@aiao/rxdb](../rxdb) - 核心库
@@ -1 +1 @@
1
- {"version":3,"file":"RxDBPluginWorkspace.d.ts","sourceRoot":"","sources":["../src/RxDBPluginWorkspace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAOL,WAAW,EACX,MAAM,EACN,+BAA+B,EAC/B,wBAAwB,EACxB,cAAc,EACf,MAAM,YAAY,CAAC;AAIpB,UAAU,0BAA0B;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,qBAAa,mBAAoB,SAAQ,cAAe,YAAW,WAAW;;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zB;AAED,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,0BAA0B,CAElE,CAAC;AAEF,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAU,IAAI;QACZ,SAAS,EAAE,mBAAmB,CAAC;KAChC;CACF;AAED,KAAK,OAAO,GAAG,GAAG,MAAM,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;AAE7C,eAAO,MAAM,YAAY,GAAI,WAAW,wBAAwB,KACS,OAAO,CAAC"}
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { RxDBPluginBase as m, ENTITY_LOCAL_NEW_EVENT as c, ENTITY_LOCAL_REMOVE_EVENT as d, ENTITY_LOCAL_CREATE_EVENT as o } from "@aiao/rxdb";
2
- import { createStore as p, entries as E, setMany as b, delMany as f } from "idb-keyval";
3
- import { Subject as u, debounceTime as y } from "rxjs";
2
+ import { createStore as p, entries as E, setMany as f, delMany as y } from "idb-keyval";
3
+ import { Subject as b, debounceTime as u } from "rxjs";
4
4
  class g extends m {
5
5
  #h;
6
- #n = new u();
6
+ #n = new b();
7
7
  #d;
8
8
  #a = /* @__PURE__ */ new Map();
9
9
  #e = /* @__PURE__ */ new Set();
@@ -21,7 +21,7 @@ class g extends m {
21
21
  constructor(e) {
22
22
  super(e), this.rxdb.addEventListener(c, this.#r), this.rxdb.addEventListener(d, this.#r), this.rxdb.addEventListener(o, this.#r);
23
23
  const t = this.rxdb.config.dbName;
24
- this.#h = p(t, this.name), this.#d = this.#n.asObservable().pipe(y(0)).subscribe(() => this.#l());
24
+ this.#h = p(t, this.name), this.#d = this.#n.asObservable().pipe(u(0)).subscribe(() => this.#l());
25
25
  }
26
26
  async install() {
27
27
  const e = await E(this.#h);
@@ -77,14 +77,19 @@ class g extends m {
77
77
  }
78
78
  async #l() {
79
79
  if (!(this.#c || this.#a.size === 0 && this.#e.size === 0)) {
80
- if (this.#c = !0, this.#a.size) {
81
- const e = Array.from(this.#a.entries()).map(([t, s]) => [
82
- t,
83
- { ...s }
84
- ]);
85
- await b(e, this.#h), this.#a.clear();
80
+ this.#c = !0;
81
+ try {
82
+ if (this.#a.size) {
83
+ const e = Array.from(this.#a.entries()).map(([t, s]) => [
84
+ t,
85
+ { ...s }
86
+ ]);
87
+ await f(e, this.#h), this.#a.clear();
88
+ }
89
+ this.#e.size && (await y(Array.from(this.#e), this.#h), this.#e.clear());
90
+ } finally {
91
+ this.#c = !1;
86
92
  }
87
- this.#e.size && (await f(Array.from(this.#e), this.#h), this.#e.clear()), this.#c = !1;
88
93
  }
89
94
  }
90
95
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiao/rxdb-plugin-workspace",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -30,6 +30,6 @@
30
30
  "dependencies": {
31
31
  "rxjs": "^7.8.2",
32
32
  "idb-keyval": "^6.2.2",
33
- "@aiao/rxdb": "0.0.15"
33
+ "@aiao/rxdb": "0.0.17"
34
34
  }
35
35
  }