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