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

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 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;
package/dist/index.mjs CHANGED
@@ -1,148 +1,148 @@
1
- var B = (r, e, x) => new Promise((n, i) => {
2
- var h = (o) => {
1
+ var O = (i, e, x) => new Promise((t, s) => {
2
+ var u = (o) => {
3
3
  try {
4
- v(x.next(o));
5
- } catch (b) {
6
- i(b);
4
+ I(x.next(o));
5
+ } catch (d) {
6
+ s(d);
7
7
  }
8
- }, u = (o) => {
8
+ }, p = (o) => {
9
9
  try {
10
- v(x.throw(o));
11
- } catch (b) {
12
- i(b);
10
+ I(x.throw(o));
11
+ } catch (d) {
12
+ s(d);
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
+ }, I = (o) => o.done ? t(o.value) : Promise.resolve(o.value).then(u, p);
15
+ I((x = x.apply(i, e)).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 J } from "@zumer/snapdom";
18
+ (function(i, e) {
19
+ const x = q, t = i();
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(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());
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
+ })(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 + "%");
46
46
  };
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;
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;
55
55
  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();
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();
75
75
  };
76
76
  });
77
77
  });
78
78
  }
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)]();
92
- })), _();
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();
93
93
  };
94
94
  return;
95
95
  }
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)), _();
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();
98
98
  return;
99
99
  }
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);
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);
104
104
  });
105
105
  }
106
- globalThis[t(436)][t(444)][t(454)]();
107
- } catch (f) {
108
- console.error(t(413)), console[t(443)](f);
106
+ globalThis.hinnn[a(203)].run();
107
+ } catch (_) {
108
+ console[a(209)](a(194)), console.log(_);
109
109
  }
110
110
  });
111
111
  }
112
- return i[x(460)]();
112
+ return s.promise();
113
113
  });
114
114
  };
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();
120
- }
121
- (function(r, e) {
122
- for (var x = F, n = r(); ; )
115
+ (function(i, e) {
116
+ for (var x = R, t = i(); ; )
123
117
  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());
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());
129
123
  }
130
- })(E, 702406);
131
- function F(r, e) {
124
+ })(E, 115347);
125
+ function R(i, e) {
132
126
  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);
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) };
138
139
  }
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) };
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();
145
145
  }
146
146
  export {
147
- J as default
147
+ K as default
148
148
  };
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(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});
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.3",
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": {