hzengine-core 0.1.2-dev → 0.1.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.
- package/dist/async/index.js +150 -162
- package/dist/audio/index.js +249 -260
- package/dist/config/index.js +57 -57
- package/dist/debug/index.js +9 -8
- package/dist/index.js +108 -103
- package/dist/plugins/basic_command/img.js +247 -249
- package/dist/plugins/basic_command/menu.js +140 -140
- package/dist/plugins/transform/animation.js +430 -440
- package/dist/plugins/transform/hz_anime.js +196 -211
- package/dist/plugins/transform/index.js +94 -93
- package/dist/script/index.js +537 -537
- package/dist/storage/index.js +447 -440
- package/dist/system/index.js +131 -144
- package/dist/ui/index.js +525 -535
- package/package.json +1 -1
- package/src/platform/index.ts +14 -12
- package/src/plugins/transform/animation.ts +1 -1
- package/src/script/index.ts +13 -0
- package/src/storage/index.ts +47 -47
- package/tsconfig.json +1 -1
- package/types/platform/index.d.ts +137 -134
- package/types/script/index.d.ts +129 -123
- package/types/script/strtools.d.ts +31 -31
package/types/script/index.d.ts
CHANGED
|
@@ -1,123 +1,129 @@
|
|
|
1
|
-
import { HZEngineCore } from "../index.js";
|
|
2
|
-
import { Storage } from "../storage/index.js";
|
|
3
|
-
import { mergeObjs2Str as joinObjs2Str, splitStr2Objs } from "./strtools.js";
|
|
4
|
-
export declare class Script {
|
|
5
|
-
_core: HZEngineCore;
|
|
6
|
-
constructor(_core: HZEngineCore);
|
|
7
|
-
/**
|
|
8
|
-
* 调用栈
|
|
9
|
-
* 在call时保存当前执行位置和语句栈,在return时恢复执行位置和语句栈
|
|
10
|
-
*/
|
|
11
|
-
private accessor _callStack;
|
|
12
|
-
/**
|
|
13
|
-
* 语句栈
|
|
14
|
-
* 比如while, if,会在语句开始时入栈,语句结束时出栈
|
|
15
|
-
*/
|
|
16
|
-
private accessor _statementStack;
|
|
17
|
-
/**
|
|
18
|
-
* 下一次执行的脚本位置
|
|
19
|
-
* 注意:存储该值的时候应总是拷贝赋值而非直接引用赋值
|
|
20
|
-
*/
|
|
21
|
-
private accessor _nextRunPosition;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
private
|
|
48
|
-
|
|
49
|
-
private
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
export
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
type
|
|
123
|
-
|
|
1
|
+
import { HZEngineCore } from "../index.js";
|
|
2
|
+
import { Storage } from "../storage/index.js";
|
|
3
|
+
import { mergeObjs2Str as joinObjs2Str, splitStr2Objs } from "./strtools.js";
|
|
4
|
+
export declare class Script {
|
|
5
|
+
_core: HZEngineCore;
|
|
6
|
+
constructor(_core: HZEngineCore);
|
|
7
|
+
/**
|
|
8
|
+
* 调用栈
|
|
9
|
+
* 在call时保存当前执行位置和语句栈,在return时恢复执行位置和语句栈
|
|
10
|
+
*/
|
|
11
|
+
private accessor _callStack;
|
|
12
|
+
/**
|
|
13
|
+
* 语句栈
|
|
14
|
+
* 比如while, if,会在语句开始时入栈,语句结束时出栈
|
|
15
|
+
*/
|
|
16
|
+
private accessor _statementStack;
|
|
17
|
+
/**
|
|
18
|
+
* 下一次执行的脚本位置
|
|
19
|
+
* 注意:存储该值的时候应总是拷贝赋值而非直接引用赋值
|
|
20
|
+
*/
|
|
21
|
+
private accessor _nextRunPosition;
|
|
22
|
+
get nextRunPosition(): [path: string, index: number] | null;
|
|
23
|
+
/**
|
|
24
|
+
* 当前正在执行的命令内容
|
|
25
|
+
*/
|
|
26
|
+
private _currentRawCommand;
|
|
27
|
+
get currentRawCommand(): string;
|
|
28
|
+
/**
|
|
29
|
+
* 执行_nextRunPosition,并返回下一行_nextRunPosition是否不为null
|
|
30
|
+
*/
|
|
31
|
+
runSingleLine(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* 跳转到目标标签
|
|
34
|
+
* @param targetLabel
|
|
35
|
+
*/
|
|
36
|
+
jumpLabel(targetLabel: string): void;
|
|
37
|
+
jump(path: string, index: number, clearStatementStack?: boolean): void;
|
|
38
|
+
/**
|
|
39
|
+
* 调用目标标签
|
|
40
|
+
* 保存当前执行位置至调用栈,跳转到目标位置,直到return返回
|
|
41
|
+
* @param targetLabel
|
|
42
|
+
*/
|
|
43
|
+
callLabel(targetLabel: string): void;
|
|
44
|
+
hasLabel(targetLabel: string): boolean;
|
|
45
|
+
return(): void;
|
|
46
|
+
clear(): void;
|
|
47
|
+
private _locateLabel;
|
|
48
|
+
incrementNextPosition(): void;
|
|
49
|
+
private _middlewares;
|
|
50
|
+
use(middleware: Script.Middleware, add_front?: boolean): void;
|
|
51
|
+
private _processCmd;
|
|
52
|
+
private _processUnsolvedCmd;
|
|
53
|
+
private _buildContext;
|
|
54
|
+
private _statementAnalyseStack;
|
|
55
|
+
private _analyseStatementMiddlewares;
|
|
56
|
+
private _buildAnalyseStatementContext;
|
|
57
|
+
useAnalyseStatement(middleware: Script.MiddlewareForAnalyseStatement, add_front?: boolean): void;
|
|
58
|
+
/**
|
|
59
|
+
* 分析statement
|
|
60
|
+
*
|
|
61
|
+
* Analyze the statement syntax and record the script point location and related information in advance.
|
|
62
|
+
* When the script executes a statement, the regular middleware corresponding to that statement will load
|
|
63
|
+
* the information saved by analyseStatement before the statement, and if there is no analysis, it will call
|
|
64
|
+
* analyseStatement to analyze, and the corresponding analysis middleware will process and save the information.
|
|
65
|
+
* After analysis is complete, reset _nextRunPosition to the location before the call, switch back to the normal mode,
|
|
66
|
+
* and continue executing.
|
|
67
|
+
*/
|
|
68
|
+
analyseStatement(ctx: Script.Context): void;
|
|
69
|
+
evalScope(code: string): any;
|
|
70
|
+
evalExpression(code: string): any;
|
|
71
|
+
parseString(str: string): string;
|
|
72
|
+
}
|
|
73
|
+
export declare namespace Script {
|
|
74
|
+
type Middleware = (ctx: Context, next: () => void) => void;
|
|
75
|
+
class Context {
|
|
76
|
+
protected _core: HZEngineCore;
|
|
77
|
+
private _rawtext;
|
|
78
|
+
readonly currentPath: string;
|
|
79
|
+
readonly currentLineIndex: number;
|
|
80
|
+
private _statementStack;
|
|
81
|
+
constructor(_core: HZEngineCore, _rawtext: string, currentPath: string, currentLineIndex: number, _statementStack: StatementStack);
|
|
82
|
+
get rawtext(): string;
|
|
83
|
+
set rawtext(rawtext: string);
|
|
84
|
+
private _rawtextChanged;
|
|
85
|
+
private _slicedArgs;
|
|
86
|
+
get slicedArgs(): Context.SlicedArg[];
|
|
87
|
+
set slicedArgs(slicedArgs: Context.SlicedArg[]);
|
|
88
|
+
/**
|
|
89
|
+
* 開始一個新的Statement,返回該Statement的數據
|
|
90
|
+
* Start a new statement and return the data of the new statement
|
|
91
|
+
* @param identifier the identifier of the statement
|
|
92
|
+
* @returns the data of the new statement
|
|
93
|
+
*/
|
|
94
|
+
startStatement(identifier: string, data?: Storage.Saveable<unknown>): StatementData;
|
|
95
|
+
endStatement(identifier: string): NonNullable<Storage.Saveable<unknown>>;
|
|
96
|
+
get statementStack(): StatementStack;
|
|
97
|
+
getStatementData(): NonNullable<Storage.Saveable<unknown>>;
|
|
98
|
+
setStatementData(statement_data: NonNullable<Storage.Saveable<unknown>>, start_position: [path: string, index: number]): void;
|
|
99
|
+
}
|
|
100
|
+
namespace Utils {
|
|
101
|
+
export const joinSlicedArgs: typeof joinObjs2Str;
|
|
102
|
+
export const splitRawtext: typeof splitStr2Objs;
|
|
103
|
+
export function splitCommas(rawtext: string): string[];
|
|
104
|
+
export function parseTuple(rawtext: string): TupleOrArr;
|
|
105
|
+
export function parseArray(rawtext: string): TupleOrArr;
|
|
106
|
+
export function parseHzsArgs(rawtext: string): TupleOrArr;
|
|
107
|
+
type TupleOrArr = (string | TupleOrArr)[];
|
|
108
|
+
export {};
|
|
109
|
+
}
|
|
110
|
+
type MiddlewareForAnalyseStatement = (ctx: ContextForAnalyseStatement, next: () => void) => void;
|
|
111
|
+
class ContextForAnalyseStatement extends Context {
|
|
112
|
+
startStatement(identifier: string, data?: Storage.Saveable<unknown>): StatementData;
|
|
113
|
+
endStatement(identifier: string): NonNullable<Storage.Saveable<unknown>>;
|
|
114
|
+
}
|
|
115
|
+
namespace Context {
|
|
116
|
+
interface SlicedArg {
|
|
117
|
+
str: string;
|
|
118
|
+
isQuoted?: boolean;
|
|
119
|
+
isSquared?: boolean;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
type StatementStackItem = [
|
|
123
|
+
identifier: string,
|
|
124
|
+
start_position: [path: string, index: number],
|
|
125
|
+
statement_data: Storage.JSONValue
|
|
126
|
+
];
|
|
127
|
+
type StatementStack = StatementStackItem[];
|
|
128
|
+
type StatementData = NonNullable<Storage.JSONValue>;
|
|
129
|
+
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 将一行字符串切割为(str,quoted)[]的形式
|
|
3
|
-
* @param str
|
|
4
|
-
* @returns
|
|
5
|
-
*/
|
|
6
|
-
export declare function splitStr2Objs(str: string): {
|
|
7
|
-
str: string;
|
|
8
|
-
isQuoted?: boolean;
|
|
9
|
-
isSquared?: boolean;
|
|
10
|
-
isRounded?: boolean;
|
|
11
|
-
}[];
|
|
12
|
-
export declare function mergeObjs2Str(objs: {
|
|
13
|
-
str: string;
|
|
14
|
-
isQuoted?: boolean;
|
|
15
|
-
isSquared?: boolean;
|
|
16
|
-
isRounded?: boolean;
|
|
17
|
-
}[]): string;
|
|
18
|
-
export declare function splitStr2Strs(str: string): string[];
|
|
19
|
-
/**
|
|
20
|
-
* 转义一遍字符串,使其中\n等变成对应字符(可能报错)
|
|
21
|
-
* @param str
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
export declare function transformStr(str: string): any;
|
|
25
|
-
export declare function parseInterpolatedStr(str: string): ParsedInterpolationItem[];
|
|
26
|
-
export declare function removeComment(str: string): string;
|
|
27
|
-
type ParsedInterpolationItem = {
|
|
28
|
-
str: string;
|
|
29
|
-
isExpression: boolean;
|
|
30
|
-
};
|
|
31
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* 将一行字符串切割为(str,quoted)[]的形式
|
|
3
|
+
* @param str
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
export declare function splitStr2Objs(str: string): {
|
|
7
|
+
str: string;
|
|
8
|
+
isQuoted?: boolean | undefined;
|
|
9
|
+
isSquared?: boolean | undefined;
|
|
10
|
+
isRounded?: boolean | undefined;
|
|
11
|
+
}[];
|
|
12
|
+
export declare function mergeObjs2Str(objs: {
|
|
13
|
+
str: string;
|
|
14
|
+
isQuoted?: boolean;
|
|
15
|
+
isSquared?: boolean;
|
|
16
|
+
isRounded?: boolean;
|
|
17
|
+
}[]): string;
|
|
18
|
+
export declare function splitStr2Strs(str: string): string[];
|
|
19
|
+
/**
|
|
20
|
+
* 转义一遍字符串,使其中\n等变成对应字符(可能报错)
|
|
21
|
+
* @param str
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
export declare function transformStr(str: string): any;
|
|
25
|
+
export declare function parseInterpolatedStr(str: string): ParsedInterpolationItem[];
|
|
26
|
+
export declare function removeComment(str: string): string;
|
|
27
|
+
type ParsedInterpolationItem = {
|
|
28
|
+
str: string;
|
|
29
|
+
isExpression: boolean;
|
|
30
|
+
};
|
|
31
|
+
export {};
|