@sv-print/plugin-api-image 0.1.4 → 0.1.6

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/README.md CHANGED
@@ -8,13 +8,32 @@
8
8
  npm install @sv-print/plugin-api-image
9
9
  ```
10
10
 
11
- ## 使用
11
+ ```js
12
+ import pluginApiImage from "@sv-print/plugin-api-image";
13
+ const plugins = [pluginApiImage({})];
14
+ ```
12
15
 
13
- sv-print 插件引入的两种方式见:[sv-print 插件引入的两种方式:https://www.ibujian.cn/svp/plugin/a02.html](https://www.ibujian.cn/svp/plugin/a02.html)
16
+ ## 示例
14
17
 
15
18
  ```js
16
- import pluginEleBwip from "@sv-print/plugin-ele-bwip-js";
17
- const plugins = [pluginEleBwip({})];
19
+ let hiprintTemplate = new hiprint.PrintTemplate(options);
20
+ // 其中 “text” 是一个元素的 “字段名(field)
21
+ let printData = { text: "这是打印时显示的文本" };
22
+ // 导出图片, 获取 url/blob 对象
23
+ const res = await hiprintTemplate.toImage(printData, {
24
+ isDownload: false, // 不自动下载
25
+ name: "图片名称",
26
+ limit: 10, // 默认 10 多少页为一个 图片文件, 太多 图片文件就很长
27
+ type: "image/jpeg", // 默认 image/jpeg --> canvas.toDataURL(type, quality)
28
+ pixelRatio: 2, // 图片像素比 2: 提高清晰度 默认 window.devicePixelRatio.
29
+ quality: 0.8, // 默认 0.92 图片质量 0-1
30
+ toType: "url", // 默认 url 支持: url、blob
31
+ onProgress: (cur, total) => {
32
+ const percent = Math.floor((cur / total) * 100);
33
+ console.log("toImage 进度", percent);
34
+ },
35
+ });
36
+ console.log("toImage", res);
18
37
  ```
19
38
 
20
39
  ## License
@@ -32,3 +51,7 @@ LGPL
32
51
  4.禁止将本开源的代码和资源进行任何形式任何名义的出售,否则产生的一切任何后果责任由侵权者自负;
33
52
 
34
53
  5.商用请仔细审查代码和漏洞,不得用于任一国家许可范围之外的商业应用,产生的一切任何后果责任自负;
54
+
55
+ ```
56
+
57
+ ```
package/dist/index.js CHANGED
@@ -1 +1,37 @@
1
- "use strict";var W=(r,t,e)=>new Promise((a,l)=>{var h=c=>{try{I(e.next(c))}catch(b){l(b)}},u=c=>{try{I(e.throw(c))}catch(b){l(b)}},I=c=>c.done?a(c.value):Promise.resolve(c.value).then(h,u);I((e=e.apply(r,t)).next())});const E=require("html-to-image");function F(r){if(r&&r.__esModule)return r;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const a=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,a.get?a:{enumerable:!0,get:()=>r[e]})}}return t.default=r,Object.freeze(t)}const L=F(E);(function(r,t){const e=j,a=r();for(;[];)try{if(parseInt(e(289))/1+-parseInt(e(367))/2+parseInt(e(324))/3*(parseInt(e(316))/4)+-parseInt(e(306))/5+parseInt(e(325))/6*(parseInt(e(336))/7)+parseInt(e(344))/8*(parseInt(e(334))/9)+-parseInt(e(308))/10*(-parseInt(e(286))/11)===t)break;a.push(a.shift())}catch(l){a.push(a.shift())}})(M,710956);function M(){const r=["toDataURL","height","baseURI","find","position:fixed","display","download.jpg","loadAllImages","indexOf","length","jpg","remove",".jpg","start","removeTempContainer","log","pixelRatio","add","698464IYwzVZ","resolve","devicePixelRatio","queue","quality","push","imageSmoothingEnabled","run","tagName","image/jpeg","onProgress","toImage percent: ","getHtml","1738qOahFf","toType","floor","451297HqroPf","forEach","includes","svg","getContext","clear","png","getTempContainer","name","jpeg","css","src","IMG","end",".hiprint-printPanel .hiprint-printPaper","style","width","5644560azgNiN","createElement","5920pDYpGT","toImage \u5931\u8D25(\u53EF\u80FD\u60A8\u7684\u56FE\u7247\u8D44\u6E90\u65E0\u6CD5\u6B63\u5E38\u52A0\u8F7D): ","body","appendChild","then","drawImage","onload","hinnn","1052056OdLMHP","url","replace","cur","limit","#fff","isDownload","download","6hwSYbH","6XXeNZP","clearRect","gif","canvas","printPanels","base64","split","promise","none","9xKBDjH","extend","3945767IekuVg","ceil","click","http","toLowerCase","pop","toCanvas","blob","4436464MMWMcf","href","setAttribute","total","bmp"];return M=function(){return r},M()}function j(r,t){const e=M();return j=function(a,l){return a=a-277,e[a]},j(r,t)}const U=function(r,t){return W(this,null,function*(){const e=j;let a=this,l=globalThis.$.Deferred(),h=!![],u=10,I=(c,b)=>{const p=j,T=Math[p(288)](c/b*100);console[p(364)](p(319),c,p(347),b),console[p(364)](p(284),T+"%")};if(this[e(329)].length){let c=globalThis.$[e(335)]({filter:x=>{const n=e;return x.tagName!=n(301)||x[n(281)]==n(301)&&([n(359),n(298),n(295),n(327),n(348),"webp",n(292)][n(291)](x[n(300)].split(".")[n(341)]()[n(340)]())||x[n(300)]!=x.baseURI||x.src[n(357)](n(339))>-1&&x[n(300)]!=x[n(351)]||x[n(300)][n(357)](n(330))>-1)},backgroundColor:e(321)},t||{}),b=yield this[e(285)](r,t);t&&t[e(322)]!=null&&(h=t.isDownload),t&&t[e(283)]!=null&&(I=t.onProgress),t&&t[e(320)]!=null&&(u=t.limit),globalThis.$(b)[e(299)]("width","")[e(299)](e(350),""),this.createTempContainer();let p=this[e(296)]();this.svg2canvas(b,c),p.html(b[0]);let T=p[e(352)](e(303))[e(358)];globalThis.$(b)[e(299)](e(353)),this[e(356)](b,function(){const x=e;try{let n=[],R=Math[x(337)](T/u),X=T%u||1;const f=document[x(307)](x(328)),C=f[x(293)]("2d"),H=p.width()*(c[x(365)]||globalThis[x(369)]);for(let v=0;v<R;v++){C[x(326)](0,0,f[x(305)],f[x(350)]);const O=v==R-1;let G=0,D=O?X:u;for(let g=0;g<D;g++){C[x(326)](0,0,f[x(305)],f.height);const i=v*u+g,y=p[x(352)](x(303))[i];globalThis[x(315)][x(370)].add(function(k){const _=x;L[_(342)](y,c)[_(312)](function(m){const s=_;let w=m[s(293)]("2d");w[s(279)]=![];let P=m.toDataURL(s(282),c[s(277)]||.92),o=new Image;o[s(300)]=P,o[s(314)]=function(){const d=s;g===0&&(f[d(305)]=H,f.height=o[d(350)]*D),G+=o[d(350)],C[d(313)](o,0,G-o[d(350)],H,o[d(350)]),I(i+1,T),k()}})})}globalThis[x(315)].queue[x(366)](function(g){const i=x;let y=c.type||i(282),k=c[i(287)]||"url",_=c.quality||.8;if(h){let m=f[i(349)](y,_),s=new Image;s[i(300)]=m,s[i(314)]=function(){const w=i;n.push({url:m,start:v*u+1,end:v*u+D}),O&&(globalThis.hinnn[w(370)].clear(),a[w(363)](),n[w(290)](P=>{const o=w;let d=document.createElement("a"),q=t[o(297)]||o(355);q.indexOf(".")==-1&&(q+=o(361));let S=q[o(331)](".")[o(341)](),Y=q[o(318)]("."+S,"")+"_"+P[o(362)]+"-"+P[o(302)]+"."+S;d[o(304)][o(354)]=o(333),d.setAttribute(o(323),Y),d[o(346)](o(345),P[o(317)]),document[o(310)][o(311)](d),d[o(338)](),d[o(360)]()})),g()};return}if(k==i(317)){n.push(f[i(349)](y,_)),O&&(globalThis[i(315)][i(370)][i(294)](),a[i(363)](),l[i(368)](n)),g();return}k==i(343)&&f.toBlob(function(m){const s=i;n[s(278)](m),O&&(globalThis[s(315)][s(370)].clear(),a[s(363)](),l[s(368)](n)),g()},y,_)})}globalThis[x(315)].queue[x(280)]()}catch(n){console.error(x(309)),console[x(364)](n)}})}return l[e(332)]()})};function N(r,t){var e=A();return N=function(a,l){a=a-132;var h=e[a];return h},N(r,t)}(function(r,t){for(var e=N,a=r();[];)try{var l=parseInt(e(141))/1+-parseInt(e(142))/2*(parseInt(e(144))/3)+-parseInt(e(143))/4*(-parseInt(e(139))/5)+-parseInt(e(138))/6+-parseInt(e(136))/7+-parseInt(e(134))/8*(-parseInt(e(132))/9)+parseInt(e(137))/10;if(l===t)break;a.push(a.shift())}catch(h){a.push(a.shift())}})(A,429921);function Z(r){var t=N;return{name:"add toImage Api",description:"add toImage Api",hooks:[{hook:t(140),name:t(135),description:t(135),priority:1,run:({template:e,options:a})=>{var l=t;Object.defineProperty(e,l(133),{value:U,enumerable:![],writable:!![],configurable:!![]})}}],leastHiprintVersion:"0.3.0"}}function A(){var r=["add toImage Api to PrintTemplate","53613RFXdgt","2654180GiWpZa","899760buZBGF","42740jYPwWY","newPrintTemplate","243290IFIGAk","765172hmfXSH","196NPJNIG","6qNKtTX","72dAWOWk","toImage","425152nOqmtJ"];return A=function(){return r},A()}module.exports=Z;
1
+ "use strict";var H=(r,e,x)=>new Promise((n,s)=>{var _=o=>{try{T(x.next(o))}catch(d){s(d)}},f=o=>{try{T(x.throw(o))}catch(d){s(d)}},T=o=>o.done?n(o.value):Promise.resolve(o.value).then(_,f);T((x=x.apply(r,e)).next())});const z=require("html-to-image");function X(r){if(r&&r.__esModule)return r;const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const x in r)if(x!=="default"){const n=Object.getOwnPropertyDescriptor(r,x);Object.defineProperty(e,x,n.get?n:{enumerable:!0,get:()=>r[x]})}}return e.default=r,Object.freeze(e)}const F=X(z);(function(r,e){const x=G,n=r();for(;[];)try{if(-parseInt(x(214))/1+parseInt(x(216))/2*(parseInt(x(156))/3)+-parseInt(x(209))/4+parseInt(x(235))/5*(parseInt(x(141))/6)+parseInt(x(201))/7+parseInt(x(138))/8*(parseInt(x(133))/9)+-parseInt(x(195))/10===e)break;n.push(n.shift())}catch(s){n.push(n.shift())}})(U,530777);function G(r,e){const x=U();return G=function(n,s){return n=n-125,x[n]},G(r,e)}function U(){const r=["panelLayoutOptions","getHtml","log","tagName","split","push","bmp","png","layoutColumnGap",`mm;
2
+ }
3
+ </style>`,"promise","error","svg","pop","isDownload","mm -","clear",'<div class="hiprint-printTemplate"></div>',"remove","gif","5574770ZFkrus","display","start","download.jpg","then","getContext","2980565JyqIBA","paperHeight",".hiprint-printPaper","webp","createElement","devicePixelRatio","printPanels","href","1440824kCvhdt","IMG","body","baseURI","type","256445KocNgi","removeClass","26204gqFAmG","height","url","toImage percent: ","Deferred","http","css","quality","min","paperWidth","jpeg","mm ","clone","position:fixed","add","clearRect","pixelRatio","ceil","end","15PmlZWM",".hiprint-printPanel .hiprint-printPaper","find","getTempContainer","extend","replace",`mm;"></div>
4
+ </div>`,"canvas","download","click","hinnn","createTempContainer","includes","setAttribute","6577731vQhOou","layoutRowGap","src","jpg",'<div class="hiprint-printPanel-small"></div>',"8EJUwVc","toImage \u5931\u8D25(\u53EF\u80FD\u60A8\u7684\u56FE\u7247\u8D44\u6E90\u65E0\u6CD5\u6B63\u5E38\u52A0\u8F7D): ","width","677238fBeALd","indexOf","toBlob","style","layoutType","forEach","toLowerCase",`<style>
5
+ .hiprint-printPanel-small{
6
+ box-sizing: border-box;
7
+ border: 0px;
8
+ }
9
+ .hiprint-printPaper-small{
10
+ position: relative;
11
+ padding: 0;
12
+ }
13
+ .hiprint-printTemplate .hiprint-printPaper{
14
+ margin: -`,"onload","resolve","total","mm;height:","base64","svg2canvas",".hiprint-printPanel","48LVERkP","image/jpeg","append","length","html","floor","row","onProgress","none","run","removeTempContainer","limit","queue","toDataURL","appendChild","blob","drawImage",`mm;
15
+ }
16
+ .hiprint-printTemplate .hiprint-printPanel-small {
17
+ display:inline-block;
18
+ padding: `,"#fff"];return U=function(){return r},U()}const J=function(r,e){return H(this,null,function*(){const x=G;let n=this,s=globalThis.$[x(220)](),_=!![],f=10,T=(o,d)=>{const m=x,$=Math[m(161)](o/d*100);console[m(177)]("cur",o,m(151),d),console.log(m(219),$+"%")};if(this.printPanels.length){let o=globalThis.$[x(239)]({filter:t=>{const a=x;return t[a(178)]!=a(210)||t[a(178)]==a(210)&&([a(136),a(226),a(182),a(194),a(181),a(204),a(187)][a(131)](t[a(135)][a(179)](".")[a(188)]()[a(147)]())||t[a(135)]!=t[a(212)]||t[a(135)][a(142)](a(221))>-1&&t[a(135)]!=t[a(212)]||t[a(135)][a(142)](a(153))>-1)},backgroundColor:x(174)},e||{}),d=yield this[x(176)](r,e);e&&e[x(189)]!=null&&(_=e[x(189)]),e&&e[x(163)]!=null&&(T=e[x(163)]),e&&e[x(167)]!=null&&(f=e[x(167)]),globalThis.$(d)[x(222)]("width","").css("height",""),this[x(130)]();let m=this[x(238)](),$=this[x(207)][0][x(140)],Z=this[x(207)][0].height;const c=this[x(207)][0][x(175)];if(c&&(c[x(134)]>0||c[x(183)]>0)&&e[x(225)]&&e[x(202)]){let t=Math.floor(e[x(225)]/($+c.layoutRowGap/2)),a=Math[x(161)](e[x(202)]/(Z+c[x(183)]/2));const C=t*a,E=d[x(237)](x(236)),b=E.length,q=Math[x(233)](b/C);let I=globalThis.$(x(192));c[x(145)]==x(162)?I[x(158)](x(148)+(Number(c[x(134)])||0)/2+x(190)+(Number(c[x(183)])||0)/2+`mm;
19
+ }
20
+ .hiprint-printTemplate .hiprint-printPanel-small {
21
+ display:inline-block;
22
+ padding: `+(Number(c[x(134)])||0)/2+"mm "+(Number(c.layoutColumnGap)||0)/2+x(184)):I[x(158)](`<style>
23
+ .hiprint-printPanel-small{
24
+ box-sizing: border-box;
25
+ border: 0px;
26
+ }
27
+ .hiprint-printPaper-small{
28
+ position: relative;
29
+ padding: 0;
30
+ }
31
+ .hiprint-printTemplate .hiprint-printPaper{
32
+ display: flex;
33
+ flex-wrap: wrap;
34
+ flex-direction: column;
35
+ align-content: flex-start;
36
+ margin: -`+(Number(c.layoutRowGap)||0)/2+"mm -"+(Number(c[x(183)])||0)/2+x(173)+(Number(c[x(134)])||0)/2+x(227)+(Number(c.layoutColumnGap)||0)/2+x(184));for(let P=0;P<q;P++){const g=globalThis.$(`<div class="hiprint-printPanel">
37
+ <div class="hiprint-printPaper" style="width:`+e[x(225)]+x(152)+e.paperHeight+x(125)),k=P*C,M=Math[x(224)]((P+1)*C,b);for(let v=k;v<M;v++){const u=E.eq(v)[x(228)]();u[x(215)]("hiprint-printPaper"),u.addClass("hiprint-printPaper-small start-"+v);const l=globalThis.$(x(137));l.append(u),g[x(237)](x(203))[x(158)](l)}I.append(g)}this[x(154)](I,o),m[x(160)](I[0])}else this.svg2canvas(d,o),m[x(160)](d[0]);let B=m[x(237)](x(236))[x(159)];globalThis.$(d)[x(222)](x(229)),this.loadAllImages(d,function(){const t=x;try{let a=[],C=Math[t(233)](B/f),E=B%f||1;const b=document[t(205)](t(126)),q=b[t(200)]("2d"),I=m[t(237)](t(155)).eq(0).width(),P=I*(o[t(232)]||globalThis[t(206)]);for(let g=0;g<C;g++){q[t(231)](0,0,b[t(140)],b[t(217)]);const k=g==C-1;let M=0,v=k?E:f;for(let u=0;u<v;u++){q[t(231)](0,0,b.width,b[t(217)]);const l=g*f+u,j=m[t(237)](".hiprint-printPanel .hiprint-printPaper")[l];globalThis[t(129)].queue.add(function(R){const N=t;F.toCanvas(j,o)[N(199)](function(w){const p=N;let y=w.getContext("2d");y.imageSmoothingEnabled=![];let A=w.toDataURL(p(157),o[p(223)]||.92),i=new Image;i[p(135)]=A,i[p(149)]=function(){const h=p;u===0&&(b[h(140)]=P,b[h(217)]=i[h(217)]*v),M+=i[h(217)],q[h(172)](i,0,M-i[h(217)],P,i.height),T(l+1,B),R()}})})}globalThis[t(129)][t(168)][t(230)](function(u){const l=t;let j=o[l(213)]||l(157),R=o.toType||"url",N=o.quality||.8;if(_){let w=b[l(169)](j,N),p=new Image;p[l(135)]=w,p[l(149)]=function(){const y=l;a.push({url:w,start:g*f+1,end:g*f+v}),k&&(globalThis[y(129)][y(168)][y(191)](),n[y(166)](),a[y(146)](A=>{const i=y;let h=document.createElement("a"),O=e.name||i(198);O[i(142)](".")==-1&&(O+=".jpg");let L=O[i(179)](".").pop(),S=O[i(240)]("."+L,"")+"_"+A[i(197)]+"-"+A[i(234)]+"."+L;h[i(144)][i(196)]=i(164),h[i(132)](i(127),S),h[i(132)](i(208),A[i(218)]),document[i(211)][i(170)](h),h[i(128)](),h[i(193)]()})),u()};return}if(R==l(218)){a[l(180)](b[l(169)](j,N)),k&&(globalThis.hinnn.queue.clear(),n[l(166)](),s.resolve(a)),u();return}R==l(171)&&b[l(143)](function(w){const p=l;a[p(180)](w),k&&(globalThis[p(129)][p(168)][p(191)](),n[p(166)](),s[p(150)](a)),u()},j,N)})}globalThis[t(129)].queue[t(165)]()}catch(a){console[t(186)](t(139)),console[t(177)](a)}})}return s[x(185)]()})};function V(r,e){var x=D();return V=function(n,s){n=n-439;var _=x[n];return _},V(r,e)}(function(r,e){for(var x=V,n=r();[];)try{var s=-parseInt(x(449))/1+-parseInt(x(450))/2+-parseInt(x(441))/3*(-parseInt(x(451))/4)+-parseInt(x(440))/5+-parseInt(x(448))/6+-parseInt(x(445))/7*(parseInt(x(444))/8)+parseInt(x(452))/9;if(s===e)break;n.push(n.shift())}catch(_){n.push(n.shift())}})(D,672242);function D(){var r=["toImage","newPrintTemplate","5735748wEEXNA","866176wrVrBA","2662854EUUogl","124DeyVZy","40837464ixUXSs","defineProperty","add toImage Api to PrintTemplate","478835hEHDBX","53187kqUhVY","0.3.0","add toImage Api","40AVZCZk","1631735VNBrko"];return D=function(){return r},D()}function W(r){var e=V;return{name:e(443),description:e(443),hooks:[{hook:e(447),name:e(439),description:e(439),priority:1,run:({template:x,options:n})=>{var s=e;Object[s(453)](x,s(446),{value:J,enumerable:![],writable:!![],configurable:!![]})}}],leastHiprintVersion:e(442)}}module.exports=W;
package/dist/index.mjs CHANGED
@@ -1,153 +1,207 @@
1
- var X = (c, n, x) => new Promise((o, l) => {
2
- var h = (r) => {
1
+ var Z = (l, a, x) => new Promise((i, p) => {
2
+ var _ = (r) => {
3
3
  try {
4
- I(x.next(r));
5
- } catch (p) {
6
- l(p);
4
+ T(x.next(r));
5
+ } catch (d) {
6
+ p(d);
7
7
  }
8
- }, u = (r) => {
8
+ }, f = (r) => {
9
9
  try {
10
- I(x.throw(r));
11
- } catch (p) {
12
- l(p);
10
+ T(x.throw(r));
11
+ } catch (d) {
12
+ p(d);
13
13
  }
14
- }, I = (r) => r.done ? o(r.value) : Promise.resolve(r.value).then(h, u);
15
- I((x = x.apply(c, n)).next());
14
+ }, T = (r) => r.done ? i(r.value) : Promise.resolve(r.value).then(_, f);
15
+ T((x = x.apply(l, a)).next());
16
16
  });
17
- import * as F from "html-to-image";
18
- (function(c, n) {
19
- const x = k, o = c();
17
+ import * as z from "html-to-image";
18
+ (function(l, a) {
19
+ const x = V, i = l();
20
20
  for (; []; )
21
21
  try {
22
- if (parseInt(x(289)) / 1 + -parseInt(x(367)) / 2 + parseInt(x(324)) / 3 * (parseInt(x(316)) / 4) + -parseInt(x(306)) / 5 + parseInt(x(325)) / 6 * (parseInt(x(336)) / 7) + parseInt(x(344)) / 8 * (parseInt(x(334)) / 9) + -parseInt(x(308)) / 10 * (-parseInt(x(286)) / 11) === n)
22
+ if (-parseInt(x(214)) / 1 + parseInt(x(216)) / 2 * (parseInt(x(156)) / 3) + -parseInt(x(209)) / 4 + parseInt(x(235)) / 5 * (parseInt(x(141)) / 6) + parseInt(x(201)) / 7 + parseInt(x(138)) / 8 * (parseInt(x(133)) / 9) + -parseInt(x(195)) / 10 === a)
23
23
  break;
24
- o.push(o.shift());
25
- } catch (l) {
26
- o.push(o.shift());
24
+ i.push(i.shift());
25
+ } catch (p) {
26
+ i.push(i.shift());
27
27
  }
28
- })(C, 710956);
29
- function C() {
30
- const c = ["toDataURL", "height", "baseURI", "find", "position:fixed", "display", "download.jpg", "loadAllImages", "indexOf", "length", "jpg", "remove", ".jpg", "start", "removeTempContainer", "log", "pixelRatio", "add", "698464IYwzVZ", "resolve", "devicePixelRatio", "queue", "quality", "push", "imageSmoothingEnabled", "run", "tagName", "image/jpeg", "onProgress", "toImage percent: ", "getHtml", "1738qOahFf", "toType", "floor", "451297HqroPf", "forEach", "includes", "svg", "getContext", "clear", "png", "getTempContainer", "name", "jpeg", "css", "src", "IMG", "end", ".hiprint-printPanel .hiprint-printPaper", "style", "width", "5644560azgNiN", "createElement", "5920pDYpGT", "toImage \u5931\u8D25(\u53EF\u80FD\u60A8\u7684\u56FE\u7247\u8D44\u6E90\u65E0\u6CD5\u6B63\u5E38\u52A0\u8F7D): ", "body", "appendChild", "then", "drawImage", "onload", "hinnn", "1052056OdLMHP", "url", "replace", "cur", "limit", "#fff", "isDownload", "download", "6hwSYbH", "6XXeNZP", "clearRect", "gif", "canvas", "printPanels", "base64", "split", "promise", "none", "9xKBDjH", "extend", "3945767IekuVg", "ceil", "click", "http", "toLowerCase", "pop", "toCanvas", "blob", "4436464MMWMcf", "href", "setAttribute", "total", "bmp"];
31
- return C = function() {
32
- return c;
33
- }, C();
28
+ })($, 530777);
29
+ function V(l, a) {
30
+ const x = $();
31
+ return V = function(i, p) {
32
+ return i = i - 125, x[i];
33
+ }, V(l, a);
34
34
  }
35
- function k(c, n) {
36
- const x = C();
37
- return k = function(o, l) {
38
- return o = o - 277, x[o];
39
- }, k(c, n);
35
+ function $() {
36
+ const l = ["panelLayoutOptions", "getHtml", "log", "tagName", "split", "push", "bmp", "png", "layoutColumnGap", `mm;
37
+ }
38
+ </style>`, "promise", "error", "svg", "pop", "isDownload", "mm -", "clear", '<div class="hiprint-printTemplate"></div>', "remove", "gif", "5574770ZFkrus", "display", "start", "download.jpg", "then", "getContext", "2980565JyqIBA", "paperHeight", ".hiprint-printPaper", "webp", "createElement", "devicePixelRatio", "printPanels", "href", "1440824kCvhdt", "IMG", "body", "baseURI", "type", "256445KocNgi", "removeClass", "26204gqFAmG", "height", "url", "toImage percent: ", "Deferred", "http", "css", "quality", "min", "paperWidth", "jpeg", "mm ", "clone", "position:fixed", "add", "clearRect", "pixelRatio", "ceil", "end", "15PmlZWM", ".hiprint-printPanel .hiprint-printPaper", "find", "getTempContainer", "extend", "replace", `mm;"></div>
39
+ </div>`, "canvas", "download", "click", "hinnn", "createTempContainer", "includes", "setAttribute", "6577731vQhOou", "layoutRowGap", "src", "jpg", '<div class="hiprint-printPanel-small"></div>', "8EJUwVc", "toImage \u5931\u8D25(\u53EF\u80FD\u60A8\u7684\u56FE\u7247\u8D44\u6E90\u65E0\u6CD5\u6B63\u5E38\u52A0\u8F7D): ", "width", "677238fBeALd", "indexOf", "toBlob", "style", "layoutType", "forEach", "toLowerCase", `<style>
40
+ .hiprint-printPanel-small{
41
+ box-sizing: border-box;
42
+ border: 0px;
43
+ }
44
+ .hiprint-printPaper-small{
45
+ position: relative;
46
+ padding: 0;
47
+ }
48
+ .hiprint-printTemplate .hiprint-printPaper{
49
+ margin: -`, "onload", "resolve", "total", "mm;height:", "base64", "svg2canvas", ".hiprint-printPanel", "48LVERkP", "image/jpeg", "append", "length", "html", "floor", "row", "onProgress", "none", "run", "removeTempContainer", "limit", "queue", "toDataURL", "appendChild", "blob", "drawImage", `mm;
50
+ }
51
+ .hiprint-printTemplate .hiprint-printPanel-small {
52
+ display:inline-block;
53
+ padding: `, "#fff"];
54
+ return $ = function() {
55
+ return l;
56
+ }, $();
40
57
  }
41
- const L = function(c, n) {
42
- return X(this, null, function* () {
43
- const x = k;
44
- let o = this, l = globalThis.$.Deferred(), h = !![], u = 10, I = (r, p) => {
45
- const b = k, T = Math[b(288)](r / p * 100);
46
- console[b(364)](b(319), r, b(347), p), console[b(364)](b(284), T + "%");
58
+ const F = function(l, a) {
59
+ return Z(this, null, function* () {
60
+ const x = V;
61
+ let i = this, p = globalThis.$[x(220)](), _ = !![], f = 10, T = (r, d) => {
62
+ const u = x, D = Math[u(161)](r / d * 100);
63
+ console[u(177)]("cur", r, u(151), d), console.log(u(219), D + "%");
47
64
  };
48
- if (this[x(329)].length) {
49
- let r = globalThis.$[x(335)]({ filter: (e) => {
65
+ if (this.printPanels.length) {
66
+ let r = globalThis.$[x(239)]({ filter: (e) => {
50
67
  const t = x;
51
- return e.tagName != t(301) || e[t(281)] == t(301) && ([t(359), t(298), t(295), t(327), t(348), "webp", t(292)][t(291)](e[t(300)].split(".")[t(341)]()[t(340)]()) || e[t(300)] != e.baseURI || e.src[t(357)](t(339)) > -1 && e[t(300)] != e[t(351)] || e[t(300)][t(357)](t(330)) > -1);
52
- }, backgroundColor: x(321) }, n || {}), p = yield this[x(285)](c, n);
53
- n && n[x(322)] != null && (h = n.isDownload), n && n[x(283)] != null && (I = n.onProgress), n && n[x(320)] != null && (u = n.limit), globalThis.$(p)[x(299)]("width", "")[x(299)](x(350), ""), this.createTempContainer();
54
- let b = this[x(296)]();
55
- this.svg2canvas(p, r), b.html(p[0]);
56
- let T = b[x(352)](x(303))[x(358)];
57
- globalThis.$(p)[x(299)](x(353)), this[x(356)](p, function() {
68
+ return e[t(178)] != t(210) || e[t(178)] == t(210) && ([t(136), t(226), t(182), t(194), t(181), t(204), t(187)][t(131)](e[t(135)][t(179)](".")[t(188)]()[t(147)]()) || e[t(135)] != e[t(212)] || e[t(135)][t(142)](t(221)) > -1 && e[t(135)] != e[t(212)] || e[t(135)][t(142)](t(153)) > -1);
69
+ }, backgroundColor: x(174) }, a || {}), d = yield this[x(176)](l, a);
70
+ a && a[x(189)] != null && (_ = a[x(189)]), a && a[x(163)] != null && (T = a[x(163)]), a && a[x(167)] != null && (f = a[x(167)]), globalThis.$(d)[x(222)]("width", "").css("height", ""), this[x(130)]();
71
+ let u = this[x(238)](), D = this[x(207)][0][x(140)], O = this[x(207)][0].height;
72
+ const c = this[x(207)][0][x(175)];
73
+ if (c && (c[x(134)] > 0 || c[x(183)] > 0) && a[x(225)] && a[x(202)]) {
74
+ let e = Math.floor(a[x(225)] / (D + c.layoutRowGap / 2)), t = Math[x(161)](a[x(202)] / (O + c[x(183)] / 2));
75
+ const C = e * t, R = d[x(237)](x(236)), b = R.length, q = Math[x(233)](b / C);
76
+ let I = globalThis.$(x(192));
77
+ c[x(145)] == x(162) ? I[x(158)](x(148) + (Number(c[x(134)]) || 0) / 2 + x(190) + (Number(c[x(183)]) || 0) / 2 + `mm;
78
+ }
79
+ .hiprint-printTemplate .hiprint-printPanel-small {
80
+ display:inline-block;
81
+ padding: ` + (Number(c[x(134)]) || 0) / 2 + "mm " + (Number(c.layoutColumnGap) || 0) / 2 + x(184)) : I[x(158)](`<style>
82
+ .hiprint-printPanel-small{
83
+ box-sizing: border-box;
84
+ border: 0px;
85
+ }
86
+ .hiprint-printPaper-small{
87
+ position: relative;
88
+ padding: 0;
89
+ }
90
+ .hiprint-printTemplate .hiprint-printPaper{
91
+ display: flex;
92
+ flex-wrap: wrap;
93
+ flex-direction: column;
94
+ align-content: flex-start;
95
+ margin: -` + (Number(c.layoutRowGap) || 0) / 2 + "mm -" + (Number(c[x(183)]) || 0) / 2 + x(173) + (Number(c[x(134)]) || 0) / 2 + x(227) + (Number(c.layoutColumnGap) || 0) / 2 + x(184));
96
+ for (let P = 0; P < q; P++) {
97
+ const g = globalThis.$(`<div class="hiprint-printPanel">
98
+ <div class="hiprint-printPaper" style="width:` + a[x(225)] + x(152) + a.paperHeight + x(125)), k = P * C, G = Math[x(224)]((P + 1) * C, b);
99
+ for (let v = k; v < G; v++) {
100
+ const m = R.eq(v)[x(228)]();
101
+ m[x(215)]("hiprint-printPaper"), m.addClass("hiprint-printPaper-small start-" + v);
102
+ const o = globalThis.$(x(137));
103
+ o.append(m), g[x(237)](x(203))[x(158)](o);
104
+ }
105
+ I.append(g);
106
+ }
107
+ this[x(154)](I, r), u[x(160)](I[0]);
108
+ } else
109
+ this.svg2canvas(d, r), u[x(160)](d[0]);
110
+ let L = u[x(237)](x(236))[x(159)];
111
+ globalThis.$(d)[x(222)](x(229)), this.loadAllImages(d, function() {
58
112
  const e = x;
59
113
  try {
60
- let t = [], M = Math[e(337)](T / u), Y = T % u || 1;
61
- const f = document[e(307)](e(328)), D = f[e(293)]("2d"), O = b.width() * (r[e(365)] || globalThis[e(369)]);
62
- for (let v = 0; v < M; v++) {
63
- D[e(326)](0, 0, f[e(305)], f[e(350)]);
64
- const q = v == M - 1;
65
- let G = 0, H = q ? Y : u;
66
- for (let g = 0; g < H; g++) {
67
- D[e(326)](0, 0, f[e(305)], f.height);
68
- const i = v * u + g, P = b[e(352)](e(303))[i];
69
- globalThis[e(315)][e(370)].add(function(j) {
70
- const _ = e;
71
- F[_(342)](P, r)[_(312)](function(m) {
72
- const s = _;
73
- let w = m[s(293)]("2d");
74
- w[s(279)] = ![];
75
- let y = m.toDataURL(s(282), r[s(277)] || 0.92), a = new Image();
76
- a[s(300)] = y, a[s(314)] = function() {
77
- const d = s;
78
- g === 0 && (f[d(305)] = O, f.height = a[d(350)] * H), G += a[d(350)], D[d(313)](a, 0, G - a[d(350)], O, a[d(350)]), I(i + 1, T), j();
114
+ let t = [], C = Math[e(233)](L / f), R = L % f || 1;
115
+ const b = document[e(205)](e(126)), q = b[e(200)]("2d"), I = u[e(237)](e(155)).eq(0).width(), P = I * (r[e(232)] || globalThis[e(206)]);
116
+ for (let g = 0; g < C; g++) {
117
+ q[e(231)](0, 0, b[e(140)], b[e(217)]);
118
+ const k = g == C - 1;
119
+ let G = 0, v = k ? R : f;
120
+ for (let m = 0; m < v; m++) {
121
+ q[e(231)](0, 0, b.width, b[e(217)]);
122
+ const o = g * f + m, A = u[e(237)](".hiprint-printPanel .hiprint-printPaper")[o];
123
+ globalThis[e(129)].queue.add(function(M) {
124
+ const N = e;
125
+ z.toCanvas(A, r)[N(199)](function(w) {
126
+ const s = N;
127
+ let y = w.getContext("2d");
128
+ y.imageSmoothingEnabled = ![];
129
+ let E = w.toDataURL(s(157), r[s(223)] || 0.92), n = new Image();
130
+ n[s(135)] = E, n[s(149)] = function() {
131
+ const h = s;
132
+ m === 0 && (b[h(140)] = P, b[h(217)] = n[h(217)] * v), G += n[h(217)], q[h(172)](n, 0, G - n[h(217)], P, n.height), T(o + 1, L), M();
79
133
  };
80
134
  });
81
135
  });
82
136
  }
83
- globalThis[e(315)].queue[e(366)](function(g) {
84
- const i = e;
85
- let P = r.type || i(282), j = r[i(287)] || "url", _ = r.quality || 0.8;
86
- if (h) {
87
- let m = f[i(349)](P, _), s = new Image();
88
- s[i(300)] = m, s[i(314)] = function() {
89
- const w = i;
90
- t.push({ url: m, start: v * u + 1, end: v * u + H }), q && (globalThis.hinnn[w(370)].clear(), o[w(363)](), t[w(290)]((y) => {
91
- const a = w;
92
- let d = document.createElement("a"), A = n[a(297)] || a(355);
93
- A.indexOf(".") == -1 && (A += a(361));
94
- let W = A[a(331)](".")[a(341)](), E = A[a(318)]("." + W, "") + "_" + y[a(362)] + "-" + y[a(302)] + "." + W;
95
- d[a(304)][a(354)] = a(333), d.setAttribute(a(323), E), d[a(346)](a(345), y[a(317)]), document[a(310)][a(311)](d), d[a(338)](), d[a(360)]();
96
- })), g();
137
+ globalThis[e(129)][e(168)][e(230)](function(m) {
138
+ const o = e;
139
+ let A = r[o(213)] || o(157), M = r.toType || "url", N = r.quality || 0.8;
140
+ if (_) {
141
+ let w = b[o(169)](A, N), s = new Image();
142
+ s[o(135)] = w, s[o(149)] = function() {
143
+ const y = o;
144
+ t.push({ url: w, start: g * f + 1, end: g * f + v }), k && (globalThis[y(129)][y(168)][y(191)](), i[y(166)](), t[y(146)]((E) => {
145
+ const n = y;
146
+ let h = document.createElement("a"), U = a.name || n(198);
147
+ U[n(142)](".") == -1 && (U += ".jpg");
148
+ let H = U[n(179)](".").pop(), X = U[n(240)]("." + H, "") + "_" + E[n(197)] + "-" + E[n(234)] + "." + H;
149
+ h[n(144)][n(196)] = n(164), h[n(132)](n(127), X), h[n(132)](n(208), E[n(218)]), document[n(211)][n(170)](h), h[n(128)](), h[n(193)]();
150
+ })), m();
97
151
  };
98
152
  return;
99
153
  }
100
- if (j == i(317)) {
101
- t.push(f[i(349)](P, _)), q && (globalThis[i(315)][i(370)][i(294)](), o[i(363)](), l[i(368)](t)), g();
154
+ if (M == o(218)) {
155
+ t[o(180)](b[o(169)](A, N)), k && (globalThis.hinnn.queue.clear(), i[o(166)](), p.resolve(t)), m();
102
156
  return;
103
157
  }
104
- j == i(343) && f.toBlob(function(m) {
105
- const s = i;
106
- t[s(278)](m), q && (globalThis[s(315)][s(370)].clear(), o[s(363)](), l[s(368)](t)), g();
107
- }, P, _);
158
+ M == o(171) && b[o(143)](function(w) {
159
+ const s = o;
160
+ t[s(180)](w), k && (globalThis[s(129)][s(168)][s(191)](), i[s(166)](), p[s(150)](t)), m();
161
+ }, A, N);
108
162
  });
109
163
  }
110
- globalThis[e(315)].queue[e(280)]();
164
+ globalThis[e(129)].queue[e(165)]();
111
165
  } catch (t) {
112
- console.error(e(309)), console[e(364)](t);
166
+ console[e(186)](e(139)), console[e(177)](t);
113
167
  }
114
168
  });
115
169
  }
116
- return l[x(332)]();
170
+ return p[x(185)]();
117
171
  });
118
172
  };
119
- function N(c, n) {
120
- var x = R();
121
- return N = function(o, l) {
122
- o = o - 132;
123
- var h = x[o];
124
- return h;
125
- }, N(c, n);
173
+ function j(l, a) {
174
+ var x = B();
175
+ return j = function(i, p) {
176
+ i = i - 439;
177
+ var _ = x[i];
178
+ return _;
179
+ }, j(l, a);
126
180
  }
127
- (function(c, n) {
128
- for (var x = N, o = c(); []; )
181
+ (function(l, a) {
182
+ for (var x = j, i = l(); []; )
129
183
  try {
130
- var l = parseInt(x(141)) / 1 + -parseInt(x(142)) / 2 * (parseInt(x(144)) / 3) + -parseInt(x(143)) / 4 * (-parseInt(x(139)) / 5) + -parseInt(x(138)) / 6 + -parseInt(x(136)) / 7 + -parseInt(x(134)) / 8 * (-parseInt(x(132)) / 9) + parseInt(x(137)) / 10;
131
- if (l === n)
184
+ var p = -parseInt(x(449)) / 1 + -parseInt(x(450)) / 2 + -parseInt(x(441)) / 3 * (-parseInt(x(451)) / 4) + -parseInt(x(440)) / 5 + -parseInt(x(448)) / 6 + -parseInt(x(445)) / 7 * (parseInt(x(444)) / 8) + parseInt(x(452)) / 9;
185
+ if (p === a)
132
186
  break;
133
- o.push(o.shift());
134
- } catch (h) {
135
- o.push(o.shift());
187
+ i.push(i.shift());
188
+ } catch (_) {
189
+ i.push(i.shift());
136
190
  }
137
- })(R, 429921);
138
- function Z(c) {
139
- var n = N;
140
- return { name: "add toImage Api", description: "add toImage Api", hooks: [{ hook: n(140), name: n(135), description: n(135), priority: 1, run: ({ template: x, options: o }) => {
141
- var l = n;
142
- Object.defineProperty(x, l(133), { value: L, enumerable: ![], writable: !![], configurable: !![] });
143
- } }], leastHiprintVersion: "0.3.0" };
191
+ })(B, 672242);
192
+ function B() {
193
+ var l = ["toImage", "newPrintTemplate", "5735748wEEXNA", "866176wrVrBA", "2662854EUUogl", "124DeyVZy", "40837464ixUXSs", "defineProperty", "add toImage Api to PrintTemplate", "478835hEHDBX", "53187kqUhVY", "0.3.0", "add toImage Api", "40AVZCZk", "1631735VNBrko"];
194
+ return B = function() {
195
+ return l;
196
+ }, B();
144
197
  }
145
- function R() {
146
- var c = ["add toImage Api to PrintTemplate", "53613RFXdgt", "2654180GiWpZa", "899760buZBGF", "42740jYPwWY", "newPrintTemplate", "243290IFIGAk", "765172hmfXSH", "196NPJNIG", "6qNKtTX", "72dAWOWk", "toImage", "425152nOqmtJ"];
147
- return R = function() {
148
- return c;
149
- }, R();
198
+ function W(l) {
199
+ var a = j;
200
+ return { name: a(443), description: a(443), hooks: [{ hook: a(447), name: a(439), description: a(439), priority: 1, run: ({ template: x, options: i }) => {
201
+ var p = a;
202
+ Object[p(453)](x, p(446), { value: F, enumerable: ![], writable: !![], configurable: !![] });
203
+ } }], leastHiprintVersion: a(442) };
150
204
  }
151
205
  export {
152
- Z as default
206
+ W as default
153
207
  };
package/dist/index.umd.js CHANGED
@@ -1 +1,37 @@
1
- (function(b,_){typeof exports=="object"&&typeof module!="undefined"?module.exports=_(require("html-to-image")):typeof define=="function"&&define.amd?define(["html-to-image"],_):(b=typeof globalThis!="undefined"?globalThis:b||self,b.pluginApiImage=_(b.htmlToImage))})(this,function(b){"use strict";var L=(b,_,w)=>new Promise((y,h)=>{var H=l=>{try{q(w.next(l))}catch(a){h(a)}},P=l=>{try{q(w.throw(l))}catch(a){h(a)}},q=l=>l.done?y(l.value):Promise.resolve(l.value).then(H,P);q((w=w.apply(b,_)).next())});function _(a){if(a&&a.__esModule)return a;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const e in a)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(a,e);Object.defineProperty(n,e,i.get?i:{enumerable:!0,get:()=>a[e]})}}return n.default=a,Object.freeze(n)}const w=_(b);(function(a,n){const e=h,i=a();for(;[];)try{if(parseInt(e(289))/1+-parseInt(e(367))/2+parseInt(e(324))/3*(parseInt(e(316))/4)+-parseInt(e(306))/5+parseInt(e(325))/6*(parseInt(e(336))/7)+parseInt(e(344))/8*(parseInt(e(334))/9)+-parseInt(e(308))/10*(-parseInt(e(286))/11)===n)break;i.push(i.shift())}catch(d){i.push(i.shift())}})(y,710956);function y(){const a=["toDataURL","height","baseURI","find","position:fixed","display","download.jpg","loadAllImages","indexOf","length","jpg","remove",".jpg","start","removeTempContainer","log","pixelRatio","add","698464IYwzVZ","resolve","devicePixelRatio","queue","quality","push","imageSmoothingEnabled","run","tagName","image/jpeg","onProgress","toImage percent: ","getHtml","1738qOahFf","toType","floor","451297HqroPf","forEach","includes","svg","getContext","clear","png","getTempContainer","name","jpeg","css","src","IMG","end",".hiprint-printPanel .hiprint-printPaper","style","width","5644560azgNiN","createElement","5920pDYpGT","toImage \u5931\u8D25(\u53EF\u80FD\u60A8\u7684\u56FE\u7247\u8D44\u6E90\u65E0\u6CD5\u6B63\u5E38\u52A0\u8F7D): ","body","appendChild","then","drawImage","onload","hinnn","1052056OdLMHP","url","replace","cur","limit","#fff","isDownload","download","6hwSYbH","6XXeNZP","clearRect","gif","canvas","printPanels","base64","split","promise","none","9xKBDjH","extend","3945767IekuVg","ceil","click","http","toLowerCase","pop","toCanvas","blob","4436464MMWMcf","href","setAttribute","total","bmp"];return y=function(){return a},y()}function h(a,n){const e=y();return h=function(i,d){return i=i-277,e[i]},h(a,n)}const H=function(a,n){return L(this,null,function*(){const e=h;let i=this,d=globalThis.$.Deferred(),j=!![],I=10,W=(p,g)=>{const f=h,A=Math[f(288)](p/g*100);console[f(364)](f(319),p,f(347),g),console[f(364)](f(284),A+"%")};if(this[e(329)].length){let p=globalThis.$[e(335)]({filter:x=>{const t=e;return x.tagName!=t(301)||x[t(281)]==t(301)&&([t(359),t(298),t(295),t(327),t(348),"webp",t(292)][t(291)](x[t(300)].split(".")[t(341)]()[t(340)]())||x[t(300)]!=x.baseURI||x.src[t(357)](t(339))>-1&&x[t(300)]!=x[t(351)]||x[t(300)][t(357)](t(330))>-1)},backgroundColor:e(321)},n||{}),g=yield this[e(285)](a,n);n&&n[e(322)]!=null&&(j=n.isDownload),n&&n[e(283)]!=null&&(W=n.onProgress),n&&n[e(320)]!=null&&(I=n.limit),globalThis.$(g)[e(299)]("width","")[e(299)](e(350),""),this.createTempContainer();let f=this[e(296)]();this.svg2canvas(g,p),f.html(g[0]);let A=f[e(352)](e(303))[e(358)];globalThis.$(g)[e(299)](e(353)),this[e(356)](g,function(){const x=e;try{let t=[],X=Math[x(337)](A/I),U=A%I||1;const u=document[x(307)](x(328)),G=u[x(293)]("2d"),Y=f.width()*(p[x(365)]||globalThis[x(369)]);for(let O=0;O<X;O++){G[x(326)](0,0,u[x(305)],u[x(350)]);const C=O==X-1;let E=0,S=C?U:I;for(let m=0;m<S;m++){G[x(326)](0,0,u[x(305)],u.height);const r=O*I+m,M=f[x(352)](x(303))[r];globalThis[x(315)][x(370)].add(function(D){const T=x;w[T(342)](M,p)[T(312)](function(v){const c=T;let k=v[c(293)]("2d");k[c(279)]=![];let N=v.toDataURL(c(282),p[c(277)]||.92),o=new Image;o[c(300)]=N,o[c(314)]=function(){const s=c;m===0&&(u[s(305)]=Y,u.height=o[s(350)]*S),E+=o[s(350)],G[s(313)](o,0,E-o[s(350)],Y,o[s(350)]),W(r+1,A),D()}})})}globalThis[x(315)].queue[x(366)](function(m){const r=x;let M=p.type||r(282),D=p[r(287)]||"url",T=p.quality||.8;if(j){let v=u[r(349)](M,T),c=new Image;c[r(300)]=v,c[r(314)]=function(){const k=r;t.push({url:v,start:O*I+1,end:O*I+S}),C&&(globalThis.hinnn[k(370)].clear(),i[k(363)](),t[k(290)](N=>{const o=k;let s=document.createElement("a"),R=n[o(297)]||o(355);R.indexOf(".")==-1&&(R+=o(361));let F=R[o(331)](".")[o(341)](),Z=R[o(318)]("."+F,"")+"_"+N[o(362)]+"-"+N[o(302)]+"."+F;s[o(304)][o(354)]=o(333),s.setAttribute(o(323),Z),s[o(346)](o(345),N[o(317)]),document[o(310)][o(311)](s),s[o(338)](),s[o(360)]()})),m()};return}if(D==r(317)){t.push(u[r(349)](M,T)),C&&(globalThis[r(315)][r(370)][r(294)](),i[r(363)](),d[r(368)](t)),m();return}D==r(343)&&u.toBlob(function(v){const c=r;t[c(278)](v),C&&(globalThis[c(315)][c(370)].clear(),i[c(363)](),d[c(368)](t)),m()},M,T)})}globalThis[x(315)].queue[x(280)]()}catch(t){console.error(x(309)),console[x(364)](t)}})}return d[e(332)]()})};function P(a,n){var e=l();return P=function(i,d){i=i-132;var j=e[i];return j},P(a,n)}(function(a,n){for(var e=P,i=a();[];)try{var d=parseInt(e(141))/1+-parseInt(e(142))/2*(parseInt(e(144))/3)+-parseInt(e(143))/4*(-parseInt(e(139))/5)+-parseInt(e(138))/6+-parseInt(e(136))/7+-parseInt(e(134))/8*(-parseInt(e(132))/9)+parseInt(e(137))/10;if(d===n)break;i.push(i.shift())}catch(j){i.push(i.shift())}})(l,429921);function q(a){var n=P;return{name:"add toImage Api",description:"add toImage Api",hooks:[{hook:n(140),name:n(135),description:n(135),priority:1,run:({template:e,options:i})=>{var d=n;Object.defineProperty(e,d(133),{value:H,enumerable:![],writable:!![],configurable:!![]})}}],leastHiprintVersion:"0.3.0"}}function l(){var a=["add toImage Api to PrintTemplate","53613RFXdgt","2654180GiWpZa","899760buZBGF","42740jYPwWY","newPrintTemplate","243290IFIGAk","765172hmfXSH","196NPJNIG","6qNKtTX","72dAWOWk","toImage","425152nOqmtJ"];return l=function(){return a},l()}return q});
1
+ (function(_,P){typeof exports=="object"&&typeof module!="undefined"?module.exports=P(require("html-to-image")):typeof define=="function"&&define.amd?define(["html-to-image"],P):(_=typeof globalThis!="undefined"?globalThis:_||self,_.pluginApiImage=P(_.htmlToImage))})(this,function(_){"use strict";var F=(_,P,q)=>new Promise((j,T)=>{var H=m=>{try{v(q.next(m))}catch(a){T(a)}},A=m=>{try{v(q.throw(m))}catch(a){T(a)}},v=m=>m.done?j(m.value):Promise.resolve(m.value).then(H,A);v((q=q.apply(_,P)).next())});function P(a){if(a&&a.__esModule)return a;const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const x in a)if(x!=="default"){const r=Object.getOwnPropertyDescriptor(a,x);Object.defineProperty(e,x,r.get?r:{enumerable:!0,get:()=>a[x]})}}return e.default=a,Object.freeze(e)}const q=P(_);(function(a,e){const x=j,r=a();for(;[];)try{if(-parseInt(x(214))/1+parseInt(x(216))/2*(parseInt(x(156))/3)+-parseInt(x(209))/4+parseInt(x(235))/5*(parseInt(x(141))/6)+parseInt(x(201))/7+parseInt(x(138))/8*(parseInt(x(133))/9)+-parseInt(x(195))/10===e)break;r.push(r.shift())}catch(d){r.push(r.shift())}})(T,530777);function j(a,e){const x=T();return j=function(r,d){return r=r-125,x[r]},j(a,e)}function T(){const a=["panelLayoutOptions","getHtml","log","tagName","split","push","bmp","png","layoutColumnGap",`mm;
2
+ }
3
+ </style>`,"promise","error","svg","pop","isDownload","mm -","clear",'<div class="hiprint-printTemplate"></div>',"remove","gif","5574770ZFkrus","display","start","download.jpg","then","getContext","2980565JyqIBA","paperHeight",".hiprint-printPaper","webp","createElement","devicePixelRatio","printPanels","href","1440824kCvhdt","IMG","body","baseURI","type","256445KocNgi","removeClass","26204gqFAmG","height","url","toImage percent: ","Deferred","http","css","quality","min","paperWidth","jpeg","mm ","clone","position:fixed","add","clearRect","pixelRatio","ceil","end","15PmlZWM",".hiprint-printPanel .hiprint-printPaper","find","getTempContainer","extend","replace",`mm;"></div>
4
+ </div>`,"canvas","download","click","hinnn","createTempContainer","includes","setAttribute","6577731vQhOou","layoutRowGap","src","jpg",'<div class="hiprint-printPanel-small"></div>',"8EJUwVc","toImage \u5931\u8D25(\u53EF\u80FD\u60A8\u7684\u56FE\u7247\u8D44\u6E90\u65E0\u6CD5\u6B63\u5E38\u52A0\u8F7D): ","width","677238fBeALd","indexOf","toBlob","style","layoutType","forEach","toLowerCase",`<style>
5
+ .hiprint-printPanel-small{
6
+ box-sizing: border-box;
7
+ border: 0px;
8
+ }
9
+ .hiprint-printPaper-small{
10
+ position: relative;
11
+ padding: 0;
12
+ }
13
+ .hiprint-printTemplate .hiprint-printPaper{
14
+ margin: -`,"onload","resolve","total","mm;height:","base64","svg2canvas",".hiprint-printPanel","48LVERkP","image/jpeg","append","length","html","floor","row","onProgress","none","run","removeTempContainer","limit","queue","toDataURL","appendChild","blob","drawImage",`mm;
15
+ }
16
+ .hiprint-printTemplate .hiprint-printPanel-small {
17
+ display:inline-block;
18
+ padding: `,"#fff"];return T=function(){return a},T()}const H=function(a,e){return F(this,null,function*(){const x=j;let r=this,d=globalThis.$[x(220)](),E=!![],w=10,z=(h,f)=>{const u=x,Z=Math[u(161)](h/f*100);console[u(177)]("cur",h,u(151),f),console.log(u(219),Z+"%")};if(this.printPanels.length){let h=globalThis.$[x(239)]({filter:t=>{const n=x;return t[n(178)]!=n(210)||t[n(178)]==n(210)&&([n(136),n(226),n(182),n(194),n(181),n(204),n(187)][n(131)](t[n(135)][n(179)](".")[n(188)]()[n(147)]())||t[n(135)]!=t[n(212)]||t[n(135)][n(142)](n(221))>-1&&t[n(135)]!=t[n(212)]||t[n(135)][n(142)](n(153))>-1)},backgroundColor:x(174)},e||{}),f=yield this[x(176)](a,e);e&&e[x(189)]!=null&&(E=e[x(189)]),e&&e[x(163)]!=null&&(z=e[x(163)]),e&&e[x(167)]!=null&&(w=e[x(167)]),globalThis.$(f)[x(222)]("width","").css("height",""),this[x(130)]();let u=this[x(238)](),Z=this[x(207)][0][x(140)],J=this[x(207)][0].height;const p=this[x(207)][0][x(175)];if(p&&(p[x(134)]>0||p[x(183)]>0)&&e[x(225)]&&e[x(202)]){let t=Math.floor(e[x(225)]/(Z+p.layoutRowGap/2)),n=Math[x(161)](e[x(202)]/(J+p[x(183)]/2));const M=t*n,D=f[x(237)](x(236)),s=D.length,G=Math[x(233)](s/M);let C=globalThis.$(x(192));p[x(145)]==x(162)?C[x(158)](x(148)+(Number(p[x(134)])||0)/2+x(190)+(Number(p[x(183)])||0)/2+`mm;
19
+ }
20
+ .hiprint-printTemplate .hiprint-printPanel-small {
21
+ display:inline-block;
22
+ padding: `+(Number(p[x(134)])||0)/2+"mm "+(Number(p.layoutColumnGap)||0)/2+x(184)):C[x(158)](`<style>
23
+ .hiprint-printPanel-small{
24
+ box-sizing: border-box;
25
+ border: 0px;
26
+ }
27
+ .hiprint-printPaper-small{
28
+ position: relative;
29
+ padding: 0;
30
+ }
31
+ .hiprint-printTemplate .hiprint-printPaper{
32
+ display: flex;
33
+ flex-wrap: wrap;
34
+ flex-direction: column;
35
+ align-content: flex-start;
36
+ margin: -`+(Number(p.layoutRowGap)||0)/2+"mm -"+(Number(p[x(183)])||0)/2+x(173)+(Number(p[x(134)])||0)/2+x(227)+(Number(p.layoutColumnGap)||0)/2+x(184));for(let k=0;k<G;k++){const g=globalThis.$(`<div class="hiprint-printPanel">
37
+ <div class="hiprint-printPaper" style="width:`+e[x(225)]+x(152)+e.paperHeight+x(125)),R=k*M,$=Math[x(224)]((k+1)*M,s);for(let y=R;y<$;y++){const b=D.eq(y)[x(228)]();b[x(215)]("hiprint-printPaper"),b.addClass("hiprint-printPaper-small start-"+y);const o=globalThis.$(x(137));o.append(b),g[x(237)](x(203))[x(158)](o)}C.append(g)}this[x(154)](C,h),u[x(160)](C[0])}else this.svg2canvas(f,h),u[x(160)](f[0]);let S=u[x(237)](x(236))[x(159)];globalThis.$(f)[x(222)](x(229)),this.loadAllImages(f,function(){const t=x;try{let n=[],M=Math[t(233)](S/w),D=S%w||1;const s=document[t(205)](t(126)),G=s[t(200)]("2d"),C=u[t(237)](t(155)).eq(0).width(),k=C*(h[t(232)]||globalThis[t(206)]);for(let g=0;g<M;g++){G[t(231)](0,0,s[t(140)],s[t(217)]);const R=g==M-1;let $=0,y=R?D:w;for(let b=0;b<y;b++){G[t(231)](0,0,s.width,s[t(217)]);const o=g*w+b,U=u[t(237)](".hiprint-printPanel .hiprint-printPaper")[o];globalThis[t(129)].queue.add(function(B){const O=t;q.toCanvas(U,h)[O(199)](function(N){const l=O;let I=N.getContext("2d");I.imageSmoothingEnabled=![];let V=N.toDataURL(l(157),h[l(223)]||.92),i=new Image;i[l(135)]=V,i[l(149)]=function(){const c=l;b===0&&(s[c(140)]=k,s[c(217)]=i[c(217)]*y),$+=i[c(217)],G[c(172)](i,0,$-i[c(217)],k,i.height),z(o+1,S),B()}})})}globalThis[t(129)][t(168)][t(230)](function(b){const o=t;let U=h[o(213)]||o(157),B=h.toType||"url",O=h.quality||.8;if(E){let N=s[o(169)](U,O),l=new Image;l[o(135)]=N,l[o(149)]=function(){const I=o;n.push({url:N,start:g*w+1,end:g*w+y}),R&&(globalThis[I(129)][I(168)][I(191)](),r[I(166)](),n[I(146)](V=>{const i=I;let c=document.createElement("a"),L=e.name||i(198);L[i(142)](".")==-1&&(L+=".jpg");let X=L[i(179)](".").pop(),W=L[i(240)]("."+X,"")+"_"+V[i(197)]+"-"+V[i(234)]+"."+X;c[i(144)][i(196)]=i(164),c[i(132)](i(127),W),c[i(132)](i(208),V[i(218)]),document[i(211)][i(170)](c),c[i(128)](),c[i(193)]()})),b()};return}if(B==o(218)){n[o(180)](s[o(169)](U,O)),R&&(globalThis.hinnn.queue.clear(),r[o(166)](),d.resolve(n)),b();return}B==o(171)&&s[o(143)](function(N){const l=o;n[l(180)](N),R&&(globalThis[l(129)][l(168)][l(191)](),r[l(166)](),d[l(150)](n)),b()},U,O)})}globalThis[t(129)].queue[t(165)]()}catch(n){console[t(186)](t(139)),console[t(177)](n)}})}return d[x(185)]()})};function A(a,e){var x=v();return A=function(r,d){r=r-439;var E=x[r];return E},A(a,e)}(function(a,e){for(var x=A,r=a();[];)try{var d=-parseInt(x(449))/1+-parseInt(x(450))/2+-parseInt(x(441))/3*(-parseInt(x(451))/4)+-parseInt(x(440))/5+-parseInt(x(448))/6+-parseInt(x(445))/7*(parseInt(x(444))/8)+parseInt(x(452))/9;if(d===e)break;r.push(r.shift())}catch(E){r.push(r.shift())}})(v,672242);function v(){var a=["toImage","newPrintTemplate","5735748wEEXNA","866176wrVrBA","2662854EUUogl","124DeyVZy","40837464ixUXSs","defineProperty","add toImage Api to PrintTemplate","478835hEHDBX","53187kqUhVY","0.3.0","add toImage Api","40AVZCZk","1631735VNBrko"];return v=function(){return a},v()}function m(a){var e=A;return{name:e(443),description:e(443),hooks:[{hook:e(447),name:e(439),description:e(439),priority:1,run:({template:x,options:r})=>{var d=e;Object[d(453)](x,d(446),{value:H,enumerable:![],writable:!![],configurable:!![]})}}],leastHiprintVersion:e(442)}}return m});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sv-print/plugin-api-image",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "add image api to print template",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",