@leafer-in/robot 1.1.0 → 1.1.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.
package/dist/robot.js CHANGED
@@ -1,5 +1,5 @@
1
1
  this.LeaferIN = this.LeaferIN || {};
2
- this.LeaferIN.Robot = (function (exports, draw) {
2
+ this.LeaferIN.robot = (function (exports, draw) {
3
3
  'use strict';
4
4
 
5
5
  /******************************************************************************
package/dist/robot.min.js CHANGED
@@ -1 +1 @@
1
- this.LeaferIN=this.LeaferIN||{},this.LeaferIN.Robot=function(t,o){"use strict";function e(t,o,e,i){var s,r=arguments.length,a=r<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,o,e,i);else for(var n=t.length-1;n>=0;n--)(s=t[n])&&(a=(r<3?s(a):r>3?s(o,e,a):s(o,e))||a);return r>3&&a&&Object.defineProperty(o,e,a),a}"function"==typeof SuppressedError&&SuppressedError;class i extends o.UIData{get __drawAfterFill(){return!0}setRobot(t){this._robot=t,this.__leaf.__updateRobot()}setAction(t){this._action=t,this.__leaf.__updateAction()}}return t.Robot=class extends o.UI{get __tag(){return"Robot"}get nowFrame(){return this.robotFrames&&this.robotFrames[this.now]}constructor(t){super(t)}play(){this.running=!0}pause(){this.running=!1}stop(){this.pause()}__updateRobot(){const{robot:t}=this;if(this.robotFrames=[],!t)return;let o=0;t instanceof Array?t.forEach((t=>this.__loadRobot(t,o,o+=t.total||1))):this.__loadRobot(t,0,t.total)}__updateAction(){const t=this.actions[this.action];if(this.stop(),this.__timer&&clearTimeout(this.__timer),void 0!==t)if("number"==typeof t)this.now=t;else if("object"==typeof t){const o=t instanceof Array,e=o?t:t.keyframes;this.__action=o?void 0:t;const{length:i}=e;if(i>1){const t=this.now=e[0],o=e[e.length-1];this.play(),this.__runAction(t,o)}else i&&(this.now=e[0])}}__loadRobot(t,e,i){for(let t=e;t<i;t++)this.robotFrames.push(void 0);const s=o.ImageManager.get(t);s.ready?this.__createFrames(s,t,e,i):s.load((()=>this.__createFrames(s,t,e,i)))}__createFrames(t,e,i,s){const{offset:r,size:a,total:n}=e,{width:h,height:_}=a&&("number"==typeof a?{width:a,height:a}:a)||(n>1?this:t);let p=r?r.x:0,d=r?r.y:0;for(let o=i;o<s;o++)this.robotFrames[o]={view:t.view,x:p,y:d,width:h,height:_},p+h>=t.width?(p=0,d+=_):p+=h;this.__updateRobotBounds(),this.forceRender(),this.emitEvent(new o.ImageEvent(o.ImageEvent.LOADED,{image:t}))}__runAction(t,o){let{FPS:e,loop:i,__action:s}=this;s&&(s.FPS&&(e=s.FPS),void 0!==s.loop&&(i=s.loop)),this.__timer=setTimeout((()=>{if(this.running){if(this.now===o){if(!i)return this.stop();this.now=t}else this.now++;this.__updateRobotBounds()}this.__runAction(t,o)}),1e3/e)}__updateRobotBounds(){const{nowFrame:t}=this;if(t){const o=this.__,e=t.width/o.pixelRatio,i=t.height/o.pixelRatio;o.width===e&&o.height===i||this.forceUpdate("width"),o.__naturalWidth=e,o.__naturalHeight=i}}__drawContent(t,o){const{nowFrame:e}=this,{width:i,height:s}=this.__;e&&t.drawImage(e.view,e.x,e.y,e.width,e.height,0,0,i,s)}destroy(){this.robotFrames&&(this.robotFrames=null),super.destroy()}},e([o.dataProcessor(i)],t.Robot.prototype,"__",void 0),e([o.boundsType()],t.Robot.prototype,"robot",void 0),e([o.dataType()],t.Robot.prototype,"actions",void 0),e([o.dataType("")],t.Robot.prototype,"action",void 0),e([o.surfaceType(0)],t.Robot.prototype,"now",void 0),e([o.dataType(12)],t.Robot.prototype,"FPS",void 0),e([o.dataType(!0)],t.Robot.prototype,"loop",void 0),t.Robot=e([o.registerUI()],t.Robot),t.RobotData=i,t}({},LeaferUI);
1
+ this.LeaferIN=this.LeaferIN||{},this.LeaferIN.robot=function(t,o){"use strict";function e(t,o,e,i){var s,r=arguments.length,a=r<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,o,e,i);else for(var n=t.length-1;n>=0;n--)(s=t[n])&&(a=(r<3?s(a):r>3?s(o,e,a):s(o,e))||a);return r>3&&a&&Object.defineProperty(o,e,a),a}"function"==typeof SuppressedError&&SuppressedError;class i extends o.UIData{get __drawAfterFill(){return!0}setRobot(t){this._robot=t,this.__leaf.__updateRobot()}setAction(t){this._action=t,this.__leaf.__updateAction()}}return t.Robot=class extends o.UI{get __tag(){return"Robot"}get nowFrame(){return this.robotFrames&&this.robotFrames[this.now]}constructor(t){super(t)}play(){this.running=!0}pause(){this.running=!1}stop(){this.pause()}__updateRobot(){const{robot:t}=this;if(this.robotFrames=[],!t)return;let o=0;t instanceof Array?t.forEach((t=>this.__loadRobot(t,o,o+=t.total||1))):this.__loadRobot(t,0,t.total)}__updateAction(){const t=this.actions[this.action];if(this.stop(),this.__timer&&clearTimeout(this.__timer),void 0!==t)if("number"==typeof t)this.now=t;else if("object"==typeof t){const o=t instanceof Array,e=o?t:t.keyframes;this.__action=o?void 0:t;const{length:i}=e;if(i>1){const t=this.now=e[0],o=e[e.length-1];this.play(),this.__runAction(t,o)}else i&&(this.now=e[0])}}__loadRobot(t,e,i){for(let t=e;t<i;t++)this.robotFrames.push(void 0);const s=o.ImageManager.get(t);s.ready?this.__createFrames(s,t,e,i):s.load((()=>this.__createFrames(s,t,e,i)))}__createFrames(t,e,i,s){const{offset:r,size:a,total:n}=e,{width:h,height:_}=a&&("number"==typeof a?{width:a,height:a}:a)||(n>1?this:t);let p=r?r.x:0,d=r?r.y:0;for(let o=i;o<s;o++)this.robotFrames[o]={view:t.view,x:p,y:d,width:h,height:_},p+h>=t.width?(p=0,d+=_):p+=h;this.__updateRobotBounds(),this.forceRender(),this.emitEvent(new o.ImageEvent(o.ImageEvent.LOADED,{image:t}))}__runAction(t,o){let{FPS:e,loop:i,__action:s}=this;s&&(s.FPS&&(e=s.FPS),void 0!==s.loop&&(i=s.loop)),this.__timer=setTimeout((()=>{if(this.running){if(this.now===o){if(!i)return this.stop();this.now=t}else this.now++;this.__updateRobotBounds()}this.__runAction(t,o)}),1e3/e)}__updateRobotBounds(){const{nowFrame:t}=this;if(t){const o=this.__,e=t.width/o.pixelRatio,i=t.height/o.pixelRatio;o.width===e&&o.height===i||this.forceUpdate("width"),o.__naturalWidth=e,o.__naturalHeight=i}}__drawContent(t,o){const{nowFrame:e}=this,{width:i,height:s}=this.__;e&&t.drawImage(e.view,e.x,e.y,e.width,e.height,0,0,i,s)}destroy(){this.robotFrames&&(this.robotFrames=null),super.destroy()}},e([o.dataProcessor(i)],t.Robot.prototype,"__",void 0),e([o.boundsType()],t.Robot.prototype,"robot",void 0),e([o.dataType()],t.Robot.prototype,"actions",void 0),e([o.dataType("")],t.Robot.prototype,"action",void 0),e([o.surfaceType(0)],t.Robot.prototype,"now",void 0),e([o.dataType(12)],t.Robot.prototype,"FPS",void 0),e([o.dataType(!0)],t.Robot.prototype,"loop",void 0),t.Robot=e([o.registerUI()],t.Robot),t.RobotData=i,t}({},LeaferUI);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-in/robot",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "@leafer-in/robot",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -34,8 +34,8 @@
34
34
  "leaferjs"
35
35
  ],
36
36
  "peerDependencies": {
37
- "@leafer-ui/draw": "^1.1.0",
38
- "@leafer-ui/interface": "^1.1.0",
39
- "@leafer-in/interface": "^1.1.0"
37
+ "@leafer-ui/draw": "^1.1.2",
38
+ "@leafer-ui/interface": "^1.1.2",
39
+ "@leafer-in/interface": "^1.1.2"
40
40
  }
41
41
  }