@adonisjs/events 8.1.0-0 → 8.1.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.
@@ -0,0 +1,3 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ declare const _default: import("util").DebugLogger;
3
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import { debuglog } from 'node:util';
2
+ export default debuglog('adonisjs:events');
@@ -1,9 +1,9 @@
1
+ import { type Application } from '@adonisjs/application';
1
2
  import type { EventsListItem } from './types.js';
2
3
  import { EventsBuffer } from './events_buffer.js';
3
- import { type Application } from '@adonisjs/application';
4
4
  export declare class Emitter<EventsList extends Record<string | symbol | number, any>> {
5
5
  #private;
6
- constructor(app: Application);
6
+ constructor(app: Application<any, any, any>);
7
7
  onError(callback: (event: keyof EventsList, error: any, data: any) => void): this;
8
8
  on<Name extends keyof EventsList>(event: Name, handler: string | ((data: EventsList[Name]) => any | Promise<any>)): this;
9
9
  once<Name extends keyof EventsList>(event: Name, handler: string | ((data: EventsList[Name]) => any | Promise<any>)): this;
@@ -1,6 +1,7 @@
1
1
  import Emittery from 'emittery';
2
- import { EventsBuffer } from './events_buffer.js';
3
2
  import { moduleExpression } from '@adonisjs/fold';
3
+ import debug from './debug.js';
4
+ import { EventsBuffer } from './events_buffer.js';
4
5
  export class Emitter {
5
6
  #transport = new Emittery();
6
7
  #eventsBuffer;
@@ -56,6 +57,7 @@ export class Emitter {
56
57
  }
57
58
  async emit(event, data) {
58
59
  if (this.#eventsToFake.has(event) || this.#eventsToFake.has('*')) {
60
+ debug('faking emit. event: "%s", data: %O', event, data);
59
61
  this.#eventsBuffer.events.push({ name: event, data });
60
62
  return;
61
63
  }
@@ -110,14 +112,17 @@ export class Emitter {
110
112
  this.restore();
111
113
  this.#eventsBuffer = new EventsBuffer();
112
114
  if (!events) {
115
+ debug('faking all events');
113
116
  this.#eventsToFake.add('*');
114
117
  }
115
118
  else {
119
+ debug('faking events: %O', events);
116
120
  events.forEach((event) => this.#eventsToFake.add(event));
117
121
  }
118
122
  return this.#eventsBuffer;
119
123
  }
120
124
  restore() {
125
+ debug('restoring existing fakes');
121
126
  this.#eventsToFake.clear();
122
127
  this.#eventsBuffer?.flush();
123
128
  this.#eventsBuffer = undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonisjs/events",
3
- "version": "8.1.0-0",
3
+ "version": "8.1.2-0",
4
4
  "description": "An implementation of the event emitter built on top of emittery",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "scripts": {
20
20
  "pretest": "npm run lint",
21
- "test": "c8 npm run vscode:test",
21
+ "test": "cross-env NODE_DEBUG=adonisjs:events c8 npm run vscode:test",
22
22
  "clean": "del-cli build",
23
23
  "compile": "npm run lint && npm run clean && tsc",
24
24
  "build": "npm run compile",
@@ -37,11 +37,11 @@
37
37
  "author": "virk,adonisjs",
38
38
  "license": "MIT",
39
39
  "devDependencies": {
40
- "@adonisjs/application": "^6.1.0-0",
41
- "@adonisjs/config": "^4.1.0-0",
42
- "@adonisjs/env": "^4.0.2-0",
43
- "@adonisjs/fold": "^9.3.1-0",
44
- "@adonisjs/logger": "^5.0.1-0",
40
+ "@adonisjs/application": "^6.2.0-0",
41
+ "@adonisjs/config": "^4.1.1-0",
42
+ "@adonisjs/env": "^4.0.3-0",
43
+ "@adonisjs/fold": "^9.5.0-0",
44
+ "@adonisjs/logger": "^5.1.0-0",
45
45
  "@commitlint/cli": "^17.3.0",
46
46
  "@commitlint/config-conventional": "^17.3.0",
47
47
  "@japa/assert": "^1.3.6",
@@ -50,29 +50,30 @@
50
50
  "@japa/runner": "^2.2.2",
51
51
  "@japa/spec-reporter": "^1.3.2",
52
52
  "@poppinss/dev-utils": "^2.0.1",
53
- "@swc/core": "^1.3.20",
53
+ "@swc/core": "^1.3.22",
54
54
  "@types/fs-extra": "^9.0.13",
55
- "@types/node": "^18.11.9",
55
+ "@types/node": "^18.11.12",
56
56
  "c8": "^7.12.0",
57
+ "cross-env": "^7.0.3",
57
58
  "del-cli": "^5.0.0",
58
- "eslint": "^8.28.0",
59
+ "eslint": "^8.29.0",
59
60
  "eslint-config-prettier": "^8.3.0",
60
61
  "eslint-plugin-adonis": "^3.0.3",
61
62
  "eslint-plugin-prettier": "^4.2.1",
62
- "fs-extra": "^11.0.0",
63
+ "fs-extra": "^11.1.0",
63
64
  "github-label-sync": "^2.0.1",
64
65
  "husky": "^8.0.2",
65
66
  "np": "^7.6.2",
66
- "prettier": "^2.8.0",
67
+ "prettier": "^2.8.1",
67
68
  "ts-node": "^10.9.1",
68
- "typescript": "^4.9.3"
69
+ "typescript": "^4.9.4"
69
70
  },
70
71
  "dependencies": {
71
72
  "emittery": "^1.0.1"
72
73
  },
73
74
  "peerDependencies": {
74
- "@adonisjs/application": "^6.1.0-0",
75
- "@adonisjs/fold": "^9.3.1-0"
75
+ "@adonisjs/fold": "^9.5.0-0",
76
+ "@adonisjs/application": "^6.2.0-0"
76
77
  },
77
78
  "repository": {
78
79
  "type": "git",