/** * YEvent describes the changes on a YType. */ export class YEvent { /** * @param {AbstractType} target The changed type. * @param {Transaction} transaction */ constructor(target: AbstractType, transaction: Transaction); /** * The type on which this event was created on. * @type {AbstractType} */ target: AbstractType; /** * The current target on which the observe callback is called. * @type {AbstractType} */ currentTarget: AbstractType; /** * The transaction that triggered this event. * @type {Transaction} */ transaction: Transaction; /** * @type {Object|null} */ _changes: Object | null; /** * @type {null | Map} */ _keys: Map | null; /** * @type {null | Array<{ insert?: string | Array | object | AbstractType, retain?: number, delete?: number, attributes?: Object }>} */ _delta: { insert?: string | object | any[] | AbstractType | undefined; retain?: number | undefined; delete?: number | undefined; attributes?: { [x: string]: any; } | undefined; }[] | null; /** * Computes the path from `y` to the changed type. * * @todo v14 should standardize on path: Array<{parent, index}> because that is easier to work with. * * The following property holds: * @example * let type = y * event.path.forEach(dir => { * type = type.get(dir) * }) * type === event.target // => true */ get path(): (string | number)[]; /** * Check if a struct is deleted by this event. * * In contrast to change.deleted, this method also returns true if the struct was added and then deleted. * * @param {AbstractStruct} struct * @return {boolean} */ deletes(struct: AbstractStruct): boolean; /** * @type {Map} */ get keys(): Map; /** * @type {Array<{insert?: string | Array | object | AbstractType, retain?: number, delete?: number, attributes?: Object}>} */ get delta(): { insert?: string | object | any[] | AbstractType | undefined; retain?: number | undefined; delete?: number | undefined; attributes?: { [x: string]: any; } | undefined; }[]; /** * Check if a struct is added by this event. * * In contrast to change.deleted, this method also returns true if the struct was added and then deleted. * * @param {AbstractStruct} struct * @return {boolean} */ adds(struct: AbstractStruct): boolean; /** * @type {{added:Set,deleted:Set,keys:Map,delta:Array<{insert?:Array|string, delete?:number, retain?:number}>}} */ get changes(): { added: Set; deleted: Set; keys: Map; delta: Array<{ insert?: Array | string; delete?: number; retain?: number; }>; }; } import { AbstractType } from "../types/AbstractType.js"; import { Transaction } from "./Transaction.js"; import { AbstractStruct } from "../structs/AbstractStruct.js"; import { Item } from "../structs/Item.js";