@eva/plugin-renderer-nine-patch 2.0.0-beta.9 → 2.0.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- window.EVA = window.EVA || {};
2
- window.EVA.plugin = window.EVA.plugin || {};
3
- window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
1
+ globalThis.EVA = globalThis.EVA || {};
2
+ globalThis.EVA.plugin = globalThis.EVA.plugin || {};
3
+ globalThis.EVA.plugin.renderer = globalThis.EVA.plugin.renderer || {};
4
4
  var _EVA_IIFE_ninePatch = function (exports, eva_js, pluginRenderer, rendererAdapter) {
5
5
  'use strict';
6
6
  function __decorate(decorators, target, key, desc) {
@@ -128,7 +128,8 @@ var _EVA_IIFE_ninePatch = function (exports, eva_js, pluginRenderer, rendererAda
128
128
  const asyncId = this.increaseAsyncId(gameObjectId);
129
129
  const {
130
130
  type,
131
- data
131
+ data,
132
+ instance
132
133
  } = yield eva_js.resource.getResource(component.resource);
133
134
  if (!this.validateAsyncId(gameObjectId, asyncId)) return;
134
135
  if (!data) {
@@ -136,8 +137,12 @@ var _EVA_IIFE_ninePatch = function (exports, eva_js, pluginRenderer, rendererAda
136
137
  return;
137
138
  }
138
139
  let img;
139
- if (type === eva_js.RESOURCE_TYPE.SPRITE) {
140
- img = component.resource + resourceKeySplit + component.spriteName;
140
+ if (type === eva_js.RESOURCE_TYPE.SPRITE && component.spriteName) {
141
+ if (!instance) {
142
+ console.error(`GameObjectNinePatch Sprite resource rely on the Sprite system`);
143
+ return;
144
+ }
145
+ img = instance[component.resource + resourceKeySplit + component.spriteName];
141
146
  } else {
142
147
  img = data.image;
143
148
  }
@@ -178,4 +183,4 @@ var _EVA_IIFE_ninePatch = function (exports, eva_js, pluginRenderer, rendererAda
178
183
  });
179
184
  return exports;
180
185
  }({}, EVA, EVA.plugin.renderer, EVA.rendererAdapter);
181
- window.EVA.plugin.renderer.ninePatch = window.EVA.plugin.renderer.ninePatch || _EVA_IIFE_ninePatch;
186
+ globalThis.EVA.plugin.renderer.ninePatch = globalThis.EVA.plugin.renderer.ninePatch || _EVA_IIFE_ninePatch;
@@ -1 +1 @@
1
- window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_ninePatch=function(e,t,i,n){"use strict";function r(e,t,i,n){var r,o=arguments.length,c=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(c=(o<3?r(c):o>3?r(t,i,c):r(t,i))||c);return o>3&&c&&Object.defineProperty(t,i,c),c}function o(e,t,i,n){return new(i||(i=Promise))((function(r,o){function c(e){try{h(n.next(e))}catch(e){o(e)}}function s(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(c,s)}h((n=n.apply(e,t||[])).next())}))}function c(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}function s(e){return function(t,i){var n=c(t,i);n.key=i,n.type=e}}function h(e){return function(t,i){c(t,i).step=e}}class d extends t.Component{constructor(){super(...arguments),this.resource="",this.spriteName="",this.leftWidth=0,this.topHeight=0,this.rightWidth=0,this.bottomHeight=0}init(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}}d.componentName="NinePatch",r([s("string")],d.prototype,"resource",void 0),r([s("string")],d.prototype,"spriteName",void 0),r([s("number"),h(1)],d.prototype,"leftWidth",void 0),r([s("number"),h(1)],d.prototype,"topHeight",void 0),r([s("number"),h(1)],d.prototype,"rightWidth",void 0),r([s("number"),h(1)],d.prototype,"bottomHeight",void 0);let a=class extends i.Renderer{constructor(){super(...arguments),this.name="NinePatch",this.ninePatch={}}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:i}=e.transform.size;this.ninePatch[e.id]&&(this.ninePatch[e.id].width=t,this.ninePatch[e.id].height=i)}componentChanged(e){return o(this,void 0,void 0,(function*(){"NinePatch"===e.componentName&&(e.type===t.OBSERVER_TYPE.ADD?this.add(e):e.type===t.OBSERVER_TYPE.REMOVE?this.remove(e):(this.remove(e),this.add(e)))}))}add(e){return o(this,void 0,void 0,(function*(){const i=e.component,r=e.gameObject.id,o=this.increaseAsyncId(r),{type:c,data:s}=yield t.resource.getResource(i.resource);if(!this.validateAsyncId(r,o))return;if(!s)return void console.error(`GameObject:${e.gameObject.name}'s NinePatch resource load error`);let h;h=c===t.RESOURCE_TYPE.SPRITE?i.resource+"_s|r|c_"+i.spriteName:s.image;const{leftWidth:d,topHeight:a,rightWidth:u,bottomHeight:p}=i,g=new n.NinePatch(h,d,a,u,p);this.ninePatch[e.gameObject.id]=g,i.ninePatch=g,this.containerManager.getContainer(e.gameObject.id).addChildAt(g,0)}))}remove(e){const t=e.gameObject.id;this.increaseAsyncId(t);const i=this.ninePatch[t];i&&(this.containerManager.getContainer(e.gameObject.id).removeChild(i),delete this.ninePatch[e.gameObject.id],i.destroy({children:!0}))}};a.systemName="NinePatch",a=r([t.decorators.componentObserver({NinePatch:["resource","spriteName","leftWidth","topHeight","rightWidth","bottomHeight"]})],a);var u=a;return e.NinePatch=d,e.NinePatchSystem=u,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter);window.EVA.plugin.renderer.ninePatch=window.EVA.plugin.renderer.ninePatch||_EVA_IIFE_ninePatch;
1
+ globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{},globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||{};var _EVA_IIFE_ninePatch=function(e,t,i,r){"use strict";function n(e,t,i,r){var n,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,r);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(s=(o<3?n(s):o>3?n(t,i,s):n(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s}function o(e,t,i,r){return new(i||(i=Promise))((function(n,o){function s(e){try{h(r.next(e))}catch(e){o(e)}}function c(e){try{h(r.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}h((r=r.apply(e,t||[])).next())}))}function s(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}function c(e){return function(t,i){var r=s(t,i);r.key=i,r.type=e}}function h(e){return function(t,i){s(t,i).step=e}}class a extends t.Component{constructor(){super(...arguments),this.resource="",this.spriteName="",this.leftWidth=0,this.topHeight=0,this.rightWidth=0,this.bottomHeight=0}init(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}}a.componentName="NinePatch",n([c("string")],a.prototype,"resource",void 0),n([c("string")],a.prototype,"spriteName",void 0),n([c("number"),h(1)],a.prototype,"leftWidth",void 0),n([c("number"),h(1)],a.prototype,"topHeight",void 0),n([c("number"),h(1)],a.prototype,"rightWidth",void 0),n([c("number"),h(1)],a.prototype,"bottomHeight",void 0);let d=class extends i.Renderer{constructor(){super(...arguments),this.name="NinePatch",this.ninePatch={}}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:i}=e.transform.size;this.ninePatch[e.id]&&(this.ninePatch[e.id].width=t,this.ninePatch[e.id].height=i)}componentChanged(e){return o(this,void 0,void 0,(function*(){"NinePatch"===e.componentName&&(e.type===t.OBSERVER_TYPE.ADD?this.add(e):e.type===t.OBSERVER_TYPE.REMOVE?this.remove(e):(this.remove(e),this.add(e)))}))}add(e){return o(this,void 0,void 0,(function*(){const i=e.component,n=e.gameObject.id,o=this.increaseAsyncId(n),{type:s,data:c,instance:h}=yield t.resource.getResource(i.resource);if(!this.validateAsyncId(n,o))return;if(!c)return void console.error(`GameObject:${e.gameObject.name}'s NinePatch resource load error`);let a;if(s===t.RESOURCE_TYPE.SPRITE&&i.spriteName){if(!h)return void console.error("GameObjectNinePatch Sprite resource rely on the Sprite system");a=h[i.resource+"_s|r|c_"+i.spriteName]}else a=c.image;const{leftWidth:d,topHeight:u,rightWidth:p,bottomHeight:g}=i,l=new r.NinePatch(a,d,u,p,g);this.ninePatch[e.gameObject.id]=l,i.ninePatch=l,this.containerManager.getContainer(e.gameObject.id).addChildAt(l,0)}))}remove(e){const t=e.gameObject.id;this.increaseAsyncId(t);const i=this.ninePatch[t];i&&(this.containerManager.getContainer(e.gameObject.id).removeChild(i),delete this.ninePatch[e.gameObject.id],i.destroy({children:!0}))}};d.systemName="NinePatch",d=n([t.decorators.componentObserver({NinePatch:["resource","spriteName","leftWidth","topHeight","rightWidth","bottomHeight"]})],d);var u=d;return e.NinePatch=a,e.NinePatchSystem=u,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter);globalThis.EVA.plugin.renderer.ninePatch=globalThis.EVA.plugin.renderer.ninePatch||_EVA_IIFE_ninePatch;
@@ -120,7 +120,7 @@ let NinePatch = class NinePatch extends pluginRenderer.Renderer {
120
120
  const component = changed.component;
121
121
  const gameObjectId = changed.gameObject.id;
122
122
  const asyncId = this.increaseAsyncId(gameObjectId);
123
- const { type, data } = yield eva_js.resource.getResource(component.resource);
123
+ const { type, data, instance } = yield eva_js.resource.getResource(component.resource);
124
124
  if (!this.validateAsyncId(gameObjectId, asyncId))
125
125
  return;
126
126
  if (!data) {
@@ -128,8 +128,12 @@ let NinePatch = class NinePatch extends pluginRenderer.Renderer {
128
128
  return;
129
129
  }
130
130
  let img;
131
- if (type === eva_js.RESOURCE_TYPE.SPRITE) {
132
- img = component.resource + resourceKeySplit + component.spriteName;
131
+ if (type === eva_js.RESOURCE_TYPE.SPRITE && component.spriteName) {
132
+ if (!instance) {
133
+ console.error(`GameObjectNinePatch Sprite resource rely on the Sprite system`);
134
+ return;
135
+ }
136
+ img = instance[component.resource + resourceKeySplit + component.spriteName];
133
137
  }
134
138
  else {
135
139
  img = data.image;
@@ -13,4 +13,4 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
13
13
  See the Apache Version 2.0 License for specific language governing permissions
14
14
  and limitations under the License.
15
15
  ***************************************************************************** */
16
- function n(e,t,i,r){var n,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,r);else for(var h=e.length-1;h>=0;h--)(n=e[h])&&(s=(o<3?n(s):o>3?n(t,i,s):n(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s}function o(e,t,i,r){return new(i||(i=Promise))((function(n,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function h(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?n(e.value):new i((function(t){t(e.value)})).then(s,h)}c((r=r.apply(e,t||[])).next())}))}class s extends e.Component{constructor(){super(...arguments),this.resource="",this.spriteName="",this.leftWidth=0,this.topHeight=0,this.rightWidth=0,this.bottomHeight=0}init(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}}s.componentName="NinePatch",n([t.type("string")],s.prototype,"resource",void 0),n([t.type("string")],s.prototype,"spriteName",void 0),n([t.type("number"),t.step(1)],s.prototype,"leftWidth",void 0),n([t.type("number"),t.step(1)],s.prototype,"topHeight",void 0),n([t.type("number"),t.step(1)],s.prototype,"rightWidth",void 0),n([t.type("number"),t.step(1)],s.prototype,"bottomHeight",void 0);let h=class extends i.Renderer{constructor(){super(...arguments),this.name="NinePatch",this.ninePatch={}}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:i}=e.transform.size;this.ninePatch[e.id]&&(this.ninePatch[e.id].width=t,this.ninePatch[e.id].height=i)}componentChanged(t){return o(this,void 0,void 0,(function*(){"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)))}))}add(t){return o(this,void 0,void 0,(function*(){const i=t.component,n=t.gameObject.id,o=this.increaseAsyncId(n),{type:s,data:h}=yield e.resource.getResource(i.resource);if(!this.validateAsyncId(n,o))return;if(!h)return void console.error(`GameObject:${t.gameObject.name}'s NinePatch resource load error`);let c;c=s===e.RESOURCE_TYPE.SPRITE?i.resource+"_s|r|c_"+i.spriteName:h.image;const{leftWidth:a,topHeight:d,rightWidth:p,bottomHeight:m}=i,u=new r.NinePatch(c,a,d,p,m);this.ninePatch[t.gameObject.id]=u,i.ninePatch=u,this.containerManager.getContainer(t.gameObject.id).addChildAt(u,0)}))}remove(e){const t=e.gameObject.id;this.increaseAsyncId(t);const i=this.ninePatch[t];i&&(this.containerManager.getContainer(e.gameObject.id).removeChild(i),delete this.ninePatch[e.gameObject.id],i.destroy({children:!0}))}};h.systemName="NinePatch",h=n([e.decorators.componentObserver({NinePatch:["resource","spriteName","leftWidth","topHeight","rightWidth","bottomHeight"]})],h);var c=h;exports.NinePatch=s,exports.NinePatchSystem=c;
16
+ function n(e,t,i,r){var n,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,r);else for(var h=e.length-1;h>=0;h--)(n=e[h])&&(s=(o<3?n(s):o>3?n(t,i,s):n(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s}function o(e,t,i,r){return new(i||(i=Promise))((function(n,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function h(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?n(e.value):new i((function(t){t(e.value)})).then(s,h)}c((r=r.apply(e,t||[])).next())}))}class s extends e.Component{constructor(){super(...arguments),this.resource="",this.spriteName="",this.leftWidth=0,this.topHeight=0,this.rightWidth=0,this.bottomHeight=0}init(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}}s.componentName="NinePatch",n([t.type("string")],s.prototype,"resource",void 0),n([t.type("string")],s.prototype,"spriteName",void 0),n([t.type("number"),t.step(1)],s.prototype,"leftWidth",void 0),n([t.type("number"),t.step(1)],s.prototype,"topHeight",void 0),n([t.type("number"),t.step(1)],s.prototype,"rightWidth",void 0),n([t.type("number"),t.step(1)],s.prototype,"bottomHeight",void 0);let h=class extends i.Renderer{constructor(){super(...arguments),this.name="NinePatch",this.ninePatch={}}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:i}=e.transform.size;this.ninePatch[e.id]&&(this.ninePatch[e.id].width=t,this.ninePatch[e.id].height=i)}componentChanged(t){return o(this,void 0,void 0,(function*(){"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)))}))}add(t){return o(this,void 0,void 0,(function*(){const i=t.component,n=t.gameObject.id,o=this.increaseAsyncId(n),{type:s,data:h,instance:c}=yield e.resource.getResource(i.resource);if(!this.validateAsyncId(n,o))return;if(!h)return void console.error(`GameObject:${t.gameObject.name}'s NinePatch resource load error`);let a;if(s===e.RESOURCE_TYPE.SPRITE&&i.spriteName){if(!c)return void console.error("GameObjectNinePatch Sprite resource rely on the Sprite system");a=c[i.resource+"_s|r|c_"+i.spriteName]}else a=h.image;const{leftWidth:d,topHeight:p,rightWidth:m,bottomHeight:u}=i,g=new r.NinePatch(a,d,p,m,u);this.ninePatch[t.gameObject.id]=g,i.ninePatch=g,this.containerManager.getContainer(t.gameObject.id).addChildAt(g,0)}))}remove(e){const t=e.gameObject.id;this.increaseAsyncId(t);const i=this.ninePatch[t];i&&(this.containerManager.getContainer(e.gameObject.id).removeChild(i),delete this.ninePatch[e.gameObject.id],i.destroy({children:!0}))}};h.systemName="NinePatch",h=n([e.decorators.componentObserver({NinePatch:["resource","spriteName","leftWidth","topHeight","rightWidth","bottomHeight"]})],h);var c=h;exports.NinePatch=s,exports.NinePatchSystem=c;
@@ -116,7 +116,7 @@ let NinePatch = class NinePatch extends Renderer {
116
116
  const component = changed.component;
117
117
  const gameObjectId = changed.gameObject.id;
118
118
  const asyncId = this.increaseAsyncId(gameObjectId);
119
- const { type, data } = yield resource.getResource(component.resource);
119
+ const { type, data, instance } = yield resource.getResource(component.resource);
120
120
  if (!this.validateAsyncId(gameObjectId, asyncId))
121
121
  return;
122
122
  if (!data) {
@@ -124,8 +124,12 @@ let NinePatch = class NinePatch extends Renderer {
124
124
  return;
125
125
  }
126
126
  let img;
127
- if (type === RESOURCE_TYPE.SPRITE) {
128
- img = component.resource + resourceKeySplit + component.spriteName;
127
+ if (type === RESOURCE_TYPE.SPRITE && component.spriteName) {
128
+ if (!instance) {
129
+ console.error(`GameObjectNinePatch Sprite resource rely on the Sprite system`);
130
+ return;
131
+ }
132
+ img = instance[component.resource + resourceKeySplit + component.spriteName];
129
133
  }
130
134
  else {
131
135
  img = data.image;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-nine-patch",
3
- "version": "2.0.0-beta.9",
3
+ "version": "2.0.1-beta.0",
4
4
  "description": "@eva/plugin-renderer-nine-patch",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-nine-patch.esm.js",
@@ -19,8 +19,8 @@
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
21
  "@eva/inspector-decorator": "^0.0.5",
22
- "@eva/plugin-renderer": "2.0.0-beta.9",
23
- "@eva/renderer-adapter": "2.0.0-beta.9",
24
- "@eva/eva.js": "2.0.0-beta.9"
22
+ "@eva/plugin-renderer": "2.0.1-beta.0",
23
+ "@eva/renderer-adapter": "2.0.1-beta.0",
24
+ "@eva/eva.js": "2.0.1-beta.0"
25
25
  }
26
26
  }