webgal-parser 4.4.14-3 → 4.4.15
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/build/cjs/index.cjs
CHANGED
|
@@ -1802,15 +1802,14 @@ function parseCSS(css) {
|
|
|
1802
1802
|
const result = {};
|
|
1803
1803
|
let specialRules = '';
|
|
1804
1804
|
let matches;
|
|
1805
|
-
//
|
|
1806
|
-
const classRegex = /\.([^{\s]+)\s*{([^}]
|
|
1807
|
-
// 更新特殊规则正则表达式以正确处理一层嵌套,并确保大括号成对出现
|
|
1805
|
+
// 使用非贪婪匹配,尝试正确处理任意层次的嵌套
|
|
1806
|
+
const classRegex = /\.([^{\s]+)\s*{((?:[^{}]*|{[^}]*})*)}/g;
|
|
1808
1807
|
const specialRegex = /(@[^{]+{\s*(?:[^{}]*{[^}]*}[^{}]*)+\s*})/g;
|
|
1809
|
-
// 提取类和样式
|
|
1810
1808
|
while ((matches = classRegex.exec(css)) !== null) {
|
|
1811
|
-
|
|
1809
|
+
const key = matches[1];
|
|
1810
|
+
const value = matches[2].trim().replace(/\s*;\s*/g, ';\n');
|
|
1811
|
+
result[key] = value;
|
|
1812
1812
|
}
|
|
1813
|
-
// 提取特殊规则,并确保包含所有的大括号
|
|
1814
1813
|
while ((matches = specialRegex.exec(css)) !== null) {
|
|
1815
1814
|
specialRules += matches[1].trim() + '\n';
|
|
1816
1815
|
}
|
package/build/es/index.js
CHANGED
|
@@ -1798,15 +1798,14 @@ function parseCSS(css) {
|
|
|
1798
1798
|
const result = {};
|
|
1799
1799
|
let specialRules = '';
|
|
1800
1800
|
let matches;
|
|
1801
|
-
//
|
|
1802
|
-
const classRegex = /\.([^{\s]+)\s*{([^}]
|
|
1803
|
-
// 更新特殊规则正则表达式以正确处理一层嵌套,并确保大括号成对出现
|
|
1801
|
+
// 使用非贪婪匹配,尝试正确处理任意层次的嵌套
|
|
1802
|
+
const classRegex = /\.([^{\s]+)\s*{((?:[^{}]*|{[^}]*})*)}/g;
|
|
1804
1803
|
const specialRegex = /(@[^{]+{\s*(?:[^{}]*{[^}]*}[^{}]*)+\s*})/g;
|
|
1805
|
-
// 提取类和样式
|
|
1806
1804
|
while ((matches = classRegex.exec(css)) !== null) {
|
|
1807
|
-
|
|
1805
|
+
const key = matches[1];
|
|
1806
|
+
const value = matches[2].trim().replace(/\s*;\s*/g, ';\n');
|
|
1807
|
+
result[key] = value;
|
|
1808
1808
|
}
|
|
1809
|
-
// 提取特殊规则,并确保包含所有的大括号
|
|
1810
1809
|
while ((matches = specialRegex.exec(css)) !== null) {
|
|
1811
1810
|
specialRules += matches[1].trim() + '\n';
|
|
1812
1811
|
}
|
|
@@ -1801,15 +1801,14 @@ var webgalParser = (function (exports) {
|
|
|
1801
1801
|
const result = {};
|
|
1802
1802
|
let specialRules = '';
|
|
1803
1803
|
let matches;
|
|
1804
|
-
//
|
|
1805
|
-
const classRegex = /\.([^{\s]+)\s*{([^}]
|
|
1806
|
-
// 更新特殊规则正则表达式以正确处理一层嵌套,并确保大括号成对出现
|
|
1804
|
+
// 使用非贪婪匹配,尝试正确处理任意层次的嵌套
|
|
1805
|
+
const classRegex = /\.([^{\s]+)\s*{((?:[^{}]*|{[^}]*})*)}/g;
|
|
1807
1806
|
const specialRegex = /(@[^{]+{\s*(?:[^{}]*{[^}]*}[^{}]*)+\s*})/g;
|
|
1808
|
-
// 提取类和样式
|
|
1809
1807
|
while ((matches = classRegex.exec(css)) !== null) {
|
|
1810
|
-
|
|
1808
|
+
const key = matches[1];
|
|
1809
|
+
const value = matches[2].trim().replace(/\s*;\s*/g, ';\n');
|
|
1810
|
+
result[key] = value;
|
|
1811
1811
|
}
|
|
1812
|
-
// 提取特殊规则,并确保包含所有的大括号
|
|
1813
1812
|
while ((matches = specialRegex.exec(css)) !== null) {
|
|
1814
1813
|
specialRules += matches[1].trim() + '\n';
|
|
1815
1814
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webgal-parser",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.15",
|
|
4
4
|
"description": "WebGAL script parser",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "vitest",
|
|
7
7
|
"coverage": "vitest run --coverage",
|
|
8
8
|
"build": "rimraf -rf ./build && rollup --config",
|
|
9
9
|
"build-ci": "rollup --config",
|
|
10
|
-
"debug": "tsx test/debug.ts"
|
|
10
|
+
"debug": "tsx test/debug.ts",
|
|
11
|
+
"debug-scss-parser": "tsx test/debugCssParser.ts"
|
|
11
12
|
},
|
|
12
13
|
"types": "./build/types/index.d.ts",
|
|
13
14
|
"module": "./build/es/index.js",
|
package/src/styleParser/index.ts
CHANGED
|
@@ -20,17 +20,17 @@ function parseCSS(css: string): [Record<string, string>, string] {
|
|
|
20
20
|
const result: Record<string, string> = {};
|
|
21
21
|
let specialRules = '';
|
|
22
22
|
let matches;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
|
|
24
|
+
// 使用非贪婪匹配,尝试正确处理任意层次的嵌套
|
|
25
|
+
const classRegex = /\.([^{\s]+)\s*{((?:[^{}]*|{[^}]*})*)}/g;
|
|
26
26
|
const specialRegex = /(@[^{]+{\s*(?:[^{}]*{[^}]*}[^{}]*)+\s*})/g;
|
|
27
27
|
|
|
28
|
-
// 提取类和样式
|
|
29
28
|
while ((matches = classRegex.exec(css)) !== null) {
|
|
30
|
-
|
|
29
|
+
const key = matches[1];
|
|
30
|
+
const value = matches[2].trim().replace(/\s*;\s*/g, ';\n');
|
|
31
|
+
result[key] = value;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
// 提取特殊规则,并确保包含所有的大括号
|
|
34
34
|
while ((matches = specialRegex.exec(css)) !== null) {
|
|
35
35
|
specialRules += matches[1].trim() + '\n';
|
|
36
36
|
}
|