react-native-webrtc 124.0.7 → 155.0.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/.claude/settings.local.json +9 -0
- package/.eslintignore +1 -0
- package/CLAUDE.md +714 -0
- package/README.md +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/oney/WebRTCModule/AbstractVideoCaptureController.java +5 -3
- package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +84 -7
- package/android/src/main/java/com/oney/WebRTCModule/MediaProjectionService.java +24 -3
- package/android/src/main/java/com/oney/WebRTCModule/ScreenCaptureController.java +4 -4
- package/android/src/main/java/com/oney/WebRTCModule/SerializeUtils.java +8 -0
- package/android/src/main/java/com/oney/WebRTCModule/ThreadUtils.java +8 -0
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +116 -27
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +56 -28
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoEffectProcessor.java +3 -3
- package/ios/RCTWebRTC/RCTConvert+WebRTC.m +21 -0
- package/ios/RCTWebRTC/ScreenCapturePickerViewManager.m +22 -23
- package/ios/RCTWebRTC/SerializeUtils.m +6 -0
- package/ios/RCTWebRTC/VideoCaptureController.m +40 -1
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m +16 -9
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.h +2 -0
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +95 -0
- package/ios/RCTWebRTC/WebRTCModule+Transceivers.m +5 -1
- package/lib/commonjs/Constraints.js.map +1 -1
- package/lib/commonjs/EventEmitter.js.map +1 -1
- package/lib/commonjs/Logger.js.map +1 -1
- package/lib/commonjs/MediaDevices.js +13 -12
- package/lib/commonjs/MediaDevices.js.map +1 -1
- package/lib/commonjs/MediaStream.js +14 -9
- package/lib/commonjs/MediaStream.js.map +1 -1
- package/lib/commonjs/MediaStreamError.js.map +1 -1
- package/lib/commonjs/MediaStreamErrorEvent.js.map +1 -1
- package/lib/commonjs/MediaStreamTrack.js +28 -12
- package/lib/commonjs/MediaStreamTrack.js.map +1 -1
- package/lib/commonjs/MediaStreamTrackEvent.js +2 -2
- package/lib/commonjs/MediaStreamTrackEvent.js.map +1 -1
- package/lib/commonjs/MessageEvent.js +2 -2
- package/lib/commonjs/MessageEvent.js.map +1 -1
- package/lib/commonjs/Permissions.js +1 -2
- package/lib/commonjs/Permissions.js.map +1 -1
- package/lib/commonjs/RTCAudioSession.js.map +1 -1
- package/lib/commonjs/RTCCertificate.js +25 -0
- package/lib/commonjs/RTCCertificate.js.map +1 -0
- package/lib/commonjs/RTCDataChannel.js +38 -13
- package/lib/commonjs/RTCDataChannel.js.map +1 -1
- package/lib/commonjs/RTCDataChannelEvent.js +2 -2
- package/lib/commonjs/RTCDataChannelEvent.js.map +1 -1
- package/lib/commonjs/RTCErrorEvent.js +2 -2
- package/lib/commonjs/RTCErrorEvent.js.map +1 -1
- package/lib/commonjs/RTCIceCandidate.js.map +1 -1
- package/lib/commonjs/RTCIceCandidateEvent.js +2 -2
- package/lib/commonjs/RTCIceCandidateEvent.js.map +1 -1
- package/lib/commonjs/RTCPIPView.js +1 -2
- package/lib/commonjs/RTCPIPView.js.map +1 -1
- package/lib/commonjs/RTCPeerConnection.js +109 -27
- package/lib/commonjs/RTCPeerConnection.js.map +1 -1
- package/lib/commonjs/RTCRtcpParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpCapabilities.js.map +1 -1
- package/lib/commonjs/RTCRtpCodecCapability.js.map +1 -1
- package/lib/commonjs/RTCRtpCodecParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpEncodingParameters.js +17 -1
- package/lib/commonjs/RTCRtpEncodingParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpHeaderExtension.js.map +1 -1
- package/lib/commonjs/RTCRtpParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpReceiveParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpReceiver.js.map +1 -1
- package/lib/commonjs/RTCRtpSendParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpSender.js.map +1 -1
- package/lib/commonjs/RTCRtpTransceiver.js.map +1 -1
- package/lib/commonjs/RTCSessionDescription.js.map +1 -1
- package/lib/commonjs/RTCTrackEvent.js +2 -2
- package/lib/commonjs/RTCTrackEvent.js.map +1 -1
- package/lib/commonjs/RTCUtil.js.map +1 -1
- package/lib/commonjs/RTCView.js +1 -2
- package/lib/commonjs/RTCView.js.map +1 -1
- package/lib/commonjs/ScreenCapturePickerView.js +1 -2
- package/lib/commonjs/ScreenCapturePickerView.js.map +1 -1
- package/lib/commonjs/getDisplayMedia.js +2 -1
- package/lib/commonjs/getDisplayMedia.js.map +1 -1
- package/lib/commonjs/getUserMedia.js.map +1 -1
- package/lib/commonjs/index.js +22 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/vendor/event-target-shim/LICENSE +22 -0
- package/lib/commonjs/vendor/event-target-shim/index.js +1221 -0
- package/lib/commonjs/vendor/event-target-shim/index.js.map +1 -0
- package/lib/module/Constraints.js.map +1 -1
- package/lib/module/EventEmitter.js.map +1 -1
- package/lib/module/Logger.js.map +1 -1
- package/lib/module/MediaDevices.js +11 -9
- package/lib/module/MediaDevices.js.map +1 -1
- package/lib/module/MediaStream.js +13 -8
- package/lib/module/MediaStream.js.map +1 -1
- package/lib/module/MediaStreamError.js.map +1 -1
- package/lib/module/MediaStreamErrorEvent.js.map +1 -1
- package/lib/module/MediaStreamTrack.js +25 -9
- package/lib/module/MediaStreamTrack.js.map +1 -1
- package/lib/module/MediaStreamTrackEvent.js +1 -1
- package/lib/module/MediaStreamTrackEvent.js.map +1 -1
- package/lib/module/MessageEvent.js +1 -1
- package/lib/module/MessageEvent.js.map +1 -1
- package/lib/module/Permissions.js.map +1 -1
- package/lib/module/RTCAudioSession.js.map +1 -1
- package/lib/module/RTCCertificate.js +18 -0
- package/lib/module/RTCCertificate.js.map +1 -0
- package/lib/module/RTCDataChannel.js +37 -12
- package/lib/module/RTCDataChannel.js.map +1 -1
- package/lib/module/RTCDataChannelEvent.js +1 -1
- package/lib/module/RTCDataChannelEvent.js.map +1 -1
- package/lib/module/RTCErrorEvent.js +1 -1
- package/lib/module/RTCErrorEvent.js.map +1 -1
- package/lib/module/RTCIceCandidate.js.map +1 -1
- package/lib/module/RTCIceCandidateEvent.js +1 -1
- package/lib/module/RTCIceCandidateEvent.js.map +1 -1
- package/lib/module/RTCPIPView.js.map +1 -1
- package/lib/module/RTCPeerConnection.js +103 -21
- package/lib/module/RTCPeerConnection.js.map +1 -1
- package/lib/module/RTCRtcpParameters.js.map +1 -1
- package/lib/module/RTCRtpCapabilities.js.map +1 -1
- package/lib/module/RTCRtpCodecCapability.js.map +1 -1
- package/lib/module/RTCRtpCodecParameters.js.map +1 -1
- package/lib/module/RTCRtpEncodingParameters.js +17 -1
- package/lib/module/RTCRtpEncodingParameters.js.map +1 -1
- package/lib/module/RTCRtpHeaderExtension.js.map +1 -1
- package/lib/module/RTCRtpParameters.js.map +1 -1
- package/lib/module/RTCRtpReceiveParameters.js.map +1 -1
- package/lib/module/RTCRtpReceiver.js.map +1 -1
- package/lib/module/RTCRtpSendParameters.js.map +1 -1
- package/lib/module/RTCRtpSender.js.map +1 -1
- package/lib/module/RTCRtpTransceiver.js.map +1 -1
- package/lib/module/RTCSessionDescription.js.map +1 -1
- package/lib/module/RTCTrackEvent.js +1 -1
- package/lib/module/RTCTrackEvent.js.map +1 -1
- package/lib/module/RTCUtil.js.map +1 -1
- package/lib/module/RTCView.js.map +1 -1
- package/lib/module/ScreenCapturePickerView.js.map +1 -1
- package/lib/module/getDisplayMedia.js +2 -1
- package/lib/module/getDisplayMedia.js.map +1 -1
- package/lib/module/getUserMedia.js.map +1 -1
- package/lib/module/index.js +5 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/vendor/event-target-shim/LICENSE +22 -0
- package/lib/module/vendor/event-target-shim/index.js +1221 -0
- package/lib/module/vendor/event-target-shim/index.js.map +1 -0
- package/lib/typescript/MediaDevices.d.ts +8 -4
- package/lib/typescript/MediaStream.d.ts +5 -1
- package/lib/typescript/MediaStreamTrack.d.ts +7 -1
- package/lib/typescript/MediaStreamTrackEvent.d.ts +1 -1
- package/lib/typescript/MessageEvent.d.ts +1 -1
- package/lib/typescript/RTCCertificate.d.ts +16 -0
- package/lib/typescript/RTCDataChannel.d.ts +13 -1
- package/lib/typescript/RTCDataChannelEvent.d.ts +1 -1
- package/lib/typescript/RTCErrorEvent.d.ts +1 -1
- package/lib/typescript/RTCIceCandidateEvent.d.ts +1 -1
- package/lib/typescript/RTCPeerConnection.d.ts +30 -1
- package/lib/typescript/RTCRtpEncodingParameters.d.ts +4 -0
- package/lib/typescript/RTCTrackEvent.d.ts +1 -1
- package/lib/typescript/getDisplayMedia.d.ts +7 -1
- package/lib/typescript/index.d.ts +4 -1
- package/lib/typescript/vendor/event-target-shim/index.d.ts +411 -0
- package/package.json +3 -4
- package/react-native-webrtc.podspec +2 -2
- package/src/MediaDevices.ts +15 -14
- package/src/MediaStream.ts +17 -9
- package/src/MediaStreamTrack.ts +30 -10
- package/src/MediaStreamTrackEvent.ts +2 -2
- package/src/MessageEvent.ts +1 -1
- package/src/RTCCertificate.ts +24 -0
- package/src/RTCDataChannel.ts +49 -14
- package/src/RTCDataChannelEvent.ts +2 -2
- package/src/RTCErrorEvent.ts +1 -1
- package/src/RTCIceCandidateEvent.ts +2 -2
- package/src/RTCPeerConnection.ts +138 -24
- package/src/RTCRtpEncodingParameters.ts +20 -0
- package/src/RTCTrackEvent.ts +1 -1
- package/src/getDisplayMedia.ts +9 -2
- package/src/index.ts +9 -2
- package/src/vendor/event-target-shim/LICENSE +22 -0
- package/src/vendor/event-target-shim/index.d.ts +411 -0
- package/src/vendor/event-target-shim/index.js +1186 -0
- package/tools/postbuild.mjs +67 -0
|
@@ -0,0 +1,1221 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Assert a condition.
|
|
9
|
+
* @param condition The condition that it should satisfy.
|
|
10
|
+
* @param message The error message.
|
|
11
|
+
* @param args The arguments for replacing placeholders in the message.
|
|
12
|
+
*/
|
|
13
|
+
function assertType(condition, message) {
|
|
14
|
+
if (!condition) {
|
|
15
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
16
|
+
args[_key - 2] = arguments[_key];
|
|
17
|
+
}
|
|
18
|
+
throw new TypeError(format(message, args));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Convert a text and arguments to one string.
|
|
23
|
+
* @param message The formating text
|
|
24
|
+
* @param args The arguments.
|
|
25
|
+
*/
|
|
26
|
+
function format(message, args) {
|
|
27
|
+
let i = 0;
|
|
28
|
+
return message.replace(/%[os]/gu, () => anyToString(args[i++]));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Convert a value to a string representation.
|
|
32
|
+
* @param x The value to get the string representation.
|
|
33
|
+
*/
|
|
34
|
+
function anyToString(x) {
|
|
35
|
+
if (typeof x !== "object" || x === null) {
|
|
36
|
+
return String(x);
|
|
37
|
+
}
|
|
38
|
+
return Object.prototype.toString.call(x);
|
|
39
|
+
}
|
|
40
|
+
let currentErrorHandler;
|
|
41
|
+
/**
|
|
42
|
+
* Set the error handler.
|
|
43
|
+
* @param value The error handler to set.
|
|
44
|
+
*/
|
|
45
|
+
function setErrorHandler(value) {
|
|
46
|
+
assertType(typeof value === "function" || value === undefined, "The error handler must be a function or undefined, but got %o.", value);
|
|
47
|
+
currentErrorHandler = value;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Print a error message.
|
|
51
|
+
* @param maybeError The error object.
|
|
52
|
+
*/
|
|
53
|
+
function reportError(maybeError) {
|
|
54
|
+
try {
|
|
55
|
+
const error = maybeError instanceof Error ? maybeError : new Error(anyToString(maybeError));
|
|
56
|
+
// Call the user-defined error handler if exists.
|
|
57
|
+
if (currentErrorHandler) {
|
|
58
|
+
currentErrorHandler(error);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
// Dispatch an `error` event if this is on a browser.
|
|
62
|
+
if (typeof dispatchEvent === "function" && typeof ErrorEvent === "function") {
|
|
63
|
+
dispatchEvent(new ErrorEvent("error", {
|
|
64
|
+
error,
|
|
65
|
+
message: error.message
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
// Emit an `uncaughtException` event if this is on Node.js.
|
|
69
|
+
//istanbul ignore else
|
|
70
|
+
else if (typeof process !== "undefined" && typeof process.emit === "function") {
|
|
71
|
+
process.emit("uncaughtException", error);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
// Otherwise, print the error.
|
|
75
|
+
console.error(error);
|
|
76
|
+
} catch (_a) {
|
|
77
|
+
// ignore.
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The global object.
|
|
83
|
+
*/
|
|
84
|
+
//istanbul ignore next
|
|
85
|
+
const Global = typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : typeof globalThis !== "undefined" ? globalThis : undefined;
|
|
86
|
+
let currentWarnHandler;
|
|
87
|
+
/**
|
|
88
|
+
* Set the warning handler.
|
|
89
|
+
* @param value The warning handler to set.
|
|
90
|
+
*/
|
|
91
|
+
function setWarningHandler(value) {
|
|
92
|
+
assertType(typeof value === "function" || value === undefined, "The warning handler must be a function or undefined, but got %o.", value);
|
|
93
|
+
currentWarnHandler = value;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The warning information.
|
|
97
|
+
*/
|
|
98
|
+
class Warning {
|
|
99
|
+
constructor(code, message) {
|
|
100
|
+
this.code = code;
|
|
101
|
+
this.message = message;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Report this warning.
|
|
105
|
+
* @param args The arguments of the warning.
|
|
106
|
+
*/
|
|
107
|
+
warn() {
|
|
108
|
+
var _a;
|
|
109
|
+
try {
|
|
110
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
111
|
+
args[_key2] = arguments[_key2];
|
|
112
|
+
}
|
|
113
|
+
// Call the user-defined warning handler if exists.
|
|
114
|
+
if (currentWarnHandler) {
|
|
115
|
+
currentWarnHandler({
|
|
116
|
+
...this,
|
|
117
|
+
args
|
|
118
|
+
});
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
// Otherwise, print the warning.
|
|
122
|
+
const stack = ((_a = new Error().stack) !== null && _a !== void 0 ? _a : "").replace(/^(?:.+?\n){2}/gu, "\n");
|
|
123
|
+
console.warn(this.message, ...args, stack);
|
|
124
|
+
} catch (_b) {
|
|
125
|
+
// Ignore.
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const InitEventWasCalledWhileDispatching = new Warning("W01", "Unable to initialize event under dispatching.");
|
|
130
|
+
const FalsyWasAssignedToCancelBubble = new Warning("W02", "Assigning any falsy value to 'cancelBubble' property has no effect.");
|
|
131
|
+
const TruthyWasAssignedToReturnValue = new Warning("W03", "Assigning any truthy value to 'returnValue' property has no effect.");
|
|
132
|
+
const NonCancelableEventWasCanceled = new Warning("W04", "Unable to preventDefault on non-cancelable events.");
|
|
133
|
+
const CanceledInPassiveListener = new Warning("W05", "Unable to preventDefault inside passive event listener invocation.");
|
|
134
|
+
const EventListenerWasDuplicated = new Warning("W06", "An event listener wasn't added because it has been added already: %o, %o");
|
|
135
|
+
const OptionWasIgnored = new Warning("W07", "The %o option value was abandoned because the event listener wasn't added as duplicated.");
|
|
136
|
+
const InvalidEventListener = new Warning("W08", "The 'callback' argument must be a function or an object that has 'handleEvent' method: %o");
|
|
137
|
+
const InvalidAttributeHandler = new Warning("W09", "Event attribute handler must be a function: %o");
|
|
138
|
+
|
|
139
|
+
/*eslint-disable class-methods-use-this */
|
|
140
|
+
/**
|
|
141
|
+
* An implementation of `Event` interface, that wraps a given event object.
|
|
142
|
+
* `EventTarget` shim can control the internal state of this `Event` objects.
|
|
143
|
+
* @see https://dom.spec.whatwg.org/#event
|
|
144
|
+
*/
|
|
145
|
+
class Event {
|
|
146
|
+
/**
|
|
147
|
+
* @see https://dom.spec.whatwg.org/#dom-event-none
|
|
148
|
+
*/
|
|
149
|
+
static get NONE() {
|
|
150
|
+
return NONE;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* @see https://dom.spec.whatwg.org/#dom-event-capturing_phase
|
|
154
|
+
*/
|
|
155
|
+
static get CAPTURING_PHASE() {
|
|
156
|
+
return CAPTURING_PHASE;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* @see https://dom.spec.whatwg.org/#dom-event-at_target
|
|
160
|
+
*/
|
|
161
|
+
static get AT_TARGET() {
|
|
162
|
+
return AT_TARGET;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* @see https://dom.spec.whatwg.org/#dom-event-bubbling_phase
|
|
166
|
+
*/
|
|
167
|
+
static get BUBBLING_PHASE() {
|
|
168
|
+
return BUBBLING_PHASE;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Initialize this event instance.
|
|
172
|
+
* @param type The type of this event.
|
|
173
|
+
* @param eventInitDict Options to initialize.
|
|
174
|
+
* @see https://dom.spec.whatwg.org/#dom-event-event
|
|
175
|
+
*/
|
|
176
|
+
constructor(type, eventInitDict) {
|
|
177
|
+
Object.defineProperty(this, "isTrusted", {
|
|
178
|
+
value: false,
|
|
179
|
+
enumerable: true
|
|
180
|
+
});
|
|
181
|
+
const opts = eventInitDict !== null && eventInitDict !== void 0 ? eventInitDict : {};
|
|
182
|
+
internalDataMap.set(this, {
|
|
183
|
+
type: String(type),
|
|
184
|
+
bubbles: Boolean(opts.bubbles),
|
|
185
|
+
cancelable: Boolean(opts.cancelable),
|
|
186
|
+
composed: Boolean(opts.composed),
|
|
187
|
+
target: null,
|
|
188
|
+
currentTarget: null,
|
|
189
|
+
stopPropagationFlag: false,
|
|
190
|
+
stopImmediatePropagationFlag: false,
|
|
191
|
+
canceledFlag: false,
|
|
192
|
+
inPassiveListenerFlag: false,
|
|
193
|
+
dispatchFlag: false,
|
|
194
|
+
timeStamp: Date.now()
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* The type of this event.
|
|
199
|
+
* @see https://dom.spec.whatwg.org/#dom-event-type
|
|
200
|
+
*/
|
|
201
|
+
get type() {
|
|
202
|
+
return $(this).type;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* The event target of the current dispatching.
|
|
206
|
+
* @see https://dom.spec.whatwg.org/#dom-event-target
|
|
207
|
+
*/
|
|
208
|
+
get target() {
|
|
209
|
+
return $(this).target;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The event target of the current dispatching.
|
|
213
|
+
* @deprecated Use the `target` property instead.
|
|
214
|
+
* @see https://dom.spec.whatwg.org/#dom-event-srcelement
|
|
215
|
+
*/
|
|
216
|
+
get srcElement() {
|
|
217
|
+
return $(this).target;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* The event target of the current dispatching.
|
|
221
|
+
* @see https://dom.spec.whatwg.org/#dom-event-currenttarget
|
|
222
|
+
*/
|
|
223
|
+
get currentTarget() {
|
|
224
|
+
return $(this).currentTarget;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* The event target of the current dispatching.
|
|
228
|
+
* This doesn't support node tree.
|
|
229
|
+
* @see https://dom.spec.whatwg.org/#dom-event-composedpath
|
|
230
|
+
*/
|
|
231
|
+
composedPath() {
|
|
232
|
+
const currentTarget = $(this).currentTarget;
|
|
233
|
+
if (currentTarget) {
|
|
234
|
+
return [currentTarget];
|
|
235
|
+
}
|
|
236
|
+
return [];
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* @see https://dom.spec.whatwg.org/#dom-event-none
|
|
240
|
+
*/
|
|
241
|
+
get NONE() {
|
|
242
|
+
return NONE;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* @see https://dom.spec.whatwg.org/#dom-event-capturing_phase
|
|
246
|
+
*/
|
|
247
|
+
get CAPTURING_PHASE() {
|
|
248
|
+
return CAPTURING_PHASE;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* @see https://dom.spec.whatwg.org/#dom-event-at_target
|
|
252
|
+
*/
|
|
253
|
+
get AT_TARGET() {
|
|
254
|
+
return AT_TARGET;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* @see https://dom.spec.whatwg.org/#dom-event-bubbling_phase
|
|
258
|
+
*/
|
|
259
|
+
get BUBBLING_PHASE() {
|
|
260
|
+
return BUBBLING_PHASE;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* The current event phase.
|
|
264
|
+
* @see https://dom.spec.whatwg.org/#dom-event-eventphase
|
|
265
|
+
*/
|
|
266
|
+
get eventPhase() {
|
|
267
|
+
return $(this).dispatchFlag ? 2 : 0;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Stop event bubbling.
|
|
271
|
+
* Because this shim doesn't support node tree, this merely changes the `cancelBubble` property value.
|
|
272
|
+
* @see https://dom.spec.whatwg.org/#dom-event-stoppropagation
|
|
273
|
+
*/
|
|
274
|
+
stopPropagation() {
|
|
275
|
+
$(this).stopPropagationFlag = true;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* `true` if event bubbling was stopped.
|
|
279
|
+
* @deprecated
|
|
280
|
+
* @see https://dom.spec.whatwg.org/#dom-event-cancelbubble
|
|
281
|
+
*/
|
|
282
|
+
get cancelBubble() {
|
|
283
|
+
return $(this).stopPropagationFlag;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Stop event bubbling if `true` is set.
|
|
287
|
+
* @deprecated Use the `stopPropagation()` method instead.
|
|
288
|
+
* @see https://dom.spec.whatwg.org/#dom-event-cancelbubble
|
|
289
|
+
*/
|
|
290
|
+
set cancelBubble(value) {
|
|
291
|
+
if (value) {
|
|
292
|
+
$(this).stopPropagationFlag = true;
|
|
293
|
+
} else {
|
|
294
|
+
FalsyWasAssignedToCancelBubble.warn();
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Stop event bubbling and subsequent event listener callings.
|
|
299
|
+
* @see https://dom.spec.whatwg.org/#dom-event-stopimmediatepropagation
|
|
300
|
+
*/
|
|
301
|
+
stopImmediatePropagation() {
|
|
302
|
+
const data = $(this);
|
|
303
|
+
data.stopPropagationFlag = data.stopImmediatePropagationFlag = true;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* `true` if this event will bubble.
|
|
307
|
+
* @see https://dom.spec.whatwg.org/#dom-event-bubbles
|
|
308
|
+
*/
|
|
309
|
+
get bubbles() {
|
|
310
|
+
return $(this).bubbles;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* `true` if this event can be canceled by the `preventDefault()` method.
|
|
314
|
+
* @see https://dom.spec.whatwg.org/#dom-event-cancelable
|
|
315
|
+
*/
|
|
316
|
+
get cancelable() {
|
|
317
|
+
return $(this).cancelable;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* `true` if the default behavior will act.
|
|
321
|
+
* @deprecated Use the `defaultPrevented` proeprty instead.
|
|
322
|
+
* @see https://dom.spec.whatwg.org/#dom-event-returnvalue
|
|
323
|
+
*/
|
|
324
|
+
get returnValue() {
|
|
325
|
+
return !$(this).canceledFlag;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Cancel the default behavior if `false` is set.
|
|
329
|
+
* @deprecated Use the `preventDefault()` method instead.
|
|
330
|
+
* @see https://dom.spec.whatwg.org/#dom-event-returnvalue
|
|
331
|
+
*/
|
|
332
|
+
set returnValue(value) {
|
|
333
|
+
if (!value) {
|
|
334
|
+
setCancelFlag($(this));
|
|
335
|
+
} else {
|
|
336
|
+
TruthyWasAssignedToReturnValue.warn();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Cancel the default behavior.
|
|
341
|
+
* @see https://dom.spec.whatwg.org/#dom-event-preventdefault
|
|
342
|
+
*/
|
|
343
|
+
preventDefault() {
|
|
344
|
+
setCancelFlag($(this));
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* `true` if the default behavior was canceled.
|
|
348
|
+
* @see https://dom.spec.whatwg.org/#dom-event-defaultprevented
|
|
349
|
+
*/
|
|
350
|
+
get defaultPrevented() {
|
|
351
|
+
return $(this).canceledFlag;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* @see https://dom.spec.whatwg.org/#dom-event-composed
|
|
355
|
+
*/
|
|
356
|
+
get composed() {
|
|
357
|
+
return $(this).composed;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* @see https://dom.spec.whatwg.org/#dom-event-istrusted
|
|
361
|
+
*/
|
|
362
|
+
//istanbul ignore next
|
|
363
|
+
get isTrusted() {
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* @see https://dom.spec.whatwg.org/#dom-event-timestamp
|
|
368
|
+
*/
|
|
369
|
+
get timeStamp() {
|
|
370
|
+
return $(this).timeStamp;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* @deprecated Don't use this method. The constructor did initialization.
|
|
374
|
+
*/
|
|
375
|
+
initEvent(type) {
|
|
376
|
+
let bubbles = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
377
|
+
let cancelable = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
378
|
+
const data = $(this);
|
|
379
|
+
if (data.dispatchFlag) {
|
|
380
|
+
InitEventWasCalledWhileDispatching.warn();
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
internalDataMap.set(this, {
|
|
384
|
+
...data,
|
|
385
|
+
type: String(type),
|
|
386
|
+
bubbles: Boolean(bubbles),
|
|
387
|
+
cancelable: Boolean(cancelable),
|
|
388
|
+
target: null,
|
|
389
|
+
currentTarget: null,
|
|
390
|
+
stopPropagationFlag: false,
|
|
391
|
+
stopImmediatePropagationFlag: false,
|
|
392
|
+
canceledFlag: false
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
//------------------------------------------------------------------------------
|
|
397
|
+
// Helpers
|
|
398
|
+
//------------------------------------------------------------------------------
|
|
399
|
+
const NONE = 0;
|
|
400
|
+
const CAPTURING_PHASE = 1;
|
|
401
|
+
const AT_TARGET = 2;
|
|
402
|
+
const BUBBLING_PHASE = 3;
|
|
403
|
+
/**
|
|
404
|
+
* Private data for event wrappers.
|
|
405
|
+
*/
|
|
406
|
+
const internalDataMap = new WeakMap();
|
|
407
|
+
/**
|
|
408
|
+
* Get private data.
|
|
409
|
+
* @param event The event object to get private data.
|
|
410
|
+
* @param name The variable name to report.
|
|
411
|
+
* @returns The private data of the event.
|
|
412
|
+
*/
|
|
413
|
+
function $(event) {
|
|
414
|
+
let name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "this";
|
|
415
|
+
const retv = internalDataMap.get(event);
|
|
416
|
+
assertType(retv != null, "'%s' must be an object that Event constructor created, but got another one: %o", name, event);
|
|
417
|
+
return retv;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* https://dom.spec.whatwg.org/#set-the-canceled-flag
|
|
421
|
+
* @param data private data.
|
|
422
|
+
*/
|
|
423
|
+
function setCancelFlag(data) {
|
|
424
|
+
if (data.inPassiveListenerFlag) {
|
|
425
|
+
CanceledInPassiveListener.warn();
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
if (!data.cancelable) {
|
|
429
|
+
NonCancelableEventWasCanceled.warn();
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
data.canceledFlag = true;
|
|
433
|
+
}
|
|
434
|
+
// Set enumerable
|
|
435
|
+
Object.defineProperty(Event, "NONE", {
|
|
436
|
+
enumerable: true
|
|
437
|
+
});
|
|
438
|
+
Object.defineProperty(Event, "CAPTURING_PHASE", {
|
|
439
|
+
enumerable: true
|
|
440
|
+
});
|
|
441
|
+
Object.defineProperty(Event, "AT_TARGET", {
|
|
442
|
+
enumerable: true
|
|
443
|
+
});
|
|
444
|
+
Object.defineProperty(Event, "BUBBLING_PHASE", {
|
|
445
|
+
enumerable: true
|
|
446
|
+
});
|
|
447
|
+
const keys = Object.getOwnPropertyNames(Event.prototype);
|
|
448
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
449
|
+
if (keys[i] === "constructor") {
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
Object.defineProperty(Event.prototype, keys[i], {
|
|
453
|
+
enumerable: true
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
// Ensure `event instanceof window.Event` is `true`.
|
|
457
|
+
if (typeof Global !== "undefined" && typeof Global.Event !== "undefined") {
|
|
458
|
+
Object.setPrototypeOf(Event.prototype, Global.Event.prototype);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Create a new InvalidStateError instance.
|
|
463
|
+
* @param message The error message.
|
|
464
|
+
*/
|
|
465
|
+
function createInvalidStateError(message) {
|
|
466
|
+
if (Global.DOMException) {
|
|
467
|
+
return new Global.DOMException(message, "InvalidStateError");
|
|
468
|
+
}
|
|
469
|
+
if (DOMException == null) {
|
|
470
|
+
DOMException = class DOMException extends Error {
|
|
471
|
+
constructor(msg) {
|
|
472
|
+
super(msg);
|
|
473
|
+
if (Error.captureStackTrace) {
|
|
474
|
+
Error.captureStackTrace(this, DOMException);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
// eslint-disable-next-line class-methods-use-this
|
|
478
|
+
get code() {
|
|
479
|
+
return 11;
|
|
480
|
+
}
|
|
481
|
+
// eslint-disable-next-line class-methods-use-this
|
|
482
|
+
get name() {
|
|
483
|
+
return "InvalidStateError";
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
Object.defineProperties(DOMException.prototype, {
|
|
487
|
+
code: {
|
|
488
|
+
enumerable: true
|
|
489
|
+
},
|
|
490
|
+
name: {
|
|
491
|
+
enumerable: true
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
defineErrorCodeProperties(DOMException);
|
|
495
|
+
defineErrorCodeProperties(DOMException.prototype);
|
|
496
|
+
}
|
|
497
|
+
return new DOMException(message);
|
|
498
|
+
}
|
|
499
|
+
//------------------------------------------------------------------------------
|
|
500
|
+
// Helpers
|
|
501
|
+
//------------------------------------------------------------------------------
|
|
502
|
+
let DOMException;
|
|
503
|
+
const ErrorCodeMap = {
|
|
504
|
+
INDEX_SIZE_ERR: 1,
|
|
505
|
+
DOMSTRING_SIZE_ERR: 2,
|
|
506
|
+
HIERARCHY_REQUEST_ERR: 3,
|
|
507
|
+
WRONG_DOCUMENT_ERR: 4,
|
|
508
|
+
INVALID_CHARACTER_ERR: 5,
|
|
509
|
+
NO_DATA_ALLOWED_ERR: 6,
|
|
510
|
+
NO_MODIFICATION_ALLOWED_ERR: 7,
|
|
511
|
+
NOT_FOUND_ERR: 8,
|
|
512
|
+
NOT_SUPPORTED_ERR: 9,
|
|
513
|
+
INUSE_ATTRIBUTE_ERR: 10,
|
|
514
|
+
INVALID_STATE_ERR: 11,
|
|
515
|
+
SYNTAX_ERR: 12,
|
|
516
|
+
INVALID_MODIFICATION_ERR: 13,
|
|
517
|
+
NAMESPACE_ERR: 14,
|
|
518
|
+
INVALID_ACCESS_ERR: 15,
|
|
519
|
+
VALIDATION_ERR: 16,
|
|
520
|
+
TYPE_MISMATCH_ERR: 17,
|
|
521
|
+
SECURITY_ERR: 18,
|
|
522
|
+
NETWORK_ERR: 19,
|
|
523
|
+
ABORT_ERR: 20,
|
|
524
|
+
URL_MISMATCH_ERR: 21,
|
|
525
|
+
QUOTA_EXCEEDED_ERR: 22,
|
|
526
|
+
TIMEOUT_ERR: 23,
|
|
527
|
+
INVALID_NODE_TYPE_ERR: 24,
|
|
528
|
+
DATA_CLONE_ERR: 25
|
|
529
|
+
};
|
|
530
|
+
function defineErrorCodeProperties(obj) {
|
|
531
|
+
const keys = Object.keys(ErrorCodeMap);
|
|
532
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
533
|
+
const key = keys[i];
|
|
534
|
+
const value = ErrorCodeMap[key];
|
|
535
|
+
Object.defineProperty(obj, key, {
|
|
536
|
+
get() {
|
|
537
|
+
return value;
|
|
538
|
+
},
|
|
539
|
+
configurable: true,
|
|
540
|
+
enumerable: true
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* An implementation of `Event` interface, that wraps a given event object.
|
|
547
|
+
* This class controls the internal state of `Event`.
|
|
548
|
+
* @see https://dom.spec.whatwg.org/#interface-event
|
|
549
|
+
*/
|
|
550
|
+
class EventWrapper extends Event {
|
|
551
|
+
/**
|
|
552
|
+
* Wrap a given event object to control states.
|
|
553
|
+
* @param event The event-like object to wrap.
|
|
554
|
+
*/
|
|
555
|
+
static wrap(event) {
|
|
556
|
+
return new (getWrapperClassOf(event))(event);
|
|
557
|
+
}
|
|
558
|
+
constructor(event) {
|
|
559
|
+
super(event.type, {
|
|
560
|
+
bubbles: event.bubbles,
|
|
561
|
+
cancelable: event.cancelable,
|
|
562
|
+
composed: event.composed
|
|
563
|
+
});
|
|
564
|
+
if (event.cancelBubble) {
|
|
565
|
+
super.stopPropagation();
|
|
566
|
+
}
|
|
567
|
+
if (event.defaultPrevented) {
|
|
568
|
+
super.preventDefault();
|
|
569
|
+
}
|
|
570
|
+
internalDataMap$1.set(this, {
|
|
571
|
+
original: event
|
|
572
|
+
});
|
|
573
|
+
// Define accessors
|
|
574
|
+
const keys = Object.keys(event);
|
|
575
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
576
|
+
const key = keys[i];
|
|
577
|
+
if (!(key in this)) {
|
|
578
|
+
Object.defineProperty(this, key, defineRedirectDescriptor(event, key));
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
stopPropagation() {
|
|
583
|
+
super.stopPropagation();
|
|
584
|
+
const {
|
|
585
|
+
original
|
|
586
|
+
} = $$1(this);
|
|
587
|
+
if ("stopPropagation" in original) {
|
|
588
|
+
original.stopPropagation();
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
get cancelBubble() {
|
|
592
|
+
return super.cancelBubble;
|
|
593
|
+
}
|
|
594
|
+
set cancelBubble(value) {
|
|
595
|
+
super.cancelBubble = value;
|
|
596
|
+
const {
|
|
597
|
+
original
|
|
598
|
+
} = $$1(this);
|
|
599
|
+
if ("cancelBubble" in original) {
|
|
600
|
+
original.cancelBubble = value;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
stopImmediatePropagation() {
|
|
604
|
+
super.stopImmediatePropagation();
|
|
605
|
+
const {
|
|
606
|
+
original
|
|
607
|
+
} = $$1(this);
|
|
608
|
+
if ("stopImmediatePropagation" in original) {
|
|
609
|
+
original.stopImmediatePropagation();
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
get returnValue() {
|
|
613
|
+
return super.returnValue;
|
|
614
|
+
}
|
|
615
|
+
set returnValue(value) {
|
|
616
|
+
super.returnValue = value;
|
|
617
|
+
const {
|
|
618
|
+
original
|
|
619
|
+
} = $$1(this);
|
|
620
|
+
if ("returnValue" in original) {
|
|
621
|
+
original.returnValue = value;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
preventDefault() {
|
|
625
|
+
super.preventDefault();
|
|
626
|
+
const {
|
|
627
|
+
original
|
|
628
|
+
} = $$1(this);
|
|
629
|
+
if ("preventDefault" in original) {
|
|
630
|
+
original.preventDefault();
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
get timeStamp() {
|
|
634
|
+
const {
|
|
635
|
+
original
|
|
636
|
+
} = $$1(this);
|
|
637
|
+
if ("timeStamp" in original) {
|
|
638
|
+
return original.timeStamp;
|
|
639
|
+
}
|
|
640
|
+
return super.timeStamp;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Private data for event wrappers.
|
|
645
|
+
*/
|
|
646
|
+
const internalDataMap$1 = new WeakMap();
|
|
647
|
+
/**
|
|
648
|
+
* Get private data.
|
|
649
|
+
* @param event The event object to get private data.
|
|
650
|
+
* @returns The private data of the event.
|
|
651
|
+
*/
|
|
652
|
+
function $$1(event) {
|
|
653
|
+
const retv = internalDataMap$1.get(event);
|
|
654
|
+
assertType(retv != null, "'this' is expected an Event object, but got", event);
|
|
655
|
+
return retv;
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Cache for wrapper classes.
|
|
659
|
+
* @type {WeakMap<Object, Function>}
|
|
660
|
+
* @private
|
|
661
|
+
*/
|
|
662
|
+
const wrapperClassCache = new WeakMap();
|
|
663
|
+
// Make association for wrappers.
|
|
664
|
+
wrapperClassCache.set(Object.prototype, EventWrapper);
|
|
665
|
+
if (typeof Global !== "undefined" && typeof Global.Event !== "undefined") {
|
|
666
|
+
wrapperClassCache.set(Global.Event.prototype, EventWrapper);
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Get the wrapper class of a given prototype.
|
|
670
|
+
* @param originalEvent The event object to wrap.
|
|
671
|
+
*/
|
|
672
|
+
function getWrapperClassOf(originalEvent) {
|
|
673
|
+
const prototype = Object.getPrototypeOf(originalEvent);
|
|
674
|
+
if (prototype == null) {
|
|
675
|
+
return EventWrapper;
|
|
676
|
+
}
|
|
677
|
+
let wrapper = wrapperClassCache.get(prototype);
|
|
678
|
+
if (wrapper == null) {
|
|
679
|
+
wrapper = defineWrapper(getWrapperClassOf(prototype), prototype);
|
|
680
|
+
wrapperClassCache.set(prototype, wrapper);
|
|
681
|
+
}
|
|
682
|
+
return wrapper;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Define new wrapper class.
|
|
686
|
+
* @param BaseEventWrapper The base wrapper class.
|
|
687
|
+
* @param originalPrototype The prototype of the original event.
|
|
688
|
+
*/
|
|
689
|
+
function defineWrapper(BaseEventWrapper, originalPrototype) {
|
|
690
|
+
class CustomEventWrapper extends BaseEventWrapper {}
|
|
691
|
+
const keys = Object.keys(originalPrototype);
|
|
692
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
693
|
+
Object.defineProperty(CustomEventWrapper.prototype, keys[i], defineRedirectDescriptor(originalPrototype, keys[i]));
|
|
694
|
+
}
|
|
695
|
+
return CustomEventWrapper;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Get the property descriptor to redirect a given property.
|
|
699
|
+
*/
|
|
700
|
+
function defineRedirectDescriptor(obj, key) {
|
|
701
|
+
const d = Object.getOwnPropertyDescriptor(obj, key);
|
|
702
|
+
return {
|
|
703
|
+
get() {
|
|
704
|
+
const original = $$1(this).original;
|
|
705
|
+
const value = original[key];
|
|
706
|
+
if (typeof value === "function") {
|
|
707
|
+
return value.bind(original);
|
|
708
|
+
}
|
|
709
|
+
return value;
|
|
710
|
+
},
|
|
711
|
+
set(value) {
|
|
712
|
+
const original = $$1(this).original;
|
|
713
|
+
original[key] = value;
|
|
714
|
+
},
|
|
715
|
+
configurable: d.configurable,
|
|
716
|
+
enumerable: d.enumerable
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Create a new listener.
|
|
722
|
+
* @param callback The callback function.
|
|
723
|
+
* @param capture The capture flag.
|
|
724
|
+
* @param passive The passive flag.
|
|
725
|
+
* @param once The once flag.
|
|
726
|
+
* @param signal The abort signal.
|
|
727
|
+
* @param signalListener The abort event listener for the abort signal.
|
|
728
|
+
*/
|
|
729
|
+
function createListener(callback, capture, passive, once, signal, signalListener) {
|
|
730
|
+
return {
|
|
731
|
+
callback,
|
|
732
|
+
flags: (capture ? 1 /* Capture */ : 0) | (passive ? 2 /* Passive */ : 0) | (once ? 4 /* Once */ : 0),
|
|
733
|
+
signal,
|
|
734
|
+
signalListener
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Set the `removed` flag to the given listener.
|
|
739
|
+
* @param listener The listener to check.
|
|
740
|
+
*/
|
|
741
|
+
function setRemoved(listener) {
|
|
742
|
+
listener.flags |= 8 /* Removed */;
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Check if the given listener has the `capture` flag or not.
|
|
746
|
+
* @param listener The listener to check.
|
|
747
|
+
*/
|
|
748
|
+
function isCapture(listener) {
|
|
749
|
+
return (listener.flags & 1 /* Capture */) === 1 /* Capture */;
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Check if the given listener has the `passive` flag or not.
|
|
753
|
+
* @param listener The listener to check.
|
|
754
|
+
*/
|
|
755
|
+
function isPassive(listener) {
|
|
756
|
+
return (listener.flags & 2 /* Passive */) === 2 /* Passive */;
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Check if the given listener has the `once` flag or not.
|
|
760
|
+
* @param listener The listener to check.
|
|
761
|
+
*/
|
|
762
|
+
function isOnce(listener) {
|
|
763
|
+
return (listener.flags & 4 /* Once */) === 4 /* Once */;
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Check if the given listener has the `removed` flag or not.
|
|
767
|
+
* @param listener The listener to check.
|
|
768
|
+
*/
|
|
769
|
+
function isRemoved(listener) {
|
|
770
|
+
return (listener.flags & 8 /* Removed */) === 8 /* Removed */;
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Call an event listener.
|
|
774
|
+
* @param listener The listener to call.
|
|
775
|
+
* @param target The event target object for `thisArg`.
|
|
776
|
+
* @param event The event object for the first argument.
|
|
777
|
+
* @param attribute `true` if this callback is an event attribute handler.
|
|
778
|
+
*/
|
|
779
|
+
function invokeCallback(_ref, target, event) {
|
|
780
|
+
let {
|
|
781
|
+
callback
|
|
782
|
+
} = _ref;
|
|
783
|
+
try {
|
|
784
|
+
if (typeof callback === "function") {
|
|
785
|
+
callback.call(target, event);
|
|
786
|
+
} else if (typeof callback.handleEvent === "function") {
|
|
787
|
+
callback.handleEvent(event);
|
|
788
|
+
}
|
|
789
|
+
} catch (thrownError) {
|
|
790
|
+
reportError(thrownError);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* Find the index of given listener.
|
|
796
|
+
* This returns `-1` if not found.
|
|
797
|
+
* @param list The listener list.
|
|
798
|
+
* @param callback The callback function to find.
|
|
799
|
+
* @param capture The capture flag to find.
|
|
800
|
+
*/
|
|
801
|
+
function findIndexOfListener(_ref2, callback, capture) {
|
|
802
|
+
let {
|
|
803
|
+
listeners
|
|
804
|
+
} = _ref2;
|
|
805
|
+
for (let i = 0; i < listeners.length; ++i) {
|
|
806
|
+
if (listeners[i].callback === callback && isCapture(listeners[i]) === capture) {
|
|
807
|
+
return i;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
return -1;
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Add the given listener.
|
|
814
|
+
* Does copy-on-write if needed.
|
|
815
|
+
* @param list The listener list.
|
|
816
|
+
* @param callback The callback function.
|
|
817
|
+
* @param capture The capture flag.
|
|
818
|
+
* @param passive The passive flag.
|
|
819
|
+
* @param once The once flag.
|
|
820
|
+
* @param signal The abort signal.
|
|
821
|
+
*/
|
|
822
|
+
function addListener(list, callback, capture, passive, once, signal) {
|
|
823
|
+
let signalListener;
|
|
824
|
+
if (signal) {
|
|
825
|
+
signalListener = removeListener.bind(null, list, callback, capture);
|
|
826
|
+
signal.addEventListener("abort", signalListener);
|
|
827
|
+
}
|
|
828
|
+
const listener = createListener(callback, capture, passive, once, signal, signalListener);
|
|
829
|
+
if (list.cow) {
|
|
830
|
+
list.cow = false;
|
|
831
|
+
list.listeners = [...list.listeners, listener];
|
|
832
|
+
} else {
|
|
833
|
+
list.listeners.push(listener);
|
|
834
|
+
}
|
|
835
|
+
return listener;
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Remove a listener.
|
|
839
|
+
* @param list The listener list.
|
|
840
|
+
* @param callback The callback function to find.
|
|
841
|
+
* @param capture The capture flag to find.
|
|
842
|
+
* @returns `true` if it mutated the list directly.
|
|
843
|
+
*/
|
|
844
|
+
function removeListener(list, callback, capture) {
|
|
845
|
+
const index = findIndexOfListener(list, callback, capture);
|
|
846
|
+
if (index !== -1) {
|
|
847
|
+
return removeListenerAt(list, index);
|
|
848
|
+
}
|
|
849
|
+
return false;
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* Remove a listener.
|
|
853
|
+
* @param list The listener list.
|
|
854
|
+
* @param index The index of the target listener.
|
|
855
|
+
* @param disableCow Disable copy-on-write if true.
|
|
856
|
+
* @returns `true` if it mutated the `listeners` array directly.
|
|
857
|
+
*/
|
|
858
|
+
function removeListenerAt(list, index) {
|
|
859
|
+
let disableCow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
860
|
+
const listener = list.listeners[index];
|
|
861
|
+
// Set the removed flag.
|
|
862
|
+
setRemoved(listener);
|
|
863
|
+
// Dispose the abort signal listener if exists.
|
|
864
|
+
if (listener.signal) {
|
|
865
|
+
listener.signal.removeEventListener("abort", listener.signalListener);
|
|
866
|
+
}
|
|
867
|
+
// Remove it from the array.
|
|
868
|
+
if (list.cow && !disableCow) {
|
|
869
|
+
list.cow = false;
|
|
870
|
+
list.listeners = list.listeners.filter((_, i) => i !== index);
|
|
871
|
+
return false;
|
|
872
|
+
}
|
|
873
|
+
list.listeners.splice(index, 1);
|
|
874
|
+
return true;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* Create a new `ListenerListMap` object.
|
|
879
|
+
*/
|
|
880
|
+
function createListenerListMap() {
|
|
881
|
+
return Object.create(null);
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Get the listener list of the given type.
|
|
885
|
+
* If the listener list has not been initialized, initialize and return it.
|
|
886
|
+
* @param listenerMap The listener list map.
|
|
887
|
+
* @param type The event type to get.
|
|
888
|
+
*/
|
|
889
|
+
function ensureListenerList(listenerMap, type) {
|
|
890
|
+
var _a;
|
|
891
|
+
return (_a = listenerMap[type]) !== null && _a !== void 0 ? _a : listenerMap[type] = {
|
|
892
|
+
attrCallback: undefined,
|
|
893
|
+
attrListener: undefined,
|
|
894
|
+
cow: false,
|
|
895
|
+
listeners: []
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* An implementation of the `EventTarget` interface.
|
|
901
|
+
* @see https://dom.spec.whatwg.org/#eventtarget
|
|
902
|
+
*/
|
|
903
|
+
class EventTarget {
|
|
904
|
+
/**
|
|
905
|
+
* Initialize this instance.
|
|
906
|
+
*/
|
|
907
|
+
constructor() {
|
|
908
|
+
internalDataMap$2.set(this, createListenerListMap());
|
|
909
|
+
}
|
|
910
|
+
// Implementation
|
|
911
|
+
addEventListener(type0, callback0, options0) {
|
|
912
|
+
const listenerMap = $$2(this);
|
|
913
|
+
const {
|
|
914
|
+
callback,
|
|
915
|
+
capture,
|
|
916
|
+
once,
|
|
917
|
+
passive,
|
|
918
|
+
signal,
|
|
919
|
+
type
|
|
920
|
+
} = normalizeAddOptions(type0, callback0, options0);
|
|
921
|
+
if (callback == null || (signal === null || signal === void 0 ? void 0 : signal.aborted)) {
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
const list = ensureListenerList(listenerMap, type);
|
|
925
|
+
// Find existing listener.
|
|
926
|
+
const i = findIndexOfListener(list, callback, capture);
|
|
927
|
+
if (i !== -1) {
|
|
928
|
+
warnDuplicate(list.listeners[i], passive, once, signal);
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
// Add the new listener.
|
|
932
|
+
addListener(list, callback, capture, passive, once, signal);
|
|
933
|
+
}
|
|
934
|
+
// Implementation
|
|
935
|
+
removeEventListener(type0, callback0, options0) {
|
|
936
|
+
const listenerMap = $$2(this);
|
|
937
|
+
const {
|
|
938
|
+
callback,
|
|
939
|
+
capture,
|
|
940
|
+
type
|
|
941
|
+
} = normalizeOptions(type0, callback0, options0);
|
|
942
|
+
const list = listenerMap[type];
|
|
943
|
+
if (callback != null && list) {
|
|
944
|
+
removeListener(list, callback, capture);
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
// Implementation
|
|
948
|
+
dispatchEvent(e) {
|
|
949
|
+
const list = $$2(this)[String(e.type)];
|
|
950
|
+
if (list == null) {
|
|
951
|
+
return true;
|
|
952
|
+
}
|
|
953
|
+
const event = e instanceof Event ? e : EventWrapper.wrap(e);
|
|
954
|
+
const eventData = $(event, "event");
|
|
955
|
+
if (eventData.dispatchFlag) {
|
|
956
|
+
throw createInvalidStateError("This event has been in dispatching.");
|
|
957
|
+
}
|
|
958
|
+
eventData.dispatchFlag = true;
|
|
959
|
+
eventData.target = eventData.currentTarget = this;
|
|
960
|
+
if (!eventData.stopPropagationFlag) {
|
|
961
|
+
const {
|
|
962
|
+
cow,
|
|
963
|
+
listeners
|
|
964
|
+
} = list;
|
|
965
|
+
// Set copy-on-write flag.
|
|
966
|
+
list.cow = true;
|
|
967
|
+
// Call listeners.
|
|
968
|
+
for (let i = 0; i < listeners.length; ++i) {
|
|
969
|
+
const listener = listeners[i];
|
|
970
|
+
// Skip if removed.
|
|
971
|
+
if (isRemoved(listener)) {
|
|
972
|
+
continue;
|
|
973
|
+
}
|
|
974
|
+
// Remove this listener if has the `once` flag.
|
|
975
|
+
if (isOnce(listener) && removeListenerAt(list, i, !cow)) {
|
|
976
|
+
// Because this listener was removed, the next index is the
|
|
977
|
+
// same as the current value.
|
|
978
|
+
i -= 1;
|
|
979
|
+
}
|
|
980
|
+
// Call this listener with the `passive` flag.
|
|
981
|
+
eventData.inPassiveListenerFlag = isPassive(listener);
|
|
982
|
+
invokeCallback(listener, this, event);
|
|
983
|
+
eventData.inPassiveListenerFlag = false;
|
|
984
|
+
// Stop if the `event.stopImmediatePropagation()` method was called.
|
|
985
|
+
if (eventData.stopImmediatePropagationFlag) {
|
|
986
|
+
break;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
// Restore copy-on-write flag.
|
|
990
|
+
if (!cow) {
|
|
991
|
+
list.cow = false;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
eventData.target = null;
|
|
995
|
+
eventData.currentTarget = null;
|
|
996
|
+
eventData.stopImmediatePropagationFlag = false;
|
|
997
|
+
eventData.stopPropagationFlag = false;
|
|
998
|
+
eventData.dispatchFlag = false;
|
|
999
|
+
return !eventData.canceledFlag;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Internal data.
|
|
1004
|
+
*/
|
|
1005
|
+
const internalDataMap$2 = new WeakMap();
|
|
1006
|
+
/**
|
|
1007
|
+
* Get private data.
|
|
1008
|
+
* @param target The event target object to get private data.
|
|
1009
|
+
* @param name The variable name to report.
|
|
1010
|
+
* @returns The private data of the event.
|
|
1011
|
+
*/
|
|
1012
|
+
function $$2(target) {
|
|
1013
|
+
let name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "this";
|
|
1014
|
+
const retv = internalDataMap$2.get(target);
|
|
1015
|
+
assertType(retv != null, "'%s' must be an object that EventTarget constructor created, but got another one: %o", name, target);
|
|
1016
|
+
return retv;
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Normalize options.
|
|
1020
|
+
* @param options The options to normalize.
|
|
1021
|
+
*/
|
|
1022
|
+
function normalizeAddOptions(type, callback, options) {
|
|
1023
|
+
var _a;
|
|
1024
|
+
assertCallback(callback);
|
|
1025
|
+
if (typeof options === "object" && options !== null) {
|
|
1026
|
+
return {
|
|
1027
|
+
type: String(type),
|
|
1028
|
+
callback: callback !== null && callback !== void 0 ? callback : undefined,
|
|
1029
|
+
capture: Boolean(options.capture),
|
|
1030
|
+
passive: Boolean(options.passive),
|
|
1031
|
+
once: Boolean(options.once),
|
|
1032
|
+
signal: (_a = options.signal) !== null && _a !== void 0 ? _a : undefined
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
return {
|
|
1036
|
+
type: String(type),
|
|
1037
|
+
callback: callback !== null && callback !== void 0 ? callback : undefined,
|
|
1038
|
+
capture: Boolean(options),
|
|
1039
|
+
passive: false,
|
|
1040
|
+
once: false,
|
|
1041
|
+
signal: undefined
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* Normalize options.
|
|
1046
|
+
* @param options The options to normalize.
|
|
1047
|
+
*/
|
|
1048
|
+
function normalizeOptions(type, callback, options) {
|
|
1049
|
+
assertCallback(callback);
|
|
1050
|
+
if (typeof options === "object" && options !== null) {
|
|
1051
|
+
return {
|
|
1052
|
+
type: String(type),
|
|
1053
|
+
callback: callback !== null && callback !== void 0 ? callback : undefined,
|
|
1054
|
+
capture: Boolean(options.capture)
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
return {
|
|
1058
|
+
type: String(type),
|
|
1059
|
+
callback: callback !== null && callback !== void 0 ? callback : undefined,
|
|
1060
|
+
capture: Boolean(options)
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Assert the type of 'callback' argument.
|
|
1065
|
+
* @param callback The callback to check.
|
|
1066
|
+
*/
|
|
1067
|
+
function assertCallback(callback) {
|
|
1068
|
+
if (typeof callback === "function" || typeof callback === "object" && callback !== null && typeof callback.handleEvent === "function") {
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
if (callback == null || typeof callback === "object") {
|
|
1072
|
+
InvalidEventListener.warn(callback);
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1075
|
+
throw new TypeError(format(InvalidEventListener.message, [callback]));
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* Print warning for duplicated.
|
|
1079
|
+
* @param listener The current listener that is duplicated.
|
|
1080
|
+
* @param passive The passive flag of the new duplicated listener.
|
|
1081
|
+
* @param once The once flag of the new duplicated listener.
|
|
1082
|
+
* @param signal The signal object of the new duplicated listener.
|
|
1083
|
+
*/
|
|
1084
|
+
function warnDuplicate(listener, passive, once, signal) {
|
|
1085
|
+
EventListenerWasDuplicated.warn(isCapture(listener) ? "capture" : "bubble", listener.callback);
|
|
1086
|
+
if (isPassive(listener) !== passive) {
|
|
1087
|
+
OptionWasIgnored.warn("passive");
|
|
1088
|
+
}
|
|
1089
|
+
if (isOnce(listener) !== once) {
|
|
1090
|
+
OptionWasIgnored.warn("once");
|
|
1091
|
+
}
|
|
1092
|
+
if (listener.signal !== signal) {
|
|
1093
|
+
OptionWasIgnored.warn("signal");
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
// Set enumerable
|
|
1097
|
+
const keys$1 = Object.getOwnPropertyNames(EventTarget.prototype);
|
|
1098
|
+
for (let i = 0; i < keys$1.length; ++i) {
|
|
1099
|
+
if (keys$1[i] === "constructor") {
|
|
1100
|
+
continue;
|
|
1101
|
+
}
|
|
1102
|
+
Object.defineProperty(EventTarget.prototype, keys$1[i], {
|
|
1103
|
+
enumerable: true
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
// Ensure `eventTarget instanceof window.EventTarget` is `true`.
|
|
1107
|
+
if (typeof Global !== "undefined" && typeof Global.EventTarget !== "undefined") {
|
|
1108
|
+
Object.setPrototypeOf(EventTarget.prototype, Global.EventTarget.prototype);
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
/**
|
|
1112
|
+
* Get the current value of a given event attribute.
|
|
1113
|
+
* @param target The `EventTarget` object to get.
|
|
1114
|
+
* @param type The event type.
|
|
1115
|
+
*/
|
|
1116
|
+
function getEventAttributeValue(target, type) {
|
|
1117
|
+
var _a, _b;
|
|
1118
|
+
const listMap = $$2(target, "target");
|
|
1119
|
+
return (_b = (_a = listMap[type]) === null || _a === void 0 ? void 0 : _a.attrCallback) !== null && _b !== void 0 ? _b : null;
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* Set an event listener to a given event attribute.
|
|
1123
|
+
* @param target The `EventTarget` object to set.
|
|
1124
|
+
* @param type The event type.
|
|
1125
|
+
* @param callback The event listener.
|
|
1126
|
+
*/
|
|
1127
|
+
function setEventAttributeValue(target, type, callback) {
|
|
1128
|
+
if (callback != null && typeof callback !== "function") {
|
|
1129
|
+
InvalidAttributeHandler.warn(callback);
|
|
1130
|
+
}
|
|
1131
|
+
if (typeof callback === "function" || typeof callback === "object" && callback !== null) {
|
|
1132
|
+
upsertEventAttributeListener(target, type, callback);
|
|
1133
|
+
} else {
|
|
1134
|
+
removeEventAttributeListener(target, type);
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
//------------------------------------------------------------------------------
|
|
1138
|
+
// Helpers
|
|
1139
|
+
//------------------------------------------------------------------------------
|
|
1140
|
+
/**
|
|
1141
|
+
* Update or insert the given event attribute handler.
|
|
1142
|
+
* @param target The `EventTarget` object to set.
|
|
1143
|
+
* @param type The event type.
|
|
1144
|
+
* @param callback The event listener.
|
|
1145
|
+
*/
|
|
1146
|
+
function upsertEventAttributeListener(target, type, callback) {
|
|
1147
|
+
const list = ensureListenerList($$2(target, "target"), String(type));
|
|
1148
|
+
list.attrCallback = callback;
|
|
1149
|
+
if (list.attrListener == null) {
|
|
1150
|
+
list.attrListener = addListener(list, defineEventAttributeCallback(list), false, false, false, undefined);
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* Remove the given event attribute handler.
|
|
1155
|
+
* @param target The `EventTarget` object to remove.
|
|
1156
|
+
* @param type The event type.
|
|
1157
|
+
* @param callback The event listener.
|
|
1158
|
+
*/
|
|
1159
|
+
function removeEventAttributeListener(target, type) {
|
|
1160
|
+
const listMap = $$2(target, "target");
|
|
1161
|
+
const list = listMap[String(type)];
|
|
1162
|
+
if (list && list.attrListener) {
|
|
1163
|
+
removeListener(list, list.attrListener.callback, false);
|
|
1164
|
+
list.attrCallback = list.attrListener = undefined;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* Define the callback function for the given listener list object.
|
|
1169
|
+
* It calls `attrCallback` property if the property value is a function.
|
|
1170
|
+
* @param list The `ListenerList` object.
|
|
1171
|
+
*/
|
|
1172
|
+
function defineEventAttributeCallback(list) {
|
|
1173
|
+
return function (event) {
|
|
1174
|
+
const callback = list.attrCallback;
|
|
1175
|
+
if (typeof callback === "function") {
|
|
1176
|
+
callback.call(this, event);
|
|
1177
|
+
}
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
/**
|
|
1182
|
+
* Define an `EventTarget` class that has event attibutes.
|
|
1183
|
+
* @param types The types to define event attributes.
|
|
1184
|
+
* @deprecated Use `getEventAttributeValue`/`setEventAttributeValue` pair on your derived class instead because of static analysis friendly.
|
|
1185
|
+
*/
|
|
1186
|
+
function defineCustomEventTarget() {
|
|
1187
|
+
class CustomEventTarget extends EventTarget {}
|
|
1188
|
+
for (let i = 0; i < arguments.length; ++i) {
|
|
1189
|
+
defineEventAttribute(CustomEventTarget.prototype, i < 0 || arguments.length <= i ? undefined : arguments[i]);
|
|
1190
|
+
}
|
|
1191
|
+
return CustomEventTarget;
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Define an event attribute.
|
|
1195
|
+
* @param target The `EventTarget` object to define an event attribute.
|
|
1196
|
+
* @param type The event type to define.
|
|
1197
|
+
* @param _eventClass Unused, but to infer `Event` class type.
|
|
1198
|
+
* @deprecated Use `getEventAttributeValue`/`setEventAttributeValue` pair on your derived class instead because of static analysis friendly.
|
|
1199
|
+
*/
|
|
1200
|
+
function defineEventAttribute(target, type, _eventClass) {
|
|
1201
|
+
Object.defineProperty(target, `on${type}`, {
|
|
1202
|
+
get() {
|
|
1203
|
+
return getEventAttributeValue(this, type);
|
|
1204
|
+
},
|
|
1205
|
+
set(value) {
|
|
1206
|
+
setEventAttributeValue(this, type, value);
|
|
1207
|
+
},
|
|
1208
|
+
configurable: true,
|
|
1209
|
+
enumerable: true
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
exports.Event = Event;
|
|
1213
|
+
exports.EventTarget = EventTarget;
|
|
1214
|
+
exports.default = EventTarget;
|
|
1215
|
+
exports.defineCustomEventTarget = defineCustomEventTarget;
|
|
1216
|
+
exports.defineEventAttribute = defineEventAttribute;
|
|
1217
|
+
exports.getEventAttributeValue = getEventAttributeValue;
|
|
1218
|
+
exports.setErrorHandler = setErrorHandler;
|
|
1219
|
+
exports.setEventAttributeValue = setEventAttributeValue;
|
|
1220
|
+
exports.setWarningHandler = setWarningHandler;
|
|
1221
|
+
//# sourceMappingURL=index.js.map
|