@tailwindcss-mangle/core 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/dist/index.cjs +280 -149
- package/dist/index.d.cts +89 -0
- package/dist/index.d.mts +89 -0
- package/dist/index.d.ts +46 -8
- package/dist/index.mjs +278 -152
- package/package.json +26 -10
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
|
|
2
|
+
import { MangleUserConfig } from '@tailwindcss-mangle/config';
|
|
3
|
+
import { ClassGenerator } from '@tailwindcss-mangle/shared';
|
|
4
|
+
export { ClassGenerator } from '@tailwindcss-mangle/shared';
|
|
5
|
+
import postcss from 'postcss';
|
|
6
|
+
import { StringLiteral, TemplateElement } from '@babel/types';
|
|
7
|
+
import { BabelFileResult } from '@babel/core';
|
|
8
|
+
import MagicString from 'magic-string';
|
|
9
|
+
|
|
10
|
+
interface InitConfigOptions {
|
|
11
|
+
cwd?: string;
|
|
12
|
+
classList?: string[];
|
|
13
|
+
mangleOptions?: MangleUserConfig;
|
|
14
|
+
}
|
|
15
|
+
declare class Context {
|
|
16
|
+
options: MangleUserConfig;
|
|
17
|
+
private includeMatcher;
|
|
18
|
+
private excludeMatcher;
|
|
19
|
+
private replaceMap;
|
|
20
|
+
classSet: Set<string>;
|
|
21
|
+
classGenerator: ClassGenerator;
|
|
22
|
+
preserveFunctionSet: Set<string>;
|
|
23
|
+
preserveClassNamesSet: Set<string>;
|
|
24
|
+
preserveFunctionRegexs: RegExp[];
|
|
25
|
+
constructor();
|
|
26
|
+
isPreserveClass(className: string): boolean;
|
|
27
|
+
addPreserveClass(className: string): Set<string>;
|
|
28
|
+
isPreserveFunction(calleeName: string): boolean;
|
|
29
|
+
private mergeOptions;
|
|
30
|
+
isInclude(file: string): boolean;
|
|
31
|
+
currentMangleClassFilter(className: string): boolean;
|
|
32
|
+
getClassSet(): Set<string>;
|
|
33
|
+
getReplaceMap(): Map<string, string>;
|
|
34
|
+
addToUsedBy(key: string, file: string): void;
|
|
35
|
+
loadClassSet(classList: string[]): void;
|
|
36
|
+
initConfig(opts?: InitConfigOptions): Promise<_tailwindcss_mangle_config.UserConfig | null>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface IClassGeneratorContextItem {
|
|
40
|
+
name: string;
|
|
41
|
+
usedBy: string[];
|
|
42
|
+
}
|
|
43
|
+
interface IClassGeneratorOptions {
|
|
44
|
+
reserveClassName?: (string | RegExp)[];
|
|
45
|
+
customGenerate?: (original: string, opts: IClassGeneratorOptions, context: Record<string, any>) => string | undefined;
|
|
46
|
+
log?: boolean;
|
|
47
|
+
exclude?: (string | RegExp)[];
|
|
48
|
+
include?: (string | RegExp)[];
|
|
49
|
+
ignoreClass?: (string | RegExp)[];
|
|
50
|
+
classPrefix?: string;
|
|
51
|
+
}
|
|
52
|
+
interface IHandlerOptions {
|
|
53
|
+
replaceMap: Map<string, string>;
|
|
54
|
+
ctx: Context;
|
|
55
|
+
}
|
|
56
|
+
interface IHtmlHandlerOptions extends IHandlerOptions {
|
|
57
|
+
}
|
|
58
|
+
interface IJsHandlerOptions extends IHandlerOptions {
|
|
59
|
+
splitQuote?: boolean;
|
|
60
|
+
minified?: boolean;
|
|
61
|
+
}
|
|
62
|
+
interface ICssHandlerOptions extends IHandlerOptions {
|
|
63
|
+
ignoreVueScoped?: boolean;
|
|
64
|
+
file?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
declare function cssHandler(rawSource: string, options: ICssHandlerOptions): postcss.LazyResult<postcss.Root>;
|
|
68
|
+
|
|
69
|
+
declare function htmlHandler(rawSource: string, options: IHtmlHandlerOptions): string;
|
|
70
|
+
|
|
71
|
+
interface IPreProcessJsOptions {
|
|
72
|
+
code: string | MagicString;
|
|
73
|
+
replaceMap: Map<string, string>;
|
|
74
|
+
id: string;
|
|
75
|
+
ctx: Context;
|
|
76
|
+
}
|
|
77
|
+
declare function preProcessJs(options: IPreProcessJsOptions): string;
|
|
78
|
+
interface IPreProcessRawCodeOptions {
|
|
79
|
+
code: string | MagicString;
|
|
80
|
+
replaceMap: Map<string, string>;
|
|
81
|
+
id: string;
|
|
82
|
+
ctx: Context;
|
|
83
|
+
}
|
|
84
|
+
declare function preProcessRawCode(options: IPreProcessRawCodeOptions): string;
|
|
85
|
+
|
|
86
|
+
declare function handleValue(raw: string, node: StringLiteral | TemplateElement, options: IJsHandlerOptions): string;
|
|
87
|
+
declare function jsHandler(rawSource: string, options: IJsHandlerOptions): BabelFileResult;
|
|
88
|
+
|
|
89
|
+
export { Context, type IClassGeneratorContextItem, type IClassGeneratorOptions, type ICssHandlerOptions, type IHandlerOptions, type IHtmlHandlerOptions, type IJsHandlerOptions, cssHandler, handleValue, htmlHandler, jsHandler, preProcessJs, preProcessRawCode };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,41 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
|
|
2
|
+
import { MangleUserConfig } from '@tailwindcss-mangle/config';
|
|
3
3
|
import { ClassGenerator } from '@tailwindcss-mangle/shared';
|
|
4
4
|
export { ClassGenerator } from '@tailwindcss-mangle/shared';
|
|
5
|
+
import postcss from 'postcss';
|
|
5
6
|
import { StringLiteral, TemplateElement } from '@babel/types';
|
|
6
7
|
import { BabelFileResult } from '@babel/core';
|
|
7
8
|
import MagicString from 'magic-string';
|
|
8
9
|
|
|
10
|
+
interface InitConfigOptions {
|
|
11
|
+
cwd?: string;
|
|
12
|
+
classList?: string[];
|
|
13
|
+
mangleOptions?: MangleUserConfig;
|
|
14
|
+
}
|
|
15
|
+
declare class Context {
|
|
16
|
+
options: MangleUserConfig;
|
|
17
|
+
private includeMatcher;
|
|
18
|
+
private excludeMatcher;
|
|
19
|
+
private replaceMap;
|
|
20
|
+
classSet: Set<string>;
|
|
21
|
+
classGenerator: ClassGenerator;
|
|
22
|
+
preserveFunctionSet: Set<string>;
|
|
23
|
+
preserveClassNamesSet: Set<string>;
|
|
24
|
+
preserveFunctionRegexs: RegExp[];
|
|
25
|
+
constructor();
|
|
26
|
+
isPreserveClass(className: string): boolean;
|
|
27
|
+
addPreserveClass(className: string): Set<string>;
|
|
28
|
+
isPreserveFunction(calleeName: string): boolean;
|
|
29
|
+
private mergeOptions;
|
|
30
|
+
isInclude(file: string): boolean;
|
|
31
|
+
currentMangleClassFilter(className: string): boolean;
|
|
32
|
+
getClassSet(): Set<string>;
|
|
33
|
+
getReplaceMap(): Map<string, string>;
|
|
34
|
+
addToUsedBy(key: string, file: string): void;
|
|
35
|
+
loadClassSet(classList: string[]): void;
|
|
36
|
+
initConfig(opts?: InitConfigOptions): Promise<_tailwindcss_mangle_config.UserConfig | null>;
|
|
37
|
+
}
|
|
38
|
+
|
|
9
39
|
interface IClassGeneratorContextItem {
|
|
10
40
|
name: string;
|
|
11
41
|
usedBy: string[];
|
|
@@ -20,8 +50,8 @@ interface IClassGeneratorOptions {
|
|
|
20
50
|
classPrefix?: string;
|
|
21
51
|
}
|
|
22
52
|
interface IHandlerOptions {
|
|
23
|
-
classGenerator: ClassGenerator;
|
|
24
53
|
replaceMap: Map<string, string>;
|
|
54
|
+
ctx: Context;
|
|
25
55
|
}
|
|
26
56
|
interface IHtmlHandlerOptions extends IHandlerOptions {
|
|
27
57
|
}
|
|
@@ -34,18 +64,26 @@ interface ICssHandlerOptions extends IHandlerOptions {
|
|
|
34
64
|
file?: string;
|
|
35
65
|
}
|
|
36
66
|
|
|
37
|
-
declare function cssHandler(rawSource: string, options: ICssHandlerOptions): postcss.LazyResult
|
|
67
|
+
declare function cssHandler(rawSource: string, options: ICssHandlerOptions): postcss.LazyResult<postcss.Root>;
|
|
38
68
|
|
|
39
69
|
declare function htmlHandler(rawSource: string, options: IHtmlHandlerOptions): string;
|
|
40
70
|
|
|
41
|
-
|
|
71
|
+
interface IPreProcessJsOptions {
|
|
72
|
+
code: string | MagicString;
|
|
73
|
+
replaceMap: Map<string, string>;
|
|
74
|
+
id: string;
|
|
75
|
+
ctx: Context;
|
|
76
|
+
}
|
|
77
|
+
declare function preProcessJs(options: IPreProcessJsOptions): string;
|
|
78
|
+
interface IPreProcessRawCodeOptions {
|
|
42
79
|
code: string | MagicString;
|
|
43
80
|
replaceMap: Map<string, string>;
|
|
44
81
|
id: string;
|
|
45
|
-
|
|
46
|
-
}
|
|
82
|
+
ctx: Context;
|
|
83
|
+
}
|
|
84
|
+
declare function preProcessRawCode(options: IPreProcessRawCodeOptions): string;
|
|
47
85
|
|
|
48
86
|
declare function handleValue(raw: string, node: StringLiteral | TemplateElement, options: IJsHandlerOptions): string;
|
|
49
87
|
declare function jsHandler(rawSource: string, options: IJsHandlerOptions): BabelFileResult;
|
|
50
88
|
|
|
51
|
-
export { IClassGeneratorContextItem, IClassGeneratorOptions, ICssHandlerOptions, IHandlerOptions, IHtmlHandlerOptions, IJsHandlerOptions, cssHandler, handleValue, htmlHandler, jsHandler, preProcessJs };
|
|
89
|
+
export { Context, type IClassGeneratorContextItem, type IClassGeneratorOptions, type ICssHandlerOptions, type IHandlerOptions, type IHtmlHandlerOptions, type IJsHandlerOptions, cssHandler, handleValue, htmlHandler, jsHandler, preProcessJs, preProcessRawCode };
|