webgal-parser 4.3.5 → 4.3.6

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.
Files changed (40) hide show
  1. package/build/index.global.js +421 -421
  2. package/build/index.js +421 -421
  3. package/build/types/index.d.ts +10 -10
  4. package/build/types/interface/assets.d.ts +12 -12
  5. package/build/types/interface/runtimeInterface.d.ts +9 -9
  6. package/build/types/interface/sceneInterface.d.ts +91 -91
  7. package/build/types/sceneParser.d.ts +14 -14
  8. package/build/types/scriptParser/argsParser.d.ts +9 -9
  9. package/build/types/scriptParser/assetsScanner.d.ts +9 -9
  10. package/build/types/scriptParser/commandParser.d.ts +9 -9
  11. package/build/types/scriptParser/contentParser.d.ts +9 -9
  12. package/build/types/scriptParser/scriptParser.d.ts +9 -9
  13. package/build/types/scriptParser/subSceneScanner.d.ts +7 -7
  14. package/index.d.ts +10 -10
  15. package/index.js +421 -421
  16. package/interface/assets.d.ts +12 -12
  17. package/interface/assets.js +16 -16
  18. package/interface/runtimeInterface.d.ts +9 -9
  19. package/interface/runtimeInterface.js +2 -2
  20. package/interface/sceneInterface.d.ts +91 -91
  21. package/interface/sceneInterface.js +32 -32
  22. package/interface/sceneInterface.ts +1 -0
  23. package/package.json +1 -1
  24. package/sceneParser.d.ts +14 -14
  25. package/sceneParser.js +53 -53
  26. package/scriptParser/argsParser.d.ts +9 -9
  27. package/scriptParser/argsParser.js +70 -70
  28. package/scriptParser/assetsScanner.d.ts +9 -9
  29. package/scriptParser/assetsScanner.js +75 -75
  30. package/scriptParser/assetsScanner.ts +10 -2
  31. package/scriptParser/commandParser.d.ts +9 -9
  32. package/scriptParser/commandParser.js +60 -60
  33. package/scriptParser/contentParser.d.ts +9 -9
  34. package/scriptParser/contentParser.js +68 -68
  35. package/scriptParser/contentParser.ts +2 -0
  36. package/scriptParser/scriptParser.d.ts +9 -9
  37. package/scriptParser/scriptParser.js +81 -81
  38. package/scriptParser/subSceneScanner.d.ts +7 -7
  39. package/scriptParser/subSceneScanner.js +26 -26
  40. package/test/test.ts +1 -1
@@ -1,9 +1,9 @@
1
- import { arg, commandType, IAsset } from '../interface/sceneInterface';
2
- /**
3
- * 根据语句类型、语句内容、参数列表,扫描该语句可能携带的资源
4
- * @param command 语句类型
5
- * @param content 语句内容
6
- * @param args 参数列表
7
- * @return {Array<IAsset>} 语句携带的参数列表
8
- */
9
- export declare const assetsScanner: (command: commandType, content: string, args: Array<arg>) => Array<IAsset>;
1
+ import { arg, commandType, IAsset } from '../interface/sceneInterface';
2
+ /**
3
+ * 根据语句类型、语句内容、参数列表,扫描该语句可能携带的资源
4
+ * @param command 语句类型
5
+ * @param content 语句内容
6
+ * @param args 参数列表
7
+ * @return {Array<IAsset>} 语句携带的参数列表
8
+ */
9
+ export declare const assetsScanner: (command: commandType, content: string, args: Array<arg>) => Array<IAsset>;
@@ -1,75 +1,75 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.assetsScanner = void 0;
4
- var sceneInterface_1 = require("../interface/sceneInterface");
5
- var assets_1 = require("../interface/assets");
6
- /**
7
- * 根据语句类型、语句内容、参数列表,扫描该语句可能携带的资源
8
- * @param command 语句类型
9
- * @param content 语句内容
10
- * @param args 参数列表
11
- * @return {Array<IAsset>} 语句携带的参数列表
12
- */
13
- var assetsScanner = function (command, content, args) {
14
- var hasVocalArg = false;
15
- var returnAssetsList = [];
16
- if (command === sceneInterface_1.commandType.say) {
17
- args.forEach(function (e) {
18
- if (e.key === 'vocal') {
19
- hasVocalArg = true;
20
- returnAssetsList.push({
21
- name: e.value,
22
- url: e.value,
23
- lineNumber: 0,
24
- type: assets_1.fileType.vocal
25
- });
26
- }
27
- });
28
- }
29
- if (content === 'none' || content === '') {
30
- return returnAssetsList;
31
- }
32
- // 处理语句携带的资源
33
- if (command === sceneInterface_1.commandType.changeBg) {
34
- returnAssetsList.push({
35
- name: content,
36
- url: content,
37
- lineNumber: 0,
38
- type: assets_1.fileType.background
39
- });
40
- }
41
- if (command === sceneInterface_1.commandType.changeFigure) {
42
- returnAssetsList.push({
43
- name: content,
44
- url: content,
45
- lineNumber: 0,
46
- type: assets_1.fileType.figure
47
- });
48
- }
49
- if (command === sceneInterface_1.commandType.miniAvatar) {
50
- returnAssetsList.push({
51
- name: content,
52
- url: content,
53
- lineNumber: 0,
54
- type: assets_1.fileType.figure
55
- });
56
- }
57
- if (command === sceneInterface_1.commandType.video) {
58
- returnAssetsList.push({
59
- name: content,
60
- url: content,
61
- lineNumber: 0,
62
- type: assets_1.fileType.video
63
- });
64
- }
65
- if (command === sceneInterface_1.commandType.bgm) {
66
- returnAssetsList.push({
67
- name: content,
68
- url: content,
69
- lineNumber: 0,
70
- type: assets_1.fileType.bgm
71
- });
72
- }
73
- return returnAssetsList;
74
- };
75
- exports.assetsScanner = assetsScanner;
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.assetsScanner = void 0;
4
+ var sceneInterface_1 = require("../interface/sceneInterface");
5
+ var assets_1 = require("../interface/assets");
6
+ /**
7
+ * 根据语句类型、语句内容、参数列表,扫描该语句可能携带的资源
8
+ * @param command 语句类型
9
+ * @param content 语句内容
10
+ * @param args 参数列表
11
+ * @return {Array<IAsset>} 语句携带的参数列表
12
+ */
13
+ var assetsScanner = function (command, content, args) {
14
+ var hasVocalArg = false;
15
+ var returnAssetsList = [];
16
+ if (command === sceneInterface_1.commandType.say) {
17
+ args.forEach(function (e) {
18
+ if (e.key === 'vocal') {
19
+ hasVocalArg = true;
20
+ returnAssetsList.push({
21
+ name: e.value,
22
+ url: e.value,
23
+ lineNumber: 0,
24
+ type: assets_1.fileType.vocal
25
+ });
26
+ }
27
+ });
28
+ }
29
+ if (content === 'none' || content === '') {
30
+ return returnAssetsList;
31
+ }
32
+ // 处理语句携带的资源
33
+ if (command === sceneInterface_1.commandType.changeBg) {
34
+ returnAssetsList.push({
35
+ name: content,
36
+ url: content,
37
+ lineNumber: 0,
38
+ type: assets_1.fileType.background
39
+ });
40
+ }
41
+ if (command === sceneInterface_1.commandType.changeFigure) {
42
+ returnAssetsList.push({
43
+ name: content,
44
+ url: content,
45
+ lineNumber: 0,
46
+ type: assets_1.fileType.figure
47
+ });
48
+ }
49
+ if (command === sceneInterface_1.commandType.miniAvatar) {
50
+ returnAssetsList.push({
51
+ name: content,
52
+ url: content,
53
+ lineNumber: 0,
54
+ type: assets_1.fileType.figure
55
+ });
56
+ }
57
+ if (command === sceneInterface_1.commandType.video) {
58
+ returnAssetsList.push({
59
+ name: content,
60
+ url: content,
61
+ lineNumber: 0,
62
+ type: assets_1.fileType.video
63
+ });
64
+ }
65
+ if (command === sceneInterface_1.commandType.bgm) {
66
+ returnAssetsList.push({
67
+ name: content,
68
+ url: content,
69
+ lineNumber: 0,
70
+ type: assets_1.fileType.bgm
71
+ });
72
+ }
73
+ return returnAssetsList;
74
+ };
75
+ exports.assetsScanner = assetsScanner;
@@ -1,5 +1,5 @@
1
- import { arg, commandType, IAsset } from '../interface/sceneInterface';
2
- import { fileType } from '../interface/assets';
1
+ import { arg, commandType, IAsset } from "../interface/sceneInterface";
2
+ import { fileType } from "../interface/assets";
3
3
 
4
4
  /**
5
5
  * 根据语句类型、语句内容、参数列表,扫描该语句可能携带的资源
@@ -68,5 +68,13 @@ export const assetsScanner = (command: commandType, content: string, args: Array
68
68
  type: fileType.bgm,
69
69
  });
70
70
  }
71
+ if (command === commandType.playEffect){
72
+ returnAssetsList.push({
73
+ name: content,
74
+ url: content,
75
+ lineNumber: 0,
76
+ type: fileType.vocal,
77
+ });
78
+ }
71
79
  return returnAssetsList;
72
80
  };
@@ -1,9 +1,9 @@
1
- import { parsedCommand } from "../interface/sceneInterface";
2
- /**
3
- * 处理命令
4
- * @param commandRaw
5
- * @param ADD_NEXT_ARG_LIST
6
- * @param SCRIPT_CONFIG
7
- * @return {parsedCommand} 处理后的命令
8
- */
9
- export declare const commandParser: (commandRaw: string, ADD_NEXT_ARG_LIST: any, SCRIPT_CONFIG: any) => parsedCommand;
1
+ import { parsedCommand } from "../interface/sceneInterface";
2
+ /**
3
+ * 处理命令
4
+ * @param commandRaw
5
+ * @param ADD_NEXT_ARG_LIST
6
+ * @param SCRIPT_CONFIG
7
+ * @return {parsedCommand} 处理后的命令
8
+ */
9
+ export declare const commandParser: (commandRaw: string, ADD_NEXT_ARG_LIST: any, SCRIPT_CONFIG: any) => parsedCommand;
@@ -1,60 +1,60 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.commandParser = void 0;
4
- var sceneInterface_1 = require("../interface/sceneInterface");
5
- /**
6
- * 处理命令
7
- * @param commandRaw
8
- * @param ADD_NEXT_ARG_LIST
9
- * @param SCRIPT_CONFIG
10
- * @return {parsedCommand} 处理后的命令
11
- */
12
- var commandParser = function (commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG) {
13
- var returnCommand = {
14
- type: sceneInterface_1.commandType.say,
15
- additionalArgs: []
16
- };
17
- // 开始处理命令内容
18
- var type = getCommandType(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
19
- returnCommand.type = type;
20
- // 如果是对话,加上额外的参数
21
- if (type === sceneInterface_1.commandType.say) {
22
- returnCommand.additionalArgs.push({
23
- key: "speaker",
24
- value: commandRaw
25
- });
26
- }
27
- returnCommand = addNextArg(returnCommand, type, ADD_NEXT_ARG_LIST);
28
- return returnCommand;
29
- };
30
- exports.commandParser = commandParser;
31
- /**
32
- * 根据command原始值判断是什么命令
33
- * @param command command原始值
34
- * @param ADD_NEXT_ARG_LIST
35
- * @param SCRIPT_CONFIG
36
- * @return {commandType} 得到的command类型
37
- */
38
- function getCommandType(command, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG) {
39
- // if (command.match(/if/)) {
40
- // return commandType.if;
41
- // }
42
- var commandMap = new Map();
43
- SCRIPT_CONFIG.forEach(function (e) {
44
- commandMap.set(e.scriptString, e.scriptType);
45
- });
46
- if (commandMap.has(command)) {
47
- return commandMap.get(command);
48
- }
49
- else
50
- return sceneInterface_1.commandType.say;
51
- }
52
- function addNextArg(commandToParse, thisCommandType, ADD_NEXT_ARG_LIST) {
53
- if (ADD_NEXT_ARG_LIST.includes(thisCommandType)) {
54
- commandToParse.additionalArgs.push({
55
- key: "next",
56
- value: true
57
- });
58
- }
59
- return commandToParse;
60
- }
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.commandParser = void 0;
4
+ var sceneInterface_1 = require("../interface/sceneInterface");
5
+ /**
6
+ * 处理命令
7
+ * @param commandRaw
8
+ * @param ADD_NEXT_ARG_LIST
9
+ * @param SCRIPT_CONFIG
10
+ * @return {parsedCommand} 处理后的命令
11
+ */
12
+ var commandParser = function (commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG) {
13
+ var returnCommand = {
14
+ type: sceneInterface_1.commandType.say,
15
+ additionalArgs: []
16
+ };
17
+ // 开始处理命令内容
18
+ var type = getCommandType(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
19
+ returnCommand.type = type;
20
+ // 如果是对话,加上额外的参数
21
+ if (type === sceneInterface_1.commandType.say) {
22
+ returnCommand.additionalArgs.push({
23
+ key: "speaker",
24
+ value: commandRaw
25
+ });
26
+ }
27
+ returnCommand = addNextArg(returnCommand, type, ADD_NEXT_ARG_LIST);
28
+ return returnCommand;
29
+ };
30
+ exports.commandParser = commandParser;
31
+ /**
32
+ * 根据command原始值判断是什么命令
33
+ * @param command command原始值
34
+ * @param ADD_NEXT_ARG_LIST
35
+ * @param SCRIPT_CONFIG
36
+ * @return {commandType} 得到的command类型
37
+ */
38
+ function getCommandType(command, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG) {
39
+ // if (command.match(/if/)) {
40
+ // return commandType.if;
41
+ // }
42
+ var commandMap = new Map();
43
+ SCRIPT_CONFIG.forEach(function (e) {
44
+ commandMap.set(e.scriptString, e.scriptType);
45
+ });
46
+ if (commandMap.has(command)) {
47
+ return commandMap.get(command);
48
+ }
49
+ else
50
+ return sceneInterface_1.commandType.say;
51
+ }
52
+ function addNextArg(commandToParse, thisCommandType, ADD_NEXT_ARG_LIST) {
53
+ if (ADD_NEXT_ARG_LIST.includes(thisCommandType)) {
54
+ commandToParse.additionalArgs.push({
55
+ key: "next",
56
+ value: true
57
+ });
58
+ }
59
+ return commandToParse;
60
+ }
@@ -1,9 +1,9 @@
1
- import { commandType } from "../interface/sceneInterface";
2
- /**
3
- * 解析语句内容的函数,主要作用是把文件名改为绝对地址或相对地址(根据使用情况而定)
4
- * @param contentRaw 原始语句内容
5
- * @param type 语句类型
6
- * @param assetSetter
7
- * @return {string} 解析后的语句内容
8
- */
9
- export declare const contentParser: (contentRaw: string, type: commandType, assetSetter: any) => any;
1
+ import { commandType } from "../interface/sceneInterface";
2
+ /**
3
+ * 解析语句内容的函数,主要作用是把文件名改为绝对地址或相对地址(根据使用情况而定)
4
+ * @param contentRaw 原始语句内容
5
+ * @param type 语句类型
6
+ * @param assetSetter
7
+ * @return {string} 解析后的语句内容
8
+ */
9
+ export declare const contentParser: (contentRaw: string, type: commandType, assetSetter: any) => any;
@@ -1,68 +1,68 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.contentParser = void 0;
4
- var sceneInterface_1 = require("../interface/sceneInterface");
5
- var assets_1 = require("../interface/assets");
6
- /**
7
- * 解析语句内容的函数,主要作用是把文件名改为绝对地址或相对地址(根据使用情况而定)
8
- * @param contentRaw 原始语句内容
9
- * @param type 语句类型
10
- * @param assetSetter
11
- * @return {string} 解析后的语句内容
12
- */
13
- var contentParser = function (contentRaw, type, assetSetter) {
14
- if (contentRaw === "none" || contentRaw === "") {
15
- return "";
16
- }
17
- switch (type) {
18
- case sceneInterface_1.commandType.changeBg:
19
- return assetSetter(contentRaw, assets_1.fileType.background);
20
- case sceneInterface_1.commandType.changeFigure:
21
- return assetSetter(contentRaw, assets_1.fileType.figure);
22
- case sceneInterface_1.commandType.bgm:
23
- return assetSetter(contentRaw, assets_1.fileType.bgm);
24
- case sceneInterface_1.commandType.callScene:
25
- return assetSetter(contentRaw, assets_1.fileType.scene);
26
- case sceneInterface_1.commandType.changeScene:
27
- return assetSetter(contentRaw, assets_1.fileType.scene);
28
- case sceneInterface_1.commandType.miniAvatar:
29
- return assetSetter(contentRaw, assets_1.fileType.figure);
30
- case sceneInterface_1.commandType.video:
31
- return assetSetter(contentRaw, assets_1.fileType.video);
32
- case sceneInterface_1.commandType.choose:
33
- return getChooseContent(contentRaw, assetSetter);
34
- case sceneInterface_1.commandType.unlockBgm:
35
- return assetSetter(contentRaw, assets_1.fileType.bgm);
36
- case sceneInterface_1.commandType.unlockCg:
37
- return assetSetter(contentRaw, assets_1.fileType.background);
38
- default:
39
- return contentRaw;
40
- }
41
- };
42
- exports.contentParser = contentParser;
43
- function getChooseContent(contentRaw, assetSetter) {
44
- var chooseList = contentRaw.split("|");
45
- var chooseKeyList = [];
46
- var chooseValueList = [];
47
- for (var _i = 0, chooseList_1 = chooseList; _i < chooseList_1.length; _i++) {
48
- var e = chooseList_1[_i];
49
- chooseKeyList.push(e.split(":")[0]);
50
- chooseValueList.push(e.split(":")[1]);
51
- }
52
- var parsedChooseList = chooseValueList.map(function (e) {
53
- if (e.match(/\./)) {
54
- return assetSetter(e, assets_1.fileType.scene);
55
- }
56
- else {
57
- return e;
58
- }
59
- });
60
- var ret = "";
61
- for (var i = 0; i < chooseKeyList.length; i++) {
62
- if (i !== 0) {
63
- ret = ret + "|";
64
- }
65
- ret = ret + "".concat(chooseKeyList[i], ":").concat(parsedChooseList[i]);
66
- }
67
- return ret;
68
- }
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.contentParser = void 0;
4
+ var sceneInterface_1 = require("../interface/sceneInterface");
5
+ var assets_1 = require("../interface/assets");
6
+ /**
7
+ * 解析语句内容的函数,主要作用是把文件名改为绝对地址或相对地址(根据使用情况而定)
8
+ * @param contentRaw 原始语句内容
9
+ * @param type 语句类型
10
+ * @param assetSetter
11
+ * @return {string} 解析后的语句内容
12
+ */
13
+ var contentParser = function (contentRaw, type, assetSetter) {
14
+ if (contentRaw === "none" || contentRaw === "") {
15
+ return "";
16
+ }
17
+ switch (type) {
18
+ case sceneInterface_1.commandType.changeBg:
19
+ return assetSetter(contentRaw, assets_1.fileType.background);
20
+ case sceneInterface_1.commandType.changeFigure:
21
+ return assetSetter(contentRaw, assets_1.fileType.figure);
22
+ case sceneInterface_1.commandType.bgm:
23
+ return assetSetter(contentRaw, assets_1.fileType.bgm);
24
+ case sceneInterface_1.commandType.callScene:
25
+ return assetSetter(contentRaw, assets_1.fileType.scene);
26
+ case sceneInterface_1.commandType.changeScene:
27
+ return assetSetter(contentRaw, assets_1.fileType.scene);
28
+ case sceneInterface_1.commandType.miniAvatar:
29
+ return assetSetter(contentRaw, assets_1.fileType.figure);
30
+ case sceneInterface_1.commandType.video:
31
+ return assetSetter(contentRaw, assets_1.fileType.video);
32
+ case sceneInterface_1.commandType.choose:
33
+ return getChooseContent(contentRaw, assetSetter);
34
+ case sceneInterface_1.commandType.unlockBgm:
35
+ return assetSetter(contentRaw, assets_1.fileType.bgm);
36
+ case sceneInterface_1.commandType.unlockCg:
37
+ return assetSetter(contentRaw, assets_1.fileType.background);
38
+ default:
39
+ return contentRaw;
40
+ }
41
+ };
42
+ exports.contentParser = contentParser;
43
+ function getChooseContent(contentRaw, assetSetter) {
44
+ var chooseList = contentRaw.split("|");
45
+ var chooseKeyList = [];
46
+ var chooseValueList = [];
47
+ for (var _i = 0, chooseList_1 = chooseList; _i < chooseList_1.length; _i++) {
48
+ var e = chooseList_1[_i];
49
+ chooseKeyList.push(e.split(":")[0]);
50
+ chooseValueList.push(e.split(":")[1]);
51
+ }
52
+ var parsedChooseList = chooseValueList.map(function (e) {
53
+ if (e.match(/\./)) {
54
+ return assetSetter(e, assets_1.fileType.scene);
55
+ }
56
+ else {
57
+ return e;
58
+ }
59
+ });
60
+ var ret = "";
61
+ for (var i = 0; i < chooseKeyList.length; i++) {
62
+ if (i !== 0) {
63
+ ret = ret + "|";
64
+ }
65
+ ret = ret + "".concat(chooseKeyList[i], ":").concat(parsedChooseList[i]);
66
+ }
67
+ return ret;
68
+ }
@@ -33,6 +33,8 @@ export const contentParser = (contentRaw: string, type: commandType, assetSetter
33
33
  return assetSetter(contentRaw, fileType.bgm);
34
34
  case commandType.unlockCg:
35
35
  return assetSetter(contentRaw, fileType.background);
36
+ case commandType.playEffect:
37
+ return assetSetter(contentRaw,fileType.vocal);
36
38
  default:
37
39
  return contentRaw;
38
40
  }
@@ -1,9 +1,9 @@
1
- import { ISentence } from "../interface/sceneInterface";
2
- /**
3
- * 语句解析器
4
- * @param sentenceRaw 原始语句
5
- * @param assetSetter
6
- * @param ADD_NEXT_ARG_LIST
7
- * @param SCRIPT_CONFIG
8
- */
9
- export declare const scriptParser: (sentenceRaw: string, assetSetter: any, ADD_NEXT_ARG_LIST: any, SCRIPT_CONFIG: any) => ISentence;
1
+ import { ISentence } from "../interface/sceneInterface";
2
+ /**
3
+ * 语句解析器
4
+ * @param sentenceRaw 原始语句
5
+ * @param assetSetter
6
+ * @param ADD_NEXT_ARG_LIST
7
+ * @param SCRIPT_CONFIG
8
+ */
9
+ export declare const scriptParser: (sentenceRaw: string, assetSetter: any, ADD_NEXT_ARG_LIST: any, SCRIPT_CONFIG: any) => ISentence;