@drincs/pixi-vn
Version:
Pixi'VN is a npm package that provides various features for creating visual novels.
471 lines (465 loc) • 21.8 kB
TypeScript
import * as _pixi_sound_lib_filters from '@pixi/sound/lib/filters';
import { S as SoundManager, s as soundUtils } from './index-Czfdktw9.js';
export { b as Sound, c as SoundManagerStatic, a as sound } from './index-Czfdktw9.js';
export { AnimationOptions as MotionAnimationOptions } from 'motion';
import * as pixi_js from 'pixi.js';
import { ApplicationOptions, Rectangle } from 'pixi.js';
export { pixi_js as PIXI };
export { Assets, ContainerOptions, Rectangle, Texture, TextureSourceLike, Ticker as TickerValue, UPDATE_PRIORITY } from 'pixi.js';
export { AssetSrc, AssetsBundle, AssetsManifest, LoadParserName, ResolvedAsset, ResolvedSrc, UnresolvedAsset } from 'pixi.js/lib/assets/types';
import { C as CanvasManagerInterface, c as canvasUtils } from './index-D0ncbTLh.js';
export { $ as AnimationOptions, a0 as AnimationSequenceOptions, H as CanvasBaseInterface, b as CanvasEvent, a5 as CanvasEventNamesType, d as CanvasManagerStatic, e as Container, I as ImageContainer, K as ImageContainerMemory, B as ImageContainerOptions, f as ImageSprite, M as ImageSpriteMemory, D as ImageSpriteOptions, a1 as KeyframesType, L as Layer, W as MoveInOutProps, a2 as ObjectSegment, a3 as ObjectSegmentWithTransition, X as PushInOutProps, R as RegisteredCanvasComponents, i as RegisteredEvents, a4 as SequenceOptions, J as ShakeEffectProps, Y as ShowWithDissolveTransitionProps, Z as ShowWithFadeTransitionProps, S as Sprite, N as SpriteBaseMemory, O as SpriteMemory, E as SpriteOptions, T as Text, P as TextMemory, F as TextOptions, U as TextureMemory, V as VideoSprite, Q as VideoSpriteMemory, G as VideoSpriteOptions, _ as ZoomInOutProps, v as addImage, t as addImageCointainer, y as addVideo, a as canvas, g as canvasComponentDecorator, h as eventDecorator, x as getTexture, m as moveIn, j as moveOut, p as pushIn, k as pushOut, r as removeWithDissolve, l as removeWithFade, s as shakeEffect, w as showImage, u as showImageContainer, A as showVideo, n as showWithDissolve, o as showWithFade, z as zoomIn, q as zoomOut } from './index-D0ncbTLh.js';
import { c as characterUtils } from './index-Cvdua0o-.js';
export { C as CharacterBaseModel, b as CharacterInterface, a as CharacterStoredClass, R as RegisteredCharacters } from './index-Cvdua0o-.js';
export { CachedMap } from './classes/index.js';
import { filters as filters$1 } from '@pixi/sound';
import { P as PauseType, R as RepeatType } from './TickersSequence-Cf1Vcu22.js';
export { T as Ticker, a as TickerArgs, b as TickerHistory, c as TickerInfo, d as TickersSequence } from './TickersSequence-Cf1Vcu22.js';
import { HistoryManagerInterface } from './history/index.js';
export { HistoryManagerStatic, stepHistory } from './history/index.js';
import { GameState } from './interfaces/index.js';
export { GameStepStateData } from './interfaces/index.js';
import { S as StepLabelType, a as StepLabelPropsType, N as NarrationManagerInterface, L as LabelAbstract, n as narrationUtils } from './index-_rD16ks5.js';
export { C as ChoiceInterface, I as InputInfo, e as Label, g as LabelProps, k as LabelSteps, j as NarrationManagerStatic, R as RegisteredLabels, h as StepLabelProps, i as StepLabelResult, l as StepLabelResultType, b as narration, c as newChoiceOption, d as newCloseChoiceOption, f as newLabel } from './index-_rD16ks5.js';
import { StorageManagerInterface } from './storage/index.js';
export { StorageManagerStatic, storage } from './storage/index.js';
import { GameStepState, HistoryInfo, CharacterInterface } from '@drincs/pixi-vn';
import { S as StorageElementType } from './StorageElementType-DTGcnkzF.js';
export { a as StorageObjectType } from './StorageElementType-DTGcnkzF.js';
import { createExportableElement } from './utils/index.js';
import { Devtools } from '@pixi/devtools';
export { C as CanvasBaseItem, b as CanvasBaseItemMemory, a as CanvasGameState, d as ContainerChild, c as ContainerMemory } from './ContainerMemory-DrijxCcD.js';
export { CommonTickerProps, FadeAlphaTicker, FadeAlphaTickerProps, MoveTicker, MoveTickerProps, RegisteredTickers, RotateTicker, RotateTickerProps, TickerBase, TickerProgrationExponential, TickerProgrationLinear, TickerProgrationType, TickerTimeoutHistory, ZoomTicker, ZoomTickerProps, animate, tickerDecorator } from './canvas/tickers/index.js';
export { H as HistoryGameState } from './HistoryGameState-i_gx3rGM.js';
export { a as ChoiceOptionInterface, d as Close, b as CloseChoiceOptionInterface, C as CloseType, D as DialogueInterface, H as HistoryStep, L as LabelRunModeType, O as OpenedLabel, S as StoredChoiceInterface, c as StoredIndexedChoiceInterface } from './OpenedLabel-DxlOwJKw.js';
export { N as NarrationGameState } from './NarrationGameState-CqDh48n_.js';
export { H as HistoryChoiceMenuOption, N as NarrationHistory } from './HistoryChoiceMenuOption-Kj_P28ke.js';
export { E as ExportedSound, c as SoundFilterMemory, S as SoundGameState, a as SoundOptions, b as SoundPlayOptions } from './SoundGameState-BG_iPwjt.js';
export { S as StoredClassModel } from './StoredClassModel-CjdhvNgB.js';
export { S as StorageGameState } from './StorageGameState-Cnfj75sk.js';
import 'lru-cache';
import 'deep-diff';
import 'microdiff';
var version = "1.3.12";
declare const Repeat: RepeatType;
/**
* Pause the tickers for a duration.
* @param duration Duration in seconds
* @returns The pause object
*/
declare function Pause(duration: number): PauseType;
declare const filters: {
DistortionFilter: typeof filters$1.DistortionFilter;
EqualizerFilter: typeof filters$1.EqualizerFilter;
MonoFilter: typeof filters$1.MonoFilter;
ReverbFilter: typeof filters$1.ReverbFilter;
StereoFilter: typeof filters$1.StereoFilter;
StreamFilter: typeof filters$1.StreamFilter;
TelephoneFilter: typeof filters$1.TelephoneFilter;
};
/**
* Is a special alias to indicate the game layer.
*/
declare const CANVAS_APP_GAME_LAYER_ALIAS = "__game_layer__";
declare const SYSTEM_RESERVED_STORAGE_KEYS: {
/**
* The key of the current dialogue memory
*/
CURRENT_DIALOGUE_MEMORY_KEY: string;
/**
* The key of the last dialogue added in the step memory
*/
LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY: string;
/**
* The key of the current menu options memory
*/
CURRENT_MENU_OPTIONS_MEMORY_KEY: string;
/**
* The key of the last menu options added in the step memory
*/
LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY: string;
/**
* The key of the input memory. This value can be read by pixi-vn json importer
*/
CURRENT_INPUT_VALUE_MEMORY_KEY: string;
/**
* The key of the last input added in the step memory
*/
LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY: string;
/**
* The key of the current input info
*/
CURRENT_INPUT_INFO_MEMORY_KEY: string;
/**
* The key of the characters memory
*/
CHARACTER_CATEGORY_KEY: string;
/**
* This variable is used to add the next dialog text into the current dialog memory.
* This value was added to introduce Ink Glue functionality https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md#glue
*/
ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY: string;
/**
* The key of a list of all labels that have been opened during the progression of the steps.
*/
OPENED_LABELS_COUNTER_KEY: string;
/**
* The key of a list of all choices that have been made during the progression of the steps.
*/
ALL_CHOICES_MADE_KEY: string;
/**
* The key of the current step times counter.
* This value was added to introduce Ink Sequences, cycles and other alternatives https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md#sequences-cycles-and-other-alternatives
*/
CURRENT_STEP_TIMES_COUNTER_KEY: string;
/**
* The key of the last dialogue step glued in the step memory
*/
LAST_STEP_GLUED: string;
};
declare class GameUnifier {
static init(options: {
/**
* This function returns the current step counter. This counter corresponds to the total number of steps that have been executed so far.
*
* If your game engine does not have a history of steps, you can return 0.
*/
getStepCounter: () => number;
/**
* This function sets the current step counter.
*
* If your game engine does not have a history of steps, you can not set the step counter.
*/
setStepCounter: (value: number) => void;
/**
* This function returns the current state of the game step.
*
* If your game engine does not have a history of steps, you can return an empty object.
*/
getCurrentGameStepState: () => GameStepState;
/**
* This function restores the game step state.
*
* If your game engine does not have a history of steps, you can return a resolved promise.
*
* @param state The state to restore.
* @param navigate The function to navigate to the restored path.
*/
restoreGameStepState: (state: GameStepState, navigate: (path: string) => void | Promise<void>) => Promise<void>;
/**
* This function returns the number of opened labels.
*
* If your game engine does not have a narration system, you can return 0.
*/
getOpenedLabels: () => number;
/**
* This function is called after the narration.goNext() method is executed.
* It can be used to force the completion of the ticker in the game engine.
*/
onGoNextEnd?: () => Promise<void>;
/**
* This function returns the value of a variable.
* @param key The key of the variable.
* @returns The value of the variable.
*/
getVariable: <T extends StorageElementType>(key: string) => T | undefined;
/**
* This function sets the value of a variable.
* @param key The key of the variable.
* @param value The value of the variable.
*/
setVariable: (key: string, value: StorageElementType) => void;
/**
* This function removes a variable.
* @param key The key of the variable.
*/
removeVariable: (key: string) => void;
/**
* This function returns the value of a flag.
* @param name The name of the flag.
*/
getFlag: (name: string) => boolean;
/**
* This function sets the value of a flag.
* @param name The name of the flag.
* @param value The value of the flag.
*/
setFlag: (name: string, value: boolean) => void;
/**
* This function is called after the narration.goNext() method is executed.
*
* It can be used to clear old temporary variables.
*
* @param openedLabelsNumber The number of opened labels.
*/
onLabelClosing?: (openedLabelsNumber: number) => void;
/**
* Add a history step to the history.
*
* If your game engine does not have a history of steps, you can return a resolved promise.
*
* @param historyInfo The history information.
* @param opstions Options to add the step.
*/
addHistoryItem(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;
/**
* This function returns the number of steps that are currently running.
*/
getCurrentStepsRunningNumber: () => number;
/**
* This function returns the character by its id.
* @param id The id of the character.
* @returns The character or undefined if it does not exist.
*/
getCharacter: (id: string) => CharacterInterface | undefined;
}): void;
private static _getStepCounter;
private static _setStepCounter;
/**
* Returns the current step counter. This counter corresponds to the total number of steps that have been executed so far.
*/
static get stepCounter(): number;
/**
* Returns the current state of the game step.
*/
static set stepCounter(value: number);
private static _getCurrentGameStepState;
/**
* Returns the current state of the game step.
*/
static get currentGameStepState(): GameStepState;
private static _restoreGameStepState;
/**
* Restores the game step state.
* @param state The state to restore.
* @param navigate The function to navigate to the restored path.
*/
static get restoreGameStepState(): (state: GameStepState, navigate: (path: string) => void | Promise<void>) => Promise<void>;
private static _getOpenedLabels;
/**
* Returns the number of opened labels.
*/
static get openedLabels(): number;
private static _onGoNextEnd;
/**
* This function is called after the narration.goNext() method is executed.
* It can be used to force the completion of the ticker in the game engine.
*/
static get onGoNextEnd(): () => Promise<void>;
private static _getVariable;
/**
* This function returns the value of a variable.
* @param key The key of the variable.
* @returns The value of the variable.
*/
static get getVariable(): <T extends StorageElementType>(key: string) => T | undefined;
private static _setVariable;
/**
* This function sets the value of a variable.
* @param key The key of the variable.
* @param value The value of the variable.
*/
static get setVariable(): (key: string, value: StorageElementType) => void;
private static _removeVariable;
/**
* This function removes a variable.
* @param key The key of the variable.
*/
static get removeVariable(): (key: string) => void;
private static _getFlag;
/**
* This function returns the value of a flag.
* @param name The name of the flag.
*/
static get getFlag(): (name: string) => boolean;
private static _setFlag;
/**
* This function sets the value of a flag.
* @param name The name of the flag.
* @param value The value of the flag.
*/
static get setFlag(): (name: string, value: boolean) => void;
private static _onLabelClosing;
/**
* This function is called after the narration.goNext() method is executed
* It can be used to clear old temporary variables.
* @param openedLabelsNumber The number of opened labels.
*/
static get onLabelClosing(): (openedLabelsNumber: number) => void;
private static _addHistoryItem;
/**
* Add a history step to the history.
* @param historyInfo The history information.
* @param opstions Options to add the step.
*/
static get addHistoryItem(): (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;
private static _getCurrentStepsRunningNumber;
/**
* Returns the number of steps that are currently running.
*/
static get currentStepsRunningNumber(): number;
private static _getCharacter;
/**
* This function returns the character by its id.
* @param id The id of the character.
* @returns The character or undefined if it does not exist.
*/
static get getCharacter(): (id: string) => CharacterInterface | undefined;
static onEnd?: StepLabelType;
static onError?: (type: "step", error: any, props: StepLabelPropsType) => void;
}
declare namespace Game {
/**
* Initialize the Game and PixiJS Application and the interface div.
* This method should be called before any other method.
* @param element The html element where I will put the canvas. Example: document.body
* @param width The width of the canvas
* @param height The height of the canvas
* @param options The options of PixiJS Application
* @param devtoolsOptions The options of the devtools. You can read more about it in the [PixiJS Devtools documentation](https://pixijs.io/devtools/docs/plugin/)
* @example
* ```typescript
* const body = document.body
* if (!body) {
* throw new Error('body element not found')
* }
* await Game.initialize(body, {
* width: 1920,
* height: 1080,
* backgroundColor: "#303030"
* })
* ```
*/
function init(element: HTMLElement, options: Partial<ApplicationOptions> & {
width: number;
height: number;
}, devtoolsOptions?: Devtools): Promise<void>;
/**
* Clear all game data. This function is used to reset the game.
*/
function clear(): void;
/**
* Get all the game data. It can be used to save the game.
* @returns The game data
*/
function exportGameState(): GameState;
/**
* Load the save data
* @param data The save data
* @param navigate The function to navigate to a path
*/
function restoreGameState(data: GameState, navigate: (path: string) => void | Promise<void>): Promise<void>;
/**
* Convert a JSON string to a save data
* @param json The JSON string
* @returns The save data
*/
function jsonToGameState(json: string): GameState;
/**
* Function to be executed at the end of the game. It should be set in the game initialization.
* @example
* ```typescript
* Game.onEnd(async (props) => {
* props.navigate("/end")
* })
* ```
*/
function onEnd(value: StepLabelType): void;
/**
* Function to be executed when an error occurs in the step.
* @example
* ```typescript
* Game.onError((type, error, props) => {
* props.notify("An error occurred")
* // send a notification to GlitchTip, Sentry, etc...
* })
* ```
*/
function onError(value: (type: "step", error: any, props: StepLabelPropsType) => void): void;
/**
* Is a function that will be executed before any step is executed.
* @param stepId Step id
* @param label Label
* @returns
*/
function onStepStart(value: (stepId: number, label: LabelAbstract<any>) => void | Promise<void>): void;
/**
* Is a function that will be executed in {@link Game.onStepStart} if the id of the step is 0
* and when the user laods a save file.
* When you load a save file, will be executed all onLoadingLabel functions of the {@link narrationUtils.narration}.openedLabels.
* It is useful for example to make sure all images used have been cached
* @param stepId Step id
* @param label Label
* @returns
* @example
* ```typescript
* Game.onLoadingLabel(async (stepId, label) => {
* await Assets.load('path/to/image1.png')
* await Assets.load('path/to/image2.png')
* })
* ```
*/
function onLoadingLabel(value: (stepId: number, label: LabelAbstract<any>) => void | Promise<void>): void;
/**
* Is a function that will be executed when the step ends.
* @param stepId Step id
* @param label Label
* @returns
*/
function onStepEnd(value: (stepId: number, label: LabelAbstract<any>) => void | Promise<void>): void;
}
declare const _default: {
canvas: CanvasManagerInterface;
narration: NarrationManagerInterface;
sound: SoundManager;
storage: StorageManagerInterface;
history: HistoryManagerInterface;
Game: typeof Game;
GameUnifier: typeof GameUnifier;
createExportableElement: typeof createExportableElement;
Assets: pixi_js.AssetsClass;
Rectangle: typeof Rectangle;
characterUtils: typeof characterUtils;
canvasUtils: typeof canvasUtils;
narrationUtils: typeof narrationUtils;
soundUtils: typeof soundUtils;
CANVAS_APP_GAME_LAYER_ALIAS: string;
filters: {
DistortionFilter: typeof _pixi_sound_lib_filters.DistortionFilter;
EqualizerFilter: typeof _pixi_sound_lib_filters.EqualizerFilter;
MonoFilter: typeof _pixi_sound_lib_filters.MonoFilter;
ReverbFilter: typeof _pixi_sound_lib_filters.ReverbFilter;
StereoFilter: typeof _pixi_sound_lib_filters.StereoFilter;
StreamFilter: typeof _pixi_sound_lib_filters.StreamFilter;
TelephoneFilter: typeof _pixi_sound_lib_filters.TelephoneFilter;
};
Pause: typeof Pause;
Repeat: "repeat";
SYSTEM_RESERVED_STORAGE_KEYS: {
CURRENT_DIALOGUE_MEMORY_KEY: string;
LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY: string;
CURRENT_MENU_OPTIONS_MEMORY_KEY: string;
LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY: string;
CURRENT_INPUT_VALUE_MEMORY_KEY: string;
LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY: string;
CURRENT_INPUT_INFO_MEMORY_KEY: string;
CHARACTER_CATEGORY_KEY: string;
ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY: string;
OPENED_LABELS_COUNTER_KEY: string;
ALL_CHOICES_MADE_KEY: string;
CURRENT_STEP_TIMES_COUNTER_KEY: string;
LAST_STEP_GLUED: string;
};
PIXIVN_VERSION: string;
};
export { CANVAS_APP_GAME_LAYER_ALIAS, CanvasManagerInterface, Game, GameState, GameUnifier, HistoryManagerInterface, LabelAbstract, NarrationManagerInterface, version as PIXIVN_VERSION, Pause, PauseType, Repeat, RepeatType, SYSTEM_RESERVED_STORAGE_KEYS, StepLabelPropsType, StepLabelType, StorageElementType, StorageManagerInterface, createExportableElement, _default as default, filters };