@pluv/addon-indexeddb 0.18.0 → 0.20.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.
- package/.turbo/turbo-build.log +15 -15
- package/CHANGELOG.md +17 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +8 -16
- package/dist/index.mjs +8 -16
- package/package.json +7 -7
- package/src/addonIndexedDB.ts +3 -3
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/addon-indexeddb@0.
|
|
2
|
+
> @pluv/addon-indexeddb@0.20.0 build /home/runner/work/pluv/pluv/packages/addon-indexeddb
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
+
ESM dist/index.mjs 3.75 KB
|
|
12
|
+
ESM ⚡️ Build success in 68ms
|
|
13
|
+
CJS dist/index.js 4.78 KB
|
|
14
|
+
CJS ⚡️ Build success in 82ms
|
|
15
|
+
DTS Build start
|
|
16
|
+
DTS ⚡️ Build success in 3247ms
|
|
17
|
+
DTS dist/index.d.mts 736.00 B
|
|
18
|
+
DTS dist/index.d.ts 736.00 B
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @pluv/addon-indexeddb
|
|
2
2
|
|
|
3
|
+
## 0.20.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [9492085]
|
|
8
|
+
- @pluv/client@0.20.0
|
|
9
|
+
- @pluv/crdt@0.20.0
|
|
10
|
+
|
|
11
|
+
## 0.19.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [137444b]
|
|
16
|
+
- Updated dependencies [f5e4370]
|
|
17
|
+
- @pluv/client@0.19.0
|
|
18
|
+
- @pluv/crdt@0.19.0
|
|
19
|
+
|
|
3
20
|
## 0.18.0
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as _pluv_types from '@pluv/types';
|
|
2
2
|
import { IOLike, JsonObject } from '@pluv/types';
|
|
3
3
|
import { PluvRoomAddon, PluvRoom } from '@pluv/client';
|
|
4
|
-
import {
|
|
4
|
+
import { CrdtType } from '@pluv/crdt';
|
|
5
5
|
|
|
6
|
-
interface AddonIndexedDBConfig<TIO extends IOLike, TPresence extends JsonObject = {}, TStorage extends Record<string,
|
|
6
|
+
interface AddonIndexedDBConfig<TIO extends IOLike, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<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,
|
|
9
|
+
declare const addonIndexedDB: <TIO extends IOLike<_pluv_types.IOAuthorize<any, any, any>, {}>, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<any, any>> = {}>(config?: AddonIndexedDBConfig<TIO, TPresence, TStorage>) => PluvRoomAddon<TIO, TPresence, TStorage>;
|
|
10
10
|
|
|
11
11
|
export { addonIndexedDB };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as _pluv_types from '@pluv/types';
|
|
2
2
|
import { IOLike, JsonObject } from '@pluv/types';
|
|
3
3
|
import { PluvRoomAddon, PluvRoom } from '@pluv/client';
|
|
4
|
-
import {
|
|
4
|
+
import { CrdtType } from '@pluv/crdt';
|
|
5
5
|
|
|
6
|
-
interface AddonIndexedDBConfig<TIO extends IOLike, TPresence extends JsonObject = {}, TStorage extends Record<string,
|
|
6
|
+
interface AddonIndexedDBConfig<TIO extends IOLike, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<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,
|
|
9
|
+
declare const addonIndexedDB: <TIO extends IOLike<_pluv_types.IOAuthorize<any, any, any>, {}>, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<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,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.
|
|
3
|
+
"version": "0.20.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.
|
|
22
|
-
"@pluv/crdt": "^0.
|
|
21
|
+
"@pluv/client": "^0.20.0",
|
|
22
|
+
"@pluv/crdt": "^0.20.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"eslint": "^8.57.0",
|
|
26
|
-
"tsup": "^8.0
|
|
26
|
+
"tsup": "^8.1.0",
|
|
27
27
|
"typescript": "^5.4.5",
|
|
28
|
-
"@pluv/tsconfig": "^0.
|
|
29
|
-
"@pluv/types": "^0.
|
|
30
|
-
"eslint-config-pluv": "^0.
|
|
28
|
+
"@pluv/tsconfig": "^0.20.0",
|
|
29
|
+
"@pluv/types": "^0.20.0",
|
|
30
|
+
"eslint-config-pluv": "^0.20.0"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/addonIndexedDB.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { PluvRoom, PluvRoomAddon } from "@pluv/client";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CrdtType } from "@pluv/crdt";
|
|
3
3
|
import type { IOLike, JsonObject } from "@pluv/types";
|
|
4
4
|
import { IndexedDBStorage } from "./IndexedDBStorage";
|
|
5
5
|
|
|
6
6
|
export interface AddonIndexedDBConfig<
|
|
7
7
|
TIO extends IOLike,
|
|
8
8
|
TPresence extends JsonObject = {},
|
|
9
|
-
TStorage extends Record<string,
|
|
9
|
+
TStorage extends Record<string, CrdtType<any, any>> = {},
|
|
10
10
|
> {
|
|
11
11
|
enabled?: boolean | ((room: PluvRoom<TIO, TPresence, TStorage>) => boolean);
|
|
12
12
|
}
|
|
@@ -14,7 +14,7 @@ export interface AddonIndexedDBConfig<
|
|
|
14
14
|
export const addonIndexedDB = <
|
|
15
15
|
TIO extends IOLike,
|
|
16
16
|
TPresence extends JsonObject = {},
|
|
17
|
-
TStorage extends Record<string,
|
|
17
|
+
TStorage extends Record<string, CrdtType<any, any>> = {},
|
|
18
18
|
>(
|
|
19
19
|
config?: AddonIndexedDBConfig<TIO, TPresence, TStorage>,
|
|
20
20
|
): PluvRoomAddon<TIO, TPresence, TStorage> => {
|