@eva/plugin-renderer-event 2.0.0-beta.1 → 2.0.0-beta.2

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.
@@ -4,23 +4,6 @@ window.EVA.plugin = window.EVA.plugin || {};
4
4
  window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
5
5
  var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
6
6
  'use strict';
7
- var extendStatics = function (d, b) {
8
- extendStatics = Object.setPrototypeOf || {
9
- __proto__: []
10
- } instanceof Array && function (d, b) {
11
- d.__proto__ = b;
12
- } || function (d, b) {
13
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
14
- };
15
- return extendStatics(d, b);
16
- };
17
- function __extends(d, b) {
18
- extendStatics(d, b);
19
- function __() {
20
- this.constructor = d;
21
- }
22
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23
- }
24
7
  function __decorate(decorators, target, key, desc) {
25
8
  var c = arguments.length,
26
9
  r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
@@ -28,74 +11,30 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
28
11
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
29
12
  return c > 3 && r && Object.defineProperty(target, key, r), r;
30
13
  }
31
- function __values(o) {
32
- var s = typeof Symbol === "function" && Symbol.iterator,
33
- m = s && o[s],
34
- i = 0;
35
- if (m) return m.call(o);
36
- if (o && typeof o.length === "number") return {
37
- next: function () {
38
- if (o && i >= o.length) o = void 0;
39
- return {
40
- value: o && o[i++],
41
- done: !o
42
- };
43
- }
44
- };
45
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
46
- }
47
- function __read(o, n) {
48
- var m = typeof Symbol === "function" && o[Symbol.iterator];
49
- if (!m) return o;
50
- var i = m.call(o),
51
- r,
52
- ar = [],
53
- e;
54
- try {
55
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
56
- } catch (error) {
57
- e = {
58
- error: error
59
- };
60
- } finally {
61
- try {
62
- if (r && !r.done && (m = i["return"])) m.call(i);
63
- } finally {
64
- if (e) throw e.error;
65
- }
66
- }
67
- return ar;
68
- }
69
- function __spread() {
70
- for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
71
- return ar;
72
- }
73
- var hitAreaFunc = {
14
+ const hitAreaFunc = {
74
15
  Circle: pixi_js.Circle,
75
16
  Ellipse: pixi_js.Ellipse,
76
17
  Polygon: pixi_js.Polygon,
77
18
  Rect: pixi_js.Rectangle,
78
19
  RoundedRect: pixi_js.RoundedRectangle
79
20
  };
80
- var propertyForHitArea = {
21
+ const propertyForHitArea = {
81
22
  Circle: ['x', 'y', 'radius'],
82
23
  Ellipse: ['x', 'y', 'width', 'height'],
83
24
  Rect: ['x', 'y', 'width', 'height'],
84
25
  RoundedRect: ['x', 'y', 'width', 'height', 'radius'],
85
26
  Polygon: ['paths']
86
27
  };
87
- var Event$2 = function (_super) {
88
- __extends(Event, _super);
89
- function Event() {
90
- var _this = _super !== null && _super.apply(this, arguments) || this;
91
- _this.name = 'Event';
92
- return _this;
28
+ let Event$1 = class Event extends pluginRenderer.Renderer {
29
+ constructor() {
30
+ super(...arguments);
31
+ this.name = 'Event';
93
32
  }
94
- Event.prototype.init = function () {
33
+ init() {
95
34
  this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
96
35
  this.renderSystem.rendererManager.register(this);
97
- };
98
- Event.prototype.componentChanged = function (changed) {
36
+ }
37
+ componentChanged(changed) {
99
38
  switch (changed.type) {
100
39
  case eva_js.OBSERVER_TYPE.ADD:
101
40
  this.add(changed);
@@ -107,20 +46,18 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
107
46
  this.change(changed);
108
47
  break;
109
48
  }
110
- };
111
- Event.prototype.add = function (changed) {
112
- var container = this.containerManager.getContainer(changed.gameObject.id);
49
+ }
50
+ add(changed) {
51
+ const container = this.containerManager.getContainer(changed.gameObject.id);
113
52
  container.interactive = true;
114
53
  container.interactiveChildren = true;
115
- var component = changed.component;
54
+ const component = changed.component;
116
55
  if (component.hitArea) {
117
56
  this.addHitArea(changed, container, component.hitArea);
118
57
  }
119
- container.on('pointertap', function (e) {
58
+ container.on('pointertap', e => {
120
59
  component.emit('tap', {
121
- stopPropagation: function () {
122
- return e.stopPropagation();
123
- },
60
+ stopPropagation: () => e.stopPropagation(),
124
61
  data: {
125
62
  pointerId: e.data.pointerId,
126
63
  position: {
@@ -132,11 +69,9 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
132
69
  gameObject: component.gameObject
133
70
  });
134
71
  });
135
- container.on('pointerdown', function (e) {
72
+ container.on('pointerdown', e => {
136
73
  component.emit('touchstart', {
137
- stopPropagation: function () {
138
- return e.stopPropagation();
139
- },
74
+ stopPropagation: () => e.stopPropagation(),
140
75
  data: {
141
76
  pointerId: e.data.pointerId,
142
77
  position: {
@@ -148,11 +83,9 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
148
83
  gameObject: component.gameObject
149
84
  });
150
85
  });
151
- container.on('pointermove', function (e) {
86
+ container.on('pointermove', e => {
152
87
  component.emit('touchmove', {
153
- stopPropagation: function () {
154
- return e.stopPropagation();
155
- },
88
+ stopPropagation: () => e.stopPropagation(),
156
89
  data: {
157
90
  pointerId: e.data.pointerId,
158
91
  position: {
@@ -164,11 +97,9 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
164
97
  gameObject: component.gameObject
165
98
  });
166
99
  });
167
- container.on('pointerup', function (e) {
100
+ container.on('pointerup', e => {
168
101
  component.emit('touchend', {
169
- stopPropagation: function () {
170
- return e.stopPropagation();
171
- },
102
+ stopPropagation: () => e.stopPropagation(),
172
103
  data: {
173
104
  pointerId: e.data.pointerId,
174
105
  position: {
@@ -180,11 +111,9 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
180
111
  gameObject: component.gameObject
181
112
  });
182
113
  });
183
- container.on('pointerupoutside', function (e) {
114
+ container.on('pointerupoutside', e => {
184
115
  component.emit('touchendoutside', {
185
- stopPropagation: function () {
186
- return e.stopPropagation();
187
- },
116
+ stopPropagation: () => e.stopPropagation(),
188
117
  data: {
189
118
  pointerId: e.data.pointerId,
190
119
  position: {
@@ -196,11 +125,9 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
196
125
  gameObject: component.gameObject
197
126
  });
198
127
  });
199
- container.on('pointercancel', function (e) {
128
+ container.on('pointercancel', e => {
200
129
  component.emit('touchcancel', {
201
- stopPropagation: function () {
202
- return e.stopPropagation();
203
- },
130
+ stopPropagation: () => e.stopPropagation(),
204
131
  data: {
205
132
  pointerId: e.data.pointerId,
206
133
  position: {
@@ -212,9 +139,9 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
212
139
  gameObject: component.gameObject
213
140
  });
214
141
  });
215
- };
216
- Event.prototype.remove = function (changed) {
217
- var container = this.containerManager.getContainer(changed.gameObject.id);
142
+ }
143
+ remove(changed) {
144
+ const container = this.containerManager.getContainer(changed.gameObject.id);
218
145
  container.interactive = false;
219
146
  container.off('tap');
220
147
  container.off('pointerdown');
@@ -223,55 +150,42 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
223
150
  container.off('pointerupoutside');
224
151
  container.off('pointercancel');
225
152
  changed.component.removeAllListeners();
226
- };
227
- Event.prototype.change = function (changed) {
228
- var container = this.containerManager.getContainer(changed.gameObject.id);
153
+ }
154
+ change(changed) {
155
+ const container = this.containerManager.getContainer(changed.gameObject.id);
229
156
  container.interactive = true;
230
- var component = changed.component;
157
+ const component = changed.component;
231
158
  if (component.hitArea) {
232
159
  this.addHitArea(changed, container, component.hitArea);
233
160
  } else {
234
161
  component.hitArea = null;
235
162
  }
236
- };
237
- Event.prototype.addHitArea = function (changed, container, hitArea) {
238
- var e_1, _a, _b;
239
- var type = hitArea.type,
240
- style = hitArea.style;
163
+ }
164
+ addHitArea(changed, container, hitArea) {
165
+ const {
166
+ type,
167
+ style
168
+ } = hitArea;
241
169
  if (!hitAreaFunc[type]) {
242
- console.error(changed.gameObject.name + "'s hitArea type is not defined");
170
+ console.error(`${changed.gameObject.name}'s hitArea type is not defined`);
243
171
  return;
244
172
  }
245
- var params = [];
246
- try {
247
- for (var _c = __values(propertyForHitArea[type]), _d = _c.next(); !_d.done; _d = _c.next()) {
248
- var key = _d.value;
249
- params.push(style[key]);
250
- }
251
- } catch (e_1_1) {
252
- e_1 = {
253
- error: e_1_1
254
- };
255
- } finally {
256
- try {
257
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
258
- } finally {
259
- if (e_1) throw e_1.error;
260
- }
173
+ const params = [];
174
+ for (const key of propertyForHitArea[type]) {
175
+ params.push(style[key]);
261
176
  }
262
- var hitAreaShape = new ((_b = hitAreaFunc[type]).bind.apply(_b, __spread([void 0], params)))();
177
+ const hitAreaShape = new hitAreaFunc[type](...params);
263
178
  container.hitArea = hitAreaShape;
264
- };
265
- Event.systemName = 'Event';
266
- Event = __decorate([eva_js.decorators.componentObserver({
267
- Event: [{
268
- prop: ['hitArea'],
269
- deep: true
270
- }]
271
- })], Event);
272
- return Event;
273
- }(pluginRenderer.Renderer);
274
- var Event$3 = Event$2;
179
+ }
180
+ };
181
+ Event$1.systemName = 'Event';
182
+ Event$1 = __decorate([eva_js.decorators.componentObserver({
183
+ Event: [{
184
+ prop: ['hitArea'],
185
+ deep: true
186
+ }]
187
+ })], Event$1);
188
+ var Event$2 = Event$1;
275
189
  exports.HIT_AREA_TYPE = void 0;
276
190
  (function (HIT_AREA_TYPE) {
277
191
  HIT_AREA_TYPE["Circle"] = "Circle";
@@ -280,35 +194,27 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
280
194
  HIT_AREA_TYPE["Rect"] = "Rect";
281
195
  HIT_AREA_TYPE["RoundedRect"] = "RoundedRect";
282
196
  })(exports.HIT_AREA_TYPE || (exports.HIT_AREA_TYPE = {}));
283
- var Event = function (_super) {
284
- __extends(Event, _super);
285
- function Event() {
286
- var _this = _super !== null && _super.apply(this, arguments) || this;
287
- _this.hitArea = undefined;
288
- return _this;
197
+ class Event extends eva_js.Component {
198
+ constructor() {
199
+ super(...arguments);
200
+ this.hitArea = undefined;
289
201
  }
290
- Event.prototype.init = function (params) {
202
+ init(params) {
291
203
  params && _extends(this, params);
292
- };
293
- Event.prototype.emit = function (en) {
294
- var args = [];
295
- for (var _i = 1; _i < arguments.length; _i++) {
296
- args[_i - 1] = arguments[_i];
297
- }
298
- return _super.prototype.emit.apply(this, __spread([en], args));
299
- };
300
- Event.prototype.once = function (en, fn, context) {
301
- return _super.prototype.once.call(this, en, fn, context);
302
- };
303
- Event.prototype.on = function (en, fn, context) {
304
- return _super.prototype.on.call(this, en, fn, context);
305
- };
306
- Event.componentName = 'Event';
307
- return Event;
308
- }(eva_js.Component);
309
- var Event$1 = Event;
310
- exports.Event = Event$1;
311
- exports.EventSystem = Event$3;
204
+ }
205
+ emit(en, ...args) {
206
+ return super.emit(en, ...args);
207
+ }
208
+ once(en, fn, context) {
209
+ return super.once(en, fn, context);
210
+ }
211
+ on(en, fn, context) {
212
+ return super.on(en, fn, context);
213
+ }
214
+ }
215
+ Event.componentName = 'Event';
216
+ exports.Event = Event;
217
+ exports.EventSystem = Event$2;
312
218
  Object.defineProperty(exports, '__esModule', {
313
219
  value: true
314
220
  });
@@ -1 +1 @@
1
- function _extends(){return _extends=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)({}).hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},_extends.apply(null,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_event=function(t,e,o,n){"use strict";var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])},r(t,e)};function a(t,e){function o(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}function i(t,e){var o="function"==typeof Symbol&&t[Symbol.iterator];if(!o)return t;var n,r,a=o.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){r={error:t}}finally{try{n&&!n.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}return i}function l(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t}var p,c={Circle:n.Circle,Ellipse:n.Ellipse,Polygon:n.Polygon,Rect:n.Rectangle,RoundedRect:n.RoundedRectangle},d={Circle:["x","y","radius"],Ellipse:["x","y","width","height"],Rect:["x","y","width","height"],RoundedRect:["x","y","width","height","radius"],Polygon:["paths"]},s=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="Event",e}return a(n,t),n.prototype.init=function(){this.renderSystem=this.game.getSystem(e.RendererSystem),this.renderSystem.rendererManager.register(this)},n.prototype.componentChanged=function(t){switch(t.type){case o.OBSERVER_TYPE.ADD:this.add(t);break;case o.OBSERVER_TYPE.REMOVE:this.remove(t);break;case o.OBSERVER_TYPE.CHANGE:this.change(t)}},n.prototype.add=function(t){var e=this.containerManager.getContainer(t.gameObject.id);e.interactive=!0,e.interactiveChildren=!0;var o=t.component;o.hitArea&&this.addHitArea(t,e,o.hitArea),e.on("pointertap",(function(t){o.emit("tap",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointerdown",(function(t){o.emit("touchstart",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointermove",(function(t){o.emit("touchmove",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointerup",(function(t){o.emit("touchend",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointerupoutside",(function(t){o.emit("touchendoutside",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointercancel",(function(t){o.emit("touchcancel",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})}))},n.prototype.remove=function(t){var e=this.containerManager.getContainer(t.gameObject.id);e.interactive=!1,e.off("tap"),e.off("pointerdown"),e.off("pointermove"),e.off("pointerup"),e.off("pointerupoutside"),e.off("pointercancel"),t.component.removeAllListeners()},n.prototype.change=function(t){var e=this.containerManager.getContainer(t.gameObject.id);e.interactive=!0;var o=t.component;o.hitArea?this.addHitArea(t,e,o.hitArea):o.hitArea=null},n.prototype.addHitArea=function(t,e,o){var n,r,a,i=o.type,p=o.style;if(c[i]){var s=[];try{for(var u=function(t){var e="function"==typeof Symbol&&Symbol.iterator,o=e&&t[e],n=0;if(o)return o.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(d[i]),f=u.next();!f.done;f=u.next()){var g=f.value;s.push(p[g])}}catch(t){n={error:t}}finally{try{f&&!f.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}var y=new((a=c[i]).bind.apply(a,l([void 0],s)));e.hitArea=y}else console.error(t.gameObject.name+"'s hitArea type is not defined")},n.systemName="Event",n=function(t,e,o,n){var r,a=arguments.length,i=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,o,n);else for(var l=t.length-1;l>=0;l--)(r=t[l])&&(i=(a<3?r(i):a>3?r(e,o,i):r(e,o))||i);return a>3&&i&&Object.defineProperty(e,o,i),i}([o.decorators.componentObserver({Event:[{prop:["hitArea"],deep:!0}]})],n),n}(e.Renderer),u=s;t.HIT_AREA_TYPE=void 0,(p=t.HIT_AREA_TYPE||(t.HIT_AREA_TYPE={})).Circle="Circle",p.Ellipse="Ellipse",p.Polygon="Polygon",p.Rect="Rect",p.RoundedRect="RoundedRect";var f=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.hitArea=void 0,e}return a(e,t),e.prototype.init=function(t){t&&_extends(this,t)},e.prototype.emit=function(e){for(var o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];return t.prototype.emit.apply(this,l([e],o))},e.prototype.once=function(e,o,n){return t.prototype.once.call(this,e,o,n)},e.prototype.on=function(e,o,n){return t.prototype.on.call(this,e,o,n)},e.componentName="Event",e}(o.Component),g=f;return t.Event=g,t.EventSystem=u,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA.plugin.renderer,EVA,PIXI);window.EVA.plugin.renderer.event=window.EVA.plugin.renderer.event||_EVA_IIFE_event;
1
+ function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)({}).hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},_extends.apply(null,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_event=function(e,t,o,n){"use strict";const a={Circle:n.Circle,Ellipse:n.Ellipse,Polygon:n.Polygon,Rect:n.Rectangle,RoundedRect:n.RoundedRectangle},r={Circle:["x","y","radius"],Ellipse:["x","y","width","height"],Rect:["x","y","width","height"],RoundedRect:["x","y","width","height","radius"],Polygon:["paths"]};let i=class extends t.Renderer{constructor(){super(...arguments),this.name="Event"}init(){this.renderSystem=this.game.getSystem(t.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(e){switch(e.type){case o.OBSERVER_TYPE.ADD:this.add(e);break;case o.OBSERVER_TYPE.REMOVE:this.remove(e);break;case o.OBSERVER_TYPE.CHANGE:this.change(e)}}add(e){const t=this.containerManager.getContainer(e.gameObject.id);t.interactive=!0,t.interactiveChildren=!0;const o=e.component;o.hitArea&&this.addHitArea(e,t,o.hitArea),t.on("pointertap",(e=>{o.emit("tap",{stopPropagation:()=>e.stopPropagation(),data:{pointerId:e.data.pointerId,position:{x:e.data.global.x,y:e.data.global.y},localPosition:t.worldTransform.applyInverse(e.data.global)},gameObject:o.gameObject})})),t.on("pointerdown",(e=>{o.emit("touchstart",{stopPropagation:()=>e.stopPropagation(),data:{pointerId:e.data.pointerId,position:{x:e.data.global.x,y:e.data.global.y},localPosition:t.worldTransform.applyInverse(e.data.global)},gameObject:o.gameObject})})),t.on("pointermove",(e=>{o.emit("touchmove",{stopPropagation:()=>e.stopPropagation(),data:{pointerId:e.data.pointerId,position:{x:e.data.global.x,y:e.data.global.y},localPosition:t.worldTransform.applyInverse(e.data.global)},gameObject:o.gameObject})})),t.on("pointerup",(e=>{o.emit("touchend",{stopPropagation:()=>e.stopPropagation(),data:{pointerId:e.data.pointerId,position:{x:e.data.global.x,y:e.data.global.y},localPosition:t.worldTransform.applyInverse(e.data.global)},gameObject:o.gameObject})})),t.on("pointerupoutside",(e=>{o.emit("touchendoutside",{stopPropagation:()=>e.stopPropagation(),data:{pointerId:e.data.pointerId,position:{x:e.data.global.x,y:e.data.global.y},localPosition:t.worldTransform.applyInverse(e.data.global)},gameObject:o.gameObject})})),t.on("pointercancel",(e=>{o.emit("touchcancel",{stopPropagation:()=>e.stopPropagation(),data:{pointerId:e.data.pointerId,position:{x:e.data.global.x,y:e.data.global.y},localPosition:t.worldTransform.applyInverse(e.data.global)},gameObject:o.gameObject})}))}remove(e){const t=this.containerManager.getContainer(e.gameObject.id);t.interactive=!1,t.off("tap"),t.off("pointerdown"),t.off("pointermove"),t.off("pointerup"),t.off("pointerupoutside"),t.off("pointercancel"),e.component.removeAllListeners()}change(e){const t=this.containerManager.getContainer(e.gameObject.id);t.interactive=!0;const o=e.component;o.hitArea?this.addHitArea(e,t,o.hitArea):o.hitArea=null}addHitArea(e,t,o){const{type:n,style:i}=o;if(!a[n])return void console.error(`${e.gameObject.name}'s hitArea type is not defined`);const d=[];for(const e of r[n])d.push(i[e]);const s=new a[n](...d);t.hitArea=s}};i.systemName="Event",i=function(e,t,o,n){var a,r=arguments.length,i=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,o,n);else for(var d=e.length-1;d>=0;d--)(a=e[d])&&(i=(r<3?a(i):r>3?a(t,o,i):a(t,o))||i);return r>3&&i&&Object.defineProperty(t,o,i),i}([o.decorators.componentObserver({Event:[{prop:["hitArea"],deep:!0}]})],i);var d,s=i;e.HIT_AREA_TYPE=void 0,(d=e.HIT_AREA_TYPE||(e.HIT_AREA_TYPE={})).Circle="Circle",d.Ellipse="Ellipse",d.Polygon="Polygon",d.Rect="Rect",d.RoundedRect="RoundedRect";class l extends o.Component{constructor(){super(...arguments),this.hitArea=void 0}init(e){e&&_extends(this,e)}emit(e,...t){return super.emit(e,...t)}once(e,t,o){return super.once(e,t,o)}on(e,t,o){return super.on(e,t,o)}}return l.componentName="Event",e.Event=l,e.EventSystem=s,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA.plugin.renderer,EVA,PIXI);window.EVA.plugin.renderer.event=window.EVA.plugin.renderer.event||_EVA_IIFE_event;
@@ -20,88 +20,38 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
20
20
  See the Apache Version 2.0 License for specific language governing permissions
21
21
  and limitations under the License.
22
22
  ***************************************************************************** */
23
- /* global Reflect, Promise */
24
-
25
- var extendStatics = function(d, b) {
26
- extendStatics = Object.setPrototypeOf ||
27
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
28
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
29
- return extendStatics(d, b);
30
- };
31
-
32
- function __extends(d, b) {
33
- extendStatics(d, b);
34
- function __() { this.constructor = d; }
35
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36
- }
37
23
 
38
24
  function __decorate(decorators, target, key, desc) {
39
25
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
40
26
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
41
27
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
42
28
  return c > 3 && r && Object.defineProperty(target, key, r), r;
43
- }
44
-
45
- function __values(o) {
46
- var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
47
- if (m) return m.call(o);
48
- return {
49
- next: function () {
50
- if (o && i >= o.length) o = void 0;
51
- return { value: o && o[i++], done: !o };
52
- }
53
- };
54
- }
55
-
56
- function __read(o, n) {
57
- var m = typeof Symbol === "function" && o[Symbol.iterator];
58
- if (!m) return o;
59
- var i = m.call(o), r, ar = [], e;
60
- try {
61
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
62
- }
63
- catch (error) { e = { error: error }; }
64
- finally {
65
- try {
66
- if (r && !r.done && (m = i["return"])) m.call(i);
67
- }
68
- finally { if (e) throw e.error; }
69
- }
70
- return ar;
71
- }
72
-
73
- function __spread() {
74
- for (var ar = [], i = 0; i < arguments.length; i++)
75
- ar = ar.concat(__read(arguments[i]));
76
- return ar;
77
29
  }
78
30
 
79
- var hitAreaFunc = {
31
+ const hitAreaFunc = {
80
32
  Circle: pixi_js.Circle,
81
33
  Ellipse: pixi_js.Ellipse,
82
34
  Polygon: pixi_js.Polygon,
83
35
  Rect: pixi_js.Rectangle,
84
36
  RoundedRect: pixi_js.RoundedRectangle,
85
37
  };
86
- var propertyForHitArea = {
38
+ const propertyForHitArea = {
87
39
  Circle: ['x', 'y', 'radius'],
88
40
  Ellipse: ['x', 'y', 'width', 'height'],
89
41
  Rect: ['x', 'y', 'width', 'height'],
90
42
  RoundedRect: ['x', 'y', 'width', 'height', 'radius'],
91
43
  Polygon: ['paths'],
92
44
  };
93
- var Event$2 = (function (_super) {
94
- __extends(Event, _super);
95
- function Event() {
96
- var _this = _super !== null && _super.apply(this, arguments) || this;
97
- _this.name = 'Event';
98
- return _this;
45
+ let Event$1 = class Event extends pluginRenderer.Renderer {
46
+ constructor() {
47
+ super(...arguments);
48
+ this.name = 'Event';
99
49
  }
100
- Event.prototype.init = function () {
50
+ init() {
101
51
  this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
102
52
  this.renderSystem.rendererManager.register(this);
103
- };
104
- Event.prototype.componentChanged = function (changed) {
53
+ }
54
+ componentChanged(changed) {
105
55
  switch (changed.type) {
106
56
  case eva_js.OBSERVER_TYPE.ADD:
107
57
  this.add(changed);
@@ -113,18 +63,18 @@ var Event$2 = (function (_super) {
113
63
  this.change(changed);
114
64
  break;
115
65
  }
116
- };
117
- Event.prototype.add = function (changed) {
118
- var container = this.containerManager.getContainer(changed.gameObject.id);
66
+ }
67
+ add(changed) {
68
+ const container = this.containerManager.getContainer(changed.gameObject.id);
119
69
  container.interactive = true;
120
70
  container.interactiveChildren = true;
121
- var component = changed.component;
71
+ const component = changed.component;
122
72
  if (component.hitArea) {
123
73
  this.addHitArea(changed, container, component.hitArea);
124
74
  }
125
- container.on('pointertap', function (e) {
75
+ container.on('pointertap', e => {
126
76
  component.emit('tap', {
127
- stopPropagation: function () { return e.stopPropagation(); },
77
+ stopPropagation: () => e.stopPropagation(),
128
78
  data: {
129
79
  pointerId: e.data.pointerId,
130
80
  position: {
@@ -136,9 +86,9 @@ var Event$2 = (function (_super) {
136
86
  gameObject: component.gameObject,
137
87
  });
138
88
  });
139
- container.on('pointerdown', function (e) {
89
+ container.on('pointerdown', e => {
140
90
  component.emit('touchstart', {
141
- stopPropagation: function () { return e.stopPropagation(); },
91
+ stopPropagation: () => e.stopPropagation(),
142
92
  data: {
143
93
  pointerId: e.data.pointerId,
144
94
  position: {
@@ -150,9 +100,9 @@ var Event$2 = (function (_super) {
150
100
  gameObject: component.gameObject,
151
101
  });
152
102
  });
153
- container.on('pointermove', function (e) {
103
+ container.on('pointermove', e => {
154
104
  component.emit('touchmove', {
155
- stopPropagation: function () { return e.stopPropagation(); },
105
+ stopPropagation: () => e.stopPropagation(),
156
106
  data: {
157
107
  pointerId: e.data.pointerId,
158
108
  position: {
@@ -164,9 +114,9 @@ var Event$2 = (function (_super) {
164
114
  gameObject: component.gameObject,
165
115
  });
166
116
  });
167
- container.on('pointerup', function (e) {
117
+ container.on('pointerup', e => {
168
118
  component.emit('touchend', {
169
- stopPropagation: function () { return e.stopPropagation(); },
119
+ stopPropagation: () => e.stopPropagation(),
170
120
  data: {
171
121
  pointerId: e.data.pointerId,
172
122
  position: {
@@ -178,9 +128,9 @@ var Event$2 = (function (_super) {
178
128
  gameObject: component.gameObject,
179
129
  });
180
130
  });
181
- container.on('pointerupoutside', function (e) {
131
+ container.on('pointerupoutside', e => {
182
132
  component.emit('touchendoutside', {
183
- stopPropagation: function () { return e.stopPropagation(); },
133
+ stopPropagation: () => e.stopPropagation(),
184
134
  data: {
185
135
  pointerId: e.data.pointerId,
186
136
  position: {
@@ -192,9 +142,9 @@ var Event$2 = (function (_super) {
192
142
  gameObject: component.gameObject,
193
143
  });
194
144
  });
195
- container.on('pointercancel', function (e) {
145
+ container.on('pointercancel', e => {
196
146
  component.emit('touchcancel', {
197
- stopPropagation: function () { return e.stopPropagation(); },
147
+ stopPropagation: () => e.stopPropagation(),
198
148
  data: {
199
149
  pointerId: e.data.pointerId,
200
150
  position: {
@@ -206,9 +156,9 @@ var Event$2 = (function (_super) {
206
156
  gameObject: component.gameObject,
207
157
  });
208
158
  });
209
- };
210
- Event.prototype.remove = function (changed) {
211
- var container = this.containerManager.getContainer(changed.gameObject.id);
159
+ }
160
+ remove(changed) {
161
+ const container = this.containerManager.getContainer(changed.gameObject.id);
212
162
  container.interactive = false;
213
163
  container.off('tap');
214
164
  container.off('pointerdown');
@@ -217,51 +167,39 @@ var Event$2 = (function (_super) {
217
167
  container.off('pointerupoutside');
218
168
  container.off('pointercancel');
219
169
  changed.component.removeAllListeners();
220
- };
221
- Event.prototype.change = function (changed) {
222
- var container = this.containerManager.getContainer(changed.gameObject.id);
170
+ }
171
+ change(changed) {
172
+ const container = this.containerManager.getContainer(changed.gameObject.id);
223
173
  container.interactive = true;
224
- var component = changed.component;
174
+ const component = changed.component;
225
175
  if (component.hitArea) {
226
176
  this.addHitArea(changed, container, component.hitArea);
227
177
  }
228
178
  else {
229
179
  component.hitArea = null;
230
180
  }
231
- };
232
- Event.prototype.addHitArea = function (changed, container, hitArea) {
233
- var e_1, _a, _b;
234
- var type = hitArea.type, style = hitArea.style;
181
+ }
182
+ addHitArea(changed, container, hitArea) {
183
+ const { type, style } = hitArea;
235
184
  if (!hitAreaFunc[type]) {
236
- console.error(changed.gameObject.name + "'s hitArea type is not defined");
185
+ console.error(`${changed.gameObject.name}'s hitArea type is not defined`);
237
186
  return;
238
187
  }
239
- var params = [];
240
- try {
241
- for (var _c = __values(propertyForHitArea[type]), _d = _c.next(); !_d.done; _d = _c.next()) {
242
- var key = _d.value;
243
- params.push(style[key]);
244
- }
245
- }
246
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
247
- finally {
248
- try {
249
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
250
- }
251
- finally { if (e_1) throw e_1.error; }
188
+ const params = [];
189
+ for (const key of propertyForHitArea[type]) {
190
+ params.push(style[key]);
252
191
  }
253
- var hitAreaShape = new ((_b = hitAreaFunc[type]).bind.apply(_b, __spread([void 0], params)))();
192
+ const hitAreaShape = new hitAreaFunc[type](...params);
254
193
  container.hitArea = hitAreaShape;
255
- };
256
- Event.systemName = 'Event';
257
- Event = __decorate([
258
- eva_js.decorators.componentObserver({
259
- Event: [{ prop: ['hitArea'], deep: true }],
260
- })
261
- ], Event);
262
- return Event;
263
- }(pluginRenderer.Renderer));
264
- var Event$3 = Event$2;
194
+ }
195
+ };
196
+ Event$1.systemName = 'Event';
197
+ Event$1 = __decorate([
198
+ eva_js.decorators.componentObserver({
199
+ Event: [{ prop: ['hitArea'], deep: true }],
200
+ })
201
+ ], Event$1);
202
+ var Event$2 = Event$1;
265
203
 
266
204
  exports.HIT_AREA_TYPE = void 0;
267
205
  (function (HIT_AREA_TYPE) {
@@ -271,33 +209,25 @@ exports.HIT_AREA_TYPE = void 0;
271
209
  HIT_AREA_TYPE["Rect"] = "Rect";
272
210
  HIT_AREA_TYPE["RoundedRect"] = "RoundedRect";
273
211
  })(exports.HIT_AREA_TYPE || (exports.HIT_AREA_TYPE = {}));
274
- var Event = (function (_super) {
275
- __extends(Event, _super);
276
- function Event() {
277
- var _this = _super !== null && _super.apply(this, arguments) || this;
278
- _this.hitArea = undefined;
279
- return _this;
212
+ class Event extends eva_js.Component {
213
+ constructor() {
214
+ super(...arguments);
215
+ this.hitArea = undefined;
280
216
  }
281
- Event.prototype.init = function (params) {
217
+ init(params) {
282
218
  params && Object.assign(this, params);
283
- };
284
- Event.prototype.emit = function (en) {
285
- var args = [];
286
- for (var _i = 1; _i < arguments.length; _i++) {
287
- args[_i - 1] = arguments[_i];
288
- }
289
- return _super.prototype.emit.apply(this, __spread([en], args));
290
- };
291
- Event.prototype.once = function (en, fn, context) {
292
- return _super.prototype.once.call(this, en, fn, context);
293
- };
294
- Event.prototype.on = function (en, fn, context) {
295
- return _super.prototype.on.call(this, en, fn, context);
296
- };
297
- Event.componentName = 'Event';
298
- return Event;
299
- }(eva_js.Component));
300
- var Event$1 = Event;
219
+ }
220
+ emit(en, ...args) {
221
+ return super.emit(en, ...args);
222
+ }
223
+ once(en, fn, context) {
224
+ return super.once(en, fn, context);
225
+ }
226
+ on(en, fn, context) {
227
+ return super.on(en, fn, context);
228
+ }
229
+ }
230
+ Event.componentName = 'Event';
301
231
 
302
- exports.Event = Event$1;
303
- exports.EventSystem = Event$3;
232
+ exports.Event = Event;
233
+ exports.EventSystem = Event$2;
@@ -1 +1,16 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@eva/plugin-renderer"),e=require("@eva/eva.js"),o=require("pixi.js"),n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])},n(t,e)};function r(t,e){function o(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}function a(t,e){var o="function"==typeof Symbol&&t[Symbol.iterator];if(!o)return t;var n,r,a=o.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){r={error:t}}finally{try{n&&!n.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}return i}function i(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(a(arguments[e]));return t}var p,l={Circle:o.Circle,Ellipse:o.Ellipse,Polygon:o.Polygon,Rect:o.Rectangle,RoundedRect:o.RoundedRectangle},c={Circle:["x","y","radius"],Ellipse:["x","y","width","height"],Rect:["x","y","width","height"],RoundedRect:["x","y","width","height","radius"],Polygon:["paths"]},d=function(o){function n(){var t=null!==o&&o.apply(this,arguments)||this;return t.name="Event",t}return r(n,o),n.prototype.init=function(){this.renderSystem=this.game.getSystem(t.RendererSystem),this.renderSystem.rendererManager.register(this)},n.prototype.componentChanged=function(t){switch(t.type){case e.OBSERVER_TYPE.ADD:this.add(t);break;case e.OBSERVER_TYPE.REMOVE:this.remove(t);break;case e.OBSERVER_TYPE.CHANGE:this.change(t)}},n.prototype.add=function(t){var e=this.containerManager.getContainer(t.gameObject.id);e.interactive=!0,e.interactiveChildren=!0;var o=t.component;o.hitArea&&this.addHitArea(t,e,o.hitArea),e.on("pointertap",(function(t){o.emit("tap",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointerdown",(function(t){o.emit("touchstart",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointermove",(function(t){o.emit("touchmove",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointerup",(function(t){o.emit("touchend",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointerupoutside",(function(t){o.emit("touchendoutside",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointercancel",(function(t){o.emit("touchcancel",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})}))},n.prototype.remove=function(t){var e=this.containerManager.getContainer(t.gameObject.id);e.interactive=!1,e.off("tap"),e.off("pointerdown"),e.off("pointermove"),e.off("pointerup"),e.off("pointerupoutside"),e.off("pointercancel"),t.component.removeAllListeners()},n.prototype.change=function(t){var e=this.containerManager.getContainer(t.gameObject.id);e.interactive=!0;var o=t.component;o.hitArea?this.addHitArea(t,e,o.hitArea):o.hitArea=null},n.prototype.addHitArea=function(t,e,o){var n,r,a,p=o.type,d=o.style;if(l[p]){var s=[];try{for(var u=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],o=0;return e?e.call(t):{next:function(){return t&&o>=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}}}(c[p]),f=u.next();!f.done;f=u.next()){var y=f.value;s.push(d[y])}}catch(t){n={error:t}}finally{try{f&&!f.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}var g=new((a=l[p]).bind.apply(a,i([void 0],s)));e.hitArea=g}else console.error(t.gameObject.name+"'s hitArea type is not defined")},n.systemName="Event",n=function(t,e,o,n){var r,a=arguments.length,i=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,o,n);else for(var p=t.length-1;p>=0;p--)(r=t[p])&&(i=(a<3?r(i):a>3?r(e,o,i):r(e,o))||i);return a>3&&i&&Object.defineProperty(e,o,i),i}([e.decorators.componentObserver({Event:[{prop:["hitArea"],deep:!0}]})],n),n}(t.Renderer),s=d;exports.HIT_AREA_TYPE=void 0,(p=exports.HIT_AREA_TYPE||(exports.HIT_AREA_TYPE={})).Circle="Circle",p.Ellipse="Ellipse",p.Polygon="Polygon",p.Rect="Rect",p.RoundedRect="RoundedRect";var u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.hitArea=void 0,e}return r(e,t),e.prototype.init=function(t){t&&Object.assign(this,t)},e.prototype.emit=function(e){for(var o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];return t.prototype.emit.apply(this,i([e],o))},e.prototype.once=function(e,o,n){return t.prototype.once.call(this,e,o,n)},e.prototype.on=function(e,o,n){return t.prototype.on.call(this,e,o,n)},e.componentName="Event",e}(e.Component);exports.Event=u,exports.EventSystem=s;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/plugin-renderer"),t=require("@eva/eva.js"),o=require("pixi.js");const a={Circle:o.Circle,Ellipse:o.Ellipse,Polygon:o.Polygon,Rect:o.Rectangle,RoundedRect:o.RoundedRectangle},n={Circle:["x","y","radius"],Ellipse:["x","y","width","height"],Rect:["x","y","width","height"],RoundedRect:["x","y","width","height","radius"],Polygon:["paths"]};let r=class extends e.Renderer{constructor(){super(...arguments),this.name="Event"}init(){this.renderSystem=this.game.getSystem(e.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(e){switch(e.type){case t.OBSERVER_TYPE.ADD:this.add(e);break;case t.OBSERVER_TYPE.REMOVE:this.remove(e);break;case t.OBSERVER_TYPE.CHANGE:this.change(e)}}add(e){const t=this.containerManager.getContainer(e.gameObject.id);t.interactive=!0,t.interactiveChildren=!0;const o=e.component;o.hitArea&&this.addHitArea(e,t,o.hitArea),t.on("pointertap",(e=>{o.emit("tap",{stopPropagation:()=>e.stopPropagation(),data:{pointerId:e.data.pointerId,position:{x:e.data.global.x,y:e.data.global.y},localPosition:t.worldTransform.applyInverse(e.data.global)},gameObject:o.gameObject})})),t.on("pointerdown",(e=>{o.emit("touchstart",{stopPropagation:()=>e.stopPropagation(),data:{pointerId:e.data.pointerId,position:{x:e.data.global.x,y:e.data.global.y},localPosition:t.worldTransform.applyInverse(e.data.global)},gameObject:o.gameObject})})),t.on("pointermove",(e=>{o.emit("touchmove",{stopPropagation:()=>e.stopPropagation(),data:{pointerId:e.data.pointerId,position:{x:e.data.global.x,y:e.data.global.y},localPosition:t.worldTransform.applyInverse(e.data.global)},gameObject:o.gameObject})})),t.on("pointerup",(e=>{o.emit("touchend",{stopPropagation:()=>e.stopPropagation(),data:{pointerId:e.data.pointerId,position:{x:e.data.global.x,y:e.data.global.y},localPosition:t.worldTransform.applyInverse(e.data.global)},gameObject:o.gameObject})})),t.on("pointerupoutside",(e=>{o.emit("touchendoutside",{stopPropagation:()=>e.stopPropagation(),data:{pointerId:e.data.pointerId,position:{x:e.data.global.x,y:e.data.global.y},localPosition:t.worldTransform.applyInverse(e.data.global)},gameObject:o.gameObject})})),t.on("pointercancel",(e=>{o.emit("touchcancel",{stopPropagation:()=>e.stopPropagation(),data:{pointerId:e.data.pointerId,position:{x:e.data.global.x,y:e.data.global.y},localPosition:t.worldTransform.applyInverse(e.data.global)},gameObject:o.gameObject})}))}remove(e){const t=this.containerManager.getContainer(e.gameObject.id);t.interactive=!1,t.off("tap"),t.off("pointerdown"),t.off("pointermove"),t.off("pointerup"),t.off("pointerupoutside"),t.off("pointercancel"),e.component.removeAllListeners()}change(e){const t=this.containerManager.getContainer(e.gameObject.id);t.interactive=!0;const o=e.component;o.hitArea?this.addHitArea(e,t,o.hitArea):o.hitArea=null}addHitArea(e,t,o){const{type:r,style:i}=o;if(!a[r])return void console.error(`${e.gameObject.name}'s hitArea type is not defined`);const s=[];for(const e of n[r])s.push(i[e]);const p=new a[r](...s);t.hitArea=p}};r.systemName="Event",r=
2
+ /*! *****************************************************************************
3
+ Copyright (c) Microsoft Corporation. All rights reserved.
4
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
5
+ this file except in compliance with the License. You may obtain a copy of the
6
+ License at http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
10
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
11
+ MERCHANTABLITY OR NON-INFRINGEMENT.
12
+
13
+ See the Apache Version 2.0 License for specific language governing permissions
14
+ and limitations under the License.
15
+ ***************************************************************************** */
16
+ function(e,t,o,a){var n,r=arguments.length,i=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,o):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,o,a);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(i=(r<3?n(i):r>3?n(t,o,i):n(t,o))||i);return r>3&&i&&Object.defineProperty(t,o,i),i}([t.decorators.componentObserver({Event:[{prop:["hitArea"],deep:!0}]})],r);var i,s=r;exports.HIT_AREA_TYPE=void 0,(i=exports.HIT_AREA_TYPE||(exports.HIT_AREA_TYPE={})).Circle="Circle",i.Ellipse="Ellipse",i.Polygon="Polygon",i.Rect="Rect",i.RoundedRect="RoundedRect";class p extends t.Component{constructor(){super(...arguments),this.hitArea=void 0}init(e){e&&Object.assign(this,e)}emit(e,...t){return super.emit(e,...t)}once(e,t,o){return super.once(e,t,o)}on(e,t,o){return super.on(e,t,o)}}p.componentName="Event",exports.Event=p,exports.EventSystem=s;
@@ -1,4 +1,4 @@
1
- import { RendererSystem, Renderer } from '@eva/plugin-renderer';
1
+ import { Renderer, RendererSystem } from '@eva/plugin-renderer';
2
2
  import { OBSERVER_TYPE, decorators, Component } from '@eva/eva.js';
3
3
  import { Circle, Ellipse, Polygon, Rectangle, RoundedRectangle } from 'pixi.js';
4
4
 
@@ -16,88 +16,38 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
16
16
  See the Apache Version 2.0 License for specific language governing permissions
17
17
  and limitations under the License.
18
18
  ***************************************************************************** */
19
- /* global Reflect, Promise */
20
-
21
- var extendStatics = function(d, b) {
22
- extendStatics = Object.setPrototypeOf ||
23
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
24
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25
- return extendStatics(d, b);
26
- };
27
-
28
- function __extends(d, b) {
29
- extendStatics(d, b);
30
- function __() { this.constructor = d; }
31
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32
- }
33
19
 
34
20
  function __decorate(decorators, target, key, desc) {
35
21
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
36
22
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
37
23
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
38
24
  return c > 3 && r && Object.defineProperty(target, key, r), r;
39
- }
40
-
41
- function __values(o) {
42
- var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
43
- if (m) return m.call(o);
44
- return {
45
- next: function () {
46
- if (o && i >= o.length) o = void 0;
47
- return { value: o && o[i++], done: !o };
48
- }
49
- };
50
- }
51
-
52
- function __read(o, n) {
53
- var m = typeof Symbol === "function" && o[Symbol.iterator];
54
- if (!m) return o;
55
- var i = m.call(o), r, ar = [], e;
56
- try {
57
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
58
- }
59
- catch (error) { e = { error: error }; }
60
- finally {
61
- try {
62
- if (r && !r.done && (m = i["return"])) m.call(i);
63
- }
64
- finally { if (e) throw e.error; }
65
- }
66
- return ar;
67
- }
68
-
69
- function __spread() {
70
- for (var ar = [], i = 0; i < arguments.length; i++)
71
- ar = ar.concat(__read(arguments[i]));
72
- return ar;
73
25
  }
74
26
 
75
- var hitAreaFunc = {
76
- Circle: Circle,
77
- Ellipse: Ellipse,
78
- Polygon: Polygon,
27
+ const hitAreaFunc = {
28
+ Circle,
29
+ Ellipse,
30
+ Polygon,
79
31
  Rect: Rectangle,
80
32
  RoundedRect: RoundedRectangle,
81
33
  };
82
- var propertyForHitArea = {
34
+ const propertyForHitArea = {
83
35
  Circle: ['x', 'y', 'radius'],
84
36
  Ellipse: ['x', 'y', 'width', 'height'],
85
37
  Rect: ['x', 'y', 'width', 'height'],
86
38
  RoundedRect: ['x', 'y', 'width', 'height', 'radius'],
87
39
  Polygon: ['paths'],
88
40
  };
89
- var Event$2 = (function (_super) {
90
- __extends(Event, _super);
91
- function Event() {
92
- var _this = _super !== null && _super.apply(this, arguments) || this;
93
- _this.name = 'Event';
94
- return _this;
41
+ let Event$1 = class Event extends Renderer {
42
+ constructor() {
43
+ super(...arguments);
44
+ this.name = 'Event';
95
45
  }
96
- Event.prototype.init = function () {
46
+ init() {
97
47
  this.renderSystem = this.game.getSystem(RendererSystem);
98
48
  this.renderSystem.rendererManager.register(this);
99
- };
100
- Event.prototype.componentChanged = function (changed) {
49
+ }
50
+ componentChanged(changed) {
101
51
  switch (changed.type) {
102
52
  case OBSERVER_TYPE.ADD:
103
53
  this.add(changed);
@@ -109,18 +59,18 @@ var Event$2 = (function (_super) {
109
59
  this.change(changed);
110
60
  break;
111
61
  }
112
- };
113
- Event.prototype.add = function (changed) {
114
- var container = this.containerManager.getContainer(changed.gameObject.id);
62
+ }
63
+ add(changed) {
64
+ const container = this.containerManager.getContainer(changed.gameObject.id);
115
65
  container.interactive = true;
116
66
  container.interactiveChildren = true;
117
- var component = changed.component;
67
+ const component = changed.component;
118
68
  if (component.hitArea) {
119
69
  this.addHitArea(changed, container, component.hitArea);
120
70
  }
121
- container.on('pointertap', function (e) {
71
+ container.on('pointertap', e => {
122
72
  component.emit('tap', {
123
- stopPropagation: function () { return e.stopPropagation(); },
73
+ stopPropagation: () => e.stopPropagation(),
124
74
  data: {
125
75
  pointerId: e.data.pointerId,
126
76
  position: {
@@ -132,9 +82,9 @@ var Event$2 = (function (_super) {
132
82
  gameObject: component.gameObject,
133
83
  });
134
84
  });
135
- container.on('pointerdown', function (e) {
85
+ container.on('pointerdown', e => {
136
86
  component.emit('touchstart', {
137
- stopPropagation: function () { return e.stopPropagation(); },
87
+ stopPropagation: () => e.stopPropagation(),
138
88
  data: {
139
89
  pointerId: e.data.pointerId,
140
90
  position: {
@@ -146,9 +96,9 @@ var Event$2 = (function (_super) {
146
96
  gameObject: component.gameObject,
147
97
  });
148
98
  });
149
- container.on('pointermove', function (e) {
99
+ container.on('pointermove', e => {
150
100
  component.emit('touchmove', {
151
- stopPropagation: function () { return e.stopPropagation(); },
101
+ stopPropagation: () => e.stopPropagation(),
152
102
  data: {
153
103
  pointerId: e.data.pointerId,
154
104
  position: {
@@ -160,9 +110,9 @@ var Event$2 = (function (_super) {
160
110
  gameObject: component.gameObject,
161
111
  });
162
112
  });
163
- container.on('pointerup', function (e) {
113
+ container.on('pointerup', e => {
164
114
  component.emit('touchend', {
165
- stopPropagation: function () { return e.stopPropagation(); },
115
+ stopPropagation: () => e.stopPropagation(),
166
116
  data: {
167
117
  pointerId: e.data.pointerId,
168
118
  position: {
@@ -174,9 +124,9 @@ var Event$2 = (function (_super) {
174
124
  gameObject: component.gameObject,
175
125
  });
176
126
  });
177
- container.on('pointerupoutside', function (e) {
127
+ container.on('pointerupoutside', e => {
178
128
  component.emit('touchendoutside', {
179
- stopPropagation: function () { return e.stopPropagation(); },
129
+ stopPropagation: () => e.stopPropagation(),
180
130
  data: {
181
131
  pointerId: e.data.pointerId,
182
132
  position: {
@@ -188,9 +138,9 @@ var Event$2 = (function (_super) {
188
138
  gameObject: component.gameObject,
189
139
  });
190
140
  });
191
- container.on('pointercancel', function (e) {
141
+ container.on('pointercancel', e => {
192
142
  component.emit('touchcancel', {
193
- stopPropagation: function () { return e.stopPropagation(); },
143
+ stopPropagation: () => e.stopPropagation(),
194
144
  data: {
195
145
  pointerId: e.data.pointerId,
196
146
  position: {
@@ -202,9 +152,9 @@ var Event$2 = (function (_super) {
202
152
  gameObject: component.gameObject,
203
153
  });
204
154
  });
205
- };
206
- Event.prototype.remove = function (changed) {
207
- var container = this.containerManager.getContainer(changed.gameObject.id);
155
+ }
156
+ remove(changed) {
157
+ const container = this.containerManager.getContainer(changed.gameObject.id);
208
158
  container.interactive = false;
209
159
  container.off('tap');
210
160
  container.off('pointerdown');
@@ -213,51 +163,39 @@ var Event$2 = (function (_super) {
213
163
  container.off('pointerupoutside');
214
164
  container.off('pointercancel');
215
165
  changed.component.removeAllListeners();
216
- };
217
- Event.prototype.change = function (changed) {
218
- var container = this.containerManager.getContainer(changed.gameObject.id);
166
+ }
167
+ change(changed) {
168
+ const container = this.containerManager.getContainer(changed.gameObject.id);
219
169
  container.interactive = true;
220
- var component = changed.component;
170
+ const component = changed.component;
221
171
  if (component.hitArea) {
222
172
  this.addHitArea(changed, container, component.hitArea);
223
173
  }
224
174
  else {
225
175
  component.hitArea = null;
226
176
  }
227
- };
228
- Event.prototype.addHitArea = function (changed, container, hitArea) {
229
- var e_1, _a, _b;
230
- var type = hitArea.type, style = hitArea.style;
177
+ }
178
+ addHitArea(changed, container, hitArea) {
179
+ const { type, style } = hitArea;
231
180
  if (!hitAreaFunc[type]) {
232
- console.error(changed.gameObject.name + "'s hitArea type is not defined");
181
+ console.error(`${changed.gameObject.name}'s hitArea type is not defined`);
233
182
  return;
234
183
  }
235
- var params = [];
236
- try {
237
- for (var _c = __values(propertyForHitArea[type]), _d = _c.next(); !_d.done; _d = _c.next()) {
238
- var key = _d.value;
239
- params.push(style[key]);
240
- }
241
- }
242
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
243
- finally {
244
- try {
245
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
246
- }
247
- finally { if (e_1) throw e_1.error; }
184
+ const params = [];
185
+ for (const key of propertyForHitArea[type]) {
186
+ params.push(style[key]);
248
187
  }
249
- var hitAreaShape = new ((_b = hitAreaFunc[type]).bind.apply(_b, __spread([void 0], params)))();
188
+ const hitAreaShape = new hitAreaFunc[type](...params);
250
189
  container.hitArea = hitAreaShape;
251
- };
252
- Event.systemName = 'Event';
253
- Event = __decorate([
254
- decorators.componentObserver({
255
- Event: [{ prop: ['hitArea'], deep: true }],
256
- })
257
- ], Event);
258
- return Event;
259
- }(Renderer));
260
- var Event$3 = Event$2;
190
+ }
191
+ };
192
+ Event$1.systemName = 'Event';
193
+ Event$1 = __decorate([
194
+ decorators.componentObserver({
195
+ Event: [{ prop: ['hitArea'], deep: true }],
196
+ })
197
+ ], Event$1);
198
+ var Event$2 = Event$1;
261
199
 
262
200
  var HIT_AREA_TYPE;
263
201
  (function (HIT_AREA_TYPE) {
@@ -267,32 +205,24 @@ var HIT_AREA_TYPE;
267
205
  HIT_AREA_TYPE["Rect"] = "Rect";
268
206
  HIT_AREA_TYPE["RoundedRect"] = "RoundedRect";
269
207
  })(HIT_AREA_TYPE || (HIT_AREA_TYPE = {}));
270
- var Event = (function (_super) {
271
- __extends(Event, _super);
272
- function Event() {
273
- var _this = _super !== null && _super.apply(this, arguments) || this;
274
- _this.hitArea = undefined;
275
- return _this;
208
+ class Event extends Component {
209
+ constructor() {
210
+ super(...arguments);
211
+ this.hitArea = undefined;
276
212
  }
277
- Event.prototype.init = function (params) {
213
+ init(params) {
278
214
  params && Object.assign(this, params);
279
- };
280
- Event.prototype.emit = function (en) {
281
- var args = [];
282
- for (var _i = 1; _i < arguments.length; _i++) {
283
- args[_i - 1] = arguments[_i];
284
- }
285
- return _super.prototype.emit.apply(this, __spread([en], args));
286
- };
287
- Event.prototype.once = function (en, fn, context) {
288
- return _super.prototype.once.call(this, en, fn, context);
289
- };
290
- Event.prototype.on = function (en, fn, context) {
291
- return _super.prototype.on.call(this, en, fn, context);
292
- };
293
- Event.componentName = 'Event';
294
- return Event;
295
- }(Component));
296
- var Event$1 = Event;
215
+ }
216
+ emit(en, ...args) {
217
+ return super.emit(en, ...args);
218
+ }
219
+ once(en, fn, context) {
220
+ return super.once(en, fn, context);
221
+ }
222
+ on(en, fn, context) {
223
+ return super.on(en, fn, context);
224
+ }
225
+ }
226
+ Event.componentName = 'Event';
297
227
 
298
- export { Event$1 as Event, Event$3 as EventSystem, HIT_AREA_TYPE };
228
+ export { Event, Event$2 as EventSystem, HIT_AREA_TYPE };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-event",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "@eva/plugin-renderer-event",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-event.esm.js",
@@ -18,8 +18,8 @@
18
18
  "license": "MIT",
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
- "@eva/plugin-renderer": "2.0.0-beta.1",
22
- "@eva/eva.js": "2.0.0-beta.1",
21
+ "@eva/plugin-renderer": "2.0.0-beta.2",
22
+ "@eva/eva.js": "2.0.0-beta.2",
23
23
  "pixi.js": "^8.6.3"
24
24
  }
25
25
  }