@eva/plugin-renderer-sprite 2.0.0-beta.8 → 2.0.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_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
5
5
  'use strict';
6
6
  function __decorate(decorators, target, key, desc) {
@@ -75,7 +75,7 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
75
75
  this._image = null;
76
76
  this._image = image;
77
77
  if (image) {
78
- if (image instanceof HTMLImageElement) {
78
+ if (typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement) {
79
79
  this.sprite = pixi_js.Sprite.from(image);
80
80
  } else if (image instanceof pixi_js.Texture) {
81
81
  this.sprite = new pixi_js.Sprite(image);
@@ -88,7 +88,7 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
88
88
  if (this._image === val) {
89
89
  return;
90
90
  }
91
- if (val instanceof HTMLImageElement) {
91
+ if (typeof HTMLImageElement !== 'undefined' && val instanceof HTMLImageElement) {
92
92
  this.sprite.texture && this.sprite.texture.destroy(false);
93
93
  this.sprite.texture = pixi_js.Texture.from(val);
94
94
  } else if (val instanceof pixi_js.Texture) {
@@ -215,4 +215,4 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
215
215
  });
216
216
  return exports;
217
217
  }({}, EVA, EVA.plugin.renderer, PIXI);
218
- window.EVA.plugin.renderer.sprite = window.EVA.plugin.renderer.sprite || _EVA_IIFE_sprite;
218
+ globalThis.EVA.plugin.renderer.sprite = globalThis.EVA.plugin.renderer.sprite || _EVA_IIFE_sprite;
@@ -1 +1 @@
1
- window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_sprite=function(e,t,r,i){"use strict";function s(e,t,r,i){var s,n=arguments.length,o=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(o=(n<3?s(o):n>3?s(t,r,o):s(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}function n(e,t,r,i){return new(r||(r=Promise))((function(s,n){function o(e){try{a(i.next(e))}catch(e){n(e)}}function c(e){try{a(i.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,c)}a((i=i.apply(e,t||[])).next())}))}function o(e){return function(t,r){var i=function(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}(t,r);i.key=r,i.type=e}}class c extends t.Component{constructor(){super(...arguments),this.resource="",this.spriteName=""}init(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)}}c.componentName="Sprite",s([o("string")],c.prototype,"resource",void 0),s([o("string")],c.prototype,"spriteName",void 0);class a{constructor(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.sprite=i.Sprite.from(e):e instanceof i.Texture&&(this.sprite=new i.Sprite(e)):this.sprite=new i.Sprite}set image(e){this._image!==e&&(e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=i.Texture.from(e)):e instanceof i.Texture&&(this.sprite.texture=e),this._image=e)}get image(){return this._image}}const p="_s|r|c_";t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE,(({name:e,data:t})=>new Promise((r=>{const s=t.json.data,n=t.image instanceof i.Texture?t.image:i.Texture.from(t.image),o=s.frames||{},c=s.animations||{},a={};for(const t in o){a[e+p+t]=o[t]}for(const t in c){const r=[];if(c[t]&&c[t].length>=0)for(const i of c[t]){const t=e+p+i;r.push(t)}c[t]=r}s.frames=a;const u=new i.Spritesheet(n,s);u.parse().then((()=>{r(u.textures)}))})))),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE,(({instance:e})=>{if(e)for(const t in e)e[t].destroy(!0)}));let u=class extends r.Renderer{constructor(){super(...arguments),this.name="Sprite",this.sprites={}}init(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:r}=e.transform.size;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=t,this.sprites[e.id].sprite.height=r)}componentChanged(e){return n(this,void 0,void 0,(function*(){if("Sprite"===e.componentName){const r=e.gameObject.id,i=e.component;if(e.type===t.OBSERVER_TYPE.ADD){const s=new a(null);this.sprites[e.gameObject.id]=s,this.containerManager.getContainer(e.gameObject.id).addChildAt(s.sprite,0);const n=this.increaseAsyncId(r),{instance:o}=yield t.resource.getResource(i.resource);if(!this.validateAsyncId(r,n))return;if(!o)return void console.error(`GameObject:${e.gameObject.name}'s Sprite resource load error`);s.image=o[i.resource+p+i.spriteName]}else if(e.type===t.OBSERVER_TYPE.CHANGE){const s=this.increaseAsyncId(r),{instance:n}=yield t.resource.getResource(i.resource);if(!this.validateAsyncId(r,s))return;if(!n)return void console.error(`GameObject:${e.gameObject.name}'s Sprite resource load error`);this.sprites[e.gameObject.id].image=n[i.resource+p+i.spriteName]}else if(e.type===t.OBSERVER_TYPE.REMOVE){this.increaseAsyncId(r);const t=this.sprites[e.gameObject.id];this.containerManager.getContainer(e.gameObject.id).removeChild(t.sprite),t.sprite.destroy({children:!0}),delete this.sprites[e.gameObject.id]}}}))}};u.systemName="Sprite",u=s([t.decorators.componentObserver({Sprite:["spriteName"]})],u);var d=u;return e.Sprite=c,e.SpriteSystem=d,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,PIXI);window.EVA.plugin.renderer.sprite=window.EVA.plugin.renderer.sprite||_EVA_IIFE_sprite;
1
+ globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{},globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||{};var _EVA_IIFE_sprite=function(e,t,r,s){"use strict";function i(e,t,r,s){var i,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,s);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(o=(n<3?i(o):n>3?i(t,r,o):i(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}function n(e,t,r,s){return new(r||(r=Promise))((function(i,n){function o(e){try{a(s.next(e))}catch(e){n(e)}}function c(e){try{a(s.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,c)}a((s=s.apply(e,t||[])).next())}))}function o(e){return function(t,r){var s=function(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}(t,r);s.key=r,s.type=e}}class c extends t.Component{constructor(){super(...arguments),this.resource="",this.spriteName=""}init(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)}}c.componentName="Sprite",i([o("string")],c.prototype,"resource",void 0),i([o("string")],c.prototype,"spriteName",void 0);class a{constructor(e){this._image=null,this._image=e,e?"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?this.sprite=s.Sprite.from(e):e instanceof s.Texture&&(this.sprite=new s.Sprite(e)):this.sprite=new s.Sprite}set image(e){this._image!==e&&("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=s.Texture.from(e)):e instanceof s.Texture&&(this.sprite.texture=e),this._image=e)}get image(){return this._image}}const p="_s|r|c_";t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE,(({name:e,data:t})=>new Promise((r=>{const i=t.json.data,n=t.image instanceof s.Texture?t.image:s.Texture.from(t.image),o=i.frames||{},c=i.animations||{},a={};for(const t in o){a[e+p+t]=o[t]}for(const t in c){const r=[];if(c[t]&&c[t].length>=0)for(const s of c[t]){const t=e+p+s;r.push(t)}c[t]=r}i.frames=a;const u=new s.Spritesheet(n,i);u.parse().then((()=>{r(u.textures)}))})))),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE,(({instance:e})=>{if(e)for(const t in e)e[t].destroy(!0)}));let u=class extends r.Renderer{constructor(){super(...arguments),this.name="Sprite",this.sprites={}}init(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:r}=e.transform.size;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=t,this.sprites[e.id].sprite.height=r)}componentChanged(e){return n(this,void 0,void 0,(function*(){if("Sprite"===e.componentName){const r=e.gameObject.id,s=e.component;if(e.type===t.OBSERVER_TYPE.ADD){const i=new a(null);this.sprites[e.gameObject.id]=i,this.containerManager.getContainer(e.gameObject.id).addChildAt(i.sprite,0);const n=this.increaseAsyncId(r),{instance:o}=yield t.resource.getResource(s.resource);if(!this.validateAsyncId(r,n))return;if(!o)return void console.error(`GameObject:${e.gameObject.name}'s Sprite resource load error`);i.image=o[s.resource+p+s.spriteName]}else if(e.type===t.OBSERVER_TYPE.CHANGE){const i=this.increaseAsyncId(r),{instance:n}=yield t.resource.getResource(s.resource);if(!this.validateAsyncId(r,i))return;if(!n)return void console.error(`GameObject:${e.gameObject.name}'s Sprite resource load error`);this.sprites[e.gameObject.id].image=n[s.resource+p+s.spriteName]}else if(e.type===t.OBSERVER_TYPE.REMOVE){this.increaseAsyncId(r);const t=this.sprites[e.gameObject.id];this.containerManager.getContainer(e.gameObject.id).removeChild(t.sprite),t.sprite.destroy({children:!0}),delete this.sprites[e.gameObject.id]}}}))}};u.systemName="Sprite",u=i([t.decorators.componentObserver({Sprite:["spriteName"]})],u);var m=u;return e.Sprite=c,e.SpriteSystem=m,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,PIXI);globalThis.EVA.plugin.renderer.sprite=globalThis.EVA.plugin.renderer.sprite||_EVA_IIFE_sprite;
@@ -64,7 +64,7 @@ class Sprite$2 {
64
64
  this._image = null;
65
65
  this._image = image;
66
66
  if (image) {
67
- if (image instanceof HTMLImageElement) {
67
+ if (typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement) {
68
68
  this.sprite = pixi_js.Sprite.from(image);
69
69
  }
70
70
  else if (image instanceof pixi_js.Texture) {
@@ -79,7 +79,7 @@ class Sprite$2 {
79
79
  if (this._image === val) {
80
80
  return;
81
81
  }
82
- if (val instanceof HTMLImageElement) {
82
+ if (typeof HTMLImageElement !== 'undefined' && val instanceof HTMLImageElement) {
83
83
  this.sprite.texture && this.sprite.texture.destroy(false);
84
84
  this.sprite.texture = pixi_js.Texture.from(val);
85
85
  }
@@ -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 i(e,t,r,s){var i,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,s);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(o=(n<3?i(o):n>3?i(t,r,o):i(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}class n extends e.Component{constructor(){super(...arguments),this.resource="",this.spriteName=""}init(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)}}n.componentName="Sprite",i([t.type("string")],n.prototype,"resource",void 0),i([t.type("string")],n.prototype,"spriteName",void 0);class o{constructor(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.sprite=s.Sprite.from(e):e instanceof s.Texture&&(this.sprite=new s.Sprite(e)):this.sprite=new s.Sprite}set image(e){this._image!==e&&(e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=s.Texture.from(e)):e instanceof s.Texture&&(this.sprite.texture=e),this._image=e)}get image(){return this._image}}const c="_s|r|c_";e.resource.registerInstance(e.RESOURCE_TYPE.SPRITE,(({name:e,data:t})=>new Promise((r=>{const i=t.json.data,n=t.image instanceof s.Texture?t.image:s.Texture.from(t.image),o=i.frames||{},a=i.animations||{},p={};for(const t in o){p[e+c+t]=o[t]}for(const t in a){const r=[];if(a[t]&&a[t].length>=0)for(const s of a[t]){const t=e+c+s;r.push(t)}a[t]=r}i.frames=p;const m=new s.Spritesheet(n,i);m.parse().then((()=>{r(m.textures)}))})))),e.resource.registerDestroy(e.RESOURCE_TYPE.SPRITE,(({instance:e})=>{if(e)for(const t in e)e[t].destroy(!0)}));let a=class extends r.Renderer{constructor(){super(...arguments),this.name="Sprite",this.sprites={}}init(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:r}=e.transform.size;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=t,this.sprites[e.id].sprite.height=r)}componentChanged(t){return r=this,s=void 0,n=function*(){if("Sprite"===t.componentName){const r=t.gameObject.id,s=t.component;if(t.type===e.OBSERVER_TYPE.ADD){const i=new o(null);this.sprites[t.gameObject.id]=i,this.containerManager.getContainer(t.gameObject.id).addChildAt(i.sprite,0);const n=this.increaseAsyncId(r),{instance:a}=yield e.resource.getResource(s.resource);if(!this.validateAsyncId(r,n))return;if(!a)return void console.error(`GameObject:${t.gameObject.name}'s Sprite resource load error`);i.image=a[s.resource+c+s.spriteName]}else if(t.type===e.OBSERVER_TYPE.CHANGE){const i=this.increaseAsyncId(r),{instance:n}=yield e.resource.getResource(s.resource);if(!this.validateAsyncId(r,i))return;if(!n)return void console.error(`GameObject:${t.gameObject.name}'s Sprite resource load error`);this.sprites[t.gameObject.id].image=n[s.resource+c+s.spriteName]}else if(t.type===e.OBSERVER_TYPE.REMOVE){this.increaseAsyncId(r);const e=this.sprites[t.gameObject.id];this.containerManager.getContainer(t.gameObject.id).removeChild(e.sprite),e.sprite.destroy({children:!0}),delete this.sprites[t.gameObject.id]}}},new((i=void 0)||(i=Promise))((function(e,t){function o(e){try{a(n.next(e))}catch(e){t(e)}}function c(e){try{a(n.throw(e))}catch(e){t(e)}}function a(t){t.done?e(t.value):new i((function(e){e(t.value)})).then(o,c)}a((n=n.apply(r,s||[])).next())}));var r,s,i,n}};a.systemName="Sprite",a=i([e.decorators.componentObserver({Sprite:["spriteName"]})],a);var p=a;exports.Sprite=n,exports.SpriteSystem=p;
16
+ function i(e,t,r,s){var i,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,s);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(o=(n<3?i(o):n>3?i(t,r,o):i(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}class n extends e.Component{constructor(){super(...arguments),this.resource="",this.spriteName=""}init(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)}}n.componentName="Sprite",i([t.type("string")],n.prototype,"resource",void 0),i([t.type("string")],n.prototype,"spriteName",void 0);class o{constructor(e){this._image=null,this._image=e,e?"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?this.sprite=s.Sprite.from(e):e instanceof s.Texture&&(this.sprite=new s.Sprite(e)):this.sprite=new s.Sprite}set image(e){this._image!==e&&("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=s.Texture.from(e)):e instanceof s.Texture&&(this.sprite.texture=e),this._image=e)}get image(){return this._image}}const c="_s|r|c_";e.resource.registerInstance(e.RESOURCE_TYPE.SPRITE,(({name:e,data:t})=>new Promise((r=>{const i=t.json.data,n=t.image instanceof s.Texture?t.image:s.Texture.from(t.image),o=i.frames||{},a=i.animations||{},p={};for(const t in o){p[e+c+t]=o[t]}for(const t in a){const r=[];if(a[t]&&a[t].length>=0)for(const s of a[t]){const t=e+c+s;r.push(t)}a[t]=r}i.frames=p;const m=new s.Spritesheet(n,i);m.parse().then((()=>{r(m.textures)}))})))),e.resource.registerDestroy(e.RESOURCE_TYPE.SPRITE,(({instance:e})=>{if(e)for(const t in e)e[t].destroy(!0)}));let a=class extends r.Renderer{constructor(){super(...arguments),this.name="Sprite",this.sprites={}}init(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:r}=e.transform.size;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=t,this.sprites[e.id].sprite.height=r)}componentChanged(t){return r=this,s=void 0,n=function*(){if("Sprite"===t.componentName){const r=t.gameObject.id,s=t.component;if(t.type===e.OBSERVER_TYPE.ADD){const i=new o(null);this.sprites[t.gameObject.id]=i,this.containerManager.getContainer(t.gameObject.id).addChildAt(i.sprite,0);const n=this.increaseAsyncId(r),{instance:a}=yield e.resource.getResource(s.resource);if(!this.validateAsyncId(r,n))return;if(!a)return void console.error(`GameObject:${t.gameObject.name}'s Sprite resource load error`);i.image=a[s.resource+c+s.spriteName]}else if(t.type===e.OBSERVER_TYPE.CHANGE){const i=this.increaseAsyncId(r),{instance:n}=yield e.resource.getResource(s.resource);if(!this.validateAsyncId(r,i))return;if(!n)return void console.error(`GameObject:${t.gameObject.name}'s Sprite resource load error`);this.sprites[t.gameObject.id].image=n[s.resource+c+s.spriteName]}else if(t.type===e.OBSERVER_TYPE.REMOVE){this.increaseAsyncId(r);const e=this.sprites[t.gameObject.id];this.containerManager.getContainer(t.gameObject.id).removeChild(e.sprite),e.sprite.destroy({children:!0}),delete this.sprites[t.gameObject.id]}}},new((i=void 0)||(i=Promise))((function(e,t){function o(e){try{a(n.next(e))}catch(e){t(e)}}function c(e){try{a(n.throw(e))}catch(e){t(e)}}function a(t){t.done?e(t.value):new i((function(e){e(t.value)})).then(o,c)}a((n=n.apply(r,s||[])).next())}));var r,s,i,n}};a.systemName="Sprite",a=i([e.decorators.componentObserver({Sprite:["spriteName"]})],a);var p=a;exports.Sprite=n,exports.SpriteSystem=p;
@@ -60,7 +60,7 @@ class Sprite$2 {
60
60
  this._image = null;
61
61
  this._image = image;
62
62
  if (image) {
63
- if (image instanceof HTMLImageElement) {
63
+ if (typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement) {
64
64
  this.sprite = Sprite$4.from(image);
65
65
  }
66
66
  else if (image instanceof Texture) {
@@ -75,7 +75,7 @@ class Sprite$2 {
75
75
  if (this._image === val) {
76
76
  return;
77
77
  }
78
- if (val instanceof HTMLImageElement) {
78
+ if (typeof HTMLImageElement !== 'undefined' && val instanceof HTMLImageElement) {
79
79
  this.sprite.texture && this.sprite.texture.destroy(false);
80
80
  this.sprite.texture = Texture.from(val);
81
81
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-sprite",
3
- "version": "2.0.0-beta.8",
3
+ "version": "2.0.0",
4
4
  "description": "@eva/plugin-renderer-sprite",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-sprite.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.8",
23
- "@eva/eva.js": "2.0.0-beta.8",
24
- "pixi.js": "^8.6.5"
22
+ "@eva/plugin-renderer": "2.0.0",
23
+ "@eva/eva.js": "2.0.0",
24
+ "pixi.js": "^8.8.1"
25
25
  }
26
26
  }