UNPKG

@drincs/pixi-vn

Version:

Pixi'VN is a npm package that provides various features for creating visual novels.

64 lines (60 loc) 2.66 kB
import { IncomingMessage, ServerResponse } from 'node:http'; /** @const {string} API endpoint for characters data - GET to retrieve, POST to update */ declare const PIXIVN_DEV_API_CHARACTERS = "/__pixi-vn/characters"; /** @const {string} API endpoint for narration labels - GET to retrieve, POST to update */ declare const PIXIVN_DEV_API_LABELS = "/__pixi-vn/labels"; /** @const {string} API endpoint for assets manifest - GET to retrieve, POST to update */ declare const PIXIVN_DEV_API_ASSETS_MANIFEST = "/__pixi-vn/assets/manifest"; /** @const {string} API endpoint for canvas options - GET to retrieve, POST to update */ declare const PIXIVN_DEV_API_CANVAS_OPTIONS = "/__pixi-vn/canvas-options"; /** * Represents a Vite plugin configuration object. * Defines the structure for registering middleware and handling server requests. * * @typedef {Object} Plugin * @property {string} name - Unique identifier for the plugin * @property {"serve"} apply - Plugin application scope (development server only) * @property {Function} configureServer - Middleware configuration function */ type Plugin = { name: string; apply: "serve"; configureServer: (server: { middlewares: { use: (path: string, handler: (req: IncomingMessage, res: ServerResponse) => void) => void; }; }) => void; }; /** * Creates a Vite development server plugin for Pixi VN integration. * * This plugin provides four API endpoints to sync game state between the client * and the development server. Only active in development mode (serve). * * **Endpoints:** * - `GET /__pixi-vn/characters` - Retrieve cached registered characters * - `POST /__pixi-vn/characters` - Update registered characters from client * - `GET /__pixi-vn/labels` - Retrieve cached narration labels * - `POST /__pixi-vn/labels` - Update narration labels from client * - `GET /__pixi-vn/assets/manifest` - Retrieve PIXI assets manifest * - `POST /__pixi-vn/assets/manifest` - Update assets manifest from client * - `GET /__pixi-vn/canvas-options` - Retrieve canvas rendering options * - `POST /__pixi-vn/canvas-options` - Update canvas options from client * * @returns {Plugin} Configured Vite plugin object * * @example * ```typescript * // vite.config.ts * import { defineConfig } from 'vite'; * import { vitePluginPixivn } from '@drincs/pixi-vn/vite'; * * export default defineConfig({ * plugins: [vitePluginPixivn()], * }); * ``` * * @public */ declare function vitePluginPixivn(): Plugin; export { PIXIVN_DEV_API_ASSETS_MANIFEST, PIXIVN_DEV_API_CANVAS_OPTIONS, PIXIVN_DEV_API_CHARACTERS, PIXIVN_DEV_API_LABELS, vitePluginPixivn };