@leafer-game/miniapp 1.0.10 → 1.1.1
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 -659
- package/dist/miniapp.esm.js +5 -654
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.module.js +248 -430
- package/dist/miniapp.module.min.js +1 -1
- package/package.json +4 -4
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"),r=require("@leafer-in/animate"),i=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:r}=t;e||(e=f),e.scale&&(o.MathHelper.assignScale(e,e.scale),delete e.scale),e!==f&&o.State.canAnimate||(n=null);let i=!!n&&function(t,e,n){let r="in"===t?"transition":"transitionOut";"out"===t&&o.isNull(n[r])&&o.isNull(e[r])&&(r="transition");return o.isNull(e[r])?n[r]:e[r]}(n,e,t);const a=i?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"),r&&t.set(r,!0);const s=p(t);if(s){const{animation:o}=s;if(o){const r=t.animate(o,void 0,"animation",!0);Object.assign(s,r.endingStyle),"in"!==n||e.animation!==o?r.kill():i=!1,delete s.animation}t.normalStyle=d(s,t),t.set(s,!0)}else t.normalStyle=void 0;if(i){const e=d(a,t);t.set(a,!0),t.animate([a,e],i,"transition",!0)}t.__layout.stateStyleChanged=!1}function p(t){let e;const n={},{state:r}=t,i=l(t),a=r&&t.states[r];a&&o.State.isState(r,t,i)&&(e=S(n,a));const s=n.selectedStyle||t.selectedStyle;if(s&&o.State.isSelected(t,i)&&(e=S(n,s)),o.State.isDisabled(t,i)){const o=n.disabledStyle||t.disabledStyle;o&&(e=S(n,o))}else{const r=n.focusStyle||t.focusStyle;r&&o.State.isFocus(t,i)&&(e=S(n,r));const a=n.hoverStyle||t.hoverStyle;a&&o.State.isHover(t,i)&&(e=S(n,a));const s=n.pressStyle||t.pressStyle;s&&o.State.isPress(t,i)&&(e=S(n,s))}return e?n:void 0}function d(t,e,n,r){const i=n?t:{},a=n||t;for(let t in a)r&&o.State.animateExcludes[t]||(i[t]=e[t]);return i}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 r,i;for(let a=0,s=t.length;a<s;a++){if(r=t[a],e){switch(i=!0,e){case"hoverStyle":o.State.isHover(r)&&(i=!1);break;case"pressStyle":o.State.isPress(r)&&(i=!1);break;case"focusStyle":o.State.isFocus(r)&&(i=!1)}i&&m(r,e)}else n&&g(r,n);r.isBranch&&b(r.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 r=0,i=t.length;r<i;r++)o=t[r],e?P(o,e):n&&_(o,n),o.isBranch&&v(o.children,e,n)}function x(t,e,n){let o;const r=e.leafer?e.leafer.interaction:null;if(r&&(o=r[t](e),!o&&n)){const i=l(e,n);i&&(o=r[t](i))}return o}function M(t,e,n){let o=e[t];if(!o&&n){const r=l(e,n);r&&(o=r[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 r=l(e,n);r&&(o=r.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 H=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],O=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:k}=Math,w={getDistance(t,e,n,o,r,i,a,s){let l,c,u,f,h,p,d=0;for(let y=0;y<H.length;y++)l=.5*(1+H[y]),c=.5*(1-H[y]),u=T(l,t,n,r,a),f=T(l,e,o,i,s),h=T(c,t,n,r,a),p=T(c,e,o,i,s),d+=O[y]*(k(u*u+f*f)+k(h*h+p*p));return.5*d},getDerivative(t,e,n,o,r){const i=1-t;return 3*i*i*(n-e)+6*i*t*(o-n)+3*t*t*(r-o)},cut(t,e,o,r,i,a,s,l,c,u){const f=1-e,h=f*o+e*i,p=f*r+e*a,d=f*i+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:T}=w,{M:j,L:A,C:C,Z:E}=n.PathCommandMap,F={},L={},N={transform(t,e){let n,o=0;const r=t.length;for(;o<r;)switch(n=t[o],n){case j:case A:N.transformPoints(t,e,o,1),o+=3;break;case C:N.transformPoints(t,e,o,3),o+=7;break;case E:o+=1}},transformPoints(t,e,o,r){for(let i=o+1,a=i+2*r;i<a;i+=2)F.x=t[i],F.y=t[i+1],n.MatrixHelper.toOuterPoint(e,F),t[i]=F.x,t[i+1]=F.y},getMotionPathData(t){let e,o,r,i,a=0,s=[],l=0,c=0,u=0;const f=t.length;for(;l<f;){switch(i=t[l],i){case j:case A:o=t[l+1],r=t[l+2],e=i===A&&l>0?n.PointHelper.getDistanceFrom(c,u,o,r):0,c=o,u=r,l+=3;break;case C:o=t[l+5],r=t[l+6],e=w.getDistance(c,u,t[l+1],t[l+2],t[l+3],t[l+4],o,r),c=o,u=r,l+=7;break;case E:l+=1;default:e=0}s.push(e),a+=e}return{total:a,segments:s,data:t}},getDistancePoint(t,e){const{segments:o,data:r}=t;e=n.UnitConvert.number(e,t.total);let i,a,s,l,c=0,u={},f=0,h=0,p=0,d=0;const y=r.length;for(;f<y;){switch(l=r[f],l){case j:case A:if(a=r[f+1],s=r[f+2],i=o[h],c+i>e||!t.total)return f||(p=a,d=s),L.x=p,L.y=d,u.x=a,u.y=s,n.PointHelper.getDistancePoint(L,u,e-c,!0),u.rotation=n.PointHelper.getAngle(L,u),u;p=a,d=s,f+=3;break;case C:if(a=r[f+5],s=r[f+6],i=o[h],c+i>e){const t=r[f+1],o=r[f+2],l=r[f+3],h=r[f+4];return e-=c,n.BezierHelper.getPointAndSet(e/i,p,d,t,o,l,h,a,s,u),n.BezierHelper.getPointAndSet(Math.max(0,e-.1)/i,p,d,t,o,l,h,a,s,L),u.rotation=n.PointHelper.getAngle(L,u),u}p=a,d=s,f+=7;break;case E:f+=1;default:i=0}h++,c+=i}return u},getDistancePath(t,e){const{segments:o,data:r}=t,i=[];e=n.UnitConvert.number(e,t.total);let a,s,l,c,u=0,f={},h=0,p=0,d=0,y=0;const S=r.length;for(;h<S;){switch(c=r[h],c){case j:case A:if(s=r[h+1],l=r[h+2],a=o[p],u+a>e||!t.total)return h||(d=s,y=l),L.x=d,L.y=y,f.x=s,f.y=l,n.PointHelper.getDistancePoint(L,f,e-u,!0),i.push(c,f.x,f.y),i;d=s,y=l,h+=3,i.push(c,d,y);break;case C:const S=r[h+1],m=r[h+2],g=r[h+3],b=r[h+4];if(s=r[h+5],l=r[h+6],a=o[p],u+a>e)return w.cut(i,(e-u)/a,d,y,S,m,g,b,s,l),i;d=s,y=l,h+=7,i.push(c,S,m,g,b,s,l);break;case E:h+=1,i.push(c);default:a=0}p++,u+=a}return i}};function B(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,r){return t?"object"==typeof t&&(t=n.UnitConvert.number(t,r.getMotionTotal())):t=0,e?"object"==typeof e&&(e=n.UnitConvert.number(e,r.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 q=n.UI.prototype,{updateMatrix:U,updateAllMatrix:I}=n.LeafHelper,{updateBounds:R}=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=N.getDistancePath(n,e))}else t.set(t.getMotionPoint(e)),t.__hasAutoLayout||(t.isBranch?(I(t),R(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=N.getMotionPathData(t.getPath(!0,!0))}B()(q,"motionPath"),B()(q,"motion"),B(!0)(q,"motionRotation"),q.getMotionPathData=function(){return W(V(this))},q.getMotionPoint=function(t){const e=V(this),o=W(e);if(!o.total)return{};const r=N.getDistancePoint(o,t);n.MatrixHelper.toOuterPoint(e.localTransform,r);const{motionRotation:i}=this;return!1===i?delete r.rotation:"number"==typeof i&&(r.rotation+=i),r},q.getMotionTotal=function(){return this.getMotionPathData().total},q.__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 r=0;r<e.length;r++)t=e[r],n.isNull(t.motion)||t.__layout.matrixChanged||(o&&t!==this&&this.leafer.layouter.addExtra(t),z(t))}else z(this)};"ios"===wx.getSystemInfoSync().platform&&(i.LeaferImage.prototype.getPattern=function(t,e,n,o){const r=i.Platform.canvas.createPattern(this.view,e),{width:a,height:s}=t;this.width===a&&this.height===s||(n||(n=i.MatrixHelper.get()),i.MatrixHelper.scale(n,a/this.width,s/this.height));try{n&&r.setTransform&&(r.setTransform(n),n=null)}catch(t){}return o&&(o.transform=n),r}),exports.HighBezierHelper=w,exports.HighCurveHelper=N,exports.motionPathType=B,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(r).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return r[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]}})}));
|