@leafer-game/miniapp 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/miniapp.cjs +19 -679
- package/dist/miniapp.esm.js +5 -674
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.module.js +130 -360
- package/dist/miniapp.module.min.js +1 -1
- package/package.json +4 -4
package/dist/miniapp.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"@leafer-ui/miniapp";export*from"@leafer-in/robot";
|
|
1
|
+
export*from"@leafer-ui/miniapp";export*from"@leafer-in/robot";export*from"@leafer-in/state";export*from"@leafer-in/animate";export*from"@leafer-in/motion-path";import{LeaferImage as t,Platform as e,MatrixHelper as r}from"@leafer/core";"ios"===wx.getSystemInfoSync().platform&&(t.prototype.getPattern=function(t,o,i,a){const n=e.canvas.createPattern(this.view,o),{width:f,height:h}=t;this.width===f&&this.height===h||(i||(i=r.get()),r.scale(i,f/this.width,h/this.height));try{i&&n.setTransform&&(n.setTransform(i),i=null)}catch(t){}return a&&(a.transform=i),n});
|
package/dist/miniapp.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer-ui/miniapp"),e=require("@leafer-in/robot"),n=require("@leafer-ui/draw"),o=require("@leafer-ui/core"),i=require("@leafer-in/animate"),r=require("@leafer/core");function a(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 s(t){return n.decorateLeafAttr(t,(t=>n.attr({set(e){this.__setAttr(t,e),this.__layout.stateStyleChanged=!0}})))}function l(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 c(t,e){"object"!=typeof e&&(e=void 0),h(t,e,"in")}function u(t,e){const{normalStyle:n}=t;"object"!=typeof e&&(e=void 0),n&&(e||(e=n),h(t,e,"out"))}const f={};function h(t,e,n){const{normalStyle:i}=t;e||(e=f),e.scale&&(o.MathHelper.assignScale(e,e.scale),delete e.scale),e!==f&&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=y(e,t),o=t.animate();o&&y(n,t,o.fromStyle);return n}(t,e):void 0;t.killAnimate("transition"),i&&t.set(i,"temp");const s=p(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 p(t){let e;const n={},{state:i}=t,r=l(t),a=i&&t.states[i];a&&o.State.isState(i,t,r)&&(e=S(n,a));const s=n.selectedStyle||t.selectedStyle;if(s&&o.State.isSelected(t,r)&&(e=S(n,s)),o.State.isDisabled(t,r)){const o=n.disabledStyle||t.disabledStyle;o&&(e=S(n,o))}else{const i=n.focusStyle||t.focusStyle;i&&o.State.isFocus(t,r)&&(e=S(n,i));const a=n.hoverStyle||t.hoverStyle;a&&o.State.isHover(t,r)&&(e=S(n,a));const s=n.pressStyle||t.pressStyle;s&&o.State.isPress(t,r)&&(e=S(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 y(t,e,n){return d(t,e,n,!0)}function S(t,e){return Object.assign(t,e),!0}function m(t,e){const n=t[e];n&&c(t,n),t.button&&b(t.children,e)}function g(t,e,n){n||(n=t.states[e]),c(t,n),t.button&&b(t.children,null,e)}function b(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&&m(i,e)}else n&&g(i,n);i.isBranch&&b(i.children,e,n)}}function P(t,e){const n=t[e];n&&u(t,n),t.button&&v(t.children,e)}function _(t,e,n){u(t,n),t.button&&v(t.children,null,e)}function v(t,e,n){if(!t)return;let o;for(let i=0,r=t.length;i<r;i++)o=t[i],e?P(o,e):n&&_(o,n),o.isBranch&&v(o.children,e,n)}function x(t,e,n){let o;const i=e.leafer?e.leafer.interaction:null;if(i&&(o=i[t](e),!o&&n)){const r=l(e,n);r&&(o=i[t](r))}return o}function M(t,e,n){let o=e[t];if(!o&&n){const i=l(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=l(e,n);i&&(o=i.states[t])}return!!o}(t,e,n)},o.State.isSelected=function(t,e){return M("selected",t,e)},o.State.isDisabled=function(t,e){return M("disabled",t,e)},o.State.isFocus=function(t,e){return x("isFocus",t,e)},o.State.isHover=function(t,e){return x("isHover",t,e)},o.State.isPress=function(t,e){return x("isPress",t,e)},o.State.isDrag=function(t,e){return x("isDrag",t,e)},o.State.setStyleName=function(t,e,n){n?g(t,e,t[e]):_(t,e,t[e])},o.State.set=function(t,e){const n=t.states[e];n?g(t,e,n):_(t,e,n)},o.State.getStyle=p,o.State.updateStyle=h,o.State.updateEventStyle=function(t,e){switch(e){case o.PointerEvent.ENTER:m(t,"hoverStyle");break;case o.PointerEvent.LEAVE:P(t,"hoverStyle");break;case o.PointerEvent.DOWN:m(t,"pressStyle");break;case o.PointerEvent.UP:P(t,"pressStyle")}};const D=o.UI.prototype;a(!1,"selectedStyle")(D,"selected"),a(!1,"disabledStyle")(D,"disabled"),s({})(D,"states"),a("")(D,"state"),o.dataType()(D,"normalStyle"),s()(D,"hoverStyle"),s()(D,"pressStyle"),s()(D,"focusStyle"),s()(D,"selectedStyle"),s()(D,"disabledStyle"),o.dataType(!1)(D,"button"),D.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?m(this,"focusStyle"):P(this,"focusStyle")}))},D.updateState=function(){o.State.updateStyle(this,void 0,"in")};const O=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],H=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:T}=Math,k={getDistance(t,e,n,o,i,r,a,s,l=1){let c,u,f,h,p,d,y=0,S=l/2;for(let l=0;l<O.length;l++)c=S*(1+O[l]),u=S*(1-O[l]),f=w(c,t,n,i,a),h=w(c,e,o,r,s),p=w(u,t,n,i,a),d=w(u,e,o,r,s),y+=H[l]*(T(f*f+h*h)+T(p*p+d*d));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=w(t,e,i,a,l),f=w(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,p=t/e,d=u/e/3;if(p>=1)return 1;if(p<=0)return 0;for(;h-f>d;)j(n,o,i,r,a,s,l,c,p)<t?f=p:h=p,p=(f+h)/2;return p},cut(t,e,o,i,r,a,s,l,c,u){const f=1-e,h=f*o+e*r,p=f*i+e*a,d=f*r+e*s,y=f*a+e*l,S=f*h+e*d,m=f*p+e*y,g=f*S+e*(f*d+e*(f*s+e*c)),b=f*m+e*(f*y+e*(f*l+e*u));t.push(n.PathCommandMap.C,h,p,S,m,g,b)}},{getDerivative:w,getDistance:j}=k,{M:C,L:E,C:A,Z:F}=n.PathCommandMap,L={},N={},R={transform(t,e){let n,o=0;const i=t.length;for(;o<i;)switch(n=t[o],n){case C:case E:R.transformPoints(t,e,o,1),o+=3;break;case A:R.transformPoints(t,e,o,3),o+=7;break;case F:o+=1}},transformPoints(t,e,o,i){for(let r=o+1,a=r+2*i;r<a;r+=2)L.x=t[r],L.y=t[r+1],n.MatrixHelper.toOuterPoint(e,L),t[r]=L.x,t[r+1]=L.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=k.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 F: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,p,d,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],p=r[m+4],d=k.getT(e-y,a,b,P,u,f,h,p,s,l,o),n.BezierHelper.getPointAndSet(d,b,P,u,f,h,p,s,l,S),S.rotation=k.getRotation(d,b,P,u,f,h,p,s,l),S;b=s,P=l,m+=7;break;case F: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,p,d,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],p=r[g+3],d=r[g+4],l=r[g+5],c=r[g+6],s=i[b],S+s>e)return y=k.getT(e-S,s,P,_,f,h,p,d,l,c,o),k.cut(a,y,P,_,f,h,p,d,l,c),a;P=l,_=c,g+=7,a.push(u,f,h,p,d,l,c);break;case F:g+=1,a.push(u);default:s=0}b++,S+=s}return a}};function q(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:I}=n.LeafHelper,{updateBounds:z}=n.BranchHelper;function V(t){const{motion:e,leaferIsCreated:o}=t;if(!n.isNull(e)){if(o&&(t.leafer.created=!1),t.motionPath){const n=Z(t);n.total&&(t.__.__pathForRender=R.getDistancePath(n,e,t.motionPrecision))}else t.set(t.getMotionPoint(e)),t.__hasAutoLayout||(t.isBranch?(I(t),z(t,t)):U(t));o&&(t.leafer.created=!0)}}function W(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 Z(t){const e=t.__;return e.__pathForMotion?e.__pathForMotion:e.__pathForMotion=R.getMotionPathData(t.getPath(!0,!0))}q()(B,"motionPath"),q(1)(B,"motionPrecision"),q()(B,"motion"),q(!0)(B,"motionRotation"),B.getMotionPathData=function(){return Z(W(this))},B.getMotionPoint=function(t){const e=W(this),o=Z(e);if(!o.total)return{};const i=R.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),V(t))}else V(this)};"ios"===wx.getSystemInfoSync().platform&&(r.LeaferImage.prototype.getPattern=function(t,e,n,o){const i=r.Platform.canvas.createPattern(this.view,e),{width:a,height:s}=t;this.width===a&&this.height===s||(n||(n=r.MatrixHelper.get()),r.MatrixHelper.scale(n,a/this.width,s/this.height));try{n&&i.setTransform&&(i.setTransform(n),n=null)}catch(t){}return o&&(o.transform=n),i}),exports.HighBezierHelper=k,exports.HighCurveHelper=R,exports.motionPathType=q,exports.stateStyleType=s,exports.stateType=a,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/miniapp"),t=require("@leafer-in/robot"),r=require("@leafer-in/state"),o=require("@leafer-in/animate"),n=require("@leafer-in/motion-path"),a=require("@leafer/core");"ios"===wx.getSystemInfoSync().platform&&(a.LeaferImage.prototype.getPattern=function(e,t,r,o){const n=a.Platform.canvas.createPattern(this.view,t),{width:i,height:c}=e;this.width===i&&this.height===c||(r||(r=a.MatrixHelper.get()),a.MatrixHelper.scale(r,i/this.width,c/this.height));try{r&&n.setTransform&&(n.setTransform(r),r=null)}catch(e){}return o&&(o.transform=r),n}),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]}})}));
|