@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 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,s){super(t,o),this.downloadRequest$=e.createEmitter(),this.engine=s}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 i="export",n={id:i,name:"Export Plugin",version:"1.0.0",provides:["export"],requires:[],optional:[],defaultConfig:{enabled:!0}},r={manifest:n,create:(e,t)=>new s(i,e,t),reducer:()=>{},initialState:{}};exports.EXPORT_PLUGIN_ID=i,exports.ExportPlugin=s,exports.ExportPluginPackage=r,exports.manifest=n;
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
@@ -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 private engine: PdfEngine;\n\n constructor(id: string, registry: PluginRegistry, engine: PdfEngine) {\n super(id, registry);\n\n this.engine = engine;\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, engine) => new ExportPlugin(EXPORT_PLUGIN_ID, registry, engine),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './export-plugin';\nexport * from './types';\nexport * from './manifest';\n"],"names":["_ExportPlugin","BasePlugin","constructor","id","registry","engine","super","this","downloadRequest$","createEmitter","initialize","_","buildCapability","saveAsCopy","bind","download","onRequest","on","emit","document","coreState","core","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,WAOhC,WAAAC,CAAYC,EAAYC,EAA0BC,GAChDC,MAAMH,EAAIC,GALKG,KAAAC,iBAAmBC,kBAOlCF,KAAKF,OAASA,CAAA,CAGhB,gBAAMK,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,KAAKF,OAAOQ,WAAWM,GALrBG,EAAAA,cAAcC,OAAO,CAC1BC,KAAMC,EAAaA,aAAAC,WACnBC,QAAS,sBAGyB,GAnCxC3B,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,OAAQ,CAACnC,EAAUC,IAAW,IAAIuB,EAAaC,EAAkBzB,EAAUC,GAC3EmC,QAAS,OACTC,aAAc,CAAA"}
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, engine) {
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, engine) => new ExportPlugin(EXPORT_PLUGIN_ID, registry, engine),
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 private engine: PdfEngine;\n\n constructor(id: string, registry: PluginRegistry, engine: PdfEngine) {\n super(id, registry);\n\n this.engine = engine;\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, engine) => new ExportPlugin(EXPORT_PLUGIN_ID, registry, engine),\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,EAOjF,YAAY,IAAY,UAA0B,QAAmB;AACnE,UAAM,IAAI,QAAQ;AALpB,SAAiB,mBAAmB,cAA0B;AAO5D,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,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;AArCE,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,UAAU,WAAW,IAAI,aAAa,kBAAkB,UAAU,MAAM;AAAA,EACjF,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,cAAc,CAAA;AAChB;"}
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
- private engine;
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;
@@ -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"),n=require("preact/hooks"),i=()=>e.useCapability(r.ExportPlugin.id);exports.Download=function(){const{provides:e}=i(),r=n.useRef(null);return n.useEffect((()=>{if(!e)return;return e.onRequest((async t=>{if("download"===t){const t=r.current;if(!t)return;e.saveAsCopy().wait((e=>{const r=URL.createObjectURL(new Blob([e]));t.href=r,t.download="document.pdf",t.click(),URL.revokeObjectURL(r)}),o.ignore)}}))}),[e]),t.jsx("a",{style:{display:"none"},ref:r})},exports.useExportCapability=i,exports.useExportPlugin=()=>e.usePlugin(r.ExportPlugin.id);
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,qBCC3E,WACL,MAAQC,SAAUC,GAAqBL,IACjCM,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,EACVL,EAAGU,SAAW,eACdV,EAAGW,QACHL,IAAIM,gBAAgBP,EAAG,GACtBQ,SAAM,IAIN,GACN,CAACpB,UAEI,IAAE,CAAAqB,MAAO,CAAEC,QAAS,QAAUrB,OACxC,wDD7B+B,IAAMsB,YAAwB1B,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"}
@@ -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);
@@ -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;ACC7E,SAAS,WAAW;AACzB,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;AACV,aAAG,WAAW;AACd,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;"}
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;"}
@@ -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"),n=require("react"),i=()=>e.useCapability(r.ExportPlugin.id);exports.Download=function(){const{provides:e}=i(),r=n.useRef(null);return n.useEffect((()=>{if(!e)return;return e.onRequest((async t=>{if("download"===t){const t=r.current;if(!t)return;e.saveAsCopy().wait((e=>{const r=URL.createObjectURL(new Blob([e]));t.href=r,t.download="document.pdf",t.click(),URL.revokeObjectURL(r)}),o.ignore)}}))}),[e]),t.jsx("a",{style:{display:"none"},ref:r})},exports.useExportCapability=i,exports.useExportPlugin=()=>e.usePlugin(r.ExportPlugin.id);
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
@@ -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,qBCC3E,WACL,MAAQC,SAAUC,GAAqBL,IACjCM,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,EACVL,EAAGU,SAAW,eACdV,EAAGW,QACHL,IAAIM,gBAAgBP,EAAG,GACtBQ,SAAM,IAIN,GACN,CAACpB,UAEI,IAAE,CAAAqB,MAAO,CAAEC,QAAS,QAAUrB,OACxC,wDD7B+B,IAAMsB,YAAwB1B,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"}
@@ -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);
@@ -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;ACC7E,SAAS,WAAW;AACzB,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;AACV,aAAG,WAAW;AACd,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;"}
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;"}
@@ -1 +1,4 @@
1
- export declare function Download(): import("preact").JSX.Element;
1
+ export interface DownloadProps {
2
+ fileName?: string;
3
+ }
4
+ export declare function Download(props: DownloadProps): import("preact").JSX.Element;
@@ -1 +1,4 @@
1
- export declare function Download(): import("react/jsx-runtime").JSX.Element;
1
+ export interface DownloadProps {
2
+ fileName?: string;
3
+ }
4
+ export declare function Download(props: DownloadProps): import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-export",
3
- "version": "1.0.17",
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.17"
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.17",
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.17"
38
+ "@embedpdf/core": "1.0.19"
39
39
  },
40
40
  "files": [
41
41
  "dist",