@embedpdf/plugin-scroll 1.0.19 → 1.0.21

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/preact"),t=require("@embedpdf/plugin-scroll");require("preact");const r=require("preact/hooks"),i=require("preact/jsx-runtime"),o=()=>e.usePlugin(t.ScrollPlugin.id),l=()=>e.useCapability(t.ScrollPlugin.id);exports.Scroller=function({renderPage:a,overlayElements:n,...s}){const{provides:c}=l(),{plugin:g}=o(),{registry:u}=e.useRegistry(),[d,p]=r.useState((()=>(null==c?void 0:c.getScrollerLayout())??null));if(r.useEffect((()=>{if(c)return c.onScrollerData(p)}),[c]),r.useEffect((()=>{g&&g.setLayoutReady()}),[g]),!d)return null;if(!u)return null;const h=u.getStore().getState();return i.jsxs("div",{...s,style:{width:`${d.totalWidth}px`,height:`${d.totalHeight}px`,position:"relative",boxSizing:"border-box",margin:"0 auto",...d.strategy===t.ScrollStrategy.Horizontal&&{display:"flex",flexDirection:"row"}},children:[i.jsx("div",{style:{...d.strategy===t.ScrollStrategy.Horizontal?{width:d.startSpacing,height:"100%",flexShrink:0}:{height:d.startSpacing,width:"100%"}}}),i.jsx("div",{style:{gap:d.pageGap,display:"flex",alignItems:"center",position:"relative",boxSizing:"border-box",...d.strategy===t.ScrollStrategy.Horizontal?{flexDirection:"row",minHeight:"100%"}:{flexDirection:"column",minWidth:"fit-content"}},children:d.items.map((e=>i.jsx("div",{style:{display:"flex",justifyContent:"center",gap:d.pageGap},children:e.pageLayouts.map((e=>i.jsx("div",{style:{width:`${e.rotatedWidth}px`,height:`${e.rotatedHeight}px`},children:a({...e,rotation:h.core.rotation,scale:h.core.scale,document:h.core.document})},e.pageNumber)))},e.pageNumbers[0])))}),i.jsx("div",{style:{...d.strategy===t.ScrollStrategy.Horizontal?{width:d.endSpacing,height:"100%",flexShrink:0}:{height:d.endSpacing,width:"100%"}}}),n]})},exports.useScroll=()=>{const{provides:e}=l(),[t,i]=r.useState(1),[o,a]=r.useState(1);return r.useEffect((()=>{if(e)return e.onPageChange((({pageNumber:e,totalPages:t})=>{i(e),a(t)}))}),[e]),{...e,currentPage:t,totalPages:o}},exports.useScrollCapability=l,exports.useScrollPlugin=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/preact"),t=require("@embedpdf/plugin-scroll");require("preact");const r=require("preact/hooks"),i=require("preact/jsx-runtime"),o=()=>e.usePlugin(t.ScrollPlugin.id),l=()=>e.useCapability(t.ScrollPlugin.id);exports.Scroller=function({renderPage:a,overlayElements:n,...s}){const{provides:c}=l(),{plugin:g}=o(),{registry:u}=e.useRegistry(),[p,d]=r.useState((()=>(null==c?void 0:c.getScrollerLayout())??null));if(r.useEffect((()=>{if(c)return c.onScrollerData(d)}),[c]),r.useEffect((()=>{g&&g.setLayoutReady()}),[g]),!p)return null;if(!u)return null;const h=u.getStore().getState();return i.jsxs("div",{...s,style:{width:`${p.totalWidth}px`,height:`${p.totalHeight}px`,position:"relative",boxSizing:"border-box",margin:"0 auto",...p.strategy===t.ScrollStrategy.Horizontal&&{display:"flex",flexDirection:"row"}},children:[i.jsx("div",{style:{...p.strategy===t.ScrollStrategy.Horizontal?{width:p.startSpacing,height:"100%",flexShrink:0}:{height:p.startSpacing,width:"100%"}}}),i.jsx("div",{style:{gap:p.pageGap,display:"flex",alignItems:"center",position:"relative",boxSizing:"border-box",...p.strategy===t.ScrollStrategy.Horizontal?{flexDirection:"row",minHeight:"100%"}:{flexDirection:"column",minWidth:"fit-content"}},children:p.items.map((e=>i.jsx("div",{style:{display:"flex",justifyContent:"center",gap:p.pageGap},children:e.pageLayouts.map((e=>i.jsx("div",{style:{width:`${e.rotatedWidth}px`,height:`${e.rotatedHeight}px`},children:a({...e,rotation:h.core.rotation,scale:h.core.scale,document:h.core.document})},e.pageNumber)))},e.pageNumbers[0])))}),i.jsx("div",{style:{...p.strategy===t.ScrollStrategy.Horizontal?{width:p.endSpacing,height:"100%",flexShrink:0}:{height:p.endSpacing,width:"100%"}}}),n]})},exports.useScroll=()=>{const{provides:e}=l(),[t,i]=r.useState(1),[o,a]=r.useState(1);return r.useEffect((()=>{if(e)return e.onPageChange((({pageNumber:e,totalPages:t})=>{i(e),a(t)}))}),[e]),{...e,currentPage:t,totalPages:o}},exports.useScrollCapability=l,exports.useScrollPlugin=o,Object.keys(t).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})}));
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-scroll.ts","../../src/shared/components/scroller.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { ScrollPlugin } from '@embedpdf/plugin-scroll';\nimport { useEffect, useState } from '@framework';\n\nexport const useScrollPlugin = () => usePlugin<ScrollPlugin>(ScrollPlugin.id);\nexport const useScrollCapability = () => useCapability<ScrollPlugin>(ScrollPlugin.id);\n\nexport const useScroll = () => {\n const { provides: scroll } = useScrollCapability();\n const [currentPage, setCurrentPage] = useState(1);\n const [totalPages, setTotalPages] = useState(1);\n\n useEffect(() => {\n if (!scroll) return;\n return scroll.onPageChange(({ pageNumber, totalPages }) => {\n setCurrentPage(pageNumber);\n setTotalPages(totalPages);\n });\n }, [scroll]);\n\n return {\n ...scroll,\n currentPage,\n totalPages,\n };\n};\n","import { ReactNode, useEffect, useState, HTMLAttributes } from '@framework';\nimport { ScrollStrategy, ScrollerLayout, PageLayout } from '@embedpdf/plugin-scroll';\nimport { useRegistry } from '@embedpdf/core/@framework';\nimport { PdfDocumentObject, Rotation } from '@embedpdf/models';\n\nimport { useScrollCapability, useScrollPlugin } from '../hooks';\n\ninterface RenderPageProps extends PageLayout {\n rotation: Rotation;\n scale: number;\n document: PdfDocumentObject | null;\n}\n\ntype ScrollerProps = HTMLAttributes<HTMLDivElement> & {\n renderPage: (props: RenderPageProps) => ReactNode;\n overlayElements?: ReactNode[];\n};\n\nexport function Scroller({ renderPage, overlayElements, ...props }: ScrollerProps) {\n const { provides: scrollProvides } = useScrollCapability();\n const { plugin: scrollPlugin } = useScrollPlugin();\n const { registry } = useRegistry();\n const [scrollerLayout, setScrollerLayout] = useState<ScrollerLayout | null>(\n () => scrollProvides?.getScrollerLayout() ?? null,\n );\n\n useEffect(() => {\n if (!scrollProvides) return;\n\n return scrollProvides.onScrollerData(setScrollerLayout);\n }, [scrollProvides]);\n\n useEffect(() => {\n if (!scrollPlugin) return;\n\n scrollPlugin.setLayoutReady();\n }, [scrollPlugin]);\n\n if (!scrollerLayout) return null;\n if (!registry) return null;\n\n const coreState = registry.getStore().getState();\n\n return (\n <div\n {...props}\n style={{\n width: `${scrollerLayout.totalWidth}px`,\n height: `${scrollerLayout.totalHeight}px`,\n position: 'relative',\n boxSizing: 'border-box',\n margin: '0 auto',\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal && {\n display: 'flex',\n flexDirection: 'row',\n }),\n }}\n >\n <div\n style={{\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n width: scrollerLayout.startSpacing,\n height: '100%',\n flexShrink: 0,\n }\n : {\n height: scrollerLayout.startSpacing,\n width: '100%',\n }),\n }}\n />\n <div\n style={{\n gap: scrollerLayout.pageGap,\n display: 'flex',\n alignItems: 'center',\n position: 'relative',\n boxSizing: 'border-box',\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n flexDirection: 'row',\n minHeight: '100%',\n }\n : {\n flexDirection: 'column',\n minWidth: 'fit-content',\n }),\n }}\n >\n {scrollerLayout.items.map((item) => (\n <div\n key={item.pageNumbers[0]}\n style={{\n display: 'flex',\n justifyContent: 'center',\n gap: scrollerLayout.pageGap,\n }}\n >\n {item.pageLayouts.map((layout) => (\n <div\n key={layout.pageNumber}\n style={{\n width: `${layout.rotatedWidth}px`,\n height: `${layout.rotatedHeight}px`,\n }}\n >\n {renderPage({\n ...layout,\n rotation: coreState.core.rotation,\n scale: coreState.core.scale,\n document: coreState.core.document,\n })}\n </div>\n ))}\n </div>\n ))}\n </div>\n <div\n style={{\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n width: scrollerLayout.endSpacing,\n height: '100%',\n flexShrink: 0,\n }\n : {\n height: scrollerLayout.endSpacing,\n width: '100%',\n }),\n }}\n />\n {overlayElements}\n </div>\n );\n}\n"],"names":["useScrollPlugin","usePlugin","ScrollPlugin","id","useScrollCapability","useCapability","renderPage","overlayElements","props","provides","scrollProvides","plugin","scrollPlugin","registry","useRegistry","scrollerLayout","setScrollerLayout","useState","getScrollerLayout","useEffect","onScrollerData","setLayoutReady","coreState","getStore","getState","jsxRuntime","jsxs","style","width","totalWidth","height","totalHeight","position","boxSizing","margin","strategy","ScrollStrategy","Horizontal","display","flexDirection","children","jsx","startSpacing","flexShrink","gap","pageGap","alignItems","minHeight","minWidth","items","map","item","justifyContent","pageLayouts","layout","rotatedWidth","rotatedHeight","rotation","core","scale","document","pageNumber","pageNumbers","endSpacing","scroll","currentPage","setCurrentPage","totalPages","setTotalPages","onPageChange"],"mappings":"gPAIaA,EAAkB,IAAMC,YAAwBC,EAAAA,aAAaC,IAC7DC,EAAsB,IAAMC,gBAA4BH,EAAAA,aAAaC,qBCa3E,UAAkBG,WAAEA,EAAAC,gBAAYA,KAAoBC,IACzD,MAAQC,SAAUC,GAAmBN,KAC7BO,OAAQC,GAAiBZ,KAC3Ba,SAAEA,GAAaC,iBACdC,EAAgBC,GAAqBC,EAAAA,UAC1C,WAAMP,WAAgBQ,sBAAuB,OAe3C,GAZJC,EAAAA,WAAU,KACR,GAAKT,EAEE,OAAAA,EAAeU,eAAeJ,EAAiB,GACrD,CAACN,IAEJS,EAAAA,WAAU,KACHP,GAELA,EAAaS,gBAAe,GAC3B,CAACT,KAECG,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tBjC,OAAQ,OACRa,WAAY,GAEd,CACEb,OAAQf,EAAegD,WACvBnC,MAAO,WAIhBrB,IAGP,oBDhIyB,KACvB,MAAQE,SAAUuD,GAAW5D,KACtB6D,EAAaC,GAAkBjD,EAAAA,SAAS,IACxCkD,EAAYC,GAAiBnD,EAAAA,SAAS,GAUtC,OARPE,EAAAA,WAAU,KACR,GAAK6C,EACL,OAAOA,EAAOK,cAAa,EAAGR,aAAYM,WAAAA,MACxCD,EAAeL,GACfO,EAAcD,EAAU,GACzB,GACA,CAACH,IAEG,IACFA,EACHC,cACAE,aACF"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-scroll.ts","../../src/shared/components/scroller.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { ScrollPlugin } from '@embedpdf/plugin-scroll';\nimport { useEffect, useState } from '@framework';\n\nexport const useScrollPlugin = () => usePlugin<ScrollPlugin>(ScrollPlugin.id);\nexport const useScrollCapability = () => useCapability<ScrollPlugin>(ScrollPlugin.id);\n\nexport const useScroll = () => {\n const { provides: scroll } = useScrollCapability();\n const [currentPage, setCurrentPage] = useState(1);\n const [totalPages, setTotalPages] = useState(1);\n\n useEffect(() => {\n if (!scroll) return;\n return scroll.onPageChange(({ pageNumber, totalPages }) => {\n setCurrentPage(pageNumber);\n setTotalPages(totalPages);\n });\n }, [scroll]);\n\n return {\n ...scroll,\n currentPage,\n totalPages,\n };\n};\n","import { ReactNode, useEffect, useState, HTMLAttributes } from '@framework';\nimport { ScrollStrategy, ScrollerLayout, PageLayout } from '@embedpdf/plugin-scroll';\nimport { useRegistry } from '@embedpdf/core/@framework';\nimport { PdfDocumentObject, Rotation } from '@embedpdf/models';\n\nimport { useScrollCapability, useScrollPlugin } from '../hooks';\n\nexport interface RenderPageProps extends PageLayout {\n rotation: Rotation;\n scale: number;\n document: PdfDocumentObject | null;\n}\n\ntype ScrollerProps = HTMLAttributes<HTMLDivElement> & {\n renderPage: (props: RenderPageProps) => ReactNode;\n overlayElements?: ReactNode[];\n};\n\nexport function Scroller({ renderPage, overlayElements, ...props }: ScrollerProps) {\n const { provides: scrollProvides } = useScrollCapability();\n const { plugin: scrollPlugin } = useScrollPlugin();\n const { registry } = useRegistry();\n const [scrollerLayout, setScrollerLayout] = useState<ScrollerLayout | null>(\n () => scrollProvides?.getScrollerLayout() ?? null,\n );\n\n useEffect(() => {\n if (!scrollProvides) return;\n\n return scrollProvides.onScrollerData(setScrollerLayout);\n }, [scrollProvides]);\n\n useEffect(() => {\n if (!scrollPlugin) return;\n\n scrollPlugin.setLayoutReady();\n }, [scrollPlugin]);\n\n if (!scrollerLayout) return null;\n if (!registry) return null;\n\n const coreState = registry.getStore().getState();\n\n return (\n <div\n {...props}\n style={{\n width: `${scrollerLayout.totalWidth}px`,\n height: `${scrollerLayout.totalHeight}px`,\n position: 'relative',\n boxSizing: 'border-box',\n margin: '0 auto',\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal && {\n display: 'flex',\n flexDirection: 'row',\n }),\n }}\n >\n <div\n style={{\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n width: scrollerLayout.startSpacing,\n height: '100%',\n flexShrink: 0,\n }\n : {\n height: scrollerLayout.startSpacing,\n width: '100%',\n }),\n }}\n />\n <div\n style={{\n gap: scrollerLayout.pageGap,\n display: 'flex',\n alignItems: 'center',\n position: 'relative',\n boxSizing: 'border-box',\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n flexDirection: 'row',\n minHeight: '100%',\n }\n : {\n flexDirection: 'column',\n minWidth: 'fit-content',\n }),\n }}\n >\n {scrollerLayout.items.map((item) => (\n <div\n key={item.pageNumbers[0]}\n style={{\n display: 'flex',\n justifyContent: 'center',\n gap: scrollerLayout.pageGap,\n }}\n >\n {item.pageLayouts.map((layout) => (\n <div\n key={layout.pageNumber}\n style={{\n width: `${layout.rotatedWidth}px`,\n height: `${layout.rotatedHeight}px`,\n }}\n >\n {renderPage({\n ...layout,\n rotation: coreState.core.rotation,\n scale: coreState.core.scale,\n document: coreState.core.document,\n })}\n </div>\n ))}\n </div>\n ))}\n </div>\n <div\n style={{\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n width: scrollerLayout.endSpacing,\n height: '100%',\n flexShrink: 0,\n }\n : {\n height: scrollerLayout.endSpacing,\n width: '100%',\n }),\n }}\n />\n {overlayElements}\n </div>\n );\n}\n"],"names":["useScrollPlugin","usePlugin","ScrollPlugin","id","useScrollCapability","useCapability","renderPage","overlayElements","props","provides","scrollProvides","plugin","scrollPlugin","registry","useRegistry","scrollerLayout","setScrollerLayout","useState","getScrollerLayout","useEffect","onScrollerData","setLayoutReady","coreState","getStore","getState","jsxRuntime","jsxs","style","width","totalWidth","height","totalHeight","position","boxSizing","margin","strategy","ScrollStrategy","Horizontal","display","flexDirection","children","jsx","startSpacing","flexShrink","gap","pageGap","alignItems","minHeight","minWidth","items","map","item","justifyContent","pageLayouts","layout","rotatedWidth","rotatedHeight","rotation","core","scale","document","pageNumber","pageNumbers","endSpacing","scroll","currentPage","setCurrentPage","totalPages","setTotalPages","onPageChange"],"mappings":"gPAIaA,EAAkB,IAAMC,YAAwBC,EAAAA,aAAaC,IAC7DC,EAAsB,IAAMC,gBAA4BH,EAAAA,aAAaC,qBCa3E,UAAkBG,WAAEA,EAAAC,gBAAYA,KAAoBC,IACzD,MAAQC,SAAUC,GAAmBN,KAC7BO,OAAQC,GAAiBZ,KAC3Ba,SAAEA,GAAaC,iBACdC,EAAgBC,GAAqBC,EAAAA,UAC1C,WAAMP,WAAgBQ,sBAAuB,OAe3C,GAZJC,EAAAA,WAAU,KACR,GAAKT,EAEE,OAAAA,EAAeU,eAAeJ,EAAiB,GACrD,CAACN,IAEJS,EAAAA,WAAU,KACHP,GAELA,EAAaS,gBAAe,GAC3B,CAACT,KAECG,EAAuB,OAAA,KACxB,IAACF,EAAiB,OAAA,KAEtB,MAAMS,EAAYT,EAASU,WAAWC,WAGp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GP,oBDhIyB,KACvB,MAAQE,SAAUuD,GAAW5D,KACtB6D,EAAaC,GAAkBjD,EAAAA,SAAS,IACxCkD,EAAYC,GAAiBnD,EAAAA,SAAS,GAUtC,OARPE,EAAAA,WAAU,KACR,GAAK6C,EACL,OAAOA,EAAOK,cAAa,EAAGR,aAAYM,WAAAA,MACxCD,EAAeL,GACfO,EAAcD,EAAU,GACzB,GACA,CAACH,IAEG,IACFA,EACHC,cACAE,aACF"}
@@ -1,5 +1,6 @@
1
1
  import { usePlugin, useCapability, useRegistry } from "@embedpdf/core/preact";
2
2
  import { ScrollPlugin, ScrollStrategy } from "@embedpdf/plugin-scroll";
3
+ export * from "@embedpdf/plugin-scroll";
3
4
  import "preact";
4
5
  import { useState, useEffect } from "preact/hooks";
5
6
  import { jsxs, jsx } from "preact/jsx-runtime";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-scroll.ts","../../src/shared/components/scroller.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { ScrollPlugin } from '@embedpdf/plugin-scroll';\nimport { useEffect, useState } from '@framework';\n\nexport const useScrollPlugin = () => usePlugin<ScrollPlugin>(ScrollPlugin.id);\nexport const useScrollCapability = () => useCapability<ScrollPlugin>(ScrollPlugin.id);\n\nexport const useScroll = () => {\n const { provides: scroll } = useScrollCapability();\n const [currentPage, setCurrentPage] = useState(1);\n const [totalPages, setTotalPages] = useState(1);\n\n useEffect(() => {\n if (!scroll) return;\n return scroll.onPageChange(({ pageNumber, totalPages }) => {\n setCurrentPage(pageNumber);\n setTotalPages(totalPages);\n });\n }, [scroll]);\n\n return {\n ...scroll,\n currentPage,\n totalPages,\n };\n};\n","import { ReactNode, useEffect, useState, HTMLAttributes } from '@framework';\nimport { ScrollStrategy, ScrollerLayout, PageLayout } from '@embedpdf/plugin-scroll';\nimport { useRegistry } from '@embedpdf/core/@framework';\nimport { PdfDocumentObject, Rotation } from '@embedpdf/models';\n\nimport { useScrollCapability, useScrollPlugin } from '../hooks';\n\ninterface RenderPageProps extends PageLayout {\n rotation: Rotation;\n scale: number;\n document: PdfDocumentObject | null;\n}\n\ntype ScrollerProps = HTMLAttributes<HTMLDivElement> & {\n renderPage: (props: RenderPageProps) => ReactNode;\n overlayElements?: ReactNode[];\n};\n\nexport function Scroller({ renderPage, overlayElements, ...props }: ScrollerProps) {\n const { provides: scrollProvides } = useScrollCapability();\n const { plugin: scrollPlugin } = useScrollPlugin();\n const { registry } = useRegistry();\n const [scrollerLayout, setScrollerLayout] = useState<ScrollerLayout | null>(\n () => scrollProvides?.getScrollerLayout() ?? null,\n );\n\n useEffect(() => {\n if (!scrollProvides) return;\n\n return scrollProvides.onScrollerData(setScrollerLayout);\n }, [scrollProvides]);\n\n useEffect(() => {\n if (!scrollPlugin) return;\n\n scrollPlugin.setLayoutReady();\n }, [scrollPlugin]);\n\n if (!scrollerLayout) return null;\n if (!registry) return null;\n\n const coreState = registry.getStore().getState();\n\n return (\n <div\n {...props}\n style={{\n width: `${scrollerLayout.totalWidth}px`,\n height: `${scrollerLayout.totalHeight}px`,\n position: 'relative',\n boxSizing: 'border-box',\n margin: '0 auto',\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal && {\n display: 'flex',\n flexDirection: 'row',\n }),\n }}\n >\n <div\n style={{\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n width: scrollerLayout.startSpacing,\n height: '100%',\n flexShrink: 0,\n }\n : {\n height: scrollerLayout.startSpacing,\n width: '100%',\n }),\n }}\n />\n <div\n style={{\n gap: scrollerLayout.pageGap,\n display: 'flex',\n alignItems: 'center',\n position: 'relative',\n boxSizing: 'border-box',\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n flexDirection: 'row',\n minHeight: '100%',\n }\n : {\n flexDirection: 'column',\n minWidth: 'fit-content',\n }),\n }}\n >\n {scrollerLayout.items.map((item) => (\n <div\n key={item.pageNumbers[0]}\n style={{\n display: 'flex',\n justifyContent: 'center',\n gap: scrollerLayout.pageGap,\n }}\n >\n {item.pageLayouts.map((layout) => (\n <div\n key={layout.pageNumber}\n style={{\n width: `${layout.rotatedWidth}px`,\n height: `${layout.rotatedHeight}px`,\n }}\n >\n {renderPage({\n ...layout,\n rotation: coreState.core.rotation,\n scale: coreState.core.scale,\n document: coreState.core.document,\n })}\n </div>\n ))}\n </div>\n ))}\n </div>\n <div\n style={{\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n width: scrollerLayout.endSpacing,\n height: '100%',\n flexShrink: 0,\n }\n : {\n height: scrollerLayout.endSpacing,\n width: '100%',\n }),\n }}\n />\n {overlayElements}\n </div>\n );\n}\n"],"names":["totalPages"],"mappings":";;;;;AAIO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;AAE7E,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,UAAU,OAAO,IAAI,oBAAoB;AACjD,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,CAAC;AAChD,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,CAAC;AAE9C,YAAU,MAAM;AACd,QAAI,CAAC,OAAQ;AACb,WAAO,OAAO,aAAa,CAAC,EAAE,YAAY,YAAAA,kBAAiB;AACzD,qBAAe,UAAU;AACzB,oBAAcA,WAAU;AAAA,IAAA,CACzB;AAAA,EAAA,GACA,CAAC,MAAM,CAAC;AAEJ,SAAA;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AACF;ACPO,SAAS,SAAS,EAAE,YAAY,iBAAiB,GAAG,SAAwB;AACjF,QAAM,EAAE,UAAU,eAAe,IAAI,oBAAoB;AACzD,QAAM,EAAE,QAAQ,aAAa,IAAI,gBAAgB;AAC3C,QAAA,EAAE,SAAS,IAAI,YAAY;AAC3B,QAAA,CAAC,gBAAgB,iBAAiB,IAAI;AAAA,IAC1C,OAAM,iDAAgB,wBAAuB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eAAA,MAAM,IAAI,CAAC,SACzB;AAAA,cAAC;AAAA,cAAA;AAAA,gBAEC,OAAO;AAAA,kBACL,SAAS;AAAA,kBACT,gBAAgB;AAAA,kBAChB,KAAK,eAAe;AAAA,gBACtB;AAAA,gBAEC,UAAK,KAAA,YAAY,IAAI,CAAC,WACrB;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBAEC,OAAO;AAAA,sBACL,OAAO,GAAG,OAAO,YAAY;AAAA,sBAC7B,QAAQ,GAAG,OAAO,aAAa;AAAA,oBACjC;AAAA,oBAEC,UAAW,WAAA;AAAA,sBACV,GAAG;AAAA,sBACH,UAAU,UAAU,KAAK;AAAA,sBACzB,OAAO,UAAU,KAAK;AAAA,sBACtB,UAAU,UAAU,KAAK;AAAA,oBAC1B,CAAA;AAAA,kBAAA;AAAA,kBAXI,OAAO;AAAA,gBAaf,CAAA;AAAA,cAAA;AAAA,cAtBI,KAAK,YAAY,CAAC;AAAA,YAwB1B,CAAA;AAAA,UAAA;AAAA,QACH;AAAA,QACA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,OAAO;AAAA,cACL,GAAI,eAAe,aAAa,eAAe,aAC3C;AAAA,gBACE,OAAO,eAAe;AAAA,gBACtB,QAAQ;AAAA,gBACR,YAAY;AAAA,cAAA,IAEd;AAAA,gBACE,QAAQ,eAAe;AAAA,gBACvB,OAAO;AAAA,cAAA;AAAA,YACT;AAAA,UACN;AAAA,QACF;AAAA,QACC;AAAA,MAAA;AAAA,IAAA;AAAA,EACH;AAEJ;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-scroll.ts","../../src/shared/components/scroller.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { ScrollPlugin } from '@embedpdf/plugin-scroll';\nimport { useEffect, useState } from '@framework';\n\nexport const useScrollPlugin = () => usePlugin<ScrollPlugin>(ScrollPlugin.id);\nexport const useScrollCapability = () => useCapability<ScrollPlugin>(ScrollPlugin.id);\n\nexport const useScroll = () => {\n const { provides: scroll } = useScrollCapability();\n const [currentPage, setCurrentPage] = useState(1);\n const [totalPages, setTotalPages] = useState(1);\n\n useEffect(() => {\n if (!scroll) return;\n return scroll.onPageChange(({ pageNumber, totalPages }) => {\n setCurrentPage(pageNumber);\n setTotalPages(totalPages);\n });\n }, [scroll]);\n\n return {\n ...scroll,\n currentPage,\n totalPages,\n };\n};\n","import { ReactNode, useEffect, useState, HTMLAttributes } from '@framework';\nimport { ScrollStrategy, ScrollerLayout, PageLayout } from '@embedpdf/plugin-scroll';\nimport { useRegistry } from '@embedpdf/core/@framework';\nimport { PdfDocumentObject, Rotation } from '@embedpdf/models';\n\nimport { useScrollCapability, useScrollPlugin } from '../hooks';\n\nexport interface RenderPageProps extends PageLayout {\n rotation: Rotation;\n scale: number;\n document: PdfDocumentObject | null;\n}\n\ntype ScrollerProps = HTMLAttributes<HTMLDivElement> & {\n renderPage: (props: RenderPageProps) => ReactNode;\n overlayElements?: ReactNode[];\n};\n\nexport function Scroller({ renderPage, overlayElements, ...props }: ScrollerProps) {\n const { provides: scrollProvides } = useScrollCapability();\n const { plugin: scrollPlugin } = useScrollPlugin();\n const { registry } = useRegistry();\n const [scrollerLayout, setScrollerLayout] = useState<ScrollerLayout | null>(\n () => scrollProvides?.getScrollerLayout() ?? null,\n );\n\n useEffect(() => {\n if (!scrollProvides) return;\n\n return scrollProvides.onScrollerData(setScrollerLayout);\n }, [scrollProvides]);\n\n useEffect(() => {\n if (!scrollPlugin) return;\n\n scrollPlugin.setLayoutReady();\n }, [scrollPlugin]);\n\n if (!scrollerLayout) return null;\n if (!registry) return null;\n\n const coreState = registry.getStore().getState();\n\n return (\n <div\n {...props}\n style={{\n width: `${scrollerLayout.totalWidth}px`,\n height: `${scrollerLayout.totalHeight}px`,\n position: 'relative',\n boxSizing: 'border-box',\n margin: '0 auto',\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal && {\n display: 'flex',\n flexDirection: 'row',\n }),\n }}\n >\n <div\n style={{\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n width: scrollerLayout.startSpacing,\n height: '100%',\n flexShrink: 0,\n }\n : {\n height: scrollerLayout.startSpacing,\n width: '100%',\n }),\n }}\n />\n <div\n style={{\n gap: scrollerLayout.pageGap,\n display: 'flex',\n alignItems: 'center',\n position: 'relative',\n boxSizing: 'border-box',\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n flexDirection: 'row',\n minHeight: '100%',\n }\n : {\n flexDirection: 'column',\n minWidth: 'fit-content',\n }),\n }}\n >\n {scrollerLayout.items.map((item) => (\n <div\n key={item.pageNumbers[0]}\n style={{\n display: 'flex',\n justifyContent: 'center',\n gap: scrollerLayout.pageGap,\n }}\n >\n {item.pageLayouts.map((layout) => (\n <div\n key={layout.pageNumber}\n style={{\n width: `${layout.rotatedWidth}px`,\n height: `${layout.rotatedHeight}px`,\n }}\n >\n {renderPage({\n ...layout,\n rotation: coreState.core.rotation,\n scale: coreState.core.scale,\n document: coreState.core.document,\n })}\n </div>\n ))}\n </div>\n ))}\n </div>\n <div\n style={{\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n width: scrollerLayout.endSpacing,\n height: '100%',\n flexShrink: 0,\n }\n : {\n height: scrollerLayout.endSpacing,\n width: '100%',\n }),\n }}\n />\n {overlayElements}\n </div>\n );\n}\n"],"names":["totalPages"],"mappings":";;;;;;AAIO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;AAE7E,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,UAAU,OAAO,IAAI,oBAAoB;AACjD,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,CAAC;AAChD,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,CAAC;AAE9C,YAAU,MAAM;AACd,QAAI,CAAC,OAAQ;AACb,WAAO,OAAO,aAAa,CAAC,EAAE,YAAY,YAAAA,k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,gBACE,QAAQ,eAAe;AAAA,gBACvB,OAAO;AAAA,cAAA;AAAA,YACT;AAAA,UACN;AAAA,QACF;AAAA,QACC;AAAA,MAAA;AAAA,IAAA;AAAA,EACH;AAEJ;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/react"),t=require("@embedpdf/plugin-scroll"),r=require("react"),i=require("react/jsx-runtime"),l=()=>e.usePlugin(t.ScrollPlugin.id),o=()=>e.useCapability(t.ScrollPlugin.id);exports.Scroller=function({renderPage:a,overlayElements:n,...s}){const{provides:g}=o(),{plugin:c}=l(),{registry:u}=e.useRegistry(),[d,p]=r.useState((()=>(null==g?void 0:g.getScrollerLayout())??null));if(r.useEffect((()=>{if(g)return g.onScrollerData(p)}),[g]),r.useEffect((()=>{c&&c.setLayoutReady()}),[c]),!d)return null;if(!u)return null;const h=u.getStore().getState();return i.jsxs("div",{...s,style:{width:`${d.totalWidth}px`,height:`${d.totalHeight}px`,position:"relative",boxSizing:"border-box",margin:"0 auto",...d.strategy===t.ScrollStrategy.Horizontal&&{display:"flex",flexDirection:"row"}},children:[i.jsx("div",{style:{...d.strategy===t.ScrollStrategy.Horizontal?{width:d.startSpacing,height:"100%",flexShrink:0}:{height:d.startSpacing,width:"100%"}}}),i.jsx("div",{style:{gap:d.pageGap,display:"flex",alignItems:"center",position:"relative",boxSizing:"border-box",...d.strategy===t.ScrollStrategy.Horizontal?{flexDirection:"row",minHeight:"100%"}:{flexDirection:"column",minWidth:"fit-content"}},children:d.items.map((e=>i.jsx("div",{style:{display:"flex",justifyContent:"center",gap:d.pageGap},children:e.pageLayouts.map((e=>i.jsx("div",{style:{width:`${e.rotatedWidth}px`,height:`${e.rotatedHeight}px`},children:a({...e,rotation:h.core.rotation,scale:h.core.scale,document:h.core.document})},e.pageNumber)))},e.pageNumbers[0])))}),i.jsx("div",{style:{...d.strategy===t.ScrollStrategy.Horizontal?{width:d.endSpacing,height:"100%",flexShrink:0}:{height:d.endSpacing,width:"100%"}}}),n]})},exports.useScroll=()=>{const{provides:e}=o(),[t,i]=r.useState(1),[l,a]=r.useState(1);return r.useEffect((()=>{if(e)return e.onPageChange((({pageNumber:e,totalPages:t})=>{i(e),a(t)}))}),[e]),{...e,currentPage:t,totalPages:l}},exports.useScrollCapability=o,exports.useScrollPlugin=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/react"),t=require("@embedpdf/plugin-scroll"),r=require("react"),i=require("react/jsx-runtime"),o=()=>e.usePlugin(t.ScrollPlugin.id),l=()=>e.useCapability(t.ScrollPlugin.id);exports.Scroller=function({renderPage:a,overlayElements:n,...s}){const{provides:c}=l(),{plugin:g}=o(),{registry:u}=e.useRegistry(),[d,p]=r.useState((()=>(null==c?void 0:c.getScrollerLayout())??null));if(r.useEffect((()=>{if(c)return c.onScrollerData(p)}),[c]),r.useEffect((()=>{g&&g.setLayoutReady()}),[g]),!d)return null;if(!u)return null;const h=u.getStore().getState();return i.jsxs("div",{...s,style:{width:`${d.totalWidth}px`,height:`${d.totalHeight}px`,position:"relative",boxSizing:"border-box",margin:"0 auto",...d.strategy===t.ScrollStrategy.Horizontal&&{display:"flex",flexDirection:"row"}},children:[i.jsx("div",{style:{...d.strategy===t.ScrollStrategy.Horizontal?{width:d.startSpacing,height:"100%",flexShrink:0}:{height:d.startSpacing,width:"100%"}}}),i.jsx("div",{style:{gap:d.pageGap,display:"flex",alignItems:"center",position:"relative",boxSizing:"border-box",...d.strategy===t.ScrollStrategy.Horizontal?{flexDirection:"row",minHeight:"100%"}:{flexDirection:"column",minWidth:"fit-content"}},children:d.items.map((e=>i.jsx("div",{style:{display:"flex",justifyContent:"center",gap:d.pageGap},children:e.pageLayouts.map((e=>i.jsx("div",{style:{width:`${e.rotatedWidth}px`,height:`${e.rotatedHeight}px`},children:a({...e,rotation:h.core.rotation,scale:h.core.scale,document:h.core.document})},e.pageNumber)))},e.pageNumbers[0])))}),i.jsx("div",{style:{...d.strategy===t.ScrollStrategy.Horizontal?{width:d.endSpacing,height:"100%",flexShrink:0}:{height:d.endSpacing,width:"100%"}}}),n]})},exports.useScroll=()=>{const{provides:e}=l(),[t,i]=r.useState(1),[o,a]=r.useState(1);return r.useEffect((()=>{if(e)return e.onPageChange((({pageNumber:e,totalPages:t})=>{i(e),a(t)}))}),[e]),{...e,currentPage:t,totalPages:o}},exports.useScrollCapability=l,exports.useScrollPlugin=o,Object.keys(t).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})}));
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-scroll.ts","../../src/shared/components/scroller.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { ScrollPlugin } from '@embedpdf/plugin-scroll';\nimport { useEffect, useState } from '@framework';\n\nexport const useScrollPlugin = () => usePlugin<ScrollPlugin>(ScrollPlugin.id);\nexport const useScrollCapability = () => useCapability<ScrollPlugin>(ScrollPlugin.id);\n\nexport const useScroll = () => {\n const { provides: scroll } = useScrollCapability();\n const [currentPage, setCurrentPage] = useState(1);\n const [totalPages, setTotalPages] = useState(1);\n\n useEffect(() => {\n if (!scroll) return;\n return scroll.onPageChange(({ pageNumber, totalPages }) => {\n setCurrentPage(pageNumber);\n setTotalPages(totalPages);\n });\n }, [scroll]);\n\n return {\n ...scroll,\n currentPage,\n totalPages,\n };\n};\n","import { ReactNode, useEffect, useState, HTMLAttributes } from '@framework';\nimport { ScrollStrategy, ScrollerLayout, PageLayout } from '@embedpdf/plugin-scroll';\nimport { useRegistry } from '@embedpdf/core/@framework';\nimport { PdfDocumentObject, Rotation } from '@embedpdf/models';\n\nimport { useScrollCapability, useScrollPlugin } from '../hooks';\n\ninterface RenderPageProps extends PageLayout {\n rotation: Rotation;\n scale: number;\n document: PdfDocumentObject | null;\n}\n\ntype ScrollerProps = HTMLAttributes<HTMLDivElement> & {\n renderPage: (props: RenderPageProps) => ReactNode;\n overlayElements?: ReactNode[];\n};\n\nexport function Scroller({ renderPage, overlayElements, ...props }: ScrollerProps) {\n const { provides: scrollProvides } = useScrollCapability();\n const { plugin: scrollPlugin } = useScrollPlugin();\n const { registry } = useRegistry();\n const [scrollerLayout, setScrollerLayout] = useState<ScrollerLayout | null>(\n () => scrollProvides?.getScrollerLayout() ?? null,\n );\n\n useEffect(() => {\n if (!scrollProvides) return;\n\n return scrollProvides.onScrollerData(setScrollerLayout);\n }, [scrollProvides]);\n\n useEffect(() => {\n if (!scrollPlugin) return;\n\n scrollPlugin.setLayoutReady();\n }, [scrollPlugin]);\n\n if (!scrollerLayout) return null;\n if (!registry) return null;\n\n const coreState = registry.getStore().getState();\n\n return (\n <div\n {...props}\n style={{\n width: `${scrollerLayout.totalWidth}px`,\n height: `${scrollerLayout.totalHeight}px`,\n position: 'relative',\n boxSizing: 'border-box',\n margin: '0 auto',\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal && {\n display: 'flex',\n flexDirection: 'row',\n }),\n }}\n >\n <div\n style={{\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n width: scrollerLayout.startSpacing,\n height: '100%',\n flexShrink: 0,\n }\n : {\n height: scrollerLayout.startSpacing,\n width: '100%',\n }),\n }}\n />\n <div\n style={{\n gap: scrollerLayout.pageGap,\n display: 'flex',\n alignItems: 'center',\n position: 'relative',\n boxSizing: 'border-box',\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n flexDirection: 'row',\n minHeight: '100%',\n }\n : {\n flexDirection: 'column',\n minWidth: 'fit-content',\n }),\n }}\n >\n {scrollerLayout.items.map((item) => (\n <div\n key={item.pageNumbers[0]}\n style={{\n display: 'flex',\n justifyContent: 'center',\n gap: scrollerLayout.pageGap,\n }}\n >\n {item.pageLayouts.map((layout) => (\n <div\n key={layout.pageNumber}\n style={{\n width: `${layout.rotatedWidth}px`,\n height: `${layout.rotatedHeight}px`,\n }}\n >\n {renderPage({\n ...layout,\n rotation: coreState.core.rotation,\n scale: coreState.core.scale,\n document: coreState.core.document,\n })}\n </div>\n ))}\n </div>\n ))}\n </div>\n <div\n style={{\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n width: scrollerLayout.endSpacing,\n height: '100%',\n flexShrink: 0,\n }\n : {\n height: scrollerLayout.endSpacing,\n width: '100%',\n }),\n }}\n />\n {overlayElements}\n </div>\n );\n}\n"],"names":["useScrollPlugin","usePlugin","ScrollPlugin","id","useScrollCapability","useCapability","renderPage","overlayElements","props","provides","scrollProvides","plugin","scrollPlugin","registry","useRegistry","scrollerLayout","setScrollerLayout","useState","getScrollerLayout","useEffect","onScrollerData","setLayoutReady","coreState","getStore","getState","jsxRuntime","jsxs","style","width","totalWidth","height","totalHeight","position","boxSizing","margin","strategy","ScrollStrategy","Horizontal","display","flexDirection","children","jsx","startSpacing","flexShrink","gap","pageGap","alignItems","minHeight","minWidth","items","map","item","justifyContent","pageLayouts","layout","rotatedWidth","rotatedHeight","rotation","core","scale","document","pageNumber","pageNumbers","endSpacing","scroll","currentPage","setCurrentPage","totalPages","setTotalPages","onPageChange"],"mappings":"+MAIaA,EAAkB,IAAMC,YAAwBC,EAAAA,aAAaC,IAC7DC,EAAsB,IAAMC,gBAA4BH,EAAAA,aAAaC,qBCa3E,UAAkBG,WAAEA,EAAAC,gBAAYA,KAAoBC,IACzD,MAAQC,SAAUC,GAAmBN,KAC7BO,OAAQC,GAAiBZ,KAC3Ba,SAAEA,GAAaC,iBACdC,EAAgBC,GAAqBC,EAAAA,UAC1C,WAAMP,WAAgBQ,sBAAuB,OAe3C,GAZJC,EAAAA,WAAU,KACR,GAAKT,EAEE,OAAAA,EAAeU,eAAeJ,EAAiB,GACrD,CAACN,IAEJS,EAAAA,WAAU,KACHP,GAELA,EAAaS,gBAAe,GAC3B,CAACT,KAECG,EAAuB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OAAQ,OACRa,WAAY,GAEd,CACEb,OAAQf,EAAegD,WACvBnC,MAAO,WAIhBrB,IAGP,oBDhIyB,KACvB,MAAQE,SAAUuD,GAAW5D,KACtB6D,EAAaC,GAAkBjD,EAAAA,SAAS,IACxCkD,EAAYC,GAAiBnD,EAAAA,SAAS,GAUtC,OARPE,EAAAA,WAAU,KACR,GAAK6C,EACL,OAAOA,EAAOK,cAAa,EAAGR,aAAYM,WAAAA,MACxCD,EAAeL,GACfO,EAAcD,EAAU,GACzB,GACA,CAACH,IAEG,IACFA,EACHC,cACAE,aACF"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-scroll.ts","../../src/shared/components/scroller.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { ScrollPlugin } from '@embedpdf/plugin-scroll';\nimport { useEffect, useState } from '@framework';\n\nexport const useScrollPlugin = () => usePlugin<ScrollPlugin>(ScrollPlugin.id);\nexport const useScrollCapability = () => useCapability<ScrollPlugin>(ScrollPlugin.id);\n\nexport const useScroll = () => {\n const { provides: scroll } = useScrollCapability();\n const [currentPage, setCurrentPage] = useState(1);\n const [totalPages, setTotalPages] = useState(1);\n\n useEffect(() => {\n if (!scroll) return;\n return scroll.onPageChange(({ pageNumber, totalPages }) => {\n setCurrentPage(pageNumber);\n setTotalPages(totalPages);\n });\n }, [scroll]);\n\n return {\n ...scroll,\n currentPage,\n totalPages,\n };\n};\n","import { ReactNode, useEffect, useState, HTMLAttributes } from '@framework';\nimport { ScrollStrategy, ScrollerLayout, PageLayout } from '@embedpdf/plugin-scroll';\nimport { useRegistry } from '@embedpdf/core/@framework';\nimport { PdfDocumentObject, Rotation } from '@embedpdf/models';\n\nimport { useScrollCapability, useScrollPlugin } from '../hooks';\n\nexport interface RenderPageProps extends PageLayout {\n rotation: Rotation;\n scale: number;\n document: PdfDocumentObject | null;\n}\n\ntype ScrollerProps = HTMLAttributes<HTMLDivElement> & {\n renderPage: (props: RenderPageProps) => ReactNode;\n overlayElements?: ReactNode[];\n};\n\nexport function Scroller({ renderPage, overlayElements, ...props }: ScrollerProps) {\n const { provides: scrollProvides } = useScrollCapability();\n const { plugin: scrollPlugin } = useScrollPlugin();\n const { registry } = useRegistry();\n const [scrollerLayout, setScrollerLayout] = useState<ScrollerLayout | null>(\n () => scrollProvides?.getScrollerLayout() ?? null,\n );\n\n useEffect(() => {\n if (!scrollProvides) return;\n\n return scrollProvides.onScrollerData(setScrollerLayout);\n }, [scrollProvides]);\n\n useEffect(() => {\n if (!scrollPlugin) return;\n\n scrollPlugin.setLayoutReady();\n }, [scrollPlugin]);\n\n if (!scrollerLayout) return null;\n if (!registry) return null;\n\n const coreState = registry.getStore().getState();\n\n return (\n <div\n {...props}\n style={{\n width: `${scrollerLayout.totalWidth}px`,\n height: `${scrollerLayout.totalHeight}px`,\n position: 'relative',\n boxSizing: 'border-box',\n margin: '0 auto',\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal && {\n display: 'flex',\n flexDirection: 'row',\n }),\n }}\n >\n <div\n style={{\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n width: scrollerLayout.startSpacing,\n height: '100%',\n flexShrink: 0,\n }\n : {\n height: scrollerLayout.startSpacing,\n width: '100%',\n }),\n }}\n />\n <div\n style={{\n gap: scrollerLayout.pageGap,\n display: 'flex',\n alignItems: 'center',\n position: 'relative',\n boxSizing: 'border-box',\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n flexDirection: 'row',\n minHeight: '100%',\n }\n : {\n flexDirection: 'column',\n minWidth: 'fit-content',\n }),\n }}\n >\n {scrollerLayout.items.map((item) => (\n <div\n key={item.pageNumbers[0]}\n style={{\n display: 'flex',\n justifyContent: 'center',\n gap: scrollerLayout.pageGap,\n }}\n >\n {item.pageLayouts.map((layout) => (\n <div\n key={layout.pageNumber}\n style={{\n width: `${layout.rotatedWidth}px`,\n height: `${layout.rotatedHeight}px`,\n }}\n >\n {renderPage({\n ...layout,\n rotation: coreState.core.rotation,\n scale: coreState.core.scale,\n document: coreState.core.document,\n })}\n </div>\n ))}\n </div>\n ))}\n </div>\n <div\n style={{\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n width: scrollerLayout.endSpacing,\n height: '100%',\n flexShrink: 0,\n }\n : {\n height: scrollerLayout.endSpacing,\n width: '100%',\n }),\n }}\n />\n {overlayElements}\n </div>\n );\n}\n"],"names":["useScrollPlugin","usePlugin","ScrollPlugin","id","useScrollCapability","useCapability","renderPage","overlayElements","props","provides","scrollProvides","plugin","scrollPlugin","registry","useRegistry","scrollerLayout","setScrollerLayout","useState","getScrollerLayout","useEffect","onScrollerData","setLayoutReady","coreState","getStore","getState","jsxRuntime","jsxs","style","width","totalWidth","height","totalHeight","position","boxSizing","margin","strategy","ScrollStrategy","Horizontal","display","flexDirection","children","jsx","startSpacing","flexShrink","gap","pageGap","alignItems","minHeight","minWidth","items","map","item","justifyContent","pageLayouts","layout","rotatedWidth","rotatedHeight","rotation","core","scale","document","pageNumber","pageNumbers","endSpacing","scroll","currentPage","setCurrentPage","totalPages","setTotalPages","onPageChange"],"mappings":"+MAIaA,EAAkB,IAAMC,YAAwBC,EAAAA,aAAaC,IAC7DC,EAAsB,IAAMC,gBAA4BH,EAAAA,aAAaC,qBCa3E,UAAkBG,WAAEA,EAAAC,gBAAYA,KAAoBC,IACzD,MAAQC,SAAUC,GAAmBN,KAC7BO,OAAQC,GAAiBZ,KAC3Ba,SAAEA,GAAaC,iBACdC,EAAgBC,GAAqBC,EAAAA,UAC1C,WAAMP,WAAgBQ,sBAAuB,OAe3C,GAZJC,EAAAA,WAAU,KACR,GAAKT,EAEE,OAAAA,EAAeU,eAAeJ,EAAiB,GACrD,CAACN,IAEJS,EAAAA,WAAU,KACHP,GAELA,EAAaS,gBAAe,GAC3B,CAACT,KAECG,EAAuB,OAAA,KACxB,IAACF,EAAiB,OAAA,KAEtB,MAAMS,EAAYT,EAASU,WAAWC,WAGpC,OAA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DhIyB,KACvB,MAAQE,SAAUuD,GAAW5D,KACtB6D,EAAaC,GAAkBjD,EAAAA,SAAS,IACxCkD,EAAYC,GAAiBnD,EAAAA,SAAS,GAUtC,OARPE,EAAAA,WAAU,KACR,GAAK6C,EACL,OAAOA,EAAOK,cAAa,EAAGR,aAAYM,WAAAA,MACxCD,EAAeL,GACfO,EAAcD,EAAU,GACzB,GACA,CAACH,IAEG,IACFA,EACHC,cACAE,aACF"}
@@ -1,5 +1,6 @@
1
1
  import { usePlugin, useCapability, useRegistry } from "@embedpdf/core/react";
2
2
  import { ScrollPlugin, ScrollStrategy } from "@embedpdf/plugin-scroll";
3
+ export * from "@embedpdf/plugin-scroll";
3
4
  import { useState, useEffect } from "react";
4
5
  import { jsxs, jsx } from "react/jsx-runtime";
5
6
  const useScrollPlugin = () => usePlugin(ScrollPlugin.id);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-scroll.ts","../../src/shared/components/scroller.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { ScrollPlugin } from '@embedpdf/plugin-scroll';\nimport { useEffect, useState } from '@framework';\n\nexport const useScrollPlugin = () => usePlugin<ScrollPlugin>(ScrollPlugin.id);\nexport const useScrollCapability = () => useCapability<ScrollPlugin>(ScrollPlugin.id);\n\nexport const useScroll = () => {\n const { provides: scroll } = useScrollCapability();\n const [currentPage, setCurrentPage] = useState(1);\n const [totalPages, setTotalPages] = useState(1);\n\n useEffect(() => {\n if (!scroll) return;\n return scroll.onPageChange(({ pageNumber, totalPages }) => {\n setCurrentPage(pageNumber);\n setTotalPages(totalPages);\n });\n }, [scroll]);\n\n return {\n ...scroll,\n currentPage,\n totalPages,\n };\n};\n","import { ReactNode, useEffect, useState, HTMLAttributes } from '@framework';\nimport { ScrollStrategy, ScrollerLayout, PageLayout } from '@embedpdf/plugin-scroll';\nimport { useRegistry } from '@embedpdf/core/@framework';\nimport { PdfDocumentObject, Rotation } from '@embedpdf/models';\n\nimport { useScrollCapability, useScrollPlugin } from '../hooks';\n\ninterface RenderPageProps extends PageLayout {\n rotation: Rotation;\n scale: number;\n document: PdfDocumentObject | null;\n}\n\ntype ScrollerProps = HTMLAttributes<HTMLDivElement> & {\n renderPage: (props: RenderPageProps) => ReactNode;\n overlayElements?: ReactNode[];\n};\n\nexport function Scroller({ renderPage, overlayElements, ...props }: ScrollerProps) {\n const { provides: scrollProvides } = useScrollCapability();\n const { plugin: scrollPlugin } = useScrollPlugin();\n const { registry } = useRegistry();\n const [scrollerLayout, setScrollerLayout] = useState<ScrollerLayout | null>(\n () => scrollProvides?.getScrollerLayout() ?? null,\n );\n\n useEffect(() => {\n if (!scrollProvides) return;\n\n return scrollProvides.onScrollerData(setScrollerLayout);\n }, [scrollProvides]);\n\n useEffect(() => {\n if (!scrollPlugin) return;\n\n scrollPlugin.setLayoutReady();\n }, [scrollPlugin]);\n\n if (!scrollerLayout) return null;\n if (!registry) return null;\n\n const coreState = registry.getStore().getState();\n\n return (\n <div\n {...props}\n style={{\n width: `${scrollerLayout.totalWidth}px`,\n height: `${scrollerLayout.totalHeight}px`,\n position: 'relative',\n boxSizing: 'border-box',\n margin: '0 auto',\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal && {\n display: 'flex',\n flexDirection: 'row',\n }),\n }}\n >\n <div\n style={{\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n width: scrollerLayout.startSpacing,\n height: '100%',\n flexShrink: 0,\n }\n : {\n height: scrollerLayout.startSpacing,\n width: '100%',\n }),\n }}\n />\n <div\n style={{\n gap: scrollerLayout.pageGap,\n display: 'flex',\n alignItems: 'center',\n position: 'relative',\n boxSizing: 'border-box',\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n flexDirection: 'row',\n minHeight: '100%',\n }\n : {\n flexDirection: 'column',\n minWidth: 'fit-content',\n }),\n }}\n >\n {scrollerLayout.items.map((item) => (\n <div\n key={item.pageNumbers[0]}\n style={{\n display: 'flex',\n justifyContent: 'center',\n gap: scrollerLayout.pageGap,\n }}\n >\n {item.pageLayouts.map((layout) => (\n <div\n key={layout.pageNumber}\n style={{\n width: `${layout.rotatedWidth}px`,\n height: `${layout.rotatedHeight}px`,\n }}\n >\n {renderPage({\n ...layout,\n rotation: coreState.core.rotation,\n scale: coreState.core.scale,\n document: coreState.core.document,\n })}\n </div>\n ))}\n </div>\n ))}\n </div>\n <div\n style={{\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n width: scrollerLayout.endSpacing,\n height: '100%',\n flexShrink: 0,\n }\n : {\n height: scrollerLayout.endSpacing,\n width: '100%',\n }),\n }}\n />\n {overlayElements}\n </div>\n );\n}\n"],"names":["totalPages"],"mappings":";;;;AAIO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;AAE7E,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,UAAU,OAAO,IAAI,oBAAoB;AACjD,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,CAAC;AAChD,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,CAAC;AAE9C,YAAU,MAAM;AACd,QAAI,CAAC,OAAQ;AACb,WAAO,OAAO,aAAa,CAAC,EAAE,YAAY,YAAAA,kBAAiB;AACzD,qBAAe,UAAU;AACzB,oBAAcA,WAAU;AAAA,IAAA,CACzB;AAAA,EAAA,GACA,CAAC,MAAM,CAAC;AAEJ,SAAA;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AACF;ACPO,SAAS,SAAS,EAAE,YAAY,iBAAiB,GAAG,SAAwB;AACjF,QAAM,EAAE,UAAU,eAAe,IAAI,oBAAoB;AACzD,QAAM,EAAE,QAAQ,aAAa,IAAI,gBAAgB;AAC3C,QAAA,EAAE,SAAS,IAAI,YAAY;AAC3B,QAAA,CAAC,gBAAgB,iBAAiB,IAAI;AAAA,IAC1C,OAAM,iD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,YAEC,UAAe,eAAA,MAAM,IAAI,CAAC,SACzB;AAAA,cAAC;AAAA,cAAA;AAAA,gBAEC,OAAO;AAAA,kBACL,SAAS;AAAA,kBACT,gBAAgB;AAAA,kBAChB,KAAK,eAAe;AAAA,gBACtB;AAAA,gBAEC,UAAK,KAAA,YAAY,IAAI,CAAC,WACrB;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBAEC,OAAO;AAAA,sBACL,OAAO,GAAG,OAAO,YAAY;AAAA,sBAC7B,QAAQ,GAAG,OAAO,aAAa;AAAA,oBACjC;AAAA,oBAEC,UAAW,WAAA;AAAA,sBACV,GAAG;AAAA,sBACH,UAAU,UAAU,KAAK;AAAA,sBACzB,OAAO,UAAU,KAAK;AAAA,sBACtB,UAAU,UAAU,KAAK;AAAA,oBAC1B,CAAA;AAAA,kBAAA;AAAA,kBAXI,OAAO;AAAA,gBAaf,CAAA;AAAA,cAAA;AAAA,cAtBI,KAAK,YAAY,CAAC;AAAA,YAwB1B,CAAA;AAAA,UAAA;AAAA,QACH;AAAA,QACA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,OAAO;AAAA,cACL,GAAI,eAAe,aAAa,eAAe,aAC3C;AAAA,gBACE,OAAO,eAAe;AAAA,gBACtB,QAAQ;AAAA,gBACR,YAAY;AAAA,cAAA,IAEd;AAAA,gBACE,QAAQ,eAAe;AAAA,gBACvB,OAAO;AAAA,cAAA;AAAA,YACT;AAAA,UACN;AAAA,QACF;AAAA,QACC;AAAA,MAAA;AAAA,IAAA;AAAA,EACH;AAEJ;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-scroll.ts","../../src/shared/components/scroller.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { ScrollPlugin } from '@embedpdf/plugin-scroll';\nimport { useEffect, useState } from '@framework';\n\nexport const useScrollPlugin = () => usePlugin<ScrollPlugin>(ScrollPlugin.id);\nexport const useScrollCapability = () => useCapability<ScrollPlugin>(ScrollPlugin.id);\n\nexport const useScroll = () => {\n const { provides: scroll } = useScrollCapability();\n const [currentPage, setCurrentPage] = useState(1);\n const [totalPages, setTotalPages] = useState(1);\n\n useEffect(() => {\n if (!scroll) return;\n return scroll.onPageChange(({ pageNumber, totalPages }) => {\n setCurrentPage(pageNumber);\n setTotalPages(totalPages);\n });\n }, [scroll]);\n\n return {\n ...scroll,\n currentPage,\n totalPages,\n };\n};\n","import { ReactNode, useEffect, useState, HTMLAttributes } from '@framework';\nimport { ScrollStrategy, ScrollerLayout, PageLayout } from '@embedpdf/plugin-scroll';\nimport { useRegistry } from '@embedpdf/core/@framework';\nimport { PdfDocumentObject, Rotation } from '@embedpdf/models';\n\nimport { useScrollCapability, useScrollPlugin } from '../hooks';\n\nexport interface RenderPageProps extends PageLayout {\n rotation: Rotation;\n scale: number;\n document: PdfDocumentObject | null;\n}\n\ntype ScrollerProps = HTMLAttributes<HTMLDivElement> & {\n renderPage: (props: RenderPageProps) => ReactNode;\n overlayElements?: ReactNode[];\n};\n\nexport function Scroller({ renderPage, overlayElements, ...props }: ScrollerProps) {\n const { provides: scrollProvides } = useScrollCapability();\n const { plugin: scrollPlugin } = useScrollPlugin();\n const { registry } = useRegistry();\n const [scrollerLayout, setScrollerLayout] = useState<ScrollerLayout | null>(\n () => scrollProvides?.getScrollerLayout() ?? null,\n );\n\n useEffect(() => {\n if (!scrollProvides) return;\n\n return scrollProvides.onScrollerData(setScrollerLayout);\n }, [scrollProvides]);\n\n useEffect(() => {\n if (!scrollPlugin) return;\n\n scrollPlugin.setLayoutReady();\n }, [scrollPlugin]);\n\n if (!scrollerLayout) return null;\n if (!registry) return null;\n\n const coreState = registry.getStore().getState();\n\n return (\n <div\n {...props}\n style={{\n width: `${scrollerLayout.totalWidth}px`,\n height: `${scrollerLayout.totalHeight}px`,\n position: 'relative',\n boxSizing: 'border-box',\n margin: '0 auto',\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal && {\n display: 'flex',\n flexDirection: 'row',\n }),\n }}\n >\n <div\n style={{\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n width: scrollerLayout.startSpacing,\n height: '100%',\n flexShrink: 0,\n }\n : {\n height: scrollerLayout.startSpacing,\n width: '100%',\n }),\n }}\n />\n <div\n style={{\n gap: scrollerLayout.pageGap,\n display: 'flex',\n alignItems: 'center',\n position: 'relative',\n boxSizing: 'border-box',\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n flexDirection: 'row',\n minHeight: '100%',\n }\n : {\n flexDirection: 'column',\n minWidth: 'fit-content',\n }),\n }}\n >\n {scrollerLayout.items.map((item) => (\n <div\n key={item.pageNumbers[0]}\n style={{\n display: 'flex',\n justifyContent: 'center',\n gap: scrollerLayout.pageGap,\n }}\n >\n {item.pageLayouts.map((layout) => (\n <div\n key={layout.pageNumber}\n style={{\n width: `${layout.rotatedWidth}px`,\n height: `${layout.rotatedHeight}px`,\n }}\n >\n {renderPage({\n ...layout,\n rotation: coreState.core.rotation,\n scale: coreState.core.scale,\n document: coreState.core.document,\n })}\n </div>\n ))}\n </div>\n ))}\n </div>\n <div\n style={{\n ...(scrollerLayout.strategy === ScrollStrategy.Horizontal\n ? {\n width: scrollerLayout.endSpacing,\n height: '100%',\n flexShrink: 0,\n }\n : {\n height: scrollerLayout.endSpacing,\n width: '100%',\n }),\n }}\n />\n {overlayElements}\n </div>\n );\n}\n"],"names":["totalPages"],"mappings":";;;;;AAIO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;AAE7E,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,UAAU,OAAO,IAAI,oBAAoB;AACjD,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,CAAC;AAChD,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,CAAC;AAE9C,YAAU,MAAM;AACd,QAAI,CAAC,OAAQ;AACb,WAAO,OAAO,aAAa,CAAC,EAAE,YA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,IAEd;AAAA,gBACE,QAAQ,eAAe;AAAA,gBACvB,OAAO;AAAA,cAAA;AAAA,YACT;AAAA,UACN;AAAA,QACF;AAAA,QACC;AAAA,MAAA;AAAA,IAAA;AAAA,EACH;AAEJ;"}
@@ -1,7 +1,7 @@
1
1
  import { ReactNode, HTMLAttributes } from '../../preact/adapter.ts';
2
2
  import { PageLayout } from '../../lib/index.ts';
3
3
  import { PdfDocumentObject, Rotation } from '@embedpdf/models';
4
- interface RenderPageProps extends PageLayout {
4
+ export interface RenderPageProps extends PageLayout {
5
5
  rotation: Rotation;
6
6
  scale: number;
7
7
  document: PdfDocumentObject | null;
@@ -1,2 +1,3 @@
1
1
  export * from './hooks';
2
2
  export * from './components';
3
+ export * from '../lib/index.ts';
@@ -1,7 +1,7 @@
1
1
  import { ReactNode, HTMLAttributes } from '../../react/adapter.ts';
2
2
  import { PageLayout } from '../../lib/index.ts';
3
3
  import { PdfDocumentObject, Rotation } from '@embedpdf/models';
4
- interface RenderPageProps extends PageLayout {
4
+ export interface RenderPageProps extends PageLayout {
5
5
  rotation: Rotation;
6
6
  scale: number;
7
7
  document: PdfDocumentObject | null;
@@ -1,2 +1,3 @@
1
1
  export * from './hooks';
2
2
  export * from './components';
3
+ export * from '../lib/index.ts';
@@ -1,17 +1,10 @@
1
1
  import { StyleValue } from 'vue';
2
- import { PageLayout } from '../../lib/index.ts';
3
- import { PdfDocumentObject, Rotation } from '@embedpdf/models';
4
2
  type __VLS_Props = {
5
3
  style?: StyleValue;
6
4
  overlayElements?: any[];
7
5
  };
8
- interface PageSlotProps extends PageLayout {
9
- rotation: Rotation;
10
- scale: number;
11
- document: PdfDocumentObject | null;
12
- }
13
6
  declare var __VLS_1: {
14
- page: PageSlotProps;
7
+ page: any;
15
8
  };
16
9
  type __VLS_Slots = {} & {
17
10
  default?: (props: typeof __VLS_1) => any;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),t=require("@embedpdf/core/vue"),l=require("@embedpdf/plugin-scroll"),r=()=>t.usePlugin(l.ScrollPlugin.id),o=()=>t.useCapability(l.ScrollPlugin.id);const a=e.defineComponent({__name:"scroller",props:{style:{type:[Boolean,null,String,Object,Array]},overlayElements:{default:()=>[]}},setup(a){const n=a,i=e.useAttrs(),{provides:u}=o(),{plugin:c}=r(),{registry:s}=t.useRegistry(),p=e.ref(null);function y(e){const t=s.value.getStore().getState().core;return{...e,rotation:t.rotation,scale:t.scale,document:t.document}}e.watchEffect((e=>{if(!u.value)return;p.value=u.value.getScrollerLayout();e(u.value.onScrollerData((e=>p.value=e)))})),e.onMounted((()=>{var e;null==(e=c.value)||e.setLayoutReady()}));const g=e.computed((()=>{if(!p.value)return n.style;return["object"!=typeof n.style||Array.isArray(n.style)?n.style??{}:{...n.style},{width:`${p.value.totalWidth}px`,height:`${p.value.totalHeight}px`,position:"relative",boxSizing:"border-box",margin:"0 auto",...p.value.strategy===l.ScrollStrategy.Horizontal&&{display:"flex",flexDirection:"row"}}]}));return(t,l)=>p.value&&e.unref(s)?(e.openBlock(),e.createElementBlock("div",e.mergeProps({key:0,style:g.value},e.unref(i)),["horizontal"===p.value.strategy?(e.openBlock(),e.createElementBlock("div",{key:0,style:e.normalizeStyle({width:p.value.startSpacing+"px",height:"100%",flexShrink:0})},null,4)):(e.openBlock(),e.createElementBlock("div",{key:1,style:e.normalizeStyle({height:p.value.startSpacing+"px",width:"100%"})},null,4)),e.createElementVNode("div",{style:e.normalizeStyle({gap:p.value.pageGap+"px",display:"flex",alignItems:"center",position:"relative",boxSizing:"border-box",flexDirection:"horizontal"===p.value.strategy?"row":"column",minHeight:"horizontal"===p.value.strategy?"100%":void 0,minWidth:"vertical"===p.value.strategy?"fit-content":void 0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value.items,(l=>(e.openBlock(),e.createElementBlock("div",{key:l.pageNumbers[0],style:e.normalizeStyle({display:"flex",justifyContent:"center",gap:p.value.pageGap+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.pageLayouts,(l=>(e.openBlock(),e.createElementBlock("div",{key:l.pageNumber,style:e.normalizeStyle({width:l.rotatedWidth+"px",height:l.rotatedHeight+"px"})},[e.renderSlot(t.$slots,"default",{page:y(l)})],4)))),128))],4)))),128))],4),"horizontal"===p.value.strategy?(e.openBlock(),e.createElementBlock("div",{key:2,style:e.normalizeStyle({width:p.value.endSpacing+"px",height:"100%",flexShrink:0})},null,4)):(e.openBlock(),e.createElementBlock("div",{key:3,style:e.normalizeStyle({height:p.value.endSpacing+"px",width:"100%"})},null,4)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.overlayElements,((t,l)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t),{key:l})))),128))],16)):e.createCommentVNode("",!0)}});exports.Scroller=a,exports.useScroll=function(){const{provides:t}=o(),l=e.ref(1),r=e.ref(1);return e.watchEffect((e=>{if(!t.value)return;e(t.value.onPageChange((({pageNumber:e,totalPages:t})=>{l.value=e,r.value=t})))})),{scroll:t,currentPage:l,totalPages:r}},exports.useScrollCapability=o,exports.useScrollPlugin=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),t=require("@embedpdf/core/vue"),l=require("@embedpdf/plugin-scroll"),r=()=>t.usePlugin(l.ScrollPlugin.id),o=()=>t.useCapability(l.ScrollPlugin.id);const a=e.defineComponent({__name:"scroller",props:{style:{type:[Boolean,null,String,Object,Array]},overlayElements:{default:()=>[]}},setup(a){const n=a,i=e.useAttrs(),{provides:u}=o(),{plugin:c}=r(),{registry:s}=t.useRegistry(),p=e.ref(null);function y(e){const t=s.value.getStore().getState().core;return{...e,rotation:t.rotation,scale:t.scale,document:t.document}}e.watchEffect((e=>{if(!u.value)return;p.value=u.value.getScrollerLayout();e(u.value.onScrollerData((e=>p.value=e)))})),e.onMounted((()=>{var e;null==(e=c.value)||e.setLayoutReady()}));const g=e.computed((()=>{if(!p.value)return n.style;return["object"!=typeof n.style||Array.isArray(n.style)?n.style??{}:{...n.style},{width:`${p.value.totalWidth}px`,height:`${p.value.totalHeight}px`,position:"relative",boxSizing:"border-box",margin:"0 auto",...p.value.strategy===l.ScrollStrategy.Horizontal&&{display:"flex",flexDirection:"row"}}]}));return(t,l)=>p.value&&e.unref(s)?(e.openBlock(),e.createElementBlock("div",e.mergeProps({key:0,style:g.value},e.unref(i)),["horizontal"===p.value.strategy?(e.openBlock(),e.createElementBlock("div",{key:0,style:e.normalizeStyle({width:p.value.startSpacing+"px",height:"100%",flexShrink:0})},null,4)):(e.openBlock(),e.createElementBlock("div",{key:1,style:e.normalizeStyle({height:p.value.startSpacing+"px",width:"100%"})},null,4)),e.createElementVNode("div",{style:e.normalizeStyle({gap:p.value.pageGap+"px",display:"flex",alignItems:"center",position:"relative",boxSizing:"border-box",flexDirection:"horizontal"===p.value.strategy?"row":"column",minHeight:"horizontal"===p.value.strategy?"100%":void 0,minWidth:"vertical"===p.value.strategy?"fit-content":void 0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value.items,(l=>(e.openBlock(),e.createElementBlock("div",{key:l.pageNumbers[0],style:e.normalizeStyle({display:"flex",justifyContent:"center",gap:p.value.pageGap+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.pageLayouts,(l=>(e.openBlock(),e.createElementBlock("div",{key:l.pageNumber,style:e.normalizeStyle({width:l.rotatedWidth+"px",height:l.rotatedHeight+"px"})},[e.renderSlot(t.$slots,"default",{page:y(l)})],4)))),128))],4)))),128))],4),"horizontal"===p.value.strategy?(e.openBlock(),e.createElementBlock("div",{key:2,style:e.normalizeStyle({width:p.value.endSpacing+"px",height:"100%",flexShrink:0})},null,4)):(e.openBlock(),e.createElementBlock("div",{key:3,style:e.normalizeStyle({height:p.value.endSpacing+"px",width:"100%"})},null,4)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.overlayElements,((t,l)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t),{key:l})))),128))],16)):e.createCommentVNode("",!0)}});exports.Scroller=a,exports.useScroll=function(){const{provides:t}=o(),l=e.ref(1),r=e.ref(1);return e.watchEffect((e=>{if(!t.value)return;e(t.value.onPageChange((({pageNumber:e,totalPages:t})=>{l.value=e,r.value=t})))})),{scroll:t,currentPage:l,totalPages:r}},exports.useScrollCapability=o,exports.useScrollPlugin=r,Object.keys(l).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>l[e]})}));
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,2 +1,3 @@
1
1
  export * from './components';
2
2
  export * from './hooks';
3
+ export * from '../lib/index.ts';
package/dist/vue/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { ref, watchEffect, defineComponent, useAttrs, onMounted, computed, createElementBlock, createCommentVNode, unref, openBlock, mergeProps, createElementVNode, normalizeStyle, Fragment, renderList, renderSlot, createBlock, resolveDynamicComponent } from "vue";
2
2
  import { useCapability, usePlugin, useRegistry } from "@embedpdf/core/vue";
3
3
  import { ScrollPlugin, ScrollStrategy } from "@embedpdf/plugin-scroll";
4
+ export * from "@embedpdf/plugin-scroll";
4
5
  const useScrollPlugin = () => usePlugin(ScrollPlugin.id);
5
6
  const useScrollCapability = () => useCapability(ScrollPlugin.id);
6
7
  function useScroll() {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/vue/hooks/use-scroll.ts","../../src/vue/components/scroller.vue"],"sourcesContent":["import { ref, watchEffect } from 'vue';\nimport { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { ScrollPlugin } from '@embedpdf/plugin-scroll';\n\nexport const useScrollPlugin = () => usePlugin<ScrollPlugin>(ScrollPlugin.id);\nexport const useScrollCapability = () => useCapability<ScrollPlugin>(ScrollPlugin.id);\n\n/**\n * Convenience hook that also tracks current / total page.\n */\nexport function useScroll() {\n const { provides: scroll } = useScrollCapability();\n\n const currentPage = ref(1);\n const totalPages = ref(1);\n\n watchEffect((onCleanup) => {\n if (!scroll.value) return;\n\n const off = scroll.value.onPageChange(({ pageNumber, totalPages: tp }) => {\n currentPage.value = pageNumber;\n totalPages.value = tp;\n });\n onCleanup(off);\n });\n\n return {\n scroll,\n currentPage,\n totalPages,\n };\n}\n","<script setup lang=\"ts\">\n/* ------------------------------------------------------------------ */\n/* imports */\n/* ------------------------------------------------------------------ */\nimport { computed, onMounted, ref, watchEffect, useAttrs } from 'vue';\nimport type { StyleValue } from 'vue';\n\nimport { useScrollCapability, useScrollPlugin } from '../hooks';\nimport { ScrollStrategy, type ScrollerLayout, type PageLayout } from '@embedpdf/plugin-scroll';\nimport { useRegistry } from '@embedpdf/core/vue';\nimport type { PdfDocumentObject, Rotation } from '@embedpdf/models';\n\n/* ------------------------------------------------------------------ */\n/* props – pure layout; page content comes from the *slot* */\n/* ------------------------------------------------------------------ */\nconst props = withDefaults(\n defineProps<{\n style?: StyleValue;\n overlayElements?: any[];\n }>(),\n { overlayElements: () => [] },\n);\n\nconst attrs = useAttrs();\n\n/* ------------------------------------------------------------------ */\n/* plugin + reactive state */\n/* ------------------------------------------------------------------ */\nconst { provides: scrollProvides } = useScrollCapability();\nconst { plugin: scrollPlugin } = useScrollPlugin();\nconst { registry } = useRegistry(); // shallowRef<PluginRegistry|null>\n\nconst layout = ref<ScrollerLayout | null>(null);\n\n/* subscribe to scroller‑layout updates */\nwatchEffect((onCleanup) => {\n if (!scrollProvides.value) return;\n\n layout.value = scrollProvides.value.getScrollerLayout();\n const off = scrollProvides.value.onScrollerData((l) => (layout.value = l));\n onCleanup(off);\n});\n\n/* inform plugin once the DOM is ready */\nonMounted(() => {\n scrollPlugin.value?.setLayoutReady();\n});\n\n/* ------------------------------------------------------------------ */\n/* helpers */\n/* ------------------------------------------------------------------ */\ninterface PageSlotProps extends PageLayout {\n rotation: Rotation;\n scale: number;\n document: PdfDocumentObject | null;\n}\n\n/** Build the prop object that we’ll forward into the default slot */\nfunction pageSlotProps(pl: PageLayout): PageSlotProps {\n const core = registry.value!.getStore().getState().core;\n return {\n ...pl,\n rotation: core.rotation,\n scale: core.scale,\n document: core.document,\n };\n}\n\n/* ------------------------------------------------------------------ */\n/* computed root style */\n/* ------------------------------------------------------------------ */\nconst rootStyle = computed<StyleValue>(() => {\n if (!layout.value) return props.style;\n\n const base =\n typeof props.style === 'object' && !Array.isArray(props.style)\n ? { ...props.style }\n : (props.style ?? {});\n\n return [\n base,\n {\n width: `${layout.value.totalWidth}px`,\n height: `${layout.value.totalHeight}px`,\n position: 'relative',\n boxSizing: 'border-box',\n margin: '0 auto',\n ...(layout.value.strategy === ScrollStrategy.Horizontal && {\n display: 'flex',\n flexDirection: 'row',\n }),\n },\n ];\n});\n</script>\n\n<template>\n <!-- render nothing until both layout + registry exist -->\n <div v-if=\"layout && registry\" :style=\"rootStyle\" v-bind=\"attrs\">\n <!-- leading spacer -->\n <div\n v-if=\"layout.strategy === 'horizontal'\"\n :style=\"{ width: layout.startSpacing + 'px', height: '100%', flexShrink: 0 }\"\n />\n <div v-else :style=\"{ height: layout.startSpacing + 'px', width: '100%' }\" />\n\n <!-- actual page grid -->\n <div\n :style=\"{\n gap: layout.pageGap + 'px',\n display: 'flex',\n alignItems: 'center',\n position: 'relative',\n boxSizing: 'border-box',\n flexDirection: layout.strategy === 'horizontal' ? 'row' : 'column',\n minHeight: layout.strategy === 'horizontal' ? '100%' : undefined,\n minWidth: layout.strategy === 'vertical' ? 'fit-content' : undefined,\n }\"\n >\n <template v-for=\"item in layout.items\" :key=\"item.pageNumbers[0]\">\n <div :style=\"{ display: 'flex', justifyContent: 'center', gap: layout.pageGap + 'px' }\">\n <div\n v-for=\"pl in item.pageLayouts\"\n :key=\"pl.pageNumber\"\n :style=\"{ width: pl.rotatedWidth + 'px', height: pl.rotatedHeight + 'px' }\"\n >\n <!-- 🔑 give the host app full control over page content -->\n <slot :page=\"pageSlotProps(pl)\" />\n </div>\n </div>\n </template>\n </div>\n\n <!-- trailing spacer -->\n <div\n v-if=\"layout.strategy === 'horizontal'\"\n :style=\"{ width: layout.endSpacing + 'px', height: '100%', flexShrink: 0 }\"\n />\n <div v-else :style=\"{ height: layout.endSpacing + 'px', width: '100%' }\" />\n\n <!-- optional overlay components -->\n <component v-for=\"(el, i) in props.overlayElements\" :is=\"el\" :key=\"i\" />\n </div>\n</template>\n"],"names":["_unref","_openBlock","_createElementBlock","_mergeProps","_normalizeStyle","_createElementVNode","_Fragment","_renderList","_renderSlot","_createBlock","_resolveDynamicComponent"],"mappings":";;;AAIO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;AAK7E,SAAS,YAAY;AAC1B,QAAM,EAAE,UAAU,OAAO,IAAI,oBAAoB;AAE3C,QAAA,cAAc,IAAI,CAAC;AACnB,QAAA,aAAa,IAAI,CAAC;AAExB,cAAY,CAAC,cAAc;AACrB,QAAA,CAAC,OAAO,MAAO;AAEb,UAAA,MAAM,OAAO,MAAM,aAAa,CAAC,EAAE,YAAY,YAAY,SAAS;AACxE,kBAAY,QAAQ;AACpB,iBAAW,QAAQ;AAAA,IAAA,CACpB;AACD,cAAU,GAAG;AAAA,EAAA,CACd;AAEM,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;;;;;;AChBA,UAAM,QAAQ;AAQd,UAAM,QAAQ,SAAS;AAKvB,UAAM,EAAE,UAAU,eAAe,IAAI,oBAAoB;AACzD,UAAM,EAAE,QAAQ,aAAa,IAAI,gBAAgB;AAC3C,UAAA,EAAE,SAAS,IAAI,YAAY;AAE3B,UAAA,SAAS,IAA2B,IAAI;AAG9C,gBAAY,CAAC,cAAc;AACrB,UAAA,CAAC,eAAe,MAAO;AAEpB,aAAA,QAAQ,eAAe,MAAM,kBAAkB;AAChD,YAAA,MAAM,eAAe,MAAM,eAAe,CAAC,MAAO,OAAO,QA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["../../src/vue/hooks/use-scroll.ts","../../src/vue/components/scroller.vue"],"sourcesContent":["import { ref, watchEffect } from 'vue';\nimport { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { ScrollPlugin } from '@embedpdf/plugin-scroll';\n\nexport const useScrollPlugin = () => usePlugin<ScrollPlugin>(ScrollPlugin.id);\nexport const useScrollCapability = () => useCapability<ScrollPlugin>(ScrollPlugin.id);\n\n/**\n * Convenience hook that also tracks current / total page.\n */\nexport function useScroll() {\n const { provides: scroll } = useScrollCapability();\n\n const currentPage = ref(1);\n const totalPages = ref(1);\n\n watchEffect((onCleanup) => {\n if (!scroll.value) return;\n\n const off = scroll.value.onPageChange(({ pageNumber, totalPages: tp }) => {\n currentPage.value = pageNumber;\n totalPages.value = tp;\n });\n onCleanup(off);\n });\n\n return {\n scroll,\n currentPage,\n totalPages,\n };\n}\n","<script setup lang=\"ts\">\n/* ------------------------------------------------------------------ */\n/* imports */\n/* ------------------------------------------------------------------ */\nimport { computed, onMounted, ref, watchEffect, useAttrs } from 'vue';\nimport type { StyleValue } from 'vue';\n\nimport { useScrollCapability, useScrollPlugin } from '../hooks';\nimport { ScrollStrategy, type ScrollerLayout, type PageLayout } from '@embedpdf/plugin-scroll';\nimport { useRegistry } from '@embedpdf/core/vue';\nimport type { PdfDocumentObject, Rotation } from '@embedpdf/models';\n\n/* ------------------------------------------------------------------ */\n/* props – pure layout; page content comes from the *slot* */\n/* ------------------------------------------------------------------ */\nconst props = withDefaults(\n defineProps<{\n style?: StyleValue;\n overlayElements?: any[];\n }>(),\n { overlayElements: () => [] },\n);\n\nconst attrs = useAttrs();\n\n/* ------------------------------------------------------------------ */\n/* plugin + reactive state */\n/* ------------------------------------------------------------------ */\nconst { provides: scrollProvides } = useScrollCapability();\nconst { plugin: scrollPlugin } = useScrollPlugin();\nconst { registry } = useRegistry(); // shallowRef<PluginRegistry|null>\n\nconst layout = ref<ScrollerLayout | null>(null);\n\n/* subscribe to scroller‑layout updates */\nwatchEffect((onCleanup) => {\n if (!scrollProvides.value) return;\n\n layout.value = scrollProvides.value.getScrollerLayout();\n const off = scrollProvides.value.onScrollerData((l) => (layout.value = l));\n onCleanup(off);\n});\n\n/* inform plugin once the DOM is ready */\nonMounted(() => {\n scrollPlugin.value?.setLayoutReady();\n});\n\n/* ------------------------------------------------------------------ */\n/* helpers */\n/* ------------------------------------------------------------------ */\ninterface PageSlotProps extends PageLayout {\n rotation: Rotation;\n scale: number;\n document: PdfDocumentObject | null;\n}\n\n/** Build the prop object that we’ll forward into the default slot */\nfunction pageSlotProps(pl: PageLayout): PageSlotProps {\n const core = registry.value!.getStore().getState().core;\n return {\n ...pl,\n rotation: core.rotation,\n scale: core.scale,\n document: core.document,\n };\n}\n\n/* ------------------------------------------------------------------ */\n/* computed root style */\n/* ------------------------------------------------------------------ */\nconst rootStyle = computed<StyleValue>(() => {\n if (!layout.value) return props.style;\n\n const base =\n typeof props.style === 'object' && !Array.isArray(props.style)\n ? { ...props.style }\n : (props.style ?? {});\n\n return [\n base,\n {\n width: `${layout.value.totalWidth}px`,\n height: `${layout.value.totalHeight}px`,\n position: 'relative',\n boxSizing: 'border-box',\n margin: '0 auto',\n ...(layout.value.strategy === ScrollStrategy.Horizontal && {\n display: 'flex',\n flexDirection: 'row',\n }),\n },\n ];\n});\n</script>\n\n<template>\n <!-- render nothing until both layout + registry exist -->\n <div v-if=\"layout && registry\" :style=\"rootStyle\" v-bind=\"attrs\">\n <!-- leading spacer -->\n <div\n v-if=\"layout.strategy === 'horizontal'\"\n :style=\"{ width: layout.startSpacing + 'px', height: '100%', flexShrink: 0 }\"\n />\n <div v-else :style=\"{ height: layout.startSpacing + 'px', width: '100%' }\" />\n\n <!-- actual page grid -->\n <div\n :style=\"{\n gap: layout.pageGap + 'px',\n display: 'flex',\n alignItems: 'center',\n position: 'relative',\n boxSizing: 'border-box',\n flexDirection: layout.strategy === 'horizontal' ? 'row' : 'column',\n minHeight: layout.strategy === 'horizontal' ? '100%' : undefined,\n minWidth: layout.strategy === 'vertical' ? 'fit-content' : undefined,\n }\"\n >\n <template v-for=\"item in layout.items\" :key=\"item.pageNumbers[0]\">\n <div :style=\"{ display: 'flex', justifyContent: 'center', gap: layout.pageGap + 'px' }\">\n <div\n v-for=\"pl in item.pageLayouts\"\n :key=\"pl.pageNumber\"\n :style=\"{ width: pl.rotatedWidth + 'px', height: pl.rotatedHeight + 'px' }\"\n >\n <!-- 🔑 give the host app full control over page content -->\n <slot :page=\"pageSlotProps(pl)\" />\n </div>\n </div>\n </template>\n </div>\n\n <!-- trailing spacer -->\n <div\n v-if=\"layout.strategy === 'horizontal'\"\n :style=\"{ width: layout.endSpacing + 'px', height: '100%', flexShrink: 0 }\"\n />\n <div v-else :style=\"{ height: layout.endSpacing + 'px', width: '100%' }\" />\n\n <!-- optional overlay components -->\n <component v-for=\"(el, i) in props.overlayElements\" :is=\"el\" :key=\"i\" />\n </div>\n</template>\n"],"names":["_unref","_openBlock","_createElementBlock","_mergeProps","_normalizeStyle","_createElementVNode","_Fragment","_renderList","_renderSlot","_createBlock","_resolveDynamicComponent"],"mappings":";;;;AAIO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;AAK7E,SAAS,YAAY;AAC1B,QAAM,EAAE,UAAU,OAAO,IAAI,oBAAoB;AAE3C,QAAA,cAAc,IAAI,CAAC;AACnB,QAAA,aAAa,IAAI,CAAC;AAExB,cAAY,CAAC,cAAc;AACrB,QAAA,CAAC,OAAO,MAAO;AAEb,UAAA,MAAM,OAAO,MAAM,aAAa,CAAC,EAAE,YAAY,YAAY,SAAS;AACxE,kBAAY,QAAQ;AACpB,iBAAW,QAAQ;AAAA,IAAA,CACpB;AACD,cAAU,GAAG;AAAA,EAAA,CACd;AAEM,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;;;;;;AChBA,UAAM,QAAQ;AAQd,UAAM,QAAQ,SAAS;AAKvB,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AEpCF,mBAA2E,OAAA;AAAA;UAA9D,OAAKE,eAAA,EAAA,QAAY,OAAM,MAAC,aAAU,MAAA,OAAA,OAAA,CAAA;AAAA,QAAA;SAG/CH,UAAA,IAAA,GAAAC,mBAAwEI,2BAA3C,MAAM,iBAAhB,CAAA,IAAI,MAAC;AAAxB,iBAAAL,UAAA,GAAAQ,YAAwEC,wBAAf,EAAE,GAAG,EAAA,KAAK,GAAC;AAAA;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-scroll",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -28,22 +28,22 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "@embedpdf/models": "1.0.19"
31
+ "@embedpdf/models": "1.0.21"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/react": "^18.2.0",
35
35
  "typescript": "^5.0.0",
36
- "@embedpdf/plugin-viewport": "1.0.19",
37
- "@embedpdf/core": "1.0.19",
38
- "@embedpdf/build": "1.0.0"
36
+ "@embedpdf/core": "1.0.21",
37
+ "@embedpdf/build": "1.0.0",
38
+ "@embedpdf/plugin-viewport": "1.0.21"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "preact": "^10.26.4",
42
42
  "react": ">=16.8.0",
43
43
  "react-dom": ">=16.8.0",
44
44
  "vue": ">=3.2.0",
45
- "@embedpdf/plugin-viewport": "1.0.19",
46
- "@embedpdf/core": "1.0.19"
45
+ "@embedpdf/core": "1.0.21",
46
+ "@embedpdf/plugin-viewport": "1.0.21"
47
47
  },
48
48
  "files": [
49
49
  "dist",