tailwindcss-patch 8.2.2 → 8.2.4
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-SB2W2SQP.mjs → chunk-4BI6FMCK.mjs} +50 -11
- package/dist/{chunk-5KFYHNFJ.js → chunk-OQKHXYAK.js} +66 -27
- package/dist/cli.js +22 -22
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +78 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +6 -6
|
@@ -135,9 +135,20 @@ async function extractValidCandidates(options) {
|
|
|
135
135
|
const { __unstable__loadDesignSystem } = await importNode();
|
|
136
136
|
const designSystem = await __unstable__loadDesignSystem(css, { base });
|
|
137
137
|
const candidates = await extractRawCandidates(sources);
|
|
138
|
-
const
|
|
138
|
+
const parsedCandidates = candidates.filter(
|
|
139
139
|
(rawCandidate) => designSystem.parseCandidate(rawCandidate).length > 0
|
|
140
140
|
);
|
|
141
|
+
if (parsedCandidates.length === 0) {
|
|
142
|
+
return parsedCandidates;
|
|
143
|
+
}
|
|
144
|
+
const cssByCandidate = designSystem.candidatesToCss(parsedCandidates);
|
|
145
|
+
const validCandidates = [];
|
|
146
|
+
for (let index = 0; index < parsedCandidates.length; index++) {
|
|
147
|
+
const css2 = cssByCandidate[index];
|
|
148
|
+
if (typeof css2 === "string" && css2.trim().length > 0) {
|
|
149
|
+
validCandidates.push(parsedCandidates[index]);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
141
152
|
return validCandidates;
|
|
142
153
|
}
|
|
143
154
|
function normalizeSources(sources, cwd) {
|
|
@@ -468,9 +479,12 @@ function normalizeExtendLengthUnitsOptions(features) {
|
|
|
468
479
|
};
|
|
469
480
|
}
|
|
470
481
|
function normalizeTailwindV4Options(v4, fallbackBase) {
|
|
471
|
-
const
|
|
482
|
+
const configuredBase = v4?.base ? path2.resolve(v4.base) : void 0;
|
|
483
|
+
const base = configuredBase ?? fallbackBase;
|
|
472
484
|
const cssEntries = Array.isArray(v4?.cssEntries) ? v4.cssEntries.filter((entry) => Boolean(entry)).map((entry) => path2.resolve(entry)) : [];
|
|
473
|
-
const
|
|
485
|
+
const userSources = v4?.sources;
|
|
486
|
+
const hasUserDefinedSources = Boolean(userSources?.length);
|
|
487
|
+
const sources = hasUserDefinedSources ? userSources : [
|
|
474
488
|
{
|
|
475
489
|
base,
|
|
476
490
|
pattern: "**/*",
|
|
@@ -479,9 +493,11 @@ function normalizeTailwindV4Options(v4, fallbackBase) {
|
|
|
479
493
|
];
|
|
480
494
|
return {
|
|
481
495
|
base,
|
|
496
|
+
configuredBase,
|
|
482
497
|
css: v4?.css,
|
|
483
498
|
cssEntries,
|
|
484
|
-
sources
|
|
499
|
+
sources,
|
|
500
|
+
hasUserDefinedSources
|
|
485
501
|
};
|
|
486
502
|
}
|
|
487
503
|
function normalizeTailwindOptions(tailwind, projectRoot) {
|
|
@@ -587,13 +603,31 @@ async function collectClassesFromTailwindV4(options) {
|
|
|
587
603
|
if (!v4Options) {
|
|
588
604
|
return set;
|
|
589
605
|
}
|
|
590
|
-
const
|
|
591
|
-
|
|
592
|
-
|
|
606
|
+
const toAbsolute = (value) => {
|
|
607
|
+
if (!value) {
|
|
608
|
+
return void 0;
|
|
609
|
+
}
|
|
610
|
+
return path3.isAbsolute(value) ? value : path3.resolve(options.projectRoot, value);
|
|
611
|
+
};
|
|
612
|
+
const resolvedConfiguredBase = toAbsolute(v4Options.configuredBase);
|
|
613
|
+
const resolvedDefaultBase = toAbsolute(v4Options.base) ?? process3.cwd();
|
|
614
|
+
const resolveSources = (base) => {
|
|
615
|
+
if (!v4Options.sources?.length) {
|
|
616
|
+
return void 0;
|
|
617
|
+
}
|
|
618
|
+
if (!v4Options.hasUserDefinedSources && !resolvedConfiguredBase) {
|
|
619
|
+
return v4Options.sources.map((source) => ({
|
|
620
|
+
base,
|
|
621
|
+
pattern: source.pattern,
|
|
622
|
+
negated: source.negated
|
|
623
|
+
}));
|
|
624
|
+
}
|
|
625
|
+
return v4Options.sources.map((source) => ({
|
|
626
|
+
base: source.base ?? base,
|
|
593
627
|
pattern: source.pattern,
|
|
594
628
|
negated: source.negated
|
|
595
|
-
};
|
|
596
|
-
}
|
|
629
|
+
}));
|
|
630
|
+
};
|
|
597
631
|
if (v4Options.cssEntries.length > 0) {
|
|
598
632
|
for (const entry of v4Options.cssEntries) {
|
|
599
633
|
const filePath = path3.isAbsolute(entry) ? entry : path3.resolve(options.projectRoot, entry);
|
|
@@ -601,9 +635,12 @@ async function collectClassesFromTailwindV4(options) {
|
|
|
601
635
|
continue;
|
|
602
636
|
}
|
|
603
637
|
const css = await fs3.readFile(filePath, "utf8");
|
|
638
|
+
const entryDir = path3.dirname(filePath);
|
|
639
|
+
const baseForEntry = resolvedConfiguredBase ?? entryDir;
|
|
640
|
+
const sources = resolveSources(baseForEntry);
|
|
604
641
|
const candidates = await extractValidCandidates({
|
|
605
642
|
cwd: options.projectRoot,
|
|
606
|
-
base:
|
|
643
|
+
base: baseForEntry,
|
|
607
644
|
css,
|
|
608
645
|
sources
|
|
609
646
|
});
|
|
@@ -614,9 +651,11 @@ async function collectClassesFromTailwindV4(options) {
|
|
|
614
651
|
}
|
|
615
652
|
}
|
|
616
653
|
} else {
|
|
654
|
+
const baseForCss = resolvedConfiguredBase ?? resolvedDefaultBase;
|
|
655
|
+
const sources = resolveSources(baseForCss);
|
|
617
656
|
const candidates = await extractValidCandidates({
|
|
618
657
|
cwd: options.projectRoot,
|
|
619
|
-
base:
|
|
658
|
+
base: baseForCss,
|
|
620
659
|
css: v4Options.css,
|
|
621
660
|
sources
|
|
622
661
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
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.5.
|
|
2
|
-
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src
|
|
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.5.1_jiti@2.6.1_postcss@8.5.6_tsx@4.20.6_typescript@5.9.3_yaml@2.8.1/node_modules/tsup/assets/cjs_shims.js
|
|
2
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
3
3
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
4
4
|
|
|
5
5
|
// src/logger.ts
|
|
@@ -139,9 +139,20 @@ async function extractValidCandidates(options) {
|
|
|
139
139
|
const { __unstable__loadDesignSystem } = await importNode();
|
|
140
140
|
const designSystem = await __unstable__loadDesignSystem(css, { base });
|
|
141
141
|
const candidates = await extractRawCandidates(sources);
|
|
142
|
-
const
|
|
142
|
+
const parsedCandidates = candidates.filter(
|
|
143
143
|
(rawCandidate) => designSystem.parseCandidate(rawCandidate).length > 0
|
|
144
144
|
);
|
|
145
|
+
if (parsedCandidates.length === 0) {
|
|
146
|
+
return parsedCandidates;
|
|
147
|
+
}
|
|
148
|
+
const cssByCandidate = designSystem.candidatesToCss(parsedCandidates);
|
|
149
|
+
const validCandidates = [];
|
|
150
|
+
for (let index = 0; index < parsedCandidates.length; index++) {
|
|
151
|
+
const css2 = cssByCandidate[index];
|
|
152
|
+
if (typeof css2 === "string" && css2.trim().length > 0) {
|
|
153
|
+
validCandidates.push(parsedCandidates[index]);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
145
156
|
return validCandidates;
|
|
146
157
|
}
|
|
147
158
|
function normalizeSources(sources, cwd) {
|
|
@@ -472,9 +483,12 @@ function normalizeExtendLengthUnitsOptions(features) {
|
|
|
472
483
|
};
|
|
473
484
|
}
|
|
474
485
|
function normalizeTailwindV4Options(v4, fallbackBase) {
|
|
475
|
-
const
|
|
486
|
+
const configuredBase = _optionalChain([v4, 'optionalAccess', _35 => _35.base]) ? _pathe2.default.resolve(v4.base) : void 0;
|
|
487
|
+
const base = _nullishCoalesce(configuredBase, () => ( fallbackBase));
|
|
476
488
|
const cssEntries = Array.isArray(_optionalChain([v4, 'optionalAccess', _36 => _36.cssEntries])) ? v4.cssEntries.filter((entry) => Boolean(entry)).map((entry) => _pathe2.default.resolve(entry)) : [];
|
|
477
|
-
const
|
|
489
|
+
const userSources = _optionalChain([v4, 'optionalAccess', _37 => _37.sources]);
|
|
490
|
+
const hasUserDefinedSources = Boolean(_optionalChain([userSources, 'optionalAccess', _38 => _38.length]));
|
|
491
|
+
const sources = hasUserDefinedSources ? userSources : [
|
|
478
492
|
{
|
|
479
493
|
base,
|
|
480
494
|
pattern: "**/*",
|
|
@@ -483,9 +497,11 @@ function normalizeTailwindV4Options(v4, fallbackBase) {
|
|
|
483
497
|
];
|
|
484
498
|
return {
|
|
485
499
|
base,
|
|
500
|
+
configuredBase,
|
|
486
501
|
css: _optionalChain([v4, 'optionalAccess', _39 => _39.css]),
|
|
487
502
|
cssEntries,
|
|
488
|
-
sources
|
|
503
|
+
sources,
|
|
504
|
+
hasUserDefinedSources
|
|
489
505
|
};
|
|
490
506
|
}
|
|
491
507
|
function normalizeTailwindOptions(tailwind, projectRoot) {
|
|
@@ -591,13 +607,31 @@ async function collectClassesFromTailwindV4(options) {
|
|
|
591
607
|
if (!v4Options) {
|
|
592
608
|
return set;
|
|
593
609
|
}
|
|
594
|
-
const
|
|
595
|
-
|
|
596
|
-
|
|
610
|
+
const toAbsolute = (value) => {
|
|
611
|
+
if (!value) {
|
|
612
|
+
return void 0;
|
|
613
|
+
}
|
|
614
|
+
return _pathe2.default.isAbsolute(value) ? value : _pathe2.default.resolve(options.projectRoot, value);
|
|
615
|
+
};
|
|
616
|
+
const resolvedConfiguredBase = toAbsolute(v4Options.configuredBase);
|
|
617
|
+
const resolvedDefaultBase = _nullishCoalesce(toAbsolute(v4Options.base), () => ( _process2.default.cwd()));
|
|
618
|
+
const resolveSources = (base) => {
|
|
619
|
+
if (!_optionalChain([v4Options, 'access', _49 => _49.sources, 'optionalAccess', _50 => _50.length])) {
|
|
620
|
+
return void 0;
|
|
621
|
+
}
|
|
622
|
+
if (!v4Options.hasUserDefinedSources && !resolvedConfiguredBase) {
|
|
623
|
+
return v4Options.sources.map((source) => ({
|
|
624
|
+
base,
|
|
625
|
+
pattern: source.pattern,
|
|
626
|
+
negated: source.negated
|
|
627
|
+
}));
|
|
628
|
+
}
|
|
629
|
+
return v4Options.sources.map((source) => ({
|
|
630
|
+
base: _nullishCoalesce(source.base, () => ( base)),
|
|
597
631
|
pattern: source.pattern,
|
|
598
632
|
negated: source.negated
|
|
599
|
-
};
|
|
600
|
-
}
|
|
633
|
+
}));
|
|
634
|
+
};
|
|
601
635
|
if (v4Options.cssEntries.length > 0) {
|
|
602
636
|
for (const entry of v4Options.cssEntries) {
|
|
603
637
|
const filePath = _pathe2.default.isAbsolute(entry) ? entry : _pathe2.default.resolve(options.projectRoot, entry);
|
|
@@ -605,9 +639,12 @@ async function collectClassesFromTailwindV4(options) {
|
|
|
605
639
|
continue;
|
|
606
640
|
}
|
|
607
641
|
const css = await _fsextra2.default.readFile(filePath, "utf8");
|
|
642
|
+
const entryDir = _pathe2.default.dirname(filePath);
|
|
643
|
+
const baseForEntry = _nullishCoalesce(resolvedConfiguredBase, () => ( entryDir));
|
|
644
|
+
const sources = resolveSources(baseForEntry);
|
|
608
645
|
const candidates = await extractValidCandidates({
|
|
609
646
|
cwd: options.projectRoot,
|
|
610
|
-
base:
|
|
647
|
+
base: baseForEntry,
|
|
611
648
|
css,
|
|
612
649
|
sources
|
|
613
650
|
});
|
|
@@ -618,9 +655,11 @@ async function collectClassesFromTailwindV4(options) {
|
|
|
618
655
|
}
|
|
619
656
|
}
|
|
620
657
|
} else {
|
|
658
|
+
const baseForCss = _nullishCoalesce(resolvedConfiguredBase, () => ( resolvedDefaultBase));
|
|
659
|
+
const sources = resolveSources(baseForCss);
|
|
621
660
|
const candidates = await extractValidCandidates({
|
|
622
661
|
cwd: options.projectRoot,
|
|
623
|
-
base:
|
|
662
|
+
base: baseForCss,
|
|
624
663
|
css: v4Options.css,
|
|
625
664
|
sources
|
|
626
665
|
});
|
|
@@ -769,7 +808,7 @@ function transformProcessTailwindFeaturesReturnContextV2(content) {
|
|
|
769
808
|
traverse(ast, {
|
|
770
809
|
FunctionDeclaration(path9) {
|
|
771
810
|
const node = path9.node;
|
|
772
|
-
if (_optionalChain([node, 'access',
|
|
811
|
+
if (_optionalChain([node, 'access', _51 => _51.id, 'optionalAccess', _52 => _52.name]) !== "processTailwindFeatures" || node.body.body.length !== 1 || !t.isReturnStatement(node.body.body[0])) {
|
|
773
812
|
return;
|
|
774
813
|
}
|
|
775
814
|
const returnStatement3 = node.body.body[0];
|
|
@@ -802,7 +841,7 @@ function transformPostcssPluginV2(content, options) {
|
|
|
802
841
|
Program(path9) {
|
|
803
842
|
const program = path9.node;
|
|
804
843
|
const index = program.body.findIndex((statement) => {
|
|
805
|
-
return t.isFunctionDeclaration(statement) && _optionalChain([statement, 'access',
|
|
844
|
+
return t.isFunctionDeclaration(statement) && _optionalChain([statement, 'access', _53 => _53.id, 'optionalAccess', _54 => _54.name]) === "_default";
|
|
806
845
|
});
|
|
807
846
|
if (index === -1) {
|
|
808
847
|
return;
|
|
@@ -839,7 +878,7 @@ function transformPostcssPluginV2(content, options) {
|
|
|
839
878
|
return;
|
|
840
879
|
}
|
|
841
880
|
const fn = path9.node;
|
|
842
|
-
if (_optionalChain([fn, 'access',
|
|
881
|
+
if (_optionalChain([fn, 'access', _55 => _55.id, 'optionalAccess', _56 => _56.name]) !== "_default") {
|
|
843
882
|
return;
|
|
844
883
|
}
|
|
845
884
|
if (fn.body.body.length !== 1 || !t.isReturnStatement(fn.body.body[0])) {
|
|
@@ -929,7 +968,7 @@ function transformProcessTailwindFeaturesReturnContext(content) {
|
|
|
929
968
|
traverse(ast, {
|
|
930
969
|
FunctionDeclaration(path9) {
|
|
931
970
|
const node = path9.node;
|
|
932
|
-
if (_optionalChain([node, 'access',
|
|
971
|
+
if (_optionalChain([node, 'access', _57 => _57.id, 'optionalAccess', _58 => _58.name]) !== "processTailwindFeatures" || node.body.body.length !== 1) {
|
|
933
972
|
return;
|
|
934
973
|
}
|
|
935
974
|
const [returnStatement3] = node.body.body;
|
|
@@ -963,7 +1002,7 @@ function transformPostcssPlugin(content, { refProperty }) {
|
|
|
963
1002
|
Program(path9) {
|
|
964
1003
|
const program = path9.node;
|
|
965
1004
|
const index = program.body.findIndex((statement) => {
|
|
966
|
-
return t2.isExpressionStatement(statement) && t2.isAssignmentExpression(statement.expression) && t2.isMemberExpression(statement.expression.left) && t2.isFunctionExpression(statement.expression.right) && _optionalChain([statement, 'access',
|
|
1005
|
+
return t2.isExpressionStatement(statement) && t2.isAssignmentExpression(statement.expression) && t2.isMemberExpression(statement.expression.left) && t2.isFunctionExpression(statement.expression.right) && _optionalChain([statement, 'access', _59 => _59.expression, 'access', _60 => _60.right, 'access', _61 => _61.id, 'optionalAccess', _62 => _62.name]) === "tailwindcss";
|
|
967
1006
|
});
|
|
968
1007
|
if (index === -1) {
|
|
969
1008
|
return;
|
|
@@ -1004,7 +1043,7 @@ function transformPostcssPlugin(content, { refProperty }) {
|
|
|
1004
1043
|
return;
|
|
1005
1044
|
}
|
|
1006
1045
|
const fn = path9.node;
|
|
1007
|
-
if (_optionalChain([fn, 'access',
|
|
1046
|
+
if (_optionalChain([fn, 'access', _63 => _63.id, 'optionalAccess', _64 => _64.name]) !== "tailwindcss" || fn.body.body.length !== 1) {
|
|
1008
1047
|
return;
|
|
1009
1048
|
}
|
|
1010
1049
|
const [returnStatement3] = fn.body.body;
|
|
@@ -1312,7 +1351,7 @@ function applyTailwindPatches(context) {
|
|
|
1312
1351
|
majorVersion
|
|
1313
1352
|
});
|
|
1314
1353
|
}
|
|
1315
|
-
if (_optionalChain([options, 'access',
|
|
1354
|
+
if (_optionalChain([options, 'access', _65 => _65.features, 'access', _66 => _66.extendLengthUnits, 'optionalAccess', _67 => _67.enabled])) {
|
|
1316
1355
|
if (majorVersion === 3) {
|
|
1317
1356
|
results.extendLengthUnits = applyExtendLengthUnitsPatchV3(
|
|
1318
1357
|
packageInfo.rootPath,
|
|
@@ -1478,7 +1517,7 @@ var TailwindcssPatcher = (_class = class {
|
|
|
1478
1517
|
return this.mergeWithCacheSync(set);
|
|
1479
1518
|
}
|
|
1480
1519
|
async extract(options) {
|
|
1481
|
-
const shouldWrite = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1520
|
+
const shouldWrite = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _68 => _68.write]), () => ( this.options.output.enabled));
|
|
1482
1521
|
const classSet = await this.getClassSet();
|
|
1483
1522
|
const classList = Array.from(classSet);
|
|
1484
1523
|
const result = {
|
|
@@ -1507,18 +1546,18 @@ var TailwindcssPatcher = (_class = class {
|
|
|
1507
1546
|
__init() {this.extractValidCandidates = exports.extractValidCandidates = extractValidCandidates}
|
|
1508
1547
|
async collectContentTokens(options) {
|
|
1509
1548
|
return extractProjectCandidatesWithPositions({
|
|
1510
|
-
cwd: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1511
|
-
sources: _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1549
|
+
cwd: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _69 => _69.cwd]), () => ( this.options.projectRoot)),
|
|
1550
|
+
sources: _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _70 => _70.sources]), () => ( _optionalChain([this, 'access', _71 => _71.options, 'access', _72 => _72.tailwind, 'access', _73 => _73.v4, 'optionalAccess', _74 => _74.sources]))), () => ( []))
|
|
1512
1551
|
});
|
|
1513
1552
|
}
|
|
1514
1553
|
async collectContentTokensByFile(options) {
|
|
1515
1554
|
const report = await this.collectContentTokens({
|
|
1516
|
-
cwd: _optionalChain([options, 'optionalAccess',
|
|
1517
|
-
sources: _optionalChain([options, 'optionalAccess',
|
|
1555
|
+
cwd: _optionalChain([options, 'optionalAccess', _75 => _75.cwd]),
|
|
1556
|
+
sources: _optionalChain([options, 'optionalAccess', _76 => _76.sources])
|
|
1518
1557
|
});
|
|
1519
1558
|
return groupTokensByFile(report, {
|
|
1520
|
-
key: _optionalChain([options, 'optionalAccess',
|
|
1521
|
-
stripAbsolutePaths: _optionalChain([options, 'optionalAccess',
|
|
1559
|
+
key: _optionalChain([options, 'optionalAccess', _77 => _77.key]),
|
|
1560
|
+
stripAbsolutePaths: _optionalChain([options, 'optionalAccess', _78 => _78.stripAbsolutePaths])
|
|
1522
1561
|
});
|
|
1523
1562
|
}
|
|
1524
1563
|
}, _class);
|
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkOQKHXYAKjs = require('./chunk-OQKHXYAK.js');
|
|
8
8
|
|
|
9
9
|
// src/cli.ts
|
|
10
10
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
@@ -108,15 +108,15 @@ var cli = _cac2.default.call(void 0, "tw-patch");
|
|
|
108
108
|
async function loadPatchOptions(cwd, overrides) {
|
|
109
109
|
const { config } = await _config.getConfig.call(void 0, cwd);
|
|
110
110
|
const legacyConfig = config;
|
|
111
|
-
const base = _optionalChain([config, 'optionalAccess', _ => _.registry]) ?
|
|
111
|
+
const base = _optionalChain([config, 'optionalAccess', _ => _.registry]) ? _chunkOQKHXYAKjs.fromUnifiedConfig.call(void 0, config.registry) : _optionalChain([legacyConfig, 'optionalAccess', _2 => _2.patch]) ? _chunkOQKHXYAKjs.fromLegacyOptions.call(void 0, { patch: legacyConfig.patch }) : {};
|
|
112
112
|
const merged = defu(_nullishCoalesce(overrides, () => ( {})), base);
|
|
113
113
|
return merged;
|
|
114
114
|
}
|
|
115
115
|
cli.command("install", "Apply Tailwind CSS runtime patches").option("--cwd <dir>", "Working directory", { default: _process2.default.cwd() }).action(async (args) => {
|
|
116
116
|
const options = await loadPatchOptions(args.cwd);
|
|
117
|
-
const patcher = new (0,
|
|
117
|
+
const patcher = new (0, _chunkOQKHXYAKjs.TailwindcssPatcher)(options);
|
|
118
118
|
await patcher.patch();
|
|
119
|
-
|
|
119
|
+
_chunkOQKHXYAKjs.logger_default.success("Tailwind CSS runtime patched successfully.");
|
|
120
120
|
});
|
|
121
121
|
cli.command("extract", "Collect generated class names into a cache file").option("--cwd <dir>", "Working directory", { default: _process2.default.cwd() }).option("--output <file>", "Override output file path").option("--format <format>", "Output format (json|lines)").option("--css <file>", "Tailwind CSS entry CSS when using v4").option("--no-write", "Skip writing to disk").action(async (args) => {
|
|
122
122
|
const overrides = {};
|
|
@@ -134,18 +134,18 @@ cli.command("extract", "Collect generated class names into a cache file").option
|
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
136
|
const options = await loadPatchOptions(args.cwd, overrides);
|
|
137
|
-
const patcher = new (0,
|
|
137
|
+
const patcher = new (0, _chunkOQKHXYAKjs.TailwindcssPatcher)(options);
|
|
138
138
|
const result = await patcher.extract({ write: args.write });
|
|
139
139
|
if (result.filename) {
|
|
140
|
-
|
|
140
|
+
_chunkOQKHXYAKjs.logger_default.success(`Collected ${result.classList.length} classes \u2192 ${result.filename}`);
|
|
141
141
|
} else {
|
|
142
|
-
|
|
142
|
+
_chunkOQKHXYAKjs.logger_default.success(`Collected ${result.classList.length} classes.`);
|
|
143
143
|
}
|
|
144
144
|
});
|
|
145
145
|
var TOKEN_FORMATS = ["json", "lines", "grouped-json"];
|
|
146
146
|
cli.command("tokens", "Extract Tailwind tokens with file/position metadata").option("--cwd <dir>", "Working directory", { default: _process2.default.cwd() }).option("--output <file>", "Override output file path", { default: ".tw-patch/tw-token-report.json" }).option("--format <format>", "Output format (json|lines|grouped-json)", { default: "json" }).option("--group-key <key>", "Grouping key for grouped-json output (relative|absolute)", { default: "relative" }).option("--no-write", "Skip writing to disk").action(async (args) => {
|
|
147
147
|
const options = await loadPatchOptions(args.cwd);
|
|
148
|
-
const patcher = new (0,
|
|
148
|
+
const patcher = new (0, _chunkOQKHXYAKjs.TailwindcssPatcher)(options);
|
|
149
149
|
const report = await patcher.collectContentTokens();
|
|
150
150
|
const shouldWrite = _nullishCoalesce(args.write, () => ( true));
|
|
151
151
|
let format = _nullishCoalesce(args.format, () => ( "json"));
|
|
@@ -154,7 +154,7 @@ cli.command("tokens", "Extract Tailwind tokens with file/position metadata").opt
|
|
|
154
154
|
}
|
|
155
155
|
const targetFile = _nullishCoalesce(args.output, () => ( ".tw-patch/tw-token-report.json"));
|
|
156
156
|
const groupKey = args.groupKey === "absolute" ? "absolute" : "relative";
|
|
157
|
-
const buildGrouped = () =>
|
|
157
|
+
const buildGrouped = () => _chunkOQKHXYAKjs.groupTokensByFile.call(void 0, report, {
|
|
158
158
|
key: groupKey,
|
|
159
159
|
stripAbsolutePaths: groupKey !== "absolute"
|
|
160
160
|
});
|
|
@@ -172,48 +172,48 @@ cli.command("tokens", "Extract Tailwind tokens with file/position metadata").opt
|
|
|
172
172
|
await _fsextra2.default.writeFile(target, `${lines.join("\n")}
|
|
173
173
|
`, "utf8");
|
|
174
174
|
}
|
|
175
|
-
|
|
175
|
+
_chunkOQKHXYAKjs.logger_default.success(
|
|
176
176
|
`Collected ${report.entries.length} tokens (${format}) \u2192 ${target.replace(_process2.default.cwd(), ".")}`
|
|
177
177
|
);
|
|
178
178
|
} else {
|
|
179
|
-
|
|
179
|
+
_chunkOQKHXYAKjs.logger_default.success(`Collected ${report.entries.length} tokens from ${report.filesScanned} files.`);
|
|
180
180
|
if (format === "lines") {
|
|
181
181
|
const preview = report.entries.slice(0, 5).map(formatTokenLine).join("\n");
|
|
182
182
|
if (preview) {
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
_chunkOQKHXYAKjs.logger_default.log("");
|
|
184
|
+
_chunkOQKHXYAKjs.logger_default.info(preview);
|
|
185
185
|
if (report.entries.length > 5) {
|
|
186
|
-
|
|
186
|
+
_chunkOQKHXYAKjs.logger_default.info(`\u2026and ${report.entries.length - 5} more.`);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
} else if (format === "grouped-json") {
|
|
190
190
|
const map = resolveGrouped();
|
|
191
191
|
const { preview, moreFiles } = formatGroupedPreview(map);
|
|
192
192
|
if (preview) {
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
_chunkOQKHXYAKjs.logger_default.log("");
|
|
194
|
+
_chunkOQKHXYAKjs.logger_default.info(preview);
|
|
195
195
|
if (moreFiles > 0) {
|
|
196
|
-
|
|
196
|
+
_chunkOQKHXYAKjs.logger_default.info(`\u2026and ${moreFiles} more files.`);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
} else {
|
|
200
200
|
const previewEntries = report.entries.slice(0, 3);
|
|
201
201
|
if (previewEntries.length) {
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
_chunkOQKHXYAKjs.logger_default.log("");
|
|
203
|
+
_chunkOQKHXYAKjs.logger_default.info(JSON.stringify(previewEntries, null, 2));
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
if (report.skippedFiles.length) {
|
|
208
|
-
|
|
208
|
+
_chunkOQKHXYAKjs.logger_default.warn("Skipped files:");
|
|
209
209
|
for (const skipped of report.skippedFiles) {
|
|
210
|
-
|
|
210
|
+
_chunkOQKHXYAKjs.logger_default.warn(` \u2022 ${skipped.file} (${skipped.reason})`);
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
});
|
|
214
214
|
cli.command("init", "Generate a tailwindcss-patch config file").option("--cwd <dir>", "Working directory", { default: _process2.default.cwd() }).action(async (args) => {
|
|
215
215
|
await _config.initConfig.call(void 0, args.cwd);
|
|
216
|
-
|
|
216
|
+
_chunkOQKHXYAKjs.logger_default.success(`\u2728 ${_config.CONFIG_NAME}.config.ts initialized!`);
|
|
217
217
|
});
|
|
218
218
|
cli.help();
|
|
219
219
|
cli.parse();
|
package/dist/cli.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -7,66 +7,131 @@ export { defineConfig } from '@tailwindcss-mangle/config';
|
|
|
7
7
|
import * as consola from 'consola';
|
|
8
8
|
|
|
9
9
|
type CacheStrategy = 'merge' | 'overwrite';
|
|
10
|
+
/**
|
|
11
|
+
* Configures how the Tailwind class cache is stored and where it lives on disk.
|
|
12
|
+
*/
|
|
10
13
|
interface CacheUserOptions {
|
|
14
|
+
/** Whether caching is enabled. */
|
|
11
15
|
enabled?: boolean;
|
|
16
|
+
/** Working directory used when resolving cache paths. */
|
|
12
17
|
cwd?: string;
|
|
18
|
+
/** Directory where cache files are written. */
|
|
13
19
|
dir?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Cache filename. Defaults to `class-cache.json` inside the derived cache folder
|
|
22
|
+
* when omitted.
|
|
23
|
+
*/
|
|
14
24
|
file?: string;
|
|
25
|
+
/** Strategy used when merging new class lists with an existing cache. */
|
|
15
26
|
strategy?: CacheStrategy;
|
|
16
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Controls how extracted class lists are written to disk.
|
|
30
|
+
*/
|
|
17
31
|
interface OutputUserOptions {
|
|
32
|
+
/** Whether to produce an output file. */
|
|
18
33
|
enabled?: boolean;
|
|
34
|
+
/** Optional absolute or relative path to the output file. */
|
|
19
35
|
file?: string;
|
|
36
|
+
/** Output format, defaults to JSON when omitted. */
|
|
20
37
|
format?: 'json' | 'lines';
|
|
38
|
+
/** Pretty-print spacing (truthy value enables indentation). */
|
|
21
39
|
pretty?: number | boolean;
|
|
40
|
+
/** Whether to strip the universal selector (`*`) from the final list. */
|
|
22
41
|
removeUniversalSelector?: boolean;
|
|
23
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Options controlling how Tailwind contexts are exposed during runtime patching.
|
|
45
|
+
*/
|
|
24
46
|
interface ExposeContextUserOptions {
|
|
47
|
+
/** Name of the property used to reference an exposed context. */
|
|
25
48
|
refProperty?: string;
|
|
26
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Extends the built-in length-unit patch with custom defaults.
|
|
52
|
+
*/
|
|
27
53
|
interface ExtendLengthUnitsUserOptions extends Partial<ILengthUnitsPatchOptions> {
|
|
54
|
+
/** Enables or disables the length-unit patch. */
|
|
28
55
|
enabled?: boolean;
|
|
29
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Feature switches that toggle optional Tailwind patch capabilities.
|
|
59
|
+
*/
|
|
30
60
|
interface FeatureUserOptions {
|
|
61
|
+
/** Whether to expose runtime Tailwind contexts (or configure how they are exposed). */
|
|
31
62
|
exposeContext?: boolean | ExposeContextUserOptions;
|
|
63
|
+
/** Extends the length-unit patch or disables it entirely. */
|
|
32
64
|
extendLengthUnits?: false | ExtendLengthUnitsUserOptions;
|
|
33
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Shared configuration used for Tailwind v2/v3 patching flows.
|
|
68
|
+
*/
|
|
34
69
|
interface TailwindConfigUserOptions {
|
|
70
|
+
/** Path to a Tailwind config file when auto-detection is insufficient. */
|
|
35
71
|
config?: string;
|
|
72
|
+
/** Custom working directory used when resolving config-relative paths. */
|
|
36
73
|
cwd?: string;
|
|
74
|
+
/** Optional PostCSS plugin name to use instead of the default. */
|
|
37
75
|
postcssPlugin?: string;
|
|
38
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Additional configuration specific to Tailwind CSS v4 extraction.
|
|
79
|
+
*/
|
|
39
80
|
interface TailwindV4UserOptions {
|
|
81
|
+
/** Base directory used when resolving v4 content sources and configs. */
|
|
40
82
|
base?: string;
|
|
83
|
+
/** Raw CSS passed directly to the v4 design system. */
|
|
41
84
|
css?: string;
|
|
85
|
+
/** Set of CSS entry files that should be scanned for `@config` directives. */
|
|
42
86
|
cssEntries?: string[];
|
|
87
|
+
/** Overrides the content sources scanned by the oxide scanner. */
|
|
43
88
|
sources?: SourceEntry[];
|
|
44
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* High-level Tailwind patch configuration shared across versions.
|
|
92
|
+
*/
|
|
45
93
|
interface TailwindUserOptions extends TailwindConfigUserOptions {
|
|
46
94
|
/**
|
|
47
95
|
* Optional hint for picking the patch strategy.
|
|
48
96
|
* When omitted we infer from the installed Tailwind CSS package version.
|
|
49
97
|
*/
|
|
50
98
|
version?: 2 | 3 | 4;
|
|
99
|
+
/** Tailwind package name if the project uses a fork. */
|
|
51
100
|
packageName?: string;
|
|
101
|
+
/** Package resolution options forwarded to `local-pkg`. */
|
|
52
102
|
resolve?: PackageResolvingOptions;
|
|
103
|
+
/** Overrides applied when patching Tailwind CSS v2. */
|
|
53
104
|
v2?: TailwindConfigUserOptions;
|
|
105
|
+
/** Overrides applied when patching Tailwind CSS v3. */
|
|
54
106
|
v3?: TailwindConfigUserOptions;
|
|
107
|
+
/** Options specific to Tailwind CSS v4 patching. */
|
|
55
108
|
v4?: TailwindV4UserOptions;
|
|
56
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Root configuration consumed by the Tailwind CSS patch runner.
|
|
112
|
+
*/
|
|
57
113
|
interface TailwindcssPatchOptions {
|
|
58
114
|
/**
|
|
59
115
|
* Base directory used when resolving Tailwind resources.
|
|
60
116
|
* Defaults to `process.cwd()`.
|
|
61
117
|
*/
|
|
62
118
|
cwd?: string;
|
|
119
|
+
/** Whether to overwrite generated artifacts (e.g., caches, outputs). */
|
|
63
120
|
overwrite?: boolean;
|
|
121
|
+
/** Tailwind-specific configuration grouped by major version. */
|
|
64
122
|
tailwind?: TailwindUserOptions;
|
|
123
|
+
/** Feature toggles for optional helpers. */
|
|
65
124
|
features?: FeatureUserOptions;
|
|
125
|
+
/** Optional function that filters final class names. */
|
|
66
126
|
filter?: (className: string) => boolean;
|
|
127
|
+
/** Cache configuration or boolean to enable/disable quickly. */
|
|
67
128
|
cache?: boolean | CacheUserOptions;
|
|
129
|
+
/** Output configuration or boolean to inherits defaults. */
|
|
68
130
|
output?: OutputUserOptions;
|
|
69
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Stable shape for output configuration after normalization.
|
|
134
|
+
*/
|
|
70
135
|
interface NormalizedOutputOptions {
|
|
71
136
|
enabled: boolean;
|
|
72
137
|
file?: string;
|
|
@@ -74,6 +139,9 @@ interface NormalizedOutputOptions {
|
|
|
74
139
|
pretty: number | false;
|
|
75
140
|
removeUniversalSelector: boolean;
|
|
76
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Stable cache configuration used internally after defaults are applied.
|
|
144
|
+
*/
|
|
77
145
|
interface NormalizedCacheOptions {
|
|
78
146
|
enabled: boolean;
|
|
79
147
|
cwd: string;
|
|
@@ -82,19 +150,27 @@ interface NormalizedCacheOptions {
|
|
|
82
150
|
path: string;
|
|
83
151
|
strategy: CacheStrategy;
|
|
84
152
|
}
|
|
153
|
+
/** Tracks whether runtime contexts should be exposed and via which property. */
|
|
85
154
|
interface NormalizedExposeContextOptions {
|
|
86
155
|
enabled: boolean;
|
|
87
156
|
refProperty: string;
|
|
88
157
|
}
|
|
158
|
+
/** Normalized representation of the extend-length-units feature flag. */
|
|
89
159
|
interface NormalizedExtendLengthUnitsOptions extends ILengthUnitsPatchOptions {
|
|
90
160
|
enabled: boolean;
|
|
91
161
|
}
|
|
162
|
+
/** Normalized Tailwind v4 configuration consumed by runtime helpers. */
|
|
92
163
|
interface NormalizedTailwindV4Options {
|
|
93
164
|
base: string;
|
|
165
|
+
configuredBase?: string;
|
|
94
166
|
css?: string;
|
|
95
167
|
cssEntries: string[];
|
|
96
168
|
sources: SourceEntry[];
|
|
169
|
+
hasUserDefinedSources: boolean;
|
|
97
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Tailwind configuration ready for consumption by the runtime after normalization.
|
|
173
|
+
*/
|
|
98
174
|
interface NormalizedTailwindConfigOptions extends TailwindConfigUserOptions {
|
|
99
175
|
packageName: string;
|
|
100
176
|
versionHint?: 2 | 3 | 4;
|
|
@@ -103,10 +179,12 @@ interface NormalizedTailwindConfigOptions extends TailwindConfigUserOptions {
|
|
|
103
179
|
v3?: TailwindConfigUserOptions;
|
|
104
180
|
v4?: NormalizedTailwindV4Options;
|
|
105
181
|
}
|
|
182
|
+
/** Grouped normalized feature flags. */
|
|
106
183
|
interface NormalizedFeatureOptions {
|
|
107
184
|
exposeContext: NormalizedExposeContextOptions;
|
|
108
185
|
extendLengthUnits: NormalizedExtendLengthUnitsOptions | null;
|
|
109
186
|
}
|
|
187
|
+
/** Final normalized shape consumed throughout the patch runtime. */
|
|
110
188
|
interface NormalizedTailwindcssPatchOptions {
|
|
111
189
|
projectRoot: string;
|
|
112
190
|
overwrite: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,66 +7,131 @@ export { defineConfig } from '@tailwindcss-mangle/config';
|
|
|
7
7
|
import * as consola from 'consola';
|
|
8
8
|
|
|
9
9
|
type CacheStrategy = 'merge' | 'overwrite';
|
|
10
|
+
/**
|
|
11
|
+
* Configures how the Tailwind class cache is stored and where it lives on disk.
|
|
12
|
+
*/
|
|
10
13
|
interface CacheUserOptions {
|
|
14
|
+
/** Whether caching is enabled. */
|
|
11
15
|
enabled?: boolean;
|
|
16
|
+
/** Working directory used when resolving cache paths. */
|
|
12
17
|
cwd?: string;
|
|
18
|
+
/** Directory where cache files are written. */
|
|
13
19
|
dir?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Cache filename. Defaults to `class-cache.json` inside the derived cache folder
|
|
22
|
+
* when omitted.
|
|
23
|
+
*/
|
|
14
24
|
file?: string;
|
|
25
|
+
/** Strategy used when merging new class lists with an existing cache. */
|
|
15
26
|
strategy?: CacheStrategy;
|
|
16
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Controls how extracted class lists are written to disk.
|
|
30
|
+
*/
|
|
17
31
|
interface OutputUserOptions {
|
|
32
|
+
/** Whether to produce an output file. */
|
|
18
33
|
enabled?: boolean;
|
|
34
|
+
/** Optional absolute or relative path to the output file. */
|
|
19
35
|
file?: string;
|
|
36
|
+
/** Output format, defaults to JSON when omitted. */
|
|
20
37
|
format?: 'json' | 'lines';
|
|
38
|
+
/** Pretty-print spacing (truthy value enables indentation). */
|
|
21
39
|
pretty?: number | boolean;
|
|
40
|
+
/** Whether to strip the universal selector (`*`) from the final list. */
|
|
22
41
|
removeUniversalSelector?: boolean;
|
|
23
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Options controlling how Tailwind contexts are exposed during runtime patching.
|
|
45
|
+
*/
|
|
24
46
|
interface ExposeContextUserOptions {
|
|
47
|
+
/** Name of the property used to reference an exposed context. */
|
|
25
48
|
refProperty?: string;
|
|
26
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Extends the built-in length-unit patch with custom defaults.
|
|
52
|
+
*/
|
|
27
53
|
interface ExtendLengthUnitsUserOptions extends Partial<ILengthUnitsPatchOptions> {
|
|
54
|
+
/** Enables or disables the length-unit patch. */
|
|
28
55
|
enabled?: boolean;
|
|
29
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Feature switches that toggle optional Tailwind patch capabilities.
|
|
59
|
+
*/
|
|
30
60
|
interface FeatureUserOptions {
|
|
61
|
+
/** Whether to expose runtime Tailwind contexts (or configure how they are exposed). */
|
|
31
62
|
exposeContext?: boolean | ExposeContextUserOptions;
|
|
63
|
+
/** Extends the length-unit patch or disables it entirely. */
|
|
32
64
|
extendLengthUnits?: false | ExtendLengthUnitsUserOptions;
|
|
33
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Shared configuration used for Tailwind v2/v3 patching flows.
|
|
68
|
+
*/
|
|
34
69
|
interface TailwindConfigUserOptions {
|
|
70
|
+
/** Path to a Tailwind config file when auto-detection is insufficient. */
|
|
35
71
|
config?: string;
|
|
72
|
+
/** Custom working directory used when resolving config-relative paths. */
|
|
36
73
|
cwd?: string;
|
|
74
|
+
/** Optional PostCSS plugin name to use instead of the default. */
|
|
37
75
|
postcssPlugin?: string;
|
|
38
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Additional configuration specific to Tailwind CSS v4 extraction.
|
|
79
|
+
*/
|
|
39
80
|
interface TailwindV4UserOptions {
|
|
81
|
+
/** Base directory used when resolving v4 content sources and configs. */
|
|
40
82
|
base?: string;
|
|
83
|
+
/** Raw CSS passed directly to the v4 design system. */
|
|
41
84
|
css?: string;
|
|
85
|
+
/** Set of CSS entry files that should be scanned for `@config` directives. */
|
|
42
86
|
cssEntries?: string[];
|
|
87
|
+
/** Overrides the content sources scanned by the oxide scanner. */
|
|
43
88
|
sources?: SourceEntry[];
|
|
44
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* High-level Tailwind patch configuration shared across versions.
|
|
92
|
+
*/
|
|
45
93
|
interface TailwindUserOptions extends TailwindConfigUserOptions {
|
|
46
94
|
/**
|
|
47
95
|
* Optional hint for picking the patch strategy.
|
|
48
96
|
* When omitted we infer from the installed Tailwind CSS package version.
|
|
49
97
|
*/
|
|
50
98
|
version?: 2 | 3 | 4;
|
|
99
|
+
/** Tailwind package name if the project uses a fork. */
|
|
51
100
|
packageName?: string;
|
|
101
|
+
/** Package resolution options forwarded to `local-pkg`. */
|
|
52
102
|
resolve?: PackageResolvingOptions;
|
|
103
|
+
/** Overrides applied when patching Tailwind CSS v2. */
|
|
53
104
|
v2?: TailwindConfigUserOptions;
|
|
105
|
+
/** Overrides applied when patching Tailwind CSS v3. */
|
|
54
106
|
v3?: TailwindConfigUserOptions;
|
|
107
|
+
/** Options specific to Tailwind CSS v4 patching. */
|
|
55
108
|
v4?: TailwindV4UserOptions;
|
|
56
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Root configuration consumed by the Tailwind CSS patch runner.
|
|
112
|
+
*/
|
|
57
113
|
interface TailwindcssPatchOptions {
|
|
58
114
|
/**
|
|
59
115
|
* Base directory used when resolving Tailwind resources.
|
|
60
116
|
* Defaults to `process.cwd()`.
|
|
61
117
|
*/
|
|
62
118
|
cwd?: string;
|
|
119
|
+
/** Whether to overwrite generated artifacts (e.g., caches, outputs). */
|
|
63
120
|
overwrite?: boolean;
|
|
121
|
+
/** Tailwind-specific configuration grouped by major version. */
|
|
64
122
|
tailwind?: TailwindUserOptions;
|
|
123
|
+
/** Feature toggles for optional helpers. */
|
|
65
124
|
features?: FeatureUserOptions;
|
|
125
|
+
/** Optional function that filters final class names. */
|
|
66
126
|
filter?: (className: string) => boolean;
|
|
127
|
+
/** Cache configuration or boolean to enable/disable quickly. */
|
|
67
128
|
cache?: boolean | CacheUserOptions;
|
|
129
|
+
/** Output configuration or boolean to inherits defaults. */
|
|
68
130
|
output?: OutputUserOptions;
|
|
69
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Stable shape for output configuration after normalization.
|
|
134
|
+
*/
|
|
70
135
|
interface NormalizedOutputOptions {
|
|
71
136
|
enabled: boolean;
|
|
72
137
|
file?: string;
|
|
@@ -74,6 +139,9 @@ interface NormalizedOutputOptions {
|
|
|
74
139
|
pretty: number | false;
|
|
75
140
|
removeUniversalSelector: boolean;
|
|
76
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Stable cache configuration used internally after defaults are applied.
|
|
144
|
+
*/
|
|
77
145
|
interface NormalizedCacheOptions {
|
|
78
146
|
enabled: boolean;
|
|
79
147
|
cwd: string;
|
|
@@ -82,19 +150,27 @@ interface NormalizedCacheOptions {
|
|
|
82
150
|
path: string;
|
|
83
151
|
strategy: CacheStrategy;
|
|
84
152
|
}
|
|
153
|
+
/** Tracks whether runtime contexts should be exposed and via which property. */
|
|
85
154
|
interface NormalizedExposeContextOptions {
|
|
86
155
|
enabled: boolean;
|
|
87
156
|
refProperty: string;
|
|
88
157
|
}
|
|
158
|
+
/** Normalized representation of the extend-length-units feature flag. */
|
|
89
159
|
interface NormalizedExtendLengthUnitsOptions extends ILengthUnitsPatchOptions {
|
|
90
160
|
enabled: boolean;
|
|
91
161
|
}
|
|
162
|
+
/** Normalized Tailwind v4 configuration consumed by runtime helpers. */
|
|
92
163
|
interface NormalizedTailwindV4Options {
|
|
93
164
|
base: string;
|
|
165
|
+
configuredBase?: string;
|
|
94
166
|
css?: string;
|
|
95
167
|
cssEntries: string[];
|
|
96
168
|
sources: SourceEntry[];
|
|
169
|
+
hasUserDefinedSources: boolean;
|
|
97
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Tailwind configuration ready for consumption by the runtime after normalization.
|
|
173
|
+
*/
|
|
98
174
|
interface NormalizedTailwindConfigOptions extends TailwindConfigUserOptions {
|
|
99
175
|
packageName: string;
|
|
100
176
|
versionHint?: 2 | 3 | 4;
|
|
@@ -103,10 +179,12 @@ interface NormalizedTailwindConfigOptions extends TailwindConfigUserOptions {
|
|
|
103
179
|
v3?: TailwindConfigUserOptions;
|
|
104
180
|
v4?: NormalizedTailwindV4Options;
|
|
105
181
|
}
|
|
182
|
+
/** Grouped normalized feature flags. */
|
|
106
183
|
interface NormalizedFeatureOptions {
|
|
107
184
|
exposeContext: NormalizedExposeContextOptions;
|
|
108
185
|
extendLengthUnits: NormalizedExtendLengthUnitsOptions | null;
|
|
109
186
|
}
|
|
187
|
+
/** Final normalized shape consumed throughout the patch runtime. */
|
|
110
188
|
interface NormalizedTailwindcssPatchOptions {
|
|
111
189
|
projectRoot: string;
|
|
112
190
|
overwrite: boolean;
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkOQKHXYAKjs = require('./chunk-OQKHXYAK.js');
|
|
16
16
|
|
|
17
17
|
// src/index.ts
|
|
18
18
|
var _config = require('@tailwindcss-mangle/config');
|
|
@@ -31,4 +31,4 @@ var _config = require('@tailwindcss-mangle/config');
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
exports.CacheStore =
|
|
34
|
+
exports.CacheStore = _chunkOQKHXYAKjs.CacheStore; exports.TailwindcssPatcher = _chunkOQKHXYAKjs.TailwindcssPatcher; exports.collectClassesFromContexts = _chunkOQKHXYAKjs.collectClassesFromContexts; exports.collectClassesFromTailwindV4 = _chunkOQKHXYAKjs.collectClassesFromTailwindV4; exports.defineConfig = _config.defineConfig; exports.extractProjectCandidatesWithPositions = _chunkOQKHXYAKjs.extractProjectCandidatesWithPositions; exports.extractRawCandidates = _chunkOQKHXYAKjs.extractRawCandidates; exports.extractRawCandidatesWithPositions = _chunkOQKHXYAKjs.extractRawCandidatesWithPositions; exports.extractValidCandidates = _chunkOQKHXYAKjs.extractValidCandidates; exports.groupTokensByFile = _chunkOQKHXYAKjs.groupTokensByFile; exports.loadRuntimeContexts = _chunkOQKHXYAKjs.loadRuntimeContexts; exports.logger = _chunkOQKHXYAKjs.logger_default; exports.normalizeOptions = _chunkOQKHXYAKjs.normalizeOptions; exports.runTailwindBuild = _chunkOQKHXYAKjs.runTailwindBuild;
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwindcss-patch",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.4",
|
|
4
4
|
"description": "patch tailwindcss for exposing context and extract classes",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@babel/parser": "^7.28.5",
|
|
55
55
|
"@babel/traverse": "^7.28.5",
|
|
56
56
|
"@babel/types": "^7.28.5",
|
|
57
|
-
"@tailwindcss/node": "^4.1.
|
|
57
|
+
"@tailwindcss/node": "^4.1.17",
|
|
58
58
|
"cac": "^6.7.14",
|
|
59
59
|
"consola": "^3.4.2",
|
|
60
60
|
"fs-extra": "^11.3.2",
|
|
@@ -66,10 +66,10 @@
|
|
|
66
66
|
"@tailwindcss-mangle/config": "6.1.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@tailwindcss/oxide": "^4.1.
|
|
70
|
-
"@tailwindcss/postcss": "^4.1.
|
|
71
|
-
"@tailwindcss/vite": "^4.1.
|
|
72
|
-
"tailwindcss": "^4.1.
|
|
69
|
+
"@tailwindcss/oxide": "^4.1.17",
|
|
70
|
+
"@tailwindcss/postcss": "^4.1.17",
|
|
71
|
+
"@tailwindcss/vite": "^4.1.17",
|
|
72
|
+
"tailwindcss": "^4.1.17",
|
|
73
73
|
"tailwindcss-3": "npm:tailwindcss@^3.4.18",
|
|
74
74
|
"tailwindcss-4": "npm:tailwindcss@^4.1.16"
|
|
75
75
|
},
|