@yagejs/debug 0.1.0
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/README.md +45 -0
- package/dist/api.cjs +34 -0
- package/dist/api.cjs.map +1 -0
- package/dist/api.d.cts +68 -0
- package/dist/api.d.ts +68 -0
- package/dist/api.js +7 -0
- package/dist/api.js.map +1 -0
- package/dist/chunk-QSE3OVXA.js +12 -0
- package/dist/chunk-QSE3OVXA.js.map +1 -0
- package/dist/index.cjs +655 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +82 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.js +624 -0
- package/dist/index.js.map +1 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @yagejs/debug
|
|
2
|
+
|
|
3
|
+
FPS counter, entity inspector, and dev overlays for the [YAGE](https://yage.dev) 2D game engine.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @yagejs/debug
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { Engine } from "@yagejs/core";
|
|
15
|
+
import { DebugPlugin } from "@yagejs/debug";
|
|
16
|
+
|
|
17
|
+
const engine = new Engine({ debug: true });
|
|
18
|
+
engine.use(new DebugPlugin());
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## What's in the box
|
|
22
|
+
|
|
23
|
+
- **DebugPlugin** - FPS counter, entity count, and HUD overlays
|
|
24
|
+
- **Debug registry** - other packages contribute widgets (physics collider overlay, input state, etc.)
|
|
25
|
+
- **Manual clock mode** - deterministic frame-stepping for tests
|
|
26
|
+
- **Stats store** - per-frame metrics collection
|
|
27
|
+
|
|
28
|
+
### For package authors
|
|
29
|
+
|
|
30
|
+
`@yagejs/debug/api` exposes hooks for other packages to register debug contributors:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { DebugRegistryKey } from "@yagejs/debug/api";
|
|
34
|
+
|
|
35
|
+
const registry = engine.context.resolve(DebugRegistryKey);
|
|
36
|
+
registry.registerContributor({ /* ... */ });
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Docs
|
|
40
|
+
|
|
41
|
+
Full documentation at [yage.dev](https://yage.dev).
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
MIT
|
package/dist/api.cjs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/api.ts
|
|
21
|
+
var api_exports = {};
|
|
22
|
+
__export(api_exports, {
|
|
23
|
+
DebugRegistryKey: () => DebugRegistryKey
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(api_exports);
|
|
26
|
+
|
|
27
|
+
// src/types.ts
|
|
28
|
+
var import_core = require("@yagejs/core");
|
|
29
|
+
var DebugRegistryKey = new import_core.ServiceKey("debugRegistry");
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
DebugRegistryKey
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=api.cjs.map
|
package/dist/api.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/api.ts","../src/types.ts"],"sourcesContent":["export { DebugRegistryKey } from \"./types.js\";\nexport type {\n DebugGraphics,\n WorldDebugApi,\n HudDebugApi,\n StatsApi,\n DebugContributor,\n DebugRegistry,\n} from \"./types.js\";\n","import { ServiceKey } from \"@yagejs/core\";\n\n/**\n * Minimal subset of PixiJS Graphics used by debug drawing.\n * Avoids a runtime pixi.js dependency in the ./api subpath.\n */\nexport interface DebugGraphics {\n position: { x: number; y: number };\n rotation: number;\n visible: boolean;\n clear(): DebugGraphics;\n rect(x: number, y: number, width: number, height: number): DebugGraphics;\n circle(x: number, y: number, radius: number): DebugGraphics;\n moveTo(x: number, y: number): DebugGraphics;\n lineTo(x: number, y: number): DebugGraphics;\n stroke(style: { width: number; color: number; alpha?: number }): DebugGraphics;\n fill(style: { color: number; alpha?: number }): DebugGraphics;\n}\n\n/** Camera-space drawing API passed to contributors. */\nexport interface WorldDebugApi {\n acquireGraphics(): DebugGraphics | undefined;\n isFlagEnabled(flag: string): boolean;\n readonly cameraZoom: number;\n}\n\n/** Screen-space HUD API passed to contributors. */\nexport interface HudDebugApi {\n addLine(text: string): void;\n isFlagEnabled(flag: string): boolean;\n readonly screenWidth: number;\n readonly screenHeight: number;\n}\n\n/** Rolling-window statistics collector. */\nexport interface StatsApi {\n push(key: string, value: number): void;\n average(key: string): number;\n latest(key: string): number;\n min(key: string): number;\n max(key: string): number;\n}\n\n/** A debug contributor that registers drawing/sampling callbacks. */\nexport interface DebugContributor {\n readonly name: string;\n readonly flags: readonly string[];\n drawWorld?(api: WorldDebugApi): void;\n drawHud?(api: HudDebugApi): void;\n sample?(stats: StatsApi, dt: number): void;\n dispose?(): void;\n}\n\n/** Service interface for the debug registry. */\nexport interface DebugRegistry {\n register(contributor: DebugContributor): void;\n isEnabled(): boolean;\n isFlagEnabled(contributorName: string, flag: string): boolean;\n}\n\n/** Service key for resolving the DebugRegistry via DI. */\nexport const DebugRegistryKey = new ServiceKey<DebugRegistry>(\"debugRegistry\");\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAA2B;AA6DpB,IAAM,mBAAmB,IAAI,uBAA0B,eAAe;","names":[]}
|
package/dist/api.d.cts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ServiceKey } from '@yagejs/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Minimal subset of PixiJS Graphics used by debug drawing.
|
|
5
|
+
* Avoids a runtime pixi.js dependency in the ./api subpath.
|
|
6
|
+
*/
|
|
7
|
+
interface DebugGraphics {
|
|
8
|
+
position: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
rotation: number;
|
|
13
|
+
visible: boolean;
|
|
14
|
+
clear(): DebugGraphics;
|
|
15
|
+
rect(x: number, y: number, width: number, height: number): DebugGraphics;
|
|
16
|
+
circle(x: number, y: number, radius: number): DebugGraphics;
|
|
17
|
+
moveTo(x: number, y: number): DebugGraphics;
|
|
18
|
+
lineTo(x: number, y: number): DebugGraphics;
|
|
19
|
+
stroke(style: {
|
|
20
|
+
width: number;
|
|
21
|
+
color: number;
|
|
22
|
+
alpha?: number;
|
|
23
|
+
}): DebugGraphics;
|
|
24
|
+
fill(style: {
|
|
25
|
+
color: number;
|
|
26
|
+
alpha?: number;
|
|
27
|
+
}): DebugGraphics;
|
|
28
|
+
}
|
|
29
|
+
/** Camera-space drawing API passed to contributors. */
|
|
30
|
+
interface WorldDebugApi {
|
|
31
|
+
acquireGraphics(): DebugGraphics | undefined;
|
|
32
|
+
isFlagEnabled(flag: string): boolean;
|
|
33
|
+
readonly cameraZoom: number;
|
|
34
|
+
}
|
|
35
|
+
/** Screen-space HUD API passed to contributors. */
|
|
36
|
+
interface HudDebugApi {
|
|
37
|
+
addLine(text: string): void;
|
|
38
|
+
isFlagEnabled(flag: string): boolean;
|
|
39
|
+
readonly screenWidth: number;
|
|
40
|
+
readonly screenHeight: number;
|
|
41
|
+
}
|
|
42
|
+
/** Rolling-window statistics collector. */
|
|
43
|
+
interface StatsApi {
|
|
44
|
+
push(key: string, value: number): void;
|
|
45
|
+
average(key: string): number;
|
|
46
|
+
latest(key: string): number;
|
|
47
|
+
min(key: string): number;
|
|
48
|
+
max(key: string): number;
|
|
49
|
+
}
|
|
50
|
+
/** A debug contributor that registers drawing/sampling callbacks. */
|
|
51
|
+
interface DebugContributor {
|
|
52
|
+
readonly name: string;
|
|
53
|
+
readonly flags: readonly string[];
|
|
54
|
+
drawWorld?(api: WorldDebugApi): void;
|
|
55
|
+
drawHud?(api: HudDebugApi): void;
|
|
56
|
+
sample?(stats: StatsApi, dt: number): void;
|
|
57
|
+
dispose?(): void;
|
|
58
|
+
}
|
|
59
|
+
/** Service interface for the debug registry. */
|
|
60
|
+
interface DebugRegistry {
|
|
61
|
+
register(contributor: DebugContributor): void;
|
|
62
|
+
isEnabled(): boolean;
|
|
63
|
+
isFlagEnabled(contributorName: string, flag: string): boolean;
|
|
64
|
+
}
|
|
65
|
+
/** Service key for resolving the DebugRegistry via DI. */
|
|
66
|
+
declare const DebugRegistryKey: ServiceKey<DebugRegistry>;
|
|
67
|
+
|
|
68
|
+
export { type DebugContributor, type DebugGraphics, type DebugRegistry, DebugRegistryKey, type HudDebugApi, type StatsApi, type WorldDebugApi };
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ServiceKey } from '@yagejs/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Minimal subset of PixiJS Graphics used by debug drawing.
|
|
5
|
+
* Avoids a runtime pixi.js dependency in the ./api subpath.
|
|
6
|
+
*/
|
|
7
|
+
interface DebugGraphics {
|
|
8
|
+
position: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
rotation: number;
|
|
13
|
+
visible: boolean;
|
|
14
|
+
clear(): DebugGraphics;
|
|
15
|
+
rect(x: number, y: number, width: number, height: number): DebugGraphics;
|
|
16
|
+
circle(x: number, y: number, radius: number): DebugGraphics;
|
|
17
|
+
moveTo(x: number, y: number): DebugGraphics;
|
|
18
|
+
lineTo(x: number, y: number): DebugGraphics;
|
|
19
|
+
stroke(style: {
|
|
20
|
+
width: number;
|
|
21
|
+
color: number;
|
|
22
|
+
alpha?: number;
|
|
23
|
+
}): DebugGraphics;
|
|
24
|
+
fill(style: {
|
|
25
|
+
color: number;
|
|
26
|
+
alpha?: number;
|
|
27
|
+
}): DebugGraphics;
|
|
28
|
+
}
|
|
29
|
+
/** Camera-space drawing API passed to contributors. */
|
|
30
|
+
interface WorldDebugApi {
|
|
31
|
+
acquireGraphics(): DebugGraphics | undefined;
|
|
32
|
+
isFlagEnabled(flag: string): boolean;
|
|
33
|
+
readonly cameraZoom: number;
|
|
34
|
+
}
|
|
35
|
+
/** Screen-space HUD API passed to contributors. */
|
|
36
|
+
interface HudDebugApi {
|
|
37
|
+
addLine(text: string): void;
|
|
38
|
+
isFlagEnabled(flag: string): boolean;
|
|
39
|
+
readonly screenWidth: number;
|
|
40
|
+
readonly screenHeight: number;
|
|
41
|
+
}
|
|
42
|
+
/** Rolling-window statistics collector. */
|
|
43
|
+
interface StatsApi {
|
|
44
|
+
push(key: string, value: number): void;
|
|
45
|
+
average(key: string): number;
|
|
46
|
+
latest(key: string): number;
|
|
47
|
+
min(key: string): number;
|
|
48
|
+
max(key: string): number;
|
|
49
|
+
}
|
|
50
|
+
/** A debug contributor that registers drawing/sampling callbacks. */
|
|
51
|
+
interface DebugContributor {
|
|
52
|
+
readonly name: string;
|
|
53
|
+
readonly flags: readonly string[];
|
|
54
|
+
drawWorld?(api: WorldDebugApi): void;
|
|
55
|
+
drawHud?(api: HudDebugApi): void;
|
|
56
|
+
sample?(stats: StatsApi, dt: number): void;
|
|
57
|
+
dispose?(): void;
|
|
58
|
+
}
|
|
59
|
+
/** Service interface for the debug registry. */
|
|
60
|
+
interface DebugRegistry {
|
|
61
|
+
register(contributor: DebugContributor): void;
|
|
62
|
+
isEnabled(): boolean;
|
|
63
|
+
isFlagEnabled(contributorName: string, flag: string): boolean;
|
|
64
|
+
}
|
|
65
|
+
/** Service key for resolving the DebugRegistry via DI. */
|
|
66
|
+
declare const DebugRegistryKey: ServiceKey<DebugRegistry>;
|
|
67
|
+
|
|
68
|
+
export { type DebugContributor, type DebugGraphics, type DebugRegistry, DebugRegistryKey, type HudDebugApi, type StatsApi, type WorldDebugApi };
|
package/dist/api.js
ADDED
package/dist/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/types.ts
|
|
5
|
+
import { ServiceKey } from "@yagejs/core";
|
|
6
|
+
var DebugRegistryKey = new ServiceKey("debugRegistry");
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
__name,
|
|
10
|
+
DebugRegistryKey
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=chunk-QSE3OVXA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import { ServiceKey } from \"@yagejs/core\";\n\n/**\n * Minimal subset of PixiJS Graphics used by debug drawing.\n * Avoids a runtime pixi.js dependency in the ./api subpath.\n */\nexport interface DebugGraphics {\n position: { x: number; y: number };\n rotation: number;\n visible: boolean;\n clear(): DebugGraphics;\n rect(x: number, y: number, width: number, height: number): DebugGraphics;\n circle(x: number, y: number, radius: number): DebugGraphics;\n moveTo(x: number, y: number): DebugGraphics;\n lineTo(x: number, y: number): DebugGraphics;\n stroke(style: { width: number; color: number; alpha?: number }): DebugGraphics;\n fill(style: { color: number; alpha?: number }): DebugGraphics;\n}\n\n/** Camera-space drawing API passed to contributors. */\nexport interface WorldDebugApi {\n acquireGraphics(): DebugGraphics | undefined;\n isFlagEnabled(flag: string): boolean;\n readonly cameraZoom: number;\n}\n\n/** Screen-space HUD API passed to contributors. */\nexport interface HudDebugApi {\n addLine(text: string): void;\n isFlagEnabled(flag: string): boolean;\n readonly screenWidth: number;\n readonly screenHeight: number;\n}\n\n/** Rolling-window statistics collector. */\nexport interface StatsApi {\n push(key: string, value: number): void;\n average(key: string): number;\n latest(key: string): number;\n min(key: string): number;\n max(key: string): number;\n}\n\n/** A debug contributor that registers drawing/sampling callbacks. */\nexport interface DebugContributor {\n readonly name: string;\n readonly flags: readonly string[];\n drawWorld?(api: WorldDebugApi): void;\n drawHud?(api: HudDebugApi): void;\n sample?(stats: StatsApi, dt: number): void;\n dispose?(): void;\n}\n\n/** Service interface for the debug registry. */\nexport interface DebugRegistry {\n register(contributor: DebugContributor): void;\n isEnabled(): boolean;\n isFlagEnabled(contributorName: string, flag: string): boolean;\n}\n\n/** Service key for resolving the DebugRegistry via DI. */\nexport const DebugRegistryKey = new ServiceKey<DebugRegistry>(\"debugRegistry\");\n"],"mappings":";;;;AAAA,SAAS,kBAAkB;AA6DpB,IAAM,mBAAmB,IAAI,WAA0B,eAAe;","names":[]}
|