@embedpdf/plugin-export 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,4 @@
1
+ export interface DownloadProps {
2
+ fileName?: string;
3
+ }
4
+ export declare function Download(props: DownloadProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from './download';
@@ -0,0 +1 @@
1
+ export * from './use-export';
@@ -0,0 +1,11 @@
1
+ import { ExportPlugin } from '../../index.ts';
2
+ export declare const useExportPlugin: () => {
3
+ plugin: ExportPlugin | null;
4
+ isLoading: boolean;
5
+ ready: Promise<void>;
6
+ };
7
+ export declare const useExportCapability: () => {
8
+ provides: Readonly<import('../../index.ts').ExportCapability> | null;
9
+ isLoading: boolean;
10
+ ready: Promise<void>;
11
+ };
@@ -0,0 +1,4 @@
1
+ export * from './hooks';
2
+ export * from './component';
3
+ export * from '../index.ts';
4
+ export declare const ExportPluginPackage: import('@embedpdf/core').WithAutoMount<import('@embedpdf/core').PluginPackage<import('../index.ts').ExportPlugin, import('../index.ts').ExportPluginConfig, unknown, import('@embedpdf/core').Action>>;
@@ -0,0 +1,3 @@
1
+ declare const Download: import('svelte', { with: { "resolution-mode": "import" } }).Component<Record<string, never>, {}, "">;
2
+ type Download = ReturnType<typeof Download>;
3
+ export default Download;
@@ -0,0 +1 @@
1
+ export { default as Download } from './Download.svelte';
@@ -0,0 +1 @@
1
+ export * from './use-export.svelte';
@@ -0,0 +1,11 @@
1
+ import { ExportPlugin } from '../../lib/index.ts';
2
+ export declare const useExportPlugin: () => {
3
+ plugin: ExportPlugin | null;
4
+ isLoading: boolean;
5
+ ready: Promise<void>;
6
+ };
7
+ export declare const useExportCapability: () => {
8
+ provides: Readonly<import('../../lib/index.ts').ExportCapability> | null;
9
+ isLoading: boolean;
10
+ ready: Promise<void>;
11
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=require("@embedpdf/plugin-export");require("svelte/internal/disclose-version");const r=require("svelte/internal/client"),o=require("@embedpdf/models"),n=require("@embedpdf/core/svelte");function i(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const r in e)if("default"!==r){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}return t.default=e,Object.freeze(t)}const l=i(r),u=()=>n.usePlugin(t.ExportPlugin.id),a=()=>n.useCapability(t.ExportPlugin.id);var s=l.from_html('<a style="display: none" href="/" aria-label="Download link"></a>');function c(e,t){l.push(t,!0);const r=a(),n=u();let i;l.user_effect((()=>{if(!r.provides)return;if(!n.plugin)return;return n.plugin.onRequest((e=>{var t;if("download"===e){const e=i;if(!e)return;const r=null==(t=n.plugin)?void 0:t.saveAsCopyAndGetBufferAndName();null==r||r.wait((({buffer:t,name:r})=>{const o=URL.createObjectURL(new Blob([t]));e.href=o,e.download=r,e.click(),URL.revokeObjectURL(o)}),o.ignore)}}))}));var c=s();l.bind_this(c,(e=>i=e),(()=>i)),l.append(e,c),l.pop()}const p=e.createPluginPackage(t.ExportPluginPackage).addUtility(c).build();exports.Download=c,exports.ExportPluginPackage=p,exports.useExportCapability=a,exports.useExportPlugin=u,Object.keys(t).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})}));
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-export.svelte.ts","../../src/svelte/components/Download.svelte","../../src/svelte/index.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { ExportPlugin } from '@embedpdf/plugin-export';\n\nexport const useExportPlugin = () => usePlugin<ExportPlugin>(ExportPlugin.id);\nexport const useExportCapability = () => useCapability<ExportPlugin>(ExportPlugin.id);\n","<script lang=\"ts\">\n import { ignore } from '@embedpdf/models';\n import { useExportCapability, useExportPlugin } from '../hooks';\n\n const exportCapability = useExportCapability();\n const exportPlugin = useExportPlugin();\n\n let anchorElement: HTMLAnchorElement | undefined;\n\n $effect(() => {\n if (!exportCapability.provides) return;\n if (!exportPlugin.plugin) return;\n\n const unsub = exportPlugin.plugin.onRequest((action) => {\n if (action === 'download') {\n const el = anchorElement;\n if (!el) return;\n\n const task = exportPlugin.plugin?.saveAsCopyAndGetBufferAndName();\n task?.wait(({ buffer, name }) => {\n const url = URL.createObjectURL(new Blob([buffer]));\n el.href = url;\n el.download = name;\n el.click();\n URL.revokeObjectURL(url);\n }, ignore);\n }\n });\n\n return unsub;\n });\n</script>\n\n<a style=\"display: none\" bind:this={anchorElement} href=\"/\" aria-label=\"Download link\"></a>\n","import { createPluginPackage } from '@embedpdf/core';\nimport { ExportPluginPackage as BaseExportPackage } from '@embedpdf/plugin-export';\n\nimport { Download } from './components';\n\nexport * from './hooks';\nexport * from './components';\n\nexport * from '@embedpdf/plugin-export';\n\nexport const ExportPluginPackage = createPluginPackage(BaseExportPackage)\n .addUtility(Download)\n .build();\n"],"names":["useExportPlugin","usePlugin","ExportPlugin","id","useExportCapability","useCapability","exportCapability","exportPlugin","anchorElement","$","user_effect","provides","plugin","onRequest","action","el","task","_a","saveAsCopyAndGetBufferAndName","wait","buffer","name","url","URL","createObjectURL","Blob","href","download","click","revokeObjectURL","ignore","bind_this","a","$$value","ExportPluginPackage","createPluginPackage","BaseExportPackage","addUtility","Download","build"],"mappings":"skBAGaA,EAAwB,IAAAC,YAAwBC,EAAAA,aAAaC,IAC7DC,EAA4B,IAAAC,gBAA4BH,EAAAA,aAAaC,wHCA1E,MAAAG,EAAmBF,IACnBG,EAAeP,IAEjB,IAAAQ,EAEJC,EAAAC,aAAc,KACP,IAAAJ,EAAiBK,SAAQ,OACzB,IAAAJ,EAAaK,OAAM,OAkBjB,OAhBOL,EAAaK,OAAOC,WAAWC,aAC5B,aAAXA,EAAuB,CACnB,MAAAC,EAAKP,MACNO,EAAE,OAED,MAAAC,EAAO,OAAAC,EAAaV,EAAAK,aAAQ,EAAAK,EAAAC,gCAC5B,MAAAF,GAAAA,EAAAG,QAAQC,SAAQC,WACd,MAAAC,EAAMC,IAAIC,gBAAoB,IAAAC,MAAML,KAC1CL,EAAGW,KAAOJ,EACVP,EAAGY,SAAWN,EACdN,EAAGa,QACHL,IAAIM,gBAAgBP,EAAG,GACtBQ,EAAAA,OACL,IAGK,cAIyBrB,EAAAsB,UAAAC,GAAAC,GAAAzB,UAAAA,yBAFpC,CCrBO,MAAM0B,EAAsBC,EAAoBA,oBAAAC,EAAiBF,qBACrEG,WAAWC,GACXC"}
@@ -0,0 +1,4 @@
1
+ export * from './hooks';
2
+ export * from './components';
3
+ export * from '../lib/index.ts';
4
+ export declare const ExportPluginPackage: import('@embedpdf/core').WithAutoMount<import('@embedpdf/core').PluginPackage<import('../lib/index.ts').ExportPlugin, import('../lib/index.ts').ExportPluginConfig, unknown, import('@embedpdf/core').Action>>;
@@ -0,0 +1,51 @@
1
+ import { createPluginPackage } from "@embedpdf/core";
2
+ import { ExportPlugin, ExportPluginPackage as ExportPluginPackage$1 } from "@embedpdf/plugin-export";
3
+ export * from "@embedpdf/plugin-export";
4
+ import "svelte/internal/disclose-version";
5
+ import * as $ from "svelte/internal/client";
6
+ import { ignore } from "@embedpdf/models";
7
+ import { useCapability, usePlugin } from "@embedpdf/core/svelte";
8
+ const useExportPlugin = () => usePlugin(ExportPlugin.id);
9
+ const useExportCapability = () => useCapability(ExportPlugin.id);
10
+ var root = $.from_html(`<a style="display: none" href="/" aria-label="Download link"></a>`);
11
+ function Download($$anchor, $$props) {
12
+ $.push($$props, true);
13
+ const exportCapability = useExportCapability();
14
+ const exportPlugin = useExportPlugin();
15
+ let anchorElement;
16
+ $.user_effect(() => {
17
+ if (!exportCapability.provides) return;
18
+ if (!exportPlugin.plugin) return;
19
+ const unsub = exportPlugin.plugin.onRequest((action) => {
20
+ var _a;
21
+ if (action === "download") {
22
+ const el = anchorElement;
23
+ if (!el) return;
24
+ const task = (_a = exportPlugin.plugin) == null ? void 0 : _a.saveAsCopyAndGetBufferAndName();
25
+ task == null ? void 0 : task.wait(
26
+ ({ buffer, name }) => {
27
+ const url = URL.createObjectURL(new Blob([buffer]));
28
+ el.href = url;
29
+ el.download = name;
30
+ el.click();
31
+ URL.revokeObjectURL(url);
32
+ },
33
+ ignore
34
+ );
35
+ }
36
+ });
37
+ return unsub;
38
+ });
39
+ var a = root();
40
+ $.bind_this(a, ($$value) => anchorElement = $$value, () => anchorElement);
41
+ $.append($$anchor, a);
42
+ $.pop();
43
+ }
44
+ const ExportPluginPackage = createPluginPackage(ExportPluginPackage$1).addUtility(Download).build();
45
+ export {
46
+ Download,
47
+ ExportPluginPackage,
48
+ useExportCapability,
49
+ useExportPlugin
50
+ };
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-export.svelte.ts","../../src/svelte/components/Download.svelte","../../src/svelte/index.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { ExportPlugin } from '@embedpdf/plugin-export';\n\nexport const useExportPlugin = () => usePlugin<ExportPlugin>(ExportPlugin.id);\nexport const useExportCapability = () => useCapability<ExportPlugin>(ExportPlugin.id);\n","<script lang=\"ts\">\n import { ignore } from '@embedpdf/models';\n import { useExportCapability, useExportPlugin } from '../hooks';\n\n const exportCapability = useExportCapability();\n const exportPlugin = useExportPlugin();\n\n let anchorElement: HTMLAnchorElement | undefined;\n\n $effect(() => {\n if (!exportCapability.provides) return;\n if (!exportPlugin.plugin) return;\n\n const unsub = exportPlugin.plugin.onRequest((action) => {\n if (action === 'download') {\n const el = anchorElement;\n if (!el) return;\n\n const task = exportPlugin.plugin?.saveAsCopyAndGetBufferAndName();\n task?.wait(({ buffer, name }) => {\n const url = URL.createObjectURL(new Blob([buffer]));\n el.href = url;\n el.download = name;\n el.click();\n URL.revokeObjectURL(url);\n }, ignore);\n }\n });\n\n return unsub;\n });\n</script>\n\n<a style=\"display: none\" bind:this={anchorElement} href=\"/\" aria-label=\"Download link\"></a>\n","import { createPluginPackage } from '@embedpdf/core';\nimport { ExportPluginPackage as BaseExportPackage } from '@embedpdf/plugin-export';\n\nimport { Download } from './components';\n\nexport * from './hooks';\nexport * from './components';\n\nexport * from '@embedpdf/plugin-export';\n\nexport const ExportPluginPackage = createPluginPackage(BaseExportPackage)\n .addUtility(Download)\n .build();\n"],"names":["BaseExportPackage"],"mappings":";;;;;;;AAGa,MAAA,kBAAwB,MAAA,UAAwB,aAAa,EAAE;AAC/D,MAAA,sBAA4B,MAAA,cAA4B,aAAa,EAAE;;qCCJpF;;AAIQ,QAAA,mBAAmB,oBAAmB;AACtC,QAAA,eAAe,gBAAe;MAEhC;AAEJ,IAAA,YAAc,MAAA;AACP,QAAA,CAAA,iBAAiB,SAAQ;AACzB,QAAA,CAAA,aAAa,OAAM;UAElB,QAAQ,aAAa,OAAO,UAAS,CAAE,WAAW;;UAClD,WAAW,YAAY;AACnB,cAAA,KAAK;aACN,GAAE;AAED,cAAA,QAAO,kBAAa,WAAb,mBAAqB;AAClC,qCAAM;AAAA,aAAQ,QAAQ,WAAW;AACzB,kBAAA,MAAM,IAAI,gBAAoB,IAAA,MAAM,MAAM,CAAA,CAAA;AAChD,eAAG,OAAO;AACV,eAAG,WAAW;AACd,eAAG,MAAK;AACR,gBAAI,gBAAgB,GAAG;AAAA,UACxB;AAAA,UAAE;AAAA;AAAA,MACL;AAAA,KACD;WAEM;AAAA,GACR;;AAGiC,IAAA,UAAA,GAAA,CAAA,YAAA,+BAAA,aAAa;;;AAFjD;ACrBO,MAAM,sBAAsB,oBAAoBA,qBAAiB,EACrE,WAAW,QAAQ,EACnB,MAAM;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-export",
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,23 +26,29 @@
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
  "typescript": "^5.0.0",
37
- "@embedpdf/core": "1.3.16",
38
- "@embedpdf/build": "1.0.1"
42
+ "@embedpdf/core": "1.4.1",
43
+ "@embedpdf/build": "1.1.0"
39
44
  },
40
45
  "peerDependencies": {
41
46
  "react": ">=16.8.0",
42
47
  "react-dom": ">=16.8.0",
43
48
  "preact": "^10.26.4",
44
49
  "vue": ">=3.2.0",
45
- "@embedpdf/core": "1.3.16"
50
+ "svelte": ">=5 <6",
51
+ "@embedpdf/core": "1.4.1"
46
52
  },
47
53
  "files": [
48
54
  "dist",
@@ -65,7 +71,8 @@
65
71
  "build:react": "vite build --mode react",
66
72
  "build:preact": "vite build --mode preact",
67
73
  "build:vue": "vite build --mode vue",
68
- "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\"",
74
+ "build:svelte": "vite build --mode svelte",
75
+ "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\"",
69
76
  "clean": "rimraf dist",
70
77
  "lint": "eslint src --color",
71
78
  "lint:fix": "eslint src --color --fix"