tailwindcss-patch 5.0.2 → 6.0.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/README.md +5 -2
- package/bin/tw-patch.js +1 -1
- package/dist/{chunk-LOQK6LST.js → chunk-AZHCF3SW.mjs} +155 -135
- package/dist/{cli.cjs → chunk-P7C42UCO.js} +287 -297
- package/dist/cli.js +17 -17
- package/dist/cli.mjs +35 -0
- package/dist/{index.d.cts → index.d.mts} +17 -13
- package/dist/index.d.ts +17 -13
- 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,
|
|
@@ -92,38 +59,33 @@ var CacheManager = class {
|
|
|
92
59
|
write(data) {
|
|
93
60
|
try {
|
|
94
61
|
const { dir, filename } = this.options;
|
|
95
|
-
|
|
96
|
-
|
|
62
|
+
_fsextra2.default.ensureDirSync(dir);
|
|
63
|
+
_fsextra2.default.outputFileSync(filename, JSON.stringify([...data], void 0, 2), "utf8");
|
|
97
64
|
return filename;
|
|
98
|
-
} catch {
|
|
65
|
+
} catch (e2) {
|
|
99
66
|
logger_default.error("write cache file fail!");
|
|
100
67
|
}
|
|
101
68
|
}
|
|
102
69
|
read() {
|
|
103
70
|
const { filename } = this.options;
|
|
104
71
|
try {
|
|
105
|
-
if (
|
|
106
|
-
const data =
|
|
72
|
+
if (_fsextra2.default.existsSync(filename)) {
|
|
73
|
+
const data = _fsextra2.default.readFileSync(filename, "utf8");
|
|
107
74
|
return new Set(JSON.parse(data));
|
|
108
75
|
}
|
|
109
|
-
} catch {
|
|
76
|
+
} catch (e3) {
|
|
110
77
|
logger_default.error(`parse cache content fail! path:${filename}`);
|
|
111
78
|
try {
|
|
112
|
-
|
|
113
|
-
} catch {
|
|
79
|
+
_fsextra2.default.unlinkSync(filename);
|
|
80
|
+
} catch (e4) {
|
|
114
81
|
logger_default.error(`delete cache file fail! path:${filename}`);
|
|
115
82
|
}
|
|
116
83
|
}
|
|
117
84
|
}
|
|
118
85
|
};
|
|
119
86
|
|
|
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
87
|
// src/defaults.ts
|
|
126
|
-
|
|
88
|
+
|
|
127
89
|
|
|
128
90
|
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
129
91
|
function isPlainObject(value) {
|
|
@@ -229,150 +191,39 @@ function getPatchOptions(options) {
|
|
|
229
191
|
return defu(
|
|
230
192
|
options,
|
|
231
193
|
{
|
|
232
|
-
basedir:
|
|
194
|
+
basedir: _process2.default.cwd()
|
|
233
195
|
},
|
|
234
196
|
getDefaultPatchOptions()
|
|
235
197
|
);
|
|
236
198
|
}
|
|
237
199
|
|
|
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
|
-
}
|
|
200
|
+
// src/core/patches/exportContext/index.ts
|
|
343
201
|
|
|
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
202
|
|
|
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
203
|
|
|
353
204
|
// src/core/patches/exportContext/postcss-v2.ts
|
|
354
|
-
var
|
|
205
|
+
var _types = require('@babel/types'); var t = _interopRequireWildcard(_types); var t2 = _interopRequireWildcard(_types); var t3 = _interopRequireWildcard(_types);
|
|
355
206
|
|
|
356
207
|
// src/babel/index.ts
|
|
357
|
-
var
|
|
358
|
-
var
|
|
359
|
-
var
|
|
208
|
+
var _generator = require('@babel/generator'); var _generator2 = _interopRequireDefault(_generator);
|
|
209
|
+
var _traverse = require('@babel/traverse'); var _traverse2 = _interopRequireDefault(_traverse);
|
|
210
|
+
var _parser = require('@babel/parser');
|
|
360
211
|
function _interopDefaultCompat(e) {
|
|
361
212
|
return e && typeof e === "object" && "default" in e ? e.default : e;
|
|
362
213
|
}
|
|
363
|
-
var generate = _interopDefaultCompat(
|
|
364
|
-
var traverse = _interopDefaultCompat(
|
|
214
|
+
var generate = _interopDefaultCompat(_generator2.default);
|
|
215
|
+
var traverse = _interopDefaultCompat(_traverse2.default);
|
|
365
216
|
|
|
366
217
|
// src/core/patches/exportContext/postcss-v2.ts
|
|
367
218
|
function inspectProcessTailwindFeaturesReturnContext(content) {
|
|
368
|
-
const ast = (0,
|
|
219
|
+
const ast = _parser.parse.call(void 0, content, {
|
|
369
220
|
sourceType: "unambiguous"
|
|
370
221
|
});
|
|
371
222
|
let hasPatched = false;
|
|
372
223
|
traverse(ast, {
|
|
373
224
|
FunctionDeclaration(p) {
|
|
374
225
|
const n = p.node;
|
|
375
|
-
if (n.id
|
|
226
|
+
if (_optionalChain([n, 'access', _ => _.id, 'optionalAccess', _2 => _2.name]) === "processTailwindFeatures" && n.body.body.length === 1 && t.isReturnStatement(n.body.body[0])) {
|
|
376
227
|
const rts = n.body.body[0];
|
|
377
228
|
if (t.isFunctionExpression(rts.argument)) {
|
|
378
229
|
const body = rts.argument.body.body;
|
|
@@ -392,7 +243,7 @@ function inspectProcessTailwindFeaturesReturnContext(content) {
|
|
|
392
243
|
};
|
|
393
244
|
}
|
|
394
245
|
function inspectPostcssPlugin(content) {
|
|
395
|
-
const ast = (0,
|
|
246
|
+
const ast = _parser.parse.call(void 0, content);
|
|
396
247
|
const exportKey = "contextRef";
|
|
397
248
|
const variableName = "contextRef";
|
|
398
249
|
const valueKey = "value";
|
|
@@ -401,7 +252,7 @@ function inspectPostcssPlugin(content) {
|
|
|
401
252
|
Program(p) {
|
|
402
253
|
const n = p.node;
|
|
403
254
|
const idx = n.body.findIndex((x) => {
|
|
404
|
-
return t.isFunctionDeclaration(x) && x.id
|
|
255
|
+
return t.isFunctionDeclaration(x) && _optionalChain([x, 'access', _3 => _3.id, 'optionalAccess', _4 => _4.name]) === "_default";
|
|
405
256
|
});
|
|
406
257
|
if (idx > -1) {
|
|
407
258
|
const prevStatement = n.body[idx - 1];
|
|
@@ -434,7 +285,7 @@ function inspectPostcssPlugin(content) {
|
|
|
434
285
|
return;
|
|
435
286
|
}
|
|
436
287
|
const n = p.node;
|
|
437
|
-
if (n.id
|
|
288
|
+
if (_optionalChain([n, 'access', _5 => _5.id, 'optionalAccess', _6 => _6.name]) === "_default" && n.body.body.length === 1 && t.isReturnStatement(n.body.body[0])) {
|
|
438
289
|
const returnStatement3 = n.body.body[0];
|
|
439
290
|
if (t.isCallExpression(returnStatement3.argument) && t.isMemberExpression(returnStatement3.argument.callee) && t.isArrayExpression(returnStatement3.argument.callee.object)) {
|
|
440
291
|
const targetFn = returnStatement3.argument.callee.object.elements[1];
|
|
@@ -498,14 +349,14 @@ function inspectPostcssPlugin(content) {
|
|
|
498
349
|
}
|
|
499
350
|
|
|
500
351
|
// src/core/patches/exportContext/postcss-v3.ts
|
|
501
|
-
|
|
352
|
+
|
|
502
353
|
function inspectProcessTailwindFeaturesReturnContext2(content) {
|
|
503
|
-
const ast = (0,
|
|
354
|
+
const ast = _parser.parse.call(void 0, content);
|
|
504
355
|
let hasPatched = false;
|
|
505
356
|
traverse(ast, {
|
|
506
357
|
FunctionDeclaration(p) {
|
|
507
358
|
const n = p.node;
|
|
508
|
-
if (n.id
|
|
359
|
+
if (_optionalChain([n, 'access', _7 => _7.id, 'optionalAccess', _8 => _8.name]) === "processTailwindFeatures" && n.body.body.length === 1 && t2.isReturnStatement(n.body.body[0])) {
|
|
509
360
|
const rts = n.body.body[0];
|
|
510
361
|
if (t2.isFunctionExpression(rts.argument)) {
|
|
511
362
|
const body = rts.argument.body.body;
|
|
@@ -525,7 +376,7 @@ function inspectProcessTailwindFeaturesReturnContext2(content) {
|
|
|
525
376
|
};
|
|
526
377
|
}
|
|
527
378
|
function inspectPostcssPlugin2(content) {
|
|
528
|
-
const ast = (0,
|
|
379
|
+
const ast = _parser.parse.call(void 0, content);
|
|
529
380
|
const exportKey = "contextRef";
|
|
530
381
|
const variableName = "contextRef";
|
|
531
382
|
const valueKey = "value";
|
|
@@ -534,7 +385,7 @@ function inspectPostcssPlugin2(content) {
|
|
|
534
385
|
Program(p) {
|
|
535
386
|
const n = p.node;
|
|
536
387
|
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
|
|
388
|
+
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
389
|
});
|
|
539
390
|
if (idx > -1) {
|
|
540
391
|
const prevStatement = n.body[idx - 1];
|
|
@@ -564,7 +415,7 @@ function inspectPostcssPlugin2(content) {
|
|
|
564
415
|
return;
|
|
565
416
|
}
|
|
566
417
|
const n = p.node;
|
|
567
|
-
if (n.id
|
|
418
|
+
if (_optionalChain([n, 'access', _13 => _13.id, 'optionalAccess', _14 => _14.name]) === "tailwindcss" && n.body.body.length === 1 && t2.isReturnStatement(n.body.body[0])) {
|
|
568
419
|
const returnStatement3 = n.body.body[0];
|
|
569
420
|
if (t2.isObjectExpression(returnStatement3.argument) && returnStatement3.argument.properties.length === 2) {
|
|
570
421
|
const properties = returnStatement3.argument.properties;
|
|
@@ -639,13 +490,13 @@ function inspectPostcssPlugin2(content) {
|
|
|
639
490
|
// src/core/patches/exportContext/index.ts
|
|
640
491
|
function monkeyPatchForExposingContextV3(twDir, opt) {
|
|
641
492
|
const k0 = "lib/processTailwindFeatures.js";
|
|
642
|
-
const processTailwindFeaturesFilePath =
|
|
643
|
-
const processTailwindFeaturesContent =
|
|
493
|
+
const processTailwindFeaturesFilePath = _pathe2.default.resolve(twDir, k0);
|
|
494
|
+
const processTailwindFeaturesContent = _fsextra2.default.readFileSync(processTailwindFeaturesFilePath, "utf8");
|
|
644
495
|
const result = {};
|
|
645
496
|
if (processTailwindFeaturesContent) {
|
|
646
497
|
const { code, hasPatched } = inspectProcessTailwindFeaturesReturnContext2(processTailwindFeaturesContent);
|
|
647
498
|
if (!hasPatched && opt.overwrite) {
|
|
648
|
-
|
|
499
|
+
_fsextra2.default.writeFileSync(processTailwindFeaturesFilePath, code, {
|
|
649
500
|
encoding: "utf8"
|
|
650
501
|
});
|
|
651
502
|
logger_default.success("patch tailwindcss processTailwindFeatures for return context successfully!");
|
|
@@ -656,21 +507,21 @@ function monkeyPatchForExposingContextV3(twDir, opt) {
|
|
|
656
507
|
let k1;
|
|
657
508
|
const try0 = "lib/plugin.js";
|
|
658
509
|
const try1 = "lib/index.js";
|
|
659
|
-
const pluginFilePath =
|
|
660
|
-
const indexFilePath =
|
|
661
|
-
if (
|
|
510
|
+
const pluginFilePath = _pathe2.default.resolve(twDir, try0);
|
|
511
|
+
const indexFilePath = _pathe2.default.resolve(twDir, try1);
|
|
512
|
+
if (_fsextra2.default.existsSync(pluginFilePath)) {
|
|
662
513
|
k1 = try0;
|
|
663
514
|
injectFilepath = pluginFilePath;
|
|
664
|
-
} else if (
|
|
515
|
+
} else if (_fsextra2.default.existsSync(indexFilePath)) {
|
|
665
516
|
k1 = try1;
|
|
666
517
|
injectFilepath = indexFilePath;
|
|
667
518
|
}
|
|
668
519
|
if (injectFilepath && k1) {
|
|
669
|
-
const pluginContent =
|
|
520
|
+
const pluginContent = _fsextra2.default.readFileSync(injectFilepath, "utf8");
|
|
670
521
|
if (pluginContent) {
|
|
671
522
|
const { code, hasPatched } = inspectPostcssPlugin2(pluginContent);
|
|
672
523
|
if (!hasPatched && opt.overwrite) {
|
|
673
|
-
|
|
524
|
+
_fsextra2.default.writeFileSync(injectFilepath, code, {
|
|
674
525
|
encoding: "utf8"
|
|
675
526
|
});
|
|
676
527
|
logger_default.success("patch tailwindcss for expose runtime context successfully!");
|
|
@@ -682,13 +533,13 @@ function monkeyPatchForExposingContextV3(twDir, opt) {
|
|
|
682
533
|
}
|
|
683
534
|
function monkeyPatchForExposingContextV2(twDir, opt) {
|
|
684
535
|
const k0 = "lib/jit/processTailwindFeatures.js";
|
|
685
|
-
const processTailwindFeaturesFilePath =
|
|
686
|
-
const processTailwindFeaturesContent =
|
|
536
|
+
const processTailwindFeaturesFilePath = _pathe2.default.resolve(twDir, k0);
|
|
537
|
+
const processTailwindFeaturesContent = _fsextra2.default.readFileSync(processTailwindFeaturesFilePath, "utf8");
|
|
687
538
|
const result = {};
|
|
688
539
|
if (processTailwindFeaturesContent) {
|
|
689
540
|
const { code, hasPatched } = inspectProcessTailwindFeaturesReturnContext(processTailwindFeaturesContent);
|
|
690
541
|
if (!hasPatched && opt.overwrite) {
|
|
691
|
-
|
|
542
|
+
_fsextra2.default.writeFileSync(processTailwindFeaturesFilePath, code, {
|
|
692
543
|
encoding: "utf8"
|
|
693
544
|
});
|
|
694
545
|
logger_default.success("patch tailwindcss processTailwindFeatures for return content successfully!");
|
|
@@ -696,12 +547,12 @@ function monkeyPatchForExposingContextV2(twDir, opt) {
|
|
|
696
547
|
result[k0] = code;
|
|
697
548
|
}
|
|
698
549
|
const k1 = "lib/jit/index.js";
|
|
699
|
-
const indexFilePath =
|
|
700
|
-
const pluginContent =
|
|
550
|
+
const indexFilePath = _pathe2.default.resolve(twDir, k1);
|
|
551
|
+
const pluginContent = _fsextra2.default.readFileSync(indexFilePath, "utf8");
|
|
701
552
|
if (pluginContent) {
|
|
702
553
|
const { code, hasPatched } = inspectPostcssPlugin(pluginContent);
|
|
703
554
|
if (!hasPatched && opt.overwrite) {
|
|
704
|
-
|
|
555
|
+
_fsextra2.default.writeFileSync(indexFilePath, code, {
|
|
705
556
|
encoding: "utf8"
|
|
706
557
|
});
|
|
707
558
|
logger_default.success("patch tailwindcss for expose runtime content successfully!");
|
|
@@ -712,32 +563,32 @@ function monkeyPatchForExposingContextV2(twDir, opt) {
|
|
|
712
563
|
}
|
|
713
564
|
|
|
714
565
|
// src/core/patches/supportCustomUnits/index.ts
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
|
|
718
569
|
function findAstNode(content, options) {
|
|
719
570
|
const { variableName, units } = options;
|
|
720
|
-
const ast = (0,
|
|
571
|
+
const ast = _parser.parse.call(void 0, content);
|
|
721
572
|
let arrayRef;
|
|
722
573
|
let changed = false;
|
|
723
574
|
traverse(ast, {
|
|
724
|
-
Identifier(
|
|
725
|
-
if (
|
|
726
|
-
arrayRef =
|
|
727
|
-
const set = new Set(
|
|
575
|
+
Identifier(path7) {
|
|
576
|
+
if (path7.node.name === variableName && t3.isVariableDeclarator(path7.parent) && t3.isArrayExpression(path7.parent.init)) {
|
|
577
|
+
arrayRef = path7.parent.init;
|
|
578
|
+
const set = new Set(path7.parent.init.elements.map((x) => x.value));
|
|
728
579
|
for (let i = 0; i < units.length; i++) {
|
|
729
580
|
const unit = units[i];
|
|
730
581
|
if (!set.has(unit)) {
|
|
731
|
-
|
|
582
|
+
path7.parent.init.elements = path7.parent.init.elements.map((x) => {
|
|
732
583
|
if (t3.isStringLiteral(x)) {
|
|
733
584
|
return {
|
|
734
|
-
type: x
|
|
735
|
-
value: x
|
|
585
|
+
type: _optionalChain([x, 'optionalAccess', _15 => _15.type]),
|
|
586
|
+
value: _optionalChain([x, 'optionalAccess', _16 => _16.value])
|
|
736
587
|
};
|
|
737
588
|
}
|
|
738
589
|
return x;
|
|
739
590
|
});
|
|
740
|
-
|
|
591
|
+
path7.parent.init.elements.push({
|
|
741
592
|
type: "StringLiteral",
|
|
742
593
|
value: unit
|
|
743
594
|
});
|
|
@@ -760,8 +611,8 @@ function monkeyPatchForSupportingCustomUnit(rootDir, options) {
|
|
|
760
611
|
overwrite: true
|
|
761
612
|
});
|
|
762
613
|
const { lengthUnitsFilePath, overwrite, destPath } = opts;
|
|
763
|
-
const dataTypesFilePath =
|
|
764
|
-
const dataTypesFileContent =
|
|
614
|
+
const dataTypesFilePath = _pathe2.default.resolve(rootDir, lengthUnitsFilePath);
|
|
615
|
+
const dataTypesFileContent = _fsextra2.default.readFileSync(dataTypesFilePath, {
|
|
765
616
|
encoding: "utf8"
|
|
766
617
|
});
|
|
767
618
|
const { arrayRef, changed } = findAstNode(dataTypesFileContent, opts);
|
|
@@ -776,7 +627,7 @@ function monkeyPatchForSupportingCustomUnit(rootDir, options) {
|
|
|
776
627
|
const next = dataTypesFileContent.slice(arrayRef.end);
|
|
777
628
|
const newCode = prev + code + next;
|
|
778
629
|
if (overwrite) {
|
|
779
|
-
|
|
630
|
+
_fsextra2.default.writeFileSync(_nullishCoalesce(destPath, () => ( dataTypesFilePath)), newCode, {
|
|
780
631
|
encoding: "utf8"
|
|
781
632
|
});
|
|
782
633
|
logger_default.success("patch tailwindcss for custom length unit successfully!");
|
|
@@ -789,28 +640,31 @@ function monkeyPatchForSupportingCustomUnit(rootDir, options) {
|
|
|
789
640
|
}
|
|
790
641
|
|
|
791
642
|
// src/core/runtime.ts
|
|
792
|
-
var
|
|
643
|
+
var _module = require('module');
|
|
644
|
+
|
|
645
|
+
var _semver = require('semver');
|
|
646
|
+
var require2 = _module.createRequire.call(void 0, importMetaUrl);
|
|
793
647
|
function internalPatch(pkgJsonPath, options) {
|
|
794
648
|
if (pkgJsonPath) {
|
|
795
|
-
const pkgJson =
|
|
796
|
-
const twDir =
|
|
649
|
+
const pkgJson = require2(pkgJsonPath);
|
|
650
|
+
const twDir = _pathe2.default.dirname(pkgJsonPath);
|
|
797
651
|
options.version = pkgJson.version;
|
|
798
|
-
if ((0,
|
|
652
|
+
if (_semver.gte.call(void 0, pkgJson.version, "3.0.0")) {
|
|
799
653
|
let result = {};
|
|
800
|
-
if (options.applyPatches
|
|
654
|
+
if (_optionalChain([options, 'access', _17 => _17.applyPatches, 'optionalAccess', _18 => _18.exportContext])) {
|
|
801
655
|
result = monkeyPatchForExposingContextV3(twDir, options);
|
|
802
656
|
}
|
|
803
|
-
if (options.applyPatches
|
|
657
|
+
if (_optionalChain([options, 'access', _19 => _19.applyPatches, 'optionalAccess', _20 => _20.extendLengthUnits])) {
|
|
804
658
|
try {
|
|
805
|
-
Object.assign(result
|
|
659
|
+
Object.assign(_nullishCoalesce(result, () => ( {})), monkeyPatchForSupportingCustomUnit(twDir, defu(options.applyPatches.extendLengthUnits === true ? void 0 : options.applyPatches.extendLengthUnits, {
|
|
806
660
|
overwrite: options.overwrite
|
|
807
661
|
})));
|
|
808
|
-
} catch {
|
|
662
|
+
} catch (e5) {
|
|
809
663
|
}
|
|
810
664
|
}
|
|
811
665
|
return result;
|
|
812
|
-
} else if ((0,
|
|
813
|
-
if (options.applyPatches
|
|
666
|
+
} else if (_semver.gte.call(void 0, pkgJson.version, "2.0.0")) {
|
|
667
|
+
if (_optionalChain([options, 'access', _21 => _21.applyPatches, 'optionalAccess', _22 => _22.exportContext])) {
|
|
814
668
|
return monkeyPatchForExposingContextV2(twDir, options);
|
|
815
669
|
}
|
|
816
670
|
}
|
|
@@ -818,27 +672,125 @@ function internalPatch(pkgJsonPath, options) {
|
|
|
818
672
|
}
|
|
819
673
|
|
|
820
674
|
// src/core/patcher.ts
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
var _localpkg = require('local-pkg');
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
// src/utils.ts
|
|
682
|
+
function isObject(val) {
|
|
683
|
+
return val !== null && typeof val === "object" && Array.isArray(val) === false;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
// src/core/candidates.ts
|
|
687
|
+
|
|
688
|
+
function importNode() {
|
|
689
|
+
return Promise.resolve().then(() => _interopRequireWildcard(require("@tailwindcss/node")));
|
|
690
|
+
}
|
|
691
|
+
function importOxide() {
|
|
692
|
+
return Promise.resolve().then(() => _interopRequireWildcard(require("@tailwindcss/oxide")));
|
|
693
|
+
}
|
|
694
|
+
async function extractRawCandidates(sources) {
|
|
695
|
+
const { Scanner } = await importOxide();
|
|
696
|
+
const scanner = new Scanner({
|
|
697
|
+
sources
|
|
698
|
+
});
|
|
699
|
+
const candidates = scanner.scan();
|
|
700
|
+
return candidates;
|
|
701
|
+
}
|
|
702
|
+
async function extractValidCandidates(options) {
|
|
703
|
+
const cwd = _process2.default.cwd();
|
|
704
|
+
const { sources, base, css } = defuOverrideArray(
|
|
705
|
+
// @ts-ignore
|
|
706
|
+
options,
|
|
707
|
+
{
|
|
708
|
+
css: '@import "tailwindcss";',
|
|
709
|
+
base: cwd,
|
|
710
|
+
sources: [
|
|
711
|
+
{
|
|
712
|
+
base: cwd,
|
|
713
|
+
pattern: "**/*"
|
|
714
|
+
}
|
|
715
|
+
]
|
|
716
|
+
}
|
|
717
|
+
);
|
|
718
|
+
const { __unstable__loadDesignSystem } = await importNode();
|
|
719
|
+
const designSystem = await __unstable__loadDesignSystem(css, { base });
|
|
720
|
+
const candidates = await extractRawCandidates(sources);
|
|
721
|
+
const validCandidates = candidates.filter(
|
|
722
|
+
(rawCandidate) => designSystem.parseCandidate(rawCandidate).length > 0
|
|
723
|
+
);
|
|
724
|
+
return validCandidates;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// src/core/postcss.ts
|
|
728
|
+
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);
|
|
732
|
+
var _tailwindcssconfig = require('tailwindcss-config');
|
|
733
|
+
var require3 = _module.createRequire.call(void 0, importMetaUrl);
|
|
734
|
+
async function processTailwindcss(options) {
|
|
735
|
+
const { config: userConfig, cwd, majorVersion, postcssPlugin } = defu(options, {
|
|
736
|
+
cwd: _process2.default.cwd(),
|
|
737
|
+
majorVersion: 3
|
|
738
|
+
});
|
|
739
|
+
let config = userConfig;
|
|
740
|
+
if (!(typeof config === "string" && _pathe2.default.isAbsolute(config))) {
|
|
741
|
+
const result = await _tailwindcssconfig.loadConfig.call(void 0, {
|
|
742
|
+
cwd
|
|
743
|
+
});
|
|
744
|
+
if (!result) {
|
|
745
|
+
throw new Error(`No TailwindCSS Config found in: ${cwd}`);
|
|
746
|
+
}
|
|
747
|
+
config = result.filepath;
|
|
748
|
+
}
|
|
749
|
+
const targetPostcssPlugin = _nullishCoalesce(postcssPlugin, () => ( (majorVersion === 4 ? "@tailwindcss/postcss" : "tailwindcss")));
|
|
750
|
+
if (majorVersion === 4) {
|
|
751
|
+
return await _postcss2.default.call(void 0, [
|
|
752
|
+
require3(targetPostcssPlugin)({
|
|
753
|
+
config
|
|
754
|
+
})
|
|
755
|
+
]).process("@import 'tailwindcss';", {
|
|
756
|
+
from: void 0
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
return await _postcss2.default.call(void 0, [
|
|
760
|
+
require3(targetPostcssPlugin)({
|
|
761
|
+
config
|
|
762
|
+
})
|
|
763
|
+
]).process("@tailwind base;@tailwind components;@tailwind utilities;", {
|
|
764
|
+
from: void 0
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
// src/core/patcher.ts
|
|
769
|
+
var require4 = _module.createRequire.call(void 0, importMetaUrl);
|
|
770
|
+
var TailwindcssPatcher = (_class = class {
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
constructor(options = {}) {;_class.prototype.__init.call(this);
|
|
831
779
|
this.rawOptions = options;
|
|
832
780
|
this.cacheOptions = getCacheOptions(options.cache);
|
|
833
781
|
this.patchOptions = getPatchOptions(options.patch);
|
|
834
782
|
this.cacheManager = new CacheManager(this.cacheOptions);
|
|
835
|
-
|
|
836
|
-
if (
|
|
837
|
-
|
|
783
|
+
const packageInfo = _localpkg.getPackageInfoSync.call(void 0, "tailwindcss");
|
|
784
|
+
if (!packageInfo) {
|
|
785
|
+
throw new Error("tailwindcss not found");
|
|
838
786
|
}
|
|
787
|
+
if (packageInfo.version) {
|
|
788
|
+
this.majorVersion = Number.parseInt(packageInfo.version[0]);
|
|
789
|
+
}
|
|
790
|
+
this.packageInfo = packageInfo;
|
|
839
791
|
this.patch = () => {
|
|
840
792
|
try {
|
|
841
|
-
return internalPatch(this.packageInfo
|
|
793
|
+
return internalPatch(_optionalChain([this, 'access', _23 => _23.packageInfo, 'optionalAccess', _24 => _24.packageJsonPath]), this.patchOptions);
|
|
842
794
|
} catch (error) {
|
|
843
795
|
logger_default.error(`patch tailwindcss failed: ${error.message}`);
|
|
844
796
|
}
|
|
@@ -854,14 +806,14 @@ var TailwindcssPatcher = class {
|
|
|
854
806
|
}
|
|
855
807
|
getContexts() {
|
|
856
808
|
if (this.packageInfo) {
|
|
857
|
-
const distPath =
|
|
809
|
+
const distPath = _pathe2.default.join(this.packageInfo.rootPath, "lib");
|
|
858
810
|
let injectFilePath;
|
|
859
811
|
if (this.majorVersion === 2) {
|
|
860
|
-
injectFilePath =
|
|
861
|
-
} else {
|
|
862
|
-
injectFilePath =
|
|
863
|
-
if (!
|
|
864
|
-
injectFilePath =
|
|
812
|
+
injectFilePath = _pathe2.default.join(distPath, "jit/index.js");
|
|
813
|
+
} else if (this.majorVersion === 3) {
|
|
814
|
+
injectFilePath = _pathe2.default.join(distPath, "plugin.js");
|
|
815
|
+
if (!_fsextra2.default.existsSync(injectFilePath)) {
|
|
816
|
+
injectFilePath = _pathe2.default.join(distPath, "index.js");
|
|
865
817
|
}
|
|
866
818
|
}
|
|
867
819
|
if (injectFilePath) {
|
|
@@ -877,17 +829,62 @@ var TailwindcssPatcher = class {
|
|
|
877
829
|
const contexts = this.getContexts();
|
|
878
830
|
return contexts.filter((x) => isObject(x)).map((x) => x.classCache);
|
|
879
831
|
}
|
|
880
|
-
getClassCacheSet(options) {
|
|
881
|
-
const classCaches = this.getClassCaches();
|
|
832
|
+
async getClassCacheSet(options) {
|
|
882
833
|
const classSet = /* @__PURE__ */ new Set();
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
834
|
+
const { output, tailwindcss } = _nullishCoalesce(options, () => ( {}));
|
|
835
|
+
if (this.majorVersion === 4) {
|
|
836
|
+
const { v4 } = _nullishCoalesce(tailwindcss, () => ( {}));
|
|
837
|
+
if (Array.isArray(_optionalChain([v4, 'optionalAccess', _25 => _25.cssEntries]))) {
|
|
838
|
+
const results = (await Promise.all(
|
|
839
|
+
v4.cssEntries.map(async (x) => {
|
|
840
|
+
if (await _fsextra2.default.exists(x)) {
|
|
841
|
+
const css = await _fsextra2.default.readFile(x, "utf8");
|
|
842
|
+
return css;
|
|
843
|
+
}
|
|
844
|
+
return false;
|
|
845
|
+
})
|
|
846
|
+
)).filter((x) => x);
|
|
847
|
+
for (const css of results) {
|
|
848
|
+
const candidates = await extractValidCandidates({
|
|
849
|
+
base: _optionalChain([v4, 'optionalAccess', _26 => _26.base]),
|
|
850
|
+
css,
|
|
851
|
+
sources: _optionalChain([v4, 'optionalAccess', _27 => _27.sources, 'optionalAccess', _28 => _28.map, 'call', _29 => _29((x) => {
|
|
852
|
+
return {
|
|
853
|
+
base: _nullishCoalesce(_nullishCoalesce(x.base, () => ( _optionalChain([v4, 'optionalAccess', _30 => _30.base]))), () => ( _process2.default.cwd())),
|
|
854
|
+
pattern: x.pattern
|
|
855
|
+
};
|
|
856
|
+
})])
|
|
857
|
+
});
|
|
858
|
+
for (const candidate of candidates) {
|
|
859
|
+
classSet.add(candidate);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
} else {
|
|
863
|
+
const candidates = await extractValidCandidates({
|
|
864
|
+
base: _optionalChain([v4, 'optionalAccess', _31 => _31.base]),
|
|
865
|
+
css: _optionalChain([v4, 'optionalAccess', _32 => _32.css]),
|
|
866
|
+
sources: _optionalChain([v4, 'optionalAccess', _33 => _33.sources, 'optionalAccess', _34 => _34.map, 'call', _35 => _35((x) => {
|
|
867
|
+
return {
|
|
868
|
+
base: _nullishCoalesce(_nullishCoalesce(x.base, () => ( _optionalChain([v4, 'optionalAccess', _36 => _36.base]))), () => ( _process2.default.cwd())),
|
|
869
|
+
pattern: x.pattern
|
|
870
|
+
};
|
|
871
|
+
})])
|
|
872
|
+
});
|
|
873
|
+
for (const candidate of candidates) {
|
|
874
|
+
classSet.add(candidate);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
} else {
|
|
878
|
+
const classCaches = this.getClassCaches();
|
|
879
|
+
for (const classCacheMap of classCaches) {
|
|
880
|
+
const keys = classCacheMap.keys();
|
|
881
|
+
for (const key of keys) {
|
|
882
|
+
const v = key.toString();
|
|
883
|
+
if (_optionalChain([output, 'optionalAccess', _37 => _37.removeUniversalSelector]) && v === "*") {
|
|
884
|
+
continue;
|
|
885
|
+
}
|
|
886
|
+
classSet.add(v);
|
|
889
887
|
}
|
|
890
|
-
classSet.add(v);
|
|
891
888
|
}
|
|
892
889
|
}
|
|
893
890
|
return classSet;
|
|
@@ -895,10 +892,12 @@ var TailwindcssPatcher = class {
|
|
|
895
892
|
/**
|
|
896
893
|
* @description 在多个 tailwindcss 上下文时,这个方法将被执行多次,所以策略上应该使用 append
|
|
897
894
|
*/
|
|
898
|
-
getClassSet(options) {
|
|
899
|
-
const {
|
|
900
|
-
const
|
|
901
|
-
|
|
895
|
+
async getClassSet(options) {
|
|
896
|
+
const { output, tailwindcss } = _nullishCoalesce(options, () => ( {}));
|
|
897
|
+
const cacheStrategy = _nullishCoalesce(this.cacheOptions.strategy, () => ( "merge"));
|
|
898
|
+
const set = await this.getClassCacheSet({
|
|
899
|
+
output,
|
|
900
|
+
tailwindcss
|
|
902
901
|
});
|
|
903
902
|
if (cacheStrategy === "overwrite") {
|
|
904
903
|
set.size > 0 && this.setCache(set);
|
|
@@ -914,48 +913,39 @@ var TailwindcssPatcher = class {
|
|
|
914
913
|
return set;
|
|
915
914
|
}
|
|
916
915
|
async extract(options) {
|
|
917
|
-
const { output, tailwindcss } = options
|
|
916
|
+
const { output, tailwindcss } = _nullishCoalesce(options, () => ( {}));
|
|
918
917
|
if (output && tailwindcss) {
|
|
919
|
-
const {
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
918
|
+
const { filename, loose } = output;
|
|
919
|
+
if (this.majorVersion === 3) {
|
|
920
|
+
await processTailwindcss({
|
|
921
|
+
...tailwindcss,
|
|
922
|
+
majorVersion: this.majorVersion
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
const set = await this.getClassSet({
|
|
926
|
+
output,
|
|
927
|
+
tailwindcss
|
|
923
928
|
});
|
|
924
929
|
if (filename) {
|
|
925
|
-
await import_fs_extra5.default.ensureDir(import_pathe7.default.dirname(filename));
|
|
926
930
|
const classList = [...set];
|
|
927
|
-
await
|
|
931
|
+
await _fsextra2.default.outputJSON(filename, classList, {
|
|
928
932
|
spaces: loose ? 2 : void 0
|
|
929
933
|
});
|
|
930
934
|
return filename;
|
|
931
935
|
}
|
|
932
936
|
}
|
|
933
937
|
}
|
|
934
|
-
}
|
|
938
|
+
__init() {this.extractValidCandidates = extractValidCandidates}
|
|
939
|
+
}, _class);
|
|
935
940
|
|
|
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();
|
|
941
|
+
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
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;
|