@animus-ui/vite-plugin 0.1.0-next.v7 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -0
- package/dist/index.d.ts +45 -44
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +426 -491
- package/package.json +33 -14
- package/dist/config-serializer.d.ts +0 -25
- package/dist/config-serializer.d.ts.map +0 -1
- package/dist/resolve-global-styles.d.ts +0 -13
- package/dist/resolve-global-styles.d.ts.map +0 -1
- package/dist/resolve-transforms.d.ts +0 -14
- package/dist/resolve-transforms.d.ts.map +0 -1
- package/dist/theme-evaluator.d.ts +0 -32
- package/dist/theme-evaluator.d.ts.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @animus-ui/vite-plugin
|
|
2
|
+
|
|
3
|
+
Static CSS extraction plugin for Vite. Transforms `@animus-ui/system` builder chains into static CSS at build time — zero runtime style injection.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @animus-ui/vite-plugin @animus-ui/system
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
// vite.config.ts
|
|
15
|
+
import react from '@vitejs/plugin-react';
|
|
16
|
+
import { animusExtract } from '@animus-ui/vite-plugin';
|
|
17
|
+
import { defineConfig } from 'vite';
|
|
18
|
+
|
|
19
|
+
export default defineConfig({
|
|
20
|
+
plugins: [react(), animusExtract({ system: './src/ds.ts' })],
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The `system` option points to the file that exports your built system instance. The plugin loads this file in a subprocess to serialize the prop config and theme data for the Rust extraction pipeline.
|
|
25
|
+
|
|
26
|
+
## What It Does
|
|
27
|
+
|
|
28
|
+
1. **Build time**: Analyzes all files importing from `@animus-ui/system`, extracts static styles into CSS with `@layer` ordering
|
|
29
|
+
2. **Dev server**: Runs extraction on startup, holds results in memory, serves CSS via virtual module
|
|
30
|
+
3. **Transforms**: Resolves `__TRANSFORM__` placeholders using your system's named transform functions
|
|
31
|
+
4. **Global styles**: Emits global styles (reset, base) from your exported `createGlobalStyles()` configuration
|
|
32
|
+
|
|
33
|
+
## Important
|
|
34
|
+
|
|
35
|
+
- Do **not** add React resolve aliases to `vite.config.ts` — they break the extraction transform pipeline
|
|
36
|
+
- After system config changes, restart the dev server (the subprocess runs at `buildStart`)
|
|
37
|
+
- Run `bun run clean:light` if styles seem stale (clears `.vite` cache)
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -1,60 +1,61 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
2
|
export interface AnimusExtractOptions {
|
|
3
|
-
/**
|
|
4
|
-
* Theme data for the extraction pipeline.
|
|
5
|
-
*
|
|
6
|
-
* Two forms are accepted:
|
|
7
|
-
* - `string` — pre-serialized flat JSON (legacy; no CSS variable emission)
|
|
8
|
-
* - `{ scales: string; variables: string }` — pre-evaluated scales JSON
|
|
9
|
-
* plus fully-formed CSS variable declarations to prepend to the virtual
|
|
10
|
-
* stylesheet. The caller is responsible for evaluating the theme module
|
|
11
|
-
* (e.g. via `evaluateTheme` or a Bun subprocess) before passing it here.
|
|
12
|
-
*
|
|
13
|
-
* When omitted, the plugin auto-detects `src/theme.ts`, `src/theme.js`,
|
|
14
|
-
* `theme.ts`, or `theme.js` relative to the project root.
|
|
15
|
-
*/
|
|
16
|
-
theme?: string | {
|
|
17
|
-
scales: string;
|
|
18
|
-
variables: string;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Explicit path to the theme module (relative to project root or absolute).
|
|
22
|
-
* Takes precedence over auto-detection, but lower priority than `theme`.
|
|
23
|
-
*/
|
|
24
|
-
themePath?: string;
|
|
25
3
|
/**
|
|
26
4
|
* Path to a module exporting a SystemInstance from `@animus-ui/system`.
|
|
27
|
-
* The module is loaded via
|
|
28
|
-
*
|
|
5
|
+
* The module is loaded via Rust NAPI (OXC + rquickjs) at build start.
|
|
6
|
+
* It provides prop config, group registry, theme tokens, selector aliases,
|
|
7
|
+
* and global styles — everything the extraction pipeline needs.
|
|
29
8
|
*/
|
|
30
|
-
system
|
|
31
|
-
/**
|
|
32
|
-
* Path to a module exporting `getExtractConfig()`. The module is loaded via
|
|
33
|
-
* bun subprocess at build start. Use this for custom Animus instances created
|
|
34
|
-
* with `createAnimus().addGroup(...).build()`.
|
|
35
|
-
*
|
|
36
|
-
* When omitted, automatically imported from `@animus-ui/core`.
|
|
37
|
-
*/
|
|
38
|
-
configPath?: string;
|
|
39
|
-
/**
|
|
40
|
-
* Pre-serialized prop config JSON. When omitted, automatically imported from
|
|
41
|
-
* `@animus-ui/core` via `getExtractConfig()`.
|
|
42
|
-
*/
|
|
43
|
-
config?: string;
|
|
44
|
-
/** Pre-serialized group registry JSON. Maps group names to prop name arrays. */
|
|
45
|
-
groupRegistry?: string;
|
|
9
|
+
system: string;
|
|
46
10
|
/** Glob patterns to include. Defaults to .ts/.tsx/.js/.jsx files. */
|
|
47
11
|
include?: string[];
|
|
48
12
|
/** Glob patterns to exclude. */
|
|
49
13
|
exclude?: string[];
|
|
50
|
-
/**
|
|
51
|
-
|
|
14
|
+
/**
|
|
15
|
+
* File extensions to scan for component definitions and JSX usages.
|
|
16
|
+
* Replaces the default list entirely (not additive). Include `.mdx` to
|
|
17
|
+
* extract components rendered from MDX files — `@mdx-js/mdx` must be
|
|
18
|
+
* installed as a peer for MDX files to be preprocessed; otherwise the
|
|
19
|
+
* plugin warns once at buildStart and skips them.
|
|
20
|
+
*
|
|
21
|
+
* @default ['.ts', '.tsx', '.js', '.jsx', '.mdx']
|
|
22
|
+
*/
|
|
23
|
+
extensions?: string[];
|
|
52
24
|
/** When true, extraction failures throw instead of warning. Use in CI to enforce full extraction. */
|
|
53
25
|
strict?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* When true, run structural self-verification at the end of `buildStart`:
|
|
28
|
+
* component CSS non-empty, assembled layer ordering correct, `:root` block
|
|
29
|
+
* present in variable CSS, no unresolved `__TRANSFORM__` placeholders. Prefix
|
|
30
|
+
* output with `[animus:verify]`. Failures throw when `strict: true`,
|
|
31
|
+
* otherwise warn.
|
|
32
|
+
*/
|
|
33
|
+
verify?: boolean;
|
|
54
34
|
/** Enable verbose logging. Also activatable via ANIMUS_DEBUG=1 env var. */
|
|
55
35
|
verbose?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Browser targets for CSS autoprefixing and syntax lowering.
|
|
38
|
+
* Accepts a browserslist query string or array of queries.
|
|
39
|
+
* Falls back to project's browserslist config, then to `defaults`.
|
|
40
|
+
*/
|
|
41
|
+
targets?: string | string[];
|
|
42
|
+
/**
|
|
43
|
+
* Control CSS minification.
|
|
44
|
+
* - `true`: always minify (dev + prod)
|
|
45
|
+
* - `false`: never minify (autoprefixing still applies)
|
|
46
|
+
* - `undefined` (default): minify in prod only
|
|
47
|
+
*/
|
|
48
|
+
minify?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Full `@layer` declaration order. Must include all 7 Animus `anm-*` layers
|
|
51
|
+
* as a subsequence in their required order. Consumer layers may be
|
|
52
|
+
* interleaved around them. Names are emitted as-is.
|
|
53
|
+
*
|
|
54
|
+
* Example: `['reset', 'anm-global', 'anm-base', ..., 'anm-custom', 'overrides']`
|
|
55
|
+
*/
|
|
56
|
+
layers?: string[];
|
|
56
57
|
}
|
|
57
|
-
export declare function
|
|
58
|
-
export
|
|
58
|
+
export declare function discoverFiles(dir: string, rootDir: string, excludePatterns: string[], extensionsSet: ReadonlySet<string>): string[];
|
|
59
|
+
export declare function animusExtract(options: AnimusExtractOptions): Plugin;
|
|
59
60
|
export default animusExtract;
|
|
60
61
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,MAAM,CAAC;AAE3C,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,qGAAqG;IACrG,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAgBD,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,EAAE,EACzB,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,GACjC,MAAM,EAAE,CAqCV;AAqFD,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CA2rCnE;eAEc,aAAa"}
|