@eva/plugin-renderer-img 2.1.0-beta.2 → 2.1.0-beta.4

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_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
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_img=function(e,t,r,n,o){"use strict";function i(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s}function s(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function c(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(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?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,c)}a((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 l="IDE_PROPERTY_METADATA";function u(e,t,r,n){let o=Reflect.getMetadata("design:type",e,t),i=o===Array;const s=function(e){return e===String?"string":e===Number?"number":e===Boolean?"boolean":"unknown"}(o);if("unknown"!==s&&(o=s),n){const e=n();Array.isArray(e)?(i=!0,o=e[0]):o=e}const c=Reflect.getMetadata(l,e.constructor)||{},a=_extends(_extends(_extends({},c[t]||{}),{type:o,isArray:i}),r);c[t]=a,Reflect.defineMetadata(l,c,e.constructor);!function(e,t,r){const n=e.constructor,o=n.IDEProps||{};o[t]=_extends(_extends({key:t},o[t]),r),n.IDEProps=o}(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 o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(a,["isArray"]))}function d(e){return t={type:e},(e,n)=>{if("symbol"==typeof n)throw new a;const{options:o,returnTypeFunc:i}=function(e,t){return"function"==typeof e?{returnTypeFunc:e,options:t||{}}:{options:e||{}}}(t,r);u(e,n,o,i)};var t,r}var p;!function(e){e[e.Edit=2]="Edit",e[e.Game=4]="Game",e[e.All=6]="All"}(p||(p={}));class h extends t.Component{constructor(e){super(e),this.resource="",this.anchor={x:0,y:0},this.init(e)}init(e){var t,r;e&&e.resource&&(this.resource=e.resource),e&&e.anchor&&(this.anchor={x:null!==(t=e.anchor.x)&&void 0!==t?t:this.anchor.x,y:null!==(r=e.anchor.y)&&void 0!==r?r:this.anchor.y}),e&&"number"==typeof e.width&&(this.width=e.width),e&&"number"==typeof e.height&&(this.height=e.height)}load(e){return e&&(this.resource=e),this}setAnchor(e,t=e){return this.anchor.x=e,this.anchor.y=t,this}setSize(e,t){return this.width=e,this.height=t,this}destroy(){return this}}h.componentName="Img",i([d("string"),s("design:type",String)],h.prototype,"resource",void 0),i([d("number"),s("design:type",Number)],h.prototype,"width",void 0),i([d("number"),s("design:type",Number)],h.prototype,"height",void 0),t.resource.registerInstance(t.RESOURCE_TYPE.IMAGE,({data:e={}})=>{const{image:t}=e;if(t){if(t instanceof o.Texture)return t;return o.Texture.from(t)}return e}),t.resource.registerDestroy(t.RESOURCE_TYPE.IMAGE,({instance:e})=>{e&&e.destroy(!0)});let g=class extends r.Renderer{constructor(){super(...arguments),this.name="ImgSystem",this.imgs={}}init(e){var t,n;const o=null===(n=null===(t=this.game)||void 0===t?void 0:t.getSystem)||void 0===n?void 0:n.call(t,r.RendererSystem);(null==o?void 0:o.rendererManager)&&(this.renderSystem=o,this.renderSystem.rendererManager.register(this))}update(e){super.update(e)}rendererUpdate(e){const t=e.getComponent("Img");this.applySpriteLayout(e,t)}componentChanged(e){var r,o,i,s,a,l;return c(this,void 0,void 0,function*(){if("Img"===e.componentName){const c=e.gameObject.id,u=e.component;if(e.type===t.OBSERVER_TYPE.ADD){const i=new n.Sprite(null);this.imgs[c]=i,null===(o=null===(r=this.containerManager)||void 0===r?void 0:r.getContainer(c))||void 0===o||o.addChildAt(i.sprite,0),this.applySpriteLayout(e.gameObject,u);const s=this.increaseAsyncId(c),{instance:a}=yield t.resource.getResource(u.resource);if(!this.validateAsyncId(c,s))return;if(!a)return void console.error(`GameObject:${e.gameObject.name}'s Img resource load error`);i.image=a,this.applySpriteLayout(e.gameObject,u)}else if(e.type===t.OBSERVER_TYPE.CHANGE){if(this.applySpriteLayout(e.gameObject,u),null===(s=null===(i=e.prop)||void 0===i?void 0:i.prop)||void 0===s?void 0:s.includes("resource")){const r=this.increaseAsyncId(c),{instance:n}=yield t.resource.getResource(u.resource);if(!this.validateAsyncId(c,r))return;if(!n)return void console.error(`GameObject:${e.gameObject.name}'s Img resource load error`);this.imgs[c].image=n,this.applySpriteLayout(e.gameObject,u)}}else if(e.type===t.OBSERVER_TYPE.REMOVE){this.increaseAsyncId(c);const e=this.imgs[c];if(!e)return;null===(l=null===(a=this.containerManager)||void 0===a?void 0:a.getContainer(c))||void 0===l||l.removeChild(e.sprite),e.sprite.destroy({children:!0}),delete this.imgs[c]}}})}applySpriteLayout(e,t){var r,n,o,i,s;const c=this.imgs[e.id];if(!c)return;const a=null===(r=e.transform)||void 0===r?void 0:r.size,l=null!==(n=null==t?void 0:t.width)&&void 0!==n?n:null==a?void 0:a.width,u=null!==(o=null==t?void 0:t.height)&&void 0!==o?o:null==a?void 0:a.height;"number"==typeof l&&(c.sprite.width=l),"number"==typeof u&&(c.sprite.height=u);const d=null==t?void 0:t.anchor;d&&(null===(s=null===(i=c.sprite.anchor)||void 0===i?void 0:i.set)||void 0===s||s.call(i,d.x,d.y))}destroy(){var e,t;for(const r in this.imgs){const n=this.imgs[r];null===(t=null===(e=this.containerManager)||void 0===e?void 0:e.getContainer(parseInt(r)))||void 0===t||t.removeChild(n.sprite),n.sprite.destroy({children:!0}),delete this.imgs[r]}}};g.systemName="ImgSystem",g=i([t.decorators.componentObserver({Img:["resource",{prop:"anchor",deep:!0},"width","height"]})],g);var y=g;return e.Img=h,e.ImgSystem=y,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter,PIXI);globalThis.EVA.plugin.renderer.img=globalThis.EVA.plugin.renderer.img||_EVA_IIFE_img;
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_img=function(e,t,r,n,o){"use strict";function i(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s}function s(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function c(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(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?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,c)}a((n=n.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError,"function"==typeof SuppressedError&&SuppressedError;class a extends Error{constructor(){super("Symbol keys are not supported yet!"),Object.setPrototypeOf(this,new.target.prototype)}}const u="IDE_PROPERTY_METADATA";function l(e,t,r,n){let o=Reflect.getMetadata("design:type",e,t),i=o===Array;const s=function(e){return e===String?"string":e===Number?"number":e===Boolean?"boolean":"unknown"}(o);if("unknown"!==s&&(o=s),n){const e=n();Array.isArray(e)?(i=!0,o=e[0]):o=e}const c=Reflect.getMetadata(u,e.constructor)||{},a=_extends(_extends(_extends({},c[t]||{}),{type:o,isArray:i}),r);c[t]=a,Reflect.defineMetadata(u,c,e.constructor);!function(e,t,r){const n=e.constructor,o=n.IDEProps||{};o[t]=_extends(_extends({key:t},o[t]),r),n.IDEProps=o}(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 o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(a,["isArray"]))}function d(e){return t={type:e},(e,n)=>{if("symbol"==typeof n)throw new a;const{options:o,returnTypeFunc:i}=function(e,t){return"function"==typeof e?{returnTypeFunc:e,options:t||{}}:{options:e||{}}}(t,r);l(e,n,o,i)};var t,r}var p;!function(e){e[e.Edit=2]="Edit",e[e.Game=4]="Game",e[e.All=6]="All"}(p||(p={}));class h extends t.Component{constructor(e){super(e),this.resource="",this.anchor={x:0,y:0},this.init(e)}init(e){var t,r;e&&e.resource&&(this.resource=e.resource),e&&e.anchor&&(this.anchor={x:null!==(t=e.anchor.x)&&void 0!==t?t:this.anchor.x,y:null!==(r=e.anchor.y)&&void 0!==r?r:this.anchor.y}),e&&"number"==typeof e.width&&(this.width=e.width),e&&"number"==typeof e.height&&(this.height=e.height)}load(e){return e&&(this.resource=e),this}setAnchor(e,t=e){return this.anchor.x=e,this.anchor.y=t,this}setSize(e,t){return this.width=e,this.height=t,this}destroy(){return this}}h.componentName="Img",i([d("string"),s("design:type",String)],h.prototype,"resource",void 0),i([d("number"),s("design:type",Number)],h.prototype,"width",void 0),i([d("number"),s("design:type",Number)],h.prototype,"height",void 0),t.resource.registerInstance(t.RESOURCE_TYPE.IMAGE,({data:e={}})=>{const{image:t}=e;if(t){if(t instanceof o.Texture)return t;return o.Texture.from(t)}return e}),t.resource.registerDestroy(t.RESOURCE_TYPE.IMAGE,({instance:e})=>{e&&e.destroy(!0)});let g=class extends r.Renderer{constructor(){super(...arguments),this.name="ImgSystem",this.imgs={}}init(e){var t,n;const o=null===(n=null===(t=this.game)||void 0===t?void 0:t.getSystem)||void 0===n?void 0:n.call(t,r.RendererSystem);(null==o?void 0:o.rendererManager)&&(this.renderSystem=o,this.renderSystem.rendererManager.register(this))}update(e){super.update(e)}rendererUpdate(e){const t=e.getComponent("Img");this.applySpriteLayout(e,t)}componentChanged(e){var r,o,i,s,a,u;return c(this,void 0,void 0,function*(){if("Img"===e.componentName){const c=e.gameObject.id,l=e.component;if(e.type===t.OBSERVER_TYPE.ADD){const i=new n.Sprite(null);this.imgs[c]=i,null===(o=null===(r=this.containerManager)||void 0===r?void 0:r.getContainer(c))||void 0===o||o.addChildAt(i.sprite,0),this.applySpriteLayout(e.gameObject,l);const s=this.increaseAsyncId(c),{instance:a}=yield t.resource.getResource(l.resource);if(!this.validateAsyncId(c,s))return;if(!a)return void console.error(`GameObject:${e.gameObject.name}'s Img resource load error`);i.image=a,this.applySpriteLayout(e.gameObject,l)}else if(e.type===t.OBSERVER_TYPE.CHANGE){if(this.applySpriteLayout(e.gameObject,l),null===(s=null===(i=e.prop)||void 0===i?void 0:i.prop)||void 0===s?void 0:s.includes("resource")){const r=this.increaseAsyncId(c),{instance:n}=yield t.resource.getResource(l.resource);if(!this.validateAsyncId(c,r))return;if(!n)return void console.error(`GameObject:${e.gameObject.name}'s Img resource load error`);this.imgs[c].image=n,this.applySpriteLayout(e.gameObject,l)}}else if(e.type===t.OBSERVER_TYPE.REMOVE){this.increaseAsyncId(c);const e=this.imgs[c];if(!e)return;null===(u=null===(a=this.containerManager)||void 0===a?void 0:a.getContainer(c))||void 0===u||u.removeChild(e.sprite),e.sprite.destroy({children:!0}),delete this.imgs[c]}}})}applySpriteLayout(e,t){var r,n,o,i,s;const c=this.imgs[e.id];if(!c)return;const a=null===(r=e.transform)||void 0===r?void 0:r.size,u=null!==(n=null==t?void 0:t.width)&&void 0!==n?n:null==a?void 0:a.width,l=null!==(o=null==t?void 0:t.height)&&void 0!==o?o:null==a?void 0:a.height;"number"==typeof u&&(c.sprite.width=u),"number"==typeof l&&(c.sprite.height=l);const d=null==t?void 0:t.anchor;d&&(null===(s=null===(i=c.sprite.anchor)||void 0===i?void 0:i.set)||void 0===s||s.call(i,d.x,d.y))}destroy(){var e,t;for(const r in this.imgs){const n=this.imgs[r];null===(t=null===(e=this.containerManager)||void 0===e?void 0:e.getContainer(parseInt(r)))||void 0===t||t.removeChild(n.sprite),n.sprite.destroy({children:!0}),delete this.imgs[r]}}};g.systemName="ImgSystem",g=i([t.decorators.componentObserver({Img:["resource",{prop:"anchor",deep:!0},"width","height"]})],g);var y=g;return e.Img=h,e.ImgSystem=y,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter,PIXI);globalThis.EVA.plugin.renderer.img=globalThis.EVA.plugin.renderer.img||_EVA_IIFE_img;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-img",
3
- "version": "2.1.0-beta.2",
3
+ "version": "2.1.0-beta.4",
4
4
  "description": "@eva/plugin-renderer-img",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-img.esm.js",
@@ -19,9 +19,9 @@
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.2",
23
- "@eva/renderer-adapter": "2.1.0-beta.2",
24
- "@eva/eva.js": "2.1.0-beta.2",
22
+ "@eva/plugin-renderer": "2.1.0-beta.4",
23
+ "@eva/renderer-adapter": "2.1.0-beta.4",
24
+ "@eva/eva.js": "2.1.0-beta.4",
25
25
  "pixi.js": "^8.17.0"
26
26
  }
27
27
  }