tailwindcss-patch 8.2.1 → 8.2.3
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/{chunk-5KFYHNFJ.js → chunk-CFH3UEW6.js} +12 -1
- package/dist/{chunk-SB2W2SQP.mjs → chunk-KH3TRSVT.mjs} +12 -1
- package/dist/cli.js +22 -22
- package/dist/cli.mjs +1 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +7 -7
|
@@ -139,9 +139,20 @@ async function extractValidCandidates(options) {
|
|
|
139
139
|
const { __unstable__loadDesignSystem } = await importNode();
|
|
140
140
|
const designSystem = await __unstable__loadDesignSystem(css, { base });
|
|
141
141
|
const candidates = await extractRawCandidates(sources);
|
|
142
|
-
const
|
|
142
|
+
const parsedCandidates = candidates.filter(
|
|
143
143
|
(rawCandidate) => designSystem.parseCandidate(rawCandidate).length > 0
|
|
144
144
|
);
|
|
145
|
+
if (parsedCandidates.length === 0) {
|
|
146
|
+
return parsedCandidates;
|
|
147
|
+
}
|
|
148
|
+
const cssByCandidate = designSystem.candidatesToCss(parsedCandidates);
|
|
149
|
+
const validCandidates = [];
|
|
150
|
+
for (let index = 0; index < parsedCandidates.length; index++) {
|
|
151
|
+
const css2 = cssByCandidate[index];
|
|
152
|
+
if (typeof css2 === "string" && css2.trim().length > 0) {
|
|
153
|
+
validCandidates.push(parsedCandidates[index]);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
145
156
|
return validCandidates;
|
|
146
157
|
}
|
|
147
158
|
function normalizeSources(sources, cwd) {
|
|
@@ -135,9 +135,20 @@ async function extractValidCandidates(options) {
|
|
|
135
135
|
const { __unstable__loadDesignSystem } = await importNode();
|
|
136
136
|
const designSystem = await __unstable__loadDesignSystem(css, { base });
|
|
137
137
|
const candidates = await extractRawCandidates(sources);
|
|
138
|
-
const
|
|
138
|
+
const parsedCandidates = candidates.filter(
|
|
139
139
|
(rawCandidate) => designSystem.parseCandidate(rawCandidate).length > 0
|
|
140
140
|
);
|
|
141
|
+
if (parsedCandidates.length === 0) {
|
|
142
|
+
return parsedCandidates;
|
|
143
|
+
}
|
|
144
|
+
const cssByCandidate = designSystem.candidatesToCss(parsedCandidates);
|
|
145
|
+
const validCandidates = [];
|
|
146
|
+
for (let index = 0; index < parsedCandidates.length; index++) {
|
|
147
|
+
const css2 = cssByCandidate[index];
|
|
148
|
+
if (typeof css2 === "string" && css2.trim().length > 0) {
|
|
149
|
+
validCandidates.push(parsedCandidates[index]);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
141
152
|
return validCandidates;
|
|
142
153
|
}
|
|
143
154
|
function normalizeSources(sources, cwd) {
|
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkCFH3UEW6js = require('./chunk-CFH3UEW6.js');
|
|
8
8
|
|
|
9
9
|
// src/cli.ts
|
|
10
10
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
@@ -108,15 +108,15 @@ var cli = _cac2.default.call(void 0, "tw-patch");
|
|
|
108
108
|
async function loadPatchOptions(cwd, overrides) {
|
|
109
109
|
const { config } = await _config.getConfig.call(void 0, cwd);
|
|
110
110
|
const legacyConfig = config;
|
|
111
|
-
const base = _optionalChain([config, 'optionalAccess', _ => _.registry]) ?
|
|
111
|
+
const base = _optionalChain([config, 'optionalAccess', _ => _.registry]) ? _chunkCFH3UEW6js.fromUnifiedConfig.call(void 0, config.registry) : _optionalChain([legacyConfig, 'optionalAccess', _2 => _2.patch]) ? _chunkCFH3UEW6js.fromLegacyOptions.call(void 0, { patch: legacyConfig.patch }) : {};
|
|
112
112
|
const merged = defu(_nullishCoalesce(overrides, () => ( {})), base);
|
|
113
113
|
return merged;
|
|
114
114
|
}
|
|
115
115
|
cli.command("install", "Apply Tailwind CSS runtime patches").option("--cwd <dir>", "Working directory", { default: _process2.default.cwd() }).action(async (args) => {
|
|
116
116
|
const options = await loadPatchOptions(args.cwd);
|
|
117
|
-
const patcher = new (0,
|
|
117
|
+
const patcher = new (0, _chunkCFH3UEW6js.TailwindcssPatcher)(options);
|
|
118
118
|
await patcher.patch();
|
|
119
|
-
|
|
119
|
+
_chunkCFH3UEW6js.logger_default.success("Tailwind CSS runtime patched successfully.");
|
|
120
120
|
});
|
|
121
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
122
|
const overrides = {};
|
|
@@ -134,18 +134,18 @@ cli.command("extract", "Collect generated class names into a cache file").option
|
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
136
|
const options = await loadPatchOptions(args.cwd, overrides);
|
|
137
|
-
const patcher = new (0,
|
|
137
|
+
const patcher = new (0, _chunkCFH3UEW6js.TailwindcssPatcher)(options);
|
|
138
138
|
const result = await patcher.extract({ write: args.write });
|
|
139
139
|
if (result.filename) {
|
|
140
|
-
|
|
140
|
+
_chunkCFH3UEW6js.logger_default.success(`Collected ${result.classList.length} classes \u2192 ${result.filename}`);
|
|
141
141
|
} else {
|
|
142
|
-
|
|
142
|
+
_chunkCFH3UEW6js.logger_default.success(`Collected ${result.classList.length} classes.`);
|
|
143
143
|
}
|
|
144
144
|
});
|
|
145
145
|
var TOKEN_FORMATS = ["json", "lines", "grouped-json"];
|
|
146
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
147
|
const options = await loadPatchOptions(args.cwd);
|
|
148
|
-
const patcher = new (0,
|
|
148
|
+
const patcher = new (0, _chunkCFH3UEW6js.TailwindcssPatcher)(options);
|
|
149
149
|
const report = await patcher.collectContentTokens();
|
|
150
150
|
const shouldWrite = _nullishCoalesce(args.write, () => ( true));
|
|
151
151
|
let format = _nullishCoalesce(args.format, () => ( "json"));
|
|
@@ -154,7 +154,7 @@ cli.command("tokens", "Extract Tailwind tokens with file/position metadata").opt
|
|
|
154
154
|
}
|
|
155
155
|
const targetFile = _nullishCoalesce(args.output, () => ( ".tw-patch/tw-token-report.json"));
|
|
156
156
|
const groupKey = args.groupKey === "absolute" ? "absolute" : "relative";
|
|
157
|
-
const buildGrouped = () =>
|
|
157
|
+
const buildGrouped = () => _chunkCFH3UEW6js.groupTokensByFile.call(void 0, report, {
|
|
158
158
|
key: groupKey,
|
|
159
159
|
stripAbsolutePaths: groupKey !== "absolute"
|
|
160
160
|
});
|
|
@@ -172,48 +172,48 @@ cli.command("tokens", "Extract Tailwind tokens with file/position metadata").opt
|
|
|
172
172
|
await _fsextra2.default.writeFile(target, `${lines.join("\n")}
|
|
173
173
|
`, "utf8");
|
|
174
174
|
}
|
|
175
|
-
|
|
175
|
+
_chunkCFH3UEW6js.logger_default.success(
|
|
176
176
|
`Collected ${report.entries.length} tokens (${format}) \u2192 ${target.replace(_process2.default.cwd(), ".")}`
|
|
177
177
|
);
|
|
178
178
|
} else {
|
|
179
|
-
|
|
179
|
+
_chunkCFH3UEW6js.logger_default.success(`Collected ${report.entries.length} tokens from ${report.filesScanned} files.`);
|
|
180
180
|
if (format === "lines") {
|
|
181
181
|
const preview = report.entries.slice(0, 5).map(formatTokenLine).join("\n");
|
|
182
182
|
if (preview) {
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
_chunkCFH3UEW6js.logger_default.log("");
|
|
184
|
+
_chunkCFH3UEW6js.logger_default.info(preview);
|
|
185
185
|
if (report.entries.length > 5) {
|
|
186
|
-
|
|
186
|
+
_chunkCFH3UEW6js.logger_default.info(`\u2026and ${report.entries.length - 5} more.`);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
} else if (format === "grouped-json") {
|
|
190
190
|
const map = resolveGrouped();
|
|
191
191
|
const { preview, moreFiles } = formatGroupedPreview(map);
|
|
192
192
|
if (preview) {
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
_chunkCFH3UEW6js.logger_default.log("");
|
|
194
|
+
_chunkCFH3UEW6js.logger_default.info(preview);
|
|
195
195
|
if (moreFiles > 0) {
|
|
196
|
-
|
|
196
|
+
_chunkCFH3UEW6js.logger_default.info(`\u2026and ${moreFiles} more files.`);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
} else {
|
|
200
200
|
const previewEntries = report.entries.slice(0, 3);
|
|
201
201
|
if (previewEntries.length) {
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
_chunkCFH3UEW6js.logger_default.log("");
|
|
203
|
+
_chunkCFH3UEW6js.logger_default.info(JSON.stringify(previewEntries, null, 2));
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
if (report.skippedFiles.length) {
|
|
208
|
-
|
|
208
|
+
_chunkCFH3UEW6js.logger_default.warn("Skipped files:");
|
|
209
209
|
for (const skipped of report.skippedFiles) {
|
|
210
|
-
|
|
210
|
+
_chunkCFH3UEW6js.logger_default.warn(` \u2022 ${skipped.file} (${skipped.reason})`);
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
});
|
|
214
214
|
cli.command("init", "Generate a tailwindcss-patch config file").option("--cwd <dir>", "Working directory", { default: _process2.default.cwd() }).action(async (args) => {
|
|
215
215
|
await _config.initConfig.call(void 0, args.cwd);
|
|
216
|
-
|
|
216
|
+
_chunkCFH3UEW6js.logger_default.success(`\u2728 ${_config.CONFIG_NAME}.config.ts initialized!`);
|
|
217
217
|
});
|
|
218
218
|
cli.help();
|
|
219
219
|
cli.parse();
|
package/dist/cli.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkCFH3UEW6js = require('./chunk-CFH3UEW6.js');
|
|
16
16
|
|
|
17
17
|
// src/index.ts
|
|
18
18
|
var _config = require('@tailwindcss-mangle/config');
|
|
@@ -31,4 +31,4 @@ var _config = require('@tailwindcss-mangle/config');
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
exports.CacheStore =
|
|
34
|
+
exports.CacheStore = _chunkCFH3UEW6js.CacheStore; exports.TailwindcssPatcher = _chunkCFH3UEW6js.TailwindcssPatcher; exports.collectClassesFromContexts = _chunkCFH3UEW6js.collectClassesFromContexts; exports.collectClassesFromTailwindV4 = _chunkCFH3UEW6js.collectClassesFromTailwindV4; exports.defineConfig = _config.defineConfig; exports.extractProjectCandidatesWithPositions = _chunkCFH3UEW6js.extractProjectCandidatesWithPositions; exports.extractRawCandidates = _chunkCFH3UEW6js.extractRawCandidates; exports.extractRawCandidatesWithPositions = _chunkCFH3UEW6js.extractRawCandidatesWithPositions; exports.extractValidCandidates = _chunkCFH3UEW6js.extractValidCandidates; exports.groupTokensByFile = _chunkCFH3UEW6js.groupTokensByFile; exports.loadRuntimeContexts = _chunkCFH3UEW6js.loadRuntimeContexts; exports.logger = _chunkCFH3UEW6js.logger_default; exports.normalizeOptions = _chunkCFH3UEW6js.normalizeOptions; exports.runTailwindBuild = _chunkCFH3UEW6js.runTailwindBuild;
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwindcss-patch",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.3",
|
|
4
4
|
"description": "patch tailwindcss for exposing context and extract classes",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@babel/parser": "^7.28.5",
|
|
55
55
|
"@babel/traverse": "^7.28.5",
|
|
56
56
|
"@babel/types": "^7.28.5",
|
|
57
|
-
"@tailwindcss/node": "^4.1.
|
|
57
|
+
"@tailwindcss/node": "^4.1.17",
|
|
58
58
|
"cac": "^6.7.14",
|
|
59
59
|
"consola": "^3.4.2",
|
|
60
60
|
"fs-extra": "^11.3.2",
|
|
@@ -63,13 +63,13 @@
|
|
|
63
63
|
"postcss": "^8.5.6",
|
|
64
64
|
"semver": "^7.7.3",
|
|
65
65
|
"tailwindcss-config": "^1.1.2",
|
|
66
|
-
"@tailwindcss-mangle/config": "6.0
|
|
66
|
+
"@tailwindcss-mangle/config": "6.1.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@tailwindcss/oxide": "^4.1.
|
|
70
|
-
"@tailwindcss/postcss": "^4.1.
|
|
71
|
-
"@tailwindcss/vite": "^4.1.
|
|
72
|
-
"tailwindcss": "^4.1.
|
|
69
|
+
"@tailwindcss/oxide": "^4.1.17",
|
|
70
|
+
"@tailwindcss/postcss": "^4.1.17",
|
|
71
|
+
"@tailwindcss/vite": "^4.1.17",
|
|
72
|
+
"tailwindcss": "^4.1.17",
|
|
73
73
|
"tailwindcss-3": "npm:tailwindcss@^3.4.18",
|
|
74
74
|
"tailwindcss-4": "npm:tailwindcss@^4.1.16"
|
|
75
75
|
},
|