@embedpdf/plugin-render 1.0.11 → 1.0.12

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.
Files changed (46) hide show
  1. package/dist/index.cjs +2 -128
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.ts +1 -44
  4. package/dist/index.js +7 -11
  5. package/dist/index.js.map +1 -1
  6. package/dist/lib/index.d.ts +6 -0
  7. package/dist/lib/manifest.d.ts +4 -0
  8. package/dist/lib/render-plugin.d.ts +12 -0
  9. package/dist/lib/types.d.ts +29 -0
  10. package/dist/preact/adapter.d.ts +5 -0
  11. package/dist/preact/core.d.ts +1 -0
  12. package/dist/preact/index.cjs +2 -97
  13. package/dist/preact/index.cjs.map +1 -1
  14. package/dist/preact/index.d.ts +1 -26
  15. package/dist/preact/index.js +7 -10
  16. package/dist/preact/index.js.map +1 -1
  17. package/dist/react/adapter.d.ts +2 -0
  18. package/dist/react/core.d.ts +1 -0
  19. package/dist/react/index.cjs +2 -96
  20. package/dist/react/index.cjs.map +1 -1
  21. package/dist/react/index.d.ts +1 -24
  22. package/dist/react/index.js +7 -10
  23. package/dist/react/index.js.map +1 -1
  24. package/dist/shared-preact/components/index.d.ts +1 -0
  25. package/dist/shared-preact/components/render-layer.d.ts +9 -0
  26. package/dist/shared-preact/hooks/index.d.ts +1 -0
  27. package/dist/shared-preact/hooks/use-render.d.ts +11 -0
  28. package/dist/shared-preact/index.d.ts +2 -0
  29. package/dist/shared-react/components/index.d.ts +1 -0
  30. package/dist/shared-react/components/render-layer.d.ts +9 -0
  31. package/dist/shared-react/hooks/index.d.ts +1 -0
  32. package/dist/shared-react/hooks/use-render.d.ts +11 -0
  33. package/dist/shared-react/index.d.ts +2 -0
  34. package/dist/vue/components/index.d.ts +1 -0
  35. package/dist/vue/components/render-layer.vue.d.ts +10 -0
  36. package/dist/vue/hooks/index.d.ts +1 -0
  37. package/dist/vue/hooks/use-render.d.ts +3 -0
  38. package/dist/vue/index.cjs +2 -0
  39. package/dist/vue/index.cjs.map +1 -0
  40. package/dist/vue/index.d.ts +2 -0
  41. package/dist/vue/index.js +75 -0
  42. package/dist/vue/index.js.map +1 -0
  43. package/package.json +20 -14
  44. package/dist/index.d.cts +0 -44
  45. package/dist/preact/index.d.cts +0 -26
  46. package/dist/react/index.d.cts +0 -24
package/dist/index.cjs CHANGED
@@ -1,128 +1,2 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
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
- RenderPlugin: () => RenderPlugin,
24
- RenderPluginPackage: () => RenderPluginPackage
25
- });
26
- module.exports = __toCommonJS(index_exports);
27
-
28
- // src/lib/render-plugin.ts
29
- var import_core = require("@embedpdf/core");
30
- var import_models = require("@embedpdf/models");
31
- var RenderPlugin = class extends import_core.BasePlugin {
32
- constructor(id, registry, engine) {
33
- super(id, registry);
34
- this.engine = engine;
35
- }
36
- async initialize(_config) {
37
- }
38
- buildCapability() {
39
- return {
40
- renderPage: this.renderPage.bind(this),
41
- renderPageRect: this.renderPageRect.bind(this)
42
- };
43
- }
44
- renderPage({
45
- pageIndex,
46
- scaleFactor = 1,
47
- dpr = 1,
48
- rotation = import_models.Rotation.Degree0,
49
- options = { withAnnotations: false },
50
- imageType = "image/webp"
51
- }) {
52
- const coreState = this.coreState.core;
53
- if (!coreState.document) {
54
- throw new Error("document does not open");
55
- }
56
- const page = coreState.document.pages.find((page2) => page2.index === pageIndex);
57
- if (!page) {
58
- throw new Error("page does not exist");
59
- }
60
- return this.engine.renderPage(
61
- coreState.document,
62
- page,
63
- scaleFactor,
64
- rotation,
65
- dpr,
66
- options,
67
- imageType
68
- );
69
- }
70
- renderPageRect({
71
- pageIndex,
72
- scaleFactor = 1,
73
- dpr = 1,
74
- rect,
75
- rotation = import_models.Rotation.Degree0,
76
- options = { withAnnotations: false },
77
- imageType = "image/webp"
78
- }) {
79
- const coreState = this.coreState.core;
80
- if (!coreState.document) {
81
- throw new Error("document does not open");
82
- }
83
- const page = coreState.document.pages.find((page2) => page2.index === pageIndex);
84
- if (!page) {
85
- throw new Error("page does not exist");
86
- }
87
- return this.engine.renderPageRect(
88
- coreState.document,
89
- page,
90
- scaleFactor,
91
- rotation,
92
- dpr,
93
- rect,
94
- options,
95
- imageType
96
- );
97
- }
98
- };
99
- RenderPlugin.id = "render";
100
-
101
- // src/lib/manifest.ts
102
- var RENDER_PLUGIN_ID = "render";
103
- var manifest = {
104
- id: RENDER_PLUGIN_ID,
105
- name: "Render Plugin",
106
- version: "1.0.0",
107
- provides: ["render"],
108
- requires: [],
109
- optional: [],
110
- defaultConfig: {
111
- enabled: true
112
- }
113
- };
114
-
115
- // src/lib/index.ts
116
- var RenderPluginPackage = {
117
- manifest,
118
- create: (registry, engine) => new RenderPlugin(RENDER_PLUGIN_ID, registry, engine),
119
- reducer: () => {
120
- },
121
- initialState: {}
122
- };
123
- // Annotate the CommonJS export names for ESM import in node:
124
- 0 && (module.exports = {
125
- RenderPlugin,
126
- RenderPluginPackage
127
- });
128
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),n=require("@embedpdf/models"),t=class extends e.BasePlugin{constructor(e,n,t){super(e,n),this.engine=t}async initialize(e){}buildCapability(){return{renderPage:this.renderPage.bind(this),renderPageRect:this.renderPageRect.bind(this)}}renderPage({pageIndex:e,scaleFactor:t=1,dpr:r=1,rotation:o=n.Rotation.Degree0,options:i={withAnnotations:!1},imageType:d="image/webp"}){const a=this.coreState.core;if(!a.document)throw new Error("document does not open");const s=a.document.pages.find((n=>n.index===e));if(!s)throw new Error("page does not exist");return this.engine.renderPage(a.document,s,t,o,r,i,d)}renderPageRect({pageIndex:e,scaleFactor:t=1,dpr:r=1,rect:o,rotation:i=n.Rotation.Degree0,options:d={withAnnotations:!1},imageType:a="image/webp"}){const s=this.coreState.core;if(!s.document)throw new Error("document does not open");const c=s.document.pages.find((n=>n.index===e));if(!c)throw new Error("page does not exist");return this.engine.renderPageRect(s.document,c,t,i,r,o,d,a)}};t.id="render";let r=t;const o="render",i={manifest:{id:o,name:"Render Plugin",version:"1.0.0",provides:["render"],requires:[],optional:[],defaultConfig:{enabled:!0}},create:(e,n)=>new r(o,e,n),reducer:()=>{},initialState:{}};exports.RenderPlugin=r,exports.RenderPluginPackage=i;
2
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/lib/render-plugin.ts","../src/lib/manifest.ts","../src/lib/index.ts"],"sourcesContent":["export * from './lib';\n","import { BasePlugin, PluginRegistry } from '@embedpdf/core';\nimport {\n RenderCapability,\n RenderPageOptions,\n RenderPageRectOptions,\n RenderPluginConfig,\n} from './types';\nimport { PdfEngine, Rotation } from '@embedpdf/models';\n\nexport class RenderPlugin extends BasePlugin<RenderPluginConfig, RenderCapability> {\n static readonly id = 'render' as const;\n private engine: PdfEngine;\n\n constructor(id: string, registry: PluginRegistry, engine: PdfEngine) {\n super(id, registry);\n this.engine = engine;\n }\n\n async initialize(_config: RenderPluginConfig): Promise<void> {}\n\n protected buildCapability(): RenderCapability {\n return {\n renderPage: this.renderPage.bind(this),\n renderPageRect: this.renderPageRect.bind(this),\n };\n }\n\n private renderPage({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n rotation = Rotation.Degree0,\n options = { withAnnotations: false },\n imageType = 'image/webp',\n }: RenderPageOptions) {\n const coreState = this.coreState.core;\n\n if (!coreState.document) {\n throw new Error('document does not open');\n }\n\n const page = coreState.document.pages.find((page) => page.index === pageIndex);\n if (!page) {\n throw new Error('page does not exist');\n }\n\n return this.engine.renderPage(\n coreState.document,\n page,\n scaleFactor,\n rotation,\n dpr,\n options,\n imageType,\n );\n }\n\n private renderPageRect({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n rect,\n rotation = Rotation.Degree0,\n options = { withAnnotations: false },\n imageType = 'image/webp',\n }: RenderPageRectOptions) {\n const coreState = this.coreState.core;\n\n if (!coreState.document) {\n throw new Error('document does not open');\n }\n\n const page = coreState.document.pages.find((page) => page.index === pageIndex);\n if (!page) {\n throw new Error('page does not exist');\n }\n\n return this.engine.renderPageRect(\n coreState.document,\n page,\n scaleFactor,\n rotation,\n dpr,\n rect,\n options,\n imageType,\n );\n }\n}\n","import { PluginManifest } from '@embedpdf/core';\nimport { RenderPluginConfig } from './types';\n\nexport const RENDER_PLUGIN_ID = 'render';\n\nexport const manifest: PluginManifest<RenderPluginConfig> = {\n id: RENDER_PLUGIN_ID,\n name: 'Render Plugin',\n version: '1.0.0',\n provides: ['render'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n },\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { RenderPluginConfig } from './types';\nimport { RenderPlugin } from './render-plugin';\nimport { manifest, RENDER_PLUGIN_ID } from './manifest';\n\nexport const RenderPluginPackage: PluginPackage<RenderPlugin, RenderPluginConfig> = {\n manifest,\n create: (registry, engine) => new RenderPlugin(RENDER_PLUGIN_ID, registry, engine),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './render-plugin';\nexport * from './types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACA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SAAS;AAC7E,QAAI,CAAC,MAAM;AACT,YAAM,IAAI,MAAM,qBAAqB;AAAA,IACvC;AAEA,WAAO,KAAK,OAAO;AAAA,MACjB,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AA/Ea,aACK,KAAK;;;ACPhB,IAAM,mBAAmB;AAEzB,IAAM,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,EACX;AACF;;;ACVO,IAAM,sBAAuE;AAAA,EAClF;AAAA,EACA,QAAQ,CAAC,UAAU,WAAW,IAAI,aAAa,kBAAkB,UAAU,MAAM;AAAA,EACjF,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,cAAc,CAAC;AACjB;","names":["page"]}
1
+ {"version":3,"file":"index.cjs","sources":["../src/lib/render-plugin.ts","../src/lib/manifest.ts","../src/lib/index.ts"],"sourcesContent":["import { BasePlugin, PluginRegistry } from '@embedpdf/core';\nimport {\n RenderCapability,\n RenderPageOptions,\n RenderPageRectOptions,\n RenderPluginConfig,\n} from './types';\nimport { PdfEngine, Rotation } from '@embedpdf/models';\n\nexport class RenderPlugin extends BasePlugin<RenderPluginConfig, RenderCapability> {\n static readonly id = 'render' as const;\n private engine: PdfEngine;\n\n constructor(id: string, registry: PluginRegistry, engine: PdfEngine) {\n super(id, registry);\n this.engine = engine;\n }\n\n async initialize(_config: RenderPluginConfig): Promise<void> {}\n\n protected buildCapability(): RenderCapability {\n return {\n renderPage: this.renderPage.bind(this),\n renderPageRect: this.renderPageRect.bind(this),\n };\n }\n\n private renderPage({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n rotation = Rotation.Degree0,\n options = { withAnnotations: false },\n imageType = 'image/webp',\n }: RenderPageOptions) {\n const coreState = this.coreState.core;\n\n if (!coreState.document) {\n throw new Error('document does not open');\n }\n\n const page = coreState.document.pages.find((page) => page.index === pageIndex);\n if (!page) {\n throw new Error('page does not exist');\n }\n\n return this.engine.renderPage(\n coreState.document,\n page,\n scaleFactor,\n rotation,\n dpr,\n options,\n imageType,\n );\n }\n\n private renderPageRect({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n rect,\n rotation = Rotation.Degree0,\n options = { withAnnotations: false },\n imageType = 'image/webp',\n }: RenderPageRectOptions) {\n const coreState = this.coreState.core;\n\n if (!coreState.document) {\n throw new Error('document does not open');\n }\n\n const page = coreState.document.pages.find((page) => page.index === pageIndex);\n if (!page) {\n throw new Error('page does not exist');\n }\n\n return this.engine.renderPageRect(\n coreState.document,\n page,\n scaleFactor,\n rotation,\n dpr,\n rect,\n options,\n imageType,\n );\n }\n}\n","import { PluginManifest } from '@embedpdf/core';\nimport { RenderPluginConfig } from './types';\n\nexport const RENDER_PLUGIN_ID = 'render';\n\nexport const manifest: PluginManifest<RenderPluginConfig> = {\n id: RENDER_PLUGIN_ID,\n name: 'Render Plugin',\n version: '1.0.0',\n provides: ['render'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n },\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { RenderPluginConfig } from './types';\nimport { RenderPlugin } from './render-plugin';\nimport { manifest, RENDER_PLUGIN_ID } from './manifest';\n\nexport const RenderPluginPackage: PluginPackage<RenderPlugin, RenderPluginConfig> = {\n manifest,\n create: (registry, engine) => new RenderPlugin(RENDER_PLUGIN_ID, registry, engine),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './render-plugin';\nexport * from './types';\n"],"names":["_RenderPlugin","BasePlugin","constructor","id","registry","engine","super","this","initialize","_config","buildCapability","renderPage","bind","renderPageRect","pageIndex","scaleFactor","dpr","rotation","Rotation","Degree0","options","withAnnotations","imageType","coreState","core","document","Error","page","pages","find","index","rect","RenderPlugin","RENDER_PLUGIN_ID","RenderPluginPackage","manifest","name","version","provides","requires","optional","defaultConfig","enabled","create","reducer","initialState"],"mappings":"gJASaA,EAAN,cAA2BC,EAAAA,WAIhC,WAAAC,CAAYC,EAAYC,EAA0BC,GAChDC,MAAMH,EAAIC,GACVG,KAAKF,OAASA,CAAA,CAGhB,gBAAMG,CAAWC,GAA4C,CAEnD,eAAAC,GACD,MAAA,CACLC,WAAYJ,KAAKI,WAAWC,KAAKL,MACjCM,eAAgBN,KAAKM,eAAeD,KAAKL,MAC3C,CAGM,UAAAI,EAAWG,UACjBA,EAAAC,YACAA,EAAc,EAAAC,IACdA,EAAM,EAAAC,SACNA,EAAWC,EAASA,SAAAC,QAAAC,QACpBA,EAAU,CAAEC,iBAAiB,GAAMC,UACnCA,EAAY,eAEN,MAAAC,EAAYhB,KAAKgB,UAAUC,KAE7B,IAACD,EAAUE,SACP,MAAA,IAAIC,MAAM,0BAGZ,MAAAC,EAAOJ,EAAUE,SAASG,MAAMC,MAAMF,GAASA,EAAKG,QAAUhB,IACpE,IAAKa,EACG,MAAA,IAAID,MAAM,uBAGlB,OAAOnB,KAAKF,OAAOM,WACjBY,EAAUE,SACVE,EACAZ,EACAE,EACAD,EACAI,EACAE,EACF,CAGM,cAAAT,EAAeC,UACrBA,EAAAC,YACAA,EAAc,EAAAC,IACdA,EAAM,EAAAe,KACNA,EAAAd,SACAA,EAAWC,EAASA,SAAAC,QAAAC,QACpBA,EAAU,CAAEC,iBAAiB,GAAMC,UACnCA,EAAY,eAEN,MAAAC,EAAYhB,KAAKgB,UAAUC,KAE7B,IAACD,EAAUE,SACP,MAAA,IAAIC,MAAM,0BAGZ,MAAAC,EAAOJ,EAAUE,SAASG,MAAMC,MAAMF,GAASA,EAAKG,QAAUhB,IACpE,IAAKa,EACG,MAAA,IAAID,MAAM,uBAGlB,OAAOnB,KAAKF,OAAOQ,eACjBU,EAAUE,SACVE,EACAZ,EACAE,EACAD,EACAe,EACAX,EACAE,EACF,GA5EFtB,EAAgBG,GAAK,SADhB,IAAM6B,EAANhC,ECNA,MAAMiC,EAAmB,SCEnBC,EAAuE,CAClFC,SDD0D,CAC1DhC,GAAI8B,EACJG,KAAM,gBACNC,QAAS,QACTC,SAAU,CAAC,UACXC,SAAU,GACVC,SAAU,GACVC,cAAe,CACbC,SAAS,ICNXC,OAAQ,CAACvC,EAAUC,IAAW,IAAI2B,EAAaC,EAAkB7B,EAAUC,GAC3EuC,QAAS,OACTC,aAAc,CAAA"}
package/dist/index.d.ts CHANGED
@@ -1,44 +1 @@
1
- import { BasePluginConfig, BasePlugin, PluginRegistry, PluginPackage } from '@embedpdf/core';
2
- import { Rotation, ImageConversionTypes, Task, PdfErrorReason, Rect, PdfEngine } from '@embedpdf/models';
3
-
4
- interface RenderPluginConfig extends BasePluginConfig {
5
- }
6
- interface RenderPageRectOptions {
7
- pageIndex: number;
8
- scaleFactor?: number;
9
- rotation?: Rotation;
10
- dpr?: number;
11
- rect: Rect;
12
- options?: {
13
- withAnnotations: boolean;
14
- };
15
- imageType?: ImageConversionTypes;
16
- }
17
- interface RenderPageOptions {
18
- pageIndex: number;
19
- scaleFactor?: number;
20
- dpr?: number;
21
- rotation?: Rotation;
22
- options?: {
23
- withAnnotations: boolean;
24
- };
25
- imageType?: ImageConversionTypes;
26
- }
27
- interface RenderCapability {
28
- renderPage: (options: RenderPageOptions) => Task<Blob, PdfErrorReason>;
29
- renderPageRect: (options: RenderPageRectOptions) => Task<Blob, PdfErrorReason>;
30
- }
31
-
32
- declare class RenderPlugin extends BasePlugin<RenderPluginConfig, RenderCapability> {
33
- static readonly id: "render";
34
- private engine;
35
- constructor(id: string, registry: PluginRegistry, engine: PdfEngine);
36
- initialize(_config: RenderPluginConfig): Promise<void>;
37
- protected buildCapability(): RenderCapability;
38
- private renderPage;
39
- private renderPageRect;
40
- }
41
-
42
- declare const RenderPluginPackage: PluginPackage<RenderPlugin, RenderPluginConfig>;
43
-
44
- export { type RenderCapability, type RenderPageOptions, type RenderPageRectOptions, RenderPlugin, type RenderPluginConfig, RenderPluginPackage };
1
+ export * from './lib';
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
- // src/lib/render-plugin.ts
2
1
  import { BasePlugin } from "@embedpdf/core";
3
2
  import { Rotation } from "@embedpdf/models";
4
- var RenderPlugin = class extends BasePlugin {
3
+ const _RenderPlugin = class _RenderPlugin extends BasePlugin {
5
4
  constructor(id, registry, engine) {
6
5
  super(id, registry);
7
6
  this.engine = engine;
@@ -69,11 +68,10 @@ var RenderPlugin = class extends BasePlugin {
69
68
  );
70
69
  }
71
70
  };
72
- RenderPlugin.id = "render";
73
-
74
- // src/lib/manifest.ts
75
- var RENDER_PLUGIN_ID = "render";
76
- var manifest = {
71
+ _RenderPlugin.id = "render";
72
+ let RenderPlugin = _RenderPlugin;
73
+ const RENDER_PLUGIN_ID = "render";
74
+ const manifest = {
77
75
  id: RENDER_PLUGIN_ID,
78
76
  name: "Render Plugin",
79
77
  version: "1.0.0",
@@ -84,9 +82,7 @@ var manifest = {
84
82
  enabled: true
85
83
  }
86
84
  };
87
-
88
- // src/lib/index.ts
89
- var RenderPluginPackage = {
85
+ const RenderPluginPackage = {
90
86
  manifest,
91
87
  create: (registry, engine) => new RenderPlugin(RENDER_PLUGIN_ID, registry, engine),
92
88
  reducer: () => {
@@ -97,4 +93,4 @@ export {
97
93
  RenderPlugin,
98
94
  RenderPluginPackage
99
95
  };
100
- //# sourceMappingURL=index.js.map
96
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/render-plugin.ts","../src/lib/manifest.ts","../src/lib/index.ts"],"sourcesContent":["import { BasePlugin, PluginRegistry } from '@embedpdf/core';\nimport {\n RenderCapability,\n RenderPageOptions,\n RenderPageRectOptions,\n RenderPluginConfig,\n} from './types';\nimport { PdfEngine, Rotation } from '@embedpdf/models';\n\nexport class RenderPlugin extends BasePlugin<RenderPluginConfig, RenderCapability> {\n static readonly id = 'render' as const;\n private engine: PdfEngine;\n\n constructor(id: string, registry: PluginRegistry, engine: PdfEngine) {\n super(id, registry);\n this.engine = engine;\n }\n\n async initialize(_config: RenderPluginConfig): Promise<void> {}\n\n protected buildCapability(): RenderCapability {\n return {\n renderPage: this.renderPage.bind(this),\n renderPageRect: this.renderPageRect.bind(this),\n };\n }\n\n private renderPage({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n rotation = Rotation.Degree0,\n options = { withAnnotations: false },\n imageType = 'image/webp',\n }: RenderPageOptions) {\n const coreState = this.coreState.core;\n\n if (!coreState.document) {\n throw new Error('document does not open');\n }\n\n const page = coreState.document.pages.find((page) => page.index === pageIndex);\n if (!page) {\n throw new Error('page does not exist');\n }\n\n return this.engine.renderPage(\n coreState.document,\n page,\n scaleFactor,\n rotation,\n dpr,\n options,\n imageType,\n );\n }\n\n private renderPageRect({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n rect,\n rotation = Rotation.Degree0,\n options = { withAnnotations: false },\n imageType = 'image/webp',\n }: RenderPageRectOptions) {\n const coreState = this.coreState.core;\n\n if (!coreState.document) {\n throw new Error('document does not open');\n }\n\n const page = coreState.document.pages.find((page) => page.index === pageIndex);\n if (!page) {\n throw new Error('page does not exist');\n }\n\n return this.engine.renderPageRect(\n coreState.document,\n page,\n scaleFactor,\n rotation,\n dpr,\n rect,\n options,\n imageType,\n );\n }\n}\n","import { PluginManifest } from '@embedpdf/core';\nimport { RenderPluginConfig } from './types';\n\nexport const RENDER_PLUGIN_ID = 'render';\n\nexport const manifest: PluginManifest<RenderPluginConfig> = {\n id: RENDER_PLUGIN_ID,\n name: 'Render Plugin',\n version: '1.0.0',\n provides: ['render'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n },\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { RenderPluginConfig } from './types';\nimport { RenderPlugin } from './render-plugin';\nimport { manifest, RENDER_PLUGIN_ID } from './manifest';\n\nexport const RenderPluginPackage: PluginPackage<RenderPlugin, RenderPluginConfig> = {\n manifest,\n create: (registry, engine) => new RenderPlugin(RENDER_PLUGIN_ID, registry, engine),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './render-plugin';\nexport * from './types';\n"],"mappings":";AAAA,SAAS,kBAAkC;AAO3C,SAAoB,gBAAgB;AAE7B,IAAM,eAAN,cAA2B,WAAiD;AAAA,EAIjF,YAAY,IAAY,UAA0B,QAAmB;AACnE,UAAM,IAAI,QAAQ;AAClB,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,MAAM,WAAW,SAA4C;AAAA,EAAC;AAAA,EAEpD,kBAAoC;AAC5C,WAAO;AAAA,MACL,YAAY,KAAK,WAAW,KAAK,IAAI;AAAA,MACrC,gBAAgB,KAAK,eAAe,KAAK,IAAI;AAAA,IAC/C;AAAA,EACF;AAAA,EAEQ,WAAW;AAAA,IACjB;AAAA,IACA,cAAc;AAAA,IACd,MAAM;AAAA,IACN,WAAW,SAAS;AAAA,IACpB,UAAU,EAAE,iBAAiB,MAAM;AAAA,IACnC,YAAY;AAAA,EACd,GAAsB;AACpB,UAAM,YAAY,KAAK,UAAU;AAEjC,QAAI,CAAC,UAAU,UAAU;AACvB,YAAM,IAAI,MAAM,wBAAwB;AAAA,IAC1C;AAEA,UAAM,OAAO,UAAU,SAAS,MAAM,KAAK,CAACA,UAASA,MAAK,UAAU,SAAS;AAC7E,QAAI,CAAC,MAAM;AACT,YAAM,IAAI,MAAM,qBAAqB;AAAA,IACvC;AAEA,WAAO,KAAK,OAAO;AAAA,MACjB,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEQ,eAAe;AAAA,IACrB;AAAA,IACA,cAAc;AAAA,IACd,MAAM;AAAA,IACN;AAAA,IACA,WAAW,SAAS;AAAA,IACpB,UAAU,EAAE,iBAAiB,MAAM;AAAA,IACnC,YAAY;AAAA,EACd,GAA0B;AACxB,UAAM,YAAY,KAAK,UAAU;AAEjC,QAAI,CAAC,UAAU,UAAU;AACvB,YAAM,IAAI,MAAM,wBAAwB;AAAA,IAC1C;AAEA,UAAM,OAAO,UAAU,SAAS,MAAM,KAAK,CAACA,UAASA,MAAK,UAAU,SAAS;AAC7E,QAAI,CAAC,MAAM;AACT,YAAM,IAAI,MAAM,qBAAqB;AAAA,IACvC;AAEA,WAAO,KAAK,OAAO;AAAA,MACjB,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AA/Ea,aACK,KAAK;;;ACPhB,IAAM,mBAAmB;AAEzB,IAAM,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,EACX;AACF;;;ACVO,IAAM,sBAAuE;AAAA,EAClF;AAAA,EACA,QAAQ,CAAC,UAAU,WAAW,IAAI,aAAa,kBAAkB,UAAU,MAAM;AAAA,EACjF,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,cAAc,CAAC;AACjB;","names":["page"]}
1
+ {"version":3,"file":"index.js","sources":["../src/lib/render-plugin.ts","../src/lib/manifest.ts","../src/lib/index.ts"],"sourcesContent":["import { BasePlugin, PluginRegistry } from '@embedpdf/core';\nimport {\n RenderCapability,\n RenderPageOptions,\n RenderPageRectOptions,\n RenderPluginConfig,\n} from './types';\nimport { PdfEngine, Rotation } from '@embedpdf/models';\n\nexport class RenderPlugin extends BasePlugin<RenderPluginConfig, RenderCapability> {\n static readonly id = 'render' as const;\n private engine: PdfEngine;\n\n constructor(id: string, registry: PluginRegistry, engine: PdfEngine) {\n super(id, registry);\n this.engine = engine;\n }\n\n async initialize(_config: RenderPluginConfig): Promise<void> {}\n\n protected buildCapability(): RenderCapability {\n return {\n renderPage: this.renderPage.bind(this),\n renderPageRect: this.renderPageRect.bind(this),\n };\n }\n\n private renderPage({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n rotation = Rotation.Degree0,\n options = { withAnnotations: false },\n imageType = 'image/webp',\n }: RenderPageOptions) {\n const coreState = this.coreState.core;\n\n if (!coreState.document) {\n throw new Error('document does not open');\n }\n\n const page = coreState.document.pages.find((page) => page.index === pageIndex);\n if (!page) {\n throw new Error('page does not exist');\n }\n\n return this.engine.renderPage(\n coreState.document,\n page,\n scaleFactor,\n rotation,\n dpr,\n options,\n imageType,\n );\n }\n\n private renderPageRect({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n rect,\n rotation = Rotation.Degree0,\n options = { withAnnotations: false },\n imageType = 'image/webp',\n }: RenderPageRectOptions) {\n const coreState = this.coreState.core;\n\n if (!coreState.document) {\n throw new Error('document does not open');\n }\n\n const page = coreState.document.pages.find((page) => page.index === pageIndex);\n if (!page) {\n throw new Error('page does not exist');\n }\n\n return this.engine.renderPageRect(\n coreState.document,\n page,\n scaleFactor,\n rotation,\n dpr,\n rect,\n options,\n imageType,\n );\n }\n}\n","import { PluginManifest } from '@embedpdf/core';\nimport { RenderPluginConfig } from './types';\n\nexport const RENDER_PLUGIN_ID = 'render';\n\nexport const manifest: PluginManifest<RenderPluginConfig> = {\n id: RENDER_PLUGIN_ID,\n name: 'Render Plugin',\n version: '1.0.0',\n provides: ['render'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n },\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { RenderPluginConfig } from './types';\nimport { RenderPlugin } from './render-plugin';\nimport { manifest, RENDER_PLUGIN_ID } from './manifest';\n\nexport const RenderPluginPackage: PluginPackage<RenderPlugin, RenderPluginConfig> = {\n manifest,\n create: (registry, engine) => new RenderPlugin(RENDER_PLUGIN_ID, registry, engine),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './render-plugin';\nexport * from './types';\n"],"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7E,QAAI,CAAC,MAAM;AACH,YAAA,IAAI,MAAM,qBAAqB;AAAA,IAAA;AAGvC,WAAO,KAAK,OAAO;AAAA,MACjB,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EAAA;AAEJ;AA9EE,cAAgB,KAAK;AADhB,IAAM,eAAN;ACNA,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;ACVO,MAAM,sBAAuE;AAAA,EAClF;AAAA,EACA,QAAQ,CAAC,UAAU,WAAW,IAAI,aAAa,kBAAkB,UAAU,MAAM;AAAA,EACjF,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,cAAc,CAAA;AAChB;"}
@@ -0,0 +1,6 @@
1
+ import { PluginPackage } from '@embedpdf/core';
2
+ import { RenderPluginConfig } from './types';
3
+ import { RenderPlugin } from './render-plugin';
4
+ export declare const RenderPluginPackage: PluginPackage<RenderPlugin, RenderPluginConfig>;
5
+ export * from './render-plugin';
6
+ export * from './types';
@@ -0,0 +1,4 @@
1
+ import { PluginManifest } from '@embedpdf/core';
2
+ import { RenderPluginConfig } from './types';
3
+ export declare const RENDER_PLUGIN_ID = "render";
4
+ export declare const manifest: PluginManifest<RenderPluginConfig>;
@@ -0,0 +1,12 @@
1
+ import { BasePlugin, PluginRegistry } from '@embedpdf/core';
2
+ import { RenderCapability, RenderPluginConfig } from './types';
3
+ import { PdfEngine } from '@embedpdf/models';
4
+ export declare class RenderPlugin extends BasePlugin<RenderPluginConfig, RenderCapability> {
5
+ static readonly id: "render";
6
+ private engine;
7
+ constructor(id: string, registry: PluginRegistry, engine: PdfEngine);
8
+ initialize(_config: RenderPluginConfig): Promise<void>;
9
+ protected buildCapability(): RenderCapability;
10
+ private renderPage;
11
+ private renderPageRect;
12
+ }
@@ -0,0 +1,29 @@
1
+ import { BasePluginConfig } from '@embedpdf/core';
2
+ import { ImageConversionTypes, PdfErrorReason, Rect, Rotation, Task } from '@embedpdf/models';
3
+ export interface RenderPluginConfig extends BasePluginConfig {
4
+ }
5
+ export interface RenderPageRectOptions {
6
+ pageIndex: number;
7
+ scaleFactor?: number;
8
+ rotation?: Rotation;
9
+ dpr?: number;
10
+ rect: Rect;
11
+ options?: {
12
+ withAnnotations: boolean;
13
+ };
14
+ imageType?: ImageConversionTypes;
15
+ }
16
+ export interface RenderPageOptions {
17
+ pageIndex: number;
18
+ scaleFactor?: number;
19
+ dpr?: number;
20
+ rotation?: Rotation;
21
+ options?: {
22
+ withAnnotations: boolean;
23
+ };
24
+ imageType?: ImageConversionTypes;
25
+ }
26
+ export interface RenderCapability {
27
+ renderPage: (options: RenderPageOptions) => Task<Blob, PdfErrorReason>;
28
+ renderPageRect: (options: RenderPageRectOptions) => Task<Blob, PdfErrorReason>;
29
+ }
@@ -0,0 +1,5 @@
1
+ import { Fragment } from 'preact';
2
+ import { useEffect, useRef, useState } from 'preact/hooks';
3
+ export { Fragment, useEffect, useRef, useState };
4
+ export type CSSProperties = import('preact').JSX.CSSProperties;
5
+ export type HTMLAttributes<T = any> = import('preact').JSX.HTMLAttributes<T extends EventTarget ? T : never>;
@@ -0,0 +1 @@
1
+ export * from '@embedpdf/core/preact';
@@ -1,97 +1,2 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
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
- RenderLayer: () => RenderLayer,
24
- useRenderCapability: () => useRenderCapability,
25
- useRenderPlugin: () => useRenderPlugin
26
- });
27
- module.exports = __toCommonJS(preact_exports);
28
-
29
- // src/preact/hooks/use-render.ts
30
- var import_preact = require("@embedpdf/core/preact");
31
- var import_plugin_render = require("@embedpdf/plugin-render");
32
- var useRenderPlugin = () => (0, import_preact.usePlugin)(import_plugin_render.RenderPlugin.id);
33
- var useRenderCapability = () => (0, import_preact.useCapability)(import_plugin_render.RenderPlugin.id);
34
-
35
- // src/preact/components/render-layer.tsx
36
- var import_preact2 = require("preact");
37
- var import_hooks = require("preact/hooks");
38
- var import_models = require("@embedpdf/models");
39
- var import_jsx_runtime = require("preact/jsx-runtime");
40
- function RenderLayer({
41
- pageIndex,
42
- scaleFactor = 1,
43
- dpr = 1,
44
- style,
45
- ...props
46
- }) {
47
- const { provides: renderProvides } = useRenderCapability();
48
- const [imageUrl, setImageUrl] = (0, import_hooks.useState)(null);
49
- const urlRef = (0, import_hooks.useRef)(null);
50
- (0, import_hooks.useEffect)(() => {
51
- if (renderProvides) {
52
- const task = renderProvides.renderPage({ pageIndex, scaleFactor, dpr });
53
- task.wait((blob) => {
54
- const url = URL.createObjectURL(blob);
55
- setImageUrl(url);
56
- urlRef.current = url;
57
- }, import_models.ignore);
58
- return () => {
59
- if (urlRef.current) {
60
- URL.revokeObjectURL(urlRef.current);
61
- urlRef.current = null;
62
- } else {
63
- task.abort({
64
- code: import_models.PdfErrorCode.Cancelled,
65
- message: "canceled render task"
66
- });
67
- }
68
- };
69
- }
70
- }, [pageIndex, scaleFactor, dpr, renderProvides]);
71
- const handleImageLoad = () => {
72
- if (urlRef.current) {
73
- URL.revokeObjectURL(urlRef.current);
74
- urlRef.current = null;
75
- }
76
- };
77
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_preact2.Fragment, { children: imageUrl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
78
- "img",
79
- {
80
- src: imageUrl,
81
- onLoad: handleImageLoad,
82
- ...props,
83
- style: {
84
- width: "100%",
85
- height: "100%",
86
- ...style || {}
87
- }
88
- }
89
- ) });
90
- }
91
- // Annotate the CommonJS export names for ESM import in node:
92
- 0 && (module.exports = {
93
- RenderLayer,
94
- useRenderCapability,
95
- useRenderPlugin
96
- });
97
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("preact/jsx-runtime"),r=require("preact"),t=require("preact/hooks"),n=require("@embedpdf/models"),u=require("@embedpdf/core/preact"),c=require("@embedpdf/plugin-render"),d=()=>u.useCapability(c.RenderPlugin.id);exports.RenderLayer=function({pageIndex:u,scaleFactor:c=1,dpr:s=1,style:i,...o}){const{provides:a}=d(),[l,p]=t.useState(null),g=t.useRef(null);return t.useEffect((()=>{if(a){const e=a.renderPage({pageIndex:u,scaleFactor:c,dpr:s});return e.wait((e=>{const r=URL.createObjectURL(e);p(r),g.current=r}),n.ignore),()=>{g.current?(URL.revokeObjectURL(g.current),g.current=null):e.abort({code:n.PdfErrorCode.Cancelled,message:"canceled render task"})}}}),[u,c,s,a]),e.jsx(r.Fragment,{children:l&&e.jsx("img",{src:l,onLoad:()=>{g.current&&(URL.revokeObjectURL(g.current),g.current=null)},...o,style:{width:"100%",height:"100%",...i||{}}})})},exports.useRenderCapability=d,exports.useRenderPlugin=()=>u.usePlugin(c.RenderPlugin.id);
2
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/preact/index.ts","../../src/preact/hooks/use-render.ts","../../src/preact/components/render-layer.tsx"],"sourcesContent":["export * from './hooks';\nexport * from './components';\n","import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { RenderPlugin } from '@embedpdf/plugin-render';\n\nexport const useRenderPlugin = () => usePlugin<RenderPlugin>(RenderPlugin.id);\nexport const useRenderCapability = () => useCapability<RenderPlugin>(RenderPlugin.id);\n","/** @jsxImportSource preact */\nimport { Fragment, JSX } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { ignore, PdfErrorCode } from '@embedpdf/models';\n\nimport { useRenderCapability } from '../hooks/use-render';\n\ntype RenderLayoutProps = Omit<JSX.HTMLAttributes<HTMLImageElement>, 'style'> & {\n pageIndex: number;\n scaleFactor?: number;\n dpr?: number;\n style?: JSX.CSSProperties;\n};\n\nexport function RenderLayer({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n style,\n ...props\n}: RenderLayoutProps) {\n const { provides: renderProvides } = useRenderCapability();\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (renderProvides) {\n const task = renderProvides.renderPage({ pageIndex, scaleFactor, dpr });\n task.wait((blob) => {\n const url = URL.createObjectURL(blob);\n setImageUrl(url);\n urlRef.current = url;\n }, ignore);\n\n return () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n };\n }\n }, [pageIndex, scaleFactor, dpr, renderProvides]);\n\n const handleImageLoad = () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n }\n };\n\n return (\n <Fragment>\n {imageUrl && (\n <img\n src={imageUrl}\n onLoad={handleImageLoad}\n {...props}\n style={{\n width: '100%',\n height: '100%',\n ...(style || {}),\n }}\n />\n )}\n </Fragment>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA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I,SAAS,CAAC;AAAA,MAChB;AAAA;AAAA,EACF,GAEJ;AAEJ;","names":["import_preact"]}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-render.ts","../../src/shared/components/render-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { RenderPlugin } from '@embedpdf/plugin-render';\n\nexport const useRenderPlugin = () => usePlugin<RenderPlugin>(RenderPlugin.id);\nexport const useRenderCapability = () => useCapability<RenderPlugin>(RenderPlugin.id);\n","import { Fragment, useEffect, useRef, useState } from '@framework';\nimport type { CSSProperties, HTMLAttributes } from '@framework';\n\nimport { ignore, PdfErrorCode } from '@embedpdf/models';\n\nimport { useRenderCapability } from '../hooks/use-render';\n\ntype RenderLayerProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {\n pageIndex: number;\n scaleFactor?: number;\n dpr?: number;\n style?: CSSProperties;\n};\n\nexport function RenderLayer({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n style,\n ...props\n}: RenderLayerProps) {\n const { provides: renderProvides } = useRenderCapability();\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (renderProvides) {\n const task = renderProvides.renderPage({ pageIndex, scaleFactor, dpr });\n task.wait((blob) => {\n const url = URL.createObjectURL(blob);\n setImageUrl(url);\n urlRef.current = url;\n }, ignore);\n\n return () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n };\n }\n }, [pageIndex, scaleFactor, dpr, renderProvides]);\n\n const handleImageLoad = () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n }\n };\n\n return (\n <Fragment>\n {imageUrl && (\n <img\n src={imageUrl}\n onLoad={handleImageLoad}\n {...props}\n style={{\n width: '100%',\n height: '100%',\n ...(style || {}),\n }}\n />\n )}\n </Fragment>\n );\n}\n"],"names":["useRenderCapability","useCapability","RenderPlugin","id","pageIndex","scaleFactor","dpr","style","props","provides","renderProvides","imageUrl","setImageUrl","useState","urlRef","useRef","useEffect","task","renderPage","wait","blob","url","URL","createObjectURL","current","ignore","revokeObjectURL","abort","code","PdfErrorCode","Cancelled","message","jsx","Fragment","children","jsxRuntime","src","onLoad","width","height","usePlugin"],"mappings":"0QAIaA,EAAsB,IAAMC,gBAA4BC,EAAAA,aAAaC,wBCU3E,UAAqBC,UAC1BA,EAAAC,YACAA,EAAc,EAAAC,IACdA,EAAM,EAAAC,MACNA,KACGC,IAEH,MAAQC,SAAUC,GAAmBV,KAC9BW,EAAUC,GAAeC,EAAAA,SAAwB,MAClDC,EAASC,SAAsB,MAiCnC,OA/BFC,EAAAA,WAAU,KACR,GAAIN,EAAgB,CAClB,MAAMO,EAAOP,EAAeQ,WAAW,CAAEd,YAAWC,cAAaC,QAOjE,OANKW,EAAAE,MAAMC,IACH,MAAAC,EAAMC,IAAIC,gBAAgBH,GAChCR,EAAYS,GACZP,EAAOU,QAAUH,CAAA,GAChBI,UAEI,KACDX,EAAOU,SACLF,IAAAI,gBAAgBZ,EAAOU,SAC3BV,EAAOU,QAAU,MAEjBP,EAAKU,MAAM,CACTC,KAAMC,EAAaA,aAAAC,UACnBC,QAAS,wBACV,CAEL,IAED,CAAC3B,EAAWC,EAAaC,EAAKI,MAU/BsB,IAACC,YACEC,SACCvB,GAAAwB,EAAAH,IAAC,MAAA,CACCI,IAAKzB,EACL0B,OAZgB,KAClBvB,EAAOU,UACLF,IAAAI,gBAAgBZ,EAAOU,SAC3BV,EAAOU,QAAU,KAAA,KAUThB,EACJD,MAAO,CACL+B,MAAO,OACPC,OAAQ,UACJhC,GAAS,CAAA,MAMzB,wDDpE+B,IAAMiC,YAAwBtC,EAAAA,aAAaC"}
@@ -1,26 +1 @@
1
- import * as _embedpdf_plugin_render from '@embedpdf/plugin-render';
2
- import { RenderPlugin } from '@embedpdf/plugin-render';
3
- import { JSX } from 'preact';
4
-
5
- declare const useRenderPlugin: () => {
6
- plugin: RenderPlugin | null;
7
- isLoading: boolean;
8
- ready: Promise<void>;
9
- };
10
- declare const useRenderCapability: () => {
11
- provides: Readonly<_embedpdf_plugin_render.RenderCapability> | null;
12
- isLoading: boolean;
13
- ready: Promise<void>;
14
- };
15
-
16
- /** @jsxImportSource preact */
17
-
18
- type RenderLayoutProps = Omit<JSX.HTMLAttributes<HTMLImageElement>, 'style'> & {
19
- pageIndex: number;
20
- scaleFactor?: number;
21
- dpr?: number;
22
- style?: JSX.CSSProperties;
23
- };
24
- declare function RenderLayer({ pageIndex, scaleFactor, dpr, style, ...props }: RenderLayoutProps): JSX.Element;
25
-
26
- export { RenderLayer, useRenderCapability, useRenderPlugin };
1
+ export * from '../shared-preact';
@@ -1,14 +1,11 @@
1
- // src/preact/hooks/use-render.ts
2
- import { useCapability, usePlugin } from "@embedpdf/core/preact";
3
- import { RenderPlugin } from "@embedpdf/plugin-render";
4
- var useRenderPlugin = () => usePlugin(RenderPlugin.id);
5
- var useRenderCapability = () => useCapability(RenderPlugin.id);
6
-
7
- // src/preact/components/render-layer.tsx
1
+ import { jsx } from "preact/jsx-runtime";
8
2
  import { Fragment } from "preact";
9
- import { useEffect, useRef, useState } from "preact/hooks";
3
+ import { useState, useRef, useEffect } from "preact/hooks";
10
4
  import { ignore, PdfErrorCode } from "@embedpdf/models";
11
- import { jsx } from "preact/jsx-runtime";
5
+ import { usePlugin, useCapability } from "@embedpdf/core/preact";
6
+ import { RenderPlugin } from "@embedpdf/plugin-render";
7
+ const useRenderPlugin = () => usePlugin(RenderPlugin.id);
8
+ const useRenderCapability = () => useCapability(RenderPlugin.id);
12
9
  function RenderLayer({
13
10
  pageIndex,
14
11
  scaleFactor = 1,
@@ -65,4 +62,4 @@ export {
65
62
  useRenderCapability,
66
63
  useRenderPlugin
67
64
  };
68
- //# sourceMappingURL=index.js.map
65
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/preact/hooks/use-render.ts","../../src/preact/components/render-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { RenderPlugin } from '@embedpdf/plugin-render';\n\nexport const useRenderPlugin = () => usePlugin<RenderPlugin>(RenderPlugin.id);\nexport const useRenderCapability = () => useCapability<RenderPlugin>(RenderPlugin.id);\n","/** @jsxImportSource preact */\nimport { Fragment, JSX } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { ignore, PdfErrorCode } from '@embedpdf/models';\n\nimport { useRenderCapability } from '../hooks/use-render';\n\ntype RenderLayoutProps = Omit<JSX.HTMLAttributes<HTMLImageElement>, 'style'> & {\n pageIndex: number;\n scaleFactor?: number;\n dpr?: number;\n style?: JSX.CSSProperties;\n};\n\nexport function RenderLayer({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n style,\n ...props\n}: RenderLayoutProps) {\n const { provides: renderProvides } = useRenderCapability();\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (renderProvides) {\n const task = renderProvides.renderPage({ pageIndex, scaleFactor, dpr });\n task.wait((blob) => {\n const url = URL.createObjectURL(blob);\n setImageUrl(url);\n urlRef.current = url;\n }, ignore);\n\n return () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n };\n }\n }, [pageIndex, scaleFactor, dpr, renderProvides]);\n\n const handleImageLoad = () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n }\n };\n\n return (\n <Fragment>\n {imageUrl && (\n <img\n src={imageUrl}\n onLoad={handleImageLoad}\n {...props}\n style={{\n width: '100%',\n height: '100%',\n ...(style || {}),\n }}\n />\n )}\n </Fragment>\n );\n}\n"],"mappings":";AAAA,SAAS,eAAe,iBAAiB;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,SAAS,CAAC;AAAA,MAChB;AAAA;AAAA,EACF,GAEJ;AAEJ;","names":[]}
1
+ {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-render.ts","../../src/shared/components/render-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { RenderPlugin } from '@embedpdf/plugin-render';\n\nexport const useRenderPlugin = () => usePlugin<RenderPlugin>(RenderPlugin.id);\nexport const useRenderCapability = () => useCapability<RenderPlugin>(RenderPlugin.id);\n","import { Fragment, useEffect, useRef, useState } from '@framework';\nimport type { CSSProperties, HTMLAttributes } from '@framework';\n\nimport { ignore, PdfErrorCode } from '@embedpdf/models';\n\nimport { useRenderCapability } from '../hooks/use-render';\n\ntype RenderLayerProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {\n pageIndex: number;\n scaleFactor?: number;\n dpr?: number;\n style?: CSSProperties;\n};\n\nexport function RenderLayer({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n style,\n ...props\n}: RenderLayerProps) {\n const { provides: renderProvides } = useRenderCapability();\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (renderProvides) {\n const task = renderProvides.renderPage({ pageIndex, scaleFactor, dpr });\n task.wait((blob) => {\n const url = URL.createObjectURL(blob);\n setImageUrl(url);\n urlRef.current = url;\n }, ignore);\n\n return () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n };\n }\n }, [pageIndex, scaleFactor, dpr, renderProvides]);\n\n const handleImageLoad = () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n }\n };\n\n return (\n <Fragment>\n {imageUrl && (\n <img\n src={imageUrl}\n onLoad={handleImageLoad}\n {...props}\n style={{\n width: '100%',\n height: '100%',\n ...(style || {}),\n }}\n />\n )}\n </F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+ export { Fragment, useEffect, useRef, useState } from 'react';
2
+ export type { CSSProperties, HTMLAttributes } from 'react';
@@ -0,0 +1 @@
1
+ export * from '@embedpdf/core/react';
@@ -1,96 +1,2 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
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
- RenderLayer: () => RenderLayer,
24
- useRenderCapability: () => useRenderCapability,
25
- useRenderPlugin: () => useRenderPlugin
26
- });
27
- module.exports = __toCommonJS(react_exports);
28
-
29
- // src/react/hooks/use-render.ts
30
- var import_react = require("@embedpdf/core/react");
31
- var import_plugin_render = require("@embedpdf/plugin-render");
32
- var useRenderPlugin = () => (0, import_react.usePlugin)(import_plugin_render.RenderPlugin.id);
33
- var useRenderCapability = () => (0, import_react.useCapability)(import_plugin_render.RenderPlugin.id);
34
-
35
- // src/react/components/render-layer.tsx
36
- var import_react2 = require("react");
37
- var import_models = require("@embedpdf/models");
38
- var import_jsx_runtime = require("react/jsx-runtime");
39
- function RenderLayer({
40
- pageIndex,
41
- scaleFactor = 1,
42
- dpr = 1,
43
- style,
44
- ...props
45
- }) {
46
- const { provides: renderProvides } = useRenderCapability();
47
- const [imageUrl, setImageUrl] = (0, import_react2.useState)(null);
48
- const urlRef = (0, import_react2.useRef)(null);
49
- (0, import_react2.useEffect)(() => {
50
- if (renderProvides) {
51
- const task = renderProvides.renderPage({ pageIndex, scaleFactor, dpr });
52
- task.wait((blob) => {
53
- const url = URL.createObjectURL(blob);
54
- setImageUrl(url);
55
- urlRef.current = url;
56
- }, import_models.ignore);
57
- return () => {
58
- if (urlRef.current) {
59
- URL.revokeObjectURL(urlRef.current);
60
- urlRef.current = null;
61
- } else {
62
- task.abort({
63
- code: import_models.PdfErrorCode.Cancelled,
64
- message: "canceled render task"
65
- });
66
- }
67
- };
68
- }
69
- }, [pageIndex, scaleFactor, dpr, renderProvides]);
70
- const handleImageLoad = () => {
71
- if (urlRef.current) {
72
- URL.revokeObjectURL(urlRef.current);
73
- urlRef.current = null;
74
- }
75
- };
76
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.Fragment, { children: imageUrl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
77
- "img",
78
- {
79
- src: imageUrl,
80
- onLoad: handleImageLoad,
81
- ...props,
82
- style: {
83
- width: "100%",
84
- height: "100%",
85
- ...style || {}
86
- }
87
- }
88
- ) });
89
- }
90
- // Annotate the CommonJS export names for ESM import in node:
91
- 0 && (module.exports = {
92
- RenderLayer,
93
- useRenderCapability,
94
- useRenderPlugin
95
- });
96
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),t=require("@embedpdf/models"),n=require("@embedpdf/core/react"),u=require("@embedpdf/plugin-render"),c=()=>n.useCapability(u.RenderPlugin.id);exports.RenderLayer=function({pageIndex:n,scaleFactor:u=1,dpr:d=1,style:s,...i}){const{provides:a}=c(),[l,o]=r.useState(null),p=r.useRef(null);return r.useEffect((()=>{if(a){const e=a.renderPage({pageIndex:n,scaleFactor:u,dpr:d});return e.wait((e=>{const r=URL.createObjectURL(e);o(r),p.current=r}),t.ignore),()=>{p.current?(URL.revokeObjectURL(p.current),p.current=null):e.abort({code:t.PdfErrorCode.Cancelled,message:"canceled render task"})}}}),[n,u,d,a]),e.jsx(r.Fragment,{children:l&&e.jsx("img",{src:l,onLoad:()=>{p.current&&(URL.revokeObjectURL(p.current),p.current=null)},...i,style:{width:"100%",height:"100%",...s||{}}})})},exports.useRenderCapability=c,exports.useRenderPlugin=()=>n.usePlugin(u.RenderPlugin.id);
2
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react/index.ts","../../src/react/hooks/use-render.ts","../../src/react/components/render-layer.tsx"],"sourcesContent":["export * from './hooks';\nexport * from './components';\n","import { useCapability, usePlugin } from '@embedpdf/core/react';\nimport { RenderPlugin } from '@embedpdf/plugin-render';\n\nexport const useRenderPlugin = () => usePlugin<RenderPlugin>(RenderPlugin.id);\nexport const useRenderCapability = () => useCapability<RenderPlugin>(RenderPlugin.id);\n","import { Fragment, useEffect, useRef, useState } from 'react';\nimport { ignore, PdfErrorCode } from '@embedpdf/models';\n\nimport { useRenderCapability } from '../hooks/use-render';\n\ntype RenderLayoutProps = Omit<React.HTMLAttributes<HTMLImageElement>, 'style'> & {\n pageIndex: number;\n scaleFactor?: number;\n dpr?: number;\n style?: React.CSSProperties;\n};\n\nexport function RenderLayer({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n style,\n ...props\n}: RenderLayoutProps) {\n const { provides: renderProvides } = useRenderCapability();\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (renderProvides) {\n const task = renderProvides.renderPage({ pageIndex, scaleFactor, dpr });\n task.wait((blob) => {\n const url = URL.createObjectURL(blob);\n setImageUrl(url);\n urlRef.current = url;\n }, ignore);\n\n return () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n };\n }\n }, [pageIndex, scaleFactor, dpr, renderProvides]);\n\n const handleImageLoad = () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n }\n };\n\n return (\n <Fragment>\n {imageUrl && (\n <img\n src={imageUrl}\n onLoad={handleImageLoad}\n {...props}\n style={{\n width: '100%',\n height: '100%',\n ...(style || {}),\n }}\n />\n )}\n </Fragment>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAyC;AACzC,2BAA6B;AAEtB,IAAM,kBAAkB,UAAM,wBAAwB,kCAAa,EAAE;AACrE,IAAM,sBAAsB,UAAM,4BAA4B,kCAAa,EAAE;;;ACJpF,IAAAA,gBAAsD;AACtD,oBAAqC;AAuD7B;AA5CD,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA,cAAc;AAAA,EACd,MAAM;AAAA,EACN;AAAA,EACA,GAAG;AACL,GAAsB;AACpB,QAAM,EAAE,UAAU,eAAe,IAAI,oBAAoB;AACzD,QAAM,CAAC,UAAU,WAAW,QAAI,wBAAwB,IAAI;AAC5D,QAAM,aAAS,sBAAsB,IAAI;AAEzC,+BAAU,MAAM;AACd,QAAI,gBAAgB;AAClB,YAAM,OAAO,eAAe,WAAW,EAAE,WAAW,aAAa,IAAI,CAAC;AACtE,WAAK,KAAK,CAAC,SAAS;AAClB,cAAM,MAAM,IAAI,gBAAgB,IAAI;AACpC,oBAAY,GAAG;AACf,eAAO,UAAU;AAAA,MACnB,GAAG,oBAAM;AAET,aAAO,MAAM;AACX,YAAI,OAAO,SAAS;AAClB,cAAI,gBAAgB,OAAO,OAAO;AAClC,iBAAO,UAAU;AAAA,QACnB,OAAO;AACL,eAAK,MAAM;AAAA,YACT,MAAM,2BAAa;AAAA,YACnB,SAAS;AAAA,UACX,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF,GAAG,CAAC,WAAW,aAAa,KAAK,cAAc,CAAC;AAEhD,QAAM,kBAAkB,MAAM;AAC5B,QAAI,OAAO,SAAS;AAClB,UAAI,gBAAgB,OAAO,OAAO;AAClC,aAAO,UAAU;AAAA,IACnB;AAAA,EACF;AAEA,SACE,4CAAC,0BACE,sBACC;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL,QAAQ;AAAA,MACP,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,GAAI,SAAS,CAAC;AAAA,MAChB;AAAA;AAAA,EACF,GAEJ;AAEJ;","names":["import_react"]}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-render.ts","../../src/shared/components/render-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { RenderPlugin } from '@embedpdf/plugin-render';\n\nexport const useRenderPlugin = () => usePlugin<RenderPlugin>(RenderPlugin.id);\nexport const useRenderCapability = () => useCapability<RenderPlugin>(RenderPlugin.id);\n","import { Fragment, useEffect, useRef, useState } from '@framework';\nimport type { CSSProperties, HTMLAttributes } from '@framework';\n\nimport { ignore, PdfErrorCode } from '@embedpdf/models';\n\nimport { useRenderCapability } from '../hooks/use-render';\n\ntype RenderLayerProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {\n pageIndex: number;\n scaleFactor?: number;\n dpr?: number;\n style?: CSSProperties;\n};\n\nexport function RenderLayer({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n style,\n ...props\n}: RenderLayerProps) {\n const { provides: renderProvides } = useRenderCapability();\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (renderProvides) {\n const task = renderProvides.renderPage({ pageIndex, scaleFactor, dpr });\n task.wait((blob) => {\n const url = URL.createObjectURL(blob);\n setImageUrl(url);\n urlRef.current = url;\n }, ignore);\n\n return () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n };\n }\n }, [pageIndex, scaleFactor, dpr, renderProvides]);\n\n const handleImageLoad = () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n }\n };\n\n return (\n <Fragment>\n {imageUrl && (\n <img\n src={imageUrl}\n onLoad={handleImageLoad}\n {...props}\n style={{\n width: '100%',\n height: '100%',\n ...(style || {}),\n }}\n />\n )}\n </Fragment>\n );\n}\n"],"names":["useRenderCapability","useCapability","RenderPlugin","id","pageIndex","scaleFactor","dpr","style","props","provides","renderProvides","imageUrl","setImageUrl","useState","urlRef","useRef","useEffect","task","renderPage","wait","blob","url","URL","createObjectURL","current","ignore","revokeObjectURL","abort","code","PdfErrorCode","Cancelled","message","jsx","Fragment","children","jsxRuntime","src","onLoad","width","height","usePlugin"],"mappings":"6OAIaA,EAAsB,IAAMC,gBAA4BC,EAAAA,aAAaC,wBCU3E,UAAqBC,UAC1BA,EAAAC,YACAA,EAAc,EAAAC,IACdA,EAAM,EAAAC,MACNA,KACGC,IAEH,MAAQC,SAAUC,GAAmBV,KAC9BW,EAAUC,GAAeC,EAAAA,SAAwB,MAClDC,EAASC,SAAsB,MAiCnC,OA/BFC,EAAAA,WAAU,KACR,GAAIN,EAAgB,CAClB,MAAMO,EAAOP,EAAeQ,WAAW,CAAEd,YAAWC,cAAaC,QAOjE,OANKW,EAAAE,MAAMC,IACH,MAAAC,EAAMC,IAAIC,gBAAgBH,GAChCR,EAAYS,GACZP,EAAOU,QAAUH,CAAA,GAChBI,UAEI,KACDX,EAAOU,SACLF,IAAAI,gBAAgBZ,EAAOU,SAC3BV,EAAOU,QAAU,MAEjBP,EAAKU,MAAM,CACTC,KAAMC,EAAaA,aAAAC,UACnBC,QAAS,wBACV,CAEL,IAED,CAAC3B,EAAWC,EAAaC,EAAKI,MAU/BsB,IAACC,YACEC,SACCvB,GAAAwB,EAAAH,IAAC,MAAA,CACCI,IAAKzB,EACL0B,OAZgB,KAClBvB,EAAOU,UACLF,IAAAI,gBAAgBZ,EAAOU,SAC3BV,EAAOU,QAAU,KAAA,KAUThB,EACJD,MAAO,CACL+B,MAAO,OACPC,OAAQ,UACJhC,GAAS,CAAA,MAMzB,wDDpE+B,IAAMiC,YAAwBtC,EAAAA,aAAaC"}
@@ -1,24 +1 @@
1
- import * as _embedpdf_plugin_render from '@embedpdf/plugin-render';
2
- import { RenderPlugin } from '@embedpdf/plugin-render';
3
- import * as react_jsx_runtime from 'react/jsx-runtime';
4
-
5
- declare const useRenderPlugin: () => {
6
- plugin: RenderPlugin | null;
7
- isLoading: boolean;
8
- ready: Promise<void>;
9
- };
10
- declare const useRenderCapability: () => {
11
- provides: Readonly<_embedpdf_plugin_render.RenderCapability> | null;
12
- isLoading: boolean;
13
- ready: Promise<void>;
14
- };
15
-
16
- type RenderLayoutProps = Omit<React.HTMLAttributes<HTMLImageElement>, 'style'> & {
17
- pageIndex: number;
18
- scaleFactor?: number;
19
- dpr?: number;
20
- style?: React.CSSProperties;
21
- };
22
- declare function RenderLayer({ pageIndex, scaleFactor, dpr, style, ...props }: RenderLayoutProps): react_jsx_runtime.JSX.Element;
23
-
24
- export { RenderLayer, useRenderCapability, useRenderPlugin };
1
+ export * from '../shared-react';
@@ -1,13 +1,10 @@
1
- // src/react/hooks/use-render.ts
2
- import { useCapability, usePlugin } from "@embedpdf/core/react";
3
- import { RenderPlugin } from "@embedpdf/plugin-render";
4
- var useRenderPlugin = () => usePlugin(RenderPlugin.id);
5
- var useRenderCapability = () => useCapability(RenderPlugin.id);
6
-
7
- // src/react/components/render-layer.tsx
8
- import { Fragment, useEffect, useRef, useState } from "react";
9
- import { ignore, PdfErrorCode } from "@embedpdf/models";
10
1
  import { jsx } from "react/jsx-runtime";
2
+ import { useState, useRef, useEffect, Fragment } from "react";
3
+ import { ignore, PdfErrorCode } from "@embedpdf/models";
4
+ import { usePlugin, useCapability } from "@embedpdf/core/react";
5
+ import { RenderPlugin } from "@embedpdf/plugin-render";
6
+ const useRenderPlugin = () => usePlugin(RenderPlugin.id);
7
+ const useRenderCapability = () => useCapability(RenderPlugin.id);
11
8
  function RenderLayer({
12
9
  pageIndex,
13
10
  scaleFactor = 1,
@@ -64,4 +61,4 @@ export {
64
61
  useRenderCapability,
65
62
  useRenderPlugin
66
63
  };
67
- //# sourceMappingURL=index.js.map
64
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react/hooks/use-render.ts","../../src/react/components/render-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/react';\nimport { RenderPlugin } from '@embedpdf/plugin-render';\n\nexport const useRenderPlugin = () => usePlugin<RenderPlugin>(RenderPlugin.id);\nexport const useRenderCapability = () => useCapability<RenderPlugin>(RenderPlugin.id);\n","import { Fragment, useEffect, useRef, useState } from 'react';\nimport { ignore, PdfErrorCode } from '@embedpdf/models';\n\nimport { useRenderCapability } from '../hooks/use-render';\n\ntype RenderLayoutProps = Omit<React.HTMLAttributes<HTMLImageElement>, 'style'> & {\n pageIndex: number;\n scaleFactor?: number;\n dpr?: number;\n style?: React.CSSProperties;\n};\n\nexport function RenderLayer({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n style,\n ...props\n}: RenderLayoutProps) {\n const { provides: renderProvides } = useRenderCapability();\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (renderProvides) {\n const task = renderProvides.renderPage({ pageIndex, scaleFactor, dpr });\n task.wait((blob) => {\n const url = URL.createObjectURL(blob);\n setImageUrl(url);\n urlRef.current = url;\n }, ignore);\n\n return () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n };\n }\n }, [pageIndex, scaleFactor, dpr, renderProvides]);\n\n const handleImageLoad = () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n }\n };\n\n return (\n <Fragment>\n {imageUrl && (\n <img\n src={imageUrl}\n onLoad={handleImageLoad}\n {...props}\n style={{\n width: '100%',\n height: '100%',\n ...(style || {}),\n }}\n />\n )}\n </Fragment>\n );\n}\n"],"mappings":";AAAA,SAAS,eAAe,iBAAiB;AACzC,SAAS,oBAAoB;AAEtB,IAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,IAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;;;ACJpF,SAAS,UAAU,WAAW,QAAQ,gBAAgB;AACtD,SAAS,QAAQ,oBAAoB;AAuD7B;AA5CD,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA,cAAc;AAAA,EACd,MAAM;AAAA,EACN;AAAA,EACA,GAAG;AACL,GAAsB;AACpB,QAAM,EAAE,UAAU,eAAe,IAAI,oBAAoB;AACzD,QAAM,CAAC,UAAU,WAAW,IAAI,SAAwB,IAAI;AAC5D,QAAM,SAAS,OAAsB,IAAI;AAEzC,YAAU,MAAM;AACd,QAAI,gBAAgB;AAClB,YAAM,OAAO,eAAe,WAAW,EAAE,WAAW,aAAa,IAAI,CAAC;AACtE,WAAK,KAAK,CAAC,SAAS;AAClB,cAAM,MAAM,IAAI,gBAAgB,IAAI;AACpC,oBAAY,GAAG;AACf,eAAO,UAAU;AAAA,MACnB,GAAG,MAAM;AAET,aAAO,MAAM;AACX,YAAI,OAAO,SAAS;AAClB,cAAI,gBAAgB,OAAO,OAAO;AAClC,iBAAO,UAAU;AAAA,QACnB,OAAO;AACL,eAAK,MAAM;AAAA,YACT,MAAM,aAAa;AAAA,YACnB,SAAS;AAAA,UACX,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF,GAAG,CAAC,WAAW,aAAa,KAAK,cAAc,CAAC;AAEhD,QAAM,kBAAkB,MAAM;AAC5B,QAAI,OAAO,SAAS;AAClB,UAAI,gBAAgB,OAAO,OAAO;AAClC,aAAO,UAAU;AAAA,IACnB;AAAA,EACF;AAEA,SACE,oBAAC,YACE,sBACC;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL,QAAQ;AAAA,MACP,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,GAAI,SAAS,CAAC;AAAA,MAChB;AAAA;AAAA,EACF,GAEJ;AAEJ;","names":[]}
1
+ {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-render.ts","../../src/shared/components/render-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { RenderPlugin } from '@embedpdf/plugin-render';\n\nexport const useRenderPlugin = () => usePlugin<RenderPlugin>(RenderPlugin.id);\nexport const useRenderCapability = () => useCapability<RenderPlugin>(RenderPlugin.id);\n","import { Fragment, useEffect, useRef, useState } from '@framework';\nimport type { CSSProperties, HTMLAttributes } from '@framework';\n\nimport { ignore, PdfErrorCode } from '@embedpdf/models';\n\nimport { useRenderCapability } from '../hooks/use-render';\n\ntype RenderLayerProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {\n pageIndex: number;\n scaleFactor?: number;\n dpr?: number;\n style?: CSSProperties;\n};\n\nexport function RenderLayer({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n style,\n ...props\n}: RenderLayerProps) {\n const { provides: renderProvides } = useRenderCapability();\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (renderProvides) {\n const task = renderProvides.renderPage({ pageIndex, scaleFactor, dpr });\n task.wait((blob) => {\n const url = URL.createObjectURL(blob);\n setImageUrl(url);\n urlRef.current = url;\n }, ignore);\n\n return () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n };\n }\n }, [pageIndex, scaleFactor, dpr, renderProvides]);\n\n const handleImageLoad = () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n }\n };\n\n return (\n <Fragment>\n {imageUrl && (\n <img\n src={imageUrl}\n onLoad={handleImageLoad}\n {...props}\n style={{\n width: '100%',\n height: '100%',\n ...(style || {}),\n }}\n />\n )}\n </Fragment>\n );\n}\n"],"names":[],"mappings":";;;;;AAGO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;ACU7E,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA,cAAc;AAAA,EACd,MAAM;AAAA,EACN;AAAA,EACA,GAAG;AACL,GAAqB;AACnB,QAAM,EAAE,UAAU,eAAe,IAAI,oBAAoB;AACzD,QAAM,CAAC,UAAU,WAAW,IAAI,SAAwB,IAAI;AACtD,QAAA,SAAS,OAAsB,IAAI;AAEzC,YAAU,MAAM;AACd,QAAI,gBAAgB;AAClB,YAAM,OAAO,eAAe,WAAW,EAAE,WAAW,aAAa,KAAK;AACjE,WAAA,KAAK,CAAC,SAAS;AACZ,cAAA,MAAM,IAAI,gBAAgB,IAAI;AACpC,oBAAY,GAAG;AACf,eAAO,UAAU;AAAA,SAChB,MAAM;AAET,aAAO,MAAM;AACX,YAAI,OAAO,SAAS;AACd,cAAA,gBAAgB,OAAO,OAAO;AAClC,iBAAO,UAAU;AAAA,QAAA,OACZ;AACL,eAAK,MAAM;AAAA,YACT,MAAM,aAAa;AAAA,YACnB,SAAS;AAAA,UAAA,CACV;AAAA,QAAA;AAAA,MAEL;AAAA,IAAA;AAAA,KAED,CAAC,WAAW,aAAa,KAAK,cAAc,CAAC;AAEhD,QAAM,kBAAkB,MAAM;AAC5B,QAAI,OAAO,SAAS;AACd,UAAA,gBAAgB,OAAO,OAAO;AAClC,aAAO,UAAU;AAAA,IAAA;AAAA,EAErB;AAGE,SAAA,oBAAC,YACE,UACC,YAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAK;AAAA,MACL,QAAQ;AAAA,MACP,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,GAAI,SAAS,CAAA;AAAA,MAAC;AAAA,IAChB;AAAA,EAAA,GAGN;AAEJ;"}
@@ -0,0 +1 @@
1
+ export * from './render-layer';
@@ -0,0 +1,9 @@
1
+ import { CSSProperties, HTMLAttributes } from '../../preact/adapter.ts';
2
+ type RenderLayerProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {
3
+ pageIndex: number;
4
+ scaleFactor?: number;
5
+ dpr?: number;
6
+ style?: CSSProperties;
7
+ };
8
+ export declare function RenderLayer({ pageIndex, scaleFactor, dpr, style, ...props }: RenderLayerProps): import("preact").JSX.Element;
9
+ export {};
@@ -0,0 +1 @@
1
+ export * from './use-render';
@@ -0,0 +1,11 @@
1
+ import { RenderPlugin } from '../../lib/index.ts';
2
+ export declare const useRenderPlugin: () => {
3
+ plugin: RenderPlugin | null;
4
+ isLoading: boolean;
5
+ ready: Promise<void>;
6
+ };
7
+ export declare const useRenderCapability: () => {
8
+ provides: Readonly<import('../../lib/index.ts').RenderCapability> | null;
9
+ isLoading: boolean;
10
+ ready: Promise<void>;
11
+ };
@@ -0,0 +1,2 @@
1
+ export * from './components';
2
+ export * from './hooks';
@@ -0,0 +1 @@
1
+ export * from './render-layer';
@@ -0,0 +1,9 @@
1
+ import { CSSProperties, HTMLAttributes } from '../../react/adapter.ts';
2
+ type RenderLayerProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {
3
+ pageIndex: number;
4
+ scaleFactor?: number;
5
+ dpr?: number;
6
+ style?: CSSProperties;
7
+ };
8
+ export declare function RenderLayer({ pageIndex, scaleFactor, dpr, style, ...props }: RenderLayerProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1 @@
1
+ export * from './use-render';
@@ -0,0 +1,11 @@
1
+ import { RenderPlugin } from '../../lib/index.ts';
2
+ export declare const useRenderPlugin: () => {
3
+ plugin: RenderPlugin | null;
4
+ isLoading: boolean;
5
+ ready: Promise<void>;
6
+ };
7
+ export declare const useRenderCapability: () => {
8
+ provides: Readonly<import('../../lib/index.ts').RenderCapability> | null;
9
+ isLoading: boolean;
10
+ ready: Promise<void>;
11
+ };
@@ -0,0 +1,2 @@
1
+ export * from './components';
2
+ export * from './hooks';
@@ -0,0 +1 @@
1
+ export { default as RenderLayer } from './render-layer.vue';
@@ -0,0 +1,10 @@
1
+ interface Props {
2
+ pageIndex: number;
3
+ scaleFactor?: number;
4
+ dpr?: number;
5
+ }
6
+ declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {
7
+ scaleFactor: number;
8
+ dpr: number;
9
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
10
+ export default _default;
@@ -0,0 +1 @@
1
+ export * from './use-render';
@@ -0,0 +1,3 @@
1
+ import { RenderPlugin } from '../../lib/index.ts';
2
+ export declare const useRenderPlugin: () => import('@embedpdf/core/vue').PluginState<RenderPlugin>;
3
+ export declare const useRenderCapability: () => import('@embedpdf/core/vue').CapabilityState<Readonly<import('../../lib/index.ts').RenderCapability>>;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),r=require("@embedpdf/models"),n=require("@embedpdf/core/vue"),l=require("@embedpdf/plugin-render"),t=()=>n.useCapability(l.RenderPlugin.id),a=["src"],u=e.defineComponent({__name:"render-layer",props:{pageIndex:{},scaleFactor:{default:1},dpr:{default:1}},setup(n){const l=n,{provides:u}=t(),d=e.ref(null);let o=null,c=null;function i(){c&&!o&&c.abort({code:r.PdfErrorCode.Cancelled,message:"canceled render task"})}function s(){o&&(URL.revokeObjectURL(o),o=null)}return e.watch((()=>[l.pageIndex,l.scaleFactor,l.dpr,u.value]),(function(){if(i(),s(),d.value=null,c=null,!u.value)return;const e=u.value.renderPage({pageIndex:l.pageIndex,scaleFactor:l.scaleFactor,dpr:l.dpr});c=e,e.wait((e=>{o=URL.createObjectURL(e),d.value=o,c=null}),r.ignore)}),{immediate:!0}),e.onBeforeUnmount((()=>{i(),s()})),(r,n)=>d.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:d.value,style:{width:"100%",height:"100%"},onLoad:s},null,40,a)):e.createCommentVNode("",!0)}});exports.RenderLayer=u,exports.useRenderCapability=t,exports.useRenderPlugin=()=>n.usePlugin(l.RenderPlugin.id);
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/vue/hooks/use-render.ts","../../src/vue/components/render-layer.vue"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { RenderPlugin } from '@embedpdf/plugin-render';\n\nexport const useRenderPlugin = () => usePlugin<RenderPlugin>(RenderPlugin.id);\nexport const useRenderCapability = () => useCapability<RenderPlugin>(RenderPlugin.id);\n","<script setup lang=\"ts\">\nimport { ref, watch, onBeforeUnmount } from 'vue';\nimport { ignore, PdfErrorCode, PdfErrorReason, Task } from '@embedpdf/models';\n\nimport { useRenderCapability } from '../hooks';\n\ninterface Props {\n pageIndex: number;\n scaleFactor?: number;\n dpr?: number;\n}\n\nconst props = withDefaults(defineProps<Props>(), {\n scaleFactor: 1,\n dpr: 1,\n});\n\nconst { provides: renderProvides } = useRenderCapability();\n\nconst imageUrl = ref<string | null>(null);\nlet currentBlobUrl: string | null = null;\nlet currentTask: Task<Blob, PdfErrorReason> | null = null; // Track current render task\n\n/* ------------------------------------------ */\n/* Helper function to abort current task */\n/* ------------------------------------------ */\nfunction abortCurrentTask() {\n if (currentTask && !currentBlobUrl) {\n currentTask.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n}\n\n/* ------------------------------------------ */\n/* render whenever pageIndex/scale/dpr change */\n/* ------------------------------------------ */\nfunction revoke() {\n if (currentBlobUrl) {\n URL.revokeObjectURL(currentBlobUrl);\n currentBlobUrl = null;\n }\n}\n\nfunction startRender() {\n // Abort any existing task\n abortCurrentTask();\n\n revoke();\n imageUrl.value = null;\n currentTask = null;\n\n if (!renderProvides.value) return;\n\n const task = renderProvides.value.renderPage({\n pageIndex: props.pageIndex,\n scaleFactor: props.scaleFactor,\n dpr: props.dpr,\n });\n\n currentTask = task;\n\n task.wait((blob) => {\n currentBlobUrl = URL.createObjectURL(blob);\n imageUrl.value = currentBlobUrl;\n currentTask = null; // Task completed\n }, ignore);\n}\n\nwatch(() => [props.pageIndex, props.scaleFactor, props.dpr, renderProvides.value], startRender, {\n immediate: true,\n});\n\n/* ------------------------------------------ */\nonBeforeUnmount(() => {\n // Abort any pending task when component unmounts\n abortCurrentTask();\n revoke();\n});\n</script>\n\n<template>\n <img v-if=\"imageUrl\" :src=\"imageUrl\" :style=\"{ width: '100%', height: '100%' }\" @load=\"revoke\" />\n</template>\n"],"names":["useRenderCapability","useCapability","RenderPlugin","id","props","__props","provides","renderProvides","imageUrl","ref","currentBlobUrl","currentTask","abortCurrentTask","abort","code","PdfErrorCode","Cancelled","message","revoke","URL","revokeObjectURL","watch","pageIndex","scaleFactor","dpr","value","task","renderPage","wait","blob","createObjectURL","ignore","immediate","onBeforeUnmount","_createElementBlock","src","style","width","height","onLoad","usePlugin"],"mappings":"0MAIaA,EAAsB,IAAMC,gBAA4BC,EAAAA,aAAaC,+HCQlF,MAAMC,EAAQC,GAKNC,SAAUC,GAAmBP,IAE/BQ,EAAWC,MAAmB,MACpC,IAAIC,EAAgC,KAChCC,EAAiD,KAKrD,SAASC,IACHD,IAAgBD,GAClBC,EAAYE,MAAM,CAChBC,KAAMC,EAAaA,aAAAC,UACnBC,QAAS,wBAEb,CAMF,SAASC,IACHR,IACFS,IAAIC,gBAAgBV,GACHA,EAAA,KACnB,QA4BIW,EAAAA,OAAA,IAAM,CAACjB,EAAMkB,UAAWlB,EAAMmB,YAAanB,EAAMoB,IAAKjB,EAAekB,SAzB3E,WAQM,GANab,IAEVM,IACPV,EAASiB,MAAQ,KACHd,EAAA,MAETJ,EAAekB,MAAO,OAErB,MAAAC,EAAOnB,EAAekB,MAAME,WAAW,CAC3CL,UAAWlB,EAAMkB,UACjBC,YAAanB,EAAMmB,YACnBC,IAAKpB,EAAMoB,MAGCb,EAAAe,EAETA,EAAAE,MAAMC,IACQnB,EAAAS,IAAIW,gBAAgBD,GACrCrB,EAASiB,MAAQf,EACHC,EAAA,IAAA,GACboB,SAAM,GAGqF,CAC9FC,WAAW,IAIbC,EAAAA,iBAAgB,KAEGrB,IACVM,GAAA,WAKIV,EAAQiB,qBAAnBS,EAAAA,mBAAiG,MAAA,OAA3EC,IAAK3B,EAAQiB,MAAGW,MAAO,CAAiCC,MAAA,OAAAC,OAAA,QAAGC,OAAMrB,0HDhF1D,IAAMsB,YAAwBtC,EAAAA,aAAaC"}
@@ -0,0 +1,2 @@
1
+ export * from './components';
2
+ export * from './hooks';
@@ -0,0 +1,75 @@
1
+ import { defineComponent, ref, watch, onBeforeUnmount, createElementBlock, createCommentVNode, openBlock } from "vue";
2
+ import { ignore, PdfErrorCode } from "@embedpdf/models";
3
+ import { useCapability, usePlugin } from "@embedpdf/core/vue";
4
+ import { RenderPlugin } from "@embedpdf/plugin-render";
5
+ const useRenderPlugin = () => usePlugin(RenderPlugin.id);
6
+ const useRenderCapability = () => useCapability(RenderPlugin.id);
7
+ const _hoisted_1 = ["src"];
8
+ const _sfc_main = /* @__PURE__ */ defineComponent({
9
+ __name: "render-layer",
10
+ props: {
11
+ pageIndex: {},
12
+ scaleFactor: { default: 1 },
13
+ dpr: { default: 1 }
14
+ },
15
+ setup(__props) {
16
+ const props = __props;
17
+ const { provides: renderProvides } = useRenderCapability();
18
+ const imageUrl = ref(null);
19
+ let currentBlobUrl = null;
20
+ let currentTask = null;
21
+ function abortCurrentTask() {
22
+ if (currentTask && !currentBlobUrl) {
23
+ currentTask.abort({
24
+ code: PdfErrorCode.Cancelled,
25
+ message: "canceled render task"
26
+ });
27
+ }
28
+ }
29
+ function revoke() {
30
+ if (currentBlobUrl) {
31
+ URL.revokeObjectURL(currentBlobUrl);
32
+ currentBlobUrl = null;
33
+ }
34
+ }
35
+ function startRender() {
36
+ abortCurrentTask();
37
+ revoke();
38
+ imageUrl.value = null;
39
+ currentTask = null;
40
+ if (!renderProvides.value) return;
41
+ const task = renderProvides.value.renderPage({
42
+ pageIndex: props.pageIndex,
43
+ scaleFactor: props.scaleFactor,
44
+ dpr: props.dpr
45
+ });
46
+ currentTask = task;
47
+ task.wait((blob) => {
48
+ currentBlobUrl = URL.createObjectURL(blob);
49
+ imageUrl.value = currentBlobUrl;
50
+ currentTask = null;
51
+ }, ignore);
52
+ }
53
+ watch(() => [props.pageIndex, props.scaleFactor, props.dpr, renderProvides.value], startRender, {
54
+ immediate: true
55
+ });
56
+ onBeforeUnmount(() => {
57
+ abortCurrentTask();
58
+ revoke();
59
+ });
60
+ return (_ctx, _cache) => {
61
+ return imageUrl.value ? (openBlock(), createElementBlock("img", {
62
+ key: 0,
63
+ src: imageUrl.value,
64
+ style: { width: "100%", height: "100%" },
65
+ onLoad: revoke
66
+ }, null, 40, _hoisted_1)) : createCommentVNode("", true);
67
+ };
68
+ }
69
+ });
70
+ export {
71
+ _sfc_main as RenderLayer,
72
+ useRenderCapability,
73
+ useRenderPlugin
74
+ };
75
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/vue/hooks/use-render.ts","../../src/vue/components/render-layer.vue"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { RenderPlugin } from '@embedpdf/plugin-render';\n\nexport const useRenderPlugin = () => usePlugin<RenderPlugin>(RenderPlugin.id);\nexport const useRenderCapability = () => useCapability<RenderPlugin>(RenderPlugin.id);\n","<script setup lang=\"ts\">\nimport { ref, watch, onBeforeUnmount } from 'vue';\nimport { ignore, PdfErrorCode, PdfErrorReason, Task } from '@embedpdf/models';\n\nimport { useRenderCapability } from '../hooks';\n\ninterface Props {\n pageIndex: number;\n scaleFactor?: number;\n dpr?: number;\n}\n\nconst props = withDefaults(defineProps<Props>(), {\n scaleFactor: 1,\n dpr: 1,\n});\n\nconst { provides: renderProvides } = useRenderCapability();\n\nconst imageUrl = ref<string | null>(null);\nlet currentBlobUrl: string | null = null;\nlet currentTask: Task<Blob, PdfErrorReason> | null = null; // Track current render task\n\n/* ------------------------------------------ */\n/* Helper function to abort current task */\n/* ------------------------------------------ */\nfunction abortCurrentTask() {\n if (currentTask && !currentBlobUrl) {\n currentTask.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n}\n\n/* ------------------------------------------ */\n/* render whenever pageIndex/scale/dpr change */\n/* ------------------------------------------ */\nfunction revoke() {\n if (currentBlobUrl) {\n URL.revokeObjectURL(currentBlobUrl);\n currentBlobUrl = null;\n }\n}\n\nfunction startRender() {\n // Abort any existing task\n abortCurrentTask();\n\n revoke();\n imageUrl.value = null;\n currentTask = null;\n\n if (!renderProvides.value) return;\n\n const task = renderProvides.value.renderPage({\n pageIndex: props.pageIndex,\n scaleFactor: props.scaleFactor,\n dpr: props.dpr,\n });\n\n currentTask = task;\n\n task.wait((blob) => {\n currentBlobUrl = URL.createObjectURL(blob);\n imageUrl.value = currentBlobUrl;\n currentTask = null; // Task completed\n }, ignore);\n}\n\nwatch(() => [props.pageIndex, props.scaleFactor, props.dpr, renderProvides.value], startRender, {\n immediate: true,\n});\n\n/* ------------------------------------------ */\nonBeforeUnmount(() => {\n // Abort any pending task when component unmounts\n abortCurrentTask();\n revoke();\n});\n</script>\n\n<template>\n <img v-if=\"imageUrl\" :src=\"imageUrl\" :style=\"{ width: '100%', height: '100%' }\" @load=\"revoke\" />\n</template>\n"],"names":["_createElementBlock"],"mappings":";;;;AAGO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;;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main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -20,24 +20,28 @@
20
20
  "types": "./dist/react/index.d.ts",
21
21
  "import": "./dist/react/index.js",
22
22
  "require": "./dist/react/index.cjs"
23
+ },
24
+ "./vue": {
25
+ "types": "./dist/vue/index.d.ts",
26
+ "import": "./dist/vue/index.js",
27
+ "require": "./dist/vue/index.cjs"
23
28
  }
24
29
  },
25
30
  "dependencies": {
26
- "@embedpdf/models": "1.0.11"
31
+ "@embedpdf/models": "1.0.12"
27
32
  },
28
33
  "devDependencies": {
29
34
  "@types/react": "^18.2.0",
30
- "tsup": "^8.0.0",
31
35
  "typescript": "^5.0.0",
32
- "@embedpdf/plugin-loader": "1.0.11",
33
- "@embedpdf/core": "1.0.11"
36
+ "@embedpdf/build": "1.0.0",
37
+ "@embedpdf/core": "1.0.12"
34
38
  },
35
39
  "peerDependencies": {
40
+ "preact": "^10.26.4",
36
41
  "react": ">=16.8.0",
37
42
  "react-dom": ">=16.8.0",
38
- "preact": "^10.26.4",
39
- "@embedpdf/core": "1.0.11",
40
- "@embedpdf/plugin-loader": "1.0.11"
43
+ "vue": ">=3.2.0",
44
+ "@embedpdf/core": "1.0.12"
41
45
  },
42
46
  "files": [
43
47
  "dist",
@@ -56,11 +60,13 @@
56
60
  "access": "public"
57
61
  },
58
62
  "scripts": {
59
- "build": "PROJECT_CWD=$(pwd) pnpm -w p:build",
60
- "build:watch": "PROJECT_CWD=$(pwd) pnpm -w p:build:watch",
61
- "clean": "PROJECT_CWD=$(pwd) pnpm -w p:clean",
62
- "lint": "PROJECT_CWD=$(pwd) pnpm -w p:lint",
63
- "lint:fix": "PROJECT_CWD=$(pwd) pnpm -w p:lint:fix",
64
- "typecheck": "PROJECT_CWD=$(pwd) pnpm -w p:typecheck"
63
+ "build:base": "vite build --mode base",
64
+ "build:react": "vite build --mode react",
65
+ "build:preact": "vite build --mode preact",
66
+ "build:vue": "vite build --mode vue",
67
+ "build": "pnpm run clean && concurrently -c auto -n base,react,preact,vue \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\" \"vite build --mode vue\"",
68
+ "clean": "rimraf dist",
69
+ "lint": "eslint src --color",
70
+ "lint:fix": "eslint src --color --fix"
65
71
  }
66
72
  }
package/dist/index.d.cts DELETED
@@ -1,44 +0,0 @@
1
- import { BasePluginConfig, BasePlugin, PluginRegistry, PluginPackage } from '@embedpdf/core';
2
- import { Rotation, ImageConversionTypes, Task, PdfErrorReason, Rect, PdfEngine } from '@embedpdf/models';
3
-
4
- interface RenderPluginConfig extends BasePluginConfig {
5
- }
6
- interface RenderPageRectOptions {
7
- pageIndex: number;
8
- scaleFactor?: number;
9
- rotation?: Rotation;
10
- dpr?: number;
11
- rect: Rect;
12
- options?: {
13
- withAnnotations: boolean;
14
- };
15
- imageType?: ImageConversionTypes;
16
- }
17
- interface RenderPageOptions {
18
- pageIndex: number;
19
- scaleFactor?: number;
20
- dpr?: number;
21
- rotation?: Rotation;
22
- options?: {
23
- withAnnotations: boolean;
24
- };
25
- imageType?: ImageConversionTypes;
26
- }
27
- interface RenderCapability {
28
- renderPage: (options: RenderPageOptions) => Task<Blob, PdfErrorReason>;
29
- renderPageRect: (options: RenderPageRectOptions) => Task<Blob, PdfErrorReason>;
30
- }
31
-
32
- declare class RenderPlugin extends BasePlugin<RenderPluginConfig, RenderCapability> {
33
- static readonly id: "render";
34
- private engine;
35
- constructor(id: string, registry: PluginRegistry, engine: PdfEngine);
36
- initialize(_config: RenderPluginConfig): Promise<void>;
37
- protected buildCapability(): RenderCapability;
38
- private renderPage;
39
- private renderPageRect;
40
- }
41
-
42
- declare const RenderPluginPackage: PluginPackage<RenderPlugin, RenderPluginConfig>;
43
-
44
- export { type RenderCapability, type RenderPageOptions, type RenderPageRectOptions, RenderPlugin, type RenderPluginConfig, RenderPluginPackage };
@@ -1,26 +0,0 @@
1
- import * as _embedpdf_plugin_render from '@embedpdf/plugin-render';
2
- import { RenderPlugin } from '@embedpdf/plugin-render';
3
- import { JSX } from 'preact';
4
-
5
- declare const useRenderPlugin: () => {
6
- plugin: RenderPlugin | null;
7
- isLoading: boolean;
8
- ready: Promise<void>;
9
- };
10
- declare const useRenderCapability: () => {
11
- provides: Readonly<_embedpdf_plugin_render.RenderCapability> | null;
12
- isLoading: boolean;
13
- ready: Promise<void>;
14
- };
15
-
16
- /** @jsxImportSource preact */
17
-
18
- type RenderLayoutProps = Omit<JSX.HTMLAttributes<HTMLImageElement>, 'style'> & {
19
- pageIndex: number;
20
- scaleFactor?: number;
21
- dpr?: number;
22
- style?: JSX.CSSProperties;
23
- };
24
- declare function RenderLayer({ pageIndex, scaleFactor, dpr, style, ...props }: RenderLayoutProps): JSX.Element;
25
-
26
- export { RenderLayer, useRenderCapability, useRenderPlugin };
@@ -1,24 +0,0 @@
1
- import * as _embedpdf_plugin_render from '@embedpdf/plugin-render';
2
- import { RenderPlugin } from '@embedpdf/plugin-render';
3
- import * as react_jsx_runtime from 'react/jsx-runtime';
4
-
5
- declare const useRenderPlugin: () => {
6
- plugin: RenderPlugin | null;
7
- isLoading: boolean;
8
- ready: Promise<void>;
9
- };
10
- declare const useRenderCapability: () => {
11
- provides: Readonly<_embedpdf_plugin_render.RenderCapability> | null;
12
- isLoading: boolean;
13
- ready: Promise<void>;
14
- };
15
-
16
- type RenderLayoutProps = Omit<React.HTMLAttributes<HTMLImageElement>, 'style'> & {
17
- pageIndex: number;
18
- scaleFactor?: number;
19
- dpr?: number;
20
- style?: React.CSSProperties;
21
- };
22
- declare function RenderLayer({ pageIndex, scaleFactor, dpr, style, ...props }: RenderLayoutProps): react_jsx_runtime.JSX.Element;
23
-
24
- export { RenderLayer, useRenderCapability, useRenderPlugin };