yeow-api 0.2.19 → 0.2.22
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 +1 -1
- package/src/event.ts +5 -1
- package/src/world.ts +2 -1
package/package.json
CHANGED
package/src/event.ts
CHANGED
|
@@ -355,13 +355,17 @@ export function eventOff(eventType: string, handler: Function): void {
|
|
|
355
355
|
try {
|
|
356
356
|
handler(wrapped);
|
|
357
357
|
} catch (e: any) {
|
|
358
|
-
const errInfo = {
|
|
358
|
+
const errInfo: any = {
|
|
359
359
|
message: e?.message || String(e),
|
|
360
360
|
stack: e?.stack || '',
|
|
361
361
|
fileName: e?.fileName || 'main.js',
|
|
362
362
|
lineNumber: e?.lineNumber || 0,
|
|
363
363
|
columnNumber: e?.columnNumber || 0,
|
|
364
364
|
};
|
|
365
|
+
if (!errInfo.fileName || errInfo.fileName === 'main.js' || !errInfo.lineNumber) {
|
|
366
|
+
const m = e?.stack?.match(/at\s+(?:\S+\s+)?\(?([^\s(]+):(\d+):(\d+)\)?/);
|
|
367
|
+
if (m) { errInfo.fileName = m[1]; errInfo.lineNumber = parseInt(m[2]); errInfo.columnNumber = parseInt(m[3]); }
|
|
368
|
+
}
|
|
365
369
|
(globalThis as any).$send('js-error', JSON.stringify(errInfo));
|
|
366
370
|
}
|
|
367
371
|
}
|
package/src/world.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { call, post } from './task.js';
|
|
2
2
|
import { Location } from './location.js';
|
|
3
|
+
import { Block } from './block.js';
|
|
3
4
|
|
|
4
5
|
export class World {
|
|
5
6
|
static get(name: string): World | null { const d = call('world.get', { name }) as any; return d ? new World(d.name) : null; }
|
|
@@ -23,7 +24,7 @@ export class World {
|
|
|
23
24
|
setGameRule(rule: string, value: string): Promise<boolean> { return post('world.setGameRule', { world: this.name, rule, value }) as Promise<boolean>; }
|
|
24
25
|
setGameRuleSync(rule: string, value: string): boolean { return call('world.setGameRule', { world: this.name, rule, value }) as boolean; }
|
|
25
26
|
getBiome(x: number, y: number, z: number): string { return call('world.getBiome', { world: this.name, x, y, z }) as string; }
|
|
26
|
-
getBlock(x: number, y: number, z: number):
|
|
27
|
+
getBlock(x: number, y: number, z: number): Block | null { const r = call('world.getBlock', { world: this.name, x, y, z }) as any; return r ? new Block(this.name, r.x, r.y, r.z, r.type) : null; }
|
|
27
28
|
setBlock(x: number, y: number, z: number, blockType: string): Promise<void> { return post('world.setBlock', { world: this.name, x, y, z, blockType }) as Promise<void>; }
|
|
28
29
|
setBlockSync(x: number, y: number, z: number, blockType: string) { call('world.setBlock', { world: this.name, x, y, z, blockType }); }
|
|
29
30
|
getEntities(): string[] { return call('world.getEntities', { world: this.name }) as string[]; }
|