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