@embedpdf/plugin-export 1.0.11 → 1.0.13
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 +2 -92
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -28
- package/dist/index.js +8 -12
- package/dist/index.js.map +1 -1
- package/dist/lib/export-plugin.d.ts +13 -0
- package/dist/lib/index.d.ts +7 -0
- package/dist/lib/manifest.d.ts +4 -0
- package/dist/lib/types.d.ts +9 -0
- package/dist/preact/adapter.d.ts +1 -0
- package/dist/preact/core.d.ts +1 -0
- package/dist/preact/index.cjs +2 -68
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.d.ts +1 -18
- package/dist/preact/index.js +6 -9
- package/dist/preact/index.js.map +1 -1
- package/dist/react/adapter.d.ts +1 -0
- package/dist/react/core.d.ts +1 -0
- package/dist/react/index.cjs +2 -68
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.ts +1 -18
- package/dist/react/index.js +6 -9
- package/dist/react/index.js.map +1 -1
- package/dist/shared-preact/component/download.d.ts +1 -0
- package/dist/shared-preact/component/index.d.ts +1 -0
- package/dist/shared-preact/hooks/index.d.ts +1 -0
- package/dist/shared-preact/hooks/use-export.d.ts +11 -0
- package/dist/shared-preact/index.d.ts +2 -0
- package/dist/shared-react/component/download.d.ts +1 -0
- package/dist/shared-react/component/index.d.ts +1 -0
- package/dist/shared-react/hooks/index.d.ts +1 -0
- package/dist/shared-react/hooks/use-export.d.ts +11 -0
- package/dist/shared-react/index.d.ts +2 -0
- package/package.json +12 -11
- package/dist/index.d.cts +0 -28
- package/dist/preact/index.d.cts +0 -18
- package/dist/react/index.d.cts +0 -18
package/dist/index.cjs
CHANGED
|
@@ -1,92 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
EXPORT_PLUGIN_ID: () => EXPORT_PLUGIN_ID,
|
|
24
|
-
ExportPlugin: () => ExportPlugin,
|
|
25
|
-
ExportPluginPackage: () => ExportPluginPackage,
|
|
26
|
-
manifest: () => manifest
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(index_exports);
|
|
29
|
-
|
|
30
|
-
// src/lib/export-plugin.ts
|
|
31
|
-
var import_core = require("@embedpdf/core");
|
|
32
|
-
var import_models = require("@embedpdf/models");
|
|
33
|
-
var ExportPlugin = class extends import_core.BasePlugin {
|
|
34
|
-
constructor(id, registry, engine) {
|
|
35
|
-
super(id, registry);
|
|
36
|
-
this.downloadRequest$ = (0, import_core.createEmitter)();
|
|
37
|
-
this.engine = engine;
|
|
38
|
-
}
|
|
39
|
-
async initialize(_) {
|
|
40
|
-
}
|
|
41
|
-
buildCapability() {
|
|
42
|
-
return {
|
|
43
|
-
saveAsCopy: this.saveAsCopy.bind(this),
|
|
44
|
-
download: this.download.bind(this),
|
|
45
|
-
onRequest: this.downloadRequest$.on
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
download() {
|
|
49
|
-
this.downloadRequest$.emit("download");
|
|
50
|
-
}
|
|
51
|
-
saveAsCopy() {
|
|
52
|
-
const document = this.coreState.core.document;
|
|
53
|
-
if (!document)
|
|
54
|
-
return import_models.PdfTaskHelper.reject({
|
|
55
|
-
code: import_models.PdfErrorCode.DocNotOpen,
|
|
56
|
-
message: "Document not found"
|
|
57
|
-
});
|
|
58
|
-
return this.engine.saveAsCopy(document);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
ExportPlugin.id = "export";
|
|
62
|
-
|
|
63
|
-
// src/lib/manifest.ts
|
|
64
|
-
var EXPORT_PLUGIN_ID = "export";
|
|
65
|
-
var manifest = {
|
|
66
|
-
id: EXPORT_PLUGIN_ID,
|
|
67
|
-
name: "Export Plugin",
|
|
68
|
-
version: "1.0.0",
|
|
69
|
-
provides: ["export"],
|
|
70
|
-
requires: [],
|
|
71
|
-
optional: [],
|
|
72
|
-
defaultConfig: {
|
|
73
|
-
enabled: true
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// src/lib/index.ts
|
|
78
|
-
var ExportPluginPackage = {
|
|
79
|
-
manifest,
|
|
80
|
-
create: (registry, engine) => new ExportPlugin(EXPORT_PLUGIN_ID, registry, engine),
|
|
81
|
-
reducer: () => {
|
|
82
|
-
},
|
|
83
|
-
initialState: {}
|
|
84
|
-
};
|
|
85
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
-
0 && (module.exports = {
|
|
87
|
-
EXPORT_PLUGIN_ID,
|
|
88
|
-
ExportPlugin,
|
|
89
|
-
ExportPluginPackage,
|
|
90
|
-
manifest
|
|
91
|
-
});
|
|
92
|
-
//# sourceMappingURL=index.cjs.map
|
|
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;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { Task, PdfErrorReason, PdfEngine } from '@embedpdf/models';
|
|
3
|
-
|
|
4
|
-
interface ExportPluginConfig extends BasePluginConfig {
|
|
5
|
-
}
|
|
6
|
-
interface ExportCapability {
|
|
7
|
-
saveAsCopy: () => Task<ArrayBuffer, PdfErrorReason>;
|
|
8
|
-
download: () => void;
|
|
9
|
-
onRequest: EventHook<'download'>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declare class ExportPlugin extends BasePlugin<ExportPluginConfig, ExportCapability> {
|
|
13
|
-
static readonly id: "export";
|
|
14
|
-
private readonly downloadRequest$;
|
|
15
|
-
private engine;
|
|
16
|
-
constructor(id: string, registry: PluginRegistry, engine: PdfEngine);
|
|
17
|
-
initialize(_: ExportPluginConfig): Promise<void>;
|
|
18
|
-
protected buildCapability(): ExportCapability;
|
|
19
|
-
private download;
|
|
20
|
-
private saveAsCopy;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
declare const EXPORT_PLUGIN_ID = "export";
|
|
24
|
-
declare const manifest: PluginManifest<ExportPluginConfig>;
|
|
25
|
-
|
|
26
|
-
declare const ExportPluginPackage: PluginPackage<ExportPlugin, ExportPluginConfig>;
|
|
27
|
-
|
|
28
|
-
export { EXPORT_PLUGIN_ID, type ExportCapability, ExportPlugin, type ExportPluginConfig, ExportPluginPackage, manifest };
|
|
1
|
+
export * from './lib';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
// src/lib/export-plugin.ts
|
|
2
1
|
import { BasePlugin, createEmitter } from "@embedpdf/core";
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { PdfTaskHelper, PdfErrorCode } from "@embedpdf/models";
|
|
3
|
+
const _ExportPlugin = class _ExportPlugin extends BasePlugin {
|
|
5
4
|
constructor(id, registry, engine) {
|
|
6
5
|
super(id, registry);
|
|
7
6
|
this.downloadRequest$ = createEmitter();
|
|
@@ -29,11 +28,10 @@ var ExportPlugin = class extends BasePlugin {
|
|
|
29
28
|
return this.engine.saveAsCopy(document);
|
|
30
29
|
}
|
|
31
30
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var manifest = {
|
|
31
|
+
_ExportPlugin.id = "export";
|
|
32
|
+
let ExportPlugin = _ExportPlugin;
|
|
33
|
+
const EXPORT_PLUGIN_ID = "export";
|
|
34
|
+
const manifest = {
|
|
37
35
|
id: EXPORT_PLUGIN_ID,
|
|
38
36
|
name: "Export Plugin",
|
|
39
37
|
version: "1.0.0",
|
|
@@ -44,9 +42,7 @@ var manifest = {
|
|
|
44
42
|
enabled: true
|
|
45
43
|
}
|
|
46
44
|
};
|
|
47
|
-
|
|
48
|
-
// src/lib/index.ts
|
|
49
|
-
var ExportPluginPackage = {
|
|
45
|
+
const ExportPluginPackage = {
|
|
50
46
|
manifest,
|
|
51
47
|
create: (registry, engine) => new ExportPlugin(EXPORT_PLUGIN_ID, registry, engine),
|
|
52
48
|
reducer: () => {
|
|
@@ -59,4 +55,4 @@ export {
|
|
|
59
55
|
ExportPluginPackage,
|
|
60
56
|
manifest
|
|
61
57
|
};
|
|
62
|
-
//# sourceMappingURL=index.js.map
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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"],"mappings":"
|
|
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;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BasePlugin, PluginRegistry } from '@embedpdf/core';
|
|
2
|
+
import { PdfEngine } from '@embedpdf/models';
|
|
3
|
+
import { ExportCapability, ExportPluginConfig } from './types';
|
|
4
|
+
export declare class ExportPlugin extends BasePlugin<ExportPluginConfig, ExportCapability> {
|
|
5
|
+
static readonly id: "export";
|
|
6
|
+
private readonly downloadRequest$;
|
|
7
|
+
private engine;
|
|
8
|
+
constructor(id: string, registry: PluginRegistry, engine: PdfEngine);
|
|
9
|
+
initialize(_: ExportPluginConfig): Promise<void>;
|
|
10
|
+
protected buildCapability(): ExportCapability;
|
|
11
|
+
private download;
|
|
12
|
+
private saveAsCopy;
|
|
13
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PluginPackage } from '@embedpdf/core';
|
|
2
|
+
import { ExportPlugin } from './export-plugin';
|
|
3
|
+
import { ExportPluginConfig } from './types';
|
|
4
|
+
export declare const ExportPluginPackage: PluginPackage<ExportPlugin, ExportPluginConfig>;
|
|
5
|
+
export * from './export-plugin';
|
|
6
|
+
export * from './types';
|
|
7
|
+
export * from './manifest';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BasePluginConfig, EventHook } from '@embedpdf/core';
|
|
2
|
+
import { PdfErrorReason, Task } from '@embedpdf/models';
|
|
3
|
+
export interface ExportPluginConfig extends BasePluginConfig {
|
|
4
|
+
}
|
|
5
|
+
export interface ExportCapability {
|
|
6
|
+
saveAsCopy: () => Task<ArrayBuffer, PdfErrorReason>;
|
|
7
|
+
download: () => void;
|
|
8
|
+
onRequest: EventHook<'download'>;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useEffect, useRef } from 'preact/hooks';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@embedpdf/core/preact';
|
package/dist/preact/index.cjs
CHANGED
|
@@ -1,68 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/preact/index.ts
|
|
21
|
-
var preact_exports = {};
|
|
22
|
-
__export(preact_exports, {
|
|
23
|
-
Download: () => Download,
|
|
24
|
-
useExportCapability: () => useExportCapability,
|
|
25
|
-
useExportPlugin: () => useExportPlugin
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(preact_exports);
|
|
28
|
-
|
|
29
|
-
// src/preact/hooks/use-export.ts
|
|
30
|
-
var import_preact = require("@embedpdf/core/preact");
|
|
31
|
-
var import_plugin_export = require("@embedpdf/plugin-export");
|
|
32
|
-
var useExportPlugin = () => (0, import_preact.usePlugin)(import_plugin_export.ExportPlugin.id);
|
|
33
|
-
var useExportCapability = () => (0, import_preact.useCapability)(import_plugin_export.ExportPlugin.id);
|
|
34
|
-
|
|
35
|
-
// src/preact/components/download.tsx
|
|
36
|
-
var import_models = require("@embedpdf/models");
|
|
37
|
-
var import_hooks = require("preact/hooks");
|
|
38
|
-
var import_jsx_runtime = require("preact/jsx-runtime");
|
|
39
|
-
function Download() {
|
|
40
|
-
const { provides: exportCapability } = useExportCapability();
|
|
41
|
-
const ref = (0, import_hooks.useRef)(null);
|
|
42
|
-
(0, import_hooks.useEffect)(() => {
|
|
43
|
-
if (!exportCapability) return;
|
|
44
|
-
const unsub = exportCapability.onRequest(async (action) => {
|
|
45
|
-
if (action === "download") {
|
|
46
|
-
const el = ref.current;
|
|
47
|
-
if (!el) return;
|
|
48
|
-
const task = exportCapability.saveAsCopy();
|
|
49
|
-
task.wait((buffer) => {
|
|
50
|
-
const url = URL.createObjectURL(new Blob([buffer]));
|
|
51
|
-
el.href = url;
|
|
52
|
-
el.download = "document.pdf";
|
|
53
|
-
el.click();
|
|
54
|
-
URL.revokeObjectURL(url);
|
|
55
|
-
}, import_models.ignore);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
return unsub;
|
|
59
|
-
}, [exportCapability]);
|
|
60
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { style: { display: "none" }, ref });
|
|
61
|
-
}
|
|
62
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
-
0 && (module.exports = {
|
|
64
|
-
Download,
|
|
65
|
-
useExportCapability,
|
|
66
|
-
useExportPlugin
|
|
67
|
-
});
|
|
68
|
-
//# sourceMappingURL=index.cjs.map
|
|
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);
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
package/dist/preact/index.d.ts
CHANGED
|
@@ -1,18 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { ExportPlugin } from '@embedpdf/plugin-export';
|
|
3
|
-
import * as preact from 'preact';
|
|
4
|
-
|
|
5
|
-
declare const useExportPlugin: () => {
|
|
6
|
-
plugin: ExportPlugin | null;
|
|
7
|
-
isLoading: boolean;
|
|
8
|
-
ready: Promise<void>;
|
|
9
|
-
};
|
|
10
|
-
declare const useExportCapability: () => {
|
|
11
|
-
provides: Readonly<_embedpdf_plugin_export.ExportCapability> | null;
|
|
12
|
-
isLoading: boolean;
|
|
13
|
-
ready: Promise<void>;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
declare function Download(): preact.JSX.Element;
|
|
17
|
-
|
|
18
|
-
export { Download, useExportCapability, useExportPlugin };
|
|
1
|
+
export * from '../shared-preact';
|
package/dist/preact/index.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import { useCapability, usePlugin } from "@embedpdf/core/preact";
|
|
1
|
+
import { usePlugin, useCapability } from "@embedpdf/core/preact";
|
|
3
2
|
import { ExportPlugin } from "@embedpdf/plugin-export";
|
|
4
|
-
var useExportPlugin = () => usePlugin(ExportPlugin.id);
|
|
5
|
-
var useExportCapability = () => useCapability(ExportPlugin.id);
|
|
6
|
-
|
|
7
|
-
// src/preact/components/download.tsx
|
|
8
|
-
import { ignore } from "@embedpdf/models";
|
|
9
|
-
import { useEffect, useRef } from "preact/hooks";
|
|
10
3
|
import { jsx } from "preact/jsx-runtime";
|
|
4
|
+
import { ignore } from "@embedpdf/models";
|
|
5
|
+
import { useRef, useEffect } from "preact/hooks";
|
|
6
|
+
const useExportPlugin = () => usePlugin(ExportPlugin.id);
|
|
7
|
+
const useExportCapability = () => useCapability(ExportPlugin.id);
|
|
11
8
|
function Download() {
|
|
12
9
|
const { provides: exportCapability } = useExportCapability();
|
|
13
10
|
const ref = useRef(null);
|
|
@@ -36,4 +33,4 @@ export {
|
|
|
36
33
|
useExportCapability,
|
|
37
34
|
useExportPlugin
|
|
38
35
|
};
|
|
39
|
-
//# sourceMappingURL=index.js.map
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
package/dist/preact/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
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;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useEffect, useRef } from 'react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@embedpdf/core/react';
|
package/dist/react/index.cjs
CHANGED
|
@@ -1,68 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/react/index.ts
|
|
21
|
-
var react_exports = {};
|
|
22
|
-
__export(react_exports, {
|
|
23
|
-
Download: () => Download,
|
|
24
|
-
useExportCapability: () => useExportCapability,
|
|
25
|
-
useExportPlugin: () => useExportPlugin
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(react_exports);
|
|
28
|
-
|
|
29
|
-
// src/react/hooks/use-export.ts
|
|
30
|
-
var import_react = require("@embedpdf/core/react");
|
|
31
|
-
var import_plugin_export = require("@embedpdf/plugin-export");
|
|
32
|
-
var useExportPlugin = () => (0, import_react.usePlugin)(import_plugin_export.ExportPlugin.id);
|
|
33
|
-
var useExportCapability = () => (0, import_react.useCapability)(import_plugin_export.ExportPlugin.id);
|
|
34
|
-
|
|
35
|
-
// src/react/component/download.tsx
|
|
36
|
-
var import_models = require("@embedpdf/models");
|
|
37
|
-
var import_react2 = require("react");
|
|
38
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
39
|
-
function Download() {
|
|
40
|
-
const { provides: exportCapability } = useExportCapability();
|
|
41
|
-
const ref = (0, import_react2.useRef)(null);
|
|
42
|
-
(0, import_react2.useEffect)(() => {
|
|
43
|
-
if (!exportCapability) return;
|
|
44
|
-
const unsub = exportCapability.onRequest(async (action) => {
|
|
45
|
-
if (action === "download") {
|
|
46
|
-
const el = ref.current;
|
|
47
|
-
if (!el) return;
|
|
48
|
-
const task = exportCapability.saveAsCopy();
|
|
49
|
-
task.wait((buffer) => {
|
|
50
|
-
const url = URL.createObjectURL(new Blob([buffer]));
|
|
51
|
-
el.href = url;
|
|
52
|
-
el.download = "document.pdf";
|
|
53
|
-
el.click();
|
|
54
|
-
URL.revokeObjectURL(url);
|
|
55
|
-
}, import_models.ignore);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
return unsub;
|
|
59
|
-
}, [exportCapability]);
|
|
60
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { style: { display: "none" }, ref });
|
|
61
|
-
}
|
|
62
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
-
0 && (module.exports = {
|
|
64
|
-
Download,
|
|
65
|
-
useExportCapability,
|
|
66
|
-
useExportPlugin
|
|
67
|
-
});
|
|
68
|
-
//# sourceMappingURL=index.cjs.map
|
|
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);
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
package/dist/react/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,18 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { ExportPlugin } from '@embedpdf/plugin-export';
|
|
3
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
-
|
|
5
|
-
declare const useExportPlugin: () => {
|
|
6
|
-
plugin: ExportPlugin | null;
|
|
7
|
-
isLoading: boolean;
|
|
8
|
-
ready: Promise<void>;
|
|
9
|
-
};
|
|
10
|
-
declare const useExportCapability: () => {
|
|
11
|
-
provides: Readonly<_embedpdf_plugin_export.ExportCapability> | null;
|
|
12
|
-
isLoading: boolean;
|
|
13
|
-
ready: Promise<void>;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
declare function Download(): react_jsx_runtime.JSX.Element;
|
|
17
|
-
|
|
18
|
-
export { Download, useExportCapability, useExportPlugin };
|
|
1
|
+
export * from '../shared-react';
|
package/dist/react/index.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import { useCapability, usePlugin } from "@embedpdf/core/react";
|
|
1
|
+
import { usePlugin, useCapability } from "@embedpdf/core/react";
|
|
3
2
|
import { ExportPlugin } from "@embedpdf/plugin-export";
|
|
4
|
-
var useExportPlugin = () => usePlugin(ExportPlugin.id);
|
|
5
|
-
var useExportCapability = () => useCapability(ExportPlugin.id);
|
|
6
|
-
|
|
7
|
-
// src/react/component/download.tsx
|
|
8
|
-
import { ignore } from "@embedpdf/models";
|
|
9
|
-
import { useEffect, useRef } from "react";
|
|
10
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { ignore } from "@embedpdf/models";
|
|
5
|
+
import { useRef, useEffect } from "react";
|
|
6
|
+
const useExportPlugin = () => usePlugin(ExportPlugin.id);
|
|
7
|
+
const useExportCapability = () => useCapability(ExportPlugin.id);
|
|
11
8
|
function Download() {
|
|
12
9
|
const { provides: exportCapability } = useExportCapability();
|
|
13
10
|
const ref = useRef(null);
|
|
@@ -36,4 +33,4 @@ export {
|
|
|
36
33
|
useExportCapability,
|
|
37
34
|
useExportPlugin
|
|
38
35
|
};
|
|
39
|
-
//# sourceMappingURL=index.js.map
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
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;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Download(): import("preact").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './download';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-export';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ExportPlugin } from '../../lib/index.ts';
|
|
2
|
+
export declare const useExportPlugin: () => {
|
|
3
|
+
plugin: ExportPlugin | null;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare const useExportCapability: () => {
|
|
8
|
+
provides: Readonly<import('../../lib/index.ts').ExportCapability> | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
ready: Promise<void>;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Download(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './download';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-export';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ExportPlugin } from '../../lib/index.ts';
|
|
2
|
+
export declare const useExportPlugin: () => {
|
|
3
|
+
plugin: ExportPlugin | null;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare const useExportCapability: () => {
|
|
8
|
+
provides: Readonly<import('../../lib/index.ts').ExportCapability> | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
ready: Promise<void>;
|
|
11
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-export",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
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.13"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/react": "^18.2.0",
|
|
30
|
-
"tsup": "^8.0.0",
|
|
31
30
|
"typescript": "^5.0.0",
|
|
32
|
-
"@embedpdf/core": "1.0.
|
|
31
|
+
"@embedpdf/core": "1.0.13",
|
|
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.13"
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
41
|
"dist",
|
|
@@ -54,11 +54,12 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
|
-
"build": "
|
|
58
|
-
"build:
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
57
|
+
"build:base": "vite build --mode base",
|
|
58
|
+
"build:react": "vite build --mode react",
|
|
59
|
+
"build:preact": "vite build --mode preact",
|
|
60
|
+
"build": "pnpm run clean && concurrently -c auto -n base,react,preact \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\"",
|
|
61
|
+
"clean": "rimraf dist",
|
|
62
|
+
"lint": "eslint src --color",
|
|
63
|
+
"lint:fix": "eslint src --color --fix"
|
|
63
64
|
}
|
|
64
65
|
}
|
package/dist/index.d.cts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { BasePluginConfig, EventHook, BasePlugin, PluginRegistry, PluginManifest, PluginPackage } from '@embedpdf/core';
|
|
2
|
-
import { Task, PdfErrorReason, PdfEngine } from '@embedpdf/models';
|
|
3
|
-
|
|
4
|
-
interface ExportPluginConfig extends BasePluginConfig {
|
|
5
|
-
}
|
|
6
|
-
interface ExportCapability {
|
|
7
|
-
saveAsCopy: () => Task<ArrayBuffer, PdfErrorReason>;
|
|
8
|
-
download: () => void;
|
|
9
|
-
onRequest: EventHook<'download'>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declare class ExportPlugin extends BasePlugin<ExportPluginConfig, ExportCapability> {
|
|
13
|
-
static readonly id: "export";
|
|
14
|
-
private readonly downloadRequest$;
|
|
15
|
-
private engine;
|
|
16
|
-
constructor(id: string, registry: PluginRegistry, engine: PdfEngine);
|
|
17
|
-
initialize(_: ExportPluginConfig): Promise<void>;
|
|
18
|
-
protected buildCapability(): ExportCapability;
|
|
19
|
-
private download;
|
|
20
|
-
private saveAsCopy;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
declare const EXPORT_PLUGIN_ID = "export";
|
|
24
|
-
declare const manifest: PluginManifest<ExportPluginConfig>;
|
|
25
|
-
|
|
26
|
-
declare const ExportPluginPackage: PluginPackage<ExportPlugin, ExportPluginConfig>;
|
|
27
|
-
|
|
28
|
-
export { EXPORT_PLUGIN_ID, type ExportCapability, ExportPlugin, type ExportPluginConfig, ExportPluginPackage, manifest };
|
package/dist/preact/index.d.cts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as _embedpdf_plugin_export from '@embedpdf/plugin-export';
|
|
2
|
-
import { ExportPlugin } from '@embedpdf/plugin-export';
|
|
3
|
-
import * as preact from 'preact';
|
|
4
|
-
|
|
5
|
-
declare const useExportPlugin: () => {
|
|
6
|
-
plugin: ExportPlugin | null;
|
|
7
|
-
isLoading: boolean;
|
|
8
|
-
ready: Promise<void>;
|
|
9
|
-
};
|
|
10
|
-
declare const useExportCapability: () => {
|
|
11
|
-
provides: Readonly<_embedpdf_plugin_export.ExportCapability> | null;
|
|
12
|
-
isLoading: boolean;
|
|
13
|
-
ready: Promise<void>;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
declare function Download(): preact.JSX.Element;
|
|
17
|
-
|
|
18
|
-
export { Download, useExportCapability, useExportPlugin };
|
package/dist/react/index.d.cts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as _embedpdf_plugin_export from '@embedpdf/plugin-export';
|
|
2
|
-
import { ExportPlugin } from '@embedpdf/plugin-export';
|
|
3
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
-
|
|
5
|
-
declare const useExportPlugin: () => {
|
|
6
|
-
plugin: ExportPlugin | null;
|
|
7
|
-
isLoading: boolean;
|
|
8
|
-
ready: Promise<void>;
|
|
9
|
-
};
|
|
10
|
-
declare const useExportCapability: () => {
|
|
11
|
-
provides: Readonly<_embedpdf_plugin_export.ExportCapability> | null;
|
|
12
|
-
isLoading: boolean;
|
|
13
|
-
ready: Promise<void>;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
declare function Download(): react_jsx_runtime.JSX.Element;
|
|
17
|
-
|
|
18
|
-
export { Download, useExportCapability, useExportPlugin };
|