leafer-game 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/web.cjs +26 -684
- package/dist/web.esm.js +2 -671
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +140 -420
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +140 -418
- package/dist/web.module.min.js +1 -1
- package/package.json +7 -7
package/dist/web.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("leafer-ui"),e=require("@leafer-in/robot"),n=require("@leafer-ui/draw"),o=require("@leafer-ui/core"),i=require("@leafer-in/animate");function r(t,e){return n.decorateLeafAttr(t,(t=>n.attr({set(o){this.__setAttr(t,o),this.waitLeafer((()=>e?n.State.setStyleName(this,e,o):n.State.set(this,o)))}})))}function a(t){return n.decorateLeafAttr(t,(t=>n.attr({set(e){this.__setAttr(t,e),this.__layout.stateStyleChanged=!0}})))}function s(t,e){if(e&&!0!==e)return e;if(!t.button){let{parent:e}=t;for(let t=0;t<2;t++)if(e){if(e.button)return e;e=e.parent}}return null}function l(t,e){"object"!=typeof e&&(e=void 0),f(t,e,"in")}function c(t,e){const{normalStyle:n}=t;"object"!=typeof e&&(e=void 0),n&&(e||(e=n),f(t,e,"out"))}const u={};function f(t,e,n){const{normalStyle:i}=t;e||(e=u),e.scale&&(o.MathHelper.assignScale(e,e.scale),delete e.scale),e!==u&&o.State.canAnimate||(n=null);let r=!!n&&function(t,e,n){let i="in"===t?"transition":"transitionOut";"out"===t&&o.isNull(n[i])&&o.isNull(e[i])&&(i="transition");return o.isNull(e[i])?n[i]:e[i]}(n,e,t);const a=r?function(t,e){const n=p(e,t),o=t.animate();o&&p(n,t,o.fromStyle);return n}(t,e):void 0;t.killAnimate("transition"),i&&t.set(i,"temp");const s=h(t);if(s){const{animation:o}=s;if(o){const i=t.animate(o,void 0,"animation",!0);Object.assign(s,i.endingStyle),"in"!==n||e.animation!==o?i.kill():r=!1,delete s.animation}t.normalStyle=d(s,t),t.set(s,"temp")}else t.normalStyle=void 0;if(r){const e=d(a,t);t.set(a,"temp"),t.animate([a,e],r,"transition",!0)}t.__layout.stateStyleChanged=!1}function h(t){let e;const n={},{state:i}=t,r=s(t),a=i&&t.states[i];a&&o.State.isState(i,t,r)&&(e=y(n,a));const l=n.selectedStyle||t.selectedStyle;if(l&&o.State.isSelected(t,r)&&(e=y(n,l)),o.State.isDisabled(t,r)){const o=n.disabledStyle||t.disabledStyle;o&&(e=y(n,o))}else{const i=n.focusStyle||t.focusStyle;i&&o.State.isFocus(t,r)&&(e=y(n,i));const a=n.hoverStyle||t.hoverStyle;a&&o.State.isHover(t,r)&&(e=y(n,a));const s=n.pressStyle||t.pressStyle;s&&o.State.isPress(t,r)&&(e=y(n,s))}return e?n:void 0}function d(t,e,n,i){const r=n?t:{},a=n||t;for(let t in a)i&&o.State.animateExcludes[t]||(r[t]=e[t]);return r}function p(t,e,n){return d(t,e,n,!0)}function y(t,e){return Object.assign(t,e),!0}function S(t,e){const n=t[e];n&&l(t,n),t.button&&g(t.children,e)}function m(t,e,n){n||(n=t.states[e]),l(t,n),t.button&&g(t.children,null,e)}function g(t,e,n){if(!t)return;let i,r;for(let a=0,s=t.length;a<s;a++){if(i=t[a],e){switch(r=!0,e){case"hoverStyle":o.State.isHover(i)&&(r=!1);break;case"pressStyle":o.State.isPress(i)&&(r=!1);break;case"focusStyle":o.State.isFocus(i)&&(r=!1)}r&&S(i,e)}else n&&m(i,n);i.isBranch&&g(i.children,e,n)}}function b(t,e){const n=t[e];n&&c(t,n),t.button&&_(t.children,e)}function P(t,e,n){c(t,n),t.button&&_(t.children,null,e)}function _(t,e,n){if(!t)return;let o;for(let i=0,r=t.length;i<r;i++)o=t[i],e?b(o,e):n&&P(o,n),o.isBranch&&_(o.children,e,n)}function v(t,e,n){let o;const i=e.leafer?e.leafer.interaction:null;if(i&&(o=i[t](e),!o&&n)){const r=s(e,n);r&&(o=i[t](r))}return o}function x(t,e,n){let o=e[t];if(!o&&n){const i=s(e,n);i&&(o=i[t])}return o}o.State.animateExcludes={animation:1,animationOut:1,transition:1,transitionOut:1,states:1,state:1,normalStyle:1,hoverStyle:1,pressStyle:1,focusStyle:1,selectedStyle:1,disabledStyle:1},o.State.isState=function(t,e,n){return function(t,e,n){let o=e.states[t];if(!o&&n){const i=s(e,n);i&&(o=i.states[t])}return!!o}(t,e,n)},o.State.isSelected=function(t,e){return x("selected",t,e)},o.State.isDisabled=function(t,e){return x("disabled",t,e)},o.State.isFocus=function(t,e){return v("isFocus",t,e)},o.State.isHover=function(t,e){return v("isHover",t,e)},o.State.isPress=function(t,e){return v("isPress",t,e)},o.State.isDrag=function(t,e){return v("isDrag",t,e)},o.State.setStyleName=function(t,e,n){n?m(t,e,t[e]):P(t,e,t[e])},o.State.set=function(t,e){const n=t.states[e];n?m(t,e,n):P(t,e,n)},o.State.getStyle=h,o.State.updateStyle=f,o.State.updateEventStyle=function(t,e){switch(e){case o.PointerEvent.ENTER:S(t,"hoverStyle");break;case o.PointerEvent.LEAVE:b(t,"hoverStyle");break;case o.PointerEvent.DOWN:S(t,"pressStyle");break;case o.PointerEvent.UP:b(t,"pressStyle")}};const M=o.UI.prototype;r(!1,"selectedStyle")(M,"selected"),r(!1,"disabledStyle")(M,"disabled"),a({})(M,"states"),r("")(M,"state"),o.dataType()(M,"normalStyle"),a()(M,"hoverStyle"),a()(M,"pressStyle"),a()(M,"focusStyle"),a()(M,"selectedStyle"),a()(M,"disabledStyle"),o.dataType(!1)(M,"button"),M.focus=function(t=!0){this.waitLeafer((()=>{let{focusData:e}=this.app.interaction;t?(e&&e.focus(!1),e=this):e=null,this.app.interaction.focusData=e,t?S(this,"focusStyle"):b(this,"focusStyle")}))},M.updateState=function(){o.State.updateStyle(this,void 0,"in")};const D=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],O=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:k}=Math,H={getDistance(t,e,n,o,i,r,a,s,l=1){let c,u,f,h,d,p,y=0,S=l/2;for(let l=0;l<D.length;l++)c=S*(1+D[l]),u=S*(1-D[l]),f=T(c,t,n,i,a),h=T(c,e,o,r,s),d=T(u,t,n,i,a),p=T(u,e,o,r,s),y+=O[l]*(k(f*f+h*h)+k(d*d+p*p));return y*S},getDerivative(t,e,n,o,i){const r=1-t;return 3*r*r*(n-e)+6*r*t*(o-n)+3*t*t*(i-o)},getRotation(t,e,o,i,r,a,s,l,c){const u=T(t,e,i,a,l),f=T(t,o,r,s,c);return Math.atan2(f,u)/n.OneRadian},getT(t,e,n,o,i,r,a,s,l,c,u=1){let f=0,h=1,d=t/e,p=u/e/3;if(d>=1)return 1;if(d<=0)return 0;for(;h-f>p;)j(n,o,i,r,a,s,l,c,d)<t?f=d:h=d,d=(f+h)/2;return d},cut(t,e,o,i,r,a,s,l,c,u){const f=1-e,h=f*o+e*r,d=f*i+e*a,p=f*r+e*s,y=f*a+e*l,S=f*h+e*p,m=f*d+e*y,g=f*S+e*(f*p+e*(f*s+e*c)),b=f*m+e*(f*y+e*(f*l+e*u));t.push(n.PathCommandMap.C,h,d,S,m,g,b)}},{getDerivative:T,getDistance:j}=H,{M:C,L:E,C:A,Z:w}=n.PathCommandMap,F={},N={},L={transform(t,e){let n,o=0;const i=t.length;for(;o<i;)switch(n=t[o],n){case C:case E:L.transformPoints(t,e,o,1),o+=3;break;case A:L.transformPoints(t,e,o,3),o+=7;break;case w:o+=1}},transformPoints(t,e,o,i){for(let r=o+1,a=r+2*i;r<a;r+=2)F.x=t[r],F.y=t[r+1],n.MatrixHelper.toOuterPoint(e,F),t[r]=F.x,t[r+1]=F.y},getMotionPathData(t){let e,o,i,r,a=0,s=[],l=0,c=0,u=0;const f=t.length;for(;l<f;){switch(r=t[l],r){case C:case E:o=t[l+1],i=t[l+2],e=r===E&&l>0?n.PointHelper.getDistanceFrom(c,u,o,i):0,c=o,u=i,l+=3;break;case A:o=t[l+5],i=t[l+6],e=H.getDistance(c,u,t[l+1],t[l+2],t[l+3],t[l+4],o,i),c=o,u=i,l+=7;break;case w:l+=1;default:e=0}s.push(e),a+=e}return{total:a,segments:s,data:t}},getDistancePoint(t,e,o){const{segments:i,data:r}=t;e=n.UnitConvert.number(e,t.total);let a,s,l,c,u,f,h,d,p,y=0,S={},m=0,g=0,b=0,P=0;const _=r.length;for(;m<_;){switch(c=r[m],c){case C:case E:if(s=r[m+1],l=r[m+2],a=i[g],y+a>e||!t.total)return m||(b=s,P=l),N.x=b,N.y=P,S.x=s,S.y=l,n.PointHelper.getDistancePoint(N,S,e-y,!0),S.rotation=n.PointHelper.getAngle(N,S),S;b=s,P=l,m+=3;break;case A:if(s=r[m+5],l=r[m+6],a=i[g],y+a>e)return u=r[m+1],f=r[m+2],h=r[m+3],d=r[m+4],p=H.getT(e-y,a,b,P,u,f,h,d,s,l,o),n.BezierHelper.getPointAndSet(p,b,P,u,f,h,d,s,l,S),S.rotation=H.getRotation(p,b,P,u,f,h,d,s,l),S;b=s,P=l,m+=7;break;case w:m+=1;default:a=0}g++,y+=a}return S},getDistancePath(t,e,o){const{segments:i,data:r}=t,a=[];e=n.UnitConvert.number(e,t.total);let s,l,c,u,f,h,d,p,y,S=0,m={},g=0,b=0,P=0,_=0;const v=r.length;for(;g<v;){switch(u=r[g],u){case C:case E:if(l=r[g+1],c=r[g+2],s=i[b],S+s>e||!t.total)return g||(P=l,_=c),N.x=P,N.y=_,m.x=l,m.y=c,n.PointHelper.getDistancePoint(N,m,e-S,!0),a.push(u,m.x,m.y),a;P=l,_=c,g+=3,a.push(u,P,_);break;case A:if(f=r[g+1],h=r[g+2],d=r[g+3],p=r[g+4],l=r[g+5],c=r[g+6],s=i[b],S+s>e)return y=H.getT(e-S,s,P,_,f,h,d,p,l,c,o),H.cut(a,y,P,_,f,h,d,p,l,c),a;P=l,_=c,g+=7,a.push(u,f,h,d,p,l,c);break;case w:g+=1,a.push(u);default:s=0}b++,S+=s}return a}};function R(t){return n.decorateLeafAttr(t,(t=>n.attr({set(e){this.__setAttr(t,e),this.__hasMotionPath=this.motionPath||!n.isNull(this.motion),this.__layout.matrixChanged||this.__layout.matrixChange()}})))}n.Transition.register("motion",(function(t,e,o,i){return t?"object"==typeof t&&(t=n.UnitConvert.number(t,i.getMotionTotal())):t=0,e?"object"==typeof e&&(e=n.UnitConvert.number(e,i.getMotionTotal())):e=0,n.Transition.number(t,e,o)})),n.Transition.register("motionRotation",(function(t,e,o){return n.Transition.number(t,e,o)}));const B=n.UI.prototype,{updateMatrix:U,updateAllMatrix:q}=n.LeafHelper,{updateBounds:I}=n.BranchHelper;function z(t){const{motion:e,leaferIsCreated:o}=t;if(!n.isNull(e)){if(o&&(t.leafer.created=!1),t.motionPath){const n=W(t);n.total&&(t.__.__pathForRender=L.getDistancePath(n,e,t.motionPrecision))}else t.set(t.getMotionPoint(e)),t.__hasAutoLayout||(t.isBranch?(q(t),I(t,t)):U(t));o&&(t.leafer.created=!0)}}function V(t){const{parent:e}=t;if(!t.motionPath&&e){const{children:t}=e;for(let e=0;e<t.length;e++)if(t[e].motionPath)return t[e]}return t}function W(t){const e=t.__;return e.__pathForMotion?e.__pathForMotion:e.__pathForMotion=L.getMotionPathData(t.getPath(!0,!0))}R()(B,"motionPath"),R(1)(B,"motionPrecision"),R()(B,"motion"),R(!0)(B,"motionRotation"),B.getMotionPathData=function(){return W(V(this))},B.getMotionPoint=function(t){const e=V(this),o=W(e);if(!o.total)return{};const i=L.getDistancePoint(o,t,e.motionPrecision);n.MatrixHelper.toOuterPoint(e.localTransform,i);const{motionRotation:r}=this;return!1===r?delete i.rotation:"number"==typeof r&&(i.rotation+=r),i},B.getMotionTotal=function(){return this.getMotionPathData().total},B.__updateMotionPath=function(){const t=this.__;if(this.__layout.resized&&t.__pathForMotion&&(t.__pathForMotion=void 0),this.motionPath){let t;const{children:e}=this.parent,{leaferIsReady:o}=this;for(let i=0;i<e.length;i++)t=e[i],n.isNull(t.motion)||t.__layout.matrixChanged||(o&&t!==this&&this.leafer.layouter.addExtra(t),z(t))}else z(this)},exports.HighBezierHelper=H,exports.HighCurveHelper=L,exports.motionPathType=R,exports.stateStyleType=a,exports.stateType=r,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})})),Object.keys(i).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return i[t]}})}));
|
|
1
|
+
"use strict";var e=require("leafer-ui"),t=require("@leafer-in/robot"),r=require("@leafer-in/state"),o=require("@leafer-in/animate"),n=require("@leafer-in/motion-path");Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})})),Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(r).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return r[e]}})})),Object.keys(o).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return o[e]}})})),Object.keys(n).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return n[e]}})}));
|