UNPKG

@typescript-package/history

Version:

A lightweight TypeScript package for tracking the history of values.

1 lines 50.9 kB
{"version":3,"file":"typescript-package-history.mjs","sources":["../../../package/history/src/lib/core/history-storage.abstract.ts","../../../package/history/src/lib/core/history-core.abstract.ts","../../../package/history/src/lib/core/history-append.abstract.ts","../../../package/history/src/lib/core/history-current.abstract.ts","../../../package/history/src/lib/core/history-prepend.abstract.ts","../../../package/history/src/lib/base/current-history.class.ts","../../../package/history/src/lib/base/history-base.abstract.ts","../../../package/history/src/lib/base/redo-history.class.ts","../../../package/history/src/lib/base/undo-history.class.ts","../../../package/history/src/lib/history.class.ts","../../../package/history/src/public-api.ts","../../../package/history/src/typescript-package-history.ts"],"sourcesContent":["import {\n // Class.\n Data,\n // Abstract.\n DataCore,\n // Type.\n DataConstructorInput,\n} from '@typescript-package/data';\n/**\n * @description The history storage of specified data.\n * @export\n * @abstract\n * @class HistoryStorage\n * @template Value \n * @template {DataCore<readonly Value[]>} [DataType=Data<readonly Value[]>] \n */\nexport abstract class HistoryStorage<\n Value,\n DataType extends DataCore<readonly Value[]> = Data<readonly Value[]>\n> {\n /**\n * @description Returns the `string` tag representation of the `HistoryStorage` class when used in `Object.prototype.toString.call(instance)`.\n * @public\n * @readonly\n * @type {string}\n */\n public get [Symbol.toStringTag](): string {\n return HistoryStorage.name;\n }\n\n /**\n * @description Returns the data holder of `DataType`.\n * @public\n * @readonly\n * @type {DataType}\n */\n public get data(): DataType {\n return this.#data;\n }\n\n /**\n * @description The length of the history.\n * @public\n * @readonly\n * @type {number}\n */\n public get length(): number {\n return this.#data.value.length;\n }\n\n /**\n * @description The data type to store the value.\n * @type {DataType}\n */\n #data: DataType;\n\n /**\n * Creates an instance of `HistoryStorage` child class.\n * @constructor\n * @param {readonly Value[]} value The initial array.\n * @param {?DataConstructorInput<readonly Value[], DataType>} [data] Custom data holder, optionally with params.\n */ \n constructor(\n value: readonly Value[],\n data?: DataConstructorInput<readonly Value[], DataType>\n ) {\n this.#data = new (Array.isArray(data) ? data[0] : data ?? Data)(value, ...Array.isArray(data) ? data.slice(1) : []) as DataType;\n }\n\n /**\n * @description Destroys the storage data, by default setting it to `null`.\n * @public\n * @returns {this} The `this` current instance.\n */\n public destroy(): this {\n this.#data.destroy();\n return this;\n }\n\n /**\n * @description Gets the readonly history.\n * @public\n * @returns {readonly Value[]} \n */\n public get(): readonly Value[] {\n return this.#data.value;\n }\n\n /**\n * @description Checks whether the storage is empty.\n * @public\n * @returns {boolean} \n */\n public isEmpty(): boolean {\n return this.#data.value.length === 0;\n }\n\n /**\n * @description Sets the data value.\n * @protected\n * @param {readonly Value[]} value The data value of `Value[]` to set.\n * @returns {this} The `this` current instance.\n */\n protected set(value: readonly Value[]): this {\n this.#data.set(value);\n return this;\n }\n}\n","import {\n// Class.\n Data,\n // Abstract.\n DataCore,\n // Type.\n DataConstructorInput,\n} from '@typescript-package/data';\n// Abstract.\nimport { HistoryStorage } from './history-storage.abstract';\n/**\n * @description The core class for history append and prepend.\n * @export\n * @abstract\n * @class HistoryCore\n * @template Value \n * @template {number} [Size=number] \n * @template {DataCore<readonly Value[]>} [DataType=Data<readonly Value[]>] \n * @extends {HistoryStorage<Value, DataType>}\n */\nexport abstract class HistoryCore<\n Value,\n Size extends number = number,\n DataType extends DataCore<readonly Value[]> = Data<readonly Value[]>\n> extends HistoryStorage<Value, DataType> {\n /**\n * @description Returns the `string` tag representation of the `HistoryCore` class when used in `Object.prototype.toString.call(instance)`.\n * @public\n * @readonly\n * @type {string}\n */\n public override get [Symbol.toStringTag](): string {\n return HistoryCore.name;\n }\n\n /**\n * @description Gets the history.\n * @protected\n * @readonly\n * @type {readonly Value[]}\n */\n protected get history(): readonly Value[] {\n return super.data.value;\n }\n\n /**\n * @description The maximum size of the history.\n * @public\n * @readonly\n * @type {Size}\n */\n public get size(): Size {\n return this.#size;\n }\n\n /**\n * @description The maximum size of the history.\n * @type {Size}\n */\n #size: Size;\n\n /**\n * Creates an instance of `HistoryCore` child class.\n * @constructor\n * @param {Size} size The maximum undo history size.\n * @param {?DataConstructorInput<readonly Value[], DataType>} [data] Custom data holder.\n */\n constructor(\n size: Size,\n data?: DataConstructorInput<readonly Value[], DataType>\n ) {\n super([], data);\n this.#size = size;\n }\n\n //#region public method\n /**\n * @description Adds the value to the history.\n * @public\n * @param {Value} value The value to store.\n * @returns {this} The `this` current instance.\n */\n public abstract add(value: Value): this;\n\n /**\n * @description Returns the value at the specified index in the history.\n * @public\n * @param {number} index The position in the history (0-based index).\n * @returns {Value | undefined} The value at the specified position.\n */\n public at(index: number): Value | undefined {\n return this.history[index];\n }\n\n /**\n * @description Clears the history.\n * @public\n * @returns {this} The `this` current instance.\n */\n public clear(): this {\n super.set([] as readonly Value[]);\n return this;\n }\n\n /**\n * @description Returns the first value without modifying history.\n * @public\n * @abstract\n * @returns {(Value | undefined)} \n */\n public first(): Value | undefined {\n return this.history[0];\n }\n\n /**\n * @description Returns the last value without modifying history.\n * @public\n * @abstract\n * @returns {(Value | undefined)} \n */\n public last(): Value | undefined {\n return this.history.at(-1);\n }\n\n /**\n * @description Returns the next value without modifying history.\n * @public\n * @abstract\n * @returns {(Value | undefined)} \n */\n public abstract next(): Value | undefined;\n\n /**\n * @description Sets the size for history.\n * @public\n * @param {Size} size The maximum size of `Size`.\n * @returns {this} The `this` current instance.\n */\n public setSize(size: Size): this {\n this.#size = size;\n return this;\n }\n\n /**\n * @description Takes the first value.\n * @public\n * @abstract\n * @returns {(Value | undefined)} \n */\n public abstract take(): Value | undefined;\n //#endregion\n\n //#region protected method\n /**\n * @description \"Removes the last element from an array and returns it. If the array is empty, undefined is returned and the array is not modified.\"\n * @protected\n * @returns {this} The `this` current instance.\n */\n protected pop(): Value | undefined {\n const history = [...this.history];\n if (Array.isArray(history) && history.length > 0) {\n const last = history.pop();\n this.set(history);\n return last;\n }\n return undefined;\n }\n\n /**\n * @description \"Appends new elements to the end of an array, and returns the new length of the array.\"\n * @protected\n * @param {...readonly Value[]} items The items to append.\n * @returns {number} The new length.\n */\n protected push(...items: readonly Value[]): number {\n const history = [...this.history];\n const length = history.push(...items);\n return (this.set(history), length);\n }\n\n /**\n * @description \"Removes the first element from an array and returns it. If the array is empty, undefined is returned and the array is not modified.\"\n * @protected\n * @returns {this} The `this` current instance.\n */\n protected shift(): Value | undefined {\n const history = [...this.history];\n if (Array.isArray(history) && history.length > 0) {\n const first = history.shift();\n this.set(history);\n return first;\n }\n return undefined;\n }\n\n /**\n * @description The method to trim the history.\n * @protected\n * @param {('pop' | 'shift')} method The method `pop` or `shift` to trim the history.\n * @returns {this} The `this` current instance.\n */\n protected trim(method: 'pop' | 'shift'): this {\n if (this.#size > 0) {\n while (this.history.length > this.size) {\n method === 'pop' ? this.pop() : method === 'shift' && this.shift();\n } \n }\n return this;\n }\n\n /**\n * @description \"Inserts new elements at the start of an array, and returns the new length of the array.\"\n * @protected\n * @param {...readonly Value[]} items The items to insert.\n * @returns {number} The new length.\n */\n protected unshift(...items: readonly Value[]): number {\n const history = [...this.history];\n const length = history.unshift(...items);\n return (this.set(history), length);\n }\n //#endregion\n}\n","import {\n // Class.\n Data,\n // Abstract.\n DataCore,\n // Type.\n DataConstructorInput,\n} from '@typescript-package/data';\n// Abstract.\nimport { HistoryCore } from './history-core.abstract';\n/**\n * @description Class extends the `HistoryCore` class to maintain a history of values in a append manner.\n * This means that new entries are added to the end of the history, and as the history exceeds its size limit, entries from the beginning are removed.\n * LIFO(Last in, First out): The last value that was added (the most recent one) will be the first one to be removed.\n * Add: Add to the end of the array (push).\n * Take: Remove from the end of the array (pop), which is the most recent item.\n * PeekFirst: Look at the first item in the history (oldest).\n * PeekLast: Look at the last item in the history (newest).\n * @export\n * @abstract\n * @class HistoryAppend\n * @template Value \n * @template {number} [Size=number] \n * @template {DataCore<readonly Value[]>} [DataType=Data<readonly Value[]>] \n * @extends {HistoryCore<Value, Size, DataType>}\n */\nexport abstract class HistoryAppend<\n Value,\n Size extends number = number,\n DataType extends DataCore<readonly Value[]> = Data<readonly Value[]>\n> extends HistoryCore<Value, Size, DataType> {\n /**\n * @description The default value of maximum history size.\n * @public\n * @static\n * @type {number}\n */\n public static size: number = 10;\n\n /**\n * @description Returns the `string` tag representation of the `HistoryAppend` class when used in `Object.prototype.toString.call(instance)`.\n * @public\n * @readonly\n * @type {string}\n */\n public override get [Symbol.toStringTag](): string {\n return HistoryAppend.name;\n }\n\n /**\n * Creates an instance of `HistoryAppend` child class.\n * @constructor\n * @param {Size} [size=HistoryAppend.size as Size] The maximum history size.\n * @param {?readonly Value[]} [initialValue] Initial value to add.\n * @param {?DataConstructorInput<readonly Value[], DataType>} [data] Custom data holder.\n */\n constructor(\n size: Size = HistoryAppend.size as Size,\n initialValue?: readonly Value[],\n data?: DataConstructorInput<readonly Value[], DataType>,\n ) {\n super(size, data);\n Array.isArray(initialValue) && initialValue.forEach(value => this.add(value));\n }\n\n /**\n * @description Adds the value to the history.\n * - FIFO unshift/queue style\n * @public\n * @param {Value} value The value to store.\n * @returns {this} The `this` current instance.\n */\n public add(value: Value): this {\n if (super.size > 0) {\n super.push(value);\n super.trim('shift');\n }\n return this;\n }\n\n /**\n * @description Returns the most recent (last index added) value in the history without modifying it. \n * @public\n * @returns {(Value | undefined)} \n */\n public newest(): Value | undefined {\n return super.last();\n }\n\n /**\n * @description Returns the next value that would be removed (the most recent one) without modifying history.\n * - LIFO behavior\n * @public\n * @returns {(Value | undefined)} The next value in the append manner.\n */\n public next(): Value | undefined {\n return super.last();\n }\n\n /**\n * @description Returns the first(index 0 the oldest) value in the history without modifying it.\n * @public\n * @returns {(Value | undefined)} \n */\n public oldest(): Value | undefined {\n return super.first();\n }\n\n /**\n * @description Removes and returns the last value in the history.\n * - LIFO behavior\n * @public\n * @returns {(Value | undefined)} \n */\n public take(): Value | undefined {\n return super.pop();\n }\n}\n","// Data.\nimport { Data, DataCore, DataConstructorInput } from '@typescript-package/data';\n// Abstract.\nimport { HistoryStorage } from './history-storage.abstract';\n/**\n * @description The class represents the current value of the history.\n * The class is used to:\n * - store the current value of the history,\n * - check whether the current value is set,\n * - update the current value of the history,\n * - clear the current value of the history,\n * - get the current value of the history.\n * @export\n * @abstract\n * @class HistoryCurrent\n * @template Value \n * @template {DataCore<readonly Value[]>} [DataType=Data<readonly Value[]>] \n * @extends {HistoryStorage<Value, DataType>}\n */\nexport abstract class HistoryCurrent<\n Value,\n DataType extends DataCore<readonly Value[]> = Data<readonly Value[]>\n> extends HistoryStorage<Value, DataType> {\n /**\n * @description Returns the `string` tag representation of the `HistoryCurrent` class when used in `Object.prototype.toString.call(instance)`.\n * @public\n * @readonly\n * @type {string}\n */\n public override get [Symbol.toStringTag](): string {\n return HistoryCurrent.name;\n }\n\n /**\n * @description\n * @public\n * @abstract\n * @readonly\n * @type {Value}\n */\n public abstract get value(): Value;\n\n /**\n * Creates an instance of `HistoryCurrent` child class.\n * @constructor\n * @param {{value?: Value}} [param0={}] \n * @param {Value} param0.value \n * @param {?DataConstructor<readonly Value[], DataType>} [data] \n */\n constructor(\n {value}: {value?: Value} = {},\n data?: DataConstructorInput<readonly Value[], DataType>\n ) {\n super(Object.hasOwn(arguments[0] || {}, 'value') ? [value] as [Value] : [], data);\n }\n\n /**\n * @description Clears the `current` history.\n * @public\n * @returns {this} The current instance.\n */\n public clear(): this {\n super.set([]);\n return this;\n }\n\n /**\n * @description Checks whether the current value is set.\n * @public\n * @abstract\n * @returns {boolean} \n */\n public abstract has(): boolean;\n\n /**\n * @description Updates a current value.\n * @public\n * @abstract\n * @param {Value} value \n * @returns {this} \n */\n public abstract update(value: Value): this;\n}\n","import {\n // Class.\n Data,\n // Abstract.\n DataCore,\n // Type.\n DataConstructorInput,\n} from '@typescript-package/data';\n// Abstract.\nimport { HistoryCore } from './history-core.abstract';\n/**\n * @description Class extends the `HistoryCore` class to maintain a history of values in a prepend manner.\n * This means that new entries are added to the beginning of the history, and older entries are shifted out as the history size exceeds its limit.\n * LIFO(Last in, First out): The last value that was added (the most recent one) will be the first one to be removed.\n * Add: Add to the beginning of the array (unshift).\n * Take: Remove from the beginning of the array (shift), which is the most recent item.\n * PeekFirst: Look at the first item in the history (newest).\n * PeekLast: Look at the last item in the history (oldest).\n * @export\n * @abstract\n * @class HistoryPrepend\n * @template Value \n * @template {number} [Size=number] \n * @template {DataCore<readonly Value[]>} [DataType=Data<readonly Value[]>] \n * @extends {HistoryCore<Value, Size, DataType>}\n */\nexport abstract class HistoryPrepend<\n Value,\n Size extends number = number,\n DataType extends DataCore<readonly Value[]> = Data<readonly Value[]>\n> extends HistoryCore<Value, Size, DataType> {\n /**\n * @description The default value of maximum history size.\n * @public\n * @static\n * @type {number}\n */\n public static size: number = 10;\n\n /**\n * @description Returns the `string` tag representation of the `HistoryPrepend` class when used in `Object.prototype.toString.call(instance)`.\n * @public\n * @readonly\n * @type {string}\n */\n public override get [Symbol.toStringTag](): string {\n return HistoryPrepend.name;\n }\n\n /**\n * Creates an instance of `HistoryPrepend` child class.\n * @constructor\n * @param {Size} [size=HistoryPrepend.size as Size] The maximum history size.\n * @param {?readonly Value[]} [initialValue] Initial value to add.\n * @param {?DataConstructorInput<readonly Value[], DataType>} [data] Custom data holder.\n */\n constructor(\n size: Size = HistoryPrepend.size as Size,\n initialValue?: readonly Value[],\n data?: DataConstructorInput<readonly Value[], DataType>,\n ) {\n super(size, data);\n Array.isArray(initialValue) && initialValue.forEach(value => this.add(value));\n }\n\n /**\n * @description Adds the value to the history in a backward manner.\n * @public\n * @param {Value} value The value to store.\n * @returns {this} The `this` current instance.\n */\n public add(value: Value): this {\n if (super.size > 0) {\n super.unshift(value);\n super.trim('pop');\n }\n return this;\n }\n\n /**\n * @description Returns the next(index 0) value in the history, the newest value without modifying history.\n * @public\n * @returns {Value | undefined} The next redo value.\n */\n public next(): Value | undefined {\n return super.first();\n }\n\n /**\n * @description Returns the most recent(first index 0) value in the history without modifying it. \n * @public\n * @returns {(Value | undefined)} \n */\n public newest(): Value | undefined {\n return super.first();\n }\n\n /**\n * @description Returns the last value in the history, the oldest value without modifying history.\n * @public\n * @returns {Value | undefined} The next redo value.\n */\n public oldest(): Value | undefined {\n return super.last();\n }\n\n /**\n * @description Removes and returns the first value in the history.\n * @public\n * @returns {(Value | undefined)} \n */\n public take(): Value | undefined {\n return super.shift();\n }\n}\n","// Data.\nimport { Data, DataCore, DataConstructorInput } from '@typescript-package/data';\n// Abstract.\nimport { HistoryCurrent } from '../core';\n/**\n * @description\n * @export\n * @class CurrentHistory\n * @template Value \n * @template {DataCore<readonly Value[]>} [DataType=Data<readonly Value[]>] \n * @extends {HistoryCurrent<Value, DataType>}\n */\nexport class CurrentHistory<\n Value,\n DataType extends DataCore<readonly Value[]> = Data<readonly Value[]>\n> extends HistoryCurrent<Value, DataType> {\n /**\n * @description Returns the `string` tag representation of the `CurrentHistory` class when used in `Object.prototype.toString.call(instance)`.\n * @public\n * @readonly\n * @type {string}\n */\n public override get [Symbol.toStringTag](): string {\n return CurrentHistory.name;\n }\n\n /**\n * @description The current history value.\n * @public\n * @readonly\n * @type {Value}\n */\n public get value(): Value {\n return Array.isArray(super.data.value) ? super.data.value[0] : undefined as Value;\n }\n\n /**\n * Creates an instance of `CurrentHistory`.\n * @constructor\n * @param {{value?: Value}} [param0={}] THe object with current `value`.\n * @param {Value} param0.value The current value inside the object.\n * @param {?DataConstructorInput<Value, DataType>} [data] Custom data holder.\n */\n constructor(\n {value}: {value?: Value} = {},\n data?: DataConstructorInput<readonly Value[], DataType>\n ) {\n super(arguments[0], data);\n }\n\n /**\n * @description Destroys the history of this instance.\n * @public\n * @returns {this} The `this` current instance.\n */\n public override destroy(): this {\n super.clear();\n super.destroy();\n return this;\n }\n\n /**\n * @description Checks whether the current value is set.\n * @public\n * @returns {boolean} Indicates whether instance has set the current value.\n */\n public has(): boolean {\n return Array.isArray(super.data.value) && super.data.value.length > 0;\n }\n\n /**\n * @description Updates a current value.\n * @public\n * @param {Value} value The current value.\n * @returns {this} The `this` current instance.\n */\n public update(value: Value): this {\n super.set([value]);\n return this;\n }\n}\n","import {\n // Abstract.\n DataCore,\n // Type.\n DataConstructorInput,\n ImmutableArray,\n} from '@typescript-package/data';\n// Abstract.\nimport { HistoryCore, HistoryCurrent } from '../core';\n// Type.\nimport { HistoryCurrentConstructor, HistoryCoreConstructor } from '../type';\n/**\n * @description The base abstract class to manage history.\n * @export\n * @abstract\n * @class HistoryBase\n * @template Value \n * @template {number} [Size=number] \n * @template {DataCore<readonly Value[]>} [DataType=Data<readonly Value[]>] \n */\nexport abstract class HistoryBase<\n Value,\n Size extends number,\n DataType extends DataCore<readonly Value[]>,\n CurrentType extends HistoryCurrent<Value, DataType>,\n RedoType extends HistoryCore<Value, Size, DataType>,\n UndoType extends HistoryCore<Value, Size, DataType>,\n> {\n /**\n * @description The max size for undo history.\n * @public\n * @static\n * @type {number}\n */\n public static size: number = Infinity;\n\n /**\n * @description Returns the `string` tag representation of the `HistoryBase` class when used in `Object.prototype.toString.call(instance)`.\n * @public\n * @readonly\n * @type {string}\n */\n public get [Symbol.toStringTag](): string {\n return HistoryBase.name;\n }\n\n /**\n * @description Gets the current value stored in history.\n * @public\n * @readonly\n * @type {Value}\n */\n public get current(): Value {\n return this.#current.value;\n }\n\n /**\n * @description Returns the current history of `CurrentHistory`.\n * @public\n * @readonly\n * @type {CurrentType}\n */\n public get currentHistory(): CurrentType {\n return this.#current;\n }\n\n /**\n * @description\n * @public\n * @readonly\n * @type {{\n * current: DataType,\n * redo: DataType,\n * undo: DataType\n * }}\n */\n public get data(): {\n current: DataType,\n redo: DataType,\n undo: DataType\n } {\n return {\n current: this.#current.data,\n redo: this.#redo.data,\n undo: this.#undo.data,\n }\n }\n\n /**\n * @description Returns the redo history.\n * @public\n * @readonly \n * @type {RedoType}\n */\n public get redoHistory(): RedoType {\n return this.#redo;\n }\n \n /**\n * @description Returns the undo history.\n * @public\n * @readonly\n * @type {UndoType}\n */\n public get undoHistory(): UndoType {\n return this.#undo;\n }\n\n /**\n * @description A private field to store the current value.\n * @type {CurrentType}\n */\n #current: CurrentType;\n\n /**\n * @description Privately stored callback function invoked on redo.\n * @type {(value: Value) => void}\n */\n #onRedoCallback?: (value: Value) => void;\n\n /**\n * @description Privately stored callback function invoked on undo.\n * @type {(value: Value) => void}\n */\n #onUndoCallback?: (value: Value) => void;\n\n /**\n * @description The class to manage the redo history.\n * @type {RedoType}\n */\n #redo: RedoType;\n\n /**\n * @description The class to manage the undo history.\n * @type {UndoType}\n */\n #undo: UndoType;\n\n /**\n * Creates an instance of `HistoryBase` child class.\n * @constructor\n * @param {{ value?: Value, size?: Size}} [param0={}] \n * @param {Value} param0.value \n * @param {Size} param0.size \n * @param {?DataConstructorInput<readonly Value[], DataType>} [data] \n * @param {{\n * current?: HistoryCurrentConstructor<Value, DataType, CurrentType>,\n * redo?: HistoryCoreConstructor<Value, Size, DataType, RedoType>,\n * undo?: HistoryCoreConstructor<Value, Size, DataType, UndoType>,\n * }} [param1={}] \n * @param {HistoryCurrentConstructor<Value, DataType, CurrentType>} param1.current \n * @param {HistoryCoreConstructor<Value, Size, DataType, RedoType>} param1.redo \n * @param {HistoryCoreConstructor<Value, Size, DataType, UndoType>} param1.undo \n */\n constructor(\n {value, size}: { value?: Value, size?: Size} = {},\n data?: DataConstructorInput<readonly Value[], DataType>,\n {current, redo, undo}: {\n current?: HistoryCurrentConstructor<Value, DataType, CurrentType>,\n redo?: HistoryCoreConstructor<Value, Size, DataType, RedoType>,\n undo?: HistoryCoreConstructor<Value, Size, DataType, UndoType>,\n } = {},\n ) {\n this.#current = new (current!)(arguments[0], data);\n this.#redo = new (redo!)(size, undefined, data);\n this.#undo = new (undo!)(size, undefined, data);\n }\n\n /**\n * @description Clears the `current`, `undo` and `redo` history.\n * @public\n * @returns {this} The `this` current instance.\n */\n public clear(): this {\n this.#current.clear();\n this.#redo.clear();\n this.#undo.clear();\n return this;\n }\n\n /**\n * @description Destroys the history of this instance.\n * @public\n * @returns {this} The `this` current instance.\n */\n public destroy(): this {\n this.clear();\n this.#current.destroy();\n this.#redo.destroy();\n this.#undo.destroy();\n return this;\n }\n\n //#region get\n /**\n * @description Gets the current, undo and redo history.\n * @public\n * @returns {{ current: Readonly<Value>, undo: ImmutableArray<Value>; redo: ImmutableArray<Value> }} \n */\n public get(): { current: Readonly<Value>, undo: ImmutableArray<Value>; redo: ImmutableArray<Value> } {\n return {\n current: this.#current.value,\n undo: this.#undo.get(),\n redo: this.#redo.get(),\n };\n }\n \n /**\n * @description The instance method returns read-only redo history.\n * @public\n * @template Type\n * @returns {(ImmutableArray<Value>)} \n */\n public getRedo(): ImmutableArray<Value> {\n return this.#redo.get();\n }\n\n /**\n * @description The instance method returns read-only undo history.\n * @public\n * @template Type \n * @returns {(ImmutableArray<Value>)} \n */\n public getUndo(): ImmutableArray<Value> {\n return this.#undo.get();\n }\n //#endregion\n\n /**\n * @description Checks whether the current value is set.\n * @public\n * @returns {boolean} \n */\n public hasCurrent(): boolean {\n return this.#current.has();\n }\n\n /**\n * @description Checks whether the history is enabled by checking undo size.\n * @public\n * @returns {boolean} \n */\n public isEnabled(): boolean {\n return this.#undo.size > 0 === true;\n }\n\n //#region on\n /**\n * @description Sets the callback function invoked on redo.\n * @public\n * @param {(value: Value) => void} callbackFn The callback function to invoke.\n * @returns {this} \n */\n public onRedo(callbackFn: (value: Value) => void): this {\n this.#onRedoCallback = callbackFn;\n return this;\n }\n\n /**\n * @description Sets the callback function invoked on undo.\n * @public\n * @param {(value: Value) => void} callbackFn The callback function to invoke.\n * @returns {this} \n */\n public onUndo(callbackFn: (value: Value) => void): this {\n this.#onUndoCallback = callbackFn;\n return this;\n }\n //#endregion\n\n /**\n * @description Returns the specified by index value from redo history.\n * @public\n * @param {number} [index=0] \n * @returns {(Value | undefined)} \n */\n public redoAt(index: number = 0): Value | undefined {\n return this.#redo.at(index);\n }\n\n /**\n * @description Returns the specified by index value from undo history.\n * @public\n * @param {number} [index=this.#undo.length - 1] \n * @returns {(Value | undefined)} \n */\n public undoAt(index: number = this.#undo.length - 1): Value | undefined {\n return this.#undo.at(index);\n }\n\n //#region first\n /**\n * @description Returns the first value that would be redone without modifying history.\n * @public\n * @returns {Value | undefined} The first redo value.\n */\n public firstRedo(): Value | undefined {\n return this.#redo.first();\n }\n\n /**\n * @description Returns the first value that would be undone without modifying history.\n * @public\n * @returns {Value | undefined} The first undo value.\n */\n public firstUndo(): Value | undefined {\n return this.#undo.first();\n }\n //#endregion\n\n //#region last\n /**\n * @description Returns the last value that would be redone without modifying history.\n * @public\n * @returns {Value | undefined} The last redo value.\n */\n public lastRedo(): Value | undefined {\n return this.#redo.last();\n }\n\n /**\n * @description Returns the last value that would be undone without modifying history.\n * @public\n * @returns {Value | undefined} The last undo value.\n */\n public lastUndo(): Value | undefined {\n return this.#undo.last();\n }\n //#endregion\n\n //#region next\n /**\n * @description Returns the next value that would be redone without modifying history.\n * @public\n * @returns {Value | undefined} The next redo value.\n */\n public nextRedo(): Value | undefined {\n return this.#redo.next();\n }\n\n /**\n * @description Returns the next value that would be undone without modifying history.\n * @public\n * @returns {Value | undefined} The next undo value.\n */\n public nextUndo(): Value | undefined {\n return this.#undo.next();\n }\n //#endregion\n\n /**\n * @description Pick the current, redo or undo history.\n * @public\n * @param {('current' | 'redo' | 'undo')} type \n * @returns {ImmutableArray<Value>} \n */\n public pick(type: 'current' | 'redo' | 'undo'): ImmutableArray<Value> {\n switch(type) {\n case 'current': return this.#current.get();\n case 'redo': return this.#redo.get();\n case 'undo': return this.#undo.get();\n default: throw new Error(`Invalid type: ${type}. Expected 'current', 'redo', or 'undo'.`);\n }\n }\n\n /**\n * @description Redoes the last undone action.\n * @public\n * @returns {this} The current instance.\n */\n public redo(): this {\n const redo = this.#redo;\n if (redo.get()?.length) {\n const value = redo.take();\n this.#undo.add(this.#current.value);\n this.#current.update(value as Value);\n this.#onRedoCallback?.(value as Value);\n }\n return this;\n }\n\n /**\n * @description Sets a new value and updates the undo history.\n * @public\n * @param {Value} value \n * @returns {this} The `this` current instance.\n */\n public set(value: Value): this {\n this.#current.has() && this.#undo.add(this.#current.value);\n this.#current.update(value);\n this.#redo.clear();\n return this;\n }\n\n /**\n * @description Sets the size of undo history.\n * @public\n * @param {Size} size The maximum size for undo history.\n */\n public setSize(size: Size): this {\n this.#undo.setSize(size);\n return this;\n }\n\n /**\n * @description Undoes the last action and moves it to redo history.\n * @public\n * @returns {this} The current instance.\n */\n public undo(): this {\n const undo = this.#undo;\n if (undo.get()?.length) {\n const value = undo.take();\n this.#redo.add(this.#current.value);\n this.#current.update(value as Value);\n this.#onUndoCallback?.(value as Value);\n }\n return this;\n }\n}\n","import {\n // Class.\n Data,\n // Abstract.\n DataCore,\n // Type.\n DataConstructorInput\n} from '@typescript-package/data';\n// Abstract.\nimport { HistoryPrepend } from '../core';\n/**\n * @description Manages the redo history with prepend mechanism.\n * @export\n * @class RedoHistory\n * @template [Value=any] The type of elements stored in the history\n * @template {number} [Size=number] The maximum size of the history.\n * @template {DataCore<readonly Value[]>} [DataType=Data<readonly Value[]>] \n * @extends {HistoryPrepend<Value, Size, DataType>}\n */\nexport class RedoHistory<\n Value = any,\n Size extends number = number,\n DataType extends DataCore<readonly Value[]> = Data<readonly Value[]>\n> extends HistoryPrepend<Value, Size, DataType> {\n /**\n * Creates an instance of `RedoHistory`.\n * @constructor\n * @param {Size} [size=RedoHistory.size as Size] \n * @param {?readonly [Value]} [initialValue] \n * @param {?DataConstructorInput<readonly Value[], DataType>} [data] \n */\n constructor(\n size: Size = RedoHistory.size as Size,\n initialValue?: readonly Value[],\n data?: DataConstructorInput<readonly Value[], DataType>,\n ) {\n super(size, initialValue, data);\n }\n}\n","import {\n // Class.\n Data,\n // Abstract.\n DataCore,\n // Type.\n DataConstructorInput\n} from '@typescript-package/data';\n// Abstract.\nimport { HistoryAppend } from '../core';\n/**\n * @description Manages the undo history with append mechanism.\n * @export\n * @class UndoHistory\n * @template [Value=any] The type of elements stored in the history.\n * @template {number} [Size=number] The maximum size of the history.\n * @template {DataCore<readonly Value[]>} [DataType=Data<readonly Value[]>] \n * @extends {HistoryAppend<Value, Size, DataType>}\n */\nexport class UndoHistory<\n Value = any,\n Size extends number = number,\n DataType extends DataCore<readonly Value[]> = Data<readonly Value[]>\n> extends HistoryAppend<Value, Size, DataType>{\n /**\n * Creates an instance of `UndoHistory`.\n * @constructor\n * @param {Size} [size=HistoryAppend.size as Size] \n * @param {?readonly [Value]} [initialValue] \n * @param {?DataConstructorInput<readonly Value[], DataType>} [data] \n */\n constructor(\n size: Size = HistoryAppend.size as Size,\n initialValue?: readonly Value[],\n data?: DataConstructorInput<readonly Value[], DataType>,\n ) {\n super(size, initialValue, data);\n }\n}\n","import {\n // Class.\n Data,\n // Abstract.\n DataCore,\n // Type.\n DataConstructorInput\n} from '@typescript-package/data';\n// Abstract.\nimport { CurrentHistory, HistoryBase, RedoHistory, UndoHistory } from './base';\nimport { HistoryCore, HistoryCurrent } from './core';\n// Type.\nimport { HistoryCoreConstructor, HistoryCurrentConstructor } from './type';\n/**\n * @description The class to manage the value changes.\n * @export\n * @class History\n * @template Value \n * @template {number} [Size=number] \n * @template {DataCore<readonly Value[]>} [DataType=Data<readonly Value[]>] \n */\nexport class History<\n Value,\n Size extends number = number,\n DataType extends DataCore<readonly Value[]> = Data<readonly Value[]>,\n CurrentType extends HistoryCurrent<Value, DataType> = CurrentHistory<Value, DataType>,\n RedoType extends HistoryCore<Value, Size, DataType> = RedoHistory<Value, Size, DataType>,\n UndoType extends HistoryCore<Value, Size, DataType> = UndoHistory<Value, Size, DataType>,\n> extends HistoryBase<Value, Size, DataType, CurrentType, RedoType, UndoType> {\n /**\n * @description The max size for undo history.\n * @public\n * @static\n * @type {number}\n */\n public static override size: number = Infinity;\n\n /**\n * @description Returns the `string` tag representation of the `History` class when used in `Object.prototype.toString.call(instance)`.\n * @public\n * @readonly\n * @type {string}\n */\n public override get [Symbol.toStringTag](): string {\n return History.name;\n }\n\n /**\n * Creates an instance of `History`.\n * @constructor\n * @param {{ value?: Value, size?: Size}} [param0={}] The optional `value` and maximum undo history `size`.\n * @param {Value} param0.value The initial value.\n * @param {Size} param0.size The maximum undo history size.\n * @param {?DataConstructorInput<readonly Value[], DataType>} [data] The custom data holder for history, current, undo and redo.\n * @param {{\n * current?: HistoryCurrentConstructor<Value, DataType, CurrentType>,\n * redo?: HistoryCoreConstructor<Value, Size, DataType, RedoType>,\n * undo?: HistoryCoreConstructor<Value, Size, DataType, UndoType>,\n * }} [param1={}] \n * @param {HistoryCurrentConstructor<Value, DataType, CurrentType>} param1.current Custom current history class of `HistoryCurrent`.\n * @param {HistoryCoreConstructor<Value, Size, DataType, RedoType>} param1.redo Custom redo history class of `HistoryCore`.\n * @param {HistoryCoreConstructor<Value, Size, DataType, UndoType>} param1.undo Custom undo history class of `HistoryCore`.\n */\n constructor(\n {value, size}: { value?: Value, size?: Size} = {},\n data?: DataConstructorInput<readonly Value[], DataType>,\n {current, redo, undo}: {\n current?: HistoryCurrentConstructor<Value, DataType, CurrentType>,\n redo?: HistoryCoreConstructor<Value, Size, DataType, RedoType>,\n undo?: HistoryCoreConstructor<Value, Size, DataType, UndoType>,\n } = {},\n ) {\n super(arguments[0], data, {\n current: current ?? CurrentHistory as HistoryCurrentConstructor<Value, DataType, CurrentType>,\n redo: redo ?? RedoHistory as unknown as HistoryCoreConstructor<Value, Size, DataType, RedoType>,\n undo: undo ?? UndoHistory as unknown as HistoryCoreConstructor<Value, Size, DataType, UndoType>\n });\n }\n}\n","/*\n * Public API Surface of history\n */\n// Main.\nexport {\n History\n} from './lib';\n// Core.\nexport {\n // Abstract.\n HistoryAppend,\n HistoryCore,\n HistoryCurrent,\n HistoryPrepend,\n HistoryStorage,\n} from './lib';\n// Base.\nexport {\n CurrentHistory,\n HistoryBase,\n RedoHistory,\n UndoHistory,\n} from './lib/base';\n// Type.\nexport type {\n HistoryCoreConstructor,\n HistoryCurrentConstructor,\n} from './lib/type';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAQA;;;;;;;AAOG;MACmB,cAAc,CAAA;AAIlC;;;;;AAKG;AAC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