@drincs/pixi-vn-json
Version:
Pixi'VN can be integrated with JSON files to create a visual novel.
128 lines (121 loc) • 7.46 kB
text/typescript
import { c as PixiVNJsonOperation, b as PixiVNJsonIfElse, d as PixiVNJsonOperationString, e as PixiVNJsonCanvasAnimate, f as PixiVNJsonUnknownEdit, g as PixiVNJsonCanvasRemove, h as PixiVNJsonCanvasEffect, i as PixiVNJsonCanvasImageContainerShow, j as PixiVNJsonImageContainerEdit, k as PixiVNJsonCanvasImageVideoShow, l as PixiVNJsonImageEdit, m as PixiVNJsonCanvasTextShow, n as PixiVNJsonTextEdit, o as PixiVNJsonVideoEdit, p as PixiVNJsonVideoPauseResume, q as PixiVNJsonNarration, r as PixiVNJsonSound, P as PixiVNJsonLabelStep, s as PixiVNJsonValueGet, t as PixiVNJsonArithmeticOperations, u as PixiVNJsonConditions, v as PixiVNJsonFunction, w as PixiVNJsonConditionalStatements, x as PixiVNJsonConditionalResultToCombine, y as PixiVNJsonOnlyStorageSet, a as PixiVNJsonValueSet } from './PixiVNJsonLabelStep-C-9WKwTo.cjs';
import { ImageSpriteMemory, VideoSpriteMemory, ContainerMemory, ContainerChild } from '@drincs/pixi-vn/canvas';
import { StepLabelPropsType } from '@drincs/pixi-vn/narration';
import { StorageElementType } from '@drincs/pixi-vn/storage';
import '@drincs/pixi-vn';
import '@drincs/pixi-vn/motion';
import 'pixi.js';
/**
* Loads or lazily-loads asset bundles/aliases described by a JSON operation.
* Supports both individual asset aliases (`type: "assets"`) and named bundles
* (`type: "bundle"`), each with `"load"` (blocking) or `"lazyload"` (background) variants.
*
* @param origin - The operation or conditional expression that describes what to load.
*/
declare function loadAssets(origin: PixiVNJsonOperation | PixiVNJsonIfElse<PixiVNJsonOperation> | PixiVNJsonOperationString): Promise<void>;
/**
* Handles show, edit, and remove operations for {@link ImageSprite} canvas elements.
*
* @param operation - The image operation descriptor.
*/
declare function imageOperation(operation: PixiVNJsonCanvasImageVideoShow | PixiVNJsonImageEdit | PixiVNJsonCanvasRemove): Promise<void>;
/**
* Handles show, edit, remove, pause, and resume operations for {@link VideoSprite} canvas elements.
*
* @param operation - The video operation descriptor.
*/
declare function videoOperation(operation: PixiVNJsonCanvasRemove | PixiVNJsonCanvasImageVideoShow | PixiVNJsonVideoEdit | PixiVNJsonVideoPauseResume): Promise<void>;
/**
* Handles show, edit, and remove operations for {@link ImageContainer} canvas elements.
*
* @param operation - The image-container operation descriptor.
*/
declare function imageContainerOperation(operation: PixiVNJsonCanvasRemove | PixiVNJsonCanvasImageContainerShow | PixiVNJsonImageContainerEdit): Promise<void>;
/**
* Handles show, edit, and remove operations for {@link Text} canvas elements.
* On show, the text content is run through the active {@link translator} before display.
*
* @param operation - The text operation descriptor.
*/
declare function textOperation(operation: PixiVNJsonCanvasRemove | PixiVNJsonCanvasTextShow | PixiVNJsonTextEdit): Promise<void>;
/**
* Handles edit and remove operations for any canvas element whose specific type is unknown.
* Useful as a generic fallback when the element type is not determined at the call site.
*
* @param operation - The generic canvas-element operation descriptor.
*/
declare function canvasElementOperation(operation: PixiVNJsonUnknownEdit<ImageSpriteMemory | VideoSpriteMemory | ContainerMemory<ContainerChild>> | PixiVNJsonCanvasRemove): Promise<void>;
/**
* Applies a visual effect (e.g. shake) to a canvas element.
*
* @param operation - The canvas effect descriptor.
*/
declare function effectOperation(operation: PixiVNJsonCanvasEffect): Promise<void>;
/**
* Starts a keyframe animation or animation sequence on a canvas element.
*
* @param operation - The animate operation descriptor.
*/
declare function animateOperation(operation: PixiVNJsonCanvasAnimate): void;
/**
* Handles narration-related operations such as requesting player input or
* clearing the current dialogue line.
*
* @param operation - The narration operation descriptor.
*/
declare function narrationOperation(operation: PixiVNJsonNarration): void;
/**
* Handles all sound operations: play, stop, pause, resume, and property editing.
* Supports targeting individual sounds, channels, or all sounds at once.
*
* @param operation - The sound operation descriptor.
*/
declare function soundOperation(operation: PixiVNJsonSound): void;
/**
* Sets a value in the appropriate storage layer (flag storage, persistent storage,
* temporary storage, or label parameters) as described by the operation.
*
* @param value - The storage-set operation descriptor.
* @param props - The current step label props (used to resolve dynamic values).
*/
declare function setStorageValue(value: PixiVNJsonValueSet, props?: StepLabelPropsType): void;
/**
* Sets a default (initial) value in persistent or temporary storage.
* Unlike {@link setStorageValue}, this only applies to `"storage"` and `"tempstorage"` types
* and writes to `storage.default` so the value is used as a fallback.
*
* @param value - The initial storage-set operation descriptor.
* @param props - The current step label props (used to resolve dynamic values).
*/
declare function setInitialStorageValue(value: PixiVNJsonOnlyStorageSet, props?: StepLabelPropsType): void;
/**
* Resolves a JSON logic value (storage get, arithmetic, condition, function, conditional statement)
* down to a plain TypeScript value of type `T`.
*
* This is the main evaluation entry-point: conditional statements are unwrapped first,
* then the remaining expression type is dispatched to the appropriate handler.
*
* @param value - The value or expression to resolve.
* @param props - The current step label props passed down through the call chain.
* @returns The resolved value, or `undefined` if the expression cannot be evaluated.
*/
declare function getLogichValue<T = StorageElementType>(value: T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions | PixiVNJsonFunction | PixiVNJsonConditionalStatements<T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions>, props?: StepLabelPropsType): T | undefined;
/**
* Get the value from the conditional statements.
* @param statement is the conditional statements object
* @returns the value from the conditional statements
*/
declare function getValueFromConditionalStatements<T>(statement: PixiVNJsonConditionalResultToCombine<T> | PixiVNJsonConditionalStatements<T> | T | undefined, props?: StepLabelPropsType): T | undefined;
/**
* Resolves the `conditionalStep` field of a label step and merges the result back
* into the step, recursively, until no more conditional overrides remain.
*
* Undefined properties on the resolved conditional step are deleted so they do not
* overwrite existing values on the base step.
*
* @param originalStep - The label step that may contain a `conditionalStep` expression.
* @param props - The current step label props used to evaluate the condition.
* @returns The fully resolved label step.
*/
declare function getConditionalStep(originalStep: PixiVNJsonLabelStep, props?: StepLabelPropsType): PixiVNJsonLabelStep;
export { animateOperation, canvasElementOperation, effectOperation, getConditionalStep, getLogichValue, getValueFromConditionalStatements, imageContainerOperation, imageOperation, loadAssets, narrationOperation, setInitialStorageValue, setStorageValue, soundOperation, textOperation, videoOperation };