tailwindcss-patch 5.0.2 → 6.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/cli.js CHANGED
@@ -1,34 +1,34 @@
1
- import {
2
- TailwindcssPatcher,
3
- config_exports,
4
- getPatchOptions,
5
- logger_default
6
- } from "./chunk-LOQK6LST.js";
1
+ "use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+
3
+
4
+
5
+ var _chunkU3S6WRCPjs = require('./chunk-U3S6WRCP.js');
7
6
 
8
7
  // src/cli.ts
9
- import process from "node:process";
10
- import cac from "cac";
8
+ var _process = require('process'); var _process2 = _interopRequireDefault(_process);
9
+ var _config = require('@tailwindcss-mangle/config');
10
+ var _cac = require('cac'); var _cac2 = _interopRequireDefault(_cac);
11
11
  function init() {
12
- const cwd = process.cwd();
13
- return (0, config_exports.initConfig)(cwd);
12
+ const cwd = _process2.default.cwd();
13
+ return _config.initConfig.call(void 0, cwd);
14
14
  }
15
- var cli = cac();
15
+ var cli = _cac2.default.call(void 0, );
16
16
  cli.command("install", "patch install").action(() => {
17
- const twPatcher = new TailwindcssPatcher({
18
- patch: getPatchOptions()
17
+ const twPatcher = new (0, _chunkU3S6WRCPjs.TailwindcssPatcher)({
18
+ patch: _chunkU3S6WRCPjs.getPatchOptions.call(void 0, )
19
19
  });
20
20
  twPatcher.patch();
21
21
  });
22
22
  cli.command("init").action(async () => {
23
23
  await init();
24
- logger_default.success(`\u2728 ${config_exports.configName}.config.ts initialized!`);
24
+ _chunkU3S6WRCPjs.logger_default.success(`\u2728 ${_config.CONFIG_NAME}.config.ts initialized!`);
25
25
  });
26
26
  cli.command("extract").action(async () => {
27
- const { config } = await (0, config_exports.getConfig)();
27
+ const { config } = await _config.getConfig.call(void 0, );
28
28
  if (config) {
29
- const twPatcher = new TailwindcssPatcher();
29
+ const twPatcher = new (0, _chunkU3S6WRCPjs.TailwindcssPatcher)();
30
30
  const p = await twPatcher.extract(config.patch);
31
- logger_default.success(`\u2728 tailwindcss-patch extract success! file path: ${p}`);
31
+ _chunkU3S6WRCPjs.logger_default.success(`\u2728 tailwindcss-patch extract success! file path: ${p}`);
32
32
  }
33
33
  });
34
34
  cli.help();
package/dist/cli.mjs ADDED
@@ -0,0 +1,35 @@
1
+ import {
2
+ TailwindcssPatcher,
3
+ getPatchOptions,
4
+ logger_default
5
+ } from "./chunk-U2NQZPXE.mjs";
6
+
7
+ // src/cli.ts
8
+ import process from "node:process";
9
+ import { CONFIG_NAME, getConfig, initConfig } from "@tailwindcss-mangle/config";
10
+ import cac from "cac";
11
+ function init() {
12
+ const cwd = process.cwd();
13
+ return initConfig(cwd);
14
+ }
15
+ var cli = cac();
16
+ cli.command("install", "patch install").action(() => {
17
+ const twPatcher = new TailwindcssPatcher({
18
+ patch: getPatchOptions()
19
+ });
20
+ twPatcher.patch();
21
+ });
22
+ cli.command("init").action(async () => {
23
+ await init();
24
+ logger_default.success(`\u2728 ${CONFIG_NAME}.config.ts initialized!`);
25
+ });
26
+ cli.command("extract").action(async () => {
27
+ const { config } = await getConfig();
28
+ if (config) {
29
+ const twPatcher = new TailwindcssPatcher();
30
+ const p = await twPatcher.extract(config.patch);
31
+ logger_default.success(`\u2728 tailwindcss-patch extract success! file path: ${p}`);
32
+ }
33
+ });
34
+ cli.help();
35
+ cli.parse();
@@ -1,7 +1,9 @@
1
- import { UserConfig } from '@tailwindcss-mangle/config';
1
+ import { PatchUserConfig } from '@tailwindcss-mangle/config';
2
2
  export { defineConfig } from '@tailwindcss-mangle/config';
3
- import { Rule, Node } from 'postcss';
3
+ import { PackageJson } from 'pkg-types';
4
+ import { Node, Rule } from 'postcss';
4
5
  import { Config } from 'tailwindcss';
6
+ import { GlobEntry } from '@tailwindcss/oxide';
5
7
  import * as consola from 'consola';
6
8
 
7
9
  type CacheStrategy = 'merge' | 'overwrite';
@@ -10,6 +12,7 @@ interface PackageInfo {
10
12
  version: string | undefined;
11
13
  rootPath: string;
12
14
  packageJsonPath: string;
15
+ packageJson: PackageJson;
13
16
  }
14
17
  interface CacheOptions {
15
18
  dir?: string;
@@ -20,7 +23,7 @@ interface CacheOptions {
20
23
  interface InternalCacheOptions extends CacheOptions {
21
24
  enable?: boolean;
22
25
  }
23
- interface PatchOptions {
26
+ interface PatchOptions extends PatchUserConfig {
24
27
  overwrite?: boolean;
25
28
  paths?: string[];
26
29
  basedir?: string;
@@ -43,7 +46,7 @@ type TailwindcssClassCache = Map<string, ({
43
46
  } | Rule)[]>;
44
47
  interface TailwindcssRuntimeContext {
45
48
  applyClassCache: Map<any, any>;
46
- candidateRuleCache: Map<string | string, Set<[
49
+ candidateRuleCache: Map<string, Set<[
47
50
  {
48
51
  arbitrary: any;
49
52
  index: any;
@@ -99,34 +102,37 @@ declare class CacheManager {
99
102
  getOptions(options?: CacheOptions): Required<CacheOptions> & {
100
103
  filename: string;
101
104
  };
102
- write(data: Set<string>): string | undefined;
103
- read(): Set<string> | undefined;
105
+ write(data: Set<string>): Promise<string | undefined>;
106
+ read(): Promise<Set<string> | undefined>;
104
107
  }
105
108
 
109
+ interface ExtractValidCandidatesOption {
110
+ sources?: GlobEntry[];
111
+ base?: string;
112
+ css?: string;
113
+ }
114
+ declare function extractValidCandidates(options?: ExtractValidCandidatesOption): Promise<string[]>;
115
+
106
116
  declare class TailwindcssPatcher {
107
117
  rawOptions: TailwindcssPatcherOptions;
108
118
  cacheOptions: InternalCacheOptions;
109
119
  patchOptions: InternalPatchOptions;
110
120
  patch: () => void;
111
121
  cacheManager: CacheManager;
112
- packageInfo?: PackageInfo;
122
+ packageInfo: PackageInfo;
113
123
  majorVersion?: number;
114
124
  constructor(options?: TailwindcssPatcherOptions);
115
- setCache(set: Set<string>): string | undefined;
116
- getCache(): Set<string> | undefined;
125
+ setCache(set: Set<string>): Promise<string | undefined> | undefined;
126
+ getCache(): Promise<Set<string> | undefined>;
117
127
  getContexts(): TailwindcssRuntimeContext[];
118
128
  getClassCaches(): TailwindcssClassCache[];
119
- getClassCacheSet(options?: {
120
- removeUniversalSelector?: boolean;
121
- }): Set<string>;
129
+ getClassCacheSet(): Promise<Set<string>>;
122
130
  /**
123
131
  * @description 在多个 tailwindcss 上下文时,这个方法将被执行多次,所以策略上应该使用 append
124
132
  */
125
- getClassSet(options?: {
126
- cacheStrategy?: CacheStrategy;
127
- removeUniversalSelector?: boolean;
128
- }): Set<string>;
129
- extract(options?: UserConfig['patch']): Promise<string | undefined>;
133
+ getClassSet(): Promise<Set<string>>;
134
+ extract(options?: PatchUserConfig): Promise<string | undefined>;
135
+ extractValidCandidates: typeof extractValidCandidates;
130
136
  }
131
137
 
132
138
  declare function monkeyPatchForExposingContextV3(twDir: string, opt: InternalPatchOptions): Record<string, any> | undefined;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import { UserConfig } from '@tailwindcss-mangle/config';
1
+ import { PatchUserConfig } from '@tailwindcss-mangle/config';
2
2
  export { defineConfig } from '@tailwindcss-mangle/config';
3
- import { Rule, Node } from 'postcss';
3
+ import { PackageJson } from 'pkg-types';
4
+ import { Node, Rule } from 'postcss';
4
5
  import { Config } from 'tailwindcss';
6
+ import { GlobEntry } from '@tailwindcss/oxide';
5
7
  import * as consola from 'consola';
6
8
 
7
9
  type CacheStrategy = 'merge' | 'overwrite';
@@ -10,6 +12,7 @@ interface PackageInfo {
10
12
  version: string | undefined;
11
13
  rootPath: string;
12
14
  packageJsonPath: string;
15
+ packageJson: PackageJson;
13
16
  }
14
17
  interface CacheOptions {
15
18
  dir?: string;
@@ -20,7 +23,7 @@ interface CacheOptions {
20
23
  interface InternalCacheOptions extends CacheOptions {
21
24
  enable?: boolean;
22
25
  }
23
- interface PatchOptions {
26
+ interface PatchOptions extends PatchUserConfig {
24
27
  overwrite?: boolean;
25
28
  paths?: string[];
26
29
  basedir?: string;
@@ -43,7 +46,7 @@ type TailwindcssClassCache = Map<string, ({
43
46
  } | Rule)[]>;
44
47
  interface TailwindcssRuntimeContext {
45
48
  applyClassCache: Map<any, any>;
46
- candidateRuleCache: Map<string | string, Set<[
49
+ candidateRuleCache: Map<string, Set<[
47
50
  {
48
51
  arbitrary: any;
49
52
  index: any;
@@ -99,34 +102,37 @@ declare class CacheManager {
99
102
  getOptions(options?: CacheOptions): Required<CacheOptions> & {
100
103
  filename: string;
101
104
  };
102
- write(data: Set<string>): string | undefined;
103
- read(): Set<string> | undefined;
105
+ write(data: Set<string>): Promise<string | undefined>;
106
+ read(): Promise<Set<string> | undefined>;
104
107
  }
105
108
 
109
+ interface ExtractValidCandidatesOption {
110
+ sources?: GlobEntry[];
111
+ base?: string;
112
+ css?: string;
113
+ }
114
+ declare function extractValidCandidates(options?: ExtractValidCandidatesOption): Promise<string[]>;
115
+
106
116
  declare class TailwindcssPatcher {
107
117
  rawOptions: TailwindcssPatcherOptions;
108
118
  cacheOptions: InternalCacheOptions;
109
119
  patchOptions: InternalPatchOptions;
110
120
  patch: () => void;
111
121
  cacheManager: CacheManager;
112
- packageInfo?: PackageInfo;
122
+ packageInfo: PackageInfo;
113
123
  majorVersion?: number;
114
124
  constructor(options?: TailwindcssPatcherOptions);
115
- setCache(set: Set<string>): string | undefined;
116
- getCache(): Set<string> | undefined;
125
+ setCache(set: Set<string>): Promise<string | undefined> | undefined;
126
+ getCache(): Promise<Set<string> | undefined>;
117
127
  getContexts(): TailwindcssRuntimeContext[];
118
128
  getClassCaches(): TailwindcssClassCache[];
119
- getClassCacheSet(options?: {
120
- removeUniversalSelector?: boolean;
121
- }): Set<string>;
129
+ getClassCacheSet(): Promise<Set<string>>;
122
130
  /**
123
131
  * @description 在多个 tailwindcss 上下文时,这个方法将被执行多次,所以策略上应该使用 append
124
132
  */
125
- getClassSet(options?: {
126
- cacheStrategy?: CacheStrategy;
127
- removeUniversalSelector?: boolean;
128
- }): Set<string>;
129
- extract(options?: UserConfig['patch']): Promise<string | undefined>;
133
+ getClassSet(): Promise<Set<string>>;
134
+ extract(options?: PatchUserConfig): Promise<string | undefined>;
135
+ extractValidCandidates: typeof extractValidCandidates;
130
136
  }
131
137
 
132
138
  declare function monkeyPatchForExposingContextV3(twDir: string, opt: InternalPatchOptions): Record<string, any> | undefined;
package/dist/index.js CHANGED
@@ -1,23 +1,24 @@
1
- import {
2
- CacheManager,
3
- TailwindcssPatcher,
4
- config_exports,
5
- getCacheOptions,
6
- internalPatch,
7
- logger_default,
8
- monkeyPatchForExposingContextV2,
9
- monkeyPatchForExposingContextV3,
10
- monkeyPatchForSupportingCustomUnit
11
- } from "./chunk-LOQK6LST.js";
12
- var export_defineConfig = config_exports.defineConfig;
13
- export {
14
- CacheManager,
15
- TailwindcssPatcher,
16
- export_defineConfig as defineConfig,
17
- getCacheOptions,
18
- internalPatch,
19
- logger_default as logger,
20
- monkeyPatchForExposingContextV2,
21
- monkeyPatchForExposingContextV3,
22
- monkeyPatchForSupportingCustomUnit
23
- };
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+ var _chunkU3S6WRCPjs = require('./chunk-U3S6WRCP.js');
11
+
12
+ // src/index.ts
13
+ var _config = require('@tailwindcss-mangle/config');
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+ exports.CacheManager = _chunkU3S6WRCPjs.CacheManager; exports.TailwindcssPatcher = _chunkU3S6WRCPjs.TailwindcssPatcher; exports.defineConfig = _config.defineConfig; exports.getCacheOptions = _chunkU3S6WRCPjs.getCacheOptions; exports.internalPatch = _chunkU3S6WRCPjs.internalPatch; exports.logger = _chunkU3S6WRCPjs.logger_default; exports.monkeyPatchForExposingContextV2 = _chunkU3S6WRCPjs.monkeyPatchForExposingContextV2; exports.monkeyPatchForExposingContextV3 = _chunkU3S6WRCPjs.monkeyPatchForExposingContextV3; exports.monkeyPatchForSupportingCustomUnit = _chunkU3S6WRCPjs.monkeyPatchForSupportingCustomUnit;
package/dist/index.mjs ADDED
@@ -0,0 +1,24 @@
1
+ import {
2
+ CacheManager,
3
+ TailwindcssPatcher,
4
+ getCacheOptions,
5
+ internalPatch,
6
+ logger_default,
7
+ monkeyPatchForExposingContextV2,
8
+ monkeyPatchForExposingContextV3,
9
+ monkeyPatchForSupportingCustomUnit
10
+ } from "./chunk-U2NQZPXE.mjs";
11
+
12
+ // src/index.ts
13
+ import { defineConfig } from "@tailwindcss-mangle/config";
14
+ export {
15
+ CacheManager,
16
+ TailwindcssPatcher,
17
+ defineConfig,
18
+ getCacheOptions,
19
+ internalPatch,
20
+ logger_default as logger,
21
+ monkeyPatchForExposingContextV2,
22
+ monkeyPatchForExposingContextV3,
23
+ monkeyPatchForSupportingCustomUnit
24
+ };
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "tailwindcss-patch",
3
- "type": "module",
4
- "version": "5.0.2",
3
+ "version": "6.0.1",
5
4
  "description": "patch tailwindcss for exposing context and extract classes",
6
5
  "author": "ice breaker <1324318532@qq.com>",
7
6
  "license": "MIT",
@@ -23,12 +22,12 @@
23
22
  "exports": {
24
23
  ".": {
25
24
  "types": "./dist/index.d.ts",
26
- "import": "./dist/index.js",
27
- "require": "./dist/index.cjs"
25
+ "import": "./dist/index.mjs",
26
+ "require": "./dist/index.js"
28
27
  }
29
28
  },
30
- "main": "./dist/index.cjs",
31
- "module": "./dist/index.js",
29
+ "main": "./dist/index.js",
30
+ "module": "./dist/index.mjs",
32
31
  "types": "./dist/index.d.ts",
33
32
  "bin": {
34
33
  "tw-patch": "bin/tw-patch.js",
@@ -51,20 +50,28 @@
51
50
  }
52
51
  },
53
52
  "dependencies": {
54
- "@babel/generator": "^7.26.2",
55
- "@babel/parser": "^7.26.2",
56
- "@babel/traverse": "^7.25.9",
57
- "@babel/types": "^7.26.0",
53
+ "@babel/generator": "^7.26.9",
54
+ "@babel/parser": "^7.26.9",
55
+ "@babel/traverse": "^7.26.9",
56
+ "@babel/types": "^7.26.9",
58
57
  "cac": "^6.7.14",
59
- "consola": "^3.2.3",
60
- "fs-extra": "^11.2.0",
61
- "jiti": "^2.4.0",
62
- "lilconfig": "^3.1.2",
63
- "pathe": "^1.1.2",
64
- "postcss": "^8.4.47",
65
- "resolve": "^1.22.8",
66
- "semver": "^7.6.3",
67
- "@tailwindcss-mangle/config": "^4.0.1"
58
+ "consola": "^3.4.0",
59
+ "fs-extra": "^11.3.0",
60
+ "local-pkg": "^1.0.0",
61
+ "pathe": "^2.0.3",
62
+ "postcss": "^8.5.2",
63
+ "semver": "^7.7.1",
64
+ "tailwindcss-config": "^1.0.0",
65
+ "@tailwindcss-mangle/config": "^5.0.0"
66
+ },
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",
72
+ "tailwindcss": "^4.0.6",
73
+ "tailwindcss-3": "npm:tailwindcss@^3",
74
+ "tailwindcss-4": "npm:tailwindcss@^4"
68
75
  },
69
76
  "scripts": {
70
77
  "dev": "tsup --watch --sourcemap",