webgal-parser 4.3.13-9 → 4.4.3

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 (42) hide show
  1. package/build/cjs/configParser/configParser.d.ts +1 -0
  2. package/build/cjs/index.d.ts +4 -3
  3. package/build/cjs/index.js +17 -3
  4. package/build/cjs/interface/sceneInterface.d.ts +3 -1
  5. package/build/cjs/parser4/index.d.ts +1 -0
  6. package/build/es/configParser/configParser.d.ts +1 -0
  7. package/build/es/index.d.ts +4 -3
  8. package/build/es/index.js +17 -3
  9. package/build/es/interface/sceneInterface.d.ts +3 -1
  10. package/build/es/parser4/index.d.ts +1 -0
  11. package/build/types/config/scriptConfig.d.ts +6 -0
  12. package/build/types/configParser/configParser.d.ts +1 -0
  13. package/build/types/index.d.ts +13 -0
  14. package/build/types/interface/assets.d.ts +12 -0
  15. package/build/types/interface/runtimeInterface.d.ts +9 -0
  16. package/build/types/interface/sceneInterface.d.ts +96 -0
  17. package/build/types/parser4/index.d.ts +1 -0
  18. package/build/types/sceneParser.d.ts +14 -0
  19. package/build/types/scriptParser/argsParser.d.ts +9 -0
  20. package/build/types/scriptParser/assetsScanner.d.ts +9 -0
  21. package/build/types/scriptParser/commandParser.d.ts +9 -0
  22. package/build/types/scriptParser/contentParser.d.ts +9 -0
  23. package/build/types/scriptParser/scriptParser.d.ts +9 -0
  24. package/build/types/scriptParser/subSceneScanner.d.ts +7 -0
  25. package/build/umd/index.global.js +1776 -0
  26. package/package.json +7 -4
  27. package/src/config/scriptConfig.ts +46 -46
  28. package/src/configParser/configParser.ts +4 -0
  29. package/src/index.ts +11 -6
  30. package/src/interface/assets.ts +12 -12
  31. package/src/interface/runtimeInterface.ts +9 -9
  32. package/src/interface/sceneInterface.ts +5 -3
  33. package/src/parser4/index.ts +158 -0
  34. package/src/sceneParser.ts +47 -47
  35. package/src/scriptParser/argsParser.ts +68 -62
  36. package/src/scriptParser/assetsScanner.ts +72 -72
  37. package/src/scriptParser/commandParser.ts +57 -57
  38. package/src/scriptParser/contentParser.ts +66 -66
  39. package/src/scriptParser/scriptParser.ts +87 -87
  40. package/src/scriptParser/subSceneScanner.ts +23 -23
  41. package/build/cjs/index.js.map +0 -1
  42. package/build/es/index.js.map +0 -1
@@ -0,0 +1 @@
1
+ export declare function configParser(configText: string): string;
@@ -1,4 +1,4 @@
1
- import { commandType, IAsset, IScene } from "./interface/sceneInterface";
1
+ import { IAsset } from "./interface/sceneInterface";
2
2
  import { fileType } from "./interface/assets";
3
3
  import { ADD_NEXT_ARG_LIST, SCRIPT_CONFIG } from "./config/scriptConfig";
4
4
  export default class SceneParser {
@@ -6,7 +6,8 @@ export default class SceneParser {
6
6
  private readonly assetSetter;
7
7
  private readonly ADD_NEXT_ARG_LIST;
8
8
  private readonly SCRIPT_CONFIG;
9
- constructor(assetsPrefetcher: ((assetList: Array<IAsset>) => void), assetSetter: (fileName: string, assetType: fileType) => string, ADD_NEXT_ARG_LIST: Array<commandType>, SCRIPT_CONFIG: Array<any>);
10
- parse(rawScene: string, sceneName: string, sceneUrl: string): IScene;
9
+ constructor(assetsPrefetcher: ((assetList: Array<IAsset>) => void), assetSetter: (fileName: string, assetType: fileType) => string, ADD_NEXT_ARG_LIST: Array<number>, SCRIPT_CONFIG: Array<any>);
10
+ parse(rawScene: string, sceneName: string, sceneUrl: string): import("./interface/sceneInterface").IScene;
11
+ parseConfig(configText: string): string;
11
12
  }
12
13
  export { ADD_NEXT_ARG_LIST, SCRIPT_CONFIG };
@@ -33,6 +33,8 @@ var commandType;
33
33
  commandType[commandType["playEffect"] = 26] = "playEffect";
34
34
  commandType[commandType["setTempAnimation"] = 27] = "setTempAnimation";
35
35
  commandType[commandType["comment"] = 28] = "comment";
36
+ commandType[commandType["setTransform"] = 29] = "setTransform";
37
+ commandType[commandType["setTransition"] = 30] = "setTransition";
36
38
  })(commandType || (commandType = {}));
37
39
 
38
40
  /**
@@ -123,8 +125,13 @@ function argsParser(argsRaw, assetSetter) {
123
125
  return e !== "";
124
126
  });
125
127
  rawArgsList.forEach((e) => {
126
- const argName = e.split("=")[0];
127
- const argValue = e.split("=")[1];
128
+ const equalSignIndex = e.indexOf('=');
129
+ let argName = e.slice(0, equalSignIndex);
130
+ let argValue = e.slice(equalSignIndex + 1);
131
+ if (equalSignIndex < 0) {
132
+ argName = e;
133
+ argValue = undefined;
134
+ }
128
135
  // 判断是不是语音参数
129
136
  if (e.match(/.ogg|.mp3|.wav/)) {
130
137
  returnArrayList.push({
@@ -1735,6 +1742,11 @@ const ADD_NEXT_ARG_LIST = [
1735
1742
  commandType.playEffect,
1736
1743
  ];
1737
1744
 
1745
+ function configParser(configText) {
1746
+ // TODO
1747
+ return configText;
1748
+ }
1749
+
1738
1750
  class SceneParser {
1739
1751
  assetsPrefetcher;
1740
1752
  assetSetter;
@@ -1749,9 +1761,11 @@ class SceneParser {
1749
1761
  parse(rawScene, sceneName, sceneUrl) {
1750
1762
  return sceneParser(rawScene, sceneName, sceneUrl, this.assetsPrefetcher, this.assetSetter, this.ADD_NEXT_ARG_LIST, this.SCRIPT_CONFIG);
1751
1763
  }
1764
+ parseConfig(configText) {
1765
+ return configParser(configText);
1766
+ }
1752
1767
  }
1753
1768
 
1754
1769
  exports.ADD_NEXT_ARG_LIST = ADD_NEXT_ARG_LIST;
1755
1770
  exports.SCRIPT_CONFIG = SCRIPT_CONFIG;
1756
1771
  exports.default = SceneParser;
1757
- //# sourceMappingURL=index.js.map
@@ -32,7 +32,9 @@ export declare enum commandType {
32
32
  setAnimation = 25,
33
33
  playEffect = 26,
34
34
  setTempAnimation = 27,
35
- comment = 28
35
+ comment = 28,
36
+ setTransform = 29,
37
+ setTransition = 30
36
38
  }
37
39
  /**
38
40
  * 单个参数接口
@@ -0,0 +1 @@
1
+ export declare const parser4 = "unreleased";
@@ -0,0 +1 @@
1
+ export declare function configParser(configText: string): string;
@@ -1,4 +1,4 @@
1
- import { commandType, IAsset, IScene } from "./interface/sceneInterface";
1
+ import { IAsset } from "./interface/sceneInterface";
2
2
  import { fileType } from "./interface/assets";
3
3
  import { ADD_NEXT_ARG_LIST, SCRIPT_CONFIG } from "./config/scriptConfig";
4
4
  export default class SceneParser {
@@ -6,7 +6,8 @@ export default class SceneParser {
6
6
  private readonly assetSetter;
7
7
  private readonly ADD_NEXT_ARG_LIST;
8
8
  private readonly SCRIPT_CONFIG;
9
- constructor(assetsPrefetcher: ((assetList: Array<IAsset>) => void), assetSetter: (fileName: string, assetType: fileType) => string, ADD_NEXT_ARG_LIST: Array<commandType>, SCRIPT_CONFIG: Array<any>);
10
- parse(rawScene: string, sceneName: string, sceneUrl: string): IScene;
9
+ constructor(assetsPrefetcher: ((assetList: Array<IAsset>) => void), assetSetter: (fileName: string, assetType: fileType) => string, ADD_NEXT_ARG_LIST: Array<number>, SCRIPT_CONFIG: Array<any>);
10
+ parse(rawScene: string, sceneName: string, sceneUrl: string): import("./interface/sceneInterface").IScene;
11
+ parseConfig(configText: string): string;
11
12
  }
12
13
  export { ADD_NEXT_ARG_LIST, SCRIPT_CONFIG };
package/build/es/index.js CHANGED
@@ -29,6 +29,8 @@ var commandType;
29
29
  commandType[commandType["playEffect"] = 26] = "playEffect";
30
30
  commandType[commandType["setTempAnimation"] = 27] = "setTempAnimation";
31
31
  commandType[commandType["comment"] = 28] = "comment";
32
+ commandType[commandType["setTransform"] = 29] = "setTransform";
33
+ commandType[commandType["setTransition"] = 30] = "setTransition";
32
34
  })(commandType || (commandType = {}));
33
35
 
34
36
  /**
@@ -119,8 +121,13 @@ function argsParser(argsRaw, assetSetter) {
119
121
  return e !== "";
120
122
  });
121
123
  rawArgsList.forEach((e) => {
122
- const argName = e.split("=")[0];
123
- const argValue = e.split("=")[1];
124
+ const equalSignIndex = e.indexOf('=');
125
+ let argName = e.slice(0, equalSignIndex);
126
+ let argValue = e.slice(equalSignIndex + 1);
127
+ if (equalSignIndex < 0) {
128
+ argName = e;
129
+ argValue = undefined;
130
+ }
124
131
  // 判断是不是语音参数
125
132
  if (e.match(/.ogg|.mp3|.wav/)) {
126
133
  returnArrayList.push({
@@ -1731,6 +1738,11 @@ const ADD_NEXT_ARG_LIST = [
1731
1738
  commandType.playEffect,
1732
1739
  ];
1733
1740
 
1741
+ function configParser(configText) {
1742
+ // TODO
1743
+ return configText;
1744
+ }
1745
+
1734
1746
  class SceneParser {
1735
1747
  assetsPrefetcher;
1736
1748
  assetSetter;
@@ -1745,7 +1757,9 @@ class SceneParser {
1745
1757
  parse(rawScene, sceneName, sceneUrl) {
1746
1758
  return sceneParser(rawScene, sceneName, sceneUrl, this.assetsPrefetcher, this.assetSetter, this.ADD_NEXT_ARG_LIST, this.SCRIPT_CONFIG);
1747
1759
  }
1760
+ parseConfig(configText) {
1761
+ return configParser(configText);
1762
+ }
1748
1763
  }
1749
1764
 
1750
1765
  export { ADD_NEXT_ARG_LIST, SCRIPT_CONFIG, SceneParser as default };
1751
- //# sourceMappingURL=index.js.map
@@ -32,7 +32,9 @@ export declare enum commandType {
32
32
  setAnimation = 25,
33
33
  playEffect = 26,
34
34
  setTempAnimation = 27,
35
- comment = 28
35
+ comment = 28,
36
+ setTransform = 29,
37
+ setTransition = 30
36
38
  }
37
39
  /**
38
40
  * 单个参数接口
@@ -0,0 +1 @@
1
+ export declare const parser4 = "unreleased";
@@ -0,0 +1,6 @@
1
+ import { commandType } from "../interface/sceneInterface";
2
+ export declare const SCRIPT_CONFIG: {
3
+ scriptString: string;
4
+ scriptType: commandType;
5
+ }[];
6
+ export declare const ADD_NEXT_ARG_LIST: commandType[];
@@ -0,0 +1 @@
1
+ export declare function configParser(configText: string): string;
@@ -0,0 +1,13 @@
1
+ import { IAsset } from "./interface/sceneInterface";
2
+ import { fileType } from "./interface/assets";
3
+ import { ADD_NEXT_ARG_LIST, SCRIPT_CONFIG } from "./config/scriptConfig";
4
+ export default class SceneParser {
5
+ private readonly assetsPrefetcher;
6
+ private readonly assetSetter;
7
+ private readonly ADD_NEXT_ARG_LIST;
8
+ private readonly SCRIPT_CONFIG;
9
+ constructor(assetsPrefetcher: ((assetList: Array<IAsset>) => void), assetSetter: (fileName: string, assetType: fileType) => string, ADD_NEXT_ARG_LIST: Array<number>, SCRIPT_CONFIG: Array<any>);
10
+ parse(rawScene: string, sceneName: string, sceneUrl: string): import("./interface/sceneInterface").IScene;
11
+ parseConfig(configText: string): string;
12
+ }
13
+ export { ADD_NEXT_ARG_LIST, SCRIPT_CONFIG };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 内置资源类型的枚举
3
+ */
4
+ export declare enum fileType {
5
+ background = 0,
6
+ bgm = 1,
7
+ figure = 2,
8
+ scene = 3,
9
+ tex = 4,
10
+ vocal = 5,
11
+ video = 6
12
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 子场景结束后回到父场景的入口
3
+ * @interface sceneEntry
4
+ */
5
+ export interface sceneEntry {
6
+ sceneName: string;
7
+ sceneUrl: string;
8
+ continueLine: number;
9
+ }
@@ -0,0 +1,96 @@
1
+ /**
2
+ * 语句类型
3
+ */
4
+ import { sceneEntry } from "./runtimeInterface";
5
+ import { fileType } from "./assets";
6
+ export declare enum commandType {
7
+ say = 0,
8
+ changeBg = 1,
9
+ changeFigure = 2,
10
+ bgm = 3,
11
+ video = 4,
12
+ pixi = 5,
13
+ pixiInit = 6,
14
+ intro = 7,
15
+ miniAvatar = 8,
16
+ changeScene = 9,
17
+ choose = 10,
18
+ end = 11,
19
+ setComplexAnimation = 12,
20
+ setFilter = 13,
21
+ label = 14,
22
+ jumpLabel = 15,
23
+ chooseLabel = 16,
24
+ setVar = 17,
25
+ if = 18,
26
+ callScene = 19,
27
+ showVars = 20,
28
+ unlockCg = 21,
29
+ unlockBgm = 22,
30
+ filmMode = 23,
31
+ setTextbox = 24,
32
+ setAnimation = 25,
33
+ playEffect = 26,
34
+ setTempAnimation = 27,
35
+ comment = 28,
36
+ setTransform = 29,
37
+ setTransition = 30
38
+ }
39
+ /**
40
+ * 单个参数接口
41
+ * @interface arg
42
+ */
43
+ export interface arg {
44
+ key: string;
45
+ value: string | boolean | number;
46
+ }
47
+ /**
48
+ * 资源接口
49
+ * @interface IAsset
50
+ */
51
+ export interface IAsset {
52
+ name: string;
53
+ type: fileType;
54
+ url: string;
55
+ lineNumber: number;
56
+ }
57
+ /**
58
+ * 单条语句接口
59
+ * @interface ISentence
60
+ */
61
+ export interface ISentence {
62
+ command: commandType;
63
+ commandRaw: string;
64
+ content: string;
65
+ args: Array<arg>;
66
+ sentenceAssets: Array<IAsset>;
67
+ subScene: Array<string>;
68
+ }
69
+ /**
70
+ * 场景接口
71
+ * @interface IScene
72
+ */
73
+ export interface IScene {
74
+ sceneName: string;
75
+ sceneUrl: string;
76
+ sentenceList: Array<ISentence>;
77
+ assetsList: Array<IAsset>;
78
+ subSceneList: Array<string>;
79
+ }
80
+ /**
81
+ * 当前的场景数据
82
+ * @interface ISceneData
83
+ */
84
+ export interface ISceneData {
85
+ currentSentenceId: number;
86
+ sceneStack: Array<sceneEntry>;
87
+ currentScene: IScene;
88
+ }
89
+ /**
90
+ * 处理后的命令接口
91
+ * @interface parsedCommand
92
+ */
93
+ export interface parsedCommand {
94
+ type: commandType;
95
+ additionalArgs: Array<arg>;
96
+ }
@@ -0,0 +1 @@
1
+ export declare const parser4 = "unreleased";
@@ -0,0 +1,14 @@
1
+ import { IAsset, IScene } from "./interface/sceneInterface";
2
+ import { fileType } from "./interface/assets";
3
+ /**
4
+ * 场景解析器
5
+ * @param rawScene 原始场景
6
+ * @param sceneName 场景名称
7
+ * @param sceneUrl 场景url
8
+ * @param assetsPrefetcher
9
+ * @param assetSetter
10
+ * @param ADD_NEXT_ARG_LIST
11
+ * @param SCRIPT_CONFIG
12
+ * @return {IScene} 解析后的场景
13
+ */
14
+ export declare const sceneParser: (rawScene: string, sceneName: string, sceneUrl: string, assetsPrefetcher: (assetList: Array<IAsset>) => void, assetSetter: (fileName: string, assetType: fileType) => string, ADD_NEXT_ARG_LIST: any, SCRIPT_CONFIG: any) => IScene;
@@ -0,0 +1,9 @@
1
+ import { arg } from "../interface/sceneInterface";
2
+ import { fileType } from "../interface/assets";
3
+ /**
4
+ * 参数解析器
5
+ * @param argsRaw 原始参数字符串
6
+ * @param assetSetter
7
+ * @return {Array<arg>} 解析后的参数列表
8
+ */
9
+ export declare function argsParser(argsRaw: string, assetSetter: (fileName: string, assetType: fileType) => string): Array<arg>;
@@ -0,0 +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>;
@@ -0,0 +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;
@@ -0,0 +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;
@@ -0,0 +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;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 扫描子场景
3
+ * @param content 语句内容
4
+ * @return {Array<string>} 子场景列表
5
+ */
6
+ import { commandType } from "../interface/sceneInterface";
7
+ export declare const subSceneScanner: (command: commandType, content: string) => Array<string>;