tailwindcss-patch 8.2.4 → 8.4.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/dist/cli.js CHANGED
@@ -1,238 +1,8 @@
1
- "use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1
+ "use strict";
2
2
 
3
-
4
-
5
-
6
-
7
- var _chunkOQKHXYAKjs = require('./chunk-OQKHXYAK.js');
8
-
9
- // src/cli.ts
10
- var _process = require('process'); var _process2 = _interopRequireDefault(_process);
11
- var _config = require('@tailwindcss-mangle/config');
12
-
13
- // ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
14
- function isPlainObject(value) {
15
- if (value === null || typeof value !== "object") {
16
- return false;
17
- }
18
- const prototype = Object.getPrototypeOf(value);
19
- if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
20
- return false;
21
- }
22
- if (Symbol.iterator in value) {
23
- return false;
24
- }
25
- if (Symbol.toStringTag in value) {
26
- return Object.prototype.toString.call(value) === "[object Module]";
27
- }
28
- return true;
29
- }
30
- function _defu(baseObject, defaults, namespace = ".", merger) {
31
- if (!isPlainObject(defaults)) {
32
- return _defu(baseObject, {}, namespace, merger);
33
- }
34
- const object = Object.assign({}, defaults);
35
- for (const key in baseObject) {
36
- if (key === "__proto__" || key === "constructor") {
37
- continue;
38
- }
39
- const value = baseObject[key];
40
- if (value === null || value === void 0) {
41
- continue;
42
- }
43
- if (merger && merger(object, key, value, namespace)) {
44
- continue;
45
- }
46
- if (Array.isArray(value) && Array.isArray(object[key])) {
47
- object[key] = [...value, ...object[key]];
48
- } else if (isPlainObject(value) && isPlainObject(object[key])) {
49
- object[key] = _defu(
50
- value,
51
- object[key],
52
- (namespace ? `${namespace}.` : "") + key.toString(),
53
- merger
54
- );
55
- } else {
56
- object[key] = value;
57
- }
58
- }
59
- return object;
60
- }
61
- function createDefu(merger) {
62
- return (...arguments_) => (
63
- // eslint-disable-next-line unicorn/no-array-reduce
64
- arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
65
- );
66
- }
67
- var defu = createDefu();
68
- var defuFn = createDefu((object, key, currentValue) => {
69
- if (object[key] !== void 0 && typeof currentValue === "function") {
70
- object[key] = currentValue(object[key]);
71
- return true;
72
- }
73
- });
74
- var defuArrayFn = createDefu((object, key, currentValue) => {
75
- if (Array.isArray(object[key]) && typeof currentValue === "function") {
76
- object[key] = currentValue(object[key]);
77
- return true;
78
- }
79
- });
80
-
81
- // ../shared/src/utils.ts
82
- var defuOverrideArray = createDefu((obj, key, value) => {
83
- if (Array.isArray(obj[key]) && Array.isArray(value)) {
84
- obj[key] = value;
85
- return true;
86
- }
87
- });
88
- var preserveClassNames = [
89
- // https://tailwindcss.com/docs/transition-timing-function start
90
- // https://github.com/sonofmagic/tailwindcss-mangle/issues/21
91
- "ease-out",
92
- "ease-linear",
93
- "ease-in",
94
- "ease-in-out"
95
- // https://tailwindcss.com/docs/transition-timing-function end
96
- ];
97
- var preserveClassNamesMap = preserveClassNames.reduce((acc, cur) => {
98
- acc[cur] = true;
99
- return acc;
100
- }, {});
101
- var acceptChars = [..."abcdefghijklmnopqrstuvwxyz"];
3
+ var _chunkPF5ZTTYMjs = require('./chunk-PF5ZTTYM.js');
102
4
 
103
5
  // src/cli.ts
104
- var _cac = require('cac'); var _cac2 = _interopRequireDefault(_cac);
105
- var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
106
- var _pathe = require('pathe'); var _pathe2 = _interopRequireDefault(_pathe);
107
- var cli = _cac2.default.call(void 0, "tw-patch");
108
- async function loadPatchOptions(cwd, overrides) {
109
- const { config } = await _config.getConfig.call(void 0, cwd);
110
- const legacyConfig = config;
111
- const base = _optionalChain([config, 'optionalAccess', _ => _.registry]) ? _chunkOQKHXYAKjs.fromUnifiedConfig.call(void 0, config.registry) : _optionalChain([legacyConfig, 'optionalAccess', _2 => _2.patch]) ? _chunkOQKHXYAKjs.fromLegacyOptions.call(void 0, { patch: legacyConfig.patch }) : {};
112
- const merged = defu(_nullishCoalesce(overrides, () => ( {})), base);
113
- return merged;
114
- }
115
- cli.command("install", "Apply Tailwind CSS runtime patches").option("--cwd <dir>", "Working directory", { default: _process2.default.cwd() }).action(async (args) => {
116
- const options = await loadPatchOptions(args.cwd);
117
- const patcher = new (0, _chunkOQKHXYAKjs.TailwindcssPatcher)(options);
118
- await patcher.patch();
119
- _chunkOQKHXYAKjs.logger_default.success("Tailwind CSS runtime patched successfully.");
120
- });
121
- cli.command("extract", "Collect generated class names into a cache file").option("--cwd <dir>", "Working directory", { default: _process2.default.cwd() }).option("--output <file>", "Override output file path").option("--format <format>", "Output format (json|lines)").option("--css <file>", "Tailwind CSS entry CSS when using v4").option("--no-write", "Skip writing to disk").action(async (args) => {
122
- const overrides = {};
123
- if (args.output || args.format) {
124
- overrides.output = {
125
- file: args.output,
126
- format: args.format
127
- };
128
- }
129
- if (args.css) {
130
- overrides.tailwind = {
131
- v4: {
132
- cssEntries: [args.css]
133
- }
134
- };
135
- }
136
- const options = await loadPatchOptions(args.cwd, overrides);
137
- const patcher = new (0, _chunkOQKHXYAKjs.TailwindcssPatcher)(options);
138
- const result = await patcher.extract({ write: args.write });
139
- if (result.filename) {
140
- _chunkOQKHXYAKjs.logger_default.success(`Collected ${result.classList.length} classes \u2192 ${result.filename}`);
141
- } else {
142
- _chunkOQKHXYAKjs.logger_default.success(`Collected ${result.classList.length} classes.`);
143
- }
144
- });
145
- var TOKEN_FORMATS = ["json", "lines", "grouped-json"];
146
- cli.command("tokens", "Extract Tailwind tokens with file/position metadata").option("--cwd <dir>", "Working directory", { default: _process2.default.cwd() }).option("--output <file>", "Override output file path", { default: ".tw-patch/tw-token-report.json" }).option("--format <format>", "Output format (json|lines|grouped-json)", { default: "json" }).option("--group-key <key>", "Grouping key for grouped-json output (relative|absolute)", { default: "relative" }).option("--no-write", "Skip writing to disk").action(async (args) => {
147
- const options = await loadPatchOptions(args.cwd);
148
- const patcher = new (0, _chunkOQKHXYAKjs.TailwindcssPatcher)(options);
149
- const report = await patcher.collectContentTokens();
150
- const shouldWrite = _nullishCoalesce(args.write, () => ( true));
151
- let format = _nullishCoalesce(args.format, () => ( "json"));
152
- if (!TOKEN_FORMATS.includes(format)) {
153
- format = "json";
154
- }
155
- const targetFile = _nullishCoalesce(args.output, () => ( ".tw-patch/tw-token-report.json"));
156
- const groupKey = args.groupKey === "absolute" ? "absolute" : "relative";
157
- const buildGrouped = () => _chunkOQKHXYAKjs.groupTokensByFile.call(void 0, report, {
158
- key: groupKey,
159
- stripAbsolutePaths: groupKey !== "absolute"
160
- });
161
- const grouped = format === "grouped-json" ? buildGrouped() : null;
162
- const resolveGrouped = () => _nullishCoalesce(grouped, () => ( buildGrouped()));
163
- if (shouldWrite) {
164
- const target = _pathe2.default.resolve(targetFile);
165
- await _fsextra2.default.ensureDir(_pathe2.default.dirname(target));
166
- if (format === "json") {
167
- await _fsextra2.default.writeJSON(target, report, { spaces: 2 });
168
- } else if (format === "grouped-json") {
169
- await _fsextra2.default.writeJSON(target, resolveGrouped(), { spaces: 2 });
170
- } else {
171
- const lines = report.entries.map(formatTokenLine);
172
- await _fsextra2.default.writeFile(target, `${lines.join("\n")}
173
- `, "utf8");
174
- }
175
- _chunkOQKHXYAKjs.logger_default.success(
176
- `Collected ${report.entries.length} tokens (${format}) \u2192 ${target.replace(_process2.default.cwd(), ".")}`
177
- );
178
- } else {
179
- _chunkOQKHXYAKjs.logger_default.success(`Collected ${report.entries.length} tokens from ${report.filesScanned} files.`);
180
- if (format === "lines") {
181
- const preview = report.entries.slice(0, 5).map(formatTokenLine).join("\n");
182
- if (preview) {
183
- _chunkOQKHXYAKjs.logger_default.log("");
184
- _chunkOQKHXYAKjs.logger_default.info(preview);
185
- if (report.entries.length > 5) {
186
- _chunkOQKHXYAKjs.logger_default.info(`\u2026and ${report.entries.length - 5} more.`);
187
- }
188
- }
189
- } else if (format === "grouped-json") {
190
- const map = resolveGrouped();
191
- const { preview, moreFiles } = formatGroupedPreview(map);
192
- if (preview) {
193
- _chunkOQKHXYAKjs.logger_default.log("");
194
- _chunkOQKHXYAKjs.logger_default.info(preview);
195
- if (moreFiles > 0) {
196
- _chunkOQKHXYAKjs.logger_default.info(`\u2026and ${moreFiles} more files.`);
197
- }
198
- }
199
- } else {
200
- const previewEntries = report.entries.slice(0, 3);
201
- if (previewEntries.length) {
202
- _chunkOQKHXYAKjs.logger_default.log("");
203
- _chunkOQKHXYAKjs.logger_default.info(JSON.stringify(previewEntries, null, 2));
204
- }
205
- }
206
- }
207
- if (report.skippedFiles.length) {
208
- _chunkOQKHXYAKjs.logger_default.warn("Skipped files:");
209
- for (const skipped of report.skippedFiles) {
210
- _chunkOQKHXYAKjs.logger_default.warn(` \u2022 ${skipped.file} (${skipped.reason})`);
211
- }
212
- }
213
- });
214
- cli.command("init", "Generate a tailwindcss-patch config file").option("--cwd <dir>", "Working directory", { default: _process2.default.cwd() }).action(async (args) => {
215
- await _config.initConfig.call(void 0, args.cwd);
216
- _chunkOQKHXYAKjs.logger_default.success(`\u2728 ${_config.CONFIG_NAME}.config.ts initialized!`);
217
- });
6
+ var cli = _chunkPF5ZTTYMjs.createTailwindcssPatchCli.call(void 0, );
218
7
  cli.help();
219
8
  cli.parse();
220
- function formatTokenLine(entry) {
221
- return `${entry.relativeFile}:${entry.line}:${entry.column} ${entry.rawCandidate} (${entry.start}-${entry.end})`;
222
- }
223
- function formatGroupedPreview(map, limit = 3) {
224
- const files = Object.keys(map);
225
- if (!files.length) {
226
- return { preview: "", moreFiles: 0 };
227
- }
228
- const lines = files.slice(0, limit).map((file) => {
229
- const tokens = map[file];
230
- const sample = tokens.slice(0, 3).map((token) => token.rawCandidate).join(", ");
231
- const suffix = tokens.length > 3 ? ", \u2026" : "";
232
- return `${file}: ${tokens.length} tokens (${sample}${suffix})`;
233
- });
234
- return {
235
- preview: lines.join("\n"),
236
- moreFiles: Math.max(0, files.length - limit)
237
- };
238
- }
package/dist/cli.mjs CHANGED
@@ -1,238 +1,8 @@
1
1
  import {
2
- TailwindcssPatcher,
3
- fromLegacyOptions,
4
- fromUnifiedConfig,
5
- groupTokensByFile,
6
- logger_default
7
- } from "./chunk-4BI6FMCK.mjs";
2
+ createTailwindcssPatchCli
3
+ } from "./chunk-SHYTHM5B.mjs";
8
4
 
9
5
  // src/cli.ts
10
- import process from "process";
11
- import { CONFIG_NAME, getConfig, initConfig } from "@tailwindcss-mangle/config";
12
-
13
- // ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
14
- function isPlainObject(value) {
15
- if (value === null || typeof value !== "object") {
16
- return false;
17
- }
18
- const prototype = Object.getPrototypeOf(value);
19
- if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
20
- return false;
21
- }
22
- if (Symbol.iterator in value) {
23
- return false;
24
- }
25
- if (Symbol.toStringTag in value) {
26
- return Object.prototype.toString.call(value) === "[object Module]";
27
- }
28
- return true;
29
- }
30
- function _defu(baseObject, defaults, namespace = ".", merger) {
31
- if (!isPlainObject(defaults)) {
32
- return _defu(baseObject, {}, namespace, merger);
33
- }
34
- const object = Object.assign({}, defaults);
35
- for (const key in baseObject) {
36
- if (key === "__proto__" || key === "constructor") {
37
- continue;
38
- }
39
- const value = baseObject[key];
40
- if (value === null || value === void 0) {
41
- continue;
42
- }
43
- if (merger && merger(object, key, value, namespace)) {
44
- continue;
45
- }
46
- if (Array.isArray(value) && Array.isArray(object[key])) {
47
- object[key] = [...value, ...object[key]];
48
- } else if (isPlainObject(value) && isPlainObject(object[key])) {
49
- object[key] = _defu(
50
- value,
51
- object[key],
52
- (namespace ? `${namespace}.` : "") + key.toString(),
53
- merger
54
- );
55
- } else {
56
- object[key] = value;
57
- }
58
- }
59
- return object;
60
- }
61
- function createDefu(merger) {
62
- return (...arguments_) => (
63
- // eslint-disable-next-line unicorn/no-array-reduce
64
- arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
65
- );
66
- }
67
- var defu = createDefu();
68
- var defuFn = createDefu((object, key, currentValue) => {
69
- if (object[key] !== void 0 && typeof currentValue === "function") {
70
- object[key] = currentValue(object[key]);
71
- return true;
72
- }
73
- });
74
- var defuArrayFn = createDefu((object, key, currentValue) => {
75
- if (Array.isArray(object[key]) && typeof currentValue === "function") {
76
- object[key] = currentValue(object[key]);
77
- return true;
78
- }
79
- });
80
-
81
- // ../shared/src/utils.ts
82
- var defuOverrideArray = createDefu((obj, key, value) => {
83
- if (Array.isArray(obj[key]) && Array.isArray(value)) {
84
- obj[key] = value;
85
- return true;
86
- }
87
- });
88
- var preserveClassNames = [
89
- // https://tailwindcss.com/docs/transition-timing-function start
90
- // https://github.com/sonofmagic/tailwindcss-mangle/issues/21
91
- "ease-out",
92
- "ease-linear",
93
- "ease-in",
94
- "ease-in-out"
95
- // https://tailwindcss.com/docs/transition-timing-function end
96
- ];
97
- var preserveClassNamesMap = preserveClassNames.reduce((acc, cur) => {
98
- acc[cur] = true;
99
- return acc;
100
- }, {});
101
- var acceptChars = [..."abcdefghijklmnopqrstuvwxyz"];
102
-
103
- // src/cli.ts
104
- import cac from "cac";
105
- import fs from "fs-extra";
106
- import path from "pathe";
107
- var cli = cac("tw-patch");
108
- async function loadPatchOptions(cwd, overrides) {
109
- const { config } = await getConfig(cwd);
110
- const legacyConfig = config;
111
- const base = config?.registry ? fromUnifiedConfig(config.registry) : legacyConfig?.patch ? fromLegacyOptions({ patch: legacyConfig.patch }) : {};
112
- const merged = defu(overrides ?? {}, base);
113
- return merged;
114
- }
115
- cli.command("install", "Apply Tailwind CSS runtime patches").option("--cwd <dir>", "Working directory", { default: process.cwd() }).action(async (args) => {
116
- const options = await loadPatchOptions(args.cwd);
117
- const patcher = new TailwindcssPatcher(options);
118
- await patcher.patch();
119
- logger_default.success("Tailwind CSS runtime patched successfully.");
120
- });
121
- cli.command("extract", "Collect generated class names into a cache file").option("--cwd <dir>", "Working directory", { default: process.cwd() }).option("--output <file>", "Override output file path").option("--format <format>", "Output format (json|lines)").option("--css <file>", "Tailwind CSS entry CSS when using v4").option("--no-write", "Skip writing to disk").action(async (args) => {
122
- const overrides = {};
123
- if (args.output || args.format) {
124
- overrides.output = {
125
- file: args.output,
126
- format: args.format
127
- };
128
- }
129
- if (args.css) {
130
- overrides.tailwind = {
131
- v4: {
132
- cssEntries: [args.css]
133
- }
134
- };
135
- }
136
- const options = await loadPatchOptions(args.cwd, overrides);
137
- const patcher = new TailwindcssPatcher(options);
138
- const result = await patcher.extract({ write: args.write });
139
- if (result.filename) {
140
- logger_default.success(`Collected ${result.classList.length} classes \u2192 ${result.filename}`);
141
- } else {
142
- logger_default.success(`Collected ${result.classList.length} classes.`);
143
- }
144
- });
145
- var TOKEN_FORMATS = ["json", "lines", "grouped-json"];
146
- cli.command("tokens", "Extract Tailwind tokens with file/position metadata").option("--cwd <dir>", "Working directory", { default: process.cwd() }).option("--output <file>", "Override output file path", { default: ".tw-patch/tw-token-report.json" }).option("--format <format>", "Output format (json|lines|grouped-json)", { default: "json" }).option("--group-key <key>", "Grouping key for grouped-json output (relative|absolute)", { default: "relative" }).option("--no-write", "Skip writing to disk").action(async (args) => {
147
- const options = await loadPatchOptions(args.cwd);
148
- const patcher = new TailwindcssPatcher(options);
149
- const report = await patcher.collectContentTokens();
150
- const shouldWrite = args.write ?? true;
151
- let format = args.format ?? "json";
152
- if (!TOKEN_FORMATS.includes(format)) {
153
- format = "json";
154
- }
155
- const targetFile = args.output ?? ".tw-patch/tw-token-report.json";
156
- const groupKey = args.groupKey === "absolute" ? "absolute" : "relative";
157
- const buildGrouped = () => groupTokensByFile(report, {
158
- key: groupKey,
159
- stripAbsolutePaths: groupKey !== "absolute"
160
- });
161
- const grouped = format === "grouped-json" ? buildGrouped() : null;
162
- const resolveGrouped = () => grouped ?? buildGrouped();
163
- if (shouldWrite) {
164
- const target = path.resolve(targetFile);
165
- await fs.ensureDir(path.dirname(target));
166
- if (format === "json") {
167
- await fs.writeJSON(target, report, { spaces: 2 });
168
- } else if (format === "grouped-json") {
169
- await fs.writeJSON(target, resolveGrouped(), { spaces: 2 });
170
- } else {
171
- const lines = report.entries.map(formatTokenLine);
172
- await fs.writeFile(target, `${lines.join("\n")}
173
- `, "utf8");
174
- }
175
- logger_default.success(
176
- `Collected ${report.entries.length} tokens (${format}) \u2192 ${target.replace(process.cwd(), ".")}`
177
- );
178
- } else {
179
- logger_default.success(`Collected ${report.entries.length} tokens from ${report.filesScanned} files.`);
180
- if (format === "lines") {
181
- const preview = report.entries.slice(0, 5).map(formatTokenLine).join("\n");
182
- if (preview) {
183
- logger_default.log("");
184
- logger_default.info(preview);
185
- if (report.entries.length > 5) {
186
- logger_default.info(`\u2026and ${report.entries.length - 5} more.`);
187
- }
188
- }
189
- } else if (format === "grouped-json") {
190
- const map = resolveGrouped();
191
- const { preview, moreFiles } = formatGroupedPreview(map);
192
- if (preview) {
193
- logger_default.log("");
194
- logger_default.info(preview);
195
- if (moreFiles > 0) {
196
- logger_default.info(`\u2026and ${moreFiles} more files.`);
197
- }
198
- }
199
- } else {
200
- const previewEntries = report.entries.slice(0, 3);
201
- if (previewEntries.length) {
202
- logger_default.log("");
203
- logger_default.info(JSON.stringify(previewEntries, null, 2));
204
- }
205
- }
206
- }
207
- if (report.skippedFiles.length) {
208
- logger_default.warn("Skipped files:");
209
- for (const skipped of report.skippedFiles) {
210
- logger_default.warn(` \u2022 ${skipped.file} (${skipped.reason})`);
211
- }
212
- }
213
- });
214
- cli.command("init", "Generate a tailwindcss-patch config file").option("--cwd <dir>", "Working directory", { default: process.cwd() }).action(async (args) => {
215
- await initConfig(args.cwd);
216
- logger_default.success(`\u2728 ${CONFIG_NAME}.config.ts initialized!`);
217
- });
6
+ var cli = createTailwindcssPatchCli();
218
7
  cli.help();
219
8
  cli.parse();
220
- function formatTokenLine(entry) {
221
- return `${entry.relativeFile}:${entry.line}:${entry.column} ${entry.rawCandidate} (${entry.start}-${entry.end})`;
222
- }
223
- function formatGroupedPreview(map, limit = 3) {
224
- const files = Object.keys(map);
225
- if (!files.length) {
226
- return { preview: "", moreFiles: 0 };
227
- }
228
- const lines = files.slice(0, limit).map((file) => {
229
- const tokens = map[file];
230
- const sample = tokens.slice(0, 3).map((token) => token.rawCandidate).join(", ");
231
- const suffix = tokens.length > 3 ? ", \u2026" : "";
232
- return `${file}: ${tokens.length} tokens (${sample}${suffix})`;
233
- });
234
- return {
235
- preview: lines.join("\n"),
236
- moreFiles: Math.max(0, files.length - limit)
237
- };
238
- }
package/dist/index.d.mts CHANGED
@@ -2,8 +2,9 @@ import { SourceEntry } from '@tailwindcss/oxide';
2
2
  import postcss, { Node, Rule } from 'postcss';
3
3
  import { Config } from 'tailwindcss';
4
4
  import { PackageResolvingOptions, PackageInfo } from 'local-pkg';
5
- import { TailwindLocatorOptions, TailwindNextOptions } from '@tailwindcss-mangle/config';
5
+ import { TailwindLocatorOptions, TailwindNextOptions, getConfig } from '@tailwindcss-mangle/config';
6
6
  export { defineConfig } from '@tailwindcss-mangle/config';
7
+ import { Command, CAC } from 'cac';
7
8
  import * as consola from 'consola';
8
9
 
9
10
  type CacheStrategy = 'merge' | 'overwrite';
@@ -424,6 +425,82 @@ declare class CacheStore {
424
425
 
425
426
  declare const logger: consola.ConsolaInstance;
426
427
 
428
+ type TailwindcssPatchCommand = 'install' | 'extract' | 'tokens' | 'init';
429
+ declare const tailwindcssPatchCommands: TailwindcssPatchCommand[];
430
+ type TokenOutputFormat = 'json' | 'lines' | 'grouped-json';
431
+ type TokenGroupKey = 'relative' | 'absolute';
432
+ type CacOptionConfig = Parameters<Command['option']>[2];
433
+ interface TailwindcssPatchCommandOptionDefinition {
434
+ flags: string;
435
+ description?: string;
436
+ config?: CacOptionConfig;
437
+ }
438
+ interface TailwindcssPatchCommandOptions {
439
+ name?: string;
440
+ aliases?: string[];
441
+ description?: string;
442
+ optionDefs?: TailwindcssPatchCommandOptionDefinition[];
443
+ appendDefaultOptions?: boolean;
444
+ }
445
+ interface BaseCommandArgs {
446
+ cwd: string;
447
+ }
448
+ interface InstallCommandArgs extends BaseCommandArgs {
449
+ }
450
+ interface ExtractCommandArgs extends BaseCommandArgs {
451
+ output?: string;
452
+ format?: 'json' | 'lines';
453
+ css?: string;
454
+ write?: boolean;
455
+ }
456
+ interface TokensCommandArgs extends BaseCommandArgs {
457
+ output?: string;
458
+ format?: TokenOutputFormat;
459
+ groupKey?: TokenGroupKey;
460
+ write?: boolean;
461
+ }
462
+ interface InitCommandArgs extends BaseCommandArgs {
463
+ }
464
+ interface TailwindcssPatchCommandArgMap {
465
+ install: InstallCommandArgs;
466
+ extract: ExtractCommandArgs;
467
+ tokens: TokensCommandArgs;
468
+ init: InitCommandArgs;
469
+ }
470
+ interface TailwindcssPatchCommandResultMap {
471
+ install: void;
472
+ extract: ExtractResult;
473
+ tokens: TailwindTokenReport;
474
+ init: void;
475
+ }
476
+ interface TailwindcssPatchCommandContext<TCommand extends TailwindcssPatchCommand> {
477
+ cli: CAC;
478
+ command: Command;
479
+ commandName: TCommand;
480
+ args: TailwindcssPatchCommandArgMap[TCommand];
481
+ cwd: string;
482
+ logger: typeof logger;
483
+ loadConfig: () => ReturnType<typeof getConfig>;
484
+ loadPatchOptions: (overrides?: TailwindcssPatchOptions) => Promise<TailwindcssPatchOptions>;
485
+ createPatcher: (overrides?: TailwindcssPatchOptions) => Promise<TailwindcssPatcher>;
486
+ }
487
+ type TailwindcssPatchCommandHandler<TCommand extends TailwindcssPatchCommand> = (context: TailwindcssPatchCommandContext<TCommand>, next: () => Promise<TailwindcssPatchCommandResultMap[TCommand]>) => Promise<TailwindcssPatchCommandResultMap[TCommand]> | TailwindcssPatchCommandResultMap[TCommand];
488
+ type TailwindcssPatchCommandHandlerMap = Partial<{
489
+ [K in TailwindcssPatchCommand]: TailwindcssPatchCommandHandler<K>;
490
+ }>;
491
+ interface TailwindcssPatchCliMountOptions {
492
+ commandPrefix?: string;
493
+ commands?: TailwindcssPatchCommand[];
494
+ commandOptions?: Partial<Record<TailwindcssPatchCommand, TailwindcssPatchCommandOptions>>;
495
+ commandHandlers?: TailwindcssPatchCommandHandlerMap;
496
+ }
497
+ interface TailwindcssPatchCliOptions {
498
+ name?: string;
499
+ mountOptions?: TailwindcssPatchCliMountOptions;
500
+ }
501
+ declare function mountTailwindcssPatchCommands(cli: CAC, options?: TailwindcssPatchCliMountOptions): CAC;
502
+ declare function createTailwindcssPatchCli(options?: TailwindcssPatchCliOptions): CAC;
503
+
427
504
  declare function normalizeOptions(options?: TailwindcssPatchOptions): NormalizedTailwindcssPatchOptions;
428
505
 
429
506
  declare function collectClassesFromContexts(contexts: TailwindcssRuntimeContext[], filter: (className: string) => boolean): Set<string>;
@@ -439,4 +516,4 @@ interface TailwindBuildOptions {
439
516
  }
440
517
  declare function runTailwindBuild(options: TailwindBuildOptions): Promise<postcss.Result<postcss.Root>>;
441
518
 
442
- export { CacheStore, type CacheStrategy, type ExtractResult, type ILengthUnitsPatchOptions, type NormalizedTailwindcssPatchOptions, type TailwindPatchRuntime, type TailwindTokenByFileMap, type TailwindTokenFileKey, type TailwindTokenLocation, type TailwindTokenReport, type TailwindcssClassCache, type TailwindcssPatchOptions, TailwindcssPatcher, type TailwindcssRuntimeContext, collectClassesFromContexts, collectClassesFromTailwindV4, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractValidCandidates, groupTokensByFile, loadRuntimeContexts, logger, normalizeOptions, runTailwindBuild };
519
+ export { CacheStore, type CacheStrategy, type ExtractResult, type ILengthUnitsPatchOptions, type NormalizedTailwindcssPatchOptions, 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, collectClassesFromContexts, collectClassesFromTailwindV4, createTailwindcssPatchCli, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractValidCandidates, groupTokensByFile, loadRuntimeContexts, logger, mountTailwindcssPatchCommands, normalizeOptions, runTailwindBuild, tailwindcssPatchCommands };
package/dist/index.d.ts CHANGED
@@ -2,8 +2,9 @@ import { SourceEntry } from '@tailwindcss/oxide';
2
2
  import postcss, { Node, Rule } from 'postcss';
3
3
  import { Config } from 'tailwindcss';
4
4
  import { PackageResolvingOptions, PackageInfo } from 'local-pkg';
5
- import { TailwindLocatorOptions, TailwindNextOptions } from '@tailwindcss-mangle/config';
5
+ import { TailwindLocatorOptions, TailwindNextOptions, getConfig } from '@tailwindcss-mangle/config';
6
6
  export { defineConfig } from '@tailwindcss-mangle/config';
7
+ import { Command, CAC } from 'cac';
7
8
  import * as consola from 'consola';
8
9
 
9
10
  type CacheStrategy = 'merge' | 'overwrite';
@@ -424,6 +425,82 @@ declare class CacheStore {
424
425
 
425
426
  declare const logger: consola.ConsolaInstance;
426
427
 
428
+ type TailwindcssPatchCommand = 'install' | 'extract' | 'tokens' | 'init';
429
+ declare const tailwindcssPatchCommands: TailwindcssPatchCommand[];
430
+ type TokenOutputFormat = 'json' | 'lines' | 'grouped-json';
431
+ type TokenGroupKey = 'relative' | 'absolute';
432
+ type CacOptionConfig = Parameters<Command['option']>[2];
433
+ interface TailwindcssPatchCommandOptionDefinition {
434
+ flags: string;
435
+ description?: string;
436
+ config?: CacOptionConfig;
437
+ }
438
+ interface TailwindcssPatchCommandOptions {
439
+ name?: string;
440
+ aliases?: string[];
441
+ description?: string;
442
+ optionDefs?: TailwindcssPatchCommandOptionDefinition[];
443
+ appendDefaultOptions?: boolean;
444
+ }
445
+ interface BaseCommandArgs {
446
+ cwd: string;
447
+ }
448
+ interface InstallCommandArgs extends BaseCommandArgs {
449
+ }
450
+ interface ExtractCommandArgs extends BaseCommandArgs {
451
+ output?: string;
452
+ format?: 'json' | 'lines';
453
+ css?: string;
454
+ write?: boolean;
455
+ }
456
+ interface TokensCommandArgs extends BaseCommandArgs {
457
+ output?: string;
458
+ format?: TokenOutputFormat;
459
+ groupKey?: TokenGroupKey;
460
+ write?: boolean;
461
+ }
462
+ interface InitCommandArgs extends BaseCommandArgs {
463
+ }
464
+ interface TailwindcssPatchCommandArgMap {
465
+ install: InstallCommandArgs;
466
+ extract: ExtractCommandArgs;
467
+ tokens: TokensCommandArgs;
468
+ init: InitCommandArgs;
469
+ }
470
+ interface TailwindcssPatchCommandResultMap {
471
+ install: void;
472
+ extract: ExtractResult;
473
+ tokens: TailwindTokenReport;
474
+ init: void;
475
+ }
476
+ interface TailwindcssPatchCommandContext<TCommand extends TailwindcssPatchCommand> {
477
+ cli: CAC;
478
+ command: Command;
479
+ commandName: TCommand;
480
+ args: TailwindcssPatchCommandArgMap[TCommand];
481
+ cwd: string;
482
+ logger: typeof logger;
483
+ loadConfig: () => ReturnType<typeof getConfig>;
484
+ loadPatchOptions: (overrides?: TailwindcssPatchOptions) => Promise<TailwindcssPatchOptions>;
485
+ createPatcher: (overrides?: TailwindcssPatchOptions) => Promise<TailwindcssPatcher>;
486
+ }
487
+ type TailwindcssPatchCommandHandler<TCommand extends TailwindcssPatchCommand> = (context: TailwindcssPatchCommandContext<TCommand>, next: () => Promise<TailwindcssPatchCommandResultMap[TCommand]>) => Promise<TailwindcssPatchCommandResultMap[TCommand]> | TailwindcssPatchCommandResultMap[TCommand];
488
+ type TailwindcssPatchCommandHandlerMap = Partial<{
489
+ [K in TailwindcssPatchCommand]: TailwindcssPatchCommandHandler<K>;
490
+ }>;
491
+ interface TailwindcssPatchCliMountOptions {
492
+ commandPrefix?: string;
493
+ commands?: TailwindcssPatchCommand[];
494
+ commandOptions?: Partial<Record<TailwindcssPatchCommand, TailwindcssPatchCommandOptions>>;
495
+ commandHandlers?: TailwindcssPatchCommandHandlerMap;
496
+ }
497
+ interface TailwindcssPatchCliOptions {
498
+ name?: string;
499
+ mountOptions?: TailwindcssPatchCliMountOptions;
500
+ }
501
+ declare function mountTailwindcssPatchCommands(cli: CAC, options?: TailwindcssPatchCliMountOptions): CAC;
502
+ declare function createTailwindcssPatchCli(options?: TailwindcssPatchCliOptions): CAC;
503
+
427
504
  declare function normalizeOptions(options?: TailwindcssPatchOptions): NormalizedTailwindcssPatchOptions;
428
505
 
429
506
  declare function collectClassesFromContexts(contexts: TailwindcssRuntimeContext[], filter: (className: string) => boolean): Set<string>;
@@ -439,4 +516,4 @@ interface TailwindBuildOptions {
439
516
  }
440
517
  declare function runTailwindBuild(options: TailwindBuildOptions): Promise<postcss.Result<postcss.Root>>;
441
518
 
442
- export { CacheStore, type CacheStrategy, type ExtractResult, type ILengthUnitsPatchOptions, type NormalizedTailwindcssPatchOptions, type TailwindPatchRuntime, type TailwindTokenByFileMap, type TailwindTokenFileKey, type TailwindTokenLocation, type TailwindTokenReport, type TailwindcssClassCache, type TailwindcssPatchOptions, TailwindcssPatcher, type TailwindcssRuntimeContext, collectClassesFromContexts, collectClassesFromTailwindV4, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractValidCandidates, groupTokensByFile, loadRuntimeContexts, logger, normalizeOptions, runTailwindBuild };
519
+ export { CacheStore, type CacheStrategy, type ExtractResult, type ILengthUnitsPatchOptions, type NormalizedTailwindcssPatchOptions, 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, collectClassesFromContexts, collectClassesFromTailwindV4, createTailwindcssPatchCli, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractValidCandidates, groupTokensByFile, loadRuntimeContexts, logger, mountTailwindcssPatchCommands, normalizeOptions, runTailwindBuild, tailwindcssPatchCommands };