webgal-parser 4.4.15 → 4.5.13
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 +221 -17
- package/build/cjs/index.d.ts +2 -0
- package/build/cjs/interface/sceneInterface.d.ts +2 -1
- package/build/cjs/sceneTextPreProcessor.d.ts +11 -0
- package/build/es/index.d.ts +2 -0
- package/build/es/index.js +221 -18
- package/build/es/interface/sceneInterface.d.ts +2 -1
- package/build/es/sceneTextPreProcessor.d.ts +11 -0
- package/build/types/index.d.ts +2 -0
- package/build/types/interface/sceneInterface.d.ts +2 -1
- package/build/types/sceneTextPreProcessor.d.ts +11 -0
- package/build/umd/index.global.js +221 -17
- package/package.json +4 -3
- package/src/config/scriptConfig.ts +18 -9
- package/src/configParser/configParser.ts +1 -1
- package/src/index.ts +3 -1
- package/src/interface/sceneInterface.ts +2 -1
- package/src/sceneTextPreProcessor.ts +223 -0
- package/src/scriptParser/contentParser.ts +3 -3
- package/src/scriptParser/scriptParser.ts +15 -6
|
@@ -45,12 +45,12 @@ export const contentParser = (
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
function getChooseContent(contentRaw: string, assetSetter: any): string {
|
|
48
|
-
const chooseList = contentRaw.split(
|
|
48
|
+
const chooseList = contentRaw.split(/(?<!\\)\|/);
|
|
49
49
|
const chooseKeyList: Array<string> = [];
|
|
50
50
|
const chooseValueList: Array<string> = [];
|
|
51
51
|
for (const e of chooseList) {
|
|
52
|
-
chooseKeyList.push(e.split(
|
|
53
|
-
chooseValueList.push(e.split(
|
|
52
|
+
chooseKeyList.push(e.split(/(?<!\\):/)[0] ?? '');
|
|
53
|
+
chooseValueList.push(e.split(/(?<!\\):/)[1] ?? '');
|
|
54
54
|
}
|
|
55
55
|
const parsedChooseList = chooseValueList.map((e) => {
|
|
56
56
|
if (e.match(/\./)) {
|
|
@@ -35,8 +35,9 @@ export const scriptParser = (
|
|
|
35
35
|
|
|
36
36
|
// 正式开始解析
|
|
37
37
|
|
|
38
|
-
//
|
|
39
|
-
let newSentenceRaw = sentenceRaw.split(
|
|
38
|
+
// 去分号
|
|
39
|
+
let newSentenceRaw = sentenceRaw.split(/(?<!\\);/)[0];
|
|
40
|
+
newSentenceRaw = newSentenceRaw.replaceAll('\\;',';');
|
|
40
41
|
if (newSentenceRaw === '') {
|
|
41
42
|
// 注释提前返回
|
|
42
43
|
return {
|
|
@@ -56,7 +57,11 @@ export const scriptParser = (
|
|
|
56
57
|
// 没有command,说明这是一条连续对话或单条语句
|
|
57
58
|
if (getCommandResult === null) {
|
|
58
59
|
commandRaw = newSentenceRaw;
|
|
59
|
-
parsedCommand = commandParser(
|
|
60
|
+
parsedCommand = commandParser(
|
|
61
|
+
commandRaw,
|
|
62
|
+
ADD_NEXT_ARG_LIST,
|
|
63
|
+
SCRIPT_CONFIG_MAP,
|
|
64
|
+
);
|
|
60
65
|
command = parsedCommand.type;
|
|
61
66
|
for (const e of parsedCommand.additionalArgs) {
|
|
62
67
|
// 由于是连续对话,所以我们去除 speaker 参数。
|
|
@@ -72,7 +77,11 @@ export const scriptParser = (
|
|
|
72
77
|
getCommandResult.index + 1,
|
|
73
78
|
newSentenceRaw.length,
|
|
74
79
|
);
|
|
75
|
-
parsedCommand = commandParser(
|
|
80
|
+
parsedCommand = commandParser(
|
|
81
|
+
commandRaw,
|
|
82
|
+
ADD_NEXT_ARG_LIST,
|
|
83
|
+
SCRIPT_CONFIG_MAP,
|
|
84
|
+
);
|
|
76
85
|
command = parsedCommand.type;
|
|
77
86
|
for (const e of parsedCommand.additionalArgs) {
|
|
78
87
|
args.push(e);
|
|
@@ -91,12 +100,12 @@ export const scriptParser = (
|
|
|
91
100
|
args.push(e);
|
|
92
101
|
}
|
|
93
102
|
}
|
|
94
|
-
content = contentParser(newSentenceRaw, command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
|
|
103
|
+
content = contentParser(newSentenceRaw.trim(), command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
|
|
95
104
|
sentenceAssets = assetsScanner(command, content, args); // 扫描语句携带资源
|
|
96
105
|
subScene = subSceneScanner(command, content); // 扫描语句携带子场景
|
|
97
106
|
return {
|
|
98
107
|
command: command, // 语句类型
|
|
99
|
-
commandRaw: commandRaw, // 命令原始内容,方便调试
|
|
108
|
+
commandRaw: commandRaw.trim(), // 命令原始内容,方便调试
|
|
100
109
|
content: content, // 语句内容
|
|
101
110
|
args: args, // 参数列表
|
|
102
111
|
sentenceAssets: sentenceAssets, // 语句携带的资源列表
|