@hocuspocus/extension-redis 3.0.4-rc.0 → 3.0.7-rc.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.
Files changed (50) hide show
  1. package/dist/hocuspocus-redis.cjs.map +1 -1
  2. package/dist/hocuspocus-redis.esm.js.map +1 -1
  3. package/dist/packages/common/src/auth.d.ts +1 -1
  4. package/dist/packages/common/src/index.d.ts +4 -4
  5. package/dist/packages/extension-database/src/index.d.ts +1 -1
  6. package/dist/packages/extension-logger/src/index.d.ts +1 -1
  7. package/dist/packages/extension-redis/src/Redis.d.ts +0 -2
  8. package/dist/packages/extension-redis/src/index.d.ts +1 -1
  9. package/dist/packages/extension-sqlite/src/index.d.ts +1 -1
  10. package/dist/packages/extension-throttle/src/index.d.ts +0 -1
  11. package/dist/packages/extension-webhook/src/index.d.ts +0 -1
  12. package/dist/packages/provider/src/HocuspocusProvider.d.ts +9 -7
  13. package/dist/packages/provider/src/HocuspocusProviderWebsocket.d.ts +4 -6
  14. package/dist/packages/provider/src/IncomingMessage.d.ts +2 -2
  15. package/dist/packages/provider/src/MessageReceiver.d.ts +2 -2
  16. package/dist/packages/provider/src/MessageSender.d.ts +2 -2
  17. package/dist/packages/provider/src/OutgoingMessage.d.ts +2 -2
  18. package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +3 -3
  19. package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +3 -3
  20. package/dist/packages/provider/src/OutgoingMessages/CloseMessage.d.ts +3 -3
  21. package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +3 -3
  22. package/dist/packages/provider/src/OutgoingMessages/StatelessMessage.d.ts +3 -3
  23. package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +3 -3
  24. package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +3 -3
  25. package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +3 -3
  26. package/dist/packages/provider/src/index.d.ts +3 -3
  27. package/dist/packages/provider/src/types.d.ts +14 -108
  28. package/dist/packages/server/src/ClientConnection.d.ts +3 -5
  29. package/dist/packages/server/src/Connection.d.ts +13 -5
  30. package/dist/packages/server/src/DirectConnection.d.ts +3 -3
  31. package/dist/packages/server/src/Document.d.ts +1 -1
  32. package/dist/packages/server/src/Hocuspocus.d.ts +4 -5
  33. package/dist/packages/server/src/IncomingMessage.d.ts +4 -3
  34. package/dist/packages/server/src/MessageReceiver.d.ts +5 -5
  35. package/dist/packages/server/src/OutgoingMessage.d.ts +1 -1
  36. package/dist/packages/server/src/Server.d.ts +1 -2
  37. package/dist/packages/server/src/index.d.ts +9 -9
  38. package/dist/packages/server/src/types.d.ts +28 -9
  39. package/dist/packages/server/src/util/getParameters.d.ts +0 -2
  40. package/dist/packages/transformer/src/Prosemirror.d.ts +1 -1
  41. package/dist/packages/transformer/src/Tiptap.d.ts +1 -1
  42. package/dist/packages/transformer/src/index.d.ts +3 -3
  43. package/dist/playground/frontend/app/SocketContext.d.ts +2 -0
  44. package/dist/playground/frontend/next.config.d.ts +3 -0
  45. package/dist/tests/utils/index.d.ts +9 -9
  46. package/dist/tests/utils/newHocuspocusProviderWebsocket.d.ts +1 -1
  47. package/package.json +3 -3
  48. package/src/index.ts +1 -1
  49. package/dist/playground/frontend/vite.config.d.ts +0 -2
  50. /package/dist/{playground/frontend/src/main.d.ts → tests/server/beforeSync.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"hocuspocus-redis.cjs","sources":["../src/Redis.ts"],"sourcesContent":["import type { ClusterNode, ClusterOptions, RedisOptions } from 'ioredis'\nimport RedisClient from 'ioredis'\nimport Redlock from 'redlock'\nimport { v4 as uuid } from 'uuid'\nimport type {\n Document,\n Extension,\n afterLoadDocumentPayload,\n afterStoreDocumentPayload,\n onDisconnectPayload,\n onStoreDocumentPayload,\n onAwarenessUpdatePayload,\n onChangePayload,\n onConfigurePayload,\n beforeBroadcastStatelessPayload, Hocuspocus} from '@hocuspocus/server'\nimport {\n IncomingMessage,\n OutgoingMessage,\n MessageReceiver,\n} from '@hocuspocus/server'\n\nexport type RedisInstance = RedisClient.Cluster | RedisClient.Redis\n\nexport interface Configuration {\n /**\n * Redis port\n */\n port: number,\n /**\n * Redis host\n */\n host: string,\n /**\n * Redis Cluster\n */\n nodes?: ClusterNode[],\n /**\n * Duplicate from an existed Redis instance\n */\n redis?: RedisInstance,\n /**\n * Redis instance creator\n */\n createClient?: () => RedisInstance,\n /**\n * Options passed directly to Redis constructor\n *\n * https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options\n */\n options?: ClusterOptions | RedisOptions,\n /**\n * An unique instance name, required to filter messages in Redis.\n * If none is provided an unique id is generated.\n */\n identifier: string,\n /**\n * Namespace for Redis keys, if none is provided 'hocuspocus' is used\n */\n prefix: string,\n /**\n * The maximum time for the Redis lock in ms (in case it can’t be released).\n */\n lockTimeout: number,\n /**\n * A delay before onDisconnect is executed. This allows last minute updates'\n * sync messages to be received by the subscription before it's closed.\n */\n disconnectDelay: number,\n}\n\nexport class Redis implements Extension {\n /**\n * Make sure to give that extension a higher priority, so\n * the `onStoreDocument` hook is able to intercept the chain,\n * before documents are stored to the database.\n */\n priority = 1000\n\n configuration: Configuration = {\n port: 6379,\n host: '127.0.0.1',\n prefix: 'hocuspocus',\n identifier: `host-${uuid()}`,\n lockTimeout: 1000,\n disconnectDelay: 1000,\n }\n\n redisTransactionOrigin = '__hocuspocus__redis__origin__'\n\n pub: RedisInstance\n\n sub: RedisInstance\n\n instance!: Hocuspocus\n\n redlock: Redlock\n\n locks = new Map<string, Redlock.Lock>()\n\n messagePrefix: Buffer\n\n /**\n * When we have a high frequency of updates to a document we don't need tons of setTimeouts\n * piling up, so we'll track them to keep it to the most recent per document.\n */\n private pendingDisconnects = new Map<string, NodeJS.Timeout>()\n\n private pendingAfterStoreDocumentResolves = new Map<string, { timeout: NodeJS.Timeout; resolve:() => void }>()\n\n public constructor(configuration: Partial<Configuration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n\n // Create Redis instance\n const {\n port,\n host,\n options,\n nodes,\n redis,\n createClient,\n } = this.configuration\n\n if (typeof createClient === 'function') {\n this.pub = createClient()\n this.sub = createClient()\n } else if (redis) {\n this.pub = redis.duplicate()\n this.sub = redis.duplicate()\n } else if (nodes && nodes.length > 0) {\n this.pub = new RedisClient.Cluster(nodes, options)\n this.sub = new RedisClient.Cluster(nodes, options)\n } else {\n this.pub = new RedisClient(port, host, options)\n this.sub = new RedisClient(port, host, options)\n }\n this.sub.on('messageBuffer', this.handleIncomingMessage)\n\n this.redlock = new Redlock([this.pub], {\n retryCount: 0,\n })\n\n const identifierBuffer = Buffer.from(this.configuration.identifier, 'utf-8')\n this.messagePrefix = Buffer.concat([Buffer.from([identifierBuffer.length]), identifierBuffer])\n }\n\n async onConfigure({ instance }: onConfigurePayload) {\n this.instance = instance\n }\n\n private getKey(documentName: string) {\n return `${this.configuration.prefix}:${documentName}`\n }\n\n private pubKey(documentName: string) {\n return this.getKey(documentName)\n }\n\n private subKey(documentName: string) {\n return this.getKey(documentName)\n }\n\n private lockKey(documentName: string) {\n return `${this.getKey(documentName)}:lock`\n }\n\n private encodeMessage(message: Uint8Array) {\n return Buffer.concat([this.messagePrefix, Buffer.from(message)])\n }\n\n private decodeMessage(buffer: Buffer) {\n const identifierLength = buffer[0]\n const identifier = buffer.toString('utf-8', 1, identifierLength + 1)\n\n return [identifier, buffer.slice(identifierLength + 1)]\n }\n\n /**\n * Once a document is loaded, subscribe to the channel in Redis.\n */\n public async afterLoadDocument({ documentName, document }: afterLoadDocumentPayload) {\n return new Promise((resolve, reject) => {\n // On document creation the node will connect to pub and sub channels\n // for the document.\n this.sub.subscribe(this.subKey(documentName), async error => {\n if (error) {\n reject(error)\n return\n }\n\n this.publishFirstSyncStep(documentName, document)\n this.requestAwarenessFromOtherInstances(documentName)\n\n resolve(undefined)\n })\n })\n }\n\n /**\n * Publish the first sync step through Redis.\n */\n private async publishFirstSyncStep(documentName: string, document: Document) {\n const syncMessage = new OutgoingMessage(documentName)\n .createSyncMessage()\n .writeFirstSyncStepFor(document)\n\n return this.pub.publishBuffer(this.pubKey(documentName), this.encodeMessage(syncMessage.toUint8Array()))\n }\n\n /**\n * Let’s ask Redis who is connected already.\n */\n private async requestAwarenessFromOtherInstances(documentName: string) {\n const awarenessMessage = new OutgoingMessage(documentName)\n .writeQueryAwareness()\n\n return this.pub.publishBuffer(\n this.pubKey(documentName),\n this.encodeMessage(awarenessMessage.toUint8Array()),\n )\n }\n\n /**\n * Before the document is stored, make sure to set a lock in Redis.\n * That’s meant to avoid conflicts with other instances trying to store the document.\n */\n async onStoreDocument({ documentName }: onStoreDocumentPayload) {\n // Attempt to acquire a lock and read lastReceivedTimestamp from Redis,\n // to avoid conflict with other instances storing the same document.\n\n return new Promise((resolve, reject) => {\n this.redlock.lock(this.lockKey(documentName), this.configuration.lockTimeout, async (error, lock) => {\n if (error || !lock) {\n // Expected behavior: Could not acquire lock, another instance locked it already.\n // No further `onStoreDocument` hooks will be executed.\n console.log('unable to acquire lock')\n reject()\n return\n }\n\n this.locks.set(this.lockKey(documentName), lock)\n\n resolve(undefined)\n })\n })\n }\n\n /**\n * Release the Redis lock, so other instances can store documents.\n */\n async afterStoreDocument({ documentName, socketId }: afterStoreDocumentPayload) {\n this.locks.get(this.lockKey(documentName))?.unlock()\n .catch(() => {\n // Not able to unlock Redis. The lock will expire after ${lockTimeout} ms.\n // console.error(`Not able to unlock Redis. The lock will expire after ${this.configuration.lockTimeout}ms.`)\n })\n .finally(() => {\n this.locks.delete(this.lockKey(documentName))\n })\n\n // if the change was initiated by a directConnection, we need to delay this hook to make sure sync can finish first.\n // for provider connections, this usually happens in the onDisconnect hook\n if (socketId === 'server') {\n const pending = this.pendingAfterStoreDocumentResolves.get(documentName)\n\n if (pending) {\n clearTimeout(pending.timeout)\n pending.resolve()\n this.pendingAfterStoreDocumentResolves.delete(documentName)\n }\n\n let resolveFunction: () => void = () => {}\n const delayedPromise = new Promise<void>(resolve => {\n resolveFunction = resolve\n })\n\n const timeout = setTimeout(() => {\n this.pendingAfterStoreDocumentResolves.delete(documentName)\n resolveFunction()\n }, this.configuration.disconnectDelay)\n\n this.pendingAfterStoreDocumentResolves.set(documentName, { timeout, resolve: resolveFunction })\n\n await delayedPromise\n }\n }\n\n /**\n * Handle awareness update messages received directly by this Hocuspocus instance.\n */\n async onAwarenessUpdate({\n documentName, awareness, added, updated, removed,\n }: onAwarenessUpdatePayload) {\n const changedClients = added.concat(updated, removed)\n const message = new OutgoingMessage(documentName)\n .createAwarenessUpdateMessage(awareness, changedClients)\n\n return this.pub.publishBuffer(\n this.pubKey(documentName),\n this.encodeMessage(message.toUint8Array()),\n )\n }\n\n /**\n * Handle incoming messages published on subscribed document channels.\n * Note that this will also include messages from ourselves as it is not possible\n * in Redis to filter these.\n */\n private handleIncomingMessage = async (channel: Buffer, data: Buffer) => {\n const [identifier, messageBuffer] = this.decodeMessage(data)\n\n if (identifier === this.configuration.identifier) {\n return\n }\n\n const message = new IncomingMessage(messageBuffer)\n const documentName = message.readVarString()\n message.writeVarString(documentName)\n\n const document = this.instance.documents.get(documentName)\n\n if (!document) {\n return\n }\n\n new MessageReceiver(\n message,\n this.redisTransactionOrigin,\n ).apply(document, undefined, reply => {\n return this.pub.publishBuffer(\n this.pubKey(document.name),\n this.encodeMessage(reply),\n )\n })\n }\n\n /**\n * if the ydoc changed, we'll need to inform other Hocuspocus servers about it.\n */\n public async onChange(data: onChangePayload): Promise<any> {\n if (data.transactionOrigin !== this.redisTransactionOrigin) {\n return this.publishFirstSyncStep(data.documentName, data.document)\n }\n }\n\n /**\n * Make sure to *not* listen for further changes, when there’s\n * no one connected anymore.\n */\n public onDisconnect = async ({ documentName }: onDisconnectPayload) => {\n const pending = this.pendingDisconnects.get(documentName)\n\n if (pending) {\n clearTimeout(pending)\n this.pendingDisconnects.delete(documentName)\n }\n\n const disconnect = () => {\n const document = this.instance.documents.get(documentName)\n\n this.pendingDisconnects.delete(documentName)\n\n // Do nothing, when other users are still connected to the document.\n if (!document || document.getConnectionsCount() > 0) {\n return\n }\n\n // Time to end the subscription on the document channel.\n this.sub.unsubscribe(this.subKey(documentName), (error: any) => {\n if (error) {\n console.error(error)\n }\n })\n\n this.instance.unloadDocument(document)\n }\n // Delay the disconnect procedure to allow last minute syncs to happen\n const timeout = setTimeout(disconnect, this.configuration.disconnectDelay)\n this.pendingDisconnects.set(documentName, timeout)\n }\n\n async beforeBroadcastStateless(data: beforeBroadcastStatelessPayload) {\n const message = new OutgoingMessage(data.documentName)\n .writeBroadcastStateless(data.payload)\n\n return this.pub.publishBuffer(\n this.pubKey(data.documentName),\n this.encodeMessage(message.toUint8Array()),\n )\n }\n\n /**\n * Kill the Redlock connection immediately.\n */\n async onDestroy() {\n await this.redlock.quit()\n this.pub.disconnect(false)\n this.sub.disconnect(false)\n }\n}\n"],"names":["uuid","IncomingMessage","MessageReceiver","OutgoingMessage"],"mappings":";;;;;;;MAsEa,KAAK,CAAA;AAuChB,IAAA,WAAA,CAAmB,aAAqC,EAAA;AAtCxD;;;;AAIG;QACH,IAAQ,CAAA,QAAA,GAAG,IAAI;AAEf,QAAA,IAAA,CAAA,aAAa,GAAkB;AAC7B,YAAA,IAAI,EAAE,IAAI;AACV,YAAA,IAAI,EAAE,WAAW;AACjB,YAAA,MAAM,EAAE,YAAY;AACpB,YAAA,UAAU,EAAE,CAAA,KAAA,EAAQA,OAAI,EAAE,CAAE,CAAA;AAC5B,YAAA,WAAW,EAAE,IAAI;AACjB,YAAA,eAAe,EAAE,IAAI;SACtB;QAED,IAAsB,CAAA,sBAAA,GAAG,+BAA+B;AAUxD,QAAA,IAAA,CAAA,KAAK,GAAG,IAAI,GAAG,EAAwB;AAIvC;;;AAGG;AACK,QAAA,IAAA,CAAA,kBAAkB,GAAG,IAAI,GAAG,EAA0B;AAEtD,QAAA,IAAA,CAAA,iCAAiC,GAAG,IAAI,GAAG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CAAC;QAExC,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAC3B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,EAC9B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAC3C;;AAGH;;AAEG;AACH,IAAA,MAAM,SAAS,GAAA;AACb,QAAA,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;AACzB,QAAA,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC;AAC1B,QAAA,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC;;AAE7B;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"hocuspocus-redis.esm.js","sources":["../src/Redis.ts"],"sourcesContent":["import type { ClusterNode, ClusterOptions, RedisOptions } from 'ioredis'\nimport RedisClient from 'ioredis'\nimport Redlock from 'redlock'\nimport { v4 as uuid } from 'uuid'\nimport type {\n Document,\n Extension,\n afterLoadDocumentPayload,\n afterStoreDocumentPayload,\n onDisconnectPayload,\n onStoreDocumentPayload,\n onAwarenessUpdatePayload,\n onChangePayload,\n onConfigurePayload,\n beforeBroadcastStatelessPayload, Hocuspocus} from '@hocuspocus/server'\nimport {\n IncomingMessage,\n OutgoingMessage,\n MessageReceiver,\n} from '@hocuspocus/server'\n\nexport type RedisInstance = RedisClient.Cluster | RedisClient.Redis\n\nexport interface Configuration {\n /**\n * Redis port\n */\n port: number,\n /**\n * Redis host\n */\n host: string,\n /**\n * Redis Cluster\n */\n nodes?: ClusterNode[],\n /**\n * Duplicate from an existed Redis instance\n */\n redis?: RedisInstance,\n /**\n * Redis instance creator\n */\n createClient?: () => RedisInstance,\n /**\n * Options passed directly to Redis constructor\n *\n * https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options\n */\n options?: ClusterOptions | RedisOptions,\n /**\n * An unique instance name, required to filter messages in Redis.\n * If none is provided an unique id is generated.\n */\n identifier: string,\n /**\n * Namespace for Redis keys, if none is provided 'hocuspocus' is used\n */\n prefix: string,\n /**\n * The maximum time for the Redis lock in ms (in case it can’t be released).\n */\n lockTimeout: number,\n /**\n * A delay before onDisconnect is executed. This allows last minute updates'\n * sync messages to be received by the subscription before it's closed.\n */\n disconnectDelay: number,\n}\n\nexport class Redis implements Extension {\n /**\n * Make sure to give that extension a higher priority, so\n * the `onStoreDocument` hook is able to intercept the chain,\n * before documents are stored to the database.\n */\n priority = 1000\n\n configuration: Configuration = {\n port: 6379,\n host: '127.0.0.1',\n prefix: 'hocuspocus',\n identifier: `host-${uuid()}`,\n lockTimeout: 1000,\n disconnectDelay: 1000,\n }\n\n redisTransactionOrigin = '__hocuspocus__redis__origin__'\n\n pub: RedisInstance\n\n sub: RedisInstance\n\n instance!: Hocuspocus\n\n redlock: Redlock\n\n locks = new Map<string, Redlock.Lock>()\n\n messagePrefix: Buffer\n\n /**\n * When we have a high frequency of updates to a document we don't need tons of setTimeouts\n * piling up, so we'll track them to keep it to the most recent per document.\n */\n private pendingDisconnects = new Map<string, NodeJS.Timeout>()\n\n private pendingAfterStoreDocumentResolves = new Map<string, { timeout: NodeJS.Timeout; resolve:() => void }>()\n\n public constructor(configuration: Partial<Configuration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n\n // Create Redis instance\n const {\n port,\n host,\n options,\n nodes,\n redis,\n createClient,\n } = this.configuration\n\n if (typeof createClient === 'function') {\n this.pub = createClient()\n this.sub = createClient()\n } else if (redis) {\n this.pub = redis.duplicate()\n this.sub = redis.duplicate()\n } else if (nodes && nodes.length > 0) {\n this.pub = new RedisClient.Cluster(nodes, options)\n this.sub = new RedisClient.Cluster(nodes, options)\n } else {\n this.pub = new RedisClient(port, host, options)\n this.sub = new RedisClient(port, host, options)\n }\n this.sub.on('messageBuffer', this.handleIncomingMessage)\n\n this.redlock = new Redlock([this.pub], {\n retryCount: 0,\n })\n\n const identifierBuffer = Buffer.from(this.configuration.identifier, 'utf-8')\n this.messagePrefix = Buffer.concat([Buffer.from([identifierBuffer.length]), identifierBuffer])\n }\n\n async onConfigure({ instance }: onConfigurePayload) {\n this.instance = instance\n }\n\n private getKey(documentName: string) {\n return `${this.configuration.prefix}:${documentName}`\n }\n\n private pubKey(documentName: string) {\n return this.getKey(documentName)\n }\n\n private subKey(documentName: string) {\n return this.getKey(documentName)\n }\n\n private lockKey(documentName: string) {\n return `${this.getKey(documentName)}:lock`\n }\n\n private encodeMessage(message: Uint8Array) {\n return Buffer.concat([this.messagePrefix, Buffer.from(message)])\n }\n\n private decodeMessage(buffer: Buffer) {\n const identifierLength = buffer[0]\n const identifier = buffer.toString('utf-8', 1, identifierLength + 1)\n\n return [identifier, buffer.slice(identifierLength + 1)]\n }\n\n /**\n * Once a document is loaded, subscribe to the channel in Redis.\n */\n public async afterLoadDocument({ documentName, document }: afterLoadDocumentPayload) {\n return new Promise((resolve, reject) => {\n // On document creation the node will connect to pub and sub channels\n // for the document.\n this.sub.subscribe(this.subKey(documentName), async error => {\n if (error) {\n reject(error)\n return\n }\n\n this.publishFirstSyncStep(documentName, document)\n this.requestAwarenessFromOtherInstances(documentName)\n\n resolve(undefined)\n })\n })\n }\n\n /**\n * Publish the first sync step through Redis.\n */\n private async publishFirstSyncStep(documentName: string, document: Document) {\n const syncMessage = new OutgoingMessage(documentName)\n .createSyncMessage()\n .writeFirstSyncStepFor(document)\n\n return this.pub.publishBuffer(this.pubKey(documentName), this.encodeMessage(syncMessage.toUint8Array()))\n }\n\n /**\n * Let’s ask Redis who is connected already.\n */\n private async requestAwarenessFromOtherInstances(documentName: string) {\n const awarenessMessage = new OutgoingMessage(documentName)\n .writeQueryAwareness()\n\n return this.pub.publishBuffer(\n this.pubKey(documentName),\n this.encodeMessage(awarenessMessage.toUint8Array()),\n )\n }\n\n /**\n * Before the document is stored, make sure to set a lock in Redis.\n * That’s meant to avoid conflicts with other instances trying to store the document.\n */\n async onStoreDocument({ documentName }: onStoreDocumentPayload) {\n // Attempt to acquire a lock and read lastReceivedTimestamp from Redis,\n // to avoid conflict with other instances storing the same document.\n\n return new Promise((resolve, reject) => {\n this.redlock.lock(this.lockKey(documentName), this.configuration.lockTimeout, async (error, lock) => {\n if (error || !lock) {\n // Expected behavior: Could not acquire lock, another instance locked it already.\n // No further `onStoreDocument` hooks will be executed.\n console.log('unable to acquire lock')\n reject()\n return\n }\n\n this.locks.set(this.lockKey(documentName), lock)\n\n resolve(undefined)\n })\n })\n }\n\n /**\n * Release the Redis lock, so other instances can store documents.\n */\n async afterStoreDocument({ documentName, socketId }: afterStoreDocumentPayload) {\n this.locks.get(this.lockKey(documentName))?.unlock()\n .catch(() => {\n // Not able to unlock Redis. The lock will expire after ${lockTimeout} ms.\n // console.error(`Not able to unlock Redis. The lock will expire after ${this.configuration.lockTimeout}ms.`)\n })\n .finally(() => {\n this.locks.delete(this.lockKey(documentName))\n })\n\n // if the change was initiated by a directConnection, we need to delay this hook to make sure sync can finish first.\n // for provider connections, this usually happens in the onDisconnect hook\n if (socketId === 'server') {\n const pending = this.pendingAfterStoreDocumentResolves.get(documentName)\n\n if (pending) {\n clearTimeout(pending.timeout)\n pending.resolve()\n this.pendingAfterStoreDocumentResolves.delete(documentName)\n }\n\n let resolveFunction: () => void = () => {}\n const delayedPromise = new Promise<void>(resolve => {\n resolveFunction = resolve\n })\n\n const timeout = setTimeout(() => {\n this.pendingAfterStoreDocumentResolves.delete(documentName)\n resolveFunction()\n }, this.configuration.disconnectDelay)\n\n this.pendingAfterStoreDocumentResolves.set(documentName, { timeout, resolve: resolveFunction })\n\n await delayedPromise\n }\n }\n\n /**\n * Handle awareness update messages received directly by this Hocuspocus instance.\n */\n async onAwarenessUpdate({\n documentName, awareness, added, updated, removed,\n }: onAwarenessUpdatePayload) {\n const changedClients = added.concat(updated, removed)\n const message = new OutgoingMessage(documentName)\n .createAwarenessUpdateMessage(awareness, changedClients)\n\n return this.pub.publishBuffer(\n this.pubKey(documentName),\n this.encodeMessage(message.toUint8Array()),\n )\n }\n\n /**\n * Handle incoming messages published on subscribed document channels.\n * Note that this will also include messages from ourselves as it is not possible\n * in Redis to filter these.\n */\n private handleIncomingMessage = async (channel: Buffer, data: Buffer) => {\n const [identifier, messageBuffer] = this.decodeMessage(data)\n\n if (identifier === this.configuration.identifier) {\n return\n }\n\n const message = new IncomingMessage(messageBuffer)\n const documentName = message.readVarString()\n message.writeVarString(documentName)\n\n const document = this.instance.documents.get(documentName)\n\n if (!document) {\n return\n }\n\n new MessageReceiver(\n message,\n this.redisTransactionOrigin,\n ).apply(document, undefined, reply => {\n return this.pub.publishBuffer(\n this.pubKey(document.name),\n this.encodeMessage(reply),\n )\n })\n }\n\n /**\n * if the ydoc changed, we'll need to inform other Hocuspocus servers about it.\n */\n public async onChange(data: onChangePayload): Promise<any> {\n if (data.transactionOrigin !== this.redisTransactionOrigin) {\n return this.publishFirstSyncStep(data.documentName, data.document)\n }\n }\n\n /**\n * Make sure to *not* listen for further changes, when there’s\n * no one connected anymore.\n */\n public onDisconnect = async ({ documentName }: onDisconnectPayload) => {\n const pending = this.pendingDisconnects.get(documentName)\n\n if (pending) {\n clearTimeout(pending)\n this.pendingDisconnects.delete(documentName)\n }\n\n const disconnect = () => {\n const document = this.instance.documents.get(documentName)\n\n this.pendingDisconnects.delete(documentName)\n\n // Do nothing, when other users are still connected to the document.\n if (!document || document.getConnectionsCount() > 0) {\n return\n }\n\n // Time to end the subscription on the document channel.\n this.sub.unsubscribe(this.subKey(documentName), (error: any) => {\n if (error) {\n console.error(error)\n }\n })\n\n this.instance.unloadDocument(document)\n }\n // Delay the disconnect procedure to allow last minute syncs to happen\n const timeout = setTimeout(disconnect, this.configuration.disconnectDelay)\n this.pendingDisconnects.set(documentName, timeout)\n }\n\n async beforeBroadcastStateless(data: beforeBroadcastStatelessPayload) {\n const message = new OutgoingMessage(data.documentName)\n .writeBroadcastStateless(data.payload)\n\n return this.pub.publishBuffer(\n this.pubKey(data.documentName),\n this.encodeMessage(message.toUint8Array()),\n )\n }\n\n /**\n * Kill the Redlock connection imm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E,OAAO,CAAC;AACrD,QAAA,MAAM,OAAO,GAAG,IAAI,eAAe,CAAC,YAAY;AAC7C,aAAA,4BAA4B,CAAC,SAAS,EAAE,cAAc,CAAC;QAE1D,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAC3B,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EACzB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAC3C;;AAoCH;;AAEG;IACI,MAAM,QAAQ,CAAC,IAAqB,EAAA;QACzC,IAAI,IAAI,CAAC,iBAAiB,KAAK,IAAI,CAAC,sBAAsB,EAAE;AAC1D,YAAA,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC;;;IAwCtE,MAAM,wBAAwB,CAAC,IAAqC,EAAA;QAClE,MAAM,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,YAAY;AAClD,aAAA,uBAAuB,CAAC,IAAI,CAAC,OAAO,CAAC;QAExC,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAC3B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,EAC9B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAC3C;;AAGH;;AAEG;AACH,IAAA,MAAM,SAAS,GAAA;AACb,QAAA,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;AACzB,QAAA,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC;AAC1B,QAAA,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC;;AAE7B;;;;"}
@@ -2,5 +2,5 @@ import * as encoding from 'lib0/encoding';
2
2
  import * as decoding from 'lib0/decoding';
3
3
  export declare const writeAuthentication: (encoder: encoding.Encoder, auth: string) => void;
4
4
  export declare const writePermissionDenied: (encoder: encoding.Encoder, reason: string) => void;
5
- export declare const writeAuthenticated: (encoder: encoding.Encoder, scope: 'readonly' | 'read-write') => void;
5
+ export declare const writeAuthenticated: (encoder: encoding.Encoder, scope: "readonly" | "read-write") => void;
6
6
  export declare const readAuthMessage: (decoder: decoding.Decoder, permissionDeniedHandler: (reason: string) => void, authenticatedHandler: (scope: string) => void) => void;
@@ -1,4 +1,4 @@
1
- export * from './auth.js';
2
- export * from './CloseEvents.js';
3
- export * from './awarenessStatesToArray.js';
4
- export * from './types.js';
1
+ export * from './auth.ts';
2
+ export * from './CloseEvents.ts';
3
+ export * from './awarenessStatesToArray.ts';
4
+ export * from './types.ts';
@@ -1 +1 @@
1
- export * from './Database.js';
1
+ export * from './Database.ts';
@@ -1 +1 @@
1
- export * from './Logger.js';
1
+ export * from './Logger.ts';
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import type { ClusterNode, ClusterOptions, RedisOptions } from 'ioredis';
4
2
  import RedisClient from 'ioredis';
5
3
  import Redlock from 'redlock';
@@ -1 +1 @@
1
- export * from './Redis.js';
1
+ export * from './Redis.ts';
@@ -1 +1 @@
1
- export * from './SQLite.js';
1
+ export * from './SQLite.ts';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { Extension, onConnectPayload } from '@hocuspocus/server';
3
2
  export interface ThrottleConfiguration {
4
3
  throttle: number | null | false;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { Extension, onChangePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload } from '@hocuspocus/server';
3
2
  import type { Doc } from 'yjs';
4
3
  import type { Transformer } from '@hocuspocus/transformer';
@@ -1,10 +1,10 @@
1
1
  import type { Event, MessageEvent } from 'ws';
2
2
  import { Awareness } from 'y-protocols/awareness';
3
3
  import * as Y from 'yjs';
4
- import EventEmitter from './EventEmitter.js';
5
- import type { CompleteHocuspocusProviderWebsocketConfiguration } from './HocuspocusProviderWebsocket.js';
6
- import { HocuspocusProviderWebsocket } from './HocuspocusProviderWebsocket.js';
7
- import type { ConstructableOutgoingMessage, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onSyncedParameters } from './types.js';
4
+ import EventEmitter from './EventEmitter.ts';
5
+ import type { CompleteHocuspocusProviderWebsocketConfiguration } from './HocuspocusProviderWebsocket.ts';
6
+ import { HocuspocusProviderWebsocket } from './HocuspocusProviderWebsocket.ts';
7
+ import type { ConstructableOutgoingMessage, onAuthenticatedParameters, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onSyncedParameters, onUnsyncedChangesParameters } from './types.ts';
8
8
  export type HocuspocusProviderConfiguration = Required<Pick<CompleteHocuspocusProviderConfiguration, 'name'>> & Partial<CompleteHocuspocusProviderConfiguration> & (Required<Pick<CompleteHocuspocusProviderWebsocketConfiguration, 'url'>> | Required<Pick<CompleteHocuspocusProviderConfiguration, 'websocketProvider'>>);
9
9
  export interface CompleteHocuspocusProviderConfiguration {
10
10
  /**
@@ -36,7 +36,7 @@ export interface CompleteHocuspocusProviderConfiguration {
36
36
  * Force syncing the document in the defined interval.
37
37
  */
38
38
  forceSyncInterval: false | number;
39
- onAuthenticated: () => void;
39
+ onAuthenticated: (data: onAuthenticatedParameters) => void;
40
40
  onAuthenticationFailed: (data: onAuthenticationFailedParameters) => void;
41
41
  onOpen: (data: onOpenParameters) => void;
42
42
  onConnect: () => void;
@@ -49,6 +49,7 @@ export interface CompleteHocuspocusProviderConfiguration {
49
49
  onAwarenessUpdate: (data: onAwarenessUpdateParameters) => void;
50
50
  onAwarenessChange: (data: onAwarenessChangeParameters) => void;
51
51
  onStateless: (data: onStatelessParameters) => void;
52
+ onUnsyncedChanges: (data: onUnsyncedChangesParameters) => void;
52
53
  }
53
54
  export declare class AwarenessError extends Error {
54
55
  code: number;
@@ -60,7 +61,7 @@ export declare class HocuspocusProvider extends EventEmitter {
60
61
  isAuthenticated: boolean;
61
62
  authorizedScope: string | undefined;
62
63
  manageSocket: boolean;
63
- private isAttached;
64
+ private _isAttached;
64
65
  intervals: any;
65
66
  constructor(configuration: HocuspocusProviderConfiguration);
66
67
  boundDocumentUpdateHandler: (update: Uint8Array, origin: any) => void;
@@ -74,6 +75,7 @@ export declare class HocuspocusProvider extends EventEmitter {
74
75
  forwardDestroy: (e: any) => this;
75
76
  setConfiguration(configuration?: Partial<HocuspocusProviderConfiguration>): void;
76
77
  get document(): Y.Doc;
78
+ get isAttached(): boolean;
77
79
  get awareness(): Awareness | null;
78
80
  get hasUnsyncedChanges(): boolean;
79
81
  private resetUnsyncedChanges;
@@ -94,7 +96,7 @@ export declare class HocuspocusProvider extends EventEmitter {
94
96
  get synced(): boolean;
95
97
  set synced(state: boolean);
96
98
  receiveStateless(payload: string): void;
97
- connect(): Promise<void>;
99
+ connect(): Promise<unknown>;
98
100
  disconnect(): void;
99
101
  onOpen(event: Event): Promise<void>;
100
102
  getToken(): Promise<string | null>;
@@ -1,8 +1,8 @@
1
1
  import type { MessageEvent, Event } from 'ws';
2
- import EventEmitter from './EventEmitter.js';
3
- import type { HocuspocusProvider } from './HocuspocusProvider.js';
4
- import type { onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters } from './types.js';
5
- import { WebSocketStatus } from './types.js';
2
+ import EventEmitter from './EventEmitter.ts';
3
+ import type { HocuspocusProvider } from './HocuspocusProvider.ts';
4
+ import type { onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters } from './types.ts';
5
+ import { WebSocketStatus } from './types.ts';
6
6
  export type HocusPocusWebSocket = WebSocket & {
7
7
  identifier: string;
8
8
  };
@@ -95,9 +95,7 @@ export declare class HocuspocusProviderWebsocket extends EventEmitter {
95
95
  } | null;
96
96
  constructor(configuration: HocuspocusProviderWebsocketConfiguration);
97
97
  receivedOnOpenPayload?: Event | undefined;
98
- receivedOnStatusPayload?: onStatusParameters | undefined;
99
98
  onOpen(event: Event): Promise<void>;
100
- onStatus(data: onStatusParameters): Promise<void>;
101
99
  attach(provider: HocuspocusProvider): void;
102
100
  detach(provider: HocuspocusProvider): void;
103
101
  setConfiguration(configuration?: Partial<HocuspocusProviderWebsocketConfiguration>): void;
@@ -1,6 +1,6 @@
1
1
  import type { Decoder } from 'lib0/decoding';
2
2
  import type { Encoder } from 'lib0/encoding';
3
- import type { MessageType } from './types.js';
3
+ import type { MessageType } from './types.ts';
4
4
  export declare class IncomingMessage {
5
5
  data: any;
6
6
  encoder: Encoder;
@@ -9,7 +9,7 @@ export declare class IncomingMessage {
9
9
  peekVarString(): string;
10
10
  readVarUint(): MessageType;
11
11
  readVarString(): string;
12
- readVarUint8Array(): Uint8Array;
12
+ readVarUint8Array(): Uint8Array<ArrayBufferLike>;
13
13
  writeVarUint(type: MessageType): void;
14
14
  writeVarString(string: string): void;
15
15
  writeVarUint8Array(data: Uint8Array): void;
@@ -1,5 +1,5 @@
1
- import type { HocuspocusProvider } from './HocuspocusProvider.js';
2
- import type { IncomingMessage } from './IncomingMessage.js';
1
+ import type { HocuspocusProvider } from './HocuspocusProvider.ts';
2
+ import type { IncomingMessage } from './IncomingMessage.ts';
3
3
  export declare class MessageReceiver {
4
4
  message: IncomingMessage;
5
5
  constructor(message: IncomingMessage);
@@ -1,10 +1,10 @@
1
1
  import type { Encoder } from 'lib0/encoding';
2
- import type { ConstructableOutgoingMessage } from './types.js';
2
+ import type { ConstructableOutgoingMessage } from './types.ts';
3
3
  export declare class MessageSender {
4
4
  encoder: Encoder;
5
5
  message: any;
6
6
  constructor(Message: ConstructableOutgoingMessage, args?: any);
7
- create(): Uint8Array;
7
+ create(): Uint8Array<ArrayBufferLike>;
8
8
  send(webSocket: any): void;
9
9
  broadcast(channel: string): void;
10
10
  }
@@ -1,9 +1,9 @@
1
1
  import type { Encoder } from 'lib0/encoding';
2
- import type { MessageType, OutgoingMessageArguments, OutgoingMessageInterface } from './types.js';
2
+ import type { MessageType, OutgoingMessageArguments, OutgoingMessageInterface } from './types.ts';
3
3
  export declare class OutgoingMessage implements OutgoingMessageInterface {
4
4
  encoder: Encoder;
5
5
  type?: MessageType;
6
6
  constructor();
7
7
  get(args: Partial<OutgoingMessageArguments>): Encoder | undefined;
8
- toUint8Array(): Uint8Array;
8
+ toUint8Array(): Uint8Array<ArrayBufferLike>;
9
9
  }
@@ -1,6 +1,6 @@
1
- import type { OutgoingMessageArguments } from '../types.js';
2
- import { MessageType } from '../types.js';
3
- import { OutgoingMessage } from '../OutgoingMessage.js';
1
+ import type { OutgoingMessageArguments } from '../types.ts';
2
+ import { MessageType } from '../types.ts';
3
+ import { OutgoingMessage } from '../OutgoingMessage.ts';
4
4
  export declare class AuthenticationMessage extends OutgoingMessage {
5
5
  type: MessageType;
6
6
  description: string;
@@ -1,7 +1,7 @@
1
1
  import * as encoding from 'lib0/encoding';
2
- import type { OutgoingMessageArguments } from '../types.js';
3
- import { MessageType } from '../types.js';
4
- import { OutgoingMessage } from '../OutgoingMessage.js';
2
+ import type { OutgoingMessageArguments } from '../types.ts';
3
+ import { MessageType } from '../types.ts';
4
+ import { OutgoingMessage } from '../OutgoingMessage.ts';
5
5
  export declare class AwarenessMessage extends OutgoingMessage {
6
6
  type: MessageType;
7
7
  description: string;
@@ -1,7 +1,7 @@
1
1
  import * as encoding from 'lib0/encoding';
2
- import type { OutgoingMessageArguments } from '../types.js';
3
- import { MessageType } from '../types.js';
4
- import { OutgoingMessage } from '../OutgoingMessage.js';
2
+ import type { OutgoingMessageArguments } from '../types.ts';
3
+ import { MessageType } from '../types.ts';
4
+ import { OutgoingMessage } from '../OutgoingMessage.ts';
5
5
  export declare class CloseMessage extends OutgoingMessage {
6
6
  type: MessageType;
7
7
  description: string;
@@ -1,7 +1,7 @@
1
1
  import * as encoding from 'lib0/encoding';
2
- import type { OutgoingMessageArguments } from '../types.js';
3
- import { MessageType } from '../types.js';
4
- import { OutgoingMessage } from '../OutgoingMessage.js';
2
+ import type { OutgoingMessageArguments } from '../types.ts';
3
+ import { MessageType } from '../types.ts';
4
+ import { OutgoingMessage } from '../OutgoingMessage.ts';
5
5
  export declare class QueryAwarenessMessage extends OutgoingMessage {
6
6
  type: MessageType;
7
7
  description: string;
@@ -1,6 +1,6 @@
1
- import type { OutgoingMessageArguments } from '../types.js';
2
- import { MessageType } from '../types.js';
3
- import { OutgoingMessage } from '../OutgoingMessage.js';
1
+ import type { OutgoingMessageArguments } from '../types.ts';
2
+ import { MessageType } from '../types.ts';
3
+ import { OutgoingMessage } from '../OutgoingMessage.ts';
4
4
  export declare class StatelessMessage extends OutgoingMessage {
5
5
  type: MessageType;
6
6
  description: string;
@@ -1,7 +1,7 @@
1
1
  import * as encoding from 'lib0/encoding';
2
- import type { OutgoingMessageArguments } from '../types.js';
3
- import { MessageType } from '../types.js';
4
- import { OutgoingMessage } from '../OutgoingMessage.js';
2
+ import type { OutgoingMessageArguments } from '../types.ts';
3
+ import { MessageType } from '../types.ts';
4
+ import { OutgoingMessage } from '../OutgoingMessage.ts';
5
5
  export declare class SyncStepOneMessage extends OutgoingMessage {
6
6
  type: MessageType;
7
7
  description: string;
@@ -1,7 +1,7 @@
1
1
  import * as encoding from 'lib0/encoding';
2
- import type { OutgoingMessageArguments } from '../types.js';
3
- import { MessageType } from '../types.js';
4
- import { OutgoingMessage } from '../OutgoingMessage.js';
2
+ import type { OutgoingMessageArguments } from '../types.ts';
3
+ import { MessageType } from '../types.ts';
4
+ import { OutgoingMessage } from '../OutgoingMessage.ts';
5
5
  export declare class SyncStepTwoMessage extends OutgoingMessage {
6
6
  type: MessageType;
7
7
  description: string;
@@ -1,6 +1,6 @@
1
- import type { OutgoingMessageArguments } from '../types.js';
2
- import { MessageType } from '../types.js';
3
- import { OutgoingMessage } from '../OutgoingMessage.js';
1
+ import type { OutgoingMessageArguments } from '../types.ts';
2
+ import { MessageType } from '../types.ts';
3
+ import { OutgoingMessage } from '../OutgoingMessage.ts';
4
4
  export declare class UpdateMessage extends OutgoingMessage {
5
5
  type: MessageType;
6
6
  description: string;
@@ -1,3 +1,3 @@
1
- export * from './HocuspocusProvider.js';
2
- export * from './HocuspocusProviderWebsocket.js';
3
- export * from './types.js';
1
+ export * from './HocuspocusProvider.ts';
2
+ export * from './HocuspocusProviderWebsocket.ts';
3
+ export * from './types.ts';
@@ -3,14 +3,14 @@ import type { Event, MessageEvent } from 'ws';
3
3
  import type { Awareness } from 'y-protocols/awareness';
4
4
  import type * as Y from 'yjs';
5
5
  import type { CloseEvent } from '@hocuspocus/common';
6
- import type { IncomingMessage } from './IncomingMessage.js';
7
- import type { OutgoingMessage } from './OutgoingMessage.js';
8
- import type { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage.js';
9
- import type { AwarenessMessage } from './OutgoingMessages/AwarenessMessage.js';
10
- import type { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage.js';
11
- import type { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage.js';
12
- import type { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage.js';
13
- import type { UpdateMessage } from './OutgoingMessages/UpdateMessage.js';
6
+ import type { IncomingMessage } from './IncomingMessage.ts';
7
+ import type { OutgoingMessage } from './OutgoingMessage.ts';
8
+ import type { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage.ts';
9
+ import type { AwarenessMessage } from './OutgoingMessages/AwarenessMessage.ts';
10
+ import type { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage.ts';
11
+ import type { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage.ts';
12
+ import type { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage.ts';
13
+ import type { UpdateMessage } from './OutgoingMessages/UpdateMessage.ts';
14
14
  export declare enum MessageType {
15
15
  Sync = 0,
16
16
  Awareness = 1,
@@ -49,6 +49,9 @@ export type ConstructableOutgoingMessage = Constructable<AuthenticationMessage>
49
49
  export type onAuthenticationFailedParameters = {
50
50
  reason: string;
51
51
  };
52
+ export type onAuthenticatedParameters = {
53
+ scope: 'read-write' | 'readonly';
54
+ };
52
55
  export type onOpenParameters = {
53
56
  event: Event;
54
57
  };
@@ -65,6 +68,9 @@ export type onStatusParameters = {
65
68
  export type onSyncedParameters = {
66
69
  state: boolean;
67
70
  };
71
+ export type onUnsyncedChangesParameters = {
72
+ number: number;
73
+ };
68
74
  export type onDisconnectParameters = {
69
75
  event: CloseEvent;
70
76
  };
@@ -84,103 +90,3 @@ export type StatesArray = {
84
90
  clientId: number;
85
91
  [key: string | number]: any;
86
92
  }[];
87
- export type TCollabThread<Data = any, CommentData = any> = {
88
- id: string;
89
- createdAt: number;
90
- updatedAt: number;
91
- deletedAt: number | null;
92
- resolvedAt?: string;
93
- comments: TCollabComment<CommentData>[];
94
- deletedComments: TCollabComment<CommentData>[];
95
- data: Data;
96
- };
97
- export type TCollabComment<Data = any> = {
98
- id: string;
99
- createdAt: string;
100
- updatedAt: string;
101
- deletedAt?: string;
102
- data: Data;
103
- content: any;
104
- };
105
- export type THistoryVersion = {
106
- name?: string;
107
- version: number;
108
- date: number;
109
- };
110
- export type THistoryConfiguration = {
111
- autoVersioning: boolean;
112
- currentVersion: number;
113
- stateCaptured: number;
114
- };
115
- export type THistoryAction = THistoryDocumentRevertAction | THistoryVersionCreateAction | THistoryVersionPreviewAction;
116
- export type THistoryDocumentRevertAction = {
117
- action: 'document.revert';
118
- /**
119
- * if changes haven't been persisted to a version yet, we'll create one with the specified name,
120
- * expect when `false` is passed.
121
- */
122
- currentVersionName?: string | false;
123
- /**
124
- * Name of the version that is created after the revert. Pass `false` to avoid generating a new version.
125
- */
126
- newVersionName?: string | false;
127
- };
128
- export type THistoryVersionCreateAction = {
129
- action: 'version.create';
130
- name?: string;
131
- };
132
- export type THistoryVersionPreviewAction = {
133
- action: 'version.preview';
134
- version: number;
135
- };
136
- export type THistoryEvent = THistoryVersionPreviewEvent | THistoryVersionCreatedEvent | THistoryDocumentRevertedEvent;
137
- export type THistoryVersionCreatedEvent = {
138
- event: 'version.created';
139
- version: number;
140
- };
141
- export type THistoryVersionPreviewEvent = {
142
- event: 'version.preview';
143
- version: number;
144
- ydoc: string;
145
- };
146
- export type THistoryDocumentRevertedEvent = {
147
- event: 'document.reverted';
148
- version: number;
149
- };
150
- export type DeleteCommentOptions = {
151
- /**
152
- * If `true`, the thread will also be deleted if the deleted comment was the first comment in the thread.
153
- */
154
- deleteThread?: boolean;
155
- /**
156
- * If `true`, will remove the content of the deleted comment
157
- */
158
- deleteContent?: boolean;
159
- };
160
- export type DeleteThreadOptions = {
161
- /**
162
- * If `true`, will remove the comments on the thread,
163
- * otherwise will only mark the thread as deleted
164
- * and keep the comments
165
- * @default false
166
- */
167
- deleteComments?: boolean;
168
- /**
169
- * If `true`, will forcefully remove the thread and all comments,
170
- * otherwise will only mark the thread as deleted
171
- * and keep the comments
172
- * @default false
173
- */
174
- force?: boolean;
175
- };
176
- /**
177
- * The type of thread
178
- */
179
- export type ThreadType = 'archived' | 'unarchived';
180
- export type GetThreadsOptions = {
181
- /**
182
- * The types of threads to get
183
- * @default ['unarchived']
184
- */
185
- types?: Array<ThreadType>;
186
- };
@@ -1,11 +1,9 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import type { IncomingMessage } from 'http';
4
2
  import { type CloseEvent } from '@hocuspocus/common';
5
3
  import type WebSocket from 'ws';
6
- import type Document from './Document.js';
7
- import type { Hocuspocus } from './Hocuspocus.js';
8
- import type { onDisconnectPayload } from './types.js';
4
+ import type Document from './Document.ts';
5
+ import type { Hocuspocus } from './Hocuspocus.ts';
6
+ import type { onDisconnectPayload } from './types.ts';
9
7
  /**
10
8
  * The `ClientConnection` class is responsible for handling an incoming WebSocket
11
9
  *
@@ -1,15 +1,19 @@
1
- /// <reference types="node" />
2
1
  import type { IncomingMessage as HTTPIncomingMessage } from 'http';
3
- import type WebSocket from 'ws';
4
2
  import { type CloseEvent } from '@hocuspocus/common';
5
- import type Document from './Document.js';
6
- import type { onStatelessPayload } from './types.js';
3
+ import type WebSocket from 'ws';
4
+ import type Document from './Document.ts';
5
+ import type { beforeSyncPayload, onStatelessPayload } from './types.ts';
7
6
  export declare class Connection {
8
7
  webSocket: WebSocket;
9
8
  context: any;
10
9
  document: Document;
11
10
  request: HTTPIncomingMessage;
12
- callbacks: any;
11
+ callbacks: {
12
+ onClose: ((document: Document, event?: CloseEvent) => void)[];
13
+ beforeHandleMessage: (connection: Connection, update: Uint8Array) => Promise<void>;
14
+ beforeSync: (connection: Connection, payload: Pick<beforeSyncPayload, "type" | "payload">) => Promise<void>;
15
+ statelessCallback: (payload: onStatelessPayload) => Promise<void>;
16
+ };
13
17
  socketId: string;
14
18
  readOnly: boolean;
15
19
  /**
@@ -28,6 +32,10 @@ export declare class Connection {
28
32
  * Set a callback that will be triggered before an message is handled
29
33
  */
30
34
  beforeHandleMessage(callback: (connection: Connection, update: Uint8Array) => Promise<any>): Connection;
35
+ /**
36
+ * Set a callback that will be triggered before a sync message is handled
37
+ */
38
+ beforeSync(callback: (connection: Connection, payload: Pick<beforeSyncPayload, 'type' | 'payload'>) => Promise<any>): Connection;
31
39
  /**
32
40
  * Send the given message
33
41
  */
@@ -1,6 +1,6 @@
1
- import type Document from './Document.js';
2
- import type { Hocuspocus } from './Hocuspocus.js';
3
- import type { DirectConnection as DirectConnectionInterface } from './types.js';
1
+ import type Document from './Document.ts';
2
+ import type { Hocuspocus } from './Hocuspocus.ts';
3
+ import type { DirectConnection as DirectConnectionInterface } from './types.ts';
4
4
  export declare class DirectConnection implements DirectConnectionInterface {
5
5
  document: Document | null;
6
6
  instance: Hocuspocus;
@@ -1,7 +1,7 @@
1
1
  import type WebSocket from 'ws';
2
2
  import { Awareness } from 'y-protocols/awareness';
3
3
  import { Doc } from 'yjs';
4
- import type Connection from './Connection.js';
4
+ import type Connection from './Connection.ts';
5
5
  export declare class Document extends Doc {
6
6
  awareness: Awareness;
7
7
  callbacks: {
@@ -1,10 +1,9 @@
1
- /// <reference types="node" />
2
1
  import type { IncomingMessage } from 'http';
3
2
  import type WebSocket from 'ws';
4
- import type { Server } from './Server.js';
5
- import { DirectConnection } from './DirectConnection.js';
6
- import Document from './Document.js';
7
- import type { Configuration, ConnectionConfiguration, HookName, HookPayloadByName, onStoreDocumentPayload } from './types.js';
3
+ import { DirectConnection } from './DirectConnection.ts';
4
+ import Document from './Document.ts';
5
+ import type { Server } from './Server.ts';
6
+ import type { Configuration, ConnectionConfiguration, HookName, HookPayloadByName, onStoreDocumentPayload } from './types.ts';
8
7
  export declare const defaultConfiguration: {
9
8
  name: null;
10
9
  timeout: number;
@@ -1,6 +1,6 @@
1
1
  import type { Decoder } from 'lib0/decoding';
2
2
  import type { Encoder } from 'lib0/encoding';
3
- import type { MessageType } from './types.js';
3
+ import type { MessageType } from './types.ts';
4
4
  export declare class IncomingMessage {
5
5
  /**
6
6
  * Access to the received message.
@@ -14,10 +14,11 @@ export declare class IncomingMessage {
14
14
  private encoderInternal?;
15
15
  constructor(input: any);
16
16
  get encoder(): Encoder;
17
- readVarUint8Array(): Uint8Array;
17
+ readVarUint8Array(): Uint8Array<ArrayBufferLike>;
18
+ peekVarUint8Array(): Uint8Array<ArrayBufferLike>;
18
19
  readVarUint(): number;
19
20
  readVarString(): string;
20
- toUint8Array(): Uint8Array;
21
+ toUint8Array(): Uint8Array<ArrayBufferLike>;
21
22
  writeVarUint(type: MessageType): void;
22
23
  writeVarString(string: string): void;
23
24
  get length(): number;
@@ -1,11 +1,11 @@
1
- import type Connection from './Connection.js';
2
- import type Document from './Document.js';
3
- import type { IncomingMessage } from './IncomingMessage.js';
1
+ import type Connection from './Connection.ts';
2
+ import type Document from './Document.ts';
3
+ import type { IncomingMessage } from './IncomingMessage.ts';
4
4
  export declare class MessageReceiver {
5
5
  message: IncomingMessage;
6
6
  defaultTransactionOrigin?: string;
7
7
  constructor(message: IncomingMessage, defaultTransactionOrigin?: string);
8
- apply(document: Document, connection?: Connection, reply?: (message: Uint8Array) => void): void;
9
- readSyncMessage(message: IncomingMessage, document: Document, connection?: Connection, reply?: (message: Uint8Array) => void, requestFirstSync?: boolean): 0 | 1 | 2;
8
+ apply(document: Document, connection?: Connection, reply?: (message: Uint8Array) => void): Promise<void>;
9
+ readSyncMessage(message: IncomingMessage, document: Document, connection?: Connection, reply?: (message: Uint8Array) => void, requestFirstSync?: boolean): Promise<0 | 1 | 2>;
10
10
  applyQueryAwarenessMessage(document: Document, reply?: (message: Uint8Array) => void): void;
11
11
  }
@@ -1,6 +1,6 @@
1
1
  import type { Encoder } from 'lib0/encoding';
2
2
  import type { Awareness } from 'y-protocols/awareness';
3
- import type Document from './Document.js';
3
+ import type Document from './Document.ts';
4
4
  export declare class OutgoingMessage {
5
5
  encoder: Encoder;
6
6
  type?: number;
@@ -1,8 +1,7 @@
1
- /// <reference types="node" />
2
1
  import type { IncomingMessage, Server as HTTPServer, ServerResponse } from 'http';
3
2
  import { WebSocketServer } from 'ws';
4
3
  import type { AddressInfo, ServerOptions } from 'ws';
5
- import { Hocuspocus } from './Hocuspocus.js';
4
+ import { Hocuspocus } from './Hocuspocus.ts';
6
5
  import type { Configuration } from './types';
7
6
  export interface ServerConfiguration extends Configuration {
8
7
  port?: number;
@@ -1,9 +1,9 @@
1
- export * from './Connection.js';
2
- export * from './Document.js';
3
- export * from './Hocuspocus.js';
4
- export * from './IncomingMessage.js';
5
- export * from './MessageReceiver.js';
6
- export * from './OutgoingMessage.js';
7
- export * from './Server.js';
8
- export * from './types.js';
9
- export * from './util/debounce.js';
1
+ export * from './Connection.ts';
2
+ export * from './Document.ts';
3
+ export * from './Hocuspocus.ts';
4
+ export * from './IncomingMessage.ts';
5
+ export * from './MessageReceiver.ts';
6
+ export * from './OutgoingMessage.ts';
7
+ export * from './Server.ts';
8
+ export * from './types.ts';
9
+ export * from './util/debounce.ts';
@@ -1,20 +1,16 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- /// <reference types="node" />
5
1
  import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'http';
6
2
  import type { URLSearchParams } from 'url';
7
3
  import type { Awareness } from 'y-protocols/awareness';
8
- import type Connection from './Connection.js';
9
- import type Document from './Document.js';
10
- import type { Hocuspocus } from './Hocuspocus.js';
4
+ import type Connection from './Connection.ts';
5
+ import type Document from './Document.ts';
6
+ import type { Hocuspocus } from './Hocuspocus.ts';
11
7
  export declare enum MessageType {
12
8
  Unknown = -1,
13
9
  Sync = 0,
14
10
  Awareness = 1,
15
11
  Auth = 2,
16
12
  QueryAwareness = 3,
17
- SyncReply = 4,
13
+ SyncReply = 4,// same as Sync, but won't trigger another 'SyncStep1'
18
14
  Stateless = 5,
19
15
  BroadcastStateless = 6,
20
16
  CLOSE = 7,
@@ -42,6 +38,7 @@ export interface Extension {
42
38
  onLoadDocument?(data: onLoadDocumentPayload): Promise<any>;
43
39
  afterLoadDocument?(data: afterLoadDocumentPayload): Promise<any>;
44
40
  beforeHandleMessage?(data: beforeHandleMessagePayload): Promise<any>;
41
+ beforeSync?(data: beforeSyncPayload): Promise<any>;
45
42
  beforeBroadcastStateless?(data: beforeBroadcastStatelessPayload): Promise<any>;
46
43
  onStateless?(payload: onStatelessPayload): Promise<any>;
47
44
  onChange?(data: onChangePayload): Promise<any>;
@@ -54,7 +51,7 @@ export interface Extension {
54
51
  afterUnloadDocument?(data: afterUnloadDocumentPayload): Promise<any>;
55
52
  onDestroy?(data: onDestroyPayload): Promise<any>;
56
53
  }
57
- export type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' | 'onCreateDocument' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'beforeBroadcastStateless' | 'onStateless' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'beforeUnloadDocument' | 'afterUnloadDocument' | 'onDestroy';
54
+ export type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' | 'onCreateDocument' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'beforeBroadcastStateless' | 'beforeSync' | 'onStateless' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'beforeUnloadDocument' | 'afterUnloadDocument' | 'onDestroy';
58
55
  export type HookPayloadByName = {
59
56
  onConfigure: onConfigurePayload;
60
57
  onListen: onListenPayload;
@@ -67,6 +64,7 @@ export type HookPayloadByName = {
67
64
  afterLoadDocument: afterLoadDocumentPayload;
68
65
  beforeHandleMessage: beforeHandleMessagePayload;
69
66
  beforeBroadcastStateless: beforeBroadcastStatelessPayload;
67
+ beforeSync: beforeSyncPayload;
70
68
  onStateless: onStatelessPayload;
71
69
  onChange: onChangePayload;
72
70
  onStoreDocument: onStoreDocumentPayload;
@@ -211,6 +209,27 @@ export interface beforeHandleMessagePayload {
211
209
  socketId: string;
212
210
  connection: Connection;
213
211
  }
212
+ export interface beforeSyncPayload {
213
+ clientsCount: number;
214
+ context: any;
215
+ document: Document;
216
+ documentName: string;
217
+ connection: Connection;
218
+ /**
219
+ * The y-protocols/sync message type
220
+ * @example
221
+ * 0: SyncStep1
222
+ * 1: SyncStep2
223
+ * 2: YjsUpdate
224
+ *
225
+ * @see https://github.com/yjs/y-protocols/blob/master/sync.js#L13-L40
226
+ */
227
+ type: number;
228
+ /**
229
+ * The payload of the y-sync message.
230
+ */
231
+ payload: Uint8Array;
232
+ }
214
233
  export interface beforeBroadcastStatelessPayload {
215
234
  document: Document;
216
235
  documentName: string;
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import type { IncomingMessage } from 'http';
4
2
  import { URLSearchParams } from 'url';
5
3
  /**
@@ -1,6 +1,6 @@
1
1
  import { Doc } from 'yjs';
2
2
  import { Schema } from '@tiptap/pm/model';
3
- import type { Transformer } from './types.js';
3
+ import type { Transformer } from './types.ts';
4
4
  declare class Prosemirror implements Transformer {
5
5
  defaultSchema: Schema;
6
6
  schema(schema: Schema): Prosemirror;
@@ -1,6 +1,6 @@
1
1
  import type { Doc } from 'yjs';
2
2
  import type { Extensions } from '@tiptap/core';
3
- import type { Transformer } from './types.js';
3
+ import type { Transformer } from './types.ts';
4
4
  export declare class Tiptap implements Transformer {
5
5
  defaultExtensions: Extensions;
6
6
  extensions(extensions: Extensions): Tiptap;
@@ -1,3 +1,3 @@
1
- export * from './Prosemirror.js';
2
- export * from './Tiptap.js';
3
- export * from './types.js';
1
+ export * from './Prosemirror.ts';
2
+ export * from './Tiptap.ts';
3
+ export * from './types.ts';
@@ -0,0 +1,2 @@
1
+ import type { HocuspocusProviderWebsocket } from "@hocuspocus/provider";
2
+ export declare const SocketContext: import("react").Context<HocuspocusProviderWebsocket | null>;
@@ -0,0 +1,3 @@
1
+ import type { NextConfig } from "next";
2
+ declare const nextConfig: NextConfig;
3
+ export default nextConfig;
@@ -1,9 +1,9 @@
1
- export * from './createDirectory.js';
2
- export * from './flushRedis.js';
3
- export * from './newHocuspocus.js';
4
- export * from './newHocuspocusProvider.js';
5
- export * from './newHocuspocusProviderWebsocket.js';
6
- export * from './randomInteger.js';
7
- export * from './redisConnectionSettings.js';
8
- export * from './removeDirectory.js';
9
- export * from './sleep.js';
1
+ export * from './createDirectory.ts';
2
+ export * from './flushRedis.ts';
3
+ export * from './newHocuspocus.ts';
4
+ export * from './newHocuspocusProvider.ts';
5
+ export * from './newHocuspocusProviderWebsocket.ts';
6
+ export * from './randomInteger.ts';
7
+ export * from './redisConnectionSettings.ts';
8
+ export * from './removeDirectory.ts';
9
+ export * from './sleep.ts';
@@ -1,4 +1,4 @@
1
1
  import type { HocuspocusProviderWebsocketConfiguration } from '@hocuspocus/provider';
2
2
  import { HocuspocusProviderWebsocket } from '@hocuspocus/provider';
3
3
  import type { Hocuspocus } from '@hocuspocus/server';
4
- export declare const newHocuspocusProviderWebsocket: (hocuspocus: Hocuspocus, options?: Partial<Omit<HocuspocusProviderWebsocketConfiguration, 'url'>>) => HocuspocusProviderWebsocket;
4
+ export declare const newHocuspocusProviderWebsocket: (hocuspocus: Hocuspocus, options?: Partial<Omit<HocuspocusProviderWebsocketConfiguration, "url">>) => HocuspocusProviderWebsocket;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hocuspocus/extension-redis",
3
- "version": "3.0.4-rc.0",
3
+ "version": "3.0.7-rc.0",
4
4
  "description": "Scale Hocuspocus horizontally with Redis",
5
5
  "homepage": "https://hocuspocus.dev",
6
6
  "keywords": [
@@ -15,7 +15,7 @@
15
15
  "types": "dist/packages/extension-redis/src/index.d.ts",
16
16
  "exports": {
17
17
  "source": {
18
- "import": "./src"
18
+ "import": "./src/index.ts"
19
19
  },
20
20
  "default": {
21
21
  "import": "./dist/hocuspocus-redis.esm.js",
@@ -33,7 +33,7 @@
33
33
  "@types/redlock": "^4.0.3"
34
34
  },
35
35
  "dependencies": {
36
- "@hocuspocus/server": "^3.0.4-rc.0",
36
+ "@hocuspocus/server": "^3.0.7-rc.0",
37
37
  "ioredis": "^4.28.2",
38
38
  "kleur": "^4.1.4",
39
39
  "lodash.debounce": "^4.0.8",
package/src/index.ts CHANGED
@@ -1 +1 @@
1
- export * from './Redis.js'
1
+ export * from './Redis.ts'
@@ -1,2 +0,0 @@
1
- declare const _default: import("vite").UserConfig;
2
- export default _default;