@open-core/framework 0.2.2-beta.1 → 0.2.5

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 (56) hide show
  1. package/LICENSE +373 -373
  2. package/README.md +217 -217
  3. package/dist/adapters/node/node-entity-server.js +3 -0
  4. package/dist/adapters/node/node-exports.d.ts +2 -2
  5. package/dist/kernel/utils/vector3.d.ts +1 -0
  6. package/dist/kernel/utils/vector3.js +1 -0
  7. package/dist/runtime/client/services/appearance.service.js +4 -0
  8. package/dist/runtime/server/bootstrap.js +1 -1
  9. package/dist/runtime/server/bootstrap.validation.js +2 -0
  10. package/dist/runtime/server/bus/internal-event.bus.d.ts +6 -0
  11. package/dist/runtime/server/bus/{core-event-bus.js → internal-event.bus.js} +5 -2
  12. package/dist/runtime/server/controllers/principal-export.controller.js +1 -1
  13. package/dist/runtime/server/controllers/session.controller.js +4 -4
  14. package/dist/runtime/server/decorators/onFrameworkEvent.d.ts +15 -6
  15. package/dist/runtime/server/decorators/onFrameworkEvent.js +9 -6
  16. package/dist/runtime/server/decorators/throttle.js +3 -1
  17. package/dist/runtime/server/entities/player.d.ts +6 -0
  18. package/dist/runtime/server/entities/player.js +12 -0
  19. package/dist/runtime/server/helpers/command-validation.helper.d.ts +1 -1
  20. package/dist/runtime/server/helpers/function-helper.d.ts +1 -1
  21. package/dist/runtime/server/index.d.ts +2 -1
  22. package/dist/runtime/server/index.js +3 -1
  23. package/dist/runtime/server/services/core/command.service.d.ts +1 -1
  24. package/dist/runtime/server/services/core/player.service.d.ts +0 -11
  25. package/dist/runtime/server/services/core/player.service.js +0 -15
  26. package/dist/runtime/server/services/parallel/worker-pool.js +4 -0
  27. package/dist/runtime/server/services/ports/command-execution.port.d.ts +1 -1
  28. package/dist/runtime/server/services/ports/player-session-lifecycle.port.d.ts +0 -12
  29. package/dist/runtime/server/services/remote/remote-command.service.d.ts +1 -1
  30. package/dist/runtime/server/services/services.register.js +2 -2
  31. package/dist/runtime/server/system/metadata-server.keys.d.ts +1 -1
  32. package/dist/runtime/server/system/metadata-server.keys.js +10 -10
  33. package/dist/runtime/server/system/processors/{coreEvent.processor.d.ts → internalEvent.processor.d.ts} +1 -1
  34. package/dist/runtime/server/system/processors/{coreEvent.processor.js → internalEvent.processor.js} +10 -10
  35. package/dist/runtime/server/system/processors.register.js +2 -2
  36. package/dist/runtime/server/types/index.d.ts +1 -1
  37. package/dist/runtime/server/types/index.js +1 -1
  38. package/dist/runtime/server/types/internal-events.d.ts +19 -0
  39. package/package.json +100 -99
  40. package/dist/kernel/di/tokens.d.ts +0 -30
  41. package/dist/kernel/di/tokens.js +0 -38
  42. package/dist/runtime/client/interfaces/appearance.interface.d.ts +0 -25
  43. package/dist/runtime/client/interfaces/appearance.interface.js +0 -2
  44. package/dist/runtime/server/bus/core-event-bus.d.ts +0 -6
  45. package/dist/runtime/server/controllers/command.controller.d.ts +0 -15
  46. package/dist/runtime/server/controllers/command.controller.js +0 -100
  47. package/dist/runtime/server/services/access-control.service.d.ts +0 -59
  48. package/dist/runtime/server/services/access-control.service.js +0 -127
  49. package/dist/runtime/server/services/core/vehicle-modification.service.d.ts +0 -104
  50. package/dist/runtime/server/services/core/vehicle-modification.service.js +0 -330
  51. package/dist/runtime/server/services/core/vehicle.service.d.ts +0 -128
  52. package/dist/runtime/server/services/core/vehicle.service.js +0 -391
  53. package/dist/runtime/server/services/remote/remote-principal.provider.d.ts +0 -55
  54. package/dist/runtime/server/services/remote/remote-principal.provider.js +0 -130
  55. package/dist/runtime/server/types/core-events.d.ts +0 -22
  56. /package/dist/runtime/server/types/{core-events.js → internal-events.js} +0 -0
package/README.md CHANGED
@@ -1,217 +1,217 @@
1
- # OpenCore Framework (v0.2.2-beta.1)
2
-
3
- OpenCore is a TypeScript multiplayer runtime framework targeting FiveM via an adapter.
4
-
5
- It is not a gamemode or RP framework. It provides:
6
-
7
- - A stable execution model (server and client)
8
- - Dependency Injection and metadata-driven wiring
9
- - An event/command system
10
- - Security primitives (validation, access control, rate limiting)
11
-
12
- License: MPL-2.0
13
-
14
- ## Scope
15
-
16
- This package (`@open-core/framework`) contains transversal infrastructure only.
17
-
18
- - Controllers, services, decorators, and processors
19
- - Session/lifecycle primitives and contracts
20
- - Adapters and capability registration
21
-
22
- Gameplay logic must live in separate resources/modules.
23
-
24
- ## Installation
25
-
26
- ```bash
27
- pnpm add @open-core/framework reflect-metadata tsyringe zod uuid
28
- ```
29
-
30
- This framework uses TypeScript decorators. Ensure your project has decorators enabled.
31
-
32
- ## Imports and entry points
33
-
34
- The package exposes subpath entry points:
35
-
36
- - `@open-core/framework` (root)
37
- - `@open-core/framework/server`
38
- - `@open-core/framework/client`
39
- - `@open-core/framework/shared`
40
- - `@open-core/framework/utils`
41
-
42
- Most projects will import the `Server`/`Client` namespaces:
43
-
44
- ```ts
45
- import { Server } from '@open-core/framework'
46
- ```
47
-
48
- ## Architecture
49
-
50
- OpenCore follows a Ports & Adapters (Hexagonal) architecture.
51
-
52
- - Kernel (`src/kernel`): engine-agnostic infrastructure (DI, logger, metadata scanning)
53
- - Runtime (`src/runtime`): multiplayer execution model (controllers, processors, security, lifecycle)
54
- - Adapters (`src/adapters`): platform integration (FiveM, Node testing)
55
-
56
- The runtime never auto-detects the platform. Adapters are selected explicitly at bootstrap time.
57
-
58
- ## Operating modes
59
-
60
- Each instance runs in exactly one mode configured via `Server.init()`:
61
-
62
- - `CORE`: authoritative runtime. Typically provides identity/auth/players via exports.
63
- - `RESOURCE`: a normal FiveM resource using CORE as provider for some features.
64
- - `STANDALONE`: a self-contained runtime (useful for tooling, simulations, or small servers).
65
-
66
- ## Server bootstrap
67
-
68
- Initialize the server runtime:
69
-
70
- ```ts
71
- import { Server } from '@open-core/framework/server'
72
-
73
- await Server.init({
74
- mode: 'STANDALONE',
75
- features: {
76
- commands: { enabled: true },
77
- netEvents: { enabled: true },
78
- },
79
- })
80
- ```
81
-
82
- Some features require providers (depending on your mode and configuration). Configure them before calling `init()`:
83
-
84
- ```ts
85
- import { Server } from '@open-core/framework/server'
86
-
87
- Server.setPrincipalProvider(MyPrincipalProvider)
88
- Server.setAuthProvider(MyAuthProvider)
89
- Server.setSecurityHandler(MySecurityHandler)
90
- Server.setPersistenceProvider(MyPlayerPersistence)
91
- Server.setNetEventSecurityObserver(MyNetEventSecurityObserver)
92
- ```
93
-
94
- ## Controllers and decorators
95
-
96
- OpenCore uses a decorator + processor pattern.
97
-
98
- Decorators store metadata with `Reflect.defineMetadata()`. During bootstrap, the `MetadataScanner` reads metadata and processors register handlers.
99
-
100
- ### Commands
101
-
102
- ```ts
103
- import { Server } from '@open-core/framework/server'
104
- import { z } from 'zod'
105
-
106
- const TransferSchema = z.tuple([z.coerce.number().int().positive(), z.coerce.number().min(1)])
107
-
108
- @Server.Controller()
109
- export class BankController {
110
- @Server.Command({
111
- command: 'transfer',
112
- usage: '/transfer <id> <amount>',
113
- schema: TransferSchema,
114
- })
115
- @Server.Guard({ rank: 1 })
116
- @Server.Throttle(1, 2000)
117
- async transfer(player: Server.Player, args: z.infer<typeof TransferSchema>) {
118
- const [targetId, amount] = args
119
- player.emit('chat:message', `transfer -> ${targetId} (${amount})`)
120
- }
121
- }
122
- ```
123
-
124
- ### Network events
125
-
126
- `@OnNet()` handlers always receive `Player` as the first parameter.
127
-
128
- ```ts
129
- import { Server } from '@open-core/framework/server'
130
- import { z } from 'zod'
131
-
132
- const PayloadSchema = z.object({ action: z.string(), amount: z.number().int().positive() })
133
-
134
- @Server.Controller()
135
- export class ExampleNetController {
136
- @Server.OnNet('bank:action', { schema: PayloadSchema })
137
- async onBankAction(player: Server.Player, payload: z.infer<typeof PayloadSchema>) {
138
- player.emit('chat:message', `action=${payload.action} amount=${payload.amount}`)
139
- }
140
- }
141
- ```
142
-
143
- ### Security decorators
144
-
145
- - `@Guard({ rank })` or `@Guard({ permission })`
146
- - `@Throttle(limit, windowMs)`
147
- - `@RequiresState({ missing: [...] })`
148
-
149
- ## Testing
150
-
151
- Tests run with Vitest.
152
-
153
- ```bash
154
- pnpm test
155
- pnpm test:unit
156
- pnpm test:integration
157
- pnpm test:coverage
158
- ```
159
-
160
- Note: `pnpm test` does not run benchmarks.
161
-
162
- ## Benchmarks
163
-
164
- There are two benchmark suites:
165
-
166
- - Core benchmarks (Tinybench)
167
- - Load benchmarks (Vitest project `benchmark`)
168
-
169
- ```bash
170
- pnpm bench:core
171
- pnpm bench:load
172
- pnpm bench:all
173
- ```
174
-
175
- ### Snapshot (latest local run)
176
-
177
- These values are a small extract from a recent local run (Dec 22, 2025). Results vary by machine.
178
-
179
- - **Core**
180
- - Decorators - Define metadata (Command): `~5.72M ops/sec` (mean `0.17μs`)
181
- - EventBus - Multiple event types: `~2.01M ops/sec` (mean `0.50μs`)
182
- - Dependency Injection (simple resolve): `~1.7M ops/sec`
183
- - **Load**
184
- - Net Events - Simple (10 players): `~28.85K ops/sec` (p95 `0.25ms`)
185
- - Net Events - Concurrent (500 players): `~1.18M ops/sec` (p95 `0.40ms`)
186
- - Commands (validated, ~500 players): `~14M ops/sec`
187
-
188
- Full reports and methodology are available in benchmark/README.md.
189
-
190
- ### Reports
191
-
192
- Benchmark reports are generated under `benchmark/reports/`.
193
-
194
- - `pnpm bench:all` generates aggregated reports (text/json/html)
195
- - Load metrics used by load benchmarks are persisted in `benchmark/reports/.load-metrics.json`
196
-
197
- For details about the benchmark system, see `benchmark/README.md`.
198
-
199
- ## Development scripts
200
-
201
- ```bash
202
- pnpm build
203
- pnpm watch
204
- pnpm lint
205
- pnpm lint:fix
206
- pnpm format
207
- ```
208
-
209
- ## Ecosystem
210
-
211
- OpenCore is designed to be extended via separate packages/resources.
212
-
213
- - `@open-core/identity`: identity and permission system
214
-
215
- ## License
216
-
217
- MPL-2.0. See `LICENSE`.
1
+ # OpenCore Framework (v0.2.4) Open Stable beta
2
+
3
+ OpenCore is a TypeScript multiplayer runtime framework targeting FiveM via an adapter.
4
+
5
+ It is not a gamemode or RP framework. It provides:
6
+
7
+ - A stable execution model (server and client)
8
+ - Dependency Injection and metadata-driven wiring
9
+ - An event/command system
10
+ - Security primitives (validation, access control, rate limiting)
11
+
12
+ License: MPL-2.0
13
+
14
+ ## Scope
15
+
16
+ This package (`@open-core/framework`) contains transversal infrastructure only.
17
+
18
+ - Controllers, services, decorators, and processors
19
+ - Session/lifecycle primitives and contracts
20
+ - Adapters and capability registration
21
+
22
+ Gameplay logic must live in separate resources/modules.
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ pnpm add @open-core/framework reflect-metadata tsyringe zod uuid
28
+ ```
29
+
30
+ This framework uses TypeScript decorators. Ensure your project has decorators enabled.
31
+
32
+ ## Imports and entry points
33
+
34
+ The package exposes subpath entry points:
35
+
36
+ - `@open-core/framework` (root)
37
+ - `@open-core/framework/server`
38
+ - `@open-core/framework/client`
39
+ - `@open-core/framework/shared`
40
+ - `@open-core/framework/utils`
41
+
42
+ Most projects will import the `Server`/`Client` namespaces:
43
+
44
+ ```ts
45
+ import { Server } from '@open-core/framework'
46
+ ```
47
+
48
+ ## Architecture
49
+
50
+ OpenCore follows a Ports & Adapters (Hexagonal) architecture.
51
+
52
+ - Kernel (`src/kernel`): engine-agnostic infrastructure (DI, logger, metadata scanning)
53
+ - Runtime (`src/runtime`): multiplayer execution model (controllers, processors, security, lifecycle)
54
+ - Adapters (`src/adapters`): platform integration (FiveM, Node testing)
55
+
56
+ The runtime never auto-detects the platform. Adapters are selected explicitly at bootstrap time.
57
+
58
+ ## Operating modes
59
+
60
+ Each instance runs in exactly one mode configured via `Server.init()`:
61
+
62
+ - `CORE`: authoritative runtime. Typically provides identity/auth/players via exports.
63
+ - `RESOURCE`: a normal FiveM resource using CORE as provider for some features.
64
+ - `STANDALONE`: a self-contained runtime (useful for tooling, simulations, or small servers).
65
+
66
+ ## Server bootstrap
67
+
68
+ Initialize the server runtime:
69
+
70
+ ```ts
71
+ import { Server } from '@open-core/framework/server'
72
+
73
+ await Server.init({
74
+ mode: 'STANDALONE',
75
+ features: {
76
+ commands: { enabled: true },
77
+ netEvents: { enabled: true },
78
+ },
79
+ })
80
+ ```
81
+
82
+ Some features require providers (depending on your mode and configuration). Configure them before calling `init()`:
83
+
84
+ ```ts
85
+ import { Server } from '@open-core/framework/server'
86
+
87
+ Server.setPrincipalProvider(MyPrincipalProvider)
88
+ Server.setAuthProvider(MyAuthProvider)
89
+ Server.setSecurityHandler(MySecurityHandler)
90
+ Server.setPersistenceProvider(MyPlayerPersistence)
91
+ Server.setNetEventSecurityObserver(MyNetEventSecurityObserver)
92
+ ```
93
+
94
+ ## Controllers and decorators
95
+
96
+ OpenCore uses a decorator + processor pattern.
97
+
98
+ Decorators store metadata with `Reflect.defineMetadata()`. During bootstrap, the `MetadataScanner` reads metadata and processors register handlers.
99
+
100
+ ### Commands
101
+
102
+ ```ts
103
+ import { Server } from '@open-core/framework/server'
104
+ import { z } from 'zod'
105
+
106
+ const TransferSchema = z.tuple([z.coerce.number().int().positive(), z.coerce.number().min(1)])
107
+
108
+ @Server.Controller()
109
+ export class BankController {
110
+ @Server.Command({
111
+ command: 'transfer',
112
+ usage: '/transfer <id> <amount>',
113
+ schema: TransferSchema,
114
+ })
115
+ @Server.Guard({ rank: 1 })
116
+ @Server.Throttle(1, 2000)
117
+ async transfer(player: Server.Player, args: z.infer<typeof TransferSchema>) {
118
+ const [targetId, amount] = args
119
+ player.emit('chat:message', `transfer -> ${targetId} (${amount})`)
120
+ }
121
+ }
122
+ ```
123
+
124
+ ### Network events
125
+
126
+ `@OnNet()` handlers always receive `Player` as the first parameter.
127
+
128
+ ```ts
129
+ import { Server } from '@open-core/framework/server'
130
+ import { z } from 'zod'
131
+
132
+ const PayloadSchema = z.object({ action: z.string(), amount: z.number().int().positive() })
133
+
134
+ @Server.Controller()
135
+ export class ExampleNetController {
136
+ @Server.OnNet('bank:action', { schema: PayloadSchema })
137
+ async onBankAction(player: Server.Player, payload: z.infer<typeof PayloadSchema>) {
138
+ player.emit('chat:message', `action=${payload.action} amount=${payload.amount}`)
139
+ }
140
+ }
141
+ ```
142
+
143
+ ### Security decorators
144
+
145
+ - `@Guard({ rank })` or `@Guard({ permission })`
146
+ - `@Throttle(limit, windowMs)`
147
+ - `@RequiresState({ missing: [...] })`
148
+
149
+ ## Testing
150
+
151
+ Tests run with Vitest.
152
+
153
+ ```bash
154
+ pnpm test
155
+ pnpm test:unit
156
+ pnpm test:integration
157
+ pnpm test:coverage
158
+ ```
159
+
160
+ Note: `pnpm test` does not run benchmarks.
161
+
162
+ ## Benchmarks
163
+
164
+ There are two benchmark suites:
165
+
166
+ - Core benchmarks (Tinybench)
167
+ - Load benchmarks (Vitest project `benchmark`)
168
+
169
+ ```bash
170
+ pnpm bench:core
171
+ pnpm bench:load
172
+ pnpm bench:all
173
+ ```
174
+
175
+ ### Snapshot (latest local run)
176
+
177
+ These values are a small extract from a recent local run (Dec 22, 2025). Results vary by machine.
178
+
179
+ - **Core**
180
+ - Decorators - Define metadata (Command): `~5.72M ops/sec` (mean `0.17μs`)
181
+ - EventBus - Multiple event types: `~2.01M ops/sec` (mean `0.50μs`)
182
+ - Dependency Injection (simple resolve): `~1.7M ops/sec`
183
+ - **Load**
184
+ - Net Events - Simple (10 players): `~28.85K ops/sec` (p95 `0.25ms`)
185
+ - Net Events - Concurrent (500 players): `~1.18M ops/sec` (p95 `0.40ms`)
186
+ - Commands (validated, ~500 players): `~14M ops/sec`
187
+
188
+ Full reports and methodology are available in benchmark/README.md.
189
+
190
+ ### Reports
191
+
192
+ Benchmark reports are generated under `benchmark/reports/`.
193
+
194
+ - `pnpm bench:all` generates aggregated reports (text/json/html)
195
+ - Load metrics used by load benchmarks are persisted in `benchmark/reports/.load-metrics.json`
196
+
197
+ For details about the benchmark system, see `benchmark/README.md`.
198
+
199
+ ## Development scripts
200
+
201
+ ```bash
202
+ pnpm build
203
+ pnpm watch
204
+ pnpm lint
205
+ pnpm lint:fix
206
+ pnpm format
207
+ ```
208
+
209
+ ## Ecosystem
210
+
211
+ OpenCore is designed to be extended via separate packages/resources.
212
+
213
+ - `@open-core/identity`: identity and permission system
214
+
215
+ ## License
216
+
217
+ MPL-2.0. See `LICENSE`.
@@ -68,6 +68,9 @@ let NodeEntityServer = class NodeEntityServer extends IEntityServer_1.IEntitySer
68
68
  this.stateBags.set(handle, new Map());
69
69
  }
70
70
  const bag = this.stateBags.get(handle);
71
+ if (!bag) {
72
+ throw new Error(`[OpenCore] NodeEntityServer state bag missing for handle ${handle}`);
73
+ }
71
74
  return {
72
75
  set: (key, value) => {
73
76
  bag.set(key, value);
@@ -5,7 +5,7 @@ import { IExports } from '../contracts/IExports';
5
5
  */
6
6
  export declare class NodeExports implements IExports {
7
7
  private exports;
8
- register(exportName: string, handler: Function): void;
8
+ register(exportName: string, handler: (...args: any[]) => any): void;
9
9
  getResource(resourceName: string): any;
10
10
  /**
11
11
  * Get all registered exports as an object
@@ -18,7 +18,7 @@ export declare class NodeExports implements IExports {
18
18
  /**
19
19
  * Utility method for testing: get a specific export
20
20
  */
21
- getExport(exportName: string): Function | undefined;
21
+ getExport(exportName: string): ((...args: any[]) => any) | undefined;
22
22
  /**
23
23
  * Utility method for testing: clear all exports
24
24
  */
@@ -4,6 +4,7 @@ export type Vector3 = {
4
4
  z: number;
5
5
  };
6
6
  export declare class Vec3 {
7
+ private constructor();
7
8
  static create(x: number, y: number, z: number): Vector3;
8
9
  static clone(v: Vector3): Vector3;
9
10
  static add(a: Vector3, b: Vector3): Vector3;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Vec3 = void 0;
4
4
  class Vec3 {
5
+ constructor() { }
5
6
  static create(x, y, z) {
6
7
  return { x, y, z };
7
8
  }
@@ -129,6 +129,10 @@ let AppearanceService = class AppearanceService {
129
129
  components: {},
130
130
  props: {},
131
131
  };
132
+ if (!appearance.components)
133
+ appearance.components = {};
134
+ if (!appearance.props)
135
+ appearance.props = {};
132
136
  // Components (0-11)
133
137
  for (let i = 0; i <= 11; i++) {
134
138
  const drawable = this.pedAdapter.getDrawableVariation(ped, i);
@@ -37,8 +37,8 @@ exports.initServer = initServer;
37
37
  const register_capabilities_1 = require("../../adapters/register-capabilities");
38
38
  const index_1 = require("../../kernel/di/index");
39
39
  const logger_1 = require("../../kernel/shared/logger");
40
- const index_2 = require("./contracts/index");
41
40
  const bootstrap_validation_1 = require("./bootstrap.validation");
41
+ const index_2 = require("./contracts/index");
42
42
  const controller_1 = require("./decorators/controller");
43
43
  const runtime_1 = require("./runtime");
44
44
  const services_register_1 = require("./services/services.register");
@@ -84,6 +84,8 @@ function validatePersistence() {
84
84
  if (!parsed.success)
85
85
  return zodIssuesToLines('persistence', parsed.error);
86
86
  if (adapter === 'resource') {
87
+ if (!resourceName)
88
+ return ['persistence.resourceName: Missing opencore_db_resource'];
87
89
  const db = exports[resourceName];
88
90
  if (!db) {
89
91
  return [
@@ -0,0 +1,6 @@
1
+ import { InternalEventMap } from '../types/internal-events';
2
+ type InternalEventName = keyof InternalEventMap;
3
+ type InternalEventHandler<E extends InternalEventName> = (payload: InternalEventMap[E]) => void;
4
+ export declare function onFrameworkEvent<E extends InternalEventName>(event: E, handler: InternalEventHandler<E>): () => void;
5
+ export declare function emitFrameworkEvent<E extends InternalEventName>(event: E, payload: InternalEventMap[E]): void;
6
+ export {};
@@ -5,8 +5,11 @@ exports.emitFrameworkEvent = emitFrameworkEvent;
5
5
  const logger_1 = require("../../../kernel/shared/logger");
6
6
  const handlers = {};
7
7
  function onFrameworkEvent(event, handler) {
8
- var _a;
9
- const list = ((_a = handlers[event]) !== null && _a !== void 0 ? _a : (handlers[event] = []));
8
+ let list = handlers[event];
9
+ if (!list) {
10
+ list = [];
11
+ handlers[event] = list;
12
+ }
10
13
  list.push(handler);
11
14
  return () => {
12
15
  const index = list.indexOf(handler);
@@ -16,8 +16,8 @@ exports.PrincipalExportController = void 0;
16
16
  const tsyringe_1 = require("tsyringe");
17
17
  const utils_1 = require("../../../kernel/utils");
18
18
  const index_1 = require("../contracts/index");
19
- const index_2 = require("../decorators/index");
20
19
  const export_1 = require("../decorators/export");
20
+ const index_2 = require("../decorators/index");
21
21
  const player_directory_port_1 = require("../services/ports/player-directory.port");
22
22
  /**
23
23
  * Exports principal/permission functionality for RESOURCE mode access.
@@ -11,7 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.SessionController = void 0;
13
13
  const shared_1 = require("../../../kernel/shared");
14
- const core_event_bus_1 = require("../bus/core-event-bus");
14
+ const internal_event_bus_1 = require("../bus/internal-event.bus");
15
15
  const decorators_1 = require("../decorators");
16
16
  const onFiveMEvent_1 = require("../decorators/onFiveMEvent");
17
17
  const services_1 = require("../services");
@@ -33,12 +33,12 @@ let SessionController = class SessionController {
33
33
  license: license !== null && license !== void 0 ? license : 'none',
34
34
  });
35
35
  await this.persistance.handleSessionLoad(player);
36
- (0, core_event_bus_1.emitFrameworkEvent)('core:playerSessionCreated', { clientId, license });
36
+ (0, internal_event_bus_1.emitFrameworkEvent)('internal:playerSessionCreated', { clientId, license });
37
37
  setImmediate(() => {
38
38
  const currentPlayer = this.playerDirectory.getByClient(clientId);
39
39
  if (!currentPlayer)
40
40
  return;
41
- (0, core_event_bus_1.emitFrameworkEvent)('core:playerFullyConnected', { clientId, license });
41
+ (0, internal_event_bus_1.emitFrameworkEvent)('internal:playerFullyConnected', currentPlayer);
42
42
  });
43
43
  }
44
44
  async onPlayerDropped() {
@@ -48,7 +48,7 @@ let SessionController = class SessionController {
48
48
  await this.persistance.handleSessionSave(player);
49
49
  }
50
50
  this.playerSessionLifecycle.unbind(clientId);
51
- (0, core_event_bus_1.emitFrameworkEvent)('core:playerSessionDestroyed', { clientId });
51
+ (0, internal_event_bus_1.emitFrameworkEvent)('internal:playerSessionDestroyed', { clientId });
52
52
  shared_1.loggers.session.info(`Player session destroyed`, { clientId });
53
53
  }
54
54
  };
@@ -1,4 +1,9 @@
1
- import { CoreEventMap } from '../types/core-events';
1
+ import { InternalEventMap } from '../types/internal-events';
2
+ /**
3
+ * Handler function type for framework events.
4
+ * Accepts the event payload and returns void or Promise<void>.
5
+ */
6
+ type FrameworkEventHandler<K extends keyof InternalEventMap> = (payload: InternalEventMap[K]) => void | Promise<void>;
2
7
  /**
3
8
  * Registers a method as a listener for an internal OpenCore framework event.
4
9
  *
@@ -6,17 +11,21 @@ import { CoreEventMap } from '../types/core-events';
6
11
  * This decorator only stores metadata. The framework binds listeners during bootstrap by scanning
7
12
  * controller methods.
8
13
  *
9
- * @param event - Core event name, strongly typed to {@link CoreEventMap}.
14
+ * The method signature is type-checked against the event payload. TypeScript will error if
15
+ * the handler parameter type doesn't match the expected payload for the specified event.
16
+ *
17
+ * @param event - Core event name, strongly typed to {@link InternalEventMap}.
10
18
  *
11
19
  * @example
12
20
  * ```ts
13
21
  * @Server.Controller()
14
22
  * export class SystemController {
15
- * @Server.OnFrameworkEvent('server:ready')
16
- * onServerReady() {
17
- * console.log('OpenCore framework is ready')
23
+ * @Server.OnFrameworkEvent('core:playerSessionCreated')
24
+ * onPlayerSession(payload: PlayerSessionCreatedPayload) {
25
+ * console.log(`Player ${payload.clientId} connected`)
18
26
  * }
19
27
  * }
20
28
  * ```
21
29
  */
22
- export declare function OnFrameworkEvent<K extends keyof CoreEventMap>(event: K): (target: any, propertyKey: string) => void;
30
+ export declare function OnFrameworkEvent<K extends keyof InternalEventMap>(event: K): (target: object, propertyKey: string | symbol, _descriptor: TypedPropertyDescriptor<FrameworkEventHandler<K>>) => void;
31
+ export {};
@@ -9,21 +9,24 @@ const metadata_server_keys_1 = require("../system/metadata-server.keys");
9
9
  * This decorator only stores metadata. The framework binds listeners during bootstrap by scanning
10
10
  * controller methods.
11
11
  *
12
- * @param event - Core event name, strongly typed to {@link CoreEventMap}.
12
+ * The method signature is type-checked against the event payload. TypeScript will error if
13
+ * the handler parameter type doesn't match the expected payload for the specified event.
14
+ *
15
+ * @param event - Core event name, strongly typed to {@link InternalEventMap}.
13
16
  *
14
17
  * @example
15
18
  * ```ts
16
19
  * @Server.Controller()
17
20
  * export class SystemController {
18
- * @Server.OnFrameworkEvent('server:ready')
19
- * onServerReady() {
20
- * console.log('OpenCore framework is ready')
21
+ * @Server.OnFrameworkEvent('core:playerSessionCreated')
22
+ * onPlayerSession(payload: PlayerSessionCreatedPayload) {
23
+ * console.log(`Player ${payload.clientId} connected`)
21
24
  * }
22
25
  * }
23
26
  * ```
24
27
  */
25
28
  function OnFrameworkEvent(event) {
26
- return (target, propertyKey) => {
27
- Reflect.defineMetadata(metadata_server_keys_1.METADATA_KEYS.CORE_EVENT, { event }, target, propertyKey);
29
+ return (target, propertyKey, _descriptor) => {
30
+ Reflect.defineMetadata(metadata_server_keys_1.METADATA_KEYS.INTERNAL_EVENT, { event }, target, propertyKey);
28
31
  };
29
32
  }