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,338 @@
1
+ // path utils for ZeppOS
2
+ // @CuberQAQ
3
+ // Generated by GPT-4o mini
4
+ "use strict";
5
+
6
+ var util = {
7
+ isString: (x) => typeof x === "string", // 检查是否为字符串
8
+ isObject: (x) => typeof x === "object", // 检查是否为对象
9
+ };
10
+
11
+ /**
12
+ * 检查路径是否包含协议
13
+ * @param {string} path - 路径字符串
14
+ * @returns {boolean} - 如果路径包含协议,则返回 true
15
+ */
16
+ function isProtocolPath(path) {
17
+ return /^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(path);
18
+ }
19
+
20
+ /**
21
+ * 提取协议和路径部分
22
+ * @param {string} path - 路径字符串
23
+ * @returns {{protocol: string, filepath: string}} - 包含协议和文件路径的对象
24
+ */
25
+ function extractProtocol(path) {
26
+ const match = path.match(/^([a-zA-Z][a-zA-Z\d+\-.]*):\/\/(.*)$/);
27
+ if (match) {
28
+ return {
29
+ protocol: match[1], // 获取协议
30
+ filepath: match[2], // 获取文件路径
31
+ };
32
+ }
33
+ return { protocol: null, filepath: path }; // 如果没有协议,返回原路径
34
+ }
35
+
36
+ /**
37
+ * 解析路径数组并规范化
38
+ * @param {string[]} parts - 路径组成部分
39
+ * @param {boolean} allowAboveRoot - 是否允许上级目录
40
+ * @returns {string[]} - 规范化后的路径部分
41
+ */
42
+ function normalizeArray(parts, allowAboveRoot) {
43
+ var res = [];
44
+ for (var i = 0; i < parts.length; i++) {
45
+ var p = parts[i];
46
+
47
+ // 忽略空部分和当前目录(.)
48
+ if (!p || p === ".") continue;
49
+
50
+ // 处理上级目录(..)
51
+ if (p === "..") {
52
+ if (res.length && res[res.length - 1] !== "..") {
53
+ res.pop(); // 移除最后一个部分
54
+ } else if (allowAboveRoot) {
55
+ res.push(".."); // 允许上级目录
56
+ }
57
+ } else {
58
+ res.push(p); // 添加有效部分
59
+ }
60
+ }
61
+
62
+ return res;
63
+ }
64
+
65
+ /**
66
+ * 移除数组两端的空元素
67
+ * @param {string[]} arr - 输入数组
68
+ * @returns {string[]} - 去除空元素后的数组
69
+ */
70
+ function trimArray(arr) {
71
+ var lastIndex = arr.length - 1;
72
+ var start = 0;
73
+ for (; start <= lastIndex; start++) {
74
+ if (arr[start]) break;
75
+ }
76
+
77
+ var end = lastIndex;
78
+ for (; end >= 0; end--) {
79
+ if (arr[end]) break;
80
+ }
81
+
82
+ if (start === 0 && end === lastIndex) return arr;
83
+ if (start > end) return [];
84
+ return arr.slice(start, end + 1);
85
+ }
86
+
87
+ // 使用正则表达式分割路径
88
+ var splitPathRe =
89
+ /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
90
+ var posix = {};
91
+
92
+ /**
93
+ * 分割路径
94
+ * @param {string} filename - 输入的路径字符串
95
+ * @returns {string[]} - 分割后的路径组成部分
96
+ */
97
+ function posixSplitPath(filename) {
98
+ return splitPathRe.exec(filename).slice(1);
99
+ }
100
+
101
+ /**
102
+ * 解析路径,将相对路径转换为绝对路径
103
+ * @param {...string} paths - 要解析的路径
104
+ * @returns {string} - 解析后的绝对路径
105
+ */
106
+ posix.resolve = function () {
107
+ var resolvedPath = "",
108
+ resolvedAbsolute = false;
109
+
110
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
111
+ var path = i >= 0 ? arguments[i] : process.cwd();
112
+
113
+ // 跳过空和无效的条目
114
+ if (!util.isString(path)) {
115
+ throw new TypeError("Arguments to path.resolve must be strings");
116
+ } else if (!path) {
117
+ continue;
118
+ }
119
+
120
+ // 检查路径是否包含协议
121
+ if (isProtocolPath(path)) {
122
+ const { protocol, filepath } = extractProtocol(path);
123
+ resolvedPath = filepath + "/" + resolvedPath;
124
+ resolvedAbsolute = true; // 将协议路径视为绝对路径
125
+ } else {
126
+ resolvedPath = path + "/" + resolvedPath;
127
+ resolvedAbsolute = path[0] === "/";
128
+ }
129
+ }
130
+
131
+ // 规范化路径
132
+ resolvedPath = normalizeArray(
133
+ resolvedPath.split("/"),
134
+ !resolvedAbsolute
135
+ ).join("/");
136
+
137
+ return (resolvedAbsolute ? "/" : "") + resolvedPath || ".";
138
+ };
139
+
140
+ /**
141
+ * 规范化路径,去除多余的斜杠和当前目录
142
+ * @param {string} path - 输入的路径字符串
143
+ * @returns {string} - 规范化后的路径
144
+ */
145
+ posix.normalize = function (path) {
146
+ // 检查路径是否包含协议
147
+ if (isProtocolPath(path)) {
148
+ const { protocol, filepath } = extractProtocol(path);
149
+ return protocol + "://" + normalizeArray(filepath.split("/")).join("/");
150
+ }
151
+
152
+ var isAbsolute = posix.isAbsolute(path),
153
+ trailingSlash = path && path[path.length - 1] === "/";
154
+
155
+ // 规范化路径
156
+ path = normalizeArray(path.split("/"), !isAbsolute).join("/");
157
+
158
+ if (!path && !isAbsolute) {
159
+ path = ".";
160
+ }
161
+ if (path && trailingSlash) {
162
+ path += "/";
163
+ }
164
+
165
+ return (isAbsolute ? "/" : "") + path;
166
+ };
167
+
168
+ /**
169
+ * 检查路径是否为绝对路径
170
+ * @param {string} path - 输入的路径字符串
171
+ * @returns {boolean} - 如果路径为绝对路径,则返回 true
172
+ */
173
+ posix.isAbsolute = function (path) {
174
+ return path.charAt(0) === "/";
175
+ };
176
+
177
+ /**
178
+ * 连接多个路径段为一个路径
179
+ * @param {...string} segments - 要连接的路径段
180
+ * @returns {string} - 连接后的路径
181
+ */
182
+ posix.join = function () {
183
+ var path = "";
184
+ for (var i = 0; i < arguments.length; i++) {
185
+ var segment = arguments[i];
186
+ if (!util.isString(segment)) {
187
+ throw new TypeError("Arguments to path.join must be strings");
188
+ }
189
+ if (segment) {
190
+ if (!path) {
191
+ path += segment;
192
+ } else {
193
+ path += "/" + segment;
194
+ }
195
+ }
196
+ }
197
+ return posix.normalize(path);
198
+ };
199
+
200
+ /**
201
+ * 计算相对路径
202
+ * @param {string} from - 起始路径
203
+ * @param {string} to - 目标路径
204
+ * @returns {string} - 相对路径
205
+ */
206
+ posix.relative = function (from, to) {
207
+ from = posix.resolve(from).substr(1);
208
+ to = posix.resolve(to).substr(1);
209
+
210
+ var fromParts = trimArray(from.split("/"));
211
+ var toParts = trimArray(to.split("/"));
212
+
213
+ var length = Math.min(fromParts.length, toParts.length);
214
+ var samePartsLength = length;
215
+ for (var i = 0; i < length; i++) {
216
+ if (fromParts[i] !== toParts[i]) {
217
+ samePartsLength = i;
218
+ break;
219
+ }
220
+ }
221
+
222
+ var outputParts = [];
223
+ for (var i = samePartsLength; i < fromParts.length; i++) {
224
+ outputParts.push("..");
225
+ }
226
+
227
+ outputParts = outputParts.concat(toParts.slice(samePartsLength));
228
+
229
+ return outputParts.join("/");
230
+ };
231
+
232
+ /**
233
+ * 获取路径的目录名
234
+ * @param {string} path - 输入的路径字符串
235
+ * @returns {string} - 目录名
236
+ */
237
+ posix.dirname = function (path) {
238
+ var result = posixSplitPath(path),
239
+ root = result[0],
240
+ dir = result[1];
241
+
242
+ if (!root && !dir) {
243
+ return ".";
244
+ }
245
+
246
+ if (dir) {
247
+ dir = dir.substr(0, dir.length - 1); // 去掉尾部斜杠
248
+ }
249
+
250
+ return root + dir;
251
+ };
252
+
253
+ /**
254
+ * 获取路径的基本名
255
+ * @param {string} path - 输入的路径字符串
256
+ * @param {string} [ext] - 可选的扩展名,如果提供则将其从基本名中去除
257
+ * @returns {string} - 基本名
258
+ */
259
+ posix.basename = function (path, ext) {
260
+ var f = posixSplitPath(path)[2];
261
+ if (ext && f.substr(-1 * ext.length) === ext) {
262
+ f = f.substr(0, f.length - ext.length);
263
+ }
264
+ return f;
265
+ };
266
+
267
+ /**
268
+ * 获取路径的扩展名
269
+ * @param {string} path - 输入的路径字符串
270
+ * @returns {string} - 扩展名
271
+ */
272
+ posix.extname = function (path) {
273
+ return posixSplitPath(path)[3];
274
+ };
275
+
276
+ /**
277
+ * 格式化路径对象为路径字符串
278
+ * @param {Object} pathObject - 路径对象
279
+ * @param {string} pathObject.root - 根路径
280
+ * @param {string} pathObject.dir - 目录路径
281
+ * @param {string} pathObject.base - 基本文件名
282
+ * @param {string} pathObject.ext - 扩展名
283
+ * @param {string} pathObject.name - 文件名(不包含扩展名)
284
+ * @returns {string} - 格式化后的路径字符串
285
+ */
286
+ posix.format = function (pathObject) {
287
+ if (!util.isObject(pathObject)) {
288
+ throw new TypeError(
289
+ "Parameter 'pathObject' must be an object, not " + typeof pathObject
290
+ );
291
+ }
292
+
293
+ var root = pathObject.root || "";
294
+
295
+ if (!util.isString(root)) {
296
+ throw new TypeError(
297
+ "'pathObject.root' must be a string or undefined, not " +
298
+ typeof pathObject.root
299
+ );
300
+ }
301
+
302
+ var dir = pathObject.dir ? pathObject.dir + posix.sep : "";
303
+ var base = pathObject.base || "";
304
+ return dir + base;
305
+ };
306
+
307
+ /**
308
+ * 解析路径字符串为路径对象
309
+ * @param {string} pathString - 输入的路径字符串
310
+ * @returns {{root: string, dir: string, base: string, ext: string, name: string}} - 路径对象
311
+ */
312
+ posix.parse = function (pathString) {
313
+ if (!util.isString(pathString)) {
314
+ throw new TypeError(
315
+ "Parameter 'pathString' must be a string, not " + typeof pathString
316
+ );
317
+ }
318
+ var allParts = posixSplitPath(pathString);
319
+ if (!allParts || allParts.length !== 4) {
320
+ throw new TypeError("Invalid path '" + pathString + "'");
321
+ }
322
+ allParts[1] = allParts[1] || "";
323
+ allParts[2] = allParts[2] || "";
324
+ allParts[3] = allParts[3] || "";
325
+
326
+ return {
327
+ root: allParts[0],
328
+ dir: allParts[0] + allParts[1].slice(0, -1),
329
+ base: allParts[2],
330
+ ext: allParts[3],
331
+ name: allParts[2].slice(0, allParts[2].length - allParts[3].length),
332
+ };
333
+ };
334
+
335
+ posix.sep = "/"; // POSIX 路径分隔符
336
+ posix.delimiter = ":"; // POSIX 路径分隔符(用于环境变量)
337
+
338
+ export default posix; // 导出 posix 模块
package/tsconfig.json ADDED
@@ -0,0 +1,111 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "ES6", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
+ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
+ // "jsx": "preserve", /* Specify what JSX code is generated. */
17
+ // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
18
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
+
27
+ /* Modules */
28
+ "module": "NodeNext", /* Specify what module code is generated. */
29
+ // "rootDir": "./", /* Specify the root folder within your source files. */
30
+ // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
31
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
+ "paths": {
33
+ }, /* Specify a set of entries that re-map imports to additional lookup locations. */
34
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
35
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
36
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
37
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
38
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
39
+ // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
40
+ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
41
+ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
42
+ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
43
+ // "resolveJsonModule": true, /* Enable importing .json files. */
44
+ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
45
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
46
+
47
+ /* JavaScript Support */
48
+ "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
49
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
50
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
51
+
52
+ /* Emit */
53
+ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
54
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
55
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
56
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
57
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
58
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
59
+ "outDir": "./dist", /* Specify an output folder for all emitted files. */
60
+ // "removeComments": true, /* Disable emitting comments. */
61
+ // "noEmit": true, /* Disable emitting files from a compilation. */
62
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
63
+ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
64
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
65
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
66
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
67
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
68
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
69
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
70
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
71
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
72
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
73
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
74
+ "declarationDir": "./types", /* Specify the output directory for generated declaration files. */
75
+ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
76
+
77
+ /* Interop Constraints */
78
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
79
+ // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
80
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
81
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
82
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
83
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
84
+
85
+ /* Type Checking */
86
+ "strict": true, /* Enable all strict type-checking options. */
87
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
88
+ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
89
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
90
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
91
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
92
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
93
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
94
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
95
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
96
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
97
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
98
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
99
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
100
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
101
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
102
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
103
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
104
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
105
+
106
+ /* Completeness */
107
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
108
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
109
+ },
110
+ "include": ["./src", "../hzengine-0.2-launcher/shared/zos_media.d.ts"]
111
+ }
@@ -0,0 +1,24 @@
1
+ import { HZEngineCore, Storage } from "../index.js";
2
+ export declare class Async {
3
+ _core: HZEngineCore;
4
+ static _nextTickCallbacks: (() => void)[];
5
+ static _nextTickTimerId: number | null;
6
+ static nextTick(callback: () => void): void;
7
+ static _nextTickTimerCallback(): void;
8
+ private _lastTime;
9
+ constructor(_core: HZEngineCore);
10
+ _scheduleTask(): void;
11
+ private accessor _nextTimerId;
12
+ private accessor _delayTasks;
13
+ addDelayTask(event: string, args: Storage.Saveable<unknown>[], delayMs: number): number;
14
+ addRepeatTask(event: string, args: Storage.Saveable<unknown>[], intervalMs: number, delayMs?: number): number;
15
+ removeTask(id: number): void;
16
+ }
17
+ export declare namespace Async {
18
+ interface Task {
19
+ event: string;
20
+ args: Storage.Saveable<unknown>[];
21
+ next: number;
22
+ repeat: number;
23
+ }
24
+ }
@@ -0,0 +1,14 @@
1
+ export class ZeppTimer {
2
+ constructor(callback: any, interval: any);
3
+ callback: any;
4
+ interval: any;
5
+ timerId: any;
6
+ startTime: any;
7
+ nextTick: any;
8
+ time: any;
9
+ stopped: boolean;
10
+ start(delay?: number): void;
11
+ stop(): void;
12
+ scheduleTick(): void;
13
+ tick(): void;
14
+ }
@@ -0,0 +1,64 @@
1
+ import { HZEngineCore } from "../index.js";
2
+ import { Platform } from "../platform/index.js";
3
+ export declare class Audio {
4
+ _core: HZEngineCore;
5
+ constructor(_core: HZEngineCore);
6
+ private accessor _channels;
7
+ get channels(): Record<string, Audio.Channel>;
8
+ createChannel(name: string): Audio.Channel;
9
+ }
10
+ export declare namespace Audio {
11
+ class Channel {
12
+ _audio: Audio;
13
+ _audioPlayer: Platform.AudioPlayer;
14
+ constructor(_audio: Audio);
15
+ onRelease(): void;
16
+ mode: Channel.Mode;
17
+ status: Channel.Status;
18
+ _playbackList: PlaybackItem[];
19
+ _nowIndex: number | null;
20
+ currentInfo: AudioInfo | null;
21
+ push(item: PlaybackItem): void;
22
+ play(): void;
23
+ pause(): void;
24
+ /**
25
+ * 停止并清空队列
26
+ */
27
+ stop(): void;
28
+ serialize(): Channel.Serialized;
29
+ static deserialize(audio: Audio, data: Channel.Serialized): Channel;
30
+ _onPrepared(result: boolean): void;
31
+ _onCompleted(): void;
32
+ /**
33
+ * Play the next item in the playback list. If there are no items in the
34
+ * playback list, set the channel status to Stopped and return.
35
+ * @private
36
+ */
37
+ _playNext(): void;
38
+ }
39
+ namespace Channel {
40
+ enum Mode {
41
+ PlayInOrder = 0,
42
+ PlayInOrderRepeat = 1
43
+ }
44
+ enum Status {
45
+ Stopped = 0,
46
+ Playing = 1,
47
+ Error = 2
48
+ }
49
+ type Serialized = {
50
+ mode: Channel.Mode;
51
+ status: Channel.Status;
52
+ playbackList: PlaybackItem[];
53
+ nowIndex: number | null;
54
+ };
55
+ }
56
+ interface PlaybackItem {
57
+ path: string;
58
+ }
59
+ interface AudioInfo {
60
+ duration: number;
61
+ title: string;
62
+ artist: string;
63
+ }
64
+ }
@@ -0,0 +1,9 @@
1
+ import { HZEngineCore } from "../index.js";
2
+ export declare class Config {
3
+ private _core;
4
+ constructor(_core: HZEngineCore);
5
+ getConfig(key: string): NonNullable<import("../index.js").Storage.JSONValue> | undefined;
6
+ setConfig(key: string, value: any): void;
7
+ private normalizeKey;
8
+ resetConfig(): void;
9
+ }
@@ -0,0 +1,6 @@
1
+ import { HZEngineCore } from "../index.js";
2
+ export declare class Debug {
3
+ private _core;
4
+ constructor(_core: HZEngineCore);
5
+ log(...args: any[]): void;
6
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * HZEngineCore
3
+ * @copyright Copyright (c) 2024 CuberQAQ. All rights reserved.
4
+ */
5
+ import { Async } from "./async/index.js";
6
+ import { Audio } from "./audio/index.js";
7
+ import { Config } from "./config/index.js";
8
+ import { Debug } from "./debug/index.js";
9
+ import Platform from "./platform/index.js";
10
+ import { Script } from "./script/index.js";
11
+ import { Storage } from "./storage/index.js";
12
+ import { System } from "./system/index.js";
13
+ import { UI } from "./ui/index.js";
14
+ declare class HZEngineCore<PlatformType extends Platform = any> {
15
+ platform: PlatformType;
16
+ private _eventCallbacks;
17
+ storage: Storage;
18
+ async: Async;
19
+ ui: UI<PlatformType>;
20
+ script: Script;
21
+ system: System<PlatformType>;
22
+ config: Config;
23
+ audio: Audio;
24
+ debug: Debug;
25
+ constructor(platform: PlatformType);
26
+ loadProject(options: {
27
+ projectPath: string;
28
+ cachePath: string;
29
+ savePath: string;
30
+ }): void;
31
+ start(callback?: () => unknown): void;
32
+ end(): void;
33
+ plugins: Map<string, unknown>;
34
+ loadPlugin(name: string, plugin: Plugin<PlatformType>): void;
35
+ on(event: string, cb: Function): void;
36
+ off(event: string, cb: Function): boolean;
37
+ emit(event: string, ...args: any[]): void;
38
+ }
39
+ type Plugin<PlatformType extends Platform> = (core: HZEngineCore<PlatformType>) => any;
40
+ export { HZEngineCore, UI, Storage, Script, System, Async, type Platform };
41
+ export * as TransformPlugin from "./plugins/transform/index.js";