@leafer-in/robot 1.1.1 → 1.2.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.
- package/dist/robot.cjs +2 -0
- package/dist/robot.esm.js +3 -1
- package/dist/robot.esm.min.js +1 -1
- package/dist/robot.js +2 -0
- package/dist/robot.min.cjs +1 -1
- package/dist/robot.min.js +1 -1
- package/package.json +4 -4
- package/src/index.ts +5 -1
package/dist/robot.cjs
CHANGED
package/dist/robot.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UIData, dataProcessor, boundsType, dataType, surfaceType, registerUI, UI, ImageManager, ImageEvent } from '@leafer-ui/draw';
|
|
1
|
+
import { UIData, dataProcessor, boundsType, dataType, surfaceType, registerUI, UI, ImageManager, ImageEvent, Plugin } from '@leafer-ui/draw';
|
|
2
2
|
|
|
3
3
|
/******************************************************************************
|
|
4
4
|
Copyright (c) Microsoft Corporation.
|
|
@@ -185,4 +185,6 @@ Robot = __decorate([
|
|
|
185
185
|
registerUI()
|
|
186
186
|
], Robot);
|
|
187
187
|
|
|
188
|
+
Plugin.add('robot');
|
|
189
|
+
|
|
188
190
|
export { Robot, RobotData };
|
package/dist/robot.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UIData as t,dataProcessor as o,boundsType as e,dataType as i,surfaceType as s,registerUI as r,UI as n,ImageManager as h,ImageEvent as a}from"@leafer-ui/draw";function
|
|
1
|
+
import{UIData as t,dataProcessor as o,boundsType as e,dataType as i,surfaceType as s,registerUI as r,UI as n,ImageManager as h,ImageEvent as a,Plugin as _}from"@leafer-ui/draw";function d(t,o,e,i){var s,r=arguments.length,n=r<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,o,e,i);else for(var h=t.length-1;h>=0;h--)(s=t[h])&&(n=(r<3?s(n):r>3?s(o,e,n):s(o,e))||n);return r>3&&n&&Object.defineProperty(o,e,n),n}"function"==typeof SuppressedError&&SuppressedError;class p extends t{get __drawAfterFill(){return!0}setRobot(t){this._robot=t,this.__leaf.__updateRobot()}setAction(t){this._action=t,this.__leaf.__updateAction()}}let c=class extends n{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,o,e){for(let t=o;t<e;t++)this.robotFrames.push(void 0);const i=h.get(t);i.ready?this.__createFrames(i,t,o,e):i.load((()=>this.__createFrames(i,t,o,e)))}__createFrames(t,o,e,i){const{offset:s,size:r,total:n}=o,{width:h,height:_}=r&&("number"==typeof r?{width:r,height:r}:r)||(n>1?this:t);let d=s?s.x:0,p=s?s.y:0;for(let o=e;o<i;o++)this.robotFrames[o]={view:t.view,x:d,y:p,width:h,height:_},d+h>=t.width?(d=0,p+=_):d+=h;this.__updateRobotBounds(),this.forceRender(),this.emitEvent(new a(a.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()}};d([o(p)],c.prototype,"__",void 0),d([e()],c.prototype,"robot",void 0),d([i()],c.prototype,"actions",void 0),d([i("")],c.prototype,"action",void 0),d([s(0)],c.prototype,"now",void 0),d([i(12)],c.prototype,"FPS",void 0),d([i(!0)],c.prototype,"loop",void 0),c=d([r()],c),_.add("robot");export{c as Robot,p as RobotData};
|
package/dist/robot.js
CHANGED
package/dist/robot.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer-ui/draw");function o(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 e extends t.UIData{get __drawAfterFill(){return!0}setRobot(t){this._robot=t,this.__leaf.__updateRobot()}setAction(t){this._action=t,this.__leaf.__updateAction()}}exports.Robot=class extends t.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(o,e,i){for(let t=e;t<i;t++)this.robotFrames.push(void 0);const s=t.ImageManager.get(o);s.ready?this.__createFrames(s,o,e,i):s.load((()=>this.__createFrames(s,o,e,i)))}__createFrames(o,e,i,s){const{offset:r,size:a,total:n}=e,{width:h,height:p}=a&&("number"==typeof a?{width:a,height:a}:a)||(n>1?this:o);let _=r?r.x:0,d=r?r.y:0;for(let t=i;t<s;t++)this.robotFrames[t]={view:o.view,x:_,y:d,width:h,height:p},_+h>=o.width?(_=0,d+=p):_+=h;this.__updateRobotBounds(),this.forceRender(),this.emitEvent(new t.ImageEvent(t.ImageEvent.LOADED,{image:o}))}__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()}},o([t.dataProcessor(e)],exports.Robot.prototype,"__",void 0),o([t.boundsType()],exports.Robot.prototype,"robot",void 0),o([t.dataType()],exports.Robot.prototype,"actions",void 0),o([t.dataType("")],exports.Robot.prototype,"action",void 0),o([t.surfaceType(0)],exports.Robot.prototype,"now",void 0),o([t.dataType(12)],exports.Robot.prototype,"FPS",void 0),o([t.dataType(!0)],exports.Robot.prototype,"loop",void 0),exports.Robot=o([t.registerUI()],exports.Robot),exports.RobotData=e;
|
|
1
|
+
"use strict";var t=require("@leafer-ui/draw");function o(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 e extends t.UIData{get __drawAfterFill(){return!0}setRobot(t){this._robot=t,this.__leaf.__updateRobot()}setAction(t){this._action=t,this.__leaf.__updateAction()}}exports.Robot=class extends t.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(o,e,i){for(let t=e;t<i;t++)this.robotFrames.push(void 0);const s=t.ImageManager.get(o);s.ready?this.__createFrames(s,o,e,i):s.load((()=>this.__createFrames(s,o,e,i)))}__createFrames(o,e,i,s){const{offset:r,size:a,total:n}=e,{width:h,height:p}=a&&("number"==typeof a?{width:a,height:a}:a)||(n>1?this:o);let _=r?r.x:0,d=r?r.y:0;for(let t=i;t<s;t++)this.robotFrames[t]={view:o.view,x:_,y:d,width:h,height:p},_+h>=o.width?(_=0,d+=p):_+=h;this.__updateRobotBounds(),this.forceRender(),this.emitEvent(new t.ImageEvent(t.ImageEvent.LOADED,{image:o}))}__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()}},o([t.dataProcessor(e)],exports.Robot.prototype,"__",void 0),o([t.boundsType()],exports.Robot.prototype,"robot",void 0),o([t.dataType()],exports.Robot.prototype,"actions",void 0),o([t.dataType("")],exports.Robot.prototype,"action",void 0),o([t.surfaceType(0)],exports.Robot.prototype,"now",void 0),o([t.dataType(12)],exports.Robot.prototype,"FPS",void 0),o([t.dataType(!0)],exports.Robot.prototype,"loop",void 0),exports.Robot=o([t.registerUI()],exports.Robot),t.Plugin.add("robot"),exports.RobotData=e;
|
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
|
|
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 d=r?r.x:0,p=r?r.y:0;for(let o=i;o<s;o++)this.robotFrames[o]={view:t.view,x:d,y:p,width:h,height:_},d+h>=t.width?(d=0,p+=_):d+=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),o.Plugin.add("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.
|
|
3
|
+
"version": "1.2.0",
|
|
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.
|
|
38
|
-
"@leafer-ui/interface": "^1.
|
|
39
|
-
"@leafer-in/interface": "^1.
|
|
37
|
+
"@leafer-ui/draw": "^1.2.0",
|
|
38
|
+
"@leafer-ui/interface": "^1.2.0",
|
|
39
|
+
"@leafer-in/interface": "^1.2.0"
|
|
40
40
|
}
|
|
41
41
|
}
|