@eva/plugin-renderer-nine-patch 1.2.2-alpha.1 → 1.2.2-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -314,7 +314,8 @@ var _EVA_IIFE_ninePatch = function (exports, eva_js, pluginRenderer, rendererAda
314
314
  _a = _b.sent(), type = _a.type, data = _a.data;
315
315
 
316
316
  if (!data) {
317
- throw new Error("GameObject:" + changed.gameObject.name + "'s NinePatch resource load error");
317
+ console.error("GameObject:" + changed.gameObject.name + "'s NinePatch resource load error");
318
+ return [2];
318
319
  }
319
320
 
320
321
  if (type === eva_js.RESOURCE_TYPE.SPRITE) {
@@ -1 +1 @@
1
- var _EVA_IIFE_ninePatch=function(t,e,r,n){"use strict";var o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function i(t,e){function r(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function c(t,e,r,n){var o,i=arguments.length,c=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(c=(i<3?o(c):i>3?o(e,r,c):o(e,r))||c);return i>3&&c&&Object.defineProperty(e,r,c),c}function a(t,e,r,n){return new(r||(r=Promise))((function(o,i){function c(t){try{h(n.next(t))}catch(t){i(t)}}function a(t){try{h(n.throw(t))}catch(t){i(t)}}function h(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(c,a)}h((n=n.apply(t,e||[])).next())}))}function h(t,e){var r,n,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;c;)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 c.label++,{value:i[1],done:!1};case 5:c.label++,n=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){c.label=i[1];break}if(6===i[0]&&c.label<o[1]){c.label=o[1],o=i;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(i);break}o[2]&&c.ops.pop(),c.trys.pop();continue}i=e.call(t,c)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function u(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}function s(t){return function(e,r){var n=u(e,r);n.key=r,n.type=t}}function p(t){return function(e,r){u(e,r).step=t}}var f=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.resource="",e.spriteName="",e.leftWidth=0,e.topHeight=0,e.rightWidth=0,e.bottomHeight=0,e}return i(e,t),e.prototype.init=function(t){this.resource=t.resource,this.spriteName=t.spriteName,this.leftWidth=t.leftWidth,this.topHeight=t.topHeight,this.rightWidth=t.rightWidth,this.bottomHeight=t.bottomHeight},e.componentName="NinePatch",c([s("string")],e.prototype,"resource",void 0),c([s("string")],e.prototype,"spriteName",void 0),c([s("number"),p(1)],e.prototype,"leftWidth",void 0),c([s("number"),p(1)],e.prototype,"topHeight",void 0),c([s("number"),p(1)],e.prototype,"rightWidth",void 0),c([s("number"),p(1)],e.prototype,"bottomHeight",void 0),e}(e.Component),d=function(t){function o(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="NinePatch",e.ninePatch={},e}return i(o,t),o.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},o.prototype.rendererUpdate=function(t){var e=t.transform.size,r=e.width,n=e.height;this.ninePatch[t.id]&&(this.ninePatch[t.id].width=r,this.ninePatch[t.id].height=n)},o.prototype.componentChanged=function(t){return a(this,void 0,void 0,(function(){return h(this,(function(r){return"NinePatch"===t.componentName&&(t.type===e.OBSERVER_TYPE.ADD?this.add(t):t.type===e.OBSERVER_TYPE.REMOVE?this.remove(t):(this.remove(t),this.add(t))),[2]}))}))},o.prototype.add=function(t){return a(this,void 0,void 0,(function(){var r,o,i,c,a,u,s,p,f,d;return h(this,(function(h){switch(h.label){case 0:return r=t.component,[4,e.resource.getResource(r.resource)];case 1:if(o=h.sent(),i=o.type,!(c=o.data))throw new Error("GameObject:"+t.gameObject.name+"'s NinePatch resource load error");return a=i===e.RESOURCE_TYPE.SPRITE?r.resource+"_s|r|c_"+r.spriteName:c.image,u=r.leftWidth,s=r.topHeight,p=r.rightWidth,f=r.bottomHeight,d=new n.NinePatch(a,u,s,p,f),this.ninePatch[t.gameObject.id]=d,r.ninePatch=d,this.containerManager.getContainer(t.gameObject.id).addChildAt(d,0),[2]}}))}))},o.prototype.remove=function(t){var e=this.ninePatch[t.gameObject.id];e&&(this.containerManager.getContainer(t.gameObject.id).removeChild(e),delete this.ninePatch[t.gameObject.id],e.destroy({children:!0}))},o.systemName="NinePatch",o=c([e.decorators.componentObserver({NinePatch:["resource","spriteName","leftWidth","topHeight","rightWidth","bottomHeight"]})],o)}(r.Renderer);return t.NinePatch=f,t.NinePatchSystem=d,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter);
1
+ var _EVA_IIFE_ninePatch=function(t,e,r,n){"use strict";var o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function i(t,e){function r(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function c(t,e,r,n){var o,i=arguments.length,c=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(c=(i<3?o(c):i>3?o(e,r,c):o(e,r))||c);return i>3&&c&&Object.defineProperty(e,r,c),c}function a(t,e,r,n){return new(r||(r=Promise))((function(o,i){function c(t){try{s(n.next(t))}catch(t){i(t)}}function a(t){try{s(n.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(c,a)}s((n=n.apply(t,e||[])).next())}))}function s(t,e){var r,n,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;c;)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 c.label++,{value:i[1],done:!1};case 5:c.label++,n=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){c.label=i[1];break}if(6===i[0]&&c.label<o[1]){c.label=o[1],o=i;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(i);break}o[2]&&c.ops.pop(),c.trys.pop();continue}i=e.call(t,c)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function u(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}function h(t){return function(e,r){var n=u(e,r);n.key=r,n.type=t}}function p(t){return function(e,r){u(e,r).step=t}}var f=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.resource="",e.spriteName="",e.leftWidth=0,e.topHeight=0,e.rightWidth=0,e.bottomHeight=0,e}return i(e,t),e.prototype.init=function(t){this.resource=t.resource,this.spriteName=t.spriteName,this.leftWidth=t.leftWidth,this.topHeight=t.topHeight,this.rightWidth=t.rightWidth,this.bottomHeight=t.bottomHeight},e.componentName="NinePatch",c([h("string")],e.prototype,"resource",void 0),c([h("string")],e.prototype,"spriteName",void 0),c([h("number"),p(1)],e.prototype,"leftWidth",void 0),c([h("number"),p(1)],e.prototype,"topHeight",void 0),c([h("number"),p(1)],e.prototype,"rightWidth",void 0),c([h("number"),p(1)],e.prototype,"bottomHeight",void 0),e}(e.Component),d=function(t){function o(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="NinePatch",e.ninePatch={},e}return i(o,t),o.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},o.prototype.rendererUpdate=function(t){var e=t.transform.size,r=e.width,n=e.height;this.ninePatch[t.id]&&(this.ninePatch[t.id].width=r,this.ninePatch[t.id].height=n)},o.prototype.componentChanged=function(t){return a(this,void 0,void 0,(function(){return s(this,(function(r){return"NinePatch"===t.componentName&&(t.type===e.OBSERVER_TYPE.ADD?this.add(t):t.type===e.OBSERVER_TYPE.REMOVE?this.remove(t):(this.remove(t),this.add(t))),[2]}))}))},o.prototype.add=function(t){return a(this,void 0,void 0,(function(){var r,o,i,c,a,u,h,p,f,d;return s(this,(function(s){switch(s.label){case 0:return r=t.component,[4,e.resource.getResource(r.resource)];case 1:return o=s.sent(),i=o.type,(c=o.data)?(a=i===e.RESOURCE_TYPE.SPRITE?r.resource+"_s|r|c_"+r.spriteName:c.image,u=r.leftWidth,h=r.topHeight,p=r.rightWidth,f=r.bottomHeight,d=new n.NinePatch(a,u,h,p,f),this.ninePatch[t.gameObject.id]=d,r.ninePatch=d,this.containerManager.getContainer(t.gameObject.id).addChildAt(d,0),[2]):(console.error("GameObject:"+t.gameObject.name+"'s NinePatch resource load error"),[2])}}))}))},o.prototype.remove=function(t){var e=this.ninePatch[t.gameObject.id];e&&(this.containerManager.getContainer(t.gameObject.id).removeChild(e),delete this.ninePatch[t.gameObject.id],e.destroy({children:!0}))},o.systemName="NinePatch",o=c([e.decorators.componentObserver({NinePatch:["resource","spriteName","leftWidth","topHeight","rightWidth","bottomHeight"]})],o)}(r.Renderer);return t.NinePatch=f,t.NinePatchSystem=d,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter);
@@ -0,0 +1,152 @@
1
+ import { __extends, __decorate, __awaiter, __generator } from 'tslib';
2
+ import { Component, OBSERVER_TYPE, RESOURCE_TYPE, resource, decorators } from '@eva/eva.js/dist/miniprogram';
3
+ import { type, step } from '@eva/inspector-decorator';
4
+ import { RendererSystem, Renderer } from '@eva/plugin-renderer/dist/miniprogram';
5
+ import { NinePatch as NinePatch$4 } from '@eva/renderer-adapter/dist/miniprogram';
6
+
7
+ var NinePatch$2 = function (_super) {
8
+ __extends(NinePatch, _super);
9
+
10
+ function NinePatch() {
11
+ var _this = _super !== null && _super.apply(this, arguments) || this;
12
+
13
+ _this.resource = '';
14
+ _this.spriteName = '';
15
+ _this.leftWidth = 0;
16
+ _this.topHeight = 0;
17
+ _this.rightWidth = 0;
18
+ _this.bottomHeight = 0;
19
+ return _this;
20
+ }
21
+
22
+ NinePatch.prototype.init = function (obj) {
23
+ this.resource = obj.resource;
24
+ this.spriteName = obj.spriteName;
25
+ this.leftWidth = obj.leftWidth;
26
+ this.topHeight = obj.topHeight;
27
+ this.rightWidth = obj.rightWidth;
28
+ this.bottomHeight = obj.bottomHeight;
29
+ };
30
+
31
+ NinePatch.componentName = 'NinePatch';
32
+
33
+ __decorate([type('string')], NinePatch.prototype, "resource", void 0);
34
+
35
+ __decorate([type('string')], NinePatch.prototype, "spriteName", void 0);
36
+
37
+ __decorate([type('number'), step(1)], NinePatch.prototype, "leftWidth", void 0);
38
+
39
+ __decorate([type('number'), step(1)], NinePatch.prototype, "topHeight", void 0);
40
+
41
+ __decorate([type('number'), step(1)], NinePatch.prototype, "rightWidth", void 0);
42
+
43
+ __decorate([type('number'), step(1)], NinePatch.prototype, "bottomHeight", void 0);
44
+
45
+ return NinePatch;
46
+ }(Component);
47
+
48
+ var NinePatch$3 = NinePatch$2;
49
+ var resourceKeySplit = '_s|r|c_';
50
+
51
+ var NinePatch = function (_super) {
52
+ __extends(NinePatch, _super);
53
+
54
+ function NinePatch() {
55
+ var _this = _super !== null && _super.apply(this, arguments) || this;
56
+
57
+ _this.name = 'NinePatch';
58
+ _this.ninePatch = {};
59
+ return _this;
60
+ }
61
+
62
+ NinePatch.prototype.init = function () {
63
+ this.renderSystem = this.game.getSystem(RendererSystem);
64
+ this.renderSystem.rendererManager.register(this);
65
+ };
66
+
67
+ NinePatch.prototype.rendererUpdate = function (gameObject) {
68
+ var _a = gameObject.transform.size,
69
+ width = _a.width,
70
+ height = _a.height;
71
+
72
+ if (this.ninePatch[gameObject.id]) {
73
+ this.ninePatch[gameObject.id].width = width;
74
+ this.ninePatch[gameObject.id].height = height;
75
+ }
76
+ };
77
+
78
+ NinePatch.prototype.componentChanged = function (changed) {
79
+ return __awaiter(this, void 0, void 0, function () {
80
+ return __generator(this, function (_a) {
81
+ if (changed.componentName === 'NinePatch') {
82
+ if (changed.type === OBSERVER_TYPE.ADD) {
83
+ this.add(changed);
84
+ } else if (changed.type === OBSERVER_TYPE.REMOVE) {
85
+ this.remove(changed);
86
+ } else {
87
+ this.remove(changed);
88
+ this.add(changed);
89
+ }
90
+ }
91
+
92
+ return [2];
93
+ });
94
+ });
95
+ };
96
+
97
+ NinePatch.prototype.add = function (changed) {
98
+ return __awaiter(this, void 0, void 0, function () {
99
+ var component, _a, type, data, img, leftWidth, topHeight, rightWidth, bottomHeight, np;
100
+
101
+ return __generator(this, function (_b) {
102
+ switch (_b.label) {
103
+ case 0:
104
+ component = changed.component;
105
+ return [4, resource.getResource(component.resource)];
106
+
107
+ case 1:
108
+ _a = _b.sent(), type = _a.type, data = _a.data;
109
+
110
+ if (!data) {
111
+ console.error("GameObject:" + changed.gameObject.name + "'s NinePatch resource load error");
112
+ return [2];
113
+ }
114
+
115
+ if (type === RESOURCE_TYPE.SPRITE) {
116
+ img = component.resource + resourceKeySplit + component.spriteName;
117
+ } else {
118
+ img = data.image;
119
+ }
120
+
121
+ leftWidth = component.leftWidth, topHeight = component.topHeight, rightWidth = component.rightWidth, bottomHeight = component.bottomHeight;
122
+ np = new NinePatch$4(img, leftWidth, topHeight, rightWidth, bottomHeight);
123
+ this.ninePatch[changed.gameObject.id] = np;
124
+ component.ninePatch = np;
125
+ this.containerManager.getContainer(changed.gameObject.id).addChildAt(np, 0);
126
+ return [2];
127
+ }
128
+ });
129
+ });
130
+ };
131
+
132
+ NinePatch.prototype.remove = function (changed) {
133
+ var sprite = this.ninePatch[changed.gameObject.id];
134
+
135
+ if (sprite) {
136
+ this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite);
137
+ delete this.ninePatch[changed.gameObject.id];
138
+ sprite.destroy({
139
+ children: true
140
+ });
141
+ }
142
+ };
143
+
144
+ NinePatch.systemName = 'NinePatch';
145
+ NinePatch = __decorate([decorators.componentObserver({
146
+ NinePatch: ['resource', 'spriteName', 'leftWidth', 'topHeight', 'rightWidth', 'bottomHeight']
147
+ })], NinePatch);
148
+ return NinePatch;
149
+ }(Renderer);
150
+
151
+ var NinePatch$1 = NinePatch;
152
+ export { NinePatch$3 as NinePatch, NinePatch$1 as NinePatchSystem };
@@ -177,7 +177,8 @@ var NinePatch = (function (_super) {
177
177
  case 1:
178
178
  _a = _b.sent(), type = _a.type, data = _a.data;
179
179
  if (!data) {
180
- throw new Error("GameObject:" + changed.gameObject.name + "'s NinePatch resource load error");
180
+ console.error("GameObject:" + changed.gameObject.name + "'s NinePatch resource load error");
181
+ return [2];
181
182
  }
182
183
  if (type === eva_js.RESOURCE_TYPE.SPRITE) {
183
184
  img = component.resource + resourceKeySplit + component.spriteName;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),r=require("@eva/plugin-renderer"),n=require("@eva/renderer-adapter"),i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function o(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function a(e,t,r,n){var i,o=arguments.length,a=o<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--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{h(n.next(e))}catch(e){o(e)}}function c(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){e.done?i(e.value):new r((function(t){t(e.value)})).then(a,c)}h((n=n.apply(e,t||[])).next())}))}function h(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=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++,n=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=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}var s=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.spriteName="",t.leftWidth=0,t.topHeight=0,t.rightWidth=0,t.bottomHeight=0,t}return o(r,e),r.prototype.init=function(e){this.resource=e.resource,this.spriteName=e.spriteName,this.leftWidth=e.leftWidth,this.topHeight=e.topHeight,this.rightWidth=e.rightWidth,this.bottomHeight=e.bottomHeight},r.componentName="NinePatch",a([t.type("string")],r.prototype,"resource",void 0),a([t.type("string")],r.prototype,"spriteName",void 0),a([t.type("number"),t.step(1)],r.prototype,"leftWidth",void 0),a([t.type("number"),t.step(1)],r.prototype,"topHeight",void 0),a([t.type("number"),t.step(1)],r.prototype,"rightWidth",void 0),a([t.type("number"),t.step(1)],r.prototype,"bottomHeight",void 0),r}(e.Component),p=function(t){function i(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="NinePatch",e.ninePatch={},e}return o(i,t),i.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},i.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.ninePatch[e.id]&&(this.ninePatch[e.id].width=r,this.ninePatch[e.id].height=n)},i.prototype.componentChanged=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(r){return"NinePatch"===t.componentName&&(t.type===e.OBSERVER_TYPE.ADD?this.add(t):t.type===e.OBSERVER_TYPE.REMOVE?this.remove(t):(this.remove(t),this.add(t))),[2]}))}))},i.prototype.add=function(t){return c(this,void 0,void 0,(function(){var r,i,o,a,c,s,p,u,d,l;return h(this,(function(h){switch(h.label){case 0:return r=t.component,[4,e.resource.getResource(r.resource)];case 1:if(i=h.sent(),o=i.type,!(a=i.data))throw new Error("GameObject:"+t.gameObject.name+"'s NinePatch resource load error");return c=o===e.RESOURCE_TYPE.SPRITE?r.resource+"_s|r|c_"+r.spriteName:a.image,s=r.leftWidth,p=r.topHeight,u=r.rightWidth,d=r.bottomHeight,l=new n.NinePatch(c,s,p,u,d),this.ninePatch[t.gameObject.id]=l,r.ninePatch=l,this.containerManager.getContainer(t.gameObject.id).addChildAt(l,0),[2]}}))}))},i.prototype.remove=function(e){var t=this.ninePatch[e.gameObject.id];t&&(this.containerManager.getContainer(e.gameObject.id).removeChild(t),delete this.ninePatch[e.gameObject.id],t.destroy({children:!0}))},i.systemName="NinePatch",i=a([e.decorators.componentObserver({NinePatch:["resource","spriteName","leftWidth","topHeight","rightWidth","bottomHeight"]})],i)}(r.Renderer);exports.NinePatch=s,exports.NinePatchSystem=p;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),r=require("@eva/plugin-renderer"),n=require("@eva/renderer-adapter"),i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function o(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function a(e,t,r,n){var i,o=arguments.length,a=o<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--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{h(n.next(e))}catch(e){o(e)}}function c(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){e.done?i(e.value):new r((function(t){t(e.value)})).then(a,c)}h((n=n.apply(e,t||[])).next())}))}function h(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=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++,n=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=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}var s=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.spriteName="",t.leftWidth=0,t.topHeight=0,t.rightWidth=0,t.bottomHeight=0,t}return o(r,e),r.prototype.init=function(e){this.resource=e.resource,this.spriteName=e.spriteName,this.leftWidth=e.leftWidth,this.topHeight=e.topHeight,this.rightWidth=e.rightWidth,this.bottomHeight=e.bottomHeight},r.componentName="NinePatch",a([t.type("string")],r.prototype,"resource",void 0),a([t.type("string")],r.prototype,"spriteName",void 0),a([t.type("number"),t.step(1)],r.prototype,"leftWidth",void 0),a([t.type("number"),t.step(1)],r.prototype,"topHeight",void 0),a([t.type("number"),t.step(1)],r.prototype,"rightWidth",void 0),a([t.type("number"),t.step(1)],r.prototype,"bottomHeight",void 0),r}(e.Component),p=function(t){function i(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="NinePatch",e.ninePatch={},e}return o(i,t),i.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},i.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.ninePatch[e.id]&&(this.ninePatch[e.id].width=r,this.ninePatch[e.id].height=n)},i.prototype.componentChanged=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(r){return"NinePatch"===t.componentName&&(t.type===e.OBSERVER_TYPE.ADD?this.add(t):t.type===e.OBSERVER_TYPE.REMOVE?this.remove(t):(this.remove(t),this.add(t))),[2]}))}))},i.prototype.add=function(t){return c(this,void 0,void 0,(function(){var r,i,o,a,c,s,p,u,d,l;return h(this,(function(h){switch(h.label){case 0:return r=t.component,[4,e.resource.getResource(r.resource)];case 1:return i=h.sent(),o=i.type,(a=i.data)?(c=o===e.RESOURCE_TYPE.SPRITE?r.resource+"_s|r|c_"+r.spriteName:a.image,s=r.leftWidth,p=r.topHeight,u=r.rightWidth,d=r.bottomHeight,l=new n.NinePatch(c,s,p,u,d),this.ninePatch[t.gameObject.id]=l,r.ninePatch=l,this.containerManager.getContainer(t.gameObject.id).addChildAt(l,0),[2]):(console.error("GameObject:"+t.gameObject.name+"'s NinePatch resource load error"),[2])}}))}))},i.prototype.remove=function(e){var t=this.ninePatch[e.gameObject.id];t&&(this.containerManager.getContainer(e.gameObject.id).removeChild(t),delete this.ninePatch[e.gameObject.id],t.destroy({children:!0}))},i.systemName="NinePatch",i=a([e.decorators.componentObserver({NinePatch:["resource","spriteName","leftWidth","topHeight","rightWidth","bottomHeight"]})],i)}(r.Renderer);exports.NinePatch=s,exports.NinePatchSystem=p;
@@ -173,7 +173,8 @@ var NinePatch = (function (_super) {
173
173
  case 1:
174
174
  _a = _b.sent(), type = _a.type, data = _a.data;
175
175
  if (!data) {
176
- throw new Error("GameObject:" + changed.gameObject.name + "'s NinePatch resource load error");
176
+ console.error("GameObject:" + changed.gameObject.name + "'s NinePatch resource load error");
177
+ return [2];
177
178
  }
178
179
  if (type === RESOURCE_TYPE.SPRITE) {
179
180
  img = component.resource + resourceKeySplit + component.spriteName;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-nine-patch",
3
- "version": "1.2.2-alpha.1",
3
+ "version": "1.2.2-alpha.2",
4
4
  "description": "@eva/plugin-renderer-nine-patch",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-nine-patch.esm.js",
@@ -19,9 +19,9 @@
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
21
  "@eva/inspector-decorator": "^0.0.5",
22
- "@eva/plugin-renderer": "1.2.2-alpha.1",
23
- "@eva/renderer-adapter": "1.2.2-alpha.1",
24
- "@eva/eva.js": "1.2.2-alpha.1",
22
+ "@eva/plugin-renderer": "1.2.2-alpha.2",
23
+ "@eva/renderer-adapter": "1.2.2-alpha.2",
24
+ "@eva/eva.js": "1.2.2-alpha.2",
25
25
  "@types/pixi.js": "^4.8.9"
26
26
  }
27
27
  }