@embedpdf/plugin-render 2.6.0 → 2.6.2
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 +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +42 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/render-plugin.d.ts +2 -0
- package/dist/lib/types.d.ts +5 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),n=class extends e.BasePlugin{constructor(e,n,t){super(e,n),this.config=t}buildCapability(){return{renderPage:e=>this.renderPage(e),renderPageRect:e=>this.renderPageRect(e),forDocument:e=>this.createRenderScope(e)}}createRenderScope(e){return{renderPage:n=>this.renderPage(n,e),renderPageRect:n=>this.renderPageRect(n,e)}}renderPage({pageIndex:e,options:n},t){const i=t??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(n=>n.index===e);if(!r)throw new Error(`Page ${e} not found in document ${i}`);const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),n=class extends e.BasePlugin{constructor(e,n,t){super(e,n),this.config=t}buildCapability(){return{renderPage:e=>this.renderPage(e),renderPageRect:e=>this.renderPageRect(e),renderPageRaw:e=>this.renderPageRaw(e),renderPageRectRaw:e=>this.renderPageRectRaw(e),forDocument:e=>this.createRenderScope(e)}}createRenderScope(e){return{renderPage:n=>this.renderPage(n,e),renderPageRect:n=>this.renderPageRect(n,e),renderPageRaw:n=>this.renderPageRaw(n,e),renderPageRectRaw:n=>this.renderPageRectRaw(n,e)}}renderPage({pageIndex:e,options:n},t){const i=t??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(n=>n.index===e);if(!r)throw new Error(`Page ${e} not found in document ${i}`);const d={...n??{},withForms:(null==n?void 0:n.withForms)??this.config.withForms??!1,withAnnotations:(null==n?void 0:n.withAnnotations)??this.config.withAnnotations??!1,imageType:(null==n?void 0:n.imageType)??this.config.defaultImageType??"image/png",imageQuality:(null==n?void 0:n.imageQuality)??this.config.defaultImageQuality??.92};return this.engine.renderPage(o.document,r,d)}renderPageRect({pageIndex:e,rect:n,options:t},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 d=r.document.pages.find(n=>n.index===e);if(!d)throw new Error(`Page ${e} not found in document ${o}`);const a={...t??{},withForms:(null==t?void 0:t.withForms)??this.config.withForms??!1,withAnnotations:(null==t?void 0:t.withAnnotations)??this.config.withAnnotations??!1,imageType:(null==t?void 0:t.imageType)??this.config.defaultImageType??"image/png",imageQuality:(null==t?void 0:t.imageQuality)??this.config.defaultImageQuality??.92};return this.engine.renderPageRect(r.document,d,n,a)}renderPageRaw({pageIndex:e,options:n},t){const i=t??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(n=>n.index===e);if(!r)throw new Error(`Page ${e} not found in document ${i}`);const d={...n??{},withForms:(null==n?void 0:n.withForms)??this.config.withForms??!1,withAnnotations:(null==n?void 0:n.withAnnotations)??this.config.withAnnotations??!1};return this.engine.renderPageRaw(o.document,r,d)}renderPageRectRaw({pageIndex:e,rect:n,options:t},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 d=r.document.pages.find(n=>n.index===e);if(!d)throw new Error(`Page ${e} not found in document ${o}`);const a={...t??{},withForms:(null==t?void 0:t.withForms)??this.config.withForms??!1,withAnnotations:(null==t?void 0:t.withAnnotations)??this.config.withAnnotations??!1};return this.engine.renderPageRectRaw(r.document,d,n,a)}async initialize(e){this.logger.info("RenderPlugin","Initialize","Render plugin initialized")}async destroy(){super.destroy()}};n.id="render";let t=n;const i="render",o={manifest:{id:i,name:"Render Plugin",version:"1.0.0",provides:["render"],requires:[],optional:[],defaultConfig:{}},create:(e,n)=>new t(i,e,n),reducer:()=>{},initialState:{}};exports.RenderPlugin=t,exports.RenderPluginPackage=o;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 config: RenderPluginConfig;\n\n constructor(id: string, registry: PluginRegistry, config: RenderPluginConfig) {\n super(id, registry);\n this.config = config;\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.config.withForms ?? false,\n withAnnotations: options?.withAnnotations ?? this.config.withAnnotations ?? false,\n imageType: options?.imageType ?? this.config.defaultImageType ?? 'image/png',\n imageQuality: options?.imageQuality ?? this.config.defaultImageQuality ?? 0.92,\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.config.withForms ?? false,\n withAnnotations: options?.withAnnotations ?? this.config.withAnnotations ?? false,\n imageType: options?.imageType ?? this.config.defaultImageType ?? 'image/png',\n imageQuality: options?.imageQuality ?? this.config.defaultImageQuality ?? 0.92,\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};\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","buildCapability","renderPage","options","renderPageRect","forDocument","documentId","createRenderScope","pageIndex","getActiveDocumentId","coreDoc","coreState","core","documents","document","Error","page","pages","find","p","index","mergedOptions","withForms","withAnnotations","imageType","defaultImageType","imageQuality","defaultImageQuality","engine","rect","initialize","_config","logger","info","destroy","RenderPlugin","RENDER_PLUGIN_ID","RenderPluginPackage","manifest","name","version","provides","requires","optional","defaultConfig","create","reducer","initialState"],"mappings":"kHAeaA,EAAN,cAA2BC,EAAAA,WAKhC,WAAAC,CAAYC,EAAYC,EAA0BC,GAChDC,MAAMH,EAAIC,GACVG,KAAKF,OAASA,CAChB,CAIU,eAAAG,GACR,MAAO,CAELC,WAAaC,GAA+BH,KAAKE,WAAWC,GAC5DC,eAAiBD,GAAmCH,KAAKI,eAAeD,GAGxEE,YAAcC,GAAuBN,KAAKO,kBAAkBD,GAEhE,CAMQ,iBAAAC,CAAkBD,GACxB,MAAO,CACLJ,WAAaC,GAA+BH,KAAKE,WAAWC,EAASG,GACrEF,eAAiBD,GAAmCH,KAAKI,eAAeD,EAASG,GAErF,CAMQ,UAAAJ,EAAWM,UAAEA,EAAAL,QAAWA,GAA8BG,GAC5D,MAAMV,EAAKU,GAAcN,KAAKS,sBACxB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kBAAoB,YACjEC,cAAc,MAAAvB,OAAA,EAAAA,EAASuB,eAAgB1B,KAAKF,OAAO6B,qBAAuB,KAG5E,OAAO3B,KAAK4B,OAAOxB,eAAeM,EAAQI,SAAUE,EAAMa,EAAMR,EAClE,CAMA,gBAAMS,CAAWC,GACf/B,KAAKgC,OAAOC,KAAK,eAAgB,aAAc,4BACjD,CAEA,aAAMC,GACJnC,MAAMmC,SACR,GA/FAzC,EAAgBG,GAAK,SADhB,IAAMuC,EAAN1C,ECZA,MAAM2C,EAAmB,SCEnBC,EAAuE,CAClFC,SDD0D,CAC1D1C,GAAIwC,EACJG,KAAM,gBACNC,QAAS,QACTC,SAAU,CAAC,UACXC,SAAU,GACVC,SAAU,GACVC,cAAe,CAAA,GCLfC,OAAQ,CAAChD,EAAUC,IAAW,IAAIqC,EAAaC,EAAkBvC,EAAUC,GAC3EgD,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 config: RenderPluginConfig;\n\n constructor(id: string, registry: PluginRegistry, config: RenderPluginConfig) {\n super(id, registry);\n this.config = config;\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 renderPageRaw: (options: RenderPageOptions) => this.renderPageRaw(options),\n renderPageRectRaw: (options: RenderPageRectOptions) => this.renderPageRectRaw(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 renderPageRaw: (options: RenderPageOptions) => this.renderPageRaw(options, documentId),\n renderPageRectRaw: (options: RenderPageRectOptions) =>\n this.renderPageRectRaw(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.config.withForms ?? false,\n withAnnotations: options?.withAnnotations ?? this.config.withAnnotations ?? false,\n imageType: options?.imageType ?? this.config.defaultImageType ?? 'image/png',\n imageQuality: options?.imageQuality ?? this.config.defaultImageQuality ?? 0.92,\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.config.withForms ?? false,\n withAnnotations: options?.withAnnotations ?? this.config.withAnnotations ?? false,\n imageType: options?.imageType ?? this.config.defaultImageType ?? 'image/png',\n imageQuality: options?.imageQuality ?? this.config.defaultImageQuality ?? 0.92,\n };\n\n return this.engine.renderPageRect(coreDoc.document, page, rect, mergedOptions);\n }\n\n // ─────────────────────────────────────────────────────────\n // Raw Rendering (returns ImageDataLike, skips encoding)\n // ─────────────────────────────────────────────────────────\n\n private renderPageRaw({ 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.config.withForms ?? false,\n withAnnotations: options?.withAnnotations ?? this.config.withAnnotations ?? false,\n };\n\n return this.engine.renderPageRaw(coreDoc.document, page, mergedOptions);\n }\n\n private renderPageRectRaw(\n { pageIndex, rect, options }: RenderPageRectOptions,\n documentId?: string,\n ) {\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.config.withForms ?? false,\n withAnnotations: options?.withAnnotations ?? this.config.withAnnotations ?? false,\n };\n\n return this.engine.renderPageRectRaw(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};\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","buildCapability","renderPage","options","renderPageRect","renderPageRaw","renderPageRectRaw","forDocument","documentId","createRenderScope","pageIndex","getActiveDocumentId","coreDoc","coreState","core","documents","document","Error","page","pages","find","p","index","mergedOptions","withForms","withAnnotations","imageType","defaultImageType","imageQuality","defaultImageQuality","engine","rect","initialize","_config","logger","info","destroy","RenderPlugin","RENDER_PLUGIN_ID","RenderPluginPackage","manifest","name","version","provides","requires","optional","defaultConfig","create","reducer","initialState"],"mappings":"kHAeaA,EAAN,cAA2BC,EAAAA,WAKhC,WAAAC,CAAYC,EAAYC,EAA0BC,GAChDC,MAAMH,EAAIC,GACVG,KAAKF,OAASA,CAChB,CAIU,eAAAG,GACR,MAAO,CAELC,WAAaC,GAA+BH,KAAKE,WAAWC,GAC5DC,eAAiBD,GAAmCH,KAAKI,eAAeD,GACxEE,cAAgBF,GAA+BH,KAAKK,cAAcF,GAClEG,kBAAoBH,GAAmCH,KAAKM,kBAAkBH,GAG9EI,YAAcC,GAAuBR,KAAKS,kBAAkBD,GAEhE,CAMQ,iBAAAC,CAAkBD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M,IAAIC,MAAM,YAAYrB,gBAG9B,MAAMsB,EAAON,EAAQI,SAASG,MAAMC,KAAMC,GAAMA,EAAEC,QAAUZ,GAC5D,IAAKQ,EACH,MAAM,IAAID,MAAM,QAAQP,2BAAmCd,KAG7D,MAAM2B,EAAgB,IAChBpB,GAAW,CAAA,EACfqB,WAAW,MAAArB,OAAA,EAAAA,EAASqB,YAAaxB,KAAKF,OAAO0B,YAAa,EAC1DC,iBAAiB,MAAAtB,OAAA,EAAAA,EAASsB,kBAAmBzB,KAAKF,OAAO2B,kBAAmB,GAG9E,OAAOzB,KAAK8B,OAAOxB,kBAAkBM,EAAQI,SAAUE,EAAMa,EAAMR,EACrE,CAMA,gBAAMS,CAAWC,GACfjC,KAAKkC,OAAOC,KAAK,eAAgB,aAAc,4BACjD,CAEA,aAAMC,GACJrC,MAAMqC,SACR,GAvJA3C,EAAgBG,GAAK,SADhB,IAAMyC,EAAN5C,ECZA,MAAM6C,EAAmB,SCEnBC,EAAuE,CAClFC,SDD0D,CAC1D5C,GAAI0C,EACJG,KAAM,gBACNC,QAAS,QACTC,SAAU,CAAC,UACXC,SAAU,GACVC,SAAU,GACVC,cAAe,CAAA,GCLfC,OAAQ,CAAClD,EAAUC,IAAW,IAAIuC,EAAaC,EAAkBzC,EAAUC,GAC3EkD,QAAS,OACTC,aAAc,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,8 @@ const _RenderPlugin = class _RenderPlugin extends BasePlugin {
|
|
|
10
10
|
// Active document operations
|
|
11
11
|
renderPage: (options) => this.renderPage(options),
|
|
12
12
|
renderPageRect: (options) => this.renderPageRect(options),
|
|
13
|
+
renderPageRaw: (options) => this.renderPageRaw(options),
|
|
14
|
+
renderPageRectRaw: (options) => this.renderPageRectRaw(options),
|
|
13
15
|
// Document-scoped operations
|
|
14
16
|
forDocument: (documentId) => this.createRenderScope(documentId)
|
|
15
17
|
};
|
|
@@ -20,7 +22,9 @@ const _RenderPlugin = class _RenderPlugin extends BasePlugin {
|
|
|
20
22
|
createRenderScope(documentId) {
|
|
21
23
|
return {
|
|
22
24
|
renderPage: (options) => this.renderPage(options, documentId),
|
|
23
|
-
renderPageRect: (options) => this.renderPageRect(options, documentId)
|
|
25
|
+
renderPageRect: (options) => this.renderPageRect(options, documentId),
|
|
26
|
+
renderPageRaw: (options) => this.renderPageRaw(options, documentId),
|
|
27
|
+
renderPageRectRaw: (options) => this.renderPageRectRaw(options, documentId)
|
|
24
28
|
};
|
|
25
29
|
}
|
|
26
30
|
// ─────────────────────────────────────────────────────────
|
|
@@ -65,6 +69,43 @@ const _RenderPlugin = class _RenderPlugin extends BasePlugin {
|
|
|
65
69
|
return this.engine.renderPageRect(coreDoc.document, page, rect, mergedOptions);
|
|
66
70
|
}
|
|
67
71
|
// ─────────────────────────────────────────────────────────
|
|
72
|
+
// Raw Rendering (returns ImageDataLike, skips encoding)
|
|
73
|
+
// ─────────────────────────────────────────────────────────
|
|
74
|
+
renderPageRaw({ pageIndex, options }, documentId) {
|
|
75
|
+
const id = documentId ?? this.getActiveDocumentId();
|
|
76
|
+
const coreDoc = this.coreState.core.documents[id];
|
|
77
|
+
if (!(coreDoc == null ? void 0 : coreDoc.document)) {
|
|
78
|
+
throw new Error(`Document ${id} not loaded`);
|
|
79
|
+
}
|
|
80
|
+
const page = coreDoc.document.pages.find((p) => p.index === pageIndex);
|
|
81
|
+
if (!page) {
|
|
82
|
+
throw new Error(`Page ${pageIndex} not found in document ${id}`);
|
|
83
|
+
}
|
|
84
|
+
const mergedOptions = {
|
|
85
|
+
...options ?? {},
|
|
86
|
+
withForms: (options == null ? void 0 : options.withForms) ?? this.config.withForms ?? false,
|
|
87
|
+
withAnnotations: (options == null ? void 0 : options.withAnnotations) ?? this.config.withAnnotations ?? false
|
|
88
|
+
};
|
|
89
|
+
return this.engine.renderPageRaw(coreDoc.document, page, mergedOptions);
|
|
90
|
+
}
|
|
91
|
+
renderPageRectRaw({ pageIndex, rect, options }, documentId) {
|
|
92
|
+
const id = documentId ?? this.getActiveDocumentId();
|
|
93
|
+
const coreDoc = this.coreState.core.documents[id];
|
|
94
|
+
if (!(coreDoc == null ? void 0 : coreDoc.document)) {
|
|
95
|
+
throw new Error(`Document ${id} not loaded`);
|
|
96
|
+
}
|
|
97
|
+
const page = coreDoc.document.pages.find((p) => p.index === pageIndex);
|
|
98
|
+
if (!page) {
|
|
99
|
+
throw new Error(`Page ${pageIndex} not found in document ${id}`);
|
|
100
|
+
}
|
|
101
|
+
const mergedOptions = {
|
|
102
|
+
...options ?? {},
|
|
103
|
+
withForms: (options == null ? void 0 : options.withForms) ?? this.config.withForms ?? false,
|
|
104
|
+
withAnnotations: (options == null ? void 0 : options.withAnnotations) ?? this.config.withAnnotations ?? false
|
|
105
|
+
};
|
|
106
|
+
return this.engine.renderPageRectRaw(coreDoc.document, page, rect, mergedOptions);
|
|
107
|
+
}
|
|
108
|
+
// ─────────────────────────────────────────────────────────
|
|
68
109
|
// Lifecycle
|
|
69
110
|
// ─────────────────────────────────────────────────────────
|
|
70
111
|
async initialize(_config) {
|
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 { 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 config: RenderPluginConfig;\n\n constructor(id: string, registry: PluginRegistry, config: RenderPluginConfig) {\n super(id, registry);\n this.config = config;\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.config.withForms ?? false,\n withAnnotations: options?.withAnnotations ?? this.config.withAnnotations ?? false,\n imageType: options?.imageType ?? this.config.defaultImageType ?? 'image/png',\n imageQuality: options?.imageQuality ?? this.config.defaultImageQuality ?? 0.92,\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.config.withForms ?? false,\n withAnnotations: options?.withAnnotations ?? this.config.withAnnotations ?? false,\n imageType: options?.imageType ?? this.config.defaultImageType ?? 'image/png',\n imageQuality: options?.imageQuality ?? this.config.defaultImageQuality ?? 0.92,\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};\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,EAKjF,YAAY,IAAY,UAA0B,QAA4B;AAC5E,UAAM,IAAI,QAAQ;AAClB,SAAK,SAAS;AAAA,EAChB;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;A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M;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,OAAO,aAAa;AAAA,MAC1D,kBAAiB,mCAAS,oBAAmB,KAAK,OAAO,mBAAmB;AAAA,MAC5E,YAAW,mCAAS,cAAa,KAAK,OAAO,oBAAoB;AAAA,MACjE,eAAc,mCAAS,iBAAgB,KAAK,OAAO,uBAAuB;AAAA,IAAA;AAG5E,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;AAhGE,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,CAAA;AACjB;ACRO,MAAM,sBAAuE;AAAA,EAClF;AAAA,EACA,QAAQ,CAAC,UAAU,WAAW,IAAI,aAAa,kBAAkB,UAAU,MAAM;AAAA,EACjF,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,cAAc,CAAA;AAChB;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/lib/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 config: RenderPluginConfig;\n\n constructor(id: string, registry: PluginRegistry, config: RenderPluginConfig) {\n super(id, registry);\n this.config = config;\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 renderPageRaw: (options: RenderPageOptions) => this.renderPageRaw(options),\n renderPageRectRaw: (options: RenderPageRectOptions) => this.renderPageRectRaw(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 renderPageRaw: (options: RenderPageOptions) => this.renderPageRaw(options, documentId),\n renderPageRectRaw: (options: RenderPageRectOptions) =>\n this.renderPageRectRaw(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.config.withForms ?? false,\n withAnnotations: options?.withAnnotations ?? this.config.withAnnotations ?? false,\n imageType: options?.imageType ?? this.config.defaultImageType ?? 'image/png',\n imageQuality: options?.imageQuality ?? this.config.defaultImageQuality ?? 0.92,\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.config.withForms ?? false,\n withAnnotations: options?.withAnnotations ?? this.config.withAnnotations ?? false,\n imageType: options?.imageType ?? this.config.defaultImageType ?? 'image/png',\n imageQuality: options?.imageQuality ?? this.config.defaultImageQuality ?? 0.92,\n };\n\n return this.engine.renderPageRect(coreDoc.document, page, rect, mergedOptions);\n }\n\n // ─────────────────────────────────────────────────────────\n // Raw Rendering (returns ImageDataLike, skips encoding)\n // ─────────────────────────────────────────────────────────\n\n private renderPageRaw({ 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.config.withForms ?? false,\n withAnnotations: options?.withAnnotations ?? this.config.withAnnotations ?? false,\n };\n\n return this.engine.renderPageRaw(coreDoc.document, page, mergedOptions);\n }\n\n private renderPageRectRaw(\n { pageIndex, rect, options }: RenderPageRectOptions,\n documentId?: string,\n ) {\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.config.withForms ?? false,\n withAnnotations: options?.withAnnotations ?? this.config.withAnnotations ?? false,\n };\n\n return this.engine.renderPageRectRaw(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};\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,EAKjF,YAAY,IAAY,UAA0B,QAA4B;AAC5E,UAAM,IAAI,QAAQ;AAClB,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA,EAIU,kBAAoC;AAC5C,WAAO;AAAA;AAAA,MAEL,YAAY,CAAC,YAA+B,KAAK,WAAW,OAAO;AAAA,MACnE,gBAAgB,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AU,CAAA;AAAA,EACV,eAAe,CAAA;AACjB;ACRO,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;"}
|
|
@@ -14,6 +14,8 @@ export declare class RenderPlugin extends BasePlugin<RenderPluginConfig, RenderC
|
|
|
14
14
|
private createRenderScope;
|
|
15
15
|
private renderPage;
|
|
16
16
|
private renderPageRect;
|
|
17
|
+
private renderPageRaw;
|
|
18
|
+
private renderPageRectRaw;
|
|
17
19
|
initialize(_config: RenderPluginConfig): Promise<void>;
|
|
18
20
|
destroy(): Promise<void>;
|
|
19
21
|
}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BasePluginConfig } from '@embedpdf/core';
|
|
2
|
-
import { ImageConversionTypes, PdfErrorReason, PdfRenderPageOptions, Rect, Task } from '@embedpdf/models';
|
|
2
|
+
import { ImageConversionTypes, ImageDataLike, PdfErrorReason, PdfRenderPageOptions, Rect, Task } from '@embedpdf/models';
|
|
3
3
|
export interface RenderPluginConfig extends BasePluginConfig {
|
|
4
4
|
/**
|
|
5
5
|
* Initialize and draw form widgets during renders.
|
|
@@ -34,9 +34,13 @@ export interface RenderPageOptions {
|
|
|
34
34
|
export interface RenderScope {
|
|
35
35
|
renderPage(options: RenderPageOptions): Task<Blob, PdfErrorReason>;
|
|
36
36
|
renderPageRect(options: RenderPageRectOptions): Task<Blob, PdfErrorReason>;
|
|
37
|
+
renderPageRaw(options: RenderPageOptions): Task<ImageDataLike, PdfErrorReason>;
|
|
38
|
+
renderPageRectRaw(options: RenderPageRectOptions): Task<ImageDataLike, PdfErrorReason>;
|
|
37
39
|
}
|
|
38
40
|
export interface RenderCapability {
|
|
39
41
|
renderPage(options: RenderPageOptions): Task<Blob, PdfErrorReason>;
|
|
40
42
|
renderPageRect(options: RenderPageRectOptions): Task<Blob, PdfErrorReason>;
|
|
43
|
+
renderPageRaw(options: RenderPageOptions): Task<ImageDataLike, PdfErrorReason>;
|
|
44
|
+
renderPageRectRaw(options: RenderPageRectOptions): Task<ImageDataLike, PdfErrorReason>;
|
|
41
45
|
forDocument(documentId: string): RenderScope;
|
|
42
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-render",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@embedpdf/models": "2.6.
|
|
38
|
+
"@embedpdf/models": "2.6.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/react": "^18.2.0",
|
|
42
42
|
"typescript": "^5.0.0",
|
|
43
|
-
"@embedpdf/
|
|
44
|
-
"@embedpdf/
|
|
43
|
+
"@embedpdf/core": "2.6.2",
|
|
44
|
+
"@embedpdf/build": "1.1.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"preact": "^10.26.4",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"react-dom": ">=16.8.0",
|
|
50
50
|
"vue": ">=3.2.0",
|
|
51
51
|
"svelte": ">=5 <6",
|
|
52
|
-
"@embedpdf/core": "2.6.
|
|
52
|
+
"@embedpdf/core": "2.6.2"
|
|
53
53
|
},
|
|
54
54
|
"files": [
|
|
55
55
|
"dist",
|