import { IconTypesOptions, Sprite, SvgSpriteOptions } from '@lattice-php/vite-svg-sprite'; import { Plugin, PluginOption, UserConfig } from 'vite'; type InlineDependency = string | RegExp; type ConfigWithTest = UserConfig & { test?: { server?: { deps?: { inline?: InlineDependency[]; }; }; }; }; export type LatticeViteIconsOptions = Omit & { dirs?: string[]; dts?: Partial | false; }; export type LatticeViteOptions = { appRoot?: string; icons?: boolean | LatticeViteIconsOptions; root?: string; source?: boolean; /** Refresh generated TypeScript types via the dev server. Defaults to `true`. */ typescript?: boolean; }; export declare function lattice(options?: LatticeViteOptions): PluginOption[]; /** A Composer package that contributes a Lattice component plugin. */ export type LatticeComponentPackage = { name: string; /** Absolute path to the package's installed directory. */ dir: string; /** Absolute path to the package's JS plugin entry. */ plugin: string; /** Absolute path to the package's stylesheet, when it declares one. */ css?: string; /** Absolute path to the package's icon directory, when it declares one. */ icons?: string; }; type LatticeManifest = { plugin?: string; css?: string; icons?: string; }; type InstalledPackage = { name: string; "install-path"?: string; extra?: { lattice?: LatticeManifest; }; }; type RootPackageJson = { name?: string; extra?: { lattice?: LatticeManifest; }; }; /** * Resolve every Composer package that declares `extra.lattice.plugin` into an * absolute plugin-entry path. `installPathsRelativeTo` is `vendor/composer` (the * dir `installed.json` records its `install-path`s against). */ export declare function collectComponentPackages(installed: { packages?: InstalledPackage[]; } | InstalledPackage[], installPathsRelativeTo: string): LatticeComponentPackage[]; /** * Resolve the composer ROOT project's own `extra.lattice.plugin` — Composer * never lists the root package in `installed.json`, so a component package * declaring the plugin entry in its own composer.json would otherwise be * invisible to its own dev server (e.g. inside a testbench workbench, where * the package itself is the app root). */ export declare function collectRootComponentPackage(composerJson: RootPackageJson, appRoot: string): LatticeComponentPackage[]; /** * Read `/vendor/composer/installed.json` and `/composer.json` * and collect every component package they contribute. */ export declare function discoverComponentPackages(appRoot: string): LatticeComponentPackage[]; /** * Exposes the discovered component packages as `virtual:lattice/plugins` — a * module whose default export is the array of their plugin objects, * ready for `extendRegistry(registry, ...plugins)`. Also grants Vite filesystem * access to each package dir so its source compiles from `vendor/` (or a symlink). * * Also wires the stylesheet counterpart: `@lattice-php/lattice/css` and * `@lattice-php/ui/css` normally resolve straight to the published, static * `lattice.css` — which must stay self-contained, since plenty of consumers * (the docs site, the standalone bundle, a package building itself) import it * without this plugin at all. When `uiCssPath` is given (the app actually * uses this plugin), both specifiers are instead aliased to a generated * wrapper — `@import` of the real stylesheet, every discovered package's * `@source`/`@import`, and a `@source` per framework npm package — so a * consumer's existing single import picks up every package's utilities with * no per-package import or `@source` of their own. `virtual:lattice/css` * exposes just the package-only half the same way, for anyone composing their * own wrapper. Tailwind's `@import` resolver reads the resolved file straight * off disk — it never calls back into a Vite plugin's `load` — so neither can * serve generated content directly; both are aliased to real files instead, * generated into `node_modules/.lattice/` in `buildStart`, and Vite's own * resolver (which Tailwind delegates to for `@import`) follows the alias to * them like any other file. */ export declare function componentPackagesPlugin(packages: LatticeComponentPackage[], appRoot?: string, uiCssPath?: string, options?: { requireComposer?: boolean; frameworkSources?: string[]; }): Plugin; export declare function latticeConfig(options?: LatticeViteOptions): ConfigWithTest; export declare function resolveIconOptions(options: LatticeViteOptions, packages?: LatticeComponentPackage[]): SvgSpriteOptions | null; /** * Builds the same icon sprite the `lattice()` Vite plugin serves, outside of * Vite: ui's icon set, every discovered component package's icons, and the * app's own `icons.dirs`. The result is a `SpriteValue` for `SpriteProvider` * (`href: ""` inlines the markup), which is what a Storybook, a design-system * export, a prerender script, or a test needs to render `Icon` without a * dev server or an emitted asset. */ export declare function buildLatticeSprite(options?: LatticeViteOptions): Sprite & { href: ""; }; export {};