@bangle.dev/disk
Advanced tools
Comparing version 0.17.0 to 0.17.1
@@ -11,4 +11,4 @@ import type { Disk } from '@bangle.dev/collab-server'; | ||
pendingWrites: WatchSet<string>; | ||
_doSave(docName: string, doc: Node): Promise<void>; | ||
constructor(getItem: (key: string) => Promise<Node>, setItem: (key: string, doc: Node) => Promise<void>, { debounceWait, debounceMaxWait, onPendingWrites, }: { | ||
_doSave(docName: string, doc: Node, version: number): Promise<void>; | ||
constructor(getItem: (key: string) => Promise<Node>, setItem: (key: string, doc: Node, version: number) => Promise<void>, { debounceWait, debounceMaxWait, onPendingWrites, }: { | ||
debounceWait: number; | ||
@@ -19,4 +19,7 @@ debounceMaxWait: number; | ||
load(docName: string): Promise<Node<any>>; | ||
flush(docName: string, doc: Node): Promise<void>; | ||
update(docName: string, getLatestDoc: () => Node): Promise<void>; | ||
flush(docName: string, doc: Node, version: number): Promise<void>; | ||
update(docName: string, getLatestDoc: () => { | ||
doc: Node; | ||
version: number; | ||
}): Promise<void>; | ||
flushAll(): Promise<void>; | ||
@@ -23,0 +26,0 @@ } |
@@ -46,5 +46,5 @@ import debounceFn from 'debounce-fn'; | ||
} | ||
async _doSave(docName, doc) { | ||
async _doSave(docName, doc, version) { | ||
log(docName, '_doSaveDoc called'); | ||
await this.setItem(docName, doc); | ||
await this.setItem(docName, doc, version); | ||
this.pendingWrites.delete(docName); | ||
@@ -56,3 +56,3 @@ } | ||
} | ||
async flush(docName, doc) { | ||
async flush(docName, doc, version) { | ||
log(docName, 'flush doc called'); | ||
@@ -65,3 +65,3 @@ this.pendingWrites.add(docName); | ||
} | ||
this._doSave(docName, doc); | ||
this._doSave(docName, doc, version); | ||
} | ||
@@ -74,3 +74,4 @@ async update(docName, getLatestDoc) { | ||
this.debounceFuncs.delete(docName); | ||
this._doSave(docName, getLatestDoc()); | ||
const { doc, version } = getLatestDoc(); | ||
this._doSave(docName, doc, version); | ||
}, { wait: this.debounceWait, maxWait: this.debounceMaxWait }); | ||
@@ -77,0 +78,0 @@ this.debounceFuncs.set(docName, existingFn); |
18
index.ts
@@ -18,5 +18,5 @@ import type { Disk } from '@bangle.dev/collab-server'; | ||
pendingWrites: WatchSet<string>; | ||
async _doSave(docName: string, doc: Node) { | ||
async _doSave(docName: string, doc: Node, version: number) { | ||
log(docName, '_doSaveDoc called'); | ||
await this.setItem(docName, doc); | ||
await this.setItem(docName, doc, version); | ||
this.pendingWrites.delete(docName); | ||
@@ -27,3 +27,3 @@ } | ||
private getItem: (key: string) => Promise<Node>, | ||
private setItem: (key: string, doc: Node) => Promise<void>, | ||
private setItem: (key: string, doc: Node, version: number) => Promise<void>, | ||
{ | ||
@@ -51,3 +51,3 @@ debounceWait = 300, | ||
async flush(docName: string, doc: Node) { | ||
async flush(docName: string, doc: Node, version: number) { | ||
log(docName, 'flush doc called'); | ||
@@ -62,6 +62,9 @@ this.pendingWrites.add(docName); | ||
} | ||
this._doSave(docName, doc); | ||
this._doSave(docName, doc, version); | ||
} | ||
async update(docName: string, getLatestDoc: () => Node) { | ||
async update( | ||
docName: string, | ||
getLatestDoc: () => { doc: Node; version: number }, | ||
) { | ||
let existingFn = this.debounceFuncs.get(docName); | ||
@@ -73,3 +76,4 @@ this.pendingWrites.add(docName); | ||
this.debounceFuncs.delete(docName); | ||
this._doSave(docName, getLatestDoc()); | ||
const { doc, version } = getLatestDoc(); | ||
this._doSave(docName, doc, version); | ||
}, | ||
@@ -76,0 +80,0 @@ { wait: this.debounceWait, maxWait: this.debounceMaxWait }, |
{ | ||
"name": "@bangle.dev/disk", | ||
"version": "0.17.0", | ||
"version": "0.17.1", | ||
"homepage": "https://bangle.dev", | ||
@@ -29,4 +29,5 @@ "authors": [ | ||
"devDependencies": { | ||
"@bangle.dev/collab-server": "0.17.0", | ||
"@types/prosemirror-model": "^1.13.0" | ||
"@bangle.dev/collab-server": "0.17.1", | ||
"@types/prosemirror-model": "^1.13.0", | ||
"prosemirror-model": "^1.12.0" | ||
}, | ||
@@ -33,0 +34,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43034
263
3