@idraw/renderer 0.3.0-alpha.3 → 0.3.0-alpha.4
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/index.cjs.js +1 -3
- package/dist/index.esm.js +1 -3
- package/dist/index.global.js +1 -3
- package/dist/index.global.min.js +1 -1
- package/package.json +4 -4
package/dist/index.cjs.js
CHANGED
|
@@ -275,7 +275,7 @@ var Image = window.Image;
|
|
|
275
275
|
function loadImage(src) {
|
|
276
276
|
return new Promise(function (resolve, reject) {
|
|
277
277
|
var img = new Image;
|
|
278
|
-
img.
|
|
278
|
+
img.crossOrigin = 'anonymous';
|
|
279
279
|
img.onload = function () {
|
|
280
280
|
resolve(img);
|
|
281
281
|
};
|
|
@@ -1261,9 +1261,7 @@ var Loader = (function () {
|
|
|
1261
1261
|
}
|
|
1262
1262
|
var maxParallelNum = this._opts.maxParallelNum;
|
|
1263
1263
|
var uuids = this._currentUUIDQueue.splice(0, maxParallelNum);
|
|
1264
|
-
var uuidMap = {};
|
|
1265
1264
|
uuids.forEach(function (url, i) {
|
|
1266
|
-
uuidMap[url] = i;
|
|
1267
1265
|
});
|
|
1268
1266
|
var loadUUIDList = [];
|
|
1269
1267
|
var _loadAction = function () {
|
package/dist/index.esm.js
CHANGED
|
@@ -273,7 +273,7 @@ var Image = window.Image;
|
|
|
273
273
|
function loadImage(src) {
|
|
274
274
|
return new Promise(function (resolve, reject) {
|
|
275
275
|
var img = new Image;
|
|
276
|
-
img.
|
|
276
|
+
img.crossOrigin = 'anonymous';
|
|
277
277
|
img.onload = function () {
|
|
278
278
|
resolve(img);
|
|
279
279
|
};
|
|
@@ -1259,9 +1259,7 @@ var Loader = (function () {
|
|
|
1259
1259
|
}
|
|
1260
1260
|
var maxParallelNum = this._opts.maxParallelNum;
|
|
1261
1261
|
var uuids = this._currentUUIDQueue.splice(0, maxParallelNum);
|
|
1262
|
-
var uuidMap = {};
|
|
1263
1262
|
uuids.forEach(function (url, i) {
|
|
1264
|
-
uuidMap[url] = i;
|
|
1265
1263
|
});
|
|
1266
1264
|
var loadUUIDList = [];
|
|
1267
1265
|
var _loadAction = function () {
|
package/dist/index.global.js
CHANGED
|
@@ -276,7 +276,7 @@ var iDrawRenderer = (function () {
|
|
|
276
276
|
function loadImage(src) {
|
|
277
277
|
return new Promise(function (resolve, reject) {
|
|
278
278
|
var img = new Image;
|
|
279
|
-
img.
|
|
279
|
+
img.crossOrigin = 'anonymous';
|
|
280
280
|
img.onload = function () {
|
|
281
281
|
resolve(img);
|
|
282
282
|
};
|
|
@@ -1262,9 +1262,7 @@ var iDrawRenderer = (function () {
|
|
|
1262
1262
|
}
|
|
1263
1263
|
var maxParallelNum = this._opts.maxParallelNum;
|
|
1264
1264
|
var uuids = this._currentUUIDQueue.splice(0, maxParallelNum);
|
|
1265
|
-
var uuidMap = {};
|
|
1266
1265
|
uuids.forEach(function (url, i) {
|
|
1267
|
-
uuidMap[url] = i;
|
|
1268
1266
|
});
|
|
1269
1267
|
var loadUUIDList = [];
|
|
1270
1268
|
var _loadAction = function () {
|
package/dist/index.global.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var iDrawRenderer=function(){'use strict';var t=function(e,o){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},t(e,o)};var e=function(){return e=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},e.apply(this,arguments)};function o(t,e,o,n){return new(o||(o=Promise))((function(r,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function n(t,e){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,n&&(r=2&i[0]?n.return:i[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{o=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function r(t){return'string'==typeof t&&/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)}function i(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return"".concat(t()).concat(t(),"-").concat(t(),"-").concat(t(),"-").concat(t(),"-").concat(t()).concat(t()).concat(t())}function s(t){return function t(e){var o,n=(o=e,Object.prototype.toString.call(o).replace(/[\]|\[]{1,1}/gi,'').split(' ')[1]);if(['Null','Number','String','Boolean','Undefined'].indexOf(n)>=0)return e;if('Array'===n){var r=[];return e.forEach((function(e){r.push(t(e))})),r}if('Object'===n){var i={};return Object.keys(e).forEach((function(o){i[o]=t(e[o])})),i}}(t)}function a(t){return(Object.prototype.toString.call(t)||'').replace(/(\[object|\])/gi,'').trim()}var u={type:function(t,e){var o=a(t);return!0===e?o.toLocaleLowerCase():o},array:function(t){return'Array'===a(t)},json:function(t){return'Object'===a(t)},function:function(t){return'Function'===a(t)},asyncFunction:function(t){return'AsyncFunction'===a(t)},string:function(t){return'String'===a(t)},number:function(t){return'Number'===a(t)},undefined:function(t){return'Undefined'===a(t)},null:function(t){return'Null'===a(t)},promise:function(t){return'Promise'===a(t)}},c=function(){return c=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},c.apply(this,arguments)};function l(t,e,o,n){return new(o||(o=Promise))((function(r,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function h(t,e){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,n&&(r=2&i[0]?n.return:i[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{o=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function f(t,e){var o=e.width,n=e.height;return new Promise((function(e,r){var i="\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"".concat(o||'',"\" height = \"").concat(n||'',"\">\n <foreignObject width=\"100%\" height=\"100%\">\n <div xmlns = \"http://www.w3.org/1999/xhtml\">\n ").concat(t,"\n </div>\n </foreignObject>\n </svg>\n "),s=new Blob([i],{type:'image/svg+xml;charset=utf-8'}),a=new FileReader;a.readAsDataURL(s),a.onload=function(t){var o,n=null===(o=null==t?void 0:t.target)||void 0===o?void 0:o.result;e(n)},a.onerror=function(t){r(t)}}))}function d(t){return new Promise((function(e,o){var n=new Blob([t],{type:'image/svg+xml;charset=utf-8'}),r=new FileReader;r.readAsDataURL(n),r.onload=function(t){var o,n=null===(o=null==t?void 0:t.target)||void 0===o?void 0:o.result;e(n)},r.onerror=function(t){o(t)}}))}var p=window.Image;function g(t){return new Promise((function(e,o){var n=new p;n.setAttribute('crossOrigin','anonymous'),n.onload=function(){e(n)},n.onabort=o,n.onerror=o,n.src=t}))}function _(t){return l(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,d(t)];case 1:return[4,g(e.sent())];case 2:return[2,e.sent()]}}))}))}function v(t,e){return l(this,void 0,void 0,(function(){return h(this,(function(o){switch(o.label){case 0:return[4,f(t=t.replace(/\&/gi,'&'),e)];case 1:return[4,g(o.sent())];case 2:return[2,o.sent()]}}))}))}var y=function(){function t(t,e){this._opts=e,this._ctx=t,this._transform={scale:1,scrollX:0,scrollY:0}}return t.prototype.getContext=function(){return this._ctx},t.prototype.resetSize=function(t){this._opts=c(c({},this._opts),t)},t.prototype.calcDeviceNum=function(t){return t*this._opts.devicePixelRatio},t.prototype.calcScreenNum=function(t){return t/this._opts.devicePixelRatio},t.prototype.getSize=function(){return{width:this._opts.width,height:this._opts.height,contextWidth:this._opts.contextWidth,contextHeight:this._opts.contextHeight,devicePixelRatio:this._opts.devicePixelRatio}},t.prototype.setTransform=function(t){this._transform=c(c({},this._transform),t)},t.prototype.getTransform=function(){return{scale:this._transform.scale,scrollX:this._transform.scrollX,scrollY:this._transform.scrollY}},t.prototype.setFillStyle=function(t){this._ctx.fillStyle=t},t.prototype.fill=function(t){return this._ctx.fill(t||'nonzero')},t.prototype.arc=function(t,e,o,n,r,i){return this._ctx.arc(this._doSize(t),this._doSize(e),this._doSize(o),n,r,i)},t.prototype.rect=function(t,e,o,n){return this._ctx.rect(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(n))},t.prototype.fillRect=function(t,e,o,n){return this._ctx.fillRect(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(n))},t.prototype.clearRect=function(t,e,o,n){return this._ctx.clearRect(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(n))},t.prototype.beginPath=function(){return this._ctx.beginPath()},t.prototype.closePath=function(){return this._ctx.closePath()},t.prototype.lineTo=function(t,e){return this._ctx.lineTo(this._doSize(t),this._doSize(e))},t.prototype.moveTo=function(t,e){return this._ctx.moveTo(this._doSize(t),this._doSize(e))},t.prototype.arcTo=function(t,e,o,n,r){return this._ctx.arcTo(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(n),this._doSize(r))},t.prototype.setLineWidth=function(t){return this._ctx.lineWidth=this._doSize(t)},t.prototype.setLineDash=function(t){var e=this;return this._ctx.setLineDash(t.map((function(t){return e._doSize(t)})))},t.prototype.isPointInPath=function(t,e){return this._ctx.isPointInPath(this._doX(t),this._doY(e))},t.prototype.isPointInPathWithoutScroll=function(t,e){return this._ctx.isPointInPath(this._doSize(t),this._doSize(e))},t.prototype.setStrokeStyle=function(t){this._ctx.strokeStyle=t},t.prototype.stroke=function(){return this._ctx.stroke()},t.prototype.translate=function(t,e){return this._ctx.translate(this._doSize(t),this._doSize(e))},t.prototype.rotate=function(t){return this._ctx.rotate(t)},t.prototype.drawImage=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var o=t[0],n=t[1],r=t[2],i=t[3],s=t[4],a=t[t.length-4],u=t[t.length-3],c=t[t.length-2],l=t[t.length-1];return 9===t.length?this._ctx.drawImage(o,this._doSize(n),this._doSize(r),this._doSize(i),this._doSize(s),this._doSize(a),this._doSize(u),this._doSize(c),this._doSize(l)):this._ctx.drawImage(o,this._doSize(a),this._doSize(u),this._doSize(c),this._doSize(l))},t.prototype.createPattern=function(t,e){return this._ctx.createPattern(t,e)},t.prototype.measureText=function(t){return this._ctx.measureText(t)},t.prototype.setTextAlign=function(t){this._ctx.textAlign=t},t.prototype.fillText=function(t,e,o,n){return void 0!==n?this._ctx.fillText(t,this._doSize(e),this._doSize(o),this._doSize(n)):this._ctx.fillText(t,this._doSize(e),this._doSize(o))},t.prototype.strokeText=function(t,e,o,n){return void 0!==n?this._ctx.strokeText(t,this._doSize(e),this._doSize(o),this._doSize(n)):this._ctx.strokeText(t,this._doSize(e),this._doSize(o))},t.prototype.setFont=function(t){var e=[];'bold'===t.fontWeight&&e.push("".concat(t.fontWeight)),e.push("".concat(this._doSize(t.fontSize||12),"px")),e.push("".concat(t.fontFamily||'sans-serif')),this._ctx.font="".concat(e.join(' '))},t.prototype.setTextBaseline=function(t){this._ctx.textBaseline=t},t.prototype.setGlobalAlpha=function(t){this._ctx.globalAlpha=t},t.prototype.save=function(){this._ctx.save()},t.prototype.restore=function(){this._ctx.restore()},t.prototype.scale=function(t,e){this._ctx.scale(t,e)},t.prototype.setShadowColor=function(t){this._ctx.shadowColor=t},t.prototype.setShadowOffsetX=function(t){this._ctx.shadowOffsetX=this._doSize(t)},t.prototype.setShadowOffsetY=function(t){this._ctx.shadowOffsetY=this._doSize(t)},t.prototype.setShadowBlur=function(t){this._ctx.shadowBlur=this._doSize(t)},t.prototype.ellipse=function(t,e,o,n,r,i,s,a){this._ctx.ellipse(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(n),r,i,s,a)},t.prototype._doSize=function(t){return this._opts.devicePixelRatio*t},t.prototype._doX=function(t){var e=this._transform,o=e.scale,n=(t-e.scrollX)/o;return this._doSize(n)},t.prototype._doY=function(t){var e=this._transform,o=e.scale,n=(t-e.scrollY)/o;return this._doSize(n)},t}();function m(t){return'number'==typeof t&&(t>0||t<=0)}function w(t){return'number'==typeof t&&t>=0}function x(t){return'string'==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test("".concat(t))}function S(t){return'string'==typeof t&&/^(data:image\/)/.test("".concat(t))}var b={x:function(t){return m(t)},y:function(t){return m(t)},w:w,h:function(t){return'number'==typeof t&&t>=0},angle:function(t){return'number'==typeof t&&t>=-360&&t<=360},number:m,borderWidth:function(t){return w(t)},borderRadius:function(t){return m(t)&&t>=0},color:function(t){return r(t)},imageSrc:function(t){return S(t)||x(t)},imageURL:x,imageBase64:S,svg:function(t){return'string'==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test("".concat(t).trim())&&/<\/[\s]{0,}svg>$/i.test("".concat(t).trim())},html:function(t){var e=!1;if('string'==typeof t){var o=document.createElement('div');o.innerHTML=t,o.children.length>0&&(e=!0),o=null}return e},text:function(t){return'string'==typeof t},fontSize:function(t){return m(t)&&t>0},lineHeight:function(t){return m(t)&&t>0},textAlign:function(t){return['center','left','right'].includes(t)},fontFamily:function(t){return'string'==typeof t&&t.length>0},fontWeight:function(t){return['bold'].includes(t)},strokeWidth:function(t){return m(t)&&t>0}};function z(t){void 0===t&&(t={});var e=t.borderColor,o=t.borderRadius,n=t.borderWidth;return!(t.hasOwnProperty('borderColor')&&!b.color(e))&&(!(t.hasOwnProperty('borderRadius')&&!b.number(o))&&!(t.hasOwnProperty('borderWidth')&&!b.number(n)))}var L={attrs:function(t){var e=t.x,o=t.y,n=t.w,r=t.h,i=t.angle;return!!(b.x(e)&&b.y(o)&&b.w(n)&&b.h(r)&&b.angle(i))&&(i>=-360&&i<=360)},textDesc:function(t){var e=t.text,o=t.color,n=t.fontSize,r=t.lineHeight,i=t.fontFamily,s=t.textAlign,a=t.fontWeight,u=t.bgColor,c=t.strokeWidth,l=t.strokeColor;return!!b.text(e)&&(!!b.color(o)&&(!!b.fontSize(n)&&(!(t.hasOwnProperty('bgColor')&&!b.color(u))&&(!(t.hasOwnProperty('fontWeight')&&!b.fontWeight(a))&&(!(t.hasOwnProperty('lineHeight')&&!b.lineHeight(r))&&(!(t.hasOwnProperty('fontFamily')&&!b.fontFamily(i))&&(!(t.hasOwnProperty('textAlign')&&!b.textAlign(s))&&(!(t.hasOwnProperty('strokeWidth')&&!b.strokeWidth(c))&&(!(t.hasOwnProperty('strokeColor')&&!b.color(l))&&!!z(t))))))))))},rectDesc:function(t){var e=t.bgColor;return!(t.hasOwnProperty('bgColor')&&!b.color(e))&&!!z(t)},circleDesc:function(t){var e=t.bgColor,o=t.borderColor,n=t.borderWidth;return!(t.hasOwnProperty('bgColor')&&!b.color(e))&&(!(t.hasOwnProperty('borderColor')&&!b.color(o))&&!(t.hasOwnProperty('borderWidth')&&!b.number(n)))},imageDesc:function(t){var e=t.src;return!!b.imageSrc(e)},svgDesc:function(t){var e=t.svg;return!!b.svg(e)},htmlDesc:function(t){var e=t.html;return!!b.html(e)}};function D(t,e,o){var n=function(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}(e),r=function(t){return t/180*Math.PI}(e.angle||0);return function(t,e,o,n){e&&(o>0||o<0)&&(t.translate(e.x,e.y),t.rotate(o),t.translate(-e.x,-e.y));n(t),e&&(o>0||o<0)&&(t.translate(e.x,e.y),t.rotate(-o),t.translate(-e.x,-e.y))}(t,n,r||0,o)}function E(t){t.setFillStyle('#000000'),t.setStrokeStyle('#000000'),t.setLineDash([]),t.setGlobalAlpha(1),t.setShadowColor('#00000000'),t.setShadowOffsetX(0),t.setShadowOffsetY(0),t.setShadowBlur(0)}function O(t,e,o){E(t),function(t,e){E(t),D(t,e,(function(){if(e.desc.borderWidth&&e.desc.borderWidth>0){var o=e.desc.borderWidth,n='#000000';!0===r(e.desc.borderColor)&&(n=e.desc.borderColor);var i=e.x-o/2,s=e.y-o/2,a=e.w+o,u=e.h+o,c=e.desc.borderRadius||0;(c=Math.min(c,a/2,u/2))<a/2&&c<u/2&&(c+=o/2);var l=e.desc;void 0!==l.shadowColor&&r(l.shadowColor)&&t.setShadowColor(l.shadowColor),void 0!==l.shadowOffsetX&&b.number(l.shadowOffsetX)&&t.setShadowOffsetX(l.shadowOffsetX),void 0!==l.shadowOffsetY&&b.number(l.shadowOffsetY)&&t.setShadowOffsetY(l.shadowOffsetY),void 0!==l.shadowBlur&&b.number(l.shadowBlur)&&t.setShadowBlur(l.shadowBlur),t.beginPath(),t.setLineWidth(o),t.setStrokeStyle(n),t.moveTo(i+c,s),t.arcTo(i+a,s,i+a,s+u,c),t.arcTo(i+a,s+u,i,s+u,c),t.arcTo(i,s+u,i,s,c),t.arcTo(i,s,i+a,s,c),t.closePath(),t.stroke()}}))}(t,e),E(t),D(t,e,(function(){var n=e.x,r=e.y,i=e.w,s=e.h,a=e.desc.borderRadius||0;(i<2*(a=Math.min(a,i/2,s/2))||s<2*a)&&(a=0),t.beginPath(),t.moveTo(n+a,r),t.arcTo(n+i,r,n+i,r+s,a),t.arcTo(n+i,r+s,n,r+s,a),t.arcTo(n,r+s,n,r,a),t.arcTo(n,r,n+i,r,a),t.closePath(),('string'==typeof o||['CanvasPattern'].includes(u.type(o)))&&t.setFillStyle(o),t.fill()}))}function P(t,e){O(t,e,e.desc.bgColor)}function C(t,e,o){var n=o.getContent(e.uuid);D(t,e,(function(){n&&t.drawImage(n,e.x,e.y,e.w,e.h)}))}function k(t,e,o){var n=o.getContent(e.uuid);D(t,e,(function(){n&&t.drawImage(n,e.x,e.y,e.w,e.h)}))}function T(t,e,o){var n=o.getContent(e.uuid);D(t,e,(function(){n&&t.drawImage(n,e.x,e.y,e.w,e.h)}))}function W(t,o,n){E(t),O(t,o,o.desc.bgColor||'transparent'),D(t,o,(function(){var n=e({fontSize:12,fontFamily:'sans-serif',textAlign:'center'},o.desc);t.setFillStyle(o.desc.color),t.setTextBaseline('top'),t.setFont({fontWeight:n.fontWeight,fontSize:n.fontSize,fontFamily:n.fontFamily});var i=n.text.replace(/\r\n/gi,'\n'),s=n.lineHeight||n.fontSize,a=i.split('\n'),u=[],c=0;a.forEach((function(e,n){var r='';if(e.length>0){for(var i=0;i<e.length&&(t.measureText(r+(e[i]||'')).width<t.calcDeviceNum(o.w)?r+=e[i]||'':(u.push({text:r,width:t.calcScreenNum(t.measureText(r).width)}),r=e[i]||'',c++),!((c+1)*s>o.h));i++)if(e.length-1===i&&(c+1)*s<o.h){u.push({text:r,width:t.calcScreenNum(t.measureText(r).width)}),n<a.length-1&&c++;break}}else u.push({text:'',width:0})}));var l=o.y;if(u.length*s<o.h&&(l+=(o.h-u.length*s)/2),void 0!==n.textShadowColor&&r(n.textShadowColor)&&t.setShadowColor(n.textShadowColor),void 0!==n.textShadowOffsetX&&b.number(n.textShadowOffsetX)&&t.setShadowOffsetX(n.textShadowOffsetX),void 0!==n.textShadowOffsetY&&b.number(n.textShadowOffsetY)&&t.setShadowOffsetY(n.textShadowOffsetY),void 0!==n.textShadowBlur&&b.number(n.textShadowBlur)&&t.setShadowBlur(n.textShadowBlur),u.forEach((function(e,r){var i=o.x;'center'===n.textAlign?i=o.x+(o.w-e.width)/2:'right'===n.textAlign&&(i=o.x+(o.w-e.width)),t.fillText(e.text,i,l+s*r)})),E(t),r(n.strokeColor)&&void 0!==n.strokeWidth&&n.strokeWidth>0){var h=o.y;u.length*s<o.h&&(h+=(o.h-u.length*s)/2),u.forEach((function(e,r){var i=o.x;'center'===n.textAlign?i=o.x+(o.w-e.width)/2:'right'===n.textAlign&&(i=o.x+(o.w-e.width)),void 0!==n.strokeColor&&t.setStrokeStyle(n.strokeColor),void 0!==n.strokeWidth&&n.strokeWidth>0&&t.setLineWidth(n.strokeWidth),t.strokeText(e.text,i,h+s*r)}))}}))}function R(t,e){E(t),D(t,e,(function(t){var o=e.x,n=e.y,r=e.w,i=e.h,s=e.desc,a=s.bgColor,u=void 0===a?'#000000':a,c=s.borderColor,l=void 0===c?'#000000':c,h=s.borderWidth,f=void 0===h?0:h,d=r/2,p=i/2,g=o+d,_=n+p;if(f&&f>0){var v=f/2+d,y=f/2+p;t.beginPath(),t.setStrokeStyle(l),t.setLineWidth(f),t.ellipse(g,_,v,y,0,0,2*Math.PI),t.closePath(),t.stroke()}t.beginPath(),t.setFillStyle(u),t.ellipse(g,_,d,p,0,0,2*Math.PI),t.closePath(),t.fill()}))}function F(t,e,o){var n;E(t);var i=t.getSize();if(t.clearRect(0,0,i.contextWidth,i.contextHeight),'string'==typeof e.bgColor&&r(e.bgColor)&&function(t,e){var o=t.getSize();t.setFillStyle(e),t.fillRect(0,0,o.contextWidth,o.contextHeight)}(t,e.bgColor),e.elements.length>0)for(var s=0;s<e.elements.length;s++){var a=e.elements[s];if(!0!==(null===(n=null==a?void 0:a.operation)||void 0===n?void 0:n.invisible))switch(a.type){case'rect':P(t,a);break;case'text':W(t,a);break;case'image':C(t,a,o);break;case'svg':k(t,a,o);break;case'html':T(t,a,o);break;case'circle':R(t,a)}}}Object.freeze({__proto__:null,is:b,check:L,delay:function(t){return new Promise((function(e){setTimeout((function(){e()}),t)}))},compose:function(t){return function(e,o){return function n(r){var i=t[r];r===t.length&&o&&(i=o);if(!i)return Promise.resolve();try{return Promise.resolve(i(e,n.bind(null,r+1)))}catch(t){return Promise.reject(t)}}(0)}},throttle:function(t,e){var o=-1;return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];o>0||(o=setTimeout((function(){t.apply(void 0,n),o=-1}),e))}},loadImage:g,loadSVG:_,loadHTML:v,downloadImageFromCanvas:function(t,e){var o=e.filename,n=e.type,r=void 0===n?'image/jpeg':n,i=t.toDataURL(r),s=document.createElement('a');s.href=i,s.download=o;var a=document.createEvent('MouseEvents');a.initEvent('click',!0,!1),s.dispatchEvent(a)},toColorHexStr:function(t){return'#'+t.toString(16)},toColorHexNum:function(t){return parseInt(t.replace(/^\#/,'0x'))},isColorStr:r,createUUID:i,istype:u,deepClone:s,Context:y});var A,I=function(){function t(){this._listeners=new Map}return t.prototype.on=function(t,e){if(this._listeners.has(t)){var o=this._listeners.get(t);null==o||o.push(e),this._listeners.set(t,o||[])}else this._listeners.set(t,[e])},t.prototype.off=function(t,e){if(this._listeners.has(t)){var o=this._listeners.get(t);if(Array.isArray(o))for(var n=0;n<(null==o?void 0:o.length);n++)if(o[n]===e){o.splice(n,1);break}this._listeners.set(t,o||[])}},t.prototype.trigger=function(t,e){var o=this._listeners.get(t);return!!Array.isArray(o)&&(o.forEach((function(t){t(e)})),!0)},t.prototype.has=function(t){if(this._listeners.has(t)){var e=this._listeners.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1},t}();!function(t){t.FREE="free",t.LOADING="loading",t.COMPLETE="complete"}(A||(A={}));var H,j,U,N,B=function(){function t(t){this._currentLoadData={},this._currentUUIDQueue=[],this._storageLoadData={},this._status=A.FREE,this._waitingLoadQueue=[],this._opts=t,this._event=new I,this._waitingLoadQueue=[]}return t.prototype.load=function(t,e){var o=this._resetLoadData(t,e),n=o[0],r=o[1];this._status===A.FREE||this._status===A.COMPLETE?(this._currentUUIDQueue=n,this._currentLoadData=r,this._loadTask()):this._status===A.LOADING&&n.length>0&&this._waitingLoadQueue.push({uuidQueue:n,loadData:r})},t.prototype.on=function(t,e){this._event.on(t,e)},t.prototype.off=function(t,e){this._event.off(t,e)},t.prototype.isComplete=function(){return this._status===A.COMPLETE},t.prototype.getContent=function(t){var e;return'loaded'===(null===(e=this._storageLoadData[t])||void 0===e?void 0:e.status)?this._storageLoadData[t].content:null},t.prototype._resetLoadData=function(t,e){for(var o={},n=[],r=this._storageLoadData,i=t.elements.length-1;i>=0;i--){var s=t.elements[i];['image','svg','html'].includes(s.type)&&(r[s.uuid]?e.includes(s.uuid)&&(o[s.uuid]=this._createEmptyLoadItem(s),n.push(s.uuid)):(o[s.uuid]=this._createEmptyLoadItem(s),n.push(s.uuid)))}return[n,o]},t.prototype._createEmptyLoadItem=function(t){var e='',o=t.type,n=t.w,r=t.h;if('image'===t.type)e=(i=t).desc.src||'';else if('svg'===t.type){e=(i=t).desc.svg||''}else if('html'===t.type){var i;e=function(t){return t.replace(/<script[\s\S]*?<\/script>/gi,'')}((i=t).desc.html||''),n=i.desc.width||t.w,r=i.desc.height||t.h}return{uuid:t.uuid,type:o,status:'null',content:null,source:e,elemW:n,elemH:r,element:s(t)}},t.prototype._loadTask=function(){var t=this;if(this._status!==A.LOADING){if(this._status=A.LOADING,0===this._currentUUIDQueue.length){if(0===this._waitingLoadQueue.length)return this._status=A.COMPLETE,void this._event.trigger('complete',void 0);var e=this._waitingLoadQueue.shift();if(e){var o=e.uuidQueue,n=e.loadData;this._currentLoadData=n,this._currentUUIDQueue=o}}var r=this._opts.maxParallelNum,i=this._currentUUIDQueue.splice(0,r),s={};i.forEach((function(t,e){s[t]=e}));var a=[],u=function(){if(a.length>=r)return!1;if(0===i.length)return!0;for(var e=function(e){var o=i.shift();if(void 0===o)return"break";a.push(o),t._loadElementSource(t._currentLoadData[o]).then((function(e){var n,r;a.splice(a.indexOf(o),1);var s=u();t._storageLoadData[o]={uuid:o,type:t._currentLoadData[o].type,status:'loaded',content:e,source:t._currentLoadData[o].source,elemW:t._currentLoadData[o].elemW,elemH:t._currentLoadData[o].elemH,element:t._currentLoadData[o].element},0===a.length&&0===i.length&&!0===s&&(t._status=A.FREE,t._loadTask()),t._event.trigger('load',{uuid:null===(n=t._storageLoadData[o])||void 0===n?void 0:n.uuid,type:t._storageLoadData[o].type,status:t._storageLoadData[o].status,content:t._storageLoadData[o].content,source:t._storageLoadData[o].source,elemW:t._storageLoadData[o].elemW,elemH:t._storageLoadData[o].elemH,element:null===(r=t._storageLoadData[o])||void 0===r?void 0:r.element})})).catch((function(e){var n,r,s,c,l,h,f,d,p,g,_,v;console.warn(e),a.splice(a.indexOf(o),1);var y=u();t._currentLoadData[o]&&(t._storageLoadData[o]={uuid:o,type:null===(n=t._currentLoadData[o])||void 0===n?void 0:n.type,status:'fail',content:null,error:e,source:null===(r=t._currentLoadData[o])||void 0===r?void 0:r.source,elemW:null===(s=t._currentLoadData[o])||void 0===s?void 0:s.elemW,elemH:null===(c=t._currentLoadData[o])||void 0===c?void 0:c.elemH,element:null===(l=t._currentLoadData[o])||void 0===l?void 0:l.element}),0===a.length&&0===i.length&&!0===y&&(t._status=A.FREE,t._loadTask()),t._currentLoadData[o]&&t._event.trigger('error',{uuid:o,type:null===(h=t._storageLoadData[o])||void 0===h?void 0:h.type,status:null===(f=t._storageLoadData[o])||void 0===f?void 0:f.status,content:null===(d=t._storageLoadData[o])||void 0===d?void 0:d.content,source:null===(p=t._storageLoadData[o])||void 0===p?void 0:p.source,elemW:null===(g=t._storageLoadData[o])||void 0===g?void 0:g.elemW,elemH:null===(_=t._storageLoadData[o])||void 0===_?void 0:_.elemH,element:null===(v=t._storageLoadData[o])||void 0===v?void 0:v.element})}))},o=a.length;o<r;o++){if("break"===e())break}return!1};u()}},t.prototype._loadElementSource=function(t){return o(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return t&&'image'===t.type?[4,g(t.source)]:[3,2];case 1:case 3:case 5:return[2,e.sent()];case 2:return t&&'svg'===t.type?[4,_(t.source)]:[3,4];case 4:return t&&'html'===t.type?[4,v(t.source,{width:t.elemW,height:t.elemH})]:[3,6];case 6:throw Error('Element\'s source is not support!')}}))}))},t}(),X=function(){function t(){this._listeners=new Map}return t.prototype.on=function(t,e){if(this._listeners.has(t)){var o=this._listeners.get(t);null==o||o.push(e),this._listeners.set(t,o||[])}else this._listeners.set(t,[e])},t.prototype.off=function(t,e){if(this._listeners.has(t)){var o=this._listeners.get(t);if(Array.isArray(o))for(var n=0;n<(null==o?void 0:o.length);n++)if(o[n]===e){o.splice(n,1);break}this._listeners.set(t,o||[])}},t.prototype.trigger=function(t,e){var o=this._listeners.get(t);return!!Array.isArray(o)&&(o.forEach((function(t){t(e)})),!0)},t.prototype.has=function(t){if(this._listeners.has(t)){var e=this._listeners.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1},t}(),Y=Symbol('_queue'),M=Symbol('_ctx'),Q=Symbol('_status'),G=Symbol('_loader'),Z=Symbol('_opts'),q=Symbol('_freeze'),$=Symbol('_drawFrame'),V=Symbol('_retainQueueOneItem'),J=window.requestAnimationFrame;!function(t){t.NULL="null",t.FREE="free",t.DRAWING="drawing",t.FREEZE="freeze"}(N||(N={}));var K=function(e){function o(t){var o=e.call(this)||this;return o[H]=[],o[j]=null,o[U]=N.NULL,o[Z]=t,o[G]=new B({maxParallelNum:6}),o[G].on('load',(function(t){o[$](),o.trigger('load',{element:t.element})})),o[G].on('error',(function(t){o.trigger('error',{element:t.element,error:t.error})})),o[G].on('complete',(function(){o.trigger('loadComplete',{t:Date.now()})})),o}return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function n(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}(o,e),o.prototype.render=function(t,e,o){var n=(o||{}).changeResourceUUIDs,r=void 0===n?[]:n;this[Q]=N.FREE;var a=s(e);if(Array.isArray(a.elements)&&a.elements.forEach((function(t){'string'==typeof t.uuid&&t.uuid||(t.uuid=i())})),!this[M])if(this[Z]&&'[object HTMLCanvasElement]'===Object.prototype.toString.call(t)){var u=this[Z],c=u.width,l=u.height,h=u.contextWidth,f=u.contextHeight,d=u.devicePixelRatio,p=t;p.width=c*d,p.height=l*d;var g=p.getContext('2d');this[M]=new y(g,{width:c,height:l,contextWidth:h||c,contextHeight:f||l,devicePixelRatio:d})}else t&&(this[M]=t);if(![N.FREEZE].includes(this[Q])){var _=s({data:a});this[Y].push(_),this[$](),this[G].load(a,r||[])}},o.prototype.getContext=function(){return this[M]},o.prototype.thaw=function(){this[Q]=N.FREE},o.prototype[(H=Y,j=M,U=Q,q)]=function(){this[Q]=N.FREEZE},o.prototype[$]=function(){var t=this;this[Q]!==N.FREEZE&&J((function(){if(t[Q]!==N.FREEZE){var e=t[M],o=t[Y][0],n=!1;t[Y].length>1?o=t[Y].shift():n=!0,!0!==t[G].isComplete()?(t[$](),o&&e&&F(e,o.data,t[G])):o&&e?(F(e,o.data,t[G]),t[V](),n?t[Q]=N.FREE:t[$]()):t[Q]=N.FREE,t.trigger('drawFrame',{t:Date.now()}),!0===t[G].isComplete()&&1===t[Y].length&&t[Q]===N.FREE&&(e&&t[Y][0]&&t[Y][0].data&&F(e,t[Y][0].data,t[G]),t.trigger('drawFrameComplete',{t:Date.now()}),t[q]())}}))},o.prototype[V]=function(){if(!(this[Y].length<=1)){var t=s(this[Y][this[Y].length-1]);this[Y]=[t]}},o}(X);return Object.freeze({__proto__:null,Renderer:K})}();
|
|
1
|
+
var iDrawRenderer=function(){'use strict';var t=function(e,o){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},t(e,o)};var e=function(){return e=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},e.apply(this,arguments)};function o(t,e,o,n){return new(o||(o=Promise))((function(r,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function n(t,e){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,n&&(r=2&i[0]?n.return:i[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{o=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function r(t){return'string'==typeof t&&/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)}function i(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return"".concat(t()).concat(t(),"-").concat(t(),"-").concat(t(),"-").concat(t(),"-").concat(t()).concat(t()).concat(t())}function s(t){return function t(e){var o,n=(o=e,Object.prototype.toString.call(o).replace(/[\]|\[]{1,1}/gi,'').split(' ')[1]);if(['Null','Number','String','Boolean','Undefined'].indexOf(n)>=0)return e;if('Array'===n){var r=[];return e.forEach((function(e){r.push(t(e))})),r}if('Object'===n){var i={};return Object.keys(e).forEach((function(o){i[o]=t(e[o])})),i}}(t)}function a(t){return(Object.prototype.toString.call(t)||'').replace(/(\[object|\])/gi,'').trim()}var u={type:function(t,e){var o=a(t);return!0===e?o.toLocaleLowerCase():o},array:function(t){return'Array'===a(t)},json:function(t){return'Object'===a(t)},function:function(t){return'Function'===a(t)},asyncFunction:function(t){return'AsyncFunction'===a(t)},string:function(t){return'String'===a(t)},number:function(t){return'Number'===a(t)},undefined:function(t){return'Undefined'===a(t)},null:function(t){return'Null'===a(t)},promise:function(t){return'Promise'===a(t)}},c=function(){return c=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},c.apply(this,arguments)};function l(t,e,o,n){return new(o||(o=Promise))((function(r,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function h(t,e){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,n&&(r=2&i[0]?n.return:i[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{o=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function f(t,e){var o=e.width,n=e.height;return new Promise((function(e,r){var i="\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"".concat(o||'',"\" height = \"").concat(n||'',"\">\n <foreignObject width=\"100%\" height=\"100%\">\n <div xmlns = \"http://www.w3.org/1999/xhtml\">\n ").concat(t,"\n </div>\n </foreignObject>\n </svg>\n "),s=new Blob([i],{type:'image/svg+xml;charset=utf-8'}),a=new FileReader;a.readAsDataURL(s),a.onload=function(t){var o,n=null===(o=null==t?void 0:t.target)||void 0===o?void 0:o.result;e(n)},a.onerror=function(t){r(t)}}))}function d(t){return new Promise((function(e,o){var n=new Blob([t],{type:'image/svg+xml;charset=utf-8'}),r=new FileReader;r.readAsDataURL(n),r.onload=function(t){var o,n=null===(o=null==t?void 0:t.target)||void 0===o?void 0:o.result;e(n)},r.onerror=function(t){o(t)}}))}var p=window.Image;function g(t){return new Promise((function(e,o){var n=new p;n.crossOrigin='anonymous',n.onload=function(){e(n)},n.onabort=o,n.onerror=o,n.src=t}))}function _(t){return l(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,d(t)];case 1:return[4,g(e.sent())];case 2:return[2,e.sent()]}}))}))}function v(t,e){return l(this,void 0,void 0,(function(){return h(this,(function(o){switch(o.label){case 0:return[4,f(t=t.replace(/\&/gi,'&'),e)];case 1:return[4,g(o.sent())];case 2:return[2,o.sent()]}}))}))}var y=function(){function t(t,e){this._opts=e,this._ctx=t,this._transform={scale:1,scrollX:0,scrollY:0}}return t.prototype.getContext=function(){return this._ctx},t.prototype.resetSize=function(t){this._opts=c(c({},this._opts),t)},t.prototype.calcDeviceNum=function(t){return t*this._opts.devicePixelRatio},t.prototype.calcScreenNum=function(t){return t/this._opts.devicePixelRatio},t.prototype.getSize=function(){return{width:this._opts.width,height:this._opts.height,contextWidth:this._opts.contextWidth,contextHeight:this._opts.contextHeight,devicePixelRatio:this._opts.devicePixelRatio}},t.prototype.setTransform=function(t){this._transform=c(c({},this._transform),t)},t.prototype.getTransform=function(){return{scale:this._transform.scale,scrollX:this._transform.scrollX,scrollY:this._transform.scrollY}},t.prototype.setFillStyle=function(t){this._ctx.fillStyle=t},t.prototype.fill=function(t){return this._ctx.fill(t||'nonzero')},t.prototype.arc=function(t,e,o,n,r,i){return this._ctx.arc(this._doSize(t),this._doSize(e),this._doSize(o),n,r,i)},t.prototype.rect=function(t,e,o,n){return this._ctx.rect(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(n))},t.prototype.fillRect=function(t,e,o,n){return this._ctx.fillRect(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(n))},t.prototype.clearRect=function(t,e,o,n){return this._ctx.clearRect(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(n))},t.prototype.beginPath=function(){return this._ctx.beginPath()},t.prototype.closePath=function(){return this._ctx.closePath()},t.prototype.lineTo=function(t,e){return this._ctx.lineTo(this._doSize(t),this._doSize(e))},t.prototype.moveTo=function(t,e){return this._ctx.moveTo(this._doSize(t),this._doSize(e))},t.prototype.arcTo=function(t,e,o,n,r){return this._ctx.arcTo(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(n),this._doSize(r))},t.prototype.setLineWidth=function(t){return this._ctx.lineWidth=this._doSize(t)},t.prototype.setLineDash=function(t){var e=this;return this._ctx.setLineDash(t.map((function(t){return e._doSize(t)})))},t.prototype.isPointInPath=function(t,e){return this._ctx.isPointInPath(this._doX(t),this._doY(e))},t.prototype.isPointInPathWithoutScroll=function(t,e){return this._ctx.isPointInPath(this._doSize(t),this._doSize(e))},t.prototype.setStrokeStyle=function(t){this._ctx.strokeStyle=t},t.prototype.stroke=function(){return this._ctx.stroke()},t.prototype.translate=function(t,e){return this._ctx.translate(this._doSize(t),this._doSize(e))},t.prototype.rotate=function(t){return this._ctx.rotate(t)},t.prototype.drawImage=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var o=t[0],n=t[1],r=t[2],i=t[3],s=t[4],a=t[t.length-4],u=t[t.length-3],c=t[t.length-2],l=t[t.length-1];return 9===t.length?this._ctx.drawImage(o,this._doSize(n),this._doSize(r),this._doSize(i),this._doSize(s),this._doSize(a),this._doSize(u),this._doSize(c),this._doSize(l)):this._ctx.drawImage(o,this._doSize(a),this._doSize(u),this._doSize(c),this._doSize(l))},t.prototype.createPattern=function(t,e){return this._ctx.createPattern(t,e)},t.prototype.measureText=function(t){return this._ctx.measureText(t)},t.prototype.setTextAlign=function(t){this._ctx.textAlign=t},t.prototype.fillText=function(t,e,o,n){return void 0!==n?this._ctx.fillText(t,this._doSize(e),this._doSize(o),this._doSize(n)):this._ctx.fillText(t,this._doSize(e),this._doSize(o))},t.prototype.strokeText=function(t,e,o,n){return void 0!==n?this._ctx.strokeText(t,this._doSize(e),this._doSize(o),this._doSize(n)):this._ctx.strokeText(t,this._doSize(e),this._doSize(o))},t.prototype.setFont=function(t){var e=[];'bold'===t.fontWeight&&e.push("".concat(t.fontWeight)),e.push("".concat(this._doSize(t.fontSize||12),"px")),e.push("".concat(t.fontFamily||'sans-serif')),this._ctx.font="".concat(e.join(' '))},t.prototype.setTextBaseline=function(t){this._ctx.textBaseline=t},t.prototype.setGlobalAlpha=function(t){this._ctx.globalAlpha=t},t.prototype.save=function(){this._ctx.save()},t.prototype.restore=function(){this._ctx.restore()},t.prototype.scale=function(t,e){this._ctx.scale(t,e)},t.prototype.setShadowColor=function(t){this._ctx.shadowColor=t},t.prototype.setShadowOffsetX=function(t){this._ctx.shadowOffsetX=this._doSize(t)},t.prototype.setShadowOffsetY=function(t){this._ctx.shadowOffsetY=this._doSize(t)},t.prototype.setShadowBlur=function(t){this._ctx.shadowBlur=this._doSize(t)},t.prototype.ellipse=function(t,e,o,n,r,i,s,a){this._ctx.ellipse(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(n),r,i,s,a)},t.prototype._doSize=function(t){return this._opts.devicePixelRatio*t},t.prototype._doX=function(t){var e=this._transform,o=e.scale,n=(t-e.scrollX)/o;return this._doSize(n)},t.prototype._doY=function(t){var e=this._transform,o=e.scale,n=(t-e.scrollY)/o;return this._doSize(n)},t}();function m(t){return'number'==typeof t&&(t>0||t<=0)}function w(t){return'number'==typeof t&&t>=0}function x(t){return'string'==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test("".concat(t))}function S(t){return'string'==typeof t&&/^(data:image\/)/.test("".concat(t))}var b={x:function(t){return m(t)},y:function(t){return m(t)},w:w,h:function(t){return'number'==typeof t&&t>=0},angle:function(t){return'number'==typeof t&&t>=-360&&t<=360},number:m,borderWidth:function(t){return w(t)},borderRadius:function(t){return m(t)&&t>=0},color:function(t){return r(t)},imageSrc:function(t){return S(t)||x(t)},imageURL:x,imageBase64:S,svg:function(t){return'string'==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test("".concat(t).trim())&&/<\/[\s]{0,}svg>$/i.test("".concat(t).trim())},html:function(t){var e=!1;if('string'==typeof t){var o=document.createElement('div');o.innerHTML=t,o.children.length>0&&(e=!0),o=null}return e},text:function(t){return'string'==typeof t},fontSize:function(t){return m(t)&&t>0},lineHeight:function(t){return m(t)&&t>0},textAlign:function(t){return['center','left','right'].includes(t)},fontFamily:function(t){return'string'==typeof t&&t.length>0},fontWeight:function(t){return['bold'].includes(t)},strokeWidth:function(t){return m(t)&&t>0}};function z(t){void 0===t&&(t={});var e=t.borderColor,o=t.borderRadius,n=t.borderWidth;return!(t.hasOwnProperty('borderColor')&&!b.color(e))&&(!(t.hasOwnProperty('borderRadius')&&!b.number(o))&&!(t.hasOwnProperty('borderWidth')&&!b.number(n)))}var L={attrs:function(t){var e=t.x,o=t.y,n=t.w,r=t.h,i=t.angle;return!!(b.x(e)&&b.y(o)&&b.w(n)&&b.h(r)&&b.angle(i))&&(i>=-360&&i<=360)},textDesc:function(t){var e=t.text,o=t.color,n=t.fontSize,r=t.lineHeight,i=t.fontFamily,s=t.textAlign,a=t.fontWeight,u=t.bgColor,c=t.strokeWidth,l=t.strokeColor;return!!b.text(e)&&(!!b.color(o)&&(!!b.fontSize(n)&&(!(t.hasOwnProperty('bgColor')&&!b.color(u))&&(!(t.hasOwnProperty('fontWeight')&&!b.fontWeight(a))&&(!(t.hasOwnProperty('lineHeight')&&!b.lineHeight(r))&&(!(t.hasOwnProperty('fontFamily')&&!b.fontFamily(i))&&(!(t.hasOwnProperty('textAlign')&&!b.textAlign(s))&&(!(t.hasOwnProperty('strokeWidth')&&!b.strokeWidth(c))&&(!(t.hasOwnProperty('strokeColor')&&!b.color(l))&&!!z(t))))))))))},rectDesc:function(t){var e=t.bgColor;return!(t.hasOwnProperty('bgColor')&&!b.color(e))&&!!z(t)},circleDesc:function(t){var e=t.bgColor,o=t.borderColor,n=t.borderWidth;return!(t.hasOwnProperty('bgColor')&&!b.color(e))&&(!(t.hasOwnProperty('borderColor')&&!b.color(o))&&!(t.hasOwnProperty('borderWidth')&&!b.number(n)))},imageDesc:function(t){var e=t.src;return!!b.imageSrc(e)},svgDesc:function(t){var e=t.svg;return!!b.svg(e)},htmlDesc:function(t){var e=t.html;return!!b.html(e)}};function D(t,e,o){var n=function(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}(e),r=function(t){return t/180*Math.PI}(e.angle||0);return function(t,e,o,n){e&&(o>0||o<0)&&(t.translate(e.x,e.y),t.rotate(o),t.translate(-e.x,-e.y));n(t),e&&(o>0||o<0)&&(t.translate(e.x,e.y),t.rotate(-o),t.translate(-e.x,-e.y))}(t,n,r||0,o)}function E(t){t.setFillStyle('#000000'),t.setStrokeStyle('#000000'),t.setLineDash([]),t.setGlobalAlpha(1),t.setShadowColor('#00000000'),t.setShadowOffsetX(0),t.setShadowOffsetY(0),t.setShadowBlur(0)}function O(t,e,o){E(t),function(t,e){E(t),D(t,e,(function(){if(e.desc.borderWidth&&e.desc.borderWidth>0){var o=e.desc.borderWidth,n='#000000';!0===r(e.desc.borderColor)&&(n=e.desc.borderColor);var i=e.x-o/2,s=e.y-o/2,a=e.w+o,u=e.h+o,c=e.desc.borderRadius||0;(c=Math.min(c,a/2,u/2))<a/2&&c<u/2&&(c+=o/2);var l=e.desc;void 0!==l.shadowColor&&r(l.shadowColor)&&t.setShadowColor(l.shadowColor),void 0!==l.shadowOffsetX&&b.number(l.shadowOffsetX)&&t.setShadowOffsetX(l.shadowOffsetX),void 0!==l.shadowOffsetY&&b.number(l.shadowOffsetY)&&t.setShadowOffsetY(l.shadowOffsetY),void 0!==l.shadowBlur&&b.number(l.shadowBlur)&&t.setShadowBlur(l.shadowBlur),t.beginPath(),t.setLineWidth(o),t.setStrokeStyle(n),t.moveTo(i+c,s),t.arcTo(i+a,s,i+a,s+u,c),t.arcTo(i+a,s+u,i,s+u,c),t.arcTo(i,s+u,i,s,c),t.arcTo(i,s,i+a,s,c),t.closePath(),t.stroke()}}))}(t,e),E(t),D(t,e,(function(){var n=e.x,r=e.y,i=e.w,s=e.h,a=e.desc.borderRadius||0;(i<2*(a=Math.min(a,i/2,s/2))||s<2*a)&&(a=0),t.beginPath(),t.moveTo(n+a,r),t.arcTo(n+i,r,n+i,r+s,a),t.arcTo(n+i,r+s,n,r+s,a),t.arcTo(n,r+s,n,r,a),t.arcTo(n,r,n+i,r,a),t.closePath(),('string'==typeof o||['CanvasPattern'].includes(u.type(o)))&&t.setFillStyle(o),t.fill()}))}function P(t,e){O(t,e,e.desc.bgColor)}function C(t,e,o){var n=o.getContent(e.uuid);D(t,e,(function(){n&&t.drawImage(n,e.x,e.y,e.w,e.h)}))}function k(t,e,o){var n=o.getContent(e.uuid);D(t,e,(function(){n&&t.drawImage(n,e.x,e.y,e.w,e.h)}))}function T(t,e,o){var n=o.getContent(e.uuid);D(t,e,(function(){n&&t.drawImage(n,e.x,e.y,e.w,e.h)}))}function W(t,o,n){E(t),O(t,o,o.desc.bgColor||'transparent'),D(t,o,(function(){var n=e({fontSize:12,fontFamily:'sans-serif',textAlign:'center'},o.desc);t.setFillStyle(o.desc.color),t.setTextBaseline('top'),t.setFont({fontWeight:n.fontWeight,fontSize:n.fontSize,fontFamily:n.fontFamily});var i=n.text.replace(/\r\n/gi,'\n'),s=n.lineHeight||n.fontSize,a=i.split('\n'),u=[],c=0;a.forEach((function(e,n){var r='';if(e.length>0){for(var i=0;i<e.length&&(t.measureText(r+(e[i]||'')).width<t.calcDeviceNum(o.w)?r+=e[i]||'':(u.push({text:r,width:t.calcScreenNum(t.measureText(r).width)}),r=e[i]||'',c++),!((c+1)*s>o.h));i++)if(e.length-1===i&&(c+1)*s<o.h){u.push({text:r,width:t.calcScreenNum(t.measureText(r).width)}),n<a.length-1&&c++;break}}else u.push({text:'',width:0})}));var l=o.y;if(u.length*s<o.h&&(l+=(o.h-u.length*s)/2),void 0!==n.textShadowColor&&r(n.textShadowColor)&&t.setShadowColor(n.textShadowColor),void 0!==n.textShadowOffsetX&&b.number(n.textShadowOffsetX)&&t.setShadowOffsetX(n.textShadowOffsetX),void 0!==n.textShadowOffsetY&&b.number(n.textShadowOffsetY)&&t.setShadowOffsetY(n.textShadowOffsetY),void 0!==n.textShadowBlur&&b.number(n.textShadowBlur)&&t.setShadowBlur(n.textShadowBlur),u.forEach((function(e,r){var i=o.x;'center'===n.textAlign?i=o.x+(o.w-e.width)/2:'right'===n.textAlign&&(i=o.x+(o.w-e.width)),t.fillText(e.text,i,l+s*r)})),E(t),r(n.strokeColor)&&void 0!==n.strokeWidth&&n.strokeWidth>0){var h=o.y;u.length*s<o.h&&(h+=(o.h-u.length*s)/2),u.forEach((function(e,r){var i=o.x;'center'===n.textAlign?i=o.x+(o.w-e.width)/2:'right'===n.textAlign&&(i=o.x+(o.w-e.width)),void 0!==n.strokeColor&&t.setStrokeStyle(n.strokeColor),void 0!==n.strokeWidth&&n.strokeWidth>0&&t.setLineWidth(n.strokeWidth),t.strokeText(e.text,i,h+s*r)}))}}))}function R(t,e){E(t),D(t,e,(function(t){var o=e.x,n=e.y,r=e.w,i=e.h,s=e.desc,a=s.bgColor,u=void 0===a?'#000000':a,c=s.borderColor,l=void 0===c?'#000000':c,h=s.borderWidth,f=void 0===h?0:h,d=r/2,p=i/2,g=o+d,_=n+p;if(f&&f>0){var v=f/2+d,y=f/2+p;t.beginPath(),t.setStrokeStyle(l),t.setLineWidth(f),t.ellipse(g,_,v,y,0,0,2*Math.PI),t.closePath(),t.stroke()}t.beginPath(),t.setFillStyle(u),t.ellipse(g,_,d,p,0,0,2*Math.PI),t.closePath(),t.fill()}))}function F(t,e,o){var n;E(t);var i=t.getSize();if(t.clearRect(0,0,i.contextWidth,i.contextHeight),'string'==typeof e.bgColor&&r(e.bgColor)&&function(t,e){var o=t.getSize();t.setFillStyle(e),t.fillRect(0,0,o.contextWidth,o.contextHeight)}(t,e.bgColor),e.elements.length>0)for(var s=0;s<e.elements.length;s++){var a=e.elements[s];if(!0!==(null===(n=null==a?void 0:a.operation)||void 0===n?void 0:n.invisible))switch(a.type){case'rect':P(t,a);break;case'text':W(t,a);break;case'image':C(t,a,o);break;case'svg':k(t,a,o);break;case'html':T(t,a,o);break;case'circle':R(t,a)}}}Object.freeze({__proto__:null,is:b,check:L,delay:function(t){return new Promise((function(e){setTimeout((function(){e()}),t)}))},compose:function(t){return function(e,o){return function n(r){var i=t[r];r===t.length&&o&&(i=o);if(!i)return Promise.resolve();try{return Promise.resolve(i(e,n.bind(null,r+1)))}catch(t){return Promise.reject(t)}}(0)}},throttle:function(t,e){var o=-1;return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];o>0||(o=setTimeout((function(){t.apply(void 0,n),o=-1}),e))}},loadImage:g,loadSVG:_,loadHTML:v,downloadImageFromCanvas:function(t,e){var o=e.filename,n=e.type,r=void 0===n?'image/jpeg':n,i=t.toDataURL(r),s=document.createElement('a');s.href=i,s.download=o;var a=document.createEvent('MouseEvents');a.initEvent('click',!0,!1),s.dispatchEvent(a)},toColorHexStr:function(t){return'#'+t.toString(16)},toColorHexNum:function(t){return parseInt(t.replace(/^\#/,'0x'))},isColorStr:r,createUUID:i,istype:u,deepClone:s,Context:y});var A,I=function(){function t(){this._listeners=new Map}return t.prototype.on=function(t,e){if(this._listeners.has(t)){var o=this._listeners.get(t);null==o||o.push(e),this._listeners.set(t,o||[])}else this._listeners.set(t,[e])},t.prototype.off=function(t,e){if(this._listeners.has(t)){var o=this._listeners.get(t);if(Array.isArray(o))for(var n=0;n<(null==o?void 0:o.length);n++)if(o[n]===e){o.splice(n,1);break}this._listeners.set(t,o||[])}},t.prototype.trigger=function(t,e){var o=this._listeners.get(t);return!!Array.isArray(o)&&(o.forEach((function(t){t(e)})),!0)},t.prototype.has=function(t){if(this._listeners.has(t)){var e=this._listeners.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1},t}();!function(t){t.FREE="free",t.LOADING="loading",t.COMPLETE="complete"}(A||(A={}));var H,j,U,N,B=function(){function t(t){this._currentLoadData={},this._currentUUIDQueue=[],this._storageLoadData={},this._status=A.FREE,this._waitingLoadQueue=[],this._opts=t,this._event=new I,this._waitingLoadQueue=[]}return t.prototype.load=function(t,e){var o=this._resetLoadData(t,e),n=o[0],r=o[1];this._status===A.FREE||this._status===A.COMPLETE?(this._currentUUIDQueue=n,this._currentLoadData=r,this._loadTask()):this._status===A.LOADING&&n.length>0&&this._waitingLoadQueue.push({uuidQueue:n,loadData:r})},t.prototype.on=function(t,e){this._event.on(t,e)},t.prototype.off=function(t,e){this._event.off(t,e)},t.prototype.isComplete=function(){return this._status===A.COMPLETE},t.prototype.getContent=function(t){var e;return'loaded'===(null===(e=this._storageLoadData[t])||void 0===e?void 0:e.status)?this._storageLoadData[t].content:null},t.prototype._resetLoadData=function(t,e){for(var o={},n=[],r=this._storageLoadData,i=t.elements.length-1;i>=0;i--){var s=t.elements[i];['image','svg','html'].includes(s.type)&&(r[s.uuid]?e.includes(s.uuid)&&(o[s.uuid]=this._createEmptyLoadItem(s),n.push(s.uuid)):(o[s.uuid]=this._createEmptyLoadItem(s),n.push(s.uuid)))}return[n,o]},t.prototype._createEmptyLoadItem=function(t){var e='',o=t.type,n=t.w,r=t.h;if('image'===t.type)e=(i=t).desc.src||'';else if('svg'===t.type){e=(i=t).desc.svg||''}else if('html'===t.type){var i;e=function(t){return t.replace(/<script[\s\S]*?<\/script>/gi,'')}((i=t).desc.html||''),n=i.desc.width||t.w,r=i.desc.height||t.h}return{uuid:t.uuid,type:o,status:'null',content:null,source:e,elemW:n,elemH:r,element:s(t)}},t.prototype._loadTask=function(){var t=this;if(this._status!==A.LOADING){if(this._status=A.LOADING,0===this._currentUUIDQueue.length){if(0===this._waitingLoadQueue.length)return this._status=A.COMPLETE,void this._event.trigger('complete',void 0);var e=this._waitingLoadQueue.shift();if(e){var o=e.uuidQueue,n=e.loadData;this._currentLoadData=n,this._currentUUIDQueue=o}}var r=this._opts.maxParallelNum,i=this._currentUUIDQueue.splice(0,r);i.forEach((function(t,e){}));var s=[],a=function(){if(s.length>=r)return!1;if(0===i.length)return!0;for(var e=function(e){var o=i.shift();if(void 0===o)return"break";s.push(o),t._loadElementSource(t._currentLoadData[o]).then((function(e){var n,r;s.splice(s.indexOf(o),1);var u=a();t._storageLoadData[o]={uuid:o,type:t._currentLoadData[o].type,status:'loaded',content:e,source:t._currentLoadData[o].source,elemW:t._currentLoadData[o].elemW,elemH:t._currentLoadData[o].elemH,element:t._currentLoadData[o].element},0===s.length&&0===i.length&&!0===u&&(t._status=A.FREE,t._loadTask()),t._event.trigger('load',{uuid:null===(n=t._storageLoadData[o])||void 0===n?void 0:n.uuid,type:t._storageLoadData[o].type,status:t._storageLoadData[o].status,content:t._storageLoadData[o].content,source:t._storageLoadData[o].source,elemW:t._storageLoadData[o].elemW,elemH:t._storageLoadData[o].elemH,element:null===(r=t._storageLoadData[o])||void 0===r?void 0:r.element})})).catch((function(e){var n,r,u,c,l,h,f,d,p,g,_,v;console.warn(e),s.splice(s.indexOf(o),1);var y=a();t._currentLoadData[o]&&(t._storageLoadData[o]={uuid:o,type:null===(n=t._currentLoadData[o])||void 0===n?void 0:n.type,status:'fail',content:null,error:e,source:null===(r=t._currentLoadData[o])||void 0===r?void 0:r.source,elemW:null===(u=t._currentLoadData[o])||void 0===u?void 0:u.elemW,elemH:null===(c=t._currentLoadData[o])||void 0===c?void 0:c.elemH,element:null===(l=t._currentLoadData[o])||void 0===l?void 0:l.element}),0===s.length&&0===i.length&&!0===y&&(t._status=A.FREE,t._loadTask()),t._currentLoadData[o]&&t._event.trigger('error',{uuid:o,type:null===(h=t._storageLoadData[o])||void 0===h?void 0:h.type,status:null===(f=t._storageLoadData[o])||void 0===f?void 0:f.status,content:null===(d=t._storageLoadData[o])||void 0===d?void 0:d.content,source:null===(p=t._storageLoadData[o])||void 0===p?void 0:p.source,elemW:null===(g=t._storageLoadData[o])||void 0===g?void 0:g.elemW,elemH:null===(_=t._storageLoadData[o])||void 0===_?void 0:_.elemH,element:null===(v=t._storageLoadData[o])||void 0===v?void 0:v.element})}))},o=s.length;o<r;o++){if("break"===e())break}return!1};a()}},t.prototype._loadElementSource=function(t){return o(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return t&&'image'===t.type?[4,g(t.source)]:[3,2];case 1:case 3:case 5:return[2,e.sent()];case 2:return t&&'svg'===t.type?[4,_(t.source)]:[3,4];case 4:return t&&'html'===t.type?[4,v(t.source,{width:t.elemW,height:t.elemH})]:[3,6];case 6:throw Error('Element\'s source is not support!')}}))}))},t}(),X=function(){function t(){this._listeners=new Map}return t.prototype.on=function(t,e){if(this._listeners.has(t)){var o=this._listeners.get(t);null==o||o.push(e),this._listeners.set(t,o||[])}else this._listeners.set(t,[e])},t.prototype.off=function(t,e){if(this._listeners.has(t)){var o=this._listeners.get(t);if(Array.isArray(o))for(var n=0;n<(null==o?void 0:o.length);n++)if(o[n]===e){o.splice(n,1);break}this._listeners.set(t,o||[])}},t.prototype.trigger=function(t,e){var o=this._listeners.get(t);return!!Array.isArray(o)&&(o.forEach((function(t){t(e)})),!0)},t.prototype.has=function(t){if(this._listeners.has(t)){var e=this._listeners.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1},t}(),Y=Symbol('_queue'),M=Symbol('_ctx'),Q=Symbol('_status'),G=Symbol('_loader'),Z=Symbol('_opts'),q=Symbol('_freeze'),$=Symbol('_drawFrame'),V=Symbol('_retainQueueOneItem'),J=window.requestAnimationFrame;!function(t){t.NULL="null",t.FREE="free",t.DRAWING="drawing",t.FREEZE="freeze"}(N||(N={}));var K=function(e){function o(t){var o=e.call(this)||this;return o[H]=[],o[j]=null,o[U]=N.NULL,o[Z]=t,o[G]=new B({maxParallelNum:6}),o[G].on('load',(function(t){o[$](),o.trigger('load',{element:t.element})})),o[G].on('error',(function(t){o.trigger('error',{element:t.element,error:t.error})})),o[G].on('complete',(function(){o.trigger('loadComplete',{t:Date.now()})})),o}return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function n(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}(o,e),o.prototype.render=function(t,e,o){var n=(o||{}).changeResourceUUIDs,r=void 0===n?[]:n;this[Q]=N.FREE;var a=s(e);if(Array.isArray(a.elements)&&a.elements.forEach((function(t){'string'==typeof t.uuid&&t.uuid||(t.uuid=i())})),!this[M])if(this[Z]&&'[object HTMLCanvasElement]'===Object.prototype.toString.call(t)){var u=this[Z],c=u.width,l=u.height,h=u.contextWidth,f=u.contextHeight,d=u.devicePixelRatio,p=t;p.width=c*d,p.height=l*d;var g=p.getContext('2d');this[M]=new y(g,{width:c,height:l,contextWidth:h||c,contextHeight:f||l,devicePixelRatio:d})}else t&&(this[M]=t);if(![N.FREEZE].includes(this[Q])){var _=s({data:a});this[Y].push(_),this[$](),this[G].load(a,r||[])}},o.prototype.getContext=function(){return this[M]},o.prototype.thaw=function(){this[Q]=N.FREE},o.prototype[(H=Y,j=M,U=Q,q)]=function(){this[Q]=N.FREEZE},o.prototype[$]=function(){var t=this;this[Q]!==N.FREEZE&&J((function(){if(t[Q]!==N.FREEZE){var e=t[M],o=t[Y][0],n=!1;t[Y].length>1?o=t[Y].shift():n=!0,!0!==t[G].isComplete()?(t[$](),o&&e&&F(e,o.data,t[G])):o&&e?(F(e,o.data,t[G]),t[V](),n?t[Q]=N.FREE:t[$]()):t[Q]=N.FREE,t.trigger('drawFrame',{t:Date.now()}),!0===t[G].isComplete()&&1===t[Y].length&&t[Q]===N.FREE&&(e&&t[Y][0]&&t[Y][0].data&&F(e,t[Y][0].data,t[G]),t.trigger('drawFrameComplete',{t:Date.now()}),t[q]())}}))},o.prototype[V]=function(){if(!(this[Y].length<=1)){var t=s(this[Y][this[Y].length-1]);this[Y]=[t]}},o}(X);return Object.freeze({__proto__:null,Renderer:K})}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idraw/renderer",
|
|
3
|
-
"version": "0.3.0-alpha.
|
|
3
|
+
"version": "0.3.0-alpha.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"author": "chenshenhai",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@idraw/types": "^0.3.0-alpha.
|
|
29
|
+
"@idraw/types": "^0.3.0-alpha.4"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@idraw/util": "^0.3.0-alpha.
|
|
32
|
+
"@idraw/util": "^0.3.0-alpha.4"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "eda72814239696a852bb4099e9297631824eaf48"
|
|
38
38
|
}
|