@pluv/addon-indexeddb 0.17.3 → 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.17.3 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.84 KB
12
- ESM ⚡️ Build success in 74ms
13
- CJS dist/index.js 4.87 KB
14
- CJS ⚡️ Build success in 74ms
15
- DTS Build start
16
- DTS ⚡️ Build success in 3670ms
17
- DTS dist/index.d.mts 772.00 B
18
- DTS dist/index.d.ts 772.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,24 @@
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
+
12
+ ## 0.18.0
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [06c67be]
17
+ - Updated dependencies [99b5ca9]
18
+ - Updated dependencies [df1342c]
19
+ - @pluv/client@0.18.0
20
+ - @pluv/crdt@0.18.0
21
+
3
22
  ## 0.17.3
4
23
 
5
24
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -6,6 +6,6 @@ import { AbstractCrdtType } from '@pluv/crdt';
6
6
  interface AddonIndexedDBConfig<TIO extends IOLike, TPresence extends JsonObject = {}, TStorage extends Record<string, AbstractCrdtType<any, any>> = {}> {
7
7
  enabled?: boolean | ((room: PluvRoom<TIO, TPresence, TStorage>) => boolean);
8
8
  }
9
- declare const addonIndexedDB: <TIO extends IOLike<_pluv_types.IOAuthorize<any, any, any>, {}, {}, {}, {}>, TPresence extends JsonObject = {}, TStorage extends Record<string, AbstractCrdtType<any, any>> = {}>(config?: AddonIndexedDBConfig<TIO, TPresence, TStorage>) => PluvRoomAddon<TIO, TPresence, TStorage>;
9
+ declare const addonIndexedDB: <TIO extends IOLike<_pluv_types.IOAuthorize<any, any, any>, {}>, TPresence extends JsonObject = {}, TStorage extends Record<string, AbstractCrdtType<any, any>> = {}>(config?: AddonIndexedDBConfig<TIO, TPresence, TStorage>) => PluvRoomAddon<TIO, TPresence, TStorage>;
10
10
 
11
11
  export { addonIndexedDB };
package/dist/index.d.ts CHANGED
@@ -6,6 +6,6 @@ import { AbstractCrdtType } from '@pluv/crdt';
6
6
  interface AddonIndexedDBConfig<TIO extends IOLike, TPresence extends JsonObject = {}, TStorage extends Record<string, AbstractCrdtType<any, any>> = {}> {
7
7
  enabled?: boolean | ((room: PluvRoom<TIO, TPresence, TStorage>) => boolean);
8
8
  }
9
- declare const addonIndexedDB: <TIO extends IOLike<_pluv_types.IOAuthorize<any, any, any>, {}, {}, {}, {}>, TPresence extends JsonObject = {}, TStorage extends Record<string, AbstractCrdtType<any, any>> = {}>(config?: AddonIndexedDBConfig<TIO, TPresence, TStorage>) => PluvRoomAddon<TIO, TPresence, TStorage>;
9
+ declare const addonIndexedDB: <TIO extends IOLike<_pluv_types.IOAuthorize<any, any, any>, {}>, TPresence extends JsonObject = {}, TStorage extends Record<string, AbstractCrdtType<any, any>> = {}>(config?: AddonIndexedDBConfig<TIO, TPresence, TStorage>) => PluvRoomAddon<TIO, TPresence, TStorage>;
10
10
 
11
11
  export { addonIndexedDB };
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,12 +91,8 @@ 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 [];
99
- const updates = yield db.getAll(
100
- UPGRADES_KEY,
101
- this._getLowerBound(start)
102
- );
94
+ if (!db) return [];
95
+ const updates = yield db.getAll(UPGRADES_KEY, this._getLowerBound(start));
103
96
  const lastKey = yield this._getLastKey();
104
97
  this._dbRef = lastKey + 1;
105
98
  return updates;
@@ -127,8 +120,7 @@ var IndexedDBStorage = class extends import_client.AbstractStorageStore {
127
120
  return __async(this, null, function* () {
128
121
  var _a;
129
122
  const db = this._db;
130
- if (!db)
131
- throw new Error("IndexedDB not initialized");
123
+ if (!db) throw new Error("IndexedDB not initialized");
132
124
  const store = db.transaction(UPGRADES_KEY).objectStore(UPGRADES_KEY);
133
125
  const cursor = yield store.openCursor(null, "prev");
134
126
  return (_a = cursor == null ? void 0 : cursor.key) != null ? _a : -1;
@@ -139,11 +131,9 @@ var IndexedDBStorage = class extends import_client.AbstractStorageStore {
139
131
  }
140
132
  _getSize() {
141
133
  return __async(this, null, function* () {
142
- if (this._dbSize)
143
- return this._dbSize;
134
+ if (this._dbSize) return this._dbSize;
144
135
  const db = this._db;
145
- if (!db)
146
- throw new Error("IndexedDB not initialized");
136
+ if (!db) throw new Error("IndexedDB not initialized");
147
137
  const store = db.transaction(UPGRADES_KEY).objectStore(UPGRADES_KEY);
148
138
  return store.count();
149
139
  });
@@ -158,8 +148,7 @@ var addonIndexedDB = (config) => {
158
148
  const { enabled = true } = config != null ? config : {};
159
149
  return ({ room }) => {
160
150
  const _enabled = typeof enabled === "boolean" ? enabled : enabled(room);
161
- if (!_enabled)
162
- return {};
151
+ if (!_enabled) return {};
163
152
  return {
164
153
  storage: new IndexedDBStorage(room.id)
165
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,12 +66,8 @@ 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 [];
74
- const updates = yield db.getAll(
75
- UPGRADES_KEY,
76
- this._getLowerBound(start)
77
- );
69
+ if (!db) return [];
70
+ const updates = yield db.getAll(UPGRADES_KEY, this._getLowerBound(start));
78
71
  const lastKey = yield this._getLastKey();
79
72
  this._dbRef = lastKey + 1;
80
73
  return updates;
@@ -102,8 +95,7 @@ var IndexedDBStorage = class extends AbstractStorageStore {
102
95
  return __async(this, null, function* () {
103
96
  var _a;
104
97
  const db = this._db;
105
- if (!db)
106
- throw new Error("IndexedDB not initialized");
98
+ if (!db) throw new Error("IndexedDB not initialized");
107
99
  const store = db.transaction(UPGRADES_KEY).objectStore(UPGRADES_KEY);
108
100
  const cursor = yield store.openCursor(null, "prev");
109
101
  return (_a = cursor == null ? void 0 : cursor.key) != null ? _a : -1;
@@ -114,11 +106,9 @@ var IndexedDBStorage = class extends AbstractStorageStore {
114
106
  }
115
107
  _getSize() {
116
108
  return __async(this, null, function* () {
117
- if (this._dbSize)
118
- return this._dbSize;
109
+ if (this._dbSize) return this._dbSize;
119
110
  const db = this._db;
120
- if (!db)
121
- throw new Error("IndexedDB not initialized");
111
+ if (!db) throw new Error("IndexedDB not initialized");
122
112
  const store = db.transaction(UPGRADES_KEY).objectStore(UPGRADES_KEY);
123
113
  return store.count();
124
114
  });
@@ -133,8 +123,7 @@ var addonIndexedDB = (config) => {
133
123
  const { enabled = true } = config != null ? config : {};
134
124
  return ({ room }) => {
135
125
  const _enabled = typeof enabled === "boolean" ? enabled : enabled(room);
136
- if (!_enabled)
137
- return {};
126
+ if (!_enabled) return {};
138
127
  return {
139
128
  storage: new IndexedDBStorage(room.id)
140
129
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/addon-indexeddb",
3
- "version": "0.17.3",
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.17.3",
22
- "@pluv/crdt": "^0.17.3"
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.17.3",
29
- "@pluv/types": "^0.17.3",
30
- "eslint-config-pluv": "^0.17.3"
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",
@@ -70,10 +70,7 @@ export class IndexedDBStorage extends AbstractStorageStore {
70
70
 
71
71
  if (!db) return [];
72
72
 
73
- const updates = await db.getAll(
74
- UPGRADES_KEY,
75
- this._getLowerBound(start),
76
- );
73
+ const updates = await db.getAll(UPGRADES_KEY, this._getLowerBound(start));
77
74
 
78
75
  const lastKey = await this._getLastKey();
79
76