export { INK_DEV_API_HASHTAG_COMMANDS, INK_DEV_API_INFO, INK_DEV_API_TEXT_REPLACES, InkLibraryInfo, InkTextReplaceInfo } from './dev-api.js'; import { Plugin } from 'vite'; export { InkHashtagCommandInfo } from '@drincs/pixi-vn-ink/parser'; import './types-yAwqys0L.js'; import 'inkjs/engine/Error'; /** * Options for {@link vitePluginInk}. */ interface VitePluginInkOptions { /** * Glob pattern specifying which `.ink` files to scan and load automatically. * * When provided, a virtual module `virtual:pixi-vn-ink` is generated and can be imported * anywhere in your app. It exports, as its default export, an array of strings (`string[]`) * containing the raw text of every matched `.ink` file. * * This eliminates the need to manually write a glob-import helper such as `getInkText`. * * The pattern follows the standard glob format used by * [Vite's `import.meta.glob`](https://vite.dev/guide/features#glob-import). * The plugin resolves it from Vite `root` and internally normalizes it to a root-absolute * pattern for the generated virtual module. * * @example "./ink/**\/*.ink" * @example "/src/stories/**\/*.ink" */ inkGlob?: string; /** * Output pattern for generated JSON files from matched `.ink` sources. * * When provided together with {@link VitePluginInkOptions.inkGlob}, each matched `.ink` file is * converted with `convertInkToJson` and written to the rendered destination. * * Placeholders: * - `[name]`: filename without extension * - `[ext]`: source extension without dot * - `[extname]`: source extension with dot * - `[file]`: source path relative to the `inkGlob` static base * - `[path]`: source directory relative to the `inkGlob` static base (with trailing slash) * - `[dir]`: source directory relative to Vite `root` (with trailing slash) * * Relative values are resolved from Vite `root`. * * @example "./public/ink-json/[path][name].json" * @example "/absolute/output/[dir][name].json" */ inkJsonOutputPattern?: string; /** * Custom path (including filename) for the manifest file generated alongside the exported JSON * files. * * When {@link VitePluginInkOptions.inkJsonOutputPattern} is set, a `manifest.json` file listing * all exported JSON URLs is written into the output base directory by default. Use this option * to override the manifest file location and/or its name. * * Relative values are resolved from Vite `root`. * * @example "./public/ink-json/index.json" * @example "./generated/manifest.json" */ inkJsonManifestPath?: string; /** * Character ids to recognise when splitting `characterId: text` speakers in `.ink` files. * Characters from `vite-plugin-pixi-vn` (its `api.characters`) are picked up automatically; * use this to supply ids explicitly when it is not present. * * @example ["alice", "james"] */ characters?: readonly string[]; } /** * Creates a Vite plugin that: * - Prevents Hot Module Replacement (HMR) for `.ink` files and instead sends an `ink-updated` * custom event to the client so that {@link setupInkHmrListener} can reload the story. * - Transforms `.ink` files so they can be imported as plain strings. * - Optionally generates a virtual module `virtual:pixi-vn-ink` (when {@link VitePluginInkOptions.inkGlob} * is provided) that exports all matched ink file contents as a `string[]`, removing the need * to write a manual glob-import helper. * - Optionally exports the same matched `.ink` files as `.json` to a configurable location * (when {@link VitePluginInkOptions.inkJsonOutputPattern} is provided), together with a * `manifest.json` file for bulk runtime loading with `importPixiVNJson`. * * @param options - Optional plugin configuration. * @returns A Vite plugin. * @see https://pixi-vn.com/ink#vite-plugin * @example * ```ts title="vite.config.ts" * // vite.config.ts – without inkGlob (manual loading) * import { defineConfig } from "vite"; * import { vitePluginInk } from "@drincs/pixi-vn-ink/vite"; * * export default defineConfig({ * plugins: [vitePluginInk()], * }); * ``` * * @example * ```ts title="vite.config.ts" * // vite.config.ts – with inkGlob (automatic loading via virtual module) * import { defineConfig } from "vite"; * import { vitePluginInk } from "@drincs/pixi-vn-ink/vite"; * * export default defineConfig({ * plugins: [vitePluginInk({ inkGlob: "./ink/**\/*.ink" })], * }); * ``` * * ```ts title="main.ts" * // main.ts * import { importInkText } from "@drincs/pixi-vn-ink"; * import { setupInkHmrListener } from "@drincs/pixi-vn-ink/vite-listener"; * import inkTexts from "virtual:pixi-vn-ink"; * * await importInkText(inkTexts); * setupInkHmrListener(); * ``` * * @example * ```ts title="vite.config.ts" * // vite.config.ts – generate JSON files in public/ink-json too * import { defineConfig } from "vite"; * import { vitePluginInk } from "@drincs/pixi-vn-ink/vite"; * * export default defineConfig({ * plugins: [ * vitePluginInk({ * inkGlob: "./ink/**\/*.ink", * inkJsonOutputPattern: "./public/ink-json/[path][name].json", * }), * ], * }); * ``` * * @example * ```ts title="main.ts" * // Bulk-load the generated JSON files at runtime * import { importPixiVNJson } from "@drincs/pixi-vn-json/interpreter"; * * const manifest = (await fetch("/ink-json/manifest.json").then((response) => * response.json(), * )) as string[]; * * const stories = await Promise.all( * manifest.map((url) => fetch(url).then((response) => response.json())), * ); * * await Promise.all(stories.map((story) => importPixiVNJson(story))); * ``` */ declare function vitePluginInk(options?: VitePluginInkOptions): Plugin; export { type VitePluginInkOptions, vitePluginInk };