@sv-print/plugin-api-image 0.2.3 → 0.2.5

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.js CHANGED
@@ -1 +1 @@
1
- "use strict";var O=(i,e,x)=>new Promise((t,s)=>{var u=o=>{try{I(x.next(o))}catch(d){s(d)}},p=o=>{try{I(x.throw(o))}catch(d){s(d)}},I=o=>o.done?t(o.value):Promise.resolve(o.value).then(u,p);I((x=x.apply(i,e)).next())});const J=require("@zumer/snapdom");(function(i,e){const x=A,t=i();for(;;)try{if(-parseInt(x(216))/1*(-parseInt(x(183))/2)+parseInt(x(235))/3+parseInt(x(206))/4*(parseInt(x(207))/5)+-parseInt(x(247))/6+parseInt(x(221))/7+-parseInt(x(249))/8+-parseInt(x(218))/9===e)break;t.push(t.shift())}catch(s){t.push(t.shift())}})(q,753416);function q(){const i=["appendChild","toType","height","470AUvIIr","body","26055369RzhPas","getHtml","none","9280992Jexvrk","download","add","getContext","toBlob","display",".jpg","createElement","toDataURL","remove","position:fixed","indexOf","href","push","2164002XcdVeJ","Deferred","src","then","onProgress","setAttribute","image/jpeg","forEach","style","limit","dpr","getTempContainer","6514098cBdrfs","canvas","1889760vqAnjU","start","click","devicePixelRatio","imageSmoothingEnabled","url","find","6124dPWpoh","loadAllImages",".hiprint-printPanel .hiprint-printPaper","html","type","hinnn","css","extend","toImage percent: ","onload","isDownload","toImage 失败(可能您的图片资源无法正常加载): ","log","end","pixelRatio","cur","quality","removeTempContainer","length","clear","queue","createTempContainer","resolve","1187224bzROpF","25dVjjIT","replace","error","drawImage","width","clearRect"];return q=function(){return i},q()}function A(i,e){const x=q();return A=function(t,s){return t=t-183,x[t]},A(i,e)}const L=function(i,e){return O(this,null,function*(){const x=A;let t=this,s=globalThis.$[x(236)](),u=!0,p=10,I=(o,d)=>{const f=x,w=Math.floor(o/d*100);console[f(195)](f(198),o,"total",d),console[f(195)](f(191),w+"%")};if(this.printPanels.length){let o=globalThis.$[x(190)]({backgroundColor:"#fff"},e||{}),d=yield this[x(219)](i,e);e&&(e[x(197)]&&(o[x(245)]=e[x(197)]),e.isDownload!=null&&(u=e[x(193)]),e[x(239)]!=null&&(I=e[x(239)]),e[x(244)]!=null&&(p=e[x(244)])),globalThis.$(d)[x(189)]("width","")[x(189)](x(215),""),this[x(204)]();let f=this[x(246)]();this.svg2canvas(d,o),f[x(186)](d[0]);let w=f[x(255)](x(185))[x(201)];globalThis.$(d)[x(189)](x(231)),this[x(184)](f,function(){const a=x;try{let _=[],D=Math.ceil(w/p),S=w%p||1;const b=document.createElement(a(248)),V=b[a(224)]("2d"),z=f.find(".hiprint-printPanel").eq(0)[a(211)](),F=z*(o[a(245)]||globalThis[a(252)]);for(let v=0;v<D;v++){V[a(212)](0,0,b[a(211)],b[a(215)]);const C=v==D-1;let U=0,B=C?S:p;for(let g=0;g<B;g++){V[a(212)](0,0,b.width,b[a(215)]);const c=v*p+g,y=f[a(255)](a(185))[c];globalThis[a(188)].queue[a(223)](function(k){const T=a;J.snapdom.toCanvas(y,o)[T(238)](function(m){const r=T;let h=m[r(224)]("2d");h[r(253)]=!1;let P=m[r(229)](r(241),o[r(199)]||.92),n=new Image;n[r(237)]=P,n[r(192)]=function(){const l=r;g===0&&(b.width=F,b[l(215)]=n[l(215)]*B),U+=n[l(215)],V[l(210)](n,0,U-n[l(215)],F,n.height),I(c+1,w),k()}})})}globalThis[a(188)][a(203)][a(223)](function(g){const c=a;let y=o[c(187)]||c(241),k=o[c(214)]||c(254),T=o.quality||.8;if(u){let m=b[c(229)](y,T),r=new Image;r[c(237)]=m,r[c(192)]=function(){const h=c;_[h(234)]({url:m,start:v*p+1,end:v*p+B}),C&&(globalThis[h(188)][h(203)][h(202)](),t[h(200)](),_[h(242)](P=>{const n=h;let l=document[n(228)]("a"),j=e.name||"download.jpg";j[n(232)](".")==-1&&(j+=n(227));let $=j.split(".").pop(),H=j[n(208)]("."+$,"")+"_"+P[n(250)]+"-"+P[n(196)]+"."+$;l[n(243)][n(226)]=n(220),l[n(240)](n(222),H),l.setAttribute(n(233),P.url),document[n(217)][n(213)](l),l[n(251)](),l[n(230)]()})),g()};return}if(k==c(254)){_.push(b[c(229)](y,T)),C&&(globalThis[c(188)][c(203)].clear(),t[c(200)](),s.resolve(_)),g();return}k=="blob"&&b[c(225)](function(m){const r=c;_[r(234)](m),C&&(globalThis.hinnn[r(203)][r(202)](),t[r(200)](),s[r(205)](_)),g()},y,T)})}globalThis.hinnn[a(203)].run()}catch(_){console[a(209)](a(194)),console.log(_)}})}return s.promise()})};(function(i,e){for(var x=R,t=i();;)try{var s=-parseInt(x(336))/1+parseInt(x(337))/2+parseInt(x(348))/3+parseInt(x(342))/4*(-parseInt(x(339))/5)+parseInt(x(345))/6*(parseInt(x(341))/7)+-parseInt(x(343))/8+-parseInt(x(344))/9*(-parseInt(x(334))/10);if(s===e)break;t.push(t.shift())}catch(u){t.push(t.shift())}})(E,115347);function R(i,e){var x=E();return R=function(t,s){t=t-333;var u=x[t];return u},R(i,e)}function M(i){var e=R;return{name:e(338),description:"add toImage Api",hooks:[{hook:e(333),name:e(335),description:e(335),priority:1,run:({template:x,options:t})=>{var s=e;Object[s(347)](x,s(346),{value:L,enumerable:!1,writable:!0,configurable:!0})}}],leastHiprintVersion:e(340)}}function E(){var i=["241410CCiTBm","add toImage Api to PrintTemplate","52473TYFaEg","394780CpdQAL","add toImage Api","12635wFfRUS","0.3.0","8449wkFfiw","188KkVqIa","530224jbykon","9oPChTq","60NhVjtG","toImage","defineProperty","357798eZBmgS","newPrintTemplate"];return E=function(){return i},E()}module.exports=M;
1
+ "use strict";var $=(s,t,x)=>new Promise((n,f)=>{var g=o=>{try{w(x.next(o))}catch(c){f(c)}},b=o=>{try{w(x.throw(o))}catch(c){f(c)}},w=o=>o.done?n(o.value):Promise.resolve(o.value).then(g,b);w((x=x.apply(s,t)).next())});const J=require("@zumer/snapdom");(function(s,t){const x=A,n=s();for(;;)try{if(-parseInt(x(560))/1*(parseInt(x(548))/2)+parseInt(x(514))/3+-parseInt(x(521))/4+parseInt(x(501))/5+-parseInt(x(519))/6*(parseInt(x(510))/7)+-parseInt(x(493))/8+-parseInt(x(523))/9*(-parseInt(x(529))/10)===t)break;n.push(n.shift())}catch(f){n.push(n.shift())}})(B,744745);function A(s,t){const x=B();return A=function(n,f){return n=n-484,x[n]},A(s,t)}const L=function(s,t){return $(this,null,function*(){const x=A;let n=this,f=globalThis.$[x(487)](),g=!0,b=10,w=(o,c)=>{const h=x,j=Math[h(507)](o/c*100);console.log(h(488),o,h(508),c),console[h(496)]("toImage percent: ",j+"%")};if(this[x(485)][x(506)]){let o=globalThis.$[x(541)]({backgroundColor:"#fff"},t||{}),c=yield this.getHtml(s,t);t&&(t[x(547)]&&(o[x(503)]=t[x(547)]),t[x(554)]!=null&&(g=t[x(554)]),t[x(561)]!=null&&(w=t[x(561)]),t.limit!=null&&(b=t[x(555)])),globalThis.$(c)[x(530)](x(537),"").css("height",""),this.createTempContainer();let h=this[x(549)]();this[x(538)](c,o),h[x(502)](c[0]);const j=x(546);let R=h.find(j)[x(506)];globalThis.$(c)[x(530)](x(542)),this[x(552)](h,function(){const i=x;try{let m=[],D=Math[i(528)](R/b),M=R%b||1;const y=document[i(517)](i(490)),S=y[i(563)]("2d");for(let k=0;k<D;k++){const z=k==D-1&&D>1;let U=z?M:b,P=[];for(let _=0;_<U;_++){const e=k*b+_,d=h[i(525)](j)[e];d&&globalThis[i(518)].queue[i(553)](function(I){const p=i;J.snapdom[p(494)](d,o)[p(543)](function(r){const l=p;let u=r[l(563)]("2d");u[l(531)]=!1;let v=r.toDataURL("image/jpeg",o[l(520)]||.92),T=new Image;T[l(539)]=v,T.onload=function(){P[l(550)]({image:T,idx:e}),w(e+1,R),I()}})})}globalThis.hinnn[i(558)][i(553)](function(_){const e=i;P[e(533)]((r,l)=>r[e(551)]-l[e(551)]);let d=0,I=0;for(const r of P)r[e(491)][e(537)]>d&&(d=r[e(491)].width),I+=r.image.height;y[e(537)]=d,y[e(540)]=I,S[e(505)]="#fff",S.fillRect(0,0,d,I);let p=0;for(const r of P)S[e(484)](r.image,0,p,r[e(491)].width,r[e(491)][e(540)]),p+=r[e(491)][e(540)];_()}),globalThis[i(518)].queue[i(553)](function(_){const e=i;let d=o[e(536)]||"image/jpeg",I=o[e(522)]||e(544),p=o[e(520)]||.8,r=z||D==1;if(g){let l=y[e(509)](d,p),u=new Image;u.src=l,u[e(562)]=function(){const v=e;m.push({url:l,start:k*b+1,end:k*b+U}),r&&(globalThis[v(518)][v(558)][v(524)](),n[v(513)](),m[v(489)](T=>{const a=v;let C=document[a(517)]("a"),q=o.name||a(495);q[a(492)](".")==-1&&(q+=a(486));let W=q[a(556)](".")[a(499)](),O=q[a(498)]("."+W,"")+"_"+T[a(527)]+"-"+T[a(515)]+"."+W;C.style[a(534)]=a(559),C[a(516)](a(512),O),C.setAttribute(a(545),T[a(544)]),document[a(535)][a(504)](C),C[a(532)](),C[a(500)]()})),_()};return}if(I==e(544)){m[e(550)](y[e(509)](d,p)),r&&(globalThis[e(518)][e(558)][e(524)](),n[e(513)](),f[e(564)](m)),_();return}I==e(557)&&y.toBlob(function(l){const u=e;m[u(550)](l),r&&(globalThis[u(518)][u(558)][u(524)](),n.removeTempContainer(),f[u(564)](m)),_()},d,p)})}globalThis[i(518)][i(558)][i(511)]()}catch(m){console[i(565)](i(526)),console.log(m)}})}return f[x(497)]()})};function B(){const s=["1zeZnUb","onProgress","onload","getContext","resolve","error","drawImage","printPanels",".jpg","Deferred","cur","forEach","canvas","image","indexOf","11169648SDHQcW","toCanvas","download.jpg","log","promise","replace","pop","remove","7033995DPmiKW","html","dpr","appendChild","fillStyle","length","floor","total","toDataURL","7tVWzPO","run","download","removeTempContainer","2520477kBsSDz","end","setAttribute","createElement","hinnn","8155086Fykyso","quality","4489184flchqe","toType","1406655WEoubG","clear","find","toImage 失败(可能您的图片资源无法正常加载): ","start","ceil","230jzuglH","css","imageSmoothingEnabled","click","sort","display","body","type","width","svg2canvas","src","height","extend","position:fixed","then","url","href","> .hiprint-printTemplate > .hiprint-printPanel > .hiprint-printPaper","pixelRatio","2438630jZfNpI","getTempContainer","push","idx","loadAllImages","add","isDownload","limit","split","blob","queue","none"];return B=function(){return s},B()}function E(s,t){var x=H();return E=function(n,f){n=n-271;var g=x[n];return g},E(s,t)}(function(s,t){for(var x=E,n=s();;)try{var f=-parseInt(x(275))/1+-parseInt(x(271))/2+parseInt(x(278))/3+parseInt(x(274))/4*(-parseInt(x(273))/5)+-parseInt(x(279))/6+-parseInt(x(283))/7*(-parseInt(x(285))/8)+parseInt(x(277))/9;if(f===t)break;n.push(n.shift())}catch(g){n.push(n.shift())}})(H,561926);function N(s){var t=E;return{name:t(272),description:"add toImage Api",hooks:[{hook:t(282),name:t(276),description:t(276),priority:1,run:({template:x,options:n})=>{var f=t;Object[f(281)](x,f(280),{value:L,enumerable:!1,writable:!0,configurable:!0})}}],leastHiprintVersion:t(284)}}function H(){var s=["0.3.0","1533712vnUPbY","1715410rTljDB","add toImage Api","1400CvvDEl","9008CwSMNc","1113056BtkqHk","add toImage Api to PrintTemplate","20066355Cdsjmg","2940078hXjJTi","1428528eABdlk","toImage","defineProperty","newPrintTemplate","7aJIRrD"];return H=function(){return s},H()}module.exports=N;
package/dist/index.mjs CHANGED
@@ -1,148 +1,157 @@
1
- var O = (i, e, x) => new Promise((t, s) => {
2
- var u = (o) => {
1
+ var $ = (f, t, x) => new Promise((n, s) => {
2
+ var g = (o) => {
3
3
  try {
4
- I(x.next(o));
5
- } catch (d) {
6
- s(d);
4
+ w(x.next(o));
5
+ } catch (c) {
6
+ s(c);
7
7
  }
8
- }, p = (o) => {
8
+ }, b = (o) => {
9
9
  try {
10
- I(x.throw(o));
11
- } catch (d) {
12
- s(d);
10
+ w(x.throw(o));
11
+ } catch (c) {
12
+ s(c);
13
13
  }
14
- }, I = (o) => o.done ? t(o.value) : Promise.resolve(o.value).then(u, p);
15
- I((x = x.apply(i, e)).next());
14
+ }, w = (o) => o.done ? n(o.value) : Promise.resolve(o.value).then(g, b);
15
+ w((x = x.apply(f, t)).next());
16
16
  });
17
17
  import { snapdom as J } from "@zumer/snapdom";
18
- (function(i, e) {
19
- const x = q, t = i();
18
+ (function(f, t) {
19
+ const x = q, n = f();
20
20
  for (; ; )
21
21
  try {
22
- if (-parseInt(x(216)) / 1 * (-parseInt(x(183)) / 2) + parseInt(x(235)) / 3 + parseInt(x(206)) / 4 * (parseInt(x(207)) / 5) + -parseInt(x(247)) / 6 + parseInt(x(221)) / 7 + -parseInt(x(249)) / 8 + -parseInt(x(218)) / 9 === e) break;
23
- t.push(t.shift());
22
+ if (-parseInt(x(560)) / 1 * (parseInt(x(548)) / 2) + parseInt(x(514)) / 3 + -parseInt(x(521)) / 4 + parseInt(x(501)) / 5 + -parseInt(x(519)) / 6 * (parseInt(x(510)) / 7) + -parseInt(x(493)) / 8 + -parseInt(x(523)) / 9 * (-parseInt(x(529)) / 10) === t) break;
23
+ n.push(n.shift());
24
24
  } catch (s) {
25
- t.push(t.shift());
25
+ n.push(n.shift());
26
26
  }
27
- })(A, 753416);
28
- function A() {
29
- const i = ["appendChild", "toType", "height", "470AUvIIr", "body", "26055369RzhPas", "getHtml", "none", "9280992Jexvrk", "download", "add", "getContext", "toBlob", "display", ".jpg", "createElement", "toDataURL", "remove", "position:fixed", "indexOf", "href", "push", "2164002XcdVeJ", "Deferred", "src", "then", "onProgress", "setAttribute", "image/jpeg", "forEach", "style", "limit", "dpr", "getTempContainer", "6514098cBdrfs", "canvas", "1889760vqAnjU", "start", "click", "devicePixelRatio", "imageSmoothingEnabled", "url", "find", "6124dPWpoh", "loadAllImages", ".hiprint-printPanel .hiprint-printPaper", "html", "type", "hinnn", "css", "extend", "toImage percent: ", "onload", "isDownload", "toImage 失败(可能您的图片资源无法正常加载): ", "log", "end", "pixelRatio", "cur", "quality", "removeTempContainer", "length", "clear", "queue", "createTempContainer", "resolve", "1187224bzROpF", "25dVjjIT", "replace", "error", "drawImage", "width", "clearRect"];
30
- return A = function() {
31
- return i;
32
- }, A();
27
+ })(B, 744745);
28
+ function q(f, t) {
29
+ const x = B();
30
+ return q = function(n, s) {
31
+ return n = n - 484, x[n];
32
+ }, q(f, t);
33
33
  }
34
- function q(i, e) {
35
- const x = A();
36
- return q = function(t, s) {
37
- return t = t - 183, x[t];
38
- }, q(i, e);
39
- }
40
- const L = function(i, e) {
41
- return O(this, null, function* () {
34
+ const L = function(f, t) {
35
+ return $(this, null, function* () {
42
36
  const x = q;
43
- let t = this, s = globalThis.$[x(236)](), u = !0, p = 10, I = (o, d) => {
44
- const f = x, w = Math.floor(o / d * 100);
45
- console[f(195)](f(198), o, "total", d), console[f(195)](f(191), w + "%");
37
+ let n = this, s = globalThis.$[x(487)](), g = !0, b = 10, w = (o, c) => {
38
+ const h = x, j = Math[h(507)](o / c * 100);
39
+ console.log(h(488), o, h(508), c), console[h(496)]("toImage percent: ", j + "%");
46
40
  };
47
- if (this.printPanels.length) {
48
- let o = globalThis.$[x(190)]({ backgroundColor: "#fff" }, e || {}), d = yield this[x(219)](i, e);
49
- e && (e[x(197)] && (o[x(245)] = e[x(197)]), e.isDownload != null && (u = e[x(193)]), e[x(239)] != null && (I = e[x(239)]), e[x(244)] != null && (p = e[x(244)])), globalThis.$(d)[x(189)]("width", "")[x(189)](x(215), ""), this[x(204)]();
50
- let f = this[x(246)]();
51
- this.svg2canvas(d, o), f[x(186)](d[0]);
52
- let w = f[x(255)](x(185))[x(201)];
53
- globalThis.$(d)[x(189)](x(231)), this[x(184)](f, function() {
54
- const a = x;
41
+ if (this[x(485)][x(506)]) {
42
+ let o = globalThis.$[x(541)]({ backgroundColor: "#fff" }, t || {}), c = yield this.getHtml(f, t);
43
+ t && (t[x(547)] && (o[x(503)] = t[x(547)]), t[x(554)] != null && (g = t[x(554)]), t[x(561)] != null && (w = t[x(561)]), t.limit != null && (b = t[x(555)])), globalThis.$(c)[x(530)](x(537), "").css("height", ""), this.createTempContainer();
44
+ let h = this[x(549)]();
45
+ this[x(538)](c, o), h[x(502)](c[0]);
46
+ const j = x(546);
47
+ let R = h.find(j)[x(506)];
48
+ globalThis.$(c)[x(530)](x(542)), this[x(552)](h, function() {
49
+ const i = x;
55
50
  try {
56
- let _ = [], D = Math.ceil(w / p), S = w % p || 1;
57
- const b = document.createElement(a(248)), V = b[a(224)]("2d"), z = f.find(".hiprint-printPanel").eq(0)[a(211)](), F = z * (o[a(245)] || globalThis[a(252)]);
58
- for (let v = 0; v < D; v++) {
59
- V[a(212)](0, 0, b[a(211)], b[a(215)]);
60
- const C = v == D - 1;
61
- let U = 0, B = C ? S : p;
62
- for (let g = 0; g < B; g++) {
63
- V[a(212)](0, 0, b.width, b[a(215)]);
64
- const c = v * p + g, y = f[a(255)](a(185))[c];
65
- globalThis[a(188)].queue[a(223)](function(k) {
66
- const T = a;
67
- J.toCanvas(y, o)[T(238)](function(m) {
68
- const r = T;
69
- let h = m[r(224)]("2d");
70
- h[r(253)] = !1;
71
- let P = m[r(229)](r(241), o[r(199)] || 0.92), n = new Image();
72
- n[r(237)] = P, n[r(192)] = function() {
73
- const l = r;
74
- g === 0 && (b.width = F, b[l(215)] = n[l(215)] * B), U += n[l(215)], V[l(210)](n, 0, U - n[l(215)], F, n.height), I(c + 1, w), k();
51
+ let m = [], D = Math[i(528)](R / b), M = R % b || 1;
52
+ const y = document[i(517)](i(490)), S = y[i(563)]("2d");
53
+ for (let k = 0; k < D; k++) {
54
+ const z = k == D - 1 && D > 1;
55
+ let U = z ? M : b, P = [];
56
+ for (let _ = 0; _ < U; _++) {
57
+ const e = k * b + _, d = h[i(525)](j)[e];
58
+ d && globalThis[i(518)].queue[i(553)](function(I) {
59
+ const p = i;
60
+ J[p(494)](d, o)[p(543)](function(r) {
61
+ const l = p;
62
+ let u = r[l(563)]("2d");
63
+ u[l(531)] = !1;
64
+ let v = r.toDataURL("image/jpeg", o[l(520)] || 0.92), T = new Image();
65
+ T[l(539)] = v, T.onload = function() {
66
+ P[l(550)]({ image: T, idx: e }), w(e + 1, R), I();
75
67
  };
76
68
  });
77
69
  });
78
70
  }
79
- globalThis[a(188)][a(203)][a(223)](function(g) {
80
- const c = a;
81
- let y = o[c(187)] || c(241), k = o[c(214)] || c(254), T = o.quality || 0.8;
82
- if (u) {
83
- let m = b[c(229)](y, T), r = new Image();
84
- r[c(237)] = m, r[c(192)] = function() {
85
- const h = c;
86
- _[h(234)]({ url: m, start: v * p + 1, end: v * p + B }), C && (globalThis[h(188)][h(203)][h(202)](), t[h(200)](), _[h(242)]((P) => {
87
- const n = h;
88
- let l = document[n(228)]("a"), j = e.name || "download.jpg";
89
- j[n(232)](".") == -1 && (j += n(227));
90
- let $ = j.split(".").pop(), H = j[n(208)]("." + $, "") + "_" + P[n(250)] + "-" + P[n(196)] + "." + $;
91
- l[n(243)][n(226)] = n(220), l[n(240)](n(222), H), l.setAttribute(n(233), P.url), document[n(217)][n(213)](l), l[n(251)](), l[n(230)]();
92
- })), g();
71
+ globalThis.hinnn[i(558)][i(553)](function(_) {
72
+ const e = i;
73
+ P[e(533)]((r, l) => r[e(551)] - l[e(551)]);
74
+ let d = 0, I = 0;
75
+ for (const r of P)
76
+ r[e(491)][e(537)] > d && (d = r[e(491)].width), I += r.image.height;
77
+ y[e(537)] = d, y[e(540)] = I, S[e(505)] = "#fff", S.fillRect(0, 0, d, I);
78
+ let p = 0;
79
+ for (const r of P)
80
+ S[e(484)](r.image, 0, p, r[e(491)].width, r[e(491)][e(540)]), p += r[e(491)][e(540)];
81
+ _();
82
+ }), globalThis[i(518)].queue[i(553)](function(_) {
83
+ const e = i;
84
+ let d = o[e(536)] || "image/jpeg", I = o[e(522)] || e(544), p = o[e(520)] || 0.8, r = z || D == 1;
85
+ if (g) {
86
+ let l = y[e(509)](d, p), u = new Image();
87
+ u.src = l, u[e(562)] = function() {
88
+ const v = e;
89
+ m.push({ url: l, start: k * b + 1, end: k * b + U }), r && (globalThis[v(518)][v(558)][v(524)](), n[v(513)](), m[v(489)]((T) => {
90
+ const a = v;
91
+ let C = document[a(517)]("a"), A = o.name || a(495);
92
+ A[a(492)](".") == -1 && (A += a(486));
93
+ let W = A[a(556)](".")[a(499)](), O = A[a(498)]("." + W, "") + "_" + T[a(527)] + "-" + T[a(515)] + "." + W;
94
+ C.style[a(534)] = a(559), C[a(516)](a(512), O), C.setAttribute(a(545), T[a(544)]), document[a(535)][a(504)](C), C[a(532)](), C[a(500)]();
95
+ })), _();
93
96
  };
94
97
  return;
95
98
  }
96
- if (k == c(254)) {
97
- _.push(b[c(229)](y, T)), C && (globalThis[c(188)][c(203)].clear(), t[c(200)](), s.resolve(_)), g();
99
+ if (I == e(544)) {
100
+ m[e(550)](y[e(509)](d, p)), r && (globalThis[e(518)][e(558)][e(524)](), n[e(513)](), s[e(564)](m)), _();
98
101
  return;
99
102
  }
100
- k == "blob" && b[c(225)](function(m) {
101
- const r = c;
102
- _[r(234)](m), C && (globalThis.hinnn[r(203)][r(202)](), t[r(200)](), s[r(205)](_)), g();
103
- }, y, T);
103
+ I == e(557) && y.toBlob(function(l) {
104
+ const u = e;
105
+ m[u(550)](l), r && (globalThis[u(518)][u(558)][u(524)](), n.removeTempContainer(), s[u(564)](m)), _();
106
+ }, d, p);
104
107
  });
105
108
  }
106
- globalThis.hinnn[a(203)].run();
107
- } catch (_) {
108
- console[a(209)](a(194)), console.log(_);
109
+ globalThis[i(518)][i(558)][i(511)]();
110
+ } catch (m) {
111
+ console[i(565)](i(526)), console.log(m);
109
112
  }
110
113
  });
111
114
  }
112
- return s.promise();
115
+ return s[x(497)]();
113
116
  });
114
117
  };
115
- (function(i, e) {
116
- for (var x = R, t = i(); ; )
118
+ function B() {
119
+ const f = ["1zeZnUb", "onProgress", "onload", "getContext", "resolve", "error", "drawImage", "printPanels", ".jpg", "Deferred", "cur", "forEach", "canvas", "image", "indexOf", "11169648SDHQcW", "toCanvas", "download.jpg", "log", "promise", "replace", "pop", "remove", "7033995DPmiKW", "html", "dpr", "appendChild", "fillStyle", "length", "floor", "total", "toDataURL", "7tVWzPO", "run", "download", "removeTempContainer", "2520477kBsSDz", "end", "setAttribute", "createElement", "hinnn", "8155086Fykyso", "quality", "4489184flchqe", "toType", "1406655WEoubG", "clear", "find", "toImage 失败(可能您的图片资源无法正常加载): ", "start", "ceil", "230jzuglH", "css", "imageSmoothingEnabled", "click", "sort", "display", "body", "type", "width", "svg2canvas", "src", "height", "extend", "position:fixed", "then", "url", "href", "> .hiprint-printTemplate > .hiprint-printPanel > .hiprint-printPaper", "pixelRatio", "2438630jZfNpI", "getTempContainer", "push", "idx", "loadAllImages", "add", "isDownload", "limit", "split", "blob", "queue", "none"];
120
+ return B = function() {
121
+ return f;
122
+ }, B();
123
+ }
124
+ function E(f, t) {
125
+ var x = H();
126
+ return E = function(n, s) {
127
+ n = n - 271;
128
+ var g = x[n];
129
+ return g;
130
+ }, E(f, t);
131
+ }
132
+ (function(f, t) {
133
+ for (var x = E, n = f(); ; )
117
134
  try {
118
- var s = -parseInt(x(336)) / 1 + parseInt(x(337)) / 2 + parseInt(x(348)) / 3 + parseInt(x(342)) / 4 * (-parseInt(x(339)) / 5) + parseInt(x(345)) / 6 * (parseInt(x(341)) / 7) + -parseInt(x(343)) / 8 + -parseInt(x(344)) / 9 * (-parseInt(x(334)) / 10);
119
- if (s === e) break;
120
- t.push(t.shift());
121
- } catch (u) {
122
- t.push(t.shift());
135
+ var s = -parseInt(x(275)) / 1 + -parseInt(x(271)) / 2 + parseInt(x(278)) / 3 + parseInt(x(274)) / 4 * (-parseInt(x(273)) / 5) + -parseInt(x(279)) / 6 + -parseInt(x(283)) / 7 * (-parseInt(x(285)) / 8) + parseInt(x(277)) / 9;
136
+ if (s === t) break;
137
+ n.push(n.shift());
138
+ } catch (g) {
139
+ n.push(n.shift());
123
140
  }
124
- })(E, 115347);
125
- function R(i, e) {
126
- var x = E();
127
- return R = function(t, s) {
128
- t = t - 333;
129
- var u = x[t];
130
- return u;
131
- }, R(i, e);
132
- }
133
- function K(i) {
134
- var e = R;
135
- return { name: e(338), description: "add toImage Api", hooks: [{ hook: e(333), name: e(335), description: e(335), priority: 1, run: ({ template: x, options: t }) => {
136
- var s = e;
137
- Object[s(347)](x, s(346), { value: L, enumerable: !1, writable: !0, configurable: !0 });
138
- } }], leastHiprintVersion: e(340) };
141
+ })(H, 561926);
142
+ function Z(f) {
143
+ var t = E;
144
+ return { name: t(272), description: "add toImage Api", hooks: [{ hook: t(282), name: t(276), description: t(276), priority: 1, run: ({ template: x, options: n }) => {
145
+ var s = t;
146
+ Object[s(281)](x, s(280), { value: L, enumerable: !1, writable: !0, configurable: !0 });
147
+ } }], leastHiprintVersion: t(284) };
139
148
  }
140
- function E() {
141
- var i = ["241410CCiTBm", "add toImage Api to PrintTemplate", "52473TYFaEg", "394780CpdQAL", "add toImage Api", "12635wFfRUS", "0.3.0", "8449wkFfiw", "188KkVqIa", "530224jbykon", "9oPChTq", "60NhVjtG", "toImage", "defineProperty", "357798eZBmgS", "newPrintTemplate"];
142
- return E = function() {
143
- return i;
144
- }, E();
149
+ function H() {
150
+ var f = ["0.3.0", "1533712vnUPbY", "1715410rTljDB", "add toImage Api", "1400CvvDEl", "9008CwSMNc", "1113056BtkqHk", "add toImage Api to PrintTemplate", "20066355Cdsjmg", "2940078hXjJTi", "1428528eABdlk", "toImage", "defineProperty", "newPrintTemplate", "7aJIRrD"];
151
+ return H = function() {
152
+ return f;
153
+ }, H();
145
154
  }
146
155
  export {
147
- K as default
156
+ Z as default
148
157
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(h,f){typeof exports=="object"&&typeof module!="undefined"?module.exports=f(require("@zumer/snapdom")):typeof define=="function"&&define.amd?define(["@zumer/snapdom"],f):(h=typeof globalThis!="undefined"?globalThis:h||self,h.pluginApiImage=f(h.window))})(this,function(h){"use strict";var H=(h,f,b)=>new Promise((V,g)=>{var z=x=>{try{o(b.next(x))}catch(e){g(e)}},w=x=>{try{o(b.throw(x))}catch(e){g(e)}},o=x=>x.done?V(x.value):Promise.resolve(x.value).then(z,w);o((b=b.apply(h,f)).next())});(function(o,x){const e=b,n=o();for(;;)try{if(-parseInt(e(216))/1*(-parseInt(e(183))/2)+parseInt(e(235))/3+parseInt(e(206))/4*(parseInt(e(207))/5)+-parseInt(e(247))/6+parseInt(e(221))/7+-parseInt(e(249))/8+-parseInt(e(218))/9===x)break;n.push(n.shift())}catch(r){n.push(n.shift())}})(f,753416);function f(){const o=["appendChild","toType","height","470AUvIIr","body","26055369RzhPas","getHtml","none","9280992Jexvrk","download","add","getContext","toBlob","display",".jpg","createElement","toDataURL","remove","position:fixed","indexOf","href","push","2164002XcdVeJ","Deferred","src","then","onProgress","setAttribute","image/jpeg","forEach","style","limit","dpr","getTempContainer","6514098cBdrfs","canvas","1889760vqAnjU","start","click","devicePixelRatio","imageSmoothingEnabled","url","find","6124dPWpoh","loadAllImages",".hiprint-printPanel .hiprint-printPaper","html","type","hinnn","css","extend","toImage percent: ","onload","isDownload","toImage 失败(可能您的图片资源无法正常加载): ","log","end","pixelRatio","cur","quality","removeTempContainer","length","clear","queue","createTempContainer","resolve","1187224bzROpF","25dVjjIT","replace","error","drawImage","width","clearRect"];return f=function(){return o},f()}function b(o,x){const e=f();return b=function(n,r){return n=n-183,e[n]},b(o,x)}const V=function(o,x){return H(this,null,function*(){const e=b;let n=this,r=globalThis.$[e(236)](),y=!0,I=10,F=(d,v)=>{const l=e,j=Math.floor(d/v*100);console[l(195)](l(198),d,"total",v),console[l(195)](l(191),j+"%")};if(this.printPanels.length){let d=globalThis.$[e(190)]({backgroundColor:"#fff"},x||{}),v=yield this[e(219)](o,x);x&&(x[e(197)]&&(d[e(245)]=x[e(197)]),x.isDownload!=null&&(y=x[e(193)]),x[e(239)]!=null&&(F=x[e(239)]),x[e(244)]!=null&&(I=x[e(244)])),globalThis.$(v)[e(189)]("width","")[e(189)](e(215),""),this[e(204)]();let l=this[e(246)]();this.svg2canvas(v,d),l[e(186)](v[0]);let j=l[e(255)](e(185))[e(201)];globalThis.$(v)[e(189)](e(231)),this[e(184)](l,function(){const a=e;try{let _=[],U=Math.ceil(j/I),J=j%I||1;const p=document.createElement(a(248)),B=p[a(224)]("2d"),L=l.find(".hiprint-printPanel").eq(0)[a(211)](),$=L*(d[a(245)]||globalThis[a(252)]);for(let P=0;P<U;P++){B[a(212)](0,0,p[a(211)],p[a(215)]);const q=P==U-1;let O=0,D=q?J:I;for(let m=0;m<D;m++){B[a(212)](0,0,p.width,p[a(215)]);const i=P*I+m,k=l[a(255)](a(185))[i];globalThis[a(188)].queue[a(223)](function(R){const C=a;h.snapdom.toCanvas(k,d)[C(238)](function(T){const c=C;let u=T[c(224)]("2d");u[c(253)]=!1;let A=T[c(229)](c(241),d[c(199)]||.92),t=new Image;t[c(237)]=A,t[c(192)]=function(){const s=c;m===0&&(p.width=$,p[s(215)]=t[s(215)]*D),O+=t[s(215)],B[s(210)](t,0,O-t[s(215)],$,t.height),F(i+1,j),R()}})})}globalThis[a(188)][a(203)][a(223)](function(m){const i=a;let k=d[i(187)]||i(241),R=d[i(214)]||i(254),C=d.quality||.8;if(y){let T=p[i(229)](k,C),c=new Image;c[i(237)]=T,c[i(192)]=function(){const u=i;_[u(234)]({url:T,start:P*I+1,end:P*I+D}),q&&(globalThis[u(188)][u(203)][u(202)](),n[u(200)](),_[u(242)](A=>{const t=u;let s=document[t(228)]("a"),E=x.name||"download.jpg";E[t(232)](".")==-1&&(E+=t(227));let S=E.split(".").pop(),M=E[t(208)]("."+S,"")+"_"+A[t(250)]+"-"+A[t(196)]+"."+S;s[t(243)][t(226)]=t(220),s[t(240)](t(222),M),s.setAttribute(t(233),A.url),document[t(217)][t(213)](s),s[t(251)](),s[t(230)]()})),m()};return}if(R==i(254)){_.push(p[i(229)](k,C)),q&&(globalThis[i(188)][i(203)].clear(),n[i(200)](),r.resolve(_)),m();return}R=="blob"&&p[i(225)](function(T){const c=i;_[c(234)](T),q&&(globalThis.hinnn[c(203)][c(202)](),n[c(200)](),r[c(205)](_)),m()},k,C)})}globalThis.hinnn[a(203)].run()}catch(_){console[a(209)](a(194)),console.log(_)}})}return r.promise()})};(function(o,x){for(var e=g,n=o();;)try{var r=-parseInt(e(336))/1+parseInt(e(337))/2+parseInt(e(348))/3+parseInt(e(342))/4*(-parseInt(e(339))/5)+parseInt(e(345))/6*(parseInt(e(341))/7)+-parseInt(e(343))/8+-parseInt(e(344))/9*(-parseInt(e(334))/10);if(r===x)break;n.push(n.shift())}catch(y){n.push(n.shift())}})(w,115347);function g(o,x){var e=w();return g=function(n,r){n=n-333;var y=e[n];return y},g(o,x)}function z(o){var x=g;return{name:x(338),description:"add toImage Api",hooks:[{hook:x(333),name:x(335),description:x(335),priority:1,run:({template:e,options:n})=>{var r=x;Object[r(347)](e,r(346),{value:V,enumerable:!1,writable:!0,configurable:!0})}}],leastHiprintVersion:x(340)}}function w(){var o=["241410CCiTBm","add toImage Api to PrintTemplate","52473TYFaEg","394780CpdQAL","add toImage Api","12635wFfRUS","0.3.0","8449wkFfiw","188KkVqIa","530224jbykon","9oPChTq","60NhVjtG","toImage","defineProperty","357798eZBmgS","newPrintTemplate"];return w=function(){return o},w()}return z});
1
+ (function(_,d){typeof exports=="object"&&typeof module!="undefined"?module.exports=d(require("@zumer/snapdom")):typeof define=="function"&&define.amd?define(["@zumer/snapdom"],d):(_=typeof globalThis!="undefined"?globalThis:_||self,_.pluginApiImage=d(_.window))})(this,function(_){"use strict";var J=(_,d,j)=>new Promise((k,T)=>{var R=t=>{try{i(j.next(t))}catch(x){T(x)}},C=t=>{try{i(j.throw(t))}catch(x){T(x)}},i=t=>t.done?k(t.value):Promise.resolve(t.value).then(R,C);i((j=j.apply(_,d)).next())});(function(i,t){const x=d,n=i();for(;;)try{if(-parseInt(x(560))/1*(parseInt(x(548))/2)+parseInt(x(514))/3+-parseInt(x(521))/4+parseInt(x(501))/5+-parseInt(x(519))/6*(parseInt(x(510))/7)+-parseInt(x(493))/8+-parseInt(x(523))/9*(-parseInt(x(529))/10)===t)break;n.push(n.shift())}catch(f){n.push(n.shift())}})(k,744745);function d(i,t){const x=k();return d=function(n,f){return n=n-484,x[n]},d(i,t)}const j=function(i,t){return J(this,null,function*(){const x=d;let n=this,f=globalThis.$[x(487)](),D=!0,v=10,W=(l,w)=>{const h=x,z=Math[h(507)](l/w*100);console.log(h(488),l,h(508),w),console[h(496)]("toImage percent: ",z+"%")};if(this[x(485)][x(506)]){let l=globalThis.$[x(541)]({backgroundColor:"#fff"},t||{}),w=yield this.getHtml(i,t);t&&(t[x(547)]&&(l[x(503)]=t[x(547)]),t[x(554)]!=null&&(D=t[x(554)]),t[x(561)]!=null&&(W=t[x(561)]),t.limit!=null&&(v=t[x(555)])),globalThis.$(w)[x(530)](x(537),"").css("height",""),this.createTempContainer();let h=this[x(549)]();this[x(538)](w,l),h[x(502)](w[0]);const z=x(546);let S=h.find(z)[x(506)];globalThis.$(w)[x(530)](x(542)),this[x(552)](h,function(){const a=x;try{let m=[],B=Math[a(528)](S/v),L=S%v||1;const P=document[a(517)](a(490)),U=P[a(563)]("2d");for(let A=0;A<B;A++){const $=A==B-1&&B>1;let M=$?L:v,E=[];for(let b=0;b<M;b++){const e=A*v+b,c=h[a(525)](z)[e];c&&globalThis[a(518)].queue[a(553)](function(g){const p=a;_.snapdom[p(494)](c,l)[p(543)](function(r){const s=p;let u=r[s(563)]("2d");u[s(531)]=!1;let I=r.toDataURL("image/jpeg",l[s(520)]||.92),y=new Image;y[s(539)]=I,y.onload=function(){E[s(550)]({image:y,idx:e}),W(e+1,S),g()}})})}globalThis.hinnn[a(558)][a(553)](function(b){const e=a;E[e(533)]((r,s)=>r[e(551)]-s[e(551)]);let c=0,g=0;for(const r of E)r[e(491)][e(537)]>c&&(c=r[e(491)].width),g+=r.image.height;P[e(537)]=c,P[e(540)]=g,U[e(505)]="#fff",U.fillRect(0,0,c,g);let p=0;for(const r of E)U[e(484)](r.image,0,p,r[e(491)].width,r[e(491)][e(540)]),p+=r[e(491)][e(540)];b()}),globalThis[a(518)].queue[a(553)](function(b){const e=a;let c=l[e(536)]||"image/jpeg",g=l[e(522)]||e(544),p=l[e(520)]||.8,r=$||B==1;if(D){let s=P[e(509)](c,p),u=new Image;u.src=s,u[e(562)]=function(){const I=e;m.push({url:s,start:A*v+1,end:A*v+M}),r&&(globalThis[I(518)][I(558)][I(524)](),n[I(513)](),m[I(489)](y=>{const o=I;let q=document[o(517)]("a"),H=l.name||o(495);H[o(492)](".")==-1&&(H+=o(486));let O=H[o(556)](".")[o(499)](),N=H[o(498)]("."+O,"")+"_"+y[o(527)]+"-"+y[o(515)]+"."+O;q.style[o(534)]=o(559),q[o(516)](o(512),N),q.setAttribute(o(545),y[o(544)]),document[o(535)][o(504)](q),q[o(532)](),q[o(500)]()})),b()};return}if(g==e(544)){m[e(550)](P[e(509)](c,p)),r&&(globalThis[e(518)][e(558)][e(524)](),n[e(513)](),f[e(564)](m)),b();return}g==e(557)&&P.toBlob(function(s){const u=e;m[u(550)](s),r&&(globalThis[u(518)][u(558)][u(524)](),n.removeTempContainer(),f[u(564)](m)),b()},c,p)})}globalThis[a(518)][a(558)][a(511)]()}catch(m){console[a(565)](a(526)),console.log(m)}})}return f[x(497)]()})};function k(){const i=["1zeZnUb","onProgress","onload","getContext","resolve","error","drawImage","printPanels",".jpg","Deferred","cur","forEach","canvas","image","indexOf","11169648SDHQcW","toCanvas","download.jpg","log","promise","replace","pop","remove","7033995DPmiKW","html","dpr","appendChild","fillStyle","length","floor","total","toDataURL","7tVWzPO","run","download","removeTempContainer","2520477kBsSDz","end","setAttribute","createElement","hinnn","8155086Fykyso","quality","4489184flchqe","toType","1406655WEoubG","clear","find","toImage 失败(可能您的图片资源无法正常加载): ","start","ceil","230jzuglH","css","imageSmoothingEnabled","click","sort","display","body","type","width","svg2canvas","src","height","extend","position:fixed","then","url","href","> .hiprint-printTemplate > .hiprint-printPanel > .hiprint-printPaper","pixelRatio","2438630jZfNpI","getTempContainer","push","idx","loadAllImages","add","isDownload","limit","split","blob","queue","none"];return k=function(){return i},k()}function T(i,t){var x=C();return T=function(n,f){n=n-271;var D=x[n];return D},T(i,t)}(function(i,t){for(var x=T,n=i();;)try{var f=-parseInt(x(275))/1+-parseInt(x(271))/2+parseInt(x(278))/3+parseInt(x(274))/4*(-parseInt(x(273))/5)+-parseInt(x(279))/6+-parseInt(x(283))/7*(-parseInt(x(285))/8)+parseInt(x(277))/9;if(f===t)break;n.push(n.shift())}catch(D){n.push(n.shift())}})(C,561926);function R(i){var t=T;return{name:t(272),description:"add toImage Api",hooks:[{hook:t(282),name:t(276),description:t(276),priority:1,run:({template:x,options:n})=>{var f=t;Object[f(281)](x,f(280),{value:j,enumerable:!1,writable:!0,configurable:!0})}}],leastHiprintVersion:t(284)}}function C(){var i=["0.3.0","1533712vnUPbY","1715410rTljDB","add toImage Api","1400CvvDEl","9008CwSMNc","1113056BtkqHk","add toImage Api to PrintTemplate","20066355Cdsjmg","2940078hXjJTi","1428528eABdlk","toImage","defineProperty","newPrintTemplate","7aJIRrD"];return C=function(){return i},C()}return R});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sv-print/plugin-api-image",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "add image api to print template",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",