webgal-parser 4.4.14 → 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 +7 -6
- package/build/cjs/index.d.ts +1 -1
- package/build/cjs/interface/sceneInterface.d.ts +2 -1
- package/build/es/index.d.ts +1 -1
- package/build/es/index.js +7 -6
- package/build/es/interface/sceneInterface.d.ts +2 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/interface/sceneInterface.d.ts +2 -1
- package/build/umd/index.global.js +7 -6
- package/package.json +3 -2
- package/src/config/scriptConfig.ts +2 -1
- package/src/index.ts +1 -1
- package/src/interface/sceneInterface.ts +1 -0
- package/src/styleParser/index.ts +6 -6
package/build/cjs/index.cjs
CHANGED
|
@@ -36,6 +36,7 @@ var commandType;
|
|
|
36
36
|
commandType[commandType["setTransform"] = 29] = "setTransform";
|
|
37
37
|
commandType[commandType["setTransition"] = 30] = "setTransition";
|
|
38
38
|
commandType[commandType["getUserInput"] = 31] = "getUserInput";
|
|
39
|
+
commandType[commandType["applyStyle"] = 32] = "applyStyle";
|
|
39
40
|
})(commandType || (commandType = {}));
|
|
40
41
|
|
|
41
42
|
const SCRIPT_CONFIG = [
|
|
@@ -68,6 +69,7 @@ const SCRIPT_CONFIG = [
|
|
|
68
69
|
{ scriptString: 'setTextbox', scriptType: commandType.setTextbox },
|
|
69
70
|
{ scriptString: 'setAnimation', scriptType: commandType.setAnimation },
|
|
70
71
|
{ scriptString: 'playEffect', scriptType: commandType.playEffect },
|
|
72
|
+
{ scriptString: 'applyStyle', scriptType: commandType.applyStyle },
|
|
71
73
|
];
|
|
72
74
|
const ADD_NEXT_ARG_LIST = [
|
|
73
75
|
commandType.bgm,
|
|
@@ -1800,15 +1802,14 @@ function parseCSS(css) {
|
|
|
1800
1802
|
const result = {};
|
|
1801
1803
|
let specialRules = '';
|
|
1802
1804
|
let matches;
|
|
1803
|
-
//
|
|
1804
|
-
const classRegex = /\.([^{\s]+)\s*{([^}]
|
|
1805
|
-
// 更新特殊规则正则表达式以正确处理一层嵌套,并确保大括号成对出现
|
|
1805
|
+
// 使用非贪婪匹配,尝试正确处理任意层次的嵌套
|
|
1806
|
+
const classRegex = /\.([^{\s]+)\s*{((?:[^{}]*|{[^}]*})*)}/g;
|
|
1806
1807
|
const specialRegex = /(@[^{]+{\s*(?:[^{}]*{[^}]*}[^{}]*)+\s*})/g;
|
|
1807
|
-
// 提取类和样式
|
|
1808
1808
|
while ((matches = classRegex.exec(css)) !== null) {
|
|
1809
|
-
|
|
1809
|
+
const key = matches[1];
|
|
1810
|
+
const value = matches[2].trim().replace(/\s*;\s*/g, ';\n');
|
|
1811
|
+
result[key] = value;
|
|
1810
1812
|
}
|
|
1811
|
-
// 提取特殊规则,并确保包含所有的大括号
|
|
1812
1813
|
while ((matches = specialRegex.exec(css)) !== null) {
|
|
1813
1814
|
specialRules += matches[1].trim() + '\n';
|
|
1814
1815
|
}
|
package/build/cjs/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ADD_NEXT_ARG_LIST, SCRIPT_CONFIG, ConfigMap, ConfigItem } from './confi
|
|
|
2
2
|
import { WebgalConfig } from './configParser/configParser';
|
|
3
3
|
import { fileType } from './interface/assets';
|
|
4
4
|
import { IAsset } from './interface/sceneInterface';
|
|
5
|
-
import { IWebGALStyleObj } from "
|
|
5
|
+
import { IWebGALStyleObj } from "./styleParser";
|
|
6
6
|
export default class SceneParser {
|
|
7
7
|
private readonly assetsPrefetcher;
|
|
8
8
|
private readonly assetSetter;
|
package/build/es/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ADD_NEXT_ARG_LIST, SCRIPT_CONFIG, ConfigMap, ConfigItem } from './confi
|
|
|
2
2
|
import { WebgalConfig } from './configParser/configParser';
|
|
3
3
|
import { fileType } from './interface/assets';
|
|
4
4
|
import { IAsset } from './interface/sceneInterface';
|
|
5
|
-
import { IWebGALStyleObj } from "
|
|
5
|
+
import { IWebGALStyleObj } from "./styleParser";
|
|
6
6
|
export default class SceneParser {
|
|
7
7
|
private readonly assetsPrefetcher;
|
|
8
8
|
private readonly assetSetter;
|
package/build/es/index.js
CHANGED
|
@@ -32,6 +32,7 @@ var commandType;
|
|
|
32
32
|
commandType[commandType["setTransform"] = 29] = "setTransform";
|
|
33
33
|
commandType[commandType["setTransition"] = 30] = "setTransition";
|
|
34
34
|
commandType[commandType["getUserInput"] = 31] = "getUserInput";
|
|
35
|
+
commandType[commandType["applyStyle"] = 32] = "applyStyle";
|
|
35
36
|
})(commandType || (commandType = {}));
|
|
36
37
|
|
|
37
38
|
const SCRIPT_CONFIG = [
|
|
@@ -64,6 +65,7 @@ const SCRIPT_CONFIG = [
|
|
|
64
65
|
{ scriptString: 'setTextbox', scriptType: commandType.setTextbox },
|
|
65
66
|
{ scriptString: 'setAnimation', scriptType: commandType.setAnimation },
|
|
66
67
|
{ scriptString: 'playEffect', scriptType: commandType.playEffect },
|
|
68
|
+
{ scriptString: 'applyStyle', scriptType: commandType.applyStyle },
|
|
67
69
|
];
|
|
68
70
|
const ADD_NEXT_ARG_LIST = [
|
|
69
71
|
commandType.bgm,
|
|
@@ -1796,15 +1798,14 @@ function parseCSS(css) {
|
|
|
1796
1798
|
const result = {};
|
|
1797
1799
|
let specialRules = '';
|
|
1798
1800
|
let matches;
|
|
1799
|
-
//
|
|
1800
|
-
const classRegex = /\.([^{\s]+)\s*{([^}]
|
|
1801
|
-
// 更新特殊规则正则表达式以正确处理一层嵌套,并确保大括号成对出现
|
|
1801
|
+
// 使用非贪婪匹配,尝试正确处理任意层次的嵌套
|
|
1802
|
+
const classRegex = /\.([^{\s]+)\s*{((?:[^{}]*|{[^}]*})*)}/g;
|
|
1802
1803
|
const specialRegex = /(@[^{]+{\s*(?:[^{}]*{[^}]*}[^{}]*)+\s*})/g;
|
|
1803
|
-
// 提取类和样式
|
|
1804
1804
|
while ((matches = classRegex.exec(css)) !== null) {
|
|
1805
|
-
|
|
1805
|
+
const key = matches[1];
|
|
1806
|
+
const value = matches[2].trim().replace(/\s*;\s*/g, ';\n');
|
|
1807
|
+
result[key] = value;
|
|
1806
1808
|
}
|
|
1807
|
-
// 提取特殊规则,并确保包含所有的大括号
|
|
1808
1809
|
while ((matches = specialRegex.exec(css)) !== null) {
|
|
1809
1810
|
specialRules += matches[1].trim() + '\n';
|
|
1810
1811
|
}
|
package/build/types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ADD_NEXT_ARG_LIST, SCRIPT_CONFIG, ConfigMap, ConfigItem } from './confi
|
|
|
2
2
|
import { WebgalConfig } from './configParser/configParser';
|
|
3
3
|
import { fileType } from './interface/assets';
|
|
4
4
|
import { IAsset } from './interface/sceneInterface';
|
|
5
|
-
import { IWebGALStyleObj } from "
|
|
5
|
+
import { IWebGALStyleObj } from "./styleParser";
|
|
6
6
|
export default class SceneParser {
|
|
7
7
|
private readonly assetsPrefetcher;
|
|
8
8
|
private readonly assetSetter;
|
|
@@ -35,6 +35,7 @@ var webgalParser = (function (exports) {
|
|
|
35
35
|
commandType[commandType["setTransform"] = 29] = "setTransform";
|
|
36
36
|
commandType[commandType["setTransition"] = 30] = "setTransition";
|
|
37
37
|
commandType[commandType["getUserInput"] = 31] = "getUserInput";
|
|
38
|
+
commandType[commandType["applyStyle"] = 32] = "applyStyle";
|
|
38
39
|
})(commandType || (commandType = {}));
|
|
39
40
|
|
|
40
41
|
const SCRIPT_CONFIG = [
|
|
@@ -67,6 +68,7 @@ var webgalParser = (function (exports) {
|
|
|
67
68
|
{ scriptString: 'setTextbox', scriptType: commandType.setTextbox },
|
|
68
69
|
{ scriptString: 'setAnimation', scriptType: commandType.setAnimation },
|
|
69
70
|
{ scriptString: 'playEffect', scriptType: commandType.playEffect },
|
|
71
|
+
{ scriptString: 'applyStyle', scriptType: commandType.applyStyle },
|
|
70
72
|
];
|
|
71
73
|
const ADD_NEXT_ARG_LIST = [
|
|
72
74
|
commandType.bgm,
|
|
@@ -1799,15 +1801,14 @@ var webgalParser = (function (exports) {
|
|
|
1799
1801
|
const result = {};
|
|
1800
1802
|
let specialRules = '';
|
|
1801
1803
|
let matches;
|
|
1802
|
-
//
|
|
1803
|
-
const classRegex = /\.([^{\s]+)\s*{([^}]
|
|
1804
|
-
// 更新特殊规则正则表达式以正确处理一层嵌套,并确保大括号成对出现
|
|
1804
|
+
// 使用非贪婪匹配,尝试正确处理任意层次的嵌套
|
|
1805
|
+
const classRegex = /\.([^{\s]+)\s*{((?:[^{}]*|{[^}]*})*)}/g;
|
|
1805
1806
|
const specialRegex = /(@[^{]+{\s*(?:[^{}]*{[^}]*}[^{}]*)+\s*})/g;
|
|
1806
|
-
// 提取类和样式
|
|
1807
1807
|
while ((matches = classRegex.exec(css)) !== null) {
|
|
1808
|
-
|
|
1808
|
+
const key = matches[1];
|
|
1809
|
+
const value = matches[2].trim().replace(/\s*;\s*/g, ';\n');
|
|
1810
|
+
result[key] = value;
|
|
1809
1811
|
}
|
|
1810
|
-
// 提取特殊规则,并确保包含所有的大括号
|
|
1811
1812
|
while ((matches = specialRegex.exec(css)) !== null) {
|
|
1812
1813
|
specialRules += matches[1].trim() + '\n';
|
|
1813
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",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {commandType} from '../interface/sceneInterface';
|
|
2
2
|
|
|
3
3
|
export const SCRIPT_CONFIG = [
|
|
4
4
|
{ scriptString: 'intro', scriptType: commandType.intro },
|
|
@@ -30,6 +30,7 @@ export const SCRIPT_CONFIG = [
|
|
|
30
30
|
{ scriptString: 'setTextbox', scriptType: commandType.setTextbox },
|
|
31
31
|
{ scriptString: 'setAnimation', scriptType: commandType.setAnimation },
|
|
32
32
|
{ scriptString: 'playEffect', scriptType: commandType.playEffect },
|
|
33
|
+
{ scriptString: 'applyStyle', scriptType: commandType.applyStyle },
|
|
33
34
|
];
|
|
34
35
|
export const ADD_NEXT_ARG_LIST = [
|
|
35
36
|
commandType.bgm,
|
package/src/index.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { configParser, WebgalConfig } from './configParser/configParser';
|
|
|
8
8
|
import { fileType } from './interface/assets';
|
|
9
9
|
import { IAsset } from './interface/sceneInterface';
|
|
10
10
|
import { sceneParser } from './sceneParser';
|
|
11
|
-
import {IWebGALStyleObj, scss2cssinjsParser} from "
|
|
11
|
+
import {IWebGALStyleObj, scss2cssinjsParser} from "./styleParser";
|
|
12
12
|
|
|
13
13
|
export default class SceneParser {
|
|
14
14
|
private readonly SCRIPT_CONFIG_MAP: ConfigMap;
|
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
|
}
|