webgal-parser 4.5.17 → 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.
@@ -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
- if (argValue === undefined) {
150
- returnArrayList.push({
151
- key: argName,
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: 0,
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: 0,
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: 0,
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: 0,
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: 0,
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: 0,
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; // 语句携带的子场景(可能没有)
@@ -462,7 +462,8 @@ const scriptParser = (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG
462
462
  content: sentenceComment.trim(),
463
463
  args: [{ key: 'next', value: true }],
464
464
  sentenceAssets: [],
465
- subScene: [], // 语句携带的子场景
465
+ subScene: [],
466
+ inlineComment: '', // 行内注释
466
467
  };
467
468
  }
468
469
  // 截取命令
@@ -504,7 +505,7 @@ const scriptParser = (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG
504
505
  }
505
506
  }
506
507
  content = contentParser(newSentenceRaw.trim(), command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
507
- sentenceAssets = assetsScanner(command, content, args); // 扫描语句携带资源
508
+ sentenceAssets = assetsScanner(command, content, args, lineNumber); // 扫描语句携带资源
508
509
  subScene = subSceneScanner(command, content); // 扫描语句携带子场景
509
510
  return {
510
511
  command: command,
@@ -512,7 +513,8 @@ const scriptParser = (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG
512
513
  content: content,
513
514
  args: args,
514
515
  sentenceAssets: sentenceAssets,
515
- subScene: subScene, // 语句携带的子场景
516
+ subScene: subScene,
517
+ inlineComment: sentenceComment.trim(), // 行内注释
516
518
  };
517
519
  };
518
520
 
@@ -1783,8 +1785,8 @@ const sceneParser = (rawScene, sceneName, sceneUrl, assetsPrefetcher, assetSette
1783
1785
  // .filter((sentence) => sentence.trim() !== "");
1784
1786
  let assetsList = []; // 场景资源列表
1785
1787
  let subSceneList = []; // 子场景列表
1786
- const sentenceList = rawSentenceListWithoutEmpty.map((sentence) => {
1787
- 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);
1788
1790
  // 在这里解析出语句可能携带的资源和场景,合并到 assetsList 和 subSceneList
1789
1791
  assetsList = [...assetsList, ...returnSentence.sentenceAssets];
1790
1792
  subSceneList = [...subSceneList, ...returnSentence.subScene];
@@ -69,6 +69,7 @@ export interface ISentence {
69
69
  args: Array<arg>;
70
70
  sentenceAssets: Array<IAsset>;
71
71
  subScene: Array<string>;
72
+ inlineComment: string;
72
73
  }
73
74
  /**
74
75
  * 场景接口
@@ -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>) => Array<IAsset>;
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
- if (argValue === undefined) {
146
- returnArrayList.push({
147
- key: argName,
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: 0,
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: 0,
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: 0,
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: 0,
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: 0,
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: 0,
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; // 语句携带的子场景(可能没有)
@@ -458,7 +458,8 @@ const scriptParser = (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG
458
458
  content: sentenceComment.trim(),
459
459
  args: [{ key: 'next', value: true }],
460
460
  sentenceAssets: [],
461
- subScene: [], // 语句携带的子场景
461
+ subScene: [],
462
+ inlineComment: '', // 行内注释
462
463
  };
463
464
  }
464
465
  // 截取命令
@@ -500,7 +501,7 @@ const scriptParser = (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG
500
501
  }
501
502
  }
502
503
  content = contentParser(newSentenceRaw.trim(), command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
503
- sentenceAssets = assetsScanner(command, content, args); // 扫描语句携带资源
504
+ sentenceAssets = assetsScanner(command, content, args, lineNumber); // 扫描语句携带资源
504
505
  subScene = subSceneScanner(command, content); // 扫描语句携带子场景
505
506
  return {
506
507
  command: command,
@@ -508,7 +509,8 @@ const scriptParser = (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG
508
509
  content: content,
509
510
  args: args,
510
511
  sentenceAssets: sentenceAssets,
511
- subScene: subScene, // 语句携带的子场景
512
+ subScene: subScene,
513
+ inlineComment: sentenceComment.trim(), // 行内注释
512
514
  };
513
515
  };
514
516
 
@@ -1779,8 +1781,8 @@ const sceneParser = (rawScene, sceneName, sceneUrl, assetsPrefetcher, assetSette
1779
1781
  // .filter((sentence) => sentence.trim() !== "");
1780
1782
  let assetsList = []; // 场景资源列表
1781
1783
  let subSceneList = []; // 子场景列表
1782
- const sentenceList = rawSentenceListWithoutEmpty.map((sentence) => {
1783
- 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);
1784
1786
  // 在这里解析出语句可能携带的资源和场景,合并到 assetsList 和 subSceneList
1785
1787
  assetsList = [...assetsList, ...returnSentence.sentenceAssets];
1786
1788
  subSceneList = [...subSceneList, ...returnSentence.subScene];
@@ -69,6 +69,7 @@ export interface ISentence {
69
69
  args: Array<arg>;
70
70
  sentenceAssets: Array<IAsset>;
71
71
  subScene: Array<string>;
72
+ inlineComment: string;
72
73
  }
73
74
  /**
74
75
  * 场景接口
@@ -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>) => Array<IAsset>;
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;
@@ -69,6 +69,7 @@ export interface ISentence {
69
69
  args: Array<arg>;
70
70
  sentenceAssets: Array<IAsset>;
71
71
  subScene: Array<string>;
72
+ inlineComment: string;
72
73
  }
73
74
  /**
74
75
  * 场景接口
@@ -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>) => Array<IAsset>;
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
- if (argValue === undefined) {
149
- returnArrayList.push({
150
- key: argName,
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: 0,
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: 0,
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: 0,
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: 0,
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: 0,
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: 0,
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; // 语句携带的子场景(可能没有)
@@ -461,7 +461,8 @@ var webgalParser = (function (exports) {
461
461
  content: sentenceComment.trim(),
462
462
  args: [{ key: 'next', value: true }],
463
463
  sentenceAssets: [],
464
- subScene: [], // 语句携带的子场景
464
+ subScene: [],
465
+ inlineComment: '', // 行内注释
465
466
  };
466
467
  }
467
468
  // 截取命令
@@ -503,7 +504,7 @@ var webgalParser = (function (exports) {
503
504
  }
504
505
  }
505
506
  content = contentParser(newSentenceRaw.trim(), command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
506
- sentenceAssets = assetsScanner(command, content, args); // 扫描语句携带资源
507
+ sentenceAssets = assetsScanner(command, content, args, lineNumber); // 扫描语句携带资源
507
508
  subScene = subSceneScanner(command, content); // 扫描语句携带子场景
508
509
  return {
509
510
  command: command,
@@ -511,7 +512,8 @@ var webgalParser = (function (exports) {
511
512
  content: content,
512
513
  args: args,
513
514
  sentenceAssets: sentenceAssets,
514
- subScene: subScene, // 语句携带的子场景
515
+ subScene: subScene,
516
+ inlineComment: sentenceComment.trim(), // 行内注释
515
517
  };
516
518
  };
517
519
 
@@ -1782,8 +1784,8 @@ var webgalParser = (function (exports) {
1782
1784
  // .filter((sentence) => sentence.trim() !== "");
1783
1785
  let assetsList = []; // 场景资源列表
1784
1786
  let subSceneList = []; // 子场景列表
1785
- const sentenceList = rawSentenceListWithoutEmpty.map((sentence) => {
1786
- 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);
1787
1789
  // 在这里解析出语句可能携带的资源和场景,合并到 assetsList 和 subSceneList
1788
1790
  assetsList = [...assetsList, ...returnSentence.sentenceAssets];
1789
1791
  subSceneList = [...subSceneList, ...returnSentence.subScene];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webgal-parser",
3
- "version": "4.5.17",
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.21",
23
+ "lodash": "^4.17.23",
24
24
  "tsx": "^3.12.7"
25
25
  },
26
26
  "devDependencies": {
@@ -73,6 +73,7 @@ export interface ISentence {
73
73
  args: Array<arg>; // 参数列表
74
74
  sentenceAssets: Array<IAsset>; // 语句携带的资源列表
75
75
  subScene: Array<string>; // 语句包含子场景列表
76
+ inlineComment: string; // 行内注释
76
77
  }
77
78
 
78
79
  /**
@@ -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
- if (argValue === undefined) {
41
- returnArrayList.push({
42
- key: argName,
43
- value: true,
44
- });
45
- } else {
46
- // 是字符串描述的布尔值
47
- if (argValue === 'true' || argValue === 'false') {
48
- returnArrayList.push({
49
- key: argName,
50
- value: argValue === 'true',
51
- });
52
- } else {
53
- // 是数字
54
- if (!isNaN(Number(argValue))) {
55
- returnArrayList.push({
56
- key: argName,
57
- value: Number(argValue),
58
- });
59
- } else {
60
- // 是普通参数
61
- returnArrayList.push({
62
- key: argName,
63
- value: argValue,
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: 0,
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: 0,
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: 0,
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: 0,
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: 0,
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: 0,
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; // 语句内容
@@ -49,6 +50,7 @@ export const scriptParser = (
49
50
  args: [{ key: 'next', value: true }], // 参数列表
50
51
  sentenceAssets: [], // 语句携带的资源列表
51
52
  subScene: [], // 语句携带的子场景
53
+ inlineComment: '', // 行内注释
52
54
  };
53
55
  }
54
56
  // 截取命令
@@ -102,8 +104,9 @@ export const scriptParser = (
102
104
  args.push(e);
103
105
  }
104
106
  }
107
+
105
108
  content = contentParser(newSentenceRaw.trim(), command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
106
- sentenceAssets = assetsScanner(command, content, args); // 扫描语句携带资源
109
+ sentenceAssets = assetsScanner(command, content, args, lineNumber); // 扫描语句携带资源
107
110
  subScene = subSceneScanner(command, content); // 扫描语句携带子场景
108
111
  return {
109
112
  command: command, // 语句类型
@@ -112,5 +115,6 @@ export const scriptParser = (
112
115
  args: args, // 参数列表
113
116
  sentenceAssets: sentenceAssets, // 语句携带的资源列表
114
117
  subScene: subScene, // 语句携带的子场景
118
+ inlineComment: sentenceComment.trim(), // 行内注释
115
119
  };
116
120
  };