webgal-parser 4.5.18 → 4.6.1
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 +43 -43
- package/build/cjs/scriptParser/assetsScanner.d.ts +1 -1
- package/build/cjs/scriptParser/scriptParser.d.ts +1 -1
- package/build/es/index.js +43 -43
- package/build/es/scriptParser/assetsScanner.d.ts +1 -1
- package/build/es/scriptParser/scriptParser.d.ts +1 -1
- package/build/types/scriptParser/assetsScanner.d.ts +1 -1
- package/build/types/scriptParser/scriptParser.d.ts +1 -1
- package/build/umd/index.global.js +43 -43
- package/package.json +2 -2
- package/src/sceneParser.ts +2 -1
- package/src/scriptParser/argsParser.ts +33 -30
- package/src/scriptParser/assetsScanner.ts +7 -6
- package/src/scriptParser/scriptParser.ts +2 -1
package/build/cjs/index.cjs
CHANGED
|
@@ -144,39 +144,39 @@ function argsParser(argsRaw, assetSetter) {
|
|
|
144
144
|
value: assetSetter(e, fileType.vocal),
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
+
else if (argName === 'vocal' && argValue !== undefined) {
|
|
148
|
+
returnArrayList.push({
|
|
149
|
+
key: argName,
|
|
150
|
+
value: assetSetter(argValue, fileType.vocal),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
// 判断是不是省略参数
|
|
154
|
+
else if (argValue === undefined) {
|
|
155
|
+
returnArrayList.push({
|
|
156
|
+
key: argName,
|
|
157
|
+
value: true,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
// 是字符串描述的布尔值
|
|
161
|
+
else if (argValue === 'true' || argValue === 'false') {
|
|
162
|
+
returnArrayList.push({
|
|
163
|
+
key: argName,
|
|
164
|
+
value: argValue === 'true',
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
// 是数字
|
|
168
|
+
else if (!isNaN(Number(argValue))) {
|
|
169
|
+
returnArrayList.push({
|
|
170
|
+
key: argName,
|
|
171
|
+
value: Number(argValue),
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
// 是普通参数
|
|
147
175
|
else {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
value: true,
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
// 是字符串描述的布尔值
|
|
157
|
-
if (argValue === 'true' || argValue === 'false') {
|
|
158
|
-
returnArrayList.push({
|
|
159
|
-
key: argName,
|
|
160
|
-
value: argValue === 'true',
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
// 是数字
|
|
165
|
-
if (!isNaN(Number(argValue))) {
|
|
166
|
-
returnArrayList.push({
|
|
167
|
-
key: argName,
|
|
168
|
-
value: Number(argValue),
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
// 是普通参数
|
|
173
|
-
returnArrayList.push({
|
|
174
|
-
key: argName,
|
|
175
|
-
value: argValue,
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
176
|
+
returnArrayList.push({
|
|
177
|
+
key: argName,
|
|
178
|
+
value: argValue,
|
|
179
|
+
});
|
|
180
180
|
}
|
|
181
181
|
});
|
|
182
182
|
return returnArrayList;
|
|
@@ -349,7 +349,7 @@ function getChooseContent(contentRaw, assetSetter) {
|
|
|
349
349
|
* @param args 参数列表
|
|
350
350
|
* @return {Array<IAsset>} 语句携带的参数列表
|
|
351
351
|
*/
|
|
352
|
-
const assetsScanner = (command, content, args) => {
|
|
352
|
+
const assetsScanner = (command, content, args, lineNumber) => {
|
|
353
353
|
const returnAssetsList = [];
|
|
354
354
|
if (command === commandType.say) {
|
|
355
355
|
args.forEach((e) => {
|
|
@@ -357,7 +357,7 @@ const assetsScanner = (command, content, args) => {
|
|
|
357
357
|
returnAssetsList.push({
|
|
358
358
|
name: e.value,
|
|
359
359
|
url: e.value,
|
|
360
|
-
lineNumber
|
|
360
|
+
lineNumber,
|
|
361
361
|
type: fileType.vocal,
|
|
362
362
|
});
|
|
363
363
|
}
|
|
@@ -371,7 +371,7 @@ const assetsScanner = (command, content, args) => {
|
|
|
371
371
|
returnAssetsList.push({
|
|
372
372
|
name: content,
|
|
373
373
|
url: content,
|
|
374
|
-
lineNumber
|
|
374
|
+
lineNumber,
|
|
375
375
|
type: fileType.background,
|
|
376
376
|
});
|
|
377
377
|
}
|
|
@@ -379,7 +379,7 @@ const assetsScanner = (command, content, args) => {
|
|
|
379
379
|
returnAssetsList.push({
|
|
380
380
|
name: content,
|
|
381
381
|
url: content,
|
|
382
|
-
lineNumber
|
|
382
|
+
lineNumber,
|
|
383
383
|
type: fileType.figure,
|
|
384
384
|
});
|
|
385
385
|
}
|
|
@@ -387,7 +387,7 @@ const assetsScanner = (command, content, args) => {
|
|
|
387
387
|
returnAssetsList.push({
|
|
388
388
|
name: content,
|
|
389
389
|
url: content,
|
|
390
|
-
lineNumber
|
|
390
|
+
lineNumber,
|
|
391
391
|
type: fileType.figure,
|
|
392
392
|
});
|
|
393
393
|
}
|
|
@@ -395,7 +395,7 @@ const assetsScanner = (command, content, args) => {
|
|
|
395
395
|
returnAssetsList.push({
|
|
396
396
|
name: content,
|
|
397
397
|
url: content,
|
|
398
|
-
lineNumber
|
|
398
|
+
lineNumber,
|
|
399
399
|
type: fileType.video,
|
|
400
400
|
});
|
|
401
401
|
}
|
|
@@ -403,7 +403,7 @@ const assetsScanner = (command, content, args) => {
|
|
|
403
403
|
returnAssetsList.push({
|
|
404
404
|
name: content,
|
|
405
405
|
url: content,
|
|
406
|
-
lineNumber
|
|
406
|
+
lineNumber,
|
|
407
407
|
type: fileType.bgm,
|
|
408
408
|
});
|
|
409
409
|
}
|
|
@@ -440,7 +440,7 @@ const subSceneScanner = (command, content) => {
|
|
|
440
440
|
* @param ADD_NEXT_ARG_LIST
|
|
441
441
|
* @param SCRIPT_CONFIG_MAP
|
|
442
442
|
*/
|
|
443
|
-
const scriptParser = (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP) => {
|
|
443
|
+
const scriptParser = (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP, lineNumber = 0) => {
|
|
444
444
|
let command; // 默认为对话
|
|
445
445
|
let content; // 语句内容
|
|
446
446
|
let subScene; // 语句携带的子场景(可能没有)
|
|
@@ -505,7 +505,7 @@ const scriptParser = (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG
|
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
content = contentParser(newSentenceRaw.trim(), command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
|
|
508
|
-
sentenceAssets = assetsScanner(command, content, args); // 扫描语句携带资源
|
|
508
|
+
sentenceAssets = assetsScanner(command, content, args, lineNumber); // 扫描语句携带资源
|
|
509
509
|
subScene = subSceneScanner(command, content); // 扫描语句携带子场景
|
|
510
510
|
return {
|
|
511
511
|
command: command,
|
|
@@ -1785,8 +1785,8 @@ const sceneParser = (rawScene, sceneName, sceneUrl, assetsPrefetcher, assetSette
|
|
|
1785
1785
|
// .filter((sentence) => sentence.trim() !== "");
|
|
1786
1786
|
let assetsList = []; // 场景资源列表
|
|
1787
1787
|
let subSceneList = []; // 子场景列表
|
|
1788
|
-
const sentenceList = rawSentenceListWithoutEmpty.map((sentence) => {
|
|
1789
|
-
const returnSentence = scriptParser(sentence, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP);
|
|
1788
|
+
const sentenceList = rawSentenceListWithoutEmpty.map((sentence, index) => {
|
|
1789
|
+
const returnSentence = scriptParser(sentence, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP, index);
|
|
1790
1790
|
// 在这里解析出语句可能携带的资源和场景,合并到 assetsList 和 subSceneList
|
|
1791
1791
|
assetsList = [...assetsList, ...returnSentence.sentenceAssets];
|
|
1792
1792
|
subSceneList = [...subSceneList, ...returnSentence.subScene];
|
|
@@ -6,4 +6,4 @@ import { arg, commandType, IAsset } from '../interface/sceneInterface';
|
|
|
6
6
|
* @param args 参数列表
|
|
7
7
|
* @return {Array<IAsset>} 语句携带的参数列表
|
|
8
8
|
*/
|
|
9
|
-
export declare const assetsScanner: (command: commandType, content: string, args: Array<arg
|
|
9
|
+
export declare const assetsScanner: (command: commandType, content: string, args: Array<arg>, lineNumber: number) => Array<IAsset>;
|
|
@@ -7,4 +7,4 @@ import { ConfigMap } from '../config/scriptConfig';
|
|
|
7
7
|
* @param ADD_NEXT_ARG_LIST
|
|
8
8
|
* @param SCRIPT_CONFIG_MAP
|
|
9
9
|
*/
|
|
10
|
-
export declare const scriptParser: (sentenceRaw: string, assetSetter: any, ADD_NEXT_ARG_LIST: commandType[], SCRIPT_CONFIG_MAP: ConfigMap) => ISentence;
|
|
10
|
+
export declare const scriptParser: (sentenceRaw: string, assetSetter: any, ADD_NEXT_ARG_LIST: commandType[], SCRIPT_CONFIG_MAP: ConfigMap, lineNumber?: number) => ISentence;
|
package/build/es/index.js
CHANGED
|
@@ -140,39 +140,39 @@ function argsParser(argsRaw, assetSetter) {
|
|
|
140
140
|
value: assetSetter(e, fileType.vocal),
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
+
else if (argName === 'vocal' && argValue !== undefined) {
|
|
144
|
+
returnArrayList.push({
|
|
145
|
+
key: argName,
|
|
146
|
+
value: assetSetter(argValue, fileType.vocal),
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
// 判断是不是省略参数
|
|
150
|
+
else if (argValue === undefined) {
|
|
151
|
+
returnArrayList.push({
|
|
152
|
+
key: argName,
|
|
153
|
+
value: true,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
// 是字符串描述的布尔值
|
|
157
|
+
else if (argValue === 'true' || argValue === 'false') {
|
|
158
|
+
returnArrayList.push({
|
|
159
|
+
key: argName,
|
|
160
|
+
value: argValue === 'true',
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
// 是数字
|
|
164
|
+
else if (!isNaN(Number(argValue))) {
|
|
165
|
+
returnArrayList.push({
|
|
166
|
+
key: argName,
|
|
167
|
+
value: Number(argValue),
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
// 是普通参数
|
|
143
171
|
else {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
value: true,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
// 是字符串描述的布尔值
|
|
153
|
-
if (argValue === 'true' || argValue === 'false') {
|
|
154
|
-
returnArrayList.push({
|
|
155
|
-
key: argName,
|
|
156
|
-
value: argValue === 'true',
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
// 是数字
|
|
161
|
-
if (!isNaN(Number(argValue))) {
|
|
162
|
-
returnArrayList.push({
|
|
163
|
-
key: argName,
|
|
164
|
-
value: Number(argValue),
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
// 是普通参数
|
|
169
|
-
returnArrayList.push({
|
|
170
|
-
key: argName,
|
|
171
|
-
value: argValue,
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
172
|
+
returnArrayList.push({
|
|
173
|
+
key: argName,
|
|
174
|
+
value: argValue,
|
|
175
|
+
});
|
|
176
176
|
}
|
|
177
177
|
});
|
|
178
178
|
return returnArrayList;
|
|
@@ -345,7 +345,7 @@ function getChooseContent(contentRaw, assetSetter) {
|
|
|
345
345
|
* @param args 参数列表
|
|
346
346
|
* @return {Array<IAsset>} 语句携带的参数列表
|
|
347
347
|
*/
|
|
348
|
-
const assetsScanner = (command, content, args) => {
|
|
348
|
+
const assetsScanner = (command, content, args, lineNumber) => {
|
|
349
349
|
const returnAssetsList = [];
|
|
350
350
|
if (command === commandType.say) {
|
|
351
351
|
args.forEach((e) => {
|
|
@@ -353,7 +353,7 @@ const assetsScanner = (command, content, args) => {
|
|
|
353
353
|
returnAssetsList.push({
|
|
354
354
|
name: e.value,
|
|
355
355
|
url: e.value,
|
|
356
|
-
lineNumber
|
|
356
|
+
lineNumber,
|
|
357
357
|
type: fileType.vocal,
|
|
358
358
|
});
|
|
359
359
|
}
|
|
@@ -367,7 +367,7 @@ const assetsScanner = (command, content, args) => {
|
|
|
367
367
|
returnAssetsList.push({
|
|
368
368
|
name: content,
|
|
369
369
|
url: content,
|
|
370
|
-
lineNumber
|
|
370
|
+
lineNumber,
|
|
371
371
|
type: fileType.background,
|
|
372
372
|
});
|
|
373
373
|
}
|
|
@@ -375,7 +375,7 @@ const assetsScanner = (command, content, args) => {
|
|
|
375
375
|
returnAssetsList.push({
|
|
376
376
|
name: content,
|
|
377
377
|
url: content,
|
|
378
|
-
lineNumber
|
|
378
|
+
lineNumber,
|
|
379
379
|
type: fileType.figure,
|
|
380
380
|
});
|
|
381
381
|
}
|
|
@@ -383,7 +383,7 @@ const assetsScanner = (command, content, args) => {
|
|
|
383
383
|
returnAssetsList.push({
|
|
384
384
|
name: content,
|
|
385
385
|
url: content,
|
|
386
|
-
lineNumber
|
|
386
|
+
lineNumber,
|
|
387
387
|
type: fileType.figure,
|
|
388
388
|
});
|
|
389
389
|
}
|
|
@@ -391,7 +391,7 @@ const assetsScanner = (command, content, args) => {
|
|
|
391
391
|
returnAssetsList.push({
|
|
392
392
|
name: content,
|
|
393
393
|
url: content,
|
|
394
|
-
lineNumber
|
|
394
|
+
lineNumber,
|
|
395
395
|
type: fileType.video,
|
|
396
396
|
});
|
|
397
397
|
}
|
|
@@ -399,7 +399,7 @@ const assetsScanner = (command, content, args) => {
|
|
|
399
399
|
returnAssetsList.push({
|
|
400
400
|
name: content,
|
|
401
401
|
url: content,
|
|
402
|
-
lineNumber
|
|
402
|
+
lineNumber,
|
|
403
403
|
type: fileType.bgm,
|
|
404
404
|
});
|
|
405
405
|
}
|
|
@@ -436,7 +436,7 @@ const subSceneScanner = (command, content) => {
|
|
|
436
436
|
* @param ADD_NEXT_ARG_LIST
|
|
437
437
|
* @param SCRIPT_CONFIG_MAP
|
|
438
438
|
*/
|
|
439
|
-
const scriptParser = (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP) => {
|
|
439
|
+
const scriptParser = (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP, lineNumber = 0) => {
|
|
440
440
|
let command; // 默认为对话
|
|
441
441
|
let content; // 语句内容
|
|
442
442
|
let subScene; // 语句携带的子场景(可能没有)
|
|
@@ -501,7 +501,7 @@ const scriptParser = (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG
|
|
|
501
501
|
}
|
|
502
502
|
}
|
|
503
503
|
content = contentParser(newSentenceRaw.trim(), command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
|
|
504
|
-
sentenceAssets = assetsScanner(command, content, args); // 扫描语句携带资源
|
|
504
|
+
sentenceAssets = assetsScanner(command, content, args, lineNumber); // 扫描语句携带资源
|
|
505
505
|
subScene = subSceneScanner(command, content); // 扫描语句携带子场景
|
|
506
506
|
return {
|
|
507
507
|
command: command,
|
|
@@ -1781,8 +1781,8 @@ const sceneParser = (rawScene, sceneName, sceneUrl, assetsPrefetcher, assetSette
|
|
|
1781
1781
|
// .filter((sentence) => sentence.trim() !== "");
|
|
1782
1782
|
let assetsList = []; // 场景资源列表
|
|
1783
1783
|
let subSceneList = []; // 子场景列表
|
|
1784
|
-
const sentenceList = rawSentenceListWithoutEmpty.map((sentence) => {
|
|
1785
|
-
const returnSentence = scriptParser(sentence, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP);
|
|
1784
|
+
const sentenceList = rawSentenceListWithoutEmpty.map((sentence, index) => {
|
|
1785
|
+
const returnSentence = scriptParser(sentence, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP, index);
|
|
1786
1786
|
// 在这里解析出语句可能携带的资源和场景,合并到 assetsList 和 subSceneList
|
|
1787
1787
|
assetsList = [...assetsList, ...returnSentence.sentenceAssets];
|
|
1788
1788
|
subSceneList = [...subSceneList, ...returnSentence.subScene];
|
|
@@ -6,4 +6,4 @@ import { arg, commandType, IAsset } from '../interface/sceneInterface';
|
|
|
6
6
|
* @param args 参数列表
|
|
7
7
|
* @return {Array<IAsset>} 语句携带的参数列表
|
|
8
8
|
*/
|
|
9
|
-
export declare const assetsScanner: (command: commandType, content: string, args: Array<arg
|
|
9
|
+
export declare const assetsScanner: (command: commandType, content: string, args: Array<arg>, lineNumber: number) => Array<IAsset>;
|
|
@@ -7,4 +7,4 @@ import { ConfigMap } from '../config/scriptConfig';
|
|
|
7
7
|
* @param ADD_NEXT_ARG_LIST
|
|
8
8
|
* @param SCRIPT_CONFIG_MAP
|
|
9
9
|
*/
|
|
10
|
-
export declare const scriptParser: (sentenceRaw: string, assetSetter: any, ADD_NEXT_ARG_LIST: commandType[], SCRIPT_CONFIG_MAP: ConfigMap) => ISentence;
|
|
10
|
+
export declare const scriptParser: (sentenceRaw: string, assetSetter: any, ADD_NEXT_ARG_LIST: commandType[], SCRIPT_CONFIG_MAP: ConfigMap, lineNumber?: number) => ISentence;
|
|
@@ -6,4 +6,4 @@ import { arg, commandType, IAsset } from '../interface/sceneInterface';
|
|
|
6
6
|
* @param args 参数列表
|
|
7
7
|
* @return {Array<IAsset>} 语句携带的参数列表
|
|
8
8
|
*/
|
|
9
|
-
export declare const assetsScanner: (command: commandType, content: string, args: Array<arg
|
|
9
|
+
export declare const assetsScanner: (command: commandType, content: string, args: Array<arg>, lineNumber: number) => Array<IAsset>;
|
|
@@ -7,4 +7,4 @@ import { ConfigMap } from '../config/scriptConfig';
|
|
|
7
7
|
* @param ADD_NEXT_ARG_LIST
|
|
8
8
|
* @param SCRIPT_CONFIG_MAP
|
|
9
9
|
*/
|
|
10
|
-
export declare const scriptParser: (sentenceRaw: string, assetSetter: any, ADD_NEXT_ARG_LIST: commandType[], SCRIPT_CONFIG_MAP: ConfigMap) => ISentence;
|
|
10
|
+
export declare const scriptParser: (sentenceRaw: string, assetSetter: any, ADD_NEXT_ARG_LIST: commandType[], SCRIPT_CONFIG_MAP: ConfigMap, lineNumber?: number) => ISentence;
|
|
@@ -143,39 +143,39 @@ var webgalParser = (function (exports) {
|
|
|
143
143
|
value: assetSetter(e, fileType.vocal),
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
|
+
else if (argName === 'vocal' && argValue !== undefined) {
|
|
147
|
+
returnArrayList.push({
|
|
148
|
+
key: argName,
|
|
149
|
+
value: assetSetter(argValue, fileType.vocal),
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
// 判断是不是省略参数
|
|
153
|
+
else if (argValue === undefined) {
|
|
154
|
+
returnArrayList.push({
|
|
155
|
+
key: argName,
|
|
156
|
+
value: true,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
// 是字符串描述的布尔值
|
|
160
|
+
else if (argValue === 'true' || argValue === 'false') {
|
|
161
|
+
returnArrayList.push({
|
|
162
|
+
key: argName,
|
|
163
|
+
value: argValue === 'true',
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
// 是数字
|
|
167
|
+
else if (!isNaN(Number(argValue))) {
|
|
168
|
+
returnArrayList.push({
|
|
169
|
+
key: argName,
|
|
170
|
+
value: Number(argValue),
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
// 是普通参数
|
|
146
174
|
else {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
value: true,
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
// 是字符串描述的布尔值
|
|
156
|
-
if (argValue === 'true' || argValue === 'false') {
|
|
157
|
-
returnArrayList.push({
|
|
158
|
-
key: argName,
|
|
159
|
-
value: argValue === 'true',
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
// 是数字
|
|
164
|
-
if (!isNaN(Number(argValue))) {
|
|
165
|
-
returnArrayList.push({
|
|
166
|
-
key: argName,
|
|
167
|
-
value: Number(argValue),
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
// 是普通参数
|
|
172
|
-
returnArrayList.push({
|
|
173
|
-
key: argName,
|
|
174
|
-
value: argValue,
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
175
|
+
returnArrayList.push({
|
|
176
|
+
key: argName,
|
|
177
|
+
value: argValue,
|
|
178
|
+
});
|
|
179
179
|
}
|
|
180
180
|
});
|
|
181
181
|
return returnArrayList;
|
|
@@ -348,7 +348,7 @@ var webgalParser = (function (exports) {
|
|
|
348
348
|
* @param args 参数列表
|
|
349
349
|
* @return {Array<IAsset>} 语句携带的参数列表
|
|
350
350
|
*/
|
|
351
|
-
const assetsScanner = (command, content, args) => {
|
|
351
|
+
const assetsScanner = (command, content, args, lineNumber) => {
|
|
352
352
|
const returnAssetsList = [];
|
|
353
353
|
if (command === commandType.say) {
|
|
354
354
|
args.forEach((e) => {
|
|
@@ -356,7 +356,7 @@ var webgalParser = (function (exports) {
|
|
|
356
356
|
returnAssetsList.push({
|
|
357
357
|
name: e.value,
|
|
358
358
|
url: e.value,
|
|
359
|
-
lineNumber
|
|
359
|
+
lineNumber,
|
|
360
360
|
type: fileType.vocal,
|
|
361
361
|
});
|
|
362
362
|
}
|
|
@@ -370,7 +370,7 @@ var webgalParser = (function (exports) {
|
|
|
370
370
|
returnAssetsList.push({
|
|
371
371
|
name: content,
|
|
372
372
|
url: content,
|
|
373
|
-
lineNumber
|
|
373
|
+
lineNumber,
|
|
374
374
|
type: fileType.background,
|
|
375
375
|
});
|
|
376
376
|
}
|
|
@@ -378,7 +378,7 @@ var webgalParser = (function (exports) {
|
|
|
378
378
|
returnAssetsList.push({
|
|
379
379
|
name: content,
|
|
380
380
|
url: content,
|
|
381
|
-
lineNumber
|
|
381
|
+
lineNumber,
|
|
382
382
|
type: fileType.figure,
|
|
383
383
|
});
|
|
384
384
|
}
|
|
@@ -386,7 +386,7 @@ var webgalParser = (function (exports) {
|
|
|
386
386
|
returnAssetsList.push({
|
|
387
387
|
name: content,
|
|
388
388
|
url: content,
|
|
389
|
-
lineNumber
|
|
389
|
+
lineNumber,
|
|
390
390
|
type: fileType.figure,
|
|
391
391
|
});
|
|
392
392
|
}
|
|
@@ -394,7 +394,7 @@ var webgalParser = (function (exports) {
|
|
|
394
394
|
returnAssetsList.push({
|
|
395
395
|
name: content,
|
|
396
396
|
url: content,
|
|
397
|
-
lineNumber
|
|
397
|
+
lineNumber,
|
|
398
398
|
type: fileType.video,
|
|
399
399
|
});
|
|
400
400
|
}
|
|
@@ -402,7 +402,7 @@ var webgalParser = (function (exports) {
|
|
|
402
402
|
returnAssetsList.push({
|
|
403
403
|
name: content,
|
|
404
404
|
url: content,
|
|
405
|
-
lineNumber
|
|
405
|
+
lineNumber,
|
|
406
406
|
type: fileType.bgm,
|
|
407
407
|
});
|
|
408
408
|
}
|
|
@@ -439,7 +439,7 @@ var webgalParser = (function (exports) {
|
|
|
439
439
|
* @param ADD_NEXT_ARG_LIST
|
|
440
440
|
* @param SCRIPT_CONFIG_MAP
|
|
441
441
|
*/
|
|
442
|
-
const scriptParser = (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP) => {
|
|
442
|
+
const scriptParser = (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP, lineNumber = 0) => {
|
|
443
443
|
let command; // 默认为对话
|
|
444
444
|
let content; // 语句内容
|
|
445
445
|
let subScene; // 语句携带的子场景(可能没有)
|
|
@@ -504,7 +504,7 @@ var webgalParser = (function (exports) {
|
|
|
504
504
|
}
|
|
505
505
|
}
|
|
506
506
|
content = contentParser(newSentenceRaw.trim(), command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
|
|
507
|
-
sentenceAssets = assetsScanner(command, content, args); // 扫描语句携带资源
|
|
507
|
+
sentenceAssets = assetsScanner(command, content, args, lineNumber); // 扫描语句携带资源
|
|
508
508
|
subScene = subSceneScanner(command, content); // 扫描语句携带子场景
|
|
509
509
|
return {
|
|
510
510
|
command: command,
|
|
@@ -1784,8 +1784,8 @@ var webgalParser = (function (exports) {
|
|
|
1784
1784
|
// .filter((sentence) => sentence.trim() !== "");
|
|
1785
1785
|
let assetsList = []; // 场景资源列表
|
|
1786
1786
|
let subSceneList = []; // 子场景列表
|
|
1787
|
-
const sentenceList = rawSentenceListWithoutEmpty.map((sentence) => {
|
|
1788
|
-
const returnSentence = scriptParser(sentence, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP);
|
|
1787
|
+
const sentenceList = rawSentenceListWithoutEmpty.map((sentence, index) => {
|
|
1788
|
+
const returnSentence = scriptParser(sentence, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP, index);
|
|
1789
1789
|
// 在这里解析出语句可能携带的资源和场景,合并到 assetsList 和 subSceneList
|
|
1790
1790
|
assetsList = [...assetsList, ...returnSentence.sentenceAssets];
|
|
1791
1791
|
subSceneList = [...subSceneList, ...returnSentence.subScene];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webgal-parser",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.1",
|
|
4
4
|
"description": "WebGAL script parser",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "vitest",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"chevrotain": "^10.5.0",
|
|
22
22
|
"cloudlogjs": "^1.0.11",
|
|
23
|
-
"lodash": "^4.17.
|
|
23
|
+
"lodash": "^4.17.23",
|
|
24
24
|
"tsx": "^3.12.7"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
package/src/sceneParser.ts
CHANGED
|
@@ -38,12 +38,13 @@ export const sceneParser = (
|
|
|
38
38
|
let assetsList: Array<IAsset> = []; // 场景资源列表
|
|
39
39
|
let subSceneList: Array<string> = []; // 子场景列表
|
|
40
40
|
const sentenceList: Array<ISentence> = rawSentenceListWithoutEmpty.map(
|
|
41
|
-
(sentence) => {
|
|
41
|
+
(sentence, index) => {
|
|
42
42
|
const returnSentence: ISentence = scriptParser(
|
|
43
43
|
sentence,
|
|
44
44
|
assetSetter,
|
|
45
45
|
ADD_NEXT_ARG_LIST,
|
|
46
46
|
SCRIPT_CONFIG_MAP,
|
|
47
|
+
index,
|
|
47
48
|
);
|
|
48
49
|
// 在这里解析出语句可能携带的资源和场景,合并到 assetsList 和 subSceneList
|
|
49
50
|
assetsList = [...assetsList, ...returnSentence.sentenceAssets];
|
|
@@ -35,36 +35,39 @@ export function argsParser(
|
|
|
35
35
|
key: 'vocal',
|
|
36
36
|
value: assetSetter(e, fileType.vocal),
|
|
37
37
|
});
|
|
38
|
-
} else {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
38
|
+
} else if (argName === 'vocal' && argValue !== undefined) {
|
|
39
|
+
returnArrayList.push({
|
|
40
|
+
key: argName,
|
|
41
|
+
value: assetSetter(argValue, fileType.vocal),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
// 判断是不是省略参数
|
|
45
|
+
else if (argValue === undefined) {
|
|
46
|
+
returnArrayList.push({
|
|
47
|
+
key: argName,
|
|
48
|
+
value: true,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// 是字符串描述的布尔值
|
|
52
|
+
else if (argValue === 'true' || argValue === 'false') {
|
|
53
|
+
returnArrayList.push({
|
|
54
|
+
key: argName,
|
|
55
|
+
value: argValue === 'true',
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
// 是数字
|
|
59
|
+
else if (!isNaN(Number(argValue))) {
|
|
60
|
+
returnArrayList.push({
|
|
61
|
+
key: argName,
|
|
62
|
+
value: Number(argValue),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
// 是普通参数
|
|
66
|
+
else {
|
|
67
|
+
returnArrayList.push({
|
|
68
|
+
key: argName,
|
|
69
|
+
value: argValue,
|
|
70
|
+
});
|
|
68
71
|
}
|
|
69
72
|
});
|
|
70
73
|
return returnArrayList;
|
|
@@ -12,6 +12,7 @@ export const assetsScanner = (
|
|
|
12
12
|
command: commandType,
|
|
13
13
|
content: string,
|
|
14
14
|
args: Array<arg>,
|
|
15
|
+
lineNumber: number,
|
|
15
16
|
): Array<IAsset> => {
|
|
16
17
|
let hasVocalArg = false;
|
|
17
18
|
const returnAssetsList: Array<IAsset> = [];
|
|
@@ -22,7 +23,7 @@ export const assetsScanner = (
|
|
|
22
23
|
returnAssetsList.push({
|
|
23
24
|
name: e.value as string,
|
|
24
25
|
url: e.value as string,
|
|
25
|
-
lineNumber
|
|
26
|
+
lineNumber,
|
|
26
27
|
type: fileType.vocal,
|
|
27
28
|
});
|
|
28
29
|
}
|
|
@@ -36,7 +37,7 @@ export const assetsScanner = (
|
|
|
36
37
|
returnAssetsList.push({
|
|
37
38
|
name: content,
|
|
38
39
|
url: content,
|
|
39
|
-
lineNumber
|
|
40
|
+
lineNumber,
|
|
40
41
|
type: fileType.background,
|
|
41
42
|
});
|
|
42
43
|
}
|
|
@@ -44,7 +45,7 @@ export const assetsScanner = (
|
|
|
44
45
|
returnAssetsList.push({
|
|
45
46
|
name: content,
|
|
46
47
|
url: content,
|
|
47
|
-
lineNumber
|
|
48
|
+
lineNumber,
|
|
48
49
|
type: fileType.figure,
|
|
49
50
|
});
|
|
50
51
|
}
|
|
@@ -52,7 +53,7 @@ export const assetsScanner = (
|
|
|
52
53
|
returnAssetsList.push({
|
|
53
54
|
name: content,
|
|
54
55
|
url: content,
|
|
55
|
-
lineNumber
|
|
56
|
+
lineNumber,
|
|
56
57
|
type: fileType.figure,
|
|
57
58
|
});
|
|
58
59
|
}
|
|
@@ -60,7 +61,7 @@ export const assetsScanner = (
|
|
|
60
61
|
returnAssetsList.push({
|
|
61
62
|
name: content,
|
|
62
63
|
url: content,
|
|
63
|
-
lineNumber
|
|
64
|
+
lineNumber,
|
|
64
65
|
type: fileType.video,
|
|
65
66
|
});
|
|
66
67
|
}
|
|
@@ -68,7 +69,7 @@ export const assetsScanner = (
|
|
|
68
69
|
returnAssetsList.push({
|
|
69
70
|
name: content,
|
|
70
71
|
url: content,
|
|
71
|
-
lineNumber
|
|
72
|
+
lineNumber,
|
|
72
73
|
type: fileType.bgm,
|
|
73
74
|
});
|
|
74
75
|
}
|
|
@@ -24,6 +24,7 @@ export const scriptParser = (
|
|
|
24
24
|
assetSetter: any,
|
|
25
25
|
ADD_NEXT_ARG_LIST: commandType[],
|
|
26
26
|
SCRIPT_CONFIG_MAP: ConfigMap,
|
|
27
|
+
lineNumber = 0,
|
|
27
28
|
): ISentence => {
|
|
28
29
|
let command: commandType; // 默认为对话
|
|
29
30
|
let content: string; // 语句内容
|
|
@@ -105,7 +106,7 @@ export const scriptParser = (
|
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
content = contentParser(newSentenceRaw.trim(), command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
|
|
108
|
-
sentenceAssets = assetsScanner(command, content, args); // 扫描语句携带资源
|
|
109
|
+
sentenceAssets = assetsScanner(command, content, args, lineNumber); // 扫描语句携带资源
|
|
109
110
|
subScene = subSceneScanner(command, content); // 扫描语句携带子场景
|
|
110
111
|
return {
|
|
111
112
|
command: command, // 语句类型
|