@eva/plugin-renderer-sprite 2.1.0-beta.1 → 2.1.0-beta.10

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.
@@ -41,6 +41,10 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
41
41
  step((generator = generator.apply(thisArg, _arguments || [])).next());
42
42
  });
43
43
  }
44
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
45
+ var e = new Error(message);
46
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
47
+ };
44
48
  function __rest(s, e) {
45
49
  var t = {};
46
50
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -1 +1 @@
1
- function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_extends.apply(null,arguments)}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,n){"use strict";function s(e,t,r,n){var s,i=arguments.length,o=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(i<3?s(o):i>3?s(t,r,o):s(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o}function i(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function o(e,t,r,n){return new(r||(r=Promise))(function(s,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,a)}c((n=n.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class a extends Error{constructor(){super("Symbol keys are not supported yet!"),Object.setPrototypeOf(this,new.target.prototype)}}const c="IDE_PROPERTY_METADATA";function p(e,t,r,n){let s=Reflect.getMetadata("design:type",e,t),i=s===Array;const o=function(e){return e===String?"string":e===Number?"number":e===Boolean?"boolean":"unknown"}(s);if("unknown"!==o&&(s=o),n){const e=n();Array.isArray(e)?(i=!0,s=e[0]):s=e}const a=Reflect.getMetadata(c,e.constructor)||{},p=_extends(_extends(_extends({},a[t]||{}),{type:s,isArray:i}),r);a[t]=p,Reflect.defineMetadata(c,a,e.constructor);!function(e,t,r){const n=e.constructor,s=n.IDEProps||{};s[t]=_extends(_extends({key:t},s[t]),r),n.IDEProps=s}(e,t,function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]])}return r}(p,["isArray"]))}function u(e){return t={type:e},(e,n)=>{if("symbol"==typeof n)throw new a;const{options:s,returnTypeFunc:i}=function(e,t){return"function"==typeof e?{returnTypeFunc:e,options:t||{}}:{options:e||{}}}(t,r);p(e,n,s,i)};var t,r}var l;!function(e){e[e.Edit=2]="Edit",e[e.Game=4]="Game",e[e.All=6]="All"}(l||(l={}));class f extends t.Component{constructor(e){super(e),this.resource="",this.spriteName="",this.init(e)}init(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)}setSprite(e){return this.spriteName=e,this}}f.componentName="Sprite",s([u("string"),i("design:type",String)],f.prototype,"resource",void 0),s([u("string"),i("design:type",String)],f.prototype,"spriteName",void 0);class d{constructor(e){this._image=null,this._image=e,e?"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?this.sprite=n.Sprite.from(e):e instanceof n.Texture&&(this.sprite=new n.Sprite(e)):this.sprite=new n.Sprite}set image(e){this._image!==e&&("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=n.Texture.from(e)):e instanceof n.Texture&&(this.sprite.texture=e),this._image=e)}get image(){return this._image}}const m="_s|r|c_";t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE,({name:e,data:t})=>new Promise(r=>{var s;const i=t.json.data,o=t.image instanceof n.Texture?t.image:n.Texture.from(t.image);let a=i.frames||{};if(Array.isArray(a)){const e={};for(const t of a){const r=null!==(s=t.filename)&&void 0!==s?s:t.name;r&&(e[r]=t)}a=e}else{const e=Object.values(a)[0];if(e&&"string"==typeof e.filename){const e={};for(const t in a){const r=a[t];e[r.filename||t]=r}a=e}}const c=i.animations||{},p={},u={};for(const t in a){u[e+m+t]=a[t]}for(const t in c){const r=[];if(c[t]&&c[t].length>=0)for(const n of c[t]){const t=e+m+n;r.push(t)}p[t]=r}const l=new n.Spritesheet(o,_extends(_extends({},i),{frames:u,animations:p}));l.parse().then(()=>{r(l.textures)})})),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE,({instance:e})=>{if(e)for(const t in e)e[t].destroy(!0)});let g=class extends r.Renderer{constructor(){super(...arguments),this.name="SpriteSystem",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 o(this,void 0,void 0,function*(){if("Sprite"===e.componentName){const r=e.gameObject.id,n=e.component;if(e.type===t.OBSERVER_TYPE.ADD){const s=new d(null);this.sprites[e.gameObject.id]=s,this.containerManager.getContainer(e.gameObject.id).addChildAt(s.sprite,0);const i=this.increaseAsyncId(r),{instance:o}=yield t.resource.getResource(n.resource);if(!this.validateAsyncId(r,i))return;if(!o)return void console.error(`GameObject:${e.gameObject.name}'s Sprite resource load error`);s.image=o[n.resource+m+n.spriteName]}else if(e.type===t.OBSERVER_TYPE.CHANGE){const s=this.increaseAsyncId(r),{instance:i}=yield t.resource.getResource(n.resource);if(!this.validateAsyncId(r,s))return;if(!i)return void console.error(`GameObject:${e.gameObject.name}'s Sprite resource load error`);this.sprites[e.gameObject.id].image=i[n.resource+m+n.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]}}})}};g.systemName="SpriteSystem",g=s([t.decorators.componentObserver({Sprite:["spriteName"]})],g);var h=g;return e.Sprite=f,e.SpriteSystem=h,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;
1
+ function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_extends.apply(null,arguments)}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,n){"use strict";function s(e,t,r,n){var s,i=arguments.length,o=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(o=(i<3?s(o):i>3?s(t,r,o):s(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o}function i(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function o(e,t,r,n){return new(r||(r=Promise))(function(s,i){function o(e){try{a(n.next(e))}catch(e){i(e)}}function c(e){try{a(n.throw(e))}catch(e){i(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((n=n.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError,"function"==typeof SuppressedError&&SuppressedError;class c extends Error{constructor(){super("Symbol keys are not supported yet!"),Object.setPrototypeOf(this,new.target.prototype)}}const a="IDE_PROPERTY_METADATA";function p(e,t,r,n){let s=Reflect.getMetadata("design:type",e,t),i=s===Array;const o=function(e){return e===String?"string":e===Number?"number":e===Boolean?"boolean":"unknown"}(s);if("unknown"!==o&&(s=o),n){const e=n();Array.isArray(e)?(i=!0,s=e[0]):s=e}const c=Reflect.getMetadata(a,e.constructor)||{},p=_extends(_extends(_extends({},c[t]||{}),{type:s,isArray:i}),r);c[t]=p,Reflect.defineMetadata(a,c,e.constructor);!function(e,t,r){const n=e.constructor,s=n.IDEProps||{};s[t]=_extends(_extends({key:t},s[t]),r),n.IDEProps=s}(e,t,function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]])}return r}(p,["isArray"]))}function u(e){return t={type:e},(e,n)=>{if("symbol"==typeof n)throw new c;const{options:s,returnTypeFunc:i}=function(e,t){return"function"==typeof e?{returnTypeFunc:e,options:t||{}}:{options:e||{}}}(t,r);p(e,n,s,i)};var t,r}var l;!function(e){e[e.Edit=2]="Edit",e[e.Game=4]="Game",e[e.All=6]="All"}(l||(l={}));class f extends t.Component{constructor(e){super(e),this.resource="",this.spriteName="",this.init(e)}init(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)}setSprite(e){return this.spriteName=e,this}}f.componentName="Sprite",s([u("string"),i("design:type",String)],f.prototype,"resource",void 0),s([u("string"),i("design:type",String)],f.prototype,"spriteName",void 0);class d{constructor(e){this._image=null,this._image=e,e?"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?this.sprite=n.Sprite.from(e):e instanceof n.Texture&&(this.sprite=new n.Sprite(e)):this.sprite=new n.Sprite}set image(e){this._image!==e&&("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=n.Texture.from(e)):e instanceof n.Texture&&(this.sprite.texture=e),this._image=e)}get image(){return this._image}}const m="_s|r|c_";t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE,({name:e,data:t})=>new Promise(r=>{var s;const i=t.json.data,o=t.image instanceof n.Texture?t.image:n.Texture.from(t.image);let c=i.frames||{};if(Array.isArray(c)){const e={};for(const t of c){const r=null!==(s=t.filename)&&void 0!==s?s:t.name;r&&(e[r]=t)}c=e}else{const e=Object.values(c)[0];if(e&&"string"==typeof e.filename){const e={};for(const t in c){const r=c[t];e[r.filename||t]=r}c=e}}const a=i.animations||{},p={},u={};for(const t in c){u[e+m+t]=c[t]}for(const t in a){const r=[];if(a[t]&&a[t].length>=0)for(const n of a[t]){const t=e+m+n;r.push(t)}p[t]=r}const l=new n.Spritesheet(o,_extends(_extends({},i),{frames:u,animations:p}));l.parse().then(()=>{r(l.textures)})})),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE,({instance:e})=>{if(e)for(const t in e)e[t].destroy(!0)});let g=class extends r.Renderer{constructor(){super(...arguments),this.name="SpriteSystem",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 o(this,void 0,void 0,function*(){if("Sprite"===e.componentName){const r=e.gameObject.id,n=e.component;if(e.type===t.OBSERVER_TYPE.ADD){const s=new d(null);this.sprites[e.gameObject.id]=s,this.containerManager.getContainer(e.gameObject.id).addChildAt(s.sprite,0);const i=this.increaseAsyncId(r),{instance:o}=yield t.resource.getResource(n.resource);if(!this.validateAsyncId(r,i))return;if(!o)return void console.error(`GameObject:${e.gameObject.name}'s Sprite resource load error`);s.image=o[n.resource+m+n.spriteName]}else if(e.type===t.OBSERVER_TYPE.CHANGE){const s=this.increaseAsyncId(r),{instance:i}=yield t.resource.getResource(n.resource);if(!this.validateAsyncId(r,s))return;if(!i)return void console.error(`GameObject:${e.gameObject.name}'s Sprite resource load error`);this.sprites[e.gameObject.id].image=i[n.resource+m+n.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]}}})}};g.systemName="SpriteSystem",g=s([t.decorators.componentObserver({Sprite:["spriteName"]})],g);var h=g;return e.Sprite=f,e.SpriteSystem=h,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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-sprite",
3
- "version": "2.1.0-beta.1",
3
+ "version": "2.1.0-beta.10",
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": "^2.0.0-beta.0",
22
- "@eva/plugin-renderer": "2.1.0-beta.1",
23
- "@eva/eva.js": "2.1.0-beta.1",
22
+ "@eva/plugin-renderer": "2.1.0-beta.10",
23
+ "@eva/eva.js": "2.1.0-beta.10",
24
24
  "pixi.js": "^8.17.0"
25
25
  }
26
26
  }