@eva/plugin-a11y 1.2.0-alpha.8 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/dist/EVA.plugin.a11y.js +0 -875
- package/dist/EVA.plugin.a11y.min.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-a11y",
|
|
3
|
-
"version": "1.2.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "@eva/plugin-a11y",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-a11y.esm.js",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@eva/eva.js": "1.2.0
|
|
21
|
+
"@eva/eva.js": "1.2.0",
|
|
22
22
|
"@eva/inspector-decorator": "^0.0.5",
|
|
23
|
-
"@eva/plugin-renderer": "1.2.0
|
|
23
|
+
"@eva/plugin-renderer": "1.2.0",
|
|
24
24
|
"eventemitter3": "^3.1.2"
|
|
25
25
|
}
|
|
26
26
|
}
|
package/dist/EVA.plugin.a11y.js
DELETED
|
@@ -1,875 +0,0 @@
|
|
|
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
|
-
this.EVA = this.EVA || {};
|
|
4
|
-
this.EVA.plugin = this.EVA.plugin || {};
|
|
5
|
-
|
|
6
|
-
this.EVA.plugin.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);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}this.EVA=this.EVA||{},this.EVA.plugin=this.EVA.plugin||{},this.EVA.plugin.a11y=function(t,e,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 n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function i(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return(o=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function a(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}function s(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{c(r.next(t))}catch(t){o(t)}}function s(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))}function c(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function u(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function h(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}function p(t){return function(e,n){var r=h(e,n);r.key=n,r.type=t}}function l(t){return function(e,n){h(e,n).step=t}}var v,d,f,y,g=function(t,e){var n=e.width,r=e.height,i=e.position,o=e.left,a=void 0===o?0:o,s=e.top,c=void 0===s?0:s,u=e.zIndex,h=e.pointerEvents,p=e.background;t.style.width=n+"px",t.style.height=r+"px",t.style.position=i,t.style.left=""+a,t.style.top=""+c,t.style.zIndex=""+u,t.style.pointerEvents=h,t.style.background=p,t.style.border="none",t.style.overflow="hidden"},m=function(t){function e(e){var n=t.call(this)||this;_extends(n,e);var r=e.hint,i=void 0===r?"":r,o=e.event,a=e.delay,s=void 0===a?0:a,c=e.attr,u=void 0===c?{}:c,h=e.role,p=void 0===h?"":h,l=e.props,v=void 0===l?{}:l,d=e.state,f=void 0===d?{}:d;return n.hint=i,n.event=o,n.delay=s,n.attr=u,n.role=p,n.props=v,n.state=f,n.a11yId="_"+function(t){for(var e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),n=[],r=e.length,i=0;i<t;i++)n[i]=e[0|Math.random()*r];return n.join("")}(6),n}return i(e,t),e.componentName="A11y",a([p("boolean")],e.prototype,"interactive",void 0),a([p("string")],e.prototype,"hint",void 0),a([p("number"),l(1)],e.prototype,"delay",void 0),a([p("string")],e.prototype,"role",void 0),a([p("string")],e.prototype,"a11yId",void 0),e}(e.Component),b="absolute";t.A11yActivate=void 0,(v=t.A11yActivate||(t.A11yActivate={}))[v.ENABLE=0]="ENABLE",v[v.DISABLE=1]="DISABLE",v[v.CHECK=2]="CHECK",function(t){t.NONE="none",t.AUTO="auto"}(d||(d={})),function(t){t.DEBUG="rgba(255,0,0,0.5)",t.NONE="transparent"}(f||(f={})),function(t){t.BUTTON="button",t.DIV="div"}(y||(y={}));var E=["hint","event","delay","attr","role","props","state","a11yId","name"],A=function(t,e,n){var r=this;["touchstart","touchend","tap"].forEach((function(i){t.emit(i,{stopPropagation:function(){return n.stopPropagation()},data:{position:r.eventPosition},gameObject:e})}))},O=function(r){function h(t){var e=r.call(this,t)||this;return e.cache=new Map,e.eventCache=new Map,e.zIndex=3,e}return i(h,r),Object.defineProperty(h.prototype,"ratioX",{get:function(){return this._ratioX||this.setRatio()?this._ratioX:0},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"ratioY",{get:function(){return this._ratioY||this.setRatio()?this._ratioY:0},enumerable:!1,configurable:!0}),h.prototype.init=function(e){return void 0===e&&(e={}),s(this,void 0,void 0,(function(){var n,r,i,o,a,s,u,h,p;return c(this,(function(c){switch(c.label){case 0:switch(n=e.activate,r=void 0===n?t.A11yActivate.CHECK:n,i=e.delay,o=void 0===i?100:i,a=e.checkA11yOpen,s=void 0===a?function(){return Promise.resolve(!1)}:a,u=e.zIndex,this.delay=o,this.zIndex=u||this.zIndex,r){case t.A11yActivate.CHECK:return[3,1];case t.A11yActivate.DISABLE:return[3,5];case t.A11yActivate.ENABLE:return[3,6]}return[3,7];case 1:return c.trys.push([1,3,,4]),h=this,[4,s()];case 2:return h.activate=c.sent(),[3,4];case 3:return c.sent(),this.activate=!1,[3,4];case 4:return[3,7];case 5:return this.activate=!1,[3,7];case 6:return this.activate=!0,[3,7];case 7:return this.debug=e.debug||!1,this.debug&&(this.activate=!0),this.activate?(p=document.createElement("div"),this.div=p,this.game.canvas.parentNode&&this.game.canvas.parentNode.insertBefore(this.div,this.game.canvas),[2]):[2]}}))}))},h.prototype.setRatio=function(){var t=this.getCanvasBoundingClientRect(),e=t.width,n=t.height,r=this.getRenderRect(),i=r.renderWidth,o=r.renderHeight;return this._ratioX=e/i,this._ratioY=n/o,!(!e&&!n)&&(this.initDiv(),!0)},h.prototype.getRenderRect=function(){var t=this.game.getSystem(n.RendererSystem).params,e=void 0===t?{width:300,height:300}:t,r=e.height;return{renderWidth:e.width,renderHeight:r}},h.prototype.getCanvasBoundingClientRect=function(){var t=this.game.canvas.getBoundingClientRect();return{width:t.width,height:t.height,left:t.left,top:t.top}},h.prototype.initDiv=function(){var t=this,e=window.pageXOffset,n=window.pageYOffset,r=this.getCanvasBoundingClientRect(),i={width:r.width,height:r.height,left:r.left+e+"px",top:r.top+n+"px",position:b,zIndex:this.zIndex,pointerEvents:d.NONE,background:f.NONE};g(this.div,i),this.div.addEventListener("click",(function(e){var n=e.currentTarget.getBoundingClientRect(),r=n.left,i=n.top,o=(e.pageX-r)/t.ratioX,a=(e.pageY-i)/t.ratioY;t.eventPosition={x:o,y:a}}),!0)},h.prototype.update=function(){return s(this,void 0,void 0,(function(){var t,n,r,i,o,a;return c(this,(function(s){if(t=this.componentObserver.clear(),!this.activate)return[2];try{for(n=u(t),r=n.next();!r.done;r=n.next())switch((i=r.value).type){case e.OBSERVER_TYPE.ADD:"Event"===i.componentName&&this.addEvent(i.gameObject),"A11y"===i.componentName&&this.add(i);break;case e.OBSERVER_TYPE.CHANGE:"Transform"===i.componentName&&this.transformChange(i),"A11y"===i.componentName&&this.change(i);break;case e.OBSERVER_TYPE.REMOVE:"Event"===i.componentName&&this.removeEvent(i),"A11y"===i.componentName&&this.remove(i)}}catch(t){o={error:t}}finally{try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(o)throw o.error}}return[2]}))}))},h.prototype.change=function(t){var e=t.component;if("hint"===t.prop.prop[0]){var n=this.cache.get(e.a11yId);null==n||n.setAttribute("aria-label",e.hint),n&&this.setPosition(n,t.gameObject.transform)}},h.prototype.remove=function(t){var e=t.component;if(e){var n=e.a11yId,r=this.div.querySelector("#"+n);r&&this.div.removeChild(r),this.cache.delete(n)}},h.prototype.add=function(t){var e=this;if(this.activate){var n=t.component,r=t.gameObject,i=n.delay,o=n.a11yId,a=n.event;if(r){var s=r.transform;if(s){var c=document.createElement("div");this.cache.set(o,c),a||(a=r.getComponent("Event")),setTimeout((function(){e.setPosition(c,s),e.setA11yAttr(c,n),a&&e.addEvent(r),r.scene&&e.div.appendChild(c)}),i||this.delay)}}}},h.prototype.transformChange=function(t){var e=t.component,n=t.gameObject.getComponent(m);if(n){var r=n.a11yId;if(e.inScene){if(this.cache.has(r)){var i=this.cache.get(r);i&&this.div.appendChild(i)}}else{var o=this.div.querySelector("#"+r);o&&this.div.removeChild(o)}}},h.prototype.setEvent=function(t,e,n,r){if(e){var i=A.bind(this,e,n);this.eventCache.set(r,i),t.addEventListener("click",i)}},h.prototype.addEvent=function(t){var e=t.getComponent(m);if(e){var n=t.getComponent("Event");if(n){var r=this.cache.get(e.a11yId);r&&this.setEvent(r,n,t,e.a11yId)}}},h.prototype.removeEvent=function(t){var e=t.gameObject.getComponent(m);if(e&&t.component){var n=e.a11yId,r=this.eventCache.get(n),i=this.cache.get(n);i&&i.removeEventListener("click",r)}},h.prototype.setA11yAttr=function(t,e){var n,r,i,o,a,s,c=e.hint,h=e.props,p=void 0===h?{}:h,l=e.state,v=void 0===l?{}:l,d=e.role,f=e.a11yId,y=d||"text";t.setAttribute("role",y),t.setAttribute("aria-label",c),t.id=f;var g=Object.keys(p);try{for(var m=u(g),b=m.next();!b.done;b=m.next()){var A=b.value;t.setAttribute(A,p[A])}}catch(t){n={error:t}}finally{try{b&&!b.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}var O=Object.keys(v);try{for(var w=u(O),x=w.next();!x.done;x=w.next()){A=x.value;t.setAttribute(A,v[A])}}catch(t){i={error:t}}finally{try{x&&!x.done&&(o=w.return)&&o.call(w)}finally{if(i)throw i.error}}try{for(var C=u(Object.keys(e)),I=C.next();!I.done;I=C.next()){"string"==typeof e[A=I.value]&&-1===E.indexOf(A)&&1!==A.indexOf("_")&&t.setAttribute(A,e[A])}}catch(t){a={error:t}}finally{try{I&&!I.done&&(s=C.return)&&s.call(C)}finally{if(a)throw a.error}}},h.prototype.setPosition=function(t,e){var n=e.size,r=n.width,i=n.height,a={width:0===r?1:r*this.ratioX,height:0===i?1:i*this.ratioY,position:b,zIndex:this.zIndex,pointerEvents:d.AUTO,background:this.debug?f.DEBUG:f.NONE},s=o({},e);g(t,a),function(t,e,n,r){var i=e.worldTransform,o="matrix("+i.a+", "+i.b+", "+i.c+", "+i.d+", "+i.tx*n+", "+i.ty*r+")";t.style.transform=""+o,t.style.webkitTransform=""+o,t.style.transformOrigin="left top",t.style.webkitTransformOrigin="left top"}(t,s,this.ratioX,this.ratioY)},h.prototype.onDestroy=function(){this.div.parentElement.removeChild(this.div),this.cache=null,this.eventCache=null,this.div=null},h.systemName="A11ySystem",h=a([e.decorators.componentObserver({A11y:["hint"],Transform:["inScene"],Event:[]})],h)}(e.System);return t.A11y=m,t.A11ySystem=O,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,EVA.plugin.renderer);
|