@dmisdm/pandatail 0.2.0 → 0.3.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.
@@ -0,0 +1,74 @@
1
+ import { type NativeCompiler } from "@pandacss/compiler";
2
+ import { formatDiagnostic, type Diagnostic } from "@pandacss/compiler-shared";
3
+ type AnyConfig = Record<string, any>;
4
+ export interface PandatailOptions {
5
+ /** Tailwind v4 entry stylesheet (`@import "tailwindcss"`, `@theme`, …). */
6
+ css: string;
7
+ /** Project root. Defaults to `process.cwd()`. */
8
+ cwd?: string;
9
+ /**
10
+ * Optional escape hatch for everything CSS can't express (recipes, patterns,
11
+ * textStyles, custom utilities, …): a path to a `panda.config.ts`, or an
12
+ * inline config object. Merged on top of what pandatail derives from the CSS.
13
+ */
14
+ config?: string | AnyConfig;
15
+ /** Source globs for Panda to scan. Replaces the default and the config's `include`. */
16
+ include?: string[];
17
+ /** Source globs to skip. */
18
+ exclude?: string[];
19
+ /** Where generated code goes. Defaults to the config's `outdir`, else `styled-system`. */
20
+ outdir?: string;
21
+ /**
22
+ * Panda `jsxFramework` (default `"react"`). Required for JSX style props and
23
+ * the generated `styled-system/jsx` factory. `false` disables JSX codegen.
24
+ */
25
+ jsxFramework?: "react" | "solid" | "preact" | "vue" | "qwik" | false;
26
+ /** Allow style props on JSX components, e.g. `<Box bg="brand.500" p="4" />`. Panda defaults to true. */
27
+ jsxStyleProps?: "all" | "minimal" | "none";
28
+ /** Emit Panda's CSS reset. Default false (Tailwind ships preflight). */
29
+ preflight?: boolean;
30
+ /** Panda `importMap`; where generated modules are imported from. */
31
+ importMap?: string | Record<string, string>;
32
+ /** Class name prefix. */
33
+ prefix?: string;
34
+ /** Hash class names and CSS variables. */
35
+ hash?: boolean | {
36
+ cssVar?: boolean;
37
+ className?: boolean;
38
+ };
39
+ /** Minify the generated stylesheet. */
40
+ minify?: boolean;
41
+ }
42
+ export interface PandatailProject {
43
+ compiler: NativeCompiler;
44
+ /** The fully merged config the compiler was built from. */
45
+ config: AnyConfig;
46
+ cwd: string;
47
+ /** Absolute. */
48
+ outdir: string;
49
+ /** Files whose change means the project must be recreated (CSS + config). */
50
+ dependencies: string[];
51
+ /** Non-fatal things pandatail could not translate from the CSS. */
52
+ warnings: string[];
53
+ }
54
+ /**
55
+ * Build a Panda compiler in memory from a Tailwind stylesheet, with no
56
+ * `panda.config.ts` required.
57
+ */
58
+ export declare function createPandatailProject(opts: PandatailOptions): Promise<PandatailProject>;
59
+ export interface BuildResult {
60
+ files: string[];
61
+ artifacts: number;
62
+ /** Absolute path of the written stylesheet, if CSS was written. */
63
+ cssPath?: string;
64
+ diagnostics: Diagnostic[];
65
+ }
66
+ export interface BuildOptions {
67
+ /** Write generated code (`styled-system/`). Default true. */
68
+ codegen?: boolean;
69
+ /** Write the stylesheet here (relative to project cwd). `false` to skip. Default `<outdir>/styles.css`. */
70
+ outfile?: string | false;
71
+ }
72
+ /** Scan + parse sources, then write the artifacts and/or stylesheet. */
73
+ export declare function buildProject(project: PandatailProject, opts?: BuildOptions): BuildResult;
74
+ export { formatDiagnostic };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * What a Tailwind entry stylesheet says about the project, beyond `@theme`:
3
+ * where to look for class usage (`@source`) and the custom variants
4
+ * (`@custom-variant`) that Panda should expose as conditions.
5
+ */
6
+ export interface CssScan {
7
+ /** Absolute paths / globs from `@source "…"`. */
8
+ sources: string[];
9
+ /** Absolute paths / globs from `@source not "…"`. */
10
+ excludes: string[];
11
+ /** `@custom-variant` rules, mapped to Panda condition values. */
12
+ conditions: Record<string, string>;
13
+ /** Things we saw but could not translate. */
14
+ warnings: string[];
15
+ /** Local files that were read (entry + relative `@import`s), for watching. */
16
+ files: string[];
17
+ }
18
+ export interface ScanCssOptions {
19
+ css: string;
20
+ /** Directory relative paths resolve against. */
21
+ base: string;
22
+ /** Path of the entry file, if there is one. */
23
+ file?: string;
24
+ }
25
+ /**
26
+ * Walk the entry CSS and any *relative* `@import`s (bare specifiers such as
27
+ * `tailwindcss` are skipped: they carry no project-specific `@source`s or
28
+ * variants).
29
+ */
30
+ export declare function scanCss(opts: ScanCssOptions): CssScan;
package/dist/vite.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ import type { Plugin } from "vite";
2
+ import { type PandatailOptions } from "./project";
3
+ export interface PandatailViteOptions extends Omit<PandatailOptions, "css"> {
4
+ /** Tailwind v4 entry stylesheet. Resolved against Vite's `root` unless `cwd` is set. */
5
+ css: string;
6
+ /** Stylesheet to write, relative to the root. Default `<outdir>/styles.css`. */
7
+ outfile?: string;
8
+ /** Log what was generated. Default true in dev, false during `vite build`. */
9
+ verbose?: boolean;
10
+ }
11
+ /**
12
+ * Vite plugin: generates `styled-system/` and the Panda stylesheet before the
13
+ * module graph is built, and keeps both up to date while the dev server runs.
14
+ *
15
+ * Panda config is passed as plugin options (`jsxStyleProps`, `outdir`, …);
16
+ * `config` accepts anything else, as an object or a `panda.config.ts` path.
17
+ */
18
+ export declare function pandatail(options: PandatailViteOptions): Plugin;
19
+ export default pandatail;