@native-dom/runtime 0.0.3 → 0.0.5

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.
Files changed (50) hide show
  1. package/README.md +1 -1
  2. package/dist/attributes.d.ts +21 -18
  3. package/dist/attributes.d.ts.map +1 -1
  4. package/dist/attributes.js +115 -137
  5. package/dist/attributes.js.map +1 -1
  6. package/dist/css.d.ts +137 -133
  7. package/dist/css.d.ts.map +1 -1
  8. package/dist/css.js +495 -555
  9. package/dist/css.js.map +1 -1
  10. package/dist/custom-elements.d.ts +22 -18
  11. package/dist/custom-elements.d.ts.map +1 -1
  12. package/dist/custom-elements.js +58 -58
  13. package/dist/custom-elements.js.map +1 -1
  14. package/dist/errors.d.ts +5 -2
  15. package/dist/errors.d.ts.map +1 -1
  16. package/dist/errors.js +10 -6
  17. package/dist/errors.js.map +1 -1
  18. package/dist/event-init.d.ts +81 -77
  19. package/dist/event-init.d.ts.map +1 -1
  20. package/dist/events.d.ts +164 -161
  21. package/dist/events.d.ts.map +1 -1
  22. package/dist/events.js +417 -462
  23. package/dist/events.js.map +1 -1
  24. package/dist/geometry.d.ts +44 -41
  25. package/dist/geometry.d.ts.map +1 -1
  26. package/dist/geometry.js +68 -72
  27. package/dist/geometry.js.map +1 -1
  28. package/dist/history.d.ts +17 -13
  29. package/dist/history.d.ts.map +1 -1
  30. package/dist/history.js +67 -62
  31. package/dist/history.js.map +1 -1
  32. package/dist/index.d.ts +795 -798
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +3020 -3597
  35. package/dist/index.js.map +1 -1
  36. package/dist/observers.d.ts +46 -42
  37. package/dist/observers.d.ts.map +1 -1
  38. package/dist/observers.js +59 -57
  39. package/dist/observers.js.map +1 -1
  40. package/dist/platform.d.ts +71 -67
  41. package/dist/platform.d.ts.map +1 -1
  42. package/dist/platform.js +204 -212
  43. package/dist/platform.js.map +1 -1
  44. package/dist/stats.d.ts +18 -31
  45. package/dist/stats.d.ts.map +1 -1
  46. package/dist/stats.js +75 -87
  47. package/dist/stats.js.map +1 -1
  48. package/package.json +6 -7
  49. package/dist/event-init.js +0 -2
  50. package/dist/event-init.js.map +0 -1
package/dist/events.js CHANGED
@@ -1,470 +1,425 @@
1
- export class Event {
2
- static NONE = 0;
3
- static CAPTURING_PHASE = 1;
4
- static AT_TARGET = 2;
5
- static BUBBLING_PHASE = 3;
6
- NONE = Event.NONE;
7
- CAPTURING_PHASE = Event.CAPTURING_PHASE;
8
- AT_TARGET = Event.AT_TARGET;
9
- BUBBLING_PHASE = Event.BUBBLING_PHASE;
10
- type;
11
- bubbles;
12
- cancelable;
13
- composed;
14
- timeStamp = Date.now();
15
- target = null;
16
- currentTarget = null;
17
- eventPhase = 0;
18
- defaultPrevented = false;
19
- #stopped = false;
20
- #immediateStopped = false;
21
- #passiveListener = false;
22
- #path = [];
23
- constructor(type, init = {}) {
24
- this.type = type;
25
- this.bubbles = init.bubbles ?? false;
26
- this.cancelable = init.cancelable ?? false;
27
- this.composed = init.composed ?? false;
28
- }
29
- initEvent(type, bubbles = false, cancelable = false) {
30
- defineReadonlyValue(this, "type", String(type));
31
- defineReadonlyValue(this, "bubbles", Boolean(bubbles));
32
- defineReadonlyValue(this, "cancelable", Boolean(cancelable));
33
- this.defaultPrevented = false;
34
- }
35
- stopPropagation() {
36
- this.#stopped = true;
37
- }
38
- stopImmediatePropagation() {
39
- this.#stopped = true;
40
- this.#immediateStopped = true;
41
- }
42
- preventDefault() {
43
- if (this.cancelable && !this.#passiveListener) {
44
- this.defaultPrevented = true;
45
- }
46
- }
47
- composedPath() {
48
- return [...this.#path];
49
- }
50
- get _propagationStopped() {
51
- return this.#stopped;
52
- }
53
- get _immediatePropagationStopped() {
54
- return this.#immediateStopped;
55
- }
56
- _startDispatch(target, path) {
57
- try {
58
- this.target = target;
59
- }
60
- catch {
61
- Object.defineProperty(this, "target", {
62
- configurable: true,
63
- enumerable: true,
64
- writable: true,
65
- value: target
66
- });
67
- }
68
- this.#path = path;
69
- this.#stopped = false;
70
- this.#immediateStopped = false;
71
- }
72
- _setCurrentTarget(target) {
73
- try {
74
- this.currentTarget = target;
75
- }
76
- catch {
77
- Object.defineProperty(this, "currentTarget", {
78
- configurable: true,
79
- enumerable: true,
80
- writable: true,
81
- value: target
82
- });
83
- }
84
- }
85
- _setPassiveListener(passive) {
86
- this.#passiveListener = passive;
87
- }
88
- _finishDispatch() {
89
- this._setCurrentTarget(null);
90
- this.eventPhase = Event.NONE;
91
- this.#passiveListener = false;
92
- }
93
- }
94
- export class CustomEvent extends Event {
95
- detail;
96
- constructor(type, init = {}) {
97
- super(type, init);
98
- this.detail = init.detail ?? null;
99
- }
100
- initCustomEvent(type, bubbles = false, cancelable = false, detail = null) {
101
- this.initEvent(type, bubbles, cancelable);
102
- defineReadonlyValue(this, "detail", detail);
103
- }
104
- }
1
+ //#region src/events.ts
2
+ var Event = class Event {
3
+ static NONE = 0;
4
+ static CAPTURING_PHASE = 1;
5
+ static AT_TARGET = 2;
6
+ static BUBBLING_PHASE = 3;
7
+ NONE = Event.NONE;
8
+ CAPTURING_PHASE = Event.CAPTURING_PHASE;
9
+ AT_TARGET = Event.AT_TARGET;
10
+ BUBBLING_PHASE = Event.BUBBLING_PHASE;
11
+ type;
12
+ bubbles;
13
+ cancelable;
14
+ composed;
15
+ timeStamp = Date.now();
16
+ target = null;
17
+ currentTarget = null;
18
+ eventPhase = 0;
19
+ defaultPrevented = false;
20
+ #stopped = false;
21
+ #immediateStopped = false;
22
+ #passiveListener = false;
23
+ #path = [];
24
+ constructor(type, init = {}) {
25
+ this.type = type;
26
+ this.bubbles = init.bubbles ?? false;
27
+ this.cancelable = init.cancelable ?? false;
28
+ this.composed = init.composed ?? false;
29
+ }
30
+ initEvent(type, bubbles = false, cancelable = false) {
31
+ defineReadonlyValue(this, "type", String(type));
32
+ defineReadonlyValue(this, "bubbles", Boolean(bubbles));
33
+ defineReadonlyValue(this, "cancelable", Boolean(cancelable));
34
+ this.defaultPrevented = false;
35
+ }
36
+ stopPropagation() {
37
+ this.#stopped = true;
38
+ }
39
+ stopImmediatePropagation() {
40
+ this.#stopped = true;
41
+ this.#immediateStopped = true;
42
+ }
43
+ preventDefault() {
44
+ if (this.cancelable && !this.#passiveListener) this.defaultPrevented = true;
45
+ }
46
+ composedPath() {
47
+ return [...this.#path];
48
+ }
49
+ get _propagationStopped() {
50
+ return this.#stopped;
51
+ }
52
+ get _immediatePropagationStopped() {
53
+ return this.#immediateStopped;
54
+ }
55
+ _startDispatch(target, path) {
56
+ try {
57
+ this.target = target;
58
+ } catch {
59
+ Object.defineProperty(this, "target", {
60
+ configurable: true,
61
+ enumerable: true,
62
+ writable: true,
63
+ value: target
64
+ });
65
+ }
66
+ this.#path = path;
67
+ this.#stopped = false;
68
+ this.#immediateStopped = false;
69
+ }
70
+ _setCurrentTarget(target) {
71
+ try {
72
+ this.currentTarget = target;
73
+ } catch {
74
+ Object.defineProperty(this, "currentTarget", {
75
+ configurable: true,
76
+ enumerable: true,
77
+ writable: true,
78
+ value: target
79
+ });
80
+ }
81
+ }
82
+ _setPassiveListener(passive) {
83
+ this.#passiveListener = passive;
84
+ }
85
+ _finishDispatch() {
86
+ this._setCurrentTarget(null);
87
+ this.eventPhase = Event.NONE;
88
+ this.#passiveListener = false;
89
+ }
90
+ };
91
+ var CustomEvent = class extends Event {
92
+ detail;
93
+ constructor(type, init = {}) {
94
+ super(type, init);
95
+ this.detail = init.detail ?? null;
96
+ }
97
+ initCustomEvent(type, bubbles = false, cancelable = false, detail = null) {
98
+ this.initEvent(type, bubbles, cancelable);
99
+ defineReadonlyValue(this, "detail", detail);
100
+ }
101
+ };
105
102
  function defineReadonlyValue(target, property, value) {
106
- Object.defineProperty(target, property, {
107
- configurable: true,
108
- enumerable: true,
109
- value
110
- });
111
- }
112
- export class PopStateEvent extends Event {
113
- state;
114
- constructor(type, init = {}) {
115
- super(type, init);
116
- this.state = init.state ?? null;
117
- }
118
- }
119
- export class UIEvent extends Event {
120
- detail;
121
- view;
122
- constructor(type, init = {}) {
123
- super(type, init);
124
- this.detail = init.detail ?? 0;
125
- this.view = init.view ?? null;
126
- }
127
- }
128
- export class MouseEvent extends UIEvent {
129
- altKey;
130
- button;
131
- buttons;
132
- clientX;
133
- clientY;
134
- ctrlKey;
135
- metaKey;
136
- screenX;
137
- screenY;
138
- shiftKey;
139
- constructor(type, init = {}) {
140
- super(type, init);
141
- this.altKey = init.altKey ?? false;
142
- this.button = init.button ?? 0;
143
- this.buttons = init.buttons ?? 0;
144
- this.clientX = init.clientX ?? 0;
145
- this.clientY = init.clientY ?? 0;
146
- this.ctrlKey = init.ctrlKey ?? false;
147
- this.metaKey = init.metaKey ?? false;
148
- this.screenX = init.screenX ?? 0;
149
- this.screenY = init.screenY ?? 0;
150
- this.shiftKey = init.shiftKey ?? false;
151
- }
152
- }
153
- export class PointerEvent extends MouseEvent {
154
- height;
155
- isPrimary;
156
- pointerId;
157
- pointerType;
158
- pressure;
159
- tangentialPressure;
160
- tiltX;
161
- tiltY;
162
- twist;
163
- width;
164
- constructor(type, init = {}) {
165
- super(type, init);
166
- this.height = init.height ?? 1;
167
- this.isPrimary = init.isPrimary ?? false;
168
- this.pointerId = init.pointerId ?? 0;
169
- this.pointerType = init.pointerType ?? "";
170
- this.pressure = init.pressure ?? 0;
171
- this.tangentialPressure = init.tangentialPressure ?? 0;
172
- this.tiltX = init.tiltX ?? 0;
173
- this.tiltY = init.tiltY ?? 0;
174
- this.twist = init.twist ?? 0;
175
- this.width = init.width ?? 1;
176
- }
177
- }
178
- export class KeyboardEvent extends UIEvent {
179
- altKey;
180
- code;
181
- ctrlKey;
182
- isComposing;
183
- key;
184
- keyCode;
185
- location;
186
- metaKey;
187
- repeat;
188
- shiftKey;
189
- which;
190
- constructor(type, init = {}) {
191
- super(type, init);
192
- this.altKey = init.altKey ?? false;
193
- this.code = init.code ?? "";
194
- this.ctrlKey = init.ctrlKey ?? false;
195
- this.isComposing = init.isComposing ?? false;
196
- this.key = init.key ?? "";
197
- this.keyCode = init.keyCode ?? 0;
198
- this.location = init.location ?? 0;
199
- this.metaKey = init.metaKey ?? false;
200
- this.repeat = init.repeat ?? false;
201
- this.shiftKey = init.shiftKey ?? false;
202
- this.which = init.which ?? this.keyCode;
203
- }
204
- getModifierState(keyArg) {
205
- switch (keyArg) {
206
- case "Alt":
207
- return this.altKey;
208
- case "Control":
209
- return this.ctrlKey;
210
- case "Meta":
211
- return this.metaKey;
212
- case "Shift":
213
- return this.shiftKey;
214
- default:
215
- return false;
216
- }
217
- }
218
- }
219
- export class InputEvent extends UIEvent {
220
- data;
221
- dataTransfer;
222
- inputType;
223
- isComposing;
224
- constructor(type, init = {}) {
225
- super(type, init);
226
- this.data = init.data ?? null;
227
- this.dataTransfer = init.dataTransfer ?? null;
228
- this.inputType = init.inputType ?? "";
229
- this.isComposing = init.isComposing ?? false;
230
- }
231
- }
232
- export class FocusEvent extends UIEvent {
233
- relatedTarget;
234
- constructor(type, init = {}) {
235
- super(type, init);
236
- this.relatedTarget = init.relatedTarget ?? null;
237
- }
238
- }
239
- export class SubmitEvent extends Event {
240
- submitter;
241
- constructor(type, init = {}) {
242
- super(type, init);
243
- this.submitter = init.submitter ?? null;
244
- }
245
- }
246
- export class ClipboardEvent extends Event {
247
- clipboardData;
248
- constructor(type, init = {}) {
249
- super(type, init);
250
- this.clipboardData = init.clipboardData ?? null;
251
- }
252
- }
253
- export class Touch {
254
- clientX;
255
- clientY;
256
- force;
257
- identifier;
258
- pageX;
259
- pageY;
260
- radiusX;
261
- radiusY;
262
- rotationAngle;
263
- screenX;
264
- screenY;
265
- target;
266
- constructor(init) {
267
- this.clientX = init.clientX ?? 0;
268
- this.clientY = init.clientY ?? 0;
269
- this.force = init.force ?? 0;
270
- this.identifier = init.identifier;
271
- this.pageX = init.pageX ?? 0;
272
- this.pageY = init.pageY ?? 0;
273
- this.radiusX = init.radiusX ?? 0;
274
- this.radiusY = init.radiusY ?? 0;
275
- this.rotationAngle = init.rotationAngle ?? 0;
276
- this.screenX = init.screenX ?? 0;
277
- this.screenY = init.screenY ?? 0;
278
- this.target = init.target;
279
- }
280
- }
281
- export class TouchEvent extends UIEvent {
282
- altKey;
283
- changedTouches;
284
- ctrlKey;
285
- metaKey;
286
- shiftKey;
287
- targetTouches;
288
- touches;
289
- constructor(type, init = {}) {
290
- super(type, init);
291
- this.altKey = init.altKey ?? false;
292
- this.changedTouches = init.changedTouches ?? [];
293
- this.ctrlKey = init.ctrlKey ?? false;
294
- this.metaKey = init.metaKey ?? false;
295
- this.shiftKey = init.shiftKey ?? false;
296
- this.targetTouches = init.targetTouches ?? [];
297
- this.touches = init.touches ?? [];
298
- }
103
+ Object.defineProperty(target, property, {
104
+ configurable: true,
105
+ enumerable: true,
106
+ value
107
+ });
299
108
  }
109
+ var PopStateEvent = class extends Event {
110
+ state;
111
+ constructor(type, init = {}) {
112
+ super(type, init);
113
+ this.state = init.state ?? null;
114
+ }
115
+ };
116
+ var UIEvent = class extends Event {
117
+ detail;
118
+ view;
119
+ constructor(type, init = {}) {
120
+ super(type, init);
121
+ this.detail = init.detail ?? 0;
122
+ this.view = init.view ?? null;
123
+ }
124
+ };
125
+ var MouseEvent = class extends UIEvent {
126
+ altKey;
127
+ button;
128
+ buttons;
129
+ clientX;
130
+ clientY;
131
+ ctrlKey;
132
+ metaKey;
133
+ screenX;
134
+ screenY;
135
+ shiftKey;
136
+ constructor(type, init = {}) {
137
+ super(type, init);
138
+ this.altKey = init.altKey ?? false;
139
+ this.button = init.button ?? 0;
140
+ this.buttons = init.buttons ?? 0;
141
+ this.clientX = init.clientX ?? 0;
142
+ this.clientY = init.clientY ?? 0;
143
+ this.ctrlKey = init.ctrlKey ?? false;
144
+ this.metaKey = init.metaKey ?? false;
145
+ this.screenX = init.screenX ?? 0;
146
+ this.screenY = init.screenY ?? 0;
147
+ this.shiftKey = init.shiftKey ?? false;
148
+ }
149
+ };
150
+ var PointerEvent = class extends MouseEvent {
151
+ height;
152
+ isPrimary;
153
+ pointerId;
154
+ pointerType;
155
+ pressure;
156
+ tangentialPressure;
157
+ tiltX;
158
+ tiltY;
159
+ twist;
160
+ width;
161
+ constructor(type, init = {}) {
162
+ super(type, init);
163
+ this.height = init.height ?? 1;
164
+ this.isPrimary = init.isPrimary ?? false;
165
+ this.pointerId = init.pointerId ?? 0;
166
+ this.pointerType = init.pointerType ?? "";
167
+ this.pressure = init.pressure ?? 0;
168
+ this.tangentialPressure = init.tangentialPressure ?? 0;
169
+ this.tiltX = init.tiltX ?? 0;
170
+ this.tiltY = init.tiltY ?? 0;
171
+ this.twist = init.twist ?? 0;
172
+ this.width = init.width ?? 1;
173
+ }
174
+ };
175
+ var KeyboardEvent = class extends UIEvent {
176
+ altKey;
177
+ code;
178
+ ctrlKey;
179
+ isComposing;
180
+ key;
181
+ keyCode;
182
+ location;
183
+ metaKey;
184
+ repeat;
185
+ shiftKey;
186
+ which;
187
+ constructor(type, init = {}) {
188
+ super(type, init);
189
+ this.altKey = init.altKey ?? false;
190
+ this.code = init.code ?? "";
191
+ this.ctrlKey = init.ctrlKey ?? false;
192
+ this.isComposing = init.isComposing ?? false;
193
+ this.key = init.key ?? "";
194
+ this.keyCode = init.keyCode ?? 0;
195
+ this.location = init.location ?? 0;
196
+ this.metaKey = init.metaKey ?? false;
197
+ this.repeat = init.repeat ?? false;
198
+ this.shiftKey = init.shiftKey ?? false;
199
+ this.which = init.which ?? this.keyCode;
200
+ }
201
+ getModifierState(keyArg) {
202
+ switch (keyArg) {
203
+ case "Alt": return this.altKey;
204
+ case "Control": return this.ctrlKey;
205
+ case "Meta": return this.metaKey;
206
+ case "Shift": return this.shiftKey;
207
+ default: return false;
208
+ }
209
+ }
210
+ };
211
+ var InputEvent = class extends UIEvent {
212
+ data;
213
+ dataTransfer;
214
+ inputType;
215
+ isComposing;
216
+ constructor(type, init = {}) {
217
+ super(type, init);
218
+ this.data = init.data ?? null;
219
+ this.dataTransfer = init.dataTransfer ?? null;
220
+ this.inputType = init.inputType ?? "";
221
+ this.isComposing = init.isComposing ?? false;
222
+ }
223
+ };
224
+ var FocusEvent = class extends UIEvent {
225
+ relatedTarget;
226
+ constructor(type, init = {}) {
227
+ super(type, init);
228
+ this.relatedTarget = init.relatedTarget ?? null;
229
+ }
230
+ };
231
+ var SubmitEvent = class extends Event {
232
+ submitter;
233
+ constructor(type, init = {}) {
234
+ super(type, init);
235
+ this.submitter = init.submitter ?? null;
236
+ }
237
+ };
238
+ var ClipboardEvent = class extends Event {
239
+ clipboardData;
240
+ constructor(type, init = {}) {
241
+ super(type, init);
242
+ this.clipboardData = init.clipboardData ?? null;
243
+ }
244
+ };
245
+ var Touch = class {
246
+ clientX;
247
+ clientY;
248
+ force;
249
+ identifier;
250
+ pageX;
251
+ pageY;
252
+ radiusX;
253
+ radiusY;
254
+ rotationAngle;
255
+ screenX;
256
+ screenY;
257
+ target;
258
+ constructor(init) {
259
+ this.clientX = init.clientX ?? 0;
260
+ this.clientY = init.clientY ?? 0;
261
+ this.force = init.force ?? 0;
262
+ this.identifier = init.identifier;
263
+ this.pageX = init.pageX ?? 0;
264
+ this.pageY = init.pageY ?? 0;
265
+ this.radiusX = init.radiusX ?? 0;
266
+ this.radiusY = init.radiusY ?? 0;
267
+ this.rotationAngle = init.rotationAngle ?? 0;
268
+ this.screenX = init.screenX ?? 0;
269
+ this.screenY = init.screenY ?? 0;
270
+ this.target = init.target;
271
+ }
272
+ };
273
+ var TouchEvent = class extends UIEvent {
274
+ altKey;
275
+ changedTouches;
276
+ ctrlKey;
277
+ metaKey;
278
+ shiftKey;
279
+ targetTouches;
280
+ touches;
281
+ constructor(type, init = {}) {
282
+ super(type, init);
283
+ this.altKey = init.altKey ?? false;
284
+ this.changedTouches = init.changedTouches ?? [];
285
+ this.ctrlKey = init.ctrlKey ?? false;
286
+ this.metaKey = init.metaKey ?? false;
287
+ this.shiftKey = init.shiftKey ?? false;
288
+ this.targetTouches = init.targetTouches ?? [];
289
+ this.touches = init.touches ?? [];
290
+ }
291
+ };
300
292
  const eventListenersKey = Symbol("NativeDOM.eventListeners");
301
- export class EventTarget {
302
- get [Symbol.toStringTag]() {
303
- return this.constructor.name;
304
- }
305
- addEventListener(type, listener, options = false) {
306
- if (!listener) {
307
- return;
308
- }
309
- const normalized = normalizeListenerOptions(options);
310
- const listenerMap = eventListenersFor(this);
311
- let listeners = listenerMap.get(type);
312
- if (!listeners) {
313
- listeners = [];
314
- listenerMap.set(type, listeners);
315
- }
316
- if (listeners.some((record) => record.callback === listener && record.capture === normalized.capture)) {
317
- return;
318
- }
319
- listeners.push({
320
- callback: listener,
321
- capture: normalized.capture,
322
- once: normalized.once,
323
- passive: normalized.passive
324
- });
325
- }
326
- removeEventListener(type, listener, options = false) {
327
- if (!listener) {
328
- return;
329
- }
330
- const capture = normalizeListenerOptions(options).capture;
331
- const listeners = eventListenersFor(this, false)?.get(type);
332
- if (!listeners) {
333
- return;
334
- }
335
- const index = listeners.findIndex((record) => record.callback === listener && record.capture === capture);
336
- if (index !== -1) {
337
- listeners.splice(index, 1);
338
- }
339
- }
340
- dispatchEvent(event) {
341
- if (!(event instanceof Event)) {
342
- throw new TypeError("dispatchEvent() argument must be an Event");
343
- }
344
- const pathProvider = this;
345
- const path = typeof pathProvider._eventPath === "function" ? pathProvider._eventPath() : [this];
346
- event._startDispatch(this, path);
347
- if (path.length > 1) {
348
- for (let index = path.length - 1; index >= 1; index--) {
349
- event._setCurrentTarget(path[index]);
350
- event.eventPhase = Event.CAPTURING_PHASE;
351
- path[index]._invoke(event, true);
352
- if (event._propagationStopped) {
353
- break;
354
- }
355
- }
356
- }
357
- if (!event._propagationStopped || event.currentTarget === this) {
358
- event._setCurrentTarget(this);
359
- event.eventPhase = Event.CAPTURING_PHASE;
360
- this._invoke(event, true);
361
- }
362
- if (!event._immediatePropagationStopped) {
363
- event._setCurrentTarget(this);
364
- event.eventPhase = Event.AT_TARGET;
365
- this._invoke(event, false);
366
- }
367
- if (event.bubbles && !event._propagationStopped) {
368
- for (let index = 1; index < path.length; index++) {
369
- const current = path[index];
370
- event._setCurrentTarget(current);
371
- event.eventPhase = Event.BUBBLING_PHASE;
372
- current._invoke(event, false);
373
- if (event._propagationStopped) {
374
- break;
375
- }
376
- }
377
- }
378
- event._finishDispatch();
379
- return !event.defaultPrevented;
380
- }
381
- _invoke(event, capture) {
382
- const listeners = eventListenersFor(this, false)?.get(event.type);
383
- if (listeners) {
384
- for (const record of listeners.slice()) {
385
- if (record.capture !== capture) {
386
- continue;
387
- }
388
- if (record.once) {
389
- this.removeEventListener(event.type, record.callback, { capture: record.capture });
390
- }
391
- event._setPassiveListener(record.passive);
392
- if (typeof record.callback === "function") {
393
- record.callback.call(this, event);
394
- }
395
- else {
396
- record.callback.handleEvent(event);
397
- }
398
- event._setPassiveListener(false);
399
- if (event._propagationStopped) {
400
- if (event._immediatePropagationStopped) {
401
- break;
402
- }
403
- }
404
- }
405
- }
406
- if (!capture && !event._immediatePropagationStopped) {
407
- const handler = this[`on${event.type}`];
408
- if (typeof handler === "function") {
409
- handler.call(this, event);
410
- }
411
- }
412
- }
413
- }
293
+ var EventTarget = class {
294
+ get [Symbol.toStringTag]() {
295
+ return this.constructor.name;
296
+ }
297
+ addEventListener(type, listener, options = false) {
298
+ if (!listener) return;
299
+ const normalized = normalizeListenerOptions(options);
300
+ const listenerMap = eventListenersFor(this);
301
+ let listeners = listenerMap.get(type);
302
+ if (!listeners) {
303
+ listeners = [];
304
+ listenerMap.set(type, listeners);
305
+ }
306
+ if (listeners.some((record) => record.callback === listener && record.capture === normalized.capture)) return;
307
+ listeners.push({
308
+ callback: listener,
309
+ capture: normalized.capture,
310
+ once: normalized.once,
311
+ passive: normalized.passive
312
+ });
313
+ }
314
+ removeEventListener(type, listener, options = false) {
315
+ if (!listener) return;
316
+ const capture = normalizeListenerOptions(options).capture;
317
+ const listeners = eventListenersFor(this, false)?.get(type);
318
+ if (!listeners) return;
319
+ const index = listeners.findIndex((record) => record.callback === listener && record.capture === capture);
320
+ if (index !== -1) listeners.splice(index, 1);
321
+ }
322
+ dispatchEvent(event) {
323
+ if (!(event instanceof Event)) throw new TypeError("dispatchEvent() argument must be an Event");
324
+ const pathProvider = this;
325
+ const path = typeof pathProvider._eventPath === "function" ? pathProvider._eventPath() : [this];
326
+ event._startDispatch(this, path);
327
+ if (path.length > 1) for (let index = path.length - 1; index >= 1; index--) {
328
+ event._setCurrentTarget(path[index]);
329
+ event.eventPhase = Event.CAPTURING_PHASE;
330
+ path[index]._invoke(event, true);
331
+ if (event._propagationStopped) break;
332
+ }
333
+ if (!event._propagationStopped || event.currentTarget === this) {
334
+ event._setCurrentTarget(this);
335
+ event.eventPhase = Event.CAPTURING_PHASE;
336
+ this._invoke(event, true);
337
+ }
338
+ if (!event._immediatePropagationStopped) {
339
+ event._setCurrentTarget(this);
340
+ event.eventPhase = Event.AT_TARGET;
341
+ this._invoke(event, false);
342
+ }
343
+ if (event.bubbles && !event._propagationStopped) for (let index = 1; index < path.length; index++) {
344
+ const current = path[index];
345
+ event._setCurrentTarget(current);
346
+ event.eventPhase = Event.BUBBLING_PHASE;
347
+ current._invoke(event, false);
348
+ if (event._propagationStopped) break;
349
+ }
350
+ event._finishDispatch();
351
+ return !event.defaultPrevented;
352
+ }
353
+ _invoke(event, capture) {
354
+ const listeners = eventListenersFor(this, false)?.get(event.type);
355
+ if (listeners) for (const record of listeners.slice()) {
356
+ if (record.capture !== capture) continue;
357
+ if (record.once) this.removeEventListener(event.type, record.callback, { capture: record.capture });
358
+ event._setPassiveListener(record.passive);
359
+ if (typeof record.callback === "function") record.callback.call(this, event);
360
+ else record.callback.handleEvent(event);
361
+ event._setPassiveListener(false);
362
+ if (event._propagationStopped) {
363
+ if (event._immediatePropagationStopped) break;
364
+ }
365
+ }
366
+ if (!capture && !event._immediatePropagationStopped) {
367
+ const handler = this[`on${event.type}`];
368
+ if (typeof handler === "function") handler.call(this, event);
369
+ }
370
+ }
371
+ };
414
372
  function eventListenersFor(target, create = true) {
415
- const withListeners = target;
416
- if (!withListeners[eventListenersKey] && create) {
417
- Object.defineProperty(withListeners, eventListenersKey, {
418
- configurable: true,
419
- value: new Map()
420
- });
421
- }
422
- return withListeners[eventListenersKey];
373
+ const withListeners = target;
374
+ if (!withListeners[eventListenersKey] && create) Object.defineProperty(withListeners, eventListenersKey, {
375
+ configurable: true,
376
+ value: /* @__PURE__ */ new Map()
377
+ });
378
+ return withListeners[eventListenersKey];
423
379
  }
424
380
  function normalizeListenerOptions(options) {
425
- if (typeof options === "boolean") {
426
- return {
427
- capture: options,
428
- once: false,
429
- passive: false
430
- };
431
- }
432
- return {
433
- capture: options.capture ?? false,
434
- once: options.once ?? false,
435
- passive: options.passive ?? false
436
- };
437
- }
438
- export class MediaQueryListEvent extends Event {
439
- matches;
440
- media;
441
- constructor(type, init = {}) {
442
- super(type);
443
- this.matches = init.matches ?? false;
444
- this.media = init.media ?? "";
445
- }
446
- }
447
- export class MediaQueryList extends EventTarget {
448
- onchange = null;
449
- media;
450
- matches;
451
- constructor(media, matches = false) {
452
- super();
453
- this.media = media;
454
- this.matches = matches;
455
- }
456
- addListener(listener) {
457
- this.addEventListener("change", listener);
458
- }
459
- removeListener(listener) {
460
- this.removeEventListener("change", listener);
461
- }
462
- dispatchEvent(event) {
463
- const result = super.dispatchEvent(event);
464
- if (event.type === "change" && this.onchange) {
465
- this.onchange.call(this, event);
466
- }
467
- return result;
468
- }
381
+ if (typeof options === "boolean") return {
382
+ capture: options,
383
+ once: false,
384
+ passive: false
385
+ };
386
+ return {
387
+ capture: options.capture ?? false,
388
+ once: options.once ?? false,
389
+ passive: options.passive ?? false
390
+ };
469
391
  }
392
+ var MediaQueryListEvent = class extends Event {
393
+ matches;
394
+ media;
395
+ constructor(type, init = {}) {
396
+ super(type);
397
+ this.matches = init.matches ?? false;
398
+ this.media = init.media ?? "";
399
+ }
400
+ };
401
+ var MediaQueryList = class extends EventTarget {
402
+ onchange = null;
403
+ media;
404
+ matches;
405
+ constructor(media, matches = false) {
406
+ super();
407
+ this.media = media;
408
+ this.matches = matches;
409
+ }
410
+ addListener(listener) {
411
+ this.addEventListener("change", listener);
412
+ }
413
+ removeListener(listener) {
414
+ this.removeEventListener("change", listener);
415
+ }
416
+ dispatchEvent(event) {
417
+ const result = super.dispatchEvent(event);
418
+ if (event.type === "change" && this.onchange) this.onchange.call(this, event);
419
+ return result;
420
+ }
421
+ };
422
+ //#endregion
423
+ export { ClipboardEvent, CustomEvent, Event, EventTarget, FocusEvent, InputEvent, KeyboardEvent, MediaQueryList, MediaQueryListEvent, MouseEvent, PointerEvent, PopStateEvent, SubmitEvent, Touch, TouchEvent, UIEvent };
424
+
470
425
  //# sourceMappingURL=events.js.map