bare-events 2.7.0 → 2.8.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.
- package/global.d.ts +3 -0
- package/global.js +1 -0
- package/index.d.ts +2 -0
- package/package.json +12 -2
- package/web.d.ts +12 -0
- package/web.js +19 -1
package/global.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import * as events from './web'
|
|
2
2
|
|
|
3
3
|
type EventConstructor = typeof events.Event
|
|
4
|
+
type CustomEventConstructor = typeof events.CustomEvent
|
|
4
5
|
type EventTargetConstructor = typeof events.EventTarget
|
|
5
6
|
|
|
6
7
|
declare global {
|
|
7
8
|
type Event = events.Event
|
|
9
|
+
type CustomEvent<T = any> = events.CustomEvent<T>
|
|
8
10
|
type EventTarget = events.EventTarget
|
|
9
11
|
|
|
10
12
|
const Event: EventConstructor
|
|
13
|
+
const CustomEvent: CustomEventConstructor
|
|
11
14
|
const EventTarget: EventTargetConstructor
|
|
12
15
|
}
|
package/global.js
CHANGED
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-events",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "Event emitters for JavaScript",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package": "./package.json",
|
|
@@ -44,8 +44,18 @@
|
|
|
44
44
|
},
|
|
45
45
|
"homepage": "https://github.com/holepunchto/bare-events#readme",
|
|
46
46
|
"devDependencies": {
|
|
47
|
+
"bare-abort-controller": "^1.0.0",
|
|
47
48
|
"brittle": "^3.3.2",
|
|
48
49
|
"prettier": "^3.4.2",
|
|
49
|
-
"prettier-config-standard": "^7.0.0"
|
|
50
|
+
"prettier-config-standard": "^7.0.0",
|
|
51
|
+
"uncaughts": "^1.1.1"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"bare-abort-controller": "*"
|
|
55
|
+
},
|
|
56
|
+
"peerDependenciesMeta": {
|
|
57
|
+
"bare-abort-controller": {
|
|
58
|
+
"optional": true
|
|
59
|
+
}
|
|
50
60
|
}
|
|
51
61
|
}
|
package/web.d.ts
CHANGED
|
@@ -25,6 +25,18 @@ export class Event {
|
|
|
25
25
|
constructor(type: string, options?: EventOptions)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
export interface CustomEventOptions<T = any> extends EventOptions {
|
|
29
|
+
detail?: T
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface CustomEvent<T = any> extends Event {
|
|
33
|
+
readonly detail: T
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class CustomEvent<T = any> {
|
|
37
|
+
constructor(type: string, options?: CustomEventOptions<T>)
|
|
38
|
+
}
|
|
39
|
+
|
|
28
40
|
export interface AddEventListenerOptions {
|
|
29
41
|
capture?: boolean
|
|
30
42
|
passive?: boolean
|
package/web.js
CHANGED
|
@@ -12,7 +12,7 @@ const PASSIVE = 0x2
|
|
|
12
12
|
const ONCE = 0x4
|
|
13
13
|
|
|
14
14
|
// https://dom.spec.whatwg.org/#event
|
|
15
|
-
|
|
15
|
+
class Event {
|
|
16
16
|
// https://dom.spec.whatwg.org/#dom-event-event
|
|
17
17
|
constructor(type, options = {}) {
|
|
18
18
|
const { bubbles = false, cancelable = false, composed = false } = options
|
|
@@ -106,6 +106,24 @@ exports.Event = class Event {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
exports.Event = Event
|
|
110
|
+
|
|
111
|
+
// https://dom.spec.whatwg.org/#customevent
|
|
112
|
+
exports.CustomEvent = class CustomEvent extends Event {
|
|
113
|
+
constructor(type, options = {}) {
|
|
114
|
+
super(type, options)
|
|
115
|
+
|
|
116
|
+
const { detail = null } = options
|
|
117
|
+
|
|
118
|
+
this._detail = detail
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// https://dom.spec.whatwg.org/#dom-customevent-detail
|
|
122
|
+
get detail() {
|
|
123
|
+
return this._detail
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
109
127
|
// https://dom.spec.whatwg.org/#eventtarget
|
|
110
128
|
exports.EventTarget = class EventTarget {
|
|
111
129
|
// https://dom.spec.whatwg.org/#dom-eventtarget-eventtarget
|