@adonisjs/events 8.4.9-2 → 8.4.9-4

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.
@@ -1,22 +1,55 @@
1
+ /**
2
+ * Data types for event name
3
+ */
1
4
  export type AllowedEventTypes = string | symbol | number | Constructor;
5
+ /**
6
+ * Class constructor type
7
+ */
2
8
  export type Constructor<T = unknown> = new (...args: any[]) => T;
9
+ /**
10
+ * A function that lazily imports a middleware
11
+ */
3
12
  export type LazyImport<DefaultExport> = () => Promise<{
4
13
  default: DefaultExport;
5
14
  }>;
15
+ /**
16
+ * Data structure for a buffered event
17
+ */
6
18
  export type BufferedEvent<Event, Data> = {
7
19
  event: Event;
8
20
  data: Data;
9
21
  };
22
+ /**
23
+ * Event list item inside bufferred items
24
+ */
10
25
  export type BufferedEventsList<EventsList> = {
11
26
  [Name in keyof EventsList]: BufferedEvent<Name, EventsList[Name]>;
12
27
  }[keyof EventsList] | BufferedEvent<Constructor<any>, any>;
28
+ /**
29
+ * Representation of listener method on the listener class. The
30
+ * spread args can type hint dependencies and container will
31
+ * resolve them
32
+ */
13
33
  export type ListenerMethod<Data> = (data: Data, ...args: any[]) => any | Promise<any>;
34
+ /**
35
+ * The event listener defined as an inline callback
36
+ */
14
37
  export type ListenerFn<Data> = (data: Data) => any | Promise<any>;
38
+ /**
39
+ * Returns a union of methods from a listener that accepts
40
+ * the event data as the first argument.
41
+ */
15
42
  export type GetListenersMethods<Listener extends Constructor<any>, Data> = {
16
43
  [K in keyof InstanceType<Listener>]: InstanceType<Listener>[K] extends ListenerMethod<Data> ? K : never;
17
44
  }[keyof InstanceType<Listener>];
45
+ /**
46
+ * Representation of listener class with handle method
47
+ */
18
48
  export type ListenerClassWithHandleMethod<Data> = Constructor<{
19
49
  handle: ListenerMethod<Data>;
20
50
  }>;
51
+ /**
52
+ * The event listener defined as an inline callback, string
53
+ * listener class reference or a lazily imported listener
54
+ */
21
55
  export type Listener<Data, ListenerClass extends Constructor> = ListenerFn<Data> | string | [LazyImport<ListenerClass> | ListenerClass, GetListenersMethods<ListenerClass, Data>?];
22
- //# sourceMappingURL=types.d.ts.map
@@ -1 +1,9 @@
1
+ /*
2
+ * @adonisjs/events
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
1
9
  export {};
package/package.json CHANGED
@@ -1,17 +1,13 @@
1
1
  {
2
2
  "name": "@adonisjs/events",
3
- "version": "8.4.9-2",
3
+ "version": "8.4.9-4",
4
4
  "description": "An implementation of the event emitter built on top of emittery",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
7
7
  "files": [
8
- "src",
9
- "factories",
10
- "index.ts",
11
8
  "build/src",
12
9
  "build/factories",
13
10
  "build/index.d.ts",
14
- "build/index.d.ts.map",
15
11
  "build/index.js"
16
12
  ],
17
13
  "imports": {
@@ -22,10 +18,14 @@
22
18
  "./factories": "./build/factories/main.js",
23
19
  "./types": "./build/src/types.js"
24
20
  },
21
+ "engines": {
22
+ "node": ">=18.16.0"
23
+ },
25
24
  "scripts": {
26
25
  "pretest": "npm run lint",
27
- "test": "cross-env NODE_DEBUG=adonisjs:events c8 npm run vscode:test",
26
+ "test": "cross-env NODE_DEBUG=adonisjs:events c8 npm run quick:test",
28
27
  "clean": "del-cli build",
28
+ "typecheck": "tsc --noEmit",
29
29
  "compile": "npm run lint && npm run clean && tsc",
30
30
  "build": "npm run compile",
31
31
  "release": "np",
@@ -34,7 +34,7 @@
34
34
  "prepublishOnly": "npm run build",
35
35
  "lint": "eslint . --ext=.ts",
36
36
  "sync-labels": "github-label-sync --labels .github/labels.json adonisjs/events",
37
- "vscode:test": "node --loader=ts-node/esm --experimental-import-meta-resolve bin/test.ts"
37
+ "quick:test": "node --loader=ts-node/esm --experimental-import-meta-resolve bin/test.ts"
38
38
  },
39
39
  "keywords": [
40
40
  "emitter",
@@ -43,35 +43,33 @@
43
43
  "author": "virk,adonisjs",
44
44
  "license": "MIT",
45
45
  "devDependencies": {
46
- "@adonisjs/application": "^7.1.2-3",
47
- "@adonisjs/fold": "^9.9.3-4",
48
- "@commitlint/cli": "^17.5.0",
49
- "@commitlint/config-conventional": "^17.4.4",
50
- "@japa/assert": "^1.4.1",
51
- "@japa/expect-type": "^1.0.3",
52
- "@japa/file-system": "^1.0.1",
53
- "@japa/run-failed-tests": "^1.1.1",
54
- "@japa/runner": "^2.5.1",
55
- "@japa/spec-reporter": "^1.3.3",
56
- "@swc/core": "^1.3.42",
57
- "@types/node": "^18.15.9",
58
- "c8": "^7.13.0",
46
+ "@adonisjs/application": "^7.1.2-6",
47
+ "@adonisjs/eslint-config": "^1.1.8",
48
+ "@adonisjs/fold": "^9.9.3-5",
49
+ "@adonisjs/prettier-config": "^1.1.8",
50
+ "@adonisjs/tsconfig": "^1.1.8",
51
+ "@commitlint/cli": "^17.6.7",
52
+ "@commitlint/config-conventional": "^17.6.7",
53
+ "@japa/assert": "^2.0.0-1",
54
+ "@japa/expect-type": "^2.0.0-0",
55
+ "@japa/file-system": "^2.0.0-1",
56
+ "@japa/runner": "^3.0.0-3",
57
+ "@swc/core": "^1.3.71",
58
+ "@types/node": "^20.4.5",
59
+ "c8": "^8.0.1",
59
60
  "cross-env": "^7.0.3",
60
61
  "del-cli": "^5.0.0",
61
- "eslint": "^8.36.0",
62
- "eslint-config-prettier": "^8.8.0",
63
- "eslint-plugin-adonis": "^3.0.3",
64
- "eslint-plugin-prettier": "^4.2.1",
62
+ "eslint": "^8.45.0",
65
63
  "github-label-sync": "^2.3.1",
66
64
  "husky": "^8.0.3",
67
- "np": "^7.6.4",
68
- "prettier": "^2.8.7",
65
+ "np": "^8.0.4",
66
+ "prettier": "^3.0.0",
69
67
  "ts-node": "^10.9.1",
70
- "typescript": "^5.0.2"
68
+ "typescript": "^5.1.6"
71
69
  },
72
70
  "dependencies": {
73
- "@poppinss/utils": "^6.5.0-1",
74
- "@sindresorhus/is": "^5.3.0",
71
+ "@poppinss/utils": "^6.5.0-3",
72
+ "@sindresorhus/is": "^5.6.0",
75
73
  "emittery": "^1.0.1"
76
74
  },
77
75
  "peerDependencies": {
@@ -86,36 +84,6 @@
86
84
  "url": "https://github.com/adonisjs/events/issues"
87
85
  },
88
86
  "homepage": "https://github.com/adonisjs/events#readme",
89
- "eslintConfig": {
90
- "extends": [
91
- "plugin:adonis/typescriptPackage",
92
- "prettier"
93
- ],
94
- "plugins": [
95
- "prettier"
96
- ],
97
- "rules": {
98
- "prettier/prettier": [
99
- "error",
100
- {
101
- "endOfLine": "auto"
102
- }
103
- ]
104
- }
105
- },
106
- "eslintIgnore": [
107
- "build"
108
- ],
109
- "prettier": {
110
- "trailingComma": "es5",
111
- "semi": false,
112
- "singleQuote": true,
113
- "useTabs": false,
114
- "quoteProps": "consistent",
115
- "bracketSpacing": true,
116
- "arrowParens": "always",
117
- "printWidth": 100
118
- },
119
87
  "commitlint": {
120
88
  "extends": [
121
89
  "@commitlint/config-conventional"
@@ -139,5 +107,9 @@
139
107
  "exclude": [
140
108
  "tests/**"
141
109
  ]
142
- }
110
+ },
111
+ "eslintConfig": {
112
+ "extends": "@adonisjs/eslint-config/package"
113
+ },
114
+ "prettier": "@adonisjs/prettier-config"
143
115
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../factories/emitter.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAM3C,qBAAa,cAAc;IAIzB,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC;CAG7B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../factories/main.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"base_event.d.ts","sourceRoot":"","sources":["../../src/base_event.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAM3C,qBAAa,SAAS;gBACR,GAAG,CAAC,EAAE,GAAG,EAAE;IAKvB,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IAK7B,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC;WAQ1B,QAAQ,CAAC,CAAC,SAAS,OAAO,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,qBAAqB,CAAC,CAAC,CAAC;CAS7F"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/debug.ts"],"names":[],"mappings":";;AAUA,wBAA0C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../src/emitter.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAiB,EAAE,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAI7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,6BAA6B,EAC9B,MAAM,YAAY,CAAA;AAMnB,qBAAa,OAAO,CAAC,UAAU,SAAS,MAAM,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC;;IAmD3E,IAAI,eAAe,sFAElB;gBAEW,GAAG,EAAE,WAAW,CAAC,GAAG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AE,IAAI,KAAK,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;AAMjE,MAAM,MAAM,mBAAmB,CAAC,QAAQ,SAAS,WAAW,CAAC,GAAG,CAAC,EAAE,IAAI,IAAI;KACxE,CAAC,IAAI,MAAM,YAAY,CAAC,QAAQ,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,cAAc,CAAC,IAAI,CAAC,GACvF,CAAC,GACD,KAAK;CACV,CAAC,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAA;AAK/B,MAAM,MAAM,6BAA6B,CAAC,IAAI,IAAI,WAAW,CAAC;IAC5D,MAAM,EAAE,cAAc,CAAC,IAAI,CAAC,CAAA;CAC7B,CAAC,CAAA;AAMF,MAAM,MAAM,QAAQ,CAAC,IAAI,EAAE,aAAa,SAAS,WAAW,IACxD,UAAU,CAAC,IAAI,CAAC,GAChB,MAAM,GACN,CAAC,UAAU,CAAC,aAAa,CAAC,GAAG,aAAa,EAAE,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA"}
@@ -1,24 +0,0 @@
1
- /*
2
- * @adonisjs/events
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
-
10
- import type { Application } from '@adonisjs/application'
11
- import { Emitter } from '../src/emitter.js'
12
-
13
- /**
14
- * Emitter factory is used to create an instance of emitter
15
- * for testing
16
- */
17
- export class EmitterFactory {
18
- /**
19
- * Create emitter instance
20
- */
21
- create(app: Application<any>) {
22
- return new Emitter(app)
23
- }
24
- }
package/factories/main.ts DELETED
@@ -1,10 +0,0 @@
1
- /*
2
- * @adonisjs/events
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
-
10
- export { EmitterFactory } from './emitter.js'
package/index.ts DELETED
@@ -1,11 +0,0 @@
1
- /*
2
- * @adonisjs/events
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
-
10
- export { Emitter } from './src/emitter.js'
11
- export { BaseEvent } from './src/base_event.js'
package/src/base_event.ts DELETED
@@ -1,45 +0,0 @@
1
- /*
2
- * @adonisjs/events
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
-
10
- import { RuntimeException } from '@poppinss/utils'
11
- import type { Emitter } from './emitter.js'
12
-
13
- /**
14
- * Base event adds ability to a class to act as an event. You can emit the
15
- * event by calling "Event.dispatch" method.
16
- */
17
- export class BaseEvent {
18
- constructor(..._: any[]) {}
19
-
20
- /**
21
- * The emitter to use for dispatching events
22
- */
23
- static emitter?: Emitter<any>
24
-
25
- /**
26
- * Specify the emitter instance to use for dispatching events
27
- */
28
- static useEmitter(emitter: Emitter<any>) {
29
- this.emitter = emitter
30
- }
31
-
32
- /**
33
- * Dispatch the current class as an event. The method takes the arguments
34
- * accepted by the class constructor.
35
- */
36
- static async dispatch<T extends typeof BaseEvent>(this: T, ...args: ConstructorParameters<T>) {
37
- if (!this.emitter) {
38
- throw new RuntimeException(
39
- `Cannot dispatch "${this.name}" event. Make sure to pass emitter to the "BaseEvent" class for dispatch method to work`
40
- )
41
- }
42
-
43
- return this.emitter.emit<T>(this, new this(...args) as InstanceType<T>)
44
- }
45
- }
package/src/debug.ts DELETED
@@ -1,11 +0,0 @@
1
- /*
2
- * @adonisjs/events
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
-
10
- import { debuglog } from 'node:util'
11
- export default debuglog('adonisjs:events')