implement getMap, getArray, getXml, ..
This commit is contained in:
@@ -86,7 +86,7 @@ export const readID = decoder =>
|
||||
* `type` does not store any information about the `keyname`.
|
||||
* This function finds the correct `keyname` for `type` and throws otherwise.
|
||||
*
|
||||
* @param {AbstractType} type
|
||||
* @param {AbstractType<any>} type
|
||||
* @return {string}
|
||||
*/
|
||||
export const findRootTypeKey = type => {
|
||||
|
||||
@@ -61,13 +61,13 @@ export class Transaction {
|
||||
* 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<AbstractType,Set<String|null>>}
|
||||
* @type {Map<AbstractType<YEvent>,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<AbstractType,Array<YEvent>>}
|
||||
* @type {Map<AbstractType<YEvent>,Array<YEvent>>}
|
||||
*/
|
||||
this.changedParentTypes = new Map()
|
||||
/**
|
||||
|
||||
@@ -14,6 +14,7 @@ import { YArray } from '../types/YArray.js'
|
||||
import { YText } from '../types/YText.js'
|
||||
import { YMap } from '../types/YMap.js'
|
||||
import { YXmlFragment } from '../types/YXmlElement.js'
|
||||
import { YEvent } from './YEvent.js' // eslint-disable-line
|
||||
|
||||
/**
|
||||
* A Yjs instance handles the state of shared data.
|
||||
@@ -28,7 +29,7 @@ export class Y extends Observable {
|
||||
this.gcEnabled = conf.gc || false
|
||||
this.clientID = random.uint32()
|
||||
/**
|
||||
* @type {Map<string, AbstractType>}
|
||||
* @type {Map<string, AbstractType<YEvent>>}
|
||||
*/
|
||||
this.share = new Map()
|
||||
this.store = new StructStore()
|
||||
@@ -203,7 +204,7 @@ export class Y extends Observable {
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {Function} TypeConstructor The constructor of the type definition
|
||||
* @return {AbstractType} The created type. Constructed with TypeConstructor
|
||||
* @return {AbstractType<any>} The created type. Constructed with TypeConstructor
|
||||
*/
|
||||
get (name, TypeConstructor = AbstractType) {
|
||||
// @ts-ignore
|
||||
@@ -242,7 +243,7 @@ export class Y extends Observable {
|
||||
}
|
||||
/**
|
||||
* @param {string} name
|
||||
* @return {YMap}
|
||||
* @return {YMap<any>}
|
||||
*/
|
||||
getMap (name) {
|
||||
// @ts-ignore
|
||||
|
||||
@@ -13,18 +13,18 @@ import { isDeleted } from './DeleteSet.js'
|
||||
*/
|
||||
export class YEvent {
|
||||
/**
|
||||
* @param {AbstractType} target The changed type.
|
||||
* @param {AbstractType<any> target The changed type.
|
||||
* @param {Transaction} transaction
|
||||
*/
|
||||
constructor (target, transaction) {
|
||||
/**
|
||||
* The type on which this event was created on.
|
||||
* @type {AbstractType}
|
||||
* @type {AbstractType<any>
|
||||
*/
|
||||
this.target = target
|
||||
/**
|
||||
* The current target on which the observe callback is called.
|
||||
* @type {AbstractType}
|
||||
* @type {AbstractType<any>
|
||||
*/
|
||||
this.currentTarget = target
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ export class YEvent {
|
||||
* console.log(path) // might look like => [2, 'key1']
|
||||
* child === type.get(path[0]).get(path[1])
|
||||
*
|
||||
* @param {AbstractType} parent
|
||||
* @param {AbstractType<any> parent
|
||||
* @param {AbstractItem} child target
|
||||
* @return {Array<string|number>} Path to the target
|
||||
*/
|
||||
|
||||
@@ -8,8 +8,8 @@ import { AbstractType } from '../types/AbstractType.js' // eslint-disable-line
|
||||
/**
|
||||
* Check if `parent` is a parent of `child`.
|
||||
*
|
||||
* @param {AbstractType} parent
|
||||
* @param {AbstractType} child
|
||||
* @param {AbstractType<any>} parent
|
||||
* @param {AbstractType<any>} child
|
||||
* @return {Boolean} Whether `parent` is a parent of `child`.
|
||||
*
|
||||
* @public
|
||||
|
||||
@@ -60,12 +60,12 @@ export class RelativePosition {
|
||||
|
||||
export class AbsolutePosition {
|
||||
/**
|
||||
* @param {AbstractType} type
|
||||
* @param {AbstractType<any>} type
|
||||
* @param {number} offset
|
||||
*/
|
||||
constructor (type, offset) {
|
||||
/**
|
||||
* @type {AbstractType}
|
||||
* @type {AbstractType<any>}
|
||||
*/
|
||||
this.type = type
|
||||
/**
|
||||
@@ -76,13 +76,13 @@ export class AbsolutePosition {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {AbstractType} type
|
||||
* @param {AbstractType<any> type
|
||||
* @param {number} offset
|
||||
*/
|
||||
export const createAbsolutePosition = (type, offset) => new AbsolutePosition(type, offset)
|
||||
|
||||
/**
|
||||
* @param {AbstractType} type
|
||||
* @param {AbstractType<any> type
|
||||
* @param {ID.ID|null} item
|
||||
*/
|
||||
export const createRelativePosition = (type, item) => {
|
||||
@@ -99,7 +99,7 @@ export const createRelativePosition = (type, item) => {
|
||||
/**
|
||||
* Create a relativePosition based on a absolute position.
|
||||
*
|
||||
* @param {AbstractType} type The base type (e.g. YText or YArray).
|
||||
* @param {AbstractType<any> type The base type (e.g. YText or YArray).
|
||||
* @param {number} offset The absolute position.
|
||||
* @return {RelativePosition}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user