@pluv/addon-indexeddb 0.18.0 → 0.19.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.
@@ -1,18 +1,18 @@
1
1
 
2
- > @pluv/addon-indexeddb@0.18.0 build /home/runner/work/pluv/pluv/packages/addon-indexeddb
2
+ > @pluv/addon-indexeddb@0.19.0 build /home/runner/work/pluv/pluv/packages/addon-indexeddb
3
3
  > tsup src/index.ts --format esm,cjs --dts
4
4
 
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.0.2
8
- CLI Target: es6
9
- ESM Build start
10
- CJS Build start
11
- ESM dist/index.mjs 3.81 KB
12
- ESM ⚡️ Build success in 80ms
13
- CJS dist/index.js 4.84 KB
14
- CJS ⚡️ Build success in 80ms
15
- DTS Build start
16
- DTS ⚡️ Build success in 3392ms
17
- DTS dist/index.d.mts 760.00 B
18
- DTS dist/index.d.ts 760.00 B
5
+ CLI Building entry: src/index.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v8.1.0
8
+ CLI Target: es6
9
+ ESM Build start
10
+ CJS Build start
11
+ CJS dist/index.js 4.78 KB
12
+ CJS ⚡️ Build success in 49ms
13
+ ESM dist/index.mjs 3.75 KB
14
+ ESM ⚡️ Build success in 49ms
15
+ DTS Build start
16
+ DTS ⚡️ Build success in 3091ms
17
+ DTS dist/index.d.mts 760.00 B
18
+ DTS dist/index.d.ts 760.00 B
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @pluv/addon-indexeddb
2
2
 
3
+ ## 0.19.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [137444b]
8
+ - Updated dependencies [f5e4370]
9
+ - @pluv/client@0.19.0
10
+ - @pluv/crdt@0.19.0
11
+
3
12
  ## 0.18.0
4
13
 
5
14
  ### Patch Changes
package/dist/index.js CHANGED
@@ -60,15 +60,13 @@ var IndexedDBStorage = class extends import_client.AbstractStorageStore {
60
60
  addUpdate(update) {
61
61
  return __async(this, null, function* () {
62
62
  const db = this._db;
63
- if (!db)
64
- return;
63
+ if (!db) return;
65
64
  yield db.add(UPGRADES_KEY, update);
66
65
  this._dbSize += 1;
67
66
  });
68
67
  }
69
68
  destroy() {
70
- if (!this._db)
71
- return Promise.resolve();
69
+ if (!this._db) return Promise.resolve();
72
70
  this._db.close();
73
71
  this._db = null;
74
72
  this._dbRef = 0;
@@ -78,8 +76,7 @@ var IndexedDBStorage = class extends import_client.AbstractStorageStore {
78
76
  flatten(encodedState) {
79
77
  return __async(this, null, function* () {
80
78
  const db = this._db;
81
- if (!db)
82
- return;
79
+ if (!db) return;
83
80
  yield db.add(UPGRADES_KEY, encodedState);
84
81
  yield db.delete(UPGRADES_KEY, this._getUpperBound(this._dbRef, true));
85
82
  this._dbSize = yield this._getSize();
@@ -94,8 +91,7 @@ var IndexedDBStorage = class extends import_client.AbstractStorageStore {
94
91
  getUpdates(start = 0) {
95
92
  return __async(this, null, function* () {
96
93
  const db = this._db;
97
- if (!db)
98
- return [];
94
+ if (!db) return [];
99
95
  const updates = yield db.getAll(UPGRADES_KEY, this._getLowerBound(start));
100
96
  const lastKey = yield this._getLastKey();
101
97
  this._dbRef = lastKey + 1;
@@ -124,8 +120,7 @@ var IndexedDBStorage = class extends import_client.AbstractStorageStore {
124
120
  return __async(this, null, function* () {
125
121
  var _a;
126
122
  const db = this._db;
127
- if (!db)
128
- throw new Error("IndexedDB not initialized");
123
+ if (!db) throw new Error("IndexedDB not initialized");
129
124
  const store = db.transaction(UPGRADES_KEY).objectStore(UPGRADES_KEY);
130
125
  const cursor = yield store.openCursor(null, "prev");
131
126
  return (_a = cursor == null ? void 0 : cursor.key) != null ? _a : -1;
@@ -136,11 +131,9 @@ var IndexedDBStorage = class extends import_client.AbstractStorageStore {
136
131
  }
137
132
  _getSize() {
138
133
  return __async(this, null, function* () {
139
- if (this._dbSize)
140
- return this._dbSize;
134
+ if (this._dbSize) return this._dbSize;
141
135
  const db = this._db;
142
- if (!db)
143
- throw new Error("IndexedDB not initialized");
136
+ if (!db) throw new Error("IndexedDB not initialized");
144
137
  const store = db.transaction(UPGRADES_KEY).objectStore(UPGRADES_KEY);
145
138
  return store.count();
146
139
  });
@@ -155,8 +148,7 @@ var addonIndexedDB = (config) => {
155
148
  const { enabled = true } = config != null ? config : {};
156
149
  return ({ room }) => {
157
150
  const _enabled = typeof enabled === "boolean" ? enabled : enabled(room);
158
- if (!_enabled)
159
- return {};
151
+ if (!_enabled) return {};
160
152
  return {
161
153
  storage: new IndexedDBStorage(room.id)
162
154
  };
package/dist/index.mjs CHANGED
@@ -35,15 +35,13 @@ var IndexedDBStorage = class extends AbstractStorageStore {
35
35
  addUpdate(update) {
36
36
  return __async(this, null, function* () {
37
37
  const db = this._db;
38
- if (!db)
39
- return;
38
+ if (!db) return;
40
39
  yield db.add(UPGRADES_KEY, update);
41
40
  this._dbSize += 1;
42
41
  });
43
42
  }
44
43
  destroy() {
45
- if (!this._db)
46
- return Promise.resolve();
44
+ if (!this._db) return Promise.resolve();
47
45
  this._db.close();
48
46
  this._db = null;
49
47
  this._dbRef = 0;
@@ -53,8 +51,7 @@ var IndexedDBStorage = class extends AbstractStorageStore {
53
51
  flatten(encodedState) {
54
52
  return __async(this, null, function* () {
55
53
  const db = this._db;
56
- if (!db)
57
- return;
54
+ if (!db) return;
58
55
  yield db.add(UPGRADES_KEY, encodedState);
59
56
  yield db.delete(UPGRADES_KEY, this._getUpperBound(this._dbRef, true));
60
57
  this._dbSize = yield this._getSize();
@@ -69,8 +66,7 @@ var IndexedDBStorage = class extends AbstractStorageStore {
69
66
  getUpdates(start = 0) {
70
67
  return __async(this, null, function* () {
71
68
  const db = this._db;
72
- if (!db)
73
- return [];
69
+ if (!db) return [];
74
70
  const updates = yield db.getAll(UPGRADES_KEY, this._getLowerBound(start));
75
71
  const lastKey = yield this._getLastKey();
76
72
  this._dbRef = lastKey + 1;
@@ -99,8 +95,7 @@ var IndexedDBStorage = class extends AbstractStorageStore {
99
95
  return __async(this, null, function* () {
100
96
  var _a;
101
97
  const db = this._db;
102
- if (!db)
103
- throw new Error("IndexedDB not initialized");
98
+ if (!db) throw new Error("IndexedDB not initialized");
104
99
  const store = db.transaction(UPGRADES_KEY).objectStore(UPGRADES_KEY);
105
100
  const cursor = yield store.openCursor(null, "prev");
106
101
  return (_a = cursor == null ? void 0 : cursor.key) != null ? _a : -1;
@@ -111,11 +106,9 @@ var IndexedDBStorage = class extends AbstractStorageStore {
111
106
  }
112
107
  _getSize() {
113
108
  return __async(this, null, function* () {
114
- if (this._dbSize)
115
- return this._dbSize;
109
+ if (this._dbSize) return this._dbSize;
116
110
  const db = this._db;
117
- if (!db)
118
- throw new Error("IndexedDB not initialized");
111
+ if (!db) throw new Error("IndexedDB not initialized");
119
112
  const store = db.transaction(UPGRADES_KEY).objectStore(UPGRADES_KEY);
120
113
  return store.count();
121
114
  });
@@ -130,8 +123,7 @@ var addonIndexedDB = (config) => {
130
123
  const { enabled = true } = config != null ? config : {};
131
124
  return ({ room }) => {
132
125
  const _enabled = typeof enabled === "boolean" ? enabled : enabled(room);
133
- if (!_enabled)
134
- return {};
126
+ if (!_enabled) return {};
135
127
  return {
136
128
  storage: new IndexedDBStorage(room.id)
137
129
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/addon-indexeddb",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "@pluv/io indexeddb for client storage persistance",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -18,16 +18,16 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "idb": "^8.0.0",
21
- "@pluv/client": "^0.18.0",
22
- "@pluv/crdt": "^0.18.0"
21
+ "@pluv/client": "^0.19.0",
22
+ "@pluv/crdt": "^0.19.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "eslint": "^8.57.0",
26
- "tsup": "^8.0.2",
26
+ "tsup": "^8.1.0",
27
27
  "typescript": "^5.4.5",
28
- "@pluv/tsconfig": "^0.18.0",
29
- "@pluv/types": "^0.18.0",
30
- "eslint-config-pluv": "^0.18.0"
28
+ "@pluv/tsconfig": "^0.19.0",
29
+ "@pluv/types": "^0.19.0",
30
+ "eslint-config-pluv": "^0.19.0"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsup src/index.ts --format esm,cjs --dts",