@embedpdf/plugin-viewport 1.0.11 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/index.cjs +2 -247
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.ts +1 -107
  4. package/dist/index.js +20 -32
  5. package/dist/index.js.map +1 -1
  6. package/dist/lib/actions.d.ts +27 -0
  7. package/dist/lib/index.d.ts +8 -0
  8. package/dist/lib/manifest.d.ts +4 -0
  9. package/dist/lib/reducer.d.ts +5 -0
  10. package/dist/lib/types.d.ts +52 -0
  11. package/dist/lib/viewport-plugin.d.ts +27 -0
  12. package/dist/preact/adapter.d.ts +5 -0
  13. package/dist/preact/core.d.ts +1 -0
  14. package/dist/preact/index.cjs +2 -123
  15. package/dist/preact/index.cjs.map +1 -1
  16. package/dist/preact/index.d.ts +1 -23
  17. package/dist/preact/index.js +9 -15
  18. package/dist/preact/index.js.map +1 -1
  19. package/dist/react/adapter.d.ts +2 -0
  20. package/dist/react/core.d.ts +1 -0
  21. package/dist/react/index.cjs +2 -125
  22. package/dist/react/index.cjs.map +1 -1
  23. package/dist/react/index.d.ts +1 -25
  24. package/dist/react/index.js +6 -14
  25. package/dist/react/index.js.map +1 -1
  26. package/dist/shared-preact/components/index.d.ts +1 -0
  27. package/dist/shared-preact/components/viewport.d.ts +6 -0
  28. package/dist/shared-preact/hooks/index.d.ts +2 -0
  29. package/dist/shared-preact/hooks/use-viewport-ref.d.ts +1 -0
  30. package/dist/shared-preact/hooks/use-viewport.d.ts +11 -0
  31. package/dist/shared-preact/index.d.ts +2 -0
  32. package/dist/shared-react/components/index.d.ts +1 -0
  33. package/dist/shared-react/components/viewport.d.ts +6 -0
  34. package/dist/shared-react/hooks/index.d.ts +2 -0
  35. package/dist/shared-react/hooks/use-viewport-ref.d.ts +1 -0
  36. package/dist/shared-react/hooks/use-viewport.d.ts +11 -0
  37. package/dist/shared-react/index.d.ts +2 -0
  38. package/dist/vue/components/index.d.ts +1 -0
  39. package/dist/vue/components/viewport.vue.d.ts +12 -0
  40. package/dist/vue/hooks/index.d.ts +2 -0
  41. package/dist/vue/hooks/use-viewport-ref.d.ts +1 -0
  42. package/dist/vue/hooks/use-viewport.d.ts +3 -0
  43. package/dist/vue/index.cjs +2 -0
  44. package/dist/vue/index.cjs.map +1 -0
  45. package/dist/vue/index.d.ts +2 -0
  46. package/dist/vue/index.js +89 -0
  47. package/dist/vue/index.js.map +1 -0
  48. package/package.json +21 -12
  49. package/dist/index.d.cts +0 -107
  50. package/dist/preact/index.d.cts +0 -23
  51. package/dist/react/index.d.cts +0 -25
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react/components/viewport.tsx","../../src/react/hooks/use-viewport.ts","../../src/react/hooks/use-viewport-ref.ts"],"sourcesContent":["import React, { ReactNode, useEffect, useState } from 'react';\n\nimport { useViewportCapability } from '../hooks';\nimport { useViewportRef } from '../hooks/use-viewport-ref';\n\ntype ViewportProps = React.HTMLAttributes<HTMLDivElement> & {\n children: ReactNode;\n};\n\nexport function Viewport({ children, ...props }: ViewportProps) {\n const [viewportGap, setViewportGap] = useState(0);\n const viewportRef = useViewportRef();\n const { provides: viewportProvides } = useViewportCapability();\n\n useEffect(() => {\n if (viewportProvides) {\n setViewportGap(viewportProvides.getViewportGap());\n }\n }, [viewportProvides]);\n\n const { style, ...restProps } = props;\n return (\n <div\n {...restProps}\n ref={viewportRef}\n style={{\n ...(typeof style === 'object' ? style : {}),\n padding: `${viewportGap}px`,\n }}\n >\n {children}\n </div>\n );\n}\n","import { useCapability, usePlugin } from '@embedpdf/core/react';\nimport { ViewportPlugin } from '@embedpdf/plugin-viewport';\n\nexport const useViewportPlugin = () => usePlugin<ViewportPlugin>(ViewportPlugin.id);\nexport const useViewportCapability = () => useCapability<ViewportPlugin>(ViewportPlugin.id);\n","import { Rect } from '@embedpdf/models';\nimport { useLayoutEffect, useRef } from 'react';\n\nimport { useViewportPlugin } from './use-viewport';\n\nexport function useViewportRef() {\n const { plugin: viewportPlugin } = useViewportPlugin();\n const containerRef = useRef<HTMLDivElement>(null);\n\n useLayoutEffect(() => {\n if (!viewportPlugin) return;\n\n const container = containerRef.current;\n if (!container) return;\n\n /* ---------- live rect provider --------------------------------- */\n const provideRect = (): Rect => {\n const r = container.getBoundingClientRect();\n return {\n origin: { x: r.left, y: r.top },\n size: { width: r.width, height: r.height },\n };\n };\n viewportPlugin.registerBoundingRectProvider(provideRect);\n\n // Example: On scroll, call setMetrics\n const onScroll = () => {\n viewportPlugin.setViewportScrollMetrics({\n scrollTop: container.scrollTop,\n scrollLeft: container.scrollLeft,\n });\n };\n container.addEventListener('scroll', onScroll);\n\n // Example: On resize, call setMetrics\n const resizeObserver = new ResizeObserver(() => {\n viewportPlugin.setViewportResizeMetrics({\n width: container.offsetWidth,\n height: container.offsetHeight,\n clientWidth: container.clientWidth,\n clientHeight: container.clientHeight,\n scrollTop: container.scrollTop,\n scrollLeft: container.scrollLeft,\n scrollWidth: container.scrollWidth,\n scrollHeight: container.scrollHeight,\n });\n });\n resizeObserver.observe(container);\n\n const unsubscribeScrollRequest = viewportPlugin.onScrollRequest(\n ({ x, y, behavior = 'auto' }) => {\n requestAnimationFrame(() => {\n container.scrollTo({ left: x, top: y, behavior });\n });\n },\n );\n\n // Cleanup\n return () => {\n viewportPlugin.registerBoundingRectProvider(null);\n container.removeEventListener('scroll', onScroll);\n resizeObserver.disconnect();\n unsubscribeScrollRequest();\n };\n }, [viewportPlugin]);\n\n // Return the ref so your React code can attach it to a div\n return containerRef;\n}\n"],"mappings":";AAAA,SAA2B,WAAW,gBAAgB;;;ACAtD,SAAS,eAAe,iBAAiB;AACzC,SAAS,sBAAsB;AAExB,IAAM,oBAAoB,MAAM,UAA0B,eAAe,EAAE;AAC3E,IAAM,wBAAwB,MAAM,cAA8B,eAAe,EAAE;;;ACH1F,SAAS,iBAAiB,cAAc;AAIjC,SAAS,iBAAiB;AAC/B,QAAM,EAA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C,cAAc,CAAC;AAGnB,SAAO;AACT;;;AF9CI;AAbG,SAAS,SAAS,EAAE,UAAU,GAAG,MAAM,GAAkB;AAC9D,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,CAAC;AAChD,QAAM,cAAc,eAAe;AACnC,QAAM,EAAE,UAAU,iBAAiB,IAAI,sBAAsB;AAE7D,YAAU,MAAM;AACd,QAAI,kBAAkB;AACpB,qBAAe,iBAAiB,eAAe,CAAC;AAAA,IAClD;AAAA,EACF,GAAG,CAAC,gBAAgB,CAAC;AAErB,QAAM,EAAE,OAAO,GAAG,UAAU,IAAI;AAChC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,KAAK;AAAA,MACL,OAAO;AAAA,QACL,GAAI,OAAO,UAAU,WAAW,QAAQ,CAAC;AAAA,QACzC,SAAS,GAAG,WAAW;AAAA,MACzB;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;","names":[]}
1
+ {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-viewport.ts","../../src/shared/hooks/use-viewport-ref.ts","../../src/shared/components/viewport.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { ViewportPlugin } from '@embedpdf/plugin-viewport';\n\nexport const useViewportPlugin = () => usePlugin<ViewportPlugin>(ViewportPlugin.id);\nexport const useViewportCapability = () => useCapability<ViewportPlugin>(ViewportPlugin.id);\n","import { Rect } from '@embedpdf/models';\nimport { useLayoutEffect, useRef } from '@framework';\n\nimport { useViewportPlugin } from './use-viewport';\n\nexport function useViewportRef() {\n const { plugin: viewportPlugin } = useViewportPlugin();\n const containerRef = useRef<HTMLDivElement>(null);\n\n useLayoutEffect(() => {\n if (!viewportPlugin) return;\n\n const container = containerRef.current;\n if (!container) return;\n\n /* ---------- live rect provider --------------------------------- */\n const provideRect = (): Rect => {\n const r = container.getBoundingClientRect();\n return {\n origin: { x: r.left, y: r.top },\n size: { width: r.width, height: r.height },\n };\n };\n viewportPlugin.registerBoundingRectProvider(provideRect);\n\n // Example: On scroll, call setMetrics\n const onScroll = () => {\n viewportPlugin.setViewportScrollMetrics({\n scrollTop: container.scrollTop,\n scrollLeft: container.scrollLeft,\n });\n };\n container.addEventListener('scroll', onScroll);\n\n // Example: On resize, call setMetrics\n const resizeObserver = new ResizeObserver(() => {\n viewportPlugin.setViewportResizeMetrics({\n width: container.offsetWidth,\n height: container.offsetHeight,\n clientWidth: container.clientWidth,\n clientHeight: container.clientHeight,\n scrollTop: container.scrollTop,\n scrollLeft: container.scrollLeft,\n scrollWidth: container.scrollWidth,\n scrollHeight: container.scrollHeight,\n });\n });\n resizeObserver.observe(container);\n\n const unsubscribeScrollRequest = viewportPlugin.onScrollRequest(\n ({ x, y, behavior = 'auto' }) => {\n requestAnimationFrame(() => {\n container.scrollTo({ left: x, top: y, behavior });\n });\n },\n );\n\n // Cleanup\n return () => {\n viewportPlugin.registerBoundingRectProvider(null);\n container.removeEventListener('scroll', onScroll);\n resizeObserver.disconnect();\n unsubscribeScrollRequest();\n };\n }, [viewportPlugin]);\n\n // Return the ref so your React code can attach it to a div\n return containerRef;\n}\n","import { ReactNode, useEffect, useState, HTMLAttributes } from '@framework';\n\nimport { useViewportCapability } from '../hooks';\nimport { useViewportRef } from '../hooks/use-viewport-ref';\n\ntype ViewportProps = HTMLAttributes<HTMLDivElement> & {\n children: ReactNode;\n};\n\nexport function Viewport({ children, ...props }: ViewportProps) {\n const [viewportGap, setViewportGap] = useState(0);\n const viewportRef = useViewportRef();\n const { provides: viewportProvides } = useViewportCapability();\n\n useEffect(() => {\n if (viewportProvides) {\n setViewportGap(viewportProvides.getViewportGap());\n }\n }, [viewportProvides]);\n\n const { style, ...restProps } = props;\n return (\n <div\n {...restProps}\n ref={viewportRef}\n style={{\n ...(typeof style === 'object' ? style : {}),\n padding: `${viewportGap}px`,\n }}\n >\n {children}\n </div>\n );\n}\n"],"names":[],"mappings":";;;;AAGO,MAAM,oBAAoB,MAAM,UAA0B,eAAe,E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U,QAAQ;AAChD,qBAAe,WAAW;AACD,+BAAA;AAAA,IAC3B;AAAA,EAAA,GACC,CAAC,cAAc,CAAC;AAGZ,SAAA;AACT;AC3DO,SAAS,SAAS,EAAE,UAAU,GAAG,SAAwB;AAC9D,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,CAAC;AAChD,QAAM,cAAc,eAAe;AACnC,QAAM,EAAE,UAAU,iBAAiB,IAAI,sBAAsB;AAE7D,YAAU,MAAM;AACd,QAAI,kBAAkB;AACL,qBAAA,iBAAiB,gBAAgB;AAAA,IAAA;AAAA,EAClD,GACC,CAAC,gBAAgB,CAAC;AAErB,QAAM,EAAE,OAAO,GAAG,UAAA,IAAc;AAE9B,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,MACJ,KAAK;AAAA,MACL,OAAO;AAAA,QACL,GAAI,OAAO,UAAU,WAAW,QAAQ,CAAC;AAAA,QACzC,SAAS,GAAG,WAAW;AAAA,MACzB;AAAA,MAEC;AAAA,IAAA;AAAA,EACH;AAEJ;"}
@@ -0,0 +1 @@
1
+ export * from './viewport';
@@ -0,0 +1,6 @@
1
+ import { ReactNode, HTMLAttributes } from '../../preact/adapter.ts';
2
+ type ViewportProps = HTMLAttributes<HTMLDivElement> & {
3
+ children: ReactNode;
4
+ };
5
+ export declare function Viewport({ children, ...props }: ViewportProps): import("preact").JSX.Element;
6
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './use-viewport';
2
+ export * from './use-viewport-ref';
@@ -0,0 +1 @@
1
+ export declare function useViewportRef(): import('preact').RefObject<HTMLDivElement>;
@@ -0,0 +1,11 @@
1
+ import { ViewportPlugin } from '../../lib/index.ts';
2
+ export declare const useViewportPlugin: () => {
3
+ plugin: ViewportPlugin | null;
4
+ isLoading: boolean;
5
+ ready: Promise<void>;
6
+ };
7
+ export declare const useViewportCapability: () => {
8
+ provides: Readonly<import('../../lib/index.ts').ViewportCapability> | null;
9
+ isLoading: boolean;
10
+ ready: Promise<void>;
11
+ };
@@ -0,0 +1,2 @@
1
+ export * from './components';
2
+ export * from './hooks';
@@ -0,0 +1 @@
1
+ export * from './viewport';
@@ -0,0 +1,6 @@
1
+ import { ReactNode, HTMLAttributes } from '../../react/adapter.ts';
2
+ type ViewportProps = HTMLAttributes<HTMLDivElement> & {
3
+ children: ReactNode;
4
+ };
5
+ export declare function Viewport({ children, ...props }: ViewportProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './use-viewport';
2
+ export * from './use-viewport-ref';
@@ -0,0 +1 @@
1
+ export declare function useViewportRef(): import('react').RefObject<HTMLDivElement>;
@@ -0,0 +1,11 @@
1
+ import { ViewportPlugin } from '../../lib/index.ts';
2
+ export declare const useViewportPlugin: () => {
3
+ plugin: ViewportPlugin | null;
4
+ isLoading: boolean;
5
+ ready: Promise<void>;
6
+ };
7
+ export declare const useViewportCapability: () => {
8
+ provides: Readonly<import('../../lib/index.ts').ViewportCapability> | null;
9
+ isLoading: boolean;
10
+ ready: Promise<void>;
11
+ };
@@ -0,0 +1,2 @@
1
+ export * from './components';
2
+ export * from './hooks';
@@ -0,0 +1 @@
1
+ export { default as Viewport } from './viewport.vue';
@@ -0,0 +1,12 @@
1
+ declare var __VLS_1: {};
2
+ type __VLS_Slots = {} & {
3
+ default?: (props: typeof __VLS_1) => any;
4
+ };
5
+ declare const __VLS_component: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
6
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
7
+ export default _default;
8
+ type __VLS_WithSlots<T, S> = T & {
9
+ new (): {
10
+ $slots: S;
11
+ };
12
+ };
@@ -0,0 +1,2 @@
1
+ export * from './use-viewport';
2
+ export * from './use-viewport-ref';
@@ -0,0 +1 @@
1
+ export declare function useViewportRef(): import('vue').Ref<HTMLDivElement | null, HTMLDivElement | null>;
@@ -0,0 +1,3 @@
1
+ import { ViewportPlugin } from '../../lib/index.ts';
2
+ export declare const useViewportPlugin: () => import('@embedpdf/core/vue').PluginState<ViewportPlugin>;
3
+ export declare const useViewportCapability: () => import('@embedpdf/core/vue').CapabilityState<Readonly<import('../../lib/index.ts').ViewportCapability>>;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),t=require("@embedpdf/core/vue"),o=require("@embedpdf/plugin-viewport"),r=()=>t.usePlugin(o.ViewportPlugin.id),i=()=>t.useCapability(o.ViewportPlugin.id);function l(){const{plugin:t}=r(),o=e.ref(null);return e.onMounted((()=>{const r=t.value,i=o.value;if(!i||!r)return;r.registerBoundingRectProvider((()=>{const e=i.getBoundingClientRect();return{origin:{x:e.left,y:e.top},size:{width:e.width,height:e.height}}}));const l=()=>{r.setViewportScrollMetrics({scrollTop:i.scrollTop,scrollLeft:i.scrollLeft})};i.addEventListener("scroll",l);const s=new ResizeObserver((()=>{r.setViewportResizeMetrics({width:i.offsetWidth,height:i.offsetHeight,clientWidth:i.clientWidth,clientHeight:i.clientHeight,scrollTop:i.scrollTop,scrollLeft:i.scrollLeft,scrollWidth:i.scrollWidth,scrollHeight:i.scrollHeight})}));s.observe(i);const n=r.onScrollRequest((({x:e,y:t,behavior:o="auto"})=>{requestAnimationFrame((()=>{i.scrollTo({left:e,top:t,behavior:o})}))}));e.onUnmounted((()=>{r.registerBoundingRectProvider(null),i.removeEventListener("scroll",l),s.disconnect(),n()}))})),o}const s=e.defineComponent({__name:"viewport",setup(t){const o=e.useAttrs(),{provides:r}=i(),s=e.ref(0);e.watch(r,(e=>{e&&(s.value=e.getViewportGap())}),{immediate:!0});const n=l();return(t,r)=>(e.openBlock(),e.createElementBlock("div",e.mergeProps({ref_key:"viewportRef",ref:n},e.unref(o),{style:{padding:`${s.value}px`}}),[e.renderSlot(t.$slots,"default")],16))}});exports.Viewport=s,exports.useViewportCapability=i,exports.useViewportPlugin=r,exports.useViewportRef=l;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/vue/hooks/use-viewport.ts","../../src/vue/hooks/use-viewport-ref.ts","../../src/vue/components/viewport.vue"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { ViewportPlugin } from '@embedpdf/plugin-viewport';\n\nexport const useViewportPlugin = () => usePlugin<ViewportPlugin>(ViewportPlugin.id);\nexport const useViewportCapability = () => useCapability<ViewportPlugin>(ViewportPlugin.id);\n","import { Rect } from '@embedpdf/models';\nimport { onMounted, onUnmounted, ref } from 'vue';\n\nimport { useViewportPlugin } from './use-viewport';\n\nexport function useViewportRef() {\n const { plugin: pluginRef } = useViewportPlugin();\n const containerRef = ref<HTMLDivElement | null>(null);\n\n onMounted(() => {\n const viewportPlugin = pluginRef.value;\n const container = containerRef.value;\n if (!container || !viewportPlugin) return;\n\n /* ---------- live rect provider --------------------------------- */\n const provideRect = (): Rect => {\n const r = container.getBoundingClientRect();\n return {\n origin: { x: r.left, y: r.top },\n size: { width: r.width, height: r.height },\n };\n };\n viewportPlugin.registerBoundingRectProvider(provideRect);\n\n // Example: On scroll, call setMetrics\n const onScroll = () => {\n viewportPlugin.setViewportScrollMetrics({\n scrollTop: container.scrollTop,\n scrollLeft: container.scrollLeft,\n });\n };\n container.addEventListener('scroll', onScroll);\n\n // Example: On resize, call setMetrics\n const resizeObserver = new ResizeObserver(() => {\n viewportPlugin.setViewportResizeMetrics({\n width: container.offsetWidth,\n height: container.offsetHeight,\n clientWidth: container.clientWidth,\n clientHeight: container.clientHeight,\n scrollTop: container.scrollTop,\n scrollLeft: container.scrollLeft,\n scrollWidth: container.scrollWidth,\n scrollHeight: container.scrollHeight,\n });\n });\n resizeObserver.observe(container);\n\n const unsubscribeScrollRequest = viewportPlugin.onScrollRequest(\n ({ x, y, behavior = 'auto' }) => {\n requestAnimationFrame(() => {\n container.scrollTo({ left: x, top: y, behavior });\n });\n },\n );\n\n onUnmounted(() => {\n viewportPlugin.registerBoundingRectProvider(null);\n container.removeEventListener('scroll', onScroll);\n resizeObserver.disconnect();\n unsubscribeScrollRequest();\n });\n });\n\n // Return the ref so your Vue code can attach it to a div\n return containerRef;\n}\n","<script setup lang=\"ts\">\nimport { ref, watch, useAttrs } from 'vue';\n\nimport { useViewportCapability, useViewportRef } from '../hooks';\n\n/* -------------------------------------------------- */\n/* props & attrs */\n/* -------------------------------------------------- */\nconst attrs = useAttrs(); // forward class/id/… to <div>\n\n/* -------------------------------------------------- */\n/* plugin + reactive viewport gap */\n/* -------------------------------------------------- */\nconst { provides: viewportProvides } = useViewportCapability();\nconst viewportGap = ref(0);\n\nwatch(\n viewportProvides,\n (vp) => {\n if (vp) viewportGap.value = vp.getViewportGap();\n },\n { immediate: true },\n);\n\n/* -------------------------------------------------- */\n/* element ref that wires up scroll / resize logic */\n/* -------------------------------------------------- */\nconst viewportRef = useViewportRef();\n</script>\n\n<template>\n <div ref=\"viewportRef\" v-bind=\"attrs\" :style=\"{ padding: `${viewportGap}px` }\">\n <slot />\n </div>\n</template>\n"],"names":["useViewportPlugin","usePlugin","ViewportPlugin","id","useViewportCapability","useCapability","useViewportRef","plugin","pluginRef","containerRef","ref","onMounted","viewportPlugin","value","container","registerBoundingRectProvider","r","getBoundingClientRect","origin","x","left","y","top","size","width","height","onScroll","setViewportScrollMetrics","scrollTop","scrollLeft","addEventListener","resizeObserver","ResizeObserver","setViewportResizeMetrics","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","observe","unsubscribeScrollRequest","onScrollRequest","behavior","requestAnimationFrame","scrollTo","onUnmounted","removeEventListener","disconnect","attrs","useAttrs","provides","viewportProvides","viewportGap","vue$1","watch","vp","getViewportGap","immediate","viewportRef","_openBlock","_createElementBlock","_mergeProps","_unref","style","_renderSlot","_ctx","$sl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EH,GACCI,IACKA,IAAIH,EAAYxC,MAAQ2C,EAAGC,iBAAe,GAEhD,CAAEC,WAAW,IAMf,MAAMC,EAAcrD,kBAIlBsD,cAAAC,qBAEM,MAFNC,EAAAA,WAEM,SAFG,cAAJpD,IAAIiD,GAAsBI,EAAAA,MAAKd,GAAA,CAAGe,kBAAqBX,EAAWxC,cACrEoD,aAAQC,EAAAC,OAAA"}
@@ -0,0 +1,2 @@
1
+ export { Viewport } from './components';
2
+ export * from './hooks';
@@ -0,0 +1,89 @@
1
+ import { ref, onMounted, onUnmounted, defineComponent, useAttrs, watch, createElementBlock, openBlock, mergeProps, unref, renderSlot } from "vue";
2
+ import { useCapability, usePlugin } from "@embedpdf/core/vue";
3
+ import { ViewportPlugin } from "@embedpdf/plugin-viewport";
4
+ const useViewportPlugin = () => usePlugin(ViewportPlugin.id);
5
+ const useViewportCapability = () => useCapability(ViewportPlugin.id);
6
+ function useViewportRef() {
7
+ const { plugin: pluginRef } = useViewportPlugin();
8
+ const containerRef = ref(null);
9
+ onMounted(() => {
10
+ const viewportPlugin = pluginRef.value;
11
+ const container = containerRef.value;
12
+ if (!container || !viewportPlugin) return;
13
+ const provideRect = () => {
14
+ const r = container.getBoundingClientRect();
15
+ return {
16
+ origin: { x: r.left, y: r.top },
17
+ size: { width: r.width, height: r.height }
18
+ };
19
+ };
20
+ viewportPlugin.registerBoundingRectProvider(provideRect);
21
+ const onScroll = () => {
22
+ viewportPlugin.setViewportScrollMetrics({
23
+ scrollTop: container.scrollTop,
24
+ scrollLeft: container.scrollLeft
25
+ });
26
+ };
27
+ container.addEventListener("scroll", onScroll);
28
+ const resizeObserver = new ResizeObserver(() => {
29
+ viewportPlugin.setViewportResizeMetrics({
30
+ width: container.offsetWidth,
31
+ height: container.offsetHeight,
32
+ clientWidth: container.clientWidth,
33
+ clientHeight: container.clientHeight,
34
+ scrollTop: container.scrollTop,
35
+ scrollLeft: container.scrollLeft,
36
+ scrollWidth: container.scrollWidth,
37
+ scrollHeight: container.scrollHeight
38
+ });
39
+ });
40
+ resizeObserver.observe(container);
41
+ const unsubscribeScrollRequest = viewportPlugin.onScrollRequest(
42
+ ({ x, y, behavior = "auto" }) => {
43
+ requestAnimationFrame(() => {
44
+ container.scrollTo({ left: x, top: y, behavior });
45
+ });
46
+ }
47
+ );
48
+ onUnmounted(() => {
49
+ viewportPlugin.registerBoundingRectProvider(null);
50
+ container.removeEventListener("scroll", onScroll);
51
+ resizeObserver.disconnect();
52
+ unsubscribeScrollRequest();
53
+ });
54
+ });
55
+ return containerRef;
56
+ }
57
+ const _sfc_main = /* @__PURE__ */ defineComponent({
58
+ __name: "viewport",
59
+ setup(__props) {
60
+ const attrs = useAttrs();
61
+ const { provides: viewportProvides } = useViewportCapability();
62
+ const viewportGap = ref(0);
63
+ watch(
64
+ viewportProvides,
65
+ (vp) => {
66
+ if (vp) viewportGap.value = vp.getViewportGap();
67
+ },
68
+ { immediate: true }
69
+ );
70
+ const viewportRef = useViewportRef();
71
+ return (_ctx, _cache) => {
72
+ return openBlock(), createElementBlock("div", mergeProps({
73
+ ref_key: "viewportRef",
74
+ ref: viewportRef
75
+ }, unref(attrs), {
76
+ style: { padding: `${viewportGap.value}px` }
77
+ }), [
78
+ renderSlot(_ctx.$slots, "default")
79
+ ], 16);
80
+ };
81
+ }
82
+ });
83
+ export {
84
+ _sfc_main as Viewport,
85
+ useViewportCapability,
86
+ useViewportPlugin,
87
+ useViewportRef
88
+ };
89
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/vue/hooks/use-viewport.ts","../../src/vue/hooks/use-viewport-ref.ts","../../src/vue/components/viewport.vue"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { ViewportPlugin } from '@embedpdf/plugin-viewport';\n\nexport const useViewportPlugin = () => usePlugin<ViewportPlugin>(ViewportPlugin.id);\nexport const useViewportCapability = () => useCapability<ViewportPlugin>(ViewportPlugin.id);\n","import { Rect } from '@embedpdf/models';\nimport { onMounted, onUnmounted, ref } from 'vue';\n\nimport { useViewportPlugin } from './use-viewport';\n\nexport function useViewportRef() {\n const { plugin: pluginRef } = useViewportPlugin();\n const containerRef = ref<HTMLDivElement | null>(null);\n\n onMounted(() => {\n const viewportPlugin = pluginRef.value;\n const container = containerRef.value;\n if (!container || !viewportPlugin) return;\n\n /* ---------- live rect provider --------------------------------- */\n const provideRect = (): Rect => {\n const r = container.getBoundingClientRect();\n return {\n origin: { x: r.left, y: r.top },\n size: { width: r.width, height: r.height },\n };\n };\n viewportPlugin.registerBoundingRectProvider(provideRect);\n\n // Example: On scroll, call setMetrics\n const onScroll = () => {\n viewportPlugin.setViewportScrollMetrics({\n scrollTop: container.scrollTop,\n scrollLeft: container.scrollLeft,\n });\n };\n container.addEventListener('scroll', onScroll);\n\n // Example: On resize, call setMetrics\n const resizeObserver = new ResizeObserver(() => {\n viewportPlugin.setViewportResizeMetrics({\n width: container.offsetWidth,\n height: container.offsetHeight,\n clientWidth: container.clientWidth,\n clientHeight: container.clientHeight,\n scrollTop: container.scrollTop,\n scrollLeft: container.scrollLeft,\n scrollWidth: container.scrollWidth,\n scrollHeight: container.scrollHeight,\n });\n });\n resizeObserver.observe(container);\n\n const unsubscribeScrollRequest = viewportPlugin.onScrollRequest(\n ({ x, y, behavior = 'auto' }) => {\n requestAnimationFrame(() => {\n container.scrollTo({ left: x, top: y, behavior });\n });\n },\n );\n\n onUnmounted(() => {\n viewportPlugin.registerBoundingRectProvider(null);\n container.removeEventListener('scroll', onScroll);\n resizeObserver.disconnect();\n unsubscribeScrollRequest();\n });\n });\n\n // Return the ref so your Vue code can attach it to a div\n return containerRef;\n}\n","<script setup lang=\"ts\">\nimport { ref, watch, useAttrs } from 'vue';\n\nimport { useViewportCapability, useViewportRef } from '../hooks';\n\n/* -------------------------------------------------- */\n/* props & attrs */\n/* -------------------------------------------------- */\nconst attrs = useAttrs(); // forward class/id/… to <div>\n\n/* -------------------------------------------------- */\n/* plugin + reactive viewport gap */\n/* -------------------------------------------------- */\nconst { provides: viewportProvides } = useViewportCapability();\nconst viewportGap = ref(0);\n\nwatch(\n viewportProvides,\n (vp) => {\n if (vp) viewportGap.value = vp.getViewportGap();\n },\n { immediate: true },\n);\n\n/* -------------------------------------------------- */\n/* element ref that wires up scroll / resize logic */\n/* -------------------------------------------------- */\nconst viewportRef = useViewportRef();\n</script>\n\n<template>\n <div ref=\"viewportRef\" v-bind=\"attrs\" :style=\"{ padding: `${viewportGap}px` }\">\n <slot />\n </div>\n</template>\n"],"names":["_openBlock","_createElementBlock","_mergeProps","_unref","_renderSlot"],"mappings":";;;AAGO,MAAM,oBAAoB,MAAM,UAA0B,eAAe,EAAE;AAC3E,MAAM,wBAAwB,MAAM,cAA8B,eAAe,EAAE;ACCnF,SAAS,iBAAiB;AAC/B,QAAM,EAAE,QAAQ,UAAU,IAAI,kBAAkB;AAC1C,QAAA,eAAe,IAA2B,IAAI;AAEpD,YAAU,MAAM;AACd,UAAM,iBAAiB,UAAU;AACjC,UAAM,YAAY,aAAa;AAC3B,QAAA,CAAC,aAAa,CAAC,eAAgB;AAGnC,UAAM,cAAc,MAAY;AACxB,YAAA,IAAI,UAAU,sBAAsB;AACnC,aAAA;AAAA,QACL,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,EAAE,IAAI;AAAA,QAC9B,MAAM,EAAE,OAAO,EAAE,OAAO,QAAQ,EAAE,OAAO;AAAA,MAC3C;AAAA,IACF;AACA,mBAAe,6BAA6B,WAAW;AAGvD,UAAM,WAAW,MAAM;AACrB,qBAAe,yBAAyB;AAAA,QACtC,WAAW,UAAU;AAAA,QACrB,YAAY,UAAU;AAAA,MAAA,CACvB;AAAA,IACH;AACU,cAAA,iBAAiB,UAAU,QAAQ;AAGvC,UAAA,iBAAiB,IAAI,eAAe,MAAM;AAC9C,qBAAe,yBAAyB;AAAA,QACtC,OAAO,UAAU;AAAA,QACjB,QAAQ,UAAU;AAAA,QAClB,aAAa,UAAU;AAAA,QACvB,cAAc,UAAU;AAAA,QACxB,WAAW,UAAU;AAAA,QACrB,YAAY,UAAU;AAAA,QACtB,aAAa,UAAU;AAAA,QACvB,cAAc,UAAU;AAAA,MAAA,CACzB;AAAA,IAAA,CACF;AACD,mBAAe,QAAQ,SAAS;AAEhC,UAAM,2BAA2B,eAAe;AAAA,MAC9C,CAAC,EAAE,GAAG,GAAG,WAAW,aAAa;AAC/B,8BAAsB,MAAM;AAC1B,oBAAU,SAAS,EAAE,MAAM,GAAG,KAAK,GAAG,UAAU;AAAA,QAAA,CACjD;AAAA,MAAA;AAAA,IAEL;AAEA,gBAAY,MAAM;AAChB,qBAAe,6BAA6B,IAAI;AACtC,gBAAA,oBAAoB,UAAU,QAAQ;AAChD,qBAAe,WAAW;AACD,+BAAA;AAAA,IAAA,CAC1B;AAAA,EAAA,CACF;AAGM,SAAA;AACT;;;;AC1DA,UAAM,QAAQ,SAAS;AAKvB,UAAM,EAAE,UAAU,iBAAiB,IAAI,sBAAsB;AACvD,UAAA,cAAc,IAAI,CAAC;AAEzB;AAAA,MACE;AAAA,MACA,CAAC,OAAO;AACN,YAAI,GAAI,aAAY,QAAQ,GAAG,eAAe;AAAA,MAChD;AAAA,MACA,EAAE,WAAW,KAAK;AAAA,IACpB;AAKA,UAAM,cAAc,eAAe;;AAIjC,aAAAA,UAAA,GAAAC,mBAEM,OAFNC,WAEM;AAAA,iBAFG;AAAA,QAAJ,KAAI;AAAA,MAAA,GAAsBC,MAAK,KAAA,GAAA;AAAA,QAAG,qBAAqB,YAAW,KAAA,KAAA;AAAA,MAAA;QACrEC,WAAQ,KAAA,QAAA,SAAA;AAAA;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-viewport",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -20,21 +20,28 @@
20
20
  "types": "./dist/react/index.d.ts",
21
21
  "import": "./dist/react/index.js",
22
22
  "require": "./dist/react/index.cjs"
23
+ },
24
+ "./vue": {
25
+ "types": "./dist/vue/index.d.ts",
26
+ "import": "./dist/vue/index.js",
27
+ "require": "./dist/vue/index.cjs"
23
28
  }
24
29
  },
25
- "dependencies": {},
30
+ "dependencies": {
31
+ "@embedpdf/models": "1.0.13"
32
+ },
26
33
  "devDependencies": {
27
34
  "@types/react": "^18.2.0",
28
- "tsup": "^8.0.0",
29
35
  "typescript": "^5.0.0",
30
- "@embedpdf/core": "1.0.11",
31
- "@embedpdf/models": "1.0.11"
36
+ "@embedpdf/core": "1.0.13",
37
+ "@embedpdf/build": "1.0.0"
32
38
  },
33
39
  "peerDependencies": {
34
40
  "react": ">=16.8.0",
35
41
  "react-dom": ">=16.8.0",
36
42
  "preact": "^10.26.4",
37
- "@embedpdf/core": "1.0.11"
43
+ "vue": ">=3.2.0",
44
+ "@embedpdf/core": "1.0.13"
38
45
  },
39
46
  "files": [
40
47
  "dist",
@@ -53,11 +60,13 @@
53
60
  "access": "public"
54
61
  },
55
62
  "scripts": {
56
- "build": "PROJECT_CWD=$(pwd) pnpm -w p:build",
57
- "build:watch": "PROJECT_CWD=$(pwd) pnpm -w p:build:watch",
58
- "clean": "PROJECT_CWD=$(pwd) pnpm -w p:clean",
59
- "lint": "PROJECT_CWD=$(pwd) pnpm -w p:lint",
60
- "lint:fix": "PROJECT_CWD=$(pwd) pnpm -w p:lint:fix",
61
- "typecheck": "PROJECT_CWD=$(pwd) pnpm -w p:typecheck"
63
+ "build:base": "vite build --mode base",
64
+ "build:react": "vite build --mode react",
65
+ "build:preact": "vite build --mode preact",
66
+ "build:vue": "vite build --mode vue",
67
+ "build": "pnpm run clean && concurrently -c auto -n base,react,preact,vue \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\" \"vite build --mode vue\"",
68
+ "clean": "rimraf dist",
69
+ "lint": "eslint src --color",
70
+ "lint:fix": "eslint src --color --fix"
62
71
  }
63
72
  }
package/dist/index.d.cts DELETED
@@ -1,107 +0,0 @@
1
- import * as _embedpdf_core from '@embedpdf/core';
2
- import { BasePluginConfig, EventHook, Action, BasePlugin, PluginRegistry, Listener, PluginManifest, PluginPackage } from '@embedpdf/core';
3
- import { Rect } from '@embedpdf/models';
4
-
5
- interface ViewportState {
6
- viewportGap: number;
7
- viewportMetrics: ViewportMetrics;
8
- isScrolling: boolean;
9
- }
10
- interface ViewportPluginConfig extends BasePluginConfig {
11
- viewportGap?: number;
12
- scrollEndDelay?: number;
13
- }
14
- interface ViewportInputMetrics {
15
- width: number;
16
- height: number;
17
- scrollTop: number;
18
- scrollLeft: number;
19
- clientWidth: number;
20
- clientHeight: number;
21
- scrollWidth: number;
22
- scrollHeight: number;
23
- }
24
- interface ViewportMetrics extends ViewportInputMetrics {
25
- relativePosition: {
26
- x: number;
27
- y: number;
28
- };
29
- }
30
- interface ViewportScrollMetrics {
31
- scrollTop: number;
32
- scrollLeft: number;
33
- }
34
- interface ScrollControlOptions {
35
- mode: 'debounce' | 'throttle';
36
- wait: number;
37
- }
38
- interface ScrollToPayload {
39
- x: number;
40
- y: number;
41
- behavior?: ScrollBehavior;
42
- center?: boolean;
43
- }
44
- interface ViewportCapability {
45
- getViewportGap: () => number;
46
- getMetrics: () => ViewportMetrics;
47
- scrollTo(position: ScrollToPayload): void;
48
- onViewportChange: EventHook<ViewportMetrics>;
49
- onViewportResize: EventHook<ViewportMetrics>;
50
- onScrollChange: EventHook<ViewportScrollMetrics>;
51
- onScrollActivity: EventHook<boolean>;
52
- isScrolling: () => boolean;
53
- getBoundingRect(): Rect;
54
- }
55
-
56
- declare const SET_VIEWPORT_METRICS = "SET_VIEWPORT_METRICS";
57
- declare const SET_VIEWPORT_SCROLL_METRICS = "SET_VIEWPORT_SCROLL_METRICS";
58
- declare const SET_VIEWPORT_GAP = "SET_VIEWPORT_GAP";
59
- declare const SET_SCROLL_ACTIVITY = "SET_SCROLL_ACTIVITY";
60
- interface SetViewportMetricsAction extends Action {
61
- type: typeof SET_VIEWPORT_METRICS;
62
- payload: ViewportInputMetrics;
63
- }
64
- interface SetViewportScrollMetricsAction extends Action {
65
- type: typeof SET_VIEWPORT_SCROLL_METRICS;
66
- payload: ViewportScrollMetrics;
67
- }
68
- interface SetViewportGapAction extends Action {
69
- type: typeof SET_VIEWPORT_GAP;
70
- payload: number;
71
- }
72
- interface SetScrollActivityAction extends Action {
73
- type: typeof SET_SCROLL_ACTIVITY;
74
- payload: boolean;
75
- }
76
- type ViewportAction = SetViewportMetricsAction | SetViewportScrollMetricsAction | SetViewportGapAction | SetScrollActivityAction;
77
-
78
- declare class ViewportPlugin extends BasePlugin<ViewportPluginConfig, ViewportCapability, ViewportState, ViewportAction> {
79
- readonly id: string;
80
- static readonly id: "viewport";
81
- private readonly viewportResize$;
82
- private readonly viewportMetrics$;
83
- private readonly scrollMetrics$;
84
- private readonly scrollReq$;
85
- private readonly scrollActivity$;
86
- private rectProvider;
87
- private scrollEndTimer?;
88
- private readonly scrollEndDelay;
89
- constructor(id: string, registry: PluginRegistry, config: ViewportPluginConfig);
90
- protected buildCapability(): ViewportCapability;
91
- setViewportResizeMetrics(viewportMetrics: ViewportInputMetrics): void;
92
- setViewportScrollMetrics(scrollMetrics: ViewportScrollMetrics): void;
93
- onScrollRequest(listener: Listener<ScrollToPayload>): _embedpdf_core.Unsubscribe;
94
- registerBoundingRectProvider(provider: (() => Rect) | null): void;
95
- private bumpScrollActivity;
96
- private scrollTo;
97
- onStoreUpdated(prevState: ViewportState, newState: ViewportState): void;
98
- initialize(_config: ViewportPluginConfig): Promise<void>;
99
- destroy(): Promise<void>;
100
- }
101
-
102
- declare const VIEWPORT_PLUGIN_ID = "viewport";
103
- declare const manifest: PluginManifest<ViewportPluginConfig>;
104
-
105
- declare const ViewportPluginPackage: PluginPackage<ViewportPlugin, ViewportPluginConfig, ViewportState, ViewportAction>;
106
-
107
- export { type ScrollControlOptions, type ScrollToPayload, VIEWPORT_PLUGIN_ID, type ViewportCapability, type ViewportInputMetrics, type ViewportMetrics, ViewportPlugin, type ViewportPluginConfig, ViewportPluginPackage, type ViewportScrollMetrics, type ViewportState, manifest };
@@ -1,23 +0,0 @@
1
- import * as _embedpdf_plugin_viewport from '@embedpdf/plugin-viewport';
2
- import { ViewportPlugin } from '@embedpdf/plugin-viewport';
3
- import { JSX, ComponentChildren } from 'preact';
4
-
5
- declare const useViewportPlugin: () => {
6
- plugin: ViewportPlugin | null;
7
- isLoading: boolean;
8
- ready: Promise<void>;
9
- };
10
- declare const useViewportCapability: () => {
11
- provides: Readonly<_embedpdf_plugin_viewport.ViewportCapability> | null;
12
- isLoading: boolean;
13
- ready: Promise<void>;
14
- };
15
-
16
- /** @jsxImportSource preact */
17
-
18
- type ViewportProps = JSX.HTMLAttributes<HTMLDivElement> & {
19
- children: ComponentChildren;
20
- };
21
- declare function Viewport({ children, ...props }: ViewportProps): JSX.Element;
22
-
23
- export { Viewport, useViewportCapability, useViewportPlugin };
@@ -1,25 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as React from 'react';
3
- import React__default, { ReactNode } from 'react';
4
- import * as _embedpdf_plugin_viewport from '@embedpdf/plugin-viewport';
5
- import { ViewportPlugin } from '@embedpdf/plugin-viewport';
6
-
7
- type ViewportProps = React__default.HTMLAttributes<HTMLDivElement> & {
8
- children: ReactNode;
9
- };
10
- declare function Viewport({ children, ...props }: ViewportProps): react_jsx_runtime.JSX.Element;
11
-
12
- declare const useViewportPlugin: () => {
13
- plugin: ViewportPlugin | null;
14
- isLoading: boolean;
15
- ready: Promise<void>;
16
- };
17
- declare const useViewportCapability: () => {
18
- provides: Readonly<_embedpdf_plugin_viewport.ViewportCapability> | null;
19
- isLoading: boolean;
20
- ready: Promise<void>;
21
- };
22
-
23
- declare function useViewportRef(): React.RefObject<HTMLDivElement>;
24
-
25
- export { Viewport, useViewportCapability, useViewportPlugin, useViewportRef };