@embedpdf/plugin-render 1.5.0 → 2.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=class extends e.BasePlugin{constructor(t,n){super(t,n),this.refreshPages$=e.createEmitter(),this.withForms=!1,this.withAnnotations=!1,this.coreStore.onAction(e.REFRESH_PAGES,(e=>{this.refreshPages$.emit(e.payload)}))}async initialize(e){this.withForms=e.withForms??!1,this.withAnnotations=e.withAnnotations??!1}buildCapability(){return{renderPage:this.renderPage.bind(this),renderPageRect:this.renderPageRect.bind(this)}}onRefreshPages(e){return this.refreshPages$.on(e)}renderPage({pageIndex:e,options:t}){const n=this.coreState.core;if(!n.document)throw new Error("document does not open");const i=n.document.pages.find((t=>t.index===e));if(!i)throw new Error("page does not exist");const o={...t??{},withForms:(null==t?void 0:t.withForms)??this.withForms,withAnnotations:(null==t?void 0:t.withAnnotations)??this.withAnnotations};return this.engine.renderPage(n.document,i,o)}renderPageRect({pageIndex:e,rect:t,options:n}){const i=this.coreState.core;if(!i.document)throw new Error("document does not open");const o=i.document.pages.find((t=>t.index===e));if(!o)throw new Error("page does not exist");const r={...n??{},withForms:(null==n?void 0:n.withForms)??this.withForms,withAnnotations:(null==n?void 0:n.withAnnotations)??this.withAnnotations};return this.engine.renderPageRect(i.document,o,t,r)}};t.id="render";let n=t;const i="render",o={manifest:{id:i,name:"Render Plugin",version:"1.0.0",provides:["render"],requires:[],optional:[],defaultConfig:{enabled:!0}},create:e=>new n(i,e),reducer:()=>{},initialState:{}};exports.RenderPlugin=n,exports.RenderPluginPackage=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=class extends e.BasePlugin{constructor(e,t,n){super(e,t),this.withForms=!1,this.withAnnotations=!1,this.withForms=(null==n?void 0:n.withForms)??!1,this.withAnnotations=(null==n?void 0:n.withAnnotations)??!1}buildCapability(){return{renderPage:e=>this.renderPage(e),renderPageRect:e=>this.renderPageRect(e),forDocument:e=>this.createRenderScope(e)}}createRenderScope(e){return{renderPage:t=>this.renderPage(t,e),renderPageRect:t=>this.renderPageRect(t,e)}}renderPage({pageIndex:e,options:t},n){const i=n??this.getActiveDocumentId(),o=this.coreState.core.documents[i];if(!(null==o?void 0:o.document))throw new Error(`Document ${i} not loaded`);const r=o.document.pages.find(t=>t.index===e);if(!r)throw new Error(`Page ${e} not found in document ${i}`);const s={...t??{},withForms:(null==t?void 0:t.withForms)??this.withForms,withAnnotations:(null==t?void 0:t.withAnnotations)??this.withAnnotations};return this.engine.renderPage(o.document,r,s)}renderPageRect({pageIndex:e,rect:t,options:n},i){const o=i??this.getActiveDocumentId(),r=this.coreState.core.documents[o];if(!(null==r?void 0:r.document))throw new Error(`Document ${o} not loaded`);const s=r.document.pages.find(t=>t.index===e);if(!s)throw new Error(`Page ${e} not found in document ${o}`);const d={...n??{},withForms:(null==n?void 0:n.withForms)??this.withForms,withAnnotations:(null==n?void 0:n.withAnnotations)??this.withAnnotations};return this.engine.renderPageRect(r.document,s,t,d)}async initialize(e){this.logger.info("RenderPlugin","Initialize","Render plugin initialized")}async destroy(){super.destroy()}};t.id="render";let n=t;const i="render",o={manifest:{id:i,name:"Render Plugin",version:"1.0.0",provides:["render"],requires:[],optional:[],defaultConfig:{enabled:!0}},create:(e,t)=>new n(i,e,t),reducer:()=>{},initialState:{}};exports.RenderPlugin=n,exports.RenderPluginPackage=o;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/lib/render-plugin.ts","../src/lib/manifest.ts","../src/lib/index.ts"],"sourcesContent":["import {\n BasePlugin,\n createEmitter,\n PluginRegistry,\n REFRESH_PAGES,\n Unsubscribe,\n} from '@embedpdf/core';\nimport {\n RenderCapability,\n RenderPageOptions,\n RenderPageRectOptions,\n RenderPluginConfig,\n} from './types';\n\nexport class RenderPlugin extends BasePlugin<RenderPluginConfig, RenderCapability> {\n static readonly id = 'render' as const;\n\n private readonly refreshPages$ = createEmitter<number[]>();\n private withForms = false;\n private withAnnotations = false;\n\n constructor(id: string, registry: PluginRegistry) {\n super(id, registry);\n\n this.coreStore.onAction(REFRESH_PAGES, (action) => {\n this.refreshPages$.emit(action.payload);\n });\n }\n\n async initialize(config: RenderPluginConfig): Promise<void> {\n this.withForms = config.withForms ?? false;\n this.withAnnotations = config.withAnnotations ?? false;\n }\n\n protected buildCapability(): RenderCapability {\n return {\n renderPage: this.renderPage.bind(this),\n renderPageRect: this.renderPageRect.bind(this),\n };\n }\n\n public onRefreshPages(fn: (pages: number[]) => void): Unsubscribe {\n return this.refreshPages$.on(fn);\n }\n\n private renderPage({ pageIndex, options }: 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 const mergedOptions = {\n ...(options ?? {}),\n withForms: options?.withForms ?? this.withForms,\n withAnnotations: options?.withAnnotations ?? this.withAnnotations,\n };\n\n return this.engine.renderPage(coreState.document, page, mergedOptions);\n }\n\n private renderPageRect({ pageIndex, rect, options }: 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 const mergedOptions = {\n ...(options ?? {}),\n withForms: options?.withForms ?? this.withForms,\n withAnnotations: options?.withAnnotations ?? this.withAnnotations,\n };\n\n return this.engine.renderPageRect(coreState.document, page, rect, mergedOptions);\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) => new RenderPlugin(RENDER_PLUGIN_ID, registry),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './render-plugin';\nexport * from './types';\n"],"names":["_RenderPlugin","BasePlugin","constructor","id","registry","super","this","refreshPages$","createEmitter","withForms","withAnnotations","coreStore","onAction","REFRESH_PAGES","action","emit","payload","initialize","config","buildCapability","renderPage","bind","renderPageRect","onRefreshPages","fn","on","pageIndex","options","coreState","core","document","Error","page","pages","find","index","mergedOptions","engine","rect","RenderPlugin","RENDER_PLUGIN_ID","RenderPluginPackage","manifest","name","version","provides","requires","optional","defaultConfig","enabled","create","reducer","initialState"],"mappings":"kHAcaA,EAAN,cAA2BC,EAAAA,WAOhC,WAAAC,CAAYC,EAAYC,GACtBC,MAAMF,EAAIC,GALKE,KAAAC,cAAgBC,kBACjCF,KAAQG,WAAY,EACpBH,KAAQI,iBAAkB,EAKxBJ,KAAKK,UAAUC,SAASC,EAAeA,eAACC,IACjCR,KAAAC,cAAcQ,KAAKD,EAAOE,QAAO,GACvC,CAGH,gBAAMC,CAAWC,GACVZ,KAAAG,UAAYS,EAAOT,YAAa,EAChCH,KAAAI,gBAAkBQ,EAAOR,kBAAmB,CAAA,CAGzC,eAAAS,GACD,MAAA,CACLC,WAAYd,KAAKc,WAAWC,KAAKf,MACjCgB,eAAgBhB,KAAKgB,eAAeD,KAAKf,MAC3C,CAGK,cAAAiB,CAAeC,GACb,OAAAlB,KAAKC,cAAckB,GAAGD,EAAE,CAGzB,UAAAJ,EAAWM,UAAEA,EAAWC,QAAAA,IACxB,MAAAC,EAAYtB,KAAKsB,UAAUC,KAE7B,IAACD,EAAUE,SACP,MAAA,IAAIC,MAAM,0BAGZ,MAAAC,EAAOJ,EAAUE,SAASG,MAAMC,MAAMF,GAASA,EAAKG,QAAUT,IACpE,IAAKM,EACG,MAAA,IAAID,MAAM,uBAGlB,MAAMK,EAAgB,IAChBT,GAAW,CAAC,EAChBlB,WAAoB,MAATkB,OAAS,EAAAA,EAAAlB,YAAaH,KAAKG,UACtCC,iBAA0B,MAATiB,OAAS,EAAAA,EAAAjB,kBAAmBJ,KAAKI,iBAGpD,OAAOJ,KAAK+B,OAAOjB,WAAWQ,EAAUE,SAAUE,EAAMI,EAAa,CAG/D,cAAAd,EAAeI,UAAEA,EAAWY,KAAAA,EAAAX,QAAMA,IAClC,MAAAC,EAAYtB,KAAKsB,UAAUC,KAE7B,IAACD,EAAUE,SACP,MAAA,IAAIC,MAAM,0BAGZ,MAAAC,EAAOJ,EAAUE,SAASG,MAAMC,MAAMF,GAASA,EAAKG,QAAUT,IACpE,IAAKM,EACG,MAAA,IAAID,MAAM,uBAGlB,MAAMK,EAAgB,IAChBT,GAAW,CAAC,EAChBlB,WAAoB,MAATkB,OAAS,EAAAA,EAAAlB,YAAaH,KAAKG,UACtCC,iBAA0B,MAATiB,OAAS,EAAAA,EAAAjB,kBAAmBJ,KAAKI,iBAGpD,OAAOJ,KAAK+B,OAAOf,eAAeM,EAAUE,SAAUE,EAAMM,EAAMF,EAAa,GArEjFpC,EAAgBG,GAAK,SADhB,IAAMoC,EAANvC,ECXA,MAAMwC,EAAmB,SCEnBC,EAAuE,CAClFC,SDD0D,CAC1DvC,GAAIqC,EACJG,KAAM,gBACNC,QAAS,QACTC,SAAU,CAAC,UACXC,SAAU,GACVC,SAAU,GACVC,cAAe,CACbC,SAAS,ICNXC,OAAS9C,GAAa,IAAImC,EAAaC,EAAkBpC,GACzD+C,QAAS,OACTC,aAAc,CAAA"}
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 RenderScope,\n} from './types';\n\n/**\n * Render Plugin - Simplified version that relies on core state for refresh tracking\n *\n * Key insight: Page refresh tracking is in DocumentState.pageRefreshVersions\n * This allows ANY plugin to observe page refreshes, not just the render plugin.\n */\nexport class RenderPlugin extends BasePlugin<RenderPluginConfig, RenderCapability> {\n static readonly id = 'render' as const;\n\n private withForms = false;\n private withAnnotations = false;\n\n constructor(id: string, registry: PluginRegistry, config?: RenderPluginConfig) {\n super(id, registry);\n\n this.withForms = config?.withForms ?? false;\n this.withAnnotations = config?.withAnnotations ?? false;\n }\n\n // No onDocumentLoadingStarted or onDocumentClosed needed!\n\n protected buildCapability(): RenderCapability {\n return {\n // Active document operations\n renderPage: (options: RenderPageOptions) => this.renderPage(options),\n renderPageRect: (options: RenderPageRectOptions) => this.renderPageRect(options),\n\n // Document-scoped operations\n forDocument: (documentId: string) => this.createRenderScope(documentId),\n };\n }\n\n // ─────────────────────────────────────────────────────────\n // Document Scoping\n // ─────────────────────────────────────────────────────────\n\n private createRenderScope(documentId: string): RenderScope {\n return {\n renderPage: (options: RenderPageOptions) => this.renderPage(options, documentId),\n renderPageRect: (options: RenderPageRectOptions) => this.renderPageRect(options, documentId),\n };\n }\n\n // ─────────────────────────────────────────────────────────\n // Core Operations\n // ─────────────────────────────────────────────────────────\n\n private renderPage({ pageIndex, options }: RenderPageOptions, documentId?: string) {\n const id = documentId ?? this.getActiveDocumentId();\n const coreDoc = this.coreState.core.documents[id];\n\n if (!coreDoc?.document) {\n throw new Error(`Document ${id} not loaded`);\n }\n\n const page = coreDoc.document.pages.find((p) => p.index === pageIndex);\n if (!page) {\n throw new Error(`Page ${pageIndex} not found in document ${id}`);\n }\n\n const mergedOptions = {\n ...(options ?? {}),\n withForms: options?.withForms ?? this.withForms,\n withAnnotations: options?.withAnnotations ?? this.withAnnotations,\n };\n\n return this.engine.renderPage(coreDoc.document, page, mergedOptions);\n }\n\n private renderPageRect({ pageIndex, rect, options }: RenderPageRectOptions, documentId?: string) {\n const id = documentId ?? this.getActiveDocumentId();\n const coreDoc = this.coreState.core.documents[id];\n\n if (!coreDoc?.document) {\n throw new Error(`Document ${id} not loaded`);\n }\n\n const page = coreDoc.document.pages.find((p) => p.index === pageIndex);\n if (!page) {\n throw new Error(`Page ${pageIndex} not found in document ${id}`);\n }\n\n const mergedOptions = {\n ...(options ?? {}),\n withForms: options?.withForms ?? this.withForms,\n withAnnotations: options?.withAnnotations ?? this.withAnnotations,\n };\n\n return this.engine.renderPageRect(coreDoc.document, page, rect, mergedOptions);\n }\n\n // ─────────────────────────────────────────────────────────\n // Lifecycle\n // ─────────────────────────────────────────────────────────\n\n async initialize(_config: RenderPluginConfig): Promise<void> {\n this.logger.info('RenderPlugin', 'Initialize', 'Render plugin initialized');\n }\n\n async destroy(): Promise<void> {\n super.destroy();\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, config) => new RenderPlugin(RENDER_PLUGIN_ID, registry, config),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './render-plugin';\nexport * from './types';\n"],"names":["_RenderPlugin","BasePlugin","constructor","id","registry","config","super","this","withForms","withAnnotations","buildCapability","renderPage","options","renderPageRect","forDocument","documentId","createRenderScope","pageIndex","getActiveDocumentId","coreDoc","coreState","core","documents","document","Error","page","pages","find","p","index","mergedOptions","engine","rect","initialize","_config","logger","info","destroy","RenderPlugin","RENDER_PLUGIN_ID","RenderPluginPackage","manifest","name","version","provides","requires","optional","defaultConfig","enabled","create","reducer","initialState"],"mappings":"kHAeaA,EAAN,cAA2BC,EAAAA,WAMhC,WAAAC,CAAYC,EAAYC,EAA0BC,GAChDC,MAAMH,EAAIC,GAJZG,KAAQC,WAAY,EACpBD,KAAQE,iBAAkB,EAKxBF,KAAKC,iBAAYH,WAAQG,aAAa,EACtCD,KAAKE,uBAAkBJ,WAAQI,mBAAmB,CACpD,CAIU,eAAAC,GACR,MAAO,CAELC,WAAaC,GAA+BL,KAAKI,WAAWC,GAC5DC,eAAiBD,GAAmCL,KAAKM,eAAeD,GAGxEE,YAAcC,GAAuBR,KAAKS,kBAAkBD,GAEhE,CAMQ,iBAAAC,CAAkBD,GACxB,MAAO,CACLJ,WAAaC,GAA+BL,KAAKI,WAAWC,EAASG,GACrEF,eAAiBD,GAAmCL,KAAKM,eAAeD,EAASG,GAErF,CAMQ,UAAAJ,EAAWM,UAAEA,EAAAL,QAAWA,GAA8BG,GAC5D,MAAMZ,EAAKY,GAAcR,KAAKW,sBACxBC,EAAUZ,KAAKa,UAAUC,KAAKC,UAAUnB,GAE9C,WAAKgB,WAASI,UACZ,MAAM,IAAIC,MAAM,YAAYrB,gBAG9B,MAAMsB,EAAON,EAAQI,SAASG,MAAMC,KAAMC,GAAMA,EAAEC,QAAUZ,GAC5D,IAAKQ,EACH,MAAM,IAAID,MAAM,QAAQP,2BAAmCd,KAG7D,MAAM2B,EAAgB,IAChBlB,GAAW,CAAA,EACfJ,WAAW,MAAAI,OAAA,EAAAA,EAASJ,YAAaD,KAAKC,UACtCC,iBAAiB,MAAAG,OAAA,EAAAA,EAASH,kBAAmBF,KAAKE,iBAGpD,OAAOF,KAAKwB,OAAOpB,WAAWQ,EAAQI,SAAUE,EAAMK,EACxD,CAEQ,cAAAjB,EAAeI,UAAEA,EAAAe,KAAWA,EAAApB,QAAMA,GAAkCG,GAC1E,MAAMZ,EAAKY,GAAcR,KAAKW,sBACxBC,EAAUZ,KAAKa,UAAUC,KAAKC,UAAUnB,GAE9C,WAAKgB,WAASI,UACZ,MAAM,IAAIC,MAAM,YAAYrB,gBAG9B,MAAMsB,EAAON,EAAQI,SAASG,MAAMC,KAAMC,GAAMA,EAAEC,QAAUZ,GAC5D,IAAKQ,EACH,MAAM,IAAID,MAAM,QAAQP,2BAAmCd,KAG7D,MAAM2B,EAAgB,IAChBlB,GAAW,CAAA,EACfJ,WAAW,MAAAI,OAAA,EAAAA,EAASJ,YAAaD,KAAKC,UACtCC,iBAAiB,MAAAG,OAAA,EAAAA,EAASH,kBAAmBF,KAAKE,iBAGpD,OAAOF,KAAKwB,OAAOlB,eAAeM,EAAQI,SAAUE,EAAMO,EAAMF,EAClE,CAMA,gBAAMG,CAAWC,GACf3B,KAAK4B,OAAOC,KAAK,eAAgB,aAAc,4BACjD,CAEA,aAAMC,GACJ/B,MAAM+B,SACR,GA9FArC,EAAgBG,GAAK,SADhB,IAAMmC,EAANtC,ECZA,MAAMuC,EAAmB,SCEnBC,EAAuE,CAClFC,SDD0D,CAC1DtC,GAAIoC,EACJG,KAAM,gBACNC,QAAS,QACTC,SAAU,CAAC,UACXC,SAAU,GACVC,SAAU,GACVC,cAAe,CACbC,SAAS,ICNXC,OAAQ,CAAC7C,EAAUC,IAAW,IAAIiC,EAAaC,EAAkBnC,EAAUC,GAC3E6C,QAAS,OACTC,aAAc,CAAA"}
package/dist/index.js CHANGED
@@ -1,58 +1,76 @@
1
- import { BasePlugin, createEmitter, REFRESH_PAGES } from "@embedpdf/core";
1
+ import { BasePlugin } from "@embedpdf/core";
2
2
  const _RenderPlugin = class _RenderPlugin extends BasePlugin {
3
- constructor(id, registry) {
3
+ constructor(id, registry, config) {
4
4
  super(id, registry);
5
- this.refreshPages$ = createEmitter();
6
5
  this.withForms = false;
7
6
  this.withAnnotations = false;
8
- this.coreStore.onAction(REFRESH_PAGES, (action) => {
9
- this.refreshPages$.emit(action.payload);
10
- });
11
- }
12
- async initialize(config) {
13
- this.withForms = config.withForms ?? false;
14
- this.withAnnotations = config.withAnnotations ?? false;
7
+ this.withForms = (config == null ? void 0 : config.withForms) ?? false;
8
+ this.withAnnotations = (config == null ? void 0 : config.withAnnotations) ?? false;
15
9
  }
10
+ // No onDocumentLoadingStarted or onDocumentClosed needed!
16
11
  buildCapability() {
17
12
  return {
18
- renderPage: this.renderPage.bind(this),
19
- renderPageRect: this.renderPageRect.bind(this)
13
+ // Active document operations
14
+ renderPage: (options) => this.renderPage(options),
15
+ renderPageRect: (options) => this.renderPageRect(options),
16
+ // Document-scoped operations
17
+ forDocument: (documentId) => this.createRenderScope(documentId)
20
18
  };
21
19
  }
22
- onRefreshPages(fn) {
23
- return this.refreshPages$.on(fn);
20
+ // ─────────────────────────────────────────────────────────
21
+ // Document Scoping
22
+ // ─────────────────────────────────────────────────────────
23
+ createRenderScope(documentId) {
24
+ return {
25
+ renderPage: (options) => this.renderPage(options, documentId),
26
+ renderPageRect: (options) => this.renderPageRect(options, documentId)
27
+ };
24
28
  }
25
- renderPage({ pageIndex, options }) {
26
- const coreState = this.coreState.core;
27
- if (!coreState.document) {
28
- throw new Error("document does not open");
29
+ // ─────────────────────────────────────────────────────────
30
+ // Core Operations
31
+ // ─────────────────────────────────────────────────────────
32
+ renderPage({ pageIndex, options }, documentId) {
33
+ const id = documentId ?? this.getActiveDocumentId();
34
+ const coreDoc = this.coreState.core.documents[id];
35
+ if (!(coreDoc == null ? void 0 : coreDoc.document)) {
36
+ throw new Error(`Document ${id} not loaded`);
29
37
  }
30
- const page = coreState.document.pages.find((page2) => page2.index === pageIndex);
38
+ const page = coreDoc.document.pages.find((p) => p.index === pageIndex);
31
39
  if (!page) {
32
- throw new Error("page does not exist");
40
+ throw new Error(`Page ${pageIndex} not found in document ${id}`);
33
41
  }
34
42
  const mergedOptions = {
35
43
  ...options ?? {},
36
44
  withForms: (options == null ? void 0 : options.withForms) ?? this.withForms,
37
45
  withAnnotations: (options == null ? void 0 : options.withAnnotations) ?? this.withAnnotations
38
46
  };
39
- return this.engine.renderPage(coreState.document, page, mergedOptions);
47
+ return this.engine.renderPage(coreDoc.document, page, mergedOptions);
40
48
  }
41
- renderPageRect({ pageIndex, rect, options }) {
42
- const coreState = this.coreState.core;
43
- if (!coreState.document) {
44
- throw new Error("document does not open");
49
+ renderPageRect({ pageIndex, rect, options }, documentId) {
50
+ const id = documentId ?? this.getActiveDocumentId();
51
+ const coreDoc = this.coreState.core.documents[id];
52
+ if (!(coreDoc == null ? void 0 : coreDoc.document)) {
53
+ throw new Error(`Document ${id} not loaded`);
45
54
  }
46
- const page = coreState.document.pages.find((page2) => page2.index === pageIndex);
55
+ const page = coreDoc.document.pages.find((p) => p.index === pageIndex);
47
56
  if (!page) {
48
- throw new Error("page does not exist");
57
+ throw new Error(`Page ${pageIndex} not found in document ${id}`);
49
58
  }
50
59
  const mergedOptions = {
51
60
  ...options ?? {},
52
61
  withForms: (options == null ? void 0 : options.withForms) ?? this.withForms,
53
62
  withAnnotations: (options == null ? void 0 : options.withAnnotations) ?? this.withAnnotations
54
63
  };
55
- return this.engine.renderPageRect(coreState.document, page, rect, mergedOptions);
64
+ return this.engine.renderPageRect(coreDoc.document, page, rect, mergedOptions);
65
+ }
66
+ // ─────────────────────────────────────────────────────────
67
+ // Lifecycle
68
+ // ─────────────────────────────────────────────────────────
69
+ async initialize(_config) {
70
+ this.logger.info("RenderPlugin", "Initialize", "Render plugin initialized");
71
+ }
72
+ async destroy() {
73
+ super.destroy();
56
74
  }
57
75
  };
58
76
  _RenderPlugin.id = "render";
@@ -71,7 +89,7 @@ const manifest = {
71
89
  };
72
90
  const RenderPluginPackage = {
73
91
  manifest,
74
- create: (registry) => new RenderPlugin(RENDER_PLUGIN_ID, registry),
92
+ create: (registry, config) => new RenderPlugin(RENDER_PLUGIN_ID, registry, config),
75
93
  reducer: () => {
76
94
  },
77
95
  initialState: {}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/lib/render-plugin.ts","../src/lib/manifest.ts","../src/lib/index.ts"],"sourcesContent":["import {\n BasePlugin,\n createEmitter,\n PluginRegistry,\n REFRESH_PAGES,\n Unsubscribe,\n} from '@embedpdf/core';\nimport {\n RenderCapability,\n RenderPageOptions,\n RenderPageRectOptions,\n RenderPluginConfig,\n} from './types';\n\nexport class RenderPlugin extends BasePlugin<RenderPluginConfig, RenderCapability> {\n static readonly id = 'render' as const;\n\n private readonly refreshPages$ = createEmitter<number[]>();\n private withForms = false;\n private withAnnotations = false;\n\n constructor(id: string, registry: PluginRegistry) {\n super(id, registry);\n\n this.coreStore.onAction(REFRESH_PAGES, (action) => {\n this.refreshPages$.emit(action.payload);\n });\n }\n\n async initialize(config: RenderPluginConfig): Promise<void> {\n this.withForms = config.withForms ?? false;\n this.withAnnotations = config.withAnnotations ?? false;\n }\n\n protected buildCapability(): RenderCapability {\n return {\n renderPage: this.renderPage.bind(this),\n renderPageRect: this.renderPageRect.bind(this),\n };\n }\n\n public onRefreshPages(fn: (pages: number[]) => void): Unsubscribe {\n return this.refreshPages$.on(fn);\n }\n\n private renderPage({ pageIndex, options }: 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 const mergedOptions = {\n ...(options ?? {}),\n withForms: options?.withForms ?? this.withForms,\n withAnnotations: options?.withAnnotations ?? this.withAnnotations,\n };\n\n return this.engine.renderPage(coreState.document, page, mergedOptions);\n }\n\n private renderPageRect({ pageIndex, rect, options }: 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 const mergedOptions = {\n ...(options ?? {}),\n withForms: options?.withForms ?? this.withForms,\n withAnnotations: options?.withAnnotations ?? this.withAnnotations,\n };\n\n return this.engine.renderPageRect(coreState.document, page, rect, mergedOptions);\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) => new RenderPlugin(RENDER_PLUGIN_ID, registry),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './render-plugin';\nexport * from './types';\n"],"names":["page"],"mappings":";AAcO,MAAM,gBAAN,MAAM,sBAAqB,WAAiD;AAAA,EAOjF,YAAY,IAAY,UAA0B;AAChD,UAAM,IAAI,QAAQ;AALpB,SAAiB,gBAAgB,cAAwB;AACzD,SAAQ,YAAY;AACpB,SAAQ,kBAAkB;AAKxB,SAAK,UAAU,SAAS,eAAe,CAAC,WAAW;AAC5C,WAAA,cAAc,KAAK,OAAO,OAAO;AAAA,IAAA,CACvC;AAAA,EAAA;AAAA,EAGH,MAAM,WAAW,QAA2C;AACrD,SAAA,YAAY,OAAO,aAAa;AAChC,SAAA,kBAAkB,OAAO,mBAAmB;AAAA,EAAA;AAAA,EAGzC,kBAAoC;AACrC,WAAA;AAAA,MACL,YAAY,KAAK,WAAW,KAAK,IAAI;AAAA,MACrC,gBAAgB,KAAK,eAAe,KAAK,IAAI;AAAA,IAC/C;AAAA,EAAA;AAAA,EAGK,eAAe,IAA4C;AACzD,WAAA,KAAK,cAAc,GAAG,EAAE;AAAA,EAAA;AAAA,EAGzB,WAAW,EAAE,WAAW,WAA8B;AACtD,UAAA,YAAY,KAAK,UAAU;AAE7B,QAAA,CAAC,UAAU,UAAU;AACjB,YAAA,IAAI,MAAM,wBAAwB;AAAA,IAAA;AAGpC,UAAA,OAAO,UAAU,SAAS,MAAM,KAAK,CAACA,UAASA,MAAK,UAAU,SAAS;AAC7E,QAAI,CAAC,MAAM;AACH,YAAA,IAAI,MAAM,qBAAqB;AAAA,IAAA;AAGvC,UAAM,gBAAgB;AAAA,MACpB,GAAI,WAAW,CAAC;AAAA,MAChB,YAAW,mCAAS,cAAa,KAAK;AAAA,MACtC,kBAAiB,mCAAS,oBAAmB,KAAK;AAAA,IACpD;AAEA,WAAO,KAAK,OAAO,WAAW,UAAU,UAAU,MAAM,aAAa;AAAA,EAAA;AAAA,EAG/D,eAAe,EAAE,WAAW,MAAM,WAAkC;AACpE,UAAA,YAAY,KAAK,UAAU;AAE7B,QAAA,CAAC,UAAU,UAAU;AACjB,YAAA,IAAI,MAAM,wBAAwB;AAAA,IAAA;AAGpC,UAAA,OAAO,UAAU,SAAS,MAAM,KAAK,CAACA,UAASA,MAAK,UAAU,SAAS;AAC7E,QAAI,CAAC,MAAM;AACH,YAAA,IAAI,MAAM,qBAAqB;AAAA,IAAA;AAGvC,UAAM,gBAAgB;AAAA,MACpB,GAAI,WAAW,CAAC;AAAA,MAChB,YAAW,mCAAS,cAAa,KAAK;AAAA,MACtC,kBAAiB,mCAAS,oBAAmB,KAAK;AAAA,IACpD;AAEA,WAAO,KAAK,OAAO,eAAe,UAAU,UAAU,MAAM,MAAM,aAAa;AAAA,EAAA;AAEnF;AAvEE,cAAgB,KAAK;AADhB,IAAM,eAAN;ACXA,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,aAAa,IAAI,aAAa,kBAAkB,QAAQ;AAAA,EACjE,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,cAAc,CAAA;AAChB;"}
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 RenderScope,\n} from './types';\n\n/**\n * Render Plugin - Simplified version that relies on core state for refresh tracking\n *\n * Key insight: Page refresh tracking is in DocumentState.pageRefreshVersions\n * This allows ANY plugin to observe page refreshes, not just the render plugin.\n */\nexport class RenderPlugin extends BasePlugin<RenderPluginConfig, RenderCapability> {\n static readonly id = 'render' as const;\n\n private withForms = false;\n private withAnnotations = false;\n\n constructor(id: string, registry: PluginRegistry, config?: RenderPluginConfig) {\n super(id, registry);\n\n this.withForms = config?.withForms ?? false;\n this.withAnnotations = config?.withAnnotations ?? false;\n }\n\n // No onDocumentLoadingStarted or onDocumentClosed needed!\n\n protected buildCapability(): RenderCapability {\n return {\n // Active document operations\n renderPage: (options: RenderPageOptions) => this.renderPage(options),\n renderPageRect: (options: RenderPageRectOptions) => this.renderPageRect(options),\n\n // Document-scoped operations\n forDocument: (documentId: string) => this.createRenderScope(documentId),\n };\n }\n\n // ─────────────────────────────────────────────────────────\n // Document Scoping\n // ─────────────────────────────────────────────────────────\n\n private createRenderScope(documentId: string): RenderScope {\n return {\n renderPage: (options: RenderPageOptions) => this.renderPage(options, documentId),\n renderPageRect: (options: RenderPageRectOptions) => this.renderPageRect(options, documentId),\n };\n }\n\n // ─────────────────────────────────────────────────────────\n // Core Operations\n // ─────────────────────────────────────────────────────────\n\n private renderPage({ pageIndex, options }: RenderPageOptions, documentId?: string) {\n const id = documentId ?? this.getActiveDocumentId();\n const coreDoc = this.coreState.core.documents[id];\n\n if (!coreDoc?.document) {\n throw new Error(`Document ${id} not loaded`);\n }\n\n const page = coreDoc.document.pages.find((p) => p.index === pageIndex);\n if (!page) {\n throw new Error(`Page ${pageIndex} not found in document ${id}`);\n }\n\n const mergedOptions = {\n ...(options ?? {}),\n withForms: options?.withForms ?? this.withForms,\n withAnnotations: options?.withAnnotations ?? this.withAnnotations,\n };\n\n return this.engine.renderPage(coreDoc.document, page, mergedOptions);\n }\n\n private renderPageRect({ pageIndex, rect, options }: RenderPageRectOptions, documentId?: string) {\n const id = documentId ?? this.getActiveDocumentId();\n const coreDoc = this.coreState.core.documents[id];\n\n if (!coreDoc?.document) {\n throw new Error(`Document ${id} not loaded`);\n }\n\n const page = coreDoc.document.pages.find((p) => p.index === pageIndex);\n if (!page) {\n throw new Error(`Page ${pageIndex} not found in document ${id}`);\n }\n\n const mergedOptions = {\n ...(options ?? {}),\n withForms: options?.withForms ?? this.withForms,\n withAnnotations: options?.withAnnotations ?? this.withAnnotations,\n };\n\n return this.engine.renderPageRect(coreDoc.document, page, rect, mergedOptions);\n }\n\n // ─────────────────────────────────────────────────────────\n // Lifecycle\n // ─────────────────────────────────────────────────────────\n\n async initialize(_config: RenderPluginConfig): Promise<void> {\n this.logger.info('RenderPlugin', 'Initialize', 'Render plugin initialized');\n }\n\n async destroy(): Promise<void> {\n super.destroy();\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, config) => new RenderPlugin(RENDER_PLUGIN_ID, registry, config),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './render-plugin';\nexport * from './types';\n"],"names":[],"mappings":";AAeO,MAAM,gBAAN,MAAM,sBAAqB,WAAiD;AAAA,EAMjF,YAAY,IAAY,UAA0B,QAA6B;AAC7E,UAAM,IAAI,QAAQ;AAJpB,SAAQ,YAAY;AACpB,SAAQ,kBAAkB;AAKxB,SAAK,aAAY,iCAAQ,cAAa;AACtC,SAAK,mBAAkB,iCAAQ,oBAAmB;AAAA,EACpD;AAAA;AAAA,EAIU,kBAAoC;AAC5C,WAAO;AAAA;AAAA,MAEL,YAAY,CAAC,YAA+B,KAAK,WAAW,OAAO;AAAA,MACnE,gBAAgB,CAAC,YAAmC,KAAK,eAAe,OAAO;AAAA;AAAA,MAG/E,aAAa,CAAC,eAAuB,KAAK,kBAAkB,UAAU;AAAA,IAAA;AAAA,EAE1E;AAAA;AAAA;AAAA;AAAA,EAMQ,kBAAkB,YAAiC;AACzD,WAAO;AAAA,MACL,YAAY,CAAC,YAA+B,KAAK,WAAW,SAAS,UAAU;AAAA,MAC/E,gBAAgB,CAAC,YAAmC,KAAK,eAAe,SAAS,UAAU;AAAA,IAAA;AAAA,EAE/F;AAAA;AAAA;AAAA;AAAA,EAMQ,WAAW,EAAE,WAAW,QAAA,GAA8B,YAAqB;AACjF,UAAM,KAAK,cAAc,KAAK,oBAAA;AAC9B,UAAM,UAAU,KAAK,UAAU,KAAK,UAAU,EAAE;AAEhD,QAAI,EAAC,mCAAS,WAAU;AACtB,YAAM,IAAI,MAAM,YAAY,EAAE,aAAa;AAAA,IAC7C;AAEA,UAAM,OAAO,QAAQ,SAAS,MAAM,KAAK,CAAC,MAAM,EAAE,UAAU,SAAS;AACrE,QAAI,CAAC,MAAM;AACT,YAAM,IAAI,MAAM,QAAQ,SAAS,0BAA0B,EAAE,EAAE;AAAA,IACjE;AAEA,UAAM,gBAAgB;AAAA,MACpB,GAAI,WAAW,CAAA;AAAA,MACf,YAAW,mCAAS,cAAa,KAAK;AAAA,MACtC,kBAAiB,mCAAS,oBAAmB,KAAK;AAAA,IAAA;AAGpD,WAAO,KAAK,OAAO,WAAW,QAAQ,UAAU,MAAM,aAAa;AAAA,EACrE;AAAA,EAEQ,eAAe,EAAE,WAAW,MAAM,QAAA,GAAkC,YAAqB;AAC/F,UAAM,KAAK,cAAc,KAAK,oBAAA;AAC9B,UAAM,UAAU,KAAK,UAAU,KAAK,UAAU,EAAE;AAEhD,QAAI,EAAC,mCAAS,WAAU;AACtB,YAAM,IAAI,MAAM,YAAY,EAAE,aAAa;AAAA,IAC7C;AAEA,UAAM,OAAO,QAAQ,SAAS,MAAM,KAAK,CAAC,MAAM,EAAE,UAAU,SAAS;AACrE,QAAI,CAAC,MAAM;AACT,YAAM,IAAI,MAAM,QAAQ,SAAS,0BAA0B,EAAE,EAAE;AAAA,IACjE;AAEA,UAAM,gBAAgB;AAAA,MACpB,GAAI,WAAW,CAAA;AAAA,MACf,YAAW,mCAAS,cAAa,KAAK;AAAA,MACtC,kBAAiB,mCAAS,oBAAmB,KAAK;AAAA,IAAA;AAGpD,WAAO,KAAK,OAAO,eAAe,QAAQ,UAAU,MAAM,MAAM,aAAa;AAAA,EAC/E;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,WAAW,SAA4C;AAC3D,SAAK,OAAO,KAAK,gBAAgB,cAAc,2BAA2B;AAAA,EAC5E;AAAA,EAEA,MAAM,UAAyB;AAC7B,UAAM,QAAA;AAAA,EACR;AACF;AA/FE,cAAgB,KAAK;AADhB,IAAM,eAAN;ACZA,MAAM,mBAAmB;AAEzB,MAAM,WAA+C;AAAA,EAC1D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,QAAQ;AAAA,EACnB,UAAU,CAAA;AAAA,EACV,UAAU,CAAA;AAAA,EACV,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;"}
@@ -1,14 +1,20 @@
1
- import { BasePlugin, PluginRegistry, Unsubscribe } from '@embedpdf/core';
1
+ import { BasePlugin, PluginRegistry } from '@embedpdf/core';
2
2
  import { RenderCapability, RenderPluginConfig } from './types';
3
+ /**
4
+ * Render Plugin - Simplified version that relies on core state for refresh tracking
5
+ *
6
+ * Key insight: Page refresh tracking is in DocumentState.pageRefreshVersions
7
+ * This allows ANY plugin to observe page refreshes, not just the render plugin.
8
+ */
3
9
  export declare class RenderPlugin extends BasePlugin<RenderPluginConfig, RenderCapability> {
4
10
  static readonly id: "render";
5
- private readonly refreshPages$;
6
11
  private withForms;
7
12
  private withAnnotations;
8
- constructor(id: string, registry: PluginRegistry);
9
- initialize(config: RenderPluginConfig): Promise<void>;
13
+ constructor(id: string, registry: PluginRegistry, config?: RenderPluginConfig);
10
14
  protected buildCapability(): RenderCapability;
11
- onRefreshPages(fn: (pages: number[]) => void): Unsubscribe;
15
+ private createRenderScope;
12
16
  private renderPage;
13
17
  private renderPageRect;
18
+ initialize(_config: RenderPluginConfig): Promise<void>;
19
+ destroy(): Promise<void>;
14
20
  }
@@ -21,7 +21,12 @@ export interface RenderPageOptions {
21
21
  pageIndex: number;
22
22
  options: PdfRenderPageOptions;
23
23
  }
24
+ export interface RenderScope {
25
+ renderPage(options: RenderPageOptions): Task<Blob, PdfErrorReason>;
26
+ renderPageRect(options: RenderPageRectOptions): Task<Blob, PdfErrorReason>;
27
+ }
24
28
  export interface RenderCapability {
25
- renderPage: (options: RenderPageOptions) => Task<Blob, PdfErrorReason>;
26
- renderPageRect: (options: RenderPageRectOptions) => Task<Blob, PdfErrorReason>;
29
+ renderPage(options: RenderPageOptions): Task<Blob, PdfErrorReason>;
30
+ renderPageRect(options: RenderPageRectOptions): Task<Blob, PdfErrorReason>;
31
+ forDocument(documentId: string): RenderScope;
27
32
  }
@@ -1,5 +1,5 @@
1
1
  import { Fragment } from 'preact';
2
- import { useEffect, useRef, useState } from 'preact/hooks';
3
- export { Fragment, useEffect, useRef, useState };
2
+ import { useEffect, useRef, useState, useMemo } from 'preact/hooks';
3
+ export { Fragment, useEffect, useRef, useState, useMemo };
4
4
  export type CSSProperties = import('preact').JSX.CSSProperties;
5
5
  export type HTMLAttributes<T = any> = import('preact').JSX.HTMLAttributes<T extends EventTarget ? T : never>;
@@ -1,2 +1,2 @@
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"),c=require("@embedpdf/core/preact"),u=require("@embedpdf/plugin-render"),s=()=>c.usePlugin(u.RenderPlugin.id),o=()=>c.useCapability(u.RenderPlugin.id);exports.RenderLayer=function({pageIndex:c,scale:u,scaleFactor:i,dpr:a,style:d,...l}){const{provides:p}=o(),{plugin:g}=s(),f=u??i??1,[b,R]=t.useState(null),x=t.useRef(null),[y,P]=t.useState(0);return t.useEffect((()=>{if(g)return g.onRefreshPages((e=>{e.includes(c)&&P((e=>e+1))}))}),[g]),t.useEffect((()=>{if(p){const e=p.renderPage({pageIndex:c,options:{scaleFactor:f,dpr:a||window.devicePixelRatio}});return e.wait((e=>{const r=URL.createObjectURL(e);R(r),x.current=r}),n.ignore),()=>{x.current?(URL.revokeObjectURL(x.current),x.current=null):e.abort({code:n.PdfErrorCode.Cancelled,message:"canceled render task"})}}}),[c,f,a,p,y]),e.jsx(r.Fragment,{children:b&&e.jsx("img",{src:b,onLoad:()=>{x.current&&(URL.revokeObjectURL(x.current),x.current=null)},...l,style:{width:"100%",height:"100%",...d||{}}})})},exports.useRenderCapability=o,exports.useRenderPlugin=s,Object.keys(u).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>u[e]})}));
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"),o=require("@embedpdf/core/preact"),u=require("@embedpdf/plugin-render"),s=()=>o.useCapability(u.RenderPlugin.id);exports.RenderLayer=function({documentId:u,pageIndex:c,scale:d,dpr:i,style:l,...a}){const{provides:p}=s(),g=o.useDocumentState(u),[m,b]=t.useState(null),f=t.useRef(null),R=t.useMemo(()=>g&&g.pageRefreshVersions[c]||0,[g,c]),x=t.useMemo(()=>void 0!==d?d:(null==g?void 0:g.scale)??1,[d,null==g?void 0:g.scale]),y=t.useMemo(()=>void 0!==i?i:window.devicePixelRatio,[i]);return t.useEffect(()=>{if(!p)return;const e=p.forDocument(u).renderPage({pageIndex:c,options:{scaleFactor:x,dpr:y}});return e.wait(e=>{const r=URL.createObjectURL(e);b(r),f.current=r},n.ignore),()=>{f.current?(URL.revokeObjectURL(f.current),f.current=null):e.abort({code:n.PdfErrorCode.Cancelled,message:"canceled render task"})}},[u,c,x,y,p,R]),e.jsx(r.Fragment,{children:m&&e.jsx("img",{src:m,onLoad:()=>{f.current&&(URL.revokeObjectURL(f.current),f.current=null)},...a,style:{width:"100%",height:"100%",...l||{}}})})},exports.useRenderCapability=s,exports.useRenderPlugin=()=>o.usePlugin(u.RenderPlugin.id),Object.keys(u).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>u[e]})});
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
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, useRenderPlugin } from '../hooks/use-render';\n\ntype RenderLayerProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {\n pageIndex: number;\n /**\n * The scale factor for rendering the page.\n */\n scale?: number;\n /**\n * @deprecated Use `scale` instead. Will be removed in the next major release.\n */\n scaleFactor?: number;\n dpr?: number;\n style?: CSSProperties;\n};\n\nexport function RenderLayer({\n pageIndex,\n scale,\n scaleFactor,\n dpr,\n style,\n ...props\n}: RenderLayerProps) {\n const { provides: renderProvides } = useRenderCapability();\n const { plugin: renderPlugin } = useRenderPlugin();\n\n // Handle deprecation: prefer scale over scaleFactor, but fall back to scaleFactor if scale is not provided\n const actualScale = scale ?? scaleFactor ?? 1;\n\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n const [refreshTick, setRefreshTick] = useState(0);\n\n useEffect(() => {\n if (!renderPlugin) return;\n return renderPlugin.onRefreshPages((pages) => {\n if (pages.includes(pageIndex)) {\n setRefreshTick((tick) => tick + 1);\n }\n });\n }, [renderPlugin]);\n\n useEffect(() => {\n if (renderProvides) {\n const task = renderProvides.renderPage({\n pageIndex,\n options: { scaleFactor: actualScale, dpr: dpr || window.devicePixelRatio },\n });\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, actualScale, dpr, renderProvides, refreshTick]);\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":["useRenderPlugin","usePlugin","RenderPlugin","id","useRenderCapability","useCapability","pageIndex","scale","scaleFactor","dpr","style","props","provides","renderProvides","plugin","renderPlugin","actualScale","imageUrl","setImageUrl","useState","urlRef","useRef","refreshTick","setRefreshTick","useEffect","onRefreshPages","pages","includes","tick","task","renderPage","options","window","devicePixelRatio","wait","blob","url","URL","createObjectURL","current","ignore","revokeObjectURL","abort","code","PdfErrorCode","Cancelled","message","jsx","Fragment","children","jsxRuntime","src","onLoad","width","height"],"mappings":"0QAGaA,EAAkB,IAAMC,YAAwBC,EAAAA,aAAaC,IAC7DC,EAAsB,IAAMC,gBAA4BH,EAAAA,aAAaC,wBCiB3E,UAAqBG,UAC1BA,EAAAC,MACAA,EAAAC,YACAA,EAAAC,IACAA,EAAAC,MACAA,KACGC,IAEH,MAAQC,SAAUC,GAAmBT,KAC7BU,OAAQC,GAAiBf,IAG3BgB,EAAcT,GAASC,GAAe,GAErCS,EAAUC,GAAeC,EAAAA,SAAwB,MAClDC,EAASC,SAAsB,OAC9BC,EAAaC,GAAkBJ,EAAAA,SAAS,GA6C7C,OA3CFK,EAAAA,WAAU,KACR,GAAKT,EACE,OAAAA,EAAaU,gBAAgBC,IAC9BA,EAAMC,SAASrB,IACFiB,GAACK,GAASA,EAAO,GAAC,GAEpC,GACA,CAACb,IAEJS,EAAAA,WAAU,KACR,GAAIX,EAAgB,CACZ,MAAAgB,EAAOhB,EAAeiB,WAAW,CACrCxB,YACAyB,QAAS,CAAEvB,YAAaQ,EAAaP,IAAKA,GAAOuB,OAAOC,oBAQ1D,OANKJ,EAAAK,MAAMC,IACH,MAAAC,EAAMC,IAAIC,gBAAgBH,GAChCjB,EAAYkB,GACZhB,EAAOmB,QAAUH,CAAA,GAChBI,UAEI,KACDpB,EAAOmB,SACLF,IAAAI,gBAAgBrB,EAAOmB,SAC3BnB,EAAOmB,QAAU,MAEjBV,EAAKa,MAAM,CACTC,KAAMC,EAAaA,aAAAC,UACnBC,QAAS,wBACV,CAEL,IAED,CAACxC,EAAWU,EAAaP,EAAKI,EAAgBS,MAU/CyB,IAACC,YACEC,SACChC,GAAAiC,EAAAH,IAAC,MAAA,CACCI,IAAKlC,EACLmC,OAZgB,KAClBhC,EAAOmB,UACLF,IAAAI,gBAAgBrB,EAAOmB,SAC3BnB,EAAOmB,QAAU,KAAA,KAUT5B,EACJD,MAAO,CACL2C,MAAO,OACPC,OAAQ,UACJ5C,GAAS,CAAA,MAMzB"}
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, useMemo } from '@framework';\nimport type { CSSProperties, HTMLAttributes } from '@framework';\n\nimport { ignore, PdfErrorCode, Rotation } from '@embedpdf/models';\n\nimport { useRenderCapability } from '../hooks/use-render';\nimport { useDocumentState } from '@embedpdf/core/@framework';\n\ntype RenderLayerProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {\n /**\n * The ID of the document to render from\n */\n documentId: string;\n /**\n * The page index to render (0-based)\n */\n pageIndex: number;\n /**\n * Optional scale override. If not provided, uses document's current scale.\n */\n scale?: number;\n /**\n * Optional device pixel ratio override. If not provided, uses window.devicePixelRatio.\n */\n dpr?: number;\n /**\n * Additional styles for the image element\n */\n style?: CSSProperties;\n};\n\n/**\n * RenderLayer Component\n *\n * Renders a PDF page with smart prop handling:\n * - If scale/dpr/rotation props are provided, they override document state\n * - If not provided, component uses document's current state values\n * - Automatically re-renders when:\n * 1. Document state changes (scale, rotation)\n * 2. Page is refreshed (via REFRESH_PAGES action in core)\n */\nexport function RenderLayer({\n documentId,\n pageIndex,\n scale: scaleOverride,\n dpr: dprOverride,\n style,\n ...props\n}: RenderLayerProps) {\n const { provides: renderProvides } = useRenderCapability();\n const documentState = useDocumentState(documentId);\n\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n // Get refresh version from core state\n const refreshVersion = useMemo(() => {\n if (!documentState) return 0;\n return documentState.pageRefreshVersions[pageIndex] || 0;\n }, [documentState, pageIndex]);\n\n // Determine actual render options: use overrides if provided, otherwise fall back to document state\n const actualScale = useMemo(() => {\n if (scaleOverride !== undefined) return scaleOverride;\n return documentState?.scale ?? 1;\n }, [scaleOverride, documentState?.scale]);\n\n const actualDpr = useMemo(() => {\n if (dprOverride !== undefined) return dprOverride;\n return window.devicePixelRatio;\n }, [dprOverride]);\n\n useEffect(() => {\n if (!renderProvides) return;\n\n const task = renderProvides.forDocument(documentId).renderPage({\n pageIndex,\n options: {\n scaleFactor: actualScale,\n dpr: actualDpr,\n },\n });\n\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 }, [documentId, pageIndex, actualScale, actualDpr, renderProvides, refreshVersion]);\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","documentId","pageIndex","scale","scaleOverride","dpr","dprOverride","style","props","provides","renderProvides","documentState","useDocumentState","imageUrl","setImageUrl","useState","urlRef","useRef","refreshVersion","useMemo","pageRefreshVersions","actualScale","actualDpr","window","devicePixelRatio","useEffect","task","forDocument","renderPage","options","scaleFactor","wait","blob","url","URL","createObjectURL","current","ignore","revokeObjectURL","abort","code","PdfErrorCode","Cancelled","message","jsx","Fragment","children","src","onLoad","width","height","usePlugin"],"mappings":"0QAIaA,EAAsB,IAAMC,gBAA4BC,EAAAA,aAAaC,wBCqC3E,UAAqBC,WAC1BA,EAAAC,UACAA,EACAC,MAAOC,EACPC,IAAKC,EAAAC,MACLA,KACGC,IAEH,MAAQC,SAAUC,GAAmBb,IAC/Bc,EAAgBC,EAAAA,iBAAiBX,IAEhCY,EAAUC,GAAeC,EAAAA,SAAwB,MAClDC,EAASC,EAAAA,OAAsB,MAG/BC,EAAiBC,EAAAA,QAAQ,IACxBR,GACEA,EAAcS,oBAAoBlB,IADd,EAE1B,CAACS,EAAeT,IAGbmB,EAAcF,EAAAA,QAAQ,SACJ,IAAlBf,EAAoCA,SACjCO,WAAeR,QAAS,EAC9B,CAACC,EAAe,MAAAO,OAAA,EAAAA,EAAeR,QAE5BmB,EAAYH,EAAAA,QAAQ,SACJ,IAAhBb,EAAkCA,EAC/BiB,OAAOC,iBACb,CAAClB,IAuCJ,OArCAmB,EAAAA,UAAU,KACR,IAAKf,EAAgB,OAErB,MAAMgB,EAAOhB,EAAeiB,YAAY1B,GAAY2B,WAAW,CAC7D1B,YACA2B,QAAS,CACPC,YAAaT,EACbhB,IAAKiB,KAUT,OANAI,EAAKK,KAAMC,IACT,MAAMC,EAAMC,IAAIC,gBAAgBH,GAChClB,EAAYmB,GACZjB,EAAOoB,QAAUH,GAChBI,EAAAA,QAEI,KACDrB,EAAOoB,SACTF,IAAII,gBAAgBtB,EAAOoB,SAC3BpB,EAAOoB,QAAU,MAEjBV,EAAKa,MAAM,CACTC,KAAMC,EAAAA,aAAaC,UACnBC,QAAS,2BAId,CAAC1C,EAAYC,EAAWmB,EAAaC,EAAWZ,EAAgBQ,MAUjE0B,IAACC,EAAAA,UACEC,SAAAjC,GACC+B,EAAAA,IAAC,MAAA,CACCG,IAAKlC,EACLmC,OAZgB,KAClBhC,EAAOoB,UACTF,IAAII,gBAAgBtB,EAAOoB,SAC3BpB,EAAOoB,QAAU,UAUT5B,EACJD,MAAO,CACL0C,MAAO,OACPC,OAAQ,UACJ3C,GAAS,CAAA,MAMzB,wDD1H+B,IAAM4C,YAAwBpD,EAAAA,aAAaC"}
@@ -1,58 +1,62 @@
1
1
  import { jsx } from "preact/jsx-runtime";
2
2
  import { Fragment } from "preact";
3
- import { useState, useRef, useEffect } from "preact/hooks";
3
+ import { useState, useRef, useMemo, useEffect } from "preact/hooks";
4
4
  import { ignore, PdfErrorCode } from "@embedpdf/models";
5
- import { usePlugin, useCapability } from "@embedpdf/core/preact";
5
+ import { usePlugin, useCapability, useDocumentState } from "@embedpdf/core/preact";
6
6
  import { RenderPlugin } from "@embedpdf/plugin-render";
7
7
  export * from "@embedpdf/plugin-render";
8
8
  const useRenderPlugin = () => usePlugin(RenderPlugin.id);
9
9
  const useRenderCapability = () => useCapability(RenderPlugin.id);
10
10
  function RenderLayer({
11
+ documentId,
11
12
  pageIndex,
12
- scale,
13
- scaleFactor,
14
- dpr,
13
+ scale: scaleOverride,
14
+ dpr: dprOverride,
15
15
  style,
16
16
  ...props
17
17
  }) {
18
18
  const { provides: renderProvides } = useRenderCapability();
19
- const { plugin: renderPlugin } = useRenderPlugin();
20
- const actualScale = scale ?? scaleFactor ?? 1;
19
+ const documentState = useDocumentState(documentId);
21
20
  const [imageUrl, setImageUrl] = useState(null);
22
21
  const urlRef = useRef(null);
23
- const [refreshTick, setRefreshTick] = useState(0);
22
+ const refreshVersion = useMemo(() => {
23
+ if (!documentState) return 0;
24
+ return documentState.pageRefreshVersions[pageIndex] || 0;
25
+ }, [documentState, pageIndex]);
26
+ const actualScale = useMemo(() => {
27
+ if (scaleOverride !== void 0) return scaleOverride;
28
+ return (documentState == null ? void 0 : documentState.scale) ?? 1;
29
+ }, [scaleOverride, documentState == null ? void 0 : documentState.scale]);
30
+ const actualDpr = useMemo(() => {
31
+ if (dprOverride !== void 0) return dprOverride;
32
+ return window.devicePixelRatio;
33
+ }, [dprOverride]);
24
34
  useEffect(() => {
25
- if (!renderPlugin) return;
26
- return renderPlugin.onRefreshPages((pages) => {
27
- if (pages.includes(pageIndex)) {
28
- setRefreshTick((tick) => tick + 1);
35
+ if (!renderProvides) return;
36
+ const task = renderProvides.forDocument(documentId).renderPage({
37
+ pageIndex,
38
+ options: {
39
+ scaleFactor: actualScale,
40
+ dpr: actualDpr
29
41
  }
30
42
  });
31
- }, [renderPlugin]);
32
- useEffect(() => {
33
- if (renderProvides) {
34
- const task = renderProvides.renderPage({
35
- pageIndex,
36
- options: { scaleFactor: actualScale, dpr: dpr || window.devicePixelRatio }
37
- });
38
- task.wait((blob) => {
39
- const url = URL.createObjectURL(blob);
40
- setImageUrl(url);
41
- urlRef.current = url;
42
- }, ignore);
43
- return () => {
44
- if (urlRef.current) {
45
- URL.revokeObjectURL(urlRef.current);
46
- urlRef.current = null;
47
- } else {
48
- task.abort({
49
- code: PdfErrorCode.Cancelled,
50
- message: "canceled render task"
51
- });
52
- }
53
- };
54
- }
55
- }, [pageIndex, actualScale, dpr, renderProvides, refreshTick]);
43
+ task.wait((blob) => {
44
+ const url = URL.createObjectURL(blob);
45
+ setImageUrl(url);
46
+ urlRef.current = url;
47
+ }, ignore);
48
+ return () => {
49
+ if (urlRef.current) {
50
+ URL.revokeObjectURL(urlRef.current);
51
+ urlRef.current = null;
52
+ } else {
53
+ task.abort({
54
+ code: PdfErrorCode.Cancelled,
55
+ message: "canceled render task"
56
+ });
57
+ }
58
+ };
59
+ }, [documentId, pageIndex, actualScale, actualDpr, renderProvides, refreshVersion]);
56
60
  const handleImageLoad = () => {
57
61
  if (urlRef.current) {
58
62
  URL.revokeObjectURL(urlRef.current);
@@ -1 +1 @@
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, useRenderPlugin } from '../hooks/use-render';\n\ntype RenderLayerProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {\n pageIndex: number;\n /**\n * The scale factor for rendering the page.\n */\n scale?: number;\n /**\n * @deprecated Use `scale` instead. Will be removed in the next major release.\n */\n scaleFactor?: number;\n dpr?: number;\n style?: CSSProperties;\n};\n\nexport function RenderLayer({\n pageIndex,\n scale,\n scaleFactor,\n dpr,\n style,\n ...props\n}: RenderLayerProps) {\n const { provides: renderProvides } = useRenderCapability();\n const { plugin: renderPlugin } = useRenderPlugin();\n\n // Handle deprecation: prefer scale over scaleFactor, but fall back to scaleFactor if scale is not provided\n const actualScale = scale ?? scaleFactor ?? 1;\n\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n const [refreshTick, setRefreshTick] = useState(0);\n\n useEffect(() => {\n if (!renderPlugin) return;\n return renderPlugin.onRefreshPages((pages) => {\n if (pages.includes(pageIndex)) {\n setRefreshTick((tick) => tick + 1);\n }\n });\n }, [renderPlugin]);\n\n useEffect(() => {\n if (renderProvides) {\n const task = renderProvides.renderPage({\n pageIndex,\n options: { scaleFactor: actualScale, dpr: dpr || window.devicePixelRatio },\n });\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, actualScale, dpr, renderProvides, refreshTick]);\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;ACiB7E,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAqB;AACnB,QAAM,EAAE,UAAU,eAAe,IAAI,oBAAoB;AACzD,QAAM,EAAE,QAAQ,aAAa,IAAI,gBAAgB;AAG3C,QAAA,cAAc,SAAS,eAAe;AAE5C,QAAM,CAAC,UAAU,WAAW,IAAI,SAAwB,IAAI;AACtD,QAAA,SAAS,OAAsB,IAAI;AACzC,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,CAAC;AAEhD,YAAU,MAAM;AACd,QAAI,CAAC,aAAc;AACZ,WAAA,aAAa,eAAe,CAAC,UAAU;AACxC,UAAA,MAAM,SAAS,SAAS,GAAG;AACd,uBAAA,CAAC,SAAS,OAAO,CAAC;AAAA,MAAA;AAAA,IACnC,CACD;AAAA,EAAA,GACA,CAAC,YAAY,CAAC;AAEjB,YAAU,MAAM;AACd,QAAI,gBAAgB;AACZ,YAAA,OAAO,eAAe,WAAW;AAAA,QACrC;AAAA,QACA,SAAS,EAAE,aAAa,aAAa,KAAK,OAAO,OAAO,iBAAiB;AAAA,MAAA,CAC1E;AACI,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,EACF,GACC,CAAC,WAAW,aAAa,KAAK,gBAAgB,WAAW,CAAC;AAE7D,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;"}
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, useMemo } from '@framework';\nimport type { CSSProperties, HTMLAttributes } from '@framework';\n\nimport { ignore, PdfErrorCode, Rotation } from '@embedpdf/models';\n\nimport { useRenderCapability } from '../hooks/use-render';\nimport { useDocumentState } from '@embedpdf/core/@framework';\n\ntype RenderLayerProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {\n /**\n * The ID of the document to render from\n */\n documentId: string;\n /**\n * The page index to render (0-based)\n */\n pageIndex: number;\n /**\n * Optional scale override. If not provided, uses document's current scale.\n */\n scale?: number;\n /**\n * Optional device pixel ratio override. If not provided, uses window.devicePixelRatio.\n */\n dpr?: number;\n /**\n * Additional styles for the image element\n */\n style?: CSSProperties;\n};\n\n/**\n * RenderLayer Component\n *\n * Renders a PDF page with smart prop handling:\n * - If scale/dpr/rotation props are provided, they override document state\n * - If not provided, component uses document's current state values\n * - Automatically re-renders when:\n * 1. Document state changes (scale, rotation)\n * 2. Page is refreshed (via REFRESH_PAGES action in core)\n */\nexport function RenderLayer({\n documentId,\n pageIndex,\n scale: scaleOverride,\n dpr: dprOverride,\n style,\n ...props\n}: RenderLayerProps) {\n const { provides: renderProvides } = useRenderCapability();\n const documentState = useDocumentState(documentId);\n\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n // Get refresh version from core state\n const refreshVersion = useMemo(() => {\n if (!documentState) return 0;\n return documentState.pageRefreshVersions[pageIndex] || 0;\n }, [documentState, pageIndex]);\n\n // Determine actual render options: use overrides if provided, otherwise fall back to document state\n const actualScale = useMemo(() => {\n if (scaleOverride !== undefined) return scaleOverride;\n return documentState?.scale ?? 1;\n }, [scaleOverride, documentState?.scale]);\n\n const actualDpr = useMemo(() => {\n if (dprOverride !== undefined) return dprOverride;\n return window.devicePixelRatio;\n }, [dprOverride]);\n\n useEffect(() => {\n if (!renderProvides) return;\n\n const task = renderProvides.forDocument(documentId).renderPage({\n pageIndex,\n options: {\n scaleFactor: actualScale,\n dpr: actualDpr,\n },\n });\n\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 }, [documentId, pageIndex, actualScale, actualDpr, renderProvides, refreshVersion]);\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;ACqC7E,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,KAAK;AAAA,EACL;AAAA,EACA,GAAG;AACL,GAAqB;AACnB,QAAM,EAAE,UAAU,eAAA,IAAmB,oBAAA;AACrC,QAAM,gBAAgB,iBAAiB,UAAU;AAEjD,QAAM,CAAC,UAAU,WAAW,IAAI,SAAwB,IAAI;AAC5D,QAAM,SAAS,OAAsB,IAAI;AAGzC,QAAM,iBAAiB,QAAQ,MAAM;AACnC,QAAI,CAAC,cAAe,QAAO;AAC3B,WAAO,cAAc,oBAAoB,SAAS,KAAK;AAAA,EACzD,GAAG,CAAC,eAAe,SAAS,CAAC;AAG7B,QAAM,cAAc,QAAQ,MAAM;AAChC,QAAI,kBAAkB,OAAW,QAAO;AACxC,YAAO,+CAAe,UAAS;AAAA,EACjC,GAAG,CAAC,eAAe,+CAAe,KAAK,CAAC;AAExC,QAAM,YAAY,QAAQ,MAAM;AAC9B,QAAI,gBAAgB,OAAW,QAAO;AACtC,WAAO,OAAO;AAAA,EAChB,GAAG,CAAC,WAAW,CAAC;AAEhB,YAAU,MAAM;AACd,QAAI,CAAC,eAAgB;AAErB,UAAM,OAAO,eAAe,YAAY,UAAU,EAAE,WAAW;AAAA,MAC7D;AAAA,MACA,SAAS;AAAA,QACP,aAAa;AAAA,QACb,KAAK;AAAA,MAAA;AAAA,IACP,CACD;AAED,SAAK,KAAK,CAAC,SAAS;AAClB,YAAM,MAAM,IAAI,gBAAgB,IAAI;AACpC,kBAAY,GAAG;AACf,aAAO,UAAU;AAAA,IACnB,GAAG,MAAM;AAET,WAAO,MAAM;AACX,UAAI,OAAO,SAAS;AAClB,YAAI,gBAAgB,OAAO,OAAO;AAClC,eAAO,UAAU;AAAA,MACnB,OAAO;AACL,aAAK,MAAM;AAAA,UACT,MAAM,aAAa;AAAA,UACnB,SAAS;AAAA,QAAA,CACV;AAAA,MACH;AAAA,IACF;AAAA,EACF,GAAG,CAAC,YAAY,WAAW,aAAa,WAAW,gBAAgB,cAAc,CAAC;AAElF,QAAM,kBAAkB,MAAM;AAC5B,QAAI,OAAO,SAAS;AAClB,UAAI,gBAAgB,OAAO,OAAO;AAClC,aAAO,UAAU;AAAA,IACnB;AAAA,EACF;AAEA,SACE,oBAAC,YACE,UAAA,YACC;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;"}
@@ -1,2 +1,2 @@
1
- export { Fragment, useEffect, useRef, useState } from 'react';
1
+ export { Fragment, useEffect, useRef, useState, useMemo } from 'react';
2
2
  export type { CSSProperties, HTMLAttributes } from 'react';
@@ -1,2 +1,2 @@
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"),c=require("@embedpdf/plugin-render"),u=()=>n.usePlugin(c.RenderPlugin.id),s=()=>n.useCapability(c.RenderPlugin.id);exports.RenderLayer=function({pageIndex:n,scale:c,scaleFactor:o,dpr:i,style:d,...a}){const{provides:l}=s(),{plugin:p}=u(),g=c??o??1,[f,b]=r.useState(null),R=r.useRef(null),[x,y]=r.useState(0);return r.useEffect((()=>{if(p)return p.onRefreshPages((e=>{e.includes(n)&&y((e=>e+1))}))}),[p]),r.useEffect((()=>{if(l){const e=l.renderPage({pageIndex:n,options:{scaleFactor:g,dpr:i||window.devicePixelRatio}});return e.wait((e=>{const r=URL.createObjectURL(e);b(r),R.current=r}),t.ignore),()=>{R.current?(URL.revokeObjectURL(R.current),R.current=null):e.abort({code:t.PdfErrorCode.Cancelled,message:"canceled render task"})}}}),[n,g,i,l,x]),e.jsx(r.Fragment,{children:f&&e.jsx("img",{src:f,onLoad:()=>{R.current&&(URL.revokeObjectURL(R.current),R.current=null)},...a,style:{width:"100%",height:"100%",...d||{}}})})},exports.useRenderCapability=s,exports.useRenderPlugin=u,Object.keys(c).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>c[e]})}));
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"),o=require("@embedpdf/plugin-render"),u=()=>n.useCapability(o.RenderPlugin.id);exports.RenderLayer=function({documentId:o,pageIndex:s,scale:c,dpr:d,style:i,...l}){const{provides:a}=u(),p=n.useDocumentState(o),[g,m]=r.useState(null),b=r.useRef(null),f=r.useMemo(()=>p&&p.pageRefreshVersions[s]||0,[p,s]),R=r.useMemo(()=>void 0!==c?c:(null==p?void 0:p.scale)??1,[c,null==p?void 0:p.scale]),x=r.useMemo(()=>void 0!==d?d:window.devicePixelRatio,[d]);return r.useEffect(()=>{if(!a)return;const e=a.forDocument(o).renderPage({pageIndex:s,options:{scaleFactor:R,dpr:x}});return e.wait(e=>{const r=URL.createObjectURL(e);m(r),b.current=r},t.ignore),()=>{b.current?(URL.revokeObjectURL(b.current),b.current=null):e.abort({code:t.PdfErrorCode.Cancelled,message:"canceled render task"})}},[o,s,R,x,a,f]),e.jsx(r.Fragment,{children:g&&e.jsx("img",{src:g,onLoad:()=>{b.current&&(URL.revokeObjectURL(b.current),b.current=null)},...l,style:{width:"100%",height:"100%",...i||{}}})})},exports.useRenderCapability=u,exports.useRenderPlugin=()=>n.usePlugin(o.RenderPlugin.id),Object.keys(o).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>o[e]})});
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
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, useRenderPlugin } from '../hooks/use-render';\n\ntype RenderLayerProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {\n pageIndex: number;\n /**\n * The scale factor for rendering the page.\n */\n scale?: number;\n /**\n * @deprecated Use `scale` instead. Will be removed in the next major release.\n */\n scaleFactor?: number;\n dpr?: number;\n style?: CSSProperties;\n};\n\nexport function RenderLayer({\n pageIndex,\n scale,\n scaleFactor,\n dpr,\n style,\n ...props\n}: RenderLayerProps) {\n const { provides: renderProvides } = useRenderCapability();\n const { plugin: renderPlugin } = useRenderPlugin();\n\n // Handle deprecation: prefer scale over scaleFactor, but fall back to scaleFactor if scale is not provided\n const actualScale = scale ?? scaleFactor ?? 1;\n\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n const [refreshTick, setRefreshTick] = useState(0);\n\n useEffect(() => {\n if (!renderPlugin) return;\n return renderPlugin.onRefreshPages((pages) => {\n if (pages.includes(pageIndex)) {\n setRefreshTick((tick) => tick + 1);\n }\n });\n }, [renderPlugin]);\n\n useEffect(() => {\n if (renderProvides) {\n const task = renderProvides.renderPage({\n pageIndex,\n options: { scaleFactor: actualScale, dpr: dpr || window.devicePixelRatio },\n });\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, actualScale, dpr, renderProvides, refreshTick]);\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":["useRenderPlugin","usePlugin","RenderPlugin","id","useRenderCapability","useCapability","pageIndex","scale","scaleFactor","dpr","style","props","provides","renderProvides","plugin","renderPlugin","actualScale","imageUrl","setImageUrl","useState","urlRef","useRef","refreshTick","setRefreshTick","useEffect","onRefreshPages","pages","includes","tick","task","renderPage","options","window","devicePixelRatio","wait","blob","url","URL","createObjectURL","current","ignore","revokeObjectURL","abort","code","PdfErrorCode","Cancelled","message","jsx","Fragment","children","jsxRuntime","src","onLoad","width","height"],"mappings":"6OAGaA,EAAkB,IAAMC,YAAwBC,EAAAA,aAAaC,IAC7DC,EAAsB,IAAMC,gBAA4BH,EAAAA,aAAaC,wBCiB3E,UAAqBG,UAC1BA,EAAAC,MACAA,EAAAC,YACAA,EAAAC,IACAA,EAAAC,MACAA,KACGC,IAEH,MAAQC,SAAUC,GAAmBT,KAC7BU,OAAQC,GAAiBf,IAG3BgB,EAAcT,GAASC,GAAe,GAErCS,EAAUC,GAAeC,EAAAA,SAAwB,MAClDC,EAASC,SAAsB,OAC9BC,EAAaC,GAAkBJ,EAAAA,SAAS,GA6C7C,OA3CFK,EAAAA,WAAU,KACR,GAAKT,EACE,OAAAA,EAAaU,gBAAgBC,IAC9BA,EAAMC,SAASrB,IACFiB,GAACK,GAASA,EAAO,GAAC,GAEpC,GACA,CAACb,IAEJS,EAAAA,WAAU,KACR,GAAIX,EAAgB,CACZ,MAAAgB,EAAOhB,EAAeiB,WAAW,CACrCxB,YACAyB,QAAS,CAAEvB,YAAaQ,EAAaP,IAAKA,GAAOuB,OAAOC,oBAQ1D,OANKJ,EAAAK,MAAMC,IACH,MAAAC,EAAMC,IAAIC,gBAAgBH,GAChCjB,EAAYkB,GACZhB,EAAOmB,QAAUH,CAAA,GAChBI,UAEI,KACDpB,EAAOmB,SACLF,IAAAI,gBAAgBrB,EAAOmB,SAC3BnB,EAAOmB,QAAU,MAEjBV,EAAKa,MAAM,CACTC,KAAMC,EAAaA,aAAAC,UACnBC,QAAS,wBACV,CAEL,IAED,CAACxC,EAAWU,EAAaP,EAAKI,EAAgBS,MAU/CyB,IAACC,YACEC,SACChC,GAAAiC,EAAAH,IAAC,MAAA,CACCI,IAAKlC,EACLmC,OAZgB,KAClBhC,EAAOmB,UACLF,IAAAI,gBAAgBrB,EAAOmB,SAC3BnB,EAAOmB,QAAU,KAAA,KAUT5B,EACJD,MAAO,CACL2C,MAAO,OACPC,OAAQ,UACJ5C,GAAS,CAAA,MAMzB"}
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, useMemo } from '@framework';\nimport type { CSSProperties, HTMLAttributes } from '@framework';\n\nimport { ignore, PdfErrorCode, Rotation } from '@embedpdf/models';\n\nimport { useRenderCapability } from '../hooks/use-render';\nimport { useDocumentState } from '@embedpdf/core/@framework';\n\ntype RenderLayerProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {\n /**\n * The ID of the document to render from\n */\n documentId: string;\n /**\n * The page index to render (0-based)\n */\n pageIndex: number;\n /**\n * Optional scale override. If not provided, uses document's current scale.\n */\n scale?: number;\n /**\n * Optional device pixel ratio override. If not provided, uses window.devicePixelRatio.\n */\n dpr?: number;\n /**\n * Additional styles for the image element\n */\n style?: CSSProperties;\n};\n\n/**\n * RenderLayer Component\n *\n * Renders a PDF page with smart prop handling:\n * - If scale/dpr/rotation props are provided, they override document state\n * - If not provided, component uses document's current state values\n * - Automatically re-renders when:\n * 1. Document state changes (scale, rotation)\n * 2. Page is refreshed (via REFRESH_PAGES action in core)\n */\nexport function RenderLayer({\n documentId,\n pageIndex,\n scale: scaleOverride,\n dpr: dprOverride,\n style,\n ...props\n}: RenderLayerProps) {\n const { provides: renderProvides } = useRenderCapability();\n const documentState = useDocumentState(documentId);\n\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n // Get refresh version from core state\n const refreshVersion = useMemo(() => {\n if (!documentState) return 0;\n return documentState.pageRefreshVersions[pageIndex] || 0;\n }, [documentState, pageIndex]);\n\n // Determine actual render options: use overrides if provided, otherwise fall back to document state\n const actualScale = useMemo(() => {\n if (scaleOverride !== undefined) return scaleOverride;\n return documentState?.scale ?? 1;\n }, [scaleOverride, documentState?.scale]);\n\n const actualDpr = useMemo(() => {\n if (dprOverride !== undefined) return dprOverride;\n return window.devicePixelRatio;\n }, [dprOverride]);\n\n useEffect(() => {\n if (!renderProvides) return;\n\n const task = renderProvides.forDocument(documentId).renderPage({\n pageIndex,\n options: {\n scaleFactor: actualScale,\n dpr: actualDpr,\n },\n });\n\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 }, [documentId, pageIndex, actualScale, actualDpr, renderProvides, refreshVersion]);\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","documentId","pageIndex","scale","scaleOverride","dpr","dprOverride","style","props","provides","renderProvides","documentState","useDocumentState","imageUrl","setImageUrl","useState","urlRef","useRef","refreshVersion","useMemo","pageRefreshVersions","actualScale","actualDpr","window","devicePixelRatio","useEffect","task","forDocument","renderPage","options","scaleFactor","wait","blob","url","URL","createObjectURL","current","ignore","revokeObjectURL","abort","code","PdfErrorCode","Cancelled","message","jsx","Fragment","children","src","onLoad","width","height","usePlugin"],"mappings":"6OAIaA,EAAsB,IAAMC,gBAA4BC,EAAAA,aAAaC,wBCqC3E,UAAqBC,WAC1BA,EAAAC,UACAA,EACAC,MAAOC,EACPC,IAAKC,EAAAC,MACLA,KACGC,IAEH,MAAQC,SAAUC,GAAmBb,IAC/Bc,EAAgBC,EAAAA,iBAAiBX,IAEhCY,EAAUC,GAAeC,EAAAA,SAAwB,MAClDC,EAASC,EAAAA,OAAsB,MAG/BC,EAAiBC,EAAAA,QAAQ,IACxBR,GACEA,EAAcS,oBAAoBlB,IADd,EAE1B,CAACS,EAAeT,IAGbmB,EAAcF,EAAAA,QAAQ,SACJ,IAAlBf,EAAoCA,SACjCO,WAAeR,QAAS,EAC9B,CAACC,EAAe,MAAAO,OAAA,EAAAA,EAAeR,QAE5BmB,EAAYH,EAAAA,QAAQ,SACJ,IAAhBb,EAAkCA,EAC/BiB,OAAOC,iBACb,CAAClB,IAuCJ,OArCAmB,EAAAA,UAAU,KACR,IAAKf,EAAgB,OAErB,MAAMgB,EAAOhB,EAAeiB,YAAY1B,GAAY2B,WAAW,CAC7D1B,YACA2B,QAAS,CACPC,YAAaT,EACbhB,IAAKiB,KAUT,OANAI,EAAKK,KAAMC,IACT,MAAMC,EAAMC,IAAIC,gBAAgBH,GAChClB,EAAYmB,GACZjB,EAAOoB,QAAUH,GAChBI,EAAAA,QAEI,KACDrB,EAAOoB,SACTF,IAAII,gBAAgBtB,EAAOoB,SAC3BpB,EAAOoB,QAAU,MAEjBV,EAAKa,MAAM,CACTC,KAAMC,EAAAA,aAAaC,UACnBC,QAAS,2BAId,CAAC1C,EAAYC,EAAWmB,EAAaC,EAAWZ,EAAgBQ,MAUjE0B,IAACC,EAAAA,UACEC,SAAAjC,GACC+B,EAAAA,IAAC,MAAA,CACCG,IAAKlC,EACLmC,OAZgB,KAClBhC,EAAOoB,UACTF,IAAII,gBAAgBtB,EAAOoB,SAC3BpB,EAAOoB,QAAU,UAUT5B,EACJD,MAAO,CACL0C,MAAO,OACPC,OAAQ,UACJ3C,GAAS,CAAA,MAMzB,wDD1H+B,IAAM4C,YAAwBpD,EAAAA,aAAaC"}