@embedpdf/plugin-export 1.0.17 → 1.0.19
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 +2 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/export-plugin.d.ts +1 -3
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +2 -2
- 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 +2 -2
- package/dist/react/index.js.map +1 -1
- package/dist/shared-preact/component/download.d.ts +4 -1
- package/dist/shared-react/component/download.d.ts +4 -1
- package/package.json +4 -4
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
|
|
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),onRequest:this.downloadRequest$.on}}download(){this.downloadRequest$.emit("download")}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 r="export",i={id:r,name:"Export Plugin",version:"1.0.0",provides:["export"],requires:[],optional:[],defaultConfig:{enabled:!0}},n={manifest:i,create:e=>new s(r,e),reducer:()=>{},initialState:{}};exports.EXPORT_PLUGIN_ID=r,exports.ExportPlugin=s,exports.ExportPluginPackage=n,exports.manifest=i;
|
|
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 { PdfEngine, PdfErrorCode, PdfErrorReason, PdfTaskHelper, Task } from '@embedpdf/models';\n\nimport { 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\n
|
|
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 { PdfEngine, PdfErrorCode, PdfErrorReason, PdfTaskHelper, Task } from '@embedpdf/models';\n\nimport { 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\n constructor(id: string, registry: PluginRegistry) {\n super(id, registry);\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 onRequest: this.downloadRequest$.on,\n };\n }\n\n private download(): void {\n this.downloadRequest$.emit('download');\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 },\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) => new ExportPlugin(EXPORT_PLUGIN_ID, registry),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './export-plugin';\nexport * from './types';\nexport * from './manifest';\n"],"names":["_ExportPlugin","BasePlugin","constructor","id","registry","super","this","downloadRequest$","createEmitter","initialize","_","buildCapability","saveAsCopy","bind","download","onRequest","on","emit","document","coreState","core","engine","PdfTaskHelper","reject","code","PdfErrorCode","DocNotOpen","message","ExportPlugin","EXPORT_PLUGIN_ID","manifest","name","version","provides","requires","optional","defaultConfig","enabled","ExportPluginPackage","create","reducer","initialState"],"mappings":"gJAKaA,EAAN,cAA2BC,EAAAA,WAKhC,WAAAC,CAAYC,EAAYC,GACtBC,MAAMF,EAAIC,GAHKE,KAAAC,iBAAmBC,iBAA0B,CAM9D,gBAAMC,CAAWC,GAAsC,CAE7C,eAAAC,GACD,MAAA,CACLC,WAAYN,KAAKM,WAAWC,KAAKP,MACjCQ,SAAUR,KAAKQ,SAASD,KAAKP,MAC7BS,UAAWT,KAAKC,iBAAiBS,GACnC,CAGM,QAAAF,GACDR,KAAAC,iBAAiBU,KAAK,WAAU,CAG/B,UAAAL,GACA,MAAAM,EAAWZ,KAAKa,UAAUC,KAAKF,SAErC,OAAKA,EAMEZ,KAAKe,OAAOT,WAAWM,GALrBI,EAAAA,cAAcC,OAAO,CAC1BC,KAAMC,EAAaA,aAAAC,WACnBC,QAAS,sBAGyB,GA/BxC3B,EAAgBG,GAAK,SADhB,IAAMyB,EAAN5B,ECFA,MAAM6B,EAAmB,SAEnBC,EAA+C,CAC1D3B,GAAI0B,EACJE,KAAM,gBACNC,QAAS,QACTC,SAAU,CAAC,UACXC,SAAU,GACVC,SAAU,GACVC,cAAe,CACbC,SAAS,ICPAC,EAAuE,CAClFR,WACAS,OAASnC,GAAa,IAAIwB,EAAaC,EAAkBzB,GACzDoC,QAAS,OACTC,aAAc,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { BasePlugin, createEmitter } from "@embedpdf/core";
|
|
2
2
|
import { PdfTaskHelper, PdfErrorCode } from "@embedpdf/models";
|
|
3
3
|
const _ExportPlugin = class _ExportPlugin extends BasePlugin {
|
|
4
|
-
constructor(id, registry
|
|
4
|
+
constructor(id, registry) {
|
|
5
5
|
super(id, registry);
|
|
6
6
|
this.downloadRequest$ = createEmitter();
|
|
7
|
-
this.engine = engine;
|
|
8
7
|
}
|
|
9
8
|
async initialize(_) {
|
|
10
9
|
}
|
|
@@ -44,7 +43,7 @@ const manifest = {
|
|
|
44
43
|
};
|
|
45
44
|
const ExportPluginPackage = {
|
|
46
45
|
manifest,
|
|
47
|
-
create: (registry
|
|
46
|
+
create: (registry) => new ExportPlugin(EXPORT_PLUGIN_ID, registry),
|
|
48
47
|
reducer: () => {
|
|
49
48
|
},
|
|
50
49
|
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 { PdfEngine, PdfErrorCode, PdfErrorReason, PdfTaskHelper, Task } from '@embedpdf/models';\n\nimport { 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\n
|
|
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 { PdfEngine, PdfErrorCode, PdfErrorReason, PdfTaskHelper, Task } from '@embedpdf/models';\n\nimport { 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\n constructor(id: string, registry: PluginRegistry) {\n super(id, registry);\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 onRequest: this.downloadRequest$.on,\n };\n }\n\n private download(): void {\n this.downloadRequest$.emit('download');\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 },\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) => new ExportPlugin(EXPORT_PLUGIN_ID, registry),\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,EAKjF,YAAY,IAAY,UAA0B;AAChD,UAAM,IAAI,QAAQ;AAHpB,SAAiB,mBAAmB,cAA0B;AAAA,EAAA;AAAA,EAM9D,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,MACjC,WAAW,KAAK,iBAAiB;AAAA,IACnC;AAAA,EAAA;AAAA,EAGM,WAAiB;AAClB,SAAA,iBAAiB,KAAK,UAAU;AAAA,EAAA;AAAA,EAG/B,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;AAjCE,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,EAAA;AAEb;ACTO,MAAM,sBAAuE;AAAA,EAClF;AAAA,EACA,QAAQ,CAAC,aAAa,IAAI,aAAa,kBAAkB,QAAQ;AAAA,EACjE,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,cAAc,CAAA;AAChB;"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { BasePlugin, PluginRegistry } from '@embedpdf/core';
|
|
2
|
-
import { PdfEngine } from '@embedpdf/models';
|
|
3
2
|
import { ExportCapability, ExportPluginConfig } from './types';
|
|
4
3
|
export declare class ExportPlugin extends BasePlugin<ExportPluginConfig, ExportCapability> {
|
|
5
4
|
static readonly id: "export";
|
|
6
5
|
private readonly downloadRequest$;
|
|
7
|
-
|
|
8
|
-
constructor(id: string, registry: PluginRegistry, engine: PdfEngine);
|
|
6
|
+
constructor(id: string, registry: PluginRegistry);
|
|
9
7
|
initialize(_: ExportPluginConfig): Promise<void>;
|
|
10
8
|
protected buildCapability(): ExportCapability;
|
|
11
9
|
private download;
|
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/preact"),r=require("@embedpdf/plugin-export"),t=require("preact/jsx-runtime"),o=require("@embedpdf/models"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/preact"),r=require("@embedpdf/plugin-export"),t=require("preact/jsx-runtime"),o=require("@embedpdf/models"),i=require("preact/hooks"),n=()=>e.useCapability(r.ExportPlugin.id);exports.Download=function(e){const{provides:r}=n(),u=i.useRef(null);return i.useEffect((()=>{if(!r)return;return r.onRequest((async t=>{if("download"===t){const t=u.current;if(!t)return;r.saveAsCopy().wait((r=>{const o=URL.createObjectURL(new Blob([r]));t.href=o,t.download=e.fileName??"document.pdf",t.click(),URL.revokeObjectURL(o)}),o.ignore)}}))}),[r]),t.jsx("a",{style:{display:"none"},ref:u})},exports.useExportCapability=n,exports.useExportPlugin=()=>e.usePlugin(r.ExportPlugin.id);
|
|
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 function Download() {\n const { provides: exportCapability } = useExportCapability();\n const ref = useRef<HTMLAnchorElement>(null);\n\n useEffect(() => {\n if (!exportCapability) return;\n\n const unsub = exportCapability.onRequest(async (action) => {\n if (action === 'download') {\n const el = ref.current;\n if (!el) return;\n\n const task = exportCapability.saveAsCopy();\n task.wait((buffer) => {\n const url = URL.createObjectURL(new Blob([buffer]));\n el.href = url;\n el.download = 'document.pdf';\n el.click();\n URL.revokeObjectURL(url);\n }, ignore);\n }\n });\n\n return unsub;\n }, [exportCapability]);\n\n return <a style={{ display: 'none' }} ref={ref} />;\n}\n"],"names":["useExportCapability","useCapability","ExportPlugin","id","provides","exportCapability","ref","useRef","useEffect","onRequest","async","action","el","current","saveAsCopy","wait","buffer","url","URL","createObjectURL","Blob","href","download","click","revokeObjectURL","ignore","style","display","usePlugin"],"mappings":"sPAIaA,EAAsB,IAAMC,gBAA4BC,EAAAA,aAAaC,
|
|
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\n}\n\nexport function Download(props: DownloadProps) {\n const { provides: exportCapability } = useExportCapability();\n const ref = useRef<HTMLAnchorElement>(null);\n\n useEffect(() => {\n if (!exportCapability) return;\n\n const unsub = exportCapability.onRequest(async (action) => {\n if (action === 'download') {\n const el = ref.current;\n if (!el) return;\n\n const task = exportCapability.saveAsCopy();\n task.wait((buffer) => {\n const url = URL.createObjectURL(new Blob([buffer]));\n el.href = url;\n el.download = props.fileName ?? 'document.pdf';\n el.click();\n URL.revokeObjectURL(url);\n }, ignore);\n }\n });\n\n return unsub;\n }, [exportCapability]);\n\n return <a style={{ display: 'none' }} ref={ref} />;\n}\n"],"names":["useExportCapability","useCapability","ExportPlugin","id","props","provides","exportCapability","ref","useRef","useEffect","onRequest","async","action","el","current","saveAsCopy","wait","buffer","url","URL","createObjectURL","Blob","href","download","fileName","click","revokeObjectURL","ignore","style","display","usePlugin"],"mappings":"sPAIaA,EAAsB,IAAMC,gBAA4BC,EAAAA,aAAaC,qBCK3E,SAAkBC,GACvB,MAAQC,SAAUC,GAAqBN,IACjCO,EAAMC,SAA0B,aAEtCC,EAAAA,WAAU,KACR,IAAKH,EAAkB,OAkBhB,OAhBOA,EAAiBI,WAAUC,MAAOC,IAC9C,GAAe,aAAXA,EAAuB,CACzB,MAAMC,EAAKN,EAAIO,QACf,IAAKD,EAAI,OAEIP,EAAiBS,aACzBC,MAAMC,IACH,MAAAC,EAAMC,IAAIC,gBAAgB,IAAIC,KAAK,CAACJ,KAC1CJ,EAAGS,KAAOJ,EACPL,EAAAU,SAAWnB,EAAMoB,UAAY,eAChCX,EAAGY,QACHN,IAAIO,gBAAgBR,EAAG,GACtBS,SAAM,IAIN,GACN,CAACrB,UAEI,IAAE,CAAAsB,MAAO,CAAEC,QAAS,QAAUtB,OACxC,wDDjC+B,IAAMuB,YAAwB5B,EAAAA,aAAaC"}
|
package/dist/preact/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { ignore } from "@embedpdf/models";
|
|
|
5
5
|
import { useRef, useEffect } from "preact/hooks";
|
|
6
6
|
const useExportPlugin = () => usePlugin(ExportPlugin.id);
|
|
7
7
|
const useExportCapability = () => useCapability(ExportPlugin.id);
|
|
8
|
-
function Download() {
|
|
8
|
+
function Download(props) {
|
|
9
9
|
const { provides: exportCapability } = useExportCapability();
|
|
10
10
|
const ref = useRef(null);
|
|
11
11
|
useEffect(() => {
|
|
@@ -18,7 +18,7 @@ function Download() {
|
|
|
18
18
|
task.wait((buffer) => {
|
|
19
19
|
const url = URL.createObjectURL(new Blob([buffer]));
|
|
20
20
|
el.href = url;
|
|
21
|
-
el.download = "document.pdf";
|
|
21
|
+
el.download = props.fileName ?? "document.pdf";
|
|
22
22
|
el.click();
|
|
23
23
|
URL.revokeObjectURL(url);
|
|
24
24
|
}, ignore);
|
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 function Download() {\n const { provides: exportCapability } = useExportCapability();\n const ref = useRef<HTMLAnchorElement>(null);\n\n useEffect(() => {\n if (!exportCapability) return;\n\n const unsub = exportCapability.onRequest(async (action) => {\n if (action === 'download') {\n const el = ref.current;\n if (!el) return;\n\n const task = exportCapability.saveAsCopy();\n task.wait((buffer) => {\n const url = URL.createObjectURL(new Blob([buffer]));\n el.href = url;\n el.download = 'document.pdf';\n el.click();\n URL.revokeObjectURL(url);\n }, ignore);\n }\n });\n\n return unsub;\n }, [exportCapability]);\n\n return <a style={{ display: 'none' }} ref={ref} />;\n}\n"],"names":[],"mappings":";;;;;AAGO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;
|
|
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\n}\n\nexport function Download(props: DownloadProps) {\n const { provides: exportCapability } = useExportCapability();\n const ref = useRef<HTMLAnchorElement>(null);\n\n useEffect(() => {\n if (!exportCapability) return;\n\n const unsub = exportCapability.onRequest(async (action) => {\n if (action === 'download') {\n const el = ref.current;\n if (!el) return;\n\n const task = exportCapability.saveAsCopy();\n task.wait((buffer) => {\n const url = URL.createObjectURL(new Blob([buffer]));\n el.href = url;\n el.download = props.fileName ?? 'document.pdf';\n el.click();\n URL.revokeObjectURL(url);\n }, ignore);\n }\n });\n\n return unsub;\n }, [exportCapability]);\n\n return <a style={{ display: 'none' }} ref={ref} />;\n}\n"],"names":[],"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;AACrD,QAAA,MAAM,OAA0B,IAAI;AAE1C,YAAU,MAAM;AACd,QAAI,CAAC,iBAAkB;AAEvB,UAAM,QAAQ,iBAAiB,UAAU,OAAO,WAAW;AACzD,UAAI,WAAW,YAAY;AACzB,cAAM,KAAK,IAAI;AACf,YAAI,CAAC,GAAI;AAEH,cAAA,OAAO,iBAAiB,WAAW;AACpC,aAAA,KAAK,CAAC,WAAW;AACd,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,gBAAgB,CAAC;AAErB,6BAAQ,KAAE,EAAA,OAAO,EAAE,SAAS,OAAA,GAAU,KAAU;AAClD;"}
|
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/react"),r=require("@embedpdf/plugin-export"),t=require("react/jsx-runtime"),o=require("@embedpdf/models"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/react"),r=require("@embedpdf/plugin-export"),t=require("react/jsx-runtime"),o=require("@embedpdf/models"),i=require("react"),n=()=>e.useCapability(r.ExportPlugin.id);exports.Download=function(e){const{provides:r}=n(),u=i.useRef(null);return i.useEffect((()=>{if(!r)return;return r.onRequest((async t=>{if("download"===t){const t=u.current;if(!t)return;r.saveAsCopy().wait((r=>{const o=URL.createObjectURL(new Blob([r]));t.href=o,t.download=e.fileName??"document.pdf",t.click(),URL.revokeObjectURL(o)}),o.ignore)}}))}),[r]),t.jsx("a",{style:{display:"none"},ref:u})},exports.useExportCapability=n,exports.useExportPlugin=()=>e.usePlugin(r.ExportPlugin.id);
|
|
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 function Download() {\n const { provides: exportCapability } = useExportCapability();\n const ref = useRef<HTMLAnchorElement>(null);\n\n useEffect(() => {\n if (!exportCapability) return;\n\n const unsub = exportCapability.onRequest(async (action) => {\n if (action === 'download') {\n const el = ref.current;\n if (!el) return;\n\n const task = exportCapability.saveAsCopy();\n task.wait((buffer) => {\n const url = URL.createObjectURL(new Blob([buffer]));\n el.href = url;\n el.download = 'document.pdf';\n el.click();\n URL.revokeObjectURL(url);\n }, ignore);\n }\n });\n\n return unsub;\n }, [exportCapability]);\n\n return <a style={{ display: 'none' }} ref={ref} />;\n}\n"],"names":["useExportCapability","useCapability","ExportPlugin","id","provides","exportCapability","ref","useRef","useEffect","onRequest","async","action","el","current","saveAsCopy","wait","buffer","url","URL","createObjectURL","Blob","href","download","click","revokeObjectURL","ignore","style","display","usePlugin"],"mappings":"6OAIaA,EAAsB,IAAMC,gBAA4BC,EAAAA,aAAaC,
|
|
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\n}\n\nexport function Download(props: DownloadProps) {\n const { provides: exportCapability } = useExportCapability();\n const ref = useRef<HTMLAnchorElement>(null);\n\n useEffect(() => {\n if (!exportCapability) return;\n\n const unsub = exportCapability.onRequest(async (action) => {\n if (action === 'download') {\n const el = ref.current;\n if (!el) return;\n\n const task = exportCapability.saveAsCopy();\n task.wait((buffer) => {\n const url = URL.createObjectURL(new Blob([buffer]));\n el.href = url;\n el.download = props.fileName ?? 'document.pdf';\n el.click();\n URL.revokeObjectURL(url);\n }, ignore);\n }\n });\n\n return unsub;\n }, [exportCapability]);\n\n return <a style={{ display: 'none' }} ref={ref} />;\n}\n"],"names":["useExportCapability","useCapability","ExportPlugin","id","props","provides","exportCapability","ref","useRef","useEffect","onRequest","async","action","el","current","saveAsCopy","wait","buffer","url","URL","createObjectURL","Blob","href","download","fileName","click","revokeObjectURL","ignore","style","display","usePlugin"],"mappings":"6OAIaA,EAAsB,IAAMC,gBAA4BC,EAAAA,aAAaC,qBCK3E,SAAkBC,GACvB,MAAQC,SAAUC,GAAqBN,IACjCO,EAAMC,SAA0B,aAEtCC,EAAAA,WAAU,KACR,IAAKH,EAAkB,OAkBhB,OAhBOA,EAAiBI,WAAUC,MAAOC,IAC9C,GAAe,aAAXA,EAAuB,CACzB,MAAMC,EAAKN,EAAIO,QACf,IAAKD,EAAI,OAEIP,EAAiBS,aACzBC,MAAMC,IACH,MAAAC,EAAMC,IAAIC,gBAAgB,IAAIC,KAAK,CAACJ,KAC1CJ,EAAGS,KAAOJ,EACPL,EAAAU,SAAWnB,EAAMoB,UAAY,eAChCX,EAAGY,QACHN,IAAIO,gBAAgBR,EAAG,GACtBS,SAAM,IAIN,GACN,CAACrB,UAEI,IAAE,CAAAsB,MAAO,CAAEC,QAAS,QAAUtB,OACxC,wDDjC+B,IAAMuB,YAAwB5B,EAAAA,aAAaC"}
|
package/dist/react/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { ignore } from "@embedpdf/models";
|
|
|
5
5
|
import { useRef, useEffect } from "react";
|
|
6
6
|
const useExportPlugin = () => usePlugin(ExportPlugin.id);
|
|
7
7
|
const useExportCapability = () => useCapability(ExportPlugin.id);
|
|
8
|
-
function Download() {
|
|
8
|
+
function Download(props) {
|
|
9
9
|
const { provides: exportCapability } = useExportCapability();
|
|
10
10
|
const ref = useRef(null);
|
|
11
11
|
useEffect(() => {
|
|
@@ -18,7 +18,7 @@ function Download() {
|
|
|
18
18
|
task.wait((buffer) => {
|
|
19
19
|
const url = URL.createObjectURL(new Blob([buffer]));
|
|
20
20
|
el.href = url;
|
|
21
|
-
el.download = "document.pdf";
|
|
21
|
+
el.download = props.fileName ?? "document.pdf";
|
|
22
22
|
el.click();
|
|
23
23
|
URL.revokeObjectURL(url);
|
|
24
24
|
}, ignore);
|
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 function Download() {\n const { provides: exportCapability } = useExportCapability();\n const ref = useRef<HTMLAnchorElement>(null);\n\n useEffect(() => {\n if (!exportCapability) return;\n\n const unsub = exportCapability.onRequest(async (action) => {\n if (action === 'download') {\n const el = ref.current;\n if (!el) return;\n\n const task = exportCapability.saveAsCopy();\n task.wait((buffer) => {\n const url = URL.createObjectURL(new Blob([buffer]));\n el.href = url;\n el.download = 'document.pdf';\n el.click();\n URL.revokeObjectURL(url);\n }, ignore);\n }\n });\n\n return unsub;\n }, [exportCapability]);\n\n return <a style={{ display: 'none' }} ref={ref} />;\n}\n"],"names":[],"mappings":";;;;;AAGO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;
|
|
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\n}\n\nexport function Download(props: DownloadProps) {\n const { provides: exportCapability } = useExportCapability();\n const ref = useRef<HTMLAnchorElement>(null);\n\n useEffect(() => {\n if (!exportCapability) return;\n\n const unsub = exportCapability.onRequest(async (action) => {\n if (action === 'download') {\n const el = ref.current;\n if (!el) return;\n\n const task = exportCapability.saveAsCopy();\n task.wait((buffer) => {\n const url = URL.createObjectURL(new Blob([buffer]));\n el.href = url;\n el.download = props.fileName ?? 'document.pdf';\n el.click();\n URL.revokeObjectURL(url);\n }, ignore);\n }\n });\n\n return unsub;\n }, [exportCapability]);\n\n return <a style={{ display: 'none' }} ref={ref} />;\n}\n"],"names":[],"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;AACrD,QAAA,MAAM,OAA0B,IAAI;AAE1C,YAAU,MAAM;AACd,QAAI,CAAC,iBAAkB;AAEvB,UAAM,QAAQ,iBAAiB,UAAU,OAAO,WAAW;AACzD,UAAI,WAAW,YAAY;AACzB,cAAM,KAAK,IAAI;AACf,YAAI,CAAC,GAAI;AAEH,cAAA,OAAO,iBAAiB,WAAW;AACpC,aAAA,KAAK,CAAC,WAAW;AACd,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,gBAAgB,CAAC;AAErB,6BAAQ,KAAE,EAAA,OAAO,EAAE,SAAS,OAAA,GAAU,KAAU;AAClD;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-export",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -23,19 +23,19 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@embedpdf/models": "1.0.
|
|
26
|
+
"@embedpdf/models": "1.0.19"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/react": "^18.2.0",
|
|
30
30
|
"typescript": "^5.0.0",
|
|
31
|
-
"@embedpdf/core": "1.0.
|
|
31
|
+
"@embedpdf/core": "1.0.19",
|
|
32
32
|
"@embedpdf/build": "1.0.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": ">=16.8.0",
|
|
36
36
|
"react-dom": ">=16.8.0",
|
|
37
37
|
"preact": "^10.26.4",
|
|
38
|
-
"@embedpdf/core": "1.0.
|
|
38
|
+
"@embedpdf/core": "1.0.19"
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
41
|
"dist",
|