@hocuspocus/extension-database 3.4.6-rc.0 → 3.4.6-rc.2
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/package.json +2 -2
- package/dist/index.js +0 -37
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/extension-database",
|
|
3
3
|
"description": "a generic Hocuspocus persistence driver for the database",
|
|
4
|
-
"version": "3.4.6-rc.
|
|
4
|
+
"version": "3.4.6-rc.2",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"hocuspocus",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@hocuspocus/server": "^3.4.6-rc.
|
|
30
|
+
"@hocuspocus/server": "^3.4.6-rc.2"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"yjs": "^13.6.8"
|
package/dist/index.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as Y from "yjs";
|
|
2
|
-
|
|
3
|
-
//#region packages/extension-database/src/Database.ts
|
|
4
|
-
var Database = class {
|
|
5
|
-
/**
|
|
6
|
-
* Constructor
|
|
7
|
-
*/
|
|
8
|
-
constructor(configuration) {
|
|
9
|
-
this.configuration = {
|
|
10
|
-
fetch: async () => null,
|
|
11
|
-
store: async () => {}
|
|
12
|
-
};
|
|
13
|
-
this.configuration = {
|
|
14
|
-
...this.configuration,
|
|
15
|
-
...configuration
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Get stored data from the database.
|
|
20
|
-
*/
|
|
21
|
-
async onLoadDocument(data) {
|
|
22
|
-
const update = await this.configuration.fetch(data);
|
|
23
|
-
if (update) Y.applyUpdate(data.document, update);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Store new updates in the database.
|
|
27
|
-
*/
|
|
28
|
-
async onStoreDocument(data) {
|
|
29
|
-
await this.configuration.store({
|
|
30
|
-
...data,
|
|
31
|
-
state: Buffer.from(Y.encodeStateAsUpdate(data.document))
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
//#endregion
|
|
37
|
-
export { Database };
|