@cuboapp/crdt 1.0.26 → 1.0.27
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 +7 -7
- package/src/client/types/index.ts +0 -2
package/package.json
CHANGED
package/src/client/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { keyBy, pick, uuid } from '@cuboapp/utils'
|
|
2
2
|
import { WsClientEvent } from '@cuboapp/ws'
|
|
3
|
-
import { computed, reactive } from 'vue'
|
|
3
|
+
import { computed, reactive, shallowReactive } from 'vue'
|
|
4
4
|
import { applyAwarenessUpdate, Awareness, encodeAwarenessUpdate, removeAwarenessStates } from 'y-protocols/awareness'
|
|
5
5
|
import { applyUpdate, Doc } from 'yjs'
|
|
6
6
|
|
|
@@ -27,7 +27,7 @@ export class CuboCrdtClient<M> {
|
|
|
27
27
|
public store: CuboCrdtClientStore<M> = {}
|
|
28
28
|
// Реактивен только реестр: Vue отслеживает set/delete и повторно вычисляет
|
|
29
29
|
// computed(useDoc). Сами Y.Doc/Awareness остаются исходными объектами без proxy.
|
|
30
|
-
public docs = new Map<string, CuboCrdtClientDoc>()
|
|
30
|
+
public docs = shallowReactive(new Map<string, CuboCrdtClientDoc>())
|
|
31
31
|
|
|
32
32
|
private listeners: Map<string, Map<string, (ctx: CuboCrdtClientSubscribeEvent) => void | Promise<void>>> = new Map()
|
|
33
33
|
|
|
@@ -351,7 +351,7 @@ export class CuboCrdtClient<M> {
|
|
|
351
351
|
|
|
352
352
|
const item = this.store[storeKey]
|
|
353
353
|
item?.state.rows.forEach((row) => {
|
|
354
|
-
this.detachDocument(`${entity}`, (row as any).id, subscribe_id
|
|
354
|
+
this.detachDocument(`${entity}`, (row as any).id, subscribe_id)
|
|
355
355
|
})
|
|
356
356
|
|
|
357
357
|
// очищаем стор
|
|
@@ -547,7 +547,7 @@ export class CuboCrdtClient<M> {
|
|
|
547
547
|
}
|
|
548
548
|
}
|
|
549
549
|
|
|
550
|
-
private detachDocument(entity: string, entity_id: number, subscribe_id: string
|
|
550
|
+
private detachDocument(entity: string, entity_id: number, subscribe_id: string) {
|
|
551
551
|
const key = `${entity}:${entity_id}`
|
|
552
552
|
const document = this.docs.get(key)
|
|
553
553
|
if (!document) {
|
|
@@ -620,11 +620,11 @@ export class CuboCrdtClient<M> {
|
|
|
620
620
|
|
|
621
621
|
applyUpdate(yjsDoc, update, { react: false })
|
|
622
622
|
|
|
623
|
-
const document
|
|
623
|
+
const document = shallowReactive<CuboCrdtClientDoc>({
|
|
624
624
|
doc: yjsDoc,
|
|
625
625
|
subscribes: new Set(),
|
|
626
626
|
awarenessSubscribes: new Set()
|
|
627
|
-
}
|
|
627
|
+
})
|
|
628
628
|
this.attachDocument(ctx.entity, entity_id, document, opts)
|
|
629
629
|
// Публикуем контейнер реактивному реестру только после полной инициализации.
|
|
630
630
|
// Тогда первый computed(useDoc) не увидит промежуточный doc без Awareness.
|
|
@@ -785,7 +785,7 @@ export class CuboCrdtClient<M> {
|
|
|
785
785
|
continue
|
|
786
786
|
}
|
|
787
787
|
|
|
788
|
-
this.detachDocument(ctx.entity, entity_id, opts.subscribe_id
|
|
788
|
+
this.detachDocument(ctx.entity, entity_id, opts.subscribe_id)
|
|
789
789
|
}
|
|
790
790
|
|
|
791
791
|
const rowsById = new Map(item.state.rows.map((row: any) => [Number(row.id), row]))
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type WsClient } from '@cuboapp/ws'
|
|
2
2
|
import { ComputedRef } from 'vue'
|
|
3
|
-
import { Awareness } from 'y-protocols/awareness'
|
|
4
3
|
|
|
5
4
|
import { CuboCrdtAction, CuboCrdtListSyncData, CuboCrdtListTotals, CuboCrdtSubscriptionStatus } from '../../types'
|
|
6
5
|
|
|
@@ -39,7 +38,6 @@ export type CuboCrdtClientSubscribeEvent = {
|
|
|
39
38
|
export type CuboCrdtClientList<T> = {
|
|
40
39
|
subscribe_id: string
|
|
41
40
|
storeKey: string
|
|
42
|
-
awarenesses?: ComputedRef<Map<number, Awareness> | undefined>
|
|
43
41
|
subscribe: (filters?: any) => void
|
|
44
42
|
upgrade: (filters?: any) => void
|
|
45
43
|
unsubscribe: (clear?: boolean) => void
|