4 lines
15 KiB
JavaScript
4 lines
15 KiB
JavaScript
|
import{Y as t,q as e,aR as o,aS as r,aT as n,aU as i,P as a,aV as c,aW as s,az as u,ax as h,$ as d,o as p,c as l,w as f,k as g,b as v,x as y,l as m,aX as b}from"./index.26a6cf84.js";import{_ as x}from"./plugin-vue_export-helper.21dcd24c.js";var w=void 0,C=["touchstarted","touchmoved","touchended"];function S(t){for(var e=[],o=arguments.length-1;o-- >0;)e[o]=arguments[o+1];C.forEach((function(o,r){void 0!==e[r]&&(t[o]=e[r])}))}function T(){return w||(w=t()),w}var O={},W={id:{default:"cropper",get:function(){return O.id},set:function(t){"string"!=typeof t&&console.error("id:"+t+" is invalid"),O.id=t}},width:{default:750,get:function(){return O.width},set:function(t){"number"!=typeof t&&console.error("width:"+t+" is invalid"),O.width=t}},height:{default:750,get:function(){return O.height},set:function(t){"number"!=typeof t&&console.error("height:"+t+" is invalid"),O.height=t}},pixelRatio:{default:T().pixelRatio,get:function(){return O.pixelRatio},set:function(t){"number"!=typeof t&&console.error("pixelRatio:"+t+" is invalid"),O.pixelRatio=t}},scale:{default:2.5,get:function(){return O.scale},set:function(t){"number"!=typeof t&&console.error("scale:"+t+" is invalid"),O.scale=t}},zoom:{default:5,get:function(){return O.zoom},set:function(t){"number"!=typeof t?console.error("zoom:"+t+" is invalid"):(t<0||t>10)&&console.error("zoom should be ranged in 0 ~ 10"),O.zoom=t}},src:{default:"",get:function(){return O.src},set:function(t){"string"!=typeof t&&console.error("src:"+t+" is invalid"),O.src=t}},cut:{default:{},get:function(){return O.cut},set:function(t){"object"!=typeof t&&console.error("cut:"+t+" is invalid"),O.cut=t}},boundStyle:{default:{},get:function(){return O.boundStyle},set:function(t){"object"!=typeof t&&console.error("boundStyle:"+t+" is invalid"),O.boundStyle=t}},onReady:{default:null,get:function(){return O.ready},set:function(t){O.ready=t}},onBeforeImageLoad:{default:null,get:function(){return O.beforeImageLoad},set:function(t){O.beforeImageLoad=t}},onImageLoad:{default:null,get:function(){return O.imageLoad},set:function(t){O.imageLoad=t}},onBeforeDraw:{default:null,get:function(){return O.beforeDraw},set:function(t){O.beforeDraw=t}}},I=T().windowWidth;var M="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function _(t,e){return t(e={exports:{}},e.exports),e.exports}var j=_((function(t,e){e.isStr=function(t){return"string"==typeof t},e.isNum=function(t){return"number"==typeof t},e.isArr=Array.isArray,e.isUndef=function(t){return void 0===t},e.isTrue=function(t){return!0===t},e.isFalse=function(t){return!1===t},e.isFunc=function(t){return"function"==typeof t},e.isObj=e.isObject=function(t){return null!==t&&"object"==typeof t};var o=Object.prototype.toString;e.isPlainObject=function(t){return"[object Object]"===o.call(t)};var r=Object.prototype.hasOwnProperty;e.hasOwn=function(t,e){return r.call(t,e)},e.noop=function(t,e,o){},e.isValidArrayIndex=function(t){var e=parseFloat(String(t));return e>=0&&Math.floor(e)===e&&isFinite(t)}})),A=j.isFunc,L=j.isPlainObject,R=["ready","beforeImageLoad","beforeDraw","imageLoad"];function P(t){return function(e){for(var o=[],r=arguments.length-1;r-- >0;)o[r]=arguments[r+1];return void 0===e&&(e={}),new Promise((function(r,n){e.success=function(t){r(t)},e.fail=function(t){n(t)},t.apply(void 0,[e].concat(o))}))}}function H(t,e){return void 0===e&&(e=!1),new Promise((function(o){t.draw(e,o)}))}var k=P(r),B=P(n),E=_((function(t,e){
|
|||
|
/*! http://mths.be/base64 v0.1.0 by @mathias | MIT license */
|
|||
|
!function(o){var r=e,n=t&&t.exports==r&&t,i="object"==typeof M&&M;i.global!==i&&i.window!==i||(o=i);var a=function(t){this.message=t};(a.prototype=new Error).name="InvalidCharacterError";var c=function(t){throw new a(t)},s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=/[\t\n\f\r ]/g,h={encode:function(t){t=String(t),/[^\0-\xFF]/.test(t)&&c("The string to be encoded contains characters outside of the Latin1 range.");for(var e,o,r,n,i=t.length%3,a="",u=-1,h=t.length-i;++u<h;)e=t.charCodeAt(u)<<16,o=t.charCodeAt(++u)<<8,r=t.charCodeAt(++u),a+=s.charAt((n=e+o+r)>>18&63)+s.charAt(n>>12&63)+s.charAt(n>>6&63)+s.charAt(63&n);return 2==i?(e=t.charCodeAt(u)<<8,o=t.charCodeAt(++u),a+=s.charAt((n=e+o)>>10)+s.charAt(n>>4&63)+s.charAt(n<<2&63)+"="):1==i&&(n=t.charCodeAt(u),a+=s.charAt(n>>2)+s.charAt(n<<4&63)+"=="),a},decode:function(t){var e=(t=String(t).replace(u,"")).length;e%4==0&&(e=(t=t.replace(/==?$/,"")).length),(e%4==1||/[^+a-zA-Z0-9/]/.test(t))&&c("Invalid character: the string to be decoded is not correctly encoded.");for(var o,r,n=0,i="",a=-1;++a<e;)r=s.indexOf(t.charAt(a)),o=n%4?64*o+r:r,n++%4&&(i+=String.fromCharCode(255&o>>(-2*n&6)));return i},version:"0.1.0"};if(r&&!r.nodeType)if(n)n.exports=h;else for(var d in h)h.hasOwnProperty(d)&&(r[d]=h[d]);else o.base64=h}(M)}));function z(t){var e="";if("string"==typeof t)e=t;else for(var o=0;o<t.length;o++)e+=String.fromCharCode(t[o]);return E.encode(e)}function F(t,e,o,r,n,a,c){void 0===c&&(c=function(){}),void 0===a&&(a="png"),a=function(t){return"image/"+(t=t.toLowerCase().replace(/jpg/i,"jpeg")).match(/png|jpeg|bmp|gif/)[0]}(a),/bmp/.test(a)?function(t,e,o,r,n,a){i({canvasId:t,x:e,y:o,width:r,height:n,success:function(t){a(t,null)},fail:function(t){a(null,t)}})}(t,e,o,r,n,(function(t,e){var o=function(t){var e=t.width,o=t.height,r=e*o*3,n=r+54,i=[66,77,255&n,n>>8&255,n>>16&255,n>>24&255,0,0,0,0,54,0,0,0],a=[40,0,0,0,255&e,e>>8&255,e>>16&255,e>>24&255,255&o,o>>8&255,o>>16&255,o>>24&255,1,0,24,0,0,0,0,0,255&r,r>>8&255,r>>16&255,r>>24&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=(4-3*e%4)%4,s=t.data,u="",h=e<<2,d=o,p=String.fromCharCode;do{for(var l=h*(d-1),f="",g=0;g<e;g++){var v=g<<2;f+=p(s[l+v+2])+p(s[l+v+1])+p(s[l+v])}for(var y=0;y<c;y++)f+=String.fromCharCode(0);u+=f}while(--d);return z(i.concat(a))+z(u)}(t);A(c)&&c(function(t,e){return"data:"+e+";base64,"+t}(o,"image/"+a),e)})):console.error("暂不支持生成'"+a+"'类型的base64图片")}var X=function(t,e){return void 0===t&&(t={}),void 0===e&&(e=function(){}),F(t.canvasId,t.x,t.y,t.width,t.height,"bmp",e)};var Y={touchStart:function(t){var e=this,o=t.touches,r=o[0],n=o[1];e.src&&(S(e,!0,null,null),e.__oneTouchStart(r),t.touches.length>=2&&e.__twoTouchStart(r,n))},touchMove:function(t){var e=this,o=t.touches,r=o[0],n=o[1];e.src&&(S(e,null,!0),1===t.touches.length&&e.__oneTouchMove(r),t.touches.length>=2&&e.__twoTouchMove(r,n))},touchEnd:function(t){var e=this;e.src&&(S(e,!1,!1,!0),e.__xtouchEnd())}};var D=function(t){var e,o,r=this,n={};return e=r,o=W,Object.defineProperties(e,o),Object.keys(W).forEach((function(t){n[t]=W[t].default})),Object.assign(r,n,t),r.prepare(),r.attachPage(),r.createCtx(),r.observer(),r.cutt(),r.methods(),r.init(),r.update(),r};D.prototype.init=function(){var t=this,e=t.src;return t.version="1.3.9","function"==typeof t.onReady&&t.onReady(t.ctx,t),e?t.pushOrign(e):t.updateCanvas(),S(t,!1,!1,!1),t.oldScale=1,t.newScale=1,t},Object.assign(D.prototype,Y),D.prototype.prepare=function(){var t=this;t.attachPage=function(){var o=e(),r=o[o.length-1];Object.defineProperty(r,"wecropper",{get:function(){return console.warn("Instance will not be automatically bound to the page after v1.4.0\n\nPlease use a custom instance name instead\n\nExample: \nthis.mycropper = new WeCropper(options)\n\n// ...\nthis.mycropper.getCropperImage()"),t},configurable:!0})},t.createCtx=function(){var e=t.id,r=t.targetId;e?(t.ctx=t.ctx||o(e),t.targetCtx=t.targetCtx||o(r)):console.error("constructor: create canvas context failed, 'id' must be valuable")},t.deviceRadio=I/750},D.prototype.observer=function(){var
|