You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6 lines
12 KiB

/**
* we-cropper v1.3.7
* (c) 2019 dlhandsome
* @license MIT
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.WeCropper=e()}(this,function(){"use strict";var t=void 0,e=["touchstarted","touchmoved","touchended"];function r(n){for(var o=[],t=arguments.length-1;0<t--;)o[t]=arguments[t+1];e.forEach(function(t,e){void 0!==o[e]&&(n[t]=o[e])})}function n(){return t||(t=wx.getSystemInfoSync()),t}var o={},a={id:{default:"cropper",get:function(){return o.id},set:function(t){"string"!=typeof t&&console.error("id\uff1a"+t+" is invalid"),o.id=t}},width:{default:750,get:function(){return o.width},set:function(t){"number"!=typeof t&&console.error("width\uff1a"+t+" is invalid"),o.width=t}},height:{default:750,get:function(){return o.height},set:function(t){"number"!=typeof t&&console.error("height\uff1a"+t+" is invalid"),o.height=t}},pixelRatio:{default:n().pixelRatio,get:function(){return o.pixelRatio},set:function(t){"number"!=typeof t&&console.error("pixelRatio\uff1a"+t+" is invalid"),o.pixelRatio=t}},scale:{default:2.5,get:function(){return o.scale},set:function(t){"number"!=typeof t&&console.error("scale\uff1a"+t+" is invalid"),o.scale=t}},zoom:{default:5,get:function(){return o.zoom},set:function(t){"number"!=typeof t?console.error("zoom\uff1a"+t+" is invalid"):(t<0||10<t)&&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\uff1a"+t+" is invalid"),o.src=t}},cut:{default:{},get:function(){return o.cut},set:function(t){"object"!=typeof t&&console.error("cut\uff1a"+t+" is invalid"),o.cut=t}},boundStyle:{default:{},get:function(){return o.boundStyle},set:function(t){"object"!=typeof t&&console.error("boundStyle\uff1a"+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=n().windowWidth;var f="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function c(t,e){return t(e={exports:{}},e.exports),e.exports}var u=c(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 n=Object.prototype.toString;e.isPlainObject=function(t){return"[object Object]"===n.call(t)};var o=Object.prototype.hasOwnProperty;e.hasOwn=function(t,e){return o.call(t,e)},e.noop=function(t,e,n){},e.isValidArrayIndex=function(t){var e=parseFloat(String(t));return 0<=e&&Math.floor(e)===e&&isFinite(t)}}),l=u.isFunc,p=u.isPlainObject,s=["ready","beforeImageLoad","beforeDraw","imageLoad"];function d(r){return function(t){for(var o=[],e=arguments.length-1;0<e--;)o[e]=arguments[e+1];return void 0===t&&(t={}),new Promise(function(e,n){t.success=function(t){e(t)},t.fail=function(t){n(t)},r.apply(void 0,[t].concat(o))})}}var g=d(wx.getImageInfo),v=d(wx.canvasToTempFilePath),h=c(function(u,h){!function(t){var e=h,n=u&&u.exports==e&&u,o="object"==typeof f&&f;o.global!==o&&o.window!==o||(t=o);var r=function(t){this.message=t};(r.prototype=new Error).name="InvalidCharacterError";var s=function(t){throw new r(t)},d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=/[\t\n\f\r ]/g,a={encode:function(t){t=String(t),/[^\0-\xFF]/.test(t)&&s("The string to be encoded contains characters outside of the Latin1 range.");for(var e,n,o,r,a=t.length%3,i="",c=-1,u=t.length-a;++c<u;)e=t.charCodeAt(c)<<16,n=t.charCodeAt(++c)<<8,o=t.charCodeAt(++c),i+=d.charAt((r=e+n+o)>>18&63)+d.charAt(r>>12&63)+d.charAt(r>>6&63)+d.charAt(63&r);return 2==a?(