@gjsify/dom-events 0.3.13 → 0.3.14
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/lib/esm/index.js +477 -483
- package/lib/esm/register/custom-events.js +17 -15
- package/lib/esm/register/event-target.js +14 -2
- package/lib/esm/register/ui-events.js +18 -17
- package/package.json +4 -4
- package/lib/esm/spec-aliases.d.js +0 -0
package/lib/esm/index.js
CHANGED
|
@@ -1,487 +1,481 @@
|
|
|
1
1
|
import { DOMException } from "@gjsify/dom-exception";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
ctrlKey;
|
|
283
|
-
metaKey;
|
|
284
|
-
movementX;
|
|
285
|
-
movementY;
|
|
286
|
-
offsetX;
|
|
287
|
-
offsetY;
|
|
288
|
-
screenX;
|
|
289
|
-
screenY;
|
|
290
|
-
shiftKey;
|
|
291
|
-
relatedTarget;
|
|
292
|
-
// Legacy aliases
|
|
293
|
-
get pageX() {
|
|
294
|
-
return this.clientX;
|
|
295
|
-
}
|
|
296
|
-
get pageY() {
|
|
297
|
-
return this.clientY;
|
|
298
|
-
}
|
|
299
|
-
get x() {
|
|
300
|
-
return this.clientX;
|
|
301
|
-
}
|
|
302
|
-
get y() {
|
|
303
|
-
return this.clientY;
|
|
304
|
-
}
|
|
305
|
-
constructor(type, eventInitDict) {
|
|
306
|
-
super(type, eventInitDict);
|
|
307
|
-
this.altKey = eventInitDict?.altKey ?? false;
|
|
308
|
-
this.button = eventInitDict?.button ?? 0;
|
|
309
|
-
this.buttons = eventInitDict?.buttons ?? 0;
|
|
310
|
-
this.clientX = eventInitDict?.clientX ?? 0;
|
|
311
|
-
this.clientY = eventInitDict?.clientY ?? 0;
|
|
312
|
-
this.ctrlKey = eventInitDict?.ctrlKey ?? false;
|
|
313
|
-
this.metaKey = eventInitDict?.metaKey ?? false;
|
|
314
|
-
this.movementX = eventInitDict?.movementX ?? 0;
|
|
315
|
-
this.movementY = eventInitDict?.movementY ?? 0;
|
|
316
|
-
this.offsetX = eventInitDict?.offsetX ?? 0;
|
|
317
|
-
this.offsetY = eventInitDict?.offsetY ?? 0;
|
|
318
|
-
this.screenX = eventInitDict?.screenX ?? 0;
|
|
319
|
-
this.screenY = eventInitDict?.screenY ?? 0;
|
|
320
|
-
this.shiftKey = eventInitDict?.shiftKey ?? false;
|
|
321
|
-
this.relatedTarget = eventInitDict?.relatedTarget ?? null;
|
|
322
|
-
}
|
|
323
|
-
getModifierState(key) {
|
|
324
|
-
switch (key) {
|
|
325
|
-
case "Alt":
|
|
326
|
-
return this.altKey;
|
|
327
|
-
case "Control":
|
|
328
|
-
return this.ctrlKey;
|
|
329
|
-
case "Meta":
|
|
330
|
-
return this.metaKey;
|
|
331
|
-
case "Shift":
|
|
332
|
-
return this.shiftKey;
|
|
333
|
-
default:
|
|
334
|
-
return false;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
get [Symbol.toStringTag]() {
|
|
338
|
-
return "MouseEvent";
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
class PointerEvent extends MouseEvent {
|
|
342
|
-
pointerId;
|
|
343
|
-
width;
|
|
344
|
-
height;
|
|
345
|
-
pressure;
|
|
346
|
-
tangentialPressure;
|
|
347
|
-
tiltX;
|
|
348
|
-
tiltY;
|
|
349
|
-
twist;
|
|
350
|
-
altitudeAngle;
|
|
351
|
-
azimuthAngle;
|
|
352
|
-
pointerType;
|
|
353
|
-
isPrimary;
|
|
354
|
-
constructor(type, eventInitDict) {
|
|
355
|
-
super(type, eventInitDict);
|
|
356
|
-
this.pointerId = eventInitDict?.pointerId ?? 0;
|
|
357
|
-
this.width = eventInitDict?.width ?? 1;
|
|
358
|
-
this.height = eventInitDict?.height ?? 1;
|
|
359
|
-
this.pressure = eventInitDict?.pressure ?? 0;
|
|
360
|
-
this.tangentialPressure = eventInitDict?.tangentialPressure ?? 0;
|
|
361
|
-
this.tiltX = eventInitDict?.tiltX ?? 0;
|
|
362
|
-
this.tiltY = eventInitDict?.tiltY ?? 0;
|
|
363
|
-
this.twist = eventInitDict?.twist ?? 0;
|
|
364
|
-
this.altitudeAngle = eventInitDict?.altitudeAngle ?? Math.PI / 2;
|
|
365
|
-
this.azimuthAngle = eventInitDict?.azimuthAngle ?? 0;
|
|
366
|
-
this.pointerType = eventInitDict?.pointerType ?? "";
|
|
367
|
-
this.isPrimary = eventInitDict?.isPrimary ?? false;
|
|
368
|
-
}
|
|
369
|
-
getCoalescedEvents() {
|
|
370
|
-
return [];
|
|
371
|
-
}
|
|
372
|
-
getPredictedEvents() {
|
|
373
|
-
return [];
|
|
374
|
-
}
|
|
375
|
-
get [Symbol.toStringTag]() {
|
|
376
|
-
return "PointerEvent";
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
class KeyboardEvent extends UIEvent {
|
|
380
|
-
altKey;
|
|
381
|
-
code;
|
|
382
|
-
ctrlKey;
|
|
383
|
-
isComposing;
|
|
384
|
-
key;
|
|
385
|
-
location;
|
|
386
|
-
metaKey;
|
|
387
|
-
repeat;
|
|
388
|
-
shiftKey;
|
|
389
|
-
keyCode;
|
|
390
|
-
which;
|
|
391
|
-
static DOM_KEY_LOCATION_STANDARD = 0;
|
|
392
|
-
static DOM_KEY_LOCATION_LEFT = 1;
|
|
393
|
-
static DOM_KEY_LOCATION_RIGHT = 2;
|
|
394
|
-
static DOM_KEY_LOCATION_NUMPAD = 3;
|
|
395
|
-
constructor(type, eventInitDict) {
|
|
396
|
-
super(type, eventInitDict);
|
|
397
|
-
this.altKey = eventInitDict?.altKey ?? false;
|
|
398
|
-
this.code = eventInitDict?.code ?? "";
|
|
399
|
-
this.ctrlKey = eventInitDict?.ctrlKey ?? false;
|
|
400
|
-
this.isComposing = eventInitDict?.isComposing ?? false;
|
|
401
|
-
this.key = eventInitDict?.key ?? "";
|
|
402
|
-
this.location = eventInitDict?.location ?? 0;
|
|
403
|
-
this.metaKey = eventInitDict?.metaKey ?? false;
|
|
404
|
-
this.repeat = eventInitDict?.repeat ?? false;
|
|
405
|
-
this.shiftKey = eventInitDict?.shiftKey ?? false;
|
|
406
|
-
this.keyCode = eventInitDict?.keyCode ?? 0;
|
|
407
|
-
this.which = eventInitDict?.which ?? 0;
|
|
408
|
-
}
|
|
409
|
-
getModifierState(key) {
|
|
410
|
-
switch (key) {
|
|
411
|
-
case "Alt":
|
|
412
|
-
return this.altKey;
|
|
413
|
-
case "Control":
|
|
414
|
-
return this.ctrlKey;
|
|
415
|
-
case "Meta":
|
|
416
|
-
return this.metaKey;
|
|
417
|
-
case "Shift":
|
|
418
|
-
return this.shiftKey;
|
|
419
|
-
default:
|
|
420
|
-
return false;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
get [Symbol.toStringTag]() {
|
|
424
|
-
return "KeyboardEvent";
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
class WheelEvent extends MouseEvent {
|
|
428
|
-
deltaX;
|
|
429
|
-
deltaY;
|
|
430
|
-
deltaZ;
|
|
431
|
-
deltaMode;
|
|
432
|
-
static DOM_DELTA_PIXEL = 0;
|
|
433
|
-
static DOM_DELTA_LINE = 1;
|
|
434
|
-
static DOM_DELTA_PAGE = 2;
|
|
435
|
-
constructor(type, eventInitDict) {
|
|
436
|
-
super(type, eventInitDict);
|
|
437
|
-
this.deltaX = eventInitDict?.deltaX ?? 0;
|
|
438
|
-
this.deltaY = eventInitDict?.deltaY ?? 0;
|
|
439
|
-
this.deltaZ = eventInitDict?.deltaZ ?? 0;
|
|
440
|
-
this.deltaMode = eventInitDict?.deltaMode ?? 0;
|
|
441
|
-
}
|
|
442
|
-
get [Symbol.toStringTag]() {
|
|
443
|
-
return "WheelEvent";
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
class FocusEvent extends UIEvent {
|
|
447
|
-
relatedTarget;
|
|
448
|
-
constructor(type, eventInitDict) {
|
|
449
|
-
super(type, eventInitDict);
|
|
450
|
-
this.relatedTarget = eventInitDict?.relatedTarget ?? null;
|
|
451
|
-
}
|
|
452
|
-
get [Symbol.toStringTag]() {
|
|
453
|
-
return "FocusEvent";
|
|
454
|
-
}
|
|
2
|
+
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
const kType = Symbol("type");
|
|
5
|
+
const kBubbles = Symbol("bubbles");
|
|
6
|
+
const kCancelable = Symbol("cancelable");
|
|
7
|
+
const kComposed = Symbol("composed");
|
|
8
|
+
const kTarget = Symbol("target");
|
|
9
|
+
const kCurrentTarget = Symbol("currentTarget");
|
|
10
|
+
const kEventPhase = Symbol("eventPhase");
|
|
11
|
+
const kDefaultPrevented = Symbol("defaultPrevented");
|
|
12
|
+
const kIsTrusted = Symbol("isTrusted");
|
|
13
|
+
const kTimeStamp = Symbol("timeStamp");
|
|
14
|
+
const kStop = Symbol("stop");
|
|
15
|
+
const kImmediateStop = Symbol("immediateStop");
|
|
16
|
+
const kDispatching = Symbol("dispatching");
|
|
17
|
+
const kInPassiveListener = Symbol("inPassiveListener");
|
|
18
|
+
var Event = class {
|
|
19
|
+
[kType];
|
|
20
|
+
[kBubbles];
|
|
21
|
+
[kCancelable];
|
|
22
|
+
[kComposed];
|
|
23
|
+
[kTarget] = null;
|
|
24
|
+
[kCurrentTarget] = null;
|
|
25
|
+
[kEventPhase] = 0;
|
|
26
|
+
[kDefaultPrevented] = false;
|
|
27
|
+
[kIsTrusted] = false;
|
|
28
|
+
[kTimeStamp];
|
|
29
|
+
[kStop] = false;
|
|
30
|
+
[kImmediateStop] = false;
|
|
31
|
+
[kDispatching] = false;
|
|
32
|
+
[kInPassiveListener] = false;
|
|
33
|
+
get type() {
|
|
34
|
+
return this[kType];
|
|
35
|
+
}
|
|
36
|
+
get bubbles() {
|
|
37
|
+
return this[kBubbles];
|
|
38
|
+
}
|
|
39
|
+
get cancelable() {
|
|
40
|
+
return this[kCancelable];
|
|
41
|
+
}
|
|
42
|
+
get composed() {
|
|
43
|
+
return this[kComposed];
|
|
44
|
+
}
|
|
45
|
+
get target() {
|
|
46
|
+
return this[kTarget];
|
|
47
|
+
}
|
|
48
|
+
get currentTarget() {
|
|
49
|
+
return this[kCurrentTarget];
|
|
50
|
+
}
|
|
51
|
+
get eventPhase() {
|
|
52
|
+
return this[kEventPhase];
|
|
53
|
+
}
|
|
54
|
+
get defaultPrevented() {
|
|
55
|
+
return this[kDefaultPrevented];
|
|
56
|
+
}
|
|
57
|
+
get timeStamp() {
|
|
58
|
+
return this[kTimeStamp];
|
|
59
|
+
}
|
|
60
|
+
get cancelBubble() {
|
|
61
|
+
return this[kStop];
|
|
62
|
+
}
|
|
63
|
+
set cancelBubble(value) {
|
|
64
|
+
if (value) this.stopPropagation();
|
|
65
|
+
}
|
|
66
|
+
get returnValue() {
|
|
67
|
+
return !this[kDefaultPrevented];
|
|
68
|
+
}
|
|
69
|
+
set returnValue(value) {
|
|
70
|
+
if (!value) this.preventDefault();
|
|
71
|
+
}
|
|
72
|
+
get srcElement() {
|
|
73
|
+
return this[kTarget];
|
|
74
|
+
}
|
|
75
|
+
static NONE = 0;
|
|
76
|
+
static CAPTURING_PHASE = 1;
|
|
77
|
+
static AT_TARGET = 2;
|
|
78
|
+
static BUBBLING_PHASE = 3;
|
|
79
|
+
get [Symbol.toStringTag]() {
|
|
80
|
+
return "Event";
|
|
81
|
+
}
|
|
82
|
+
constructor(type, eventInitDict) {
|
|
83
|
+
this[kType] = type;
|
|
84
|
+
this[kBubbles] = eventInitDict?.bubbles ?? false;
|
|
85
|
+
this[kCancelable] = eventInitDict?.cancelable ?? false;
|
|
86
|
+
this[kComposed] = eventInitDict?.composed ?? false;
|
|
87
|
+
this[kTimeStamp] = Date.now();
|
|
88
|
+
Object.defineProperty(this, "isTrusted", {
|
|
89
|
+
get: () => this[kIsTrusted],
|
|
90
|
+
enumerable: true,
|
|
91
|
+
configurable: false
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
composedPath() {
|
|
95
|
+
if (this[kCurrentTarget]) return [this[kCurrentTarget]];
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
preventDefault() {
|
|
99
|
+
if (this[kCancelable] && !this[kInPassiveListener]) {
|
|
100
|
+
this[kDefaultPrevented] = true;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
stopPropagation() {
|
|
104
|
+
this[kStop] = true;
|
|
105
|
+
}
|
|
106
|
+
stopImmediatePropagation() {
|
|
107
|
+
this[kStop] = true;
|
|
108
|
+
this[kImmediateStop] = true;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
var CustomEvent = class extends Event {
|
|
112
|
+
detail;
|
|
113
|
+
constructor(type, eventInitDict) {
|
|
114
|
+
super(type, eventInitDict);
|
|
115
|
+
this.detail = eventInitDict?.detail;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
var MessageEvent = class extends Event {
|
|
119
|
+
data;
|
|
120
|
+
origin;
|
|
121
|
+
lastEventId;
|
|
122
|
+
source;
|
|
123
|
+
ports;
|
|
124
|
+
constructor(type, eventInitDict) {
|
|
125
|
+
super(type, eventInitDict);
|
|
126
|
+
this.data = eventInitDict?.data ?? null;
|
|
127
|
+
this.origin = eventInitDict?.origin ?? "";
|
|
128
|
+
this.lastEventId = eventInitDict?.lastEventId ?? "";
|
|
129
|
+
this.source = eventInitDict?.source ?? null;
|
|
130
|
+
this.ports = eventInitDict?.ports ?? [];
|
|
131
|
+
}
|
|
132
|
+
get [Symbol.toStringTag]() {
|
|
133
|
+
return "MessageEvent";
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
var ErrorEvent = class extends Event {
|
|
137
|
+
message;
|
|
138
|
+
filename;
|
|
139
|
+
lineno;
|
|
140
|
+
colno;
|
|
141
|
+
error;
|
|
142
|
+
constructor(type, eventInitDict) {
|
|
143
|
+
super(type, eventInitDict);
|
|
144
|
+
this.message = eventInitDict?.message ?? "";
|
|
145
|
+
this.filename = eventInitDict?.filename ?? "";
|
|
146
|
+
this.lineno = eventInitDict?.lineno ?? 0;
|
|
147
|
+
this.colno = eventInitDict?.colno ?? 0;
|
|
148
|
+
this.error = eventInitDict?.error ?? null;
|
|
149
|
+
}
|
|
150
|
+
get [Symbol.toStringTag]() {
|
|
151
|
+
return "ErrorEvent";
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
var CloseEvent = class extends Event {
|
|
155
|
+
code;
|
|
156
|
+
reason;
|
|
157
|
+
wasClean;
|
|
158
|
+
constructor(type, eventInitDict) {
|
|
159
|
+
super(type, eventInitDict);
|
|
160
|
+
this.code = eventInitDict?.code ?? 0;
|
|
161
|
+
this.reason = eventInitDict?.reason ?? "";
|
|
162
|
+
this.wasClean = eventInitDict?.wasClean ?? false;
|
|
163
|
+
}
|
|
164
|
+
get [Symbol.toStringTag]() {
|
|
165
|
+
return "CloseEvent";
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
var ProgressEvent = class extends Event {
|
|
169
|
+
lengthComputable;
|
|
170
|
+
loaded;
|
|
171
|
+
total;
|
|
172
|
+
constructor(type, eventInitDict) {
|
|
173
|
+
super(type, eventInitDict);
|
|
174
|
+
this.lengthComputable = eventInitDict?.lengthComputable ?? false;
|
|
175
|
+
this.loaded = eventInitDict?.loaded ?? 0;
|
|
176
|
+
this.total = eventInitDict?.total ?? 0;
|
|
177
|
+
}
|
|
178
|
+
get [Symbol.toStringTag]() {
|
|
179
|
+
return "ProgressEvent";
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
var EventTarget = class {
|
|
183
|
+
_listeners = new Map();
|
|
184
|
+
get [Symbol.toStringTag]() {
|
|
185
|
+
return "EventTarget";
|
|
186
|
+
}
|
|
187
|
+
addEventListener(type, callback, options) {
|
|
188
|
+
if (callback === null) return;
|
|
189
|
+
const capture = typeof options === "boolean" ? options : options?.capture ?? false;
|
|
190
|
+
const once = typeof options === "object" ? options?.once ?? false : false;
|
|
191
|
+
const passive = typeof options === "object" ? options?.passive ?? false : false;
|
|
192
|
+
let list = this._listeners.get(type);
|
|
193
|
+
if (!list) {
|
|
194
|
+
list = [];
|
|
195
|
+
this._listeners.set(type, list);
|
|
196
|
+
}
|
|
197
|
+
for (const entry of list) {
|
|
198
|
+
if (entry.listener === callback && entry.capture === capture) return;
|
|
199
|
+
}
|
|
200
|
+
const entry = {
|
|
201
|
+
listener: callback,
|
|
202
|
+
capture,
|
|
203
|
+
once,
|
|
204
|
+
passive,
|
|
205
|
+
removed: false
|
|
206
|
+
};
|
|
207
|
+
list.push(entry);
|
|
208
|
+
if (typeof options === "object" && options?.signal) {
|
|
209
|
+
options.signal.addEventListener("abort", () => {
|
|
210
|
+
this.removeEventListener(type, callback, { capture });
|
|
211
|
+
}, { once: true });
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
removeEventListener(type, callback, options) {
|
|
215
|
+
if (callback === null) return;
|
|
216
|
+
const capture = typeof options === "boolean" ? options : options?.capture ?? false;
|
|
217
|
+
const list = this._listeners.get(type);
|
|
218
|
+
if (!list) return;
|
|
219
|
+
const idx = list.findIndex((e) => e.listener === callback && e.capture === capture);
|
|
220
|
+
if (idx !== -1) {
|
|
221
|
+
list[idx].removed = true;
|
|
222
|
+
list.splice(idx, 1);
|
|
223
|
+
if (list.length === 0) this._listeners.delete(type);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
dispatchEvent(event) {
|
|
227
|
+
if (event[kDispatching]) {
|
|
228
|
+
throw new DOMException("The event is already being dispatched.", "InvalidStateError");
|
|
229
|
+
}
|
|
230
|
+
event[kDispatching] = true;
|
|
231
|
+
event[kTarget] = this;
|
|
232
|
+
event[kCurrentTarget] = this;
|
|
233
|
+
event[kEventPhase] = Event.AT_TARGET;
|
|
234
|
+
const list = this._listeners.get(event.type);
|
|
235
|
+
if (list) {
|
|
236
|
+
const entries = [...list];
|
|
237
|
+
for (const entry of entries) {
|
|
238
|
+
if (entry.removed) continue;
|
|
239
|
+
if (event[kImmediateStop]) break;
|
|
240
|
+
if (event[kStop]) break;
|
|
241
|
+
if (entry.once) {
|
|
242
|
+
this.removeEventListener(event.type, entry.listener, { capture: entry.capture });
|
|
243
|
+
}
|
|
244
|
+
try {
|
|
245
|
+
if (entry.passive) event[kInPassiveListener] = true;
|
|
246
|
+
if (typeof entry.listener === "function") {
|
|
247
|
+
entry.listener.call(this, event);
|
|
248
|
+
} else if (typeof entry.listener.handleEvent === "function") {
|
|
249
|
+
entry.listener.handleEvent.call(entry.listener, event);
|
|
250
|
+
}
|
|
251
|
+
} catch (err) {
|
|
252
|
+
console.error(err);
|
|
253
|
+
} finally {
|
|
254
|
+
event[kInPassiveListener] = false;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
event[kEventPhase] = Event.NONE;
|
|
259
|
+
event[kCurrentTarget] = null;
|
|
260
|
+
event[kDispatching] = false;
|
|
261
|
+
return !event.defaultPrevented;
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
for (const [name, value] of [
|
|
265
|
+
["NONE", 0],
|
|
266
|
+
["CAPTURING_PHASE", 1],
|
|
267
|
+
["AT_TARGET", 2],
|
|
268
|
+
["BUBBLING_PHASE", 3]
|
|
269
|
+
]) {
|
|
270
|
+
Object.defineProperty(Event.prototype, name, {
|
|
271
|
+
value,
|
|
272
|
+
writable: false,
|
|
273
|
+
enumerable: true,
|
|
274
|
+
configurable: false
|
|
275
|
+
});
|
|
276
|
+
Object.defineProperty(Event, name, {
|
|
277
|
+
value,
|
|
278
|
+
writable: false,
|
|
279
|
+
enumerable: true,
|
|
280
|
+
configurable: false
|
|
281
|
+
});
|
|
455
282
|
}
|
|
456
|
-
var
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
283
|
+
var UIEvent = class extends Event {
|
|
284
|
+
detail;
|
|
285
|
+
view;
|
|
286
|
+
constructor(type, eventInitDict) {
|
|
287
|
+
super(type, eventInitDict);
|
|
288
|
+
this.detail = eventInitDict?.detail ?? 0;
|
|
289
|
+
this.view = null;
|
|
290
|
+
}
|
|
291
|
+
get [Symbol.toStringTag]() {
|
|
292
|
+
return "UIEvent";
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
var MouseEvent = class extends UIEvent {
|
|
296
|
+
altKey;
|
|
297
|
+
button;
|
|
298
|
+
buttons;
|
|
299
|
+
clientX;
|
|
300
|
+
clientY;
|
|
301
|
+
ctrlKey;
|
|
302
|
+
metaKey;
|
|
303
|
+
movementX;
|
|
304
|
+
movementY;
|
|
305
|
+
offsetX;
|
|
306
|
+
offsetY;
|
|
307
|
+
screenX;
|
|
308
|
+
screenY;
|
|
309
|
+
shiftKey;
|
|
310
|
+
relatedTarget;
|
|
311
|
+
get pageX() {
|
|
312
|
+
return this.clientX;
|
|
313
|
+
}
|
|
314
|
+
get pageY() {
|
|
315
|
+
return this.clientY;
|
|
316
|
+
}
|
|
317
|
+
get x() {
|
|
318
|
+
return this.clientX;
|
|
319
|
+
}
|
|
320
|
+
get y() {
|
|
321
|
+
return this.clientY;
|
|
322
|
+
}
|
|
323
|
+
constructor(type, eventInitDict) {
|
|
324
|
+
super(type, eventInitDict);
|
|
325
|
+
this.altKey = eventInitDict?.altKey ?? false;
|
|
326
|
+
this.button = eventInitDict?.button ?? 0;
|
|
327
|
+
this.buttons = eventInitDict?.buttons ?? 0;
|
|
328
|
+
this.clientX = eventInitDict?.clientX ?? 0;
|
|
329
|
+
this.clientY = eventInitDict?.clientY ?? 0;
|
|
330
|
+
this.ctrlKey = eventInitDict?.ctrlKey ?? false;
|
|
331
|
+
this.metaKey = eventInitDict?.metaKey ?? false;
|
|
332
|
+
this.movementX = eventInitDict?.movementX ?? 0;
|
|
333
|
+
this.movementY = eventInitDict?.movementY ?? 0;
|
|
334
|
+
this.offsetX = eventInitDict?.offsetX ?? 0;
|
|
335
|
+
this.offsetY = eventInitDict?.offsetY ?? 0;
|
|
336
|
+
this.screenX = eventInitDict?.screenX ?? 0;
|
|
337
|
+
this.screenY = eventInitDict?.screenY ?? 0;
|
|
338
|
+
this.shiftKey = eventInitDict?.shiftKey ?? false;
|
|
339
|
+
this.relatedTarget = eventInitDict?.relatedTarget ?? null;
|
|
340
|
+
}
|
|
341
|
+
getModifierState(key) {
|
|
342
|
+
switch (key) {
|
|
343
|
+
case "Alt": return this.altKey;
|
|
344
|
+
case "Control": return this.ctrlKey;
|
|
345
|
+
case "Meta": return this.metaKey;
|
|
346
|
+
case "Shift": return this.shiftKey;
|
|
347
|
+
default: return false;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
get [Symbol.toStringTag]() {
|
|
351
|
+
return "MouseEvent";
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
var PointerEvent = class extends MouseEvent {
|
|
355
|
+
pointerId;
|
|
356
|
+
width;
|
|
357
|
+
height;
|
|
358
|
+
pressure;
|
|
359
|
+
tangentialPressure;
|
|
360
|
+
tiltX;
|
|
361
|
+
tiltY;
|
|
362
|
+
twist;
|
|
363
|
+
altitudeAngle;
|
|
364
|
+
azimuthAngle;
|
|
365
|
+
pointerType;
|
|
366
|
+
isPrimary;
|
|
367
|
+
constructor(type, eventInitDict) {
|
|
368
|
+
super(type, eventInitDict);
|
|
369
|
+
this.pointerId = eventInitDict?.pointerId ?? 0;
|
|
370
|
+
this.width = eventInitDict?.width ?? 1;
|
|
371
|
+
this.height = eventInitDict?.height ?? 1;
|
|
372
|
+
this.pressure = eventInitDict?.pressure ?? 0;
|
|
373
|
+
this.tangentialPressure = eventInitDict?.tangentialPressure ?? 0;
|
|
374
|
+
this.tiltX = eventInitDict?.tiltX ?? 0;
|
|
375
|
+
this.tiltY = eventInitDict?.tiltY ?? 0;
|
|
376
|
+
this.twist = eventInitDict?.twist ?? 0;
|
|
377
|
+
this.altitudeAngle = eventInitDict?.altitudeAngle ?? Math.PI / 2;
|
|
378
|
+
this.azimuthAngle = eventInitDict?.azimuthAngle ?? 0;
|
|
379
|
+
this.pointerType = eventInitDict?.pointerType ?? "";
|
|
380
|
+
this.isPrimary = eventInitDict?.isPrimary ?? false;
|
|
381
|
+
}
|
|
382
|
+
getCoalescedEvents() {
|
|
383
|
+
return [];
|
|
384
|
+
}
|
|
385
|
+
getPredictedEvents() {
|
|
386
|
+
return [];
|
|
387
|
+
}
|
|
388
|
+
get [Symbol.toStringTag]() {
|
|
389
|
+
return "PointerEvent";
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
var KeyboardEvent = class extends UIEvent {
|
|
393
|
+
altKey;
|
|
394
|
+
code;
|
|
395
|
+
ctrlKey;
|
|
396
|
+
isComposing;
|
|
397
|
+
key;
|
|
398
|
+
location;
|
|
399
|
+
metaKey;
|
|
400
|
+
repeat;
|
|
401
|
+
shiftKey;
|
|
402
|
+
keyCode;
|
|
403
|
+
which;
|
|
404
|
+
static DOM_KEY_LOCATION_STANDARD = 0;
|
|
405
|
+
static DOM_KEY_LOCATION_LEFT = 1;
|
|
406
|
+
static DOM_KEY_LOCATION_RIGHT = 2;
|
|
407
|
+
static DOM_KEY_LOCATION_NUMPAD = 3;
|
|
408
|
+
constructor(type, eventInitDict) {
|
|
409
|
+
super(type, eventInitDict);
|
|
410
|
+
this.altKey = eventInitDict?.altKey ?? false;
|
|
411
|
+
this.code = eventInitDict?.code ?? "";
|
|
412
|
+
this.ctrlKey = eventInitDict?.ctrlKey ?? false;
|
|
413
|
+
this.isComposing = eventInitDict?.isComposing ?? false;
|
|
414
|
+
this.key = eventInitDict?.key ?? "";
|
|
415
|
+
this.location = eventInitDict?.location ?? 0;
|
|
416
|
+
this.metaKey = eventInitDict?.metaKey ?? false;
|
|
417
|
+
this.repeat = eventInitDict?.repeat ?? false;
|
|
418
|
+
this.shiftKey = eventInitDict?.shiftKey ?? false;
|
|
419
|
+
this.keyCode = eventInitDict?.keyCode ?? 0;
|
|
420
|
+
this.which = eventInitDict?.which ?? 0;
|
|
421
|
+
}
|
|
422
|
+
getModifierState(key) {
|
|
423
|
+
switch (key) {
|
|
424
|
+
case "Alt": return this.altKey;
|
|
425
|
+
case "Control": return this.ctrlKey;
|
|
426
|
+
case "Meta": return this.metaKey;
|
|
427
|
+
case "Shift": return this.shiftKey;
|
|
428
|
+
default: return false;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
get [Symbol.toStringTag]() {
|
|
432
|
+
return "KeyboardEvent";
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
var WheelEvent = class extends MouseEvent {
|
|
436
|
+
deltaX;
|
|
437
|
+
deltaY;
|
|
438
|
+
deltaZ;
|
|
439
|
+
deltaMode;
|
|
440
|
+
static DOM_DELTA_PIXEL = 0;
|
|
441
|
+
static DOM_DELTA_LINE = 1;
|
|
442
|
+
static DOM_DELTA_PAGE = 2;
|
|
443
|
+
constructor(type, eventInitDict) {
|
|
444
|
+
super(type, eventInitDict);
|
|
445
|
+
this.deltaX = eventInitDict?.deltaX ?? 0;
|
|
446
|
+
this.deltaY = eventInitDict?.deltaY ?? 0;
|
|
447
|
+
this.deltaZ = eventInitDict?.deltaZ ?? 0;
|
|
448
|
+
this.deltaMode = eventInitDict?.deltaMode ?? 0;
|
|
449
|
+
}
|
|
450
|
+
get [Symbol.toStringTag]() {
|
|
451
|
+
return "WheelEvent";
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
var FocusEvent = class extends UIEvent {
|
|
455
|
+
relatedTarget;
|
|
456
|
+
constructor(type, eventInitDict) {
|
|
457
|
+
super(type, eventInitDict);
|
|
458
|
+
this.relatedTarget = eventInitDict?.relatedTarget ?? null;
|
|
459
|
+
}
|
|
460
|
+
get [Symbol.toStringTag]() {
|
|
461
|
+
return "FocusEvent";
|
|
462
|
+
}
|
|
470
463
|
};
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
WheelEvent,
|
|
486
|
-
index_default as default
|
|
464
|
+
var src_default = {
|
|
465
|
+
Event,
|
|
466
|
+
CustomEvent,
|
|
467
|
+
EventTarget,
|
|
468
|
+
MessageEvent,
|
|
469
|
+
ErrorEvent,
|
|
470
|
+
CloseEvent,
|
|
471
|
+
ProgressEvent,
|
|
472
|
+
UIEvent,
|
|
473
|
+
MouseEvent,
|
|
474
|
+
PointerEvent,
|
|
475
|
+
KeyboardEvent,
|
|
476
|
+
WheelEvent,
|
|
477
|
+
FocusEvent
|
|
487
478
|
};
|
|
479
|
+
|
|
480
|
+
//#endregion
|
|
481
|
+
export { CloseEvent, CustomEvent, DOMException, ErrorEvent, Event, EventTarget, FocusEvent, KeyboardEvent, MessageEvent, MouseEvent, PointerEvent, ProgressEvent, UIEvent, WheelEvent, src_default as default };
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
ErrorEvent,
|
|
5
|
-
CloseEvent,
|
|
6
|
-
ProgressEvent
|
|
7
|
-
} from "../index.js";
|
|
1
|
+
import { CloseEvent, CustomEvent, ErrorEvent, MessageEvent, ProgressEvent } from "../index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/register/custom-events.ts
|
|
8
4
|
const toRegister = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
CustomEvent,
|
|
6
|
+
MessageEvent,
|
|
7
|
+
ErrorEvent,
|
|
8
|
+
CloseEvent,
|
|
9
|
+
ProgressEvent
|
|
14
10
|
};
|
|
15
11
|
for (const [name, value] of Object.entries(toRegister)) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
if (typeof globalThis[name] === "undefined") {
|
|
13
|
+
Object.defineProperty(globalThis, name, {
|
|
14
|
+
value,
|
|
15
|
+
writable: true,
|
|
16
|
+
configurable: true
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import { Event, EventTarget } from "../index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/register/event-target.ts
|
|
2
4
|
if (typeof globalThis.Event === "undefined") {
|
|
3
|
-
|
|
5
|
+
Object.defineProperty(globalThis, "Event", {
|
|
6
|
+
value: Event,
|
|
7
|
+
writable: true,
|
|
8
|
+
configurable: true
|
|
9
|
+
});
|
|
4
10
|
}
|
|
5
11
|
if (typeof globalThis.EventTarget === "undefined") {
|
|
6
|
-
|
|
12
|
+
Object.defineProperty(globalThis, "EventTarget", {
|
|
13
|
+
value: EventTarget,
|
|
14
|
+
writable: true,
|
|
15
|
+
configurable: true
|
|
16
|
+
});
|
|
7
17
|
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
PointerEvent,
|
|
5
|
-
KeyboardEvent,
|
|
6
|
-
WheelEvent,
|
|
7
|
-
FocusEvent
|
|
8
|
-
} from "../index.js";
|
|
1
|
+
import { FocusEvent, KeyboardEvent, MouseEvent, PointerEvent, UIEvent, WheelEvent } from "../index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/register/ui-events.ts
|
|
9
4
|
const toRegister = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
UIEvent,
|
|
6
|
+
MouseEvent,
|
|
7
|
+
PointerEvent,
|
|
8
|
+
KeyboardEvent,
|
|
9
|
+
WheelEvent,
|
|
10
|
+
FocusEvent
|
|
16
11
|
};
|
|
17
12
|
for (const [name, value] of Object.entries(toRegister)) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
if (typeof globalThis[name] === "undefined") {
|
|
14
|
+
Object.defineProperty(globalThis, name, {
|
|
15
|
+
value,
|
|
16
|
+
writable: true,
|
|
17
|
+
configurable: true
|
|
18
|
+
});
|
|
19
|
+
}
|
|
21
20
|
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/dom-events",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.14",
|
|
4
4
|
"description": "Web events module for Gjs",
|
|
5
5
|
"module": "lib/esm/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"event"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@gjsify/dom-exception": "^0.3.
|
|
51
|
+
"@gjsify/dom-exception": "^0.3.14"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@gjsify/cli": "^0.3.
|
|
55
|
-
"@gjsify/unit": "^0.3.
|
|
54
|
+
"@gjsify/cli": "^0.3.14",
|
|
55
|
+
"@gjsify/unit": "^0.3.14",
|
|
56
56
|
"@types/node": "^25.6.0",
|
|
57
57
|
"typescript": "^6.0.3"
|
|
58
58
|
}
|
|
File without changes
|