@sv-print/plugin-api-pdf 0.1.0

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.
@@ -0,0 +1,2 @@
1
+ import type { PluginOptions } from "sv-print";
2
+ export default function plugin(options?: any): PluginOptions;
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var O=(x,a,t)=>new Promise((e,o)=>{var s=c=>{try{f(t.next(c))}catch(u){o(u)}},m=c=>{try{f(t.throw(c))}catch(u){o(u)}},f=c=>c.done?e(c.value):Promise.resolve(c.value).then(s,m);f((t=t.apply(x,a)).next())});const D=require("html-to-image"),R=require("jspdf");function k(x){if(x&&x.__esModule)return x;const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(x){for(const t in x)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(x,t);Object.defineProperty(a,t,e.get?e:{enumerable:!0,get:()=>x[t]})}}return a.default=x,Object.freeze(a)}const q=k(D);function v(x,a){var t=I();return v=function(e,o){e=e-164;var s=t[e];return s},v(x,a)}(function(x,a){for(var t=v,e=x();[];)try{var o=-parseInt(t(203))/1+parseInt(t(164))/2+-parseInt(t(195))/3*(parseInt(t(197))/4)+-parseInt(t(173))/5*(parseInt(t(206))/6)+parseInt(t(225))/7+parseInt(t(180))/8+parseInt(t(184))/9;if(o===a)break;e.push(e.shift())}catch(s){e.push(e.shift())}})(I,636902);function I(){var x=["gif","split","6461058iQvSab","add","createTempContainer","#fff",".hiprint-printPanel .hiprint-printPaper","Deferred","imageSmoothingEnabled","svg","jpg","log","find","baseURI","removeTempContainer","toPdf percent: ","http","indexOf","webp","printPanels","width","6373367SGTiUH","run","getContext","clear","1637740tZXHMw","pop","IMG","promise","output","height","toDataURL",".pdf","toPt","5jLGsWV","getTempContainer","length","total","blob","isDownload","type","1143592JsWoRv","src","floor","error","2640312ONcCNU","toLocaleLowerCase","cur","extend","svg2canvas","queue","onProgress","getOrient","hinnn","css","getHtml","159laaTrO","tagName","9176MRMMSC","save","image/jpeg","each","position:fixed","addImage","330341BdDuQb"];return I=function(){return x},I()}const A=function(x,a,t){return O(this,null,function*(){var e=v,o=this,s=globalThis.$[e(211)](),m=!![];let f=(l,P)=>{var d=e;const r=Math[d(182)](l/P*100);console[d(215)](d(186),l,d(176),P),console[d(215)](d(219),r+"%")};if(this.printPanels[e(175)]){var c=globalThis[e(192)].mm[e(172)](this[e(223)][0].width),u=globalThis.hinnn.mm[e(172)](this.printPanels[0][e(169)]),y=globalThis.$[e(187)]({filter:r=>{var n=e;return r[n(196)]!=n(166)||r[n(196)]=="IMG"&&([n(214),"jpeg","png",n(204),"bmp",n(222),n(213)].includes(r[n(181)][n(205)](".")[n(165)]().toLowerCase())||r[n(181)]!=r[n(217)]||r[n(181)][n(221)](n(220))>-1&&r[n(181)]!=r[n(217)]||r[n(181)].indexOf("base64")>-1)},backgroundColor:e(209)},t||{});const l=this.printPanels[0].paperType,P=l!=null&&l!=""&&l!="\u81EA\u5B9A\u4E49";var h=new R.jsPDF({orientation:this[e(191)](0)==1?"portrait":"landscape",unit:"pt",format:P?l[e(185)]():[c,u]}),g=yield this[e(194)](x,t);t&&t.isDownload!=null&&(m=t[e(178)]),t&&t.onProgress!=null&&(f=t[e(190)]),globalThis.$(g)[e(193)](e(224),"").css("height",""),this[e(208)]();var j=this[e(174)]();this[e(188)](g,y),j.html(g[0]);let d=j[e(216)](e(210))[e(175)];globalThis.$(g)[e(193)](e(201)),this.loadAllImages(g,function(){var r=e;try{j[r(216)](r(210))[r(200)](function(n,_){var p=r;globalThis[p(192)][p(189)][p(207)](function(M){q.toCanvas(_,y).then(function(i){var b=v,C=i[b(227)]("2d");C[b(212)]=![];var G=i[b(170)](b(199),y.quality||.92);h[b(202)](G,"JPEG",0,0,c,u),n<d-1&&h.addPage(),f(n+1,d),M()})}),n==d-1&&(globalThis[p(192)][p(189)][p(207)](function(M){var i=p;if(m)o[i(218)](),a[i(221)](i(171))>-1?h[i(198)](a):h[i(198)](a+i(171));else{o[i(218)]();let b=t[i(179)]||i(177),C=h[i(168)](b);s.resolve(C)}globalThis[i(192)][i(189)][i(228)]()}),globalThis[p(192)].queue[p(226)]())})}catch(n){console[r(183)]("toPdf \u5931\u8D25(\u53EF\u80FD\u60A8\u7684\u56FE\u7247\u8D44\u6E90\u65E0\u6CD5\u6B63\u5E38\u52A0\u8F7D): "),console.log(n)}})}return s[e(167)]()})};(function(x,a){for(var t=w,e=x();[];)try{var o=-parseInt(t(272))/1+-parseInt(t(281))/2+-parseInt(t(270))/3+parseInt(t(275))/4*(-parseInt(t(271))/5)+parseInt(t(282))/6+parseInt(t(280))/7*(parseInt(t(274))/8)+parseInt(t(283))/9;if(o===a)break;e.push(e.shift())}catch(s){e.push(e.shift())}})(T,175929);function w(x,a){var t=T();return w=function(e,o){e=e-270;var s=t[e];return s},w(x,a)}function T(){var x=["newPrintTemplate","defineProperty","toPdf","2421566IwQKqK","19148rRCHpQ","578370uwOEGF","428796RGwMwp","add toPdf Api","486303dHnszW","335yooKeM","13532GMAfxs","0.3.0","8zyLrNt","7692RBKxwC","add toPdf Api to PrintTemplate"];return T=function(){return x},T()}function H(x){var a=w;return{name:a(284),description:"add toPdf Api",hooks:[{hook:a(277),name:a(276),description:"add toPdf Api to PrintTemplate",priority:1,run:({template:t,options:e})=>{var o=a;Object[o(278)](t,o(279),{value:A,enumerable:![],writable:!![],configurable:!![]})}}],leastHiprintVersion:a(273)}}module.exports=H;
package/dist/index.mjs ADDED
@@ -0,0 +1,129 @@
1
+ var O = (r, a, t) => new Promise((x, o) => {
2
+ var s = (c) => {
3
+ try {
4
+ f(t.next(c));
5
+ } catch (h) {
6
+ o(h);
7
+ }
8
+ }, m = (c) => {
9
+ try {
10
+ f(t.throw(c));
11
+ } catch (h) {
12
+ o(h);
13
+ }
14
+ }, f = (c) => c.done ? x(c.value) : Promise.resolve(c.value).then(s, m);
15
+ f((t = t.apply(r, a)).next());
16
+ });
17
+ import * as A from "html-to-image";
18
+ import { jsPDF as D } from "jspdf";
19
+ function v(r, a) {
20
+ var t = P();
21
+ return v = function(x, o) {
22
+ x = x - 164;
23
+ var s = t[x];
24
+ return s;
25
+ }, v(r, a);
26
+ }
27
+ (function(r, a) {
28
+ for (var t = v, x = r(); []; )
29
+ try {
30
+ var o = -parseInt(t(203)) / 1 + parseInt(t(164)) / 2 + -parseInt(t(195)) / 3 * (parseInt(t(197)) / 4) + -parseInt(t(173)) / 5 * (parseInt(t(206)) / 6) + parseInt(t(225)) / 7 + parseInt(t(180)) / 8 + parseInt(t(184)) / 9;
31
+ if (o === a)
32
+ break;
33
+ x.push(x.shift());
34
+ } catch (s) {
35
+ x.push(x.shift());
36
+ }
37
+ })(P, 636902);
38
+ function P() {
39
+ var r = ["gif", "split", "6461058iQvSab", "add", "createTempContainer", "#fff", ".hiprint-printPanel .hiprint-printPaper", "Deferred", "imageSmoothingEnabled", "svg", "jpg", "log", "find", "baseURI", "removeTempContainer", "toPdf percent: ", "http", "indexOf", "webp", "printPanels", "width", "6373367SGTiUH", "run", "getContext", "clear", "1637740tZXHMw", "pop", "IMG", "promise", "output", "height", "toDataURL", ".pdf", "toPt", "5jLGsWV", "getTempContainer", "length", "total", "blob", "isDownload", "type", "1143592JsWoRv", "src", "floor", "error", "2640312ONcCNU", "toLocaleLowerCase", "cur", "extend", "svg2canvas", "queue", "onProgress", "getOrient", "hinnn", "css", "getHtml", "159laaTrO", "tagName", "9176MRMMSC", "save", "image/jpeg", "each", "position:fixed", "addImage", "330341BdDuQb"];
40
+ return P = function() {
41
+ return r;
42
+ }, P();
43
+ }
44
+ const H = function(r, a, t) {
45
+ return O(this, null, function* () {
46
+ var x = v, o = this, s = globalThis.$[x(211)](), m = !![];
47
+ let f = (l, I) => {
48
+ var d = x;
49
+ const n = Math[d(182)](l / I * 100);
50
+ console[d(215)](d(186), l, d(176), I), console[d(215)](d(219), n + "%");
51
+ };
52
+ if (this.printPanels[x(175)]) {
53
+ var c = globalThis[x(192)].mm[x(172)](this[x(223)][0].width), h = globalThis.hinnn.mm[x(172)](this.printPanels[0][x(169)]), C = globalThis.$[x(187)]({ filter: (n) => {
54
+ var e = x;
55
+ return n[e(196)] != e(166) || n[e(196)] == "IMG" && ([e(214), "jpeg", "png", e(204), "bmp", e(222), e(213)].includes(n[e(181)][e(205)](".")[e(165)]().toLowerCase()) || n[e(181)] != n[e(217)] || n[e(181)][e(221)](e(220)) > -1 && n[e(181)] != n[e(217)] || n[e(181)].indexOf("base64") > -1);
56
+ }, backgroundColor: x(209) }, t || {});
57
+ const l = this.printPanels[0].paperType, I = l != null && l != "" && l != "\u81EA\u5B9A\u4E49";
58
+ var u = new D({ orientation: this[x(191)](0) == 1 ? "portrait" : "landscape", unit: "pt", format: I ? l[x(185)]() : [c, h] }), g = yield this[x(194)](r, t);
59
+ t && t.isDownload != null && (m = t[x(178)]), t && t.onProgress != null && (f = t[x(190)]), globalThis.$(g)[x(193)](x(224), "").css("height", ""), this[x(208)]();
60
+ var y = this[x(174)]();
61
+ this[x(188)](g, C), y.html(g[0]);
62
+ let d = y[x(216)](x(210))[x(175)];
63
+ globalThis.$(g)[x(193)](x(201)), this.loadAllImages(g, function() {
64
+ var n = x;
65
+ try {
66
+ y[n(216)](n(210))[n(200)](function(e, R) {
67
+ var p = n;
68
+ globalThis[p(192)][p(189)][p(207)](function(G) {
69
+ A.toCanvas(R, C).then(function(i) {
70
+ var b = v, M = i[b(227)]("2d");
71
+ M[b(212)] = ![];
72
+ var j = i[b(170)](b(199), C.quality || 0.92);
73
+ u[b(202)](j, "JPEG", 0, 0, c, h), e < d - 1 && u.addPage(), f(e + 1, d), G();
74
+ });
75
+ }), e == d - 1 && (globalThis[p(192)][p(189)][p(207)](function(G) {
76
+ var i = p;
77
+ if (m)
78
+ o[i(218)](), a[i(221)](i(171)) > -1 ? u[i(198)](a) : u[i(198)](a + i(171));
79
+ else {
80
+ o[i(218)]();
81
+ let b = t[i(179)] || i(177), M = u[i(168)](b);
82
+ s.resolve(M);
83
+ }
84
+ globalThis[i(192)][i(189)][i(228)]();
85
+ }), globalThis[p(192)].queue[p(226)]());
86
+ });
87
+ } catch (e) {
88
+ console[n(183)]("toPdf \u5931\u8D25(\u53EF\u80FD\u60A8\u7684\u56FE\u7247\u8D44\u6E90\u65E0\u6CD5\u6B63\u5E38\u52A0\u8F7D): "), console.log(e);
89
+ }
90
+ });
91
+ }
92
+ return s[x(167)]();
93
+ });
94
+ };
95
+ (function(r, a) {
96
+ for (var t = w, x = r(); []; )
97
+ try {
98
+ var o = -parseInt(t(272)) / 1 + -parseInt(t(281)) / 2 + -parseInt(t(270)) / 3 + parseInt(t(275)) / 4 * (-parseInt(t(271)) / 5) + parseInt(t(282)) / 6 + parseInt(t(280)) / 7 * (parseInt(t(274)) / 8) + parseInt(t(283)) / 9;
99
+ if (o === a)
100
+ break;
101
+ x.push(x.shift());
102
+ } catch (s) {
103
+ x.push(x.shift());
104
+ }
105
+ })(T, 175929);
106
+ function w(r, a) {
107
+ var t = T();
108
+ return w = function(x, o) {
109
+ x = x - 270;
110
+ var s = t[x];
111
+ return s;
112
+ }, w(r, a);
113
+ }
114
+ function T() {
115
+ var r = ["newPrintTemplate", "defineProperty", "toPdf", "2421566IwQKqK", "19148rRCHpQ", "578370uwOEGF", "428796RGwMwp", "add toPdf Api", "486303dHnszW", "335yooKeM", "13532GMAfxs", "0.3.0", "8zyLrNt", "7692RBKxwC", "add toPdf Api to PrintTemplate"];
116
+ return T = function() {
117
+ return r;
118
+ }, T();
119
+ }
120
+ function q(r) {
121
+ var a = w;
122
+ return { name: a(284), description: "add toPdf Api", hooks: [{ hook: a(277), name: a(276), description: "add toPdf Api to PrintTemplate", priority: 1, run: ({ template: t, options: x }) => {
123
+ var o = a;
124
+ Object[o(278)](t, o(279), { value: H, enumerable: ![], writable: !![], configurable: !![] });
125
+ } }], leastHiprintVersion: a(273) };
126
+ }
127
+ export {
128
+ q as default
129
+ };
@@ -0,0 +1 @@
1
+ (function(c,b){typeof exports=="object"&&typeof module!="undefined"?module.exports=b(require("html-to-image"),require("jspdf")):typeof define=="function"&&define.amd?define(["html-to-image","jspdf"],b):(c=typeof globalThis!="undefined"?globalThis:c||self,c.pluginApiPdf=b(c.htmlToImage,c.jspdf))})(this,function(c,b){"use strict";var k=(c,b,m)=>new Promise((y,l)=>{var v=o=>{try{f(m.next(o))}catch(P){l(P)}},j=o=>{try{f(m.throw(o))}catch(P){l(P)}},f=o=>o.done?y(o.value):Promise.resolve(o.value).then(v,j);f((m=m.apply(c,b)).next())});function m(n){if(n&&n.__esModule)return n;const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(a,t,e.get?e:{enumerable:!0,get:()=>n[t]})}}return a.default=n,Object.freeze(a)}const y=m(c);function l(n,a){var t=v();return l=function(e,s){e=e-164;var u=t[e];return u},l(n,a)}(function(n,a){for(var t=l,e=n();[];)try{var s=-parseInt(t(203))/1+parseInt(t(164))/2+-parseInt(t(195))/3*(parseInt(t(197))/4)+-parseInt(t(173))/5*(parseInt(t(206))/6)+parseInt(t(225))/7+parseInt(t(180))/8+parseInt(t(184))/9;if(s===a)break;e.push(e.shift())}catch(u){e.push(e.shift())}})(v,636902);function v(){var n=["gif","split","6461058iQvSab","add","createTempContainer","#fff",".hiprint-printPanel .hiprint-printPaper","Deferred","imageSmoothingEnabled","svg","jpg","log","find","baseURI","removeTempContainer","toPdf percent: ","http","indexOf","webp","printPanels","width","6373367SGTiUH","run","getContext","clear","1637740tZXHMw","pop","IMG","promise","output","height","toDataURL",".pdf","toPt","5jLGsWV","getTempContainer","length","total","blob","isDownload","type","1143592JsWoRv","src","floor","error","2640312ONcCNU","toLocaleLowerCase","cur","extend","svg2canvas","queue","onProgress","getOrient","hinnn","css","getHtml","159laaTrO","tagName","9176MRMMSC","save","image/jpeg","each","position:fixed","addImage","330341BdDuQb"];return v=function(){return n},v()}const j=function(n,a,t){return k(this,null,function*(){var e=l,s=this,u=globalThis.$[e(211)](),G=!![];let _=(h,w)=>{var d=e;const r=Math[d(182)](h/w*100);console[d(215)](d(186),h,d(176),w),console[d(215)](d(219),r+"%")};if(this.printPanels[e(175)]){var A=globalThis[e(192)].mm[e(172)](this[e(223)][0].width),D=globalThis.hinnn.mm[e(172)](this.printPanels[0][e(169)]),C=globalThis.$[e(187)]({filter:r=>{var x=e;return r[x(196)]!=x(166)||r[x(196)]=="IMG"&&([x(214),"jpeg","png",x(204),"bmp",x(222),x(213)].includes(r[x(181)][x(205)](".")[x(165)]().toLowerCase())||r[x(181)]!=r[x(217)]||r[x(181)][x(221)](x(220))>-1&&r[x(181)]!=r[x(217)]||r[x(181)].indexOf("base64")>-1)},backgroundColor:e(209)},t||{});const h=this.printPanels[0].paperType,w=h!=null&&h!=""&&h!="\u81EA\u5B9A\u4E49";var I=new b.jsPDF({orientation:this[e(191)](0)==1?"portrait":"landscape",unit:"pt",format:w?h[e(185)]():[A,D]}),T=yield this[e(194)](n,t);t&&t.isDownload!=null&&(G=t[e(178)]),t&&t.onProgress!=null&&(_=t[e(190)]),globalThis.$(T)[e(193)](e(224),"").css("height",""),this[e(208)]();var M=this[e(174)]();this[e(188)](T,C),M.html(T[0]);let d=M[e(216)](e(210))[e(175)];globalThis.$(T)[e(193)](e(201)),this.loadAllImages(T,function(){var r=e;try{M[r(216)](r(210))[r(200)](function(x,q){var p=r;globalThis[p(192)][p(189)][p(207)](function(R){y.toCanvas(q,C).then(function(i){var g=l,O=i[g(227)]("2d");O[g(212)]=![];var H=i[g(170)](g(199),C.quality||.92);I[g(202)](H,"JPEG",0,0,A,D),x<d-1&&I.addPage(),_(x+1,d),R()})}),x==d-1&&(globalThis[p(192)][p(189)][p(207)](function(R){var i=p;if(G)s[i(218)](),a[i(221)](i(171))>-1?I[i(198)](a):I[i(198)](a+i(171));else{s[i(218)]();let g=t[i(179)]||i(177),O=I[i(168)](g);u.resolve(O)}globalThis[i(192)][i(189)][i(228)]()}),globalThis[p(192)].queue[p(226)]())})}catch(x){console[r(183)]("toPdf \u5931\u8D25(\u53EF\u80FD\u60A8\u7684\u56FE\u7247\u8D44\u6E90\u65E0\u6CD5\u6B63\u5E38\u52A0\u8F7D): "),console.log(x)}})}return u[e(167)]()})};(function(n,a){for(var t=f,e=n();[];)try{var s=-parseInt(t(272))/1+-parseInt(t(281))/2+-parseInt(t(270))/3+parseInt(t(275))/4*(-parseInt(t(271))/5)+parseInt(t(282))/6+parseInt(t(280))/7*(parseInt(t(274))/8)+parseInt(t(283))/9;if(s===a)break;e.push(e.shift())}catch(u){e.push(e.shift())}})(o,175929);function f(n,a){var t=o();return f=function(e,s){e=e-270;var u=t[e];return u},f(n,a)}function o(){var n=["newPrintTemplate","defineProperty","toPdf","2421566IwQKqK","19148rRCHpQ","578370uwOEGF","428796RGwMwp","add toPdf Api","486303dHnszW","335yooKeM","13532GMAfxs","0.3.0","8zyLrNt","7692RBKxwC","add toPdf Api to PrintTemplate"];return o=function(){return n},o()}function P(n){var a=f;return{name:a(284),description:"add toPdf Api",hooks:[{hook:a(277),name:a(276),description:"add toPdf Api to PrintTemplate",priority:1,run:({template:t,options:e})=>{var s=a;Object[s(278)](t,s(279),{value:j,enumerable:![],writable:!![],configurable:!![]})}}],leastHiprintVersion:a(273)}}return P});
@@ -0,0 +1,2 @@
1
+ declare const toPdf: (t: any, e: any, options: any) => Promise<any>;
2
+ export { toPdf };
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@sv-print/plugin-api-pdf",
3
+ "version": "0.1.0",
4
+ "description": "add pdf api to print template",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "svelte": "./dist/index.mjs",
8
+ "jsdelivr": "./dist/index.umd.js",
9
+ "unpkg": "./dist/index.umd.js",
10
+ "module": "./dist/index.mjs",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.mjs",
16
+ "require": "./dist/index.umd.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "scripts": {
23
+ "build": "vite build && tsc src/index.ts --declaration --emitDeclarationOnly --outDir dist",
24
+ "build-browserify": "vite build --mode=browserify",
25
+ "pub": "pnpm build && npm --registry https://registry.npmjs.org/ publish --access public",
26
+ "pub-beta": "pnpm build && npm --registry https://registry.npmjs.org/ publish --access public --tag beta"
27
+ },
28
+ "keywords": [
29
+ "sv-print",
30
+ "hiprint"
31
+ ],
32
+ "author": "",
33
+ "license": "MIT",
34
+ "dependencies": {
35
+ "sv-print": "^0.2.0",
36
+ "jspdf": "^2.5.2",
37
+ "html-to-image": "^1.11.13"
38
+ },
39
+ "devDependencies": {
40
+ "vite-plugin-javascript-obfuscator": "^3.1.0"
41
+ },
42
+ "peerDependencies": {
43
+ "sv-print": "^0.2.0",
44
+ "html-to-image": "^1.11.13"
45
+ }
46
+ }