webgal-parser 4.3.13-1 → 4.3.13-10
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/config/scriptConfig.d.ts +6 -0
- package/build/cjs/index.d.ts +12 -0
- package/build/cjs/index.js +1756 -0
- package/build/cjs/interface/assets.d.ts +12 -0
- package/build/cjs/interface/runtimeInterface.d.ts +9 -0
- package/build/cjs/interface/sceneInterface.d.ts +94 -0
- package/build/cjs/sceneParser.d.ts +14 -0
- package/build/cjs/scriptParser/argsParser.d.ts +9 -0
- package/build/cjs/scriptParser/assetsScanner.d.ts +9 -0
- package/build/cjs/scriptParser/commandParser.d.ts +9 -0
- package/build/cjs/scriptParser/contentParser.d.ts +9 -0
- package/build/cjs/scriptParser/scriptParser.d.ts +9 -0
- package/build/cjs/scriptParser/subSceneScanner.d.ts +7 -0
- package/build/es/config/scriptConfig.d.ts +6 -0
- package/build/es/index.d.ts +12 -0
- package/build/es/index.js +1750 -0
- package/build/es/interface/assets.d.ts +12 -0
- package/build/es/interface/runtimeInterface.d.ts +9 -0
- package/build/es/interface/sceneInterface.d.ts +94 -0
- package/build/es/sceneParser.d.ts +14 -0
- package/build/es/scriptParser/argsParser.d.ts +9 -0
- package/build/es/scriptParser/assetsScanner.d.ts +9 -0
- package/build/es/scriptParser/commandParser.d.ts +9 -0
- package/build/es/scriptParser/contentParser.d.ts +9 -0
- package/build/es/scriptParser/scriptParser.d.ts +9 -0
- package/build/es/scriptParser/subSceneScanner.d.ts +7 -0
- package/build/types/config/scriptConfig.d.ts +6 -0
- package/build/types/index.d.ts +12 -0
- package/build/types/interface/assets.d.ts +12 -0
- package/build/types/interface/runtimeInterface.d.ts +9 -0
- package/build/types/interface/sceneInterface.d.ts +94 -0
- package/build/types/sceneParser.d.ts +14 -0
- package/build/types/scriptParser/argsParser.d.ts +9 -0
- package/build/types/scriptParser/assetsScanner.d.ts +9 -0
- package/build/types/scriptParser/commandParser.d.ts +9 -0
- package/build/types/scriptParser/contentParser.d.ts +9 -0
- package/build/types/scriptParser/scriptParser.d.ts +9 -0
- package/build/types/scriptParser/subSceneScanner.d.ts +7 -0
- package/build/umd/index.global.js +1761 -0
- package/package.json +2 -1
- package/src/config/scriptConfig.ts +2 -1
- package/src/index.ts +3 -0
- package/src/scriptParser/contentParser.ts +6 -6
- package/src/scriptParser/subSceneScanner.ts +3 -3
- package/.babelrc +0 -14
- package/rollup.config.js +0 -48
- package/test/parser.test.ts +0 -29
- package/test/test-resources/start.txt +0 -105
- package/tsconfig.json +0 -29
- package/tsconfig.node.json +0 -10
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 单个参数接口
|
|
39
|
+
* @interface arg
|
|
40
|
+
*/
|
|
41
|
+
export interface arg {
|
|
42
|
+
key: string;
|
|
43
|
+
value: string | boolean | number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 资源接口
|
|
47
|
+
* @interface IAsset
|
|
48
|
+
*/
|
|
49
|
+
export interface IAsset {
|
|
50
|
+
name: string;
|
|
51
|
+
type: fileType;
|
|
52
|
+
url: string;
|
|
53
|
+
lineNumber: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 单条语句接口
|
|
57
|
+
* @interface ISentence
|
|
58
|
+
*/
|
|
59
|
+
export interface ISentence {
|
|
60
|
+
command: commandType;
|
|
61
|
+
commandRaw: string;
|
|
62
|
+
content: string;
|
|
63
|
+
args: Array<arg>;
|
|
64
|
+
sentenceAssets: Array<IAsset>;
|
|
65
|
+
subScene: Array<string>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 场景接口
|
|
69
|
+
* @interface IScene
|
|
70
|
+
*/
|
|
71
|
+
export interface IScene {
|
|
72
|
+
sceneName: string;
|
|
73
|
+
sceneUrl: string;
|
|
74
|
+
sentenceList: Array<ISentence>;
|
|
75
|
+
assetsList: Array<IAsset>;
|
|
76
|
+
subSceneList: Array<string>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 当前的场景数据
|
|
80
|
+
* @interface ISceneData
|
|
81
|
+
*/
|
|
82
|
+
export interface ISceneData {
|
|
83
|
+
currentSentenceId: number;
|
|
84
|
+
sceneStack: Array<sceneEntry>;
|
|
85
|
+
currentScene: IScene;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* 处理后的命令接口
|
|
89
|
+
* @interface parsedCommand
|
|
90
|
+
*/
|
|
91
|
+
export interface parsedCommand {
|
|
92
|
+
type: commandType;
|
|
93
|
+
additionalArgs: Array<arg>;
|
|
94
|
+
}
|
|
@@ -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,12 @@
|
|
|
1
|
+
import { commandType, 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<commandType>, SCRIPT_CONFIG: Array<any>);
|
|
10
|
+
parse(rawScene: string, sceneName: string, sceneUrl: string): import("./interface/sceneInterface").IScene;
|
|
11
|
+
}
|
|
12
|
+
export { ADD_NEXT_ARG_LIST, SCRIPT_CONFIG };
|