fixed YArray
This commit is contained in:
@@ -8,8 +8,10 @@ import { AbstractItem } from '../structs/AbstractItem.js' // eslint-disable-line
|
||||
import { Y } from './Y.js' // eslint-disable-line
|
||||
import { YEvent } from './YEvent.js' // eslint-disable-line
|
||||
import { ItemType } from '../structs/ItemType.js' // eslint-disable-line
|
||||
import { getState } from './StructStore.js'
|
||||
import { writeStructsFromTransaction } from './structEncoding.js'
|
||||
import { createID } from './ID.js' // eslint-disable-line
|
||||
import { createDeleteSetFromTransaction, writeDeleteSet } from './DeleteSet.js'
|
||||
import { getState } from './StructStore.js'
|
||||
|
||||
/**
|
||||
* A transaction is created for every change on the Yjs model. It is possible
|
||||
@@ -54,26 +56,41 @@ export class Transaction {
|
||||
*/
|
||||
this.deleted = new Set()
|
||||
/**
|
||||
* Saves the old state set of the Yjs instance. If a state was modified,
|
||||
* the original value is saved here.
|
||||
* If a state was modified, the original value is saved here.
|
||||
* Use `stateUpdates` to compute the original state before the transaction,
|
||||
* or to compute the set of inserted operations.
|
||||
* @type {Map<Number,Number>}
|
||||
*/
|
||||
this.beforeState = new Map()
|
||||
this.stateUpdates = new Map()
|
||||
/**
|
||||
* All types that were directly modified (property added or child
|
||||
* inserted/deleted). New types are not included in this Set.
|
||||
* Maps from type to parentSubs (`item._parentSub = null` for YArray)
|
||||
* @type {Map<ItemType,Set<String|null>>}
|
||||
* @type {Map<AbstractType,Set<String|null>>}
|
||||
*/
|
||||
this.changed = new Map()
|
||||
/**
|
||||
* Stores the events for the types that observe also child elements.
|
||||
* It is mainly used by `observeDeep`.
|
||||
* @type {Map<ItemType,Array<YEvent>>}
|
||||
* @type {Map<AbstractType,Array<YEvent>>}
|
||||
*/
|
||||
this.changedParentTypes = new Map()
|
||||
this.encodedStructsLen = 0
|
||||
this.encodedStructs = encoding.createEncoder()
|
||||
/**
|
||||
* @type {encoding.Encoder|null}
|
||||
*/
|
||||
this._updateMessage = null
|
||||
}
|
||||
/**
|
||||
* @type {encoding.Encoder}
|
||||
*/
|
||||
get updateMessage () {
|
||||
if (this._updateMessage === null) {
|
||||
const encoder = encoding.createEncoder()
|
||||
writeStructsFromTransaction(encoder, this)
|
||||
writeDeleteSet(encoder, createDeleteSetFromTransaction(this))
|
||||
this._updateMessage = encoder
|
||||
}
|
||||
return this._updateMessage
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user