tailwindcss-patch 6.0.6 → 6.0.8

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.
@@ -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.2_tsx@4.19.2_typescript@5.7.3_yaml@2.7.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.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
 
@@ -161,13 +161,16 @@ var CacheManager = class {
161
161
  try {
162
162
  if (isExisted) {
163
163
  const data = await _fsextra2.default.readJSON(filename);
164
- return new Set(data);
164
+ return new Set(_nullishCoalesce(data, () => ( [])));
165
+ }
166
+ } catch (e2) {
167
+ try {
168
+ isExisted && await _fsextra2.default.remove(filename);
169
+ } catch (error) {
170
+ logger_default.error(error);
165
171
  }
166
- } catch (error) {
167
- logger_default.error(`path:${filename}`);
168
- logger_default.error(error);
169
- isExisted && await _fsextra2.default.remove(filename);
170
172
  }
173
+ return /* @__PURE__ */ new Set();
171
174
  }
172
175
  };
173
176
 
@@ -188,6 +191,9 @@ function getPatchOptions(options) {
188
191
  return defu(
189
192
  options,
190
193
  {
194
+ output: {
195
+ removeUniversalSelector: true
196
+ },
191
197
  basedir: _process2.default.cwd()
192
198
  },
193
199
  getDefaultPatchOptions()
@@ -656,7 +662,7 @@ function internalPatch(pkgJsonPath, options) {
656
662
  Object.assign(_nullishCoalesce(result, () => ( {})), monkeyPatchForSupportingCustomUnit(twDir, defu(options.applyPatches.extendLengthUnits === true ? void 0 : options.applyPatches.extendLengthUnits, {
657
663
  overwrite: options.overwrite
658
664
  })));
659
- } catch (e2) {
665
+ } catch (e3) {
660
666
  }
661
667
  }
662
668
  return result;
@@ -778,16 +784,15 @@ var TailwindcssPatcher = (_class = class {
778
784
  this.cacheOptions = getCacheOptions(options.cache);
779
785
  this.patchOptions = getPatchOptions(options.patch);
780
786
  this.cacheManager = new CacheManager(this.cacheOptions);
781
- this.filter = this.patchOptions.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
+ };
782
793
  const packageInfo = _localpkg.getPackageInfoSync.call(void 0,
783
794
  _nullishCoalesce(this.patchOptions.packageName, () => ( "tailwindcss")),
784
795
  this.patchOptions.resolve
785
- // defuOverrideArray<PackageResolvingOptions, Partial<PackageResolvingOptions>[]>(
786
- // this.patchOptions.resolve!,
787
- // {
788
- // paths: [import.meta.dirname],
789
- // },
790
- // ),
791
796
  );
792
797
  if (!packageInfo) {
793
798
  throw new Error("tailwindcss not found");
@@ -795,13 +800,13 @@ var TailwindcssPatcher = (_class = class {
795
800
  if (packageInfo.version) {
796
801
  this.majorVersion = Number.parseInt(packageInfo.version[0]);
797
802
  }
798
- if (_optionalChain([this, 'access', _23 => _23.patchOptions, 'access', _24 => _24.tailwindcss, 'optionalAccess', _25 => _25.version])) {
803
+ if (_optionalChain([this, 'access', _29 => _29.patchOptions, 'access', _30 => _30.tailwindcss, 'optionalAccess', _31 => _31.version])) {
799
804
  this.majorVersion = this.patchOptions.tailwindcss.version;
800
805
  }
801
806
  this.packageInfo = packageInfo;
802
807
  this.patch = () => {
803
808
  try {
804
- return internalPatch(_optionalChain([this, 'access', _26 => _26.packageInfo, 'optionalAccess', _27 => _27.packageJsonPath]), this.patchOptions);
809
+ return internalPatch(_optionalChain([this, 'access', _32 => _32.packageInfo, 'optionalAccess', _33 => _33.packageJsonPath]), this.patchOptions);
805
810
  } catch (error) {
806
811
  logger_default.error(`patch tailwindcss failed: ${error.message}`);
807
812
  }
@@ -845,7 +850,7 @@ var TailwindcssPatcher = (_class = class {
845
850
  const { output, tailwindcss } = this.patchOptions;
846
851
  if (this.majorVersion === 4) {
847
852
  const { v4 } = _nullishCoalesce(tailwindcss, () => ( {}));
848
- if (Array.isArray(_optionalChain([v4, 'optionalAccess', _28 => _28.cssEntries]))) {
853
+ if (Array.isArray(_optionalChain([v4, 'optionalAccess', _34 => _34.cssEntries]))) {
849
854
  const results = (await Promise.all(
850
855
  v4.cssEntries.map(async (x) => {
851
856
  if (await _fsextra2.default.exists(x)) {
@@ -857,32 +862,32 @@ var TailwindcssPatcher = (_class = class {
857
862
  )).filter((x) => x);
858
863
  for (const css of results) {
859
864
  const candidates = await extractValidCandidates({
860
- base: _optionalChain([v4, 'optionalAccess', _29 => _29.base]),
865
+ base: _optionalChain([v4, 'optionalAccess', _35 => _35.base]),
861
866
  css,
862
- sources: _optionalChain([v4, 'optionalAccess', _30 => _30.sources, 'optionalAccess', _31 => _31.map, 'call', _32 => _32((x) => {
867
+ sources: _optionalChain([v4, 'optionalAccess', _36 => _36.sources, 'optionalAccess', _37 => _37.map, 'call', _38 => _38((x) => {
863
868
  return {
864
- base: _nullishCoalesce(_nullishCoalesce(x.base, () => ( _optionalChain([v4, 'optionalAccess', _33 => _33.base]))), () => ( _process2.default.cwd())),
869
+ base: _nullishCoalesce(_nullishCoalesce(x.base, () => ( _optionalChain([v4, 'optionalAccess', _39 => _39.base]))), () => ( _process2.default.cwd())),
865
870
  pattern: x.pattern
866
871
  };
867
872
  })])
868
873
  });
869
874
  for (const candidate of candidates) {
870
- _optionalChain([this, 'access', _34 => _34.filter, 'optionalCall', _35 => _35(candidate)]) && classSet.add(candidate);
875
+ _optionalChain([this, 'access', _40 => _40.filter, 'optionalCall', _41 => _41(candidate)]) && classSet.add(candidate);
871
876
  }
872
877
  }
873
878
  } else {
874
879
  const candidates = await extractValidCandidates({
875
- base: _optionalChain([v4, 'optionalAccess', _36 => _36.base]),
876
- css: _optionalChain([v4, 'optionalAccess', _37 => _37.css]),
877
- sources: _optionalChain([v4, 'optionalAccess', _38 => _38.sources, 'optionalAccess', _39 => _39.map, 'call', _40 => _40((x) => {
880
+ base: _optionalChain([v4, 'optionalAccess', _42 => _42.base]),
881
+ css: _optionalChain([v4, 'optionalAccess', _43 => _43.css]),
882
+ sources: _optionalChain([v4, 'optionalAccess', _44 => _44.sources, 'optionalAccess', _45 => _45.map, 'call', _46 => _46((x) => {
878
883
  return {
879
- base: _nullishCoalesce(_nullishCoalesce(x.base, () => ( _optionalChain([v4, 'optionalAccess', _41 => _41.base]))), () => ( _process2.default.cwd())),
884
+ base: _nullishCoalesce(_nullishCoalesce(x.base, () => ( _optionalChain([v4, 'optionalAccess', _47 => _47.base]))), () => ( _process2.default.cwd())),
880
885
  pattern: x.pattern
881
886
  };
882
887
  })])
883
888
  });
884
889
  for (const candidate of candidates) {
885
- _optionalChain([this, 'access', _42 => _42.filter, 'optionalCall', _43 => _43(candidate)]) && classSet.add(candidate);
890
+ _optionalChain([this, 'access', _48 => _48.filter, 'optionalCall', _49 => _49(candidate)]) && classSet.add(candidate);
886
891
  }
887
892
  }
888
893
  } else {
@@ -891,10 +896,7 @@ var TailwindcssPatcher = (_class = class {
891
896
  const keys = classCacheMap.keys();
892
897
  for (const key of keys) {
893
898
  const v = key.toString();
894
- if (_optionalChain([output, 'optionalAccess', _44 => _44.removeUniversalSelector]) && v === "*") {
895
- continue;
896
- }
897
- _optionalChain([this, 'access', _45 => _45.filter, 'optionalCall', _46 => _46(v)]) && classSet.add(v);
899
+ _optionalChain([this, 'access', _50 => _50.filter, 'optionalCall', _51 => _51(v)]) && classSet.add(v);
898
900
  }
899
901
  }
900
902
  }
@@ -157,13 +157,16 @@ var CacheManager = class {
157
157
  try {
158
158
  if (isExisted) {
159
159
  const data = await fs.readJSON(filename);
160
- return new Set(data);
160
+ return new Set(data ?? []);
161
+ }
162
+ } catch {
163
+ try {
164
+ isExisted && await fs.remove(filename);
165
+ } catch (error) {
166
+ logger_default.error(error);
161
167
  }
162
- } catch (error) {
163
- logger_default.error(`path:${filename}`);
164
- logger_default.error(error);
165
- isExisted && await fs.remove(filename);
166
168
  }
169
+ return /* @__PURE__ */ new Set();
167
170
  }
168
171
  };
169
172
 
@@ -184,6 +187,9 @@ function getPatchOptions(options) {
184
187
  return defu(
185
188
  options,
186
189
  {
190
+ output: {
191
+ removeUniversalSelector: true
192
+ },
187
193
  basedir: process2.cwd()
188
194
  },
189
195
  getDefaultPatchOptions()
@@ -774,16 +780,15 @@ var TailwindcssPatcher = class {
774
780
  this.cacheOptions = getCacheOptions(options.cache);
775
781
  this.patchOptions = getPatchOptions(options.patch);
776
782
  this.cacheManager = new CacheManager(this.cacheOptions);
777
- this.filter = this.patchOptions.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
+ };
778
789
  const packageInfo = getPackageInfoSync(
779
790
  this.patchOptions.packageName ?? "tailwindcss",
780
791
  this.patchOptions.resolve
781
- // defuOverrideArray<PackageResolvingOptions, Partial<PackageResolvingOptions>[]>(
782
- // this.patchOptions.resolve!,
783
- // {
784
- // paths: [import.meta.dirname],
785
- // },
786
- // ),
787
792
  );
788
793
  if (!packageInfo) {
789
794
  throw new Error("tailwindcss not found");
@@ -887,9 +892,6 @@ var TailwindcssPatcher = class {
887
892
  const keys = classCacheMap.keys();
888
893
  for (const key of keys) {
889
894
  const v = key.toString();
890
- if (output?.removeUniversalSelector && v === "*") {
891
- continue;
892
- }
893
895
  this.filter?.(v) && classSet.add(v);
894
896
  }
895
897
  }
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkL7IXX3YUjs = require('./chunk-L7IXX3YU.js');
7
+ var _chunk436LRPDXjs = require('./chunk-436LRPDX.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, _chunkL7IXX3YUjs.TailwindcssPatcher)({
20
- patch: _chunkL7IXX3YUjs.getPatchOptions.call(void 0, )
19
+ const twPatcher = new (0, _chunk436LRPDXjs.TailwindcssPatcher)({
20
+ patch: _chunk436LRPDXjs.getPatchOptions.call(void 0, )
21
21
  });
22
22
  twPatcher.patch();
23
23
  });
24
24
  cli.command("init").action(async () => {
25
25
  await init();
26
- _chunkL7IXX3YUjs.logger_default.success(`\u2728 ${_config.CONFIG_NAME}.config.ts initialized!`);
26
+ _chunk436LRPDXjs.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, _chunkL7IXX3YUjs.TailwindcssPatcher)(
31
+ const twPatcher = new (0, _chunk436LRPDXjs.TailwindcssPatcher)(
32
32
  {
33
- patch: _chunkL7IXX3YUjs.defuOverrideArray.call(void 0, config.patch, {
33
+ patch: _chunk436LRPDXjs.defuOverrideArray.call(void 0, config.patch, {
34
34
  resolve: {
35
- paths: [_chunkL7IXX3YUjs.importMetaUrl]
35
+ paths: [_chunk436LRPDXjs.importMetaUrl]
36
36
  }
37
37
  })
38
38
  }
39
39
  );
40
40
  const p = await twPatcher.extract();
41
- p && _chunkL7IXX3YUjs.logger_default.success(`\u2728 tailwindcss-patch extract success! file path: ${p.filename}, classList length: ${p.classList.length}`);
41
+ p && _chunk436LRPDXjs.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
@@ -3,7 +3,7 @@ import {
3
3
  defuOverrideArray,
4
4
  getPatchOptions,
5
5
  logger_default
6
- } from "./chunk-JNFI3RBM.mjs";
6
+ } from "./chunk-I3NEK7LN.mjs";
7
7
 
8
8
  // src/cli.ts
9
9
  import process from "node:process";
package/dist/index.d.mts CHANGED
@@ -105,7 +105,7 @@ declare class CacheManager {
105
105
  filename: string;
106
106
  };
107
107
  write(data: Set<string>): Promise<string | undefined>;
108
- read(): Promise<Set<string> | undefined>;
108
+ read(): Promise<Set<string>>;
109
109
  }
110
110
 
111
111
  interface ExtractValidCandidatesOption {
@@ -126,7 +126,7 @@ declare class TailwindcssPatcher {
126
126
  filter?: (className: string) => boolean;
127
127
  constructor(options?: TailwindcssPatcherOptions);
128
128
  setCache(set: Set<string>): Promise<string | undefined> | undefined;
129
- getCache(): Promise<Set<string> | undefined>;
129
+ getCache(): Promise<Set<string>>;
130
130
  getContexts(): TailwindcssRuntimeContext[];
131
131
  getClassCaches(): TailwindcssClassCache[];
132
132
  getClassCacheSet(): Promise<Set<string>>;
package/dist/index.d.ts CHANGED
@@ -105,7 +105,7 @@ declare class CacheManager {
105
105
  filename: string;
106
106
  };
107
107
  write(data: Set<string>): Promise<string | undefined>;
108
- read(): Promise<Set<string> | undefined>;
108
+ read(): Promise<Set<string>>;
109
109
  }
110
110
 
111
111
  interface ExtractValidCandidatesOption {
@@ -126,7 +126,7 @@ declare class TailwindcssPatcher {
126
126
  filter?: (className: string) => boolean;
127
127
  constructor(options?: TailwindcssPatcherOptions);
128
128
  setCache(set: Set<string>): Promise<string | undefined> | undefined;
129
- getCache(): Promise<Set<string> | undefined>;
129
+ getCache(): Promise<Set<string>>;
130
130
  getContexts(): TailwindcssRuntimeContext[];
131
131
  getClassCaches(): TailwindcssClassCache[];
132
132
  getClassCacheSet(): Promise<Set<string>>;
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkL7IXX3YUjs = require('./chunk-L7IXX3YU.js');
10
+ var _chunk436LRPDXjs = require('./chunk-436LRPDX.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 = _chunkL7IXX3YUjs.CacheManager; exports.TailwindcssPatcher = _chunkL7IXX3YUjs.TailwindcssPatcher; exports.defineConfig = _config.defineConfig; exports.getCacheOptions = _chunkL7IXX3YUjs.getCacheOptions; exports.internalPatch = _chunkL7IXX3YUjs.internalPatch; exports.logger = _chunkL7IXX3YUjs.logger_default; exports.monkeyPatchForExposingContextV2 = _chunkL7IXX3YUjs.monkeyPatchForExposingContextV2; exports.monkeyPatchForExposingContextV3 = _chunkL7IXX3YUjs.monkeyPatchForExposingContextV3; exports.monkeyPatchForSupportingCustomUnit = _chunkL7IXX3YUjs.monkeyPatchForSupportingCustomUnit;
24
+ exports.CacheManager = _chunk436LRPDXjs.CacheManager; exports.TailwindcssPatcher = _chunk436LRPDXjs.TailwindcssPatcher; exports.defineConfig = _config.defineConfig; exports.getCacheOptions = _chunk436LRPDXjs.getCacheOptions; exports.internalPatch = _chunk436LRPDXjs.internalPatch; exports.logger = _chunk436LRPDXjs.logger_default; exports.monkeyPatchForExposingContextV2 = _chunk436LRPDXjs.monkeyPatchForExposingContextV2; exports.monkeyPatchForExposingContextV3 = _chunk436LRPDXjs.monkeyPatchForExposingContextV3; exports.monkeyPatchForSupportingCustomUnit = _chunk436LRPDXjs.monkeyPatchForSupportingCustomUnit;
package/dist/index.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  monkeyPatchForExposingContextV2,
8
8
  monkeyPatchForExposingContextV3,
9
9
  monkeyPatchForSupportingCustomUnit
10
- } from "./chunk-JNFI3RBM.mjs";
10
+ } from "./chunk-I3NEK7LN.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.6",
3
+ "version": "6.0.8",
4
4
  "description": "patch tailwindcss for exposing context and extract classes",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",
@@ -65,10 +65,10 @@
65
65
  "@tailwindcss-mangle/config": "^5.0.3"
66
66
  },
67
67
  "devDependencies": {
68
- "@tailwindcss/node": "^4.0.6",
69
- "@tailwindcss/oxide": "^4.0.6",
70
- "@tailwindcss/postcss": "^4.0.6",
71
- "@tailwindcss/vite": "^4.0.6",
68
+ "@tailwindcss/node": "^4.0.7",
69
+ "@tailwindcss/oxide": "^4.0.7",
70
+ "@tailwindcss/postcss": "^4.0.7",
71
+ "@tailwindcss/vite": "^4.0.7",
72
72
  "tailwindcss": "^4.0.6",
73
73
  "tailwindcss-3": "npm:tailwindcss@^3",
74
74
  "tailwindcss-4": "npm:tailwindcss@^4.0.6"