@embedpdf/plugin-export 1.3.16 → 1.4.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.
- package/dist/shared/component/download.d.ts +4 -0
- package/dist/shared/component/index.d.ts +1 -0
- package/dist/shared/hooks/index.d.ts +1 -0
- package/dist/shared/hooks/use-export.d.ts +11 -0
- package/dist/shared/index.d.ts +4 -0
- package/dist/svelte/components/Download.svelte.d.ts +3 -0
- package/dist/svelte/components/index.d.ts +1 -0
- package/dist/svelte/hooks/index.d.ts +1 -0
- package/dist/svelte/hooks/use-export.svelte.d.ts +11 -0
- package/dist/svelte/index.cjs +2 -0
- package/dist/svelte/index.cjs.map +1 -0
- package/dist/svelte/index.d.ts +4 -0
- package/dist/svelte/index.js +50 -0
- package/dist/svelte/index.js.map +1 -0
- package/package.json +13 -6
|
@@ -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 @@
|
|
|
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),a=()=>n.usePlugin(t.ExportPlugin.id),u=()=>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{provides:r}=u(),{plugin:n}=a();let i;l.user_effect((()=>{if(!r)return;if(!n)return;return n.onRequest((e=>{if("download"===e){const e=i;if(!e)return;n.saveAsCopyAndGetBufferAndName().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=u,exports.useExportPlugin=a,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 { provides: exportCapability } = useExportCapability();\n const { plugin: exportPlugin } = useExportPlugin();\n\n let anchorElement: HTMLAnchorElement | undefined;\n\n $effect(() => {\n if (!exportCapability) return;\n if (!exportPlugin) return;\n\n const unsub = exportPlugin.onRequest((action) => {\n if (action === 'download') {\n const el = anchorElement;\n if (!el) return;\n\n const task = exportPlugin.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","provides","exportCapability","plugin","exportPlugin","anchorElement","$","user_effect","onRequest","action","el","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,8HCAxEG,SAAUC,GAAqBH,KAC/BI,OAAQC,GAAiBT,IAE7B,IAAAU,EAEJC,EAAAC,aAAc,SACPL,EAAgB,WAChBE,EAAY,OAkBV,OAhBOA,EAAaI,WAAWC,OACrB,aAAXA,EAAuB,CACnB,MAAAC,EAAKL,MACNK,EAAE,OAEMN,EAAaO,gCACrBC,QAAQC,SAAQC,WACb,MAAAC,EAAMC,IAAIC,gBAAoB,IAAAC,MAAML,KAC1CH,EAAGS,KAAOJ,EACVL,EAAGU,SAAWN,EACdJ,EAAGW,QACHL,IAAIM,gBAAgBP,EAAG,GACtBQ,EAAAA,OACL,IAGK,cAIyBjB,EAAAkB,UAAAC,GAAAC,GAAArB,UAAAA,yBAFpC,CCrBO,MAAMsB,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,50 @@
|
|
|
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 { provides: exportCapability } = useExportCapability();
|
|
14
|
+
const { plugin: exportPlugin } = useExportPlugin();
|
|
15
|
+
let anchorElement;
|
|
16
|
+
$.user_effect(() => {
|
|
17
|
+
if (!exportCapability) return;
|
|
18
|
+
if (!exportPlugin) return;
|
|
19
|
+
const unsub = exportPlugin.onRequest((action) => {
|
|
20
|
+
if (action === "download") {
|
|
21
|
+
const el = anchorElement;
|
|
22
|
+
if (!el) return;
|
|
23
|
+
const task = exportPlugin.saveAsCopyAndGetBufferAndName();
|
|
24
|
+
task.wait(
|
|
25
|
+
({ buffer, name }) => {
|
|
26
|
+
const url = URL.createObjectURL(new Blob([buffer]));
|
|
27
|
+
el.href = url;
|
|
28
|
+
el.download = name;
|
|
29
|
+
el.click();
|
|
30
|
+
URL.revokeObjectURL(url);
|
|
31
|
+
},
|
|
32
|
+
ignore
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return unsub;
|
|
37
|
+
});
|
|
38
|
+
var a = root();
|
|
39
|
+
$.bind_this(a, ($$value) => anchorElement = $$value, () => anchorElement);
|
|
40
|
+
$.append($$anchor, a);
|
|
41
|
+
$.pop();
|
|
42
|
+
}
|
|
43
|
+
const ExportPluginPackage = createPluginPackage(ExportPluginPackage$1).addUtility(Download).build();
|
|
44
|
+
export {
|
|
45
|
+
Download,
|
|
46
|
+
ExportPluginPackage,
|
|
47
|
+
useExportCapability,
|
|
48
|
+
useExportPlugin
|
|
49
|
+
};
|
|
50
|
+
//# 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 { provides: exportCapability } = useExportCapability();\n const { plugin: exportPlugin } = useExportPlugin();\n\n let anchorElement: HTMLAnchorElement | undefined;\n\n $effect(() => {\n if (!exportCapability) return;\n if (!exportPlugin) return;\n\n const unsub = exportPlugin.onRequest((action) => {\n if (action === 'download') {\n const el = anchorElement;\n if (!el) return;\n\n const task = exportPlugin.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;;UAIU,UAAU,iBAAgB,IAAK,oBAAmB;UAClD,QAAQ,aAAY,IAAK,gBAAe;MAE5C;AAEJ,IAAA,YAAc,MAAA;SACP,iBAAgB;SAChB,aAAY;AAEX,UAAA,QAAQ,aAAa,UAAS,CAAE,WAAW;UAC3C,WAAW,YAAY;AACnB,cAAA,KAAK;aACN,GAAE;cAED,OAAO,aAAa,8BAA6B;AACvD,aAAK;AAAA,aAAQ,QAAQ,WAAW;AACxB,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;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
|
+
"version": "1.4.0",
|
|
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.
|
|
37
|
+
"@embedpdf/models": "1.4.0"
|
|
33
38
|
},
|
|
34
39
|
"devDependencies": {
|
|
35
40
|
"@types/react": "^18.2.0",
|
|
36
41
|
"typescript": "^5.0.0",
|
|
37
|
-
"@embedpdf/core": "1.
|
|
38
|
-
"@embedpdf/build": "1.0
|
|
42
|
+
"@embedpdf/core": "1.4.0",
|
|
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
|
-
"
|
|
50
|
+
"svelte": ">=5 <6",
|
|
51
|
+
"@embedpdf/core": "1.4.0"
|
|
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": "
|
|
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"
|