@cuboapp/crdt 1.0.2 → 1.0.4
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 +1 -1
- package/src/client/index.ts +2 -0
- package/src/index.ts +7 -8
package/package.json
CHANGED
package/src/client/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { applyUpdate, Doc } from 'yjs'
|
|
|
5
5
|
export type CuboCrdtClientOptions = {
|
|
6
6
|
host?: string
|
|
7
7
|
port?: number
|
|
8
|
+
protocol?: 'wss' | 'ws' | string
|
|
8
9
|
authToken?: () => Promise<string>
|
|
9
10
|
debug?: boolean
|
|
10
11
|
}
|
|
@@ -19,6 +20,7 @@ export class CuboCrdtClient {
|
|
|
19
20
|
this.ws = createWsClient({
|
|
20
21
|
host: this.opts.host,
|
|
21
22
|
port: this.opts.port,
|
|
23
|
+
protocol: this.opts.protocol,
|
|
22
24
|
autoReconnect: true,
|
|
23
25
|
pingInterval: 5000,
|
|
24
26
|
authToken: this.opts.authToken ? () => this.opts.authToken!() : () => ''
|
package/src/index.ts
CHANGED
|
@@ -29,19 +29,15 @@ export class CuboCrdt<
|
|
|
29
29
|
constructor(private options: CuboCrdtOptions<A>) {}
|
|
30
30
|
|
|
31
31
|
public async start() {
|
|
32
|
-
setInterval(() => {
|
|
33
|
-
|
|
34
|
-
}, 1000)
|
|
35
|
-
|
|
32
|
+
// setInterval(() => {
|
|
33
|
+
// console.log('documents', this.documents.size)
|
|
34
|
+
// }, 1000)
|
|
36
35
|
// const doc = new Doc()
|
|
37
36
|
// const map = doc.getMap('store')
|
|
38
|
-
|
|
39
37
|
// doc.on('update', (upd) => {
|
|
40
38
|
// const map1 = doc.getMap('store')
|
|
41
|
-
|
|
42
39
|
// console.log('new state', map1.toJSON())
|
|
43
40
|
// })
|
|
44
|
-
|
|
45
41
|
// doc.transact(() => {
|
|
46
42
|
// map.set('key', 'value')
|
|
47
43
|
// })
|
|
@@ -82,7 +78,10 @@ export class CuboCrdt<
|
|
|
82
78
|
const document = await this.loading.get(name)
|
|
83
79
|
|
|
84
80
|
this.loading.delete(name)
|
|
85
|
-
|
|
81
|
+
|
|
82
|
+
if (document) {
|
|
83
|
+
this.documents.set(name, document)
|
|
84
|
+
}
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
if (this.options.debug) {
|