import { UserConfig, Plugin } from 'vite'; /** * Applet Frontend Kit: Vite config helpers for applets running behind a base path * with dev proxy and optional local SDK aliasing. */ type AppletViteOptions = { /** Applet base path (e.g. "/admin/ali/chat" or "/bi-chat"). */ basePath: string; /** Backend URL for proxy (e.g. "http://localhost:3200"). */ backendUrl: string; /** Enable Vite aliases to a local SDK dist during dev iteration. Rare: prefer applet dev's managed local package. */ enableLocalSdkAliases?: boolean; /** Override SDK dist directory when enableLocalSdkAliases is true. */ sdkDistDir?: string; /** Merge additional Vite config */ extend?: UserConfig; }; /** * Returns base URL for assets (with trailing slash). Uses APPLET_ASSETS_BASE env if set, otherwise derives from basePath. */ declare function getAppletAssetsBase(basePath: string): string; /** * Returns dev server port from APPLET_VITE_PORT env, or the given default. */ declare function getAppletVitePort(defaultPort?: number): number; /** * Builds a full Vite config for an applet: base, port, dedupe, proxy, optional local SDK aliases. * * **Merge semantics for `extend`:** When you pass `extend`, it is merged with the base config as follows: * - **resolve.alias**: arrays are concatenated (base aliases first, then extend aliases). * - **plugins**: arrays are concatenated (base plugins first, then extend plugins). * - **server**, **base**, **resolve.dedupe** and other scalar/object fields: extend overrides base (Object.assign-style). * To fully override the base config, spread first: `defineConfig({ ...createAppletViteConfig(opts), ...yourOverrides })`. */ declare function createAppletViteConfig(opts: AppletViteOptions): UserConfig; /** * Returns proxy entries for applet RPC and stream under basePath. * Use as server.proxy in Vite config. * Note: /stream is SSE; plain string targets do not set ws or changeOrigin. If WebSocket upgrade or SSE proxying issues arise, configure proxy with ws: true or a custom configure. */ declare function createAppletBackendProxy(opts: { basePath: string; backendUrl: string; }): Record; /** * Returns resolve.alias entries to point @iota-uz/sdk and @iota-uz/sdk/bichat to a local dist. * Rare escape hatch for non-standard local SDK layouts. Prefer applet dev's managed local package flow. */ declare function createLocalSdkAliases(opts?: { enabled?: boolean; sdkDistDir?: string; }): Array<{ find: string | RegExp; replacement: string; }>; /** * Vite plugin that provides a virtual module exporting the compiled applet CSS string * for Shadow DOM injection (defineReactAppletElement({ styles })). * Can compile CSS via Tailwind CLI in the plugin or fall back to reading a prebuilt file. */ declare const VIRTUAL_APPLET_STYLES_ID = "virtual:applet-styles"; type AppletStylesVirtualModuleOptions = { /** * Input CSS for Tailwind (e.g. src/index.css). When set, the plugin tries to run Tailwind CLI to compile. * Default: "src/index.css" */ inputCss?: string; /** * Path to Tailwind config (optional). If not set, CLI uses its default lookup. */ tailwindConfigPath?: string; /** * Path to the compiled CSS file when not using Tailwind CLI (fallback), or when Tailwind is not available. * Default: "dist/style.css" */ outputCssPath?: string; /** * CSS to prepend: package specifiers (e.g. "@iota-uz/sdk/bichat/styles.css") or paths relative to project root. * Specifiers are resolved via Node resolution from the project root. * Default: [] */ prependCss?: string[]; }; /** * Creates a Vite plugin that registers virtual:applet-styles and exports the compiled CSS string. * When inputCss is set, tries to run Tailwind CLI to compile; if Tailwind is not available, falls back to reading outputCssPath. */ declare function createAppletStylesVirtualModulePlugin(options?: AppletStylesVirtualModuleOptions): Plugin; /** * Convenience plugin for BiChat applets: compiles app CSS and prepends SDK BiChat styles. * Uses default input src/index.css and package specifier @iota-uz/sdk/bichat/styles.css. */ declare function createBichatStylesPlugin(options?: Omit): Plugin; export { type AppletStylesVirtualModuleOptions, type AppletViteOptions, VIRTUAL_APPLET_STYLES_ID, createAppletBackendProxy, createAppletStylesVirtualModulePlugin, createAppletViteConfig, createBichatStylesPlugin, createLocalSdkAliases, getAppletAssetsBase, getAppletVitePort };