webgal-parser 4.5.13 → 4.5.16
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/CHANGELOG.md +28 -0
- package/build/cjs/index.cjs +8 -6
- package/build/cjs/interface/runtimeInterface.d.ts +6 -0
- package/build/cjs/interface/sceneInterface.d.ts +2 -2
- package/build/es/index.js +8 -6
- package/build/es/interface/runtimeInterface.d.ts +6 -0
- package/build/es/interface/sceneInterface.d.ts +2 -2
- package/build/types/interface/runtimeInterface.d.ts +6 -0
- package/build/types/interface/sceneInterface.d.ts +2 -2
- package/build/umd/index.global.js +8 -6
- package/package.json +2 -1
- package/src/interface/runtimeInterface.ts +6 -0
- package/src/interface/sceneInterface.ts +3 -3
- package/src/sceneParser.ts +1 -1
- package/src/scriptParser/argsParser.ts +3 -3
- package/src/scriptParser/scriptParser.ts +4 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# WebGAL Parser Changelog
|
|
2
|
+
|
|
3
|
+
## [4.5.13] - 2025-07-05
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- Fixed interface consistency between `webgal-parser` and main WebGAL project
|
|
7
|
+
- Added missing trailing comma in `commandType` enum to match WebGAL main project
|
|
8
|
+
- Updated `ISceneData` interface to use `ISceneEntry` instead of `sceneEntry` for better type consistency
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Added `ISceneEntry` interface as compatibility alias for `sceneEntry`
|
|
12
|
+
- Added comprehensive test cases for new animation parameters:
|
|
13
|
+
- `wait` command testing
|
|
14
|
+
- `changeFigure` with `duration`, `enter`, `exit` parameters
|
|
15
|
+
- `changeBg` with animation and transform parameters
|
|
16
|
+
|
|
17
|
+
### Improved
|
|
18
|
+
- Enhanced type safety and consistency with main WebGAL project
|
|
19
|
+
- Better test coverage for animation-related features
|
|
20
|
+
- Improved interface documentation
|
|
21
|
+
|
|
22
|
+
### Technical Notes
|
|
23
|
+
- The parser already supports all animation parameters (`duration`, `enter`, `exit`, `transform`) through its generic argument parsing system
|
|
24
|
+
- No changes to core parsing logic were needed - the parser was already compatible with the latest WebGAL features
|
|
25
|
+
- This update focuses on interface consistency and test coverage improvements
|
|
26
|
+
|
|
27
|
+
## [4.5.12] - Previous Version
|
|
28
|
+
- Previous stable release with `wait` command support
|
package/build/cjs/index.cjs
CHANGED
|
@@ -128,10 +128,10 @@ function argsParser(argsRaw, assetSetter) {
|
|
|
128
128
|
});
|
|
129
129
|
rawArgsList.forEach((e) => {
|
|
130
130
|
const equalSignIndex = e.indexOf('=');
|
|
131
|
-
let argName = e.slice(0, equalSignIndex);
|
|
132
|
-
let argValue = e.slice(equalSignIndex + 1);
|
|
131
|
+
let argName = e.slice(0, equalSignIndex).trim();
|
|
132
|
+
let argValue = e.slice(equalSignIndex + 1).trim();
|
|
133
133
|
if (equalSignIndex < 0) {
|
|
134
|
-
argName = e;
|
|
134
|
+
argName = e.trim();
|
|
135
135
|
argValue = undefined;
|
|
136
136
|
}
|
|
137
137
|
// 判断是不是语音参数
|
|
@@ -447,14 +447,16 @@ const scriptParser = (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG
|
|
|
447
447
|
let commandRaw;
|
|
448
448
|
// 正式开始解析
|
|
449
449
|
// 去分号
|
|
450
|
-
|
|
450
|
+
const commentSplit = sentenceRaw.split(/(?<!\\);/);
|
|
451
|
+
let newSentenceRaw = commentSplit[0].trim();
|
|
451
452
|
newSentenceRaw = newSentenceRaw.replaceAll('\\;', ';');
|
|
453
|
+
const sentenceComment = commentSplit[1] ?? '';
|
|
452
454
|
if (newSentenceRaw === '') {
|
|
453
455
|
// 注释提前返回
|
|
454
456
|
return {
|
|
455
457
|
command: commandType.comment,
|
|
456
458
|
commandRaw: 'comment',
|
|
457
|
-
content:
|
|
459
|
+
content: sentenceComment.trim(),
|
|
458
460
|
args: [{ key: 'next', value: true }],
|
|
459
461
|
sentenceAssets: [],
|
|
460
462
|
subScene: [], // 语句携带的子场景
|
|
@@ -1771,7 +1773,7 @@ var uniqWith_1 = uniqWith;
|
|
|
1771
1773
|
* @return {IScene} 解析后的场景
|
|
1772
1774
|
*/
|
|
1773
1775
|
const sceneParser = (rawScene, sceneName, sceneUrl, assetsPrefetcher, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP) => {
|
|
1774
|
-
const rawSentenceList = rawScene.split('\n'); // 原始句子列表
|
|
1776
|
+
const rawSentenceList = rawScene.replaceAll('\r', '').split('\n'); // 原始句子列表
|
|
1775
1777
|
// 去分号留到后面去做了,现在注释要单独处理
|
|
1776
1778
|
const rawSentenceListWithoutEmpty = rawSentenceList;
|
|
1777
1779
|
// .map((sentence) => sentence.split(";")[0])
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 语句类型
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { ISceneEntry } from './runtimeInterface';
|
|
5
5
|
import { fileType } from './assets';
|
|
6
6
|
export declare enum commandType {
|
|
7
7
|
say = 0,
|
|
@@ -86,7 +86,7 @@ export interface IScene {
|
|
|
86
86
|
*/
|
|
87
87
|
export interface ISceneData {
|
|
88
88
|
currentSentenceId: number;
|
|
89
|
-
sceneStack: Array<
|
|
89
|
+
sceneStack: Array<ISceneEntry>;
|
|
90
90
|
currentScene: IScene;
|
|
91
91
|
}
|
|
92
92
|
/**
|
package/build/es/index.js
CHANGED
|
@@ -124,10 +124,10 @@ function argsParser(argsRaw, assetSetter) {
|
|
|
124
124
|
});
|
|
125
125
|
rawArgsList.forEach((e) => {
|
|
126
126
|
const equalSignIndex = e.indexOf('=');
|
|
127
|
-
let argName = e.slice(0, equalSignIndex);
|
|
128
|
-
let argValue = e.slice(equalSignIndex + 1);
|
|
127
|
+
let argName = e.slice(0, equalSignIndex).trim();
|
|
128
|
+
let argValue = e.slice(equalSignIndex + 1).trim();
|
|
129
129
|
if (equalSignIndex < 0) {
|
|
130
|
-
argName = e;
|
|
130
|
+
argName = e.trim();
|
|
131
131
|
argValue = undefined;
|
|
132
132
|
}
|
|
133
133
|
// 判断是不是语音参数
|
|
@@ -443,14 +443,16 @@ const scriptParser = (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG
|
|
|
443
443
|
let commandRaw;
|
|
444
444
|
// 正式开始解析
|
|
445
445
|
// 去分号
|
|
446
|
-
|
|
446
|
+
const commentSplit = sentenceRaw.split(/(?<!\\);/);
|
|
447
|
+
let newSentenceRaw = commentSplit[0].trim();
|
|
447
448
|
newSentenceRaw = newSentenceRaw.replaceAll('\\;', ';');
|
|
449
|
+
const sentenceComment = commentSplit[1] ?? '';
|
|
448
450
|
if (newSentenceRaw === '') {
|
|
449
451
|
// 注释提前返回
|
|
450
452
|
return {
|
|
451
453
|
command: commandType.comment,
|
|
452
454
|
commandRaw: 'comment',
|
|
453
|
-
content:
|
|
455
|
+
content: sentenceComment.trim(),
|
|
454
456
|
args: [{ key: 'next', value: true }],
|
|
455
457
|
sentenceAssets: [],
|
|
456
458
|
subScene: [], // 语句携带的子场景
|
|
@@ -1767,7 +1769,7 @@ var uniqWith_1 = uniqWith;
|
|
|
1767
1769
|
* @return {IScene} 解析后的场景
|
|
1768
1770
|
*/
|
|
1769
1771
|
const sceneParser = (rawScene, sceneName, sceneUrl, assetsPrefetcher, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP) => {
|
|
1770
|
-
const rawSentenceList = rawScene.split('\n'); // 原始句子列表
|
|
1772
|
+
const rawSentenceList = rawScene.replaceAll('\r', '').split('\n'); // 原始句子列表
|
|
1771
1773
|
// 去分号留到后面去做了,现在注释要单独处理
|
|
1772
1774
|
const rawSentenceListWithoutEmpty = rawSentenceList;
|
|
1773
1775
|
// .map((sentence) => sentence.split(";")[0])
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 语句类型
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { ISceneEntry } from './runtimeInterface';
|
|
5
5
|
import { fileType } from './assets';
|
|
6
6
|
export declare enum commandType {
|
|
7
7
|
say = 0,
|
|
@@ -86,7 +86,7 @@ export interface IScene {
|
|
|
86
86
|
*/
|
|
87
87
|
export interface ISceneData {
|
|
88
88
|
currentSentenceId: number;
|
|
89
|
-
sceneStack: Array<
|
|
89
|
+
sceneStack: Array<ISceneEntry>;
|
|
90
90
|
currentScene: IScene;
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 语句类型
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { ISceneEntry } from './runtimeInterface';
|
|
5
5
|
import { fileType } from './assets';
|
|
6
6
|
export declare enum commandType {
|
|
7
7
|
say = 0,
|
|
@@ -86,7 +86,7 @@ export interface IScene {
|
|
|
86
86
|
*/
|
|
87
87
|
export interface ISceneData {
|
|
88
88
|
currentSentenceId: number;
|
|
89
|
-
sceneStack: Array<
|
|
89
|
+
sceneStack: Array<ISceneEntry>;
|
|
90
90
|
currentScene: IScene;
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
@@ -127,10 +127,10 @@ var webgalParser = (function (exports) {
|
|
|
127
127
|
});
|
|
128
128
|
rawArgsList.forEach((e) => {
|
|
129
129
|
const equalSignIndex = e.indexOf('=');
|
|
130
|
-
let argName = e.slice(0, equalSignIndex);
|
|
131
|
-
let argValue = e.slice(equalSignIndex + 1);
|
|
130
|
+
let argName = e.slice(0, equalSignIndex).trim();
|
|
131
|
+
let argValue = e.slice(equalSignIndex + 1).trim();
|
|
132
132
|
if (equalSignIndex < 0) {
|
|
133
|
-
argName = e;
|
|
133
|
+
argName = e.trim();
|
|
134
134
|
argValue = undefined;
|
|
135
135
|
}
|
|
136
136
|
// 判断是不是语音参数
|
|
@@ -446,14 +446,16 @@ var webgalParser = (function (exports) {
|
|
|
446
446
|
let commandRaw;
|
|
447
447
|
// 正式开始解析
|
|
448
448
|
// 去分号
|
|
449
|
-
|
|
449
|
+
const commentSplit = sentenceRaw.split(/(?<!\\);/);
|
|
450
|
+
let newSentenceRaw = commentSplit[0].trim();
|
|
450
451
|
newSentenceRaw = newSentenceRaw.replaceAll('\\;', ';');
|
|
452
|
+
const sentenceComment = commentSplit[1] ?? '';
|
|
451
453
|
if (newSentenceRaw === '') {
|
|
452
454
|
// 注释提前返回
|
|
453
455
|
return {
|
|
454
456
|
command: commandType.comment,
|
|
455
457
|
commandRaw: 'comment',
|
|
456
|
-
content:
|
|
458
|
+
content: sentenceComment.trim(),
|
|
457
459
|
args: [{ key: 'next', value: true }],
|
|
458
460
|
sentenceAssets: [],
|
|
459
461
|
subScene: [], // 语句携带的子场景
|
|
@@ -1770,7 +1772,7 @@ var webgalParser = (function (exports) {
|
|
|
1770
1772
|
* @return {IScene} 解析后的场景
|
|
1771
1773
|
*/
|
|
1772
1774
|
const sceneParser = (rawScene, sceneName, sceneUrl, assetsPrefetcher, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP) => {
|
|
1773
|
-
const rawSentenceList = rawScene.split('\n'); // 原始句子列表
|
|
1775
|
+
const rawSentenceList = rawScene.replaceAll('\r', '').split('\n'); // 原始句子列表
|
|
1774
1776
|
// 去分号留到后面去做了,现在注释要单独处理
|
|
1775
1777
|
const rawSentenceListWithoutEmpty = rawSentenceList;
|
|
1776
1778
|
// .map((sentence) => sentence.split(";")[0])
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webgal-parser",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.16",
|
|
4
4
|
"description": "WebGAL script parser",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "vitest",
|
|
7
7
|
"coverage": "vitest run --coverage",
|
|
8
8
|
"build": "rimraf -rf ./build && rollup --config",
|
|
9
|
+
"prepublishOnly": "npm run build",
|
|
9
10
|
"build-ci": "rollup --config",
|
|
10
11
|
"debug": "tsx test/debug.ts",
|
|
11
12
|
"debug-scss-parser": "tsx test/debugCssParser.ts",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 语句类型
|
|
3
3
|
*/
|
|
4
|
-
import { sceneEntry } from './runtimeInterface';
|
|
4
|
+
import { sceneEntry, ISceneEntry } from './runtimeInterface';
|
|
5
5
|
import { fileType } from './assets';
|
|
6
6
|
|
|
7
7
|
export enum commandType {
|
|
@@ -38,7 +38,7 @@ export enum commandType {
|
|
|
38
38
|
setTransition,
|
|
39
39
|
getUserInput,
|
|
40
40
|
applyStyle,
|
|
41
|
-
wait
|
|
41
|
+
wait,
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -92,7 +92,7 @@ export interface IScene {
|
|
|
92
92
|
*/
|
|
93
93
|
export interface ISceneData {
|
|
94
94
|
currentSentenceId: number; // 当前语句ID
|
|
95
|
-
sceneStack: Array<
|
|
95
|
+
sceneStack: Array<ISceneEntry>; // 场景栈
|
|
96
96
|
currentScene: IScene; // 当前场景数据
|
|
97
97
|
}
|
|
98
98
|
|
package/src/sceneParser.ts
CHANGED
|
@@ -29,7 +29,7 @@ export const sceneParser = (
|
|
|
29
29
|
ADD_NEXT_ARG_LIST: commandType[],
|
|
30
30
|
SCRIPT_CONFIG_MAP: ConfigMap,
|
|
31
31
|
): IScene => {
|
|
32
|
-
const rawSentenceList = rawScene.split('\n'); // 原始句子列表
|
|
32
|
+
const rawSentenceList = rawScene.replaceAll('\r', '').split('\n'); // 原始句子列表
|
|
33
33
|
|
|
34
34
|
// 去分号留到后面去做了,现在注释要单独处理
|
|
35
35
|
const rawSentenceListWithoutEmpty = rawSentenceList;
|
|
@@ -23,10 +23,10 @@ export function argsParser(
|
|
|
23
23
|
});
|
|
24
24
|
rawArgsList.forEach((e) => {
|
|
25
25
|
const equalSignIndex = e.indexOf('=');
|
|
26
|
-
let argName = e.slice(0, equalSignIndex);
|
|
27
|
-
let argValue: string | undefined = e.slice(equalSignIndex + 1);
|
|
26
|
+
let argName = e.slice(0, equalSignIndex).trim();
|
|
27
|
+
let argValue: string | undefined = e.slice(equalSignIndex + 1).trim();
|
|
28
28
|
if (equalSignIndex < 0) {
|
|
29
|
-
argName = e;
|
|
29
|
+
argName = e.trim();
|
|
30
30
|
argValue = undefined;
|
|
31
31
|
}
|
|
32
32
|
// 判断是不是语音参数
|
|
@@ -36,14 +36,16 @@ export const scriptParser = (
|
|
|
36
36
|
// 正式开始解析
|
|
37
37
|
|
|
38
38
|
// 去分号
|
|
39
|
-
|
|
39
|
+
const commentSplit = sentenceRaw.split(/(?<!\\);/);
|
|
40
|
+
let newSentenceRaw = commentSplit[0].trim();
|
|
40
41
|
newSentenceRaw = newSentenceRaw.replaceAll('\\;',';');
|
|
42
|
+
const sentenceComment = commentSplit[1] ?? '';
|
|
41
43
|
if (newSentenceRaw === '') {
|
|
42
44
|
// 注释提前返回
|
|
43
45
|
return {
|
|
44
46
|
command: commandType.comment, // 语句类型
|
|
45
47
|
commandRaw: 'comment', // 命令原始内容,方便调试
|
|
46
|
-
content:
|
|
48
|
+
content: sentenceComment.trim(), // 语句内容
|
|
47
49
|
args: [{ key: 'next', value: true }], // 参数列表
|
|
48
50
|
sentenceAssets: [], // 语句携带的资源列表
|
|
49
51
|
subScene: [], // 语句携带的子场景
|