@sv-print/plugin-api-image 0.2.2 → 0.2.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.js CHANGED
@@ -1 +1 @@
1
- "use strict";var B=(r,e,x)=>new Promise((n,i)=>{var h=o=>{try{v(x.next(o))}catch(b){i(b)}},u=o=>{try{v(x.throw(o))}catch(b){i(b)}},v=o=>o.done?n(o.value):Promise.resolve(o.value).then(h,u);v((x=x.apply(r,e)).next())});const S=require("@zumer/snapdom");function j(){const r=["clearRect","log","queue","createElement","141776MXtEoF","download","5AWMeBv","quality","dpr","devicePixelRatio","pop","154JvCxXU","run","find","clear","1119465HjFNXu","#fff","push","promise","name","getTempContainer","printPanels","Deferred","ceil","style","cur","toCanvas","2GAOFeX","split",".hiprint-printPanel","loadAllImages","575400DBEefY","5477481wrLhXo","onProgress","click","createTempContainer","image/jpeg","html","pixelRatio","height","toType","toBlob","isDownload","51654DgYjVv","toDataURL","css","href","remove",".jpg","removeTempContainer","download.jpg","toImage 失败(可能您的图片资源无法正常加载): ","setAttribute","replace","svg2canvas","url","indexOf","end","forEach","type","src","resolve","add","none","canvas","start",".hiprint-printPanel .hiprint-printPaper","onload","limit","floor","2010900RmMcnx","getHtml","then","toImage percent: ","hinnn","getContext","drawImage","length","19752890QOzFkk","width"];return j=function(){return r},j()}function R(r,e){const x=j();return R=function(n,i){return n=n-381,x[n]},R(r,e)}(function(r,e){const x=R,n=r();for(;;)try{if(-parseInt(x(393))/1+parseInt(x(389))/2*(-parseInt(x(457))/3)+-parseInt(x(432))/4+-parseInt(x(448))/5*(-parseInt(x(405))/6)+parseInt(x(453))/7*(parseInt(x(446))/8)+-parseInt(x(394))/9+parseInt(x(440))/10===e)break;n.push(n.shift())}catch(i){n.push(n.shift())}})(j,313893);const $=function(r,e){return B(this,null,function*(){const x=R;let n=this,i=globalThis.$[x(384)](),h=!0,u=10,v=(o,b)=>{const p=x,w=Math[p(431)](o/b*100);console[p(443)](p(387),o,"total",b),console[p(443)](p(435),w+"%")};if(this[x(383)][x(439)]){let o=globalThis.$.extend({backgroundColor:x(458)},e||{}),b=yield this[x(433)](r,e);e&&(e[x(400)]&&(o[x(450)]=e.pixelRatio),e[x(404)]!=null&&(h=e[x(404)]),e[x(395)]!=null&&(v=e[x(395)]),e[x(430)]!=null&&(u=e[x(430)])),globalThis.$(b).css(x(441),"")[x(407)](x(401),""),this[x(397)]();let p=this[x(382)]();this[x(416)](b,o),p[x(399)](b[0]);let w=p.find(x(428))[x(439)];globalThis.$(b).css("position:fixed"),this[x(392)](p,function(){const t=x;try{let f=[],U=Math[t(385)](w/u),G=w%u||1;const d=document[t(445)](t(426)),F=d[t(437)]("2d"),O=p[t(455)](t(391)).eq(0)[t(441)](),H=O*(o[t(450)]||globalThis[t(451)]);for(let T=0;T<U;T++){F[t(442)](0,0,d[t(441)],d.height);const C=T==U-1;let M=0,D=C?G:u;for(let _=0;_<D;_++){F[t(442)](0,0,d[t(441)],d[t(401)]);const c=T*u+_,y=p.find(t(428))[c];globalThis[t(436)].queue[t(424)](function(k){const g=t;S.snapdom[g(388)](y,o)[g(434)](function(m){const s=g;let I=m[s(437)]("2d");I.imageSmoothingEnabled=!1;let A=m[s(406)](s(398),o[s(449)]||.92),a=new Image;a[s(422)]=A,a[s(429)]=function(){const l=s;_===0&&(d[l(441)]=H,d[l(401)]=a.height*D),M+=a[l(401)],F[l(438)](a,0,M-a[l(401)],H,a.height),v(c+1,w),k()}})})}globalThis[t(436)][t(444)][t(424)](function(_){const c=t;let y=o[c(421)]||c(398),k=o[c(402)]||c(417),g=o[c(449)]||.8;if(h){let m=d.toDataURL(y,g),s=new Image;s.src=m,s[c(429)]=function(){const I=c;f[I(459)]({url:m,start:T*u+1,end:T*u+D}),C&&(globalThis[I(436)].queue[I(456)](),n.removeTempContainer(),f[I(420)](A=>{const a=I;let l=document[a(445)]("a"),P=e[a(381)]||a(412);P[a(418)](".")==-1&&(P+=a(410));let X=P[a(390)](".")[a(452)](),Q=P[a(415)]("."+X,"")+"_"+A[a(427)]+"-"+A[a(419)]+"."+X;l[a(386)].display=a(425),l[a(414)](a(447),Q),l[a(414)](a(408),A.url),document.body.appendChild(l),l[a(396)](),l[a(409)]()})),_()};return}if(k==c(417)){f[c(459)](d[c(406)](y,g)),C&&(globalThis[c(436)][c(444)].clear(),n[c(411)](),i[c(423)](f)),_();return}k=="blob"&&d[c(403)](function(m){const s=c;f.push(m),C&&(globalThis.hinnn[s(444)][s(456)](),n.removeTempContainer(),i[s(423)](f)),_()},y,g)})}globalThis[t(436)][t(444)][t(454)]()}catch(f){console.error(t(413)),console[t(443)](f)}})}return i[x(460)]()})};function q(){var r=["add toImage Api to PrintTemplate","1427AkFKHQ","4119890haQGfT","6583968UtqRGZ","280941AxjpFQ","44AEhNAs","defineProperty","45677710GiUZyJ","7743750AsFHSd","7890054ESuxUt","newPrintTemplate","0.3.0","toImage","add toImage Api","9zvBpja","1958AdiniS"];return q=function(){return r},q()}(function(r,e){for(var x=E,n=r();;)try{var i=parseInt(x(490))/1*(-parseInt(x(488))/2)+-parseInt(x(493))/3*(parseInt(x(494))/4)+-parseInt(x(491))/5+parseInt(x(482))/6+-parseInt(x(481))/7+-parseInt(x(492))/8+parseInt(x(487))/9*(parseInt(x(480))/10);if(i===e)break;n.push(n.shift())}catch(h){n.push(n.shift())}})(q,702406);function E(r,e){var x=q();return E=function(n,i){n=n-479;var h=x[n];return h},E(r,e)}function L(r){var e=E;return{name:e(486),description:e(486),hooks:[{hook:e(483),name:e(489),description:e(489),priority:1,run:({template:x,options:n})=>{var i=e;Object[i(479)](x,i(485),{value:$,enumerable:!1,writable:!0,configurable:!0})}}],leastHiprintVersion:e(484)}}module.exports=L;
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;
package/dist/index.mjs CHANGED
@@ -1,148 +1,157 @@
1
- var B = (r, e, x) => new Promise((n, i) => {
2
- var h = (o) => {
1
+ var F = (s, t, x) => new Promise((a, l) => {
2
+ var m = (n) => {
3
3
  try {
4
- v(x.next(o));
5
- } catch (b) {
6
- i(b);
4
+ w(x.next(n));
5
+ } catch (c) {
6
+ l(c);
7
7
  }
8
- }, u = (o) => {
8
+ }, u = (n) => {
9
9
  try {
10
- v(x.throw(o));
11
- } catch (b) {
12
- i(b);
10
+ w(x.throw(n));
11
+ } catch (c) {
12
+ l(c);
13
13
  }
14
- }, v = (o) => o.done ? n(o.value) : Promise.resolve(o.value).then(h, u);
15
- v((x = x.apply(r, e)).next());
14
+ }, w = (n) => n.done ? a(n.value) : Promise.resolve(n.value).then(m, u);
15
+ w((x = x.apply(s, t)).next());
16
16
  });
17
- import { snapdom as S } from "@zumer/snapdom";
18
- function j() {
19
- const r = ["clearRect", "log", "queue", "createElement", "141776MXtEoF", "download", "5AWMeBv", "quality", "dpr", "devicePixelRatio", "pop", "154JvCxXU", "run", "find", "clear", "1119465HjFNXu", "#fff", "push", "promise", "name", "getTempContainer", "printPanels", "Deferred", "ceil", "style", "cur", "toCanvas", "2GAOFeX", "split", ".hiprint-printPanel", "loadAllImages", "575400DBEefY", "5477481wrLhXo", "onProgress", "click", "createTempContainer", "image/jpeg", "html", "pixelRatio", "height", "toType", "toBlob", "isDownload", "51654DgYjVv", "toDataURL", "css", "href", "remove", ".jpg", "removeTempContainer", "download.jpg", "toImage 失败(可能您的图片资源无法正常加载): ", "setAttribute", "replace", "svg2canvas", "url", "indexOf", "end", "forEach", "type", "src", "resolve", "add", "none", "canvas", "start", ".hiprint-printPanel .hiprint-printPaper", "onload", "limit", "floor", "2010900RmMcnx", "getHtml", "then", "toImage percent: ", "hinnn", "getContext", "drawImage", "length", "19752890QOzFkk", "width"];
20
- return j = function() {
21
- return r;
22
- }, j();
23
- }
24
- function R(r, e) {
25
- const x = j();
26
- return R = function(n, i) {
27
- return n = n - 381, x[n];
28
- }, R(r, e);
29
- }
30
- (function(r, e) {
31
- const x = R, n = r();
17
+ import { snapdom as O } from "@zumer/snapdom";
18
+ (function(s, t) {
19
+ const x = D, a = s();
32
20
  for (; ; )
33
21
  try {
34
- if (-parseInt(x(393)) / 1 + parseInt(x(389)) / 2 * (-parseInt(x(457)) / 3) + -parseInt(x(432)) / 4 + -parseInt(x(448)) / 5 * (-parseInt(x(405)) / 6) + parseInt(x(453)) / 7 * (parseInt(x(446)) / 8) + -parseInt(x(394)) / 9 + parseInt(x(440)) / 10 === e) break;
35
- n.push(n.shift());
36
- } catch (i) {
37
- n.push(n.shift());
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());
38
26
  }
39
- })(j, 313893);
40
- const $ = function(r, e) {
41
- return B(this, null, function* () {
42
- const x = R;
43
- let n = this, i = globalThis.$[x(384)](), h = !0, u = 10, v = (o, b) => {
44
- const p = x, w = Math[p(431)](o / b * 100);
45
- console[p(443)](p(387), o, "total", b), console[p(443)](p(435), w + "%");
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 + "%");
46
34
  };
47
- if (this[x(383)][x(439)]) {
48
- let o = globalThis.$.extend({ backgroundColor: x(458) }, e || {}), b = yield this[x(433)](r, e);
49
- e && (e[x(400)] && (o[x(450)] = e.pixelRatio), e[x(404)] != null && (h = e[x(404)]), e[x(395)] != null && (v = e[x(395)]), e[x(430)] != null && (u = e[x(430)])), globalThis.$(b).css(x(441), "")[x(407)](x(401), ""), this[x(397)]();
50
- let p = this[x(382)]();
51
- this[x(416)](b, o), p[x(399)](b[0]);
52
- let w = p.find(x(428))[x(439)];
53
- globalThis.$(b).css("position:fixed"), this[x(392)](p, function() {
54
- const t = x;
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() {
43
+ const i = x;
55
44
  try {
56
- let f = [], U = Math[t(385)](w / u), G = w % u || 1;
57
- const d = document[t(445)](t(426)), q = d[t(437)]("2d"), O = p[t(455)](t(391)).eq(0)[t(441)](), H = O * (o[t(450)] || globalThis[t(451)]);
58
- for (let T = 0; T < U; T++) {
59
- q[t(442)](0, 0, d[t(441)], d.height);
60
- const C = T == U - 1;
61
- let M = 0, D = C ? G : u;
62
- for (let _ = 0; _ < D; _++) {
63
- q[t(442)](0, 0, d[t(441)], d[t(401)]);
64
- const c = T * u + _, y = p.find(t(428))[c];
65
- globalThis[t(436)].queue[t(424)](function(k) {
66
- const g = t;
67
- S[g(388)](y, o)[g(434)](function(m) {
68
- const s = g;
69
- let I = m[s(437)]("2d");
70
- I.imageSmoothingEnabled = !1;
71
- let A = m[s(406)](s(398), o[s(449)] || 0.92), a = new Image();
72
- a[s(422)] = A, a[s(429)] = function() {
73
- const l = s;
74
- _ === 0 && (d[l(441)] = H, d[l(401)] = a.height * D), M += a[l(401)], q[l(438)](a, 0, M - a[l(401)], H, a.height), v(c + 1, w), k();
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();
75
61
  };
76
62
  });
77
63
  });
78
64
  }
79
- globalThis[t(436)][t(444)][t(424)](function(_) {
80
- const c = t;
81
- let y = o[c(421)] || c(398), k = o[c(402)] || c(417), g = o[c(449)] || 0.8;
82
- if (h) {
83
- let m = d.toDataURL(y, g), s = new Image();
84
- s.src = m, s[c(429)] = function() {
85
- const I = c;
86
- f[I(459)]({ url: m, start: T * u + 1, end: T * u + D }), C && (globalThis[I(436)].queue[I(456)](), n.removeTempContainer(), f[I(420)]((A) => {
87
- const a = I;
88
- let l = document[a(445)]("a"), P = e[a(381)] || a(412);
89
- P[a(418)](".") == -1 && (P += a(410));
90
- let X = P[a(390)](".")[a(452)](), Q = P[a(415)]("." + X, "") + "_" + A[a(427)] + "-" + A[a(419)] + "." + X;
91
- l[a(386)].display = a(425), l[a(414)](a(447), Q), l[a(414)](a(408), A.url), document.body.appendChild(l), l[a(396)](), l[a(409)]();
65
+ globalThis[i(391)][i(421)][i(411)](function(_) {
66
+ 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;
75
+ _();
76
+ }), globalThis[i(391)].queue[i(411)](function(_) {
77
+ 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)]();
92
89
  })), _();
93
90
  };
94
91
  return;
95
92
  }
96
- if (k == c(417)) {
97
- f[c(459)](d[c(406)](y, g)), C && (globalThis[c(436)][c(444)].clear(), n[c(411)](), i[c(423)](f)), _();
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)), _();
98
95
  return;
99
96
  }
100
- k == "blob" && d[c(403)](function(m) {
101
- const s = c;
102
- f.push(m), C && (globalThis.hinnn[s(444)][s(456)](), n.removeTempContainer(), i[s(423)](f)), _();
103
- }, y, g);
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);
104
101
  });
105
102
  }
106
- globalThis[t(436)][t(444)][t(454)]();
107
- } catch (f) {
108
- console.error(t(413)), console[t(443)](f);
103
+ globalThis[i(391)].queue.run();
104
+ } catch (I) {
105
+ console[i(429)]("toImage 失败(可能您的图片资源无法正常加载): "), console[i(399)](I);
109
106
  }
110
107
  });
111
108
  }
112
- return i[x(460)]();
109
+ return l[x(402)]();
113
110
  });
114
111
  };
115
- function E() {
116
- var r = ["add toImage Api to PrintTemplate", "1427AkFKHQ", "4119890haQGfT", "6583968UtqRGZ", "280941AxjpFQ", "44AEhNAs", "defineProperty", "45677710GiUZyJ", "7743750AsFHSd", "7890054ESuxUt", "newPrintTemplate", "0.3.0", "toImage", "add toImage Api", "9zvBpja", "1958AdiniS"];
117
- return E = function() {
118
- return r;
119
- }, E();
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);
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);
120
131
  }
121
- (function(r, e) {
122
- for (var x = F, n = r(); ; )
132
+ (function(s, t) {
133
+ for (var x = E, a = s(); ; )
123
134
  try {
124
- var i = parseInt(x(490)) / 1 * (-parseInt(x(488)) / 2) + -parseInt(x(493)) / 3 * (parseInt(x(494)) / 4) + -parseInt(x(491)) / 5 + parseInt(x(482)) / 6 + -parseInt(x(481)) / 7 + -parseInt(x(492)) / 8 + parseInt(x(487)) / 9 * (parseInt(x(480)) / 10);
125
- if (i === e) break;
126
- n.push(n.shift());
127
- } catch (h) {
128
- n.push(n.shift());
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());
129
140
  }
130
- })(E, 702406);
131
- function F(r, e) {
132
- var x = E();
133
- return F = function(n, i) {
134
- n = n - 479;
135
- var h = x[n];
136
- return h;
137
- }, F(r, e);
141
+ })(z, 858286);
142
+ function Z(s) {
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) };
138
148
  }
139
- function J(r) {
140
- var e = F;
141
- return { name: e(486), description: e(486), hooks: [{ hook: e(483), name: e(489), description: e(489), priority: 1, run: ({ template: x, options: n }) => {
142
- var i = e;
143
- Object[i(479)](x, i(485), { value: $, enumerable: !1, writable: !0, configurable: !0 });
144
- } }], leastHiprintVersion: e(484) };
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();
145
154
  }
146
155
  export {
147
- J as default
156
+ Z as default
148
157
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(f,p){typeof exports=="object"&&typeof module!="undefined"?module.exports=p(require("@zumer/snapdom")):typeof define=="function"&&define.amd?define(["@zumer/snapdom"],p):(f=typeof globalThis!="undefined"?globalThis:f||self,f.pluginApiImage=p(f.window))})(this,function(f){"use strict";var O=(f,p,u)=>new Promise((F,m)=>{var y=x=>{try{i(u.next(x))}catch(e){m(e)}},D=x=>{try{i(u.throw(x))}catch(e){m(e)}},i=x=>x.done?F(x.value):Promise.resolve(x.value).then(y,D);i((u=u.apply(f,p)).next())});function p(){const i=["clearRect","log","queue","createElement","141776MXtEoF","download","5AWMeBv","quality","dpr","devicePixelRatio","pop","154JvCxXU","run","find","clear","1119465HjFNXu","#fff","push","promise","name","getTempContainer","printPanels","Deferred","ceil","style","cur","toCanvas","2GAOFeX","split",".hiprint-printPanel","loadAllImages","575400DBEefY","5477481wrLhXo","onProgress","click","createTempContainer","image/jpeg","html","pixelRatio","height","toType","toBlob","isDownload","51654DgYjVv","toDataURL","css","href","remove",".jpg","removeTempContainer","download.jpg","toImage 失败(可能您的图片资源无法正常加载): ","setAttribute","replace","svg2canvas","url","indexOf","end","forEach","type","src","resolve","add","none","canvas","start",".hiprint-printPanel .hiprint-printPaper","onload","limit","floor","2010900RmMcnx","getHtml","then","toImage percent: ","hinnn","getContext","drawImage","length","19752890QOzFkk","width"];return p=function(){return i},p()}function u(i,x){const e=p();return u=function(a,r){return a=a-381,e[a]},u(i,x)}(function(i,x){const e=u,a=i();for(;;)try{if(-parseInt(e(393))/1+parseInt(e(389))/2*(-parseInt(e(457))/3)+-parseInt(e(432))/4+-parseInt(e(448))/5*(-parseInt(e(405))/6)+parseInt(e(453))/7*(parseInt(e(446))/8)+-parseInt(e(394))/9+parseInt(e(440))/10===x)break;a.push(a.shift())}catch(r){a.push(a.shift())}})(p,313893);const F=function(i,x){return O(this,null,function*(){const e=u;let a=this,r=globalThis.$[e(384)](),A=!0,g=10,M=(l,I)=>{const d=e,j=Math[d(431)](l/I*100);console[d(443)](d(387),l,"total",I),console[d(443)](d(435),j+"%")};if(this[e(383)][e(439)]){let l=globalThis.$.extend({backgroundColor:e(458)},x||{}),I=yield this[e(433)](i,x);x&&(x[e(400)]&&(l[e(450)]=x.pixelRatio),x[e(404)]!=null&&(A=x[e(404)]),x[e(395)]!=null&&(M=x[e(395)]),x[e(430)]!=null&&(g=x[e(430)])),globalThis.$(I).css(e(441),"")[e(407)](e(401),""),this[e(397)]();let d=this[e(382)]();this[e(416)](I,l),d[e(399)](I[0]);let j=d.find(e(428))[e(439)];globalThis.$(I).css("position:fixed"),this[e(392)](d,function(){const t=e;try{let h=[],X=Math[t(385)](j/g),Q=j%g||1;const b=document[t(445)](t(426)),U=b[t(437)]("2d"),S=d[t(455)](t(391)).eq(0)[t(441)](),z=S*(l[t(450)]||globalThis[t(451)]);for(let C=0;C<X;C++){U[t(442)](0,0,b[t(441)],b.height);const R=C==X-1;let B=0,H=R?Q:g;for(let _=0;_<H;_++){U[t(442)](0,0,b[t(441)],b[t(401)]);const o=C*g+_,k=d.find(t(428))[o];globalThis[t(436)].queue[t(424)](function(q){const v=t;f.snapdom[v(388)](k,l)[v(434)](function(T){const c=v;let w=T[c(437)]("2d");w.imageSmoothingEnabled=!1;let P=T[c(406)](c(398),l[c(449)]||.92),n=new Image;n[c(422)]=P,n[c(429)]=function(){const s=c;_===0&&(b[s(441)]=z,b[s(401)]=n.height*H),B+=n[s(401)],U[s(438)](n,0,B-n[s(401)],z,n.height),M(o+1,j),q()}})})}globalThis[t(436)][t(444)][t(424)](function(_){const o=t;let k=l[o(421)]||o(398),q=l[o(402)]||o(417),v=l[o(449)]||.8;if(A){let T=b.toDataURL(k,v),c=new Image;c.src=T,c[o(429)]=function(){const w=o;h[w(459)]({url:T,start:C*g+1,end:C*g+H}),R&&(globalThis[w(436)].queue[w(456)](),a.removeTempContainer(),h[w(420)](P=>{const n=w;let s=document[n(445)]("a"),E=x[n(381)]||n(412);E[n(418)](".")==-1&&(E+=n(410));let G=E[n(390)](".")[n(452)](),$=E[n(415)]("."+G,"")+"_"+P[n(427)]+"-"+P[n(419)]+"."+G;s[n(386)].display=n(425),s[n(414)](n(447),$),s[n(414)](n(408),P.url),document.body.appendChild(s),s[n(396)](),s[n(409)]()})),_()};return}if(q==o(417)){h[o(459)](b[o(406)](k,v)),R&&(globalThis[o(436)][o(444)].clear(),a[o(411)](),r[o(423)](h)),_();return}q=="blob"&&b[o(403)](function(T){const c=o;h.push(T),R&&(globalThis.hinnn[c(444)][c(456)](),a.removeTempContainer(),r[c(423)](h)),_()},k,v)})}globalThis[t(436)][t(444)][t(454)]()}catch(h){console.error(t(413)),console[t(443)](h)}})}return r[e(460)]()})};function m(){var i=["add toImage Api to PrintTemplate","1427AkFKHQ","4119890haQGfT","6583968UtqRGZ","280941AxjpFQ","44AEhNAs","defineProperty","45677710GiUZyJ","7743750AsFHSd","7890054ESuxUt","newPrintTemplate","0.3.0","toImage","add toImage Api","9zvBpja","1958AdiniS"];return m=function(){return i},m()}(function(i,x){for(var e=y,a=i();;)try{var r=parseInt(e(490))/1*(-parseInt(e(488))/2)+-parseInt(e(493))/3*(parseInt(e(494))/4)+-parseInt(e(491))/5+parseInt(e(482))/6+-parseInt(e(481))/7+-parseInt(e(492))/8+parseInt(e(487))/9*(parseInt(e(480))/10);if(r===x)break;a.push(a.shift())}catch(A){a.push(a.shift())}})(m,702406);function y(i,x){var e=m();return y=function(a,r){a=a-479;var A=e[a];return A},y(i,x)}function D(i){var x=y;return{name:x(486),description:x(486),hooks:[{hook:x(483),name:x(489),description:x(489),priority:1,run:({template:e,options:a})=>{var r=x;Object[r(479)](e,r(485),{value:F,enumerable:!1,writable:!0,configurable:!0})}}],leastHiprintVersion:x(484)}}return D});
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});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sv-print/plugin-api-image",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "add image api to print template",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -32,10 +32,10 @@
32
32
  "author": "",
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "@zumer/snapdom": "^2.0.1",
36
- "sv-print": "^0.2.0"
35
+ "@zumer/snapdom": "^2.0.1"
37
36
  },
38
37
  "devDependencies": {
38
+ "sv-print": "^0.2.0",
39
39
  "vite-plugin-javascript-obfuscator": "^3.1.0"
40
40
  },
41
41
  "peerDependencies": {