@tailwindcss-mangle/shared 2.2.1 → 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.cjs +10 -8
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +10 -8
- package/package.json +19 -19
package/dist/index.cjs
CHANGED
|
@@ -13,12 +13,12 @@ const preserveClassNamesMap = preserveClassNames.reduce((acc, cur) => {
|
|
|
13
13
|
acc[cur] = true;
|
|
14
14
|
return acc;
|
|
15
15
|
}, {});
|
|
16
|
-
|
|
16
|
+
function defaultMangleClassFilter(className) {
|
|
17
17
|
if (preserveClassNamesMap[className]) {
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
return /[:-]/.test(className);
|
|
21
|
-
}
|
|
21
|
+
}
|
|
22
22
|
function groupBy(arr, cb) {
|
|
23
23
|
if (!Array.isArray(arr)) {
|
|
24
24
|
throw new TypeError("expected an array for first argument");
|
|
@@ -123,16 +123,18 @@ class ClassGenerator {
|
|
|
123
123
|
transformCssClass(className) {
|
|
124
124
|
const key = stripEscapeSequence(className);
|
|
125
125
|
const cn = this.newClassMap[key];
|
|
126
|
-
if (cn)
|
|
126
|
+
if (cn) {
|
|
127
127
|
return cn.name;
|
|
128
|
+
}
|
|
128
129
|
return className;
|
|
129
130
|
}
|
|
130
131
|
generateClassName(original) {
|
|
131
132
|
const opts = this.opts;
|
|
132
133
|
original = stripEscapeSequence(original);
|
|
133
134
|
const cn = this.newClassMap[original];
|
|
134
|
-
if (cn)
|
|
135
|
+
if (cn) {
|
|
135
136
|
return cn;
|
|
137
|
+
}
|
|
136
138
|
let newClassName;
|
|
137
139
|
if (opts.customGenerate && typeof opts.customGenerate === "function") {
|
|
138
140
|
newClassName = opts.customGenerate(original, opts, this.context);
|
|
@@ -169,17 +171,17 @@ function escapeStringRegexp(str) {
|
|
|
169
171
|
function makeRegex(str, options = {
|
|
170
172
|
exact: true
|
|
171
173
|
}) {
|
|
172
|
-
return new RegExp(
|
|
174
|
+
return new RegExp(`(?<=^|[\\s"])${escapeStringRegexp(str)}${options.exact ? '(?=$|[\\s"])' : ""}`, "g");
|
|
173
175
|
}
|
|
174
176
|
|
|
175
|
-
const validateFilterRE = /[\w
|
|
177
|
+
const validateFilterRE = /[\w\u00A0-\uFFFF%-?]/;
|
|
176
178
|
function isValidSelector(selector = "") {
|
|
177
179
|
return validateFilterRE.test(selector);
|
|
178
180
|
}
|
|
179
|
-
|
|
181
|
+
function splitCode(code, options = { splitQuote: true }) {
|
|
180
182
|
const regex = options.splitQuote ? /[\s"]+/ : /\s+/;
|
|
181
183
|
return code.split(regex).filter((x) => isValidSelector(x));
|
|
182
|
-
}
|
|
184
|
+
}
|
|
183
185
|
|
|
184
186
|
exports.ClassGenerator = ClassGenerator;
|
|
185
187
|
exports.acceptChars = acceptChars;
|
package/dist/index.d.cts
CHANGED
|
@@ -40,12 +40,12 @@ declare function makeRegex(str: string, options?: {
|
|
|
40
40
|
|
|
41
41
|
declare const validateFilterRE: RegExp;
|
|
42
42
|
declare function isValidSelector(selector?: string): selector is string;
|
|
43
|
-
declare
|
|
43
|
+
declare function splitCode(code: string, options?: {
|
|
44
44
|
splitQuote?: boolean;
|
|
45
|
-
})
|
|
45
|
+
}): string[];
|
|
46
46
|
|
|
47
47
|
declare const preserveClassNames: string[];
|
|
48
|
-
declare
|
|
48
|
+
declare function defaultMangleClassFilter(className: string): boolean;
|
|
49
49
|
declare function groupBy<T>(arr: T[], cb: (arg: T) => string): Record<string, T[]>;
|
|
50
50
|
declare const acceptChars: string[];
|
|
51
51
|
declare function stripEscapeSequence(words: string): string;
|
package/dist/index.d.mts
CHANGED
|
@@ -40,12 +40,12 @@ declare function makeRegex(str: string, options?: {
|
|
|
40
40
|
|
|
41
41
|
declare const validateFilterRE: RegExp;
|
|
42
42
|
declare function isValidSelector(selector?: string): selector is string;
|
|
43
|
-
declare
|
|
43
|
+
declare function splitCode(code: string, options?: {
|
|
44
44
|
splitQuote?: boolean;
|
|
45
|
-
})
|
|
45
|
+
}): string[];
|
|
46
46
|
|
|
47
47
|
declare const preserveClassNames: string[];
|
|
48
|
-
declare
|
|
48
|
+
declare function defaultMangleClassFilter(className: string): boolean;
|
|
49
49
|
declare function groupBy<T>(arr: T[], cb: (arg: T) => string): Record<string, T[]>;
|
|
50
50
|
declare const acceptChars: string[];
|
|
51
51
|
declare function stripEscapeSequence(words: string): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -40,12 +40,12 @@ declare function makeRegex(str: string, options?: {
|
|
|
40
40
|
|
|
41
41
|
declare const validateFilterRE: RegExp;
|
|
42
42
|
declare function isValidSelector(selector?: string): selector is string;
|
|
43
|
-
declare
|
|
43
|
+
declare function splitCode(code: string, options?: {
|
|
44
44
|
splitQuote?: boolean;
|
|
45
|
-
})
|
|
45
|
+
}): string[];
|
|
46
46
|
|
|
47
47
|
declare const preserveClassNames: string[];
|
|
48
|
-
declare
|
|
48
|
+
declare function defaultMangleClassFilter(className: string): boolean;
|
|
49
49
|
declare function groupBy<T>(arr: T[], cb: (arg: T) => string): Record<string, T[]>;
|
|
50
50
|
declare const acceptChars: string[];
|
|
51
51
|
declare function stripEscapeSequence(words: string): string;
|
package/dist/index.mjs
CHANGED
|
@@ -11,12 +11,12 @@ const preserveClassNamesMap = preserveClassNames.reduce((acc, cur) => {
|
|
|
11
11
|
acc[cur] = true;
|
|
12
12
|
return acc;
|
|
13
13
|
}, {});
|
|
14
|
-
|
|
14
|
+
function defaultMangleClassFilter(className) {
|
|
15
15
|
if (preserveClassNamesMap[className]) {
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
18
18
|
return /[:-]/.test(className);
|
|
19
|
-
}
|
|
19
|
+
}
|
|
20
20
|
function groupBy(arr, cb) {
|
|
21
21
|
if (!Array.isArray(arr)) {
|
|
22
22
|
throw new TypeError("expected an array for first argument");
|
|
@@ -121,16 +121,18 @@ class ClassGenerator {
|
|
|
121
121
|
transformCssClass(className) {
|
|
122
122
|
const key = stripEscapeSequence(className);
|
|
123
123
|
const cn = this.newClassMap[key];
|
|
124
|
-
if (cn)
|
|
124
|
+
if (cn) {
|
|
125
125
|
return cn.name;
|
|
126
|
+
}
|
|
126
127
|
return className;
|
|
127
128
|
}
|
|
128
129
|
generateClassName(original) {
|
|
129
130
|
const opts = this.opts;
|
|
130
131
|
original = stripEscapeSequence(original);
|
|
131
132
|
const cn = this.newClassMap[original];
|
|
132
|
-
if (cn)
|
|
133
|
+
if (cn) {
|
|
133
134
|
return cn;
|
|
135
|
+
}
|
|
134
136
|
let newClassName;
|
|
135
137
|
if (opts.customGenerate && typeof opts.customGenerate === "function") {
|
|
136
138
|
newClassName = opts.customGenerate(original, opts, this.context);
|
|
@@ -167,16 +169,16 @@ function escapeStringRegexp(str) {
|
|
|
167
169
|
function makeRegex(str, options = {
|
|
168
170
|
exact: true
|
|
169
171
|
}) {
|
|
170
|
-
return new RegExp(
|
|
172
|
+
return new RegExp(`(?<=^|[\\s"])${escapeStringRegexp(str)}${options.exact ? '(?=$|[\\s"])' : ""}`, "g");
|
|
171
173
|
}
|
|
172
174
|
|
|
173
|
-
const validateFilterRE = /[\w
|
|
175
|
+
const validateFilterRE = /[\w\u00A0-\uFFFF%-?]/;
|
|
174
176
|
function isValidSelector(selector = "") {
|
|
175
177
|
return validateFilterRE.test(selector);
|
|
176
178
|
}
|
|
177
|
-
|
|
179
|
+
function splitCode(code, options = { splitQuote: true }) {
|
|
178
180
|
const regex = options.splitQuote ? /[\s"]+/ : /\s+/;
|
|
179
181
|
return code.split(regex).filter((x) => isValidSelector(x));
|
|
180
|
-
}
|
|
182
|
+
}
|
|
181
183
|
|
|
182
184
|
export { ClassGenerator, acceptChars, defaultMangleClassFilter, escapeStringRegexp, groupBy, isMap, isRegexp, isValidSelector, makeRegex, preserveClassNames, regExpTest, splitCode, stripEscapeSequence, validateFilterRE };
|
package/package.json
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailwindcss-mangle/shared",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "The shared utils of tailwindcss-mangle",
|
|
5
|
+
"author": "SonOfMagic <qq1324318532@gmail.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/sonofmagic/tailwindcss-mangle",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/sonofmagic/tailwindcss-mangle.git"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"tailwindcss",
|
|
14
|
+
"patch",
|
|
15
|
+
"core",
|
|
16
|
+
"mangle",
|
|
17
|
+
"shared",
|
|
18
|
+
"utils"
|
|
19
|
+
],
|
|
5
20
|
"exports": {
|
|
6
21
|
".": {
|
|
7
22
|
"types": "./dist/index.d.ts",
|
|
@@ -9,6 +24,9 @@
|
|
|
9
24
|
"require": "./dist/index.cjs"
|
|
10
25
|
}
|
|
11
26
|
},
|
|
27
|
+
"main": "./dist/index.cjs",
|
|
28
|
+
"module": "./dist/index.mjs",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
12
30
|
"typesVersions": {
|
|
13
31
|
"*": {
|
|
14
32
|
"*": [
|
|
@@ -17,33 +35,15 @@
|
|
|
17
35
|
]
|
|
18
36
|
}
|
|
19
37
|
},
|
|
20
|
-
"main": "./dist/index.cjs",
|
|
21
|
-
"module": "./dist/index.mjs",
|
|
22
|
-
"types": "./dist/index.d.ts",
|
|
23
38
|
"files": [
|
|
24
39
|
"dist"
|
|
25
40
|
],
|
|
26
|
-
"keywords": [
|
|
27
|
-
"tailwindcss",
|
|
28
|
-
"patch",
|
|
29
|
-
"core",
|
|
30
|
-
"mangle",
|
|
31
|
-
"shared",
|
|
32
|
-
"utils"
|
|
33
|
-
],
|
|
34
|
-
"author": "SonOfMagic <qq1324318532@gmail.com>",
|
|
35
|
-
"license": "MIT",
|
|
36
41
|
"publishConfig": {
|
|
37
42
|
"access": "public",
|
|
38
43
|
"registry": "https://registry.npmjs.org/"
|
|
39
44
|
},
|
|
40
45
|
"dependencies": {},
|
|
41
46
|
"devDependencies": {},
|
|
42
|
-
"homepage": "https://github.com/sonofmagic/tailwindcss-mangle",
|
|
43
|
-
"repository": {
|
|
44
|
-
"type": "git",
|
|
45
|
-
"url": "git+https://github.com/sonofmagic/tailwindcss-mangle.git"
|
|
46
|
-
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"dev": "unbuild --sourcemap",
|
|
49
49
|
"build": "unbuild",
|