@embedpdf/plugin-export 1.0.20 → 1.0.22
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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -6
- package/dist/index.js.map +1 -1
- package/dist/lib/export-plugin.d.ts +7 -3
- package/dist/lib/types.d.ts +6 -2
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +13 -7
- package/dist/preact/index.js.map +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +13 -7
- package/dist/react/index.js.map +1 -1
- package/dist/shared-preact/index.d.ts +2 -0
- package/dist/shared-react/index.d.ts +2 -0
- package/dist/vue/components/download.vue.d.ts +5 -0
- package/dist/vue/components/index.d.ts +1 -0
- package/dist/vue/hooks/index.d.ts +1 -0
- package/dist/vue/hooks/use-export.d.ts +3 -0
- package/dist/vue/index.cjs +2 -0
- package/dist/vue/index.cjs.map +1 -0
- package/dist/vue/index.d.ts +4 -0
- package/dist/vue/index.js +60 -0
- package/dist/vue/index.js.map +1 -0
- package/package.json +13 -6
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=require("@embedpdf/models"),o=class extends e.BasePlugin{constructor(t,o){super(t,o),this.downloadRequest$=e.createEmitter()}async initialize(e){}buildCapability(){return{saveAsCopy:this.saveAsCopy.bind(this),download:this.download.bind(this)
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=require("@embedpdf/models"),o=class extends e.BasePlugin{constructor(t,o,s){super(t,o),this.downloadRequest$=e.createEmitter(),this.config=s}async initialize(e){}buildCapability(){return{saveAsCopy:this.saveAsCopy.bind(this),download:this.download.bind(this)}}onRequest(e){return this.downloadRequest$.on(e)}download(){this.downloadRequest$.emit("download")}saveAsCopyAndGetBufferAndName(){const e=new t.Task,o=this.coreState.core.document;return o?(this.saveAsCopy().wait((t=>{e.resolve({buffer:t,name:o.name??this.config.defaultFileName})}),e.fail),e):t.PdfTaskHelper.reject({code:t.PdfErrorCode.DocNotOpen,message:"Document not found"})}saveAsCopy(){const e=this.coreState.core.document;return e?this.engine.saveAsCopy(e):t.PdfTaskHelper.reject({code:t.PdfErrorCode.DocNotOpen,message:"Document not found"})}};o.id="export";let s=o;const n="export",r={id:n,name:"Export Plugin",version:"1.0.0",provides:["export"],requires:[],optional:[],defaultConfig:{enabled:!0,defaultFileName:"document.pdf"}},i={manifest:r,create:(e,t)=>new s(n,e,t),reducer:()=>{},initialState:{}};exports.EXPORT_PLUGIN_ID=n,exports.ExportPlugin=s,exports.ExportPluginPackage=i,exports.manifest=r;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/lib/export-plugin.ts","../src/lib/manifest.ts","../src/lib/index.ts"],"sourcesContent":["import { BasePlugin, createEmitter, PluginRegistry } from '@embedpdf/core';\nimport {
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/lib/export-plugin.ts","../src/lib/manifest.ts","../src/lib/index.ts"],"sourcesContent":["import { BasePlugin, createEmitter, Listener, PluginRegistry, Unsubscribe } from '@embedpdf/core';\nimport { PdfErrorCode, PdfErrorReason, PdfTaskHelper, Task } from '@embedpdf/models';\n\nimport { BufferAndName, ExportCapability, ExportPluginConfig } from './types';\n\nexport class ExportPlugin extends BasePlugin<ExportPluginConfig, ExportCapability> {\n static readonly id = 'export' as const;\n\n private readonly downloadRequest$ = createEmitter<'download'>();\n private readonly config: ExportPluginConfig;\n\n constructor(id: string, registry: PluginRegistry, config: ExportPluginConfig) {\n super(id, registry);\n\n this.config = config;\n }\n\n async initialize(_: ExportPluginConfig): Promise<void> {}\n\n protected buildCapability(): ExportCapability {\n return {\n saveAsCopy: this.saveAsCopy.bind(this),\n download: this.download.bind(this),\n };\n }\n\n public onRequest(event: Listener<'download'>): Unsubscribe {\n return this.downloadRequest$.on(event);\n }\n\n private download(): void {\n this.downloadRequest$.emit('download');\n }\n\n public saveAsCopyAndGetBufferAndName(): Task<BufferAndName, PdfErrorReason> {\n const task = new Task<BufferAndName, PdfErrorReason>();\n const document = this.coreState.core.document;\n if (!document)\n return PdfTaskHelper.reject({\n code: PdfErrorCode.DocNotOpen,\n message: 'Document not found',\n });\n\n this.saveAsCopy().wait((result) => {\n task.resolve({\n buffer: result,\n name: document.name ?? this.config.defaultFileName,\n });\n }, task.fail);\n\n return task;\n }\n\n private saveAsCopy(): Task<ArrayBuffer, PdfErrorReason> {\n const document = this.coreState.core.document;\n\n if (!document)\n return PdfTaskHelper.reject({\n code: PdfErrorCode.DocNotOpen,\n message: 'Document not found',\n });\n\n return this.engine.saveAsCopy(document);\n }\n}\n","import { PluginManifest } from '@embedpdf/core';\nimport { ExportPluginConfig } from './types';\n\nexport const EXPORT_PLUGIN_ID = 'export';\n\nexport const manifest: PluginManifest<ExportPluginConfig> = {\n id: EXPORT_PLUGIN_ID,\n name: 'Export Plugin',\n version: '1.0.0',\n provides: ['export'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n defaultFileName: 'document.pdf',\n },\n};\n","import { PluginPackage } from '@embedpdf/core';\n\nimport { ExportPlugin } from './export-plugin';\nimport { manifest, EXPORT_PLUGIN_ID } from './manifest';\nimport { ExportPluginConfig } from './types';\n\nexport const ExportPluginPackage: PluginPackage<ExportPlugin, ExportPluginConfig> = {\n manifest,\n create: (registry, config) => new ExportPlugin(EXPORT_PLUGIN_ID, registry, config),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './export-plugin';\nexport * from './types';\nexport * from './manifest';\n"],"names":["_ExportPlugin","BasePlugin","constructor","id","registry","config","super","this","downloadRequest$","createEmitter","initialize","_","buildCapability","saveAsCopy","bind","download","onRequest","event","on","emit","saveAsCopyAndGetBufferAndName","task","Task","document","coreState","core","wait","result","resolve","buffer","name","defaultFileName","fail","PdfTaskHelper","reject","code","PdfErrorCode","DocNotOpen","message","engine","ExportPlugin","EXPORT_PLUGIN_ID","manifest","version","provides","requires","optional","defaultConfig","enabled","ExportPluginPackage","create","reducer","initialState"],"mappings":"gJAKaA,EAAN,cAA2BC,EAAAA,WAMhC,WAAAC,CAAYC,EAAYC,EAA0BC,GAChDC,MAAMH,EAAIC,GAJKG,KAAAC,iBAAmBC,kBAMlCF,KAAKF,OAASA,CAAA,CAGhB,gBAAMK,CAAWC,GAAsC,CAE7C,eAAAC,GACD,MAAA,CACLC,WAAYN,KAAKM,WAAWC,KAAKP,MACjCQ,SAAUR,KAAKQ,SAASD,KAAKP,MAC/B,CAGK,SAAAS,CAAUC,GACR,OAAAV,KAAKC,iBAAiBU,GAAGD,EAAK,CAG/B,QAAAF,GACDR,KAAAC,iBAAiBW,KAAK,WAAU,CAGhC,6BAAAC,GACC,MAAAC,EAAO,IAAIC,OACXC,EAAWhB,KAAKiB,UAAUC,KAAKF,SACrC,OAAKA,GAMLhB,KAAKM,aAAaa,MAAMC,IACtBN,EAAKO,QAAQ,CACXC,OAAQF,EACRG,KAAMP,EAASO,MAAQvB,KAAKF,OAAO0B,iBACpC,GACAV,EAAKW,MAEDX,GAZEY,EAAAA,cAAcC,OAAO,CAC1BC,KAAMC,EAAaA,aAAAC,WACnBC,QAAS,sBAUN,CAGD,UAAAzB,GACA,MAAAU,EAAWhB,KAAKiB,UAAUC,KAAKF,SAErC,OAAKA,EAMEhB,KAAKgC,OAAO1B,WAAWU,GALrBU,EAAAA,cAAcC,OAAO,CAC1BC,KAAMC,EAAaA,aAAAC,WACnBC,QAAS,sBAGyB,GAxDxCtC,EAAgBG,GAAK,SADhB,IAAMqC,EAANxC,ECFA,MAAMyC,EAAmB,SAEnBC,EAA+C,CAC1DvC,GAAIsC,EACJX,KAAM,gBACNa,QAAS,QACTC,SAAU,CAAC,UACXC,SAAU,GACVC,SAAU,GACVC,cAAe,CACbC,SAAS,EACTjB,gBAAiB,iBCRRkB,EAAuE,CAClFP,WACAQ,OAAQ,CAAC9C,EAAUC,IAAW,IAAImC,EAAaC,EAAkBrC,EAAUC,GAC3E8C,QAAS,OACTC,aAAc,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,41 @@
|
|
|
1
1
|
import { BasePlugin, createEmitter } from "@embedpdf/core";
|
|
2
|
-
import { PdfTaskHelper, PdfErrorCode } from "@embedpdf/models";
|
|
2
|
+
import { Task, PdfTaskHelper, PdfErrorCode } from "@embedpdf/models";
|
|
3
3
|
const _ExportPlugin = class _ExportPlugin extends BasePlugin {
|
|
4
|
-
constructor(id, registry) {
|
|
4
|
+
constructor(id, registry, config) {
|
|
5
5
|
super(id, registry);
|
|
6
6
|
this.downloadRequest$ = createEmitter();
|
|
7
|
+
this.config = config;
|
|
7
8
|
}
|
|
8
9
|
async initialize(_) {
|
|
9
10
|
}
|
|
10
11
|
buildCapability() {
|
|
11
12
|
return {
|
|
12
13
|
saveAsCopy: this.saveAsCopy.bind(this),
|
|
13
|
-
download: this.download.bind(this)
|
|
14
|
-
onRequest: this.downloadRequest$.on
|
|
14
|
+
download: this.download.bind(this)
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
+
onRequest(event) {
|
|
18
|
+
return this.downloadRequest$.on(event);
|
|
19
|
+
}
|
|
17
20
|
download() {
|
|
18
21
|
this.downloadRequest$.emit("download");
|
|
19
22
|
}
|
|
23
|
+
saveAsCopyAndGetBufferAndName() {
|
|
24
|
+
const task = new Task();
|
|
25
|
+
const document = this.coreState.core.document;
|
|
26
|
+
if (!document)
|
|
27
|
+
return PdfTaskHelper.reject({
|
|
28
|
+
code: PdfErrorCode.DocNotOpen,
|
|
29
|
+
message: "Document not found"
|
|
30
|
+
});
|
|
31
|
+
this.saveAsCopy().wait((result) => {
|
|
32
|
+
task.resolve({
|
|
33
|
+
buffer: result,
|
|
34
|
+
name: document.name ?? this.config.defaultFileName
|
|
35
|
+
});
|
|
36
|
+
}, task.fail);
|
|
37
|
+
return task;
|
|
38
|
+
}
|
|
20
39
|
saveAsCopy() {
|
|
21
40
|
const document = this.coreState.core.document;
|
|
22
41
|
if (!document)
|
|
@@ -38,12 +57,13 @@ const manifest = {
|
|
|
38
57
|
requires: [],
|
|
39
58
|
optional: [],
|
|
40
59
|
defaultConfig: {
|
|
41
|
-
enabled: true
|
|
60
|
+
enabled: true,
|
|
61
|
+
defaultFileName: "document.pdf"
|
|
42
62
|
}
|
|
43
63
|
};
|
|
44
64
|
const ExportPluginPackage = {
|
|
45
65
|
manifest,
|
|
46
|
-
create: (registry) => new ExportPlugin(EXPORT_PLUGIN_ID, registry),
|
|
66
|
+
create: (registry, config) => new ExportPlugin(EXPORT_PLUGIN_ID, registry, config),
|
|
47
67
|
reducer: () => {
|
|
48
68
|
},
|
|
49
69
|
initialState: {}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/lib/export-plugin.ts","../src/lib/manifest.ts","../src/lib/index.ts"],"sourcesContent":["import { BasePlugin, createEmitter, PluginRegistry } from '@embedpdf/core';\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/lib/export-plugin.ts","../src/lib/manifest.ts","../src/lib/index.ts"],"sourcesContent":["import { BasePlugin, createEmitter, Listener, PluginRegistry, Unsubscribe } from '@embedpdf/core';\nimport { PdfErrorCode, PdfErrorReason, PdfTaskHelper, Task } from '@embedpdf/models';\n\nimport { BufferAndName, ExportCapability, ExportPluginConfig } from './types';\n\nexport class ExportPlugin extends BasePlugin<ExportPluginConfig, ExportCapability> {\n static readonly id = 'export' as const;\n\n private readonly downloadRequest$ = createEmitter<'download'>();\n private readonly config: ExportPluginConfig;\n\n constructor(id: string, registry: PluginRegistry, config: ExportPluginConfig) {\n super(id, registry);\n\n this.config = config;\n }\n\n async initialize(_: ExportPluginConfig): Promise<void> {}\n\n protected buildCapability(): ExportCapability {\n return {\n saveAsCopy: this.saveAsCopy.bind(this),\n download: this.download.bind(this),\n };\n }\n\n public onRequest(event: Listener<'download'>): Unsubscribe {\n return this.downloadRequest$.on(event);\n }\n\n private download(): void {\n this.downloadRequest$.emit('download');\n }\n\n public saveAsCopyAndGetBufferAndName(): Task<BufferAndName, PdfErrorReason> {\n const task = new Task<BufferAndName, PdfErrorReason>();\n const document = this.coreState.core.document;\n if (!document)\n return PdfTaskHelper.reject({\n code: PdfErrorCode.DocNotOpen,\n message: 'Document not found',\n });\n\n this.saveAsCopy().wait((result) => {\n task.resolve({\n buffer: result,\n name: document.name ?? this.config.defaultFileName,\n });\n }, task.fail);\n\n return task;\n }\n\n private saveAsCopy(): Task<ArrayBuffer, PdfErrorReason> {\n const document = this.coreState.core.document;\n\n if (!document)\n return PdfTaskHelper.reject({\n code: PdfErrorCode.DocNotOpen,\n message: 'Document not found',\n });\n\n return this.engine.saveAsCopy(document);\n }\n}\n","import { PluginManifest } from '@embedpdf/core';\nimport { ExportPluginConfig } from './types';\n\nexport const EXPORT_PLUGIN_ID = 'export';\n\nexport const manifest: PluginManifest<ExportPluginConfig> = {\n id: EXPORT_PLUGIN_ID,\n name: 'Export Plugin',\n version: '1.0.0',\n provides: ['export'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n defaultFileName: 'document.pdf',\n },\n};\n","import { PluginPackage } from '@embedpdf/core';\n\nimport { ExportPlugin } from './export-plugin';\nimport { manifest, EXPORT_PLUGIN_ID } from './manifest';\nimport { ExportPluginConfig } from './types';\n\nexport const ExportPluginPackage: PluginPackage<ExportPlugin, ExportPluginConfig> = {\n manifest,\n create: (registry, config) => new ExportPlugin(EXPORT_PLUGIN_ID, registry, config),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './export-plugin';\nexport * from './types';\nexport * from './manifest';\n"],"names":[],"mappings":";;AAKO,MAAM,gBAAN,MAAM,sBAAqB,WAAiD;AAAA,EAMjF,YAAY,IAAY,UAA0B,QAA4B;AAC5E,UAAM,IAAI,QAAQ;AAJpB,SAAiB,mBAAmB,cAA0B;AAM5D,SAAK,SAAS;AAAA,EAAA;AAAA,EAGhB,MAAM,WAAW,GAAsC;AAAA,EAAA;AAAA,EAE7C,kBAAoC;AACrC,WAAA;AAAA,MACL,YAAY,KAAK,WAAW,KAAK,IAAI;AAAA,MACrC,UAAU,KAAK,SAAS,KAAK,IAAI;AAAA,IACnC;AAAA,EAAA;AAAA,EAGK,UAAU,OAA0C;AAClD,WAAA,KAAK,iBAAiB,GAAG,KAAK;AAAA,EAAA;AAAA,EAG/B,WAAiB;AAClB,SAAA,iBAAiB,KAAK,UAAU;AAAA,EAAA;AAAA,EAGhC,gCAAqE;AACpE,UAAA,OAAO,IAAI,KAAoC;AAC/C,UAAA,WAAW,KAAK,UAAU,KAAK;AACrC,QAAI,CAAC;AACH,aAAO,cAAc,OAAO;AAAA,QAC1B,MAAM,aAAa;AAAA,QACnB,SAAS;AAAA,MAAA,CACV;AAEH,SAAK,WAAW,EAAE,KAAK,CAAC,WAAW;AACjC,WAAK,QAAQ;AAAA,QACX,QAAQ;AAAA,QACR,MAAM,SAAS,QAAQ,KAAK,OAAO;AAAA,MAAA,CACpC;AAAA,IAAA,GACA,KAAK,IAAI;AAEL,WAAA;AAAA,EAAA;AAAA,EAGD,aAAgD;AAChD,UAAA,WAAW,KAAK,UAAU,KAAK;AAErC,QAAI,CAAC;AACH,aAAO,cAAc,OAAO;AAAA,QAC1B,MAAM,aAAa;AAAA,QACnB,SAAS;AAAA,MAAA,CACV;AAEI,WAAA,KAAK,OAAO,WAAW,QAAQ;AAAA,EAAA;AAE1C;AA1DE,cAAgB,KAAK;AADhB,IAAM,eAAN;ACFA,MAAM,mBAAmB;AAEzB,MAAM,WAA+C;AAAA,EAC1D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,QAAQ;AAAA,EACnB,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,eAAe;AAAA,IACb,SAAS;AAAA,IACT,iBAAiB;AAAA,EAAA;AAErB;ACVO,MAAM,sBAAuE;AAAA,EAClF;AAAA,EACA,QAAQ,CAAC,UAAU,WAAW,IAAI,aAAa,kBAAkB,UAAU,MAAM;AAAA,EACjF,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,cAAc,CAAA;AAChB;"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { BasePlugin, PluginRegistry } from '@embedpdf/core';
|
|
2
|
-
import {
|
|
1
|
+
import { BasePlugin, Listener, PluginRegistry, Unsubscribe } from '@embedpdf/core';
|
|
2
|
+
import { PdfErrorReason, Task } from '@embedpdf/models';
|
|
3
|
+
import { BufferAndName, ExportCapability, ExportPluginConfig } from './types';
|
|
3
4
|
export declare class ExportPlugin extends BasePlugin<ExportPluginConfig, ExportCapability> {
|
|
4
5
|
static readonly id: "export";
|
|
5
6
|
private readonly downloadRequest$;
|
|
6
|
-
|
|
7
|
+
private readonly config;
|
|
8
|
+
constructor(id: string, registry: PluginRegistry, config: ExportPluginConfig);
|
|
7
9
|
initialize(_: ExportPluginConfig): Promise<void>;
|
|
8
10
|
protected buildCapability(): ExportCapability;
|
|
11
|
+
onRequest(event: Listener<'download'>): Unsubscribe;
|
|
9
12
|
private download;
|
|
13
|
+
saveAsCopyAndGetBufferAndName(): Task<BufferAndName, PdfErrorReason>;
|
|
10
14
|
private saveAsCopy;
|
|
11
15
|
}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { BasePluginConfig
|
|
1
|
+
import { BasePluginConfig } from '@embedpdf/core';
|
|
2
2
|
import { PdfErrorReason, Task } from '@embedpdf/models';
|
|
3
3
|
export interface ExportPluginConfig extends BasePluginConfig {
|
|
4
|
+
defaultFileName: string;
|
|
5
|
+
}
|
|
6
|
+
export interface BufferAndName {
|
|
7
|
+
buffer: ArrayBuffer;
|
|
8
|
+
name: string;
|
|
4
9
|
}
|
|
5
10
|
export interface ExportCapability {
|
|
6
11
|
saveAsCopy: () => Task<ArrayBuffer, PdfErrorReason>;
|
|
7
12
|
download: () => void;
|
|
8
|
-
onRequest: EventHook<'download'>;
|
|
9
13
|
}
|
package/dist/preact/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),r=require("@embedpdf/plugin-export"),t=require("preact/jsx-runtime"),o=require("@embedpdf/models"),i=require("preact/hooks"),n=require("@embedpdf/core/preact"),u=()=>n.usePlugin(r.ExportPlugin.id),a=()=>n.useCapability(r.ExportPlugin.id);function p(e){const{provides:r}=a(),{plugin:n}=u(),p=i.useRef(null);return i.useEffect((()=>{if(!r)return;if(!n)return;return n.onRequest((r=>{if("download"===r){const r=p.current;if(!r)return;n.saveAsCopyAndGetBufferAndName().wait((({buffer:t,name:o})=>{const i=URL.createObjectURL(new Blob([t]));r.href=i,r.download=e.fileName??o,r.click(),URL.revokeObjectURL(i)}),o.ignore)}}))}),[r,n]),t.jsx("a",{style:{display:"none"},ref:p})}const s=e.createPluginPackage(r.ExportPluginPackage).addUtility(p).build();exports.Download=p,exports.ExportPluginPackage=s,exports.useExportCapability=a,exports.useExportPlugin=u,Object.keys(r).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})}));
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-export.ts","../../src/shared/component/download.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { ExportPlugin } from '@embedpdf/plugin-export';\n\nexport const useExportPlugin = () => usePlugin<ExportPlugin>(ExportPlugin.id);\nexport const useExportCapability = () => useCapability<ExportPlugin>(ExportPlugin.id);\n","import { ignore } from '@embedpdf/models';\nimport { useEffect, useRef } from '@framework';\n\nimport { useExportCapability } from '../hooks';\n\nexport interface DownloadProps {\n fileName?: string
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-export.ts","../../src/shared/component/download.tsx","../../src/shared/index.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { ExportPlugin } from '@embedpdf/plugin-export';\n\nexport const useExportPlugin = () => usePlugin<ExportPlugin>(ExportPlugin.id);\nexport const useExportCapability = () => useCapability<ExportPlugin>(ExportPlugin.id);\n","import { ignore } from '@embedpdf/models';\nimport { useEffect, useRef } from '@framework';\n\nimport { useExportCapability, useExportPlugin } from '../hooks';\n\nexport interface DownloadProps {\n fileName?: string;\n}\n\nexport function Download(props: DownloadProps) {\n const { provides: exportCapability } = useExportCapability();\n const { plugin: exportPlugin } = useExportPlugin();\n const ref = useRef<HTMLAnchorElement>(null);\n\n useEffect(() => {\n if (!exportCapability) return;\n if (!exportPlugin) return;\n\n const unsub = exportPlugin.onRequest((action) => {\n if (action === 'download') {\n const el = ref.current;\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 = props.fileName ?? name;\n el.click();\n URL.revokeObjectURL(url);\n }, ignore);\n }\n });\n\n return unsub;\n }, [exportCapability, exportPlugin]);\n\n return <a style={{ display: 'none' }} ref={ref} />;\n}\n","import { createPluginPackage } from '@embedpdf/core';\nimport { ExportPluginPackage as BaseExportPackage } from '@embedpdf/plugin-export';\n\nimport { Download } from './component';\n\nexport * from './hooks';\nexport * from './component';\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","Download","props","provides","exportCapability","plugin","exportPlugin","ref","useRef","useEffect","onRequest","action","el","current","saveAsCopyAndGetBufferAndName","wait","buffer","name","url","URL","createObjectURL","Blob","href","download","fileName","click","revokeObjectURL","ignore","style","display","ExportPluginPackage","createPluginPackage","BaseExportPackage","addUtility","build"],"mappings":"kRAGaA,EAAkB,IAAMC,YAAwBC,EAAAA,aAAaC,IAC7DC,EAAsB,IAAMC,gBAA4BH,EAAAA,aAAaC,ICK3E,SAASG,EAASC,GACvB,MAAQC,SAAUC,GAAqBL,KAC/BM,OAAQC,GAAiBX,IAC3BY,EAAMC,SAA0B,aAEtCC,EAAAA,WAAU,KACR,IAAKL,EAAkB,OACvB,IAAKE,EAAc,OAkBZ,OAhBOA,EAAaI,WAAWC,IACpC,GAAe,aAAXA,EAAuB,CACzB,MAAMC,EAAKL,EAAIM,QACf,IAAKD,EAAI,OAEIN,EAAaQ,gCACrBC,MAAK,EAAGC,SAAQC,WACb,MAAAC,EAAMC,IAAIC,gBAAgB,IAAIC,KAAK,CAACL,KAC1CJ,EAAGU,KAAOJ,EACPN,EAAAW,SAAWrB,EAAMsB,UAAYP,EAChCL,EAAGa,QACHN,IAAIO,gBAAgBR,EAAG,GACtBS,SAAM,IAIN,GACN,CAACvB,EAAkBE,UAEd,IAAE,CAAAsB,MAAO,CAAEC,QAAS,QAAUtB,OACxC,CC5BO,MAAMuB,EAAsBC,EAAoBA,oBAAAC,EAAiBF,qBACrEG,WAAWhC,GACXiC"}
|
package/dist/preact/index.js
CHANGED
|
@@ -1,35 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ExportPlugin } from "@embedpdf/plugin-export";
|
|
1
|
+
import { createPluginPackage } from "@embedpdf/core";
|
|
2
|
+
import { ExportPlugin, ExportPluginPackage as ExportPluginPackage$1 } from "@embedpdf/plugin-export";
|
|
3
|
+
export * from "@embedpdf/plugin-export";
|
|
3
4
|
import { jsx } from "preact/jsx-runtime";
|
|
4
5
|
import { ignore } from "@embedpdf/models";
|
|
5
6
|
import { useRef, useEffect } from "preact/hooks";
|
|
7
|
+
import { useCapability, usePlugin } from "@embedpdf/core/preact";
|
|
6
8
|
const useExportPlugin = () => usePlugin(ExportPlugin.id);
|
|
7
9
|
const useExportCapability = () => useCapability(ExportPlugin.id);
|
|
8
10
|
function Download(props) {
|
|
9
11
|
const { provides: exportCapability } = useExportCapability();
|
|
12
|
+
const { plugin: exportPlugin } = useExportPlugin();
|
|
10
13
|
const ref = useRef(null);
|
|
11
14
|
useEffect(() => {
|
|
12
15
|
if (!exportCapability) return;
|
|
13
|
-
|
|
16
|
+
if (!exportPlugin) return;
|
|
17
|
+
const unsub = exportPlugin.onRequest((action) => {
|
|
14
18
|
if (action === "download") {
|
|
15
19
|
const el = ref.current;
|
|
16
20
|
if (!el) return;
|
|
17
|
-
const task =
|
|
18
|
-
task.wait((buffer) => {
|
|
21
|
+
const task = exportPlugin.saveAsCopyAndGetBufferAndName();
|
|
22
|
+
task.wait(({ buffer, name }) => {
|
|
19
23
|
const url = URL.createObjectURL(new Blob([buffer]));
|
|
20
24
|
el.href = url;
|
|
21
|
-
el.download = props.fileName ??
|
|
25
|
+
el.download = props.fileName ?? name;
|
|
22
26
|
el.click();
|
|
23
27
|
URL.revokeObjectURL(url);
|
|
24
28
|
}, ignore);
|
|
25
29
|
}
|
|
26
30
|
});
|
|
27
31
|
return unsub;
|
|
28
|
-
}, [exportCapability]);
|
|
32
|
+
}, [exportCapability, exportPlugin]);
|
|
29
33
|
return /* @__PURE__ */ jsx("a", { style: { display: "none" }, ref });
|
|
30
34
|
}
|
|
35
|
+
const ExportPluginPackage = createPluginPackage(ExportPluginPackage$1).addUtility(Download).build();
|
|
31
36
|
export {
|
|
32
37
|
Download,
|
|
38
|
+
ExportPluginPackage,
|
|
33
39
|
useExportCapability,
|
|
34
40
|
useExportPlugin
|
|
35
41
|
};
|
package/dist/preact/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-export.ts","../../src/shared/component/download.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { ExportPlugin } from '@embedpdf/plugin-export';\n\nexport const useExportPlugin = () => usePlugin<ExportPlugin>(ExportPlugin.id);\nexport const useExportCapability = () => useCapability<ExportPlugin>(ExportPlugin.id);\n","import { ignore } from '@embedpdf/models';\nimport { useEffect, useRef } from '@framework';\n\nimport { useExportCapability } from '../hooks';\n\nexport interface DownloadProps {\n fileName?: string
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-export.ts","../../src/shared/component/download.tsx","../../src/shared/index.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { ExportPlugin } from '@embedpdf/plugin-export';\n\nexport const useExportPlugin = () => usePlugin<ExportPlugin>(ExportPlugin.id);\nexport const useExportCapability = () => useCapability<ExportPlugin>(ExportPlugin.id);\n","import { ignore } from '@embedpdf/models';\nimport { useEffect, useRef } from '@framework';\n\nimport { useExportCapability, useExportPlugin } from '../hooks';\n\nexport interface DownloadProps {\n fileName?: string;\n}\n\nexport function Download(props: DownloadProps) {\n const { provides: exportCapability } = useExportCapability();\n const { plugin: exportPlugin } = useExportPlugin();\n const ref = useRef<HTMLAnchorElement>(null);\n\n useEffect(() => {\n if (!exportCapability) return;\n if (!exportPlugin) return;\n\n const unsub = exportPlugin.onRequest((action) => {\n if (action === 'download') {\n const el = ref.current;\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 = props.fileName ?? name;\n el.click();\n URL.revokeObjectURL(url);\n }, ignore);\n }\n });\n\n return unsub;\n }, [exportCapability, exportPlugin]);\n\n return <a style={{ display: 'none' }} ref={ref} />;\n}\n","import { createPluginPackage } from '@embedpdf/core';\nimport { ExportPluginPackage as BaseExportPackage } from '@embedpdf/plugin-export';\n\nimport { Download } from './component';\n\nexport * from './hooks';\nexport * from './component';\n\nexport * from '@embedpdf/plugin-export';\n\nexport const ExportPluginPackage = createPluginPackage(BaseExportPackage)\n .addUtility(Download)\n .build();\n"],"names":["BaseExportPackage"],"mappings":";;;;;;;AAGO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;ACK7E,SAAS,SAAS,OAAsB;AAC7C,QAAM,EAAE,UAAU,iBAAiB,IAAI,oBAAoB;AAC3D,QAAM,EAAE,QAAQ,aAAa,IAAI,gBAAgB;AAC3C,QAAA,MAAM,OAA0B,IAAI;AAE1C,YAAU,MAAM;AACd,QAAI,CAAC,iBAAkB;AACvB,QAAI,CAAC,aAAc;AAEnB,UAAM,QAAQ,aAAa,UAAU,CAAC,WAAW;AAC/C,UAAI,WAAW,YAAY;AACzB,cAAM,KAAK,IAAI;AACf,YAAI,CAAC,GAAI;AAEH,cAAA,OAAO,aAAa,8BAA8B;AACxD,aAAK,KAAK,CAAC,EAAE,QAAQ,WAAW;AACxB,gBAAA,MAAM,IAAI,gBAAgB,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;AAClD,aAAG,OAAO;AACP,aAAA,WAAW,MAAM,YAAY;AAChC,aAAG,MAAM;AACT,cAAI,gBAAgB,GAAG;AAAA,WACtB,MAAM;AAAA,MAAA;AAAA,IACX,CACD;AAEM,WAAA;AAAA,EAAA,GACN,CAAC,kBAAkB,YAAY,CAAC;AAEnC,6BAAQ,KAAE,EAAA,OAAO,EAAE,SAAS,OAAA,GAAU,KAAU;AAClD;AC5BO,MAAM,sBAAsB,oBAAoBA,qBAAiB,EACrE,WAAW,QAAQ,EACnB,MAAM;"}
|
package/dist/react/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),r=require("@embedpdf/plugin-export"),t=require("react/jsx-runtime"),o=require("@embedpdf/models"),i=require("react"),n=require("@embedpdf/core/react"),u=()=>n.usePlugin(r.ExportPlugin.id),a=()=>n.useCapability(r.ExportPlugin.id);function l(e){const{provides:r}=a(),{plugin:n}=u(),l=i.useRef(null);return i.useEffect((()=>{if(!r)return;if(!n)return;return n.onRequest((r=>{if("download"===r){const r=l.current;if(!r)return;n.saveAsCopyAndGetBufferAndName().wait((({buffer:t,name:o})=>{const i=URL.createObjectURL(new Blob([t]));r.href=i,r.download=e.fileName??o,r.click(),URL.revokeObjectURL(i)}),o.ignore)}}))}),[r,n]),t.jsx("a",{style:{display:"none"},ref:l})}const s=e.createPluginPackage(r.ExportPluginPackage).addUtility(l).build();exports.Download=l,exports.ExportPluginPackage=s,exports.useExportCapability=a,exports.useExportPlugin=u,Object.keys(r).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})}));
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/react/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-export.ts","../../src/shared/component/download.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { ExportPlugin } from '@embedpdf/plugin-export';\n\nexport const useExportPlugin = () => usePlugin<ExportPlugin>(ExportPlugin.id);\nexport const useExportCapability = () => useCapability<ExportPlugin>(ExportPlugin.id);\n","import { ignore } from '@embedpdf/models';\nimport { useEffect, useRef } from '@framework';\n\nimport { useExportCapability } from '../hooks';\n\nexport interface DownloadProps {\n fileName?: string
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-export.ts","../../src/shared/component/download.tsx","../../src/shared/index.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { ExportPlugin } from '@embedpdf/plugin-export';\n\nexport const useExportPlugin = () => usePlugin<ExportPlugin>(ExportPlugin.id);\nexport const useExportCapability = () => useCapability<ExportPlugin>(ExportPlugin.id);\n","import { ignore } from '@embedpdf/models';\nimport { useEffect, useRef } from '@framework';\n\nimport { useExportCapability, useExportPlugin } from '../hooks';\n\nexport interface DownloadProps {\n fileName?: string;\n}\n\nexport function Download(props: DownloadProps) {\n const { provides: exportCapability } = useExportCapability();\n const { plugin: exportPlugin } = useExportPlugin();\n const ref = useRef<HTMLAnchorElement>(null);\n\n useEffect(() => {\n if (!exportCapability) return;\n if (!exportPlugin) return;\n\n const unsub = exportPlugin.onRequest((action) => {\n if (action === 'download') {\n const el = ref.current;\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 = props.fileName ?? name;\n el.click();\n URL.revokeObjectURL(url);\n }, ignore);\n }\n });\n\n return unsub;\n }, [exportCapability, exportPlugin]);\n\n return <a style={{ display: 'none' }} ref={ref} />;\n}\n","import { createPluginPackage } from '@embedpdf/core';\nimport { ExportPluginPackage as BaseExportPackage } from '@embedpdf/plugin-export';\n\nimport { Download } from './component';\n\nexport * from './hooks';\nexport * from './component';\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","Download","props","provides","exportCapability","plugin","exportPlugin","ref","useRef","useEffect","onRequest","action","el","current","saveAsCopyAndGetBufferAndName","wait","buffer","name","url","URL","createObjectURL","Blob","href","download","fileName","click","revokeObjectURL","ignore","style","display","ExportPluginPackage","createPluginPackage","BaseExportPackage","addUtility","build"],"mappings":"yQAGaA,EAAkB,IAAMC,YAAwBC,EAAAA,aAAaC,IAC7DC,EAAsB,IAAMC,gBAA4BH,EAAAA,aAAaC,ICK3E,SAASG,EAASC,GACvB,MAAQC,SAAUC,GAAqBL,KAC/BM,OAAQC,GAAiBX,IAC3BY,EAAMC,SAA0B,aAEtCC,EAAAA,WAAU,KACR,IAAKL,EAAkB,OACvB,IAAKE,EAAc,OAkBZ,OAhBOA,EAAaI,WAAWC,IACpC,GAAe,aAAXA,EAAuB,CACzB,MAAMC,EAAKL,EAAIM,QACf,IAAKD,EAAI,OAEIN,EAAaQ,gCACrBC,MAAK,EAAGC,SAAQC,WACb,MAAAC,EAAMC,IAAIC,gBAAgB,IAAIC,KAAK,CAACL,KAC1CJ,EAAGU,KAAOJ,EACPN,EAAAW,SAAWrB,EAAMsB,UAAYP,EAChCL,EAAGa,QACHN,IAAIO,gBAAgBR,EAAG,GACtBS,SAAM,IAIN,GACN,CAACvB,EAAkBE,UAEd,IAAE,CAAAsB,MAAO,CAAEC,QAAS,QAAUtB,OACxC,CC5BO,MAAMuB,EAAsBC,EAAoBA,oBAAAC,EAAiBF,qBACrEG,WAAWhC,GACXiC"}
|
package/dist/react/index.js
CHANGED
|
@@ -1,35 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ExportPlugin } from "@embedpdf/plugin-export";
|
|
1
|
+
import { createPluginPackage } from "@embedpdf/core";
|
|
2
|
+
import { ExportPlugin, ExportPluginPackage as ExportPluginPackage$1 } from "@embedpdf/plugin-export";
|
|
3
|
+
export * from "@embedpdf/plugin-export";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
import { ignore } from "@embedpdf/models";
|
|
5
6
|
import { useRef, useEffect } from "react";
|
|
7
|
+
import { useCapability, usePlugin } from "@embedpdf/core/react";
|
|
6
8
|
const useExportPlugin = () => usePlugin(ExportPlugin.id);
|
|
7
9
|
const useExportCapability = () => useCapability(ExportPlugin.id);
|
|
8
10
|
function Download(props) {
|
|
9
11
|
const { provides: exportCapability } = useExportCapability();
|
|
12
|
+
const { plugin: exportPlugin } = useExportPlugin();
|
|
10
13
|
const ref = useRef(null);
|
|
11
14
|
useEffect(() => {
|
|
12
15
|
if (!exportCapability) return;
|
|
13
|
-
|
|
16
|
+
if (!exportPlugin) return;
|
|
17
|
+
const unsub = exportPlugin.onRequest((action) => {
|
|
14
18
|
if (action === "download") {
|
|
15
19
|
const el = ref.current;
|
|
16
20
|
if (!el) return;
|
|
17
|
-
const task =
|
|
18
|
-
task.wait((buffer) => {
|
|
21
|
+
const task = exportPlugin.saveAsCopyAndGetBufferAndName();
|
|
22
|
+
task.wait(({ buffer, name }) => {
|
|
19
23
|
const url = URL.createObjectURL(new Blob([buffer]));
|
|
20
24
|
el.href = url;
|
|
21
|
-
el.download = props.fileName ??
|
|
25
|
+
el.download = props.fileName ?? name;
|
|
22
26
|
el.click();
|
|
23
27
|
URL.revokeObjectURL(url);
|
|
24
28
|
}, ignore);
|
|
25
29
|
}
|
|
26
30
|
});
|
|
27
31
|
return unsub;
|
|
28
|
-
}, [exportCapability]);
|
|
32
|
+
}, [exportCapability, exportPlugin]);
|
|
29
33
|
return /* @__PURE__ */ jsx("a", { style: { display: "none" }, ref });
|
|
30
34
|
}
|
|
35
|
+
const ExportPluginPackage = createPluginPackage(ExportPluginPackage$1).addUtility(Download).build();
|
|
31
36
|
export {
|
|
32
37
|
Download,
|
|
38
|
+
ExportPluginPackage,
|
|
33
39
|
useExportCapability,
|
|
34
40
|
useExportPlugin
|
|
35
41
|
};
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-export.ts","../../src/shared/component/download.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { ExportPlugin } from '@embedpdf/plugin-export';\n\nexport const useExportPlugin = () => usePlugin<ExportPlugin>(ExportPlugin.id);\nexport const useExportCapability = () => useCapability<ExportPlugin>(ExportPlugin.id);\n","import { ignore } from '@embedpdf/models';\nimport { useEffect, useRef } from '@framework';\n\nimport { useExportCapability } from '../hooks';\n\nexport interface DownloadProps {\n fileName?: string
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-export.ts","../../src/shared/component/download.tsx","../../src/shared/index.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { ExportPlugin } from '@embedpdf/plugin-export';\n\nexport const useExportPlugin = () => usePlugin<ExportPlugin>(ExportPlugin.id);\nexport const useExportCapability = () => useCapability<ExportPlugin>(ExportPlugin.id);\n","import { ignore } from '@embedpdf/models';\nimport { useEffect, useRef } from '@framework';\n\nimport { useExportCapability, useExportPlugin } from '../hooks';\n\nexport interface DownloadProps {\n fileName?: string;\n}\n\nexport function Download(props: DownloadProps) {\n const { provides: exportCapability } = useExportCapability();\n const { plugin: exportPlugin } = useExportPlugin();\n const ref = useRef<HTMLAnchorElement>(null);\n\n useEffect(() => {\n if (!exportCapability) return;\n if (!exportPlugin) return;\n\n const unsub = exportPlugin.onRequest((action) => {\n if (action === 'download') {\n const el = ref.current;\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 = props.fileName ?? name;\n el.click();\n URL.revokeObjectURL(url);\n }, ignore);\n }\n });\n\n return unsub;\n }, [exportCapability, exportPlugin]);\n\n return <a style={{ display: 'none' }} ref={ref} />;\n}\n","import { createPluginPackage } from '@embedpdf/core';\nimport { ExportPluginPackage as BaseExportPackage } from '@embedpdf/plugin-export';\n\nimport { Download } from './component';\n\nexport * from './hooks';\nexport * from './component';\n\nexport * from '@embedpdf/plugin-export';\n\nexport const ExportPluginPackage = createPluginPackage(BaseExportPackage)\n .addUtility(Download)\n .build();\n"],"names":["BaseExportPackage"],"mappings":";;;;;;;AAGO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;ACK7E,SAAS,SAAS,OAAsB;AAC7C,QAAM,EAAE,UAAU,iBAAiB,IAAI,oBAAoB;AAC3D,QAAM,EAAE,QAAQ,aAAa,IAAI,gBAAgB;AAC3C,QAAA,MAAM,OAA0B,IAAI;AAE1C,YAAU,MAAM;AACd,QAAI,CAAC,iBAAkB;AACvB,QAAI,CAAC,aAAc;AAEnB,UAAM,QAAQ,aAAa,UAAU,CAAC,WAAW;AAC/C,UAAI,WAAW,YAAY;AACzB,cAAM,KAAK,IAAI;AACf,YAAI,CAAC,GAAI;AAEH,cAAA,OAAO,aAAa,8BAA8B;AACxD,aAAK,KAAK,CAAC,EAAE,QAAQ,WAAW;AACxB,gBAAA,MAAM,IAAI,gBAAgB,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;AAClD,aAAG,OAAO;AACP,aAAA,WAAW,MAAM,YAAY;AAChC,aAAG,MAAM;AACT,cAAI,gBAAgB,GAAG;AAAA,WACtB,MAAM;AAAA,MAAA;AAAA,IACX,CACD;AAEM,WAAA;AAAA,EAAA,GACN,CAAC,kBAAkB,YAAY,CAAC;AAEnC,6BAAQ,KAAE,EAAA,OAAO,EAAE,SAAS,OAAA,GAAU,KAAU;AAClD;AC5BO,MAAM,sBAAsB,oBAAoBA,qBAAiB,EACrE,WAAW,QAAQ,EACnB,MAAM;"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export * from './hooks';
|
|
2
2
|
export * from './component';
|
|
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>>;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export * from './hooks';
|
|
2
2
|
export * from './component';
|
|
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,5 @@
|
|
|
1
|
+
export interface DownloadProps {
|
|
2
|
+
fileName?: string;
|
|
3
|
+
}
|
|
4
|
+
declare const _default: import('vue').DefineComponent<DownloadProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<DownloadProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Download } from './download.vue';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-export';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ExportPlugin } from '../../lib/index.ts';
|
|
2
|
+
export declare const useExportPlugin: () => import('@embedpdf/core/vue').PluginState<ExportPlugin>;
|
|
3
|
+
export declare const useExportCapability: () => import('@embedpdf/core/vue').CapabilityState<Readonly<import('../../lib/index.ts').ExportCapability>>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),o=require("@embedpdf/plugin-export"),r=require("vue"),t=require("@embedpdf/models"),n=require("@embedpdf/core/vue"),l=()=>n.usePlugin(o.ExportPlugin.id),u=()=>n.useCapability(o.ExportPlugin.id),a=r.defineComponent({__name:"download",props:{fileName:{}},setup(e){const o=e,{provides:n}=u(),{plugin:a}=l(),i=r.ref(null);let p=null;return r.onMounted((()=>{const e=n.value,r=a.value;e&&r&&(p=r.onRequest((e=>{if("download"===e){const e=i.value;if(!e)return;r.saveAsCopyAndGetBufferAndName().wait((({buffer:r,name:t})=>{const n=URL.createObjectURL(new Blob([r]));e.href=n,e.download=o.fileName??t,e.click(),URL.revokeObjectURL(n)}),t.ignore)}})))})),r.onUnmounted((()=>{p&&p()})),(e,o)=>(r.openBlock(),r.createElementBlock("a",{ref_key:"anchorRef",ref:i,style:{display:"none"}},null,512))}}),i=e.createPluginPackage(o.ExportPluginPackage).addUtility(a).build();exports.Download=a,exports.ExportPluginPackage=i,exports.useExportCapability=u,exports.useExportPlugin=l,Object.keys(o).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>o[e]})}));
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/vue/hooks/use-export.ts","../../src/vue/components/download.vue","../../src/vue/index.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { ExportPlugin } from '@embedpdf/plugin-export';\n\nexport const useExportPlugin = () => usePlugin<ExportPlugin>(ExportPlugin.id);\nexport const useExportCapability = () => useCapability<ExportPlugin>(ExportPlugin.id);\n","<script setup lang=\"ts\">\nimport { ref, onMounted, onUnmounted } from 'vue';\nimport { ignore } from '@embedpdf/models';\nimport { Unsubscribe } from '@embedpdf/core';\n\nimport { useExportCapability, useExportPlugin } from '../hooks';\n\nexport interface DownloadProps {\n fileName?: string;\n}\n\nconst props = defineProps<DownloadProps>();\n\nconst { provides: exportCapabilityRef } = useExportCapability();\nconst { plugin: exportPluginRef } = useExportPlugin();\nconst anchorRef = ref<HTMLAnchorElement | null>(null);\n\nlet unsubscribe: Unsubscribe | null = null;\n\nonMounted(() => {\n const exportCapability = exportCapabilityRef.value;\n const exportPlugin = exportPluginRef.value;\n\n if (!exportCapability || !exportPlugin) return;\n\n unsubscribe = exportPlugin.onRequest((action) => {\n if (action === 'download') {\n const el = anchorRef.value;\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 = props.fileName ?? name;\n el.click();\n URL.revokeObjectURL(url);\n }, ignore);\n }\n });\n});\n\nonUnmounted(() => {\n if (unsubscribe) {\n unsubscribe();\n }\n});\n</script>\n\n<template>\n <a ref=\"anchorRef\" style=\"display: none\" />\n</template>\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","props","__props","provides","exportCapabilityRef","plugin","exportPluginRef","anchorRef","ref","unsubscribe","onMounted","exportCapability","value","exportPlugin","onRequest","action","el","saveAsCopyAndGetBufferAndName","wait","buffer","name","url","URL","createObjectURL","Blob","href","download","fileName","click","revokeObjectURL","ignore","onUnmounted","_createElementBlock","createElementBlock","style","display","ExportPluginPackage","createPluginPackage","BaseExportPackage","addUtility","Download","build"],"mappings":"sOAGaA,EAAkB,IAAMC,YAAwBC,EAAAA,aAAaC,IAC7DC,EAAsB,IAAMC,gBAA4BH,EAAAA,aAAaC,wECOlF,MAAMG,EAAQC,GAENC,SAAUC,GAAwBL,KAClCM,OAAQC,GAAoBX,IAC9BY,EAAYC,MAA8B,MAEhD,IAAIC,EAAkC,YAEtCC,EAAAA,WAAU,KACR,MAAMC,EAAmBP,EAAoBQ,MACvCC,EAAeP,EAAgBM,MAEhCD,GAAqBE,IAEZJ,EAAAI,EAAaC,WAAWC,IACpC,GAAe,aAAXA,EAAuB,CACzB,MAAMC,EAAKT,EAAUK,MACrB,IAAKI,EAAI,OAEIH,EAAaI,gCACrBC,MAAK,EAAGC,SAAQC,WACb,MAAAC,EAAMC,IAAIC,gBAAgB,IAAIC,KAAK,CAACL,KAC1CH,EAAGS,KAAOJ,EACPL,EAAAU,SAAWzB,EAAM0B,UAAYP,EAChCJ,EAAGY,QACHN,IAAIO,gBAAgBR,EAAG,GACtBS,SAAM,KAEZ,IAGHC,EAAAA,aAAY,KACNtB,GACUA,GAAA,0BAMduB,EAAAC,mBAA2C,IAAA,SAApC,YAAJzB,IAAID,EAAY2B,MAAA,CAAqBC,QAAA,uBCxC7BC,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,60 @@
|
|
|
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 { defineComponent, ref, onMounted, onUnmounted, createElementBlock, openBlock } from "vue";
|
|
5
|
+
import { ignore } from "@embedpdf/models";
|
|
6
|
+
import { useCapability, usePlugin } from "@embedpdf/core/vue";
|
|
7
|
+
const useExportPlugin = () => usePlugin(ExportPlugin.id);
|
|
8
|
+
const useExportCapability = () => useCapability(ExportPlugin.id);
|
|
9
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
10
|
+
__name: "download",
|
|
11
|
+
props: {
|
|
12
|
+
fileName: {}
|
|
13
|
+
},
|
|
14
|
+
setup(__props) {
|
|
15
|
+
const props = __props;
|
|
16
|
+
const { provides: exportCapabilityRef } = useExportCapability();
|
|
17
|
+
const { plugin: exportPluginRef } = useExportPlugin();
|
|
18
|
+
const anchorRef = ref(null);
|
|
19
|
+
let unsubscribe = null;
|
|
20
|
+
onMounted(() => {
|
|
21
|
+
const exportCapability = exportCapabilityRef.value;
|
|
22
|
+
const exportPlugin = exportPluginRef.value;
|
|
23
|
+
if (!exportCapability || !exportPlugin) return;
|
|
24
|
+
unsubscribe = exportPlugin.onRequest((action) => {
|
|
25
|
+
if (action === "download") {
|
|
26
|
+
const el = anchorRef.value;
|
|
27
|
+
if (!el) return;
|
|
28
|
+
const task = exportPlugin.saveAsCopyAndGetBufferAndName();
|
|
29
|
+
task.wait(({ buffer, name }) => {
|
|
30
|
+
const url = URL.createObjectURL(new Blob([buffer]));
|
|
31
|
+
el.href = url;
|
|
32
|
+
el.download = props.fileName ?? name;
|
|
33
|
+
el.click();
|
|
34
|
+
URL.revokeObjectURL(url);
|
|
35
|
+
}, ignore);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
onUnmounted(() => {
|
|
40
|
+
if (unsubscribe) {
|
|
41
|
+
unsubscribe();
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return (_ctx, _cache) => {
|
|
45
|
+
return openBlock(), createElementBlock("a", {
|
|
46
|
+
ref_key: "anchorRef",
|
|
47
|
+
ref: anchorRef,
|
|
48
|
+
style: { "display": "none" }
|
|
49
|
+
}, null, 512);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const ExportPluginPackage = createPluginPackage(ExportPluginPackage$1).addUtility(_sfc_main).build();
|
|
54
|
+
export {
|
|
55
|
+
_sfc_main as Download,
|
|
56
|
+
ExportPluginPackage,
|
|
57
|
+
useExportCapability,
|
|
58
|
+
useExportPlugin
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/vue/hooks/use-export.ts","../../src/vue/components/download.vue","../../src/vue/index.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { ExportPlugin } from '@embedpdf/plugin-export';\n\nexport const useExportPlugin = () => usePlugin<ExportPlugin>(ExportPlugin.id);\nexport const useExportCapability = () => useCapability<ExportPlugin>(ExportPlugin.id);\n","<script setup lang=\"ts\">\nimport { ref, onMounted, onUnmounted } from 'vue';\nimport { ignore } from '@embedpdf/models';\nimport { Unsubscribe } from '@embedpdf/core';\n\nimport { useExportCapability, useExportPlugin } from '../hooks';\n\nexport interface DownloadProps {\n fileName?: string;\n}\n\nconst props = defineProps<DownloadProps>();\n\nconst { provides: exportCapabilityRef } = useExportCapability();\nconst { plugin: exportPluginRef } = useExportPlugin();\nconst anchorRef = ref<HTMLAnchorElement | null>(null);\n\nlet unsubscribe: Unsubscribe | null = null;\n\nonMounted(() => {\n const exportCapability = exportCapabilityRef.value;\n const exportPlugin = exportPluginRef.value;\n\n if (!exportCapability || !exportPlugin) return;\n\n unsubscribe = exportPlugin.onRequest((action) => {\n if (action === 'download') {\n const el = anchorRef.value;\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 = props.fileName ?? name;\n el.click();\n URL.revokeObjectURL(url);\n }, ignore);\n }\n });\n});\n\nonUnmounted(() => {\n if (unsubscribe) {\n unsubscribe();\n }\n});\n</script>\n\n<template>\n <a ref=\"anchorRef\" style=\"display: none\" />\n</template>\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":["_createElementBlock","BaseExportPackage","Download"],"mappings":";;;;;;AAGO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;;;;;;;ACOpF,UAAM,QAAQ;AAEd,UAAM,EAAE,UAAU,oBAAoB,IAAI,oBAAoB;AAC9D,UAAM,EAAE,QAAQ,gBAAgB,IAAI,gBAAgB;AAC9C,UAAA,YAAY,IAA8B,IAAI;AAEpD,QAAI,cAAkC;AAEtC,cAAU,MAAM;AACd,YAAM,mBAAmB,oBAAoB;AAC7C,YAAM,eAAe,gBAAgB;AAEjC,UAAA,CAAC,oBAAoB,CAAC,aAAc;AAE1B,oBAAA,aAAa,UAAU,CAAC,WAAW;AAC/C,YAAI,WAAW,YAAY;AACzB,gBAAM,KAAK,UAAU;AACrB,cAAI,CAAC,GAAI;AAEH,gBAAA,OAAO,aAAa,8BAA8B;AACxD,eAAK,KAAK,CAAC,EAAE,QAAQ,WAAW;AACxB,kBAAA,MAAM,IAAI,gBAAgB,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;AAClD,eAAG,OAAO;AACP,eAAA,WAAW,MAAM,YAAY;AAChC,eAAG,MAAM;AACT,gBAAI,gBAAgB,GAAG;AAAA,aACtB,MAAM;AAAA,QAAA;AAAA,MACX,CACD;AAAA,IAAA,CACF;AAED,gBAAY,MAAM;AAChB,UAAI,aAAa;AACH,oBAAA;AAAA,MAAA;AAAA,IACd,CACD;;0BAICA,mBAA2C,KAAA;AAAA,iBAApC;AAAA,QAAJ,KAAI;AAAA,QAAY,OAAA,EAAqB,WAAA,OAAA;AAAA,MAAA;;;;ACxCnC,MAAM,sBAAsB,oBAAoBC,qBAAiB,EACrE,WAAWC,SAAQ,EACnB,MAAM;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-export",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -20,22 +20,28 @@
|
|
|
20
20
|
"types": "./dist/react/index.d.ts",
|
|
21
21
|
"import": "./dist/react/index.js",
|
|
22
22
|
"require": "./dist/react/index.cjs"
|
|
23
|
+
},
|
|
24
|
+
"./vue": {
|
|
25
|
+
"types": "./dist/vue/index.d.ts",
|
|
26
|
+
"import": "./dist/vue/index.js",
|
|
27
|
+
"require": "./dist/vue/index.cjs"
|
|
23
28
|
}
|
|
24
29
|
},
|
|
25
30
|
"dependencies": {
|
|
26
|
-
"@embedpdf/models": "1.0.
|
|
31
|
+
"@embedpdf/models": "1.0.22"
|
|
27
32
|
},
|
|
28
33
|
"devDependencies": {
|
|
29
34
|
"@types/react": "^18.2.0",
|
|
30
35
|
"typescript": "^5.0.0",
|
|
31
|
-
"@embedpdf/
|
|
32
|
-
"@embedpdf/
|
|
36
|
+
"@embedpdf/build": "1.0.0",
|
|
37
|
+
"@embedpdf/core": "1.0.22"
|
|
33
38
|
},
|
|
34
39
|
"peerDependencies": {
|
|
35
40
|
"react": ">=16.8.0",
|
|
36
41
|
"react-dom": ">=16.8.0",
|
|
37
42
|
"preact": "^10.26.4",
|
|
38
|
-
"
|
|
43
|
+
"vue": ">=3.2.0",
|
|
44
|
+
"@embedpdf/core": "1.0.22"
|
|
39
45
|
},
|
|
40
46
|
"files": [
|
|
41
47
|
"dist",
|
|
@@ -57,7 +63,8 @@
|
|
|
57
63
|
"build:base": "vite build --mode base",
|
|
58
64
|
"build:react": "vite build --mode react",
|
|
59
65
|
"build:preact": "vite build --mode preact",
|
|
60
|
-
"build": "
|
|
66
|
+
"build:vue": "vite build --mode vue",
|
|
67
|
+
"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\"",
|
|
61
68
|
"clean": "rimraf dist",
|
|
62
69
|
"lint": "eslint src --color",
|
|
63
70
|
"lint:fix": "eslint src --color --fix"
|