@sv-print/plugin-api-image 0.2.3 → 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 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 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 O = (i, e, x) => new Promise((t, s) => {
2
- var u = (o) => {
1
+ var F = (s, t, x) => new Promise((a, l) => {
2
+ var m = (n) => {
3
3
  try {
4
- I(x.next(o));
5
- } catch (d) {
6
- s(d);
4
+ w(x.next(n));
5
+ } catch (c) {
6
+ l(c);
7
7
  }
8
- }, p = (o) => {
8
+ }, u = (n) => {
9
9
  try {
10
- I(x.throw(o));
11
- } catch (d) {
12
- s(d);
10
+ w(x.throw(n));
11
+ } catch (c) {
12
+ l(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 = (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 J } from "@zumer/snapdom";
18
- (function(i, e) {
19
- const x = q, t = i();
17
+ import { snapdom as O } from "@zumer/snapdom";
18
+ (function(s, t) {
19
+ const x = D, a = s();
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());
24
- } catch (s) {
25
- t.push(t.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());
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();
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* () {
42
- 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 + "%");
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.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;
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 _ = [], 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();
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[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();
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)]();
89
+ })), _();
93
90
  };
94
91
  return;
95
92
  }
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();
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" && 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);
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.hinnn[a(203)].run();
107
- } catch (_) {
108
- console[a(209)](a(194)), console.log(_);
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 s.promise();
109
+ return l[x(402)]();
113
110
  });
114
111
  };
115
- (function(i, e) {
116
- for (var x = R, t = i(); ; )
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);
131
+ }
132
+ (function(s, t) {
133
+ for (var x = E, a = s(); ; )
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 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());
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
+ })(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) };
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 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
- 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(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.3",
3
+ "version": "0.2.4",
4
4
  "description": "add image api to print template",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",