tailwindcss-patch 2.1.0 → 2.2.0
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/README.md +57 -13
- package/dist/cli.d.cts +2 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.d.ts +1 -1
- package/dist/index.cjs +18 -0
- package/dist/index.d.cts +149 -0
- package/dist/index.d.mts +149 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +18 -0
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
# tailwindcss-patch
|
|
2
2
|
|
|
3
|
+
\[[中文(zh-cn)](./README-cn.md)\]
|
|
4
|
+
|
|
3
5
|
get tailwindcss context at runtime ! extract all classes into file!
|
|
4
6
|
|
|
5
7
|
- [tailwindcss-patch](#tailwindcss-patch)
|
|
6
8
|
- [Setup](#setup)
|
|
7
9
|
- [Usage](#usage)
|
|
8
10
|
- [Cli](#cli)
|
|
9
|
-
- [Init Config File](#init-config-file)
|
|
10
11
|
- [Extract all class into a json](#extract-all-class-into-a-json)
|
|
11
|
-
|
|
12
|
+
- [Nodejs API](#nodejs-api)
|
|
13
|
+
- [Config](#config)
|
|
14
|
+
- [Init Config File](#init-config-file)
|
|
12
15
|
- [Migration form v1 to v2](#migration-form-v1-to-v2)
|
|
13
16
|
- [0. cli command change](#0-cli-command-change)
|
|
14
17
|
- [1. default remove `*` in json array result](#1-default-remove--in-json-array-result)
|
|
18
|
+
- [What's next?](#whats-next)
|
|
15
19
|
|
|
16
20
|
> Nodejs version should >= `16.6.0`
|
|
17
21
|
|
|
@@ -20,7 +24,7 @@ get tailwindcss context at runtime ! extract all classes into file!
|
|
|
20
24
|
1. Install package
|
|
21
25
|
|
|
22
26
|
```sh
|
|
23
|
-
<yarn|npm|pnpm> add -D
|
|
27
|
+
<yarn|npm|pnpm> add -D tailwindcss-patch
|
|
24
28
|
```
|
|
25
29
|
|
|
26
30
|
2. Patch tailwindcss
|
|
@@ -46,36 +50,68 @@ npx tw-patch install
|
|
|
46
50
|
|
|
47
51
|
## Cli
|
|
48
52
|
|
|
49
|
-
### Init Config File
|
|
50
|
-
|
|
51
|
-
```sh
|
|
52
|
-
tw-patch init
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
Then there will be a ts file called `tailwindcss-mangle.config.ts` exist in your `cwd`.
|
|
56
|
-
|
|
57
53
|
### Extract all class into a json
|
|
58
54
|
|
|
59
55
|
```sh
|
|
60
|
-
tw-patch extract
|
|
56
|
+
npx tw-patch extract
|
|
61
57
|
```
|
|
62
58
|
|
|
63
59
|
default there will be a json in `.tw-patch/tw-class-list.json` in your project.
|
|
64
60
|
|
|
65
61
|
you can custom this behavior by config `tailwindcss-mangle.config.ts`
|
|
66
62
|
|
|
67
|
-
|
|
63
|
+
## Nodejs API
|
|
68
64
|
|
|
69
65
|
```js
|
|
70
66
|
import { TailwindcssPatcher } from 'tailwindcss-patch'
|
|
71
67
|
|
|
72
68
|
const twPatcher = new TailwindcssPatcher(/* options */)
|
|
69
|
+
// do patch
|
|
70
|
+
twPatcher.patch()
|
|
73
71
|
// get all contexts at runtime
|
|
74
72
|
twPatcher.getContexts()
|
|
75
73
|
// get all class generated by tailwindcss utilities
|
|
76
74
|
twPatcher.getClassSet()
|
|
77
75
|
```
|
|
78
76
|
|
|
77
|
+
## Config
|
|
78
|
+
|
|
79
|
+
### Init Config File
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
npx tw-patch init
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Then there will be a ts file called `tailwindcss-mangle.config.ts` exist in your `cwd`.
|
|
86
|
+
|
|
87
|
+
The config as follows:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { defineConfig } from 'tailwindcss-patch'
|
|
91
|
+
|
|
92
|
+
export default defineConfig({})
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
you can custom `tw-patch` behavior by `patch` option:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
import { defineConfig } from 'tailwindcss-patch'
|
|
99
|
+
|
|
100
|
+
export default defineConfig({
|
|
101
|
+
patch: {
|
|
102
|
+
output: {
|
|
103
|
+
filename: 'xxx.json',
|
|
104
|
+
loose: true,
|
|
105
|
+
removeUniversalSelector: true
|
|
106
|
+
},
|
|
107
|
+
tailwindcss: {
|
|
108
|
+
config: 'path/to/your-tailwind.config.js',
|
|
109
|
+
cwd: 'project/cwd'
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
```
|
|
114
|
+
|
|
79
115
|
## Migration form v1 to v2
|
|
80
116
|
|
|
81
117
|
### 0. cli command change
|
|
@@ -96,3 +132,11 @@ twPatcher.getClassSet()
|
|
|
96
132
|
"text-[100px]"
|
|
97
133
|
]
|
|
98
134
|
```
|
|
135
|
+
|
|
136
|
+
## What's next?
|
|
137
|
+
|
|
138
|
+
At the moment I just extracted all the tool classes to actually get the context of `tailwindcss` to analyze. You can add more functionality to this project by giving me `issue` or `pr`.
|
|
139
|
+
|
|
140
|
+
Of course, the extracted `JSON` isn't just for you to look at. You can analyze it, and I use it as a data file for my `tailwindcss-mangle`.
|
|
141
|
+
|
|
142
|
+
The `tailwindcss-mangle` itself is an obfuscation tool to obfuscate the tools generated by `tailwindcss`, see the next article for more details on how to use it.
|
package/dist/cli.d.cts
ADDED
package/dist/cli.d.mts
ADDED
package/dist/cli.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
export {
|
|
2
|
+
export { }
|
package/dist/index.cjs
CHANGED
|
@@ -109,6 +109,12 @@ function log(message, ...optionalParams) {
|
|
|
109
109
|
return console.log(`[${pkgName}]:` + message, ...optionalParams);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
var __defProp$1 = Object.defineProperty;
|
|
113
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
114
|
+
var __publicField$1 = (obj, key, value) => {
|
|
115
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
116
|
+
return value;
|
|
117
|
+
};
|
|
112
118
|
function getCacheOptions(options) {
|
|
113
119
|
let cache;
|
|
114
120
|
switch (typeof options) {
|
|
@@ -133,6 +139,7 @@ function getCacheOptions(options) {
|
|
|
133
139
|
}
|
|
134
140
|
class CacheManager {
|
|
135
141
|
constructor(options = {}) {
|
|
142
|
+
__publicField$1(this, "options");
|
|
136
143
|
this.options = this.getOptions(options);
|
|
137
144
|
}
|
|
138
145
|
mkdir(cacheDirectory) {
|
|
@@ -473,8 +480,19 @@ async function processTailwindcss(options) {
|
|
|
473
480
|
});
|
|
474
481
|
}
|
|
475
482
|
|
|
483
|
+
var __defProp = Object.defineProperty;
|
|
484
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
485
|
+
var __publicField = (obj, key, value) => {
|
|
486
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
487
|
+
return value;
|
|
488
|
+
};
|
|
476
489
|
class TailwindcssPatcher {
|
|
477
490
|
constructor(options = {}) {
|
|
491
|
+
__publicField(this, "rawOptions");
|
|
492
|
+
__publicField(this, "cacheOptions");
|
|
493
|
+
__publicField(this, "patchOptions");
|
|
494
|
+
__publicField(this, "patch");
|
|
495
|
+
__publicField(this, "cacheManager");
|
|
478
496
|
this.rawOptions = options;
|
|
479
497
|
this.cacheOptions = getCacheOptions(options.cache);
|
|
480
498
|
this.patchOptions = getPatchOptions(options.patch);
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { Rule, Node } from 'postcss';
|
|
2
|
+
import { Config } from 'tailwindcss';
|
|
3
|
+
import { UserConfig } from '@tailwindcss-mangle/config';
|
|
4
|
+
export * from '@tailwindcss-mangle/config';
|
|
5
|
+
import { SyncOpts } from 'resolve';
|
|
6
|
+
|
|
7
|
+
type CacheStrategy = 'merge' | 'overwrite';
|
|
8
|
+
interface CacheOptions {
|
|
9
|
+
dir?: string;
|
|
10
|
+
cwd?: string;
|
|
11
|
+
file?: string;
|
|
12
|
+
strategy?: CacheStrategy;
|
|
13
|
+
}
|
|
14
|
+
type InternalCacheOptions = CacheOptions & {
|
|
15
|
+
enable?: boolean;
|
|
16
|
+
};
|
|
17
|
+
interface PatchOptions {
|
|
18
|
+
overwrite?: boolean;
|
|
19
|
+
paths?: string[];
|
|
20
|
+
basedir?: string;
|
|
21
|
+
custom?: (dir: string, ctx: Record<string, any>) => void;
|
|
22
|
+
}
|
|
23
|
+
interface InternalPatchOptions {
|
|
24
|
+
overwrite: boolean;
|
|
25
|
+
paths?: string[];
|
|
26
|
+
basedir?: string;
|
|
27
|
+
custom?: (dir: string, ctx: Record<string, any>) => void;
|
|
28
|
+
version?: string;
|
|
29
|
+
}
|
|
30
|
+
interface TailwindcssPatcherOptions {
|
|
31
|
+
cache?: CacheOptions | boolean;
|
|
32
|
+
patch?: PatchOptions;
|
|
33
|
+
}
|
|
34
|
+
type TailwindcssClassCache = Map<string, ({
|
|
35
|
+
layer: string;
|
|
36
|
+
options: Record<string, any>;
|
|
37
|
+
sort: Record<string, any>;
|
|
38
|
+
} | Rule)[]>;
|
|
39
|
+
type TailwindcssRuntimeContext = {
|
|
40
|
+
applyClassCache: Map<any, any>;
|
|
41
|
+
candidateRuleCache: Map<string | string, Set<[
|
|
42
|
+
{
|
|
43
|
+
arbitrary: any;
|
|
44
|
+
index: any;
|
|
45
|
+
layer: string;
|
|
46
|
+
options: any[];
|
|
47
|
+
parallelIndex: any;
|
|
48
|
+
parentLayer: string;
|
|
49
|
+
variants: any;
|
|
50
|
+
},
|
|
51
|
+
Node
|
|
52
|
+
]>>;
|
|
53
|
+
candidateRuleMap: Map<string | string, [object, Node][]>;
|
|
54
|
+
changedContent: any[];
|
|
55
|
+
classCache: TailwindcssClassCache;
|
|
56
|
+
disposables: any[];
|
|
57
|
+
getClassList: Function;
|
|
58
|
+
getClassOrder: Function;
|
|
59
|
+
getVariants: Function;
|
|
60
|
+
markInvalidUtilityCandidate: Function;
|
|
61
|
+
markInvalidUtilityNode: Function;
|
|
62
|
+
notClassCache: Set<string>;
|
|
63
|
+
offsets: {
|
|
64
|
+
layerPositions: object;
|
|
65
|
+
offsets: object;
|
|
66
|
+
reservedVariantBits: any;
|
|
67
|
+
variantOffsets: Map<string, any>;
|
|
68
|
+
};
|
|
69
|
+
postCssNodeCache: Map<object, [Node]>;
|
|
70
|
+
ruleCache: Set<[object, Node]>;
|
|
71
|
+
stylesheetCache: Record<string, Set<any>>;
|
|
72
|
+
tailwindConfig: Config;
|
|
73
|
+
userConfigPath: string | null;
|
|
74
|
+
variantMap: Map<string, [[object, Function]]>;
|
|
75
|
+
variantOptions: Map<string, object>;
|
|
76
|
+
};
|
|
77
|
+
type DeepRequired<T> = {
|
|
78
|
+
[K in keyof T]: Required<DeepRequired<T[K]>>;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
declare function getCacheOptions(options?: CacheOptions | boolean): InternalCacheOptions;
|
|
82
|
+
declare class CacheManager {
|
|
83
|
+
options: Required<CacheOptions> & {
|
|
84
|
+
filename: string;
|
|
85
|
+
};
|
|
86
|
+
constructor(options?: CacheOptions);
|
|
87
|
+
mkdir(cacheDirectory: string): string;
|
|
88
|
+
getOptions(options?: CacheOptions): Required<CacheOptions> & {
|
|
89
|
+
filename: string;
|
|
90
|
+
};
|
|
91
|
+
write(data: Set<string>): string | undefined;
|
|
92
|
+
read(): Set<string> | undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
declare class TailwindcssPatcher {
|
|
96
|
+
rawOptions: TailwindcssPatcherOptions;
|
|
97
|
+
cacheOptions: InternalCacheOptions;
|
|
98
|
+
patchOptions: InternalPatchOptions;
|
|
99
|
+
patch: () => void;
|
|
100
|
+
cacheManager: CacheManager;
|
|
101
|
+
constructor(options?: TailwindcssPatcherOptions);
|
|
102
|
+
getPkgEntry(basedir?: string): string;
|
|
103
|
+
setCache(set: Set<string>): string | undefined;
|
|
104
|
+
getCache(): Set<string> | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* @description 在多个 tailwindcss 上下文时,这个方法将被执行多次,所以策略上应该使用 append
|
|
107
|
+
* 详见 taro weapp-tailwindcss 独立分包
|
|
108
|
+
* @param basedir
|
|
109
|
+
* @returns
|
|
110
|
+
*/
|
|
111
|
+
getClassSet(options?: {
|
|
112
|
+
basedir?: string;
|
|
113
|
+
cacheStrategy?: CacheStrategy;
|
|
114
|
+
removeUniversalSelector?: boolean;
|
|
115
|
+
}): Set<string>;
|
|
116
|
+
getContexts(basedir?: string): TailwindcssRuntimeContext[];
|
|
117
|
+
extract(options: UserConfig['patch']): Promise<string | undefined>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
declare function getTailwindcssEntry(basedir?: string): string;
|
|
121
|
+
declare function getContexts(basedir?: string): TailwindcssRuntimeContext[];
|
|
122
|
+
declare function getClassCaches(basedir?: string): TailwindcssClassCache[];
|
|
123
|
+
declare function getClassCacheSet(basedir?: string, options?: {
|
|
124
|
+
removeUniversalSelector?: boolean;
|
|
125
|
+
}): Set<string>;
|
|
126
|
+
|
|
127
|
+
declare function inspectProcessTailwindFeaturesReturnContext(content: string): {
|
|
128
|
+
code: string;
|
|
129
|
+
hasPatched: boolean;
|
|
130
|
+
};
|
|
131
|
+
declare function inspectPostcssPlugin(content: string): {
|
|
132
|
+
code: string;
|
|
133
|
+
hasPatched: boolean;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
declare function getInstalledPkgJsonPath(options?: PatchOptions): string | undefined;
|
|
137
|
+
declare function getPatchOptions(options?: PatchOptions): InternalPatchOptions;
|
|
138
|
+
declare function createPatch(opt: InternalPatchOptions): () => any;
|
|
139
|
+
declare function monkeyPatchForExposingContext(twDir: string, opt: InternalPatchOptions): {
|
|
140
|
+
processTailwindFeatures?: string | undefined;
|
|
141
|
+
plugin?: string | undefined;
|
|
142
|
+
} & Record<string, any>;
|
|
143
|
+
declare function internalPatch(pkgJsonPath: string | undefined, options: InternalPatchOptions): any | undefined;
|
|
144
|
+
|
|
145
|
+
declare function ensureFileContent(filepaths: string | string[]): string | undefined;
|
|
146
|
+
declare function requireResolve(id: string, opts?: SyncOpts): string;
|
|
147
|
+
declare function ensureDir(p: string): Promise<void>;
|
|
148
|
+
|
|
149
|
+
export { CacheManager, type CacheOptions, type CacheStrategy, type DeepRequired, type InternalCacheOptions, type InternalPatchOptions, type PatchOptions, type TailwindcssClassCache, TailwindcssPatcher, type TailwindcssPatcherOptions, type TailwindcssRuntimeContext, createPatch, ensureDir, ensureFileContent, getCacheOptions, getClassCacheSet, getClassCaches, getContexts, getInstalledPkgJsonPath, getPatchOptions, getTailwindcssEntry, inspectPostcssPlugin, inspectProcessTailwindFeaturesReturnContext, internalPatch, monkeyPatchForExposingContext, requireResolve };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { Rule, Node } from 'postcss';
|
|
2
|
+
import { Config } from 'tailwindcss';
|
|
3
|
+
import { UserConfig } from '@tailwindcss-mangle/config';
|
|
4
|
+
export * from '@tailwindcss-mangle/config';
|
|
5
|
+
import { SyncOpts } from 'resolve';
|
|
6
|
+
|
|
7
|
+
type CacheStrategy = 'merge' | 'overwrite';
|
|
8
|
+
interface CacheOptions {
|
|
9
|
+
dir?: string;
|
|
10
|
+
cwd?: string;
|
|
11
|
+
file?: string;
|
|
12
|
+
strategy?: CacheStrategy;
|
|
13
|
+
}
|
|
14
|
+
type InternalCacheOptions = CacheOptions & {
|
|
15
|
+
enable?: boolean;
|
|
16
|
+
};
|
|
17
|
+
interface PatchOptions {
|
|
18
|
+
overwrite?: boolean;
|
|
19
|
+
paths?: string[];
|
|
20
|
+
basedir?: string;
|
|
21
|
+
custom?: (dir: string, ctx: Record<string, any>) => void;
|
|
22
|
+
}
|
|
23
|
+
interface InternalPatchOptions {
|
|
24
|
+
overwrite: boolean;
|
|
25
|
+
paths?: string[];
|
|
26
|
+
basedir?: string;
|
|
27
|
+
custom?: (dir: string, ctx: Record<string, any>) => void;
|
|
28
|
+
version?: string;
|
|
29
|
+
}
|
|
30
|
+
interface TailwindcssPatcherOptions {
|
|
31
|
+
cache?: CacheOptions | boolean;
|
|
32
|
+
patch?: PatchOptions;
|
|
33
|
+
}
|
|
34
|
+
type TailwindcssClassCache = Map<string, ({
|
|
35
|
+
layer: string;
|
|
36
|
+
options: Record<string, any>;
|
|
37
|
+
sort: Record<string, any>;
|
|
38
|
+
} | Rule)[]>;
|
|
39
|
+
type TailwindcssRuntimeContext = {
|
|
40
|
+
applyClassCache: Map<any, any>;
|
|
41
|
+
candidateRuleCache: Map<string | string, Set<[
|
|
42
|
+
{
|
|
43
|
+
arbitrary: any;
|
|
44
|
+
index: any;
|
|
45
|
+
layer: string;
|
|
46
|
+
options: any[];
|
|
47
|
+
parallelIndex: any;
|
|
48
|
+
parentLayer: string;
|
|
49
|
+
variants: any;
|
|
50
|
+
},
|
|
51
|
+
Node
|
|
52
|
+
]>>;
|
|
53
|
+
candidateRuleMap: Map<string | string, [object, Node][]>;
|
|
54
|
+
changedContent: any[];
|
|
55
|
+
classCache: TailwindcssClassCache;
|
|
56
|
+
disposables: any[];
|
|
57
|
+
getClassList: Function;
|
|
58
|
+
getClassOrder: Function;
|
|
59
|
+
getVariants: Function;
|
|
60
|
+
markInvalidUtilityCandidate: Function;
|
|
61
|
+
markInvalidUtilityNode: Function;
|
|
62
|
+
notClassCache: Set<string>;
|
|
63
|
+
offsets: {
|
|
64
|
+
layerPositions: object;
|
|
65
|
+
offsets: object;
|
|
66
|
+
reservedVariantBits: any;
|
|
67
|
+
variantOffsets: Map<string, any>;
|
|
68
|
+
};
|
|
69
|
+
postCssNodeCache: Map<object, [Node]>;
|
|
70
|
+
ruleCache: Set<[object, Node]>;
|
|
71
|
+
stylesheetCache: Record<string, Set<any>>;
|
|
72
|
+
tailwindConfig: Config;
|
|
73
|
+
userConfigPath: string | null;
|
|
74
|
+
variantMap: Map<string, [[object, Function]]>;
|
|
75
|
+
variantOptions: Map<string, object>;
|
|
76
|
+
};
|
|
77
|
+
type DeepRequired<T> = {
|
|
78
|
+
[K in keyof T]: Required<DeepRequired<T[K]>>;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
declare function getCacheOptions(options?: CacheOptions | boolean): InternalCacheOptions;
|
|
82
|
+
declare class CacheManager {
|
|
83
|
+
options: Required<CacheOptions> & {
|
|
84
|
+
filename: string;
|
|
85
|
+
};
|
|
86
|
+
constructor(options?: CacheOptions);
|
|
87
|
+
mkdir(cacheDirectory: string): string;
|
|
88
|
+
getOptions(options?: CacheOptions): Required<CacheOptions> & {
|
|
89
|
+
filename: string;
|
|
90
|
+
};
|
|
91
|
+
write(data: Set<string>): string | undefined;
|
|
92
|
+
read(): Set<string> | undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
declare class TailwindcssPatcher {
|
|
96
|
+
rawOptions: TailwindcssPatcherOptions;
|
|
97
|
+
cacheOptions: InternalCacheOptions;
|
|
98
|
+
patchOptions: InternalPatchOptions;
|
|
99
|
+
patch: () => void;
|
|
100
|
+
cacheManager: CacheManager;
|
|
101
|
+
constructor(options?: TailwindcssPatcherOptions);
|
|
102
|
+
getPkgEntry(basedir?: string): string;
|
|
103
|
+
setCache(set: Set<string>): string | undefined;
|
|
104
|
+
getCache(): Set<string> | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* @description 在多个 tailwindcss 上下文时,这个方法将被执行多次,所以策略上应该使用 append
|
|
107
|
+
* 详见 taro weapp-tailwindcss 独立分包
|
|
108
|
+
* @param basedir
|
|
109
|
+
* @returns
|
|
110
|
+
*/
|
|
111
|
+
getClassSet(options?: {
|
|
112
|
+
basedir?: string;
|
|
113
|
+
cacheStrategy?: CacheStrategy;
|
|
114
|
+
removeUniversalSelector?: boolean;
|
|
115
|
+
}): Set<string>;
|
|
116
|
+
getContexts(basedir?: string): TailwindcssRuntimeContext[];
|
|
117
|
+
extract(options: UserConfig['patch']): Promise<string | undefined>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
declare function getTailwindcssEntry(basedir?: string): string;
|
|
121
|
+
declare function getContexts(basedir?: string): TailwindcssRuntimeContext[];
|
|
122
|
+
declare function getClassCaches(basedir?: string): TailwindcssClassCache[];
|
|
123
|
+
declare function getClassCacheSet(basedir?: string, options?: {
|
|
124
|
+
removeUniversalSelector?: boolean;
|
|
125
|
+
}): Set<string>;
|
|
126
|
+
|
|
127
|
+
declare function inspectProcessTailwindFeaturesReturnContext(content: string): {
|
|
128
|
+
code: string;
|
|
129
|
+
hasPatched: boolean;
|
|
130
|
+
};
|
|
131
|
+
declare function inspectPostcssPlugin(content: string): {
|
|
132
|
+
code: string;
|
|
133
|
+
hasPatched: boolean;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
declare function getInstalledPkgJsonPath(options?: PatchOptions): string | undefined;
|
|
137
|
+
declare function getPatchOptions(options?: PatchOptions): InternalPatchOptions;
|
|
138
|
+
declare function createPatch(opt: InternalPatchOptions): () => any;
|
|
139
|
+
declare function monkeyPatchForExposingContext(twDir: string, opt: InternalPatchOptions): {
|
|
140
|
+
processTailwindFeatures?: string | undefined;
|
|
141
|
+
plugin?: string | undefined;
|
|
142
|
+
} & Record<string, any>;
|
|
143
|
+
declare function internalPatch(pkgJsonPath: string | undefined, options: InternalPatchOptions): any | undefined;
|
|
144
|
+
|
|
145
|
+
declare function ensureFileContent(filepaths: string | string[]): string | undefined;
|
|
146
|
+
declare function requireResolve(id: string, opts?: SyncOpts): string;
|
|
147
|
+
declare function ensureDir(p: string): Promise<void>;
|
|
148
|
+
|
|
149
|
+
export { CacheManager, type CacheOptions, type CacheStrategy, type DeepRequired, type InternalCacheOptions, type InternalPatchOptions, type PatchOptions, type TailwindcssClassCache, TailwindcssPatcher, type TailwindcssPatcherOptions, type TailwindcssRuntimeContext, createPatch, ensureDir, ensureFileContent, getCacheOptions, getClassCacheSet, getClassCaches, getContexts, getInstalledPkgJsonPath, getPatchOptions, getTailwindcssEntry, inspectPostcssPlugin, inspectProcessTailwindFeaturesReturnContext, internalPatch, monkeyPatchForExposingContext, requireResolve };
|
package/dist/index.d.ts
CHANGED
|
@@ -146,4 +146,4 @@ declare function ensureFileContent(filepaths: string | string[]): string | undef
|
|
|
146
146
|
declare function requireResolve(id: string, opts?: SyncOpts): string;
|
|
147
147
|
declare function ensureDir(p: string): Promise<void>;
|
|
148
148
|
|
|
149
|
-
export { CacheManager, CacheOptions, CacheStrategy, DeepRequired, InternalCacheOptions, InternalPatchOptions, PatchOptions, TailwindcssClassCache, TailwindcssPatcher, TailwindcssPatcherOptions, TailwindcssRuntimeContext, createPatch, ensureDir, ensureFileContent, getCacheOptions, getClassCacheSet, getClassCaches, getContexts, getInstalledPkgJsonPath, getPatchOptions, getTailwindcssEntry, inspectPostcssPlugin, inspectProcessTailwindFeaturesReturnContext, internalPatch, monkeyPatchForExposingContext, requireResolve };
|
|
149
|
+
export { CacheManager, type CacheOptions, type CacheStrategy, type DeepRequired, type InternalCacheOptions, type InternalPatchOptions, type PatchOptions, type TailwindcssClassCache, TailwindcssPatcher, type TailwindcssPatcherOptions, type TailwindcssRuntimeContext, createPatch, ensureDir, ensureFileContent, getCacheOptions, getClassCacheSet, getClassCaches, getContexts, getInstalledPkgJsonPath, getPatchOptions, getTailwindcssEntry, inspectPostcssPlugin, inspectProcessTailwindFeaturesReturnContext, internalPatch, monkeyPatchForExposingContext, requireResolve };
|
package/dist/index.mjs
CHANGED
|
@@ -92,6 +92,12 @@ function log(message, ...optionalParams) {
|
|
|
92
92
|
return console.log(`[${pkgName}]:` + message, ...optionalParams);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
var __defProp$1 = Object.defineProperty;
|
|
96
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
97
|
+
var __publicField$1 = (obj, key, value) => {
|
|
98
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
99
|
+
return value;
|
|
100
|
+
};
|
|
95
101
|
function getCacheOptions(options) {
|
|
96
102
|
let cache;
|
|
97
103
|
switch (typeof options) {
|
|
@@ -116,6 +122,7 @@ function getCacheOptions(options) {
|
|
|
116
122
|
}
|
|
117
123
|
class CacheManager {
|
|
118
124
|
constructor(options = {}) {
|
|
125
|
+
__publicField$1(this, "options");
|
|
119
126
|
this.options = this.getOptions(options);
|
|
120
127
|
}
|
|
121
128
|
mkdir(cacheDirectory) {
|
|
@@ -456,8 +463,19 @@ async function processTailwindcss(options) {
|
|
|
456
463
|
});
|
|
457
464
|
}
|
|
458
465
|
|
|
466
|
+
var __defProp = Object.defineProperty;
|
|
467
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
468
|
+
var __publicField = (obj, key, value) => {
|
|
469
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
470
|
+
return value;
|
|
471
|
+
};
|
|
459
472
|
class TailwindcssPatcher {
|
|
460
473
|
constructor(options = {}) {
|
|
474
|
+
__publicField(this, "rawOptions");
|
|
475
|
+
__publicField(this, "cacheOptions");
|
|
476
|
+
__publicField(this, "patchOptions");
|
|
477
|
+
__publicField(this, "patch");
|
|
478
|
+
__publicField(this, "cacheManager");
|
|
461
479
|
this.rawOptions = options;
|
|
462
480
|
this.cacheOptions = getCacheOptions(options.cache);
|
|
463
481
|
this.patchOptions = getPatchOptions(options.patch);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwindcss-patch",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "patch tailwindcss for exposing context and extract classes",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -36,22 +36,22 @@
|
|
|
36
36
|
"@types/babel__generator": "^7.6.4",
|
|
37
37
|
"@types/babel__traverse": "^7.20.1",
|
|
38
38
|
"@types/resolve": "^1.20.2",
|
|
39
|
-
"@types/semver": "^7.5.
|
|
39
|
+
"@types/semver": "^7.5.2",
|
|
40
40
|
"pkg-types": "^1.0.3",
|
|
41
41
|
"tailwindcss": "^3.3.3"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@babel/generator": "^7.22.
|
|
45
|
-
"@babel/parser": "^7.22.
|
|
46
|
-
"@babel/traverse": "^7.22.
|
|
47
|
-
"@babel/types": "^7.22.
|
|
44
|
+
"@babel/generator": "^7.22.15",
|
|
45
|
+
"@babel/parser": "^7.22.16",
|
|
46
|
+
"@babel/traverse": "^7.22.19",
|
|
47
|
+
"@babel/types": "^7.22.19",
|
|
48
48
|
"cac": "^6.7.14",
|
|
49
|
-
"jiti": "^1.
|
|
49
|
+
"jiti": "^1.20.0",
|
|
50
50
|
"lilconfig": "^2.1.0",
|
|
51
|
-
"postcss": "^8.4.
|
|
52
|
-
"resolve": "^1.22.
|
|
51
|
+
"postcss": "^8.4.29",
|
|
52
|
+
"resolve": "^1.22.5",
|
|
53
53
|
"semver": "^7.5.4",
|
|
54
|
-
"@tailwindcss-mangle/config": "^2.
|
|
54
|
+
"@tailwindcss-mangle/config": "^2.2.0"
|
|
55
55
|
},
|
|
56
56
|
"homepage": "https://github.com/sonofmagic/tailwindcss-mangle",
|
|
57
57
|
"repository": {
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"test": "test"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
|
+
"dev": "unbuild --sourcemap",
|
|
68
69
|
"build": "unbuild",
|
|
69
70
|
"test": "vitest run --coverage.enabled",
|
|
70
71
|
"test:dev": "vitest",
|