@dmisdm/pandatail 0.1.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.
- package/README.md +82 -83
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +637 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +344 -213
- package/dist/namespaces.d.ts +10 -0
- package/dist/preset.d.ts +36 -13
- package/dist/project.d.ts +74 -0
- package/dist/scanCss.d.ts +30 -0
- package/dist/vite.d.ts +19 -0
- package/dist/vite.js +606 -0
- package/package.json +31 -14
- package/LICENSE +0 -21
- package/dist/extractSync.d.ts +0 -19
package/dist/preset.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type ExtractedToken } from "./extract";
|
|
2
|
+
import { type CssScan } from "./scanCss";
|
|
1
3
|
export interface TailwindPresetOptions {
|
|
2
4
|
/**
|
|
3
5
|
* Inline Tailwind v4 CSS source. Either this or {@link cssPath} must be set.
|
|
@@ -13,21 +15,42 @@ export interface TailwindPresetOptions {
|
|
|
13
15
|
*/
|
|
14
16
|
base?: string;
|
|
15
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Everything pandatail learns from a Tailwind entry stylesheet: the Panda
|
|
20
|
+
* preset (tokens + conditions) and the project info (`@source`s etc.) that
|
|
21
|
+
* the config-less compiler uses.
|
|
22
|
+
*/
|
|
23
|
+
export interface LoadedTailwind {
|
|
24
|
+
preset: ReturnType<typeof buildPreset>;
|
|
25
|
+
scan: CssScan;
|
|
26
|
+
tokens: ExtractedToken[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Load a Tailwind v4 stylesheet (via Tailwind's own design-system loader, so
|
|
30
|
+
* `@import`, `@theme` and `@plugin` behave exactly as they do in Tailwind) and
|
|
31
|
+
* project it into Panda.
|
|
32
|
+
*/
|
|
33
|
+
export declare function loadTailwind(opts: TailwindPresetOptions): Promise<LoadedTailwind>;
|
|
16
34
|
/**
|
|
17
35
|
* Build a PandaCSS preset whose token layer references the CSS custom
|
|
18
|
-
* properties that Tailwind v4 emits from the user's `@theme` blocks
|
|
36
|
+
* properties that Tailwind v4 emits from the user's `@theme` blocks, and whose
|
|
37
|
+
* conditions mirror the stylesheet's `@custom-variant`s.
|
|
19
38
|
*
|
|
20
39
|
* Tailwind owns the values; Panda owns the typed API. There is no value
|
|
21
|
-
* duplication
|
|
22
|
-
*
|
|
23
|
-
* Async variant — uses Tailwind's own design-system loader for highest
|
|
24
|
-
* fidelity. Prefer {@link tailwindPresetSync} from inside a Panda config,
|
|
25
|
-
* since Panda bundles configs to CJS and disallows top-level `await`.
|
|
26
|
-
*/
|
|
27
|
-
export declare function tailwindPreset(opts: TailwindPresetOptions): Promise<import("@pandacss/types").Preset>;
|
|
28
|
-
/**
|
|
29
|
-
* Synchronous form of {@link tailwindPreset}. Parses `@theme` blocks via
|
|
30
|
-
* PostCSS instead of invoking Tailwind's loader, so it can be called
|
|
31
|
-
* directly from a `panda.config.ts` without top-level await.
|
|
40
|
+
* duplication: every Panda token resolves to `var(--<tailwind-name>)`.
|
|
32
41
|
*/
|
|
33
|
-
export declare function
|
|
42
|
+
export declare function tailwindPreset(opts: TailwindPresetOptions): Promise<{
|
|
43
|
+
readonly name: "tailwind";
|
|
44
|
+
readonly theme: {
|
|
45
|
+
readonly tokens: Record<string, any>;
|
|
46
|
+
readonly breakpoints: Record<string, string>;
|
|
47
|
+
};
|
|
48
|
+
}>;
|
|
49
|
+
declare function buildPreset(tokens: ExtractedToken[], scan?: CssScan): {
|
|
50
|
+
readonly name: "tailwind";
|
|
51
|
+
readonly theme: {
|
|
52
|
+
readonly tokens: Record<string, any>;
|
|
53
|
+
readonly breakpoints: Record<string, string>;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export {};
|
|
@@ -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;
|