tailwindcss-patch 6.0.2 → 6.0.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.
@@ -61,24 +61,22 @@ var CacheManager = class {
61
61
  const { filename } = this.options;
62
62
  await _fsextra2.default.outputJSON(filename, [...data]);
63
63
  return filename;
64
- } catch (e2) {
65
- logger_default.error("write cache file fail!");
64
+ } catch (error) {
65
+ logger_default.error(error);
66
66
  }
67
67
  }
68
68
  async read() {
69
69
  const { filename } = this.options;
70
+ const isExisted = await _fsextra2.default.exists(filename);
70
71
  try {
71
- if (await _fsextra2.default.exists(filename)) {
72
+ if (isExisted) {
72
73
  const data = await _fsextra2.default.readJSON(filename);
73
74
  return new Set(data);
74
75
  }
75
- } catch (e3) {
76
- logger_default.error(`parse cache content fail! path:${filename}`);
77
- try {
78
- _fsextra2.default.unlinkSync(filename);
79
- } catch (e4) {
80
- logger_default.error(`delete cache file fail! path:${filename}`);
81
- }
76
+ } catch (error) {
77
+ logger_default.error(`path:${filename}`);
78
+ logger_default.error(error);
79
+ isExisted && await _fsextra2.default.remove(filename);
82
80
  }
83
81
  }
84
82
  };
@@ -179,6 +177,7 @@ var acceptChars = [..."abcdefghijklmnopqrstuvwxyz"];
179
177
  // src/defaults.ts
180
178
  function getDefaultPatchOptions() {
181
179
  return {
180
+ packageName: "tailwindcss",
182
181
  applyPatches: {
183
182
  exportContext: true,
184
183
  extendLengthUnits: false
@@ -658,7 +657,7 @@ function internalPatch(pkgJsonPath, options) {
658
657
  Object.assign(_nullishCoalesce(result, () => ( {})), monkeyPatchForSupportingCustomUnit(twDir, defu(options.applyPatches.extendLengthUnits === true ? void 0 : options.applyPatches.extendLengthUnits, {
659
658
  overwrite: options.overwrite
660
659
  })));
661
- } catch (e5) {
660
+ } catch (e2) {
662
661
  }
663
662
  }
664
663
  return result;
@@ -779,7 +778,16 @@ var TailwindcssPatcher = (_class = class {
779
778
  this.cacheOptions = getCacheOptions(options.cache);
780
779
  this.patchOptions = getPatchOptions(options.patch);
781
780
  this.cacheManager = new CacheManager(this.cacheOptions);
782
- const packageInfo = _localpkg.getPackageInfoSync.call(void 0, "tailwindcss");
781
+ const packageInfo = _localpkg.getPackageInfoSync.call(void 0,
782
+ _nullishCoalesce(this.patchOptions.packageName, () => ( "tailwindcss")),
783
+ this.patchOptions.resolve
784
+ // defuOverrideArray<PackageResolvingOptions, Partial<PackageResolvingOptions>[]>(
785
+ // this.patchOptions.resolve!,
786
+ // {
787
+ // paths: [import.meta.dirname],
788
+ // },
789
+ // ),
790
+ );
783
791
  if (!packageInfo) {
784
792
  throw new Error("tailwindcss not found");
785
793
  }
@@ -914,7 +922,7 @@ var TailwindcssPatcher = (_class = class {
914
922
  const { output, tailwindcss } = _nullishCoalesce(options, () => ( {}));
915
923
  if (output && tailwindcss) {
916
924
  const { filename, loose } = output;
917
- if (this.majorVersion === 3) {
925
+ if (this.majorVersion === 3 || this.majorVersion === 2) {
918
926
  await processTailwindcss({
919
927
  ...tailwindcss,
920
928
  majorVersion: this.majorVersion
@@ -57,24 +57,22 @@ var CacheManager = class {
57
57
  const { filename } = this.options;
58
58
  await fs.outputJSON(filename, [...data]);
59
59
  return filename;
60
- } catch {
61
- logger_default.error("write cache file fail!");
60
+ } catch (error) {
61
+ logger_default.error(error);
62
62
  }
63
63
  }
64
64
  async read() {
65
65
  const { filename } = this.options;
66
+ const isExisted = await fs.exists(filename);
66
67
  try {
67
- if (await fs.exists(filename)) {
68
+ if (isExisted) {
68
69
  const data = await fs.readJSON(filename);
69
70
  return new Set(data);
70
71
  }
71
- } catch {
72
- logger_default.error(`parse cache content fail! path:${filename}`);
73
- try {
74
- fs.unlinkSync(filename);
75
- } catch {
76
- logger_default.error(`delete cache file fail! path:${filename}`);
77
- }
72
+ } catch (error) {
73
+ logger_default.error(`path:${filename}`);
74
+ logger_default.error(error);
75
+ isExisted && await fs.remove(filename);
78
76
  }
79
77
  }
80
78
  };
@@ -175,6 +173,7 @@ var acceptChars = [..."abcdefghijklmnopqrstuvwxyz"];
175
173
  // src/defaults.ts
176
174
  function getDefaultPatchOptions() {
177
175
  return {
176
+ packageName: "tailwindcss",
178
177
  applyPatches: {
179
178
  exportContext: true,
180
179
  extendLengthUnits: false
@@ -775,7 +774,16 @@ var TailwindcssPatcher = class {
775
774
  this.cacheOptions = getCacheOptions(options.cache);
776
775
  this.patchOptions = getPatchOptions(options.patch);
777
776
  this.cacheManager = new CacheManager(this.cacheOptions);
778
- const packageInfo = getPackageInfoSync("tailwindcss");
777
+ const packageInfo = getPackageInfoSync(
778
+ this.patchOptions.packageName ?? "tailwindcss",
779
+ this.patchOptions.resolve
780
+ // defuOverrideArray<PackageResolvingOptions, Partial<PackageResolvingOptions>[]>(
781
+ // this.patchOptions.resolve!,
782
+ // {
783
+ // paths: [import.meta.dirname],
784
+ // },
785
+ // ),
786
+ );
779
787
  if (!packageInfo) {
780
788
  throw new Error("tailwindcss not found");
781
789
  }
@@ -910,7 +918,7 @@ var TailwindcssPatcher = class {
910
918
  const { output, tailwindcss } = options ?? {};
911
919
  if (output && tailwindcss) {
912
920
  const { filename, loose } = output;
913
- if (this.majorVersion === 3) {
921
+ if (this.majorVersion === 3 || this.majorVersion === 2) {
914
922
  await processTailwindcss({
915
923
  ...tailwindcss,
916
924
  majorVersion: this.majorVersion
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkS6WAH32Wjs = require('./chunk-S6WAH32W.js');
5
+ var _chunkR73U6A56js = require('./chunk-R73U6A56.js');
6
6
 
7
7
  // src/cli.ts
8
8
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
@@ -14,21 +14,21 @@ function init() {
14
14
  }
15
15
  var cli = _cac2.default.call(void 0, );
16
16
  cli.command("install", "patch install").action(() => {
17
- const twPatcher = new (0, _chunkS6WAH32Wjs.TailwindcssPatcher)({
18
- patch: _chunkS6WAH32Wjs.getPatchOptions.call(void 0, )
17
+ const twPatcher = new (0, _chunkR73U6A56js.TailwindcssPatcher)({
18
+ patch: _chunkR73U6A56js.getPatchOptions.call(void 0, )
19
19
  });
20
20
  twPatcher.patch();
21
21
  });
22
22
  cli.command("init").action(async () => {
23
23
  await init();
24
- _chunkS6WAH32Wjs.logger_default.success(`\u2728 ${_config.CONFIG_NAME}.config.ts initialized!`);
24
+ _chunkR73U6A56js.logger_default.success(`\u2728 ${_config.CONFIG_NAME}.config.ts initialized!`);
25
25
  });
26
26
  cli.command("extract").action(async () => {
27
27
  const { config } = await _config.getConfig.call(void 0, );
28
28
  if (config) {
29
- const twPatcher = new (0, _chunkS6WAH32Wjs.TailwindcssPatcher)();
29
+ const twPatcher = new (0, _chunkR73U6A56js.TailwindcssPatcher)();
30
30
  const p = await twPatcher.extract(config.patch);
31
- _chunkS6WAH32Wjs.logger_default.success(`\u2728 tailwindcss-patch extract success! file path: ${p}`);
31
+ _chunkR73U6A56js.logger_default.success(`\u2728 tailwindcss-patch extract success! file path: ${p}`);
32
32
  }
33
33
  });
34
34
  cli.help();
package/dist/cli.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  TailwindcssPatcher,
3
3
  getPatchOptions,
4
4
  logger_default
5
- } from "./chunk-NHBD2ICP.mjs";
5
+ } from "./chunk-X2JGSXYF.mjs";
6
6
 
7
7
  // src/cli.ts
8
8
  import process from "node:process";
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkS6WAH32Wjs = require('./chunk-S6WAH32W.js');
10
+ var _chunkR73U6A56js = require('./chunk-R73U6A56.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 = _chunkS6WAH32Wjs.CacheManager; exports.TailwindcssPatcher = _chunkS6WAH32Wjs.TailwindcssPatcher; exports.defineConfig = _config.defineConfig; exports.getCacheOptions = _chunkS6WAH32Wjs.getCacheOptions; exports.internalPatch = _chunkS6WAH32Wjs.internalPatch; exports.logger = _chunkS6WAH32Wjs.logger_default; exports.monkeyPatchForExposingContextV2 = _chunkS6WAH32Wjs.monkeyPatchForExposingContextV2; exports.monkeyPatchForExposingContextV3 = _chunkS6WAH32Wjs.monkeyPatchForExposingContextV3; exports.monkeyPatchForSupportingCustomUnit = _chunkS6WAH32Wjs.monkeyPatchForSupportingCustomUnit;
24
+ exports.CacheManager = _chunkR73U6A56js.CacheManager; exports.TailwindcssPatcher = _chunkR73U6A56js.TailwindcssPatcher; exports.defineConfig = _config.defineConfig; exports.getCacheOptions = _chunkR73U6A56js.getCacheOptions; exports.internalPatch = _chunkR73U6A56js.internalPatch; exports.logger = _chunkR73U6A56js.logger_default; exports.monkeyPatchForExposingContextV2 = _chunkR73U6A56js.monkeyPatchForExposingContextV2; exports.monkeyPatchForExposingContextV3 = _chunkR73U6A56js.monkeyPatchForExposingContextV3; exports.monkeyPatchForSupportingCustomUnit = _chunkR73U6A56js.monkeyPatchForSupportingCustomUnit;
package/dist/index.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  monkeyPatchForExposingContextV2,
8
8
  monkeyPatchForExposingContextV3,
9
9
  monkeyPatchForSupportingCustomUnit
10
- } from "./chunk-NHBD2ICP.mjs";
10
+ } from "./chunk-X2JGSXYF.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.2",
3
+ "version": "6.0.4",
4
4
  "description": "patch tailwindcss for exposing context and extract classes",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",
@@ -62,7 +62,7 @@
62
62
  "postcss": "^8.5.2",
63
63
  "semver": "^7.7.1",
64
64
  "tailwindcss-config": "^1.0.0",
65
- "@tailwindcss-mangle/config": "^5.0.1"
65
+ "@tailwindcss-mangle/config": "^5.0.2"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@tailwindcss/node": "^4.0.6",
@@ -71,7 +71,7 @@
71
71
  "@tailwindcss/vite": "^4.0.6",
72
72
  "tailwindcss": "^4.0.6",
73
73
  "tailwindcss-3": "npm:tailwindcss@^3",
74
- "tailwindcss-4": "npm:tailwindcss@^4"
74
+ "tailwindcss-4": "npm:tailwindcss@^4.0.6"
75
75
  },
76
76
  "scripts": {
77
77
  "dev": "tsup --watch --sourcemap",