@@ -4,75 +4,140 @@ import type { ILengthUnitsPatchOptions } from '../types'
44
55export type CacheStrategy = 'merge' | 'overwrite'
66
7+ /**
8+ * Configures how the Tailwind class cache is stored and where it lives on disk.
9+ */
710export interface CacheUserOptions {
11+ /** Whether caching is enabled. */
812 enabled ?: boolean
13+ /** Working directory used when resolving cache paths. */
914 cwd ?: string
15+ /** Directory where cache files are written. */
1016 dir ?: string
17+ /**
18+ * Cache filename. Defaults to `class-cache.json` inside the derived cache folder
19+ * when omitted.
20+ */
1121 file ?: string
22+ /** Strategy used when merging new class lists with an existing cache. */
1223 strategy ?: CacheStrategy
1324}
1425
26+ /**
27+ * Controls how extracted class lists are written to disk.
28+ */
1529export interface OutputUserOptions {
30+ /** Whether to produce an output file. */
1631 enabled ?: boolean
32+ /** Optional absolute or relative path to the output file. */
1733 file ?: string
34+ /** Output format, defaults to JSON when omitted. */
1835 format ?: 'json' | 'lines'
36+ /** Pretty-print spacing (truthy value enables indentation). */
1937 pretty ?: number | boolean
38+ /** Whether to strip the universal selector (`*`) from the final list. */
2039 removeUniversalSelector ?: boolean
2140}
2241
42+ /**
43+ * Options controlling how Tailwind contexts are exposed during runtime patching.
44+ */
2345export interface ExposeContextUserOptions {
46+ /** Name of the property used to reference an exposed context. */
2447 refProperty ?: string
2548}
2649
50+ /**
51+ * Extends the built-in length-unit patch with custom defaults.
52+ */
2753export interface ExtendLengthUnitsUserOptions extends Partial < ILengthUnitsPatchOptions > {
54+ /** Enables or disables the length-unit patch. */
2855 enabled ?: boolean
2956}
3057
58+ /**
59+ * Feature switches that toggle optional Tailwind patch capabilities.
60+ */
3161export interface FeatureUserOptions {
62+ /** Whether to expose runtime Tailwind contexts (or configure how they are exposed). */
3263 exposeContext ?: boolean | ExposeContextUserOptions
64+ /** Extends the length-unit patch or disables it entirely. */
3365 extendLengthUnits ?: false | ExtendLengthUnitsUserOptions
3466}
3567
68+ /**
69+ * Shared configuration used for Tailwind v2/v3 patching flows.
70+ */
3671export interface TailwindConfigUserOptions {
72+ /** Path to a Tailwind config file when auto-detection is insufficient. */
3773 config ?: string
74+ /** Custom working directory used when resolving config-relative paths. */
3875 cwd ?: string
76+ /** Optional PostCSS plugin name to use instead of the default. */
3977 postcssPlugin ?: string
4078}
4179
80+ /**
81+ * Additional configuration specific to Tailwind CSS v4 extraction.
82+ */
4283export interface TailwindV4UserOptions {
84+ /** Base directory used when resolving v4 content sources and configs. */
4385 base ?: string
86+ /** Raw CSS passed directly to the v4 design system. */
4487 css ?: string
88+ /** Set of CSS entry files that should be scanned for `@config` directives. */
4589 cssEntries ?: string [ ]
90+ /** Overrides the content sources scanned by the oxide scanner. */
4691 sources ?: SourceEntry [ ]
4792}
4893
94+ /**
95+ * High-level Tailwind patch configuration shared across versions.
96+ */
4997export interface TailwindUserOptions extends TailwindConfigUserOptions {
5098 /**
5199 * Optional hint for picking the patch strategy.
52100 * When omitted we infer from the installed Tailwind CSS package version.
53101 */
54102 version ?: 2 | 3 | 4
103+ /** Tailwind package name if the project uses a fork. */
55104 packageName ?: string
105+ /** Package resolution options forwarded to `local-pkg`. */
56106 resolve ?: PackageResolvingOptions
107+ /** Overrides applied when patching Tailwind CSS v2. */
57108 v2 ?: TailwindConfigUserOptions
109+ /** Overrides applied when patching Tailwind CSS v3. */
58110 v3 ?: TailwindConfigUserOptions
111+ /** Options specific to Tailwind CSS v4 patching. */
59112 v4 ?: TailwindV4UserOptions
60113}
61114
115+ /**
116+ * Root configuration consumed by the Tailwind CSS patch runner.
117+ */
62118export interface TailwindcssPatchOptions {
63119 /**
64120 * Base directory used when resolving Tailwind resources.
65121 * Defaults to `process.cwd()`.
66122 */
67123 cwd ?: string
124+ /** Whether to overwrite generated artifacts (e.g., caches, outputs). */
68125 overwrite ?: boolean
126+ /** Tailwind-specific configuration grouped by major version. */
69127 tailwind ?: TailwindUserOptions
128+ /** Feature toggles for optional helpers. */
70129 features ?: FeatureUserOptions
130+ /** Optional function that filters final class names. */
71131 filter ?: ( className : string ) => boolean
132+ /** Cache configuration or boolean to enable/disable quickly. */
72133 cache ?: boolean | CacheUserOptions
134+ /** Output configuration or boolean to inherits defaults. */
73135 output ?: OutputUserOptions
74136}
75137
138+ /**
139+ * Stable shape for output configuration after normalization.
140+ */
76141export interface NormalizedOutputOptions {
77142 enabled : boolean
78143 file ?: string
@@ -81,6 +146,9 @@ export interface NormalizedOutputOptions {
81146 removeUniversalSelector : boolean
82147}
83148
149+ /**
150+ * Stable cache configuration used internally after defaults are applied.
151+ */
84152export interface NormalizedCacheOptions {
85153 enabled : boolean
86154 cwd : string
@@ -90,22 +158,30 @@ export interface NormalizedCacheOptions {
90158 strategy : CacheStrategy
91159}
92160
161+ /** Tracks whether runtime contexts should be exposed and via which property. */
93162export interface NormalizedExposeContextOptions {
94163 enabled : boolean
95164 refProperty : string
96165}
97166
167+ /** Normalized representation of the extend-length-units feature flag. */
98168export interface NormalizedExtendLengthUnitsOptions extends ILengthUnitsPatchOptions {
99169 enabled : boolean
100170}
101171
172+ /** Normalized Tailwind v4 configuration consumed by runtime helpers. */
102173export interface NormalizedTailwindV4Options {
103174 base : string
175+ configuredBase ?: string
104176 css ?: string
105177 cssEntries : string [ ]
106178 sources : SourceEntry [ ]
179+ hasUserDefinedSources : boolean
107180}
108181
182+ /**
183+ * Tailwind configuration ready for consumption by the runtime after normalization.
184+ */
109185export interface NormalizedTailwindConfigOptions extends TailwindConfigUserOptions {
110186 packageName : string
111187 versionHint ?: 2 | 3 | 4
@@ -115,11 +191,13 @@ export interface NormalizedTailwindConfigOptions extends TailwindConfigUserOptio
115191 v4 ?: NormalizedTailwindV4Options
116192}
117193
194+ /** Grouped normalized feature flags. */
118195export interface NormalizedFeatureOptions {
119196 exposeContext : NormalizedExposeContextOptions
120197 extendLengthUnits : NormalizedExtendLengthUnitsOptions | null
121198}
122199
200+ /** Final normalized shape consumed throughout the patch runtime. */
123201export interface NormalizedTailwindcssPatchOptions {
124202 projectRoot : string
125203 overwrite : boolean
0 commit comments