@adonisjs/events 10.1.0-next.4 → 10.2.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.
@@ -7,18 +7,22 @@ import string from "@poppinss/utils/string";
7
7
  import { AssertionError } from "node:assert";
8
8
  import diagnostics_channel from "node:diagnostics_channel";
9
9
  var __defProp = Object.defineProperty;
10
- var __exportAll = (all, symbols) => {
10
+ var __exportAll = (all, no_symbols) => {
11
11
  let target = {};
12
12
  for (var name in all) __defProp(target, name, {
13
13
  get: all[name],
14
14
  enumerable: true
15
15
  });
16
- if (symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
16
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
17
17
  return target;
18
18
  };
19
19
  var debug_default = debuglog("adonisjs:events");
20
20
  var EventsBuffer = class {
21
21
  #events = [];
22
+ #restoreFn;
23
+ constructor(restoreFn) {
24
+ this.#restoreFn = restoreFn;
25
+ }
22
26
  add(event, data) {
23
27
  this.#events.push({
24
28
  event,
@@ -79,6 +83,9 @@ var EventsBuffer = class {
79
83
  flush() {
80
84
  this.#events = [];
81
85
  }
86
+ [Symbol.dispose]() {
87
+ this.#restoreFn();
88
+ }
82
89
  };
83
90
  var tracing_channels_exports = /* @__PURE__ */ __exportAll({ eventDispatch: () => eventDispatch });
84
91
  const eventDispatch = diagnostics_channel.tracingChannel("adonisjs.event.dispatch");
@@ -205,10 +212,10 @@ var Emitter = class {
205
212
  if (Array.isArray(key)) return key[0] === listener[0] && key[1] === listener[1];
206
213
  return false;
207
214
  });
208
- const normalizedListener$1 = matchingKey ? listeners.get(matchingKey) : void 0;
209
- if (normalizedListener$1 && matchingKey) {
215
+ const normalizedListener = matchingKey ? listeners.get(matchingKey) : void 0;
216
+ if (normalizedListener && matchingKey) {
210
217
  listeners.delete(matchingKey);
211
- this.#transport.off(normalizedEvent, normalizedListener$1);
218
+ this.#transport.off(normalizedEvent, normalizedListener);
212
219
  }
213
220
  return;
214
221
  }
@@ -243,7 +250,7 @@ var Emitter = class {
243
250
  }
244
251
  fake(events) {
245
252
  this.restore();
246
- this.#eventsBuffer = new EventsBuffer();
253
+ this.#eventsBuffer = new EventsBuffer(() => this.restore());
247
254
  if (!events) {
248
255
  debug_default("faking all events");
249
256
  this.#eventsToFake.add("*");
@@ -1,4 +1,4 @@
1
- import { t as Emitter } from "../emitter-CgpYPQB7.js";
1
+ import { t as Emitter } from "../emitter-BaiN6nb0.js";
2
2
  var EmitterFactory = class {
3
3
  create(app) {
4
4
  return new Emitter(app);
package/build/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as tracing_channels_exports, t as Emitter } from "./emitter-CgpYPQB7.js";
1
+ import { n as tracing_channels_exports, t as Emitter } from "./emitter-BaiN6nb0.js";
2
2
  import { RuntimeException } from "@poppinss/utils/exception";
3
3
  var BaseEvent = class {
4
4
  constructor(..._) {}
@@ -10,6 +10,7 @@ type EventFinderCallback<EventsList extends Record<string | symbol | number, any
10
10
  */
11
11
  export declare class EventsBuffer<EventsList extends Record<string | symbol | number, any>> {
12
12
  #private;
13
+ constructor(restoreFn: () => void);
13
14
  /**
14
15
  * Track emitted event
15
16
  *
@@ -79,5 +80,6 @@ export declare class EventsBuffer<EventsList extends Record<string | symbol | nu
79
80
  * Flush events collected within memory
80
81
  */
81
82
  flush(): void;
83
+ [Symbol.dispose](): void;
82
84
  }
83
85
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adonisjs/events",
3
3
  "description": "An implementation of the event emitter built on top of emittery",
4
- "version": "10.1.0-next.4",
4
+ "version": "10.2.0",
5
5
  "engines": {
6
6
  "node": ">=24.0.0"
7
7
  },
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "scripts": {
24
24
  "pretest": "npm run lint",
25
- "test": "cross-env NODE_DEBUG=adonisjs:events c8 npm run quick:test",
25
+ "test": "cross-env NODE_DEBUG=adonisjs:events npm run quick:test",
26
26
  "lint": "eslint .",
27
27
  "format": "prettier --write .",
28
28
  "typecheck": "tsc --noEmit",
@@ -36,36 +36,36 @@
36
36
  "quick:test": "node --import=@poppinss/ts-exec --enable-source-maps bin/test.ts"
37
37
  },
38
38
  "devDependencies": {
39
- "@adonisjs/application": "^9.0.0-next.14",
40
- "@adonisjs/config": "^6.1.0-next.0",
41
- "@adonisjs/eslint-config": "^3.0.0-next.9",
42
- "@adonisjs/fold": "^11.0.0-next.4",
39
+ "@adonisjs/application": "^9.0.0",
40
+ "@adonisjs/config": "^6.1.0",
41
+ "@adonisjs/eslint-config": "^3.0.0",
42
+ "@adonisjs/fold": "^11.0.0",
43
43
  "@adonisjs/prettier-config": "^1.4.5",
44
- "@adonisjs/tsconfig": "^2.0.0-next.3",
44
+ "@adonisjs/tsconfig": "^2.0.0",
45
45
  "@japa/assert": "^4.2.0",
46
46
  "@japa/expect-type": "^2.0.4",
47
47
  "@japa/file-system": "^3.0.0",
48
- "@japa/runner": "^5.0.0",
49
- "@poppinss/ts-exec": "^1.4.1",
50
- "@release-it/conventional-changelog": "^10.0.4",
51
- "@types/node": "^25.0.3",
52
- "c8": "^10.1.3",
48
+ "@japa/runner": "^5.3.0",
49
+ "@poppinss/ts-exec": "^1.4.4",
50
+ "@release-it/conventional-changelog": "^10.0.5",
51
+ "@types/node": "^25.3.0",
52
+ "c8": "^11.0.0",
53
53
  "cross-env": "^10.1.0",
54
54
  "del-cli": "^7.0.0",
55
- "eslint": "^9.39.2",
56
- "prettier": "^3.7.4",
57
- "release-it": "^19.2.2",
58
- "tsdown": "^0.18.4",
55
+ "eslint": "^10.0.2",
56
+ "prettier": "^3.8.1",
57
+ "release-it": "^19.2.4",
58
+ "tsdown": "^0.20.3",
59
59
  "typescript": "^5.9.3"
60
60
  },
61
61
  "dependencies": {
62
- "@poppinss/utils": "^7.0.0-next.5",
62
+ "@poppinss/utils": "^7.0.0",
63
63
  "@sindresorhus/is": "^7.2.0",
64
64
  "emittery": "^1.2.0"
65
65
  },
66
66
  "peerDependencies": {
67
- "@adonisjs/application": "^9.0.0-next.14",
68
- "@adonisjs/fold": "^11.0.0-next.4"
67
+ "@adonisjs/application": "^9.0.0-next.14 || ^9.0.0",
68
+ "@adonisjs/fold": "^11.0.0-next.4 || ^11.0.0"
69
69
  },
70
70
  "homepage": "https://github.com/adonisjs/events#readme",
71
71
  "repository": {