import { GameStepState, HistoryInfo } from '@drincs/pixi-vn'; import { Difference } from 'microdiff'; import { C as CachedMap } from './CachedMap-DZLvJAnA.cjs'; import { H as HistoryStep } from './HistoryStep-WGB6nA4N.cjs'; import { H as HistoryGameState } from './HistoryGameState-CGfvq5iL.cjs'; import { S as StepLabelPropsType, a as StepLabelResultType } from './StepLabelType-CN97wZzm.cjs'; import { N as NarrationHistory } from './HistoryChoiceMenuOption-BxMSXnyI.cjs'; import 'lru-cache'; import '@drincs/pixi-vn/canvas'; import './StorageElementType-C7ETezlL.cjs'; /** * How often a go-back-able checkpoint is recorded: * - `"step"` (default): every single narration step, matching visual-novel-style games * where the player may want to undo one line/sprite change at a time. * - `"paragraph"`: only when a new paragraph starts (the number of opened labels * changes), a choice is proposed, or an input is requested - matching book-style * narrations where undoing mid-paragraph doesn't make sense to the player. */ type HistoryGoBackModeType = "step" | "paragraph"; declare class HistoryManagerStatic { static _diffHistory: CachedMap; static _stepsInfoHistory: CachedMap>; static _narrationHistory: CachedMap; static stepLimitSaved: number; static goBackMode: HistoryGoBackModeType; static _originalStepData: GameStepState | undefined; static get originalStepData(): GameStepState; static set originalStepData(value: GameStepState); } interface HistoryManagerInterface { /** * How often a go-back-able checkpoint is recorded. * @default "step" * - `"step"`: every single narration step, matching visual-novel-style games where * the player may want to undo one line/sprite change at a time. * - `"paragraph"`: only when a new paragraph starts ({@link HistoryManagerInterface.currentPageParagraphs}), * a choice is proposed, or an input is requested - matching book-style narrations * where undoing mid-paragraph doesn't make sense to the player. Every step within a * paragraph is merged into the checkpoint that closes it out: `back()` from anywhere * inside paragraph N jumps all the way to the *start* of paragraph N-1, not to * wherever you were right before N began - the whole of paragraph N-1 gets replayed. */ goBackMode: HistoryGoBackModeType; /** * Get the narrative history. * @returns the history of the dialogues, choices and steps */ readonly narrativeHistory: NarrationHistory[]; /** * Get the history of the latest steps belonging to the current label and its child labels. * * This is effectively the current "page" of an interactive book: it starts over every time a * {@link NarrationManagerInterface.jump} is performed. * * @returns the history of the dialogues, choices and steps */ readonly currentLabelHistory: NarrationHistory[]; /** * Get the current page ({@link HistoryManagerInterface.currentLabelHistory}) split into paragraphs. * * A new paragraph starts every time the number of opened labels changes compared to the previous step * (i.e. a {@link NarrationManagerInterface.call} was made, or a called label returned), using * {@link NarrationHistory.openedLabelsNumber}. * * @returns the current page as an ordered list of paragraphs, each one a list of steps */ readonly currentPageParagraphs: NarrationHistory[][]; /** * The number of steps to keep in the history into the save file. * * The other older steps will be compressed will be used in {@link HistoryManagerInterface.narrativeHistory} to show the older dialogues. * In the compressed steps, the canvas and storage information will be removed. * * This also means that a player, after saving and loading a save, will only be able to go back to {@link NarrationManagerInterface.stepLimitSaved} steps. * * If you want to keep all steps in the history, you can set this value to Infinity. */ stepLimitSaved: number; /** * Delete the narrative history. * @param itemsNumber The number of items to delete. If undefined, all items will be deleted. */ removeNarrativeHistory(itemsNumber?: number): void; /** * Go back to the last step and add it to the history. * @param props The step label properties. * @param options The navigation options. * @returns */ back: (props: StepLabelPropsType, options?: { /** * The number of steps to go back. Must be greater than 0. @default 1 */ steps?: number; }) => Promise; /** * Block the go back function. */ blockGoBack(): void; /** * Return true if it is possible to go back. */ readonly canGoBack: boolean; /** * Add a step to the history. * @param historyInfo Info about the step to add. * @param opstions Options to add the step. */ add(historyInfo?: HistoryInfo, opstions?: { /** * If true, the step will not be added to the history if the current step is the same as the last step. */ ignoreSameStep?: boolean; }): void; /** * Clear the history. */ clear(): void; /** * Number of items in the history. */ readonly size: number; /** * Get the last key (id) of the history. */ readonly lastKey: number | null; /** * Get all the keys (id) of the history. */ keys(): MapIterator; /** * Get a step from the history. * * **Note:** If the step not contains any information, this method will return undefined. * @param stepIndex The key (id) of the step to get. * @returns The step. */ get(stepIndex: number): NarrationHistory | undefined; /** * Remove a step from the history. * @param stepIndex The key (id) of the step to remove. * @returns True if the step was removed, false if it was not found. */ delete(stepIndex: number): void; /** * Map that contains all information about the steps in the history. * * **Don't edit unless you're sure what you're doing.** */ readonly stepsInfoMap: CachedMap>; /** * Map that contains all the differences between the steps in the history. * The differences will be used to restore a step. * * **Don't edit unless you're sure what you're doing.** */ readonly diffMap: CachedMap; /** * Map that contains all the narration history. * * **Don't edit unless you're sure what you're doing.** */ readonly narrationMap: CachedMap; /** * Export the history to an object. * @returns The history in an object. */ export(): HistoryGameState; /** * Restore the history from an object. * @param data The history in an object. */ restore(data: object): Promise; } declare const stepHistory: HistoryManagerInterface; export { HistoryGameState, type HistoryGoBackModeType, type HistoryManagerInterface, HistoryManagerStatic, stepHistory };