@hocuspocus/server
Advanced tools
Comparing version 2.4.0 to 2.5.0-rc.0
@@ -12,4 +12,4 @@ import Document from './Document.js'; | ||
constructor(document: Document, instance: Hocuspocus, context?: any); | ||
transact(transaction: (document: Document) => void): Promise<void>; | ||
transact(transaction: (document: Document) => void, transactionOrigin?: any): Promise<void>; | ||
disconnect(): void; | ||
} |
@@ -22,2 +22,3 @@ /// <reference types="node" /> | ||
}; | ||
unloadImmediately: boolean; | ||
}; | ||
@@ -76,2 +77,5 @@ /** | ||
* Handle update of the given document | ||
* | ||
* "connection" is not necessarily type "Connection", it's the Yjs "origin" (which is "Connection" if | ||
* the update is incoming from the provider, but can be anything if the updates is originated from an extension. | ||
*/ | ||
@@ -78,0 +82,0 @@ private handleDocumentUpdate; |
@@ -112,2 +112,10 @@ /// <reference types="node" /> | ||
/** | ||
* If set to false, respects the debounce time of `onStoreDocument` before unloading a document. | ||
* Otherwise, the document will be unloaded immediately. | ||
* | ||
* This prevents a client from DOSing the server by repeatedly connecting and disconnecting when | ||
* your onStoreDocument is rate-limited. | ||
*/ | ||
unloadImmediately: boolean; | ||
/** | ||
* options to pass to the ydoc document | ||
@@ -194,2 +202,3 @@ */ | ||
socketId: string; | ||
transactionOrigin: any; | ||
} | ||
@@ -222,2 +231,3 @@ export interface beforeHandleMessagePayload { | ||
socketId: string; | ||
transactionOrigin?: any; | ||
} | ||
@@ -224,0 +234,0 @@ export interface afterStoreDocumentPayload extends onStoreDocumentPayload { |
{ | ||
"name": "@hocuspocus/server", | ||
"description": "plug & play collaboration backend", | ||
"version": "2.4.0", | ||
"version": "2.5.0-rc.0", | ||
"homepage": "https://hocuspocus.dev", | ||
@@ -32,3 +32,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@hocuspocus/common": "^2.4.0", | ||
"@hocuspocus/common": "^2.5.0-rc.0", | ||
"async-lock": "^1.3.1", | ||
@@ -35,0 +35,0 @@ "kleur": "^4.1.4", |
@@ -28,3 +28,3 @@ import { URLSearchParams } from 'url' | ||
async transact(transaction: (document: Document) => void) { | ||
async transact(transaction: (document: Document) => void, transactionOrigin?: any) { | ||
if (!this.document) { | ||
@@ -45,2 +45,3 @@ throw new Error('direct connection closed') | ||
socketId: 'server', | ||
transactionOrigin, | ||
}) | ||
@@ -47,0 +48,0 @@ } |
@@ -44,2 +44,3 @@ import { IncomingMessage } from 'http' | ||
}, | ||
unloadImmediately: true, | ||
} | ||
@@ -327,3 +328,3 @@ | ||
// document. Use the debounce helper, to clear running timers, | ||
// but make it run immediately (`true`). | ||
// but make it run immediately if configured. | ||
// Only run this if the document has finished loading earlier (i.e. not to persist the empty | ||
@@ -334,3 +335,3 @@ // ydoc if the onLoadDocument hook returned an error) | ||
this.storeDocumentHooks(document, hookPayload) | ||
}, true) | ||
}, this.configuration.unloadImmediately) | ||
} else { | ||
@@ -345,2 +346,5 @@ // Remove document from memory immediately | ||
* Handle update of the given document | ||
* | ||
* "connection" is not necessarily type "Connection", it's the Yjs "origin" (which is "Connection" if | ||
* the update is incoming from the provider, but can be anything if the updates is originated from an extension. | ||
*/ | ||
@@ -358,2 +362,3 @@ private handleDocumentUpdate(document: Document, connection: Connection | undefined, update: Uint8Array, request?: IncomingMessage): void { | ||
update, | ||
transactionOrigin: connection, | ||
} | ||
@@ -360,0 +365,0 @@ |
@@ -135,2 +135,10 @@ import { | ||
quiet: boolean, | ||
/** | ||
* If set to false, respects the debounce time of `onStoreDocument` before unloading a document. | ||
* Otherwise, the document will be unloaded immediately. | ||
* | ||
* This prevents a client from DOSing the server by repeatedly connecting and disconnecting when | ||
* your onStoreDocument is rate-limited. | ||
*/ | ||
unloadImmediately: boolean, | ||
@@ -148,2 +156,3 @@ /** | ||
getDocumentName?(data: getDocumentNamePayload): string | Promise<string>, | ||
} | ||
@@ -238,2 +247,3 @@ | ||
socketId: string, | ||
transactionOrigin: any, | ||
} | ||
@@ -269,2 +279,3 @@ | ||
socketId: string, | ||
transactionOrigin?: any, | ||
} | ||
@@ -271,0 +282,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
817661
9652
1