@cuboapp/crdt 1.0.7 → 1.0.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuboapp/crdt",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "CRDT for CUBO",
5
5
  "main": "src/index.ts",
6
6
  "repository": "git@github.com:cuboapp/crdt.git",
@@ -11,9 +11,9 @@
11
11
  "access": "public"
12
12
  },
13
13
  "dependencies": {
14
- "@cuboapp/types": "^2.0.12",
14
+ "@cuboapp/types": "^2.0.13",
15
15
  "@cuboapp/utils": "1.0.10",
16
- "@cuboapp/ws": "1.0.5",
16
+ "@cuboapp/ws": "1.0.6",
17
17
  "ws": "^8.19.0",
18
18
  "yjs": "^13.6.29"
19
19
  },
@@ -55,6 +55,10 @@ export class CuboCrdtServerDocument {
55
55
  return this.ydoc.getMap()
56
56
  }
57
57
 
58
+ getXmlFragment(name = '') {
59
+ return this.ydoc.getXmlFragment(name)
60
+ }
61
+
58
62
  getJson() {
59
63
  return this.getMap().toJSON()
60
64
  }
@@ -68,7 +68,7 @@ export class CuboCrdtServer<M, A = {}, E extends Extract<keyof M, string> = Extr
68
68
  this.ws.registerHandler(CUBO_CRDT_EVENT.UPGRADE, async ({ client, message }) => {
69
69
  const { subscribe_id: id, entity, filters } = message.data as CuboCrdtServerSubscribeDto
70
70
 
71
- if (!this.debug) {
71
+ if (this.debug) {
72
72
  console.log('[CRDT] upgrade', entity, filters)
73
73
  }
74
74
 
@@ -292,7 +292,7 @@ export class CuboCrdtServer<M, A = {}, E extends Extract<keyof M, string> = Extr
292
292
  const client = subscribe && this.clients.get(subscribe.client_id)
293
293
 
294
294
  if (client) {
295
- return this.options?.storeRow?.(entity as any, entity_id, item as any, { client, origin })
295
+ return this.options?.storeRow?.(entity as any, entity_id, item as any, { document, client, origin })
296
296
  }
297
297
  }
298
298
  })
@@ -1,4 +1,5 @@
1
1
  import { WsServer, WsServerSocket } from '@cuboapp/ws'
2
+ import { CuboCrdtServerDocument } from '../document'
2
3
  import { CuboCrdtServerDocumentOrigin } from './document'
3
4
  import { CuboCrdtServerSubscribe } from './subscribe'
4
5
 
@@ -16,6 +17,7 @@ export type CuboCrdtServerOptions<M, A, E extends Extract<keyof M, string>> = {
16
17
  entity_id: number,
17
18
  row: M[K],
18
19
  opts: {
20
+ document: CuboCrdtServerDocument
19
21
  client: CuboCrdtSocketClient<A>
20
22
  origin: CuboCrdtServerDocumentOrigin
21
23
  }