@eva/plugin-a11y 1.2.7-editor.0 → 1.2.7-editor.3
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 +105 -22
- package/dist/EVA.plugin.a11y.min.js +1 -1
- package/dist/miniprogram.js +10 -8
- package/dist/plugin-a11y.cjs.js +16 -7
- package/dist/plugin-a11y.cjs.prod.js +1 -1
- package/dist/plugin-a11y.esm.js +17 -8
- package/package.json +4 -4
package/dist/EVA.plugin.a11y.js
CHANGED
|
@@ -13,7 +13,7 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
|
|
|
13
13
|
d.__proto__ = b;
|
|
14
14
|
} || function (d, b) {
|
|
15
15
|
for (var p in b) {
|
|
16
|
-
if (
|
|
16
|
+
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -21,6 +21,8 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
function __extends(d, b) {
|
|
24
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
25
|
+
|
|
24
26
|
_extendStatics(d, b);
|
|
25
27
|
|
|
26
28
|
function __() {
|
|
@@ -56,6 +58,10 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
|
|
|
56
58
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
57
59
|
}
|
|
58
60
|
|
|
61
|
+
function __metadata(metadataKey, metadataValue) {
|
|
62
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
63
|
+
}
|
|
64
|
+
|
|
59
65
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
60
66
|
function adopt(value) {
|
|
61
67
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -216,31 +222,106 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
|
|
|
216
222
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
217
223
|
}
|
|
218
224
|
|
|
219
|
-
function
|
|
220
|
-
|
|
221
|
-
|
|
225
|
+
var SymbolKeysNotSupportedError = function (_super) {
|
|
226
|
+
__extends(SymbolKeysNotSupportedError, _super);
|
|
227
|
+
|
|
228
|
+
function SymbolKeysNotSupportedError() {
|
|
229
|
+
var _newTarget = this.constructor;
|
|
230
|
+
|
|
231
|
+
var _this = _super.call(this, 'Symbol keys are not supported yet!') || this;
|
|
232
|
+
|
|
233
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
234
|
+
return _this;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return SymbolKeysNotSupportedError;
|
|
238
|
+
}(Error);
|
|
239
|
+
|
|
240
|
+
(function (_super) {
|
|
241
|
+
__extends(StaticGetPropertiesIsNotAFunctionError, _super);
|
|
242
|
+
|
|
243
|
+
function StaticGetPropertiesIsNotAFunctionError() {
|
|
244
|
+
var _newTarget = this.constructor;
|
|
245
|
+
|
|
246
|
+
var _this = _super.call(this, 'getProperties is not a function!') || this;
|
|
247
|
+
|
|
248
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
249
|
+
return _this;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return StaticGetPropertiesIsNotAFunctionError;
|
|
253
|
+
})(Error);
|
|
254
|
+
|
|
255
|
+
var IDE_PROPERTY_METADATA = 'IDE_PROPERTY_METADATA';
|
|
256
|
+
|
|
257
|
+
function transformBasicType(type) {
|
|
258
|
+
if (type === String) {
|
|
259
|
+
return 'string';
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (type === Number) {
|
|
263
|
+
return 'number';
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (type === Boolean) {
|
|
267
|
+
return 'boolean';
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return 'unknown';
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function defineTypes(target, key, options, returnTypeFunction) {
|
|
274
|
+
var type = Reflect.getMetadata('design:type', target, key);
|
|
275
|
+
var isArray = type === Array;
|
|
276
|
+
var str = transformBasicType(type);
|
|
277
|
+
|
|
278
|
+
if (str !== 'unknown') {
|
|
279
|
+
type = str;
|
|
222
280
|
}
|
|
223
281
|
|
|
224
|
-
if (
|
|
225
|
-
|
|
282
|
+
if (returnTypeFunction) {
|
|
283
|
+
var returnType = returnTypeFunction();
|
|
284
|
+
|
|
285
|
+
if (Array.isArray(returnType)) {
|
|
286
|
+
isArray = true;
|
|
287
|
+
type = returnType[0];
|
|
288
|
+
} else {
|
|
289
|
+
type = returnType;
|
|
290
|
+
}
|
|
226
291
|
}
|
|
227
292
|
|
|
228
|
-
var
|
|
229
|
-
|
|
293
|
+
var properties = Reflect.getMetadata(IDE_PROPERTY_METADATA, target.constructor) || {};
|
|
294
|
+
properties[key] = _assign({
|
|
295
|
+
type: type,
|
|
296
|
+
isArray: isArray
|
|
297
|
+
}, options);
|
|
298
|
+
Reflect.defineMetadata(IDE_PROPERTY_METADATA, properties, target.constructor);
|
|
230
299
|
}
|
|
231
300
|
|
|
232
|
-
function
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
301
|
+
function getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions) {
|
|
302
|
+
if (typeof returnTypeFuncOrOptions === 'function') {
|
|
303
|
+
return {
|
|
304
|
+
returnTypeFunc: returnTypeFuncOrOptions,
|
|
305
|
+
options: maybeOptions || {}
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return {
|
|
310
|
+
options: returnTypeFuncOrOptions || {}
|
|
237
311
|
};
|
|
238
312
|
}
|
|
239
313
|
|
|
240
|
-
function
|
|
314
|
+
function Field(returnTypeFunction, maybeOptions) {
|
|
241
315
|
return function (target, propertyKey) {
|
|
242
|
-
|
|
243
|
-
|
|
316
|
+
if (typeof propertyKey === 'symbol') {
|
|
317
|
+
throw new SymbolKeysNotSupportedError();
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
var _a = getTypeDecoratorParams(returnTypeFunction, maybeOptions),
|
|
321
|
+
options = _a.options,
|
|
322
|
+
returnTypeFunc = _a.returnTypeFunc;
|
|
323
|
+
|
|
324
|
+
defineTypes(target, propertyKey, options, returnTypeFunc);
|
|
244
325
|
};
|
|
245
326
|
}
|
|
246
327
|
|
|
@@ -328,15 +409,17 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
|
|
|
328
409
|
|
|
329
410
|
A11y.componentName = 'A11y';
|
|
330
411
|
|
|
331
|
-
__decorate([
|
|
412
|
+
__decorate([Field(), __metadata("design:type", Boolean)], A11y.prototype, "interactive", void 0);
|
|
332
413
|
|
|
333
|
-
__decorate([
|
|
414
|
+
__decorate([Field(), __metadata("design:type", String)], A11y.prototype, "hint", void 0);
|
|
334
415
|
|
|
335
|
-
__decorate([
|
|
416
|
+
__decorate([Field({
|
|
417
|
+
step: 1
|
|
418
|
+
}), __metadata("design:type", Number)], A11y.prototype, "delay", void 0);
|
|
336
419
|
|
|
337
|
-
__decorate([
|
|
420
|
+
__decorate([Field(), __metadata("design:type", String)], A11y.prototype, "role", void 0);
|
|
338
421
|
|
|
339
|
-
__decorate([
|
|
422
|
+
__decorate([Field(), __metadata("design:type", String)], A11y.prototype, "a11yId", void 0);
|
|
340
423
|
|
|
341
424
|
return A11y;
|
|
342
425
|
}(eva_js.Component);
|
|
@@ -861,7 +944,7 @@ var _EVA_IIFE_a11y = function (exports, eva_js, pluginRenderer) {
|
|
|
861
944
|
A11y: ['hint'],
|
|
862
945
|
Transform: ['inScene'],
|
|
863
946
|
Event: []
|
|
864
|
-
})], A11ySystem);
|
|
947
|
+
}), __metadata("design:paramtypes", [Object])], A11ySystem);
|
|
865
948
|
return A11ySystem;
|
|
866
949
|
}(eva_js.System);
|
|
867
950
|
|
|
@@ -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)}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])})(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}).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 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 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,p=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=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,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,p=void 0===h?"":h,l=e.props,d=void 0===l?{}:l,v=e.state,f=void 0===v?{}:v;return n.hint=o,n.event=i,n.delay=s,n.attr=u,n.role=p,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([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,(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 E=["hint","event","delay","attr","role","props","state","a11yId","name"],w=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})}))},A=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,p;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?(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(),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:b,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(m);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=w.bind(this,e,n);this.eventCache.set(r,o),t.addEventListener("click",o)}},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),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,p=void 0===h?{}:h,l=e.state,d=void 0===l?{}:l,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(p);try{for(var m=u(g),b=m.next();!b.done;b=m.next()){var w=b.value;t.setAttribute(w,p[w])}}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()){w=x.value;t.setAttribute(w,d[w])}}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[w=I.value]&&-1===E.indexOf(w)&&1!==w.indexOf("_")&&t.setAttribute(w,e[w])}}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:b,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=m,t.A11ySystem=A,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,EVA.plugin.renderer);window.EVA.plugin.a11y=window.EVA.plugin.a11y||_EVA_IIFE_a11y;
|
|
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},_extends.apply(this,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)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)};function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");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){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function c(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 u(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 p(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.")}var l=function(t){function e(){var e=this.constructor,n=t.call(this,"Symbol keys are not supported yet!")||this;return Object.setPrototypeOf(n,e.prototype),n}return o(e,t),e}(Error);!function(t){function e(){var e=this.constructor,n=t.call(this,"getProperties is not a function!")||this;return Object.setPrototypeOf(n,e.prototype),n}o(e,t)}(Error);var h="IDE_PROPERTY_METADATA";function d(t,e,n,r){var o=Reflect.getMetadata("design:type",t,e),a=o===Array,s=function(t){return t===String?"string":t===Number?"number":t===Boolean?"boolean":"unknown"}(o);if("unknown"!==s&&(o=s),r){var c=r();Array.isArray(c)?(a=!0,o=c[0]):o=c}var u=Reflect.getMetadata(h,t.constructor)||{};u[e]=i({type:o,isArray:a},n),Reflect.defineMetadata(h,u,t.constructor)}function f(t,e){return function(n,r){if("symbol"==typeof r)throw new l;var o=function(t,e){return"function"==typeof t?{returnTypeFunc:t,options:e||{}}:{options:t||{}}}(t,e);d(n,r,o.options,o.returnTypeFunc)}}var v,y,g,m,b=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,p=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=p,t.style.background=l,t.style.border="none",t.style.overflow="hidden"},E=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,p=e.role,l=void 0===p?"":p,h=e.props,d=void 0===h?{}:h,f=e.state,v=void 0===f?{}:f;return n.hint=o,n.event=i,n.delay=s,n.attr=u,n.role=l,n.props=d,n.state=v,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([f(),s("design:type",Boolean)],e.prototype,"interactive",void 0),a([f(),s("design:type",String)],e.prototype,"hint",void 0),a([f({step:1}),s("design:type",Number)],e.prototype,"delay",void 0),a([f(),s("design:type",String)],e.prototype,"role",void 0),a([f(),s("design:type",String)],e.prototype,"a11yId",void 0),e}(e.Component),w=E,A="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"}(y||(y={})),function(t){t.DEBUG="rgba(255,0,0,0.5)",t.NONE="transparent"}(g||(g={})),function(t){t.BUTTON="button",t.DIV="div"}(m||(m={}));var O=["hint","event","delay","attr","role","props","state","a11yId","name"],x=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})}))},C=function(r){function l(t){var e=r.call(this,t)||this;return e.cache=new Map,e.eventCache=new Map,e.zIndex=3,e}return o(l,r),Object.defineProperty(l.prototype,"ratioX",{get:function(){return this._ratioX||this.setRatio()?this._ratioX:0},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"ratioY",{get:function(){return this._ratioY||this.setRatio()?this._ratioY:0},enumerable:!1,configurable:!0}),l.prototype.init=function(e){return void 0===e&&(e={}),c(this,void 0,void 0,(function(){var n,r,o,i,a,s,c,p,l;return u(this,(function(u){switch(u.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,c=e.zIndex,this.delay=i,this.zIndex=c||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 u.trys.push([1,3,,4]),p=this,[4,s()];case 2:return p.activate=u.sent(),[3,4];case 3:return u.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]}}))}))},l.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)},l.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}},l.prototype.getCanvasBoundingClientRect=function(){var t=this.game.canvas.getBoundingClientRect();return{width:t.width,height:t.height,left:t.left,top:t.top}},l.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:A,zIndex:this.zIndex,pointerEvents:y.NONE,background:g.NONE};b(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)},l.prototype.update=function(){return c(this,void 0,void 0,(function(){var t,n,r,o,i,a;return u(this,(function(s){if(t=this.componentObserver.clear(),!this.activate)return[2];try{for(n=p(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]}))}))},l.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)}},l.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)}},l.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)}}}},l.prototype.transformChange=function(t){var e=t.component,n=t.gameObject.getComponent(w);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)}}},l.prototype.setEvent=function(t,e,n,r){if(e){var o=x.bind(this,e,n);this.eventCache.set(r,o),t.addEventListener("click",o)}},l.prototype.addEvent=function(t){var e=t.getComponent(w);if(e){var n=t.getComponent("Event");if(n){var r=this.cache.get(e.a11yId);r&&this.setEvent(r,n,t,e.a11yId)}}},l.prototype.removeEvent=function(t){var e=t.gameObject.getComponent(w);if(e&&t.component){var n=e.a11yId,r=this.eventCache.get(n),o=this.cache.get(n);o&&o.removeEventListener("click",r)}},l.prototype.setA11yAttr=function(t,e){var n,r,o,i,a,s,c=e.hint,u=e.props,l=void 0===u?{}:u,h=e.state,d=void 0===h?{}:h,f=e.role,v=e.a11yId,y=f||"text";t.setAttribute("role",y),t.setAttribute("aria-label",c),t.id=v;var g=Object.keys(l);try{for(var m=p(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 w=Object.keys(d);try{for(var A=p(w),x=A.next();!x.done;x=A.next()){E=x.value;t.setAttribute(E,d[E])}}catch(t){o={error:t}}finally{try{x&&!x.done&&(i=A.return)&&i.call(A)}finally{if(o)throw o.error}}try{for(var C=p(Object.keys(e)),_=C.next();!_.done;_=C.next()){"string"==typeof e[E=_.value]&&-1===O.indexOf(E)&&1!==E.indexOf("_")&&t.setAttribute(E,e[E])}}catch(t){a={error:t}}finally{try{_&&!_.done&&(s=C.return)&&s.call(C)}finally{if(a)throw a.error}}},l.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:A,zIndex:this.zIndex,pointerEvents:y.AUTO,background:this.debug?g.DEBUG:g.NONE},s=i({},e);b(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)},l.prototype.onDestroy=function(){this.div.parentElement.removeChild(this.div),this.cache=null,this.eventCache=null,this.div=null},l.systemName="A11ySystem",l=a([e.decorators.componentObserver({A11y:["hint"],Transform:["inScene"],Event:[]}),s("design:paramtypes",[Object])],l)}(e.System);return t.A11y=w,t.A11ySystem=C,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,EVA.plugin.renderer);window.EVA.plugin.a11y=window.EVA.plugin.a11y||_EVA_IIFE_a11y;
|
package/dist/miniprogram.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
3
|
import { documentAlias, windowAlias } from '@eva/miniprogram-adapter';
|
|
4
|
-
import { __extends, __decorate, __awaiter, __generator, __values, __assign } from 'tslib';
|
|
4
|
+
import { __extends, __decorate, __metadata, __awaiter, __generator, __values, __assign } from 'tslib';
|
|
5
5
|
import { Component, OBSERVER_TYPE, decorators, System } from '@eva/eva.js/dist/miniprogram';
|
|
6
6
|
import { RendererSystem } from '@eva/plugin-renderer/dist/miniprogram';
|
|
7
|
-
import {
|
|
7
|
+
import { Field } from '@eva/inspector-decorator';
|
|
8
8
|
|
|
9
9
|
function uuid(len) {
|
|
10
10
|
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
|
|
@@ -90,15 +90,17 @@ var A11y = function (_super) {
|
|
|
90
90
|
|
|
91
91
|
A11y.componentName = 'A11y';
|
|
92
92
|
|
|
93
|
-
__decorate([
|
|
93
|
+
__decorate([Field(), __metadata("design:type", Boolean)], A11y.prototype, "interactive", void 0);
|
|
94
94
|
|
|
95
|
-
__decorate([
|
|
95
|
+
__decorate([Field(), __metadata("design:type", String)], A11y.prototype, "hint", void 0);
|
|
96
96
|
|
|
97
|
-
__decorate([
|
|
97
|
+
__decorate([Field({
|
|
98
|
+
step: 1
|
|
99
|
+
}), __metadata("design:type", Number)], A11y.prototype, "delay", void 0);
|
|
98
100
|
|
|
99
|
-
__decorate([
|
|
101
|
+
__decorate([Field(), __metadata("design:type", String)], A11y.prototype, "role", void 0);
|
|
100
102
|
|
|
101
|
-
__decorate([
|
|
103
|
+
__decorate([Field(), __metadata("design:type", String)], A11y.prototype, "a11yId", void 0);
|
|
102
104
|
|
|
103
105
|
return A11y;
|
|
104
106
|
}(Component);
|
|
@@ -623,7 +625,7 @@ var A11ySystem = function (_super) {
|
|
|
623
625
|
A11y: ['hint'],
|
|
624
626
|
Transform: ['inScene'],
|
|
625
627
|
Event: []
|
|
626
|
-
})], A11ySystem);
|
|
628
|
+
}), __metadata("design:paramtypes", [Object])], A11ySystem);
|
|
627
629
|
return A11ySystem;
|
|
628
630
|
}(System);
|
|
629
631
|
|
package/dist/plugin-a11y.cjs.js
CHANGED
|
@@ -53,6 +53,10 @@ function __decorate(decorators, target, key, desc) {
|
|
|
53
53
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
function __metadata(metadataKey, metadataValue) {
|
|
57
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
58
|
+
}
|
|
59
|
+
|
|
56
60
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
57
61
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
58
62
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -150,20 +154,24 @@ var A11y = (function (_super) {
|
|
|
150
154
|
}
|
|
151
155
|
A11y.componentName = 'A11y';
|
|
152
156
|
__decorate([
|
|
153
|
-
inspectorDecorator.
|
|
157
|
+
inspectorDecorator.Field(),
|
|
158
|
+
__metadata("design:type", Boolean)
|
|
154
159
|
], A11y.prototype, "interactive", void 0);
|
|
155
160
|
__decorate([
|
|
156
|
-
inspectorDecorator.
|
|
161
|
+
inspectorDecorator.Field(),
|
|
162
|
+
__metadata("design:type", String)
|
|
157
163
|
], A11y.prototype, "hint", void 0);
|
|
158
164
|
__decorate([
|
|
159
|
-
inspectorDecorator.
|
|
160
|
-
|
|
165
|
+
inspectorDecorator.Field({ step: 1 }),
|
|
166
|
+
__metadata("design:type", Number)
|
|
161
167
|
], A11y.prototype, "delay", void 0);
|
|
162
168
|
__decorate([
|
|
163
|
-
inspectorDecorator.
|
|
169
|
+
inspectorDecorator.Field(),
|
|
170
|
+
__metadata("design:type", String)
|
|
164
171
|
], A11y.prototype, "role", void 0);
|
|
165
172
|
__decorate([
|
|
166
|
-
inspectorDecorator.
|
|
173
|
+
inspectorDecorator.Field(),
|
|
174
|
+
__metadata("design:type", String)
|
|
167
175
|
], A11y.prototype, "a11yId", void 0);
|
|
168
176
|
return A11y;
|
|
169
177
|
}(eva_js.Component));
|
|
@@ -558,7 +566,8 @@ var A11ySystem = (function (_super) {
|
|
|
558
566
|
A11y: ['hint'],
|
|
559
567
|
Transform: ['inScene'],
|
|
560
568
|
Event: [],
|
|
561
|
-
})
|
|
569
|
+
}),
|
|
570
|
+
__metadata("design:paramtypes", [Object])
|
|
562
571
|
], A11ySystem);
|
|
563
572
|
return A11ySystem;
|
|
564
573
|
}(eva_js.System));
|
|
@@ -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){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function c(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 h(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 p(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 u,d,l,v,f=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"},y=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,d=e.props,l=void 0===d?{}:d,v=e.state,f=void 0===v?{}:v;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.Field(),s("design:type",Boolean)],e.prototype,"interactive",void 0),a([n.Field(),s("design:type",String)],e.prototype,"hint",void 0),a([n.Field({step:1}),s("design:type",Number)],e.prototype,"delay",void 0),a([n.Field(),s("design:type",String)],e.prototype,"role",void 0),a([n.Field(),s("design:type",String)],e.prototype,"a11yId",void 0),e}(t.Component),g=y;exports.A11yActivate=void 0,(u=exports.A11yActivate||(exports.A11yActivate={}))[u.ENABLE=0]="ENABLE",u[u.DISABLE=1]="DISABLE",u[u.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"}(l||(l={})),function(t){t.BUTTON="button",t.DIV="div"}(v||(v={}));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={}),c(this,void 0,void 0,(function(){var e,n,r,i,o,a,s,c,p;return h(this,(function(h){switch(h.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 h.trys.push([1,3,,4]),c=this,[4,a()];case 2:return c.activate=h.sent(),[3,4];case 3:return h.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:d.NONE,background:l.NONE};f(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 c(this,void 0,void 0,(function(){var e,n,r,i,o,a;return h(this,(function(s){if(e=this.componentObserver.clear(),!this.activate)return[2];try{for(n=p(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(g);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(g);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(g);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,h=e.props,u=void 0===h?{}:h,d=e.state,l=void 0===d?{}:d,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(u);try{for(var b=p(g),E=b.next();!E.done;E=b.next()){var O=E.value;t.setAttribute(O,u[O])}}catch(t){n={error:t}}finally{try{E&&!E.done&&(r=b.return)&&r.call(b)}finally{if(n)throw n.error}}var x=Object.keys(l);try{for(var A=p(x),w=A.next();!w.done;w=A.next()){O=w.value;t.setAttribute(O,l[O])}}catch(t){i={error:t}}finally{try{w&&!w.done&&(o=A.return)&&o.call(A)}finally{if(i)throw i.error}}try{for(var C=p(Object.keys(e)),N=C.next();!N.done;N=C.next()){"string"==typeof e[O=N.value]&&-1===m.indexOf(O)&&1!==O.indexOf("_")&&t.setAttribute(O,e[O])}}catch(t){a={error:t}}finally{try{N&&!N.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:d.AUTO,background:this.debug?l.DEBUG:l.NONE},s=o({},e);f(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:[]}),s("design:paramtypes",[Object])],r)}(t.System);exports.A11y=g,exports.A11ySystem=E;
|
package/dist/plugin-a11y.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component, decorators, System, OBSERVER_TYPE } from '@eva/eva.js';
|
|
2
2
|
import { RendererSystem } from '@eva/plugin-renderer';
|
|
3
|
-
import {
|
|
3
|
+
import { Field } from '@eva/inspector-decorator';
|
|
4
4
|
|
|
5
5
|
/*! *****************************************************************************
|
|
6
6
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -49,6 +49,10 @@ function __decorate(decorators, target, key, desc) {
|
|
|
49
49
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
function __metadata(metadataKey, metadataValue) {
|
|
53
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
54
|
+
}
|
|
55
|
+
|
|
52
56
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
53
57
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
54
58
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -146,20 +150,24 @@ var A11y = (function (_super) {
|
|
|
146
150
|
}
|
|
147
151
|
A11y.componentName = 'A11y';
|
|
148
152
|
__decorate([
|
|
149
|
-
|
|
153
|
+
Field(),
|
|
154
|
+
__metadata("design:type", Boolean)
|
|
150
155
|
], A11y.prototype, "interactive", void 0);
|
|
151
156
|
__decorate([
|
|
152
|
-
|
|
157
|
+
Field(),
|
|
158
|
+
__metadata("design:type", String)
|
|
153
159
|
], A11y.prototype, "hint", void 0);
|
|
154
160
|
__decorate([
|
|
155
|
-
|
|
156
|
-
|
|
161
|
+
Field({ step: 1 }),
|
|
162
|
+
__metadata("design:type", Number)
|
|
157
163
|
], A11y.prototype, "delay", void 0);
|
|
158
164
|
__decorate([
|
|
159
|
-
|
|
165
|
+
Field(),
|
|
166
|
+
__metadata("design:type", String)
|
|
160
167
|
], A11y.prototype, "role", void 0);
|
|
161
168
|
__decorate([
|
|
162
|
-
|
|
169
|
+
Field(),
|
|
170
|
+
__metadata("design:type", String)
|
|
163
171
|
], A11y.prototype, "a11yId", void 0);
|
|
164
172
|
return A11y;
|
|
165
173
|
}(Component));
|
|
@@ -554,7 +562,8 @@ var A11ySystem = (function (_super) {
|
|
|
554
562
|
A11y: ['hint'],
|
|
555
563
|
Transform: ['inScene'],
|
|
556
564
|
Event: [],
|
|
557
|
-
})
|
|
565
|
+
}),
|
|
566
|
+
__metadata("design:paramtypes", [Object])
|
|
558
567
|
], A11ySystem);
|
|
559
568
|
return A11ySystem;
|
|
560
569
|
}(System));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-a11y",
|
|
3
|
-
"version": "1.2.7-editor.
|
|
3
|
+
"version": "1.2.7-editor.3",
|
|
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.7-editor.
|
|
22
|
-
"@eva/inspector-decorator": "
|
|
23
|
-
"@eva/plugin-renderer": "1.2.7-editor.
|
|
21
|
+
"@eva/eva.js": "1.2.7-editor.3",
|
|
22
|
+
"@eva/inspector-decorator": "0.1.0-alpha.1",
|
|
23
|
+
"@eva/plugin-renderer": "1.2.7-editor.3",
|
|
24
24
|
"eventemitter3": "^3.1.2"
|
|
25
25
|
}
|
|
26
26
|
}
|