tailwindcss-patch 7.0.0 → 7.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/dist/{chunk-UVLKU3DI.js → chunk-6CLAFWMV.js} +26 -26
- package/dist/{chunk-AWSP7JFU.mjs → chunk-VHUTSBJN.mjs} +26 -26
- package/dist/cli.js +8 -8
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -674,22 +674,24 @@ function monkeyPatchForSupportingCustomUnitV4(rootDir, options) {
|
|
|
674
674
|
});
|
|
675
675
|
const distPath = _pathe2.default.resolve(rootDir, "dist");
|
|
676
676
|
const list = _fsextra2.default.readdirSync(distPath);
|
|
677
|
-
const chunks = list.filter((x) => x.
|
|
677
|
+
const chunks = list.filter((x) => x.endsWith("js"));
|
|
678
678
|
const guessUnitStart = /\[\s*["']cm["'],\s*["']mm["'],[\w,"]+\]/;
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
679
|
+
const guessFiles = chunks.reduce((acc, chunkName) => {
|
|
680
|
+
const guessFile = _pathe2.default.join(distPath, chunkName);
|
|
681
|
+
const code = _fsextra2.default.readFileSync(guessFile, "utf8");
|
|
682
|
+
const matches = guessUnitStart.exec(code);
|
|
683
|
+
if (matches && code) {
|
|
684
|
+
acc.push({
|
|
685
|
+
code,
|
|
686
|
+
hasPatched: false,
|
|
687
|
+
file: guessFile,
|
|
688
|
+
matches
|
|
689
|
+
});
|
|
689
690
|
}
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
691
|
+
return acc;
|
|
692
|
+
}, []);
|
|
693
|
+
for (const item of guessFiles) {
|
|
694
|
+
const { matches, code, file } = item;
|
|
693
695
|
const match = matches[0];
|
|
694
696
|
const ast = _parser.parse.call(void 0, match, {
|
|
695
697
|
sourceType: "unambiguous"
|
|
@@ -698,39 +700,37 @@ function monkeyPatchForSupportingCustomUnitV4(rootDir, options) {
|
|
|
698
700
|
ArrayExpression(path7) {
|
|
699
701
|
for (const unit of opts.units) {
|
|
700
702
|
if (path7.node.elements.some((x) => t3.isStringLiteral(x) && x.value === unit)) {
|
|
701
|
-
hasPatched = true;
|
|
703
|
+
item.hasPatched = true;
|
|
702
704
|
break;
|
|
703
705
|
}
|
|
704
706
|
path7.node.elements.push(t3.stringLiteral(unit));
|
|
705
707
|
}
|
|
706
708
|
}
|
|
707
709
|
});
|
|
708
|
-
if (hasPatched) {
|
|
709
|
-
|
|
710
|
-
code,
|
|
711
|
-
hasPatched
|
|
712
|
-
};
|
|
710
|
+
if (item.hasPatched) {
|
|
711
|
+
continue;
|
|
713
712
|
}
|
|
714
713
|
const { code: replacement } = generate(ast, {
|
|
715
714
|
minified: true
|
|
716
715
|
});
|
|
717
|
-
code = spliceChangesIntoString(code, [
|
|
716
|
+
item.code = spliceChangesIntoString(code, [
|
|
718
717
|
{
|
|
719
718
|
start: matches.index,
|
|
720
719
|
end: matches.index + match.length,
|
|
721
720
|
replacement: replacement.endsWith(";") ? replacement.slice(0, -1) : replacement
|
|
722
721
|
}
|
|
723
722
|
]);
|
|
724
|
-
if (opts.overwrite &&
|
|
725
|
-
_fsextra2.default.writeFileSync(
|
|
723
|
+
if (opts.overwrite && file) {
|
|
724
|
+
_fsextra2.default.writeFileSync(file, item.code, {
|
|
726
725
|
encoding: "utf8"
|
|
727
726
|
});
|
|
728
|
-
logger_default.success("patch tailwindcss for custom length unit successfully!");
|
|
729
727
|
}
|
|
730
728
|
}
|
|
729
|
+
if (guessFiles.some((x) => !x.hasPatched)) {
|
|
730
|
+
logger_default.success("patch tailwindcss for custom length unit successfully!");
|
|
731
|
+
}
|
|
731
732
|
return {
|
|
732
|
-
|
|
733
|
-
hasPatched
|
|
733
|
+
files: guessFiles
|
|
734
734
|
};
|
|
735
735
|
}
|
|
736
736
|
|
|
@@ -670,22 +670,24 @@ function monkeyPatchForSupportingCustomUnitV4(rootDir, options) {
|
|
|
670
670
|
});
|
|
671
671
|
const distPath = path3.resolve(rootDir, "dist");
|
|
672
672
|
const list = fs3.readdirSync(distPath);
|
|
673
|
-
const chunks = list.filter((x) => x.
|
|
673
|
+
const chunks = list.filter((x) => x.endsWith("js"));
|
|
674
674
|
const guessUnitStart = /\[\s*["']cm["'],\s*["']mm["'],[\w,"]+\]/;
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
675
|
+
const guessFiles = chunks.reduce((acc, chunkName) => {
|
|
676
|
+
const guessFile = path3.join(distPath, chunkName);
|
|
677
|
+
const code = fs3.readFileSync(guessFile, "utf8");
|
|
678
|
+
const matches = guessUnitStart.exec(code);
|
|
679
|
+
if (matches && code) {
|
|
680
|
+
acc.push({
|
|
681
|
+
code,
|
|
682
|
+
hasPatched: false,
|
|
683
|
+
file: guessFile,
|
|
684
|
+
matches
|
|
685
|
+
});
|
|
685
686
|
}
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
687
|
+
return acc;
|
|
688
|
+
}, []);
|
|
689
|
+
for (const item of guessFiles) {
|
|
690
|
+
const { matches, code, file } = item;
|
|
689
691
|
const match = matches[0];
|
|
690
692
|
const ast = parse(match, {
|
|
691
693
|
sourceType: "unambiguous"
|
|
@@ -694,39 +696,37 @@ function monkeyPatchForSupportingCustomUnitV4(rootDir, options) {
|
|
|
694
696
|
ArrayExpression(path7) {
|
|
695
697
|
for (const unit of opts.units) {
|
|
696
698
|
if (path7.node.elements.some((x) => t3.isStringLiteral(x) && x.value === unit)) {
|
|
697
|
-
hasPatched = true;
|
|
699
|
+
item.hasPatched = true;
|
|
698
700
|
break;
|
|
699
701
|
}
|
|
700
702
|
path7.node.elements.push(t3.stringLiteral(unit));
|
|
701
703
|
}
|
|
702
704
|
}
|
|
703
705
|
});
|
|
704
|
-
if (hasPatched) {
|
|
705
|
-
|
|
706
|
-
code,
|
|
707
|
-
hasPatched
|
|
708
|
-
};
|
|
706
|
+
if (item.hasPatched) {
|
|
707
|
+
continue;
|
|
709
708
|
}
|
|
710
709
|
const { code: replacement } = generate(ast, {
|
|
711
710
|
minified: true
|
|
712
711
|
});
|
|
713
|
-
code = spliceChangesIntoString(code, [
|
|
712
|
+
item.code = spliceChangesIntoString(code, [
|
|
714
713
|
{
|
|
715
714
|
start: matches.index,
|
|
716
715
|
end: matches.index + match.length,
|
|
717
716
|
replacement: replacement.endsWith(";") ? replacement.slice(0, -1) : replacement
|
|
718
717
|
}
|
|
719
718
|
]);
|
|
720
|
-
if (opts.overwrite &&
|
|
721
|
-
fs3.writeFileSync(
|
|
719
|
+
if (opts.overwrite && file) {
|
|
720
|
+
fs3.writeFileSync(file, item.code, {
|
|
722
721
|
encoding: "utf8"
|
|
723
722
|
});
|
|
724
|
-
logger_default.success("patch tailwindcss for custom length unit successfully!");
|
|
725
723
|
}
|
|
726
724
|
}
|
|
725
|
+
if (guessFiles.some((x) => !x.hasPatched)) {
|
|
726
|
+
logger_default.success("patch tailwindcss for custom length unit successfully!");
|
|
727
|
+
}
|
|
727
728
|
return {
|
|
728
|
-
|
|
729
|
-
hasPatched
|
|
729
|
+
files: guessFiles
|
|
730
730
|
};
|
|
731
731
|
}
|
|
732
732
|
|
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk6CLAFWMVjs = require('./chunk-6CLAFWMV.js');
|
|
8
8
|
|
|
9
9
|
// src/cli.ts
|
|
10
10
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
@@ -16,26 +16,26 @@ function init() {
|
|
|
16
16
|
}
|
|
17
17
|
var cli = _cac2.default.call(void 0, );
|
|
18
18
|
cli.command("install", "patch install").action(() => {
|
|
19
|
-
const twPatcher = new (0,
|
|
20
|
-
patch:
|
|
19
|
+
const twPatcher = new (0, _chunk6CLAFWMVjs.TailwindcssPatcher)({
|
|
20
|
+
patch: _chunk6CLAFWMVjs.getPatchOptions.call(void 0, )
|
|
21
21
|
});
|
|
22
22
|
twPatcher.patch();
|
|
23
23
|
});
|
|
24
24
|
cli.command("init").action(async () => {
|
|
25
25
|
await init();
|
|
26
|
-
|
|
26
|
+
_chunk6CLAFWMVjs.logger_default.success(`\u2728 ${_config.CONFIG_NAME}.config.ts initialized!`);
|
|
27
27
|
});
|
|
28
28
|
cli.command("extract").option("--css [file]", "css file entries").action(async (options) => {
|
|
29
29
|
const { config } = await _config.getConfig.call(void 0, );
|
|
30
30
|
const file = options.css;
|
|
31
31
|
if (config) {
|
|
32
|
-
const twPatcher = new (0,
|
|
32
|
+
const twPatcher = new (0, _chunk6CLAFWMVjs.TailwindcssPatcher)(
|
|
33
33
|
{
|
|
34
|
-
patch:
|
|
34
|
+
patch: _chunk6CLAFWMVjs.defuOverrideArray.call(void 0,
|
|
35
35
|
config.patch,
|
|
36
36
|
{
|
|
37
37
|
resolve: {
|
|
38
|
-
paths: [
|
|
38
|
+
paths: [_chunk6CLAFWMVjs.importMetaUrl]
|
|
39
39
|
},
|
|
40
40
|
tailwindcss: {
|
|
41
41
|
v4: {
|
|
@@ -47,7 +47,7 @@ cli.command("extract").option("--css [file]", "css file entries").action(async (
|
|
|
47
47
|
}
|
|
48
48
|
);
|
|
49
49
|
const p = await twPatcher.extract();
|
|
50
|
-
p &&
|
|
50
|
+
p && _chunk6CLAFWMVjs.logger_default.success(`\u2728 tailwindcss-patch extract success! file path: ${p.filename}, classList length: ${p.classList.length}`);
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
cli.help();
|
package/dist/cli.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -140,9 +140,14 @@ declare function monkeyPatchForExposingContextV2(twDir: string, opt: InternalPat
|
|
|
140
140
|
declare function monkeyPatchForSupportingCustomUnitV3(rootDir: string, options?: Partial<ILengthUnitsPatchOptions>): {
|
|
141
141
|
[x: string]: string;
|
|
142
142
|
} | undefined;
|
|
143
|
-
|
|
144
|
-
code: string
|
|
143
|
+
interface V4GuessFile {
|
|
144
|
+
code: string;
|
|
145
145
|
hasPatched: boolean;
|
|
146
|
+
file: string;
|
|
147
|
+
matches: RegExpMatchArray;
|
|
148
|
+
}
|
|
149
|
+
declare function monkeyPatchForSupportingCustomUnitV4(rootDir: string, options?: Partial<ILengthUnitsPatchOptions>): {
|
|
150
|
+
files: V4GuessFile[];
|
|
146
151
|
};
|
|
147
152
|
|
|
148
153
|
declare function internalPatch(pkgJsonPath: PackageInfo, options: InternalPatchOptions): any;
|
package/dist/index.d.ts
CHANGED
|
@@ -140,9 +140,14 @@ declare function monkeyPatchForExposingContextV2(twDir: string, opt: InternalPat
|
|
|
140
140
|
declare function monkeyPatchForSupportingCustomUnitV3(rootDir: string, options?: Partial<ILengthUnitsPatchOptions>): {
|
|
141
141
|
[x: string]: string;
|
|
142
142
|
} | undefined;
|
|
143
|
-
|
|
144
|
-
code: string
|
|
143
|
+
interface V4GuessFile {
|
|
144
|
+
code: string;
|
|
145
145
|
hasPatched: boolean;
|
|
146
|
+
file: string;
|
|
147
|
+
matches: RegExpMatchArray;
|
|
148
|
+
}
|
|
149
|
+
declare function monkeyPatchForSupportingCustomUnitV4(rootDir: string, options?: Partial<ILengthUnitsPatchOptions>): {
|
|
150
|
+
files: V4GuessFile[];
|
|
146
151
|
};
|
|
147
152
|
|
|
148
153
|
declare function internalPatch(pkgJsonPath: PackageInfo, options: InternalPatchOptions): any;
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunk6CLAFWMVjs = require('./chunk-6CLAFWMV.js');
|
|
12
12
|
|
|
13
13
|
// src/index.ts
|
|
14
14
|
var _config = require('@tailwindcss-mangle/config');
|
|
@@ -23,4 +23,4 @@ var _config = require('@tailwindcss-mangle/config');
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
exports.CacheManager =
|
|
26
|
+
exports.CacheManager = _chunk6CLAFWMVjs.CacheManager; exports.TailwindcssPatcher = _chunk6CLAFWMVjs.TailwindcssPatcher; exports.defineConfig = _config.defineConfig; exports.getCacheOptions = _chunk6CLAFWMVjs.getCacheOptions; exports.internalPatch = _chunk6CLAFWMVjs.internalPatch; exports.logger = _chunk6CLAFWMVjs.logger_default; exports.monkeyPatchForExposingContextV2 = _chunk6CLAFWMVjs.monkeyPatchForExposingContextV2; exports.monkeyPatchForExposingContextV3 = _chunk6CLAFWMVjs.monkeyPatchForExposingContextV3; exports.monkeyPatchForSupportingCustomUnitV3 = _chunk6CLAFWMVjs.monkeyPatchForSupportingCustomUnitV3; exports.monkeyPatchForSupportingCustomUnitV4 = _chunk6CLAFWMVjs.monkeyPatchForSupportingCustomUnitV4;
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
monkeyPatchForExposingContextV3,
|
|
9
9
|
monkeyPatchForSupportingCustomUnitV3,
|
|
10
10
|
monkeyPatchForSupportingCustomUnitV4
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-VHUTSBJN.mjs";
|
|
12
12
|
|
|
13
13
|
// src/index.ts
|
|
14
14
|
import { defineConfig } from "@tailwindcss-mangle/config";
|