@eva/plugin-worker 2.0.0-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/EVA.plugin.worker.js +1326 -0
- package/dist/EVA.plugin.worker.min.js +1 -0
- package/dist/plugin-worker.cjs.js +1202 -0
- package/dist/plugin-worker.cjs.prod.js +1 -0
- package/dist/plugin-worker.d.ts +4 -0
- package/dist/plugin-worker.esm.js +1194 -0
- package/index.js +7 -0
- package/package.json +25 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function _extends(){return _extends=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},_extends.apply(null,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{};var _EVA_IIFE_worker=function(t,e){"use strict";var n,i,o=(n=function(t){var e=Object.prototype.hasOwnProperty,n="~";function i(){}function o(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function r(t,e,i,r,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var a=new o(i,r||t,s),h=n?n+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],a]:t._events[h].push(a):(t._events[h]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}function a(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),a.prototype.eventNames=function(){var t,i,o=[];if(0===this._eventsCount)return o;for(i in t=this._events)e.call(t,i)&&o.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},a.prototype.listeners=function(t){var e=n?n+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var o=0,r=i.length,s=new Array(r);o<r;o++)s[o]=i[o].fn;return s},a.prototype.listenerCount=function(t){var e=n?n+t:t,i=this._events[e];return i?i.fn?1:i.length:0},a.prototype.emit=function(t,e,i,o,r,s){var a=n?n+t:t;if(!this._events[a])return!1;var h,p,l=this._events[a],c=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),c){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,i),!0;case 4:return l.fn.call(l.context,e,i,o),!0;case 5:return l.fn.call(l.context,e,i,o,r),!0;case 6:return l.fn.call(l.context,e,i,o,r,s),!0}for(p=1,h=new Array(c-1);p<c;p++)h[p-1]=arguments[p];l.fn.apply(l.context,h)}else{var u,v=l.length;for(p=0;p<v;p++)switch(l[p].once&&this.removeListener(t,l[p].fn,void 0,!0),c){case 1:l[p].fn.call(l[p].context);break;case 2:l[p].fn.call(l[p].context,e);break;case 3:l[p].fn.call(l[p].context,e,i);break;case 4:l[p].fn.call(l[p].context,e,i,o);break;default:if(!h)for(u=1,h=new Array(c-1);u<c;u++)h[u-1]=arguments[u];l[p].fn.apply(l[p].context,h)}}return!0},a.prototype.on=function(t,e,n){return r(this,t,e,n,!1)},a.prototype.once=function(t,e,n){return r(this,t,e,n,!0)},a.prototype.removeListener=function(t,e,i,o){var r=n?n+t:t;if(!this._events[r])return this;if(!e)return s(this,r),this;var a=this._events[r];if(a.fn)a.fn!==e||o&&!a.once||i&&a.context!==i||s(this,r);else{for(var h=0,p=[],l=a.length;h<l;h++)(a[h].fn!==e||o&&!a[h].once||i&&a[h].context!==i)&&p.push(a[h]);p.length?this._events[r]=1===p.length?p[0]:p:s(this,r)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&s(this,e)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,t.exports=a},n(i={exports:{}},i.exports),i.exports),r=o;const s=new class{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){!this._tickerAdded&&this.domElement&&(e.Ticker.system.add(this._tickerUpdate,this,e.UPDATE_PRIORITY.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(e.Ticker.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove)return void(this._didMove=!1);const t=this.events._rootPointerEvent;this.events.supportsTouchEvents&&"touch"===t.pointerType||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType,pointerId:t.pointerId}))}_tickerUpdate(t){this._deltaTime+=t.deltaTime,this._deltaTime<this.interactionFrequency||(this._deltaTime=0,this._update())}};class a{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=a.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new e.Point,this.page=new e.Point,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return!this.manager||this.path&&this.path[this.path.length-1]===this.target||(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,n){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,n,i,o){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class h extends a{constructor(){super(...arguments),this.client=new e.Point,this.movement=new e.Point,this.offset=new e.Point,this.global=new e.Point,this.screen=new e.Point}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,n){return t.worldTransform.applyInverse(n||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,n,i,o,r,s,a,h,p,l,c,u,v,d){throw new Error("Method not implemented.")}}class p extends h{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return"pointermove"===this.type||"mousemove"===this.type||"touchmove"===this.type?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class l extends h{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}l.DOM_DELTA_PIXEL=0,l.DOM_DELTA_LINE=1,l.DOM_DELTA_PAGE=2;const c=new e.Point,u=new e.Point;class v{constructor(t){this.dispatch=new r,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort(((t,e)=>t.priority-e.priority))}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const n=this.mappingTable[t.type];if(n)for(let e=0,i=n.length;e<i;e++)n[e].fn(t);else e.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){s.pauseUpdate=!0;const n=this[this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive"](this.rootTarget,this.rootTarget.eventMode,c.set(t,e),this.hitTestFn,this.hitPruneFn);return n&&n[0]}propagate(t,e){if(!t.target)return;const n=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let i=0,o=n.length-1;i<o;i++)if(t.currentTarget=n[i],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!t.propagationStopped&&!t.propagationImmediatelyStopped){t.eventPhase=t.BUBBLING_PHASE;for(let i=n.length-2;i>=0;i--)if(t.currentTarget=n[i],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,n=this._allInteractiveElements){if(0===n.length)return;t.eventPhase=t.BUBBLING_PHASE;const i=Array.isArray(e)?e:[e];for(let e=n.length-1;e>=0;e--)i.forEach((i=>{t.currentTarget=n[e],this.notifyTarget(t,i)}))}propagationPath(t){const e=[t];for(let n=0;n<2048&&t!==this.rootTarget&&t.parent;n++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,n,i,o,r=!1){let a=!1;if(this._interactivePrune(t))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||(s.pauseUpdate=!1),t.interactiveChildren&&t.children){const s=t.children;for(let h=s.length-1;h>=0;h--){const p=s[h],l=this.hitTestMoveRecursive(p,this._isInteractive(e)?e:p.eventMode,n,i,o,r||o(t,n));if(l){if(l.length>0&&!l[l.length-1].parent)continue;const e=t.isInteractive();(l.length>0||e)&&(e&&this._allInteractiveElements.push(t),l.push(t)),0===this._hitElements.length&&(this._hitElements=l),a=!0}}}const h=this._isInteractive(e),p=t.isInteractive();return p&&p&&this._allInteractiveElements.push(t),r||this._hitElements.length>0?null:a?this._hitElements:h&&!o(t,n)&&i(t,n)?p?[t]:[]:null}hitTestRecursive(t,e,n,i,o){if(this._interactivePrune(t)||o(t,n))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||(s.pauseUpdate=!1),t.interactiveChildren&&t.children){const r=t.children,s=n;for(let n=r.length-1;n>=0;n--){const a=r[n],h=this.hitTestRecursive(a,this._isInteractive(e)?e:a.eventMode,s,i,o);if(h){if(h.length>0&&!h[h.length-1].parent)continue;const e=t.isInteractive();return(h.length>0||e)&&h.push(t),h}}}const r=this._isInteractive(e),a=t.isInteractive();return r&&i(t,n)?a?[t]:[]:null}_isInteractive(t){return"static"===t||"dynamic"===t}_interactivePrune(t){return!(t&&t.visible&&t.renderable&&t.measurable)||("none"===t.eventMode||"passive"===t.eventMode&&!t.interactiveChildren)}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,u),!t.hitArea.contains(u.x,u.y)))return!0;if(t.effects&&t.effects.length)for(let n=0;n<t.effects.length;n++){const i=t.effects[n];if(i.containsPoint){if(!i.containsPoint(e,this.hitTestFn))return!0}}return!1}hitTestFn(t,e){var n;return!!t.hitArea||!!(null===(n=t)||void 0===n?void 0:n.containsPoint)&&(t.worldTransform.applyInverse(e,u),t.containsPoint(u))}notifyTarget(t,e){var n;if(!t.currentTarget.isInteractive())return;const i=`on${e=null!=e?e:t.type}`;null===(n=t.currentTarget[i])||void 0===n||n(t);const o=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this._notifyListeners(t,o),t.eventPhase===t.AT_TARGET&&this._notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof p))return void e.warn("EventBoundary cannot map a non-pointer event as a pointer event");const n=this.createPointerEvent(t);if(this.dispatchEvent(n,"pointerdown"),"touch"===n.pointerType)this.dispatchEvent(n,"touchstart");else if("mouse"===n.pointerType||"pen"===n.pointerType){const t=2===n.button;this.dispatchEvent(n,t?"rightdown":"mousedown")}this.trackingData(t.pointerId).pressTargetsByButton[t.button]=n.composedPath(),this.freeEvent(n)}mapPointerMove(t){var n,i,o;if(!(t instanceof p))return void e.warn("EventBoundary cannot map a non-pointer event as a pointer event");this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const r=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const s="mouse"===r.pointerType||"pen"===r.pointerType,a=this.trackingData(t.pointerId),h=this.findMountedTarget(a.overTargets);if((null===(n=a.overTargets)||void 0===n?void 0:n.length)>0&&h!==r.target){const e="mousemove"===t.type?"mouseout":"pointerout",n=this.createPointerEvent(t,e,h);if(this.dispatchEvent(n,"pointerout"),s&&this.dispatchEvent(n,"mouseout"),!r.composedPath().includes(h)){const e=this.createPointerEvent(t,"pointerleave",h);for(e.eventPhase=e.AT_TARGET;e.target&&!r.composedPath().includes(e.target);)e.currentTarget=e.target,this.notifyTarget(e),s&&this.notifyTarget(e,"mouseleave"),e.target=e.target.parent;this.freeEvent(e)}this.freeEvent(n)}if(h!==r.target){const e="mousemove"===t.type?"mouseover":"pointerover",n=this.clonePointerEvent(r,e);this.dispatchEvent(n,"pointerover"),s&&this.dispatchEvent(n,"mouseover");let i=null==h?void 0:h.parent;for(;i&&i!==this.rootTarget.parent&&i!==r.target;)i=i.parent;if(!i||i===this.rootTarget.parent){const t=this.clonePointerEvent(r,"pointerenter");for(t.eventPhase=t.AT_TARGET;t.target&&t.target!==h&&t.target!==this.rootTarget.parent;)t.currentTarget=t.target,this.notifyTarget(t),s&&this.notifyTarget(t,"mouseenter"),t.target=t.target.parent;this.freeEvent(t)}this.freeEvent(n)}const l=[],c=null===(i=this.enableGlobalMoveEvents)||void 0===i||i;this.moveOnAll?l.push("pointermove"):this.dispatchEvent(r,"pointermove"),c&&l.push("globalpointermove"),"touch"===r.pointerType&&(this.moveOnAll?l.splice(1,0,"touchmove"):this.dispatchEvent(r,"touchmove"),c&&l.push("globaltouchmove")),s&&(this.moveOnAll?l.splice(1,0,"mousemove"):this.dispatchEvent(r,"mousemove"),c&&l.push("globalmousemove"),this.cursor=null===(o=r.target)||void 0===o?void 0:o.cursor),l.length>0&&this.all(r,l),this._allInteractiveElements.length=0,this._hitElements.length=0,a.overTargets=r.composedPath(),this.freeEvent(r)}mapPointerOver(t){var n;if(!(t instanceof p))return void e.warn("EventBoundary cannot map a non-pointer event as a pointer event");const i=this.trackingData(t.pointerId),o=this.createPointerEvent(t),r="mouse"===o.pointerType||"pen"===o.pointerType;this.dispatchEvent(o,"pointerover"),r&&this.dispatchEvent(o,"mouseover"),"mouse"===o.pointerType&&(this.cursor=null===(n=o.target)||void 0===n?void 0:n.cursor);const s=this.clonePointerEvent(o,"pointerenter");for(s.eventPhase=s.AT_TARGET;s.target&&s.target!==this.rootTarget.parent;)s.currentTarget=s.target,this.notifyTarget(s),r&&this.notifyTarget(s,"mouseenter"),s.target=s.target.parent;i.overTargets=o.composedPath(),this.freeEvent(o),this.freeEvent(s)}mapPointerOut(t){if(!(t instanceof p))return void e.warn("EventBoundary cannot map a non-pointer event as a pointer event");const n=this.trackingData(t.pointerId);if(n.overTargets){const e="mouse"===t.pointerType||"pen"===t.pointerType,i=this.findMountedTarget(n.overTargets),o=this.createPointerEvent(t,"pointerout",i);this.dispatchEvent(o),e&&this.dispatchEvent(o,"mouseout");const r=this.createPointerEvent(t,"pointerleave",i);for(r.eventPhase=r.AT_TARGET;r.target&&r.target!==this.rootTarget.parent;)r.currentTarget=r.target,this.notifyTarget(r),e&&this.notifyTarget(r,"mouseleave"),r.target=r.target.parent;n.overTargets=null,this.freeEvent(o),this.freeEvent(r)}this.cursor=null}mapPointerUp(t){if(!(t instanceof p))return void e.warn("EventBoundary cannot map a non-pointer event as a pointer event");const n=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),"touch"===i.pointerType)this.dispatchEvent(i,"touchend");else if("mouse"===i.pointerType||"pen"===i.pointerType){const t=2===i.button;this.dispatchEvent(i,t?"rightup":"mouseup")}const o=this.trackingData(t.pointerId),r=this.findMountedTarget(o.pressTargetsByButton[t.button]);let s=r;if(r&&!i.composedPath().includes(r)){let e=r;for(;e&&!i.composedPath().includes(e);){if(i.currentTarget=e,this.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType)this.notifyTarget(i,"touchendoutside");else if("mouse"===i.pointerType||"pen"===i.pointerType){const t=2===i.button;this.notifyTarget(i,t?"rightupoutside":"mouseupoutside")}e=e.parent}delete o.pressTargetsByButton[t.button],s=e}if(s){const e=this.clonePointerEvent(i,"click");e.target=s,e.path=null,o.clicksByButton[t.button]||(o.clicksByButton[t.button]={clickCount:0,target:e.target,timeStamp:n});const r=o.clicksByButton[t.button];if(r.target===e.target&&n-r.timeStamp<200?++r.clickCount:r.clickCount=1,r.target=e.target,r.timeStamp=n,e.detail=r.clickCount,"mouse"===e.pointerType){const t=2===e.button;this.dispatchEvent(e,t?"rightclick":"click")}else"touch"===e.pointerType&&this.dispatchEvent(e,"tap");this.dispatchEvent(e,"pointertap"),this.freeEvent(e)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof p))return void e.warn("EventBoundary cannot map a non-pointer event as a pointer event");const n=this.trackingData(t.pointerId),i=this.findMountedTarget(n.pressTargetsByButton[t.button]),o=this.createPointerEvent(t);if(i){let e=i;for(;e;)o.currentTarget=e,this.notifyTarget(o,"pointerupoutside"),"touch"===o.pointerType?this.notifyTarget(o,"touchendoutside"):"mouse"!==o.pointerType&&"pen"!==o.pointerType||this.notifyTarget(o,2===o.button?"rightupoutside":"mouseupoutside"),e=e.parent;delete n.pressTargetsByButton[t.button]}this.freeEvent(o)}mapWheel(t){if(!(t instanceof l))return void e.warn("EventBoundary cannot map a non-wheel event as a wheel event");const n=this.createWheelEvent(t);this.dispatchEvent(n),this.freeEvent(n)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let n=1;n<t.length&&t[n].parent===e;n++)e=t[n];return e}createPointerEvent(t,e,n){var i;const o=this.allocateEvent(p);return this.copyPointerData(t,o),this.copyMouseData(t,o),this.copyData(t,o),o.nativeEvent=t.nativeEvent,o.originalEvent=t,o.target=null!==(i=null!=n?n:this.hitTest(o.global.x,o.global.y))&&void 0!==i?i:this._hitElements[0],"string"==typeof e&&(o.type=e),o}createWheelEvent(t){const e=this.allocateEvent(l);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const n=this.allocateEvent(p);return n.nativeEvent=t.nativeEvent,n.originalEvent=t.originalEvent,this.copyPointerData(t,n),this.copyMouseData(t,n),this.copyData(t,n),n.target=t.target,n.path=t.composedPath().slice(),n.type=null!=e?e:n.type,n}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof p&&e instanceof p&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof h&&e instanceof h&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.defaultPrevented=!1,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}_notifyListeners(t,e){const n=t.currentTarget._events[e];if(n)if("fn"in n)n.once&&t.currentTarget.removeListener(e,n.fn,void 0,!0),n.fn.call(n.context,t);else for(let i=0,o=n.length;i<o&&!t.propagationImmediatelyStopped;i++)n[i].once&&t.currentTarget.removeListener(e,n[i].fn,void 0,!0),n[i].fn.call(n[i].context,t)}}const d={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};class m{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new v(null),s.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new p(null),this._rootWheelEvent=new l(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy(_extends({},m.defaultEventFeatures),{set:(t,e,n)=>("globalMove"===e&&(this.rootBoundary.enableGlobalMoveEvents=n),t[e]=n,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){var e,n;const{canvas:i,resolution:o}=this.renderer;this.setTargetElement(i),this.resolution=o,m._defaultEventMode=null!==(e=t.eventMode)&&void 0!==e?e:"passive",_extends(this.features,null!==(n=t.eventFeatures)&&void 0!==n?n:{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(t){t||(t="default");let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this._currentCursor===t)return;this._currentCursor=t;const n=this.cursorStyles[t];if(n)switch(typeof n){case"string":e&&(this.domElement.style.cursor=n);break;case"function":n(t);break;case"object":e&&_extends(this.domElement.style,n)}else e&&"string"==typeof t&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);if(this.autoPreventDefault&&e[0].isNormalized){(t.cancelable||!("cancelable"in t))&&t.preventDefault()}for(let t=0,n=e.length;t<n;t++){const n=e[t],i=this._bootstrapEvent(this._rootPointerEvent,n);this.rootBoundary.mapEvent(i)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,s.pointerMoved();const e=this._normalizeToPointerData(t);for(let t=0,n=e.length;t<n;t++){const n=this._bootstrapEvent(this._rootPointerEvent,e[t]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);for(let t=0,n=e.length;t<n;t++){const n=this._bootstrapEvent(this._rootPointerEvent,e[t]);n.type+="",this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);for(let t=0,n=e.length;t<n;t++){const n=this._bootstrapEvent(this._rootPointerEvent,e[t]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this._removeEvents(),this.domElement=t,s.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;s.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),m.eventsHandler={pointermove:this._onPointerMove.bind(this),pointerdown:this._onPointerDown.bind(this),pointerleave:this._onPointerOverOut.bind(this),pointerover:this._onPointerOverOut.bind(this),pointerup:this._onPointerUp.bind(this),mousemove:this._onPointerMove.bind(this),mousedown:this._onPointerDown.bind(this),mouseout:this._onPointerOverOut.bind(this),mouseover:this._onPointerOverOut.bind(this),mouseup:this._onPointerUp.bind(this),touchstart:this._onPointerDown.bind(this),touchend:this._onPointerUp.bind(this),touchmove:this._onPointerMove.bind(this)},m.eventsHandler.wheel=this.onWheel.bind(this),this._eventsAdded=!0}_removeEvents(){if(!this._eventsAdded||!this.domElement)return;s.removeTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction="")),m.eventsHandler=[],this.domElement=null,this._eventsAdded=!1}mapPositionToPoint(t,e,n){const i=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},o=1/this.resolution;t.x=(e-i.left)*(this.domElement.width/i.width)*o,t.y=(n-i.top)*(this.domElement.height/i.height)*o}_normalizeToPointerData(t){return t.normalizedEvents}normalizeWheelEvent(t){const e=this._rootWheelEvent;return this._transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}_bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this._transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=d[t.type]||t.type),t}_transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}}m.extension={name:"events",type:[e.ExtensionType.WebGLSystem,e.ExtensionType.CanvasSystem,e.ExtensionType.WebGPUSystem],priority:-1},m.eventsHandler={},m.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};return t.eventHandler=t=>{const{type:e,eventName:n,event:i,normalizedEvents:o}=t;if("eva-event"===e){const t=m.eventsHandler[n];t&&t(_extends(_extends({},i),{preventDefault(){},normalizedEvents:o}))}},Object.defineProperty(t,"__esModule",{value:!0}),t}({},PIXI);window.EVA.plugin.worker=window.EVA.plugin.worker||_EVA_IIFE_worker;
|