tailwindcss-patch 6.0.7 → 6.0.9
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-7LD7UWYL.js → chunk-MMFOI5KY.js} +33 -33
- package/dist/{chunk-4NIV24YC.mjs → chunk-QPUWFRNR.mjs} +19 -19
- package/dist/cli.js +8 -8
- package/dist/cli.mjs +1 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +7 -7
|
@@ -1,4 +1,4 @@
|
|
|
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.
|
|
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.3_tsx@4.19.3_typescript@5.7.3_yaml@2.7.0/node_modules/tsup/assets/cjs_shims.js
|
|
2
2
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
3
3
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
4
4
|
|
|
@@ -163,12 +163,11 @@ var CacheManager = class {
|
|
|
163
163
|
const data = await _fsextra2.default.readJSON(filename);
|
|
164
164
|
return new Set(_nullishCoalesce(data, () => ( [])));
|
|
165
165
|
}
|
|
166
|
-
} catch (
|
|
167
|
-
logger_default.error(error);
|
|
166
|
+
} catch (e2) {
|
|
168
167
|
try {
|
|
169
168
|
isExisted && await _fsextra2.default.remove(filename);
|
|
170
|
-
} catch (
|
|
171
|
-
logger_default.error(
|
|
169
|
+
} catch (error) {
|
|
170
|
+
logger_default.error(error);
|
|
172
171
|
}
|
|
173
172
|
}
|
|
174
173
|
return /* @__PURE__ */ new Set();
|
|
@@ -192,6 +191,9 @@ function getPatchOptions(options) {
|
|
|
192
191
|
return defu(
|
|
193
192
|
options,
|
|
194
193
|
{
|
|
194
|
+
output: {
|
|
195
|
+
removeUniversalSelector: true
|
|
196
|
+
},
|
|
195
197
|
basedir: _process2.default.cwd()
|
|
196
198
|
},
|
|
197
199
|
getDefaultPatchOptions()
|
|
@@ -660,7 +662,7 @@ function internalPatch(pkgJsonPath, options) {
|
|
|
660
662
|
Object.assign(_nullishCoalesce(result, () => ( {})), monkeyPatchForSupportingCustomUnit(twDir, defu(options.applyPatches.extendLengthUnits === true ? void 0 : options.applyPatches.extendLengthUnits, {
|
|
661
663
|
overwrite: options.overwrite
|
|
662
664
|
})));
|
|
663
|
-
} catch (
|
|
665
|
+
} catch (e3) {
|
|
664
666
|
}
|
|
665
667
|
}
|
|
666
668
|
return result;
|
|
@@ -782,16 +784,15 @@ var TailwindcssPatcher = (_class = class {
|
|
|
782
784
|
this.cacheOptions = getCacheOptions(options.cache);
|
|
783
785
|
this.patchOptions = getPatchOptions(options.patch);
|
|
784
786
|
this.cacheManager = new CacheManager(this.cacheOptions);
|
|
785
|
-
this.filter =
|
|
787
|
+
this.filter = function filter(className) {
|
|
788
|
+
if (_optionalChain([this, 'access', _23 => _23.patchOptions, 'access', _24 => _24.output, 'optionalAccess', _25 => _25.removeUniversalSelector]) && className === "*") {
|
|
789
|
+
return false;
|
|
790
|
+
}
|
|
791
|
+
return Boolean(_optionalChain([this, 'access', _26 => _26.patchOptions, 'access', _27 => _27.filter, 'optionalCall', _28 => _28(className)]));
|
|
792
|
+
};
|
|
786
793
|
const packageInfo = _localpkg.getPackageInfoSync.call(void 0,
|
|
787
794
|
_nullishCoalesce(this.patchOptions.packageName, () => ( "tailwindcss")),
|
|
788
795
|
this.patchOptions.resolve
|
|
789
|
-
// defuOverrideArray<PackageResolvingOptions, Partial<PackageResolvingOptions>[]>(
|
|
790
|
-
// this.patchOptions.resolve!,
|
|
791
|
-
// {
|
|
792
|
-
// paths: [import.meta.dirname],
|
|
793
|
-
// },
|
|
794
|
-
// ),
|
|
795
796
|
);
|
|
796
797
|
if (!packageInfo) {
|
|
797
798
|
throw new Error("tailwindcss not found");
|
|
@@ -799,15 +800,17 @@ var TailwindcssPatcher = (_class = class {
|
|
|
799
800
|
if (packageInfo.version) {
|
|
800
801
|
this.majorVersion = Number.parseInt(packageInfo.version[0]);
|
|
801
802
|
}
|
|
802
|
-
if (_optionalChain([this, 'access',
|
|
803
|
+
if (_optionalChain([this, 'access', _29 => _29.patchOptions, 'access', _30 => _30.tailwindcss, 'optionalAccess', _31 => _31.version])) {
|
|
803
804
|
this.majorVersion = this.patchOptions.tailwindcss.version;
|
|
804
805
|
}
|
|
805
806
|
this.packageInfo = packageInfo;
|
|
806
807
|
this.patch = () => {
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
808
|
+
if (this.majorVersion === 3 || this.majorVersion === 2) {
|
|
809
|
+
try {
|
|
810
|
+
return internalPatch(_optionalChain([this, 'access', _32 => _32.packageInfo, 'optionalAccess', _33 => _33.packageJsonPath]), this.patchOptions);
|
|
811
|
+
} catch (error) {
|
|
812
|
+
logger_default.error(`patch tailwindcss failed: ${error.message}`);
|
|
813
|
+
}
|
|
811
814
|
}
|
|
812
815
|
};
|
|
813
816
|
}
|
|
@@ -846,10 +849,10 @@ var TailwindcssPatcher = (_class = class {
|
|
|
846
849
|
}
|
|
847
850
|
async getClassCacheSet() {
|
|
848
851
|
const classSet = /* @__PURE__ */ new Set();
|
|
849
|
-
const {
|
|
852
|
+
const { tailwindcss } = this.patchOptions;
|
|
850
853
|
if (this.majorVersion === 4) {
|
|
851
854
|
const { v4 } = _nullishCoalesce(tailwindcss, () => ( {}));
|
|
852
|
-
if (Array.isArray(_optionalChain([v4, 'optionalAccess',
|
|
855
|
+
if (Array.isArray(_optionalChain([v4, 'optionalAccess', _34 => _34.cssEntries]))) {
|
|
853
856
|
const results = (await Promise.all(
|
|
854
857
|
v4.cssEntries.map(async (x) => {
|
|
855
858
|
if (await _fsextra2.default.exists(x)) {
|
|
@@ -861,32 +864,32 @@ var TailwindcssPatcher = (_class = class {
|
|
|
861
864
|
)).filter((x) => x);
|
|
862
865
|
for (const css of results) {
|
|
863
866
|
const candidates = await extractValidCandidates({
|
|
864
|
-
base: _optionalChain([v4, 'optionalAccess',
|
|
867
|
+
base: _optionalChain([v4, 'optionalAccess', _35 => _35.base]),
|
|
865
868
|
css,
|
|
866
|
-
sources: _optionalChain([v4, 'optionalAccess',
|
|
869
|
+
sources: _optionalChain([v4, 'optionalAccess', _36 => _36.sources, 'optionalAccess', _37 => _37.map, 'call', _38 => _38((x) => {
|
|
867
870
|
return {
|
|
868
|
-
base: _nullishCoalesce(_nullishCoalesce(x.base, () => ( _optionalChain([v4, 'optionalAccess',
|
|
871
|
+
base: _nullishCoalesce(_nullishCoalesce(x.base, () => ( _optionalChain([v4, 'optionalAccess', _39 => _39.base]))), () => ( _process2.default.cwd())),
|
|
869
872
|
pattern: x.pattern
|
|
870
873
|
};
|
|
871
874
|
})])
|
|
872
875
|
});
|
|
873
876
|
for (const candidate of candidates) {
|
|
874
|
-
_optionalChain([this, 'access',
|
|
877
|
+
_optionalChain([this, 'access', _40 => _40.filter, 'optionalCall', _41 => _41(candidate)]) && classSet.add(candidate);
|
|
875
878
|
}
|
|
876
879
|
}
|
|
877
880
|
} else {
|
|
878
881
|
const candidates = await extractValidCandidates({
|
|
879
|
-
base: _optionalChain([v4, 'optionalAccess',
|
|
880
|
-
css: _optionalChain([v4, 'optionalAccess',
|
|
881
|
-
sources: _optionalChain([v4, 'optionalAccess',
|
|
882
|
+
base: _optionalChain([v4, 'optionalAccess', _42 => _42.base]),
|
|
883
|
+
css: _optionalChain([v4, 'optionalAccess', _43 => _43.css]),
|
|
884
|
+
sources: _optionalChain([v4, 'optionalAccess', _44 => _44.sources, 'optionalAccess', _45 => _45.map, 'call', _46 => _46((x) => {
|
|
882
885
|
return {
|
|
883
|
-
base: _nullishCoalesce(_nullishCoalesce(x.base, () => ( _optionalChain([v4, 'optionalAccess',
|
|
886
|
+
base: _nullishCoalesce(_nullishCoalesce(x.base, () => ( _optionalChain([v4, 'optionalAccess', _47 => _47.base]))), () => ( _process2.default.cwd())),
|
|
884
887
|
pattern: x.pattern
|
|
885
888
|
};
|
|
886
889
|
})])
|
|
887
890
|
});
|
|
888
891
|
for (const candidate of candidates) {
|
|
889
|
-
_optionalChain([this, 'access',
|
|
892
|
+
_optionalChain([this, 'access', _48 => _48.filter, 'optionalCall', _49 => _49(candidate)]) && classSet.add(candidate);
|
|
890
893
|
}
|
|
891
894
|
}
|
|
892
895
|
} else {
|
|
@@ -895,10 +898,7 @@ var TailwindcssPatcher = (_class = class {
|
|
|
895
898
|
const keys = classCacheMap.keys();
|
|
896
899
|
for (const key of keys) {
|
|
897
900
|
const v = key.toString();
|
|
898
|
-
|
|
899
|
-
continue;
|
|
900
|
-
}
|
|
901
|
-
_optionalChain([this, 'access', _45 => _45.filter, 'optionalCall', _46 => _46(v)]) && classSet.add(v);
|
|
901
|
+
_optionalChain([this, 'access', _50 => _50.filter, 'optionalCall', _51 => _51(v)]) && classSet.add(v);
|
|
902
902
|
}
|
|
903
903
|
}
|
|
904
904
|
}
|
|
@@ -159,12 +159,11 @@ var CacheManager = class {
|
|
|
159
159
|
const data = await fs.readJSON(filename);
|
|
160
160
|
return new Set(data ?? []);
|
|
161
161
|
}
|
|
162
|
-
} catch
|
|
163
|
-
logger_default.error(error);
|
|
162
|
+
} catch {
|
|
164
163
|
try {
|
|
165
164
|
isExisted && await fs.remove(filename);
|
|
166
|
-
} catch (
|
|
167
|
-
logger_default.error(
|
|
165
|
+
} catch (error) {
|
|
166
|
+
logger_default.error(error);
|
|
168
167
|
}
|
|
169
168
|
}
|
|
170
169
|
return /* @__PURE__ */ new Set();
|
|
@@ -188,6 +187,9 @@ function getPatchOptions(options) {
|
|
|
188
187
|
return defu(
|
|
189
188
|
options,
|
|
190
189
|
{
|
|
190
|
+
output: {
|
|
191
|
+
removeUniversalSelector: true
|
|
192
|
+
},
|
|
191
193
|
basedir: process2.cwd()
|
|
192
194
|
},
|
|
193
195
|
getDefaultPatchOptions()
|
|
@@ -778,16 +780,15 @@ var TailwindcssPatcher = class {
|
|
|
778
780
|
this.cacheOptions = getCacheOptions(options.cache);
|
|
779
781
|
this.patchOptions = getPatchOptions(options.patch);
|
|
780
782
|
this.cacheManager = new CacheManager(this.cacheOptions);
|
|
781
|
-
this.filter =
|
|
783
|
+
this.filter = function filter(className) {
|
|
784
|
+
if (this.patchOptions.output?.removeUniversalSelector && className === "*") {
|
|
785
|
+
return false;
|
|
786
|
+
}
|
|
787
|
+
return Boolean(this.patchOptions.filter?.(className));
|
|
788
|
+
};
|
|
782
789
|
const packageInfo = getPackageInfoSync(
|
|
783
790
|
this.patchOptions.packageName ?? "tailwindcss",
|
|
784
791
|
this.patchOptions.resolve
|
|
785
|
-
// defuOverrideArray<PackageResolvingOptions, Partial<PackageResolvingOptions>[]>(
|
|
786
|
-
// this.patchOptions.resolve!,
|
|
787
|
-
// {
|
|
788
|
-
// paths: [import.meta.dirname],
|
|
789
|
-
// },
|
|
790
|
-
// ),
|
|
791
792
|
);
|
|
792
793
|
if (!packageInfo) {
|
|
793
794
|
throw new Error("tailwindcss not found");
|
|
@@ -800,10 +801,12 @@ var TailwindcssPatcher = class {
|
|
|
800
801
|
}
|
|
801
802
|
this.packageInfo = packageInfo;
|
|
802
803
|
this.patch = () => {
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
804
|
+
if (this.majorVersion === 3 || this.majorVersion === 2) {
|
|
805
|
+
try {
|
|
806
|
+
return internalPatch(this.packageInfo?.packageJsonPath, this.patchOptions);
|
|
807
|
+
} catch (error) {
|
|
808
|
+
logger_default.error(`patch tailwindcss failed: ${error.message}`);
|
|
809
|
+
}
|
|
807
810
|
}
|
|
808
811
|
};
|
|
809
812
|
}
|
|
@@ -842,7 +845,7 @@ var TailwindcssPatcher = class {
|
|
|
842
845
|
}
|
|
843
846
|
async getClassCacheSet() {
|
|
844
847
|
const classSet = /* @__PURE__ */ new Set();
|
|
845
|
-
const {
|
|
848
|
+
const { tailwindcss } = this.patchOptions;
|
|
846
849
|
if (this.majorVersion === 4) {
|
|
847
850
|
const { v4 } = tailwindcss ?? {};
|
|
848
851
|
if (Array.isArray(v4?.cssEntries)) {
|
|
@@ -891,9 +894,6 @@ var TailwindcssPatcher = class {
|
|
|
891
894
|
const keys = classCacheMap.keys();
|
|
892
895
|
for (const key of keys) {
|
|
893
896
|
const v = key.toString();
|
|
894
|
-
if (output?.removeUniversalSelector && v === "*") {
|
|
895
|
-
continue;
|
|
896
|
-
}
|
|
897
897
|
this.filter?.(v) && classSet.add(v);
|
|
898
898
|
}
|
|
899
899
|
}
|
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkMMFOI5KYjs = require('./chunk-MMFOI5KY.js');
|
|
8
8
|
|
|
9
9
|
// src/cli.ts
|
|
10
10
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
@@ -16,29 +16,29 @@ 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, _chunkMMFOI5KYjs.TailwindcssPatcher)({
|
|
20
|
+
patch: _chunkMMFOI5KYjs.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
|
+
_chunkMMFOI5KYjs.logger_default.success(`\u2728 ${_config.CONFIG_NAME}.config.ts initialized!`);
|
|
27
27
|
});
|
|
28
28
|
cli.command("extract").action(async () => {
|
|
29
29
|
const { config } = await _config.getConfig.call(void 0, );
|
|
30
30
|
if (config) {
|
|
31
|
-
const twPatcher = new (0,
|
|
31
|
+
const twPatcher = new (0, _chunkMMFOI5KYjs.TailwindcssPatcher)(
|
|
32
32
|
{
|
|
33
|
-
patch:
|
|
33
|
+
patch: _chunkMMFOI5KYjs.defuOverrideArray.call(void 0, config.patch, {
|
|
34
34
|
resolve: {
|
|
35
|
-
paths: [
|
|
35
|
+
paths: [_chunkMMFOI5KYjs.importMetaUrl]
|
|
36
36
|
}
|
|
37
37
|
})
|
|
38
38
|
}
|
|
39
39
|
);
|
|
40
40
|
const p = await twPatcher.extract();
|
|
41
|
-
p &&
|
|
41
|
+
p && _chunkMMFOI5KYjs.logger_default.success(`\u2728 tailwindcss-patch extract success! file path: ${p.filename}, classList length: ${p.classList.length}`);
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
cli.help();
|
package/dist/cli.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkMMFOI5KYjs = require('./chunk-MMFOI5KY.js');
|
|
11
11
|
|
|
12
12
|
// src/index.ts
|
|
13
13
|
var _config = require('@tailwindcss-mangle/config');
|
|
@@ -21,4 +21,4 @@ var _config = require('@tailwindcss-mangle/config');
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
exports.CacheManager =
|
|
24
|
+
exports.CacheManager = _chunkMMFOI5KYjs.CacheManager; exports.TailwindcssPatcher = _chunkMMFOI5KYjs.TailwindcssPatcher; exports.defineConfig = _config.defineConfig; exports.getCacheOptions = _chunkMMFOI5KYjs.getCacheOptions; exports.internalPatch = _chunkMMFOI5KYjs.internalPatch; exports.logger = _chunkMMFOI5KYjs.logger_default; exports.monkeyPatchForExposingContextV2 = _chunkMMFOI5KYjs.monkeyPatchForExposingContextV2; exports.monkeyPatchForExposingContextV3 = _chunkMMFOI5KYjs.monkeyPatchForExposingContextV3; exports.monkeyPatchForSupportingCustomUnit = _chunkMMFOI5KYjs.monkeyPatchForSupportingCustomUnit;
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
monkeyPatchForExposingContextV2,
|
|
8
8
|
monkeyPatchForExposingContextV3,
|
|
9
9
|
monkeyPatchForSupportingCustomUnit
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-QPUWFRNR.mjs";
|
|
11
11
|
|
|
12
12
|
// src/index.ts
|
|
13
13
|
import { defineConfig } from "@tailwindcss-mangle/config";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwindcss-patch",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.9",
|
|
4
4
|
"description": "patch tailwindcss for exposing context and extract classes",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,16 +59,16 @@
|
|
|
59
59
|
"fs-extra": "^11.3.0",
|
|
60
60
|
"local-pkg": "^1.0.0",
|
|
61
61
|
"pathe": "^2.0.3",
|
|
62
|
-
"postcss": "^8.5.
|
|
62
|
+
"postcss": "^8.5.3",
|
|
63
63
|
"semver": "^7.7.1",
|
|
64
64
|
"tailwindcss-config": "^1.0.0",
|
|
65
|
-
"@tailwindcss-mangle/config": "^5.0.
|
|
65
|
+
"@tailwindcss-mangle/config": "^5.0.4"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@tailwindcss/node": "^4.0.
|
|
69
|
-
"@tailwindcss/oxide": "^4.0.
|
|
70
|
-
"@tailwindcss/postcss": "^4.0.
|
|
71
|
-
"@tailwindcss/vite": "^4.0.
|
|
68
|
+
"@tailwindcss/node": "^4.0.8",
|
|
69
|
+
"@tailwindcss/oxide": "^4.0.8",
|
|
70
|
+
"@tailwindcss/postcss": "^4.0.8",
|
|
71
|
+
"@tailwindcss/vite": "^4.0.8",
|
|
72
72
|
"tailwindcss": "^4.0.6",
|
|
73
73
|
"tailwindcss-3": "npm:tailwindcss@^3",
|
|
74
74
|
"tailwindcss-4": "npm:tailwindcss@^4.0.6"
|