tailwindcss-patch 8.0.0 → 8.1.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/{chunk-FSTUQMKT.js → chunk-F3S7POWF.js} +69 -0
- package/dist/{chunk-Y45IACSP.mjs → chunk-IQ26TKX2.mjs} +69 -0
- package/dist/cli.js +8 -8
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -16,6 +16,9 @@ var CacheStore = class {
|
|
|
16
16
|
async ensureDir() {
|
|
17
17
|
await _fsextra2.default.ensureDir(this.options.dir);
|
|
18
18
|
}
|
|
19
|
+
ensureDirSync() {
|
|
20
|
+
_fsextra2.default.ensureDirSync(this.options.dir);
|
|
21
|
+
}
|
|
19
22
|
async write(data) {
|
|
20
23
|
if (!this.options.enabled) {
|
|
21
24
|
return void 0;
|
|
@@ -29,6 +32,19 @@ var CacheStore = class {
|
|
|
29
32
|
return void 0;
|
|
30
33
|
}
|
|
31
34
|
}
|
|
35
|
+
writeSync(data) {
|
|
36
|
+
if (!this.options.enabled) {
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
this.ensureDirSync();
|
|
41
|
+
_fsextra2.default.writeJSONSync(this.options.path, Array.from(data));
|
|
42
|
+
return this.options.path;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
logger_default.error("Unable to persist Tailwind class cache", error);
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
32
48
|
async read() {
|
|
33
49
|
if (!this.options.enabled) {
|
|
34
50
|
return /* @__PURE__ */ new Set();
|
|
@@ -52,6 +68,29 @@ var CacheStore = class {
|
|
|
52
68
|
}
|
|
53
69
|
return /* @__PURE__ */ new Set();
|
|
54
70
|
}
|
|
71
|
+
readSync() {
|
|
72
|
+
if (!this.options.enabled) {
|
|
73
|
+
return /* @__PURE__ */ new Set();
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const exists = _fsextra2.default.pathExistsSync(this.options.path);
|
|
77
|
+
if (!exists) {
|
|
78
|
+
return /* @__PURE__ */ new Set();
|
|
79
|
+
}
|
|
80
|
+
const data = _fsextra2.default.readJSONSync(this.options.path);
|
|
81
|
+
if (Array.isArray(data)) {
|
|
82
|
+
return new Set(data.filter((item) => typeof item === "string"));
|
|
83
|
+
}
|
|
84
|
+
} catch (error) {
|
|
85
|
+
logger_default.warn("Unable to read Tailwind class cache, removing invalid file.", error);
|
|
86
|
+
try {
|
|
87
|
+
_fsextra2.default.removeSync(this.options.path);
|
|
88
|
+
} catch (cleanupError) {
|
|
89
|
+
logger_default.error("Failed to clean up invalid cache file", cleanupError);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return /* @__PURE__ */ new Set();
|
|
93
|
+
}
|
|
55
94
|
};
|
|
56
95
|
|
|
57
96
|
// src/extraction/candidate-extractor.ts
|
|
@@ -1249,6 +1288,13 @@ var TailwindcssPatcher = (_class = class {
|
|
|
1249
1288
|
const contexts = this.getContexts();
|
|
1250
1289
|
return collectClassesFromContexts(contexts, this.options.filter);
|
|
1251
1290
|
}
|
|
1291
|
+
collectClassSetSync() {
|
|
1292
|
+
if (this.majorVersion === 4) {
|
|
1293
|
+
throw new Error("getClassSetSync is not supported for Tailwind CSS v4 projects. Use getClassSet instead.");
|
|
1294
|
+
}
|
|
1295
|
+
const contexts = this.getContexts();
|
|
1296
|
+
return collectClassesFromContexts(contexts, this.options.filter);
|
|
1297
|
+
}
|
|
1252
1298
|
async mergeWithCache(set) {
|
|
1253
1299
|
if (!this.options.cache.enabled) {
|
|
1254
1300
|
return set;
|
|
@@ -1268,11 +1314,34 @@ var TailwindcssPatcher = (_class = class {
|
|
|
1268
1314
|
}
|
|
1269
1315
|
return set;
|
|
1270
1316
|
}
|
|
1317
|
+
mergeWithCacheSync(set) {
|
|
1318
|
+
if (!this.options.cache.enabled) {
|
|
1319
|
+
return set;
|
|
1320
|
+
}
|
|
1321
|
+
const existing = this.cacheStore.readSync();
|
|
1322
|
+
if (this.options.cache.strategy === "merge") {
|
|
1323
|
+
for (const value of existing) {
|
|
1324
|
+
set.add(value);
|
|
1325
|
+
}
|
|
1326
|
+
this.cacheStore.writeSync(set);
|
|
1327
|
+
} else {
|
|
1328
|
+
if (set.size > 0) {
|
|
1329
|
+
this.cacheStore.writeSync(set);
|
|
1330
|
+
} else {
|
|
1331
|
+
return existing;
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
return set;
|
|
1335
|
+
}
|
|
1271
1336
|
async getClassSet() {
|
|
1272
1337
|
await this.runTailwindBuildIfNeeded();
|
|
1273
1338
|
const set = await this.collectClassSet();
|
|
1274
1339
|
return this.mergeWithCache(set);
|
|
1275
1340
|
}
|
|
1341
|
+
getClassSetSync() {
|
|
1342
|
+
const set = this.collectClassSetSync();
|
|
1343
|
+
return this.mergeWithCacheSync(set);
|
|
1344
|
+
}
|
|
1276
1345
|
async extract(options) {
|
|
1277
1346
|
const shouldWrite = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _64 => _64.write]), () => ( this.options.output.enabled));
|
|
1278
1347
|
const classSet = await this.getClassSet();
|
|
@@ -12,6 +12,9 @@ var CacheStore = class {
|
|
|
12
12
|
async ensureDir() {
|
|
13
13
|
await fs.ensureDir(this.options.dir);
|
|
14
14
|
}
|
|
15
|
+
ensureDirSync() {
|
|
16
|
+
fs.ensureDirSync(this.options.dir);
|
|
17
|
+
}
|
|
15
18
|
async write(data) {
|
|
16
19
|
if (!this.options.enabled) {
|
|
17
20
|
return void 0;
|
|
@@ -25,6 +28,19 @@ var CacheStore = class {
|
|
|
25
28
|
return void 0;
|
|
26
29
|
}
|
|
27
30
|
}
|
|
31
|
+
writeSync(data) {
|
|
32
|
+
if (!this.options.enabled) {
|
|
33
|
+
return void 0;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
this.ensureDirSync();
|
|
37
|
+
fs.writeJSONSync(this.options.path, Array.from(data));
|
|
38
|
+
return this.options.path;
|
|
39
|
+
} catch (error) {
|
|
40
|
+
logger_default.error("Unable to persist Tailwind class cache", error);
|
|
41
|
+
return void 0;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
28
44
|
async read() {
|
|
29
45
|
if (!this.options.enabled) {
|
|
30
46
|
return /* @__PURE__ */ new Set();
|
|
@@ -48,6 +64,29 @@ var CacheStore = class {
|
|
|
48
64
|
}
|
|
49
65
|
return /* @__PURE__ */ new Set();
|
|
50
66
|
}
|
|
67
|
+
readSync() {
|
|
68
|
+
if (!this.options.enabled) {
|
|
69
|
+
return /* @__PURE__ */ new Set();
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
const exists = fs.pathExistsSync(this.options.path);
|
|
73
|
+
if (!exists) {
|
|
74
|
+
return /* @__PURE__ */ new Set();
|
|
75
|
+
}
|
|
76
|
+
const data = fs.readJSONSync(this.options.path);
|
|
77
|
+
if (Array.isArray(data)) {
|
|
78
|
+
return new Set(data.filter((item) => typeof item === "string"));
|
|
79
|
+
}
|
|
80
|
+
} catch (error) {
|
|
81
|
+
logger_default.warn("Unable to read Tailwind class cache, removing invalid file.", error);
|
|
82
|
+
try {
|
|
83
|
+
fs.removeSync(this.options.path);
|
|
84
|
+
} catch (cleanupError) {
|
|
85
|
+
logger_default.error("Failed to clean up invalid cache file", cleanupError);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return /* @__PURE__ */ new Set();
|
|
89
|
+
}
|
|
51
90
|
};
|
|
52
91
|
|
|
53
92
|
// src/extraction/candidate-extractor.ts
|
|
@@ -1245,6 +1284,13 @@ var TailwindcssPatcher = class {
|
|
|
1245
1284
|
const contexts = this.getContexts();
|
|
1246
1285
|
return collectClassesFromContexts(contexts, this.options.filter);
|
|
1247
1286
|
}
|
|
1287
|
+
collectClassSetSync() {
|
|
1288
|
+
if (this.majorVersion === 4) {
|
|
1289
|
+
throw new Error("getClassSetSync is not supported for Tailwind CSS v4 projects. Use getClassSet instead.");
|
|
1290
|
+
}
|
|
1291
|
+
const contexts = this.getContexts();
|
|
1292
|
+
return collectClassesFromContexts(contexts, this.options.filter);
|
|
1293
|
+
}
|
|
1248
1294
|
async mergeWithCache(set) {
|
|
1249
1295
|
if (!this.options.cache.enabled) {
|
|
1250
1296
|
return set;
|
|
@@ -1264,11 +1310,34 @@ var TailwindcssPatcher = class {
|
|
|
1264
1310
|
}
|
|
1265
1311
|
return set;
|
|
1266
1312
|
}
|
|
1313
|
+
mergeWithCacheSync(set) {
|
|
1314
|
+
if (!this.options.cache.enabled) {
|
|
1315
|
+
return set;
|
|
1316
|
+
}
|
|
1317
|
+
const existing = this.cacheStore.readSync();
|
|
1318
|
+
if (this.options.cache.strategy === "merge") {
|
|
1319
|
+
for (const value of existing) {
|
|
1320
|
+
set.add(value);
|
|
1321
|
+
}
|
|
1322
|
+
this.cacheStore.writeSync(set);
|
|
1323
|
+
} else {
|
|
1324
|
+
if (set.size > 0) {
|
|
1325
|
+
this.cacheStore.writeSync(set);
|
|
1326
|
+
} else {
|
|
1327
|
+
return existing;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
return set;
|
|
1331
|
+
}
|
|
1267
1332
|
async getClassSet() {
|
|
1268
1333
|
await this.runTailwindBuildIfNeeded();
|
|
1269
1334
|
const set = await this.collectClassSet();
|
|
1270
1335
|
return this.mergeWithCache(set);
|
|
1271
1336
|
}
|
|
1337
|
+
getClassSetSync() {
|
|
1338
|
+
const set = this.collectClassSetSync();
|
|
1339
|
+
return this.mergeWithCacheSync(set);
|
|
1340
|
+
}
|
|
1272
1341
|
async extract(options) {
|
|
1273
1342
|
const shouldWrite = options?.write ?? this.options.output.enabled;
|
|
1274
1343
|
const classSet = await this.getClassSet();
|
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkF3S7POWFjs = require('./chunk-F3S7POWF.js');
|
|
7
7
|
|
|
8
8
|
// src/cli.ts
|
|
9
9
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
@@ -105,15 +105,15 @@ var cli = _cac2.default.call(void 0, "tw-patch");
|
|
|
105
105
|
async function loadPatchOptions(cwd, overrides) {
|
|
106
106
|
const { config } = await _config.getConfig.call(void 0, cwd);
|
|
107
107
|
const legacyConfig = config;
|
|
108
|
-
const base = _optionalChain([config, 'optionalAccess', _ => _.registry]) ?
|
|
108
|
+
const base = _optionalChain([config, 'optionalAccess', _ => _.registry]) ? _chunkF3S7POWFjs.fromUnifiedConfig.call(void 0, config.registry) : _optionalChain([legacyConfig, 'optionalAccess', _2 => _2.patch]) ? _chunkF3S7POWFjs.fromLegacyOptions.call(void 0, { patch: legacyConfig.patch }) : {};
|
|
109
109
|
const merged = defu(_nullishCoalesce(overrides, () => ( {})), base);
|
|
110
110
|
return merged;
|
|
111
111
|
}
|
|
112
112
|
cli.command("install", "Apply Tailwind CSS runtime patches").option("--cwd <dir>", "Working directory", { default: _process2.default.cwd() }).action(async (args) => {
|
|
113
113
|
const options = await loadPatchOptions(args.cwd);
|
|
114
|
-
const patcher = new (0,
|
|
114
|
+
const patcher = new (0, _chunkF3S7POWFjs.TailwindcssPatcher)(options);
|
|
115
115
|
await patcher.patch();
|
|
116
|
-
|
|
116
|
+
_chunkF3S7POWFjs.logger_default.success("Tailwind CSS runtime patched successfully.");
|
|
117
117
|
});
|
|
118
118
|
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) => {
|
|
119
119
|
const overrides = {};
|
|
@@ -131,17 +131,17 @@ cli.command("extract", "Collect generated class names into a cache file").option
|
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
133
|
const options = await loadPatchOptions(args.cwd, overrides);
|
|
134
|
-
const patcher = new (0,
|
|
134
|
+
const patcher = new (0, _chunkF3S7POWFjs.TailwindcssPatcher)(options);
|
|
135
135
|
const result = await patcher.extract({ write: args.write });
|
|
136
136
|
if (result.filename) {
|
|
137
|
-
|
|
137
|
+
_chunkF3S7POWFjs.logger_default.success(`Collected ${result.classList.length} classes \u2192 ${result.filename}`);
|
|
138
138
|
} else {
|
|
139
|
-
|
|
139
|
+
_chunkF3S7POWFjs.logger_default.success(`Collected ${result.classList.length} classes.`);
|
|
140
140
|
}
|
|
141
141
|
});
|
|
142
142
|
cli.command("init", "Generate a tailwindcss-patch config file").option("--cwd <dir>", "Working directory", { default: _process2.default.cwd() }).action(async (args) => {
|
|
143
143
|
await _config.initConfig.call(void 0, args.cwd);
|
|
144
|
-
|
|
144
|
+
_chunkF3S7POWFjs.logger_default.success(`\u2728 ${_config.CONFIG_NAME}.config.ts initialized!`);
|
|
145
145
|
});
|
|
146
146
|
cli.help();
|
|
147
147
|
cli.parse();
|
package/dist/cli.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -280,8 +280,11 @@ declare class TailwindcssPatcher {
|
|
|
280
280
|
getContexts(): TailwindcssRuntimeContext[];
|
|
281
281
|
private runTailwindBuildIfNeeded;
|
|
282
282
|
private collectClassSet;
|
|
283
|
+
private collectClassSetSync;
|
|
283
284
|
private mergeWithCache;
|
|
285
|
+
private mergeWithCacheSync;
|
|
284
286
|
getClassSet(): Promise<Set<string>>;
|
|
287
|
+
getClassSetSync(): Set<string>;
|
|
285
288
|
extract(options?: {
|
|
286
289
|
write?: boolean;
|
|
287
290
|
}): Promise<ExtractResult>;
|
|
@@ -292,8 +295,11 @@ declare class CacheStore {
|
|
|
292
295
|
private readonly options;
|
|
293
296
|
constructor(options: NormalizedCacheOptions);
|
|
294
297
|
private ensureDir;
|
|
298
|
+
private ensureDirSync;
|
|
295
299
|
write(data: Set<string>): Promise<string | undefined>;
|
|
300
|
+
writeSync(data: Set<string>): string | undefined;
|
|
296
301
|
read(): Promise<Set<string>>;
|
|
302
|
+
readSync(): Set<string>;
|
|
297
303
|
}
|
|
298
304
|
|
|
299
305
|
declare const logger: consola.ConsolaInstance;
|
package/dist/index.d.ts
CHANGED
|
@@ -280,8 +280,11 @@ declare class TailwindcssPatcher {
|
|
|
280
280
|
getContexts(): TailwindcssRuntimeContext[];
|
|
281
281
|
private runTailwindBuildIfNeeded;
|
|
282
282
|
private collectClassSet;
|
|
283
|
+
private collectClassSetSync;
|
|
283
284
|
private mergeWithCache;
|
|
285
|
+
private mergeWithCacheSync;
|
|
284
286
|
getClassSet(): Promise<Set<string>>;
|
|
287
|
+
getClassSetSync(): Set<string>;
|
|
285
288
|
extract(options?: {
|
|
286
289
|
write?: boolean;
|
|
287
290
|
}): Promise<ExtractResult>;
|
|
@@ -292,8 +295,11 @@ declare class CacheStore {
|
|
|
292
295
|
private readonly options;
|
|
293
296
|
constructor(options: NormalizedCacheOptions);
|
|
294
297
|
private ensureDir;
|
|
298
|
+
private ensureDirSync;
|
|
295
299
|
write(data: Set<string>): Promise<string | undefined>;
|
|
300
|
+
writeSync(data: Set<string>): string | undefined;
|
|
296
301
|
read(): Promise<Set<string>>;
|
|
302
|
+
readSync(): Set<string>;
|
|
297
303
|
}
|
|
298
304
|
|
|
299
305
|
declare const logger: consola.ConsolaInstance;
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkF3S7POWFjs = require('./chunk-F3S7POWF.js');
|
|
14
14
|
|
|
15
15
|
// src/index.ts
|
|
16
16
|
var _config = require('@tailwindcss-mangle/config');
|
|
@@ -27,4 +27,4 @@ var _config = require('@tailwindcss-mangle/config');
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
exports.CacheStore =
|
|
30
|
+
exports.CacheStore = _chunkF3S7POWFjs.CacheStore; exports.TailwindcssPatcher = _chunkF3S7POWFjs.TailwindcssPatcher; exports.collectClassesFromContexts = _chunkF3S7POWFjs.collectClassesFromContexts; exports.collectClassesFromTailwindV4 = _chunkF3S7POWFjs.collectClassesFromTailwindV4; exports.defineConfig = _config.defineConfig; exports.extractRawCandidates = _chunkF3S7POWFjs.extractRawCandidates; exports.extractRawCandidatesWithPositions = _chunkF3S7POWFjs.extractRawCandidatesWithPositions; exports.extractValidCandidates = _chunkF3S7POWFjs.extractValidCandidates; exports.loadRuntimeContexts = _chunkF3S7POWFjs.loadRuntimeContexts; exports.logger = _chunkF3S7POWFjs.logger_default; exports.normalizeOptions = _chunkF3S7POWFjs.normalizeOptions; exports.runTailwindBuild = _chunkF3S7POWFjs.runTailwindBuild;
|
package/dist/index.mjs
CHANGED