tailwindcss-patch 9.0.0-alpha.1 → 9.0.0-alpha.2

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.
Files changed (70) hide show
  1. package/README.md +20 -0
  2. package/dist/{chunk-Z6OMJZTU.js → chunk-TOAZIPHJ.js} +29 -11
  3. package/dist/{chunk-SWLOK2S6.mjs → chunk-VDWTCQ74.mjs} +29 -11
  4. package/dist/cli.js +4 -4
  5. package/dist/cli.mjs +1 -1
  6. package/dist/index.d.mts +43 -35
  7. package/dist/index.d.ts +43 -35
  8. package/dist/index.js +2 -2
  9. package/dist/index.mjs +1 -1
  10. package/package.json +8 -3
  11. package/src/api/tailwindcss-patcher.ts +424 -0
  12. package/src/babel/index.ts +12 -0
  13. package/src/cache/context.ts +212 -0
  14. package/src/cache/store.ts +1440 -0
  15. package/src/cache/types.ts +71 -0
  16. package/src/cli.ts +20 -0
  17. package/src/commands/basic-handlers.ts +145 -0
  18. package/src/commands/cli.ts +56 -0
  19. package/src/commands/command-context.ts +77 -0
  20. package/src/commands/command-definitions.ts +102 -0
  21. package/src/commands/command-metadata.ts +68 -0
  22. package/src/commands/command-registrar.ts +39 -0
  23. package/src/commands/command-runtime.ts +33 -0
  24. package/src/commands/default-handler-map.ts +25 -0
  25. package/src/commands/migrate-config.ts +104 -0
  26. package/src/commands/migrate-handler.ts +67 -0
  27. package/src/commands/migration-aggregation.ts +100 -0
  28. package/src/commands/migration-args.ts +85 -0
  29. package/src/commands/migration-file-executor.ts +189 -0
  30. package/src/commands/migration-output.ts +115 -0
  31. package/src/commands/migration-report-loader.ts +26 -0
  32. package/src/commands/migration-report.ts +21 -0
  33. package/src/commands/migration-source.ts +318 -0
  34. package/src/commands/migration-target-files.ts +161 -0
  35. package/src/commands/migration-target-resolver.ts +34 -0
  36. package/src/commands/migration-types.ts +65 -0
  37. package/src/commands/restore-handler.ts +24 -0
  38. package/src/commands/status-handler.ts +17 -0
  39. package/src/commands/status-output.ts +60 -0
  40. package/src/commands/token-output.ts +30 -0
  41. package/src/commands/types.ts +137 -0
  42. package/src/commands/validate-handler.ts +42 -0
  43. package/src/commands/validate.ts +83 -0
  44. package/src/config/index.ts +25 -0
  45. package/src/config/workspace.ts +87 -0
  46. package/src/constants.ts +4 -0
  47. package/src/extraction/candidate-extractor.ts +354 -0
  48. package/src/index.ts +57 -0
  49. package/src/install/class-collector.ts +1 -0
  50. package/src/install/context-registry.ts +1 -0
  51. package/src/install/index.ts +5 -0
  52. package/src/install/patch-runner.ts +1 -0
  53. package/src/install/process-tailwindcss.ts +1 -0
  54. package/src/install/status.ts +1 -0
  55. package/src/logger.ts +5 -0
  56. package/src/options/legacy.ts +93 -0
  57. package/src/options/normalize.ts +262 -0
  58. package/src/options/types.ts +217 -0
  59. package/src/patching/operations/export-context/index.ts +110 -0
  60. package/src/patching/operations/export-context/postcss-v2.ts +235 -0
  61. package/src/patching/operations/export-context/postcss-v3.ts +249 -0
  62. package/src/patching/operations/extend-length-units.ts +197 -0
  63. package/src/patching/patch-runner.ts +46 -0
  64. package/src/patching/status.ts +262 -0
  65. package/src/runtime/class-collector.ts +105 -0
  66. package/src/runtime/collector.ts +148 -0
  67. package/src/runtime/context-registry.ts +65 -0
  68. package/src/runtime/process-tailwindcss.ts +115 -0
  69. package/src/types.ts +159 -0
  70. package/src/utils.ts +52 -0
package/README.md CHANGED
@@ -117,6 +117,26 @@ Skip `next()` to fully replace a command (e.g. custom `init` or cache clearing b
117
117
 
118
118
  The CLI loads `tailwindcss-patch.config.ts` via `@tailwindcss-mangle/config`. v9 expects the modern `registry` shape; use `tw-patch migrate` before upgrading if your config still uses deprecated keys.
119
119
 
120
+ ### Public Type Names
121
+
122
+ The current alpha exports the modern option type names only:
123
+
124
+ ```ts
125
+ import type {
126
+ ApplyOptions,
127
+ CacheOptions,
128
+ ExtractOptions,
129
+ TailwindCssOptions,
130
+ TailwindCssPatchOptions,
131
+ TailwindV2Options,
132
+ TailwindV3Options,
133
+ TailwindV4Options,
134
+ NormalizedTailwindCssPatchOptions,
135
+ } from 'tailwindcss-patch'
136
+ ```
137
+
138
+ Older aliases such as `TailwindcssPatchOptions`, `TailwindLocatorOptions`, and `TailwindTargetOptions` are intentionally removed in the alpha line.
139
+
120
140
  ### v9 upgrade flow
121
141
 
122
142
  1. Run `pnpm dlx tw-patch migrate --dry-run` to preview required config rewrites.
@@ -20,7 +20,7 @@ var _pathe = require('pathe'); var _pathe2 = _interopRequireDefault(_pathe);
20
20
  // package.json
21
21
  var package_default = {
22
22
  name: "tailwindcss-patch",
23
- version: "9.0.0-alpha.1",
23
+ version: "9.0.0-alpha.2",
24
24
  description: "patch tailwindcss for exposing context and extract classes",
25
25
  author: "ice breaker <1324318532@qq.com>",
26
26
  license: "MIT",
@@ -59,18 +59,23 @@ var package_default = {
59
59
  files: [
60
60
  "bin",
61
61
  "dist",
62
- "schema"
62
+ "schema",
63
+ "src"
63
64
  ],
64
65
  scripts: {
65
66
  dev: "tsup --watch --sourcemap",
66
67
  build: "tsup",
67
68
  test: "vitest run",
69
+ "test:types": "pnpm build && tsd --typings dist/index.d.mts --files test-d/**/*.test-d.ts",
68
70
  "test:dev": "vitest",
69
71
  "bench:cold-start": "node --import tsx bench/cold-start.ts",
70
72
  patch: "tsx dev/bin.ts install",
71
73
  r0: "tsx dev/bin.ts extract",
72
74
  r1: "tsx dev/bin.ts extract --css index.css"
73
75
  },
76
+ tsd: {
77
+ directory: "test-d"
78
+ },
74
79
  publishConfig: {
75
80
  access: "public",
76
81
  registry: "https://registry.npmjs.org/",
@@ -2099,14 +2104,12 @@ function groupTokensByFile(report, options) {
2099
2104
  const stripAbsolute = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _53 => _53.stripAbsolutePaths]), () => ( key !== "absolute"));
2100
2105
  return report.entries.reduce((acc, entry) => {
2101
2106
  const bucketKey = key === "absolute" ? entry.file : entry.relativeFile;
2102
- if (!acc[bucketKey]) {
2103
- acc[bucketKey] = [];
2104
- }
2107
+ const bucket = _nullishCoalesce(acc[bucketKey], () => ( (acc[bucketKey] = [])));
2105
2108
  const value = stripAbsolute ? {
2106
2109
  ...entry,
2107
2110
  file: entry.relativeFile
2108
2111
  } : entry;
2109
- acc[bucketKey].push(value);
2112
+ bucket.push(value);
2110
2113
  return acc;
2111
2114
  }, {});
2112
2115
  }
@@ -2121,18 +2124,22 @@ function isObject(val) {
2121
2124
  return val !== null && typeof val === "object" && Array.isArray(val) === false;
2122
2125
  }
2123
2126
  function spliceChangesIntoString(str, changes) {
2124
- if (!changes[0]) {
2127
+ const firstChange = changes[0];
2128
+ if (!firstChange) {
2125
2129
  return str;
2126
2130
  }
2127
2131
  changes.sort((a, b) => {
2128
2132
  return a.end - b.end || a.start - b.start;
2129
2133
  });
2130
2134
  let result = "";
2131
- let previous = changes[0];
2135
+ let previous = firstChange;
2132
2136
  result += str.slice(0, previous.start);
2133
2137
  result += previous.replacement;
2134
2138
  for (let i = 1; i < changes.length; ++i) {
2135
2139
  const change = changes[i];
2140
+ if (!change) {
2141
+ continue;
2142
+ }
2136
2143
  result += str.slice(previous.end, change.start);
2137
2144
  result += change.replacement;
2138
2145
  previous = change;
@@ -2441,7 +2448,12 @@ function transformPostcssPluginV2(content, options) {
2441
2448
  const previous = program.body[index - 1];
2442
2449
  const beforePrevious = program.body[index - 2];
2443
2450
  const alreadyHasVariable = Boolean(
2444
- previous && t.isVariableDeclaration(previous) && previous.declarations.length === 1 && t.isIdentifier(previous.declarations[0].id) && previous.declarations[0].id.name === refIdentifier.name
2451
+ previous && t.isVariableDeclaration(previous) && previous.declarations.length === 1 && (() => {
2452
+ const declaration = previous.declarations[0];
2453
+ return Boolean(
2454
+ declaration && t.isIdentifier(declaration.id) && declaration.id.name === refIdentifier.name
2455
+ );
2456
+ })()
2445
2457
  );
2446
2458
  const alreadyAssignsExports = Boolean(
2447
2459
  beforePrevious && t.isExpressionStatement(beforePrevious) && t.isAssignmentExpression(beforePrevious.expression) && t.isMemberExpression(beforePrevious.expression.left) && t.isIdentifier(beforePrevious.expression.right) && beforePrevious.expression.right.name === refIdentifier.name && generate(beforePrevious.expression.left).code === generate(exportMember).code
@@ -2602,7 +2614,12 @@ function transformPostcssPlugin(content, { refProperty }) {
2602
2614
  const previousStatement = program.body[index - 1];
2603
2615
  const lastStatement = program.body[program.body.length - 1];
2604
2616
  const alreadyHasVariable = Boolean(
2605
- previousStatement && t2.isVariableDeclaration(previousStatement) && previousStatement.declarations.length === 1 && t2.isIdentifier(previousStatement.declarations[0].id) && previousStatement.declarations[0].id.name === refIdentifier.name
2617
+ previousStatement && t2.isVariableDeclaration(previousStatement) && previousStatement.declarations.length === 1 && (() => {
2618
+ const declaration = previousStatement.declarations[0];
2619
+ return Boolean(
2620
+ declaration && t2.isIdentifier(declaration.id) && declaration.id.name === refIdentifier.name
2621
+ );
2622
+ })()
2606
2623
  );
2607
2624
  const alreadyAssignsModuleExports = Boolean(
2608
2625
  t2.isExpressionStatement(lastStatement) && t2.isAssignmentExpression(lastStatement.expression) && t2.isMemberExpression(lastStatement.expression.left) && t2.isIdentifier(lastStatement.expression.right) && lastStatement.expression.right.name === refIdentifier.name && generate(lastStatement.expression.left).code === generate(moduleExportsMember).code
@@ -4988,13 +5005,14 @@ function registerTailwindcssPatchCommand(cli, commandName, options, prefix, defa
4988
5005
  const command = cli.command(metadata.name, metadata.description);
4989
5006
  applyCommandOptions(command, metadata.optionDefs);
4990
5007
  command.action(async (args) => {
5008
+ const defaultHandler = defaultCommandHandlers[commandName];
4991
5009
  return runWithCommandHandler(
4992
5010
  cli,
4993
5011
  command,
4994
5012
  commandName,
4995
5013
  args,
4996
5014
  _optionalChain([options, 'access', _129 => _129.commandHandlers, 'optionalAccess', _130 => _130[commandName]]),
4997
- defaultCommandHandlers[commandName]
5015
+ defaultHandler
4998
5016
  );
4999
5017
  });
5000
5018
  metadata.aliases.forEach((alias) => command.alias(alias));
@@ -20,7 +20,7 @@ import path from "pathe";
20
20
  // package.json
21
21
  var package_default = {
22
22
  name: "tailwindcss-patch",
23
- version: "9.0.0-alpha.1",
23
+ version: "9.0.0-alpha.2",
24
24
  description: "patch tailwindcss for exposing context and extract classes",
25
25
  author: "ice breaker <1324318532@qq.com>",
26
26
  license: "MIT",
@@ -59,18 +59,23 @@ var package_default = {
59
59
  files: [
60
60
  "bin",
61
61
  "dist",
62
- "schema"
62
+ "schema",
63
+ "src"
63
64
  ],
64
65
  scripts: {
65
66
  dev: "tsup --watch --sourcemap",
66
67
  build: "tsup",
67
68
  test: "vitest run",
69
+ "test:types": "pnpm build && tsd --typings dist/index.d.mts --files test-d/**/*.test-d.ts",
68
70
  "test:dev": "vitest",
69
71
  "bench:cold-start": "node --import tsx bench/cold-start.ts",
70
72
  patch: "tsx dev/bin.ts install",
71
73
  r0: "tsx dev/bin.ts extract",
72
74
  r1: "tsx dev/bin.ts extract --css index.css"
73
75
  },
76
+ tsd: {
77
+ directory: "test-d"
78
+ },
74
79
  publishConfig: {
75
80
  access: "public",
76
81
  registry: "https://registry.npmjs.org/",
@@ -2099,14 +2104,12 @@ function groupTokensByFile(report, options) {
2099
2104
  const stripAbsolute = options?.stripAbsolutePaths ?? key !== "absolute";
2100
2105
  return report.entries.reduce((acc, entry) => {
2101
2106
  const bucketKey = key === "absolute" ? entry.file : entry.relativeFile;
2102
- if (!acc[bucketKey]) {
2103
- acc[bucketKey] = [];
2104
- }
2107
+ const bucket = acc[bucketKey] ?? (acc[bucketKey] = []);
2105
2108
  const value = stripAbsolute ? {
2106
2109
  ...entry,
2107
2110
  file: entry.relativeFile
2108
2111
  } : entry;
2109
- acc[bucketKey].push(value);
2112
+ bucket.push(value);
2110
2113
  return acc;
2111
2114
  }, {});
2112
2115
  }
@@ -2121,18 +2124,22 @@ function isObject(val) {
2121
2124
  return val !== null && typeof val === "object" && Array.isArray(val) === false;
2122
2125
  }
2123
2126
  function spliceChangesIntoString(str, changes) {
2124
- if (!changes[0]) {
2127
+ const firstChange = changes[0];
2128
+ if (!firstChange) {
2125
2129
  return str;
2126
2130
  }
2127
2131
  changes.sort((a, b) => {
2128
2132
  return a.end - b.end || a.start - b.start;
2129
2133
  });
2130
2134
  let result = "";
2131
- let previous = changes[0];
2135
+ let previous = firstChange;
2132
2136
  result += str.slice(0, previous.start);
2133
2137
  result += previous.replacement;
2134
2138
  for (let i = 1; i < changes.length; ++i) {
2135
2139
  const change = changes[i];
2140
+ if (!change) {
2141
+ continue;
2142
+ }
2136
2143
  result += str.slice(previous.end, change.start);
2137
2144
  result += change.replacement;
2138
2145
  previous = change;
@@ -2441,7 +2448,12 @@ function transformPostcssPluginV2(content, options) {
2441
2448
  const previous = program.body[index - 1];
2442
2449
  const beforePrevious = program.body[index - 2];
2443
2450
  const alreadyHasVariable = Boolean(
2444
- previous && t.isVariableDeclaration(previous) && previous.declarations.length === 1 && t.isIdentifier(previous.declarations[0].id) && previous.declarations[0].id.name === refIdentifier.name
2451
+ previous && t.isVariableDeclaration(previous) && previous.declarations.length === 1 && (() => {
2452
+ const declaration = previous.declarations[0];
2453
+ return Boolean(
2454
+ declaration && t.isIdentifier(declaration.id) && declaration.id.name === refIdentifier.name
2455
+ );
2456
+ })()
2445
2457
  );
2446
2458
  const alreadyAssignsExports = Boolean(
2447
2459
  beforePrevious && t.isExpressionStatement(beforePrevious) && t.isAssignmentExpression(beforePrevious.expression) && t.isMemberExpression(beforePrevious.expression.left) && t.isIdentifier(beforePrevious.expression.right) && beforePrevious.expression.right.name === refIdentifier.name && generate(beforePrevious.expression.left).code === generate(exportMember).code
@@ -2602,7 +2614,12 @@ function transformPostcssPlugin(content, { refProperty }) {
2602
2614
  const previousStatement = program.body[index - 1];
2603
2615
  const lastStatement = program.body[program.body.length - 1];
2604
2616
  const alreadyHasVariable = Boolean(
2605
- previousStatement && t2.isVariableDeclaration(previousStatement) && previousStatement.declarations.length === 1 && t2.isIdentifier(previousStatement.declarations[0].id) && previousStatement.declarations[0].id.name === refIdentifier.name
2617
+ previousStatement && t2.isVariableDeclaration(previousStatement) && previousStatement.declarations.length === 1 && (() => {
2618
+ const declaration = previousStatement.declarations[0];
2619
+ return Boolean(
2620
+ declaration && t2.isIdentifier(declaration.id) && declaration.id.name === refIdentifier.name
2621
+ );
2622
+ })()
2606
2623
  );
2607
2624
  const alreadyAssignsModuleExports = Boolean(
2608
2625
  t2.isExpressionStatement(lastStatement) && t2.isAssignmentExpression(lastStatement.expression) && t2.isMemberExpression(lastStatement.expression.left) && t2.isIdentifier(lastStatement.expression.right) && lastStatement.expression.right.name === refIdentifier.name && generate(lastStatement.expression.left).code === generate(moduleExportsMember).code
@@ -4988,13 +5005,14 @@ function registerTailwindcssPatchCommand(cli, commandName, options, prefix, defa
4988
5005
  const command = cli.command(metadata.name, metadata.description);
4989
5006
  applyCommandOptions(command, metadata.optionDefs);
4990
5007
  command.action(async (args) => {
5008
+ const defaultHandler = defaultCommandHandlers[commandName];
4991
5009
  return runWithCommandHandler(
4992
5010
  cli,
4993
5011
  command,
4994
5012
  commandName,
4995
5013
  args,
4996
5014
  options.commandHandlers?.[commandName],
4997
- defaultCommandHandlers[commandName]
5015
+ defaultHandler
4998
5016
  );
4999
5017
  });
5000
5018
  metadata.aliases.forEach((alias) => command.alias(alias));
package/dist/cli.js CHANGED
@@ -2,23 +2,23 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkZ6OMJZTUjs = require('./chunk-Z6OMJZTU.js');
5
+ var _chunkTOAZIPHJjs = require('./chunk-TOAZIPHJ.js');
6
6
  require('./chunk-5CWNAWKP.js');
7
7
 
8
8
  // src/cli.ts
9
9
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
10
10
  async function main() {
11
- const cli = _chunkZ6OMJZTUjs.createTailwindcssPatchCli.call(void 0, );
11
+ const cli = _chunkTOAZIPHJjs.createTailwindcssPatchCli.call(void 0, );
12
12
  cli.help();
13
13
  cli.parse(_process2.default.argv, { run: false });
14
14
  await cli.runMatchedCommand();
15
15
  }
16
16
  main().catch((error) => {
17
- if (error instanceof _chunkZ6OMJZTUjs.ValidateCommandError) {
17
+ if (error instanceof _chunkTOAZIPHJjs.ValidateCommandError) {
18
18
  _process2.default.exitCode = error.exitCode;
19
19
  return;
20
20
  }
21
21
  const message = error instanceof Error ? error.message : String(error);
22
- _chunkZ6OMJZTUjs.logger_default.error(message);
22
+ _chunkTOAZIPHJjs.logger_default.error(message);
23
23
  _process2.default.exitCode = 1;
24
24
  });
package/dist/cli.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  ValidateCommandError,
3
3
  createTailwindcssPatchCli,
4
4
  logger_default
5
- } from "./chunk-SWLOK2S6.mjs";
5
+ } from "./chunk-VDWTCQ74.mjs";
6
6
  import "./chunk-A67ABH3M.mjs";
7
7
 
8
8
  // src/cli.ts
package/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ import { TailwindcssMangleConfig } from '@tailwindcss-mangle/config';
1
2
  import { SourceEntry } from '@tailwindcss/oxide';
2
3
  import postcss, { Rule, Node } from 'postcss';
3
4
  import { Config } from 'tailwindcss';
@@ -10,7 +11,7 @@ type CacheDriver = 'file' | 'memory' | 'noop';
10
11
  /**
11
12
  * Configures how the Tailwind class cache is stored and where it lives on disk.
12
13
  */
13
- interface CacheUserOptions {
14
+ interface CacheOptions {
14
15
  /** Whether caching is enabled. */
15
16
  enabled?: boolean;
16
17
  /** Working directory used when resolving cache paths. */
@@ -30,7 +31,7 @@ interface CacheUserOptions {
30
31
  /**
31
32
  * Preferred options for extraction output behavior.
32
33
  */
33
- interface TailwindExtractionUserOptions {
34
+ interface ExtractOptions {
34
35
  /** Whether to produce an output file. */
35
36
  write?: boolean;
36
37
  /** Optional absolute or relative path to the output file. */
@@ -45,32 +46,29 @@ interface TailwindExtractionUserOptions {
45
46
  /**
46
47
  * Options controlling how Tailwind contexts are exposed during runtime patching.
47
48
  */
48
- interface ExposeContextUserOptions {
49
+ interface ExposeContextOptions {
49
50
  /** Name of the property used to reference an exposed context. */
50
51
  refProperty?: string;
51
52
  }
52
53
  /**
53
54
  * Extends the built-in length-unit patch with custom defaults.
54
55
  */
55
- interface ExtendLengthUnitsUserOptions extends Partial<ILengthUnitsPatchOptions> {
56
+ interface ExtendLengthUnitsOptions extends Partial<ILengthUnitsPatchOptions> {
56
57
  /** Enables or disables the length-unit patch. */
57
58
  enabled?: boolean;
58
59
  }
59
60
  /**
60
61
  * Preferred options for runtime patch behavior.
61
62
  */
62
- interface PatchApplyUserOptions {
63
+ interface ApplyOptions {
63
64
  /** Whether patched files can be overwritten on disk. */
64
65
  overwrite?: boolean;
65
66
  /** Whether to expose runtime Tailwind contexts (or configure how they are exposed). */
66
- exposeContext?: boolean | ExposeContextUserOptions;
67
+ exposeContext?: boolean | ExposeContextOptions;
67
68
  /** Extends the length-unit patch or disables it entirely. */
68
- extendLengthUnits?: false | ExtendLengthUnitsUserOptions;
69
+ extendLengthUnits?: false | ExtendLengthUnitsOptions;
69
70
  }
70
- /**
71
- * Shared configuration used for Tailwind v2/v3 patching flows.
72
- */
73
- interface TailwindRuntimeConfigUserOptions {
71
+ interface TailwindRuntimeOptionsBase {
74
72
  /** Path to a Tailwind config file when auto-detection is insufficient. */
75
73
  config?: string;
76
74
  /** Custom working directory used when resolving config-relative paths. */
@@ -78,10 +76,20 @@ interface TailwindRuntimeConfigUserOptions {
78
76
  /** Optional PostCSS plugin name to use instead of the default. */
79
77
  postcssPlugin?: string;
80
78
  }
79
+ /**
80
+ * Configuration specific to Tailwind CSS v2 patching flows.
81
+ */
82
+ interface TailwindV2Options extends TailwindRuntimeOptionsBase {
83
+ }
84
+ /**
85
+ * Configuration specific to Tailwind CSS v3 patching flows.
86
+ */
87
+ interface TailwindV3Options extends TailwindRuntimeOptionsBase {
88
+ }
81
89
  /**
82
90
  * Additional configuration specific to Tailwind CSS v4 extraction.
83
91
  */
84
- interface TailwindV4RuntimeUserOptions {
92
+ interface TailwindV4Options {
85
93
  /** Base directory used when resolving v4 content sources and configs. */
86
94
  base?: string;
87
95
  /** Raw CSS passed directly to the v4 design system. */
@@ -94,7 +102,7 @@ interface TailwindV4RuntimeUserOptions {
94
102
  /**
95
103
  * High-level Tailwind patch configuration shared across versions.
96
104
  */
97
- interface TailwindcssUserOptions extends TailwindRuntimeConfigUserOptions {
105
+ interface TailwindCssOptions extends TailwindRuntimeOptionsBase {
98
106
  /** Explicit Tailwind CSS major version used by the current project. When omitted, the installed package version is inferred. */
99
107
  version?: 2 | 3 | 4;
100
108
  /** Tailwind package name if the project uses a fork. */
@@ -102,31 +110,31 @@ interface TailwindcssUserOptions extends TailwindRuntimeConfigUserOptions {
102
110
  /** Package resolution options forwarded to `local-pkg`. */
103
111
  resolve?: PackageResolvingOptions;
104
112
  /** Overrides applied when patching Tailwind CSS v2. */
105
- v2?: TailwindRuntimeConfigUserOptions;
113
+ v2?: TailwindV2Options;
106
114
  /** Overrides applied when patching Tailwind CSS v3. */
107
- v3?: TailwindRuntimeConfigUserOptions;
115
+ v3?: TailwindV3Options;
108
116
  /** Options specific to Tailwind CSS v4 patching. */
109
- v4?: TailwindV4RuntimeUserOptions;
117
+ v4?: TailwindV4Options;
110
118
  }
111
119
  /**
112
120
  * Root configuration consumed by the Tailwind CSS patch runner.
113
121
  */
114
- interface TailwindcssPatchOptions {
122
+ interface TailwindCssPatchOptions {
115
123
  /**
116
124
  * Base directory used when resolving Tailwind resources.
117
125
  * Defaults to `process.cwd()`.
118
126
  */
119
127
  projectRoot?: string;
120
128
  /** Preferred Tailwind runtime configuration. */
121
- tailwindcss?: TailwindcssUserOptions;
129
+ tailwindcss?: TailwindCssOptions;
122
130
  /** Preferred patch toggles. */
123
- apply?: PatchApplyUserOptions;
131
+ apply?: ApplyOptions;
124
132
  /** Preferred extraction output settings. */
125
- extract?: TailwindExtractionUserOptions;
133
+ extract?: ExtractOptions;
126
134
  /** Optional function that filters final class names. */
127
135
  filter?: (className: string) => boolean;
128
136
  /** Cache configuration or boolean to enable/disable quickly. */
129
- cache?: boolean | CacheUserOptions;
137
+ cache?: boolean | CacheOptions;
130
138
  }
131
139
  /**
132
140
  * Stable shape for output configuration after normalization.
@@ -171,12 +179,12 @@ interface NormalizedTailwindV4Options {
171
179
  /**
172
180
  * Tailwind configuration ready for consumption by the runtime after normalization.
173
181
  */
174
- interface NormalizedTailwindConfigOptions extends TailwindRuntimeConfigUserOptions {
182
+ interface NormalizedTailwindConfigOptions extends TailwindRuntimeOptionsBase {
175
183
  packageName: string;
176
184
  versionHint?: 2 | 3 | 4;
177
185
  resolve?: PackageResolvingOptions;
178
- v2?: TailwindRuntimeConfigUserOptions;
179
- v3?: TailwindRuntimeConfigUserOptions;
186
+ v2?: TailwindV2Options;
187
+ v3?: TailwindV3Options;
180
188
  v4?: NormalizedTailwindV4Options;
181
189
  }
182
190
  /** Grouped normalized feature flags. */
@@ -185,7 +193,7 @@ interface NormalizedFeatureOptions {
185
193
  extendLengthUnits: NormalizedExtendLengthUnitsOptions | null;
186
194
  }
187
195
  /** Final normalized shape consumed throughout the patch runtime. */
188
- interface NormalizedTailwindcssPatchOptions {
196
+ interface NormalizedTailwindCssPatchOptions {
189
197
  projectRoot: string;
190
198
  overwrite: boolean;
191
199
  tailwind: NormalizedTailwindConfigOptions;
@@ -322,7 +330,7 @@ interface TailwindTokenReport {
322
330
  }
323
331
  type TailwindTokenByFileMap = Record<string, TailwindTokenLocation[]>;
324
332
  interface TailwindPatchRuntime {
325
- options: NormalizedTailwindcssPatchOptions;
333
+ options: NormalizedTailwindCssPatchOptions;
326
334
  majorVersion: 2 | 3 | 4;
327
335
  }
328
336
 
@@ -388,7 +396,7 @@ interface PatchRunnerResult {
388
396
  extendLengthUnits?: ReturnType<typeof applyExtendLengthUnitsPatchV3> | ReturnType<typeof applyExtendLengthUnitsPatchV4>;
389
397
  }
390
398
 
391
- declare function normalizeOptions(options?: TailwindcssPatchOptions): NormalizedTailwindcssPatchOptions;
399
+ declare function normalizeOptions(options?: TailwindCssPatchOptions): NormalizedTailwindCssPatchOptions;
392
400
 
393
401
  interface TailwindcssConfigModule {
394
402
  CONFIG_NAME: string;
@@ -429,14 +437,14 @@ declare function groupTokensByFile(report: TailwindTokenReport, options?: {
429
437
  type TailwindMajorVersion = 2 | 3 | 4;
430
438
 
431
439
  declare class TailwindcssPatcher {
432
- readonly options: NormalizedTailwindcssPatchOptions;
440
+ readonly options: NormalizedTailwindCssPatchOptions;
433
441
  readonly packageInfo: PackageInfo;
434
442
  readonly majorVersion: TailwindMajorVersion;
435
443
  private readonly cacheContext;
436
444
  private readonly cacheStore;
437
445
  private readonly collector;
438
446
  private patchMemo;
439
- constructor(options?: TailwindcssPatchOptions);
447
+ constructor(options?: TailwindCssPatchOptions);
440
448
  patch(): Promise<PatchRunnerResult>;
441
449
  getPatchStatus(): Promise<PatchStatusReport>;
442
450
  getContexts(): TailwindcssRuntimeContext[];
@@ -666,8 +674,8 @@ interface TailwindcssPatchCommandContext<TCommand extends TailwindcssPatchComman
666
674
  cwd: string;
667
675
  logger: typeof logger;
668
676
  loadConfig: () => Promise<TailwindcssConfigResult>;
669
- loadPatchOptions: (overrides?: TailwindcssPatchOptions) => Promise<TailwindcssPatchOptions>;
670
- createPatcher: (overrides?: TailwindcssPatchOptions) => Promise<TailwindcssPatcher>;
677
+ loadPatchOptions: (overrides?: TailwindCssPatchOptions) => Promise<TailwindCssPatchOptions>;
678
+ createPatcher: (overrides?: TailwindCssPatchOptions) => Promise<TailwindcssPatcher>;
671
679
  }
672
680
  type TailwindcssPatchCommandHandler<TCommand extends TailwindcssPatchCommand> = (context: TailwindcssPatchCommandContext<TCommand>, next: () => Promise<TailwindcssPatchCommandResultMap[TCommand]>) => Promise<TailwindcssPatchCommandResultMap[TCommand]> | TailwindcssPatchCommandResultMap[TCommand];
673
681
  type TailwindcssPatchCommandHandlerMap = Partial<{
@@ -720,7 +728,7 @@ declare function migrateConfigFiles(options: MigrateConfigFilesOptions): Promise
720
728
  declare function restoreConfigFiles(options: RestoreConfigFilesOptions): Promise<RestoreConfigFilesResult>;
721
729
 
722
730
  declare function collectClassesFromContexts(contexts: TailwindcssRuntimeContext[], filter: (className: string) => boolean): Set<string>;
723
- declare function collectClassesFromTailwindV4(options: NormalizedTailwindcssPatchOptions): Promise<Set<string>>;
731
+ declare function collectClassesFromTailwindV4(options: NormalizedTailwindCssPatchOptions): Promise<Set<string>>;
724
732
 
725
733
  declare function loadRuntimeContexts(packageInfo: PackageInfo, majorVersion: 2 | 3 | 4, refProperty: string): TailwindcssRuntimeContext[];
726
734
 
@@ -734,11 +742,11 @@ declare function runTailwindBuild(options: TailwindBuildOptions): Promise<postcs
734
742
 
735
743
  interface PatchStatusContext {
736
744
  packageInfo: PackageInfo;
737
- options: NormalizedTailwindcssPatchOptions;
745
+ options: NormalizedTailwindCssPatchOptions;
738
746
  majorVersion: 2 | 3 | 4;
739
747
  }
740
748
  declare function getPatchStatusReport(context: PatchStatusContext): PatchStatusReport;
741
749
 
742
- declare function defineConfig<T>(config: T): T;
750
+ declare function defineConfig<T extends TailwindcssMangleConfig>(config: T): T;
743
751
 
744
- export { type CacheClearOptions, type CacheClearResult, type CacheClearScope, type CacheContextMetadata, type CacheReadMeta, CacheStore, type CacheStrategy, type ConfigFileMigrationEntry, type ConfigFileMigrationReport, type ExtractResult, type ILengthUnitsPatchOptions, MIGRATION_REPORT_KIND, MIGRATION_REPORT_SCHEMA_VERSION, type MigrateConfigFilesOptions, type NormalizedTailwindcssPatchOptions, type PatchCheckStatus, type PatchName, type PatchStatusEntry, type PatchStatusReport, type RestoreConfigFilesOptions, type RestoreConfigFilesResult, type TailwindPatchRuntime, type TailwindTokenByFileMap, type TailwindTokenFileKey, type TailwindTokenLocation, type TailwindTokenReport, type TailwindcssClassCache, type TailwindcssPatchCliMountOptions, type TailwindcssPatchCliOptions, type TailwindcssPatchCommand, type TailwindcssPatchCommandContext, type TailwindcssPatchCommandHandler, type TailwindcssPatchCommandHandlerMap, type TailwindcssPatchCommandOptionDefinition, type TailwindcssPatchCommandOptions, type TailwindcssPatchOptions, TailwindcssPatcher, type TailwindcssRuntimeContext, VALIDATE_EXIT_CODES, VALIDATE_FAILURE_REASONS, ValidateCommandError, type ValidateFailureReason, type ValidateFailureSummary, type ValidateJsonFailurePayload, type ValidateJsonSuccessPayload, collectClassesFromContexts, collectClassesFromTailwindV4, createTailwindcssPatchCli, defineConfig, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
752
+ export { type ApplyOptions, type CacheClearOptions, type CacheClearResult, type CacheClearScope, type CacheContextMetadata, type CacheOptions, type CacheReadMeta, CacheStore, type CacheStrategy, type ConfigFileMigrationEntry, type ConfigFileMigrationReport, type ExposeContextOptions, type ExtendLengthUnitsOptions, type ExtractOptions, type ExtractResult, type ILengthUnitsPatchOptions, MIGRATION_REPORT_KIND, MIGRATION_REPORT_SCHEMA_VERSION, type MigrateConfigFilesOptions, type NormalizedTailwindCssPatchOptions, type PatchCheckStatus, type PatchName, type PatchStatusEntry, type PatchStatusReport, type RestoreConfigFilesOptions, type RestoreConfigFilesResult, type TailwindCssOptions, type TailwindCssPatchOptions, type TailwindPatchRuntime, type TailwindTokenByFileMap, type TailwindTokenFileKey, type TailwindTokenLocation, type TailwindTokenReport, type TailwindV2Options, type TailwindV3Options, type TailwindV4Options, type TailwindcssClassCache, type TailwindcssPatchCliMountOptions, type TailwindcssPatchCliOptions, type TailwindcssPatchCommand, type TailwindcssPatchCommandContext, type TailwindcssPatchCommandHandler, type TailwindcssPatchCommandHandlerMap, type TailwindcssPatchCommandOptionDefinition, type TailwindcssPatchCommandOptions, TailwindcssPatcher, type TailwindcssRuntimeContext, VALIDATE_EXIT_CODES, VALIDATE_FAILURE_REASONS, ValidateCommandError, type ValidateFailureReason, type ValidateFailureSummary, type ValidateJsonFailurePayload, type ValidateJsonSuccessPayload, collectClassesFromContexts, collectClassesFromTailwindV4, createTailwindcssPatchCli, defineConfig, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };