Skip to content

Commit 565446f

Browse files
committed
feat(core-editor): cleaner event manager
1 parent c1dbfd6 commit 565446f

File tree

13 files changed

+99
-82
lines changed

13 files changed

+99
-82
lines changed

packages/core-editor/.cliff-jumperrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"$schema": "https://raw.githubusercontent.com/favware/cliff-jumper/main/assets/cliff-jumper.schema.json",
33
"name": "core",
44
"org": "nanoforge-dev",
5-
"packagePath": "packages/core",
5+
"packagePath": "packages/core-editor",
66
"identifierBase": false
77
}

packages/core-editor/.idea/.name

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core-editor/.idea/[NanoForge] Engine Core.iml renamed to packages/core-editor/.idea/[NanoForge] Engine Core Editor.iml

File renamed without changes.

packages/core-editor/.idea/modules.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core-editor/CHANGELOG.md

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,13 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
# [@nanoforge-dev/core@1.0.1](https://github.com/NanoForge-dev/Engine/compare/@nanoforge-dev/core@1.0.0...@nanoforge-dev/core@1.0.1) - (2026-02-16)
6-
75
## Documentation
86

9-
- Setup typedoc (#192) ([fa908e7](https://github.com/NanoForge-dev/Engine/commit/fa908e7e268fa1770be58fc62a0257f3760480b2)) by @MartinFillon
10-
- Fix readme badges (#186) ([fd8d93d](https://github.com/NanoForge-dev/Engine/commit/fd8d93d13a0fbad95ef9952acd10faad9e112c78)) by @Exeloo
11-
12-
# [@nanoforge-dev/core@1.0.0](https://github.com/NanoForge-dev/Engine/tree/@nanoforge-dev/core@1.0.0) - (2026-01-09)
13-
147
## Bug Fixes
158

16-
- **graphics:** Game loop ([53329d2](https://github.com/NanoForge-dev/Engine/commit/53329d28c47bfac9fe86259e9fc6f42b206062a8)) by @Exeloo
17-
- **graphics:** Fix display ([d8522e5](https://github.com/NanoForge-dev/Engine/commit/d8522e56678f3bd136733f7941c1d917c18b1400)) by @Exeloo
18-
- **ecs:** Fix tests ([d33ada5](https://github.com/NanoForge-dev/Engine/commit/d33ada5d9c37e331b8178aa1fc0daee88b07131c)) by @Exeloo
19-
- **ecs:** Change type handling on lib ecs ([580192d](https://github.com/NanoForge-dev/Engine/commit/580192d5038f386c965434f78aacdf3d1e399ff8)) by @Exeloo
20-
219
## Documentation
2210

23-
- Update README files with new structure and detailed usage examples for all packages (#157) ([63fab73](https://github.com/NanoForge-dev/Engine/commit/63fab7326bd9c7e6b00f950694ab16c9d9190c53)) by @Exeloo
24-
- Add funding (#147) ([7301fad](https://github.com/NanoForge-dev/Engine/commit/7301fad10f59b7e1f7fa788f8a2f6fc81d0db72e)) by @Exeloo
25-
- Add a basic introduction readme ([b240964](https://github.com/NanoForge-dev/Engine/commit/b240964a265b31769a8c5422e23e20156ba56192)) by @MartinFillon
26-
- Add building and dependency docs to every readme ([2d4785b](https://github.com/NanoForge-dev/Engine/commit/2d4785bdcb455e83337b37540f9ab6b3394c0850)) by @MartinFillon
27-
2811
## Features
2912

30-
- **packages/network:** Client and server for tcp/udp and networked pong as example (#156) ([839fb95](https://github.com/NanoForge-dev/Engine/commit/839fb95449f6ae0ee66d7f7e279374268b743f65)) by @Tchips46
31-
- **core:** Add client/server distinction and update rendering logic (#119) ([5271432](https://github.com/NanoForge-dev/Engine/commit/5271432710031396d7e433bfdfb015e3871f69d0)) by @Exeloo
32-
- Add schematics used types (#102) ([b992306](https://github.com/NanoForge-dev/Engine/commit/b9923064ba1da3164b1739fcdec5a819734c4ba2)) by @Exeloo
33-
- **core:** Introduce `EditableApplicationContext` for managing sound libraries ([6c7bac2](https://github.com/NanoForge-dev/Engine/commit/6c7bac261eeb7ad79203d5695d5ad76dc9e9e9f5)) by @Exeloo
34-
- **core:** Add Context that admit a ClientLibraryManager ([3835bc8](https://github.com/NanoForge-dev/Engine/commit/3835bc8a6e6d039f11a513b7fe54c353f90e9fe1)) by @Exeloo
35-
- **music:** Finish music library and add an interface for mutable libraries ([8e00c5d](https://github.com/NanoForge-dev/Engine/commit/8e00c5d00f2901ada86f59667eff7e5d3446076b)) by @MartinFillon
36-
- **core:** Add `class-transformer` and `class-validator` dependencies for validation utilities ([fd94fe7](https://github.com/NanoForge-dev/Engine/commit/fd94fe7755999c5529335666720899792a691a36)) by @Exeloo
37-
- **common, core, config:** Introduce configuration registry and validation system ([4fafb82](https://github.com/NanoForge-dev/Engine/commit/4fafb82576fec6866fc281ad5b10321d2ac430df)) by @Exeloo
38-
- **core:** Enhance type safety and execution context handling ([d986030](https://github.com/NanoForge-dev/Engine/commit/d986030a333bc08d2e37291d1a023cf8d7a6e1d6)) by @Exeloo
39-
- **app:** Add the ability to mute and unmute sounds ([947bdc0](https://github.com/NanoForge-dev/Engine/commit/947bdc00784a4c3313fe08feb4f91fc91b3ac7b7)) by @MartinFillon
40-
- **sound:** Add basic sound playing to example ([7335814](https://github.com/NanoForge-dev/Engine/commit/7335814fc532ee92a5f9d776f409c5faa4d56423)) by @MartinFillon
41-
- **core:** Add default libraries to constructor ([7d9da69](https://github.com/NanoForge-dev/Engine/commit/7d9da69be4301875020176656276236b88b737f1)) by @Exeloo
42-
- Add dependencies handling ([e51dd3b](https://github.com/NanoForge-dev/Engine/commit/e51dd3bdb5e2e3de21339bf6218e85f935efb9d5)) by @Exeloo
43-
- **common:** Add dependencies handler ([edb098a](https://github.com/NanoForge-dev/Engine/commit/edb098a65fb932ba9a9532a9b1eee7d64a7a8f0d)) by @Exeloo
44-
- **core:** Add tickrate and fix runner ([1dba5bd](https://github.com/NanoForge-dev/Engine/commit/1dba5bd89ffa20dfd29b079f93c3eb923ffbdbbc)) by @Exeloo
45-
- **input:** Add input library ([387e97d](https://github.com/NanoForge-dev/Engine/commit/387e97d7c3015a869947af4acecf48e8e1b0e2b8)) by @Exeloo
46-
- **game:** Create pong example game ([4b66674](https://github.com/NanoForge-dev/Engine/commit/4b66674c750f345e860d225384054423433beb07)) by @bill-h4rper
47-
- **game:** Add width and height ([c93c985](https://github.com/NanoForge-dev/Engine/commit/c93c985665bd99c09bc410f1499d11aeaffe3c4c)) by @Exeloo
48-
- **game:** Add graphics factory ([0f4453c](https://github.com/NanoForge-dev/Engine/commit/0f4453ced908b39e953a672324e97eba82bfeaa3)) by @Exeloo
49-
- **asset-manager:** Add asset manager ([1774a26](https://github.com/NanoForge-dev/Engine/commit/1774a26593099b4faa0a2527d1684de35211d5d2)) by @Exeloo
50-
- Add asset manager default in core ([26cc5a9](https://github.com/NanoForge-dev/Engine/commit/26cc5a99e014fbc8669a43cc4aa4d78ecc1dee14)) by @Exeloo
51-
- Add core and common ([1755c79](https://github.com/NanoForge-dev/Engine/commit/1755c799c143513d72b28edaac875267d484a44f)) by @Exeloo
52-
- Initial commit ([c9bb59e](https://github.com/NanoForge-dev/Engine/commit/c9bb59ee963e7b444e8668db55597915e9ef0e4b)) by @Exeloo
53-
5413
## Refactor
5514

56-
- **core:** Remove default libs in factory (#118) ([fa893c7](https://github.com/NanoForge-dev/Engine/commit/fa893c71616f151343c2f52a4723a64cca65814a)) by @Exeloo
57-
- Migrate namespaces to `@nanoforge-dev` and update related imports ([c84c927](https://github.com/NanoForge-dev/Engine/commit/c84c927ead941d914e5a9fd752fd3a5ac969f981)) by @Exeloo
58-
- **libraries:** Implement initialization validation and standardize nullable fields ([8b04575](https://github.com/NanoForge-dev/Engine/commit/8b04575cf7f649a440b8f40ad6114414406b0c1a)) by @Exeloo
59-

packages/core-editor/README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,27 @@
1616

1717
## About
1818

19-
`@nanoforge-dev/core` is a core package that contains game main loop. It is used to initialize the game and run it.
19+
`@nanoforge-dev/core-editor` is a core package that contains game main loop. It is used to initialize the game and run it.
2020

2121
## Installation
2222

2323
**Node.js 24.11.0 or newer is required.**
2424

2525
```sh
26-
npm install @nanoforge-dev/core
27-
yarn add @nanoforge-dev/core
28-
pnpm add @nanoforge-dev/core
29-
bun add @nanoforge-dev/core
26+
npm install @nanoforge-dev/core-editor
27+
yarn add @nanoforge-dev/core-editor
28+
pnpm add @nanoforge-dev/core-editor
29+
bun add @nanoforge-dev/core-editor
3030
```
3131

3232
## Example usage
3333

3434
Initialize the game in your main file.
3535

3636
```ts
37-
import { type IRunOptions } from "@nanoforge-dev/common";
38-
import { NanoforgeFactory } from "@nanoforge-dev/core";
37+
import { IEditorRunOptions, NanoforgeFactory } from "@nanoforge-dev/core-editor";
3938

40-
export async function main(options: IRunClientOptions) {
39+
export async function main(options: IEditorRunOptions) {
4140
const app = NanoforgeFactory.createClient();
4241

4342
await app.init(options);
@@ -63,6 +62,6 @@ If you don't understand something in the documentation, you are experiencing pro
6362

6463
[documentation]: https://github.com/NanoForge-dev/Engine
6564
[discussions]: https://github.com/NanoForge-dev/Engine/discussions
66-
[source]: https://github.com/NanoForge-dev/Engine/tree/main/packages/core
67-
[npm]: https://www.npmjs.com/package/@nanoforge-dev/core
65+
[source]: https://github.com/NanoForge-dev/Engine/tree/main/packages/core-editor
66+
[npm]: https://www.npmjs.com/package/@nanoforge-dev/core-editor
6867
[contributing]: https://github.com/NanoForge-dev/Engine/blob/main/.github/CONTRIBUTING.md

packages/core-editor/cliff.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ commit_parsers = [
6969
]
7070
filter_commits = true
7171
protect_breaking_commits = true
72-
tag_pattern = "@nanoforge-dev/core@[0-9]*"
72+
tag_pattern = "@nanoforge-dev/core-editor@[0-9]*"
7373
ignore_tags = ""
7474
topo_order = false
7575
sort_commits = "newest"

packages/core-editor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://json.schemastore.org/package.json",
33
"name": "@nanoforge-dev/core-editor",
4-
"version": "1.0",
4+
"version": "0.0",
55
"description": "NanoForge Engine - Core Editor",
66
"keywords": [
77
"nanoforge",

packages/core-editor/src/common/context/event-emitter.type.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@ export enum EventTypeEnum {
33
HARD_RELOAD = "hard-reload",
44
}
55

6-
export interface EventEmitter {
7-
eventQueue: (EventTypeEnum | string)[];
6+
export type ListenerType = (...args: any[]) => void;
7+
8+
export interface IEventEmitter {
9+
listeners: Record<EventTypeEnum | string, ListenerType[]>;
10+
eventQueue: { event: EventTypeEnum | string; args: any[] }[];
11+
12+
runEvents: () => void;
13+
14+
emitEvent: (event: EventTypeEnum, ...args: any) => void;
15+
16+
addListener: (event: EventTypeEnum | string, listener: ListenerType) => void;
17+
on: (event: EventTypeEnum | string, listener: ListenerType) => void;
18+
19+
removeListener: (event: EventTypeEnum | string, listener: ListenerType) => void;
20+
off: (event: EventTypeEnum | string, listener: ListenerType) => void;
21+
22+
removeListenersForEvent: (event: EventTypeEnum | string) => void;
23+
removeAllListeners: () => void;
824
}
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type EventEmitter } from "./event-emitter.type";
1+
import { type EventEmitter } from "../../editor/event-emitter.manager";
22
import { type Save } from "./save.type";
33

44
export type IEditorRunOptions = IEditorRunClientOptions | IEditorRunServerOptions;
@@ -9,15 +9,16 @@ export interface IEditorRunClientOptions {
99
env: Record<string, string | undefined>;
1010
editor: {
1111
save: Save;
12-
events: EventEmitter;
12+
coreEvents: EventEmitter;
13+
editorEvents: EventEmitter;
1314
};
1415
}
1516
export interface IEditorRunServerOptions {
16-
canvas: HTMLCanvasElement;
1717
files: Map<string, string>;
1818
env: Record<string, string | undefined>;
1919
editor: {
2020
save: Save;
21-
events: EventEmitter;
21+
coreEvents: EventEmitter;
22+
editorEvents: EventEmitter;
2223
};
2324
}

0 commit comments

Comments
 (0)