@eva/plugin-renderer-mask 1.2.7-editor.5 → 1.2.7-editor.8

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.
@@ -361,6 +361,14 @@ var _EVA_IIFE_mask = function (exports, eva_js, pluginRenderer, rendererAdapter)
361
361
  };
362
362
  }
363
363
 
364
+ var ExecuteMode;
365
+
366
+ (function (ExecuteMode) {
367
+ ExecuteMode[ExecuteMode["Edit"] = 2] = "Edit";
368
+ ExecuteMode[ExecuteMode["Game"] = 4] = "Game";
369
+ ExecuteMode[ExecuteMode["All"] = 6] = "All";
370
+ })(ExecuteMode || (ExecuteMode = {}));
371
+
364
372
  var _a;
365
373
 
366
374
  exports.MASK_TYPE = void 0;
@@ -1 +1 @@
1
- function _extends(){return _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_extends.apply(this,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_mask=function(e,t,r,n){"use strict";var o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},o(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function c(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function s(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function p(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e))}catch(e){i(e)}}function c(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}s((n=n.apply(e,t||[])).next())}))}function u(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=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++,n=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=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}function l(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}var y=function(e){function t(){var t=this.constructor,r=e.call(this,"Symbol keys are not supported yet!")||this;return Object.setPrototypeOf(r,t.prototype),r}return i(t,e),t}(Error);!function(e){function t(){var t=this.constructor,r=e.call(this,"getProperties is not a function!")||this;return Object.setPrototypeOf(r,t.prototype),r}i(t,e)}(Error);var d,h="IDE_PROPERTY_METADATA";function f(e,t,r,n){var o=Reflect.getMetadata("design:type",e,t),i=o===Array,c=function(e){return e===String?"string":e===Number?"number":e===Boolean?"boolean":"unknown"}(o);if("unknown"!==c&&(o=c),n){var s=n();Array.isArray(s)?(i=!0,o=s[0]):o=s}var p=Reflect.getMetadata(h,e.constructor)||{};p[t]=a({type:o,isArray:i},r),Reflect.defineMetadata(h,p,e.constructor)}function g(e,t){return function(r,n){if("symbol"==typeof n)throw new y;var o=function(e,t){return"function"==typeof e?{returnTypeFunc:e,options:t||{}}:{options:e||{}}}(e,t);f(r,n,o.options,o.returnTypeFunc)}}e.MASK_TYPE=void 0,function(e){e.Circle="Circle",e.Ellipse="Ellipse",e.Rect="Rect",e.RoundedRect="RoundedRect",e.Polygon="Polygon",e.Img="Img",e.Sprite="Sprite"}(e.MASK_TYPE||(e.MASK_TYPE={}));var m,v=function(){function t(){}return c([g({step:1}),s("design:type",Number)],t.prototype,"x",void 0),c([g({step:1}),s("design:type",Number)],t.prototype,"y",void 0),c([g({step:.1,if:function(t){return t.type===e.MASK_TYPE.Circle||t.type===e.MASK_TYPE.RoundedRect}}),s("design:type",Number)],t.prototype,"radius",void 0),c([g({step:1,if:function(t){return t.type!==e.MASK_TYPE.Circle}}),s("design:type",Number)],t.prototype,"width",void 0),c([g({step:1,if:function(t){return t.type!==e.MASK_TYPE.Circle}}),s("design:type",Number)],t.prototype,"height",void 0),t}(),w=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.style={},e.resource="",e.spriteName="",e}return i(r,t),r.prototype.init=function(e){_extends(this,e)},r.componentName="Mask",c([g({type:"selector",options:(d={},d[e.MASK_TYPE.Circle]=e.MASK_TYPE.Circle,d[e.MASK_TYPE.Ellipse]=e.MASK_TYPE.Ellipse,d[e.MASK_TYPE.Img]=e.MASK_TYPE.Img,d[e.MASK_TYPE.Rect]=e.MASK_TYPE.Rect,d[e.MASK_TYPE.RoundedRect]=e.MASK_TYPE.RoundedRect,d),alias:"type",default:e.MASK_TYPE.Circle}),s("design:type",String)],r.prototype,"mask_type",void 0),c([g((function(){return v})),s("design:type",Object)],r.prototype,"style",void 0),c([g({type:"resource",if:function(t){return t.type===e.MASK_TYPE.Img||e.MASK_TYPE.Sprite}}),s("design:type",String)],r.prototype,"resource",void 0),r}(t.Component),E=w,S={Circle:["x","y","radius"],Ellipse:["x","y","width","height"],Rect:["x","y","width","height"],RoundedRect:["x","y","width","height","radius"],Polygon:["paths"]},b={Circle:"drawCircle",Ellipse:"drawEllipse",Rect:"drawRect",RoundedRect:"drawRoundedRect",Polygon:"drawPolygon"};!function(e){e.Circle="Circle",e.Ellipse="Ellipse",e.Rect="Rect",e.RoundedRect="RoundedRect",e.Polygon="Polygon",e.Img="Img",e.Sprite="Sprite"}(m||(m={}));var R=function(e){function o(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Mask",t.changedCache={},t.maskSpriteCache={},t}return i(o,e),o.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},o.prototype.rendererUpdate=function(){this.changedCache={}},o.prototype.componentChanged=function(e){if("Mask"===e.component.name)switch(e.type){case t.OBSERVER_TYPE.ADD:this.add(e);break;case t.OBSERVER_TYPE.REMOVE:this.remove(e);break;case t.OBSERVER_TYPE.CHANGE:this.change(e)}},o.prototype.add=function(e){var t,r=e.component;if(!(r.type in m))throw new Error("no have Mask type: "+r.type);if(!r.style)throw new Error("no have Mask style: "+r.type);switch(r.type){case m.Circle:case m.Ellipse:case m.Rect:case m.RoundedRect:case m.Polygon:t=this.createGraphics(r);break;case m.Img:case m.Sprite:t=this.createSprite(r)}if(!t)throw new Error("no have mask instance, check your mask params: "+r.type);var n=this.containerManager.getContainer(e.gameObject.id);n.mask=t,n.addChild(t)},o.prototype.remove=function(e){var t=this.containerManager.getContainer(e.gameObject.id);t.removeChild(t.mask),t.mask.destroy({children:!0}),t.mask=null,delete this.maskSpriteCache[e.gameObject.id]},o.prototype.change=function(e){if(!this.changedCache[e.gameObject.id]){var t=e.component;"type"===e.prop.prop[0]?(this.changedCache[e.gameObject.id]=!0,[m.Sprite,m.Img].indexOf(t.type)>-1||t._lastType!==t.type?(this.remove(e),this.add(e),t._lastType=t.type):this.redrawGraphics(e)):"style"===e.prop.prop[0]?[m.Sprite,m.Img].indexOf(t.type)>-1?this.changeSpriteStyle(t):this.redrawGraphics(e):("resource"===e.prop.prop[0]||"spriteName"===e.prop.prop[0])&&(this.changedCache[e.gameObject.id]=!0,this.changeSprite(t))}},o.prototype.createGraphics=function(e){var t=new n.Graphics;return this.draw(t,e),t},o.prototype.redrawGraphics=function(e){var t=this.containerManager.getContainer(e.gameObject.id).mask;t.clear(),this.draw(t,e.component)},o.prototype.draw=function(e,t){var r,n,o=[];try{for(var i=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(S[t.type]),a=i.next();!a.done;a=i.next()){var c=a.value;o.push(t.style[c])}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}e.beginFill(0,1),e[b[t.type]].apply(e,function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(l(arguments[t]));return e}(o)),e.endFill()},o.prototype.createSprite=function(e){var t=new n.Sprite(null);return this.maskSpriteCache[e.gameObject.id]=t,this.setSprite(e,t),t.sprite},o.prototype.changeSpriteStyle=function(e){var t=this.maskSpriteCache[e.gameObject.id];t.sprite.width=e.style.width,t.sprite.height=e.style.height,t.sprite.position.x=e.style.x,t.sprite.position.y=e.style.y},o.prototype.changeSprite=function(e){var t=this.maskSpriteCache[e.gameObject.id];this.setSprite(e,t)},o.prototype.setSprite=function(e,r){return p(this,void 0,void 0,(function(){var n,o,i,a;return u(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),o=this.increaseAsyncId(e.gameObject.id),[4,t.resource.getResource(e.resource)];case 1:return n=c.sent(),this.validateAsyncId(e.gameObject.id,o)?[3,3]:[2];case 2:throw c.sent(),new Error("mask resource load error");case 3:return e.type===m.Sprite?(i=e.resource+"_s|r|c_"+e.spriteName,a=n.instance[i],r.image=a):r.image=n.data.image,r.sprite.width=e.style.width,r.sprite.height=e.style.height,r.sprite.position.x=e.style.x,r.sprite.position.y=e.style.y,[2]}}))}))},o.systemName="Mask",o=c([t.decorators.componentObserver({Mask:["type",{prop:["style"],deep:!0},"resource","spriteName"]})],o)}(r.Renderer),_=R;return e.Mask=E,e.MaskSystem=_,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter);window.EVA.plugin.renderer.mask=window.EVA.plugin.renderer.mask||_EVA_IIFE_mask;
1
+ function _extends(){return _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_extends.apply(this,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_mask=function(e,t,r,n){"use strict";var o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},o(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function c(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function s(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function p(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e))}catch(e){i(e)}}function c(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}s((n=n.apply(e,t||[])).next())}))}function u(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=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++,n=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=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}function l(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}var y=function(e){function t(){var t=this.constructor,r=e.call(this,"Symbol keys are not supported yet!")||this;return Object.setPrototypeOf(r,t.prototype),r}return i(t,e),t}(Error);!function(e){function t(){var t=this.constructor,r=e.call(this,"getProperties is not a function!")||this;return Object.setPrototypeOf(r,t.prototype),r}i(t,e)}(Error);var d,f,h="IDE_PROPERTY_METADATA";function g(e,t,r,n){var o=Reflect.getMetadata("design:type",e,t),i=o===Array,c=function(e){return e===String?"string":e===Number?"number":e===Boolean?"boolean":"unknown"}(o);if("unknown"!==c&&(o=c),n){var s=n();Array.isArray(s)?(i=!0,o=s[0]):o=s}var p=Reflect.getMetadata(h,e.constructor)||{};p[t]=a({type:o,isArray:i},r),Reflect.defineMetadata(h,p,e.constructor)}function m(e,t){return function(r,n){if("symbol"==typeof n)throw new y;var o=function(e,t){return"function"==typeof e?{returnTypeFunc:e,options:t||{}}:{options:e||{}}}(e,t);g(r,n,o.options,o.returnTypeFunc)}}!function(e){e[e.Edit=2]="Edit",e[e.Game=4]="Game",e[e.All=6]="All"}(d||(d={})),e.MASK_TYPE=void 0,function(e){e.Circle="Circle",e.Ellipse="Ellipse",e.Rect="Rect",e.RoundedRect="RoundedRect",e.Polygon="Polygon",e.Img="Img",e.Sprite="Sprite"}(e.MASK_TYPE||(e.MASK_TYPE={}));var v,w=function(){function t(){}return c([m({step:1}),s("design:type",Number)],t.prototype,"x",void 0),c([m({step:1}),s("design:type",Number)],t.prototype,"y",void 0),c([m({step:.1,if:function(t){return t.type===e.MASK_TYPE.Circle||t.type===e.MASK_TYPE.RoundedRect}}),s("design:type",Number)],t.prototype,"radius",void 0),c([m({step:1,if:function(t){return t.type!==e.MASK_TYPE.Circle}}),s("design:type",Number)],t.prototype,"width",void 0),c([m({step:1,if:function(t){return t.type!==e.MASK_TYPE.Circle}}),s("design:type",Number)],t.prototype,"height",void 0),t}(),E=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.style={},e.resource="",e.spriteName="",e}return i(r,t),r.prototype.init=function(e){_extends(this,e)},r.componentName="Mask",c([m({type:"selector",options:(f={},f[e.MASK_TYPE.Circle]=e.MASK_TYPE.Circle,f[e.MASK_TYPE.Ellipse]=e.MASK_TYPE.Ellipse,f[e.MASK_TYPE.Img]=e.MASK_TYPE.Img,f[e.MASK_TYPE.Rect]=e.MASK_TYPE.Rect,f[e.MASK_TYPE.RoundedRect]=e.MASK_TYPE.RoundedRect,f),alias:"type",default:e.MASK_TYPE.Circle}),s("design:type",String)],r.prototype,"mask_type",void 0),c([m((function(){return w})),s("design:type",Object)],r.prototype,"style",void 0),c([m({type:"resource",if:function(t){return t.type===e.MASK_TYPE.Img||e.MASK_TYPE.Sprite}}),s("design:type",String)],r.prototype,"resource",void 0),r}(t.Component),S=E,b={Circle:["x","y","radius"],Ellipse:["x","y","width","height"],Rect:["x","y","width","height"],RoundedRect:["x","y","width","height","radius"],Polygon:["paths"]},R={Circle:"drawCircle",Ellipse:"drawEllipse",Rect:"drawRect",RoundedRect:"drawRoundedRect",Polygon:"drawPolygon"};!function(e){e.Circle="Circle",e.Ellipse="Ellipse",e.Rect="Rect",e.RoundedRect="RoundedRect",e.Polygon="Polygon",e.Img="Img",e.Sprite="Sprite"}(v||(v={}));var _=function(e){function o(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Mask",t.changedCache={},t.maskSpriteCache={},t}return i(o,e),o.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},o.prototype.rendererUpdate=function(){this.changedCache={}},o.prototype.componentChanged=function(e){if("Mask"===e.component.name)switch(e.type){case t.OBSERVER_TYPE.ADD:this.add(e);break;case t.OBSERVER_TYPE.REMOVE:this.remove(e);break;case t.OBSERVER_TYPE.CHANGE:this.change(e)}},o.prototype.add=function(e){var t,r=e.component;if(!(r.type in v))throw new Error("no have Mask type: "+r.type);if(!r.style)throw new Error("no have Mask style: "+r.type);switch(r.type){case v.Circle:case v.Ellipse:case v.Rect:case v.RoundedRect:case v.Polygon:t=this.createGraphics(r);break;case v.Img:case v.Sprite:t=this.createSprite(r)}if(!t)throw new Error("no have mask instance, check your mask params: "+r.type);var n=this.containerManager.getContainer(e.gameObject.id);n.mask=t,n.addChild(t)},o.prototype.remove=function(e){var t=this.containerManager.getContainer(e.gameObject.id);t.removeChild(t.mask),t.mask.destroy({children:!0}),t.mask=null,delete this.maskSpriteCache[e.gameObject.id]},o.prototype.change=function(e){if(!this.changedCache[e.gameObject.id]){var t=e.component;"type"===e.prop.prop[0]?(this.changedCache[e.gameObject.id]=!0,[v.Sprite,v.Img].indexOf(t.type)>-1||t._lastType!==t.type?(this.remove(e),this.add(e),t._lastType=t.type):this.redrawGraphics(e)):"style"===e.prop.prop[0]?[v.Sprite,v.Img].indexOf(t.type)>-1?this.changeSpriteStyle(t):this.redrawGraphics(e):("resource"===e.prop.prop[0]||"spriteName"===e.prop.prop[0])&&(this.changedCache[e.gameObject.id]=!0,this.changeSprite(t))}},o.prototype.createGraphics=function(e){var t=new n.Graphics;return this.draw(t,e),t},o.prototype.redrawGraphics=function(e){var t=this.containerManager.getContainer(e.gameObject.id).mask;t.clear(),this.draw(t,e.component)},o.prototype.draw=function(e,t){var r,n,o=[];try{for(var i=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(b[t.type]),a=i.next();!a.done;a=i.next()){var c=a.value;o.push(t.style[c])}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}e.beginFill(0,1),e[R[t.type]].apply(e,function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(l(arguments[t]));return e}(o)),e.endFill()},o.prototype.createSprite=function(e){var t=new n.Sprite(null);return this.maskSpriteCache[e.gameObject.id]=t,this.setSprite(e,t),t.sprite},o.prototype.changeSpriteStyle=function(e){var t=this.maskSpriteCache[e.gameObject.id];t.sprite.width=e.style.width,t.sprite.height=e.style.height,t.sprite.position.x=e.style.x,t.sprite.position.y=e.style.y},o.prototype.changeSprite=function(e){var t=this.maskSpriteCache[e.gameObject.id];this.setSprite(e,t)},o.prototype.setSprite=function(e,r){return p(this,void 0,void 0,(function(){var n,o,i,a;return u(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),o=this.increaseAsyncId(e.gameObject.id),[4,t.resource.getResource(e.resource)];case 1:return n=c.sent(),this.validateAsyncId(e.gameObject.id,o)?[3,3]:[2];case 2:throw c.sent(),new Error("mask resource load error");case 3:return e.type===v.Sprite?(i=e.resource+"_s|r|c_"+e.spriteName,a=n.instance[i],r.image=a):r.image=n.data.image,r.sprite.width=e.style.width,r.sprite.height=e.style.height,r.sprite.position.x=e.style.x,r.sprite.position.y=e.style.y,[2]}}))}))},o.systemName="Mask",o=c([t.decorators.componentObserver({Mask:["type",{prop:["style"],deep:!0},"resource","spriteName"]})],o)}(r.Renderer),A=_;return e.Mask=S,e.MaskSystem=A,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter);window.EVA.plugin.renderer.mask=window.EVA.plugin.renderer.mask||_EVA_IIFE_mask;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-mask",
3
- "version": "1.2.7-editor.5",
3
+ "version": "1.2.7-editor.8",
4
4
  "description": "@eva/plugin-renderer-mask",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-mask.esm.js",
@@ -18,10 +18,10 @@
18
18
  "license": "MIT",
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
- "@eva/inspector-decorator": "0.1.0-alpha.1",
22
- "@eva/plugin-renderer": "1.2.7-editor.5",
23
- "@eva/renderer-adapter": "1.2.7-editor.5",
24
- "@eva/eva.js": "1.2.7-editor.5",
21
+ "@eva/inspector-decorator": "0.1.0-alpha.2",
22
+ "@eva/plugin-renderer": "1.2.7-editor.8",
23
+ "@eva/renderer-adapter": "1.2.7-editor.8",
24
+ "@eva/eva.js": "1.2.7-editor.8",
25
25
  "pixi.js": "^4.8.7"
26
26
  }
27
27
  }
@@ -1,366 +0,0 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- import { __decorate, __metadata, __extends, __values, __spread, __awaiter, __generator } from 'tslib';
4
- import { Component, OBSERVER_TYPE, resource, decorators } from '@eva/eva.js/dist/miniprogram';
5
- import { Field } from '@eva/inspector-decorator';
6
- import { RendererSystem, Renderer } from '@eva/plugin-renderer/dist/miniprogram';
7
- import { Graphics, Sprite } from '@eva/renderer-adapter/dist/miniprogram';
8
-
9
- var _a;
10
-
11
- var MASK_TYPE$1;
12
-
13
- (function (MASK_TYPE) {
14
- MASK_TYPE["Circle"] = "Circle";
15
- MASK_TYPE["Ellipse"] = "Ellipse";
16
- MASK_TYPE["Rect"] = "Rect";
17
- MASK_TYPE["RoundedRect"] = "RoundedRect";
18
- MASK_TYPE["Polygon"] = "Polygon";
19
- MASK_TYPE["Img"] = "Img";
20
- MASK_TYPE["Sprite"] = "Sprite";
21
- })(MASK_TYPE$1 || (MASK_TYPE$1 = {}));
22
-
23
- var MaskStyle = function () {
24
- function MaskStyle() {}
25
-
26
- __decorate([Field({
27
- step: 1
28
- }), __metadata("design:type", Number)], MaskStyle.prototype, "x", void 0);
29
-
30
- __decorate([Field({
31
- step: 1
32
- }), __metadata("design:type", Number)], MaskStyle.prototype, "y", void 0);
33
-
34
- __decorate([Field({
35
- step: 0.1,
36
- if: function _if(mask) {
37
- return mask.type === MASK_TYPE$1.Circle || mask.type === MASK_TYPE$1.RoundedRect;
38
- }
39
- }), __metadata("design:type", Number)], MaskStyle.prototype, "radius", void 0);
40
-
41
- __decorate([Field({
42
- step: 1,
43
- if: function _if(mask) {
44
- return mask.type !== MASK_TYPE$1.Circle;
45
- }
46
- }), __metadata("design:type", Number)], MaskStyle.prototype, "width", void 0);
47
-
48
- __decorate([Field({
49
- step: 1,
50
- if: function _if(mask) {
51
- return mask.type !== MASK_TYPE$1.Circle;
52
- }
53
- }), __metadata("design:type", Number)], MaskStyle.prototype, "height", void 0);
54
-
55
- return MaskStyle;
56
- }();
57
-
58
- var Mask$2 = function (_super) {
59
- __extends(Mask, _super);
60
-
61
- function Mask() {
62
- var _this = _super !== null && _super.apply(this, arguments) || this;
63
-
64
- _this.style = {};
65
- _this.resource = '';
66
- _this.spriteName = '';
67
- return _this;
68
- }
69
-
70
- Mask.prototype.init = function (obj) {
71
- _extends(this, obj);
72
- };
73
-
74
- Mask.componentName = 'Mask';
75
-
76
- __decorate([Field({
77
- type: 'selector',
78
- options: (_a = {}, _a[MASK_TYPE$1.Circle] = MASK_TYPE$1.Circle, _a[MASK_TYPE$1.Ellipse] = MASK_TYPE$1.Ellipse, _a[MASK_TYPE$1.Img] = MASK_TYPE$1.Img, _a[MASK_TYPE$1.Rect] = MASK_TYPE$1.Rect, _a[MASK_TYPE$1.RoundedRect] = MASK_TYPE$1.RoundedRect, _a),
79
- alias: 'type',
80
- default: MASK_TYPE$1.Circle
81
- }), __metadata("design:type", String)], Mask.prototype, "mask_type", void 0);
82
-
83
- __decorate([Field(function () {
84
- return MaskStyle;
85
- }), __metadata("design:type", Object)], Mask.prototype, "style", void 0);
86
-
87
- __decorate([Field({
88
- type: 'resource',
89
- if: function _if(mask) {
90
- return mask.type === MASK_TYPE$1.Img || MASK_TYPE$1.Sprite;
91
- }
92
- }), __metadata("design:type", String)], Mask.prototype, "resource", void 0);
93
-
94
- return Mask;
95
- }(Component);
96
-
97
- var Mask$3 = Mask$2;
98
- var resourceKeySplit = '_s|r|c_';
99
- var propertyForGraphics = {
100
- Circle: ['x', 'y', 'radius'],
101
- Ellipse: ['x', 'y', 'width', 'height'],
102
- Rect: ['x', 'y', 'width', 'height'],
103
- RoundedRect: ['x', 'y', 'width', 'height', 'radius'],
104
- Polygon: ['paths']
105
- };
106
- var functionForGraphics = {
107
- Circle: 'drawCircle',
108
- Ellipse: 'drawEllipse',
109
- Rect: 'drawRect',
110
- RoundedRect: 'drawRoundedRect',
111
- Polygon: 'drawPolygon'
112
- };
113
- var MASK_TYPE;
114
-
115
- (function (MASK_TYPE) {
116
- MASK_TYPE["Circle"] = "Circle";
117
- MASK_TYPE["Ellipse"] = "Ellipse";
118
- MASK_TYPE["Rect"] = "Rect";
119
- MASK_TYPE["RoundedRect"] = "RoundedRect";
120
- MASK_TYPE["Polygon"] = "Polygon";
121
- MASK_TYPE["Img"] = "Img";
122
- MASK_TYPE["Sprite"] = "Sprite";
123
- })(MASK_TYPE || (MASK_TYPE = {}));
124
-
125
- var Mask = function (_super) {
126
- __extends(Mask, _super);
127
-
128
- function Mask() {
129
- var _this = _super !== null && _super.apply(this, arguments) || this;
130
-
131
- _this.name = 'Mask';
132
- _this.changedCache = {};
133
- _this.maskSpriteCache = {};
134
- return _this;
135
- }
136
-
137
- Mask.prototype.init = function () {
138
- this.renderSystem = this.game.getSystem(RendererSystem);
139
- this.renderSystem.rendererManager.register(this);
140
- };
141
-
142
- Mask.prototype.rendererUpdate = function () {
143
- this.changedCache = {};
144
- };
145
-
146
- Mask.prototype.componentChanged = function (changed) {
147
- if (changed.component.name !== 'Mask') return;
148
-
149
- switch (changed.type) {
150
- case OBSERVER_TYPE.ADD:
151
- this.add(changed);
152
- break;
153
-
154
- case OBSERVER_TYPE.REMOVE:
155
- this.remove(changed);
156
- break;
157
-
158
- case OBSERVER_TYPE.CHANGE:
159
- this.change(changed);
160
- break;
161
- }
162
- };
163
-
164
- Mask.prototype.add = function (changed) {
165
- var component = changed.component;
166
-
167
- if (!(component.type in MASK_TYPE)) {
168
- throw new Error('no have Mask type: ' + component.type);
169
- }
170
-
171
- if (!component.style) {
172
- throw new Error('no have Mask style: ' + component.type);
173
- }
174
-
175
- var mask;
176
-
177
- switch (component.type) {
178
- case MASK_TYPE.Circle:
179
- mask = this.createGraphics(component);
180
- break;
181
-
182
- case MASK_TYPE.Ellipse:
183
- mask = this.createGraphics(component);
184
- break;
185
-
186
- case MASK_TYPE.Rect:
187
- mask = this.createGraphics(component);
188
- break;
189
-
190
- case MASK_TYPE.RoundedRect:
191
- mask = this.createGraphics(component);
192
- break;
193
-
194
- case MASK_TYPE.Polygon:
195
- mask = this.createGraphics(component);
196
- break;
197
-
198
- case MASK_TYPE.Img:
199
- mask = this.createSprite(component);
200
- break;
201
-
202
- case MASK_TYPE.Sprite:
203
- mask = this.createSprite(component);
204
- break;
205
- }
206
-
207
- if (!mask) {
208
- throw new Error('no have mask instance, check your mask params: ' + component.type);
209
- }
210
-
211
- var container = this.containerManager.getContainer(changed.gameObject.id);
212
- container.mask = mask;
213
- container.addChild(mask);
214
- };
215
-
216
- Mask.prototype.remove = function (changed) {
217
- var container = this.containerManager.getContainer(changed.gameObject.id);
218
- container.removeChild(container.mask);
219
- container.mask.destroy({
220
- children: true
221
- });
222
- container.mask = null;
223
- delete this.maskSpriteCache[changed.gameObject.id];
224
- };
225
-
226
- Mask.prototype.change = function (changed) {
227
- if (this.changedCache[changed.gameObject.id]) return;
228
- var component = changed.component;
229
-
230
- if (changed.prop.prop[0] === 'type') {
231
- this.changedCache[changed.gameObject.id] = true;
232
-
233
- if ([MASK_TYPE.Sprite, MASK_TYPE.Img].indexOf(component.type) > -1 || component._lastType !== component.type) {
234
- this.remove(changed);
235
- this.add(changed);
236
- component._lastType = component.type;
237
- } else {
238
- this.redrawGraphics(changed);
239
- }
240
- } else if (changed.prop.prop[0] === 'style') {
241
- if ([MASK_TYPE.Sprite, MASK_TYPE.Img].indexOf(component.type) > -1) {
242
- this.changeSpriteStyle(component);
243
- } else {
244
- this.redrawGraphics(changed);
245
- }
246
- } else if (changed.prop.prop[0] === 'resource') {
247
- this.changedCache[changed.gameObject.id] = true;
248
- this.changeSprite(component);
249
- } else if (changed.prop.prop[0] === 'spriteName') {
250
- this.changedCache[changed.gameObject.id] = true;
251
- this.changeSprite(component);
252
- }
253
- };
254
-
255
- Mask.prototype.createGraphics = function (component) {
256
- var graphics = new Graphics();
257
- this.draw(graphics, component);
258
- return graphics;
259
- };
260
-
261
- Mask.prototype.redrawGraphics = function (changed) {
262
- var container = this.containerManager.getContainer(changed.gameObject.id);
263
- var graphics = container.mask;
264
- graphics.clear();
265
- this.draw(graphics, changed.component);
266
- };
267
-
268
- Mask.prototype.draw = function (graphics, component) {
269
- var e_1, _a;
270
-
271
- var params = [];
272
-
273
- try {
274
- for (var _b = __values(propertyForGraphics[component.type]), _c = _b.next(); !_c.done; _c = _b.next()) {
275
- var key = _c.value;
276
- params.push(component.style[key]);
277
- }
278
- } catch (e_1_1) {
279
- e_1 = {
280
- error: e_1_1
281
- };
282
- } finally {
283
- try {
284
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
285
- } finally {
286
- if (e_1) throw e_1.error;
287
- }
288
- }
289
-
290
- graphics.beginFill(0x000000, 1);
291
- graphics[functionForGraphics[component.type]].apply(graphics, __spread(params));
292
- graphics.endFill();
293
- };
294
-
295
- Mask.prototype.createSprite = function (component) {
296
- var sprite = new Sprite(null);
297
- this.maskSpriteCache[component.gameObject.id] = sprite;
298
- this.setSprite(component, sprite);
299
- return sprite.sprite;
300
- };
301
-
302
- Mask.prototype.changeSpriteStyle = function (component) {
303
- var sprite = this.maskSpriteCache[component.gameObject.id];
304
- sprite.sprite.width = component.style.width;
305
- sprite.sprite.height = component.style.height;
306
- sprite.sprite.position.x = component.style.x;
307
- sprite.sprite.position.y = component.style.y;
308
- };
309
-
310
- Mask.prototype.changeSprite = function (component) {
311
- var sprite = this.maskSpriteCache[component.gameObject.id];
312
- this.setSprite(component, sprite);
313
- };
314
-
315
- Mask.prototype.setSprite = function (component, sprite) {
316
- return __awaiter(this, void 0, void 0, function () {
317
- var res, asyncId, img, texture;
318
- return __generator(this, function (_a) {
319
- switch (_a.label) {
320
- case 0:
321
- _a.trys.push([0, 2,, 3]);
322
-
323
- asyncId = this.increaseAsyncId(component.gameObject.id);
324
- return [4, resource.getResource(component.resource)];
325
-
326
- case 1:
327
- res = _a.sent();
328
- if (!this.validateAsyncId(component.gameObject.id, asyncId)) return [2];
329
- return [3, 3];
330
-
331
- case 2:
332
- _a.sent();
333
-
334
- throw new Error('mask resource load error');
335
-
336
- case 3:
337
- if (component.type === MASK_TYPE.Sprite) {
338
- img = component.resource + resourceKeySplit + component.spriteName;
339
- texture = res.instance[img];
340
- sprite.image = texture;
341
- } else {
342
- sprite.image = res.data.image;
343
- }
344
-
345
- sprite.sprite.width = component.style.width;
346
- sprite.sprite.height = component.style.height;
347
- sprite.sprite.position.x = component.style.x;
348
- sprite.sprite.position.y = component.style.y;
349
- return [2];
350
- }
351
- });
352
- });
353
- };
354
-
355
- Mask.systemName = 'Mask';
356
- Mask = __decorate([decorators.componentObserver({
357
- Mask: ['type', {
358
- prop: ['style'],
359
- deep: true
360
- }, 'resource', 'spriteName']
361
- })], Mask);
362
- return Mask;
363
- }(Renderer);
364
-
365
- var Mask$1 = Mask;
366
- export { MASK_TYPE$1 as MASK_TYPE, Mask$3 as Mask, Mask$1 as MaskSystem };