@tailwindcss-mangle/core 2.2.2 → 3.0.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.d.cts CHANGED
@@ -2,10 +2,9 @@ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
2
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';
6
- import { StringLiteral, TemplateElement } from '@babel/types';
7
- import { BabelFileResult } from '@babel/core';
5
+ import { TransformResult } from 'unplugin';
8
6
  import MagicString from 'magic-string';
7
+ import { StringLiteral, TemplateElement } from '@babel/types';
9
8
 
10
9
  interface InitConfigOptions {
11
10
  cwd?: string;
@@ -14,9 +13,7 @@ interface InitConfigOptions {
14
13
  }
15
14
  declare class Context {
16
15
  options: MangleUserConfig;
17
- private includeMatcher;
18
- private excludeMatcher;
19
- private replaceMap;
16
+ replaceMap: Map<string, string>;
20
17
  classSet: Set<string>;
21
18
  classGenerator: ClassGenerator;
22
19
  preserveFunctionSet: Set<string>;
@@ -27,13 +24,13 @@ declare class Context {
27
24
  addPreserveClass(className: string): Set<string>;
28
25
  isPreserveFunction(calleeName: string): boolean;
29
26
  private mergeOptions;
30
- isInclude(file: string): boolean;
31
27
  currentMangleClassFilter(className: string): boolean;
32
28
  getClassSet(): Set<string>;
33
29
  getReplaceMap(): Map<string, string>;
34
- addToUsedBy(key: string, file: string): void;
30
+ addToUsedBy(key: string, file?: string): void;
35
31
  loadClassSet(classList: string[]): void;
36
- initConfig(opts?: InitConfigOptions): Promise<_tailwindcss_mangle_config.UserConfig | null>;
32
+ initConfig(opts?: InitConfigOptions): Promise<_tailwindcss_mangle_config.UserConfig>;
33
+ dump(): Promise<void>;
37
34
  }
38
35
 
39
36
  interface IClassGeneratorContextItem {
@@ -49,41 +46,28 @@ interface IClassGeneratorOptions {
49
46
  ignoreClass?: (string | RegExp)[];
50
47
  classPrefix?: string;
51
48
  }
49
+ interface IHandler {
50
+ (code: string, options: IHandlerOptions): IHandlerTransformResult;
51
+ }
52
+ type IHandlerTransformResult = Exclude<TransformResult, null | undefined | string>;
52
53
  interface IHandlerOptions {
53
- replaceMap: Map<string, string>;
54
54
  ctx: Context;
55
+ id?: string;
55
56
  }
56
57
  interface IHtmlHandlerOptions extends IHandlerOptions {
57
58
  }
58
59
  interface IJsHandlerOptions extends IHandlerOptions {
59
60
  splitQuote?: boolean;
60
- minified?: boolean;
61
61
  }
62
62
  interface ICssHandlerOptions extends IHandlerOptions {
63
63
  ignoreVueScoped?: boolean;
64
- file?: string;
65
64
  }
66
65
 
67
- declare function cssHandler(rawSource: string, options: ICssHandlerOptions): postcss.LazyResult<postcss.Root>;
68
-
69
- declare function htmlHandler(rawSource: string, options: IHtmlHandlerOptions): string;
66
+ declare function cssHandler(rawSource: string, options: ICssHandlerOptions): Promise<IHandlerTransformResult>;
70
67
 
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;
68
+ declare function htmlHandler(raw: string | MagicString, options: IHtmlHandlerOptions): IHandlerTransformResult;
85
69
 
86
- declare function handleValue(raw: string, node: StringLiteral | TemplateElement, options: IJsHandlerOptions): string;
87
- declare function jsHandler(rawSource: string, options: IJsHandlerOptions): BabelFileResult;
70
+ declare function handleValue(raw: string, node: StringLiteral | TemplateElement, options: IJsHandlerOptions, ms: MagicString, offset: number, escape: boolean): string;
71
+ declare function jsHandler(rawSource: string | MagicString, options: IJsHandlerOptions): IHandlerTransformResult;
88
72
 
89
- export { Context, type IClassGeneratorContextItem, type IClassGeneratorOptions, type ICssHandlerOptions, type IHandlerOptions, type IHtmlHandlerOptions, type IJsHandlerOptions, cssHandler, handleValue, htmlHandler, jsHandler, preProcessJs, preProcessRawCode };
73
+ export { Context, type IClassGeneratorContextItem, type IClassGeneratorOptions, type ICssHandlerOptions, type IHandler, type IHandlerOptions, type IHandlerTransformResult, type IHtmlHandlerOptions, type IJsHandlerOptions, cssHandler, handleValue, htmlHandler, jsHandler };
package/dist/index.d.mts CHANGED
@@ -2,10 +2,9 @@ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
2
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';
6
- import { StringLiteral, TemplateElement } from '@babel/types';
7
- import { BabelFileResult } from '@babel/core';
5
+ import { TransformResult } from 'unplugin';
8
6
  import MagicString from 'magic-string';
7
+ import { StringLiteral, TemplateElement } from '@babel/types';
9
8
 
10
9
  interface InitConfigOptions {
11
10
  cwd?: string;
@@ -14,9 +13,7 @@ interface InitConfigOptions {
14
13
  }
15
14
  declare class Context {
16
15
  options: MangleUserConfig;
17
- private includeMatcher;
18
- private excludeMatcher;
19
- private replaceMap;
16
+ replaceMap: Map<string, string>;
20
17
  classSet: Set<string>;
21
18
  classGenerator: ClassGenerator;
22
19
  preserveFunctionSet: Set<string>;
@@ -27,13 +24,13 @@ declare class Context {
27
24
  addPreserveClass(className: string): Set<string>;
28
25
  isPreserveFunction(calleeName: string): boolean;
29
26
  private mergeOptions;
30
- isInclude(file: string): boolean;
31
27
  currentMangleClassFilter(className: string): boolean;
32
28
  getClassSet(): Set<string>;
33
29
  getReplaceMap(): Map<string, string>;
34
- addToUsedBy(key: string, file: string): void;
30
+ addToUsedBy(key: string, file?: string): void;
35
31
  loadClassSet(classList: string[]): void;
36
- initConfig(opts?: InitConfigOptions): Promise<_tailwindcss_mangle_config.UserConfig | null>;
32
+ initConfig(opts?: InitConfigOptions): Promise<_tailwindcss_mangle_config.UserConfig>;
33
+ dump(): Promise<void>;
37
34
  }
38
35
 
39
36
  interface IClassGeneratorContextItem {
@@ -49,41 +46,28 @@ interface IClassGeneratorOptions {
49
46
  ignoreClass?: (string | RegExp)[];
50
47
  classPrefix?: string;
51
48
  }
49
+ interface IHandler {
50
+ (code: string, options: IHandlerOptions): IHandlerTransformResult;
51
+ }
52
+ type IHandlerTransformResult = Exclude<TransformResult, null | undefined | string>;
52
53
  interface IHandlerOptions {
53
- replaceMap: Map<string, string>;
54
54
  ctx: Context;
55
+ id?: string;
55
56
  }
56
57
  interface IHtmlHandlerOptions extends IHandlerOptions {
57
58
  }
58
59
  interface IJsHandlerOptions extends IHandlerOptions {
59
60
  splitQuote?: boolean;
60
- minified?: boolean;
61
61
  }
62
62
  interface ICssHandlerOptions extends IHandlerOptions {
63
63
  ignoreVueScoped?: boolean;
64
- file?: string;
65
64
  }
66
65
 
67
- declare function cssHandler(rawSource: string, options: ICssHandlerOptions): postcss.LazyResult<postcss.Root>;
68
-
69
- declare function htmlHandler(rawSource: string, options: IHtmlHandlerOptions): string;
66
+ declare function cssHandler(rawSource: string, options: ICssHandlerOptions): Promise<IHandlerTransformResult>;
70
67
 
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;
68
+ declare function htmlHandler(raw: string | MagicString, options: IHtmlHandlerOptions): IHandlerTransformResult;
85
69
 
86
- declare function handleValue(raw: string, node: StringLiteral | TemplateElement, options: IJsHandlerOptions): string;
87
- declare function jsHandler(rawSource: string, options: IJsHandlerOptions): BabelFileResult;
70
+ declare function handleValue(raw: string, node: StringLiteral | TemplateElement, options: IJsHandlerOptions, ms: MagicString, offset: number, escape: boolean): string;
71
+ declare function jsHandler(rawSource: string | MagicString, options: IJsHandlerOptions): IHandlerTransformResult;
88
72
 
89
- export { Context, type IClassGeneratorContextItem, type IClassGeneratorOptions, type ICssHandlerOptions, type IHandlerOptions, type IHtmlHandlerOptions, type IJsHandlerOptions, cssHandler, handleValue, htmlHandler, jsHandler, preProcessJs, preProcessRawCode };
73
+ export { Context, type IClassGeneratorContextItem, type IClassGeneratorOptions, type ICssHandlerOptions, type IHandler, type IHandlerOptions, type IHandlerTransformResult, type IHtmlHandlerOptions, type IJsHandlerOptions, cssHandler, handleValue, htmlHandler, jsHandler };
package/dist/index.d.ts CHANGED
@@ -2,10 +2,9 @@ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
2
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';
6
- import { StringLiteral, TemplateElement } from '@babel/types';
7
- import { BabelFileResult } from '@babel/core';
5
+ import { TransformResult } from 'unplugin';
8
6
  import MagicString from 'magic-string';
7
+ import { StringLiteral, TemplateElement } from '@babel/types';
9
8
 
10
9
  interface InitConfigOptions {
11
10
  cwd?: string;
@@ -14,9 +13,7 @@ interface InitConfigOptions {
14
13
  }
15
14
  declare class Context {
16
15
  options: MangleUserConfig;
17
- private includeMatcher;
18
- private excludeMatcher;
19
- private replaceMap;
16
+ replaceMap: Map<string, string>;
20
17
  classSet: Set<string>;
21
18
  classGenerator: ClassGenerator;
22
19
  preserveFunctionSet: Set<string>;
@@ -27,13 +24,13 @@ declare class Context {
27
24
  addPreserveClass(className: string): Set<string>;
28
25
  isPreserveFunction(calleeName: string): boolean;
29
26
  private mergeOptions;
30
- isInclude(file: string): boolean;
31
27
  currentMangleClassFilter(className: string): boolean;
32
28
  getClassSet(): Set<string>;
33
29
  getReplaceMap(): Map<string, string>;
34
- addToUsedBy(key: string, file: string): void;
30
+ addToUsedBy(key: string, file?: string): void;
35
31
  loadClassSet(classList: string[]): void;
36
- initConfig(opts?: InitConfigOptions): Promise<_tailwindcss_mangle_config.UserConfig | null>;
32
+ initConfig(opts?: InitConfigOptions): Promise<_tailwindcss_mangle_config.UserConfig>;
33
+ dump(): Promise<void>;
37
34
  }
38
35
 
39
36
  interface IClassGeneratorContextItem {
@@ -49,41 +46,28 @@ interface IClassGeneratorOptions {
49
46
  ignoreClass?: (string | RegExp)[];
50
47
  classPrefix?: string;
51
48
  }
49
+ interface IHandler {
50
+ (code: string, options: IHandlerOptions): IHandlerTransformResult;
51
+ }
52
+ type IHandlerTransformResult = Exclude<TransformResult, null | undefined | string>;
52
53
  interface IHandlerOptions {
53
- replaceMap: Map<string, string>;
54
54
  ctx: Context;
55
+ id?: string;
55
56
  }
56
57
  interface IHtmlHandlerOptions extends IHandlerOptions {
57
58
  }
58
59
  interface IJsHandlerOptions extends IHandlerOptions {
59
60
  splitQuote?: boolean;
60
- minified?: boolean;
61
61
  }
62
62
  interface ICssHandlerOptions extends IHandlerOptions {
63
63
  ignoreVueScoped?: boolean;
64
- file?: string;
65
64
  }
66
65
 
67
- declare function cssHandler(rawSource: string, options: ICssHandlerOptions): postcss.LazyResult<postcss.Root>;
68
-
69
- declare function htmlHandler(rawSource: string, options: IHtmlHandlerOptions): string;
66
+ declare function cssHandler(rawSource: string, options: ICssHandlerOptions): Promise<IHandlerTransformResult>;
70
67
 
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;
68
+ declare function htmlHandler(raw: string | MagicString, options: IHtmlHandlerOptions): IHandlerTransformResult;
85
69
 
86
- declare function handleValue(raw: string, node: StringLiteral | TemplateElement, options: IJsHandlerOptions): string;
87
- declare function jsHandler(rawSource: string, options: IJsHandlerOptions): BabelFileResult;
70
+ declare function handleValue(raw: string, node: StringLiteral | TemplateElement, options: IJsHandlerOptions, ms: MagicString, offset: number, escape: boolean): string;
71
+ declare function jsHandler(rawSource: string | MagicString, options: IJsHandlerOptions): IHandlerTransformResult;
88
72
 
89
- export { Context, type IClassGeneratorContextItem, type IClassGeneratorOptions, type ICssHandlerOptions, type IHandlerOptions, type IHtmlHandlerOptions, type IJsHandlerOptions, cssHandler, handleValue, htmlHandler, jsHandler, preProcessJs, preProcessRawCode };
73
+ export { Context, type IClassGeneratorContextItem, type IClassGeneratorOptions, type ICssHandlerOptions, type IHandler, type IHandlerOptions, type IHandlerTransformResult, type IHtmlHandlerOptions, type IJsHandlerOptions, cssHandler, handleValue, htmlHandler, jsHandler };