@sv-print/plugin-api-image 0.2.4 → 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 F=(s,t,x)=>new Promise((a,l)=>{var m=n=>{try{w(x.next(n))}catch(c){l(c)}},u=n=>{try{w(x.throw(n))}catch(c){l(c)}},w=n=>n.done?a(n.value):Promise.resolve(n.value).then(m,u);w((x=x.apply(s,t)).next())});const O=require("@zumer/snapdom");(function(s,t){const x=D,a=s();for(;;)try{if(parseInt(x(367))/1*(parseInt(x(434))/2)+-parseInt(x(406))/3*(parseInt(x(366))/4)+parseInt(x(371))/5+parseInt(x(398))/6+-parseInt(x(412))/7*(-parseInt(x(403))/8)+-parseInt(x(407))/9*(-parseInt(x(363))/10)+-parseInt(x(372))/11===t)break;a.push(a.shift())}catch(l){a.push(a.shift())}})(j,498061);const S=function(s,t){return F(this,null,function*(){const x=D;let a=this,l=globalThis.$[x(416)](),m=!0,u=10,w=(n,c)=>{const h=x,A=Math[h(432)](n/c*100);console.log(h(384),n,"total",c),console[h(399)](h(379),A+"%")};if(this[x(417)][x(422)]){let n=globalThis.$.extend({backgroundColor:x(364)},t||{}),c=yield this[x(401)](s,t);t&&(t[x(394)]&&(n[x(369)]=t[x(394)]),t[x(378)]!=null&&(m=t[x(378)]),t[x(409)]!=null&&(w=t[x(409)]),t[x(420)]!=null&&(u=t.limit)),globalThis.$(c).css("width","")[x(433)]("height",""),this[x(365)]();let h=this.getTempContainer();this[x(418)](c,n),h[x(389)](c[0]);const A=x(380);let G=h[x(419)](A)[x(422)];globalThis.$(c)[x(433)](x(396)),this[x(388)](h,function(){const i=x;try{let I=[],C=Math[i(377)](G/u),K=G%u||1;const y=document[i(413)]("canvas"),M=y[i(395)]("2d");for(let P=0;P<C;P++){const R=P==C-1&&C>1;let $=R?K:u,k=[];for(let _=0;_<$;_++){const e=P*u+_,f=h[i(419)](A)[e];globalThis[i(391)][i(421)].add(function(v){const b=i;O.snapdom[b(376)](f,n).then(function(r){const d=b;let p=r[d(395)]("2d");p.imageSmoothingEnabled=!1;let g=r[d(386)](d(404),n[d(387)]||.92),T=new Image;T.src=g,T[d(400)]=function(){k[d(431)]({image:T,idx:e}),w(e+1,G),v()}})})}globalThis[i(391)][i(421)][i(411)](function(_){const e=i;k.sort((r,d)=>r[e(385)]-d[e(385)]);let f=0,v=0;for(const r of k)r[e(405)][e(437)]>f&&(f=r.image.width),v+=r.image[e(390)];y[e(437)]=f,y[e(390)]=v,M.fillStyle=e(364),M[e(374)](0,0,f,v);let b=0;for(const r of k)M.drawImage(r[e(405)],0,b,r[e(405)][e(437)],r[e(405)][e(390)]),b+=r[e(405)].height;_()}),globalThis[i(391)].queue[i(411)](function(_){const e=i;let f=n[e(393)]||e(404),v=n[e(383)]||e(408),b=n[e(387)]||.8,r=R||C==1;if(m){let d=y[e(386)](f,b),p=new Image;p.src=d,p[e(400)]=function(){const g=e;I[g(431)]({url:d,start:P*u+1,end:P*u+$}),r&&(globalThis[g(391)][g(421)][g(423)](),a[g(427)](),I[g(370)](T=>{const o=g;let q=document[o(413)]("a"),H=n.name||o(424);H[o(435)](".")==-1&&(H+=o(425));let B=H.split(".")[o(381)](),L=H[o(373)]("."+B,"")+"_"+T.start+"-"+T[o(426)]+"."+B;q[o(436)].display=o(375),q[o(430)](o(414),L),q.setAttribute(o(382),T[o(408)]),document[o(415)][o(397)](q),q[o(368)](),q[o(362)]()})),_()};return}if(v==e(408)){I[e(431)](y[e(386)](f,b)),r&&(globalThis.hinnn.queue[e(423)](),a[e(427)](),l[e(410)](I)),_();return}v==e(428)&&y[e(392)](function(d){const p=e;I.push(d),r&&(globalThis[p(391)][p(421)][p(423)](),a[p(427)](),l[p(410)](I)),_()},f,b)})}globalThis[i(391)].queue.run()}catch(I){console[i(429)]("toImage 失败(可能您的图片资源无法正常加载): "),console[i(399)](I)}})}return l[x(402)]()})};function j(){const s=["setAttribute","push","floor","css","12108eqZdzd","indexOf","style","width","remove","33470IfnIFc","#fff","createTempContainer","2012PoesHP","18GecEqg","click","dpr","forEach","2791600fyxSiZ","2021492HzigUA","replace","fillRect","none","toCanvas","ceil","isDownload","toImage percent: ","> .hiprint-printTemplate > .hiprint-printPanel > .hiprint-printPaper","pop","href","toType","cur","idx","toDataURL","quality","loadAllImages","html","height","hinnn","toBlob","type","pixelRatio","getContext","position:fixed","appendChild","2145948FTFzGK","log","onload","getHtml","promise","104rTqpmR","image/jpeg","image","2967LPUwJn","99GwaYvs","url","onProgress","resolve","add","63287CAjxoM","createElement","download","body","Deferred","printPanels","svg2canvas","find","limit","queue","length","clear","download.jpg",".jpg","end","removeTempContainer","blob","error"];return j=function(){return s},j()}function D(s,t){const x=j();return D=function(a,l){return a=a-362,x[a]},D(s,t)}function E(s,t){var x=z();return E=function(a,l){a=a-220;var m=x[a];return m},E(s,t)}(function(s,t){for(var x=E,a=s();;)try{var l=parseInt(x(230))/1*(-parseInt(x(232))/2)+parseInt(x(227))/3*(-parseInt(x(220))/4)+-parseInt(x(221))/5*(parseInt(x(223))/6)+parseInt(x(224))/7+parseInt(x(225))/8+-parseInt(x(233))/9+parseInt(x(234))/10;if(l===t)break;a.push(a.shift())}catch(m){a.push(a.shift())}})(z,858286);function U(s){var t=E;return{name:t(222),description:t(222),hooks:[{hook:t(235),name:t(229),description:t(229),priority:1,run:({template:x,options:a})=>{var l=t;Object[l(228)](x,l(226),{value:S,enumerable:!1,writable:!0,configurable:!0})}}],leastHiprintVersion:t(231)}}function z(){var s=["60744dpuzyh","defineProperty","add toImage Api to PrintTemplate","257429jceYHb","0.3.0","6qeBAkD","7497612hcOKrf","8769310KdGVTm","newPrintTemplate","8PHLvmH","2948190WPWEBo","add toImage Api","6VodhiM","11559555dgpZDx","4523832PvdXct","toImage"];return z=function(){return s},z()}module.exports=U;
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,156 +1,156 @@
1
- var F = (s, t, x) => new Promise((a, l) => {
2
- var m = (n) => {
1
+ var $ = (f, t, x) => new Promise((n, s) => {
2
+ var g = (o) => {
3
3
  try {
4
- w(x.next(n));
4
+ w(x.next(o));
5
5
  } catch (c) {
6
- l(c);
6
+ s(c);
7
7
  }
8
- }, u = (n) => {
8
+ }, b = (o) => {
9
9
  try {
10
- w(x.throw(n));
10
+ w(x.throw(o));
11
11
  } catch (c) {
12
- l(c);
12
+ s(c);
13
13
  }
14
- }, w = (n) => n.done ? a(n.value) : Promise.resolve(n.value).then(m, u);
15
- w((x = x.apply(s, t)).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
- import { snapdom as O } from "@zumer/snapdom";
18
- (function(s, t) {
19
- const x = D, a = s();
17
+ import { snapdom as J } from "@zumer/snapdom";
18
+ (function(f, t) {
19
+ const x = q, n = f();
20
20
  for (; ; )
21
21
  try {
22
- if (parseInt(x(367)) / 1 * (parseInt(x(434)) / 2) + -parseInt(x(406)) / 3 * (parseInt(x(366)) / 4) + parseInt(x(371)) / 5 + parseInt(x(398)) / 6 + -parseInt(x(412)) / 7 * (-parseInt(x(403)) / 8) + -parseInt(x(407)) / 9 * (-parseInt(x(363)) / 10) + -parseInt(x(372)) / 11 === t) break;
23
- a.push(a.shift());
24
- } catch (l) {
25
- a.push(a.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
+ } catch (s) {
25
+ n.push(n.shift());
26
26
  }
27
- })(j, 498061);
28
- const S = function(s, t) {
29
- return F(this, null, function* () {
30
- const x = D;
31
- let a = this, l = globalThis.$[x(416)](), m = !0, u = 10, w = (n, c) => {
32
- const h = x, A = Math[h(432)](n / c * 100);
33
- console.log(h(384), n, "total", c), console[h(399)](h(379), 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
+ }
34
+ const L = function(f, t) {
35
+ return $(this, null, function* () {
36
+ const x = q;
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 + "%");
34
40
  };
35
- if (this[x(417)][x(422)]) {
36
- let n = globalThis.$.extend({ backgroundColor: x(364) }, t || {}), c = yield this[x(401)](s, t);
37
- t && (t[x(394)] && (n[x(369)] = t[x(394)]), t[x(378)] != null && (m = t[x(378)]), t[x(409)] != null && (w = t[x(409)]), t[x(420)] != null && (u = t.limit)), globalThis.$(c).css("width", "")[x(433)]("height", ""), this[x(365)]();
38
- let h = this.getTempContainer();
39
- this[x(418)](c, n), h[x(389)](c[0]);
40
- const A = x(380);
41
- let G = h[x(419)](A)[x(422)];
42
- globalThis.$(c)[x(433)](x(396)), this[x(388)](h, function() {
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() {
43
49
  const i = x;
44
50
  try {
45
- let I = [], C = Math[i(377)](G / u), K = G % u || 1;
46
- const y = document[i(413)]("canvas"), M = y[i(395)]("2d");
47
- for (let P = 0; P < C; P++) {
48
- const R = P == C - 1 && C > 1;
49
- let $ = R ? K : u, k = [];
50
- for (let _ = 0; _ < $; _++) {
51
- const e = P * u + _, f = h[i(419)](A)[e];
52
- globalThis[i(391)][i(421)].add(function(v) {
53
- const b = i;
54
- O[b(376)](f, n).then(function(r) {
55
- const d = b;
56
- let p = r[d(395)]("2d");
57
- p.imageSmoothingEnabled = !1;
58
- let g = r[d(386)](d(404), n[d(387)] || 0.92), T = new Image();
59
- T.src = g, T[d(400)] = function() {
60
- k[d(431)]({ image: T, idx: e }), w(e + 1, G), v();
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();
61
67
  };
62
68
  });
63
69
  });
64
70
  }
65
- globalThis[i(391)][i(421)][i(411)](function(_) {
71
+ globalThis.hinnn[i(558)][i(553)](function(_) {
66
72
  const e = i;
67
- k.sort((r, d) => r[e(385)] - d[e(385)]);
68
- let f = 0, v = 0;
69
- for (const r of k)
70
- r[e(405)][e(437)] > f && (f = r.image.width), v += r.image[e(390)];
71
- y[e(437)] = f, y[e(390)] = v, M.fillStyle = e(364), M[e(374)](0, 0, f, v);
72
- let b = 0;
73
- for (const r of k)
74
- M.drawImage(r[e(405)], 0, b, r[e(405)][e(437)], r[e(405)][e(390)]), b += r[e(405)].height;
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)];
75
81
  _();
76
- }), globalThis[i(391)].queue[i(411)](function(_) {
82
+ }), globalThis[i(518)].queue[i(553)](function(_) {
77
83
  const e = i;
78
- let f = n[e(393)] || e(404), v = n[e(383)] || e(408), b = n[e(387)] || 0.8, r = R || C == 1;
79
- if (m) {
80
- let d = y[e(386)](f, b), p = new Image();
81
- p.src = d, p[e(400)] = function() {
82
- const g = e;
83
- I[g(431)]({ url: d, start: P * u + 1, end: P * u + $ }), r && (globalThis[g(391)][g(421)][g(423)](), a[g(427)](), I[g(370)]((T) => {
84
- const o = g;
85
- let q = document[o(413)]("a"), H = n.name || o(424);
86
- H[o(435)](".") == -1 && (H += o(425));
87
- let B = H.split(".")[o(381)](), L = H[o(373)]("." + B, "") + "_" + T.start + "-" + T[o(426)] + "." + B;
88
- q[o(436)].display = o(375), q[o(430)](o(414), L), q.setAttribute(o(382), T[o(408)]), document[o(415)][o(397)](q), q[o(368)](), q[o(362)]();
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)]();
89
95
  })), _();
90
96
  };
91
97
  return;
92
98
  }
93
- if (v == e(408)) {
94
- I[e(431)](y[e(386)](f, b)), r && (globalThis.hinnn.queue[e(423)](), a[e(427)](), l[e(410)](I)), _();
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)), _();
95
101
  return;
96
102
  }
97
- v == e(428) && y[e(392)](function(d) {
98
- const p = e;
99
- I.push(d), r && (globalThis[p(391)][p(421)][p(423)](), a[p(427)](), l[p(410)](I)), _();
100
- }, f, b);
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);
101
107
  });
102
108
  }
103
- globalThis[i(391)].queue.run();
104
- } catch (I) {
105
- console[i(429)]("toImage 失败(可能您的图片资源无法正常加载): "), console[i(399)](I);
109
+ globalThis[i(518)][i(558)][i(511)]();
110
+ } catch (m) {
111
+ console[i(565)](i(526)), console.log(m);
106
112
  }
107
113
  });
108
114
  }
109
- return l[x(402)]();
115
+ return s[x(497)]();
110
116
  });
111
117
  };
112
- function j() {
113
- const s = ["setAttribute", "push", "floor", "css", "12108eqZdzd", "indexOf", "style", "width", "remove", "33470IfnIFc", "#fff", "createTempContainer", "2012PoesHP", "18GecEqg", "click", "dpr", "forEach", "2791600fyxSiZ", "2021492HzigUA", "replace", "fillRect", "none", "toCanvas", "ceil", "isDownload", "toImage percent: ", "> .hiprint-printTemplate > .hiprint-printPanel > .hiprint-printPaper", "pop", "href", "toType", "cur", "idx", "toDataURL", "quality", "loadAllImages", "html", "height", "hinnn", "toBlob", "type", "pixelRatio", "getContext", "position:fixed", "appendChild", "2145948FTFzGK", "log", "onload", "getHtml", "promise", "104rTqpmR", "image/jpeg", "image", "2967LPUwJn", "99GwaYvs", "url", "onProgress", "resolve", "add", "63287CAjxoM", "createElement", "download", "body", "Deferred", "printPanels", "svg2canvas", "find", "limit", "queue", "length", "clear", "download.jpg", ".jpg", "end", "removeTempContainer", "blob", "error"];
114
- return j = function() {
115
- return s;
116
- }, j();
117
- }
118
- function D(s, t) {
119
- const x = j();
120
- return D = function(a, l) {
121
- return a = a - 362, x[a];
122
- }, D(s, t);
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
123
  }
124
- function E(s, t) {
125
- var x = z();
126
- return E = function(a, l) {
127
- a = a - 220;
128
- var m = x[a];
129
- return m;
130
- }, E(s, t);
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
131
  }
132
- (function(s, t) {
133
- for (var x = E, a = s(); ; )
132
+ (function(f, t) {
133
+ for (var x = E, n = f(); ; )
134
134
  try {
135
- var l = parseInt(x(230)) / 1 * (-parseInt(x(232)) / 2) + parseInt(x(227)) / 3 * (-parseInt(x(220)) / 4) + -parseInt(x(221)) / 5 * (parseInt(x(223)) / 6) + parseInt(x(224)) / 7 + parseInt(x(225)) / 8 + -parseInt(x(233)) / 9 + parseInt(x(234)) / 10;
136
- if (l === t) break;
137
- a.push(a.shift());
138
- } catch (m) {
139
- a.push(a.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());
140
140
  }
141
- })(z, 858286);
142
- function Z(s) {
141
+ })(H, 561926);
142
+ function Z(f) {
143
143
  var t = E;
144
- return { name: t(222), description: t(222), hooks: [{ hook: t(235), name: t(229), description: t(229), priority: 1, run: ({ template: x, options: a }) => {
145
- var l = t;
146
- Object[l(228)](x, l(226), { value: S, enumerable: !1, writable: !0, configurable: !0 });
147
- } }], leastHiprintVersion: t(231) };
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) };
148
148
  }
149
- function z() {
150
- var s = ["60744dpuzyh", "defineProperty", "add toImage Api to PrintTemplate", "257429jceYHb", "0.3.0", "6qeBAkD", "7497612hcOKrf", "8769310KdGVTm", "newPrintTemplate", "8PHLvmH", "2948190WPWEBo", "add toImage Api", "6VodhiM", "11559555dgpZDx", "4523832PvdXct", "toImage"];
151
- return z = function() {
152
- return s;
153
- }, z();
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();
154
154
  }
155
155
  export {
156
156
  Z as default
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(g,T){typeof exports=="object"&&typeof module!="undefined"?module.exports=T(require("@zumer/snapdom")):typeof define=="function"&&define.amd?define(["@zumer/snapdom"],T):(g=typeof globalThis!="undefined"?globalThis:g||self,g.pluginApiImage=T(g.window))})(this,function(g){"use strict";var O=(g,T,p)=>new Promise((q,v)=>{var M=t=>{try{a(p.next(t))}catch(x){v(x)}},A=t=>{try{a(p.throw(t))}catch(x){v(x)}},a=t=>t.done?q(t.value):Promise.resolve(t.value).then(M,A);a((p=p.apply(g,T)).next())});(function(a,t){const x=q,n=a();for(;;)try{if(parseInt(x(367))/1*(parseInt(x(434))/2)+-parseInt(x(406))/3*(parseInt(x(366))/4)+parseInt(x(371))/5+parseInt(x(398))/6+-parseInt(x(412))/7*(-parseInt(x(403))/8)+-parseInt(x(407))/9*(-parseInt(x(363))/10)+-parseInt(x(372))/11===t)break;n.push(n.shift())}catch(d){n.push(n.shift())}})(p,498061);const T=function(a,t){return O(this,null,function*(){const x=q;let n=this,d=globalThis.$[x(416)](),C=!0,w=10,B=(l,y)=>{const u=x,z=Math[u(432)](l/y*100);console.log(u(384),l,"total",y),console[u(399)](u(379),z+"%")};if(this[x(417)][x(422)]){let l=globalThis.$.extend({backgroundColor:x(364)},t||{}),y=yield this[x(401)](a,t);t&&(t[x(394)]&&(l[x(369)]=t[x(394)]),t[x(378)]!=null&&(C=t[x(378)]),t[x(409)]!=null&&(B=t[x(409)]),t[x(420)]!=null&&(w=t.limit)),globalThis.$(y).css("width","")[x(433)]("height",""),this[x(365)]();let u=this.getTempContainer();this[x(418)](y,l),u[x(389)](y[0]);const z=x(380);let R=u[x(419)](z)[x(422)];globalThis.$(y)[x(433)](x(396)),this[x(388)](u,function(){const i=x;try{let b=[],D=Math[i(377)](R/w),S=R%w||1;const j=document[i(413)]("canvas"),$=j[i(395)]("2d");for(let k=0;k<D;k++){const F=k==D-1&&D>1;let K=F?S:w,E=[];for(let h=0;h<K;h++){const e=k*w+h,c=u[i(419)](z)[e];globalThis[i(391)][i(421)].add(function(I){const _=i;g.snapdom[_(376)](c,l).then(function(r){const s=_;let f=r[s(395)]("2d");f.imageSmoothingEnabled=!1;let m=r[s(386)](s(404),l[s(387)]||.92),P=new Image;P.src=m,P[s(400)]=function(){E[s(431)]({image:P,idx:e}),B(e+1,R),I()}})})}globalThis[i(391)][i(421)][i(411)](function(h){const e=i;E.sort((r,s)=>r[e(385)]-s[e(385)]);let c=0,I=0;for(const r of E)r[e(405)][e(437)]>c&&(c=r.image.width),I+=r.image[e(390)];j[e(437)]=c,j[e(390)]=I,$.fillStyle=e(364),$[e(374)](0,0,c,I);let _=0;for(const r of E)$.drawImage(r[e(405)],0,_,r[e(405)][e(437)],r[e(405)][e(390)]),_+=r[e(405)].height;h()}),globalThis[i(391)].queue[i(411)](function(h){const e=i;let c=l[e(393)]||e(404),I=l[e(383)]||e(408),_=l[e(387)]||.8,r=F||D==1;if(C){let s=j[e(386)](c,_),f=new Image;f.src=s,f[e(400)]=function(){const m=e;b[m(431)]({url:s,start:k*w+1,end:k*w+K}),r&&(globalThis[m(391)][m(421)][m(423)](),n[m(427)](),b[m(370)](P=>{const o=m;let H=document[o(413)]("a"),G=l.name||o(424);G[o(435)](".")==-1&&(G+=o(425));let L=G.split(".")[o(381)](),U=G[o(373)]("."+L,"")+"_"+P.start+"-"+P[o(426)]+"."+L;H[o(436)].display=o(375),H[o(430)](o(414),U),H.setAttribute(o(382),P[o(408)]),document[o(415)][o(397)](H),H[o(368)](),H[o(362)]()})),h()};return}if(I==e(408)){b[e(431)](j[e(386)](c,_)),r&&(globalThis.hinnn.queue[e(423)](),n[e(427)](),d[e(410)](b)),h();return}I==e(428)&&j[e(392)](function(s){const f=e;b.push(s),r&&(globalThis[f(391)][f(421)][f(423)](),n[f(427)](),d[f(410)](b)),h()},c,_)})}globalThis[i(391)].queue.run()}catch(b){console[i(429)]("toImage 失败(可能您的图片资源无法正常加载): "),console[i(399)](b)}})}return d[x(402)]()})};function p(){const a=["setAttribute","push","floor","css","12108eqZdzd","indexOf","style","width","remove","33470IfnIFc","#fff","createTempContainer","2012PoesHP","18GecEqg","click","dpr","forEach","2791600fyxSiZ","2021492HzigUA","replace","fillRect","none","toCanvas","ceil","isDownload","toImage percent: ","> .hiprint-printTemplate > .hiprint-printPanel > .hiprint-printPaper","pop","href","toType","cur","idx","toDataURL","quality","loadAllImages","html","height","hinnn","toBlob","type","pixelRatio","getContext","position:fixed","appendChild","2145948FTFzGK","log","onload","getHtml","promise","104rTqpmR","image/jpeg","image","2967LPUwJn","99GwaYvs","url","onProgress","resolve","add","63287CAjxoM","createElement","download","body","Deferred","printPanels","svg2canvas","find","limit","queue","length","clear","download.jpg",".jpg","end","removeTempContainer","blob","error"];return p=function(){return a},p()}function q(a,t){const x=p();return q=function(n,d){return n=n-362,x[n]},q(a,t)}function v(a,t){var x=A();return v=function(n,d){n=n-220;var C=x[n];return C},v(a,t)}(function(a,t){for(var x=v,n=a();;)try{var d=parseInt(x(230))/1*(-parseInt(x(232))/2)+parseInt(x(227))/3*(-parseInt(x(220))/4)+-parseInt(x(221))/5*(parseInt(x(223))/6)+parseInt(x(224))/7+parseInt(x(225))/8+-parseInt(x(233))/9+parseInt(x(234))/10;if(d===t)break;n.push(n.shift())}catch(C){n.push(n.shift())}})(A,858286);function M(a){var t=v;return{name:t(222),description:t(222),hooks:[{hook:t(235),name:t(229),description:t(229),priority:1,run:({template:x,options:n})=>{var d=t;Object[d(228)](x,d(226),{value:T,enumerable:!1,writable:!0,configurable:!0})}}],leastHiprintVersion:t(231)}}function A(){var a=["60744dpuzyh","defineProperty","add toImage Api to PrintTemplate","257429jceYHb","0.3.0","6qeBAkD","7497612hcOKrf","8769310KdGVTm","newPrintTemplate","8PHLvmH","2948190WPWEBo","add toImage Api","6VodhiM","11559555dgpZDx","4523832PvdXct","toImage"];return A=function(){return a},A()}return M});
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.4",
3
+ "version": "0.2.5",
4
4
  "description": "add image api to print template",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",