This commit is contained in:
Kevin Jahns
2020-01-22 16:42:16 +01:00
parent ac8dab1e88
commit 6cd9e2be32
32 changed files with 910 additions and 574 deletions

View File

@@ -46,6 +46,7 @@ export class Doc extends Observable {
*/
this._transactionCleanups = []
}
/**
* Changes that happen inside of a transaction are bundled. This means that
* the observer fires _after_ the transaction is finished and that all changes
@@ -60,6 +61,7 @@ export class Doc extends Observable {
transact (f, origin = null) {
transact(this, f, origin)
}
/**
* Define a shared data type.
*
@@ -118,6 +120,7 @@ export class Doc extends Observable {
}
return type
}
/**
* @template T
* @param {string} name
@@ -129,6 +132,7 @@ export class Doc extends Observable {
// @ts-ignore
return this.get(name, YArray)
}
/**
* @param {string} name
* @return {YText}
@@ -139,6 +143,7 @@ export class Doc extends Observable {
// @ts-ignore
return this.get(name, YText)
}
/**
* @param {string} name
* @return {YMap<any>}
@@ -149,6 +154,7 @@ export class Doc extends Observable {
// @ts-ignore
return this.get(name, YMap)
}
/**
* @param {string} name
* @return {YXmlFragment}
@@ -159,6 +165,7 @@ export class Doc extends Observable {
// @ts-ignore
return this.get(name, YXmlFragment)
}
/**
* Emit `destroy` event and unregister all event handlers.
*
@@ -168,6 +175,7 @@ export class Doc extends Observable {
this.emit('destroyed', [true])
super.destroy()
}
/**
* @param {string} eventName
* @param {function} f
@@ -175,6 +183,7 @@ export class Doc extends Observable {
on (eventName, f) {
super.on(eventName, f)
}
/**
* @param {string} eventName
* @param {function} f

View File

@@ -81,7 +81,7 @@ export const readID = decoder =>
*/
export const findRootTypeKey = type => {
// @ts-ignore _y must be defined, otherwise unexpected case
for (let [key, value] of type.doc.share) {
for (const [key, value] of type.doc.share) {
if (value === type) {
return key
}

View File

@@ -67,6 +67,7 @@ export class PermanentUserData {
// add intial data
users.forEach(initUser)
}
/**
* @param {Doc} doc
* @param {number} clientid
@@ -116,6 +117,7 @@ export class PermanentUserData {
})
})
}
/**
* @param {number} clientid
* @return {any}
@@ -123,6 +125,7 @@ export class PermanentUserData {
getUserByClientId (clientid) {
return this.clients.get(clientid) || null
}
/**
* @param {ID} id
* @return {string | null}

View File

@@ -63,7 +63,7 @@ export class RelativePosition {
}
/**
* @param {Object} json
* @param {any} json
* @return {RelativePosition}
*
* @function

View File

@@ -185,7 +185,7 @@ export const getItem = (store, id) => find(store, id)
*/
export const findIndexCleanStart = (transaction, structs, clock) => {
const index = findIndexSS(structs, clock)
let struct = structs[index]
const struct = structs[index]
if (struct.id.clock < clock && struct instanceof Item) {
structs.splice(index + 1, 0, splitItem(transaction, struct, clock - struct.id.clock))
return index + 1

View File

@@ -181,7 +181,7 @@ export class YEvent {
})
this._changes = changes
}
return changes
return /** @type {any} */ (changes)
}
}