@neta-art/cohub-cli 8.4.0 → 8.4.1

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.
@@ -0,0 +1,2760 @@
1
+ import { F as removeItems, R as warn, T as Container, at as extensions, it as ExtensionType, nt as eventemitter3_default, ot as __commonJSMin, st as __toESM, tt as Point, v as Ticker, y as UPDATE_PRIORITY } from "./getPo2TextureFromSource.js";
2
+ import "./init.js";
3
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/dom/CanvasObserver.mjs
4
+ var CanvasObserver = class {
5
+ constructor(options) {
6
+ /** A cached value of the last transform applied to the DOM element. */
7
+ this._lastTransform = "";
8
+ /** A ResizeObserver instance to observe changes in the canvas size. */
9
+ this._observer = null;
10
+ /** A flag to indicate whether the observer is attached to the Ticker for continuous updates. */
11
+ this._tickerAttached = false;
12
+ /**
13
+ * Updates the transform of the DOM element based on the canvas size and position.
14
+ * This method calculates the scale and translation needed to keep the DOM element in sync with the canvas.
15
+ */
16
+ this.updateTranslation = () => {
17
+ if (!this._canvas) return;
18
+ const rect = this._canvas.getBoundingClientRect();
19
+ const contentWidth = this._canvas.width;
20
+ const contentHeight = this._canvas.height;
21
+ const sx = rect.width / contentWidth * this._renderer.resolution;
22
+ const sy = rect.height / contentHeight * this._renderer.resolution;
23
+ const newTransform = `translate(${rect.left}px, ${rect.top}px) scale(${sx}, ${sy})`;
24
+ if (newTransform !== this._lastTransform) {
25
+ this._domElement.style.transform = newTransform;
26
+ this._lastTransform = newTransform;
27
+ }
28
+ };
29
+ this._domElement = options.domElement;
30
+ this._renderer = options.renderer;
31
+ if (globalThis.OffscreenCanvas && this._renderer.canvas instanceof OffscreenCanvas) return;
32
+ this._canvas = this._renderer.canvas;
33
+ this._attachObserver();
34
+ }
35
+ /** The canvas element that this CanvasObserver is associated with. */
36
+ get canvas() {
37
+ return this._canvas;
38
+ }
39
+ /** Attaches the DOM element to the canvas parent if it is not already attached. */
40
+ ensureAttached() {
41
+ if (!this._domElement.parentNode && this._canvas.parentNode) {
42
+ this._canvas.parentNode.appendChild(this._domElement);
43
+ this.updateTranslation();
44
+ }
45
+ }
46
+ /** Sets up a ResizeObserver if available. This ensures that the DOM element is kept in sync with the canvas size . */
47
+ _attachObserver() {
48
+ if ("ResizeObserver" in globalThis) {
49
+ if (this._observer) {
50
+ this._observer.disconnect();
51
+ this._observer = null;
52
+ }
53
+ this._observer = new ResizeObserver((entries) => {
54
+ for (const entry of entries) {
55
+ if (entry.target !== this._canvas) continue;
56
+ const contentWidth = this.canvas.width;
57
+ const contentHeight = this.canvas.height;
58
+ const sx = entry.contentRect.width / contentWidth * this._renderer.resolution;
59
+ const sy = entry.contentRect.height / contentHeight * this._renderer.resolution;
60
+ if (this._lastScaleX !== sx || this._lastScaleY !== sy) {
61
+ this.updateTranslation();
62
+ this._lastScaleX = sx;
63
+ this._lastScaleY = sy;
64
+ }
65
+ }
66
+ });
67
+ this._observer.observe(this._canvas);
68
+ } else if (!this._tickerAttached) Ticker.shared.add(this.updateTranslation, this, UPDATE_PRIORITY.HIGH);
69
+ }
70
+ /** Destroys the CanvasObserver instance, cleaning up observers and Ticker. */
71
+ destroy() {
72
+ if (this._observer) {
73
+ this._observer.disconnect();
74
+ this._observer = null;
75
+ } else if (this._tickerAttached) Ticker.shared.remove(this.updateTranslation);
76
+ this._domElement = null;
77
+ this._renderer = null;
78
+ this._canvas = null;
79
+ this._tickerAttached = false;
80
+ this._lastTransform = "";
81
+ this._lastScaleX = null;
82
+ this._lastScaleY = null;
83
+ }
84
+ };
85
+ //#endregion
86
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/events/FederatedEvent.mjs
87
+ var FederatedEvent = class FederatedEvent {
88
+ /**
89
+ * @param manager - The event boundary which manages this event. Propagation can only occur
90
+ * within the boundary's jurisdiction.
91
+ */
92
+ constructor(manager) {
93
+ /** Flags whether this event bubbles. This will take effect only if it is set before propagation. */
94
+ this.bubbles = true;
95
+ /** @deprecated since 7.0.0 */
96
+ this.cancelBubble = true;
97
+ /**
98
+ * Flags whether this event can be canceled using {@link FederatedEvent.preventDefault}. This is always
99
+ * false (for now).
100
+ */
101
+ this.cancelable = false;
102
+ /**
103
+ * Flag added for compatibility with DOM `Event`. It is not used in the Federated Events
104
+ * API.
105
+ * @see https://dom.spec.whatwg.org/#dom-event-composed
106
+ * @ignore
107
+ */
108
+ this.composed = false;
109
+ /** Flags whether the default response of the user agent was prevent through this event. */
110
+ this.defaultPrevented = false;
111
+ /**
112
+ * The propagation phase.
113
+ * @default {@link FederatedEvent.NONE}
114
+ */
115
+ this.eventPhase = FederatedEvent.prototype.NONE;
116
+ /** Flags whether propagation was stopped. */
117
+ this.propagationStopped = false;
118
+ /** Flags whether propagation was immediately stopped. */
119
+ this.propagationImmediatelyStopped = false;
120
+ /** The coordinates of the event relative to the nearest DOM layer. This is a non-standard property. */
121
+ this.layer = new Point();
122
+ /** The coordinates of the event relative to the DOM document. This is a non-standard property. */
123
+ this.page = new Point();
124
+ /**
125
+ * The event propagation phase NONE that indicates that the event is not in any phase.
126
+ * @default 0
127
+ * @advanced
128
+ */
129
+ this.NONE = 0;
130
+ /**
131
+ * The event propagation phase CAPTURING_PHASE that indicates that the event is in the capturing phase.
132
+ * @default 1
133
+ * @advanced
134
+ */
135
+ this.CAPTURING_PHASE = 1;
136
+ /**
137
+ * The event propagation phase AT_TARGET that indicates that the event is at the target.
138
+ * @default 2
139
+ * @advanced
140
+ */
141
+ this.AT_TARGET = 2;
142
+ /**
143
+ * The event propagation phase BUBBLING_PHASE that indicates that the event is in the bubbling phase.
144
+ * @default 3
145
+ * @advanced
146
+ */
147
+ this.BUBBLING_PHASE = 3;
148
+ this.manager = manager;
149
+ }
150
+ /** @readonly */
151
+ get layerX() {
152
+ return this.layer.x;
153
+ }
154
+ /** @readonly */
155
+ get layerY() {
156
+ return this.layer.y;
157
+ }
158
+ /** @readonly */
159
+ get pageX() {
160
+ return this.page.x;
161
+ }
162
+ /** @readonly */
163
+ get pageY() {
164
+ return this.page.y;
165
+ }
166
+ /**
167
+ * Fallback for the deprecated `InteractionEvent.data`.
168
+ * @deprecated since 7.0.0
169
+ */
170
+ get data() {
171
+ return this;
172
+ }
173
+ /**
174
+ * The propagation path for this event. Alias for {@link EventBoundary.propagationPath}.
175
+ * @advanced
176
+ */
177
+ composedPath() {
178
+ if (this.manager && (!this.path || this.path[this.path.length - 1] !== this.target)) this.path = this.target ? this.manager.propagationPath(this.target) : [];
179
+ return this.path;
180
+ }
181
+ /**
182
+ * Unimplemented method included for implementing the DOM interface `Event`. It will throw an `Error`.
183
+ * @deprecated
184
+ * @ignore
185
+ * @param _type
186
+ * @param _bubbles
187
+ * @param _cancelable
188
+ */
189
+ initEvent(_type, _bubbles, _cancelable) {
190
+ throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.");
191
+ }
192
+ /**
193
+ * Unimplemented method included for implementing the DOM interface `UIEvent`. It will throw an `Error`.
194
+ * @ignore
195
+ * @deprecated
196
+ * @param _typeArg
197
+ * @param _bubblesArg
198
+ * @param _cancelableArg
199
+ * @param _viewArg
200
+ * @param _detailArg
201
+ */
202
+ initUIEvent(_typeArg, _bubblesArg, _cancelableArg, _viewArg, _detailArg) {
203
+ throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.");
204
+ }
205
+ /**
206
+ * Prevent default behavior of both PixiJS and the user agent.
207
+ * @example
208
+ * ```ts
209
+ * sprite.on('click', (event) => {
210
+ * // Prevent both browser's default click behavior
211
+ * // and PixiJS's default handling
212
+ * event.preventDefault();
213
+ *
214
+ * // Custom handling
215
+ * customClickHandler();
216
+ * });
217
+ * ```
218
+ * @remarks
219
+ * - Only works if the native event is cancelable
220
+ * - Does not stop event propagation
221
+ */
222
+ preventDefault() {
223
+ if (this.nativeEvent instanceof Event && this.nativeEvent.cancelable) this.nativeEvent.preventDefault();
224
+ this.defaultPrevented = true;
225
+ }
226
+ /**
227
+ * Stop this event from propagating to any additional listeners, including those
228
+ * on the current target and any following targets in the propagation path.
229
+ * @example
230
+ * ```ts
231
+ * container.on('pointerdown', (event) => {
232
+ * // Stop all further event handling
233
+ * event.stopImmediatePropagation();
234
+ *
235
+ * // These handlers won't be called:
236
+ * // - Other pointerdown listeners on this container
237
+ * // - Any pointerdown listeners on parent containers
238
+ * });
239
+ * ```
240
+ * @remarks
241
+ * - Immediately stops all event propagation
242
+ * - Prevents other listeners on same target from being called
243
+ * - More aggressive than stopPropagation()
244
+ */
245
+ stopImmediatePropagation() {
246
+ this.propagationImmediatelyStopped = true;
247
+ }
248
+ /**
249
+ * Stop this event from propagating to the next target in the propagation path.
250
+ * The rest of the listeners on the current target will still be notified.
251
+ * @example
252
+ * ```ts
253
+ * child.on('pointermove', (event) => {
254
+ * // Handle event on child
255
+ * updateChild();
256
+ *
257
+ * // Prevent parent handlers from being called
258
+ * event.stopPropagation();
259
+ * });
260
+ *
261
+ * // This won't be called if child handles the event
262
+ * parent.on('pointermove', (event) => {
263
+ * updateParent();
264
+ * });
265
+ * ```
266
+ * @remarks
267
+ * - Stops event bubbling to parent containers
268
+ * - Does not prevent other listeners on same target
269
+ * - Less aggressive than stopImmediatePropagation()
270
+ */
271
+ stopPropagation() {
272
+ this.propagationStopped = true;
273
+ }
274
+ };
275
+ //#endregion
276
+ //#region ../../node_modules/.pnpm/ismobilejs@1.1.1/node_modules/ismobilejs/cjs/isMobile.js
277
+ var require_isMobile = /* @__PURE__ */ __commonJSMin(((exports) => {
278
+ exports.__esModule = true;
279
+ var appleIphone = /iPhone/i;
280
+ var appleIpod = /iPod/i;
281
+ var appleTablet = /iPad/i;
282
+ var appleUniversal = /\biOS-universal(?:.+)Mac\b/i;
283
+ var androidPhone = /\bAndroid(?:.+)Mobile\b/i;
284
+ var androidTablet = /Android/i;
285
+ var amazonPhone = /(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i;
286
+ var amazonTablet = /Silk/i;
287
+ var windowsPhone = /Windows Phone/i;
288
+ var windowsTablet = /\bWindows(?:.+)ARM\b/i;
289
+ var otherBlackBerry = /BlackBerry/i;
290
+ var otherBlackBerry10 = /BB10/i;
291
+ var otherOpera = /Opera Mini/i;
292
+ var otherChrome = /\b(CriOS|Chrome)(?:.+)Mobile/i;
293
+ var otherFirefox = /Mobile(?:.+)Firefox\b/i;
294
+ var isAppleTabletOnIos13 = function(navigator) {
295
+ return typeof navigator !== "undefined" && navigator.platform === "MacIntel" && typeof navigator.maxTouchPoints === "number" && navigator.maxTouchPoints > 1 && typeof MSStream === "undefined";
296
+ };
297
+ function createMatch(userAgent) {
298
+ return function(regex) {
299
+ return regex.test(userAgent);
300
+ };
301
+ }
302
+ function isMobile(param) {
303
+ var nav = {
304
+ userAgent: "",
305
+ platform: "",
306
+ maxTouchPoints: 0
307
+ };
308
+ if (!param && typeof navigator !== "undefined") nav = {
309
+ userAgent: navigator.userAgent,
310
+ platform: navigator.platform,
311
+ maxTouchPoints: navigator.maxTouchPoints || 0
312
+ };
313
+ else if (typeof param === "string") nav.userAgent = param;
314
+ else if (param && param.userAgent) nav = {
315
+ userAgent: param.userAgent,
316
+ platform: param.platform,
317
+ maxTouchPoints: param.maxTouchPoints || 0
318
+ };
319
+ var userAgent = nav.userAgent;
320
+ var tmp = userAgent.split("[FBAN");
321
+ if (typeof tmp[1] !== "undefined") userAgent = tmp[0];
322
+ tmp = userAgent.split("Twitter");
323
+ if (typeof tmp[1] !== "undefined") userAgent = tmp[0];
324
+ var match = createMatch(userAgent);
325
+ var result = {
326
+ apple: {
327
+ phone: match(appleIphone) && !match(windowsPhone),
328
+ ipod: match(appleIpod),
329
+ tablet: !match(appleIphone) && (match(appleTablet) || isAppleTabletOnIos13(nav)) && !match(windowsPhone),
330
+ universal: match(appleUniversal),
331
+ device: (match(appleIphone) || match(appleIpod) || match(appleTablet) || match(appleUniversal) || isAppleTabletOnIos13(nav)) && !match(windowsPhone)
332
+ },
333
+ amazon: {
334
+ phone: match(amazonPhone),
335
+ tablet: !match(amazonPhone) && match(amazonTablet),
336
+ device: match(amazonPhone) || match(amazonTablet)
337
+ },
338
+ android: {
339
+ phone: !match(windowsPhone) && match(amazonPhone) || !match(windowsPhone) && match(androidPhone),
340
+ tablet: !match(windowsPhone) && !match(amazonPhone) && !match(androidPhone) && (match(amazonTablet) || match(androidTablet)),
341
+ device: !match(windowsPhone) && (match(amazonPhone) || match(amazonTablet) || match(androidPhone) || match(androidTablet)) || match(/\bokhttp\b/i)
342
+ },
343
+ windows: {
344
+ phone: match(windowsPhone),
345
+ tablet: match(windowsTablet),
346
+ device: match(windowsPhone) || match(windowsTablet)
347
+ },
348
+ other: {
349
+ blackberry: match(otherBlackBerry),
350
+ blackberry10: match(otherBlackBerry10),
351
+ opera: match(otherOpera),
352
+ firefox: match(otherFirefox),
353
+ chrome: match(otherChrome),
354
+ device: match(otherBlackBerry) || match(otherBlackBerry10) || match(otherOpera) || match(otherFirefox) || match(otherChrome)
355
+ },
356
+ any: false,
357
+ phone: false,
358
+ tablet: false
359
+ };
360
+ result.any = result.apple.device || result.android.device || result.windows.device || result.other.device;
361
+ result.phone = result.apple.phone || result.android.phone || result.windows.phone;
362
+ result.tablet = result.apple.tablet || result.android.tablet || result.windows.tablet;
363
+ return result;
364
+ }
365
+ exports["default"] = isMobile;
366
+ }));
367
+ //#endregion
368
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/utils/browser/isMobile.mjs
369
+ var import_cjs = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports) => {
370
+ function __export(m) {
371
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
372
+ }
373
+ exports.__esModule = true;
374
+ __export(require_isMobile());
375
+ exports["default"] = require_isMobile()["default"];
376
+ })))(), 1);
377
+ const isMobile = (import_cjs.default.default ?? import_cjs.default)(globalThis.navigator);
378
+ //#endregion
379
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/accessibility/AccessibilitySystem.mjs
380
+ const KEY_CODE_TAB = 9;
381
+ const DIV_TOUCH_SIZE = 100;
382
+ const DIV_TOUCH_POS_X = 0;
383
+ const DIV_TOUCH_POS_Y = 0;
384
+ const DIV_TOUCH_ZINDEX = 2;
385
+ const DIV_HOOK_SIZE = 1;
386
+ const DIV_HOOK_POS_X = -1e3;
387
+ const DIV_HOOK_POS_Y = -1e3;
388
+ const DIV_HOOK_ZINDEX = 2;
389
+ const _AccessibilitySystem = class _AccessibilitySystem {
390
+ /**
391
+ * @param {WebGLRenderer|WebGPURenderer} renderer - A reference to the current renderer
392
+ */
393
+ constructor(renderer, _mobileInfo = isMobile) {
394
+ this._mobileInfo = _mobileInfo;
395
+ /** Whether accessibility divs are visible for debugging */
396
+ this.debug = false;
397
+ /** Whether to activate on tab key press */
398
+ this._activateOnTab = true;
399
+ /** Whether to deactivate accessibility when mouse moves */
400
+ this._deactivateOnMouseMove = true;
401
+ /** Internal variable, see isActive getter. */
402
+ this._isActive = false;
403
+ /** Internal variable, see isMobileAccessibility getter. */
404
+ this._isMobileAccessibility = false;
405
+ /** This is the dom element that will sit over the PixiJS element. This is where the div overlays will go. */
406
+ this._div = null;
407
+ /** A simple pool for storing divs. */
408
+ this._pools = {};
409
+ /** This is a tick used to check if an object is no longer being rendered. */
410
+ this._renderId = 0;
411
+ /** The array of currently active accessible items. */
412
+ this._children = [];
413
+ /** Count to throttle div updates on android devices. */
414
+ this._androidUpdateCount = 0;
415
+ /** The frequency to update the div elements. */
416
+ this._androidUpdateFrequency = 500;
417
+ this._isRunningTests = false;
418
+ /** Bound function references for proper event listener removal */
419
+ this._boundOnKeyDown = this._onKeyDown.bind(this);
420
+ this._boundOnMouseMove = this._onMouseMove.bind(this);
421
+ this._hookDiv = null;
422
+ if (_mobileInfo.tablet || _mobileInfo.phone) this._createTouchHook();
423
+ this._renderer = renderer;
424
+ }
425
+ /**
426
+ * Value of `true` if accessibility is currently active and accessibility layers are showing.
427
+ * @type {boolean}
428
+ * @readonly
429
+ */
430
+ get isActive() {
431
+ return this._isActive;
432
+ }
433
+ /**
434
+ * Value of `true` if accessibility is enabled for touch devices.
435
+ * @type {boolean}
436
+ * @readonly
437
+ */
438
+ get isMobileAccessibility() {
439
+ return this._isMobileAccessibility;
440
+ }
441
+ /**
442
+ * Button element for handling touch hooks.
443
+ * @readonly
444
+ */
445
+ get hookDiv() {
446
+ return this._hookDiv;
447
+ }
448
+ /**
449
+ * The DOM element that will sit over the PixiJS element. This is where the div overlays will go.
450
+ * @readonly
451
+ */
452
+ get div() {
453
+ return this._div;
454
+ }
455
+ /**
456
+ * Creates the touch hooks.
457
+ * @private
458
+ */
459
+ _createTouchHook() {
460
+ const hookDiv = document.createElement("button");
461
+ hookDiv.style.width = `${DIV_HOOK_SIZE}px`;
462
+ hookDiv.style.height = `${DIV_HOOK_SIZE}px`;
463
+ hookDiv.style.position = "absolute";
464
+ hookDiv.style.top = `${DIV_HOOK_POS_X}px`;
465
+ hookDiv.style.left = `${DIV_HOOK_POS_Y}px`;
466
+ hookDiv.style.zIndex = DIV_HOOK_ZINDEX.toString();
467
+ hookDiv.style.backgroundColor = "#FF0000";
468
+ hookDiv.title = "select to enable accessibility for this content";
469
+ hookDiv.addEventListener("focus", () => {
470
+ this._isMobileAccessibility = true;
471
+ this._activate();
472
+ this._destroyTouchHook();
473
+ });
474
+ document.body.appendChild(hookDiv);
475
+ this._hookDiv = hookDiv;
476
+ }
477
+ /**
478
+ * Destroys the touch hooks.
479
+ * @private
480
+ */
481
+ _destroyTouchHook() {
482
+ if (!this._hookDiv) return;
483
+ document.body.removeChild(this._hookDiv);
484
+ this._hookDiv = null;
485
+ }
486
+ /**
487
+ * Activating will cause the Accessibility layer to be shown.
488
+ * This is called when a user presses the tab key.
489
+ * @private
490
+ */
491
+ _activate() {
492
+ if (this._isActive) return;
493
+ this._isActive = true;
494
+ if (!this._div) {
495
+ this._div = document.createElement("div");
496
+ this._div.style.position = "absolute";
497
+ this._div.style.top = `${DIV_TOUCH_POS_X}px`;
498
+ this._div.style.left = `${DIV_TOUCH_POS_Y}px`;
499
+ this._div.style.pointerEvents = "none";
500
+ this._div.style.zIndex = DIV_TOUCH_ZINDEX.toString();
501
+ this._canvasObserver = new CanvasObserver({
502
+ domElement: this._div,
503
+ renderer: this._renderer
504
+ });
505
+ }
506
+ if (this._activateOnTab) globalThis.addEventListener("keydown", this._boundOnKeyDown, false);
507
+ if (this._deactivateOnMouseMove) globalThis.document.addEventListener("mousemove", this._boundOnMouseMove, true);
508
+ const canvas = this._renderer.view.canvas;
509
+ if (!canvas.parentNode) {
510
+ const observer = new MutationObserver(() => {
511
+ if (canvas.parentNode) {
512
+ observer.disconnect();
513
+ this._canvasObserver.ensureAttached();
514
+ this._initAccessibilitySetup();
515
+ }
516
+ });
517
+ observer.observe(document.body, {
518
+ childList: true,
519
+ subtree: true
520
+ });
521
+ } else {
522
+ this._canvasObserver.ensureAttached();
523
+ this._initAccessibilitySetup();
524
+ }
525
+ }
526
+ _initAccessibilitySetup() {
527
+ this._renderer.runners.postrender.add(this);
528
+ if (this._renderer.lastObjectRendered) this._updateAccessibleObjects(this._renderer.lastObjectRendered);
529
+ }
530
+ /**
531
+ * Deactivates the accessibility system. Removes listeners and accessibility elements.
532
+ * @private
533
+ */
534
+ _deactivate() {
535
+ if (!this._isActive || this._isMobileAccessibility) return;
536
+ this._isActive = false;
537
+ globalThis.document.removeEventListener("mousemove", this._boundOnMouseMove, true);
538
+ if (this._activateOnTab) globalThis.addEventListener("keydown", this._boundOnKeyDown, false);
539
+ this._renderer.runners.postrender.remove(this);
540
+ for (const child of this._children) {
541
+ if (child._accessibleDiv?.parentNode) {
542
+ child._accessibleDiv.parentNode.removeChild(child._accessibleDiv);
543
+ child._accessibleDiv = null;
544
+ }
545
+ child._accessibleActive = false;
546
+ }
547
+ for (const accessibleType in this._pools) {
548
+ this._pools[accessibleType].forEach((div) => {
549
+ if (div.parentNode) div.parentNode.removeChild(div);
550
+ });
551
+ delete this._pools[accessibleType];
552
+ }
553
+ if (this._div?.parentNode) this._div.parentNode.removeChild(this._div);
554
+ this._pools = {};
555
+ this._children = [];
556
+ }
557
+ /**
558
+ * This recursive function will run through the scene graph and add any new accessible objects to the DOM layer.
559
+ * @private
560
+ * @param {Container} container - The Container to check.
561
+ */
562
+ _updateAccessibleObjects(container) {
563
+ if (!container.visible || !container.accessibleChildren) return;
564
+ if (container.accessible) {
565
+ if (!container._accessibleActive) this._addChild(container);
566
+ container._renderId = this._renderId;
567
+ }
568
+ const children = container.children;
569
+ if (children) for (let i = 0; i < children.length; i++) this._updateAccessibleObjects(children[i]);
570
+ }
571
+ /**
572
+ * Runner init called, view is available at this point.
573
+ * @ignore
574
+ */
575
+ init(options) {
576
+ const mergedOptions = { accessibilityOptions: {
577
+ ..._AccessibilitySystem.defaultOptions,
578
+ ...options?.accessibilityOptions || {}
579
+ } };
580
+ this.debug = mergedOptions.accessibilityOptions.debug;
581
+ this._activateOnTab = mergedOptions.accessibilityOptions.activateOnTab;
582
+ this._deactivateOnMouseMove = mergedOptions.accessibilityOptions.deactivateOnMouseMove;
583
+ if (mergedOptions.accessibilityOptions.enabledByDefault) this._activate();
584
+ this._renderer.runners.postrender.remove(this);
585
+ }
586
+ /**
587
+ * Updates the accessibility layer during rendering.
588
+ * - Removes divs for containers no longer in the scene
589
+ * - Updates the position and dimensions of the root div
590
+ * - Updates positions of active accessibility divs
591
+ * Only fires while the accessibility system is active.
592
+ * @ignore
593
+ */
594
+ postrender() {
595
+ const now = performance.now();
596
+ if (this._mobileInfo.android.device && now < this._androidUpdateCount) return;
597
+ this._androidUpdateCount = now + this._androidUpdateFrequency;
598
+ if ((!this._renderer.renderingToScreen || !this._renderer.view.canvas) && !this._isRunningTests) return;
599
+ const activeIds = /* @__PURE__ */ new Set();
600
+ if (this._renderer.lastObjectRendered) {
601
+ this._updateAccessibleObjects(this._renderer.lastObjectRendered);
602
+ for (const child of this._children) if (child._renderId === this._renderId) activeIds.add(this._children.indexOf(child));
603
+ }
604
+ for (let i = this._children.length - 1; i >= 0; i--) {
605
+ const child = this._children[i];
606
+ if (!activeIds.has(i)) {
607
+ if (child._accessibleDiv && child._accessibleDiv.parentNode) {
608
+ child._accessibleDiv.parentNode.removeChild(child._accessibleDiv);
609
+ this._getPool(child.accessibleType).push(child._accessibleDiv);
610
+ child._accessibleDiv = null;
611
+ }
612
+ child._accessibleActive = false;
613
+ removeItems(this._children, i, 1);
614
+ }
615
+ }
616
+ if (this._renderer.renderingToScreen) this._canvasObserver.ensureAttached();
617
+ for (let i = 0; i < this._children.length; i++) {
618
+ const child = this._children[i];
619
+ if (!child._accessibleActive || !child._accessibleDiv) continue;
620
+ const div = child._accessibleDiv;
621
+ const hitArea = child.hitArea || child.getBounds().rectangle;
622
+ if (child.hitArea) {
623
+ const wt = child.worldTransform;
624
+ div.style.left = `${wt.tx + hitArea.x * wt.a}px`;
625
+ div.style.top = `${wt.ty + hitArea.y * wt.d}px`;
626
+ div.style.width = `${hitArea.width * wt.a}px`;
627
+ div.style.height = `${hitArea.height * wt.d}px`;
628
+ } else {
629
+ this._capHitArea(hitArea);
630
+ div.style.left = `${hitArea.x}px`;
631
+ div.style.top = `${hitArea.y}px`;
632
+ div.style.width = `${hitArea.width}px`;
633
+ div.style.height = `${hitArea.height}px`;
634
+ }
635
+ }
636
+ this._renderId++;
637
+ }
638
+ /**
639
+ * private function that will visually add the information to the
640
+ * accessibility div
641
+ * @param {HTMLElement} div -
642
+ */
643
+ _updateDebugHTML(div) {
644
+ div.innerHTML = `type: ${div.type}</br> title : ${div.title}</br> tabIndex: ${div.tabIndex}`;
645
+ }
646
+ /**
647
+ * Adjust the hit area based on the bounds of a display object
648
+ * @param {Rectangle} hitArea - Bounds of the child
649
+ */
650
+ _capHitArea(hitArea) {
651
+ if (hitArea.x < 0) {
652
+ hitArea.width += hitArea.x;
653
+ hitArea.x = 0;
654
+ }
655
+ if (hitArea.y < 0) {
656
+ hitArea.height += hitArea.y;
657
+ hitArea.y = 0;
658
+ }
659
+ const { width: viewWidth, height: viewHeight } = this._renderer;
660
+ if (hitArea.x + hitArea.width > viewWidth) hitArea.width = viewWidth - hitArea.x;
661
+ if (hitArea.y + hitArea.height > viewHeight) hitArea.height = viewHeight - hitArea.y;
662
+ }
663
+ /**
664
+ * Creates or reuses a div element for a Container and adds it to the accessibility layer.
665
+ * Sets up ARIA attributes, event listeners, and positioning based on the container's properties.
666
+ * @private
667
+ * @param {Container} container - The child to make accessible.
668
+ */
669
+ _addChild(container) {
670
+ let div = this._getPool(container.accessibleType).pop();
671
+ if (div) {
672
+ div.innerHTML = "";
673
+ div.removeAttribute("title");
674
+ div.removeAttribute("aria-label");
675
+ div.tabIndex = 0;
676
+ } else {
677
+ if (container.accessibleType === "button") div = document.createElement("button");
678
+ else {
679
+ div = document.createElement(container.accessibleType);
680
+ div.style.cssText = `
681
+ color: transparent;
682
+ pointer-events: none;
683
+ padding: 0;
684
+ margin: 0;
685
+ border: 0;
686
+ outline: 0;
687
+ background: transparent;
688
+ box-sizing: border-box;
689
+ user-select: none;
690
+ -webkit-user-select: none;
691
+ -moz-user-select: none;
692
+ -ms-user-select: none;
693
+ `;
694
+ if (container.accessibleText) div.innerText = container.accessibleText;
695
+ }
696
+ div.style.width = `${DIV_TOUCH_SIZE}px`;
697
+ div.style.height = `${DIV_TOUCH_SIZE}px`;
698
+ div.style.backgroundColor = this.debug ? "rgba(255,255,255,0.5)" : "transparent";
699
+ div.style.position = "absolute";
700
+ div.style.zIndex = DIV_TOUCH_ZINDEX.toString();
701
+ div.style.borderStyle = "none";
702
+ if (navigator.userAgent.toLowerCase().includes("chrome")) div.setAttribute("aria-live", "off");
703
+ else div.setAttribute("aria-live", "polite");
704
+ if (navigator.userAgent.match(/rv:.*Gecko\//)) div.setAttribute("aria-relevant", "additions");
705
+ else div.setAttribute("aria-relevant", "text");
706
+ div.addEventListener("click", this._onClick.bind(this));
707
+ div.addEventListener("focus", this._onFocus.bind(this));
708
+ div.addEventListener("focusout", this._onFocusOut.bind(this));
709
+ }
710
+ div.style.pointerEvents = container.accessiblePointerEvents;
711
+ div.type = container.accessibleType;
712
+ if (container.accessibleTitle && container.accessibleTitle !== null) div.title = container.accessibleTitle;
713
+ else if (!container.accessibleHint || container.accessibleHint === null) div.title = `container ${container.tabIndex}`;
714
+ if (container.accessibleHint && container.accessibleHint !== null) div.setAttribute("aria-label", container.accessibleHint);
715
+ if (container.interactive) div.tabIndex = container.tabIndex;
716
+ else div.tabIndex = 0;
717
+ if (this.debug) this._updateDebugHTML(div);
718
+ container._accessibleActive = true;
719
+ container._accessibleDiv = div;
720
+ div.container = container;
721
+ this._children.push(container);
722
+ this._div.appendChild(container._accessibleDiv);
723
+ }
724
+ /**
725
+ * Dispatch events with the EventSystem.
726
+ * @param e
727
+ * @param type
728
+ * @private
729
+ */
730
+ _dispatchEvent(e, type) {
731
+ const { container: target } = e.target;
732
+ const boundary = this._renderer.events.rootBoundary;
733
+ const event = Object.assign(new FederatedEvent(boundary), { target });
734
+ boundary.rootTarget = this._renderer.lastObjectRendered;
735
+ type.forEach((type2) => boundary.dispatchEvent(event, type2));
736
+ }
737
+ /**
738
+ * Maps the div button press to pixi's EventSystem (click)
739
+ * @private
740
+ * @param {MouseEvent} e - The click event.
741
+ */
742
+ _onClick(e) {
743
+ this._dispatchEvent(e, [
744
+ "click",
745
+ "pointertap",
746
+ "tap"
747
+ ]);
748
+ }
749
+ /**
750
+ * Maps the div focus events to pixi's EventSystem (mouseover)
751
+ * @private
752
+ * @param {FocusEvent} e - The focus event.
753
+ */
754
+ _onFocus(e) {
755
+ if (!e.target.getAttribute("aria-live")) e.target.setAttribute("aria-live", "assertive");
756
+ this._dispatchEvent(e, ["mouseover"]);
757
+ }
758
+ /**
759
+ * Maps the div focus events to pixi's EventSystem (mouseout)
760
+ * @private
761
+ * @param {FocusEvent} e - The focusout event.
762
+ */
763
+ _onFocusOut(e) {
764
+ if (!e.target.getAttribute("aria-live")) e.target.setAttribute("aria-live", "polite");
765
+ this._dispatchEvent(e, ["mouseout"]);
766
+ }
767
+ /**
768
+ * Is called when a key is pressed
769
+ * @private
770
+ * @param {KeyboardEvent} e - The keydown event.
771
+ */
772
+ _onKeyDown(e) {
773
+ if (e.keyCode !== KEY_CODE_TAB || !this._activateOnTab) return;
774
+ this._activate();
775
+ }
776
+ /**
777
+ * Is called when the mouse moves across the renderer element
778
+ * @private
779
+ * @param {MouseEvent} e - The mouse event.
780
+ */
781
+ _onMouseMove(e) {
782
+ if (e.movementX === 0 && e.movementY === 0) return;
783
+ this._deactivate();
784
+ }
785
+ /**
786
+ * Destroys the accessibility system. Removes all elements and listeners.
787
+ * > [!IMPORTANT] This is typically called automatically when the {@link Application} is destroyed.
788
+ * > A typically user should not need to call this method directly.
789
+ */
790
+ destroy() {
791
+ this._deactivate();
792
+ this._destroyTouchHook();
793
+ this._canvasObserver?.destroy();
794
+ this._canvasObserver = null;
795
+ this._div = null;
796
+ this._pools = null;
797
+ this._children = null;
798
+ this._renderer = null;
799
+ this._hookDiv = null;
800
+ globalThis.removeEventListener("keydown", this._boundOnKeyDown);
801
+ this._boundOnKeyDown = null;
802
+ globalThis.document.removeEventListener("mousemove", this._boundOnMouseMove, true);
803
+ this._boundOnMouseMove = null;
804
+ }
805
+ /**
806
+ * Enables or disables the accessibility system.
807
+ * @param enabled - Whether to enable or disable accessibility.
808
+ * @example
809
+ * ```js
810
+ * app.renderer.accessibility.setAccessibilityEnabled(true); // Enable accessibility
811
+ * app.renderer.accessibility.setAccessibilityEnabled(false); // Disable accessibility
812
+ * ```
813
+ */
814
+ setAccessibilityEnabled(enabled) {
815
+ if (enabled) this._activate();
816
+ else this._deactivate();
817
+ }
818
+ _getPool(accessibleType) {
819
+ if (!this._pools[accessibleType]) this._pools[accessibleType] = [];
820
+ return this._pools[accessibleType];
821
+ }
822
+ };
823
+ /** @ignore */
824
+ _AccessibilitySystem.extension = {
825
+ type: [ExtensionType.WebGLSystem, ExtensionType.WebGPUSystem],
826
+ name: "accessibility"
827
+ };
828
+ /**
829
+ * The default options used by the system.
830
+ * You can set these before initializing the {@link Application} to change the default behavior.
831
+ * @example
832
+ * ```js
833
+ * import { AccessibilitySystem } from 'pixi.js';
834
+ *
835
+ * AccessibilitySystem.defaultOptions.enabledByDefault = true;
836
+ *
837
+ * const app = new Application()
838
+ * app.init()
839
+ * ```
840
+ */
841
+ _AccessibilitySystem.defaultOptions = {
842
+ /**
843
+ * Whether to enable accessibility features on initialization
844
+ * @default false
845
+ */
846
+ enabledByDefault: false,
847
+ /**
848
+ * Whether to visually show the accessibility divs for debugging
849
+ * @default false
850
+ */
851
+ debug: false,
852
+ /**
853
+ * Whether to activate accessibility when tab key is pressed
854
+ * @default true
855
+ */
856
+ activateOnTab: true,
857
+ /**
858
+ * Whether to deactivate accessibility when mouse moves
859
+ * @default true
860
+ */
861
+ deactivateOnMouseMove: true
862
+ };
863
+ let AccessibilitySystem = _AccessibilitySystem;
864
+ //#endregion
865
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/accessibility/accessibilityTarget.mjs
866
+ const accessibilityTarget = {
867
+ accessible: false,
868
+ accessibleTitle: null,
869
+ accessibleHint: null,
870
+ tabIndex: 0,
871
+ accessibleType: "button",
872
+ accessibleText: null,
873
+ accessiblePointerEvents: "auto",
874
+ accessibleChildren: true,
875
+ _accessibleActive: false,
876
+ _accessibleDiv: null,
877
+ _renderId: -1
878
+ };
879
+ //#endregion
880
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/dom/DOMPipe.mjs
881
+ var DOMPipe = class {
882
+ /**
883
+ * Constructor for the DOMPipe class.
884
+ * @param renderer - The renderer instance that this DOMPipe will be associated with.
885
+ */
886
+ constructor(renderer) {
887
+ /** Array to keep track of attached DOM elements */
888
+ this._attachedDomElements = [];
889
+ this._renderer = renderer;
890
+ this._renderer.runners.postrender.add(this);
891
+ this._renderer.runners.init.add(this);
892
+ this._domElement = document.createElement("div");
893
+ this._domElement.style.position = "absolute";
894
+ this._domElement.style.top = "0";
895
+ this._domElement.style.left = "0";
896
+ this._domElement.style.pointerEvents = "none";
897
+ this._domElement.style.zIndex = "1000";
898
+ }
899
+ /** Initializes the DOMPipe, setting up the main DOM element and adding it to the document body. */
900
+ init() {
901
+ this._canvasObserver = new CanvasObserver({
902
+ domElement: this._domElement,
903
+ renderer: this._renderer
904
+ });
905
+ }
906
+ /**
907
+ * Adds a renderable DOM container to the list of attached elements.
908
+ * @param domContainer - The DOM container to be added.
909
+ * @param _instructionSet - The instruction set (unused).
910
+ */
911
+ addRenderable(domContainer, _instructionSet) {
912
+ if (!this._attachedDomElements.includes(domContainer)) this._attachedDomElements.push(domContainer);
913
+ }
914
+ /**
915
+ * Updates a renderable DOM container.
916
+ * @param _domContainer - The DOM container to be updated (unused).
917
+ */
918
+ updateRenderable(_domContainer) {}
919
+ /**
920
+ * Validates a renderable DOM container.
921
+ * @param _domContainer - The DOM container to be validated (unused).
922
+ * @returns Always returns true as validation is not required.
923
+ */
924
+ validateRenderable(_domContainer) {
925
+ return true;
926
+ }
927
+ /** Handles the post-rendering process, ensuring DOM elements are correctly positioned and visible. */
928
+ postrender() {
929
+ const attachedDomElements = this._attachedDomElements;
930
+ if (attachedDomElements.length === 0) {
931
+ this._domElement.remove();
932
+ return;
933
+ }
934
+ this._canvasObserver.ensureAttached();
935
+ for (let i = 0; i < attachedDomElements.length; i++) {
936
+ const domContainer = attachedDomElements[i];
937
+ const element = domContainer.element;
938
+ if (!domContainer.parent || domContainer.globalDisplayStatus < 7) {
939
+ element?.remove();
940
+ attachedDomElements.splice(i, 1);
941
+ i--;
942
+ } else {
943
+ if (!this._domElement.contains(element)) {
944
+ element.style.position = "absolute";
945
+ element.style.pointerEvents = "auto";
946
+ this._domElement.appendChild(element);
947
+ }
948
+ const wt = domContainer.worldTransform;
949
+ const anchor = domContainer._anchor;
950
+ const ax = domContainer.width * anchor.x;
951
+ const ay = domContainer.height * anchor.y;
952
+ element.style.transformOrigin = `${ax}px ${ay}px`;
953
+ element.style.transform = `matrix(${wt.a}, ${wt.b}, ${wt.c}, ${wt.d}, ${wt.tx - ax}, ${wt.ty - ay})`;
954
+ element.style.opacity = domContainer.groupAlpha.toString();
955
+ }
956
+ }
957
+ }
958
+ /** Destroys the DOMPipe, removing all attached DOM elements and cleaning up resources. */
959
+ destroy() {
960
+ this._renderer.runners.postrender.remove(this);
961
+ for (let i = 0; i < this._attachedDomElements.length; i++) this._attachedDomElements[i].element?.remove();
962
+ this._attachedDomElements.length = 0;
963
+ this._domElement.remove();
964
+ this._canvasObserver.destroy();
965
+ this._renderer = null;
966
+ }
967
+ };
968
+ /**
969
+ * Static property defining the extension type and name for the DOMPipe.
970
+ * This is used to register the DOMPipe with different rendering pipelines.
971
+ */
972
+ DOMPipe.extension = {
973
+ type: [
974
+ ExtensionType.WebGLPipes,
975
+ ExtensionType.WebGPUPipes,
976
+ ExtensionType.CanvasPipes
977
+ ],
978
+ name: "dom"
979
+ };
980
+ //#endregion
981
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/events/EventTicker.mjs
982
+ var EventsTickerClass = class {
983
+ constructor() {
984
+ /** The frequency that fake events will be fired. */
985
+ this.interactionFrequency = 10;
986
+ this._deltaTime = 0;
987
+ this._didMove = false;
988
+ this._tickerAdded = false;
989
+ this._pauseUpdate = true;
990
+ }
991
+ /**
992
+ * Initializes the event ticker.
993
+ * @param events - The event system.
994
+ */
995
+ init(events) {
996
+ this.removeTickerListener();
997
+ this.events = events;
998
+ this.interactionFrequency = 10;
999
+ this._deltaTime = 0;
1000
+ this._didMove = false;
1001
+ this._tickerAdded = false;
1002
+ this._pauseUpdate = true;
1003
+ }
1004
+ /** Whether to pause the update checks or not. */
1005
+ get pauseUpdate() {
1006
+ return this._pauseUpdate;
1007
+ }
1008
+ set pauseUpdate(paused) {
1009
+ this._pauseUpdate = paused;
1010
+ }
1011
+ /** Adds the ticker listener. */
1012
+ addTickerListener() {
1013
+ if (this._tickerAdded || !this.domElement) return;
1014
+ Ticker.system.add(this._tickerUpdate, this, UPDATE_PRIORITY.INTERACTION);
1015
+ this._tickerAdded = true;
1016
+ }
1017
+ /** Removes the ticker listener. */
1018
+ removeTickerListener() {
1019
+ if (!this._tickerAdded) return;
1020
+ Ticker.system.remove(this._tickerUpdate, this);
1021
+ this._tickerAdded = false;
1022
+ }
1023
+ /** Sets flag to not fire extra events when the user has already moved there mouse */
1024
+ pointerMoved() {
1025
+ this._didMove = true;
1026
+ }
1027
+ /** Updates the state of interactive objects. */
1028
+ _update() {
1029
+ if (!this.domElement || this._pauseUpdate) return;
1030
+ if (this._didMove) {
1031
+ this._didMove = false;
1032
+ return;
1033
+ }
1034
+ const rootPointerEvent = this.events["_rootPointerEvent"];
1035
+ if (this.events.supportsTouchEvents && rootPointerEvent.pointerType === "touch") return;
1036
+ globalThis.document.dispatchEvent(this.events.supportsPointerEvents ? new PointerEvent("pointermove", {
1037
+ clientX: rootPointerEvent.clientX,
1038
+ clientY: rootPointerEvent.clientY,
1039
+ pointerType: rootPointerEvent.pointerType,
1040
+ pointerId: rootPointerEvent.pointerId
1041
+ }) : new MouseEvent("mousemove", {
1042
+ clientX: rootPointerEvent.clientX,
1043
+ clientY: rootPointerEvent.clientY
1044
+ }));
1045
+ }
1046
+ /**
1047
+ * Updates the state of interactive objects if at least {@link interactionFrequency}
1048
+ * milliseconds have passed since the last invocation.
1049
+ *
1050
+ * Invoked by a throttled ticker update from {@link Ticker.system}.
1051
+ * @param ticker - The throttled ticker.
1052
+ */
1053
+ _tickerUpdate(ticker) {
1054
+ this._deltaTime += ticker.deltaTime;
1055
+ if (this._deltaTime < this.interactionFrequency) return;
1056
+ this._deltaTime = 0;
1057
+ this._update();
1058
+ }
1059
+ /** Destroys the event ticker. */
1060
+ destroy() {
1061
+ this.removeTickerListener();
1062
+ this.events = null;
1063
+ this.domElement = null;
1064
+ this._deltaTime = 0;
1065
+ this._didMove = false;
1066
+ this._tickerAdded = false;
1067
+ this._pauseUpdate = true;
1068
+ }
1069
+ };
1070
+ const EventsTicker = new EventsTickerClass();
1071
+ //#endregion
1072
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/events/FederatedMouseEvent.mjs
1073
+ var FederatedMouseEvent = class extends FederatedEvent {
1074
+ constructor() {
1075
+ super(...arguments);
1076
+ /** The coordinates of the mouse event relative to the canvas. */
1077
+ this.client = new Point();
1078
+ /** The movement in this pointer relative to the last `mousemove` event. */
1079
+ this.movement = new Point();
1080
+ /** The offset of the pointer coordinates w.r.t. target Container in world space. This is not supported at the moment. */
1081
+ this.offset = new Point();
1082
+ /** The pointer coordinates in world space. */
1083
+ this.global = new Point();
1084
+ /**
1085
+ * The pointer coordinates in the renderer's {@link AbstractRenderer.screen screen}. This has slightly
1086
+ * different semantics than native PointerEvent screenX/screenY.
1087
+ */
1088
+ this.screen = new Point();
1089
+ }
1090
+ /** @readonly */
1091
+ get clientX() {
1092
+ return this.client.x;
1093
+ }
1094
+ /** @readonly */
1095
+ get clientY() {
1096
+ return this.client.y;
1097
+ }
1098
+ /**
1099
+ * Alias for {@link FederatedMouseEvent.clientX this.clientX}.
1100
+ * @readonly
1101
+ */
1102
+ get x() {
1103
+ return this.clientX;
1104
+ }
1105
+ /**
1106
+ * Alias for {@link FederatedMouseEvent.clientY this.clientY}.
1107
+ * @readonly
1108
+ */
1109
+ get y() {
1110
+ return this.clientY;
1111
+ }
1112
+ /** @readonly */
1113
+ get movementX() {
1114
+ return this.movement.x;
1115
+ }
1116
+ /** @readonly */
1117
+ get movementY() {
1118
+ return this.movement.y;
1119
+ }
1120
+ /** @readonly */
1121
+ get offsetX() {
1122
+ return this.offset.x;
1123
+ }
1124
+ /** @readonly */
1125
+ get offsetY() {
1126
+ return this.offset.y;
1127
+ }
1128
+ /** @readonly */
1129
+ get globalX() {
1130
+ return this.global.x;
1131
+ }
1132
+ /** @readonly */
1133
+ get globalY() {
1134
+ return this.global.y;
1135
+ }
1136
+ /**
1137
+ * The pointer coordinates in the renderer's screen. Alias for `screen.x`.
1138
+ * @readonly
1139
+ */
1140
+ get screenX() {
1141
+ return this.screen.x;
1142
+ }
1143
+ /**
1144
+ * The pointer coordinates in the renderer's screen. Alias for `screen.y`.
1145
+ * @readonly
1146
+ */
1147
+ get screenY() {
1148
+ return this.screen.y;
1149
+ }
1150
+ /**
1151
+ * Converts global coordinates into container-local coordinates.
1152
+ *
1153
+ * This method transforms coordinates from world space to a container's local space,
1154
+ * useful for precise positioning and hit testing.
1155
+ * @param container - The Container to get local coordinates for
1156
+ * @param point - Optional Point object to store the result. If not provided, a new Point will be created
1157
+ * @param globalPos - Optional custom global coordinates. If not provided, the event's global position is used
1158
+ * @returns The local coordinates as a Point object
1159
+ * @example
1160
+ * ```ts
1161
+ * // Basic usage - get local coordinates relative to a container
1162
+ * sprite.on('pointermove', (event: FederatedMouseEvent) => {
1163
+ * // Get position relative to the sprite
1164
+ * const localPos = event.getLocalPosition(sprite);
1165
+ * console.log('Local position:', localPos.x, localPos.y);
1166
+ * });
1167
+ * // Using custom global coordinates
1168
+ * const customGlobal = new Point(100, 100);
1169
+ * sprite.on('pointermove', (event: FederatedMouseEvent) => {
1170
+ * // Transform custom coordinates
1171
+ * const localPos = event.getLocalPosition(sprite, undefined, customGlobal);
1172
+ * console.log('Custom local position:', localPos.x, localPos.y);
1173
+ * });
1174
+ * ```
1175
+ * @see {@link Container.worldTransform} For the transformation matrix
1176
+ * @see {@link Point} For the point class used to store coordinates
1177
+ */
1178
+ getLocalPosition(container, point, globalPos) {
1179
+ return container.worldTransform.applyInverse(globalPos || this.global, point);
1180
+ }
1181
+ /**
1182
+ * Whether the modifier key was pressed when this event natively occurred.
1183
+ * @param key - The modifier key.
1184
+ */
1185
+ getModifierState(key) {
1186
+ return "getModifierState" in this.nativeEvent && this.nativeEvent.getModifierState(key);
1187
+ }
1188
+ /**
1189
+ * Not supported.
1190
+ * @param _typeArg
1191
+ * @param _canBubbleArg
1192
+ * @param _cancelableArg
1193
+ * @param _viewArg
1194
+ * @param _detailArg
1195
+ * @param _screenXArg
1196
+ * @param _screenYArg
1197
+ * @param _clientXArg
1198
+ * @param _clientYArg
1199
+ * @param _ctrlKeyArg
1200
+ * @param _altKeyArg
1201
+ * @param _shiftKeyArg
1202
+ * @param _metaKeyArg
1203
+ * @param _buttonArg
1204
+ * @param _relatedTargetArg
1205
+ * @deprecated since 7.0.0
1206
+ * @ignore
1207
+ */
1208
+ initMouseEvent(_typeArg, _canBubbleArg, _cancelableArg, _viewArg, _detailArg, _screenXArg, _screenYArg, _clientXArg, _clientYArg, _ctrlKeyArg, _altKeyArg, _shiftKeyArg, _metaKeyArg, _buttonArg, _relatedTargetArg) {
1209
+ throw new Error("Method not implemented.");
1210
+ }
1211
+ };
1212
+ //#endregion
1213
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/events/FederatedPointerEvent.mjs
1214
+ var FederatedPointerEvent = class extends FederatedMouseEvent {
1215
+ constructor() {
1216
+ super(...arguments);
1217
+ /**
1218
+ * The width of the pointer's contact along the x-axis, measured in CSS pixels.
1219
+ * radiusX of TouchEvents will be represented by this value.
1220
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/width
1221
+ */
1222
+ this.width = 0;
1223
+ /**
1224
+ * The height of the pointer's contact along the y-axis, measured in CSS pixels.
1225
+ * radiusY of TouchEvents will be represented by this value.
1226
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/height
1227
+ */
1228
+ this.height = 0;
1229
+ /**
1230
+ * Indicates whether or not the pointer device that created the event is the primary pointer.
1231
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/isPrimary
1232
+ */
1233
+ this.isPrimary = false;
1234
+ /**
1235
+ * A unique identifier for the pointing device generating the event, that persists across events.
1236
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/persistentDeviceId
1237
+ */
1238
+ this.persistentDeviceId = 0;
1239
+ }
1240
+ /**
1241
+ * Only included for completeness for now
1242
+ * @ignore
1243
+ */
1244
+ getCoalescedEvents() {
1245
+ if (this.type === "pointermove" || this.type === "mousemove" || this.type === "touchmove") return [this];
1246
+ return [];
1247
+ }
1248
+ /**
1249
+ * Only included for completeness for now
1250
+ * @ignore
1251
+ */
1252
+ getPredictedEvents() {
1253
+ throw new Error("getPredictedEvents is not supported!");
1254
+ }
1255
+ };
1256
+ //#endregion
1257
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/events/FederatedWheelEvent.mjs
1258
+ var FederatedWheelEvent = class extends FederatedMouseEvent {
1259
+ constructor() {
1260
+ super(...arguments);
1261
+ /**
1262
+ * Units specified in pixels.
1263
+ * @ignore
1264
+ */
1265
+ this.DOM_DELTA_PIXEL = 0;
1266
+ /**
1267
+ * Units specified in lines.
1268
+ * @ignore
1269
+ */
1270
+ this.DOM_DELTA_LINE = 1;
1271
+ /**
1272
+ * Units specified in pages.
1273
+ * @ignore
1274
+ */
1275
+ this.DOM_DELTA_PAGE = 2;
1276
+ }
1277
+ };
1278
+ /**
1279
+ * Units specified in pixels.
1280
+ * @ignore
1281
+ */
1282
+ FederatedWheelEvent.DOM_DELTA_PIXEL = 0;
1283
+ /**
1284
+ * Units specified in lines.
1285
+ * @ignore
1286
+ */
1287
+ FederatedWheelEvent.DOM_DELTA_LINE = 1;
1288
+ /**
1289
+ * Units specified in pages.
1290
+ * @ignore
1291
+ */
1292
+ FederatedWheelEvent.DOM_DELTA_PAGE = 2;
1293
+ //#endregion
1294
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/events/EventBoundary.mjs
1295
+ const PROPAGATION_LIMIT = 2048;
1296
+ const tempHitLocation = new Point();
1297
+ const tempLocalMapping = new Point();
1298
+ var EventBoundary = class {
1299
+ /**
1300
+ * @param rootTarget - The holder of the event boundary.
1301
+ */
1302
+ constructor(rootTarget) {
1303
+ /**
1304
+ * Emits events after they were dispatched into the scene graph.
1305
+ *
1306
+ * This can be used for global events listening, regardless of the scene graph being used. It should
1307
+ * not be used by interactive libraries for normal use.
1308
+ *
1309
+ * Special events that do not bubble all the way to the root target are not emitted from here,
1310
+ * e.g. pointerenter, pointerleave, click.
1311
+ */
1312
+ this.dispatch = new eventemitter3_default();
1313
+ /**
1314
+ * This flag would emit `pointermove`, `touchmove`, and `mousemove` events on all Containers.
1315
+ *
1316
+ * The `moveOnAll` semantics mirror those of earlier versions of PixiJS. This was disabled in favor of
1317
+ * the Pointer Event API's approach.
1318
+ */
1319
+ this.moveOnAll = false;
1320
+ /** Enables the global move events. `globalpointermove`, `globaltouchmove`, and `globalmousemove` */
1321
+ this.enableGlobalMoveEvents = true;
1322
+ /**
1323
+ * State object for mapping methods.
1324
+ * @see EventBoundary#trackingData
1325
+ */
1326
+ this.mappingState = { trackingData: {} };
1327
+ /**
1328
+ * The event pool maps event constructors to an free pool of instances of those specific events.
1329
+ * @see EventBoundary#allocateEvent
1330
+ * @see EventBoundary#freeEvent
1331
+ */
1332
+ this.eventPool = /* @__PURE__ */ new Map();
1333
+ /** Every interactive element gathered from the scene. Only used in `pointermove` */
1334
+ this._allInteractiveElements = [];
1335
+ /** Every element that passed the hit test. Only used in `pointermove` */
1336
+ this._hitElements = [];
1337
+ /** Whether or not to collect all the interactive elements from the scene. Enabled in `pointermove` */
1338
+ this._isPointerMoveEvent = false;
1339
+ this.rootTarget = rootTarget;
1340
+ this.hitPruneFn = this.hitPruneFn.bind(this);
1341
+ this.hitTestFn = this.hitTestFn.bind(this);
1342
+ this.mapPointerDown = this.mapPointerDown.bind(this);
1343
+ this.mapPointerMove = this.mapPointerMove.bind(this);
1344
+ this.mapPointerOut = this.mapPointerOut.bind(this);
1345
+ this.mapPointerOver = this.mapPointerOver.bind(this);
1346
+ this.mapPointerUp = this.mapPointerUp.bind(this);
1347
+ this.mapPointerUpOutside = this.mapPointerUpOutside.bind(this);
1348
+ this.mapWheel = this.mapWheel.bind(this);
1349
+ this.mappingTable = {};
1350
+ this.addEventMapping("pointerdown", this.mapPointerDown);
1351
+ this.addEventMapping("pointermove", this.mapPointerMove);
1352
+ this.addEventMapping("pointerout", this.mapPointerOut);
1353
+ this.addEventMapping("pointerleave", this.mapPointerOut);
1354
+ this.addEventMapping("pointerover", this.mapPointerOver);
1355
+ this.addEventMapping("pointerup", this.mapPointerUp);
1356
+ this.addEventMapping("pointerupoutside", this.mapPointerUpOutside);
1357
+ this.addEventMapping("wheel", this.mapWheel);
1358
+ }
1359
+ /**
1360
+ * Adds an event mapping for the event `type` handled by `fn`.
1361
+ *
1362
+ * Event mappings can be used to implement additional or custom events. They take an event
1363
+ * coming from the upstream scene (or directly from the {@link EventSystem}) and dispatch new downstream events
1364
+ * generally trickling down and bubbling up to {@link EventBoundary.rootTarget this.rootTarget}.
1365
+ *
1366
+ * To modify the semantics of existing events, the built-in mapping methods of EventBoundary should be overridden
1367
+ * instead.
1368
+ * @param type - The type of upstream event to map.
1369
+ * @param fn - The mapping method. The context of this function must be bound manually, if desired.
1370
+ */
1371
+ addEventMapping(type, fn) {
1372
+ if (!this.mappingTable[type]) this.mappingTable[type] = [];
1373
+ this.mappingTable[type].push({
1374
+ fn,
1375
+ priority: 0
1376
+ });
1377
+ this.mappingTable[type].sort((a, b) => a.priority - b.priority);
1378
+ }
1379
+ /**
1380
+ * Dispatches the given event
1381
+ * @param e - The event to dispatch.
1382
+ * @param type - The type of event to dispatch. Defaults to `e.type`.
1383
+ */
1384
+ dispatchEvent(e, type) {
1385
+ e.propagationStopped = false;
1386
+ e.propagationImmediatelyStopped = false;
1387
+ this.propagate(e, type);
1388
+ this.dispatch.emit(type || e.type, e);
1389
+ }
1390
+ /**
1391
+ * Maps the given upstream event through the event boundary and propagates it downstream.
1392
+ * @param e - The event to map.
1393
+ */
1394
+ mapEvent(e) {
1395
+ if (!this.rootTarget) return;
1396
+ const mappers = this.mappingTable[e.type];
1397
+ if (mappers) for (let i = 0, j = mappers.length; i < j; i++) mappers[i].fn(e);
1398
+ else warn(`[EventBoundary]: Event mapping not defined for ${e.type}`);
1399
+ }
1400
+ /**
1401
+ * Finds the Container that is the target of a event at the given coordinates.
1402
+ *
1403
+ * The passed (x,y) coordinates are in the world space above this event boundary.
1404
+ * @param x - The x coordinate of the event.
1405
+ * @param y - The y coordinate of the event.
1406
+ */
1407
+ hitTest(x, y) {
1408
+ EventsTicker.pauseUpdate = true;
1409
+ const fn = this._isPointerMoveEvent && this.enableGlobalMoveEvents ? "hitTestMoveRecursive" : "hitTestRecursive";
1410
+ const invertedPath = this[fn](this.rootTarget, this.rootTarget.eventMode, tempHitLocation.set(x, y), this.hitTestFn, this.hitPruneFn);
1411
+ return invertedPath && invertedPath[0];
1412
+ }
1413
+ /**
1414
+ * Propagate the passed event from from {@link EventBoundary.rootTarget this.rootTarget} to its
1415
+ * target `e.target`.
1416
+ * @param e - The event to propagate.
1417
+ * @param type - The type of event to propagate. Defaults to `e.type`.
1418
+ */
1419
+ propagate(e, type) {
1420
+ if (!e.target) return;
1421
+ const composedPath = e.composedPath();
1422
+ e.eventPhase = e.CAPTURING_PHASE;
1423
+ for (let i = 0, j = composedPath.length - 1; i < j; i++) {
1424
+ e.currentTarget = composedPath[i];
1425
+ this.notifyTarget(e, type);
1426
+ if (e.propagationStopped || e.propagationImmediatelyStopped) return;
1427
+ }
1428
+ e.eventPhase = e.AT_TARGET;
1429
+ e.currentTarget = e.target;
1430
+ this.notifyTarget(e, type);
1431
+ if (e.propagationStopped || e.propagationImmediatelyStopped) return;
1432
+ e.eventPhase = e.BUBBLING_PHASE;
1433
+ for (let i = composedPath.length - 2; i >= 0; i--) {
1434
+ e.currentTarget = composedPath[i];
1435
+ this.notifyTarget(e, type);
1436
+ if (e.propagationStopped || e.propagationImmediatelyStopped) return;
1437
+ }
1438
+ }
1439
+ /**
1440
+ * Emits the event `e` to all interactive containers. The event is propagated in the bubbling phase always.
1441
+ *
1442
+ * This is used in the `globalpointermove` event.
1443
+ * @param e - The emitted event.
1444
+ * @param type - The listeners to notify.
1445
+ * @param targets - The targets to notify.
1446
+ */
1447
+ all(e, type, targets = this._allInteractiveElements) {
1448
+ if (targets.length === 0) return;
1449
+ e.eventPhase = e.BUBBLING_PHASE;
1450
+ const events = Array.isArray(type) ? type : [type];
1451
+ for (let i = targets.length - 1; i >= 0; i--) events.forEach((event) => {
1452
+ e.currentTarget = targets[i];
1453
+ this.notifyTarget(e, event);
1454
+ });
1455
+ }
1456
+ /**
1457
+ * Finds the propagation path from {@link EventBoundary.rootTarget rootTarget} to the passed
1458
+ * `target`. The last element in the path is `target`.
1459
+ * @param target - The target to find the propagation path to.
1460
+ */
1461
+ propagationPath(target) {
1462
+ const propagationPath = [target];
1463
+ for (let i = 0; i < PROPAGATION_LIMIT && target !== this.rootTarget && target.parent; i++) {
1464
+ if (!target.parent) throw new Error("Cannot find propagation path to disconnected target");
1465
+ propagationPath.push(target.parent);
1466
+ target = target.parent;
1467
+ }
1468
+ propagationPath.reverse();
1469
+ return propagationPath;
1470
+ }
1471
+ hitTestMoveRecursive(currentTarget, eventMode, location, testFn, pruneFn, ignore = false) {
1472
+ let shouldReturn = false;
1473
+ if (this._interactivePrune(currentTarget)) return null;
1474
+ if (currentTarget.eventMode === "dynamic" || eventMode === "dynamic") EventsTicker.pauseUpdate = false;
1475
+ if (currentTarget.interactiveChildren && currentTarget.children) {
1476
+ const children = currentTarget.children;
1477
+ for (let i = children.length - 1; i >= 0; i--) {
1478
+ const child = children[i];
1479
+ const nestedHit = this.hitTestMoveRecursive(child, this._isInteractive(eventMode) ? eventMode : child.eventMode, location, testFn, pruneFn, ignore || pruneFn(currentTarget, location));
1480
+ if (nestedHit) {
1481
+ if (nestedHit.length > 0 && !nestedHit[nestedHit.length - 1].parent) continue;
1482
+ const isInteractive = currentTarget.isInteractive();
1483
+ if (nestedHit.length > 0 || isInteractive) {
1484
+ if (isInteractive) this._allInteractiveElements.push(currentTarget);
1485
+ nestedHit.push(currentTarget);
1486
+ }
1487
+ if (this._hitElements.length === 0) this._hitElements = nestedHit;
1488
+ shouldReturn = true;
1489
+ }
1490
+ }
1491
+ }
1492
+ const isInteractiveMode = this._isInteractive(eventMode);
1493
+ const isInteractiveTarget = currentTarget.isInteractive();
1494
+ if (isInteractiveTarget && isInteractiveTarget) this._allInteractiveElements.push(currentTarget);
1495
+ if (ignore || this._hitElements.length > 0) return null;
1496
+ if (shouldReturn) return this._hitElements;
1497
+ if (isInteractiveMode && !pruneFn(currentTarget, location) && testFn(currentTarget, location)) return isInteractiveTarget ? [currentTarget] : [];
1498
+ return null;
1499
+ }
1500
+ /**
1501
+ * Recursive implementation for {@link EventBoundary.hitTest hitTest}.
1502
+ * @param currentTarget - The Container that is to be hit tested.
1503
+ * @param eventMode - The event mode for the `currentTarget` or one of its parents.
1504
+ * @param location - The location that is being tested for overlap.
1505
+ * @param testFn - Callback that determines whether the target passes hit testing. This callback
1506
+ * can assume that `pruneFn` failed to prune the container.
1507
+ * @param pruneFn - Callback that determiness whether the target and all of its children
1508
+ * cannot pass the hit test. It is used as a preliminary optimization to prune entire subtrees
1509
+ * of the scene graph.
1510
+ * @returns An array holding the hit testing target and all its ancestors in order. The first element
1511
+ * is the target itself and the last is {@link EventBoundary.rootTarget rootTarget}. This is the opposite
1512
+ * order w.r.t. the propagation path. If no hit testing target is found, null is returned.
1513
+ */
1514
+ hitTestRecursive(currentTarget, eventMode, location, testFn, pruneFn) {
1515
+ if (this._interactivePrune(currentTarget) || pruneFn(currentTarget, location)) return null;
1516
+ if (currentTarget.eventMode === "dynamic" || eventMode === "dynamic") EventsTicker.pauseUpdate = false;
1517
+ if (currentTarget.interactiveChildren && currentTarget.children) {
1518
+ const children = currentTarget.children;
1519
+ const relativeLocation = location;
1520
+ for (let i = children.length - 1; i >= 0; i--) {
1521
+ const child = children[i];
1522
+ const nestedHit = this.hitTestRecursive(child, this._isInteractive(eventMode) ? eventMode : child.eventMode, relativeLocation, testFn, pruneFn);
1523
+ if (nestedHit) {
1524
+ if (nestedHit.length > 0 && !nestedHit[nestedHit.length - 1].parent) continue;
1525
+ const isInteractive = currentTarget.isInteractive();
1526
+ if (nestedHit.length > 0 || isInteractive) nestedHit.push(currentTarget);
1527
+ return nestedHit;
1528
+ }
1529
+ }
1530
+ }
1531
+ const isInteractiveMode = this._isInteractive(eventMode);
1532
+ const isInteractiveTarget = currentTarget.isInteractive();
1533
+ if (isInteractiveMode && testFn(currentTarget, location)) return isInteractiveTarget ? [currentTarget] : [];
1534
+ return null;
1535
+ }
1536
+ _isInteractive(int) {
1537
+ return int === "static" || int === "dynamic";
1538
+ }
1539
+ _interactivePrune(container) {
1540
+ if (!container || !container.visible || !container.renderable || !container.measurable) return true;
1541
+ if (container.eventMode === "none") return true;
1542
+ if (container.eventMode === "passive" && !container.interactiveChildren) return true;
1543
+ return false;
1544
+ }
1545
+ /**
1546
+ * Checks whether the container or any of its children cannot pass the hit test at all.
1547
+ *
1548
+ * {@link EventBoundary}'s implementation uses the {@link Container.hitArea hitArea}
1549
+ * and {@link Container._maskEffect} for pruning.
1550
+ * @param container - The container to prune.
1551
+ * @param location - The location to test for overlap.
1552
+ */
1553
+ hitPruneFn(container, location) {
1554
+ if (container.hitArea) {
1555
+ container.worldTransform.applyInverse(location, tempLocalMapping);
1556
+ if (!container.hitArea.contains(tempLocalMapping.x, tempLocalMapping.y)) return true;
1557
+ }
1558
+ if (container.effects && container.effects.length) for (let i = 0; i < container.effects.length; i++) {
1559
+ const effect = container.effects[i];
1560
+ if (effect.containsPoint) {
1561
+ if (!effect.containsPoint(location, this.hitTestFn)) return true;
1562
+ }
1563
+ }
1564
+ return false;
1565
+ }
1566
+ /**
1567
+ * Checks whether the container passes hit testing for the given location.
1568
+ * @param container - The container to test.
1569
+ * @param location - The location to test for overlap.
1570
+ * @returns - Whether `container` passes hit testing for `location`.
1571
+ */
1572
+ hitTestFn(container, location) {
1573
+ if (container.hitArea) return true;
1574
+ if (container?.containsPoint) {
1575
+ container.worldTransform.applyInverse(location, tempLocalMapping);
1576
+ return container.containsPoint(tempLocalMapping);
1577
+ }
1578
+ return false;
1579
+ }
1580
+ /**
1581
+ * Notify all the listeners to the event's `currentTarget`.
1582
+ *
1583
+ * If the `currentTarget` contains the property `on<type>`, then it is called here,
1584
+ * simulating the behavior from version 6.x and prior.
1585
+ * @param e - The event passed to the target.
1586
+ * @param type - The type of event to notify. Defaults to `e.type`.
1587
+ */
1588
+ notifyTarget(e, type) {
1589
+ if (!e.currentTarget.isInteractive()) return;
1590
+ type ?? (type = e.type);
1591
+ const handlerKey = `on${type}`;
1592
+ e.currentTarget[handlerKey]?.(e);
1593
+ const key = e.eventPhase === e.CAPTURING_PHASE || e.eventPhase === e.AT_TARGET ? `${type}capture` : type;
1594
+ this._notifyListeners(e, key);
1595
+ if (e.eventPhase === e.AT_TARGET) this._notifyListeners(e, type);
1596
+ }
1597
+ /**
1598
+ * Maps the upstream `pointerdown` events to a downstream `pointerdown` event.
1599
+ *
1600
+ * `touchstart`, `rightdown`, `mousedown` events are also dispatched for specific pointer types.
1601
+ * @param from - The upstream `pointerdown` event.
1602
+ */
1603
+ mapPointerDown(from) {
1604
+ if (!(from instanceof FederatedPointerEvent)) {
1605
+ warn("EventBoundary cannot map a non-pointer event as a pointer event");
1606
+ return;
1607
+ }
1608
+ const e = this.createPointerEvent(from);
1609
+ this.dispatchEvent(e, "pointerdown");
1610
+ if (e.pointerType === "touch") this.dispatchEvent(e, "touchstart");
1611
+ else if (e.pointerType === "mouse" || e.pointerType === "pen") {
1612
+ const isRightButton = e.button === 2;
1613
+ this.dispatchEvent(e, isRightButton ? "rightdown" : "mousedown");
1614
+ }
1615
+ const trackingData = this.trackingData(from.pointerId);
1616
+ trackingData.pressTargetsByButton[from.button] = e.composedPath();
1617
+ this.freeEvent(e);
1618
+ }
1619
+ /**
1620
+ * Maps the upstream `pointermove` to downstream `pointerout`, `pointerover`, and `pointermove` events, in that order.
1621
+ *
1622
+ * The tracking data for the specific pointer has an updated `overTarget`. `mouseout`, `mouseover`,
1623
+ * `mousemove`, and `touchmove` events are fired as well for specific pointer types.
1624
+ * @param from - The upstream `pointermove` event.
1625
+ */
1626
+ mapPointerMove(from) {
1627
+ if (!(from instanceof FederatedPointerEvent)) {
1628
+ warn("EventBoundary cannot map a non-pointer event as a pointer event");
1629
+ return;
1630
+ }
1631
+ this._allInteractiveElements.length = 0;
1632
+ this._hitElements.length = 0;
1633
+ this._isPointerMoveEvent = true;
1634
+ const e = this.createPointerEvent(from);
1635
+ this._isPointerMoveEvent = false;
1636
+ const isMouse = e.pointerType === "mouse" || e.pointerType === "pen";
1637
+ const trackingData = this.trackingData(from.pointerId);
1638
+ const outTarget = this.findMountedTarget(trackingData.overTargets);
1639
+ if (trackingData.overTargets?.length > 0 && outTarget !== e.target) {
1640
+ const outType = from.type === "mousemove" ? "mouseout" : "pointerout";
1641
+ const outEvent = this.createPointerEvent(from, outType, outTarget);
1642
+ this.dispatchEvent(outEvent, "pointerout");
1643
+ if (isMouse) this.dispatchEvent(outEvent, "mouseout");
1644
+ if (!e.composedPath().includes(outTarget)) {
1645
+ const leaveEvent = this.createPointerEvent(from, "pointerleave", outTarget);
1646
+ leaveEvent.eventPhase = leaveEvent.AT_TARGET;
1647
+ while (leaveEvent.target && !e.composedPath().includes(leaveEvent.target)) {
1648
+ leaveEvent.currentTarget = leaveEvent.target;
1649
+ this.notifyTarget(leaveEvent);
1650
+ if (isMouse) this.notifyTarget(leaveEvent, "mouseleave");
1651
+ leaveEvent.target = leaveEvent.target.parent;
1652
+ }
1653
+ this.freeEvent(leaveEvent);
1654
+ }
1655
+ this.freeEvent(outEvent);
1656
+ }
1657
+ if (outTarget !== e.target) {
1658
+ const overType = from.type === "mousemove" ? "mouseover" : "pointerover";
1659
+ const overEvent = this.clonePointerEvent(e, overType);
1660
+ this.dispatchEvent(overEvent, "pointerover");
1661
+ if (isMouse) this.dispatchEvent(overEvent, "mouseover");
1662
+ let overTargetAncestor = outTarget?.parent;
1663
+ while (overTargetAncestor && overTargetAncestor !== this.rootTarget.parent) {
1664
+ if (overTargetAncestor === e.target) break;
1665
+ overTargetAncestor = overTargetAncestor.parent;
1666
+ }
1667
+ if (!overTargetAncestor || overTargetAncestor === this.rootTarget.parent) {
1668
+ const enterEvent = this.clonePointerEvent(e, "pointerenter");
1669
+ enterEvent.eventPhase = enterEvent.AT_TARGET;
1670
+ while (enterEvent.target && enterEvent.target !== outTarget && enterEvent.target !== this.rootTarget.parent) {
1671
+ enterEvent.currentTarget = enterEvent.target;
1672
+ this.notifyTarget(enterEvent);
1673
+ if (isMouse) this.notifyTarget(enterEvent, "mouseenter");
1674
+ enterEvent.target = enterEvent.target.parent;
1675
+ }
1676
+ this.freeEvent(enterEvent);
1677
+ }
1678
+ this.freeEvent(overEvent);
1679
+ }
1680
+ const allMethods = [];
1681
+ const allowGlobalPointerEvents = this.enableGlobalMoveEvents ?? true;
1682
+ this.moveOnAll ? allMethods.push("pointermove") : this.dispatchEvent(e, "pointermove");
1683
+ allowGlobalPointerEvents && allMethods.push("globalpointermove");
1684
+ if (e.pointerType === "touch") {
1685
+ this.moveOnAll ? allMethods.splice(1, 0, "touchmove") : this.dispatchEvent(e, "touchmove");
1686
+ allowGlobalPointerEvents && allMethods.push("globaltouchmove");
1687
+ }
1688
+ if (isMouse) {
1689
+ this.moveOnAll ? allMethods.splice(1, 0, "mousemove") : this.dispatchEvent(e, "mousemove");
1690
+ allowGlobalPointerEvents && allMethods.push("globalmousemove");
1691
+ this.cursor = e.target?.cursor;
1692
+ }
1693
+ if (allMethods.length > 0) this.all(e, allMethods);
1694
+ this._allInteractiveElements.length = 0;
1695
+ this._hitElements.length = 0;
1696
+ trackingData.overTargets = e.composedPath();
1697
+ this.freeEvent(e);
1698
+ }
1699
+ /**
1700
+ * Maps the upstream `pointerover` to downstream `pointerover` and `pointerenter` events, in that order.
1701
+ *
1702
+ * The tracking data for the specific pointer gets a new `overTarget`.
1703
+ * @param from - The upstream `pointerover` event.
1704
+ */
1705
+ mapPointerOver(from) {
1706
+ if (!(from instanceof FederatedPointerEvent)) {
1707
+ warn("EventBoundary cannot map a non-pointer event as a pointer event");
1708
+ return;
1709
+ }
1710
+ const trackingData = this.trackingData(from.pointerId);
1711
+ const e = this.createPointerEvent(from);
1712
+ const isMouse = e.pointerType === "mouse" || e.pointerType === "pen";
1713
+ this.dispatchEvent(e, "pointerover");
1714
+ if (isMouse) this.dispatchEvent(e, "mouseover");
1715
+ if (e.pointerType === "mouse") this.cursor = e.target?.cursor;
1716
+ const enterEvent = this.clonePointerEvent(e, "pointerenter");
1717
+ enterEvent.eventPhase = enterEvent.AT_TARGET;
1718
+ while (enterEvent.target && enterEvent.target !== this.rootTarget.parent) {
1719
+ enterEvent.currentTarget = enterEvent.target;
1720
+ this.notifyTarget(enterEvent);
1721
+ if (isMouse) this.notifyTarget(enterEvent, "mouseenter");
1722
+ enterEvent.target = enterEvent.target.parent;
1723
+ }
1724
+ trackingData.overTargets = e.composedPath();
1725
+ this.freeEvent(e);
1726
+ this.freeEvent(enterEvent);
1727
+ }
1728
+ /**
1729
+ * Maps the upstream `pointerout` to downstream `pointerout`, `pointerleave` events, in that order.
1730
+ *
1731
+ * The tracking data for the specific pointer is cleared of a `overTarget`.
1732
+ * @param from - The upstream `pointerout` event.
1733
+ */
1734
+ mapPointerOut(from) {
1735
+ if (!(from instanceof FederatedPointerEvent)) {
1736
+ warn("EventBoundary cannot map a non-pointer event as a pointer event");
1737
+ return;
1738
+ }
1739
+ const trackingData = this.trackingData(from.pointerId);
1740
+ if (trackingData.overTargets) {
1741
+ const isMouse = from.pointerType === "mouse" || from.pointerType === "pen";
1742
+ const outTarget = this.findMountedTarget(trackingData.overTargets);
1743
+ const outEvent = this.createPointerEvent(from, "pointerout", outTarget);
1744
+ this.dispatchEvent(outEvent);
1745
+ if (isMouse) this.dispatchEvent(outEvent, "mouseout");
1746
+ const leaveEvent = this.createPointerEvent(from, "pointerleave", outTarget);
1747
+ leaveEvent.eventPhase = leaveEvent.AT_TARGET;
1748
+ while (leaveEvent.target && leaveEvent.target !== this.rootTarget.parent) {
1749
+ leaveEvent.currentTarget = leaveEvent.target;
1750
+ this.notifyTarget(leaveEvent);
1751
+ if (isMouse) this.notifyTarget(leaveEvent, "mouseleave");
1752
+ leaveEvent.target = leaveEvent.target.parent;
1753
+ }
1754
+ trackingData.overTargets = null;
1755
+ this.freeEvent(outEvent);
1756
+ this.freeEvent(leaveEvent);
1757
+ }
1758
+ this.cursor = null;
1759
+ }
1760
+ /**
1761
+ * Maps the upstream `pointerup` event to downstream `pointerup`, `pointerupoutside`,
1762
+ * and `click`/`rightclick`/`pointertap` events, in that order.
1763
+ *
1764
+ * The `pointerupoutside` event bubbles from the original `pointerdown` target to the most specific
1765
+ * ancestor of the `pointerdown` and `pointerup` targets, which is also the `click` event's target. `touchend`,
1766
+ * `rightup`, `mouseup`, `touchendoutside`, `rightupoutside`, `mouseupoutside`, and `tap` are fired as well for
1767
+ * specific pointer types.
1768
+ * @param from - The upstream `pointerup` event.
1769
+ */
1770
+ mapPointerUp(from) {
1771
+ if (!(from instanceof FederatedPointerEvent)) {
1772
+ warn("EventBoundary cannot map a non-pointer event as a pointer event");
1773
+ return;
1774
+ }
1775
+ const now = performance.now();
1776
+ const e = this.createPointerEvent(from);
1777
+ this.dispatchEvent(e, "pointerup");
1778
+ if (e.pointerType === "touch") this.dispatchEvent(e, "touchend");
1779
+ else if (e.pointerType === "mouse" || e.pointerType === "pen") {
1780
+ const isRightButton = e.button === 2;
1781
+ this.dispatchEvent(e, isRightButton ? "rightup" : "mouseup");
1782
+ }
1783
+ const trackingData = this.trackingData(from.pointerId);
1784
+ const pressTarget = this.findMountedTarget(trackingData.pressTargetsByButton[from.button]);
1785
+ let clickTarget = pressTarget;
1786
+ if (pressTarget && !e.composedPath().includes(pressTarget)) {
1787
+ let currentTarget = pressTarget;
1788
+ while (currentTarget && !e.composedPath().includes(currentTarget)) {
1789
+ e.currentTarget = currentTarget;
1790
+ this.notifyTarget(e, "pointerupoutside");
1791
+ if (e.pointerType === "touch") this.notifyTarget(e, "touchendoutside");
1792
+ else if (e.pointerType === "mouse" || e.pointerType === "pen") {
1793
+ const isRightButton = e.button === 2;
1794
+ this.notifyTarget(e, isRightButton ? "rightupoutside" : "mouseupoutside");
1795
+ }
1796
+ currentTarget = currentTarget.parent;
1797
+ }
1798
+ delete trackingData.pressTargetsByButton[from.button];
1799
+ clickTarget = currentTarget;
1800
+ }
1801
+ if (clickTarget) {
1802
+ const clickEvent = this.clonePointerEvent(e, "click");
1803
+ clickEvent.target = clickTarget;
1804
+ clickEvent.path = null;
1805
+ if (!trackingData.clicksByButton[from.button]) trackingData.clicksByButton[from.button] = {
1806
+ clickCount: 0,
1807
+ target: clickEvent.target,
1808
+ timeStamp: now
1809
+ };
1810
+ const clickHistory = trackingData.clicksByButton[from.button];
1811
+ if (clickHistory.target === clickEvent.target && now - clickHistory.timeStamp < 200) ++clickHistory.clickCount;
1812
+ else clickHistory.clickCount = 1;
1813
+ clickHistory.target = clickEvent.target;
1814
+ clickHistory.timeStamp = now;
1815
+ clickEvent.detail = clickHistory.clickCount;
1816
+ if (clickEvent.pointerType === "mouse") {
1817
+ const isRightButton = clickEvent.button === 2;
1818
+ this.dispatchEvent(clickEvent, isRightButton ? "rightclick" : "click");
1819
+ } else if (clickEvent.pointerType === "touch") this.dispatchEvent(clickEvent, "tap");
1820
+ this.dispatchEvent(clickEvent, "pointertap");
1821
+ this.freeEvent(clickEvent);
1822
+ }
1823
+ this.freeEvent(e);
1824
+ }
1825
+ /**
1826
+ * Maps the upstream `pointerupoutside` event to a downstream `pointerupoutside` event, bubbling from the original
1827
+ * `pointerdown` target to `rootTarget`.
1828
+ *
1829
+ * (The most specific ancestor of the `pointerdown` event and the `pointerup` event must the
1830
+ * `{@link EventBoundary}'s root because the `pointerup` event occurred outside of the boundary.)
1831
+ *
1832
+ * `touchendoutside`, `mouseupoutside`, and `rightupoutside` events are fired as well for specific pointer
1833
+ * types. The tracking data for the specific pointer is cleared of a `pressTarget`.
1834
+ * @param from - The upstream `pointerupoutside` event.
1835
+ */
1836
+ mapPointerUpOutside(from) {
1837
+ if (!(from instanceof FederatedPointerEvent)) {
1838
+ warn("EventBoundary cannot map a non-pointer event as a pointer event");
1839
+ return;
1840
+ }
1841
+ const trackingData = this.trackingData(from.pointerId);
1842
+ const pressTarget = this.findMountedTarget(trackingData.pressTargetsByButton[from.button]);
1843
+ const e = this.createPointerEvent(from);
1844
+ if (pressTarget) {
1845
+ let currentTarget = pressTarget;
1846
+ while (currentTarget) {
1847
+ e.currentTarget = currentTarget;
1848
+ this.notifyTarget(e, "pointerupoutside");
1849
+ if (e.pointerType === "touch") this.notifyTarget(e, "touchendoutside");
1850
+ else if (e.pointerType === "mouse" || e.pointerType === "pen") this.notifyTarget(e, e.button === 2 ? "rightupoutside" : "mouseupoutside");
1851
+ currentTarget = currentTarget.parent;
1852
+ }
1853
+ delete trackingData.pressTargetsByButton[from.button];
1854
+ }
1855
+ this.freeEvent(e);
1856
+ }
1857
+ /**
1858
+ * Maps the upstream `wheel` event to a downstream `wheel` event.
1859
+ * @param from - The upstream `wheel` event.
1860
+ */
1861
+ mapWheel(from) {
1862
+ if (!(from instanceof FederatedWheelEvent)) {
1863
+ warn("EventBoundary cannot map a non-wheel event as a wheel event");
1864
+ return;
1865
+ }
1866
+ const wheelEvent = this.createWheelEvent(from);
1867
+ this.dispatchEvent(wheelEvent);
1868
+ this.freeEvent(wheelEvent);
1869
+ }
1870
+ /**
1871
+ * Finds the most specific event-target in the given propagation path that is still mounted in the scene graph.
1872
+ *
1873
+ * This is used to find the correct `pointerup` and `pointerout` target in the case that the original `pointerdown`
1874
+ * or `pointerover` target was unmounted from the scene graph.
1875
+ * @param propagationPath - The propagation path was valid in the past.
1876
+ * @returns - The most specific event-target still mounted at the same location in the scene graph.
1877
+ */
1878
+ findMountedTarget(propagationPath) {
1879
+ if (!propagationPath) return null;
1880
+ let currentTarget = propagationPath[0];
1881
+ for (let i = 1; i < propagationPath.length; i++) if (propagationPath[i].parent === currentTarget) currentTarget = propagationPath[i];
1882
+ else break;
1883
+ return currentTarget;
1884
+ }
1885
+ /**
1886
+ * Creates an event whose `originalEvent` is `from`, with an optional `type` and `target` override.
1887
+ *
1888
+ * The event is allocated using {@link EventBoundary#allocateEvent this.allocateEvent}.
1889
+ * @param from - The `originalEvent` for the returned event.
1890
+ * @param [type=from.type] - The type of the returned event.
1891
+ * @param target - The target of the returned event.
1892
+ */
1893
+ createPointerEvent(from, type, target) {
1894
+ const event = this.allocateEvent(FederatedPointerEvent);
1895
+ this.copyPointerData(from, event);
1896
+ this.copyMouseData(from, event);
1897
+ this.copyData(from, event);
1898
+ event.nativeEvent = from.nativeEvent;
1899
+ event.originalEvent = from;
1900
+ event.target = target ?? this.hitTest(event.global.x, event.global.y) ?? this._hitElements[0];
1901
+ if (typeof type === "string") event.type = type;
1902
+ return event;
1903
+ }
1904
+ /**
1905
+ * Creates a wheel event whose `originalEvent` is `from`.
1906
+ *
1907
+ * The event is allocated using {@link EventBoundary#allocateEvent this.allocateEvent}.
1908
+ * @param from - The upstream wheel event.
1909
+ */
1910
+ createWheelEvent(from) {
1911
+ const event = this.allocateEvent(FederatedWheelEvent);
1912
+ this.copyWheelData(from, event);
1913
+ this.copyMouseData(from, event);
1914
+ this.copyData(from, event);
1915
+ event.nativeEvent = from.nativeEvent;
1916
+ event.originalEvent = from;
1917
+ event.target = this.hitTest(event.global.x, event.global.y);
1918
+ return event;
1919
+ }
1920
+ /**
1921
+ * Clones the event `from`, with an optional `type` override.
1922
+ *
1923
+ * The event is allocated using {@link EventBoundary#allocateEvent this.allocateEvent}.
1924
+ * @param from - The event to clone.
1925
+ * @param [type=from.type] - The type of the returned event.
1926
+ */
1927
+ clonePointerEvent(from, type) {
1928
+ const event = this.allocateEvent(FederatedPointerEvent);
1929
+ event.nativeEvent = from.nativeEvent;
1930
+ event.originalEvent = from.originalEvent;
1931
+ this.copyPointerData(from, event);
1932
+ this.copyMouseData(from, event);
1933
+ this.copyData(from, event);
1934
+ event.target = from.target;
1935
+ event.path = from.composedPath().slice();
1936
+ event.type = type ?? event.type;
1937
+ return event;
1938
+ }
1939
+ /**
1940
+ * Copies wheel {@link FederatedWheelEvent} data from `from` into `to`.
1941
+ *
1942
+ * The following properties are copied:
1943
+ * + deltaMode
1944
+ * + deltaX
1945
+ * + deltaY
1946
+ * + deltaZ
1947
+ * @param from - The event to copy data from.
1948
+ * @param to - The event to copy data into.
1949
+ */
1950
+ copyWheelData(from, to) {
1951
+ to.deltaMode = from.deltaMode;
1952
+ to.deltaX = from.deltaX;
1953
+ to.deltaY = from.deltaY;
1954
+ to.deltaZ = from.deltaZ;
1955
+ }
1956
+ /**
1957
+ * Copies pointer {@link FederatedPointerEvent} data from `from` into `to`.
1958
+ *
1959
+ * The following properties are copied:
1960
+ * + pointerId
1961
+ * + width
1962
+ * + height
1963
+ * + isPrimary
1964
+ * + pointerType
1965
+ * + pressure
1966
+ * + tangentialPressure
1967
+ * + tiltX
1968
+ * + tiltY
1969
+ * @param from - The event to copy data from.
1970
+ * @param to - The event to copy data into.
1971
+ */
1972
+ copyPointerData(from, to) {
1973
+ if (!(from instanceof FederatedPointerEvent && to instanceof FederatedPointerEvent)) return;
1974
+ to.pointerId = from.pointerId;
1975
+ to.width = from.width;
1976
+ to.height = from.height;
1977
+ to.isPrimary = from.isPrimary;
1978
+ to.pointerType = from.pointerType;
1979
+ to.pressure = from.pressure;
1980
+ to.tangentialPressure = from.tangentialPressure;
1981
+ to.tiltX = from.tiltX;
1982
+ to.tiltY = from.tiltY;
1983
+ to.twist = from.twist;
1984
+ to.persistentDeviceId = from.persistentDeviceId;
1985
+ }
1986
+ /**
1987
+ * Copies mouse {@link FederatedMouseEvent} data from `from` to `to`.
1988
+ *
1989
+ * The following properties are copied:
1990
+ * + altKey
1991
+ * + button
1992
+ * + buttons
1993
+ * + clientX
1994
+ * + clientY
1995
+ * + metaKey
1996
+ * + movementX
1997
+ * + movementY
1998
+ * + pageX
1999
+ * + pageY
2000
+ * + x
2001
+ * + y
2002
+ * + screen
2003
+ * + shiftKey
2004
+ * + global
2005
+ * @param from - The event to copy data from.
2006
+ * @param to - The event to copy data into.
2007
+ */
2008
+ copyMouseData(from, to) {
2009
+ if (!(from instanceof FederatedMouseEvent && to instanceof FederatedMouseEvent)) return;
2010
+ to.altKey = from.altKey;
2011
+ to.button = from.button;
2012
+ to.buttons = from.buttons;
2013
+ to.client.copyFrom(from.client);
2014
+ to.ctrlKey = from.ctrlKey;
2015
+ to.metaKey = from.metaKey;
2016
+ to.movement.copyFrom(from.movement);
2017
+ to.screen.copyFrom(from.screen);
2018
+ to.shiftKey = from.shiftKey;
2019
+ to.global.copyFrom(from.global);
2020
+ }
2021
+ /**
2022
+ * Copies base {@link FederatedEvent} data from `from` into `to`.
2023
+ *
2024
+ * The following properties are copied:
2025
+ * + isTrusted
2026
+ * + srcElement
2027
+ * + timeStamp
2028
+ * + type
2029
+ * @param from - The event to copy data from.
2030
+ * @param to - The event to copy data into.
2031
+ */
2032
+ copyData(from, to) {
2033
+ to.isTrusted = from.isTrusted;
2034
+ to.srcElement = from.srcElement;
2035
+ to.timeStamp = performance.now();
2036
+ to.type = from.type;
2037
+ to.detail = from.detail;
2038
+ to.view = from.view;
2039
+ to.which = from.which;
2040
+ to.layer.copyFrom(from.layer);
2041
+ to.page.copyFrom(from.page);
2042
+ }
2043
+ /**
2044
+ * @param id - The pointer ID.
2045
+ * @returns The tracking data stored for the given pointer. If no data exists, a blank
2046
+ * state will be created.
2047
+ */
2048
+ trackingData(id) {
2049
+ if (!this.mappingState.trackingData[id]) this.mappingState.trackingData[id] = {
2050
+ pressTargetsByButton: {},
2051
+ clicksByButton: {},
2052
+ overTarget: null
2053
+ };
2054
+ return this.mappingState.trackingData[id];
2055
+ }
2056
+ /**
2057
+ * Allocate a specific type of event from {@link EventBoundary#eventPool this.eventPool}.
2058
+ *
2059
+ * This allocation is constructor-agnostic, as long as it only takes one argument - this event
2060
+ * boundary.
2061
+ * @param constructor - The event's constructor.
2062
+ * @returns An event of the given type.
2063
+ */
2064
+ allocateEvent(constructor) {
2065
+ if (!this.eventPool.has(constructor)) this.eventPool.set(constructor, []);
2066
+ const event = this.eventPool.get(constructor).pop() || new constructor(this);
2067
+ event.eventPhase = event.NONE;
2068
+ event.currentTarget = null;
2069
+ event.defaultPrevented = false;
2070
+ event.path = null;
2071
+ event.target = null;
2072
+ return event;
2073
+ }
2074
+ /**
2075
+ * Frees the event and puts it back into the event pool.
2076
+ *
2077
+ * It is illegal to reuse the event until it is allocated again, using `this.allocateEvent`.
2078
+ *
2079
+ * It is also advised that events not allocated from {@link EventBoundary#allocateEvent this.allocateEvent}
2080
+ * not be freed. This is because of the possibility that the same event is freed twice, which can cause
2081
+ * it to be allocated twice & result in overwriting.
2082
+ * @param event - The event to be freed.
2083
+ * @throws Error if the event is managed by another event boundary.
2084
+ */
2085
+ freeEvent(event) {
2086
+ if (event.manager !== this) throw new Error("It is illegal to free an event not managed by this EventBoundary!");
2087
+ const constructor = event.constructor;
2088
+ if (!this.eventPool.has(constructor)) this.eventPool.set(constructor, []);
2089
+ this.eventPool.get(constructor).push(event);
2090
+ }
2091
+ /**
2092
+ * Similar to {@link EventEmitter.emit}, except it stops if the `propagationImmediatelyStopped` flag
2093
+ * is set on the event.
2094
+ * @param e - The event to call each listener with.
2095
+ * @param type - The event key.
2096
+ */
2097
+ _notifyListeners(e, type) {
2098
+ const listeners = e.currentTarget._events[type];
2099
+ if (!listeners) return;
2100
+ if ("fn" in listeners) {
2101
+ if (listeners.once) e.currentTarget.removeListener(type, listeners.fn, void 0, true);
2102
+ listeners.fn.call(listeners.context, e);
2103
+ } else for (let i = 0, j = listeners.length; i < j && !e.propagationImmediatelyStopped; i++) {
2104
+ if (listeners[i].once) e.currentTarget.removeListener(type, listeners[i].fn, void 0, true);
2105
+ listeners[i].fn.call(listeners[i].context, e);
2106
+ }
2107
+ }
2108
+ };
2109
+ //#endregion
2110
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/events/EventSystem.mjs
2111
+ const MOUSE_POINTER_ID = 1;
2112
+ const TOUCH_TO_POINTER = {
2113
+ touchstart: "pointerdown",
2114
+ touchend: "pointerup",
2115
+ touchendoutside: "pointerupoutside",
2116
+ touchmove: "pointermove",
2117
+ touchcancel: "pointercancel"
2118
+ };
2119
+ const _EventSystem = class _EventSystem {
2120
+ /**
2121
+ * @param {Renderer} renderer
2122
+ */
2123
+ constructor(renderer) {
2124
+ /**
2125
+ * Indicates whether the current device supports touch events according to the W3C Touch Events spec.
2126
+ * This is used to determine the appropriate event handling strategy.
2127
+ * @see {@link https://www.w3.org/TR/touch-events/} W3C Touch Events Specification
2128
+ * @readonly
2129
+ * @default 'ontouchstart' in globalThis
2130
+ */
2131
+ this.supportsTouchEvents = "ontouchstart" in globalThis;
2132
+ /**
2133
+ * Indicates whether the current device supports pointer events according to the W3C Pointer Events spec.
2134
+ * Used to optimize event handling and provide more consistent cross-device interaction.
2135
+ * @see {@link https://www.w3.org/TR/pointerevents/} W3C Pointer Events Specification
2136
+ * @readonly
2137
+ * @default !!globalThis.PointerEvent
2138
+ */
2139
+ this.supportsPointerEvents = !!globalThis.PointerEvent;
2140
+ /**
2141
+ * The DOM element to which the root event listeners are bound. This is automatically set to
2142
+ * the renderer's {@link Renderer#view view}.
2143
+ */
2144
+ this.domElement = null;
2145
+ /** The resolution used to convert between the DOM client space into world space. */
2146
+ this.resolution = 1;
2147
+ this.renderer = renderer;
2148
+ this.rootBoundary = new EventBoundary(null);
2149
+ EventsTicker.init(this);
2150
+ this.autoPreventDefault = true;
2151
+ this._eventsAdded = false;
2152
+ this._rootPointerEvent = new FederatedPointerEvent(null);
2153
+ this._rootWheelEvent = new FederatedWheelEvent(null);
2154
+ this.cursorStyles = {
2155
+ default: "inherit",
2156
+ pointer: "pointer"
2157
+ };
2158
+ this.features = new Proxy({ ..._EventSystem.defaultEventFeatures }, { set: (target, key, value) => {
2159
+ if (key === "globalMove") this.rootBoundary.enableGlobalMoveEvents = value;
2160
+ target[key] = value;
2161
+ return true;
2162
+ } });
2163
+ this._onPointerDown = this._onPointerDown.bind(this);
2164
+ this._onPointerMove = this._onPointerMove.bind(this);
2165
+ this._onPointerUp = this._onPointerUp.bind(this);
2166
+ this._onPointerOverOut = this._onPointerOverOut.bind(this);
2167
+ this.onWheel = this.onWheel.bind(this);
2168
+ }
2169
+ /**
2170
+ * The default interaction mode for all display objects.
2171
+ * @see Container.eventMode
2172
+ * @type {EventMode}
2173
+ * @readonly
2174
+ * @since 7.2.0
2175
+ */
2176
+ static get defaultEventMode() {
2177
+ return this._defaultEventMode;
2178
+ }
2179
+ /**
2180
+ * Runner init called, view is available at this point.
2181
+ * @ignore
2182
+ */
2183
+ init(options) {
2184
+ const { canvas, resolution } = this.renderer;
2185
+ this.setTargetElement(canvas);
2186
+ this.resolution = resolution;
2187
+ _EventSystem._defaultEventMode = options.eventMode ?? "passive";
2188
+ Object.assign(this.features, options.eventFeatures ?? {});
2189
+ this.rootBoundary.enableGlobalMoveEvents = this.features.globalMove;
2190
+ }
2191
+ /**
2192
+ * Handle changing resolution.
2193
+ * @ignore
2194
+ */
2195
+ resolutionChange(resolution) {
2196
+ this.resolution = resolution;
2197
+ }
2198
+ /** Destroys all event listeners and detaches the renderer. */
2199
+ destroy() {
2200
+ EventsTicker.destroy();
2201
+ this.setTargetElement(null);
2202
+ this.renderer = null;
2203
+ this._currentCursor = null;
2204
+ }
2205
+ /**
2206
+ * Sets the current cursor mode, handling any callbacks or CSS style changes.
2207
+ * The cursor can be a CSS cursor string, a custom callback function, or a key from the cursorStyles dictionary.
2208
+ * @param mode - Cursor mode to set. Can be:
2209
+ * - A CSS cursor string (e.g., 'pointer', 'grab')
2210
+ * - A key from the cursorStyles dictionary
2211
+ * - null/undefined to reset to default
2212
+ * @example
2213
+ * ```ts
2214
+ * // Using predefined cursor styles
2215
+ * app.renderer.events.setCursor('pointer'); // Set standard pointer cursor
2216
+ * app.renderer.events.setCursor('grab'); // Set grab cursor
2217
+ * app.renderer.events.setCursor(null); // Reset to default
2218
+ *
2219
+ * // Using custom cursor styles
2220
+ * app.renderer.events.cursorStyles.custom = 'url("cursor.png"), auto';
2221
+ * app.renderer.events.setCursor('custom'); // Apply custom cursor
2222
+ *
2223
+ * // Using callback-based cursor
2224
+ * app.renderer.events.cursorStyles.dynamic = (mode) => {
2225
+ * document.body.style.cursor = mode === 'hover' ? 'pointer' : 'default';
2226
+ * };
2227
+ * app.renderer.events.setCursor('dynamic'); // Trigger cursor callback
2228
+ * ```
2229
+ * @remarks
2230
+ * - Has no effect on OffscreenCanvas except for callback-based cursors
2231
+ * - Caches current cursor to avoid unnecessary DOM updates
2232
+ * - Supports CSS cursor values, style objects, and callback functions
2233
+ * @see {@link EventSystem.cursorStyles} For defining custom cursor styles
2234
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/cursor} MDN Cursor Reference
2235
+ */
2236
+ setCursor(mode) {
2237
+ mode || (mode = "default");
2238
+ let applyStyles = true;
2239
+ if (globalThis.OffscreenCanvas && this.domElement instanceof OffscreenCanvas) applyStyles = false;
2240
+ if (this._currentCursor === mode) return;
2241
+ this._currentCursor = mode;
2242
+ const style = this.cursorStyles[mode];
2243
+ if (style) switch (typeof style) {
2244
+ case "string":
2245
+ if (applyStyles) this.domElement.style.cursor = style;
2246
+ break;
2247
+ case "function":
2248
+ style(mode);
2249
+ break;
2250
+ case "object": if (applyStyles) Object.assign(this.domElement.style, style);
2251
+ }
2252
+ else if (applyStyles && typeof mode === "string" && !Object.prototype.hasOwnProperty.call(this.cursorStyles, mode)) this.domElement.style.cursor = mode;
2253
+ }
2254
+ /**
2255
+ * The global pointer event instance containing the most recent pointer state.
2256
+ * This is useful for accessing pointer information without listening to events.
2257
+ * @example
2258
+ * ```ts
2259
+ * // Access current pointer position at any time
2260
+ * const eventSystem = app.renderer.events;
2261
+ * const pointer = eventSystem.pointer;
2262
+ *
2263
+ * // Get global coordinates
2264
+ * console.log('Position:', pointer.global.x, pointer.global.y);
2265
+ *
2266
+ * // Check button state
2267
+ * console.log('Buttons pressed:', pointer.buttons);
2268
+ *
2269
+ * // Get pointer type and pressure
2270
+ * console.log('Type:', pointer.pointerType);
2271
+ * console.log('Pressure:', pointer.pressure);
2272
+ * ```
2273
+ * @readonly
2274
+ * @since 7.2.0
2275
+ * @see {@link FederatedPointerEvent} For all available pointer properties
2276
+ */
2277
+ get pointer() {
2278
+ return this._rootPointerEvent;
2279
+ }
2280
+ /**
2281
+ * Event handler for pointer down events on {@link EventSystem#domElement this.domElement}.
2282
+ * @param nativeEvent - The native mouse/pointer/touch event.
2283
+ */
2284
+ _onPointerDown(nativeEvent) {
2285
+ if (!this.features.click) return;
2286
+ this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
2287
+ const events = this._normalizeToPointerData(nativeEvent);
2288
+ if (this.autoPreventDefault && events[0].isNormalized) {
2289
+ if (nativeEvent.cancelable || !("cancelable" in nativeEvent)) nativeEvent.preventDefault();
2290
+ }
2291
+ for (let i = 0, j = events.length; i < j; i++) {
2292
+ const nativeEvent2 = events[i];
2293
+ const federatedEvent = this._bootstrapEvent(this._rootPointerEvent, nativeEvent2);
2294
+ this.rootBoundary.mapEvent(federatedEvent);
2295
+ }
2296
+ this.setCursor(this.rootBoundary.cursor);
2297
+ }
2298
+ /**
2299
+ * Event handler for pointer move events on on {@link EventSystem#domElement this.domElement}.
2300
+ * @param nativeEvent - The native mouse/pointer/touch events.
2301
+ */
2302
+ _onPointerMove(nativeEvent) {
2303
+ if (!this.features.move) return;
2304
+ this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
2305
+ EventsTicker.pointerMoved();
2306
+ const normalizedEvents = this._normalizeToPointerData(nativeEvent);
2307
+ for (let i = 0, j = normalizedEvents.length; i < j; i++) {
2308
+ const event = this._bootstrapEvent(this._rootPointerEvent, normalizedEvents[i]);
2309
+ this.rootBoundary.mapEvent(event);
2310
+ }
2311
+ this.setCursor(this.rootBoundary.cursor);
2312
+ }
2313
+ /**
2314
+ * Event handler for pointer up events on {@link EventSystem#domElement this.domElement}.
2315
+ * @param nativeEvent - The native mouse/pointer/touch event.
2316
+ */
2317
+ _onPointerUp(nativeEvent) {
2318
+ if (!this.features.click) return;
2319
+ this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
2320
+ let target = nativeEvent.target;
2321
+ if (nativeEvent.composedPath && nativeEvent.composedPath().length > 0) target = nativeEvent.composedPath()[0];
2322
+ const outside = target !== this.domElement ? "outside" : "";
2323
+ const normalizedEvents = this._normalizeToPointerData(nativeEvent);
2324
+ for (let i = 0, j = normalizedEvents.length; i < j; i++) {
2325
+ const event = this._bootstrapEvent(this._rootPointerEvent, normalizedEvents[i]);
2326
+ event.type += outside;
2327
+ this.rootBoundary.mapEvent(event);
2328
+ }
2329
+ this.setCursor(this.rootBoundary.cursor);
2330
+ }
2331
+ /**
2332
+ * Event handler for pointer over & out events on {@link EventSystem#domElement this.domElement}.
2333
+ * @param nativeEvent - The native mouse/pointer/touch event.
2334
+ */
2335
+ _onPointerOverOut(nativeEvent) {
2336
+ if (!this.features.click) return;
2337
+ this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
2338
+ const normalizedEvents = this._normalizeToPointerData(nativeEvent);
2339
+ for (let i = 0, j = normalizedEvents.length; i < j; i++) {
2340
+ const event = this._bootstrapEvent(this._rootPointerEvent, normalizedEvents[i]);
2341
+ this.rootBoundary.mapEvent(event);
2342
+ }
2343
+ this.setCursor(this.rootBoundary.cursor);
2344
+ }
2345
+ /**
2346
+ * Passive handler for `wheel` events on {@link EventSystem.domElement this.domElement}.
2347
+ * @param nativeEvent - The native wheel event.
2348
+ */
2349
+ onWheel(nativeEvent) {
2350
+ if (!this.features.wheel) return;
2351
+ const wheelEvent = this.normalizeWheelEvent(nativeEvent);
2352
+ this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
2353
+ this.rootBoundary.mapEvent(wheelEvent);
2354
+ }
2355
+ /**
2356
+ * Sets the {@link EventSystem#domElement domElement} and binds event listeners.
2357
+ * This method manages the DOM event bindings for the event system, allowing you to
2358
+ * change or remove the target element that receives input events.
2359
+ * > [!IMPORTANT] This will default to the canvas element of the renderer, so you
2360
+ * > should not need to call this unless you are using a custom element.
2361
+ * @param element - The new DOM element to bind events to, or null to remove all event bindings
2362
+ * @example
2363
+ * ```ts
2364
+ * // Set a new canvas element as the target
2365
+ * const canvas = document.createElement('canvas');
2366
+ * app.renderer.events.setTargetElement(canvas);
2367
+ *
2368
+ * // Remove all event bindings
2369
+ * app.renderer.events.setTargetElement(null);
2370
+ *
2371
+ * // Switch to a different canvas
2372
+ * const newCanvas = document.querySelector('#game-canvas');
2373
+ * app.renderer.events.setTargetElement(newCanvas);
2374
+ * ```
2375
+ * @remarks
2376
+ * - Automatically removes event listeners from previous element
2377
+ * - Required for the event system to function
2378
+ * - Safe to call multiple times
2379
+ * @see {@link EventSystem#domElement} The current DOM element
2380
+ * @see {@link EventsTicker} For the ticker system that tracks pointer movement
2381
+ */
2382
+ setTargetElement(element) {
2383
+ this._removeEvents();
2384
+ this.domElement = element;
2385
+ EventsTicker.domElement = element;
2386
+ this._addEvents();
2387
+ }
2388
+ /** Register event listeners on {@link Renderer#domElement this.domElement}. */
2389
+ _addEvents() {
2390
+ if (this._eventsAdded || !this.domElement) return;
2391
+ EventsTicker.addTickerListener();
2392
+ const style = this.domElement.style;
2393
+ if (style) {
2394
+ if (globalThis.navigator.msPointerEnabled) {
2395
+ style.msContentZooming = "none";
2396
+ style.msTouchAction = "none";
2397
+ } else if (this.supportsPointerEvents) style.touchAction = "none";
2398
+ }
2399
+ if (this.supportsPointerEvents) {
2400
+ globalThis.document.addEventListener("pointermove", this._onPointerMove, true);
2401
+ this.domElement.addEventListener("pointerdown", this._onPointerDown, true);
2402
+ this.domElement.addEventListener("pointerleave", this._onPointerOverOut, true);
2403
+ this.domElement.addEventListener("pointerover", this._onPointerOverOut, true);
2404
+ globalThis.addEventListener("pointerup", this._onPointerUp, true);
2405
+ } else {
2406
+ globalThis.document.addEventListener("mousemove", this._onPointerMove, true);
2407
+ this.domElement.addEventListener("mousedown", this._onPointerDown, true);
2408
+ this.domElement.addEventListener("mouseout", this._onPointerOverOut, true);
2409
+ this.domElement.addEventListener("mouseover", this._onPointerOverOut, true);
2410
+ globalThis.addEventListener("mouseup", this._onPointerUp, true);
2411
+ if (this.supportsTouchEvents) {
2412
+ this.domElement.addEventListener("touchstart", this._onPointerDown, true);
2413
+ this.domElement.addEventListener("touchend", this._onPointerUp, true);
2414
+ this.domElement.addEventListener("touchmove", this._onPointerMove, true);
2415
+ }
2416
+ }
2417
+ this.domElement.addEventListener("wheel", this.onWheel, {
2418
+ passive: true,
2419
+ capture: true
2420
+ });
2421
+ this._eventsAdded = true;
2422
+ }
2423
+ /** Unregister event listeners on {@link EventSystem#domElement this.domElement}. */
2424
+ _removeEvents() {
2425
+ if (!this._eventsAdded || !this.domElement) return;
2426
+ EventsTicker.removeTickerListener();
2427
+ const style = this.domElement.style;
2428
+ if (style) {
2429
+ if (globalThis.navigator.msPointerEnabled) {
2430
+ style.msContentZooming = "";
2431
+ style.msTouchAction = "";
2432
+ } else if (this.supportsPointerEvents) style.touchAction = "";
2433
+ }
2434
+ if (this.supportsPointerEvents) {
2435
+ globalThis.document.removeEventListener("pointermove", this._onPointerMove, true);
2436
+ this.domElement.removeEventListener("pointerdown", this._onPointerDown, true);
2437
+ this.domElement.removeEventListener("pointerleave", this._onPointerOverOut, true);
2438
+ this.domElement.removeEventListener("pointerover", this._onPointerOverOut, true);
2439
+ globalThis.removeEventListener("pointerup", this._onPointerUp, true);
2440
+ } else {
2441
+ globalThis.document.removeEventListener("mousemove", this._onPointerMove, true);
2442
+ this.domElement.removeEventListener("mousedown", this._onPointerDown, true);
2443
+ this.domElement.removeEventListener("mouseout", this._onPointerOverOut, true);
2444
+ this.domElement.removeEventListener("mouseover", this._onPointerOverOut, true);
2445
+ globalThis.removeEventListener("mouseup", this._onPointerUp, true);
2446
+ if (this.supportsTouchEvents) {
2447
+ this.domElement.removeEventListener("touchstart", this._onPointerDown, true);
2448
+ this.domElement.removeEventListener("touchend", this._onPointerUp, true);
2449
+ this.domElement.removeEventListener("touchmove", this._onPointerMove, true);
2450
+ }
2451
+ }
2452
+ this.domElement.removeEventListener("wheel", this.onWheel, true);
2453
+ this.domElement = null;
2454
+ this._eventsAdded = false;
2455
+ }
2456
+ /**
2457
+ * Maps coordinates from DOM/screen space into PixiJS normalized coordinates.
2458
+ * This takes into account the current scale, position, and resolution of the DOM element.
2459
+ * @param point - The point to store the mapped coordinates in
2460
+ * @param x - The x coordinate in DOM/client space
2461
+ * @param y - The y coordinate in DOM/client space
2462
+ * @example
2463
+ * ```ts
2464
+ * // Map mouse coordinates to PixiJS space
2465
+ * const point = new Point();
2466
+ * app.renderer.events.mapPositionToPoint(
2467
+ * point,
2468
+ * event.clientX,
2469
+ * event.clientY
2470
+ * );
2471
+ * console.log('Mapped position:', point.x, point.y);
2472
+ *
2473
+ * // Using with pointer events
2474
+ * sprite.on('pointermove', (event) => {
2475
+ * // event.global already contains mapped coordinates
2476
+ * console.log('Global:', event.global.x, event.global.y);
2477
+ *
2478
+ * // Map to local coordinates
2479
+ * const local = event.getLocalPosition(sprite);
2480
+ * console.log('Local:', local.x, local.y);
2481
+ * });
2482
+ * ```
2483
+ * @remarks
2484
+ * - Accounts for element scaling and positioning
2485
+ * - Adjusts for device pixel ratio/resolution
2486
+ */
2487
+ mapPositionToPoint(point, x, y) {
2488
+ const rect = this.domElement.isConnected ? this.domElement.getBoundingClientRect() : {
2489
+ x: 0,
2490
+ y: 0,
2491
+ width: this.domElement.width,
2492
+ height: this.domElement.height,
2493
+ left: 0,
2494
+ top: 0
2495
+ };
2496
+ const resolutionMultiplier = 1 / this.resolution;
2497
+ point.x = (x - rect.left) * (this.domElement.width / rect.width) * resolutionMultiplier;
2498
+ point.y = (y - rect.top) * (this.domElement.height / rect.height) * resolutionMultiplier;
2499
+ }
2500
+ /**
2501
+ * Ensures that the original event object contains all data that a regular pointer event would have
2502
+ * @param event - The original event data from a touch or mouse event
2503
+ * @returns An array containing a single normalized pointer event, in the case of a pointer
2504
+ * or mouse event, or a multiple normalized pointer events if there are multiple changed touches
2505
+ */
2506
+ _normalizeToPointerData(event) {
2507
+ const normalizedEvents = [];
2508
+ if (this.supportsTouchEvents && event instanceof TouchEvent) for (let i = 0, li = event.changedTouches.length; i < li; i++) {
2509
+ const touch = event.changedTouches[i];
2510
+ if (typeof touch.button === "undefined") touch.button = 0;
2511
+ if (typeof touch.buttons === "undefined") touch.buttons = 1;
2512
+ if (typeof touch.isPrimary === "undefined") touch.isPrimary = event.touches.length === 1 && event.type === "touchstart";
2513
+ if (typeof touch.width === "undefined") touch.width = touch.radiusX || 1;
2514
+ if (typeof touch.height === "undefined") touch.height = touch.radiusY || 1;
2515
+ if (typeof touch.tiltX === "undefined") touch.tiltX = 0;
2516
+ if (typeof touch.tiltY === "undefined") touch.tiltY = 0;
2517
+ if (typeof touch.pointerType === "undefined") touch.pointerType = "touch";
2518
+ if (typeof touch.pointerId === "undefined") touch.pointerId = touch.identifier || 0;
2519
+ if (typeof touch.pressure === "undefined") touch.pressure = touch.force || .5;
2520
+ if (typeof touch.twist === "undefined") touch.twist = 0;
2521
+ if (typeof touch.tangentialPressure === "undefined") touch.tangentialPressure = 0;
2522
+ if (typeof touch.layerX === "undefined") touch.layerX = touch.offsetX = touch.clientX;
2523
+ if (typeof touch.layerY === "undefined") touch.layerY = touch.offsetY = touch.clientY;
2524
+ touch.isNormalized = true;
2525
+ touch.type = event.type;
2526
+ touch.altKey ?? (touch.altKey = event.altKey);
2527
+ touch.ctrlKey ?? (touch.ctrlKey = event.ctrlKey);
2528
+ touch.metaKey ?? (touch.metaKey = event.metaKey);
2529
+ touch.shiftKey ?? (touch.shiftKey = event.shiftKey);
2530
+ normalizedEvents.push(touch);
2531
+ }
2532
+ else if (!globalThis.MouseEvent || event instanceof MouseEvent && (!this.supportsPointerEvents || !(event instanceof globalThis.PointerEvent))) {
2533
+ const tempEvent = event;
2534
+ if (typeof tempEvent.isPrimary === "undefined") tempEvent.isPrimary = true;
2535
+ if (typeof tempEvent.width === "undefined") tempEvent.width = 1;
2536
+ if (typeof tempEvent.height === "undefined") tempEvent.height = 1;
2537
+ if (typeof tempEvent.tiltX === "undefined") tempEvent.tiltX = 0;
2538
+ if (typeof tempEvent.tiltY === "undefined") tempEvent.tiltY = 0;
2539
+ if (typeof tempEvent.pointerType === "undefined") tempEvent.pointerType = "mouse";
2540
+ if (typeof tempEvent.pointerId === "undefined") tempEvent.pointerId = MOUSE_POINTER_ID;
2541
+ if (typeof tempEvent.pressure === "undefined") tempEvent.pressure = .5;
2542
+ if (typeof tempEvent.twist === "undefined") tempEvent.twist = 0;
2543
+ if (typeof tempEvent.tangentialPressure === "undefined") tempEvent.tangentialPressure = 0;
2544
+ tempEvent.isNormalized = true;
2545
+ normalizedEvents.push(tempEvent);
2546
+ } else normalizedEvents.push(event);
2547
+ return normalizedEvents;
2548
+ }
2549
+ /**
2550
+ * Normalizes the native {@link https://w3c.github.io/uievents/#interface-wheelevent WheelEvent}.
2551
+ *
2552
+ * The returned {@link FederatedWheelEvent} is a shared instance. It will not persist across
2553
+ * multiple native wheel events.
2554
+ * @param nativeEvent - The native wheel event that occurred on the canvas.
2555
+ * @returns A federated wheel event.
2556
+ */
2557
+ normalizeWheelEvent(nativeEvent) {
2558
+ const event = this._rootWheelEvent;
2559
+ this._transferMouseData(event, nativeEvent);
2560
+ event.deltaX = nativeEvent.deltaX;
2561
+ event.deltaY = nativeEvent.deltaY;
2562
+ event.deltaZ = nativeEvent.deltaZ;
2563
+ event.deltaMode = nativeEvent.deltaMode;
2564
+ this.mapPositionToPoint(event.screen, nativeEvent.clientX, nativeEvent.clientY);
2565
+ event.global.copyFrom(event.screen);
2566
+ event.offset.copyFrom(event.screen);
2567
+ event.nativeEvent = nativeEvent;
2568
+ event.type = nativeEvent.type;
2569
+ return event;
2570
+ }
2571
+ /**
2572
+ * Normalizes the `nativeEvent` into a federateed {@link FederatedPointerEvent}.
2573
+ * @param event
2574
+ * @param nativeEvent
2575
+ */
2576
+ _bootstrapEvent(event, nativeEvent) {
2577
+ event.originalEvent = null;
2578
+ event.nativeEvent = nativeEvent;
2579
+ event.pointerId = nativeEvent.pointerId;
2580
+ event.width = nativeEvent.width;
2581
+ event.height = nativeEvent.height;
2582
+ event.isPrimary = nativeEvent.isPrimary;
2583
+ event.pointerType = nativeEvent.pointerType;
2584
+ event.pressure = nativeEvent.pressure;
2585
+ event.tangentialPressure = nativeEvent.tangentialPressure;
2586
+ event.tiltX = nativeEvent.tiltX;
2587
+ event.tiltY = nativeEvent.tiltY;
2588
+ event.twist = nativeEvent.twist;
2589
+ this._transferMouseData(event, nativeEvent);
2590
+ this.mapPositionToPoint(event.screen, nativeEvent.clientX, nativeEvent.clientY);
2591
+ event.global.copyFrom(event.screen);
2592
+ event.offset.copyFrom(event.screen);
2593
+ event.isTrusted = nativeEvent.isTrusted;
2594
+ if (event.type === "pointerleave") event.type = "pointerout";
2595
+ if (event.type.startsWith("mouse")) event.type = event.type.replace("mouse", "pointer");
2596
+ if (event.type.startsWith("touch")) event.type = TOUCH_TO_POINTER[event.type] || event.type;
2597
+ return event;
2598
+ }
2599
+ /**
2600
+ * Transfers base & mouse event data from the `nativeEvent` to the federated event.
2601
+ * @param event
2602
+ * @param nativeEvent
2603
+ */
2604
+ _transferMouseData(event, nativeEvent) {
2605
+ event.isTrusted = nativeEvent.isTrusted;
2606
+ event.srcElement = nativeEvent.srcElement;
2607
+ event.timeStamp = performance.now();
2608
+ event.type = nativeEvent.type;
2609
+ event.altKey = nativeEvent.altKey;
2610
+ event.button = nativeEvent.button;
2611
+ event.buttons = nativeEvent.buttons;
2612
+ event.client.x = nativeEvent.clientX;
2613
+ event.client.y = nativeEvent.clientY;
2614
+ event.ctrlKey = nativeEvent.ctrlKey;
2615
+ event.metaKey = nativeEvent.metaKey;
2616
+ event.movement.x = nativeEvent.movementX;
2617
+ event.movement.y = nativeEvent.movementY;
2618
+ event.page.x = nativeEvent.pageX;
2619
+ event.page.y = nativeEvent.pageY;
2620
+ event.relatedTarget = null;
2621
+ event.shiftKey = nativeEvent.shiftKey;
2622
+ }
2623
+ };
2624
+ /** @ignore */
2625
+ _EventSystem.extension = {
2626
+ name: "events",
2627
+ type: [
2628
+ ExtensionType.WebGLSystem,
2629
+ ExtensionType.CanvasSystem,
2630
+ ExtensionType.WebGPUSystem
2631
+ ],
2632
+ priority: -1
2633
+ };
2634
+ /**
2635
+ * The event features that are enabled by the EventSystem
2636
+ * @since 7.2.0
2637
+ * @example
2638
+ * ```ts
2639
+ * import { EventSystem, EventSystemFeatures } from 'pixi.js';
2640
+ * // Access the default event features
2641
+ * EventSystem.defaultEventFeatures = {
2642
+ * // Enable pointer movement events
2643
+ * move: true,
2644
+ * // Enable global pointer move events
2645
+ * globalMove: true,
2646
+ * // Enable click events
2647
+ * click: true,
2648
+ * // Enable wheel events
2649
+ * wheel: true,
2650
+ * };
2651
+ * ```
2652
+ */
2653
+ _EventSystem.defaultEventFeatures = {
2654
+ /** Enables pointer events associated with pointer movement. */
2655
+ move: true,
2656
+ /** Enables global pointer move events. */
2657
+ globalMove: true,
2658
+ /** Enables pointer events associated with clicking. */
2659
+ click: true,
2660
+ /** Enables wheel events. */
2661
+ wheel: true
2662
+ };
2663
+ let EventSystem = _EventSystem;
2664
+ //#endregion
2665
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/events/FederatedEventTarget.mjs
2666
+ const FederatedContainer = {
2667
+ onclick: null,
2668
+ onmousedown: null,
2669
+ onmouseenter: null,
2670
+ onmouseleave: null,
2671
+ onmousemove: null,
2672
+ onglobalmousemove: null,
2673
+ onmouseout: null,
2674
+ onmouseover: null,
2675
+ onmouseup: null,
2676
+ onmouseupoutside: null,
2677
+ onpointercancel: null,
2678
+ onpointerdown: null,
2679
+ onpointerenter: null,
2680
+ onpointerleave: null,
2681
+ onpointermove: null,
2682
+ onglobalpointermove: null,
2683
+ onpointerout: null,
2684
+ onpointerover: null,
2685
+ onpointertap: null,
2686
+ onpointerup: null,
2687
+ onpointerupoutside: null,
2688
+ onrightclick: null,
2689
+ onrightdown: null,
2690
+ onrightup: null,
2691
+ onrightupoutside: null,
2692
+ ontap: null,
2693
+ ontouchcancel: null,
2694
+ ontouchend: null,
2695
+ ontouchendoutside: null,
2696
+ ontouchmove: null,
2697
+ onglobaltouchmove: null,
2698
+ ontouchstart: null,
2699
+ onwheel: null,
2700
+ get interactive() {
2701
+ return this.eventMode === "dynamic" || this.eventMode === "static";
2702
+ },
2703
+ set interactive(value) {
2704
+ this.eventMode = value ? "static" : "passive";
2705
+ },
2706
+ _internalEventMode: void 0,
2707
+ get eventMode() {
2708
+ return this._internalEventMode ?? EventSystem.defaultEventMode;
2709
+ },
2710
+ set eventMode(value) {
2711
+ this._internalEventMode = value;
2712
+ },
2713
+ isInteractive() {
2714
+ return this.eventMode === "static" || this.eventMode === "dynamic";
2715
+ },
2716
+ interactiveChildren: true,
2717
+ hitArea: null,
2718
+ addEventListener(type, listener, options) {
2719
+ const capture = typeof options === "boolean" && options || typeof options === "object" && options.capture;
2720
+ const signal = typeof options === "object" ? options.signal : void 0;
2721
+ const once = typeof options === "object" ? options.once === true : false;
2722
+ const context = typeof listener === "function" ? void 0 : listener;
2723
+ type = capture ? `${type}capture` : type;
2724
+ const listenerFn = typeof listener === "function" ? listener : listener.handleEvent;
2725
+ const emitter = this;
2726
+ if (signal) signal.addEventListener("abort", () => {
2727
+ emitter.off(type, listenerFn, context);
2728
+ });
2729
+ if (once) emitter.once(type, listenerFn, context);
2730
+ else emitter.on(type, listenerFn, context);
2731
+ },
2732
+ removeEventListener(type, listener, options) {
2733
+ const capture = typeof options === "boolean" && options || typeof options === "object" && options.capture;
2734
+ const context = typeof listener === "function" ? void 0 : listener;
2735
+ type = capture ? `${type}capture` : type;
2736
+ listener = typeof listener === "function" ? listener : listener.handleEvent;
2737
+ this.off(type, listener, context);
2738
+ },
2739
+ dispatchEvent(e) {
2740
+ if (!(e instanceof FederatedEvent)) throw new Error("Container cannot propagate events outside of the Federated Events API");
2741
+ e.defaultPrevented = false;
2742
+ e.path = null;
2743
+ e.target = this;
2744
+ e.manager.dispatchEvent(e);
2745
+ return !e.defaultPrevented;
2746
+ }
2747
+ };
2748
+ //#endregion
2749
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/accessibility/init.mjs
2750
+ extensions.add(AccessibilitySystem);
2751
+ extensions.mixin(Container, accessibilityTarget);
2752
+ //#endregion
2753
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/dom/init.mjs
2754
+ extensions.add(DOMPipe);
2755
+ //#endregion
2756
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/events/init.mjs
2757
+ extensions.add(EventSystem);
2758
+ extensions.mixin(Container, FederatedContainer);
2759
+ //#endregion
2760
+ export {};