yeow-api 0.2.44 → 0.2.46

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yeow-api",
3
- "version": "0.2.44",
3
+ "version": "0.2.46",
4
4
  "description": "Yeow API",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
package/src/material.ts CHANGED
@@ -6,14 +6,26 @@ export interface MaterialInfo {
6
6
  isItem: boolean;
7
7
  }
8
8
 
9
- export function getMaterials(): Promise<MaterialInfo[]> {
10
- return post<MaterialInfo[]>('server.getMaterials', {});
9
+ let _materials: MaterialInfo[] | null = null;
10
+
11
+ export async function getMaterials(): Promise<MaterialInfo[]> {
12
+ if (_materials) return structuredClone(_materials);
13
+ _materials = await post<MaterialInfo[]>('server.getMaterials', {});
14
+ return structuredClone(_materials);
11
15
  }
12
16
 
13
- export function getBlocks(): Promise<string[]> {
14
- return post<string[]>('server.getBlocks', {});
17
+ let _blocks: string[] | null = null;
18
+
19
+ export async function getBlocks(): Promise<string[]> {
20
+ if (_blocks) return _blocks.slice();
21
+ _blocks = await post<string[]>('server.getBlocks', {});
22
+ return _blocks.slice();
15
23
  }
16
24
 
17
- export function getItems(): Promise<string[]> {
18
- return post<string[]>('server.getItems', {});
25
+ let _items: string[] | null = null;
26
+
27
+ export async function getItems(): Promise<string[]> {
28
+ if (_items) return _items.slice();
29
+ _items = await post<string[]>('server.getItems', {});
30
+ return _items.slice();
19
31
  }
package/src/task.ts CHANGED
@@ -13,7 +13,7 @@ export function post<T = unknown>(
13
13
  if (s) e.stack += ' --- cb registered at ---\n' + s;
14
14
  }
15
15
  if (result.stack) {
16
- e.stack += '\n --- Java stack ---\n' + result.stack;
16
+ e.stack += '\n --- runtime executer error(for reference) ---\n' + result.stack;
17
17
  }
18
18
  (e as any).javaType = result.type || null;
19
19
  (e as any).taskType = result.task || null;