hzengine-core 0.1.2-dev

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 (103) hide show
  1. package/dist/async/index.js +162 -0
  2. package/dist/async/zeppos_timer.js +58 -0
  3. package/dist/audio/index.js +260 -0
  4. package/dist/config/index.js +57 -0
  5. package/dist/debug/index.js +8 -0
  6. package/dist/index.js +103 -0
  7. package/dist/platform/index.js +1 -0
  8. package/dist/plugins/basic_command/$.js +8 -0
  9. package/dist/plugins/basic_command/audio.js +40 -0
  10. package/dist/plugins/basic_command/basic.js +124 -0
  11. package/dist/plugins/basic_command/character.js +112 -0
  12. package/dist/plugins/basic_command/conditional.js +260 -0
  13. package/dist/plugins/basic_command/config.js +22 -0
  14. package/dist/plugins/basic_command/decorator.js +24 -0
  15. package/dist/plugins/basic_command/eval.js +67 -0
  16. package/dist/plugins/basic_command/img.js +249 -0
  17. package/dist/plugins/basic_command/index.js +22 -0
  18. package/dist/plugins/basic_command/menu.js +140 -0
  19. package/dist/plugins/global_gesture/index.js +25 -0
  20. package/dist/plugins/transform/animation.js +440 -0
  21. package/dist/plugins/transform/commands.js +38 -0
  22. package/dist/plugins/transform/example_profiles.js +32 -0
  23. package/dist/plugins/transform/hz_anime.js +211 -0
  24. package/dist/plugins/transform/index.js +93 -0
  25. package/dist/script/index.js +537 -0
  26. package/dist/script/readscript.js +15 -0
  27. package/dist/script/strtools.js +157 -0
  28. package/dist/storage/decorator.js +260 -0
  29. package/dist/storage/fs.js +96 -0
  30. package/dist/storage/index.js +442 -0
  31. package/dist/system/index.js +144 -0
  32. package/dist/ui/index.js +535 -0
  33. package/dist/utils/path.js +289 -0
  34. package/license.txt +202 -0
  35. package/package.json +26 -0
  36. package/src/async/index.ts +124 -0
  37. package/src/async/zeppos_timer.js +65 -0
  38. package/src/audio/index.ts +224 -0
  39. package/src/config/index.ts +80 -0
  40. package/src/debug/index.ts +11 -0
  41. package/src/index.ts +122 -0
  42. package/src/platform/index.ts +158 -0
  43. package/src/plugins/basic_command/$.ts +11 -0
  44. package/src/plugins/basic_command/audio.ts +53 -0
  45. package/src/plugins/basic_command/basic.ts +145 -0
  46. package/src/plugins/basic_command/character.ts +144 -0
  47. package/src/plugins/basic_command/conditional.ts +349 -0
  48. package/src/plugins/basic_command/config.ts +29 -0
  49. package/src/plugins/basic_command/decorator.ts +29 -0
  50. package/src/plugins/basic_command/eval.ts +88 -0
  51. package/src/plugins/basic_command/img.ts +317 -0
  52. package/src/plugins/basic_command/index.ts +24 -0
  53. package/src/plugins/basic_command/menu.ts +178 -0
  54. package/src/plugins/global_gesture/index.ts +29 -0
  55. package/src/plugins/transform/animation.ts +542 -0
  56. package/src/plugins/transform/commands.ts +53 -0
  57. package/src/plugins/transform/example_profiles.ts +36 -0
  58. package/src/plugins/transform/hz_anime.ts +214 -0
  59. package/src/plugins/transform/index.ts +141 -0
  60. package/src/plugins/transform/readme.md +1 -0
  61. package/src/script/index.ts +623 -0
  62. package/src/script/readscript.ts +17 -0
  63. package/src/script/strtools.ts +159 -0
  64. package/src/storage/decorator.ts +473 -0
  65. package/src/storage/fs.ts +104 -0
  66. package/src/storage/index.ts +541 -0
  67. package/src/system/index.ts +95 -0
  68. package/src/ui/index.ts +699 -0
  69. package/src/utils/path.js +338 -0
  70. package/tsconfig.json +111 -0
  71. package/types/async/index.d.ts +24 -0
  72. package/types/async/zeppos_timer.d.ts +14 -0
  73. package/types/audio/index.d.ts +64 -0
  74. package/types/config/index.d.ts +9 -0
  75. package/types/debug/index.d.ts +6 -0
  76. package/types/index.d.ts +41 -0
  77. package/types/platform/index.d.ts +134 -0
  78. package/types/plugins/basic_command/$.d.ts +2 -0
  79. package/types/plugins/basic_command/audio.d.ts +2 -0
  80. package/types/plugins/basic_command/basic.d.ts +3 -0
  81. package/types/plugins/basic_command/character.d.ts +2 -0
  82. package/types/plugins/basic_command/conditional.d.ts +2 -0
  83. package/types/plugins/basic_command/config.d.ts +2 -0
  84. package/types/plugins/basic_command/decorator.d.ts +2 -0
  85. package/types/plugins/basic_command/eval.d.ts +2 -0
  86. package/types/plugins/basic_command/img.d.ts +2 -0
  87. package/types/plugins/basic_command/index.d.ts +2 -0
  88. package/types/plugins/basic_command/menu.d.ts +2 -0
  89. package/types/plugins/global_gesture/index.d.ts +2 -0
  90. package/types/plugins/transform/animation.d.ts +131 -0
  91. package/types/plugins/transform/commands.d.ts +7 -0
  92. package/types/plugins/transform/example_profiles.d.ts +2 -0
  93. package/types/plugins/transform/hz_anime.d.ts +51 -0
  94. package/types/plugins/transform/index.d.ts +13 -0
  95. package/types/script/index.d.ts +123 -0
  96. package/types/script/readscript.d.ts +2 -0
  97. package/types/script/strtools.d.ts +31 -0
  98. package/types/storage/decorator.d.ts +41 -0
  99. package/types/storage/fs.d.ts +1 -0
  100. package/types/storage/index.d.ts +86 -0
  101. package/types/system/index.d.ts +35 -0
  102. package/types/ui/index.d.ts +167 -0
  103. package/types/utils/path.d.ts +84 -0
@@ -0,0 +1,134 @@
1
+ export interface Platform<WidgetFactory = any> {
2
+ name: string;
3
+ getScreenSize(): [width: number, height: number];
4
+ createUILayer({ z_index }: {
5
+ z_index: number;
6
+ }): WidgetFactory;
7
+ deleteUILayer(widgetFactory: WidgetFactory): void;
8
+ isFileSync({ path }: {
9
+ path: string;
10
+ }): boolean;
11
+ readdirSync(option: Platform.readdirSync.Option): Platform.readdirSync.Result;
12
+ statSync(option: Platform.statSync.Option): Platform.statSync.Result;
13
+ readFileSync(option: Platform.readFileSync.Option): Platform.readFileSync.Result;
14
+ writeFileSync(option: Platform.writeFileSync.Option): void;
15
+ getImageInfo(img_path: string): {
16
+ width: number;
17
+ height: number;
18
+ };
19
+ getTime(): number;
20
+ createAudioPlayer(): Platform.AudioPlayer;
21
+ releaseAudioPlayer(audio_player: Platform.AudioPlayer): void;
22
+ setFrameInterval(callback: () => void): void;
23
+ }
24
+ export declare namespace Platform {
25
+ interface AudioPlayer {
26
+ onPrepared?: (success: boolean) => void | undefined;
27
+ onCompleted?: () => void | undefined;
28
+ prepare(): void;
29
+ start(): void;
30
+ stop(): void;
31
+ release(): void;
32
+ getMediaInfo(): MediaInfo;
33
+ setSource({ path }: {
34
+ path: string;
35
+ }): void;
36
+ }
37
+ interface MediaInfo {
38
+ title: string | undefined;
39
+ artist: string | undefined;
40
+ duration: number;
41
+ }
42
+ namespace readdirSync {
43
+ interface Option {
44
+ /**
45
+ * @zh 目录路径
46
+ * @en Directory path
47
+ */
48
+ path: string;
49
+ }
50
+ /**
51
+ * @zh 如果返回 `undefined` 则目录不存在,否则返回文件名数组
52
+ * @en If `undefined` is returned, the directory does not exist, otherwise an array of filenames is returned
53
+ */
54
+ type Result = Array<string> | undefined;
55
+ }
56
+ namespace statSync {
57
+ interface Option {
58
+ /**
59
+ * @zh 路径
60
+ * @en path
61
+ */
62
+ path: string;
63
+ }
64
+ /**
65
+ * @zh 如果返回 `undefined` 则目标文件不存在,否则返回文件信息对象
66
+ * @en If `undefined` is returned, the target file does not exist, otherwise the file information object is returned
67
+ */
68
+ type Result = FSStat | undefined;
69
+ /**
70
+ * @output
71
+ */
72
+ interface FSStat {
73
+ /**
74
+ * @zh 文件大小(单位为字节)
75
+ * @en The size of the file in bytes
76
+ */
77
+ size: number;
78
+ }
79
+ }
80
+ namespace readFileSync {
81
+ interface Option {
82
+ /**
83
+ * @zh 文件路径
84
+ * @en path
85
+ */
86
+ path: string;
87
+ /**
88
+ * @zh 其他选项
89
+ * @en Other Options
90
+ */
91
+ options?: Options;
92
+ }
93
+ interface Options {
94
+ /**
95
+ * @zh 当指定了编码方式之后,API 返回结果为 `string`
96
+ * @en When the encoding method is specified, the API returns `string` as the result
97
+ */
98
+ encoding?: string;
99
+ }
100
+ /**
101
+ * @zh 文件内容。如果返回 `undefined`,则表明读取文件失败
102
+ * @en File content. If `undefined` is returned, the file failed to be read
103
+ */
104
+ type Result = ArrayBuffer | string | undefined;
105
+ }
106
+ namespace writeFileSync {
107
+ interface Option {
108
+ /**
109
+ * @zh 文件路径或者文件句柄
110
+ * @en File path or file descriptor
111
+ */
112
+ path: string | number;
113
+ /**
114
+ * @zh 写入目标文件的数据
115
+ * @en Data to be written to the target file
116
+ */
117
+ data: ArrayBuffer | string | DataView;
118
+ /**
119
+ * @zh 其他选项
120
+ * @en Other Options
121
+ */
122
+ options?: Options;
123
+ }
124
+ interface Options {
125
+ /**
126
+ * @zh 如果数据格式为 `string`,需要指定编码方式
127
+ * @en If the `data` format is `string`, you need to specify the encoding method
128
+ * @defaultValue utf8
129
+ */
130
+ encoding?: string;
131
+ }
132
+ }
133
+ }
134
+ export default Platform;
@@ -0,0 +1,2 @@
1
+ import { HZEngineCore } from "../../index.js";
2
+ export declare function $_command(core: HZEngineCore): void;
@@ -0,0 +1,2 @@
1
+ import { HZEngineCore } from "../../index.js";
2
+ export declare function audio_command(core: HZEngineCore): void;
@@ -0,0 +1,3 @@
1
+ import { HZEngineCore } from "../../index.js";
2
+ export declare function basic_commands(core: HZEngineCore): void;
3
+ export declare function sayAction(core: HZEngineCore, who: string, what: string, wait: boolean): void;
@@ -0,0 +1,2 @@
1
+ import { HZEngineCore } from "../../index.js";
2
+ export declare function character_command(core: HZEngineCore): void;
@@ -0,0 +1,2 @@
1
+ import { HZEngineCore } from "../../index.js";
2
+ export declare function conditional(core: HZEngineCore): void;
@@ -0,0 +1,2 @@
1
+ import { HZEngineCore } from "../../index.js";
2
+ export declare function config_command(core: HZEngineCore): void;
@@ -0,0 +1,2 @@
1
+ import { HZEngineCore } from "../../index.js";
2
+ export declare function decorator_module(core: HZEngineCore): void;
@@ -0,0 +1,2 @@
1
+ import { HZEngineCore } from "../../index.js";
2
+ export declare function eval_module(core: HZEngineCore): void;
@@ -0,0 +1,2 @@
1
+ import { HZEngineCore } from "../../index.js";
2
+ export declare function img(core: HZEngineCore): void;
@@ -0,0 +1,2 @@
1
+ import { HZEngineCore } from "../../index.js";
2
+ export declare function basic_command(core: HZEngineCore): void;
@@ -0,0 +1,2 @@
1
+ import { HZEngineCore } from "../../index.js";
2
+ export declare function menu_statement(core: HZEngineCore): void;
@@ -0,0 +1,2 @@
1
+ import { HZEngineCore } from "../../index.js";
2
+ export declare function global_gesture(core: HZEngineCore): void;
@@ -0,0 +1,131 @@
1
+ /**
2
+ * animation.js
3
+ * @description A library for providing multi-track animations for HZEngine. 一个用于在HZEngine中提供简单动画的库
4
+ * @date 2024/10/2
5
+ * @author CuberQAQ
6
+ */
7
+ export declare class Animation<P extends Profile.PropsType = unknown> {
8
+ normalizedProfile: Profile.Track<P>;
9
+ initProps: Partial<P>;
10
+ activeRootTrack: ActiveTrackNode<P> | null;
11
+ lastTime: number;
12
+ onFrame: ((props: Partial<P>) => void) | null;
13
+ onEnd: (() => void) | null;
14
+ customWrappers: Record<string, Wrapper>;
15
+ constructor(profile: Profile<P>, options?: Animation.Options<P>);
16
+ onStop: ((animation: Animation<P>) => void) | null;
17
+ serialize(): Animation.Serialized;
18
+ static unserialize(serialized: Animation.Serialized, wrappers?: Record<string, Wrapper>): Animation<unknown>;
19
+ timerCb(): void;
20
+ init(): void;
21
+ goto(time: number): void;
22
+ step(delta_time: number): void;
23
+ calcProps(): Partial<P>;
24
+ reverse(): void;
25
+ stop(): void;
26
+ _accessProfile(accessKeys: string[]): unknown;
27
+ _getWrapper(wrapper: string | Wrapper | undefined): Wrapper;
28
+ _calcWrappedProps<P extends Profile.PropsType>(former_props: Partial<P>, props: Partial<P>, wrapper: Wrapper | string | undefined, progress: number): Partial<P>;
29
+ }
30
+ export declare namespace Animation {
31
+ interface Options<P extends Profile.PropsType> {
32
+ initProps?: Partial<P>;
33
+ wrappers?: Record<string, Wrapper>;
34
+ }
35
+ interface Serialized {
36
+ normalizedProfile: Profile.Serialized;
37
+ initProps?: Partial<unknown>;
38
+ activeRootTrack?: ActiveTrackNode.Serialized;
39
+ lastTime: number;
40
+ }
41
+ }
42
+ export type Profile<P extends Profile.PropsType = unknown> = Profile.Section<P> | Profile.Track<P> | Profile.TrackList<P>;
43
+ export declare namespace Profile {
44
+ type Serialized = Profile;
45
+ type TrackList<P extends PropsType> = Track<P>[];
46
+ type Track<P extends PropsType> = Section<P>[];
47
+ type Section<P extends PropsType> = {
48
+ time?: number;
49
+ repeat?: number;
50
+ wrapper?: keyof typeof buildInWrappers | string | Wrapper;
51
+ frame?: Partial<P>;
52
+ syncs?: Profile<P>[];
53
+ asyncs?: Profile<P>[];
54
+ };
55
+ type FrameItem = number | boolean | string;
56
+ type PropsType = Record<string, FrameItem> | unknown;
57
+ function normalize<P extends PropsType>(profile: Profile<P>): Track<P>;
58
+ }
59
+ export interface Timer<TimerIdType> {
60
+ init(animation: Animation): void;
61
+ setTimeout(timeout?: number): TimerIdType;
62
+ clearTimeout(timerId: TimerIdType): void;
63
+ setInterval(interval?: number): TimerIdType;
64
+ clearInterval(timerId: TimerIdType): void;
65
+ getTime(): number;
66
+ setOption?(option: Timer.Options): void;
67
+ }
68
+ export declare namespace Timer {
69
+ interface Options {
70
+ fps?: number;
71
+ }
72
+ }
73
+ export declare class ActiveTrackNode<P extends Profile.PropsType> {
74
+ #private;
75
+ animation: Animation;
76
+ accessKeys: string[];
77
+ currentIndex: number | null;
78
+ repeated: number;
79
+ status: ActiveTrackNode.Status;
80
+ now_time: number;
81
+ get currentSection(): Profile.Section<P>;
82
+ get currentTrack(): Profile.Track<P> | null;
83
+ lastProps: Partial<P>;
84
+ nowProps: Partial<P>;
85
+ constructor(animation: Animation, { accessKeys, index, initProps, }: {
86
+ accessKeys: string[];
87
+ index: number | null;
88
+ initProps: Partial<P>;
89
+ });
90
+ serialize(): ActiveTrackNode.Serialized;
91
+ static unserialize<P>(animation: Animation, serialized: ActiveTrackNode.Serialized): ActiveTrackNode<P>;
92
+ /**
93
+ *
94
+ * @param delta_time
95
+ * @returns 剩餘的時間
96
+ */
97
+ step(delta_time: number): number;
98
+ calcProps(): Partial<P>;
99
+ _switchNextSection(): boolean;
100
+ activeSyncs: ActiveTrackNode<P>[];
101
+ initSyncs(): void;
102
+ stepSyncs(delta_time: number): number;
103
+ checkSyncsFinished(): boolean;
104
+ getSyncsProps(): Partial<P>;
105
+ }
106
+ export declare namespace ActiveTrackNode {
107
+ enum Status {
108
+ Playing = 0,
109
+ WaitingSyncs = 1,
110
+ Pause = 2
111
+ }
112
+ interface Serialized {
113
+ accessKeys: string[];
114
+ currentIndex: number | null;
115
+ repeated: number;
116
+ status: ActiveTrackNode.Status;
117
+ now_time: number;
118
+ lastProps: Partial<unknown>;
119
+ nowProps: Partial<unknown>;
120
+ activeSyncs: ActiveTrackNode.Serialized[];
121
+ }
122
+ }
123
+ export type Wrapper = (x: number) => number;
124
+ declare const buildInWrappers: {
125
+ none: (x: number) => 0 | 1;
126
+ linear: (x: number) => number;
127
+ easeout: (x: number) => number;
128
+ easein: (x: number) => number;
129
+ easeinout: (x: number) => number;
130
+ };
131
+ export {};
@@ -0,0 +1,7 @@
1
+ import { HZEngineCore } from "../../index.js";
2
+ export declare function registerHzscriptCommands(core: HZEngineCore): void;
3
+ export declare function getTransitionMap(core: HZEngineCore): Record<string, TransitionData>;
4
+ export type TransitionData = {
5
+ inTransforms: string[];
6
+ outTransforms: string[];
7
+ };
@@ -0,0 +1,2 @@
1
+ import { Profile } from "./animation.js";
2
+ export declare const ExampleProfile1: Profile;
@@ -0,0 +1,51 @@
1
+ import { HZEngineCore, Storage, UI } from "../../index.js";
2
+ import { Animation, Profile, Wrapper } from "./animation.js";
3
+ export declare class AnimationPlugin {
4
+ _core: HZEngineCore;
5
+ constructor(_core: HZEngineCore);
6
+ private accessor _nextAnimationId;
7
+ private accessor _animationMap;
8
+ private _lastCbUtc;
9
+ applyAnimation<P extends Profile.PropsType>({ profile, targetView, options, }: {
10
+ profile: Profile<P>;
11
+ targetView: UI.View<Storage.Saveable<unknown>>;
12
+ options?: AnimationPlugin.Options;
13
+ }): number;
14
+ stopAnimation(id: number): void;
15
+ private _nextTempAnimationId;
16
+ _tempAnimationMap: Record<string, Animation>;
17
+ createTempAnimation<P extends Profile.PropsType = unknown>({ profile, onFrame, onEnd, initProps, wrappers, }: {
18
+ profile: Profile<P>;
19
+ onFrame?: (props: Partial<P>) => void;
20
+ onEnd?: () => void;
21
+ initProps?: Partial<P>;
22
+ wrappers?: Record<string, Wrapper>;
23
+ }): number;
24
+ clearTempAnimation(id: number): void;
25
+ private _timerCb;
26
+ private _frameCb;
27
+ private _linkAnimationCb;
28
+ private _endCb;
29
+ }
30
+ declare namespace AnimationPlugin {
31
+ interface Options {
32
+ destroyOnEnd?: boolean;
33
+ isSave?: boolean;
34
+ customWrappers?: Record<string, Wrapper>;
35
+ }
36
+ interface AnimationItem {
37
+ destroyOnEnd: boolean;
38
+ isSave: boolean;
39
+ targetViewId: number;
40
+ instance: Animation;
41
+ }
42
+ namespace AnimationItem {
43
+ interface Serialized {
44
+ destroyOnEnd: boolean;
45
+ isSave: boolean;
46
+ targetViewId: number;
47
+ serializedInstance: Animation.Serialized;
48
+ }
49
+ }
50
+ }
51
+ export {};
@@ -0,0 +1,13 @@
1
+ import { HZEngineCore, Storage, UI } from "../../index.js";
2
+ import { AnimationPlugin } from "./hz_anime.js";
3
+ import { Animation, Profile } from "./animation.js";
4
+ import { TransitionData } from "./commands.js";
5
+ export declare function registerPlugin(core: HZEngineCore): InstanceType;
6
+ export interface InstanceType {
7
+ applyTransform(names: string[], target: UI.View<Storage.Saveable<unknown>>, isSave?: boolean, destroyOnEnd?: boolean): void;
8
+ getProfile(name: string): Profile | null;
9
+ createStrategy(outTransforms: string[] | null, inTransforms: string[] | null): UI.Router.RouteStrategy;
10
+ animationPlugin: AnimationPlugin;
11
+ getTransition(name: string): TransitionData | null;
12
+ }
13
+ export { Animation, Profile, AnimationPlugin };
@@ -0,0 +1,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
+ /**
23
+ * 执行_nextRunPosition,并返回下一行_nextRunPosition是否不为null
24
+ */
25
+ runSingleLine(): boolean;
26
+ /**
27
+ * 跳转到目标标签
28
+ * @param targetLabel
29
+ */
30
+ jumpLabel(targetLabel: string): void;
31
+ jump(path: string, index: number, clearStatementStack?: boolean): void;
32
+ /**
33
+ * 调用目标标签
34
+ * 保存当前执行位置至调用栈,跳转到目标位置,直到return返回
35
+ * @param targetLabel
36
+ */
37
+ callLabel(targetLabel: string): void;
38
+ hasLabel(targetLabel: string): boolean;
39
+ return(): void;
40
+ clear(): void;
41
+ private _locateLabel;
42
+ incrementNextPosition(): void;
43
+ private _middlewares;
44
+ use(middleware: Script.Middleware, add_front?: boolean): void;
45
+ private _processCmd;
46
+ private _processUnsolvedCmd;
47
+ private _buildContext;
48
+ private _statementAnalyseStack;
49
+ private _analyseStatementMiddlewares;
50
+ private _buildAnalyseStatementContext;
51
+ useAnalyseStatement(middleware: Script.MiddlewareForAnalyseStatement, add_front?: boolean): void;
52
+ /**
53
+ * 分析statement
54
+ *
55
+ * Analyze the statement syntax and record the script point location and related information in advance.
56
+ * When the script executes a statement, the regular middleware corresponding to that statement will load
57
+ * the information saved by analyseStatement before the statement, and if there is no analysis, it will call
58
+ * analyseStatement to analyze, and the corresponding analysis middleware will process and save the information.
59
+ * After analysis is complete, reset _nextRunPosition to the location before the call, switch back to the normal mode,
60
+ * and continue executing.
61
+ */
62
+ analyseStatement(ctx: Script.Context): void;
63
+ evalScope(code: string): any;
64
+ evalExpression(code: string): any;
65
+ parseString(str: string): string;
66
+ }
67
+ export declare namespace Script {
68
+ type Middleware = (ctx: Context, next: () => void) => void;
69
+ class Context {
70
+ protected _core: HZEngineCore;
71
+ private _rawtext;
72
+ readonly currentPath: string;
73
+ readonly currentLineIndex: number;
74
+ private _statementStack;
75
+ constructor(_core: HZEngineCore, _rawtext: string, currentPath: string, currentLineIndex: number, _statementStack: StatementStack);
76
+ get rawtext(): string;
77
+ set rawtext(rawtext: string);
78
+ private _rawtextChanged;
79
+ private _slicedArgs;
80
+ get slicedArgs(): Context.SlicedArg[];
81
+ set slicedArgs(slicedArgs: Context.SlicedArg[]);
82
+ /**
83
+ * 開始一個新的Statement,返回該Statement的數據
84
+ * Start a new statement and return the data of the new statement
85
+ * @param identifier the identifier of the statement
86
+ * @returns the data of the new statement
87
+ */
88
+ startStatement(identifier: string, data?: Storage.Saveable<unknown>): StatementData;
89
+ endStatement(identifier: string): NonNullable<Storage.Saveable<unknown>>;
90
+ get statementStack(): StatementStack;
91
+ getStatementData(): NonNullable<Storage.Saveable<unknown>>;
92
+ setStatementData(statement_data: NonNullable<Storage.Saveable<unknown>>, start_position: [path: string, index: number]): void;
93
+ }
94
+ namespace Utils {
95
+ export const joinSlicedArgs: typeof joinObjs2Str;
96
+ export const splitRawtext: typeof splitStr2Objs;
97
+ export function splitCommas(rawtext: string): string[];
98
+ export function parseTuple(rawtext: string): TupleOrArr;
99
+ export function parseArray(rawtext: string): TupleOrArr;
100
+ export function parseHzsArgs(rawtext: string): TupleOrArr;
101
+ type TupleOrArr = (string | TupleOrArr)[];
102
+ export {};
103
+ }
104
+ type MiddlewareForAnalyseStatement = (ctx: ContextForAnalyseStatement, next: () => void) => void;
105
+ class ContextForAnalyseStatement extends Context {
106
+ startStatement(identifier: string, data?: Storage.Saveable<unknown>): StatementData;
107
+ endStatement(identifier: string): NonNullable<Storage.Saveable<unknown>>;
108
+ }
109
+ namespace Context {
110
+ interface SlicedArg {
111
+ str: string;
112
+ isQuoted?: boolean;
113
+ isSquared?: boolean;
114
+ }
115
+ }
116
+ type StatementStackItem = [
117
+ identifier: string,
118
+ start_position: [path: string, index: number],
119
+ statement_data: Storage.JSONValue
120
+ ];
121
+ type StatementStack = StatementStackItem[];
122
+ type StatementData = NonNullable<Storage.JSONValue>;
123
+ }
@@ -0,0 +1,2 @@
1
+ import { HZEngineCore } from "../index.js";
2
+ export declare function readline(_core: HZEngineCore, path: string, line_index: number): string | undefined;
@@ -0,0 +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 {};
@@ -0,0 +1,41 @@
1
+ import { HZEngineCore, Platform, Storage } from "../index.js";
2
+ /**
3
+ * 存档属性装饰器
4
+ * @param store_key 保存数据到存档数据对象的key
5
+ * @returns
6
+ */
7
+ export declare function Save<PlatformType extends Platform, This extends {
8
+ _core: HZEngineCore;
9
+ }, Value extends Storage.Saveable<Value>>(store_key: string): (target: ClassAccessorDecoratorTarget<This, Value>, context: ClassAccessorDecoratorContext<This, Value>) => ClassAccessorDecoratorResult<This, Value>;
10
+ /**
11
+ * 存档属性装饰器
12
+ * @param store_key 保存数据到存档数据对象的key
13
+ * @returns
14
+ */
15
+ export declare function CustomSave<PlatformType extends Platform, This extends {
16
+ _core: HZEngineCore;
17
+ }, Value, SerializedValue extends Storage.Saveable<SerializedValue>>(store_key: string, serializer: (this: This, value: Value) => SerializedValue, deserializer: (this: This, value: SerializedValue) => Value): (target: ClassAccessorDecoratorTarget<This, Value>, context: ClassAccessorDecoratorContext<This, Value>) => ClassAccessorDecoratorResult<This, Value>;
18
+ export declare function SaveGetter<PlatformType extends Platform, This extends {
19
+ _core: HZEngineCore<PlatformType>;
20
+ }, Value extends Storage.Saveable<Value>>(store_key: string): (target: ClassGetterDecoratorTarget<PlatformType, This, Value>, context: ClassGetterDecoratorContext<This, Value>) => (this: This) => Value;
21
+ export declare function CustomSaveGetter<PlatformType extends Platform, This extends {
22
+ _core: HZEngineCore<PlatformType>;
23
+ }, Value, SerializedValue extends Storage.Saveable<SerializedValue>>(store_key: string, serializer: (this: This, value: Value) => SerializedValue): (target: ClassGetterDecoratorTarget<PlatformType, This, Value>, context: ClassGetterDecoratorContext<This, Value>) => (this: This) => Value;
24
+ /**
25
+ * 存档属性装饰器
26
+ * @param store_key 保存数据到存档数据对象的key
27
+ * @returns
28
+ */
29
+ export declare function SaveSetter<PlatformType extends Platform, This extends {
30
+ _core: HZEngineCore<PlatformType>;
31
+ }, Value extends Storage.Saveable<Value>>(store_key: string): (target: ClassSetterDecoratorTarget<PlatformType, This, Value>, context: ClassSetterDecoratorContext<This, Value>) => (this: This, value: Value) => void;
32
+ export declare function CustomSaveSetter<PlatformType extends Platform, This extends {
33
+ _core: HZEngineCore<PlatformType>;
34
+ }, Value, SerializedValue extends Storage.Saveable<SerializedValue>>(store_key: string, deserializer: (this: This, value: SerializedValue) => Value): (target: ClassSetterDecoratorTarget<PlatformType, This, Value>, context: ClassSetterDecoratorContext<This, Value>) => (this: This, value: Value) => void;
35
+ type ClassGetterDecoratorTarget<PlatformType extends Platform, This extends {
36
+ _core: HZEngineCore<PlatformType>;
37
+ }, Value> = (this: This) => Value;
38
+ type ClassSetterDecoratorTarget<PlatformType extends Platform, This extends {
39
+ _core: HZEngineCore<PlatformType>;
40
+ }, Value> = (this: This, value: Value) => void;
41
+ export {};
@@ -0,0 +1 @@
1
+ export {};