@embedpdf/plugin-render 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -46,7 +46,8 @@ var RenderPlugin = class extends import_core.BasePlugin {
46
46
  scaleFactor = 1,
47
47
  dpr = 1,
48
48
  rotation = import_models.Rotation.Degree0,
49
- options = { withAnnotations: false }
49
+ options = { withAnnotations: false },
50
+ imageType = "image/webp"
50
51
  }) {
51
52
  const coreState = this.coreState.core;
52
53
  if (!coreState.document) {
@@ -56,7 +57,15 @@ var RenderPlugin = class extends import_core.BasePlugin {
56
57
  if (!page) {
57
58
  throw new Error("page does not exist");
58
59
  }
59
- return this.engine.renderPage(coreState.document, page, scaleFactor, rotation, dpr, options);
60
+ return this.engine.renderPage(
61
+ coreState.document,
62
+ page,
63
+ scaleFactor,
64
+ rotation,
65
+ dpr,
66
+ options,
67
+ imageType
68
+ );
60
69
  }
61
70
  renderPageRect({
62
71
  pageIndex,
@@ -64,7 +73,8 @@ var RenderPlugin = class extends import_core.BasePlugin {
64
73
  dpr = 1,
65
74
  rect,
66
75
  rotation = import_models.Rotation.Degree0,
67
- options = { withAnnotations: false }
76
+ options = { withAnnotations: false },
77
+ imageType = "image/webp"
68
78
  }) {
69
79
  const coreState = this.coreState.core;
70
80
  if (!coreState.document) {
@@ -81,7 +91,8 @@ var RenderPlugin = class extends import_core.BasePlugin {
81
91
  rotation,
82
92
  dpr,
83
93
  rect,
84
- options
94
+ options,
95
+ imageType
85
96
  );
86
97
  }
87
98
  };
@@ -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 }: 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(coreState.document, page, scaleFactor, rotation, dpr, options);\n }\n\n private renderPageRect({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n rect,\n rotation = Rotation.Degree0,\n options = { withAnnotations: false },\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 );\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;;;ACAA,kBAA2C;AAO3C,oBAAoC;AAE7B,IAAM,eAAN,cAA2B,uBAAiD;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,uBAAS;AAAA,IACpB,UAAU,EAAE,iBAAiB,MAAM;AAAA,EACrC,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,WAAW,UAAU,UAAU,MAAM,aAAa,UAAU,KAAK,OAAO;AAAA,EAC7F;AAAA,EAEQ,eAAe;AAAA,IACrB;AAAA,IACA,cAAc;AAAA,IACd,MAAM;AAAA,IACN;AAAA,IACA,WAAW,uBAAS;AAAA,IACpB,UAAU,EAAE,iBAAiB,MAAM;AAAA,EACrC,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,IACF;AAAA,EACF;AACF;AApEa,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,"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":";;;;;;;;;;;;;;;;;;;;AA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AS,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"]}
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { BasePluginConfig, BasePlugin, PluginRegistry, PluginPackage } from '@embedpdf/core';
2
- import { Rotation, Task, PdfErrorReason, Rect, PdfEngine } from '@embedpdf/models';
2
+ import { Rotation, ImageConversionTypes, Task, PdfErrorReason, Rect, PdfEngine } from '@embedpdf/models';
3
3
 
4
4
  interface RenderPluginConfig extends BasePluginConfig {
5
5
  }
@@ -12,6 +12,7 @@ interface RenderPageRectOptions {
12
12
  options?: {
13
13
  withAnnotations: boolean;
14
14
  };
15
+ imageType?: ImageConversionTypes;
15
16
  }
16
17
  interface RenderPageOptions {
17
18
  pageIndex: number;
@@ -21,6 +22,7 @@ interface RenderPageOptions {
21
22
  options?: {
22
23
  withAnnotations: boolean;
23
24
  };
25
+ imageType?: ImageConversionTypes;
24
26
  }
25
27
  interface RenderCapability {
26
28
  renderPage: (options: RenderPageOptions) => Task<Blob, PdfErrorReason>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { BasePluginConfig, BasePlugin, PluginRegistry, PluginPackage } from '@embedpdf/core';
2
- import { Rotation, Task, PdfErrorReason, Rect, PdfEngine } from '@embedpdf/models';
2
+ import { Rotation, ImageConversionTypes, Task, PdfErrorReason, Rect, PdfEngine } from '@embedpdf/models';
3
3
 
4
4
  interface RenderPluginConfig extends BasePluginConfig {
5
5
  }
@@ -12,6 +12,7 @@ interface RenderPageRectOptions {
12
12
  options?: {
13
13
  withAnnotations: boolean;
14
14
  };
15
+ imageType?: ImageConversionTypes;
15
16
  }
16
17
  interface RenderPageOptions {
17
18
  pageIndex: number;
@@ -21,6 +22,7 @@ interface RenderPageOptions {
21
22
  options?: {
22
23
  withAnnotations: boolean;
23
24
  };
25
+ imageType?: ImageConversionTypes;
24
26
  }
25
27
  interface RenderCapability {
26
28
  renderPage: (options: RenderPageOptions) => Task<Blob, PdfErrorReason>;
package/dist/index.js CHANGED
@@ -19,7 +19,8 @@ var RenderPlugin = class extends BasePlugin {
19
19
  scaleFactor = 1,
20
20
  dpr = 1,
21
21
  rotation = Rotation.Degree0,
22
- options = { withAnnotations: false }
22
+ options = { withAnnotations: false },
23
+ imageType = "image/webp"
23
24
  }) {
24
25
  const coreState = this.coreState.core;
25
26
  if (!coreState.document) {
@@ -29,7 +30,15 @@ var RenderPlugin = class extends BasePlugin {
29
30
  if (!page) {
30
31
  throw new Error("page does not exist");
31
32
  }
32
- return this.engine.renderPage(coreState.document, page, scaleFactor, rotation, dpr, options);
33
+ return this.engine.renderPage(
34
+ coreState.document,
35
+ page,
36
+ scaleFactor,
37
+ rotation,
38
+ dpr,
39
+ options,
40
+ imageType
41
+ );
33
42
  }
34
43
  renderPageRect({
35
44
  pageIndex,
@@ -37,7 +46,8 @@ var RenderPlugin = class extends BasePlugin {
37
46
  dpr = 1,
38
47
  rect,
39
48
  rotation = Rotation.Degree0,
40
- options = { withAnnotations: false }
49
+ options = { withAnnotations: false },
50
+ imageType = "image/webp"
41
51
  }) {
42
52
  const coreState = this.coreState.core;
43
53
  if (!coreState.document) {
@@ -54,7 +64,8 @@ var RenderPlugin = class extends BasePlugin {
54
64
  rotation,
55
65
  dpr,
56
66
  rect,
57
- options
67
+ options,
68
+ imageType
58
69
  );
59
70
  }
60
71
  };
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 }: 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(coreState.document, page, scaleFactor, rotation, dpr, options);\n }\n\n private renderPageRect({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n rect,\n rotation = Rotation.Degree0,\n options = { withAnnotations: false },\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 );\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,EACrC,GAAsB;AACpB,UAAM,YAAY,KAAK,UAAU;AAEjC,QAAI,CAAC,UAAU,UAAU;AACvB,YAAM,IAAI,MAAM,wBAAwB;A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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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-render",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -23,21 +23,21 @@
23
23
  }
24
24
  },
25
25
  "dependencies": {
26
- "@embedpdf/models": "1.0.4"
26
+ "@embedpdf/models": "1.0.6"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/react": "^18.2.0",
30
30
  "tsup": "^8.0.0",
31
31
  "typescript": "^5.0.0",
32
- "@embedpdf/core": "1.0.4",
33
- "@embedpdf/plugin-loader": "1.0.4"
32
+ "@embedpdf/plugin-loader": "1.0.6",
33
+ "@embedpdf/core": "1.0.6"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": ">=16.8.0",
37
37
  "react-dom": ">=16.8.0",
38
38
  "preact": "^10.26.4",
39
- "@embedpdf/core": "1.0.4",
40
- "@embedpdf/plugin-loader": "1.0.4"
39
+ "@embedpdf/core": "1.0.6",
40
+ "@embedpdf/plugin-loader": "1.0.6"
41
41
  },
42
42
  "files": [
43
43
  "dist",