toaimin-indie-engine 1.0.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.
Files changed (149) hide show
  1. package/README.md +55 -0
  2. package/cli/bin.cjs +99 -0
  3. package/dist/audio/AudioBus.d.ts +30 -0
  4. package/dist/audio/AudioBus.d.ts.map +1 -0
  5. package/dist/audio/AudioMock.d.ts +112 -0
  6. package/dist/audio/AudioMock.d.ts.map +1 -0
  7. package/dist/audio/ProceduralAudio.d.ts +48 -0
  8. package/dist/audio/ProceduralAudio.d.ts.map +1 -0
  9. package/dist/audio/SoundManager.d.ts +73 -0
  10. package/dist/audio/SoundManager.d.ts.map +1 -0
  11. package/dist/audio/VoicePool.d.ts +26 -0
  12. package/dist/audio/VoicePool.d.ts.map +1 -0
  13. package/dist/audio/index.d.ts +7 -0
  14. package/dist/audio/index.d.ts.map +1 -0
  15. package/dist/audio/types.d.ts +87 -0
  16. package/dist/audio/types.d.ts.map +1 -0
  17. package/dist/core/EventEmitter.d.ts +64 -0
  18. package/dist/core/EventEmitter.d.ts.map +1 -0
  19. package/dist/core/Game.d.ts +248 -0
  20. package/dist/core/Game.d.ts.map +1 -0
  21. package/dist/core/GameLoop.d.ts +128 -0
  22. package/dist/core/GameLoop.d.ts.map +1 -0
  23. package/dist/core/Time.d.ts +73 -0
  24. package/dist/core/Time.d.ts.map +1 -0
  25. package/dist/core/index.d.ts +5 -0
  26. package/dist/core/index.d.ts.map +1 -0
  27. package/dist/entity/Component.d.ts +31 -0
  28. package/dist/entity/Component.d.ts.map +1 -0
  29. package/dist/entity/Entity.d.ts +61 -0
  30. package/dist/entity/Entity.d.ts.map +1 -0
  31. package/dist/entity/EntityManager.d.ts +46 -0
  32. package/dist/entity/EntityManager.d.ts.map +1 -0
  33. package/dist/entity/components/ColliderComponent.d.ts +47 -0
  34. package/dist/entity/components/ColliderComponent.d.ts.map +1 -0
  35. package/dist/entity/components/RigidBodyComponent.d.ts +38 -0
  36. package/dist/entity/components/RigidBodyComponent.d.ts.map +1 -0
  37. package/dist/entity/components/ScriptComponent.d.ts +32 -0
  38. package/dist/entity/components/ScriptComponent.d.ts.map +1 -0
  39. package/dist/entity/components/ShapeComponent.d.ts +50 -0
  40. package/dist/entity/components/ShapeComponent.d.ts.map +1 -0
  41. package/dist/entity/components/SpriteComponent.d.ts +31 -0
  42. package/dist/entity/components/SpriteComponent.d.ts.map +1 -0
  43. package/dist/entity/components/index.d.ts +6 -0
  44. package/dist/entity/components/index.d.ts.map +1 -0
  45. package/dist/entity/index.d.ts +5 -0
  46. package/dist/entity/index.d.ts.map +1 -0
  47. package/dist/index.cjs +4 -0
  48. package/dist/index.cjs.map +1 -0
  49. package/dist/index.d.ts +15 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +6326 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/input/ActionMap.d.ts +91 -0
  54. package/dist/input/ActionMap.d.ts.map +1 -0
  55. package/dist/input/InputManager.d.ts +102 -0
  56. package/dist/input/InputManager.d.ts.map +1 -0
  57. package/dist/input/Pointer.d.ts +115 -0
  58. package/dist/input/Pointer.d.ts.map +1 -0
  59. package/dist/input/VirtualJoystick.d.ts +79 -0
  60. package/dist/input/VirtualJoystick.d.ts.map +1 -0
  61. package/dist/input/index.d.ts +5 -0
  62. package/dist/input/index.d.ts.map +1 -0
  63. package/dist/math/Circle.d.ts +39 -0
  64. package/dist/math/Circle.d.ts.map +1 -0
  65. package/dist/math/Color.d.ts +58 -0
  66. package/dist/math/Color.d.ts.map +1 -0
  67. package/dist/math/MathUtils.d.ts +82 -0
  68. package/dist/math/MathUtils.d.ts.map +1 -0
  69. package/dist/math/Matrix2D.d.ts +97 -0
  70. package/dist/math/Matrix2D.d.ts.map +1 -0
  71. package/dist/math/Rect.d.ts +54 -0
  72. package/dist/math/Rect.d.ts.map +1 -0
  73. package/dist/math/Transform2D.d.ts +47 -0
  74. package/dist/math/Transform2D.d.ts.map +1 -0
  75. package/dist/math/Vector2.d.ts +89 -0
  76. package/dist/math/Vector2.d.ts.map +1 -0
  77. package/dist/math/index.d.ts +8 -0
  78. package/dist/math/index.d.ts.map +1 -0
  79. package/dist/physics/BoxCollider2D.d.ts +38 -0
  80. package/dist/physics/BoxCollider2D.d.ts.map +1 -0
  81. package/dist/physics/CircleCollider2D.d.ts +27 -0
  82. package/dist/physics/CircleCollider2D.d.ts.map +1 -0
  83. package/dist/physics/Collider2D.d.ts +79 -0
  84. package/dist/physics/Collider2D.d.ts.map +1 -0
  85. package/dist/physics/CollisionFSM.d.ts +84 -0
  86. package/dist/physics/CollisionFSM.d.ts.map +1 -0
  87. package/dist/physics/ContactSolver.d.ts +58 -0
  88. package/dist/physics/ContactSolver.d.ts.map +1 -0
  89. package/dist/physics/Narrowphase.d.ts +25 -0
  90. package/dist/physics/Narrowphase.d.ts.map +1 -0
  91. package/dist/physics/PhysicsWorld2D.d.ts +75 -0
  92. package/dist/physics/PhysicsWorld2D.d.ts.map +1 -0
  93. package/dist/physics/Raycast.d.ts +38 -0
  94. package/dist/physics/Raycast.d.ts.map +1 -0
  95. package/dist/physics/RigidBody2D.d.ts +118 -0
  96. package/dist/physics/RigidBody2D.d.ts.map +1 -0
  97. package/dist/physics/SpatialGrid.d.ts +78 -0
  98. package/dist/physics/SpatialGrid.d.ts.map +1 -0
  99. package/dist/physics/index.d.ts +14 -0
  100. package/dist/physics/index.d.ts.map +1 -0
  101. package/dist/rendering/Animation.d.ts +62 -0
  102. package/dist/rendering/Animation.d.ts.map +1 -0
  103. package/dist/rendering/AssetLoader.d.ts +35 -0
  104. package/dist/rendering/AssetLoader.d.ts.map +1 -0
  105. package/dist/rendering/Camera2D.d.ts +109 -0
  106. package/dist/rendering/Camera2D.d.ts.map +1 -0
  107. package/dist/rendering/CanvasContext.d.ts +80 -0
  108. package/dist/rendering/CanvasContext.d.ts.map +1 -0
  109. package/dist/rendering/CanvasMock.d.ts +163 -0
  110. package/dist/rendering/CanvasMock.d.ts.map +1 -0
  111. package/dist/rendering/ParticleSystem.d.ts +103 -0
  112. package/dist/rendering/ParticleSystem.d.ts.map +1 -0
  113. package/dist/rendering/Renderer.d.ts +98 -0
  114. package/dist/rendering/Renderer.d.ts.map +1 -0
  115. package/dist/rendering/Shapes.d.ts +24 -0
  116. package/dist/rendering/Shapes.d.ts.map +1 -0
  117. package/dist/rendering/Sprite.d.ts +74 -0
  118. package/dist/rendering/Sprite.d.ts.map +1 -0
  119. package/dist/rendering/SpriteSheet.d.ts +22 -0
  120. package/dist/rendering/SpriteSheet.d.ts.map +1 -0
  121. package/dist/rendering/index.d.ts +11 -0
  122. package/dist/rendering/index.d.ts.map +1 -0
  123. package/dist/scene/Blackboard.d.ts +81 -0
  124. package/dist/scene/Blackboard.d.ts.map +1 -0
  125. package/dist/scene/Scene.d.ts +160 -0
  126. package/dist/scene/Scene.d.ts.map +1 -0
  127. package/dist/scene/SceneManager.d.ts +142 -0
  128. package/dist/scene/SceneManager.d.ts.map +1 -0
  129. package/dist/scene/SceneTransition.d.ts +118 -0
  130. package/dist/scene/SceneTransition.d.ts.map +1 -0
  131. package/dist/scene/index.d.ts +5 -0
  132. package/dist/scene/index.d.ts.map +1 -0
  133. package/dist/ui/UIAnchor.d.ts +31 -0
  134. package/dist/ui/UIAnchor.d.ts.map +1 -0
  135. package/dist/ui/UIButton.d.ts +48 -0
  136. package/dist/ui/UIButton.d.ts.map +1 -0
  137. package/dist/ui/UIElement.d.ts +108 -0
  138. package/dist/ui/UIElement.d.ts.map +1 -0
  139. package/dist/ui/UILabel.d.ts +54 -0
  140. package/dist/ui/UILabel.d.ts.map +1 -0
  141. package/dist/ui/UIManager.d.ts +41 -0
  142. package/dist/ui/UIManager.d.ts.map +1 -0
  143. package/dist/ui/UIPanel.d.ts +36 -0
  144. package/dist/ui/UIPanel.d.ts.map +1 -0
  145. package/dist/ui/UIProgressBar.d.ts +47 -0
  146. package/dist/ui/UIProgressBar.d.ts.map +1 -0
  147. package/dist/ui/index.d.ts +8 -0
  148. package/dist/ui/index.d.ts.map +1 -0
  149. package/package.json +47 -0
package/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # FrameworkGame
2
+
3
+ A production-grade, modular 2D game framework in TypeScript for Web/HTML5 tailored for indie game developers.
4
+
5
+ ## Features
6
+
7
+ - **Zero Heavy Runtime Dependencies**: Pure TypeScript, minimal footprint, maximum performance.
8
+ - **Fixed-Timestep Simulation**: 60Hz deterministic game loop with render interpolation (`alpha`) and spiral-of-death protection.
9
+ - **Robust Math & Affine Transforms**:
10
+ - `Vector2`: High-performance 2D vector with mutable in-place chaining, immutable helpers, and zero-division guards.
11
+ - `Matrix2D`: 3x3 Canvas-compatible affine transformation matrix with determinant, inversion, point/direction transform.
12
+ - `Transform2D`: Hierarchical scene-graph transform with parent-child propagation and lazy dirty-flag caching.
13
+ - `Rect` & `Circle`: 2D spatial primitives with comprehensive intersection and containment algorithms.
14
+ - `MathUtils`: Frame-rate independent exponential damping (`damp`), angle wrapping, clamp, lerp, and RNG helpers.
15
+ - `Color`: High-precision RGBA color with Hex, RGB, RGBA, HSL parsing and string formatting.
16
+ - **Core Engine Lifecycle**:
17
+ - `GameLoop`: Accumulator-based loop separating `update(dt)`, `fixedUpdate(fixedDt)`, and `render(alpha)`.
18
+ - `Time`: Scaled and unscaled delta time tracking with rolling average FPS counter.
19
+ - `EventEmitter`: Type-safe pub/sub event bus with snapshot iteration and unbind helpers.
20
+
21
+ ## Installation & Build
22
+
23
+ ```bash
24
+ # Build library (ESM, CJS, and TypeScript typings)
25
+ npm run build
26
+
27
+ # Run unit test suite
28
+ npm run test
29
+
30
+ # Run interactive demo
31
+ npm run dev
32
+
33
+ # Build demo for production
34
+ npm run build:demo
35
+ ```
36
+
37
+ ## Architecture
38
+
39
+ ```
40
+ src/
41
+ ├── index.ts # Framework public entry point
42
+ ├── core/ # GameLoop, Time, EventEmitter
43
+ ├── math/ # Vector2, Matrix2D, Transform2D, Rect, Circle, MathUtils, Color
44
+ ├── rendering/ # Canvas2D renderer, camera, sprites, particles (M2)
45
+ ├── physics/ # Rigid bodies, colliders, contact solver (M3)
46
+ ├── input/ # Keyboard, pointer, touch, virtual joystick (M2)
47
+ ├── audio/ # Web Audio bus, voice pool, synth (M4)
48
+ ├── scene/ # Scene lifecycle, modal stack, transitions (M4)
49
+ ├── ui/ # Retained-mode UI hierarchy, widgets (M4)
50
+ └── entity/ # Entity-component model (M5)
51
+ ```
52
+
53
+ ## License
54
+
55
+ MIT
package/cli/bin.cjs ADDED
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env node
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const { spawn } = require('child_process');
5
+
6
+ const args = process.argv.slice(2);
7
+ const command = args[0];
8
+
9
+ if (!command) {
10
+ console.log('Usage: indie-engine <command>');
11
+ console.log('Commands: init, dev, build');
12
+ process.exit(1);
13
+ }
14
+
15
+ if (command === 'init') {
16
+ const projectName = args[1] || 'my-game';
17
+ const targetDir = path.resolve(process.cwd(), projectName);
18
+
19
+ if (fs.existsSync(targetDir)) {
20
+ console.error(`Directory ${projectName} already exists.`);
21
+ process.exit(1);
22
+ }
23
+
24
+ fs.mkdirSync(targetDir, { recursive: true });
25
+ fs.mkdirSync(path.join(targetDir, 'src'));
26
+ fs.mkdirSync(path.join(targetDir, 'assets'));
27
+
28
+ const pkgJson = {
29
+ name: projectName,
30
+ version: "1.0.0",
31
+ private: true,
32
+ scripts: {
33
+ dev: "indie-engine dev",
34
+ build: "indie-engine build"
35
+ },
36
+ dependencies: {
37
+ "framework-game": "latest"
38
+ }
39
+ };
40
+
41
+ fs.writeFileSync(
42
+ path.join(targetDir, 'package.json'),
43
+ JSON.stringify(pkgJson, null, 2)
44
+ );
45
+
46
+ const mainTs = `import { createIndieGame, createEntity, Scene } from 'framework-game';
47
+
48
+ class MainScene extends Scene {
49
+ override onStart() {
50
+ createEntity('Player')
51
+ .withPosition(400, 300)
52
+ .withSprite({ texture: 'assets/player.png', width: 64, height: 64 })
53
+ .withPhysics({ type: 'dynamic', mass: 10 })
54
+ .onUpdate((dt, entity) => {
55
+ // Player logic here
56
+ })
57
+ .build()
58
+ .setParent(this.root);
59
+ }
60
+ }
61
+
62
+ createIndieGame()
63
+ .setSize(800, 600)
64
+ .setBackground('#222')
65
+ .addScene('Main', MainScene)
66
+ .start();
67
+ `;
68
+
69
+ fs.writeFileSync(path.join(targetDir, 'src', 'main.ts'), mainTs);
70
+
71
+ const html = `<!DOCTYPE html>
72
+ <html lang="en">
73
+ <head>
74
+ <meta charset="UTF-8">
75
+ <title>${projectName}</title>
76
+ <style>
77
+ body { margin: 0; background: #000; display: flex; justify-content: center; align-items: center; height: 100vh; }
78
+ canvas { display: block; }
79
+ </style>
80
+ </head>
81
+ <body>
82
+ <script type="module" src="/src/main.ts"></script>
83
+ </body>
84
+ </html>`;
85
+
86
+ fs.writeFileSync(path.join(targetDir, 'index.html'), html);
87
+
88
+ console.log(`Created project ${projectName}`);
89
+ console.log(`cd ${projectName}`);
90
+ console.log(`npm install`);
91
+ console.log(`npm run dev`);
92
+ } else if (command === 'dev' || command === 'build') {
93
+ const viteRunnerPath = path.join(__dirname, 'vite-runner.cjs');
94
+ const child = spawn('node', [viteRunnerPath, command], { stdio: 'inherit' });
95
+ child.on('exit', (code) => process.exit(code));
96
+ } else {
97
+ console.error(`Unknown command: ${command}`);
98
+ process.exit(1);
99
+ }
@@ -0,0 +1,30 @@
1
+ import type { AudioBusOptions } from './types';
2
+ /**
3
+ * AudioBus manages a Web Audio GainNode representing a named channel in the audio hierarchy.
4
+ * Child buses route into their parent bus, inheriting master volume attenuation and mute states.
5
+ */
6
+ export declare class AudioBus {
7
+ readonly name: string;
8
+ readonly context: AudioContext;
9
+ readonly gainNode: GainNode;
10
+ private _parentBus;
11
+ private _children;
12
+ private _volume;
13
+ private _muted;
14
+ constructor(context: AudioContext, options: AudioBusOptions);
15
+ get parentBus(): AudioBus | null;
16
+ setParentBus(parent: AudioBus | null): void;
17
+ get volume(): number;
18
+ setVolume(vol: number, rampDuration?: number): this;
19
+ get muted(): boolean;
20
+ setMuted(mute: boolean, rampDuration?: number): this;
21
+ toggleMute(rampDuration?: number): boolean;
22
+ get effectiveVolume(): number;
23
+ get isEffectiveMuted(): boolean;
24
+ createChildBus(name: string, volume?: number): AudioBus;
25
+ connectSource(sourceNode: AudioNode): void;
26
+ disconnectSource(sourceNode: AudioNode): void;
27
+ private _applyGain;
28
+ destroy(): void;
29
+ }
30
+ //# sourceMappingURL=AudioBus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AudioBus.d.ts","sourceRoot":"","sources":["../../src/audio/AudioBus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;GAGG;AACH,qBAAa,QAAQ;IACnB,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,OAAO,EAAE,YAAY,CAAC;IACtC,SAAgB,QAAQ,EAAE,QAAQ,CAAC;IAEnC,OAAO,CAAC,UAAU,CAAyB;IAC3C,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,MAAM,CAAkB;gBAEpB,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe;IAiB3D,IAAW,SAAS,IAAI,QAAQ,GAAG,IAAI,CAEtC;IAEM,YAAY,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI;IAuBlD,IAAW,MAAM,IAAI,MAAM,CAE1B;IAEM,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,GAAE,MAAU,GAAG,IAAI;IAQ7D,IAAW,KAAK,IAAI,OAAO,CAE1B;IAEM,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,YAAY,GAAE,MAAU,GAAG,IAAI;IAOvD,UAAU,CAAC,YAAY,GAAE,MAAU,GAAG,OAAO;IAKpD,IAAW,eAAe,IAAI,MAAM,CAGnC;IAED,IAAW,gBAAgB,IAAI,OAAO,CAGrC;IAEM,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAAY,GAAG,QAAQ;IAQ5D,aAAa,CAAC,UAAU,EAAE,SAAS,GAAG,IAAI;IAI1C,gBAAgB,CAAC,UAAU,EAAE,SAAS,GAAG,IAAI;IAQpD,OAAO,CAAC,UAAU;IAWX,OAAO,IAAI,IAAI;CAUvB"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Mock representation of an automated AudioParam.
3
+ */
4
+ export declare class MockAudioParam {
5
+ value: number;
6
+ defaultValue: number;
7
+ minValue: number;
8
+ maxValue: number;
9
+ scheduledEvents: Array<{
10
+ type: string;
11
+ value: number;
12
+ time: number;
13
+ }>;
14
+ constructor(defaultValue?: number, minValue?: number, maxValue?: number);
15
+ setValueAtTime(value: number, startTime: number): this;
16
+ linearRampToValueAtTime(value: number, endTime: number): this;
17
+ exponentialRampToValueAtTime(value: number, endTime: number): this;
18
+ setTargetAtTime(target: number, startTime: number, _timeConstant: number): this;
19
+ cancelScheduledValues(cancelTime: number): this;
20
+ }
21
+ /**
22
+ * Base mock audio node.
23
+ */
24
+ export declare class MockAudioNode {
25
+ context: MockAudioContext;
26
+ connections: (MockAudioNode | MockAudioParam)[];
27
+ constructor(context: MockAudioContext);
28
+ connect(destination: MockAudioNode | MockAudioParam): any;
29
+ disconnect(destination?: MockAudioNode | MockAudioParam): void;
30
+ }
31
+ /**
32
+ * Mock GainNode with an automated gain parameter.
33
+ */
34
+ export declare class MockGainNode extends MockAudioNode {
35
+ gain: MockAudioParam;
36
+ constructor(context: MockAudioContext);
37
+ }
38
+ /**
39
+ * Mock OscillatorNode.
40
+ */
41
+ export declare class MockOscillatorNode extends MockAudioNode {
42
+ type: OscillatorType;
43
+ frequency: MockAudioParam;
44
+ detune: MockAudioParam;
45
+ started: boolean;
46
+ stopped: boolean;
47
+ startTime: number;
48
+ stopTime: number;
49
+ onended: ((ev?: any) => void) | null;
50
+ constructor(context: MockAudioContext);
51
+ start(when?: number): void;
52
+ stop(when?: number): void;
53
+ }
54
+ /**
55
+ * Mock AudioBuffer.
56
+ */
57
+ export declare class MockAudioBuffer {
58
+ numberOfChannels: number;
59
+ length: number;
60
+ sampleRate: number;
61
+ duration: number;
62
+ private _channels;
63
+ constructor(options: {
64
+ numberOfChannels: number;
65
+ length: number;
66
+ sampleRate: number;
67
+ });
68
+ getChannelData(channel: number): Float32Array;
69
+ copyFromChannel(destination: Float32Array, channelNumber: number, bufferOffset?: number): void;
70
+ copyToChannel(source: Float32Array, channelNumber: number, bufferOffset?: number): void;
71
+ }
72
+ /**
73
+ * Mock AudioBufferSourceNode.
74
+ */
75
+ export declare class MockAudioBufferSourceNode extends MockAudioNode {
76
+ buffer: MockAudioBuffer | null;
77
+ playbackRate: MockAudioParam;
78
+ detune: MockAudioParam;
79
+ loop: boolean;
80
+ loopStart: number;
81
+ loopEnd: number;
82
+ started: boolean;
83
+ stopped: boolean;
84
+ onended: ((ev?: any) => void) | null;
85
+ constructor(context: MockAudioContext);
86
+ start(_when?: number, _offset?: number, _duration?: number): void;
87
+ stop(_when?: number): void;
88
+ }
89
+ /**
90
+ * Mock AudioContext.
91
+ */
92
+ export declare class MockAudioContext {
93
+ state: 'suspended' | 'running' | 'closed';
94
+ currentTime: number;
95
+ sampleRate: number;
96
+ destination: MockAudioNode;
97
+ constructor();
98
+ createGain(): MockGainNode;
99
+ createOscillator(): MockOscillatorNode;
100
+ createBufferSource(): MockAudioBufferSourceNode;
101
+ createBuffer(channels: number, length: number, sampleRate: number): MockAudioBuffer;
102
+ resume(): Promise<void>;
103
+ suspend(): Promise<void>;
104
+ close(): Promise<void>;
105
+ advanceTime(seconds: number): void;
106
+ decodeAudioData(arrayBuffer: ArrayBuffer): Promise<MockAudioBuffer>;
107
+ }
108
+ /**
109
+ * Installs mock audio classes onto the global object for headless unit testing.
110
+ */
111
+ export declare function installAudioMocks(): void;
112
+ //# sourceMappingURL=AudioMock.d.ts.map
@@ -0,0 +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S,EAAE,MAAM,CAAK;IACtB,OAAO,EAAE,MAAM,CAAK;IACpB,OAAO,EAAE,OAAO,CAAS;IACzB,OAAO,EAAE,OAAO,CAAS;IACzB,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC,GAAG,IAAI,CAAQ;gBAEvC,OAAO,EAAE,gBAAgB;IAM9B,KAAK,CAAC,KAAK,GAAE,MAAU,EAAE,OAAO,GAAE,MAAU,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAIvE,IAAI,CAAC,KAAK,GAAE,MAAU,GAAG,IAAI;CAQrC;AAED;;GAEG;AACH,qBAAa,gBAAgB;IACpB,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAe;IACxD,WAAW,EAAE,MAAM,CAAK;IACxB,UAAU,EAAE,MAAM,CAAS;IAC3B,WAAW,EAAE,aAAa,CAAC;;IAM3B,UAAU,IAAI,YAAY;IAI1B,gBAAgB,IAAI,kBAAkB;IAItC,kBAAkB,IAAI,yBAAyB;IAI/C,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,eAAe;IAI7E,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIlC,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC;CAO3E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAIxC"}
@@ -0,0 +1,48 @@
1
+ import type { SynthParams } from './types';
2
+ export interface ProceduralSoundOptions {
3
+ volume?: number;
4
+ sampleRate?: number;
5
+ }
6
+ /**
7
+ * ProceduralAudio generates classic 8-bit retro sound effects using standard Web Audio nodes
8
+ * and direct mathematical buffer synthesis without any external audio asset files.
9
+ */
10
+ export declare class ProceduralAudio {
11
+ /**
12
+ * Generates a custom synth tone buffer based on frequency envelope parameters.
13
+ */
14
+ static createSynthBuffer(context: AudioContext, params: SynthParams): AudioBuffer;
15
+ /**
16
+ * Laser Sound: Frequency sweep downwards (880Hz -> 220Hz over 0.15s, square wave).
17
+ */
18
+ static createLaserBuffer(context: AudioContext, options?: ProceduralSoundOptions): AudioBuffer;
19
+ /**
20
+ * Explosion Sound: Low-frequency noise buffer with exponential gain decay (0.45s).
21
+ */
22
+ static createExplosionBuffer(context: AudioContext, options?: ProceduralSoundOptions): AudioBuffer;
23
+ /**
24
+ * Jump Sound: Upward frequency sweep (150Hz -> 600Hz over 0.18s, square wave).
25
+ */
26
+ static createJumpBuffer(context: AudioContext, options?: ProceduralSoundOptions): AudioBuffer;
27
+ /**
28
+ * Coin Sound: Two-tone chime (987.77Hz [B5] for 0.08s -> 1318.51Hz [E6] for 0.22s).
29
+ */
30
+ static createCoinBuffer(context: AudioContext, options?: ProceduralSoundOptions): AudioBuffer;
31
+ /**
32
+ * Hit Sound: Sudden pitch drop with high damping (300Hz -> 60Hz, 0.12s).
33
+ */
34
+ static createHitBuffer(context: AudioContext, options?: ProceduralSoundOptions): AudioBuffer;
35
+ /**
36
+ * Powerup Sound: 4-note ascending arpeggio (C5: 523Hz, E5: 659Hz, G5: 784Hz, C6: 1046Hz).
37
+ */
38
+ static createPowerupBuffer(context: AudioContext, options?: ProceduralSoundOptions): AudioBuffer;
39
+ /**
40
+ * Real-time oscillator player for Laser.
41
+ */
42
+ static playLaser(context: AudioContext, destination: AudioNode, options?: ProceduralSoundOptions): AudioNode;
43
+ /**
44
+ * Real-time oscillator player for Jump.
45
+ */
46
+ static playJump(context: AudioContext, destination: AudioNode, options?: ProceduralSoundOptions): AudioNode;
47
+ }
48
+ //# sourceMappingURL=ProceduralAudio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProceduralAudio.d.ts","sourceRoot":"","sources":["../../src/audio/ProceduralAudio.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,SAAS,CAAC;AAEzD,MAAM,WAAW,sBAAsB;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,qBAAa,eAAe;IAC1B;;OAEG;WACW,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,GAAG,WAAW;IAqDxF;;OAEG;WACW,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,WAAW;IAoBrG;;OAEG;WACW,qBAAqB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,WAAW;IA0BzG;;OAEG;WACW,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,WAAW;IAoBpG;;OAEG;WACW,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,WAAW;IA4BpG;;OAEG;WACW,eAAe,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,WAAW;IAqBnG;;OAEG;WACW,mBAAmB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,WAAW;IA8BvG;;OAEG;WACW,SAAS,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,SAAS;IAqBnH;;OAEG;WACW,QAAQ,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,SAAS;CAqBnH"}
@@ -0,0 +1,73 @@
1
+ import { EventEmitter } from '../core/EventEmitter';
2
+ import { AudioBus } from './AudioBus';
3
+ import type { MusicPlayOptions, SoundManagerEvents, SoundPlayOptions, SynthParams } from './types';
4
+ /**
5
+ * SoundManager coordinates the framework's Web Audio subsystem.
6
+ */
7
+ export declare class SoundManager extends EventEmitter<SoundManagerEvents> {
8
+ private _context;
9
+ private _isUnlocked;
10
+ private _unlockListenersAttached;
11
+ private _boundUnlockHandler;
12
+ private _masterBus;
13
+ private _musicBus;
14
+ private _sfxBus;
15
+ private _buses;
16
+ private _voicePool;
17
+ private _buffers;
18
+ private _currentMusicVoiceId;
19
+ private _currentMusicKey;
20
+ private _currentMusicGain;
21
+ private _currentMusicSource;
22
+ private _isMusicPlaying;
23
+ constructor();
24
+ /**
25
+ * Initializes the AudioContext and setup default buses.
26
+ */
27
+ init(): void;
28
+ get context(): AudioContext | null;
29
+ get state(): string;
30
+ get isUnlocked(): boolean;
31
+ /**
32
+ * Explicitly triggers an unlock attempt via resume().
33
+ */
34
+ unlock(): Promise<boolean>;
35
+ private _attachAutoplayUnlockListeners;
36
+ private _handleUnlocked;
37
+ private _detachAutoplayUnlockListeners;
38
+ get masterVolume(): number;
39
+ setMasterVolume(vol: number, rampDuration?: number): void;
40
+ get musicVolume(): number;
41
+ setMusicVolume(vol: number, rampDuration?: number): void;
42
+ get sfxVolume(): number;
43
+ setSfxVolume(vol: number, rampDuration?: number): void;
44
+ get isMuted(): boolean;
45
+ mute(rampDuration?: number): void;
46
+ unmute(rampDuration?: number): void;
47
+ toggleMute(rampDuration?: number): boolean;
48
+ getBus(name: string): AudioBus | undefined;
49
+ createBus(name: string, parentName?: string): AudioBus;
50
+ registerSound(key: string, buffer: AudioBuffer): void;
51
+ hasSound(key: string): boolean;
52
+ getSound(key: string): AudioBuffer | undefined;
53
+ loadSound(key: string, url: string): Promise<AudioBuffer>;
54
+ playSound(key: string, options?: SoundPlayOptions): number;
55
+ stopSound(voiceId: number, fadeDuration?: number): boolean;
56
+ stopAllSfx(fadeDuration?: number): void;
57
+ playMusic(key: string, options?: MusicPlayOptions): void;
58
+ pauseMusic(): void;
59
+ resumeMusic(): void;
60
+ stopMusic(fadeDuration?: number): void;
61
+ isMusicPlaying(): boolean;
62
+ playLaser(options?: SoundPlayOptions): number;
63
+ playExplosion(options?: SoundPlayOptions): number;
64
+ playJump(options?: SoundPlayOptions): number;
65
+ playCoin(options?: SoundPlayOptions): number;
66
+ playHit(options?: SoundPlayOptions): number;
67
+ playPowerup(options?: SoundPlayOptions): number;
68
+ playSynth(params: SynthParams, options?: SoundPlayOptions): number;
69
+ private _prebakeProceduralSounds;
70
+ stopAll(): void;
71
+ destroy(): void;
72
+ }
73
+ //# sourceMappingURL=SoundManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SoundManager.d.ts","sourceRoot":"","sources":["../../src/audio/SoundManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EAEZ,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,YAAa,SAAQ,YAAY,CAAC,kBAAkB,CAAC;IAChE,OAAO,CAAC,QAAQ,CAA6B;IAC7C,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,wBAAwB,CAAkB;IAClD,OAAO,CAAC,mBAAmB,CAA6B;IAGxD,OAAO,CAAC,UAAU,CAAyB;IAC3C,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,OAAO,CAAyB;IACxC,OAAO,CAAC,MAAM,CAAoC;IAGlD,OAAO,CAAC,UAAU,CAA0B;IAG5C,OAAO,CAAC,QAAQ,CAAuC;IAGvD,OAAO,CAAC,oBAAoB,CAAuB;IACnD,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,iBAAiB,CAAyB;IAClD,OAAO,CAAC,mBAAmB,CAAsC;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AG,OAAO,CAAC,WAAW,CAAC;IAgB/D,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM;IAgB1D,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO;IAI1D,UAAU,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI;IAMvC,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,IAAI;IAoDxD,UAAU,IAAI,IAAI;IAKlB,WAAW,IAAI,IAAI;IAMnB,SAAS,CAAC,YAAY,GAAE,MAAY,GAAG,IAAI;IAqB3C,cAAc,IAAI,OAAO;IAMzB,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM;IAI7C,aAAa,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM;IAIjD,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM;IAI5C,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM;IAI5C,OAAO,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM;IAI3C,WAAW,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM;IAI/C,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM;IASzE,OAAO,CAAC,wBAAwB;IAUzB,OAAO,IAAI,IAAI;IAKf,OAAO,IAAI,IAAI;CAiBvB"}
@@ -0,0 +1,26 @@
1
+ import type { AudioBus } from './AudioBus';
2
+ import type { SoundPlayOptions, VoicePoolConfig } from './types';
3
+ /**
4
+ * VoicePool coordinates polyphonic sound playback with concurrency limits and oldest-voice stealing.
5
+ */
6
+ export declare class VoicePool {
7
+ readonly context: AudioContext;
8
+ readonly maxVoices: number;
9
+ readonly maxInstancesPerKey: number;
10
+ readonly stealFadeDuration: number;
11
+ private _activeVoices;
12
+ private _nextVoiceId;
13
+ constructor(context: AudioContext, config?: VoicePoolConfig);
14
+ play(buffer: AudioBuffer, bus: AudioBus, options?: SoundPlayOptions): number;
15
+ stop(voiceId: number, fadeDuration?: number): boolean;
16
+ stopKey(key: string, fadeDuration?: number): number;
17
+ stopAll(fadeDuration?: number): void;
18
+ getActiveCount(): number;
19
+ getActiveCountForKey(key: string): number;
20
+ hasVoice(voiceId: number): boolean;
21
+ private _enforceKeyLimit;
22
+ private _stealOldestVoice;
23
+ private _cleanupVoice;
24
+ destroy(): void;
25
+ }
26
+ //# sourceMappingURL=VoicePool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VoicePool.d.ts","sourceRoot":"","sources":["../../src/audio/VoicePool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAe,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE9E;;GAEG;AACH,qBAAa,SAAS;IACpB,SAAgB,OAAO,EAAE,YAAY,CAAC;IACtC,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,kBAAkB,EAAE,MAAM,CAAC;IAC3C,SAAgB,iBAAiB,EAAE,MAAM,CAAC;IAE1C,OAAO,CAAC,aAAa,CAAuC;IAC5D,OAAO,CAAC,YAAY,CAAa;gBAErB,OAAO,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,eAAe;IAOpD,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM;IA0E5E,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO;IA8BrD,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM;IAWnD,OAAO,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI;IAOpC,cAAc,IAAI,MAAM;IAIxB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAQzC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAIzC,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,aAAa;IAed,OAAO,IAAI,IAAI;CAIvB"}
@@ -0,0 +1,7 @@
1
+ export * from './types';
2
+ export * from './AudioBus';
3
+ export * from './VoicePool';
4
+ export * from './ProceduralAudio';
5
+ export * from './SoundManager';
6
+ export * from './AudioMock';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/audio/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Standard waveform oscillator types supported by Web Audio.
3
+ */
4
+ export type WaveformType = 'sine' | 'square' | 'sawtooth' | 'triangle';
5
+ /**
6
+ * Audio context execution state.
7
+ */
8
+ export type AudioContextState = 'suspended' | 'running' | 'closed';
9
+ /**
10
+ * Options for playing sound effects.
11
+ */
12
+ export interface SoundPlayOptions {
13
+ volume?: number;
14
+ pitch?: number;
15
+ pitchRandom?: number;
16
+ loop?: boolean;
17
+ loopStart?: number;
18
+ loopEnd?: number;
19
+ offset?: number;
20
+ duration?: number;
21
+ fadeInDuration?: number;
22
+ bus?: string;
23
+ }
24
+ /**
25
+ * Options for background music playback.
26
+ */
27
+ export interface MusicPlayOptions {
28
+ volume?: number;
29
+ loop?: boolean;
30
+ fadeInDuration?: number;
31
+ crossFadeDuration?: number;
32
+ }
33
+ /**
34
+ * Parameters for arbitrary procedural synthesizer tones.
35
+ */
36
+ export interface SynthParams {
37
+ waveform?: WaveformType;
38
+ startFreq: number;
39
+ endFreq?: number;
40
+ duration: number;
41
+ volume?: number;
42
+ attack?: number;
43
+ decay?: number;
44
+ }
45
+ /**
46
+ * Configuration options for initializing an AudioBus.
47
+ */
48
+ export interface AudioBusOptions {
49
+ name: string;
50
+ volume?: number;
51
+ muted?: boolean;
52
+ parentBus?: import('./AudioBus').AudioBus | null;
53
+ }
54
+ /**
55
+ * Configuration options for VoicePool concurrency management.
56
+ */
57
+ export interface VoicePoolConfig {
58
+ maxVoices?: number;
59
+ maxInstancesPerKey?: number;
60
+ stealFadeDuration?: number;
61
+ }
62
+ /**
63
+ * Active voice tracking descriptor.
64
+ */
65
+ export interface ActiveVoice {
66
+ id: number;
67
+ key: string;
68
+ sourceNode: AudioBufferSourceNode;
69
+ gainNode: GainNode;
70
+ startTime: number;
71
+ duration: number;
72
+ loop: boolean;
73
+ bus: import('./AudioBus').AudioBus;
74
+ }
75
+ /**
76
+ * Event map for SoundManager pub/sub notifications.
77
+ */
78
+ export interface SoundManagerEvents {
79
+ unlock: void;
80
+ statechange: AudioContextState;
81
+ mutechange: boolean;
82
+ volumechange: {
83
+ bus: string;
84
+ volume: number;
85
+ };
86
+ }
87
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/audio/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,C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ACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,GAAG,EAAE,OAAO,YAAY,EAAE,QAAQ,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,IAAI,CAAC;IACb,WAAW,EAAE,iBAAiB,CAAC;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/C"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Generic type-safe event map definition.
3
+ */
4
+ export type EventMap = Record<string | symbol, any>;
5
+ /**
6
+ * Event listener callback function.
7
+ */
8
+ export type EventListener<T = any> = (payload: T) => void;
9
+ /**
10
+ * High-performance, type-safe Pub/Sub Event Emitter for game engine and custom game events.
11
+ */
12
+ export declare class EventEmitter<TEvents extends EventMap = Record<string, any>> {
13
+ private _events;
14
+ constructor();
15
+ /**
16
+ * Register a persistent event listener.
17
+ * @param event The event identifier.
18
+ * @param listener Callback function invoked when the event is emitted.
19
+ */
20
+ on<K extends keyof TEvents>(event: K, listener: EventListener<TEvents[K]>): this;
21
+ /**
22
+ * Register a one-time event listener that automatically unbinds after first execution.
23
+ * @param event The event identifier.
24
+ * @param listener Callback function invoked once.
25
+ */
26
+ once<K extends keyof TEvents>(event: K, listener: EventListener<TEvents[K]>): this;
27
+ /**
28
+ * Unregister an event listener.
29
+ * @param event The event identifier.
30
+ * @param listener The original callback function to remove.
31
+ */
32
+ off<K extends keyof TEvents>(event: K, listener: EventListener<TEvents[K]>): this;
33
+ /**
34
+ * Register an event listener and return an unsubscribe disposer function.
35
+ * @param event The event identifier.
36
+ * @param listener Callback function.
37
+ * @returns Disposer function that unsubscribes the listener when called.
38
+ */
39
+ subscribe<K extends keyof TEvents>(event: K, listener: EventListener<TEvents[K]>): () => void;
40
+ /**
41
+ * Emit an event to all registered listeners.
42
+ * Safe against listener array mutations during execution.
43
+ * @param event The event identifier.
44
+ * @param payload Optional event payload.
45
+ * @returns True if at least one listener was invoked, false otherwise.
46
+ */
47
+ emit<K extends keyof TEvents>(event: K, ...args: TEvents[K] extends void ? [] : [TEvents[K]]): boolean;
48
+ /**
49
+ * Clear listeners for a specific event, or all events if none specified.
50
+ * @param event Optional event identifier.
51
+ */
52
+ clear<K extends keyof TEvents>(event?: K): this;
53
+ /**
54
+ * Return the number of listeners registered for an event.
55
+ * @param event The event identifier.
56
+ */
57
+ listenerCount<K extends keyof TEvents>(event: K): number;
58
+ /**
59
+ * Check whether any listeners are registered for an event.
60
+ * @param event The event identifier.
61
+ */
62
+ hasListeners<K extends keyof TEvents>(event: K): boolean;
63
+ }
64
+ //# sourceMappingURL=EventEmitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventEmitter.d.ts","sourceRoot":"","sources":["../../src/core/EventEmitter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,CAAC;AAU1D;;GAEG;AACH,qBAAa,YAAY,CAAC,OAAO,SAAS,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACtE,OAAO,CAAC,OAAO,CAAsC;;IAMrD;;;;OAIG;IACI,EAAE,CAAC,CAAC,SAAS,MAAM,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;IAevF;;;;OAIG;IACI,IAAI,CAAC,CAAC,SAAS,MAAM,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,OAAO,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