tailwindcss-patch 5.0.0 → 5.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.
@@ -0,0 +1,143 @@
1
+ import { UserConfig } from '@tailwindcss-mangle/config';
2
+ export { defineConfig } from '@tailwindcss-mangle/config';
3
+ import { Rule, Node } from 'postcss';
4
+ import { Config } from 'tailwindcss';
5
+ import * as consola from 'consola';
6
+
7
+ type CacheStrategy = 'merge' | 'overwrite';
8
+ interface PackageInfo {
9
+ name: string;
10
+ version: string | undefined;
11
+ rootPath: string;
12
+ packageJsonPath: string;
13
+ }
14
+ interface CacheOptions {
15
+ dir?: string;
16
+ cwd?: string;
17
+ file?: string;
18
+ strategy?: CacheStrategy;
19
+ }
20
+ interface InternalCacheOptions extends CacheOptions {
21
+ enable?: boolean;
22
+ }
23
+ interface PatchOptions {
24
+ overwrite?: boolean;
25
+ paths?: string[];
26
+ basedir?: string;
27
+ applyPatches?: {
28
+ exportContext?: boolean;
29
+ extendLengthUnits?: boolean | ILengthUnitsPatchOptions;
30
+ };
31
+ }
32
+ interface InternalPatchOptions extends PatchOptions {
33
+ version?: string;
34
+ }
35
+ interface TailwindcssPatcherOptions {
36
+ cache?: CacheOptions | boolean;
37
+ patch?: PatchOptions;
38
+ }
39
+ type TailwindcssClassCache = Map<string, ({
40
+ layer: string;
41
+ options: Record<string, any>;
42
+ sort: Record<string, any>;
43
+ } | Rule)[]>;
44
+ interface TailwindcssRuntimeContext {
45
+ applyClassCache: Map<any, any>;
46
+ candidateRuleCache: Map<string | string, Set<[
47
+ {
48
+ arbitrary: any;
49
+ index: any;
50
+ layer: string;
51
+ options: any[];
52
+ parallelIndex: any;
53
+ parentLayer: string;
54
+ variants: any;
55
+ },
56
+ Node
57
+ ]>>;
58
+ candidateRuleMap: Map<string | string, [object, Node][]>;
59
+ changedContent: any[];
60
+ classCache: TailwindcssClassCache;
61
+ disposables: any[];
62
+ getClassList: Function;
63
+ getClassOrder: Function;
64
+ getVariants: Function;
65
+ markInvalidUtilityCandidate: Function;
66
+ markInvalidUtilityNode: Function;
67
+ notClassCache: Set<string>;
68
+ offsets: {
69
+ layerPositions: object;
70
+ offsets: object;
71
+ reservedVariantBits: any;
72
+ variantOffsets: Map<string, any>;
73
+ };
74
+ postCssNodeCache: Map<object, [Node]>;
75
+ ruleCache: Set<[object, Node]>;
76
+ stylesheetCache: Record<string, Set<any>>;
77
+ tailwindConfig: Config;
78
+ userConfigPath: string | null;
79
+ variantMap: Map<string, [[object, Function]]>;
80
+ variantOptions: Map<string, object>;
81
+ }
82
+ type DeepRequired<T> = {
83
+ [K in keyof T]: Required<DeepRequired<T[K]>>;
84
+ };
85
+ interface ILengthUnitsPatchOptions {
86
+ units: string[];
87
+ lengthUnitsFilePath?: string;
88
+ variableName?: string;
89
+ overwrite?: boolean;
90
+ destPath?: string;
91
+ }
92
+
93
+ declare function getCacheOptions(options?: CacheOptions | boolean): InternalCacheOptions;
94
+ declare class CacheManager {
95
+ options: Required<CacheOptions> & {
96
+ filename: string;
97
+ };
98
+ constructor(options?: CacheOptions);
99
+ getOptions(options?: CacheOptions): Required<CacheOptions> & {
100
+ filename: string;
101
+ };
102
+ write(data: Set<string>): string | undefined;
103
+ read(): Set<string> | undefined;
104
+ }
105
+
106
+ declare class TailwindcssPatcher {
107
+ rawOptions: TailwindcssPatcherOptions;
108
+ cacheOptions: InternalCacheOptions;
109
+ patchOptions: InternalPatchOptions;
110
+ patch: () => void;
111
+ cacheManager: CacheManager;
112
+ packageInfo?: PackageInfo;
113
+ majorVersion?: number;
114
+ constructor(options?: TailwindcssPatcherOptions);
115
+ setCache(set: Set<string>): string | undefined;
116
+ getCache(): Set<string> | undefined;
117
+ getContexts(): TailwindcssRuntimeContext[];
118
+ getClassCaches(): TailwindcssClassCache[];
119
+ getClassCacheSet(options?: {
120
+ removeUniversalSelector?: boolean;
121
+ }): Set<string>;
122
+ /**
123
+ * @description 在多个 tailwindcss 上下文时,这个方法将被执行多次,所以策略上应该使用 append
124
+ */
125
+ getClassSet(options?: {
126
+ cacheStrategy?: CacheStrategy;
127
+ removeUniversalSelector?: boolean;
128
+ }): Set<string>;
129
+ extract(options?: UserConfig['patch']): Promise<string | undefined>;
130
+ }
131
+
132
+ declare function monkeyPatchForExposingContextV3(twDir: string, opt: InternalPatchOptions): Record<string, any> | undefined;
133
+ declare function monkeyPatchForExposingContextV2(twDir: string, opt: InternalPatchOptions): Record<string, any>;
134
+
135
+ declare function monkeyPatchForSupportingCustomUnit(rootDir: string, options?: Partial<ILengthUnitsPatchOptions>): {
136
+ [x: string]: string;
137
+ } | undefined;
138
+
139
+ declare function internalPatch(pkgJsonPath: string | undefined, options: InternalPatchOptions): Record<string, any> | undefined;
140
+
141
+ declare const logger: consola.ConsolaInstance;
142
+
143
+ export { CacheManager, type CacheOptions, type CacheStrategy, type DeepRequired, type ILengthUnitsPatchOptions, type InternalCacheOptions, type InternalPatchOptions, type PackageInfo, type PatchOptions, type TailwindcssClassCache, TailwindcssPatcher, type TailwindcssPatcherOptions, type TailwindcssRuntimeContext, getCacheOptions, internalPatch, logger, monkeyPatchForExposingContextV2, monkeyPatchForExposingContextV3, monkeyPatchForSupportingCustomUnit };
@@ -0,0 +1,143 @@
1
+ import { UserConfig } from '@tailwindcss-mangle/config';
2
+ export { defineConfig } from '@tailwindcss-mangle/config';
3
+ import { Rule, Node } from 'postcss';
4
+ import { Config } from 'tailwindcss';
5
+ import * as consola from 'consola';
6
+
7
+ type CacheStrategy = 'merge' | 'overwrite';
8
+ interface PackageInfo {
9
+ name: string;
10
+ version: string | undefined;
11
+ rootPath: string;
12
+ packageJsonPath: string;
13
+ }
14
+ interface CacheOptions {
15
+ dir?: string;
16
+ cwd?: string;
17
+ file?: string;
18
+ strategy?: CacheStrategy;
19
+ }
20
+ interface InternalCacheOptions extends CacheOptions {
21
+ enable?: boolean;
22
+ }
23
+ interface PatchOptions {
24
+ overwrite?: boolean;
25
+ paths?: string[];
26
+ basedir?: string;
27
+ applyPatches?: {
28
+ exportContext?: boolean;
29
+ extendLengthUnits?: boolean | ILengthUnitsPatchOptions;
30
+ };
31
+ }
32
+ interface InternalPatchOptions extends PatchOptions {
33
+ version?: string;
34
+ }
35
+ interface TailwindcssPatcherOptions {
36
+ cache?: CacheOptions | boolean;
37
+ patch?: PatchOptions;
38
+ }
39
+ type TailwindcssClassCache = Map<string, ({
40
+ layer: string;
41
+ options: Record<string, any>;
42
+ sort: Record<string, any>;
43
+ } | Rule)[]>;
44
+ interface TailwindcssRuntimeContext {
45
+ applyClassCache: Map<any, any>;
46
+ candidateRuleCache: Map<string | string, Set<[
47
+ {
48
+ arbitrary: any;
49
+ index: any;
50
+ layer: string;
51
+ options: any[];
52
+ parallelIndex: any;
53
+ parentLayer: string;
54
+ variants: any;
55
+ },
56
+ Node
57
+ ]>>;
58
+ candidateRuleMap: Map<string | string, [object, Node][]>;
59
+ changedContent: any[];
60
+ classCache: TailwindcssClassCache;
61
+ disposables: any[];
62
+ getClassList: Function;
63
+ getClassOrder: Function;
64
+ getVariants: Function;
65
+ markInvalidUtilityCandidate: Function;
66
+ markInvalidUtilityNode: Function;
67
+ notClassCache: Set<string>;
68
+ offsets: {
69
+ layerPositions: object;
70
+ offsets: object;
71
+ reservedVariantBits: any;
72
+ variantOffsets: Map<string, any>;
73
+ };
74
+ postCssNodeCache: Map<object, [Node]>;
75
+ ruleCache: Set<[object, Node]>;
76
+ stylesheetCache: Record<string, Set<any>>;
77
+ tailwindConfig: Config;
78
+ userConfigPath: string | null;
79
+ variantMap: Map<string, [[object, Function]]>;
80
+ variantOptions: Map<string, object>;
81
+ }
82
+ type DeepRequired<T> = {
83
+ [K in keyof T]: Required<DeepRequired<T[K]>>;
84
+ };
85
+ interface ILengthUnitsPatchOptions {
86
+ units: string[];
87
+ lengthUnitsFilePath?: string;
88
+ variableName?: string;
89
+ overwrite?: boolean;
90
+ destPath?: string;
91
+ }
92
+
93
+ declare function getCacheOptions(options?: CacheOptions | boolean): InternalCacheOptions;
94
+ declare class CacheManager {
95
+ options: Required<CacheOptions> & {
96
+ filename: string;
97
+ };
98
+ constructor(options?: CacheOptions);
99
+ getOptions(options?: CacheOptions): Required<CacheOptions> & {
100
+ filename: string;
101
+ };
102
+ write(data: Set<string>): string | undefined;
103
+ read(): Set<string> | undefined;
104
+ }
105
+
106
+ declare class TailwindcssPatcher {
107
+ rawOptions: TailwindcssPatcherOptions;
108
+ cacheOptions: InternalCacheOptions;
109
+ patchOptions: InternalPatchOptions;
110
+ patch: () => void;
111
+ cacheManager: CacheManager;
112
+ packageInfo?: PackageInfo;
113
+ majorVersion?: number;
114
+ constructor(options?: TailwindcssPatcherOptions);
115
+ setCache(set: Set<string>): string | undefined;
116
+ getCache(): Set<string> | undefined;
117
+ getContexts(): TailwindcssRuntimeContext[];
118
+ getClassCaches(): TailwindcssClassCache[];
119
+ getClassCacheSet(options?: {
120
+ removeUniversalSelector?: boolean;
121
+ }): Set<string>;
122
+ /**
123
+ * @description 在多个 tailwindcss 上下文时,这个方法将被执行多次,所以策略上应该使用 append
124
+ */
125
+ getClassSet(options?: {
126
+ cacheStrategy?: CacheStrategy;
127
+ removeUniversalSelector?: boolean;
128
+ }): Set<string>;
129
+ extract(options?: UserConfig['patch']): Promise<string | undefined>;
130
+ }
131
+
132
+ declare function monkeyPatchForExposingContextV3(twDir: string, opt: InternalPatchOptions): Record<string, any> | undefined;
133
+ declare function monkeyPatchForExposingContextV2(twDir: string, opt: InternalPatchOptions): Record<string, any>;
134
+
135
+ declare function monkeyPatchForSupportingCustomUnit(rootDir: string, options?: Partial<ILengthUnitsPatchOptions>): {
136
+ [x: string]: string;
137
+ } | undefined;
138
+
139
+ declare function internalPatch(pkgJsonPath: string | undefined, options: InternalPatchOptions): Record<string, any> | undefined;
140
+
141
+ declare const logger: consola.ConsolaInstance;
142
+
143
+ export { CacheManager, type CacheOptions, type CacheStrategy, type DeepRequired, type ILengthUnitsPatchOptions, type InternalCacheOptions, type InternalPatchOptions, type PackageInfo, type PatchOptions, type TailwindcssClassCache, TailwindcssPatcher, type TailwindcssPatcherOptions, type TailwindcssRuntimeContext, getCacheOptions, internalPatch, logger, monkeyPatchForExposingContextV2, monkeyPatchForExposingContextV3, monkeyPatchForSupportingCustomUnit };
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
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-P2MLMFLP.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
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tailwindcss-patch",
3
3
  "type": "module",
4
- "version": "5.0.0",
4
+ "version": "5.0.1",
5
5
  "description": "patch tailwindcss for exposing context and extract classes",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -64,7 +64,7 @@
64
64
  "resolve": "^1.22.8",
65
65
  "semver": "^7.6.3",
66
66
  "tsx": "^4.19.2",
67
- "@tailwindcss-mangle/config": "^4.0.0"
67
+ "@tailwindcss-mangle/config": "^4.0.1"
68
68
  },
69
69
  "scripts": {
70
70
  "dev": "tsup --watch --sourcemap",