@embedpdf/plugin-print 1.3.16 → 1.4.1

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 @@
1
+ export * from './print';
@@ -0,0 +1 @@
1
+ export declare function PrintFrame(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from './use-print';
@@ -0,0 +1,11 @@
1
+ import { PrintPlugin } from '../../index.ts';
2
+ export declare const usePrintPlugin: () => {
3
+ plugin: PrintPlugin | null;
4
+ isLoading: boolean;
5
+ ready: Promise<void>;
6
+ };
7
+ export declare const usePrintCapability: () => {
8
+ provides: Readonly<import('../../index.ts').PrintCapability> | null;
9
+ isLoading: boolean;
10
+ ready: Promise<void>;
11
+ };
@@ -0,0 +1,4 @@
1
+ export * from './hooks';
2
+ export * from './components';
3
+ export * from '../index.ts';
4
+ export declare const PrintPluginPackage: import('@embedpdf/core').WithAutoMount<import('@embedpdf/core').PluginPackage<import('../index.ts').PrintPlugin, import('../index.ts').PrintPluginConfig, unknown, import('@embedpdf/core').Action>>;
@@ -0,0 +1 @@
1
+ export { default as PrintFrame } from './print.svelte';
@@ -0,0 +1,3 @@
1
+ declare const Print: import('svelte', { with: { "resolution-mode": "import" } }).Component<Record<string, never>, {}, "">;
2
+ type Print = ReturnType<typeof Print>;
3
+ export default Print;
@@ -0,0 +1 @@
1
+ export * from './use-print.svelte';
@@ -0,0 +1,19 @@
1
+ import { PrintPlugin } from '../../lib/index.ts';
2
+ /**
3
+ * Hook to get the print plugin's capability API.
4
+ * This provides methods for initiating print operations.
5
+ */
6
+ export declare const usePrintCapability: () => {
7
+ provides: Readonly<import('../../lib/index.ts').PrintCapability> | null;
8
+ isLoading: boolean;
9
+ ready: Promise<void>;
10
+ };
11
+ /**
12
+ * Hook to get the raw print plugin instance.
13
+ * Useful for accessing plugin-specific properties or methods not exposed in the capability.
14
+ */
15
+ export declare const usePrintPlugin: () => {
16
+ plugin: PrintPlugin | null;
17
+ isLoading: boolean;
18
+ ready: Promise<void>;
19
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("svelte/internal/client"),t=require("@embedpdf/core/svelte"),r=require("@embedpdf/plugin-print");require("svelte/internal/disclose-version");const n=require("@embedpdf/core");function i(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const r in e)if("default"!==r){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}return t.default=e,Object.freeze(t)}const o=i(e),l=()=>t.useCapability(r.PrintPlugin.id),s=()=>t.usePlugin(r.PrintPlugin.id);var a=o.from_html('<iframe title="Print Document" src="about:blank" style="position: absolute; display: none;"></iframe>');function u(e,t){o.push(t,!0);const r=l(),n=s();let i=o.state(null),u=null;o.user_effect((()=>{if(!r.provides||!n.plugin)return;const e=n.plugin.onPrintRequest((({buffer:e,task:t})=>{const r=o.get(i);if(!r)return;u&&(URL.revokeObjectURL(u),u=null);const n=URL.createObjectURL(new Blob([e],{type:"application/pdf"}));u=n,r.onload=()=>{var i,o;r.src===n&&(t.progress({stage:"iframe-ready",message:"Ready to print"}),null==(i=r.contentWindow)||i.focus(),null==(o=r.contentWindow)||o.print(),t.progress({stage:"printing",message:"Print dialog opened"}),t.resolve(e))},r.src=n}));return()=>{e(),u&&(URL.revokeObjectURL(u),u=null)}}));var c=a();o.bind_this(c,(e=>o.set(i,e)),(()=>o.get(i))),o.append(e,c),o.pop()}const c=n.createPluginPackage(r.PrintPluginPackage).addUtility(u).build();exports.PrintFrame=u,exports.PrintPluginPackage=c,exports.usePrintCapability=l,exports.usePrintPlugin=s,Object.keys(r).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})}));
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-print.svelte.ts","../../src/svelte/components/print.svelte","../../src/svelte/index.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { PrintPlugin } from '@embedpdf/plugin-print';\n\n/**\n * Hook to get the print plugin's capability API.\n * This provides methods for initiating print operations.\n */\nexport const usePrintCapability = () => useCapability<PrintPlugin>(PrintPlugin.id);\n\n/**\n * Hook to get the raw print plugin instance.\n * Useful for accessing plugin-specific properties or methods not exposed in the capability.\n */\nexport const usePrintPlugin = () => usePlugin<PrintPlugin>(PrintPlugin.id);\n","<script lang=\"ts\">\n import { usePrintCapability, usePrintPlugin } from '../hooks';\n\n const printCapability = usePrintCapability();\n const printPlugin = usePrintPlugin();\n\n let iframeRef = $state<HTMLIFrameElement | null>(null);\n let urlRef: string | null = null;\n\n $effect(() => {\n if (!printCapability.provides || !printPlugin.plugin) return;\n\n const unsubscribe = printPlugin.plugin.onPrintRequest(({ buffer, task }) => {\n const iframe = iframeRef;\n if (!iframe) return;\n\n // cleanup old URL\n if (urlRef) {\n URL.revokeObjectURL(urlRef);\n urlRef = null;\n }\n\n const url = URL.createObjectURL(new Blob([buffer], { type: 'application/pdf' }));\n urlRef = url;\n\n iframe.onload = () => {\n if (iframe.src === url) {\n task.progress({ stage: 'iframe-ready', message: 'Ready to print' });\n iframe.contentWindow?.focus();\n iframe.contentWindow?.print();\n task.progress({ stage: 'printing', message: 'Print dialog opened' });\n task.resolve(buffer);\n }\n };\n\n iframe.src = url;\n });\n\n return () => {\n unsubscribe();\n if (urlRef) {\n URL.revokeObjectURL(urlRef);\n urlRef = null;\n }\n };\n });\n</script>\n\n<iframe\n bind:this={iframeRef}\n title=\"Print Document\"\n src=\"about:blank\"\n style=\"position: absolute; display: none;\"\n>\n</iframe>\n","export * from './hooks';\nexport * from './components';\nexport * from '@embedpdf/plugin-print';\n\nimport { createPluginPackage } from '@embedpdf/core';\nimport { PrintPluginPackage as BasePrintPackage } from '@embedpdf/plugin-print';\nimport { PrintFrame } from './components';\n\n/**\n * Build a Svelte-flavoured package by adding the Svelte PrintFrame utility.\n * Keeps heavy logic inside the plugin; framework layer just wires the component.\n */\nexport const PrintPluginPackage = createPluginPackage(BasePrintPackage)\n .addUtility(PrintFrame)\n .build();\n"],"names":["usePrintCapability","useCapability","PrintPlugin","id","usePrintPlugin","usePlugin","printCapability","printPlugin","iframeRef","urlRef","$","user_effect","provides","plugin","unsubscribe","onPrintRequest","buffer","task","iframe","URL","revokeObjectURL","url","createObjectURL","Blob","type","onload","src","progress","stage","message","_a","contentWindow","focus","_b","print","resolve","bind_this","iframe_1","$$value","set","PrintPluginPackage","createPluginPackage","BasePrintPackage","addUtility","PrintFrame","build"],"mappings":"uiBAOaA,EAA2B,IAAAC,gBAA2BC,EAAAA,YAAYC,IAMlEC,EAAuB,IAAAC,YAAuBH,EAAAA,YAAYC,4JCV/D,MAAAG,EAAkBN,IAClBO,EAAcH,IAEhB,IAAAI,UAA6C,MAC7CC,EAAwB,KAE5BC,EAAAC,aAAc,KACP,IAAAL,EAAgBM,WAAaL,EAAYM,OAAM,OAE9C,MAAAC,EAAcP,EAAYM,OAAOE,gBAAkB,EAAAC,SAAQC,WACzD,MAAAC,QAASV,OACVU,EAAM,OAGPT,IACFU,IAAIC,gBAAgBX,GACXA,EAAA,YAGLY,EAAMF,IAAIG,gBAAe,IAAKC,KAAI,CAAEP,GAAM,CAAKQ,KAAM,qBAClDf,EAAAY,EAETH,EAAOO,OAAe,aAChBP,EAAOQ,MAAQL,IACjBJ,EAAKU,SAAW,CAAAC,MAAO,eAAgBC,QAAS,mBAChD,OAAAC,EAAAZ,EAAOa,gBAAeD,EAAAE,QACtB,OAAAC,EAAAf,EAAOa,gBAAeE,EAAAC,QACtBjB,EAAKU,SAAW,CAAAC,MAAO,WAAYC,QAAS,wBAC5CZ,EAAKkB,QAAQnB,GACf,EAGFE,EAAOQ,IAAML,CAAA,IAGF,MAAA,KACAP,IACPL,IACFU,IAAIC,gBAAgBX,GACXA,EAAA,KACX,CACD,cAKQC,EAAA0B,UAAAC,GAAAC,GAAA5B,EAAA6B,IAAA/B,iBAAAA,0BAHb,CClCO,MAAMgC,EAAqBC,EAAoBA,oBAAAC,EAAgBF,oBACnEG,WAAWC,GACXC"}
@@ -0,0 +1,8 @@
1
+ export * from './hooks';
2
+ export * from './components';
3
+ export * from '../lib/index.ts';
4
+ /**
5
+ * Build a Svelte-flavoured package by adding the Svelte PrintFrame utility.
6
+ * Keeps heavy logic inside the plugin; framework layer just wires the component.
7
+ */
8
+ export declare const PrintPluginPackage: import('@embedpdf/core').WithAutoMount<import('@embedpdf/core').PluginPackage<import('../lib/index.ts').PrintPlugin, import('../lib/index.ts').PrintPluginConfig, unknown, import('@embedpdf/core').Action>>;
@@ -0,0 +1,59 @@
1
+ import * as $ from "svelte/internal/client";
2
+ import { useCapability, usePlugin } from "@embedpdf/core/svelte";
3
+ import { PrintPlugin, PrintPluginPackage as PrintPluginPackage$1 } from "@embedpdf/plugin-print";
4
+ export * from "@embedpdf/plugin-print";
5
+ import "svelte/internal/disclose-version";
6
+ import { createPluginPackage } from "@embedpdf/core";
7
+ const usePrintCapability = () => useCapability(PrintPlugin.id);
8
+ const usePrintPlugin = () => usePlugin(PrintPlugin.id);
9
+ var root = $.from_html(`<iframe title="Print Document" src="about:blank" style="position: absolute; display: none;"></iframe>`);
10
+ function Print($$anchor, $$props) {
11
+ $.push($$props, true);
12
+ const printCapability = usePrintCapability();
13
+ const printPlugin = usePrintPlugin();
14
+ let iframeRef = $.state(null);
15
+ let urlRef = null;
16
+ $.user_effect(() => {
17
+ if (!printCapability.provides || !printPlugin.plugin) return;
18
+ const unsubscribe = printPlugin.plugin.onPrintRequest(({ buffer, task }) => {
19
+ const iframe = $.get(iframeRef);
20
+ if (!iframe) return;
21
+ if (urlRef) {
22
+ URL.revokeObjectURL(urlRef);
23
+ urlRef = null;
24
+ }
25
+ const url = URL.createObjectURL(new Blob([buffer], { type: "application/pdf" }));
26
+ urlRef = url;
27
+ iframe.onload = () => {
28
+ var _a, _b;
29
+ if (iframe.src === url) {
30
+ task.progress({ stage: "iframe-ready", message: "Ready to print" });
31
+ (_a = iframe.contentWindow) == null ? void 0 : _a.focus();
32
+ (_b = iframe.contentWindow) == null ? void 0 : _b.print();
33
+ task.progress({ stage: "printing", message: "Print dialog opened" });
34
+ task.resolve(buffer);
35
+ }
36
+ };
37
+ iframe.src = url;
38
+ });
39
+ return () => {
40
+ unsubscribe();
41
+ if (urlRef) {
42
+ URL.revokeObjectURL(urlRef);
43
+ urlRef = null;
44
+ }
45
+ };
46
+ });
47
+ var iframe_1 = root();
48
+ $.bind_this(iframe_1, ($$value) => $.set(iframeRef, $$value), () => $.get(iframeRef));
49
+ $.append($$anchor, iframe_1);
50
+ $.pop();
51
+ }
52
+ const PrintPluginPackage = createPluginPackage(PrintPluginPackage$1).addUtility(Print).build();
53
+ export {
54
+ Print as PrintFrame,
55
+ PrintPluginPackage,
56
+ usePrintCapability,
57
+ usePrintPlugin
58
+ };
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-print.svelte.ts","../../src/svelte/components/print.svelte","../../src/svelte/index.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { PrintPlugin } from '@embedpdf/plugin-print';\n\n/**\n * Hook to get the print plugin's capability API.\n * This provides methods for initiating print operations.\n */\nexport const usePrintCapability = () => useCapability<PrintPlugin>(PrintPlugin.id);\n\n/**\n * Hook to get the raw print plugin instance.\n * Useful for accessing plugin-specific properties or methods not exposed in the capability.\n */\nexport const usePrintPlugin = () => usePlugin<PrintPlugin>(PrintPlugin.id);\n","<script lang=\"ts\">\n import { usePrintCapability, usePrintPlugin } from '../hooks';\n\n const printCapability = usePrintCapability();\n const printPlugin = usePrintPlugin();\n\n let iframeRef = $state<HTMLIFrameElement | null>(null);\n let urlRef: string | null = null;\n\n $effect(() => {\n if (!printCapability.provides || !printPlugin.plugin) return;\n\n const unsubscribe = printPlugin.plugin.onPrintRequest(({ buffer, task }) => {\n const iframe = iframeRef;\n if (!iframe) return;\n\n // cleanup old URL\n if (urlRef) {\n URL.revokeObjectURL(urlRef);\n urlRef = null;\n }\n\n const url = URL.createObjectURL(new Blob([buffer], { type: 'application/pdf' }));\n urlRef = url;\n\n iframe.onload = () => {\n if (iframe.src === url) {\n task.progress({ stage: 'iframe-ready', message: 'Ready to print' });\n iframe.contentWindow?.focus();\n iframe.contentWindow?.print();\n task.progress({ stage: 'printing', message: 'Print dialog opened' });\n task.resolve(buffer);\n }\n };\n\n iframe.src = url;\n });\n\n return () => {\n unsubscribe();\n if (urlRef) {\n URL.revokeObjectURL(urlRef);\n urlRef = null;\n }\n };\n });\n</script>\n\n<iframe\n bind:this={iframeRef}\n title=\"Print Document\"\n src=\"about:blank\"\n style=\"position: absolute; display: none;\"\n>\n</iframe>\n","export * from './hooks';\nexport * from './components';\nexport * from '@embedpdf/plugin-print';\n\nimport { createPluginPackage } from '@embedpdf/core';\nimport { PrintPluginPackage as BasePrintPackage } from '@embedpdf/plugin-print';\nimport { PrintFrame } from './components';\n\n/**\n * Build a Svelte-flavoured package by adding the Svelte PrintFrame utility.\n * Keeps heavy logic inside the plugin; framework layer just wires the component.\n */\nexport const PrintPluginPackage = createPluginPackage(BasePrintPackage)\n .addUtility(PrintFrame)\n .build();\n"],"names":["BasePrintPackage","PrintFrame"],"mappings":";;;;;;AAOa,MAAA,qBAA2B,MAAA,cAA2B,YAAY,EAAE;AAMpE,MAAA,iBAAuB,MAAA,UAAuB,YAAY,EAAE;;kCCbzE;;AAGQ,QAAA,kBAAkB,mBAAkB;AACpC,QAAA,cAAc,eAAc;AAE9B,MAAA,oBAA6C,IAAI;AACjD,MAAA,SAAwB;AAE5B,IAAA,YAAc,MAAA;AACP,QAAA,CAAA,gBAAgB,YAAa,CAAA,YAAY,OAAM;UAE9C,cAAc,YAAY,OAAO,eAAkB,CAAA,EAAA,QAAQ,WAAW;AACpE,YAAA,eAAS,SAAS;WACnB,OAAM;AAGP,UAAA,QAAQ;AACV,YAAI,gBAAgB,MAAM;AAC1B,iBAAS;AAAA,MACX;YAEM,MAAM,IAAI,gBAAe,IAAK,KAAI,CAAE,MAAM,GAAA,EAAK,MAAM,kBAAiB,CAAA,CAAA;AAC5E,eAAS;AAET,aAAO,SAAe,MAAA;;AAChB,YAAA,OAAO,QAAQ,KAAK;AACtB,eAAK,SAAW,EAAA,OAAO,gBAAgB,SAAS,kBAAgB;AAChE,uBAAO,kBAAP,mBAAsB;AACtB,uBAAO,kBAAP,mBAAsB;AACtB,eAAK,SAAW,EAAA,OAAO,YAAY,SAAS,uBAAqB;AACjE,eAAK,QAAQ,MAAM;AAAA,QACrB;AAAA,MACD;AAED,aAAO,MAAM;AAAA,KACd;AAEY,WAAA,MAAA;AACX,kBAAW;AACP,UAAA,QAAQ;AACV,YAAI,gBAAgB,MAAM;AAC1B,iBAAS;AAAA,MACX;AAAA,IACD;AAAA,GACF;;AAIU,IAAA,UAAA,UAAA,CAAA,YAAA,EAAA,IAAA,iCAAA,SAAS,CAAA;;;AAHtB;AClCO,MAAM,qBAAqB,oBAAoBA,oBAAgB,EACnE,WAAWC,KAAU,EACrB,MAAM;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-print",
3
- "version": "1.3.16",
3
+ "version": "1.4.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.cjs",
@@ -26,24 +26,30 @@
26
26
  "types": "./dist/vue/index.d.ts",
27
27
  "import": "./dist/vue/index.js",
28
28
  "require": "./dist/vue/index.cjs"
29
+ },
30
+ "./svelte": {
31
+ "types": "./dist/svelte/index.d.ts",
32
+ "import": "./dist/svelte/index.js",
33
+ "require": "./dist/svelte/index.cjs"
29
34
  }
30
35
  },
31
36
  "dependencies": {
32
- "@embedpdf/models": "1.3.16"
37
+ "@embedpdf/models": "1.4.1"
33
38
  },
34
39
  "devDependencies": {
35
40
  "@types/react": "^18.2.0",
36
41
  "@types/react-dom": "^18.2.0",
37
42
  "typescript": "^5.0.0",
38
- "@embedpdf/build": "1.0.1",
39
- "@embedpdf/core": "1.3.16"
43
+ "@embedpdf/core": "1.4.1",
44
+ "@embedpdf/build": "1.1.0"
40
45
  },
41
46
  "peerDependencies": {
42
47
  "react": ">=18.0.0",
43
48
  "react-dom": ">=18.0.0",
44
49
  "preact": "^10.26.4",
45
50
  "vue": ">=3.2.0",
46
- "@embedpdf/core": "1.3.16"
51
+ "svelte": ">=5 <6",
52
+ "@embedpdf/core": "1.4.1"
47
53
  },
48
54
  "files": [
49
55
  "dist",
@@ -66,7 +72,8 @@
66
72
  "build:react": "vite build --mode react",
67
73
  "build:preact": "vite build --mode preact",
68
74
  "build:vue": "vite build --mode vue",
69
- "build": "pnpm run clean && concurrently -c auto -n base,react,preact,vue \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\" \"vite build --mode vue\"",
75
+ "build:svelte": "vite build --mode svelte",
76
+ "build": "pnpm run clean && concurrently -c auto -n base,react,preact,vue,svelte \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\" \"vite build --mode vue\" \"vite build --mode svelte\"",
70
77
  "clean": "rimraf dist",
71
78
  "lint": "eslint src --color",
72
79
  "lint:fix": "eslint src --color --fix"