@eva/plugin-a11y 1.2.7-fix.4 → 1.2.7-fix.6

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.
@@ -1,6 +1,8 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
2
3
  window.EVA = window.EVA || {};
3
4
  window.EVA.plugin = window.EVA.plugin || {};
5
+
4
6
  var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
5
7
  'use strict';
6
8
 
@@ -14,42 +16,53 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
14
16
  if (b.hasOwnProperty(p)) d[p] = b[p];
15
17
  }
16
18
  };
19
+
17
20
  return _extendStatics(d, b);
18
21
  };
22
+
19
23
  function __extends(d, b) {
20
24
  _extendStatics(d, b);
25
+
21
26
  function __() {
22
27
  this.constructor = d;
23
28
  }
29
+
24
30
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25
31
  }
32
+
26
33
  var _assign = function __assign() {
27
34
  _assign = Object.assign || function __assign(t) {
28
35
  for (var s, i = 1, n = arguments.length; i < n; i++) {
29
36
  s = arguments[i];
37
+
30
38
  for (var p in s) {
31
39
  if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
32
40
  }
33
41
  }
42
+
34
43
  return t;
35
44
  };
45
+
36
46
  return _assign.apply(this, arguments);
37
47
  };
48
+
38
49
  function __decorate(decorators, target, key, desc) {
39
50
  var c = arguments.length,
40
- r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
41
- d;
51
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
52
+ d;
42
53
  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--) {
43
54
  if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
44
55
  }
45
56
  return c > 3 && r && Object.defineProperty(target, key, r), r;
46
57
  }
58
+
47
59
  function __awaiter(thisArg, _arguments, P, generator) {
48
60
  function adopt(value) {
49
61
  return value instanceof P ? value : new P(function (resolve) {
50
62
  resolve(value);
51
63
  });
52
64
  }
65
+
53
66
  return new (P || (P = Promise))(function (resolve, reject) {
54
67
  function fulfilled(value) {
55
68
  try {
@@ -58,6 +71,7 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
58
71
  reject(e);
59
72
  }
60
73
  }
74
+
61
75
  function rejected(value) {
62
76
  try {
63
77
  step(generator["throw"](value));
@@ -65,26 +79,29 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
65
79
  reject(e);
66
80
  }
67
81
  }
82
+
68
83
  function step(result) {
69
84
  result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
70
85
  }
86
+
71
87
  step((generator = generator.apply(thisArg, _arguments || [])).next());
72
88
  });
73
89
  }
90
+
74
91
  function __generator(thisArg, body) {
75
92
  var _ = {
76
- label: 0,
77
- sent: function sent() {
78
- if (t[0] & 1) throw t[1];
79
- return t[1];
80
- },
81
- trys: [],
82
- ops: []
93
+ label: 0,
94
+ sent: function sent() {
95
+ if (t[0] & 1) throw t[1];
96
+ return t[1];
83
97
  },
84
- f,
85
- y,
86
- t,
87
- g;
98
+ trys: [],
99
+ ops: []
100
+ },
101
+ f,
102
+ y,
103
+ t,
104
+ g;
88
105
  return g = {
89
106
  next: verb(0),
90
107
  "throw": verb(1),
@@ -92,60 +109,79 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
92
109
  }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
93
110
  return this;
94
111
  }), g;
112
+
95
113
  function verb(n) {
96
114
  return function (v) {
97
115
  return step([n, v]);
98
116
  };
99
117
  }
118
+
100
119
  function step(op) {
101
120
  if (f) throw new TypeError("Generator is already executing.");
121
+
102
122
  while (_) {
103
123
  try {
104
124
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
105
125
  if (y = 0, t) op = [op[0] & 2, t.value];
126
+
106
127
  switch (op[0]) {
107
128
  case 0:
108
129
  case 1:
109
130
  t = op;
110
131
  break;
132
+
111
133
  case 4:
112
134
  _.label++;
113
135
  return {
114
136
  value: op[1],
115
137
  done: false
116
138
  };
139
+
117
140
  case 5:
118
141
  _.label++;
119
142
  y = op[1];
120
143
  op = [0];
121
144
  continue;
145
+
122
146
  case 7:
123
147
  op = _.ops.pop();
148
+
124
149
  _.trys.pop();
150
+
125
151
  continue;
152
+
126
153
  default:
127
154
  if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
128
155
  _ = 0;
129
156
  continue;
130
157
  }
158
+
131
159
  if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
132
160
  _.label = op[1];
133
161
  break;
134
162
  }
163
+
135
164
  if (op[0] === 6 && _.label < t[1]) {
136
165
  _.label = t[1];
137
166
  t = op;
138
167
  break;
139
168
  }
169
+
140
170
  if (t && _.label < t[2]) {
141
171
  _.label = t[2];
172
+
142
173
  _.ops.push(op);
174
+
143
175
  break;
144
176
  }
177
+
145
178
  if (t[2]) _.ops.pop();
179
+
146
180
  _.trys.pop();
181
+
147
182
  continue;
148
183
  }
184
+
149
185
  op = body.call(thisArg, _);
150
186
  } catch (e) {
151
187
  op = [6, e];
@@ -154,6 +190,7 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
154
190
  f = t = 0;
155
191
  }
156
192
  }
193
+
157
194
  if (op[0] & 5) throw op[1];
158
195
  return {
159
196
  value: op[0] ? op[1] : void 0,
@@ -161,10 +198,11 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
161
198
  };
162
199
  }
163
200
  }
201
+
164
202
  function __values(o) {
165
203
  var s = typeof Symbol === "function" && Symbol.iterator,
166
- m = s && o[s],
167
- i = 0;
204
+ m = s && o[s],
205
+ i = 0;
168
206
  if (m) return m.call(o);
169
207
  if (o && typeof o.length === "number") return {
170
208
  next: function next() {
@@ -177,16 +215,20 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
177
215
  };
178
216
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
179
217
  }
218
+
180
219
  function getIDEPropsPropertyObj(target, propertyKey) {
181
220
  if (!target.constructor.IDEProps) {
182
221
  target.constructor.IDEProps = {};
183
222
  }
223
+
184
224
  if (!target.constructor.IDEProps[propertyKey]) {
185
225
  target.constructor.IDEProps[propertyKey] = {};
186
226
  }
227
+
187
228
  var propertyObj = target.constructor.IDEProps[propertyKey];
188
229
  return propertyObj;
189
230
  }
231
+
190
232
  function type(type) {
191
233
  return function (target, propertyKey) {
192
234
  var prop = getIDEPropsPropertyObj(target, propertyKey);
@@ -194,32 +236,37 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
194
236
  prop.type = type;
195
237
  };
196
238
  }
239
+
197
240
  function step(step) {
198
241
  return function (target, propertyKey) {
199
242
  var prop = getIDEPropsPropertyObj(target, propertyKey);
200
243
  prop.step = step;
201
244
  };
202
245
  }
246
+
203
247
  function uuid(len) {
204
248
  var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
205
249
  var uuid = [];
206
250
  var radix = chars.length;
251
+
207
252
  for (var i = 0; i < len; i++) {
208
253
  uuid[i] = chars[0 | Math.random() * radix];
209
254
  }
255
+
210
256
  return uuid.join('');
211
257
  }
258
+
212
259
  var setStyle = function setStyle(element, style) {
213
260
  var width = style.width,
214
- height = style.height,
215
- position = style.position,
216
- _a = style.left,
217
- left = _a === void 0 ? 0 : _a,
218
- _b = style.top,
219
- top = _b === void 0 ? 0 : _b,
220
- zIndex = style.zIndex,
221
- pointerEvents = style.pointerEvents,
222
- background = style.background;
261
+ height = style.height,
262
+ position = style.position,
263
+ _a = style.left,
264
+ left = _a === void 0 ? 0 : _a,
265
+ _b = style.top,
266
+ top = _b === void 0 ? 0 : _b,
267
+ zIndex = style.zIndex,
268
+ pointerEvents = style.pointerEvents,
269
+ background = style.background;
223
270
  element.style.width = width + "px";
224
271
  element.style.height = height + "px";
225
272
  element.style.position = position;
@@ -231,38 +278,43 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
231
278
  element.style.border = 'none';
232
279
  element.style.overflow = 'hidden';
233
280
  };
281
+
234
282
  var setTransform = function setTransform(element, transform, ratioX, ratioY) {
235
283
  var worldTransform = transform.worldTransform;
236
284
  var a = worldTransform.a,
237
- b = worldTransform.b,
238
- c = worldTransform.c,
239
- d = worldTransform.d,
240
- tx = worldTransform.tx,
241
- ty = worldTransform.ty;
285
+ b = worldTransform.b,
286
+ c = worldTransform.c,
287
+ d = worldTransform.d,
288
+ tx = worldTransform.tx,
289
+ ty = worldTransform.ty;
242
290
  var matrix = "matrix(" + a + ", " + b + ", " + c + ", " + d + ", " + tx * ratioX + ", " + ty * ratioY + ")";
243
291
  element.style.transform = "" + matrix;
244
292
  element.style.webkitTransform = "" + matrix;
245
293
  element.style.transformOrigin = 'left top';
246
294
  element.style.webkitTransformOrigin = 'left top';
247
295
  };
296
+
248
297
  var A11y = function (_super) {
249
298
  __extends(A11y, _super);
299
+
250
300
  function A11y(param) {
251
301
  var _this = _super.call(this) || this;
302
+
252
303
  _extends(_this, param);
304
+
253
305
  var _a = param.hint,
254
- hint = _a === void 0 ? '' : _a,
255
- event = param.event,
256
- _b = param.delay,
257
- delay = _b === void 0 ? 0 : _b,
258
- _c = param.attr,
259
- attr = _c === void 0 ? {} : _c,
260
- _d = param.role,
261
- role = _d === void 0 ? '' : _d,
262
- _e = param.props,
263
- props = _e === void 0 ? {} : _e,
264
- _f = param.state,
265
- state = _f === void 0 ? {} : _f;
306
+ hint = _a === void 0 ? '' : _a,
307
+ event = param.event,
308
+ _b = param.delay,
309
+ delay = _b === void 0 ? 0 : _b,
310
+ _c = param.attr,
311
+ attr = _c === void 0 ? {} : _c,
312
+ _d = param.role,
313
+ role = _d === void 0 ? '' : _d,
314
+ _e = param.props,
315
+ props = _e === void 0 ? {} : _e,
316
+ _f = param.state,
317
+ state = _f === void 0 ? {} : _f;
266
318
  _this.hint = hint;
267
319
  _this.event = event;
268
320
  _this.delay = delay;
@@ -273,41 +325,59 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
273
325
  _this.a11yId = "_" + uuid(6);
274
326
  return _this;
275
327
  }
328
+
276
329
  A11y.componentName = 'A11y';
330
+
277
331
  __decorate([type('boolean')], A11y.prototype, "interactive", void 0);
332
+
278
333
  __decorate([type('string')], A11y.prototype, "hint", void 0);
334
+
279
335
  __decorate([type('number'), step(1)], A11y.prototype, "delay", void 0);
336
+
280
337
  __decorate([type('string')], A11y.prototype, "role", void 0);
338
+
281
339
  __decorate([type('string')], A11y.prototype, "a11yId", void 0);
340
+
282
341
  return A11y;
283
342
  }(eva_js.Component);
343
+
284
344
  var A11y$1 = A11y;
285
345
  var POSITION = 'absolute';
286
346
  var ZINDEX = 3;
287
347
  exports.A11yActivate = void 0;
348
+
288
349
  (function (A11yActivate) {
289
350
  A11yActivate[A11yActivate["ENABLE"] = 0] = "ENABLE";
290
351
  A11yActivate[A11yActivate["DISABLE"] = 1] = "DISABLE";
291
352
  A11yActivate[A11yActivate["CHECK"] = 2] = "CHECK";
292
353
  })(exports.A11yActivate || (exports.A11yActivate = {}));
354
+
293
355
  var PointerEvents;
356
+
294
357
  (function (PointerEvents) {
295
358
  PointerEvents["NONE"] = "none";
296
359
  PointerEvents["AUTO"] = "auto";
297
360
  })(PointerEvents || (PointerEvents = {}));
361
+
298
362
  var MaskBackground;
363
+
299
364
  (function (MaskBackground) {
300
365
  MaskBackground["DEBUG"] = "rgba(255,0,0,0.5)";
301
366
  MaskBackground["NONE"] = "transparent";
302
367
  })(MaskBackground || (MaskBackground = {}));
368
+
303
369
  var ElementType;
370
+
304
371
  (function (ElementType) {
305
372
  ElementType["BUTTON"] = "button";
306
373
  ElementType["DIV"] = "div";
307
374
  })(ElementType || (ElementType = {}));
375
+
308
376
  var notAttr = ['hint', 'event', 'delay', 'attr', 'role', 'props', 'state', 'a11yId', 'name'];
377
+
309
378
  var getEventFunc = function getEventFunc(event, gameObject, e) {
310
379
  var _this = this;
380
+
311
381
  ['touchstart', 'touchend', 'tap'].forEach(function (name) {
312
382
  event.emit(name, {
313
383
  stopPropagation: function stopPropagation() {
@@ -320,21 +390,26 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
320
390
  });
321
391
  });
322
392
  };
393
+
323
394
  var A11ySystem = function (_super) {
324
395
  __extends(A11ySystem, _super);
396
+
325
397
  function A11ySystem(opt) {
326
398
  var _this = _super.call(this, opt) || this;
399
+
327
400
  _this.cache = new Map();
328
401
  _this.eventCache = new Map();
329
402
  _this.zIndex = ZINDEX;
330
403
  return _this;
331
404
  }
405
+
332
406
  Object.defineProperty(A11ySystem.prototype, "ratioX", {
333
407
  get: function get() {
334
408
  if (this._ratioX) {
335
409
  return this._ratioX;
336
410
  } else {
337
411
  var success = this.setRatio();
412
+
338
413
  if (success) {
339
414
  return this._ratioX;
340
415
  } else {
@@ -351,6 +426,7 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
351
426
  return this._ratioY;
352
427
  } else {
353
428
  var success = this.setRatio();
429
+
354
430
  if (success) {
355
431
  return this._ratioY;
356
432
  } else {
@@ -361,12 +437,15 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
361
437
  enumerable: false,
362
438
  configurable: true
363
439
  });
440
+
364
441
  A11ySystem.prototype.init = function (opt) {
365
442
  if (opt === void 0) {
366
443
  opt = {};
367
444
  }
445
+
368
446
  return __awaiter(this, void 0, void 0, function () {
369
447
  var _a, activate, _b, delay, _c, checkA11yOpen, zIndex, _d, _e, div;
448
+
370
449
  return __generator(this, function (_f) {
371
450
  switch (_f.label) {
372
451
  case 0:
@@ -376,59 +455,80 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
376
455
  this.delay = delay;
377
456
  this.zIndex = zIndex || this.zIndex;
378
457
  _d = activate;
458
+
379
459
  switch (_d) {
380
460
  case exports.A11yActivate.CHECK:
381
461
  return [3, 1];
462
+
382
463
  case exports.A11yActivate.DISABLE:
383
464
  return [3, 5];
465
+
384
466
  case exports.A11yActivate.ENABLE:
385
467
  return [3, 6];
386
468
  }
469
+
387
470
  return [3, 7];
471
+
388
472
  case 1:
389
473
  _f.trys.push([1, 3,, 4]);
474
+
390
475
  _e = this;
391
476
  return [4, checkA11yOpen()];
477
+
392
478
  case 2:
393
479
  _e.activate = _f.sent();
394
480
  return [3, 4];
481
+
395
482
  case 3:
396
483
  _f.sent();
484
+
397
485
  this.activate = false;
398
486
  return [3, 4];
487
+
399
488
  case 4:
400
489
  return [3, 7];
490
+
401
491
  case 5:
402
492
  this.activate = false;
403
493
  return [3, 7];
494
+
404
495
  case 6:
405
496
  this.activate = true;
406
497
  return [3, 7];
498
+
407
499
  case 7:
408
500
  this.debug = opt.debug || false;
501
+
409
502
  if (this.debug) {
410
503
  this.activate = true;
411
504
  }
505
+
412
506
  if (!this.activate) return [2];
413
507
  div = document.createElement('div');
414
508
  this.div = div;
509
+
415
510
  if (this.game.canvas.parentNode) {
416
511
  this.game.canvas.parentNode.insertBefore(this.div, this.game.canvas);
417
512
  }
513
+
418
514
  return [2];
419
515
  }
420
516
  });
421
517
  });
422
518
  };
519
+
423
520
  A11ySystem.prototype.setRatio = function () {
424
521
  var _a = this.getCanvasBoundingClientRect(),
425
- width = _a.width,
426
- height = _a.height;
522
+ width = _a.width,
523
+ height = _a.height;
524
+
427
525
  var _b = this.getRenderRect(),
428
- renderWidth = _b.renderWidth,
429
- renderHeight = _b.renderHeight;
526
+ renderWidth = _b.renderWidth,
527
+ renderHeight = _b.renderHeight;
528
+
430
529
  this._ratioX = width / renderWidth;
431
530
  this._ratioY = height / renderHeight;
531
+
432
532
  if (width || height) {
433
533
  this.initDiv();
434
534
  return true;
@@ -436,25 +536,28 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
436
536
  return false;
437
537
  }
438
538
  };
539
+
439
540
  A11ySystem.prototype.getRenderRect = function () {
440
541
  var _a = this.game.getSystem(pluginRenderer.RendererSystem).params,
441
- params = _a === void 0 ? {
442
- width: 300,
443
- height: 300
444
- } : _a;
542
+ params = _a === void 0 ? {
543
+ width: 300,
544
+ height: 300
545
+ } : _a;
445
546
  var renderHeight = params.height,
446
- renderWidth = params.width;
547
+ renderWidth = params.width;
447
548
  return {
448
549
  renderWidth: renderWidth,
449
550
  renderHeight: renderHeight
450
551
  };
451
552
  };
553
+
452
554
  A11ySystem.prototype.getCanvasBoundingClientRect = function () {
453
555
  var _a = this.game.canvas.getBoundingClientRect(),
454
- width = _a.width,
455
- height = _a.height,
456
- left = _a.left,
457
- top = _a.top;
556
+ width = _a.width,
557
+ height = _a.height,
558
+ left = _a.left,
559
+ top = _a.top;
560
+
458
561
  return {
459
562
  width: width,
460
563
  height: height,
@@ -462,15 +565,19 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
462
565
  top: top
463
566
  };
464
567
  };
568
+
465
569
  A11ySystem.prototype.initDiv = function () {
466
570
  var _this = this;
571
+
467
572
  var pageXOffset = window.pageXOffset,
468
- pageYOffset = window.pageYOffset;
573
+ pageYOffset = window.pageYOffset;
574
+
469
575
  var _a = this.getCanvasBoundingClientRect(),
470
- width = _a.width,
471
- height = _a.height,
472
- left = _a.left,
473
- top = _a.top;
576
+ width = _a.width,
577
+ height = _a.height,
578
+ left = _a.left,
579
+ top = _a.top;
580
+
474
581
  var style = {
475
582
  width: width,
476
583
  height: height,
@@ -484,9 +591,11 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
484
591
  setStyle(this.div, style);
485
592
  this.div.addEventListener('click', function (e) {
486
593
  var currentTarget = e.currentTarget;
594
+
487
595
  var _a = currentTarget.getBoundingClientRect(),
488
- left = _a.left,
489
- top = _a.top;
596
+ left = _a.left,
597
+ top = _a.top;
598
+
490
599
  var x = (e.pageX - left) / _this.ratioX;
491
600
  var y = (e.pageY - top) / _this.ratioY;
492
601
  _this.eventPosition = {
@@ -495,27 +604,35 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
495
604
  };
496
605
  }, true);
497
606
  };
607
+
498
608
  A11ySystem.prototype.update = function () {
499
609
  return __awaiter(this, void 0, void 0, function () {
500
610
  var changes, changes_1, changes_1_1, changed;
611
+
501
612
  var e_1, _a;
613
+
502
614
  return __generator(this, function (_b) {
503
615
  changes = this.componentObserver.clear();
616
+
504
617
  if (!this.activate) {
505
618
  return [2];
506
619
  }
620
+
507
621
  try {
508
622
  for (changes_1 = __values(changes), changes_1_1 = changes_1.next(); !changes_1_1.done; changes_1_1 = changes_1.next()) {
509
623
  changed = changes_1_1.value;
624
+
510
625
  switch (changed.type) {
511
626
  case eva_js.OBSERVER_TYPE.ADD:
512
627
  changed.componentName === 'Event' && this.addEvent(changed.gameObject);
513
628
  changed.componentName === 'A11y' && this.add(changed);
514
629
  break;
630
+
515
631
  case eva_js.OBSERVER_TYPE.CHANGE:
516
632
  changed.componentName === 'Transform' && this.transformChange(changed);
517
633
  changed.componentName === 'A11y' && this.change(changed);
518
634
  break;
635
+
519
636
  case eva_js.OBSERVER_TYPE.REMOVE:
520
637
  changed.componentName === 'Event' && this.removeEvent(changed);
521
638
  changed.componentName === 'A11y' && this.remove(changed);
@@ -532,18 +649,22 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
532
649
  if (e_1) throw e_1.error;
533
650
  }
534
651
  }
652
+
535
653
  return [2];
536
654
  });
537
655
  });
538
656
  };
657
+
539
658
  A11ySystem.prototype.change = function (changed) {
540
659
  var component = changed.component;
660
+
541
661
  if (changed.prop.prop[0] === 'hint') {
542
662
  var dom = this.cache.get(component.a11yId);
543
663
  dom === null || dom === void 0 ? void 0 : dom.setAttribute('aria-label', component.hint);
544
664
  dom && this.setPosition(dom, changed.gameObject.transform);
545
665
  }
546
666
  };
667
+
547
668
  A11ySystem.prototype.remove = function (changed) {
548
669
  var component = changed.component;
549
670
  if (!component) return;
@@ -552,39 +673,48 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
552
673
  element && this.div.removeChild(element);
553
674
  this.cache.delete(a11yId);
554
675
  };
676
+
555
677
  A11ySystem.prototype.add = function (changed) {
556
678
  var _this = this;
679
+
557
680
  if (!this.activate) return;
558
681
  var component = changed.component;
559
682
  var gameObject = changed.gameObject;
560
683
  var delay = component.delay,
561
- id = component.a11yId;
684
+ id = component.a11yId;
562
685
  var event = component.event;
563
686
  if (!gameObject) return;
564
687
  var transform = gameObject.transform;
565
688
  if (!transform) return;
566
689
  var element = document.createElement('div');
567
690
  this.cache.set(id, element);
691
+
568
692
  if (!event) {
569
693
  event = gameObject.getComponent('Event');
570
694
  }
695
+
571
696
  setTimeout(function () {
572
697
  _this.setPosition(element, transform);
698
+
573
699
  _this.setA11yAttr(element, component);
700
+
574
701
  if (event) {
575
702
  _this.addEvent(gameObject);
576
703
  }
704
+
577
705
  if (gameObject.scene) {
578
706
  _this.div.appendChild(element);
579
707
  }
580
708
  }, delay || this.delay);
581
709
  };
710
+
582
711
  A11ySystem.prototype.transformChange = function (changed) {
583
712
  var component = changed.component;
584
713
  var gameObject = changed.gameObject;
585
714
  var a11yComponent = gameObject.getComponent(A11y$1);
586
715
  if (!a11yComponent) return;
587
716
  var a11yId = a11yComponent.a11yId;
717
+
588
718
  if (!component.inScene) {
589
719
  var dom = this.div.querySelector("#" + a11yId);
590
720
  dom && this.div.removeChild(dom);
@@ -595,14 +725,17 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
595
725
  }
596
726
  }
597
727
  };
728
+
598
729
  A11ySystem.prototype.setEvent = function (element, event, gameObject, id) {
599
730
  if (!event) {
600
731
  return;
601
732
  }
733
+
602
734
  var func = getEventFunc.bind(this, event, gameObject);
603
735
  this.eventCache.set(id, func);
604
736
  element.addEventListener('click', func);
605
737
  };
738
+
606
739
  A11ySystem.prototype.addEvent = function (gameObject) {
607
740
  var a11y = gameObject.getComponent(A11y$1);
608
741
  if (!a11y) return;
@@ -611,6 +744,7 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
611
744
  var element = this.cache.get(a11y.a11yId);
612
745
  element && this.setEvent(element, event, gameObject, a11y.a11yId);
613
746
  };
747
+
614
748
  A11ySystem.prototype.removeEvent = function (changed) {
615
749
  var gameObject = changed.gameObject;
616
750
  var a11y = gameObject.getComponent(A11y$1);
@@ -622,20 +756,23 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
622
756
  var element = this.cache.get(a11yId);
623
757
  element && element.removeEventListener('click', func);
624
758
  };
759
+
625
760
  A11ySystem.prototype.setA11yAttr = function (element, component) {
626
761
  var e_2, _a, e_3, _b, e_4, _c;
762
+
627
763
  var hint = component.hint,
628
- _d = component.props,
629
- props = _d === void 0 ? {} : _d,
630
- _e = component.state,
631
- state = _e === void 0 ? {} : _e,
632
- role = component.role,
633
- id = component.a11yId;
764
+ _d = component.props,
765
+ props = _d === void 0 ? {} : _d,
766
+ _e = component.state,
767
+ state = _e === void 0 ? {} : _e,
768
+ role = component.role,
769
+ id = component.a11yId;
634
770
  var realRole = role || 'text';
635
771
  element.setAttribute('role', realRole);
636
772
  element.setAttribute('aria-label', hint);
637
773
  element.id = id;
638
774
  var ariaProps = Object.keys(props);
775
+
639
776
  try {
640
777
  for (var ariaProps_1 = __values(ariaProps), ariaProps_1_1 = ariaProps_1.next(); !ariaProps_1_1.done; ariaProps_1_1 = ariaProps_1.next()) {
641
778
  var key = ariaProps_1_1.value;
@@ -652,7 +789,9 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
652
789
  if (e_2) throw e_2.error;
653
790
  }
654
791
  }
792
+
655
793
  var ariaState = Object.keys(state);
794
+
656
795
  try {
657
796
  for (var ariaState_1 = __values(ariaState), ariaState_1_1 = ariaState_1.next(); !ariaState_1_1.done; ariaState_1_1 = ariaState_1.next()) {
658
797
  var key = ariaState_1_1.value;
@@ -669,9 +808,11 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
669
808
  if (e_3) throw e_3.error;
670
809
  }
671
810
  }
811
+
672
812
  try {
673
813
  for (var _f = __values(Object.keys(component)), _g = _f.next(); !_g.done; _g = _f.next()) {
674
814
  var key = _g.value;
815
+
675
816
  if (typeof component[key] === 'string' && notAttr.indexOf(key) === -1 && key.indexOf('_') !== 1) {
676
817
  element.setAttribute(key, component[key]);
677
818
  }
@@ -688,10 +829,11 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
688
829
  }
689
830
  }
690
831
  };
832
+
691
833
  A11ySystem.prototype.setPosition = function (element, transform) {
692
834
  var _a = transform.size,
693
- width = _a.width,
694
- height = _a.height;
835
+ width = _a.width,
836
+ height = _a.height;
695
837
  var style = {
696
838
  width: width === 0 ? 1 : width * this.ratioX,
697
839
  height: height === 0 ? 1 : height * this.ratioY,
@@ -700,16 +842,20 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
700
842
  pointerEvents: PointerEvents.AUTO,
701
843
  background: this.debug ? MaskBackground.DEBUG : MaskBackground.NONE
702
844
  };
845
+
703
846
  var transformProps = _assign({}, transform);
847
+
704
848
  setStyle(element, style);
705
849
  setTransform(element, transformProps, this.ratioX, this.ratioY);
706
850
  };
851
+
707
852
  A11ySystem.prototype.onDestroy = function () {
708
853
  this.div.parentElement.removeChild(this.div);
709
854
  this.cache = null;
710
855
  this.eventCache = null;
711
856
  this.div = null;
712
857
  };
858
+
713
859
  A11ySystem.systemName = 'A11ySystem';
714
860
  A11ySystem = __decorate([eva_js.decorators.componentObserver({
715
861
  A11y: ['hint'],
@@ -718,6 +864,7 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
718
864
  })], A11ySystem);
719
865
  return A11ySystem;
720
866
  }(eva_js.System);
867
+
721
868
  var A11ySystem$1 = A11ySystem;
722
869
  exports.A11y = A11y$1;
723
870
  exports.A11ySystem = A11ySystem$1;
@@ -726,4 +873,5 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
726
873
  });
727
874
  return exports;
728
875
  }({}, EVA, EVA.plugin.renderer);
876
+
729
877
  window.EVA.plugin.a11y = window.EVA.plugin.a11y || _EVA_IIFE_a11y;