tailwindcss-patch 7.1.3 → 7.1.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.
@@ -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.5.0_jiti@2.4.2_postcss@8.5.6_tsx@4.20.3_typescript@5.8.3_yaml@2.8.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.5.0_jiti@2.5.0_postcss@8.5.6_tsx@4.20.3_typescript@5.8.3_yaml@2.8.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
 
@@ -807,16 +807,16 @@ async function extractRawCandidates(sources) {
807
807
  return candidates;
808
808
  }
809
809
  async function extractValidCandidates(options) {
810
- const cwd = _process2.default.cwd();
810
+ const defaultCwd = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _23 => _23.cwd]), () => ( _process2.default.cwd()));
811
811
  const { sources, base, css } = defuOverrideArray(
812
812
  // @ts-ignore
813
813
  options,
814
814
  {
815
815
  css: '@import "tailwindcss";',
816
- base: cwd,
816
+ base: defaultCwd,
817
817
  sources: [
818
818
  {
819
- base: cwd,
819
+ base: defaultCwd,
820
820
  pattern: "**/*",
821
821
  negated: false
822
822
  }
@@ -890,10 +890,10 @@ var TailwindcssPatcher = (_class = class {
890
890
  this.patchOptions = getPatchOptions(options.patch);
891
891
  this.cacheManager = new CacheManager(this.cacheOptions);
892
892
  this.filter = function filter(className) {
893
- if (_optionalChain([this, 'access', _23 => _23.patchOptions, 'access', _24 => _24.output, 'optionalAccess', _25 => _25.removeUniversalSelector]) && className === "*") {
893
+ if (_optionalChain([this, 'access', _24 => _24.patchOptions, 'access', _25 => _25.output, 'optionalAccess', _26 => _26.removeUniversalSelector]) && className === "*") {
894
894
  return false;
895
895
  }
896
- return Boolean(_optionalChain([this, 'access', _26 => _26.patchOptions, 'access', _27 => _27.filter, 'optionalCall', _28 => _28(className)]));
896
+ return Boolean(_optionalChain([this, 'access', _27 => _27.patchOptions, 'access', _28 => _28.filter, 'optionalCall', _29 => _29(className)]));
897
897
  };
898
898
  const packageInfo = _localpkg.getPackageInfoSync.call(void 0,
899
899
  _nullishCoalesce(this.patchOptions.packageName, () => ( "tailwindcss")),
@@ -905,7 +905,7 @@ var TailwindcssPatcher = (_class = class {
905
905
  if (packageInfo.version) {
906
906
  this.majorVersion = Number.parseInt(packageInfo.version[0]);
907
907
  }
908
- if (_optionalChain([this, 'access', _29 => _29.patchOptions, 'access', _30 => _30.tailwindcss, 'optionalAccess', _31 => _31.version])) {
908
+ if (_optionalChain([this, 'access', _30 => _30.patchOptions, 'access', _31 => _31.tailwindcss, 'optionalAccess', _32 => _32.version])) {
909
909
  this.majorVersion = this.patchOptions.tailwindcss.version;
910
910
  }
911
911
  this.packageInfo = packageInfo;
@@ -952,10 +952,10 @@ var TailwindcssPatcher = (_class = class {
952
952
  }
953
953
  async getClassCacheSet() {
954
954
  const classSet = /* @__PURE__ */ new Set();
955
- const { tailwindcss } = this.patchOptions;
955
+ const { tailwindcss, cwd } = this.patchOptions;
956
956
  if (this.majorVersion === 4) {
957
957
  const { v4 } = _nullishCoalesce(tailwindcss, () => ( {}));
958
- if (Array.isArray(_optionalChain([v4, 'optionalAccess', _32 => _32.cssEntries]))) {
958
+ if (Array.isArray(_optionalChain([v4, 'optionalAccess', _33 => _33.cssEntries]))) {
959
959
  const results = (await Promise.all(
960
960
  v4.cssEntries.map(async (x) => {
961
961
  if (await _fsextra2.default.exists(x)) {
@@ -967,34 +967,36 @@ var TailwindcssPatcher = (_class = class {
967
967
  )).filter((x) => x);
968
968
  for (const css of results) {
969
969
  const candidates = await extractValidCandidates({
970
- base: _optionalChain([v4, 'optionalAccess', _33 => _33.base]),
970
+ cwd,
971
+ base: _optionalChain([v4, 'optionalAccess', _34 => _34.base]),
971
972
  css,
972
- sources: _optionalChain([v4, 'optionalAccess', _34 => _34.sources, 'optionalAccess', _35 => _35.map, 'call', _36 => _36((x) => {
973
+ sources: _optionalChain([v4, 'optionalAccess', _35 => _35.sources, 'optionalAccess', _36 => _36.map, 'call', _37 => _37((x) => {
973
974
  return {
974
- base: _nullishCoalesce(_nullishCoalesce(x.base, () => ( _optionalChain([v4, 'optionalAccess', _37 => _37.base]))), () => ( _process2.default.cwd())),
975
+ base: _nullishCoalesce(_nullishCoalesce(x.base, () => ( _optionalChain([v4, 'optionalAccess', _38 => _38.base]))), () => ( _process2.default.cwd())),
975
976
  pattern: x.pattern,
976
977
  negated: x.negated
977
978
  };
978
979
  })])
979
980
  });
980
981
  for (const candidate of candidates) {
981
- _optionalChain([this, 'access', _38 => _38.filter, 'optionalCall', _39 => _39(candidate)]) && classSet.add(candidate);
982
+ _optionalChain([this, 'access', _39 => _39.filter, 'optionalCall', _40 => _40(candidate)]) && classSet.add(candidate);
982
983
  }
983
984
  }
984
985
  } else {
985
986
  const candidates = await extractValidCandidates({
986
- base: _optionalChain([v4, 'optionalAccess', _40 => _40.base]),
987
- css: _optionalChain([v4, 'optionalAccess', _41 => _41.css]),
988
- sources: _optionalChain([v4, 'optionalAccess', _42 => _42.sources, 'optionalAccess', _43 => _43.map, 'call', _44 => _44((x) => {
987
+ cwd,
988
+ base: _optionalChain([v4, 'optionalAccess', _41 => _41.base]),
989
+ css: _optionalChain([v4, 'optionalAccess', _42 => _42.css]),
990
+ sources: _optionalChain([v4, 'optionalAccess', _43 => _43.sources, 'optionalAccess', _44 => _44.map, 'call', _45 => _45((x) => {
989
991
  return {
990
- base: _nullishCoalesce(_nullishCoalesce(x.base, () => ( _optionalChain([v4, 'optionalAccess', _45 => _45.base]))), () => ( _process2.default.cwd())),
992
+ base: _nullishCoalesce(_nullishCoalesce(x.base, () => ( _optionalChain([v4, 'optionalAccess', _46 => _46.base]))), () => ( _process2.default.cwd())),
991
993
  pattern: x.pattern,
992
994
  negated: x.negated
993
995
  };
994
996
  })])
995
997
  });
996
998
  for (const candidate of candidates) {
997
- _optionalChain([this, 'access', _46 => _46.filter, 'optionalCall', _47 => _47(candidate)]) && classSet.add(candidate);
999
+ _optionalChain([this, 'access', _47 => _47.filter, 'optionalCall', _48 => _48(candidate)]) && classSet.add(candidate);
998
1000
  }
999
1001
  }
1000
1002
  } else {
@@ -1003,7 +1005,7 @@ var TailwindcssPatcher = (_class = class {
1003
1005
  const keys = classCacheMap.keys();
1004
1006
  for (const key of keys) {
1005
1007
  const v = key.toString();
1006
- _optionalChain([this, 'access', _48 => _48.filter, 'optionalCall', _49 => _49(v)]) && classSet.add(v);
1008
+ _optionalChain([this, 'access', _49 => _49.filter, 'optionalCall', _50 => _50(v)]) && classSet.add(v);
1007
1009
  }
1008
1010
  }
1009
1011
  }
@@ -1016,7 +1018,7 @@ var TailwindcssPatcher = (_class = class {
1016
1018
  const keys = classCacheMap.keys();
1017
1019
  for (const key of keys) {
1018
1020
  const v = key.toString();
1019
- _optionalChain([this, 'access', _50 => _50.filter, 'optionalCall', _51 => _51(v)]) && classSet.add(v);
1021
+ _optionalChain([this, 'access', _51 => _51.filter, 'optionalCall', _52 => _52(v)]) && classSet.add(v);
1020
1022
  }
1021
1023
  }
1022
1024
  return classSet;
@@ -803,16 +803,16 @@ async function extractRawCandidates(sources) {
803
803
  return candidates;
804
804
  }
805
805
  async function extractValidCandidates(options) {
806
- const cwd = process3.cwd();
806
+ const defaultCwd = options?.cwd ?? process3.cwd();
807
807
  const { sources, base, css } = defuOverrideArray(
808
808
  // @ts-ignore
809
809
  options,
810
810
  {
811
811
  css: '@import "tailwindcss";',
812
- base: cwd,
812
+ base: defaultCwd,
813
813
  sources: [
814
814
  {
815
- base: cwd,
815
+ base: defaultCwd,
816
816
  pattern: "**/*",
817
817
  negated: false
818
818
  }
@@ -948,7 +948,7 @@ var TailwindcssPatcher = class {
948
948
  }
949
949
  async getClassCacheSet() {
950
950
  const classSet = /* @__PURE__ */ new Set();
951
- const { tailwindcss } = this.patchOptions;
951
+ const { tailwindcss, cwd } = this.patchOptions;
952
952
  if (this.majorVersion === 4) {
953
953
  const { v4 } = tailwindcss ?? {};
954
954
  if (Array.isArray(v4?.cssEntries)) {
@@ -963,6 +963,7 @@ var TailwindcssPatcher = class {
963
963
  )).filter((x) => x);
964
964
  for (const css of results) {
965
965
  const candidates = await extractValidCandidates({
966
+ cwd,
966
967
  base: v4?.base,
967
968
  css,
968
969
  sources: v4?.sources?.map((x) => {
@@ -979,6 +980,7 @@ var TailwindcssPatcher = class {
979
980
  }
980
981
  } else {
981
982
  const candidates = await extractValidCandidates({
983
+ cwd,
982
984
  base: v4?.base,
983
985
  css: v4?.css,
984
986
  sources: v4?.sources?.map((x) => {
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkZB7IRGF6js = require('./chunk-ZB7IRGF6.js');
7
+ var _chunkCVGV2M6Njs = require('./chunk-CVGV2M6N.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, _chunkZB7IRGF6js.TailwindcssPatcher)({
20
- patch: _chunkZB7IRGF6js.getPatchOptions.call(void 0, )
19
+ const twPatcher = new (0, _chunkCVGV2M6Njs.TailwindcssPatcher)({
20
+ patch: _chunkCVGV2M6Njs.getPatchOptions.call(void 0, )
21
21
  });
22
22
  twPatcher.patch();
23
23
  });
24
24
  cli.command("init").action(async () => {
25
25
  await init();
26
- _chunkZB7IRGF6js.logger_default.success(`\u2728 ${_config.CONFIG_NAME}.config.ts initialized!`);
26
+ _chunkCVGV2M6Njs.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, _chunkZB7IRGF6js.TailwindcssPatcher)(
32
+ const twPatcher = new (0, _chunkCVGV2M6Njs.TailwindcssPatcher)(
33
33
  {
34
- patch: _chunkZB7IRGF6js.defuOverrideArray.call(void 0,
34
+ patch: _chunkCVGV2M6Njs.defuOverrideArray.call(void 0,
35
35
  config.patch,
36
36
  {
37
37
  resolve: {
38
- paths: [_chunkZB7IRGF6js.importMetaUrl]
38
+ paths: [_chunkCVGV2M6Njs.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 && _chunkZB7IRGF6js.logger_default.success(`\u2728 tailwindcss-patch extract success! file path: ${p.filename}, classList length: ${p.classList.length}`);
50
+ p && _chunkCVGV2M6Njs.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
@@ -3,7 +3,7 @@ import {
3
3
  defuOverrideArray,
4
4
  getPatchOptions,
5
5
  logger_default
6
- } from "./chunk-WQACRZUK.mjs";
6
+ } from "./chunk-NS2I2YPX.mjs";
7
7
 
8
8
  // src/cli.ts
9
9
  import process from "process";
package/dist/index.d.mts CHANGED
@@ -26,6 +26,7 @@ interface PatchOptions extends PatchUserConfig {
26
26
  extendLengthUnits?: boolean | ILengthUnitsPatchOptions;
27
27
  };
28
28
  filter?: (className: string) => boolean;
29
+ cwd?: string;
29
30
  }
30
31
  interface InternalPatchOptions extends PatchOptions {
31
32
  version?: string;
@@ -105,6 +106,7 @@ interface ExtractValidCandidatesOption {
105
106
  sources?: SourceEntry[];
106
107
  base?: string;
107
108
  css?: string;
109
+ cwd?: string;
108
110
  }
109
111
  declare function extractValidCandidates(options?: ExtractValidCandidatesOption): Promise<string[]>;
110
112
 
package/dist/index.d.ts CHANGED
@@ -26,6 +26,7 @@ interface PatchOptions extends PatchUserConfig {
26
26
  extendLengthUnits?: boolean | ILengthUnitsPatchOptions;
27
27
  };
28
28
  filter?: (className: string) => boolean;
29
+ cwd?: string;
29
30
  }
30
31
  interface InternalPatchOptions extends PatchOptions {
31
32
  version?: string;
@@ -105,6 +106,7 @@ interface ExtractValidCandidatesOption {
105
106
  sources?: SourceEntry[];
106
107
  base?: string;
107
108
  css?: string;
109
+ cwd?: string;
108
110
  }
109
111
  declare function extractValidCandidates(options?: ExtractValidCandidatesOption): Promise<string[]>;
110
112
 
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
 
11
- var _chunkZB7IRGF6js = require('./chunk-ZB7IRGF6.js');
11
+ var _chunkCVGV2M6Njs = require('./chunk-CVGV2M6N.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 = _chunkZB7IRGF6js.CacheManager; exports.TailwindcssPatcher = _chunkZB7IRGF6js.TailwindcssPatcher; exports.defineConfig = _config.defineConfig; exports.getCacheOptions = _chunkZB7IRGF6js.getCacheOptions; exports.internalPatch = _chunkZB7IRGF6js.internalPatch; exports.logger = _chunkZB7IRGF6js.logger_default; exports.monkeyPatchForExposingContextV2 = _chunkZB7IRGF6js.monkeyPatchForExposingContextV2; exports.monkeyPatchForExposingContextV3 = _chunkZB7IRGF6js.monkeyPatchForExposingContextV3; exports.monkeyPatchForSupportingCustomUnitV3 = _chunkZB7IRGF6js.monkeyPatchForSupportingCustomUnitV3; exports.monkeyPatchForSupportingCustomUnitV4 = _chunkZB7IRGF6js.monkeyPatchForSupportingCustomUnitV4;
26
+ exports.CacheManager = _chunkCVGV2M6Njs.CacheManager; exports.TailwindcssPatcher = _chunkCVGV2M6Njs.TailwindcssPatcher; exports.defineConfig = _config.defineConfig; exports.getCacheOptions = _chunkCVGV2M6Njs.getCacheOptions; exports.internalPatch = _chunkCVGV2M6Njs.internalPatch; exports.logger = _chunkCVGV2M6Njs.logger_default; exports.monkeyPatchForExposingContextV2 = _chunkCVGV2M6Njs.monkeyPatchForExposingContextV2; exports.monkeyPatchForExposingContextV3 = _chunkCVGV2M6Njs.monkeyPatchForExposingContextV3; exports.monkeyPatchForSupportingCustomUnitV3 = _chunkCVGV2M6Njs.monkeyPatchForSupportingCustomUnitV3; exports.monkeyPatchForSupportingCustomUnitV4 = _chunkCVGV2M6Njs.monkeyPatchForSupportingCustomUnitV4;
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  monkeyPatchForExposingContextV3,
9
9
  monkeyPatchForSupportingCustomUnitV3,
10
10
  monkeyPatchForSupportingCustomUnitV4
11
- } from "./chunk-WQACRZUK.mjs";
11
+ } from "./chunk-NS2I2YPX.mjs";
12
12
 
13
13
  // src/index.ts
14
14
  import { defineConfig } from "@tailwindcss-mangle/config";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwindcss-patch",
3
- "version": "7.1.3",
3
+ "version": "7.1.4",
4
4
  "description": "patch tailwindcss for exposing context and extract classes",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",