tailwindcss-patch 5.0.2 → 6.0.1
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/README.md +5 -2
- package/bin/tw-patch.js +1 -1
- package/dist/{chunk-LOQK6LST.js → chunk-U2NQZPXE.mjs} +158 -146
- package/dist/{cli.cjs → chunk-U3S6WRCP.js} +286 -304
- package/dist/cli.js +17 -17
- package/dist/cli.mjs +35 -0
- package/dist/{index.d.cts → index.d.mts} +23 -17
- package/dist/index.d.ts +23 -17
- package/dist/index.js +24 -23
- package/dist/index.mjs +24 -0
- package/package.json +26 -19
- package/dist/index.cjs +0 -962
- /package/dist/{cli.d.cts → cli.d.mts} +0 -0
|
@@ -1,53 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
-
mod
|
|
24
|
-
));
|
|
25
|
-
|
|
26
|
-
// ../../node_modules/.pnpm/tsup@8.3.5_jiti@2.4.0_postcss@8.4.47_tsx@4.19.2_typescript@5.6.3_yaml@2.6.0/node_modules/tsup/assets/cjs_shims.js
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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; } var _class;// ../../node_modules/.pnpm/tsup@8.3.6_jiti@2.4.2_postcss@8.5.2_tsx@4.19.2_typescript@5.7.3_yaml@2.7.0/node_modules/tsup/assets/cjs_shims.js
|
|
27
2
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
28
3
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
29
4
|
|
|
30
|
-
// src/
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
// src/config.ts
|
|
35
|
-
var config_exports = {};
|
|
36
|
-
__reExport(config_exports, require("@tailwindcss-mangle/config"));
|
|
5
|
+
// src/logger.ts
|
|
6
|
+
var _consola = require('consola');
|
|
7
|
+
var logger = _consola.createConsola.call(void 0, );
|
|
8
|
+
var logger_default = logger;
|
|
37
9
|
|
|
38
10
|
// src/core/cache.ts
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
11
|
+
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
12
|
+
var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
|
|
13
|
+
var _pathe = require('pathe'); var _pathe2 = _interopRequireDefault(_pathe);
|
|
42
14
|
|
|
43
15
|
// src/constants.ts
|
|
44
16
|
var pkgName = "tailwindcss-patch";
|
|
45
17
|
|
|
46
|
-
// src/logger.ts
|
|
47
|
-
var import_consola = require("consola");
|
|
48
|
-
var logger = (0, import_consola.createConsola)();
|
|
49
|
-
var logger_default = logger;
|
|
50
|
-
|
|
51
18
|
// src/core/cache.ts
|
|
52
19
|
function getCacheOptions(options) {
|
|
53
20
|
let cache;
|
|
@@ -72,15 +39,15 @@ function getCacheOptions(options) {
|
|
|
72
39
|
return cache;
|
|
73
40
|
}
|
|
74
41
|
var CacheManager = class {
|
|
75
|
-
|
|
42
|
+
|
|
76
43
|
constructor(options = {}) {
|
|
77
44
|
this.options = this.getOptions(options);
|
|
78
45
|
}
|
|
79
46
|
getOptions(options = {}) {
|
|
80
|
-
const cwd = options.cwd
|
|
81
|
-
const dir = options.dir
|
|
82
|
-
const file = options.file
|
|
83
|
-
const filename =
|
|
47
|
+
const cwd = _nullishCoalesce(options.cwd, () => ( _process2.default.cwd()));
|
|
48
|
+
const dir = _nullishCoalesce(options.dir, () => ( _pathe2.default.resolve(cwd, "node_modules/.cache", pkgName)));
|
|
49
|
+
const file = _nullishCoalesce(options.file, () => ( "index.json"));
|
|
50
|
+
const filename = _pathe2.default.resolve(dir, file);
|
|
84
51
|
return {
|
|
85
52
|
cwd,
|
|
86
53
|
dir,
|
|
@@ -89,41 +56,35 @@ var CacheManager = class {
|
|
|
89
56
|
strategy: "merge"
|
|
90
57
|
};
|
|
91
58
|
}
|
|
92
|
-
write(data) {
|
|
59
|
+
async write(data) {
|
|
93
60
|
try {
|
|
94
|
-
const {
|
|
95
|
-
|
|
96
|
-
import_fs_extra.default.outputFileSync(filename, JSON.stringify([...data], void 0, 2), "utf8");
|
|
61
|
+
const { filename } = this.options;
|
|
62
|
+
await _fsextra2.default.outputJSON(filename, [...data]);
|
|
97
63
|
return filename;
|
|
98
|
-
} catch {
|
|
64
|
+
} catch (e2) {
|
|
99
65
|
logger_default.error("write cache file fail!");
|
|
100
66
|
}
|
|
101
67
|
}
|
|
102
|
-
read() {
|
|
68
|
+
async read() {
|
|
103
69
|
const { filename } = this.options;
|
|
104
70
|
try {
|
|
105
|
-
if (
|
|
106
|
-
const data =
|
|
107
|
-
return new Set(
|
|
71
|
+
if (await _fsextra2.default.exists(filename)) {
|
|
72
|
+
const data = await _fsextra2.default.readJSON(filename);
|
|
73
|
+
return new Set(data);
|
|
108
74
|
}
|
|
109
|
-
} catch {
|
|
75
|
+
} catch (e3) {
|
|
110
76
|
logger_default.error(`parse cache content fail! path:${filename}`);
|
|
111
77
|
try {
|
|
112
|
-
|
|
113
|
-
} catch {
|
|
78
|
+
_fsextra2.default.unlinkSync(filename);
|
|
79
|
+
} catch (e4) {
|
|
114
80
|
logger_default.error(`delete cache file fail! path:${filename}`);
|
|
115
81
|
}
|
|
116
82
|
}
|
|
117
83
|
}
|
|
118
84
|
};
|
|
119
85
|
|
|
120
|
-
// src/core/patcher.ts
|
|
121
|
-
var import_node_module3 = require("module");
|
|
122
|
-
var import_fs_extra5 = __toESM(require("fs-extra"), 1);
|
|
123
|
-
var import_pathe7 = __toESM(require("pathe"), 1);
|
|
124
|
-
|
|
125
86
|
// src/defaults.ts
|
|
126
|
-
|
|
87
|
+
|
|
127
88
|
|
|
128
89
|
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
129
90
|
function isPlainObject(value) {
|
|
@@ -229,150 +190,39 @@ function getPatchOptions(options) {
|
|
|
229
190
|
return defu(
|
|
230
191
|
options,
|
|
231
192
|
{
|
|
232
|
-
basedir:
|
|
193
|
+
basedir: _process2.default.cwd()
|
|
233
194
|
},
|
|
234
195
|
getDefaultPatchOptions()
|
|
235
196
|
);
|
|
236
197
|
}
|
|
237
198
|
|
|
238
|
-
// src/
|
|
239
|
-
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
240
|
-
var import_pathe2 = __toESM(require("pathe"), 1);
|
|
241
|
-
var import_resolve = __toESM(require("resolve"), 1);
|
|
242
|
-
var { sync } = import_resolve.default;
|
|
243
|
-
function requireResolve(id, opts) {
|
|
244
|
-
return sync(id, opts);
|
|
245
|
-
}
|
|
246
|
-
function searchPackageJSON(dir) {
|
|
247
|
-
let packageJsonPath;
|
|
248
|
-
while (true) {
|
|
249
|
-
if (!dir) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
const newDir = import_pathe2.default.dirname(dir);
|
|
253
|
-
if (newDir === dir) {
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
dir = newDir;
|
|
257
|
-
packageJsonPath = import_pathe2.default.join(dir, "package.json");
|
|
258
|
-
if (import_fs_extra2.default.existsSync(packageJsonPath)) {
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
return packageJsonPath;
|
|
263
|
-
}
|
|
264
|
-
function getTailwindcssEntry(name = "tailwindcss", opts) {
|
|
265
|
-
return requireResolve(name, opts);
|
|
266
|
-
}
|
|
267
|
-
function getPackageJsonPath(name, options = {}) {
|
|
268
|
-
const entry = getTailwindcssEntry(name, options);
|
|
269
|
-
if (!entry) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
return searchPackageJSON(entry);
|
|
273
|
-
}
|
|
274
|
-
function getPackageInfoSync(name, options = {}) {
|
|
275
|
-
const packageJsonPath = getPackageJsonPath(name, options);
|
|
276
|
-
if (!packageJsonPath) {
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
const packageJson = JSON.parse(import_fs_extra2.default.readFileSync(packageJsonPath, "utf8"));
|
|
280
|
-
return {
|
|
281
|
-
name,
|
|
282
|
-
version: packageJson.version,
|
|
283
|
-
rootPath: import_pathe2.default.dirname(packageJsonPath),
|
|
284
|
-
packageJsonPath,
|
|
285
|
-
packageJson
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
function isObject(val) {
|
|
289
|
-
return val !== null && typeof val === "object" && Array.isArray(val) === false;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
// src/core/postcss.ts
|
|
293
|
-
var import_node_module = require("module");
|
|
294
|
-
var import_node_process3 = __toESM(require("process"), 1);
|
|
295
|
-
var import_jiti = require("jiti");
|
|
296
|
-
var import_lilconfig = require("lilconfig");
|
|
297
|
-
var import_pathe3 = __toESM(require("pathe"), 1);
|
|
298
|
-
var import_postcss = __toESM(require("postcss"), 1);
|
|
299
|
-
var jiti = (0, import_jiti.createJiti)(importMetaUrl);
|
|
300
|
-
var require2 = (0, import_node_module.createRequire)(importMetaUrl);
|
|
301
|
-
async function processTailwindcss(options) {
|
|
302
|
-
const { config: userConfig, cwd } = defu(options, {
|
|
303
|
-
cwd: import_node_process3.default.cwd()
|
|
304
|
-
});
|
|
305
|
-
let config = userConfig;
|
|
306
|
-
if (!(typeof config === "string" && import_pathe3.default.isAbsolute(config))) {
|
|
307
|
-
const moduleName = "tailwind";
|
|
308
|
-
const result = await (0, import_lilconfig.lilconfig)("tailwindcss", {
|
|
309
|
-
searchPlaces: [
|
|
310
|
-
`${moduleName}.config.js`,
|
|
311
|
-
`${moduleName}.config.cjs`,
|
|
312
|
-
`${moduleName}.config.mjs`,
|
|
313
|
-
`${moduleName}.config.ts`,
|
|
314
|
-
`${moduleName}.config.cts`,
|
|
315
|
-
`${moduleName}.config.mts`
|
|
316
|
-
],
|
|
317
|
-
loaders: {
|
|
318
|
-
// 默认支持 js 和 cjs 2种格式
|
|
319
|
-
".js": jiti,
|
|
320
|
-
".cjs": jiti,
|
|
321
|
-
".mjs": jiti,
|
|
322
|
-
".ts": jiti,
|
|
323
|
-
".cts": jiti,
|
|
324
|
-
".mts": jiti
|
|
325
|
-
}
|
|
326
|
-
}).search(cwd);
|
|
327
|
-
if (!result) {
|
|
328
|
-
throw new Error(`No TailwindCSS Config found in: ${cwd}`);
|
|
329
|
-
}
|
|
330
|
-
config = result.filepath;
|
|
331
|
-
}
|
|
332
|
-
const id = requireResolve("tailwindcss", {
|
|
333
|
-
basedir: cwd
|
|
334
|
-
});
|
|
335
|
-
return await (0, import_postcss.default)([
|
|
336
|
-
require2(id)({
|
|
337
|
-
config
|
|
338
|
-
})
|
|
339
|
-
]).process("@tailwind base;@tailwind components;@tailwind utilities;", {
|
|
340
|
-
from: void 0
|
|
341
|
-
});
|
|
342
|
-
}
|
|
199
|
+
// src/core/patches/exportContext/index.ts
|
|
343
200
|
|
|
344
|
-
// src/core/runtime.ts
|
|
345
|
-
var import_node_module2 = require("module");
|
|
346
|
-
var import_pathe6 = __toESM(require("pathe"), 1);
|
|
347
|
-
var import_semver = require("semver");
|
|
348
201
|
|
|
349
|
-
// src/core/patches/exportContext/index.ts
|
|
350
|
-
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
351
|
-
var import_pathe4 = __toESM(require("pathe"), 1);
|
|
352
202
|
|
|
353
203
|
// src/core/patches/exportContext/postcss-v2.ts
|
|
354
|
-
var
|
|
204
|
+
var _types = require('@babel/types'); var t = _interopRequireWildcard(_types); var t2 = _interopRequireWildcard(_types); var t3 = _interopRequireWildcard(_types);
|
|
355
205
|
|
|
356
206
|
// src/babel/index.ts
|
|
357
|
-
var
|
|
358
|
-
var
|
|
359
|
-
var
|
|
207
|
+
var _generator = require('@babel/generator'); var _generator2 = _interopRequireDefault(_generator);
|
|
208
|
+
var _traverse = require('@babel/traverse'); var _traverse2 = _interopRequireDefault(_traverse);
|
|
209
|
+
var _parser = require('@babel/parser');
|
|
360
210
|
function _interopDefaultCompat(e) {
|
|
361
211
|
return e && typeof e === "object" && "default" in e ? e.default : e;
|
|
362
212
|
}
|
|
363
|
-
var generate = _interopDefaultCompat(
|
|
364
|
-
var traverse = _interopDefaultCompat(
|
|
213
|
+
var generate = _interopDefaultCompat(_generator2.default);
|
|
214
|
+
var traverse = _interopDefaultCompat(_traverse2.default);
|
|
365
215
|
|
|
366
216
|
// src/core/patches/exportContext/postcss-v2.ts
|
|
367
217
|
function inspectProcessTailwindFeaturesReturnContext(content) {
|
|
368
|
-
const ast = (0,
|
|
218
|
+
const ast = _parser.parse.call(void 0, content, {
|
|
369
219
|
sourceType: "unambiguous"
|
|
370
220
|
});
|
|
371
221
|
let hasPatched = false;
|
|
372
222
|
traverse(ast, {
|
|
373
223
|
FunctionDeclaration(p) {
|
|
374
224
|
const n = p.node;
|
|
375
|
-
if (n.id
|
|
225
|
+
if (_optionalChain([n, 'access', _ => _.id, 'optionalAccess', _2 => _2.name]) === "processTailwindFeatures" && n.body.body.length === 1 && t.isReturnStatement(n.body.body[0])) {
|
|
376
226
|
const rts = n.body.body[0];
|
|
377
227
|
if (t.isFunctionExpression(rts.argument)) {
|
|
378
228
|
const body = rts.argument.body.body;
|
|
@@ -392,7 +242,7 @@ function inspectProcessTailwindFeaturesReturnContext(content) {
|
|
|
392
242
|
};
|
|
393
243
|
}
|
|
394
244
|
function inspectPostcssPlugin(content) {
|
|
395
|
-
const ast = (0,
|
|
245
|
+
const ast = _parser.parse.call(void 0, content);
|
|
396
246
|
const exportKey = "contextRef";
|
|
397
247
|
const variableName = "contextRef";
|
|
398
248
|
const valueKey = "value";
|
|
@@ -401,7 +251,7 @@ function inspectPostcssPlugin(content) {
|
|
|
401
251
|
Program(p) {
|
|
402
252
|
const n = p.node;
|
|
403
253
|
const idx = n.body.findIndex((x) => {
|
|
404
|
-
return t.isFunctionDeclaration(x) && x.id
|
|
254
|
+
return t.isFunctionDeclaration(x) && _optionalChain([x, 'access', _3 => _3.id, 'optionalAccess', _4 => _4.name]) === "_default";
|
|
405
255
|
});
|
|
406
256
|
if (idx > -1) {
|
|
407
257
|
const prevStatement = n.body[idx - 1];
|
|
@@ -434,7 +284,7 @@ function inspectPostcssPlugin(content) {
|
|
|
434
284
|
return;
|
|
435
285
|
}
|
|
436
286
|
const n = p.node;
|
|
437
|
-
if (n.id
|
|
287
|
+
if (_optionalChain([n, 'access', _5 => _5.id, 'optionalAccess', _6 => _6.name]) === "_default" && n.body.body.length === 1 && t.isReturnStatement(n.body.body[0])) {
|
|
438
288
|
const returnStatement3 = n.body.body[0];
|
|
439
289
|
if (t.isCallExpression(returnStatement3.argument) && t.isMemberExpression(returnStatement3.argument.callee) && t.isArrayExpression(returnStatement3.argument.callee.object)) {
|
|
440
290
|
const targetFn = returnStatement3.argument.callee.object.elements[1];
|
|
@@ -498,14 +348,14 @@ function inspectPostcssPlugin(content) {
|
|
|
498
348
|
}
|
|
499
349
|
|
|
500
350
|
// src/core/patches/exportContext/postcss-v3.ts
|
|
501
|
-
|
|
351
|
+
|
|
502
352
|
function inspectProcessTailwindFeaturesReturnContext2(content) {
|
|
503
|
-
const ast = (0,
|
|
353
|
+
const ast = _parser.parse.call(void 0, content);
|
|
504
354
|
let hasPatched = false;
|
|
505
355
|
traverse(ast, {
|
|
506
356
|
FunctionDeclaration(p) {
|
|
507
357
|
const n = p.node;
|
|
508
|
-
if (n.id
|
|
358
|
+
if (_optionalChain([n, 'access', _7 => _7.id, 'optionalAccess', _8 => _8.name]) === "processTailwindFeatures" && n.body.body.length === 1 && t2.isReturnStatement(n.body.body[0])) {
|
|
509
359
|
const rts = n.body.body[0];
|
|
510
360
|
if (t2.isFunctionExpression(rts.argument)) {
|
|
511
361
|
const body = rts.argument.body.body;
|
|
@@ -525,7 +375,7 @@ function inspectProcessTailwindFeaturesReturnContext2(content) {
|
|
|
525
375
|
};
|
|
526
376
|
}
|
|
527
377
|
function inspectPostcssPlugin2(content) {
|
|
528
|
-
const ast = (0,
|
|
378
|
+
const ast = _parser.parse.call(void 0, content);
|
|
529
379
|
const exportKey = "contextRef";
|
|
530
380
|
const variableName = "contextRef";
|
|
531
381
|
const valueKey = "value";
|
|
@@ -534,7 +384,7 @@ function inspectPostcssPlugin2(content) {
|
|
|
534
384
|
Program(p) {
|
|
535
385
|
const n = p.node;
|
|
536
386
|
const idx = n.body.findIndex((x) => {
|
|
537
|
-
return t2.isExpressionStatement(x) && t2.isAssignmentExpression(x.expression) && t2.isMemberExpression(x.expression.left) && t2.isFunctionExpression(x.expression.right) && x.expression.right.id
|
|
387
|
+
return t2.isExpressionStatement(x) && t2.isAssignmentExpression(x.expression) && t2.isMemberExpression(x.expression.left) && t2.isFunctionExpression(x.expression.right) && _optionalChain([x, 'access', _9 => _9.expression, 'access', _10 => _10.right, 'access', _11 => _11.id, 'optionalAccess', _12 => _12.name]) === "tailwindcss";
|
|
538
388
|
});
|
|
539
389
|
if (idx > -1) {
|
|
540
390
|
const prevStatement = n.body[idx - 1];
|
|
@@ -564,7 +414,7 @@ function inspectPostcssPlugin2(content) {
|
|
|
564
414
|
return;
|
|
565
415
|
}
|
|
566
416
|
const n = p.node;
|
|
567
|
-
if (n.id
|
|
417
|
+
if (_optionalChain([n, 'access', _13 => _13.id, 'optionalAccess', _14 => _14.name]) === "tailwindcss" && n.body.body.length === 1 && t2.isReturnStatement(n.body.body[0])) {
|
|
568
418
|
const returnStatement3 = n.body.body[0];
|
|
569
419
|
if (t2.isObjectExpression(returnStatement3.argument) && returnStatement3.argument.properties.length === 2) {
|
|
570
420
|
const properties = returnStatement3.argument.properties;
|
|
@@ -639,13 +489,13 @@ function inspectPostcssPlugin2(content) {
|
|
|
639
489
|
// src/core/patches/exportContext/index.ts
|
|
640
490
|
function monkeyPatchForExposingContextV3(twDir, opt) {
|
|
641
491
|
const k0 = "lib/processTailwindFeatures.js";
|
|
642
|
-
const processTailwindFeaturesFilePath =
|
|
643
|
-
const processTailwindFeaturesContent =
|
|
492
|
+
const processTailwindFeaturesFilePath = _pathe2.default.resolve(twDir, k0);
|
|
493
|
+
const processTailwindFeaturesContent = _fsextra2.default.readFileSync(processTailwindFeaturesFilePath, "utf8");
|
|
644
494
|
const result = {};
|
|
645
495
|
if (processTailwindFeaturesContent) {
|
|
646
496
|
const { code, hasPatched } = inspectProcessTailwindFeaturesReturnContext2(processTailwindFeaturesContent);
|
|
647
497
|
if (!hasPatched && opt.overwrite) {
|
|
648
|
-
|
|
498
|
+
_fsextra2.default.writeFileSync(processTailwindFeaturesFilePath, code, {
|
|
649
499
|
encoding: "utf8"
|
|
650
500
|
});
|
|
651
501
|
logger_default.success("patch tailwindcss processTailwindFeatures for return context successfully!");
|
|
@@ -656,21 +506,21 @@ function monkeyPatchForExposingContextV3(twDir, opt) {
|
|
|
656
506
|
let k1;
|
|
657
507
|
const try0 = "lib/plugin.js";
|
|
658
508
|
const try1 = "lib/index.js";
|
|
659
|
-
const pluginFilePath =
|
|
660
|
-
const indexFilePath =
|
|
661
|
-
if (
|
|
509
|
+
const pluginFilePath = _pathe2.default.resolve(twDir, try0);
|
|
510
|
+
const indexFilePath = _pathe2.default.resolve(twDir, try1);
|
|
511
|
+
if (_fsextra2.default.existsSync(pluginFilePath)) {
|
|
662
512
|
k1 = try0;
|
|
663
513
|
injectFilepath = pluginFilePath;
|
|
664
|
-
} else if (
|
|
514
|
+
} else if (_fsextra2.default.existsSync(indexFilePath)) {
|
|
665
515
|
k1 = try1;
|
|
666
516
|
injectFilepath = indexFilePath;
|
|
667
517
|
}
|
|
668
518
|
if (injectFilepath && k1) {
|
|
669
|
-
const pluginContent =
|
|
519
|
+
const pluginContent = _fsextra2.default.readFileSync(injectFilepath, "utf8");
|
|
670
520
|
if (pluginContent) {
|
|
671
521
|
const { code, hasPatched } = inspectPostcssPlugin2(pluginContent);
|
|
672
522
|
if (!hasPatched && opt.overwrite) {
|
|
673
|
-
|
|
523
|
+
_fsextra2.default.writeFileSync(injectFilepath, code, {
|
|
674
524
|
encoding: "utf8"
|
|
675
525
|
});
|
|
676
526
|
logger_default.success("patch tailwindcss for expose runtime context successfully!");
|
|
@@ -682,13 +532,13 @@ function monkeyPatchForExposingContextV3(twDir, opt) {
|
|
|
682
532
|
}
|
|
683
533
|
function monkeyPatchForExposingContextV2(twDir, opt) {
|
|
684
534
|
const k0 = "lib/jit/processTailwindFeatures.js";
|
|
685
|
-
const processTailwindFeaturesFilePath =
|
|
686
|
-
const processTailwindFeaturesContent =
|
|
535
|
+
const processTailwindFeaturesFilePath = _pathe2.default.resolve(twDir, k0);
|
|
536
|
+
const processTailwindFeaturesContent = _fsextra2.default.readFileSync(processTailwindFeaturesFilePath, "utf8");
|
|
687
537
|
const result = {};
|
|
688
538
|
if (processTailwindFeaturesContent) {
|
|
689
539
|
const { code, hasPatched } = inspectProcessTailwindFeaturesReturnContext(processTailwindFeaturesContent);
|
|
690
540
|
if (!hasPatched && opt.overwrite) {
|
|
691
|
-
|
|
541
|
+
_fsextra2.default.writeFileSync(processTailwindFeaturesFilePath, code, {
|
|
692
542
|
encoding: "utf8"
|
|
693
543
|
});
|
|
694
544
|
logger_default.success("patch tailwindcss processTailwindFeatures for return content successfully!");
|
|
@@ -696,12 +546,12 @@ function monkeyPatchForExposingContextV2(twDir, opt) {
|
|
|
696
546
|
result[k0] = code;
|
|
697
547
|
}
|
|
698
548
|
const k1 = "lib/jit/index.js";
|
|
699
|
-
const indexFilePath =
|
|
700
|
-
const pluginContent =
|
|
549
|
+
const indexFilePath = _pathe2.default.resolve(twDir, k1);
|
|
550
|
+
const pluginContent = _fsextra2.default.readFileSync(indexFilePath, "utf8");
|
|
701
551
|
if (pluginContent) {
|
|
702
552
|
const { code, hasPatched } = inspectPostcssPlugin(pluginContent);
|
|
703
553
|
if (!hasPatched && opt.overwrite) {
|
|
704
|
-
|
|
554
|
+
_fsextra2.default.writeFileSync(indexFilePath, code, {
|
|
705
555
|
encoding: "utf8"
|
|
706
556
|
});
|
|
707
557
|
logger_default.success("patch tailwindcss for expose runtime content successfully!");
|
|
@@ -712,32 +562,32 @@ function monkeyPatchForExposingContextV2(twDir, opt) {
|
|
|
712
562
|
}
|
|
713
563
|
|
|
714
564
|
// src/core/patches/supportCustomUnits/index.ts
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
|
|
718
568
|
function findAstNode(content, options) {
|
|
719
569
|
const { variableName, units } = options;
|
|
720
|
-
const ast = (0,
|
|
570
|
+
const ast = _parser.parse.call(void 0, content);
|
|
721
571
|
let arrayRef;
|
|
722
572
|
let changed = false;
|
|
723
573
|
traverse(ast, {
|
|
724
|
-
Identifier(
|
|
725
|
-
if (
|
|
726
|
-
arrayRef =
|
|
727
|
-
const set = new Set(
|
|
574
|
+
Identifier(path7) {
|
|
575
|
+
if (path7.node.name === variableName && t3.isVariableDeclarator(path7.parent) && t3.isArrayExpression(path7.parent.init)) {
|
|
576
|
+
arrayRef = path7.parent.init;
|
|
577
|
+
const set = new Set(path7.parent.init.elements.map((x) => x.value));
|
|
728
578
|
for (let i = 0; i < units.length; i++) {
|
|
729
579
|
const unit = units[i];
|
|
730
580
|
if (!set.has(unit)) {
|
|
731
|
-
|
|
581
|
+
path7.parent.init.elements = path7.parent.init.elements.map((x) => {
|
|
732
582
|
if (t3.isStringLiteral(x)) {
|
|
733
583
|
return {
|
|
734
|
-
type: x
|
|
735
|
-
value: x
|
|
584
|
+
type: _optionalChain([x, 'optionalAccess', _15 => _15.type]),
|
|
585
|
+
value: _optionalChain([x, 'optionalAccess', _16 => _16.value])
|
|
736
586
|
};
|
|
737
587
|
}
|
|
738
588
|
return x;
|
|
739
589
|
});
|
|
740
|
-
|
|
590
|
+
path7.parent.init.elements.push({
|
|
741
591
|
type: "StringLiteral",
|
|
742
592
|
value: unit
|
|
743
593
|
});
|
|
@@ -760,8 +610,8 @@ function monkeyPatchForSupportingCustomUnit(rootDir, options) {
|
|
|
760
610
|
overwrite: true
|
|
761
611
|
});
|
|
762
612
|
const { lengthUnitsFilePath, overwrite, destPath } = opts;
|
|
763
|
-
const dataTypesFilePath =
|
|
764
|
-
const dataTypesFileContent =
|
|
613
|
+
const dataTypesFilePath = _pathe2.default.resolve(rootDir, lengthUnitsFilePath);
|
|
614
|
+
const dataTypesFileContent = _fsextra2.default.readFileSync(dataTypesFilePath, {
|
|
765
615
|
encoding: "utf8"
|
|
766
616
|
});
|
|
767
617
|
const { arrayRef, changed } = findAstNode(dataTypesFileContent, opts);
|
|
@@ -776,7 +626,7 @@ function monkeyPatchForSupportingCustomUnit(rootDir, options) {
|
|
|
776
626
|
const next = dataTypesFileContent.slice(arrayRef.end);
|
|
777
627
|
const newCode = prev + code + next;
|
|
778
628
|
if (overwrite) {
|
|
779
|
-
|
|
629
|
+
_fsextra2.default.writeFileSync(_nullishCoalesce(destPath, () => ( dataTypesFilePath)), newCode, {
|
|
780
630
|
encoding: "utf8"
|
|
781
631
|
});
|
|
782
632
|
logger_default.success("patch tailwindcss for custom length unit successfully!");
|
|
@@ -789,28 +639,31 @@ function monkeyPatchForSupportingCustomUnit(rootDir, options) {
|
|
|
789
639
|
}
|
|
790
640
|
|
|
791
641
|
// src/core/runtime.ts
|
|
792
|
-
var
|
|
642
|
+
var _module = require('module');
|
|
643
|
+
|
|
644
|
+
var _semver = require('semver');
|
|
645
|
+
var require2 = _module.createRequire.call(void 0, importMetaUrl);
|
|
793
646
|
function internalPatch(pkgJsonPath, options) {
|
|
794
647
|
if (pkgJsonPath) {
|
|
795
|
-
const pkgJson =
|
|
796
|
-
const twDir =
|
|
648
|
+
const pkgJson = require2(pkgJsonPath);
|
|
649
|
+
const twDir = _pathe2.default.dirname(pkgJsonPath);
|
|
797
650
|
options.version = pkgJson.version;
|
|
798
|
-
if ((0,
|
|
651
|
+
if (_semver.gte.call(void 0, pkgJson.version, "3.0.0")) {
|
|
799
652
|
let result = {};
|
|
800
|
-
if (options.applyPatches
|
|
653
|
+
if (_optionalChain([options, 'access', _17 => _17.applyPatches, 'optionalAccess', _18 => _18.exportContext])) {
|
|
801
654
|
result = monkeyPatchForExposingContextV3(twDir, options);
|
|
802
655
|
}
|
|
803
|
-
if (options.applyPatches
|
|
656
|
+
if (_optionalChain([options, 'access', _19 => _19.applyPatches, 'optionalAccess', _20 => _20.extendLengthUnits])) {
|
|
804
657
|
try {
|
|
805
|
-
Object.assign(result
|
|
658
|
+
Object.assign(_nullishCoalesce(result, () => ( {})), monkeyPatchForSupportingCustomUnit(twDir, defu(options.applyPatches.extendLengthUnits === true ? void 0 : options.applyPatches.extendLengthUnits, {
|
|
806
659
|
overwrite: options.overwrite
|
|
807
660
|
})));
|
|
808
|
-
} catch {
|
|
661
|
+
} catch (e5) {
|
|
809
662
|
}
|
|
810
663
|
}
|
|
811
664
|
return result;
|
|
812
|
-
} else if ((0,
|
|
813
|
-
if (options.applyPatches
|
|
665
|
+
} else if (_semver.gte.call(void 0, pkgJson.version, "2.0.0")) {
|
|
666
|
+
if (_optionalChain([options, 'access', _21 => _21.applyPatches, 'optionalAccess', _22 => _22.exportContext])) {
|
|
814
667
|
return monkeyPatchForExposingContextV2(twDir, options);
|
|
815
668
|
}
|
|
816
669
|
}
|
|
@@ -818,27 +671,125 @@ function internalPatch(pkgJsonPath, options) {
|
|
|
818
671
|
}
|
|
819
672
|
|
|
820
673
|
// src/core/patcher.ts
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
var _localpkg = require('local-pkg');
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
// src/utils.ts
|
|
681
|
+
function isObject(val) {
|
|
682
|
+
return val !== null && typeof val === "object" && Array.isArray(val) === false;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// src/core/candidates.ts
|
|
686
|
+
|
|
687
|
+
function importNode() {
|
|
688
|
+
return Promise.resolve().then(() => _interopRequireWildcard(require("@tailwindcss/node")));
|
|
689
|
+
}
|
|
690
|
+
function importOxide() {
|
|
691
|
+
return Promise.resolve().then(() => _interopRequireWildcard(require("@tailwindcss/oxide")));
|
|
692
|
+
}
|
|
693
|
+
async function extractRawCandidates(sources) {
|
|
694
|
+
const { Scanner } = await importOxide();
|
|
695
|
+
const scanner = new Scanner({
|
|
696
|
+
sources
|
|
697
|
+
});
|
|
698
|
+
const candidates = scanner.scan();
|
|
699
|
+
return candidates;
|
|
700
|
+
}
|
|
701
|
+
async function extractValidCandidates(options) {
|
|
702
|
+
const cwd = _process2.default.cwd();
|
|
703
|
+
const { sources, base, css } = defuOverrideArray(
|
|
704
|
+
// @ts-ignore
|
|
705
|
+
options,
|
|
706
|
+
{
|
|
707
|
+
css: '@import "tailwindcss";',
|
|
708
|
+
base: cwd,
|
|
709
|
+
sources: [
|
|
710
|
+
{
|
|
711
|
+
base: cwd,
|
|
712
|
+
pattern: "**/*"
|
|
713
|
+
}
|
|
714
|
+
]
|
|
715
|
+
}
|
|
716
|
+
);
|
|
717
|
+
const { __unstable__loadDesignSystem } = await importNode();
|
|
718
|
+
const designSystem = await __unstable__loadDesignSystem(css, { base });
|
|
719
|
+
const candidates = await extractRawCandidates(sources);
|
|
720
|
+
const validCandidates = candidates.filter(
|
|
721
|
+
(rawCandidate) => designSystem.parseCandidate(rawCandidate).length > 0
|
|
722
|
+
);
|
|
723
|
+
return validCandidates;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
// src/core/postcss.ts
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
|
|
730
|
+
var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);
|
|
731
|
+
var _tailwindcssconfig = require('tailwindcss-config');
|
|
732
|
+
var require3 = _module.createRequire.call(void 0, importMetaUrl);
|
|
733
|
+
async function processTailwindcss(options) {
|
|
734
|
+
const { config: userConfig, cwd, majorVersion, postcssPlugin } = defu(options, {
|
|
735
|
+
cwd: _process2.default.cwd(),
|
|
736
|
+
majorVersion: 3
|
|
737
|
+
});
|
|
738
|
+
let config = userConfig;
|
|
739
|
+
if (!(typeof config === "string" && _pathe2.default.isAbsolute(config))) {
|
|
740
|
+
const result = await _tailwindcssconfig.loadConfig.call(void 0, {
|
|
741
|
+
cwd
|
|
742
|
+
});
|
|
743
|
+
if (!result) {
|
|
744
|
+
throw new Error(`No TailwindCSS Config found in: ${cwd}`);
|
|
745
|
+
}
|
|
746
|
+
config = result.filepath;
|
|
747
|
+
}
|
|
748
|
+
const targetPostcssPlugin = _nullishCoalesce(postcssPlugin, () => ( (majorVersion === 4 ? "@tailwindcss/postcss" : "tailwindcss")));
|
|
749
|
+
if (majorVersion === 4) {
|
|
750
|
+
return await _postcss2.default.call(void 0, [
|
|
751
|
+
require3(targetPostcssPlugin)({
|
|
752
|
+
config
|
|
753
|
+
})
|
|
754
|
+
]).process("@import 'tailwindcss';", {
|
|
755
|
+
from: void 0
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
return await _postcss2.default.call(void 0, [
|
|
759
|
+
require3(targetPostcssPlugin)({
|
|
760
|
+
config
|
|
761
|
+
})
|
|
762
|
+
]).process("@tailwind base;@tailwind components;@tailwind utilities;", {
|
|
763
|
+
from: void 0
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
// src/core/patcher.ts
|
|
768
|
+
var require4 = _module.createRequire.call(void 0, importMetaUrl);
|
|
769
|
+
var TailwindcssPatcher = (_class = class {
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
constructor(options = {}) {;_class.prototype.__init.call(this);
|
|
831
778
|
this.rawOptions = options;
|
|
832
779
|
this.cacheOptions = getCacheOptions(options.cache);
|
|
833
780
|
this.patchOptions = getPatchOptions(options.patch);
|
|
834
781
|
this.cacheManager = new CacheManager(this.cacheOptions);
|
|
835
|
-
|
|
836
|
-
if (
|
|
837
|
-
|
|
782
|
+
const packageInfo = _localpkg.getPackageInfoSync.call(void 0, "tailwindcss");
|
|
783
|
+
if (!packageInfo) {
|
|
784
|
+
throw new Error("tailwindcss not found");
|
|
785
|
+
}
|
|
786
|
+
if (packageInfo.version) {
|
|
787
|
+
this.majorVersion = Number.parseInt(packageInfo.version[0]);
|
|
838
788
|
}
|
|
789
|
+
this.packageInfo = packageInfo;
|
|
839
790
|
this.patch = () => {
|
|
840
791
|
try {
|
|
841
|
-
return internalPatch(this.packageInfo
|
|
792
|
+
return internalPatch(_optionalChain([this, 'access', _23 => _23.packageInfo, 'optionalAccess', _24 => _24.packageJsonPath]), this.patchOptions);
|
|
842
793
|
} catch (error) {
|
|
843
794
|
logger_default.error(`patch tailwindcss failed: ${error.message}`);
|
|
844
795
|
}
|
|
@@ -854,14 +805,14 @@ var TailwindcssPatcher = class {
|
|
|
854
805
|
}
|
|
855
806
|
getContexts() {
|
|
856
807
|
if (this.packageInfo) {
|
|
857
|
-
const distPath =
|
|
808
|
+
const distPath = _pathe2.default.join(this.packageInfo.rootPath, "lib");
|
|
858
809
|
let injectFilePath;
|
|
859
810
|
if (this.majorVersion === 2) {
|
|
860
|
-
injectFilePath =
|
|
861
|
-
} else {
|
|
862
|
-
injectFilePath =
|
|
863
|
-
if (!
|
|
864
|
-
injectFilePath =
|
|
811
|
+
injectFilePath = _pathe2.default.join(distPath, "jit/index.js");
|
|
812
|
+
} else if (this.majorVersion === 3) {
|
|
813
|
+
injectFilePath = _pathe2.default.join(distPath, "plugin.js");
|
|
814
|
+
if (!_fsextra2.default.existsSync(injectFilePath)) {
|
|
815
|
+
injectFilePath = _pathe2.default.join(distPath, "index.js");
|
|
865
816
|
}
|
|
866
817
|
}
|
|
867
818
|
if (injectFilePath) {
|
|
@@ -877,17 +828,62 @@ var TailwindcssPatcher = class {
|
|
|
877
828
|
const contexts = this.getContexts();
|
|
878
829
|
return contexts.filter((x) => isObject(x)).map((x) => x.classCache);
|
|
879
830
|
}
|
|
880
|
-
getClassCacheSet(
|
|
881
|
-
const classCaches = this.getClassCaches();
|
|
831
|
+
async getClassCacheSet() {
|
|
882
832
|
const classSet = /* @__PURE__ */ new Set();
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
833
|
+
const { output, tailwindcss } = this.patchOptions;
|
|
834
|
+
if (this.majorVersion === 4) {
|
|
835
|
+
const { v4 } = _nullishCoalesce(tailwindcss, () => ( {}));
|
|
836
|
+
if (Array.isArray(_optionalChain([v4, 'optionalAccess', _25 => _25.cssEntries]))) {
|
|
837
|
+
const results = (await Promise.all(
|
|
838
|
+
v4.cssEntries.map(async (x) => {
|
|
839
|
+
if (await _fsextra2.default.exists(x)) {
|
|
840
|
+
const css = await _fsextra2.default.readFile(x, "utf8");
|
|
841
|
+
return css;
|
|
842
|
+
}
|
|
843
|
+
return false;
|
|
844
|
+
})
|
|
845
|
+
)).filter((x) => x);
|
|
846
|
+
for (const css of results) {
|
|
847
|
+
const candidates = await extractValidCandidates({
|
|
848
|
+
base: _optionalChain([v4, 'optionalAccess', _26 => _26.base]),
|
|
849
|
+
css,
|
|
850
|
+
sources: _optionalChain([v4, 'optionalAccess', _27 => _27.sources, 'optionalAccess', _28 => _28.map, 'call', _29 => _29((x) => {
|
|
851
|
+
return {
|
|
852
|
+
base: _nullishCoalesce(_nullishCoalesce(x.base, () => ( _optionalChain([v4, 'optionalAccess', _30 => _30.base]))), () => ( _process2.default.cwd())),
|
|
853
|
+
pattern: x.pattern
|
|
854
|
+
};
|
|
855
|
+
})])
|
|
856
|
+
});
|
|
857
|
+
for (const candidate of candidates) {
|
|
858
|
+
classSet.add(candidate);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
} else {
|
|
862
|
+
const candidates = await extractValidCandidates({
|
|
863
|
+
base: _optionalChain([v4, 'optionalAccess', _31 => _31.base]),
|
|
864
|
+
css: _optionalChain([v4, 'optionalAccess', _32 => _32.css]),
|
|
865
|
+
sources: _optionalChain([v4, 'optionalAccess', _33 => _33.sources, 'optionalAccess', _34 => _34.map, 'call', _35 => _35((x) => {
|
|
866
|
+
return {
|
|
867
|
+
base: _nullishCoalesce(_nullishCoalesce(x.base, () => ( _optionalChain([v4, 'optionalAccess', _36 => _36.base]))), () => ( _process2.default.cwd())),
|
|
868
|
+
pattern: x.pattern
|
|
869
|
+
};
|
|
870
|
+
})])
|
|
871
|
+
});
|
|
872
|
+
for (const candidate of candidates) {
|
|
873
|
+
classSet.add(candidate);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
} else {
|
|
877
|
+
const classCaches = this.getClassCaches();
|
|
878
|
+
for (const classCacheMap of classCaches) {
|
|
879
|
+
const keys = classCacheMap.keys();
|
|
880
|
+
for (const key of keys) {
|
|
881
|
+
const v = key.toString();
|
|
882
|
+
if (_optionalChain([output, 'optionalAccess', _37 => _37.removeUniversalSelector]) && v === "*") {
|
|
883
|
+
continue;
|
|
884
|
+
}
|
|
885
|
+
classSet.add(v);
|
|
889
886
|
}
|
|
890
|
-
classSet.add(v);
|
|
891
887
|
}
|
|
892
888
|
}
|
|
893
889
|
return classSet;
|
|
@@ -895,15 +891,13 @@ var TailwindcssPatcher = class {
|
|
|
895
891
|
/**
|
|
896
892
|
* @description 在多个 tailwindcss 上下文时,这个方法将被执行多次,所以策略上应该使用 append
|
|
897
893
|
*/
|
|
898
|
-
getClassSet(
|
|
899
|
-
const
|
|
900
|
-
const set = this.getClassCacheSet(
|
|
901
|
-
removeUniversalSelector
|
|
902
|
-
});
|
|
894
|
+
async getClassSet() {
|
|
895
|
+
const cacheStrategy = _nullishCoalesce(this.cacheOptions.strategy, () => ( "merge"));
|
|
896
|
+
const set = await this.getClassCacheSet();
|
|
903
897
|
if (cacheStrategy === "overwrite") {
|
|
904
898
|
set.size > 0 && this.setCache(set);
|
|
905
899
|
} else if (cacheStrategy === "merge") {
|
|
906
|
-
const cacheSet = this.getCache();
|
|
900
|
+
const cacheSet = await this.getCache();
|
|
907
901
|
if (cacheSet) {
|
|
908
902
|
for (const x of cacheSet) {
|
|
909
903
|
set.add(x);
|
|
@@ -914,48 +908,36 @@ var TailwindcssPatcher = class {
|
|
|
914
908
|
return set;
|
|
915
909
|
}
|
|
916
910
|
async extract(options) {
|
|
917
|
-
const { output, tailwindcss } = options
|
|
911
|
+
const { output, tailwindcss } = _nullishCoalesce(options, () => ( {}));
|
|
918
912
|
if (output && tailwindcss) {
|
|
919
|
-
const {
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
913
|
+
const { filename, loose } = output;
|
|
914
|
+
if (this.majorVersion === 3) {
|
|
915
|
+
await processTailwindcss({
|
|
916
|
+
...tailwindcss,
|
|
917
|
+
majorVersion: this.majorVersion
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
const set = await this.getClassSet();
|
|
924
921
|
if (filename) {
|
|
925
|
-
await import_fs_extra5.default.ensureDir(import_pathe7.default.dirname(filename));
|
|
926
922
|
const classList = [...set];
|
|
927
|
-
await
|
|
923
|
+
await _fsextra2.default.outputJSON(filename, classList, {
|
|
928
924
|
spaces: loose ? 2 : void 0
|
|
929
925
|
});
|
|
930
926
|
return filename;
|
|
931
927
|
}
|
|
932
928
|
}
|
|
933
929
|
}
|
|
934
|
-
}
|
|
930
|
+
__init() {this.extractValidCandidates = extractValidCandidates}
|
|
931
|
+
}, _class);
|
|
935
932
|
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
});
|
|
948
|
-
cli.command("init").action(async () => {
|
|
949
|
-
await init();
|
|
950
|
-
logger_default.success(`\u2728 ${config_exports.configName}.config.ts initialized!`);
|
|
951
|
-
});
|
|
952
|
-
cli.command("extract").action(async () => {
|
|
953
|
-
const { config } = await (0, config_exports.getConfig)();
|
|
954
|
-
if (config) {
|
|
955
|
-
const twPatcher = new TailwindcssPatcher();
|
|
956
|
-
const p = await twPatcher.extract(config.patch);
|
|
957
|
-
logger_default.success(`\u2728 tailwindcss-patch extract success! file path: ${p}`);
|
|
958
|
-
}
|
|
959
|
-
});
|
|
960
|
-
cli.help();
|
|
961
|
-
cli.parse();
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
|
|
943
|
+
exports.logger_default = logger_default; exports.getCacheOptions = getCacheOptions; exports.CacheManager = CacheManager; exports.getPatchOptions = getPatchOptions; exports.monkeyPatchForExposingContextV3 = monkeyPatchForExposingContextV3; exports.monkeyPatchForExposingContextV2 = monkeyPatchForExposingContextV2; exports.monkeyPatchForSupportingCustomUnit = monkeyPatchForSupportingCustomUnit; exports.internalPatch = internalPatch; exports.TailwindcssPatcher = TailwindcssPatcher;
|