@arikajs/events 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ArikaJs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,203 @@
1
+
2
+ ## Arika Events
3
+
4
+ `@arikajs/events` is the event dispatching and listener system for the ArikaJS framework.
5
+
6
+ It provides a clean, expressive way to decouple application logic using events and listeners — enabling scalable, maintainable, and testable architectures.
7
+
8
+ This package is part of the ArikaJS framework and provides a robust event system for Node.js and TypeScript applications.
9
+
10
+ ---
11
+
12
+ ## ✨ Features
13
+
14
+ - **Event dispatching**: Centralized event management
15
+ - **Multiple listeners per event**: Support for one-to-many event handling
16
+ - **Class-based events & listeners**: Structured, object-oriented approach
17
+ - **Automatic dependency injection**: Resolving listeners via the service container
18
+ - **Sync and async listeners**: Flexible execution models
19
+ - **Queue-ready architecture**: Designed for background processing
20
+ - **Simple, expressive API**: Easy to use and understand
21
+
22
+ ---
23
+
24
+ ## 📦 Installation
25
+
26
+ ```bash
27
+ npm install @arikajs/events
28
+ # or
29
+ yarn add @arikajs/events
30
+ # or
31
+ pnpm add @arikajs/events
32
+ ```
33
+
34
+ ---
35
+
36
+ ## 🚀 Quick Start
37
+
38
+ ### Dispatching an Event
39
+
40
+ ```ts
41
+ import { Event } from '@arikajs/events';
42
+
43
+ Event.dispatch(new UserRegistered(user));
44
+ ```
45
+
46
+ ### Listening to Events
47
+
48
+ ```ts
49
+ import { Event } from '@arikajs/events';
50
+
51
+ Event.listen(UserRegistered, SendWelcomeEmail);
52
+ ```
53
+
54
+ ### 🧠 Class-Based Events
55
+
56
+ ```ts
57
+ export class UserRegistered {
58
+ constructor(public user: any) {}
59
+ }
60
+ ```
61
+
62
+ ### 🎧 Listeners
63
+
64
+ ```ts
65
+ export class SendWelcomeEmail {
66
+ async handle(event: UserRegistered) {
67
+ // send email
68
+ }
69
+ }
70
+ ```
71
+
72
+ Listeners are automatically resolved via the service container.
73
+
74
+ ---
75
+
76
+ ## 🔁 Async & Queued Listeners
77
+
78
+ Listeners can be marked as asynchronous:
79
+
80
+ ```ts
81
+ export class LogRegistration {
82
+ shouldQueue = true;
83
+
84
+ async handle(event: any) {
85
+ // queued execution
86
+ }
87
+ }
88
+ ```
89
+
90
+ (Queue integration is enabled via `@arikajs/queue`.)
91
+
92
+ ---
93
+
94
+ ## ⚙️ Configuration
95
+
96
+ Event configuration fits naturally within your application structure:
97
+
98
+ ```ts
99
+ export default {
100
+ events: {
101
+ UserRegistered: [
102
+ SendWelcomeEmail,
103
+ LogRegistration
104
+ ]
105
+ }
106
+ };
107
+ ```
108
+
109
+ ---
110
+
111
+ ## 📚 API Reference
112
+
113
+ ### `Event.dispatch(event)`
114
+
115
+ Dispatch an event instance.
116
+
117
+ ```ts
118
+ Event.dispatch(new OrderPlaced(order));
119
+ ```
120
+
121
+ ### `Event.listen(event, listener)`
122
+
123
+ Register a listener for a specific event class.
124
+
125
+ ```ts
126
+ Event.listen(OrderPlaced, ProcessPayment);
127
+ ```
128
+
129
+ ### `Event.forget(event)`
130
+
131
+ Remove all listeners for an event.
132
+
133
+ ```ts
134
+ Event.forget(OrderPlaced);
135
+ ```
136
+
137
+ ---
138
+
139
+ ## 🧠 Architecture
140
+
141
+ ```
142
+ events/
143
+ ├── src/
144
+ │ ├── EventManager.ts ← Central event dispatcher
145
+ │ ├── ListenerResolver.ts ← Resolves listeners via DI
146
+ │ ├── Dispatcher.ts ← Executes listeners
147
+ │ ├── Contracts/
148
+ │ │ └── Listener.ts
149
+ │ ├── Exceptions/
150
+ │ │ └── EventException.ts
151
+ │ └── index.ts
152
+ ├── tests/
153
+ ├── package.json
154
+ ├── tsconfig.json
155
+ ├── README.md
156
+ └── LICENSE
157
+ ```
158
+
159
+ ---
160
+
161
+ ## 🔗 Integration with ArikaJS
162
+
163
+ `@arikajs/events` integrates with:
164
+
165
+ - **`@arikajs/mail`** → email triggers
166
+ - **`@arikajs/queue`** → async listeners
167
+ - **`@arikajs/logging`** → event logs
168
+ - **`@arikajs/auth`** → auth lifecycle hooks
169
+
170
+ ---
171
+
172
+ ## 🧪 Testing
173
+
174
+ Events and listeners can be faked or mocked for tests:
175
+
176
+ ```ts
177
+ Event.fake();
178
+ Event.assertDispatched(UserRegistered);
179
+ ```
180
+
181
+ (Test helpers planned.)
182
+
183
+ ---
184
+
185
+ ## 🛣 Roadmap
186
+
187
+ - [ ] Event subscribers
188
+ - [ ] Wildcard events
189
+ - [ ] Listener priorities
190
+ - [ ] Event discovery
191
+ - [ ] Event caching
192
+
193
+ ---
194
+
195
+ ## 📄 License
196
+
197
+ `@arikajs/events` is open-source software licensed under the **MIT License**.
198
+
199
+ ---
200
+
201
+ ## 🧭 Philosophy
202
+
203
+ > "Great systems don’t call each other — they react."
@@ -0,0 +1,5 @@
1
+ export interface Listener {
2
+ handle(event: any): Promise<void> | void;
3
+ shouldQueue?: boolean;
4
+ }
5
+ //# sourceMappingURL=Listener.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Listener.d.ts","sourceRoot":"","sources":["../../src/Contracts/Listener.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,QAAQ;IACrB,MAAM,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACzC,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Listener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Listener.js","sourceRoot":"","sources":["../../src/Contracts/Listener.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import { Listener } from './Contracts/Listener';
2
+ export declare class Dispatcher {
3
+ private resolver;
4
+ constructor(resolver: (listener: any) => Promise<Listener>);
5
+ dispatch(event: any, listeners: any[]): Promise<void>;
6
+ }
7
+ //# sourceMappingURL=Dispatcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dispatcher.d.ts","sourceRoot":"","sources":["../src/Dispatcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,qBAAa,UAAU;IACP,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,OAAO,CAAC,QAAQ,CAAC;IAE5D,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAgC9D"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Dispatcher = void 0;
4
+ const EventException_1 = require("./Exceptions/EventException");
5
+ class Dispatcher {
6
+ constructor(resolver) {
7
+ this.resolver = resolver;
8
+ }
9
+ async dispatch(event, listeners) {
10
+ for (const listenerClass of listeners) {
11
+ let listener;
12
+ try {
13
+ // If it's already an instance
14
+ if (typeof listenerClass !== 'function') {
15
+ listener = listenerClass;
16
+ }
17
+ else {
18
+ // Resolve via the resolver (DI container usually)
19
+ listener = await this.resolver(listenerClass);
20
+ }
21
+ }
22
+ catch (error) {
23
+ throw new EventException_1.EventException(`Failed to resolve listener: ${error.message}`);
24
+ }
25
+ if (!listener || typeof listener.handle !== 'function') {
26
+ throw new EventException_1.EventException(`Listener [${listenerClass.name || listenerClass}] must implement handle() method.`);
27
+ }
28
+ // Check if queue implementation is needed later
29
+ if (listener.shouldQueue) {
30
+ // In a real app, this would push to queue
31
+ // For now we await it just like sync, or we could fire & forget
32
+ // await this.queue.push(listener, event);
33
+ // mocking queue behavior by running async without blocking if we wanted
34
+ await listener.handle(event);
35
+ }
36
+ else {
37
+ await listener.handle(event);
38
+ }
39
+ }
40
+ }
41
+ }
42
+ exports.Dispatcher = Dispatcher;
43
+ //# sourceMappingURL=Dispatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dispatcher.js","sourceRoot":"","sources":["../src/Dispatcher.ts"],"names":[],"mappings":";;;AAEA,gEAA6D;AAE7D,MAAa,UAAU;IACnB,YAAoB,QAA8C;QAA9C,aAAQ,GAAR,QAAQ,CAAsC;IAAI,CAAC;IAEvE,KAAK,CAAC,QAAQ,CAAC,KAAU,EAAE,SAAgB;QACvC,KAAK,MAAM,aAAa,IAAI,SAAS,EAAE,CAAC;YACpC,IAAI,QAAkB,CAAC;YAEvB,IAAI,CAAC;gBACD,8BAA8B;gBAC9B,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE,CAAC;oBACtC,QAAQ,GAAG,aAAa,CAAC;gBAC7B,CAAC;qBAAM,CAAC;oBACJ,kDAAkD;oBAClD,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;gBAClD,CAAC;YACL,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBAClB,MAAM,IAAI,+BAAc,CAAC,+BAA+B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAC7E,CAAC;YAED,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;gBACrD,MAAM,IAAI,+BAAc,CAAC,aAAa,aAAa,CAAC,IAAI,IAAI,aAAa,mCAAmC,CAAC,CAAC;YAClH,CAAC;YAED,gDAAgD;YAChD,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;gBACvB,0CAA0C;gBAC1C,gEAAgE;gBAChE,0CAA0C;gBAC1C,wEAAwE;gBACxE,MAAM,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACjC,CAAC;iBAAM,CAAC;gBACJ,MAAM,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACjC,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AAnCD,gCAmCC"}
@@ -0,0 +1,13 @@
1
+ import { ListenerResolver } from './ListenerResolver';
2
+ export declare class EventManager {
3
+ private listeners;
4
+ private dispatcher;
5
+ private resolver;
6
+ constructor(resolver?: ListenerResolver);
7
+ listen(event: any, listener: any): this;
8
+ forget(event: any): this;
9
+ dispatch(event: any): Promise<void>;
10
+ fake(): void;
11
+ assertDispatched(event: any): void;
12
+ }
13
+ //# sourceMappingURL=EventManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventManager.d.ts","sourceRoot":"","sources":["../src/EventManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,qBAAa,YAAY;IACrB,OAAO,CAAC,SAAS,CAA8B;IAC/C,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAmB;gBAEvB,QAAQ,CAAC,EAAE,gBAAgB;IAKhC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG;IAQhC,MAAM,CAAC,KAAK,EAAE,GAAG;IAKX,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBzC,IAAI;IAIJ,gBAAgB,CAAC,KAAK,EAAE,GAAG;CAGrC"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EventManager = void 0;
4
+ const Dispatcher_1 = require("./Dispatcher");
5
+ const ListenerResolver_1 = require("./ListenerResolver");
6
+ class EventManager {
7
+ constructor(resolver) {
8
+ this.listeners = new Map();
9
+ this.resolver = resolver || new ListenerResolver_1.ListenerResolver();
10
+ this.dispatcher = new Dispatcher_1.Dispatcher((ln) => this.resolver.resolve(ln));
11
+ }
12
+ listen(event, listener) {
13
+ if (!this.listeners.has(event)) {
14
+ this.listeners.set(event, []);
15
+ }
16
+ this.listeners.get(event)?.push(listener);
17
+ return this;
18
+ }
19
+ forget(event) {
20
+ this.listeners.delete(event);
21
+ return this;
22
+ }
23
+ async dispatch(event) {
24
+ let listeners = [];
25
+ // Find listeners for this event instance
26
+ // If event is an object, try to match its constructor
27
+ let eventKey = event.constructor;
28
+ if (this.listeners.has(eventKey)) {
29
+ listeners = this.listeners.get(eventKey);
30
+ }
31
+ // Also check if we dispatched a class directly (rare but possible in some patterns)
32
+ if (typeof event === 'function' && this.listeners.has(event)) {
33
+ listeners = listeners.concat(this.listeners.get(event));
34
+ }
35
+ // TODO: Wildcard listeners
36
+ if (listeners.length > 0) {
37
+ await this.dispatcher.dispatch(event, listeners);
38
+ }
39
+ }
40
+ // Testing helpers
41
+ fake() {
42
+ // Implement fake logic for testing
43
+ }
44
+ assertDispatched(event) {
45
+ // Implement assertion
46
+ }
47
+ }
48
+ exports.EventManager = EventManager;
49
+ //# sourceMappingURL=EventManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventManager.js","sourceRoot":"","sources":["../src/EventManager.ts"],"names":[],"mappings":";;;AACA,6CAA0C;AAC1C,yDAAsD;AAGtD,MAAa,YAAY;IAKrB,YAAY,QAA2B;QAJ/B,cAAS,GAAoB,IAAI,GAAG,EAAE,CAAC;QAK3C,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,IAAI,mCAAgB,EAAE,CAAC;QACnD,IAAI,CAAC,UAAU,GAAG,IAAI,uBAAU,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IACxE,CAAC;IAEM,MAAM,CAAC,KAAU,EAAE,QAAa;QACnC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAClC,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,MAAM,CAAC,KAAU;QACpB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,KAAU;QAC5B,IAAI,SAAS,GAAU,EAAE,CAAC;QAE1B,yCAAyC;QACzC,sDAAsD;QACtD,IAAI,QAAQ,GAAG,KAAK,CAAC,WAAW,CAAC;QACjC,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/B,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC;QAC9C,CAAC;QAED,oFAAoF;QACpF,IAAI,OAAO,KAAK,KAAK,UAAU,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3D,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,CAAC;QAC7D,CAAC;QAED,2BAA2B;QAE3B,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QACrD,CAAC;IACL,CAAC;IAED,kBAAkB;IACX,IAAI;QACP,mCAAmC;IACvC,CAAC;IAEM,gBAAgB,CAAC,KAAU;QAC9B,sBAAsB;IAC1B,CAAC;CACJ;AArDD,oCAqDC"}
@@ -0,0 +1,4 @@
1
+ export declare class EventException extends Error {
2
+ constructor(message: string);
3
+ }
4
+ //# sourceMappingURL=EventException.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventException.d.ts","sourceRoot":"","sources":["../../src/Exceptions/EventException.ts"],"names":[],"mappings":"AACA,qBAAa,cAAe,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAI9B"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EventException = void 0;
4
+ class EventException extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ this.name = 'EventException';
8
+ }
9
+ }
10
+ exports.EventException = EventException;
11
+ //# sourceMappingURL=EventException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventException.js","sourceRoot":"","sources":["../../src/Exceptions/EventException.ts"],"names":[],"mappings":";;;AACA,MAAa,cAAe,SAAQ,KAAK;IACrC,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IACjC,CAAC;CACJ;AALD,wCAKC"}
@@ -0,0 +1,5 @@
1
+ import { Listener } from './Contracts/Listener';
2
+ export declare class ListenerResolver {
3
+ resolve(listener: any): Promise<Listener>;
4
+ }
5
+ //# sourceMappingURL=ListenerResolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListenerResolver.d.ts","sourceRoot":"","sources":["../src/ListenerResolver.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,qBAAa,gBAAgB;IAGnB,OAAO,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC;CAWlD"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ListenerResolver = void 0;
4
+ const EventException_1 = require("./Exceptions/EventException");
5
+ class ListenerResolver {
6
+ // This would typically interface with the service container
7
+ // For now we do a simple instantiation
8
+ async resolve(listener) {
9
+ if (typeof listener === 'function') {
10
+ try {
11
+ // @ts-ignore - Assuming no-arg constructor or DI handles it
12
+ return new listener();
13
+ }
14
+ catch (e) {
15
+ throw new EventException_1.EventException(`Resolver failed to instantiate listener: ${e.message}`);
16
+ }
17
+ }
18
+ return listener;
19
+ }
20
+ }
21
+ exports.ListenerResolver = ListenerResolver;
22
+ //# sourceMappingURL=ListenerResolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListenerResolver.js","sourceRoot":"","sources":["../src/ListenerResolver.ts"],"names":[],"mappings":";;;AAGA,gEAA6D;AAE7D,MAAa,gBAAgB;IACzB,4DAA4D;IAC5D,uCAAuC;IACvC,KAAK,CAAC,OAAO,CAAC,QAAa;QACvB,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;YACjC,IAAI,CAAC;gBACD,4DAA4D;gBAC5D,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC1B,CAAC;YAAC,OAAO,CAAM,EAAE,CAAC;gBACd,MAAM,IAAI,+BAAc,CAAC,4CAA4C,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YACtF,CAAC;QACL,CAAC;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ;AAdD,4CAcC"}
@@ -0,0 +1,13 @@
1
+ import { EventManager } from './EventManager';
2
+ import { Listener } from './Contracts/Listener';
3
+ import { EventException } from './Exceptions/EventException';
4
+ export declare class Event {
5
+ private static instance;
6
+ static dispatch(event: any): Promise<void>;
7
+ static listen(event: any, listener: any): EventManager;
8
+ static forget(event: any): EventManager;
9
+ static fake(): void;
10
+ static setManager(manager: EventManager): void;
11
+ }
12
+ export { EventManager, Listener, EventException };
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,qBAAa,KAAK;IACd,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAoC;WAE7C,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;WAInC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG;WAIhC,MAAM,CAAC,KAAK,EAAE,GAAG;WAIjB,IAAI;WAKJ,UAAU,CAAC,OAAO,EAAE,YAAY;CAGjD;AAED,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EventException = exports.EventManager = exports.Event = void 0;
4
+ const EventManager_1 = require("./EventManager");
5
+ Object.defineProperty(exports, "EventManager", { enumerable: true, get: function () { return EventManager_1.EventManager; } });
6
+ const EventException_1 = require("./Exceptions/EventException");
7
+ Object.defineProperty(exports, "EventException", { enumerable: true, get: function () { return EventException_1.EventException; } });
8
+ class Event {
9
+ static dispatch(event) {
10
+ return this.instance.dispatch(event);
11
+ }
12
+ static listen(event, listener) {
13
+ return this.instance.listen(event, listener);
14
+ }
15
+ static forget(event) {
16
+ return this.instance.forget(event);
17
+ }
18
+ static fake() {
19
+ return this.instance.fake();
20
+ }
21
+ // Facade helper to set a custom manager
22
+ static setManager(manager) {
23
+ this.instance = manager;
24
+ }
25
+ }
26
+ exports.Event = Event;
27
+ Event.instance = new EventManager_1.EventManager();
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,iDAA8C;AA6BrC,6FA7BA,2BAAY,OA6BA;AA3BrB,gEAA6D;AA2B5B,+FA3BxB,+BAAc,OA2BwB;AAzB/C,MAAa,KAAK;IAGP,MAAM,CAAC,QAAQ,CAAC,KAAU;QAC7B,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAEM,MAAM,CAAC,MAAM,CAAC,KAAU,EAAE,QAAa;QAC1C,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC;IAEM,MAAM,CAAC,MAAM,CAAC,KAAU;QAC3B,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IAEM,MAAM,CAAC,IAAI;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IAChC,CAAC;IAED,wCAAwC;IACjC,MAAM,CAAC,UAAU,CAAC,OAAqB;QAC1C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5B,CAAC;;AAtBL,sBAuBC;AAtBkB,cAAQ,GAAiB,IAAI,2BAAY,EAAE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@arikajs/events",
3
+ "version": "0.0.1",
4
+ "description": "Event dispatching and listener system for the ArikaJS framework.",
5
+ "license": "MIT",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc -p tsconfig.json",
10
+ "build:tests": "tsc -p tsconfig.test.json",
11
+ "clean": "rm -rf dist",
12
+ "prepare": "echo skip",
13
+ "test": "npm run build && npm run build:tests && node scripts/fix-test-imports.js && node --test 'dist/tests/**/*.test.js'",
14
+ "test:watch": "npm run build && npm run build:tests && node --test --watch 'dist/tests/**/*.test.js'"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "keywords": [
20
+ "arika",
21
+ "arika-js",
22
+ "framework",
23
+ "events",
24
+ "listener",
25
+ "dispatcher",
26
+ "observer"
27
+ ],
28
+ "engines": {
29
+ "node": ">=20.0.0"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/arikajs/events.git"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/arikajs/events/issues"
37
+ },
38
+ "homepage": "https://github.com/arikajs/events#readme",
39
+ "dependencies": {},
40
+ "devDependencies": {
41
+ "@types/node": "^20.11.24",
42
+ "typescript": "^5.3.3"
43
+ },
44
+ "author": "Prakash Tank"
45
+ }