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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +499 -111
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/actions.d.ts +77 -9
  6. package/dist/lib/types.d.ts +55 -12
  7. package/dist/lib/viewport-plugin.d.ts +24 -9
  8. package/dist/preact/index.cjs +1 -1
  9. package/dist/preact/index.cjs.map +1 -1
  10. package/dist/preact/index.js +40 -15
  11. package/dist/preact/index.js.map +1 -1
  12. package/dist/react/index.cjs +1 -1
  13. package/dist/react/index.cjs.map +1 -1
  14. package/dist/react/index.js +40 -15
  15. package/dist/react/index.js.map +1 -1
  16. package/dist/shared/components/viewport.d.ts +5 -1
  17. package/dist/shared/hooks/use-viewport-ref.d.ts +1 -1
  18. package/dist/shared/hooks/use-viewport.d.ts +11 -1
  19. package/dist/shared-preact/components/viewport.d.ts +5 -1
  20. package/dist/shared-preact/hooks/use-viewport-ref.d.ts +1 -1
  21. package/dist/shared-preact/hooks/use-viewport.d.ts +11 -1
  22. package/dist/shared-react/components/viewport.d.ts +5 -1
  23. package/dist/shared-react/hooks/use-viewport-ref.d.ts +1 -1
  24. package/dist/shared-react/hooks/use-viewport.d.ts +11 -1
  25. package/dist/svelte/components/Viewport.svelte.d.ts +4 -0
  26. package/dist/svelte/hooks/use-viewport-ref.svelte.d.ts +5 -1
  27. package/dist/svelte/hooks/use-viewport.svelte.d.ts +15 -4
  28. package/dist/svelte/index.cjs +1 -1
  29. package/dist/svelte/index.cjs.map +1 -1
  30. package/dist/svelte/index.js +86 -21
  31. package/dist/svelte/index.js.map +1 -1
  32. package/dist/vue/components/viewport.vue.d.ts +9 -2
  33. package/dist/vue/hooks/use-viewport-ref.d.ts +6 -1
  34. package/dist/vue/hooks/use-viewport.d.ts +12 -1
  35. package/dist/vue/index.cjs +1 -1
  36. package/dist/vue/index.cjs.map +1 -1
  37. package/dist/vue/index.js +66 -38
  38. package/dist/vue/index.js.map +1 -1
  39. package/package.json +5 -5
@@ -5,25 +5,68 @@ import { ViewportPlugin } from "@embedpdf/plugin-viewport";
5
5
  export * from "@embedpdf/plugin-viewport";
6
6
  const useViewportPlugin = () => usePlugin(ViewportPlugin.id);
7
7
  const useViewportCapability = () => useCapability(ViewportPlugin.id);
8
- const useViewportScrollActivity = () => {
8
+ const useIsViewportGated = (getDocumentId) => {
9
9
  const capability = useViewportCapability();
10
- const state = $.proxy({ isScrolling: false, isSmoothScrolling: false });
10
+ let isGated = $.state(false);
11
+ const documentId = $.derived(getDocumentId);
11
12
  $.user_effect(() => {
12
- if (!capability.provides) return;
13
- return capability.provides.onScrollActivity((activity) => {
14
- state.isScrolling = activity.isScrolling;
15
- state.isSmoothScrolling = activity.isSmoothScrolling;
13
+ const provides = capability.provides;
14
+ const docId = $.get(documentId);
15
+ if (!provides || !docId) {
16
+ $.set(isGated, false);
17
+ return;
18
+ }
19
+ $.set(isGated, provides.isGated(docId), true);
20
+ return provides.onGateChange((event) => {
21
+ if (event.documentId === docId) {
22
+ $.set(isGated, event.isGated, true);
23
+ }
16
24
  });
17
25
  });
18
- return state;
26
+ return {
27
+ get current() {
28
+ return $.get(isGated);
29
+ }
30
+ };
19
31
  };
20
- function useViewportRef() {
32
+ const useViewportScrollActivity = (getDocumentId) => {
33
+ const capability = useViewportCapability();
34
+ let scrollActivity = $.state($.proxy({ isScrolling: false, isSmoothScrolling: false }));
35
+ const documentId = $.derived(getDocumentId);
36
+ $.user_effect(() => {
37
+ const provides = capability.provides;
38
+ const docId = $.get(documentId);
39
+ if (!provides || !docId) {
40
+ $.set(scrollActivity, { isScrolling: false, isSmoothScrolling: false }, true);
41
+ return;
42
+ }
43
+ return provides.onScrollActivity((event) => {
44
+ if (event.documentId === docId) {
45
+ $.set(scrollActivity, event.activity, true);
46
+ }
47
+ });
48
+ });
49
+ return {
50
+ get current() {
51
+ return $.get(scrollActivity);
52
+ }
53
+ };
54
+ };
55
+ function useViewportRef(getDocumentId) {
21
56
  const { plugin } = useViewportPlugin();
22
57
  let containerRef = $.state(null);
58
+ const documentId = $.derived(getDocumentId);
23
59
  $.user_pre_effect(() => {
24
60
  if (!plugin) return;
25
61
  const container = $.get(containerRef);
26
- if (!container) return;
62
+ const docId = $.get(documentId);
63
+ if (!container || !docId) return;
64
+ try {
65
+ plugin.registerViewport(docId);
66
+ } catch (error) {
67
+ console.error(`Failed to register viewport for document ${docId}:`, error);
68
+ return;
69
+ }
27
70
  const provideRect = () => {
28
71
  const r = container.getBoundingClientRect();
29
72
  return {
@@ -31,16 +74,16 @@ function useViewportRef() {
31
74
  size: { width: r.width, height: r.height }
32
75
  };
33
76
  };
34
- plugin.registerBoundingRectProvider(provideRect);
77
+ plugin.registerBoundingRectProvider(docId, provideRect);
35
78
  const onScroll = () => {
36
- plugin == null ? void 0 : plugin.setViewportScrollMetrics({
79
+ plugin.setViewportScrollMetrics(docId, {
37
80
  scrollTop: container.scrollTop,
38
81
  scrollLeft: container.scrollLeft
39
82
  });
40
83
  };
41
84
  container.addEventListener("scroll", onScroll);
42
85
  const resizeObserver = new ResizeObserver(() => {
43
- plugin == null ? void 0 : plugin.setViewportResizeMetrics({
86
+ plugin.setViewportResizeMetrics(docId, {
44
87
  width: container.offsetWidth,
45
88
  height: container.offsetHeight,
46
89
  clientWidth: container.clientWidth,
@@ -52,13 +95,14 @@ function useViewportRef() {
52
95
  });
53
96
  });
54
97
  resizeObserver.observe(container);
55
- const unsubscribeScrollRequest = plugin.onScrollRequest(({ x, y, behavior = "auto" }) => {
98
+ const unsubscribeScrollRequest = plugin.onScrollRequest(docId, ({ x, y, behavior = "auto" }) => {
56
99
  requestAnimationFrame(() => {
57
100
  container.scrollTo({ left: x, top: y, behavior });
58
101
  });
59
102
  });
60
103
  return () => {
61
- plugin == null ? void 0 : plugin.registerBoundingRectProvider(null);
104
+ plugin.unregisterViewport(docId);
105
+ plugin.registerBoundingRectProvider(docId, null);
62
106
  container.removeEventListener("scroll", onScroll);
63
107
  resizeObserver.disconnect();
64
108
  unsubscribeScrollRequest();
@@ -76,26 +120,46 @@ function useViewportRef() {
76
120
  var root = $.from_html(`<div><!></div>`);
77
121
  function Viewport($$anchor, $$props) {
78
122
  $.push($$props, true);
79
- let restProps = $.rest_props($$props, ["$$slots", "$$events", "$$legacy", "children", "class"]);
123
+ let restProps = $.rest_props($$props, [
124
+ "$$slots",
125
+ "$$events",
126
+ "$$legacy",
127
+ "documentId",
128
+ "children",
129
+ "class"
130
+ ]);
80
131
  let viewportGap = $.state(0);
81
- let viewportRef = useViewportRef();
132
+ const viewportRef = useViewportRef(() => $$props.documentId);
82
133
  const viewportCapability = useViewportCapability();
134
+ const isGated = useIsViewportGated(() => $$props.documentId);
83
135
  $.user_effect(() => {
84
136
  if (viewportCapability.provides) {
85
137
  $.set(viewportGap, viewportCapability.provides.getViewportGap(), true);
86
138
  }
87
139
  });
88
140
  var div = root();
89
- $.attribute_effect(div, ($0) => ({ ...restProps, class: $$props.class, [$.STYLE]: $0 }), [
90
- () => ({
141
+ $.attribute_effect(div, () => ({
142
+ ...restProps,
143
+ class: $$props.class,
144
+ [$.STYLE]: {
91
145
  width: "100%",
92
146
  height: "100%",
93
147
  overflow: "auto",
94
148
  padding: `${$.get(viewportGap)}px`
95
- })
96
- ]);
149
+ }
150
+ }));
97
151
  var node = $.child(div);
98
- $.snippet(node, () => $$props.children);
152
+ {
153
+ var consequent = ($$anchor2) => {
154
+ var fragment = $.comment();
155
+ var node_1 = $.first_child(fragment);
156
+ $.snippet(node_1, () => $$props.children);
157
+ $.append($$anchor2, fragment);
158
+ };
159
+ $.if(node, ($$render) => {
160
+ if (!isGated.current) $$render(consequent);
161
+ });
162
+ }
99
163
  $.reset(div);
100
164
  $.bind_this(div, ($$value) => viewportRef.containerRef = $$value, () => viewportRef == null ? void 0 : viewportRef.containerRef);
101
165
  $.append($$anchor, div);
@@ -103,6 +167,7 @@ function Viewport($$anchor, $$props) {
103
167
  }
104
168
  export {
105
169
  Viewport,
170
+ useIsViewportGated,
106
171
  useViewportCapability,
107
172
  useViewportPlugin,
108
173
  useViewportRef,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-viewport.svelte.ts","../../src/svelte/hooks/use-viewport-ref.svelte.ts","../../src/svelte/components/Viewport.svelte"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { ScrollActivity, ViewportPlugin } from '@embedpdf/plugin-viewport';\n\nexport const useViewportPlugin = () => usePlugin<ViewportPlugin>(ViewportPlugin.id);\nexport const useViewportCapability = () => useCapability<ViewportPlugin>(ViewportPlugin.id);\n\nexport const useViewportScrollActivity = () => {\n const capability = useViewportCapability();\n\n const state = $state({\n isScrolling: false,\n isSmoothScrolling: false,\n });\n\n $effect(() => {\n if (!capability.provides) return;\n\n return capability.provides.onScrollActivity((activity: ScrollActivity) => {\n state.isScrolling = activity.isScrolling;\n state.isSmoothScrolling = activity.isSmoothScrolling;\n });\n });\n\n return state;\n};\n","import { type Rect } from '@embedpdf/models';\nimport { useViewportPlugin } from './use-viewport.svelte';\n\nexport function useViewportRef() {\n const { plugin } = useViewportPlugin();\n let containerRef = $state<HTMLDivElement | null>(null);\n\n $effect.pre(() => {\n if (!plugin) return;\n\n const container = containerRef;\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 plugin.registerBoundingRectProvider(provideRect);\n\n // Example: On scroll, call setMetrics\n const onScroll = () => {\n plugin?.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 plugin?.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 = plugin.onScrollRequest(({ x, y, behavior = 'auto' }) => {\n requestAnimationFrame(() => {\n container.scrollTo({ left: x, top: y, behavior });\n });\n });\n\n // Cleanup\n return () => {\n plugin?.registerBoundingRectProvider(null);\n container.removeEventListener('scroll', onScroll);\n resizeObserver.disconnect();\n unsubscribeScrollRequest();\n };\n });\n\n // Return the ref so your Svelte code can attach it to a div\n return {\n get containerRef() {\n return containerRef;\n },\n set containerRef(el: HTMLDivElement | null) {\n containerRef = el;\n },\n };\n}\n","<script lang=\"ts\">\n import { useViewportCapability, useViewportRef } from '../hooks';\n import type { HTMLAttributes } from 'svelte/elements';\n import type { Snippet } from 'svelte';\n\n type ViewportProps = HTMLAttributes<HTMLDivElement> & {\n children: Snippet;\n class?: string;\n };\n\n let { children, class: propsClass, ...restProps }: ViewportProps = $props();\n\n let viewportGap = $state(0);\n\n let viewportRef = useViewportRef();\n\n const viewportCapability = useViewportCapability();\n\n $effect(() => {\n if (viewportCapability.provides) {\n viewportGap = viewportCapability.provides.getViewportGap();\n }\n });\n</script>\n\n<div\n {...restProps}\n bind:this={viewportRef.containerRef}\n style:width=\"100%\"\n style:height=\"100%\"\n style:overflow=\"auto\"\n style:padding={`${viewportGap}px`}\n class={propsClass}\n>\n {@render children()}\n</div>\n"],"names":[],"mappings":";;;;;AAGa,MAAA,oBAA0B,MAAA,UAA0B,eAAe,EAAE;AACrE,MAAA,wBAA8B,MAAA,cAA8B,eAAe,EAAE;AAE7E,MAAA,kCAAkC;AACvC,QAAA,aAAa,sBAAsB;AAEnC,QAAA,kBACJ,aAAa,OACb,mBAAmB,OAAA;AAGrB,IAAA,kBAAc;AACP,QAAA,CAAA,W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A,QACI,aAAa,IAA2B;AAC3B,QAAA,IAAA,cAAA,IAAA,IAAA;AAAA;;AAGrB;;qCCvEA;;MAUwC,YAAS,EAAA,WAAA,SAAA,CAAA,WAAA,YAAA,YAAA,YAAA,OAAA,CAAA;AAE3C,MAAA,sBAAqB,CAAC;AAEtB,MAAA,cAAc,eAAc;AAE1B,QAAA,qBAAqB,sBAAqB;AAEhD,IAAA,YAAc,MAAA;QACR,mBAAmB,UAAU;AAC/B,QAAA,IAAA,aAAc,mBAAmB,SAAS,eAAc,GAAA,IAAA;AAAA,IAC1D;AAAA,GACD;;wCAIG,WAAS,OAAA,QAAA,OAAA,CAAA,EAAA,KAAA,GAAA,GAAA,IAAA;AAAA;;;;wBAKK,WAAW,CAAA;AAAA;;;;;AAJlB,IAAA,UAAA,KAAA,CAAA,YAAA,YAAY,eAAZ,SAAA,MAAA,2CAAY,YAAY;;;AAJrC;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-viewport.svelte.ts","../../src/svelte/hooks/use-viewport-ref.svelte.ts","../../src/svelte/components/Viewport.svelte"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { GateChangeEvent, ScrollActivity, ViewportPlugin } from '@embedpdf/plugin-viewport';\n\nexport const useViewportPlugin = () => usePlugin<ViewportPlugin>(ViewportPlugin.id);\nexport const useViewportCapability = () => useCapability<ViewportPlugin>(ViewportPlugin.id);\n\n/**\n * Hook to get the gated state of the viewport for a specific document.\n * The viewport children are not rendered when gated.\n * @param getDocumentId Function that returns the document ID\n */\nexport const useIsViewportGated = (getDocumentId: () => string | null) => {\n const capability = useViewportCapability();\n\n let isGated = $state(false);\n\n // Reactive documentId\n const documentId = $derived(getDocumentId());\n\n $effect(() => {\n const provides = capability.provides;\n const docId = documentId;\n\n if (!provides || !docId) {\n isGated = false;\n return;\n }\n\n // Set initial state\n isGated = provides.isGated(docId);\n\n // Subscribe to gate state changes\n return provides.onGateChange((event: GateChangeEvent) => {\n if (event.documentId === docId) {\n isGated = event.isGated;\n }\n });\n });\n\n return {\n get current() {\n return isGated;\n },\n };\n};\n\n/**\n * Hook to get scroll activity for a specific document\n * @param getDocumentId Function that returns the document ID\n */\nexport const useViewportScrollActivity = (getDocumentId: () => string | null) => {\n const capability = useViewportCapability();\n\n let scrollActivity = $state<ScrollActivity>({\n isScrolling: false,\n isSmoothScrolling: false,\n });\n\n // Reactive documentId\n const documentId = $derived(getDocumentId());\n\n $effect(() => {\n const provides = capability.provides;\n const docId = documentId;\n\n if (!provides || !docId) {\n scrollActivity = {\n isScrolling: false,\n isSmoothScrolling: false,\n };\n return;\n }\n\n // Subscribe to scroll activity events\n return provides.onScrollActivity((event) => {\n // Filter by documentId\n if (event.documentId === docId) {\n scrollActivity = event.activity;\n }\n });\n });\n\n return {\n get current() {\n return scrollActivity;\n },\n };\n};\n","import { type Rect } from '@embedpdf/models';\nimport { useViewportPlugin } from './use-viewport.svelte';\n\n/**\n * Hook to get a ref for the viewport container element with automatic setup/teardown\n * @param getDocumentId Function that returns the document ID\n */\nexport function useViewportRef(getDocumentId: () => string | null) {\n const { plugin } = useViewportPlugin();\n\n let containerRef = $state<HTMLDivElement | null>(null);\n\n // Reactive documentId\n const documentId = $derived(getDocumentId());\n\n $effect.pre(() => {\n if (!plugin) return;\n\n const container = containerRef;\n const docId = documentId;\n if (!container || !docId) return;\n\n // Register this viewport for the document\n try {\n plugin.registerViewport(docId);\n } catch (error) {\n console.error(`Failed to register viewport for document ${docId}:`, error);\n return;\n }\n\n // Provide rect calculator\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 plugin.registerBoundingRectProvider(docId, provideRect);\n\n // On scroll\n const onScroll = () => {\n plugin.setViewportScrollMetrics(docId, {\n scrollTop: container.scrollTop,\n scrollLeft: container.scrollLeft,\n });\n };\n container.addEventListener('scroll', onScroll);\n\n // On resize\n const resizeObserver = new ResizeObserver(() => {\n plugin.setViewportResizeMetrics(docId, {\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 // Subscribe to scroll requests for this document\n const unsubscribeScrollRequest = plugin.onScrollRequest(\n docId,\n ({ x, y, behavior = 'auto' }) => {\n requestAnimationFrame(() => {\n container.scrollTo({ left: x, top: y, behavior });\n });\n },\n );\n\n // Store cleanup function\n return () => {\n plugin.unregisterViewport(docId);\n plugin.registerBoundingRectProvider(docId, null);\n container.removeEventListener('scroll', onScroll);\n resizeObserver.disconnect();\n unsubscribeScrollRequest();\n };\n });\n\n return {\n get containerRef() {\n return containerRef;\n },\n set containerRef(el: HTMLDivElement | null) {\n containerRef = el;\n },\n };\n}\n","<script lang=\"ts\">\n import { useIsViewportGated, useViewportCapability, useViewportRef } from '../hooks';\n import type { HTMLAttributes } from 'svelte/elements';\n import type { Snippet } from 'svelte';\n\n type ViewportProps = HTMLAttributes<HTMLDivElement> & {\n /**\n * The ID of the document that this viewport displays\n */\n documentId: string;\n children: Snippet;\n class?: string;\n };\n\n let { documentId, children, class: propsClass, ...restProps }: ViewportProps = $props();\n\n let viewportGap = $state(0);\n\n const viewportRef = useViewportRef(() => documentId);\n const viewportCapability = useViewportCapability();\n const isGated = useIsViewportGated(() => documentId);\n\n $effect(() => {\n if (viewportCapability.provides) {\n viewportGap = viewportCapability.provides.getViewportGap();\n }\n });\n</script>\n\n<div\n {...restProps}\n bind:this={viewportRef.containerRef}\n style:width=\"100%\"\n style:height=\"100%\"\n style:overflow=\"auto\"\n style:padding={`${viewportGap}px`}\n class={propsClass}\n>\n {#if !isGated.current}\n {@render children()}\n {/if}\n</div>\n"],"names":[],"mappings":";;;;;AAGa,MAAA,oBAAA,MAA0B,UAA0B,eAAe,EAAE;AACrE,MAAA,wBA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YAAS,EAAA,WAAA,SAAA;AAAA;;;;;;;AAEvD,MAAA,sBAAqB,CAAC;AAEpB,QAAA,cAAc,eAAc,MAAA,QAAA,UAAA;AAC5B,QAAA,qBAAqB,sBAAqB;AAC1C,QAAA,UAAU,mBAAkB,MAAA,QAAA,UAAA;AAElC,IAAA,YAAO,MAAO;QACR,mBAAmB,UAAU;AAC/B,QAAA,IAAA,aAAc,mBAAmB,SAAS,eAAc,GAAA,IAAA;AAAA,IAC1D;AAAA,EACF,CAAC;;;OAIG;AAAA;;;;;wBAKc,WAAW,CAAA;AAAA;;;;;;;;;;;AAGvB,UAAA,CAAA,QAAQ,QAAO,UAAA,UAAA;AAAA;;;AAPV,IAAA,UAAA,KAAA,CAAA,YAAA,YAAY,eAAY,SAAA,MAAxB,2CAAY,YAAY;;;AAJrC;"}
@@ -1,9 +1,16 @@
1
+ interface Props {
2
+ /**
3
+ * The ID of the document that this viewport displays
4
+ */
5
+ documentId: string;
6
+ }
1
7
  declare var __VLS_1: {};
2
8
  type __VLS_Slots = {} & {
3
9
  default?: (props: typeof __VLS_1) => any;
4
10
  };
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>;
11
+ declare const __VLS_base: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
12
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
13
+ declare const _default: typeof __VLS_export;
7
14
  export default _default;
8
15
  type __VLS_WithSlots<T, S> = T & {
9
16
  new (): {
@@ -1 +1,6 @@
1
- export declare function useViewportRef(): import('vue').Ref<HTMLDivElement | null, HTMLDivElement | null>;
1
+ import { MaybeRefOrGetter } from 'vue';
2
+ /**
3
+ * Hook to get a ref for the viewport container element with automatic setup/teardown
4
+ * @param documentId Document ID (can be ref, computed, getter, or plain value).
5
+ */
6
+ export declare function useViewportRef(documentId: MaybeRefOrGetter<string>): import('vue').Ref<HTMLDivElement | null, HTMLDivElement | null>;
@@ -1,7 +1,18 @@
1
+ import { MaybeRefOrGetter } from 'vue';
1
2
  import { ScrollActivity, ViewportPlugin } from '../../lib/index.ts';
2
3
  export declare const useViewportPlugin: () => import('@embedpdf/core/vue').PluginState<ViewportPlugin>;
3
4
  export declare const useViewportCapability: () => import('@embedpdf/core/vue').CapabilityState<Readonly<import('../../lib/index.ts').ViewportCapability>>;
4
- export declare const useViewportScrollActivity: () => import('vue').Ref<{
5
+ /**
6
+ * Hook to get the gated state of the viewport for a specific document.
7
+ * The viewport children are not rendered when gated.
8
+ * @param documentId Document ID (can be ref, computed, getter, or plain value).
9
+ */
10
+ export declare const useIsViewportGated: (documentId: MaybeRefOrGetter<string>) => import('vue').Ref<boolean, boolean>;
11
+ /**
12
+ * Hook to get scroll activity for a specific document
13
+ * @param documentId Document ID (can be ref, computed, getter, or plain value).
14
+ */
15
+ export declare const useViewportScrollActivity: (documentId: MaybeRefOrGetter<string>) => import('vue').Ref<{
5
16
  isSmoothScrolling: boolean;
6
17
  isScrolling: boolean;
7
18
  }, ScrollActivity | {
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),t=require("@embedpdf/core/vue"),r=require("@embedpdf/plugin-viewport"),o=()=>t.usePlugin(r.ViewportPlugin.id),i=()=>t.useCapability(r.ViewportPlugin.id);function l(){const{plugin:t}=o(),r=e.ref(null),i=()=>{const e=t.value,o=r.value;if(!o||!e)return;let i=!1;e.registerBoundingRectProvider((()=>{const e=o.getBoundingClientRect();return{origin:{x:e.left,y:e.top},size:{width:e.width,height:e.height}}}));const l=()=>{e.setViewportScrollMetrics({scrollTop:o.scrollTop,scrollLeft:o.scrollLeft})};o.addEventListener("scroll",l);const n=new ResizeObserver((()=>{i||e.setViewportResizeMetrics({width:o.offsetWidth,height:o.offsetHeight,clientWidth:o.clientWidth,clientHeight:o.clientHeight,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft,scrollWidth:o.scrollWidth,scrollHeight:o.scrollHeight})}));n.observe(o);const s=e.onScrollRequest((({x:e,y:t,behavior:r="auto"})=>{requestAnimationFrame((()=>{o.scrollTo({left:e,top:t,behavior:r})}))}));return()=>{i=!0,n.disconnect(),e.registerBoundingRectProvider(null),o.removeEventListener("scroll",l),s()}};let l=null;return e.watch(t,(()=>{l&&(l(),l=null),l=i()||null}),{immediate:!0}),e.watch(r,(()=>{l&&(l(),l=null),l=i()||null}),{immediate:!0}),e.onUnmounted((()=>{l&&l()})),r}const n=e.defineComponent({__name:"viewport",setup(t){const r=e.useAttrs(),{provides:o}=i(),n=e.ref(0);e.watch(o,(e=>{e&&(n.value=e.getViewportGap())}),{immediate:!0});const s=l();return(t,o)=>(e.openBlock(),e.createElementBlock("div",e.mergeProps({ref_key:"viewportRef",ref:s},e.unref(r),{style:{padding:`${n.value}px`,width:"100%",height:"100%",overflow:"auto"}}),[e.renderSlot(t.$slots,"default")],16))}});exports.Viewport=n,exports.useViewportCapability=i,exports.useViewportPlugin=o,exports.useViewportRef=l,exports.useViewportScrollActivity=()=>{const{provides:t}=i(),r=e.ref({isSmoothScrolling:!1,isScrolling:!1});return e.watch(t,((e,t,o)=>{if(e){o(e.onScrollActivity((e=>{r.value=e})))}}),{immediate:!0}),r},Object.keys(r).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})}));
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),t=require("@embedpdf/core/vue"),r=require("@embedpdf/plugin-viewport"),o=()=>t.usePlugin(r.ViewportPlugin.id),i=()=>t.useCapability(r.ViewportPlugin.id),l=t=>{const{provides:r}=i(),o=e.ref(!1);return e.watch([r,()=>e.toValue(t)],([e,t],r,i)=>{if(!e)return void(o.value=!1);o.value=e.isGated(t);i(e.onGateChange(e=>{e.documentId===t&&(o.value=e.isGated)}))},{immediate:!0}),o};function n(t){const{plugin:r}=o(),i=e.ref(null);let l=null;return e.watch([r,i,()=>e.toValue(t)],([,,e])=>{l&&(l(),l=null),l=(e=>{const t=r.value,o=i.value;if(!o||!t)return;try{t.registerViewport(e)}catch(s){return void console.error(`Failed to register viewport for document ${e}:`,s)}t.registerBoundingRectProvider(e,()=>{const e=o.getBoundingClientRect();return{origin:{x:e.left,y:e.top},size:{width:e.width,height:e.height}}});const l=()=>{t.setViewportScrollMetrics(e,{scrollTop:o.scrollTop,scrollLeft:o.scrollLeft})};o.addEventListener("scroll",l),new ResizeObserver(()=>{t.setViewportResizeMetrics(e,{width:o.offsetWidth,height:o.offsetHeight,clientWidth:o.clientWidth,clientHeight:o.clientHeight,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft,scrollWidth:o.scrollWidth,scrollHeight:o.scrollHeight})}).observe(o);const n=t.onScrollRequest(e,({x:e,y:t,behavior:r="auto"})=>{requestAnimationFrame(()=>{o.scrollTo({left:e,top:t,behavior:r})})});return()=>{t.unregisterViewport(e),t.registerBoundingRectProvider(e,null),o.removeEventListener("scroll",l),n()}})(e)||null},{immediate:!0}),e.onBeforeUnmount(()=>{l&&(l(),l=null)}),i}const s=e.defineComponent({__name:"viewport",props:{documentId:{}},setup(t){const r=t,o=e.useAttrs(),{provides:s}=i(),c=e.ref(0);e.watch(s,e=>{e&&(c.value=e.getViewportGap())},{immediate:!0});const u=l(()=>r.documentId),d=n(()=>r.documentId);return(t,r)=>(e.openBlock(),e.createElementBlock("div",e.mergeProps({ref_key:"viewportRef",ref:d},e.unref(o),{style:{padding:`${c.value}px`,width:"100%",height:"100%",overflow:"auto"}}),[e.unref(u)?e.createCommentVNode("",!0):e.renderSlot(t.$slots,"default",{key:0})],16))}});exports.Viewport=s,exports.useIsViewportGated=l,exports.useViewportCapability=i,exports.useViewportPlugin=o,exports.useViewportRef=n,exports.useViewportScrollActivity=t=>{const{provides:r}=i(),o=e.ref({isSmoothScrolling:!1,isScrolling:!1});return e.watch([r,()=>e.toValue(t)],([e,t],r,i)=>{if(!e)return void(o.value={isSmoothScrolling:!1,isScrolling:!1});i(e.onScrollActivity(e=>{e.documentId===t&&(o.value=e.activity)}))},{immediate:!0}),o},Object.keys(r).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})});
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +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 { ref, watch } from 'vue';\nimport { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { ScrollActivity, ViewportPlugin } from '@embedpdf/plugin-viewport';\n\nexport const useViewportPlugin = () => usePlugin<ViewportPlugin>(ViewportPlugin.id);\nexport const useViewportCapability = () => useCapability<ViewportPlugin>(ViewportPlugin.id);\n\nexport const useViewportScrollActivity = () => {\n const { provides } = useViewportCapability();\n const scrollActivity = ref<ScrollActivity>({\n isSmoothScrolling: false,\n isScrolling: false,\n });\n\n watch(\n provides,\n (providesValue, _, onCleanup) => {\n if (providesValue) {\n const unsubscribe = providesValue.onScrollActivity((activity) => {\n scrollActivity.value = activity;\n });\n onCleanup(unsubscribe);\n }\n },\n { immediate: true },\n );\n\n return scrollActivity;\n};\n","import { Rect } from '@embedpdf/models';\nimport { onMounted, onUnmounted, ref, watch } 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 // Setup function that runs when both plugin and container are available\n const setupViewport = () => {\n const viewportPlugin = pluginRef.value;\n const container = containerRef.value;\n\n if (!container || !viewportPlugin) return;\n\n let cleanedUp = false;\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 if (cleanedUp) return;\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 // Return cleanup function\n return () => {\n cleanedUp = true;\n resizeObserver.disconnect();\n viewportPlugin.registerBoundingRectProvider(null);\n container.removeEventListener('scroll', onScroll);\n unsubscribeScrollRequest();\n };\n };\n\n let cleanup: (() => void) | null = null;\n\n // Watch for changes in the plugin - this is the Vue equivalent of React's dependency array\n watch(\n pluginRef,\n () => {\n // Clean up previous setup if it exists\n if (cleanup) {\n cleanup();\n cleanup = null;\n }\n\n // Setup new viewport if plugin is available\n cleanup = setupViewport() || null;\n },\n { immediate: true }, // Run immediately if plugin is already available\n );\n\n // Also watch for container changes (though this is less likely to change)\n watch(\n containerRef,\n () => {\n // Clean up previous setup if it exists\n if (cleanup) {\n cleanup();\n cleanup = null;\n }\n\n // Setup new viewport if both plugin and container are available\n cleanup = setupViewport() || null;\n },\n { immediate: true },\n );\n\n onUnmounted(() => {\n if (cleanup) {\n cleanup();\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\n ref=\"viewportRef\"\n v-bind=\"attrs\"\n :style=\"{ padding: `${viewportGap}px`, width: '100%', height: '100%', overflow: 'auto' }\"\n >\n <slot />\n </div>\n</template>\n"],"names":["useViewportPlugin","usePlugin","ViewportPlugin","id","useViewportCapability","useCapability","useViewportRef","plugin","pluginRef","containerRef","ref","setupViewport","viewportPlugin","value","container","cleanedUp","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","disconnect","removeEventListener","cleanup","vue$1","watch","immediate","onUnmounted","attrs","useAttrs","provides","viewportProvides","viewportGap","vp","getViewportGap","viewportRef","_openBlock","_createElementBlock","_mergeProps","_unref","style","overflow","_renderSlot","_ctx","$slots","scrollActivity","isSmoothScrolling","isScrolling","providesValue","_","onCleanup","onScrollActivity","activity"],"mappings":"8KAIaA,EAAoB,IAAMC,YAA0BC,EAAAA,eAAeC,IACnEC,EAAwB,IAAMC,gBAA8BH,EAAAA,eAAeC,ICAjF,SAASG,IACd,MAAQC,OAAQC,GAAcR,IACxBS,EAAeC,MAA2B,MAG1CC,EAAgB,KACpB,MAAMC,EAAiBJ,EAAUK,MAC3BC,EAAYL,EAAaI,MAE3B,IAACC,IAAcF,EAAgB,OAEnC,IAAIG,GAAY,EAShBH,EAAeI,8BAPK,KACZ,MAAAC,EAAIH,EAAUI,wBACb,MAAA,CACLC,OAAQ,CAAEC,EAAGH,EAAEI,KAAMC,EAAGL,EAAEM,KAC1BC,KAAM,CAAEC,MAAOR,EAAEQ,MAAOC,OAAQT,EAAES,QACpC,IAKF,MAAMC,EAAW,KACff,EAAegB,yBAAyB,CACtCC,UAAWf,EAAUe,UACrBC,WAAYhB,EAAUgB,YACvB,EAEOhB,EAAAiB,iBAAiB,SAAUJ,GAG/B,MAAAK,EAAiB,IAAIC,gBAAe,KACpClB,GACJH,EAAesB,yBAAyB,CACtCT,MAAOX,EAAUqB,YACjBT,OAAQZ,EAAUsB,aAClBC,YAAavB,EAAUuB,YACvBC,aAAcxB,EAAUwB,aACxBT,UAAWf,EAAUe,UACrBC,WAAYhB,EAAUgB,WACtBS,YAAazB,EAAUyB,YACvBC,aAAc1B,EAAU0B,cACzB,IAEHR,EAAeS,QAAQ3B,GAEvB,MAAM4B,EAA2B9B,EAAe+B,iBAC9C,EAAGvB,IAAGE,IAAGsB,WAAW,WAClBC,uBAAsB,KACpB/B,EAAUgC,SAAS,CAAEzB,KAAMD,EAAGG,IAAKD,EAAGsB,YAAU,GACjD,IAKL,MAAO,KACO7B,GAAA,EACZiB,EAAee,aACfnC,EAAeI,6BAA6B,MAClCF,EAAAkC,oBAAoB,SAAUrB,GACfe,GAAA,CAC3B,EAGF,IAAIO,EAA+B,KAyC5B,OAtCPC,EAAAC,MACE3C,GACA,KAEMyC,IACMA,IACEA,EAAA,MAIZA,EAAUtC,KAAmB,IAAA,GAE/B,CAAEyC,WAAW,IAIfF,EAAAC,MACE1C,GACA,KAEMwC,IACMA,IACEA,EAAA,MAIZA,EAAUtC,KAAmB,IAAA,GAE/B,CAAEyC,WAAW,IAGfC,EAAAA,aAAY,KACNJ,GACMA,GAAA,IAKLxC,CACT,uDCxGM,MAAA6C,EAAQC,EAAAA,YAKNC,SAAUC,GAAqBrD,IACjCsD,EAAchD,MAAI,GAExBwC,EAAAC,MACEM,GACCE,IACKA,IAAID,EAAY7C,MAAQ8C,EAAGC,iBAAe,GAEhD,CAAER,WAAW,IAMf,MAAMS,EAAcvD,kBAIlBwD,cAAAC,qBAMM,MANNC,EAAAA,WAMM,SALA,cAAJtD,IAAImD,GACII,EAAAA,MAAKX,GAAA,CACZY,kBAAqBR,EAAW7C,UAAAY,MAAA,OAAAC,OAAA,OAAAyC,SAAA,WAEjCC,aAAQC,EAAAC,OAAA,8JF7B6B,KACjC,MAAAd,SAAEA,GAAapD,IACfmE,EAAiB7D,EAAAA,IAAoB,CACzC8D,mBAAmB,EACnBC,aAAa,IAgBR,OAbPvB,EAAAC,MACEK,GACA,CAACkB,EAAeC,EAAGC,KACjB,GAAIF,EAAe,CAIjBE,EAHoBF,EAAcG,kBAAkBC,IAClDP,EAAe1D,MAAQiE,CAAA,IAEJ,IAGzB,CAAE1B,WAAW,IAGRmB,CAAA"}
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 { ref, watch, toValue, type MaybeRefOrGetter } from 'vue';\nimport { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { GateChangeEvent, ScrollActivity, ViewportPlugin } from '@embedpdf/plugin-viewport';\n\nexport const useViewportPlugin = () => usePlugin<ViewportPlugin>(ViewportPlugin.id);\nexport const useViewportCapability = () => useCapability<ViewportPlugin>(ViewportPlugin.id);\n\n/**\n * Hook to get the gated state of the viewport for a specific document.\n * The viewport children are not rendered when gated.\n * @param documentId Document ID (can be ref, computed, getter, or plain value).\n */\nexport const useIsViewportGated = (documentId: MaybeRefOrGetter<string>) => {\n const { provides } = useViewportCapability();\n const isGated = ref(false);\n\n watch(\n [provides, () => toValue(documentId)],\n ([providesValue, docId], _, onCleanup) => {\n if (!providesValue) {\n isGated.value = false;\n return;\n }\n\n // Set initial state\n isGated.value = providesValue.isGated(docId);\n\n const unsubscribe = providesValue.onGateChange((event: GateChangeEvent) => {\n // Filter by documentId\n if (event.documentId === docId) {\n isGated.value = event.isGated;\n }\n });\n\n onCleanup(unsubscribe);\n },\n { immediate: true },\n );\n\n return isGated;\n};\n\n/**\n * Hook to get scroll activity for a specific document\n * @param documentId Document ID (can be ref, computed, getter, or plain value).\n */\nexport const useViewportScrollActivity = (documentId: MaybeRefOrGetter<string>) => {\n const { provides } = useViewportCapability();\n const scrollActivity = ref<ScrollActivity>({\n isSmoothScrolling: false,\n isScrolling: false,\n });\n\n watch(\n [provides, () => toValue(documentId)],\n ([providesValue, docId], _, onCleanup) => {\n if (!providesValue) {\n scrollActivity.value = {\n isSmoothScrolling: false,\n isScrolling: false,\n };\n return;\n }\n\n const unsubscribe = providesValue.onScrollActivity((event) => {\n // Filter by documentId\n if (event.documentId === docId) {\n scrollActivity.value = event.activity;\n }\n });\n\n onCleanup(unsubscribe);\n },\n { immediate: true },\n );\n\n return scrollActivity;\n};\n","import { Rect } from '@embedpdf/models';\nimport { onBeforeUnmount, ref, watch, toValue, type MaybeRefOrGetter } from 'vue';\nimport { useViewportPlugin } from './use-viewport';\n\n/**\n * Hook to get a ref for the viewport container element with automatic setup/teardown\n * @param documentId Document ID (can be ref, computed, getter, or plain value).\n */\nexport function useViewportRef(documentId: MaybeRefOrGetter<string>) {\n const { plugin: pluginRef } = useViewportPlugin();\n const containerRef = ref<HTMLDivElement | null>(null);\n\n let cleanup: (() => void) | null = null;\n\n // Setup function that runs when both plugin and container are available\n const setupViewport = (docId: string) => {\n const viewportPlugin = pluginRef.value;\n const container = containerRef.value;\n\n if (!container || !viewportPlugin) return;\n\n // Register this viewport for the document\n try {\n viewportPlugin.registerViewport(docId);\n } catch (error) {\n console.error(`Failed to register viewport for document ${docId}:`, error);\n return;\n }\n\n // Provide rect calculator\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(docId, provideRect);\n\n // On scroll\n const onScroll = () => {\n viewportPlugin.setViewportScrollMetrics(docId, {\n scrollTop: container.scrollTop,\n scrollLeft: container.scrollLeft,\n });\n };\n container.addEventListener('scroll', onScroll);\n\n // On resize\n const resizeObserver = new ResizeObserver(() => {\n viewportPlugin.setViewportResizeMetrics(docId, {\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 // Subscribe to scroll requests for this document\n const unsubscribeScrollRequest = viewportPlugin.onScrollRequest(\n docId,\n ({ x, y, behavior = 'auto' }) => {\n requestAnimationFrame(() => {\n container.scrollTo({ left: x, top: y, behavior });\n });\n },\n );\n\n // Return cleanup function\n return () => {\n viewportPlugin.unregisterViewport(docId);\n viewportPlugin.registerBoundingRectProvider(docId, null);\n container.removeEventListener('scroll', onScroll);\n unsubscribeScrollRequest();\n };\n };\n\n // Watch for changes in plugin, container, or documentId\n watch(\n [pluginRef, containerRef, () => toValue(documentId)],\n ([, , docId]) => {\n // Clean up previous setup\n if (cleanup) {\n cleanup();\n cleanup = null;\n }\n\n // Setup new viewport\n cleanup = setupViewport(docId) || null;\n },\n { immediate: true },\n );\n\n onBeforeUnmount(() => {\n if (cleanup) {\n cleanup();\n cleanup = null;\n }\n });\n\n return containerRef;\n}\n","<script setup lang=\"ts\">\nimport { ref, watch, useAttrs } from 'vue';\nimport { useIsViewportGated, useViewportCapability, useViewportRef } from '../hooks';\n\n/* -------------------------------------------------- */\n/* props & attrs */\n/* -------------------------------------------------- */\ninterface Props {\n /**\n * The ID of the document that this viewport displays\n */\n documentId: string;\n}\n\nconst props = defineProps<Props>();\nconst attrs = useAttrs();\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/* Gating logic                                    */\n/* -------------------------------------------------- */\nconst isGated = useIsViewportGated(() => props.documentId);\n\n/* -------------------------------------------------- */\n/* element ref that wires up scroll / resize logic */\n/* -------------------------------------------------- */\nconst viewportRef = useViewportRef(() => props.documentId);\n</script>\n\n<template>\n <div\n ref=\"viewportRef\"\n v-bind=\"attrs\"\n :style=\"{ padding: `${viewportGap}px`, width: '100%', height: '100%', overflow: 'auto' }\"\n >\n <slot v-if=\"!isGated\" />\n </div>\n</template>\n"],"names":["useViewportPlugin","usePlugin","ViewportPlugin","id","useViewportCapability","useCapability","useIsViewportGated","documentId","provides","isGated","ref","watch","toValue","providesValue","docId","_","onCleanup","value","onGateChange","event","immediate","useViewportRef","plugin","pluginRef","containerRef","cleanup","viewportPlugin","container","registerViewport","error","console","registerBoundingRectProvider","r","getBoundingClientRect","origin","x","left","y","top","size","width","height","onScroll","setViewportScrollMetrics","scrollTop","scrollLeft","addEventListener","ResizeObserver","setViewportResizeMetrics","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","observe","unsubscribeScrollRequest","onScrollRequest","behavior","requestAnimationFrame","scrollTo","unregisterViewport","removeEventListener","setupViewport","onBeforeUnmount","props","__props","attrs","useAttrs","viewportProvides","viewportGap","vp","getViewportGap","viewportRef","_openBlock","_createElementBlock","_mergeProps","_unref","style","overflow","_renderSlot","_ctx","$slots","key","scrollActivity","isSmoothScrolling","isScrolling","onScrollActivity","activity"],"mappings":"8KAIaA,EAAoB,IAAMC,YAA0BC,EAAAA,eAAeC,IACnEC,EAAwB,IAAMC,gBAA8BH,EAAAA,eAAeC,IAO3EG,EAAsBC,IACjC,MAAMC,SAAEA,GAAaJ,IACfK,EAAUC,EAAAA,KAAI,GAyBpB,OAvBAC,EAAAA,MACE,CAACH,EAAU,IAAMI,UAAQL,IACzB,EAAEM,EAAeC,GAAQC,EAAGC,KAC1B,IAAKH,EAEH,YADAJ,EAAQQ,OAAQ,GAKlBR,EAAQQ,MAAQJ,EAAcJ,QAAQK,GAStCE,EAPoBH,EAAcK,aAAcC,IAE1CA,EAAMZ,aAAeO,IACvBL,EAAQQ,MAAQE,EAAMV,aAM5B,CAAEW,WAAW,IAGRX,GC/BF,SAASY,EAAed,GAC7B,MAAQe,OAAQC,GAAcvB,IACxBwB,EAAed,EAAAA,IAA2B,MAEhD,IAAIe,EAA+B,KA6FnC,OAtBAd,EAAAA,MACE,CAACY,EAAWC,EAAc,IAAMZ,EAAAA,QAAQL,IACxC,EAAC,CAAA,CAAKO,MAEAW,IACFA,IACAA,EAAU,MAIZA,EA9EkB,CAACX,IACrB,MAAMY,EAAiBH,EAAUN,MAC3BU,EAAYH,EAAaP,MAE/B,IAAKU,IAAcD,EAAgB,OAGnC,IACEA,EAAeE,iBAAiBd,EAClC,OAASe,GAEP,YADAC,QAAQD,MAAM,4CAA4Cf,KAAUe,EAEtE,CAUAH,EAAeK,6BAA6BjB,EAPxB,KAClB,MAAMkB,EAAIL,EAAUM,wBACpB,MAAO,CACLC,OAAQ,CAAEC,EAAGH,EAAEI,KAAMC,EAAGL,EAAEM,KAC1BC,KAAM,CAAEC,MAAOR,EAAEQ,MAAOC,OAAQT,EAAES,WAMtC,MAAMC,EAAW,KACfhB,EAAeiB,yBAAyB7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AA,oLFFc5E,IACxC,MAAMC,SAAEA,GAAaJ,IACfgF,EAAiB1E,EAAAA,IAAoB,CACzC2E,mBAAmB,EACnBC,aAAa,IA0Bf,OAvBA3E,EAAAA,MACE,CAACH,EAAU,IAAMI,UAAQL,IACzB,EAAEM,EAAeC,GAAQC,EAAGC,KAC1B,IAAKH,EAKH,YAJAuE,EAAenE,MAAQ,CACrBoE,mBAAmB,EACnBC,aAAa,IAYjBtE,EAPoBH,EAAc0E,iBAAkBpE,IAE9CA,EAAMZ,aAAeO,IACvBsE,EAAenE,MAAQE,EAAMqE,cAMnC,CAAEpE,WAAW,IAGRgE"}
package/dist/vue/index.js CHANGED
@@ -1,37 +1,72 @@
1
- import { ref, watch, onUnmounted, defineComponent, useAttrs, createElementBlock, openBlock, mergeProps, unref, renderSlot } from "vue";
1
+ import { ref, watch, toValue, onBeforeUnmount, defineComponent, useAttrs, createElementBlock, openBlock, mergeProps, unref, renderSlot, createCommentVNode } from "vue";
2
2
  import { useCapability, usePlugin } from "@embedpdf/core/vue";
3
3
  import { ViewportPlugin } from "@embedpdf/plugin-viewport";
4
4
  export * from "@embedpdf/plugin-viewport";
5
5
  const useViewportPlugin = () => usePlugin(ViewportPlugin.id);
6
6
  const useViewportCapability = () => useCapability(ViewportPlugin.id);
7
- const useViewportScrollActivity = () => {
7
+ const useIsViewportGated = (documentId) => {
8
+ const { provides } = useViewportCapability();
9
+ const isGated = ref(false);
10
+ watch(
11
+ [provides, () => toValue(documentId)],
12
+ ([providesValue, docId], _, onCleanup) => {
13
+ if (!providesValue) {
14
+ isGated.value = false;
15
+ return;
16
+ }
17
+ isGated.value = providesValue.isGated(docId);
18
+ const unsubscribe = providesValue.onGateChange((event) => {
19
+ if (event.documentId === docId) {
20
+ isGated.value = event.isGated;
21
+ }
22
+ });
23
+ onCleanup(unsubscribe);
24
+ },
25
+ { immediate: true }
26
+ );
27
+ return isGated;
28
+ };
29
+ const useViewportScrollActivity = (documentId) => {
8
30
  const { provides } = useViewportCapability();
9
31
  const scrollActivity = ref({
10
32
  isSmoothScrolling: false,
11
33
  isScrolling: false
12
34
  });
13
35
  watch(
14
- provides,
15
- (providesValue, _, onCleanup) => {
16
- if (providesValue) {
17
- const unsubscribe = providesValue.onScrollActivity((activity) => {
18
- scrollActivity.value = activity;
19
- });
20
- onCleanup(unsubscribe);
36
+ [provides, () => toValue(documentId)],
37
+ ([providesValue, docId], _, onCleanup) => {
38
+ if (!providesValue) {
39
+ scrollActivity.value = {
40
+ isSmoothScrolling: false,
41
+ isScrolling: false
42
+ };
43
+ return;
21
44
  }
45
+ const unsubscribe = providesValue.onScrollActivity((event) => {
46
+ if (event.documentId === docId) {
47
+ scrollActivity.value = event.activity;
48
+ }
49
+ });
50
+ onCleanup(unsubscribe);
22
51
  },
23
52
  { immediate: true }
24
53
  );
25
54
  return scrollActivity;
26
55
  };
27
- function useViewportRef() {
56
+ function useViewportRef(documentId) {
28
57
  const { plugin: pluginRef } = useViewportPlugin();
29
58
  const containerRef = ref(null);
30
- const setupViewport = () => {
59
+ let cleanup = null;
60
+ const setupViewport = (docId) => {
31
61
  const viewportPlugin = pluginRef.value;
32
62
  const container = containerRef.value;
33
63
  if (!container || !viewportPlugin) return;
34
- let cleanedUp = false;
64
+ try {
65
+ viewportPlugin.registerViewport(docId);
66
+ } catch (error) {
67
+ console.error(`Failed to register viewport for document ${docId}:`, error);
68
+ return;
69
+ }
35
70
  const provideRect = () => {
36
71
  const r = container.getBoundingClientRect();
37
72
  return {
@@ -39,17 +74,16 @@ function useViewportRef() {
39
74
  size: { width: r.width, height: r.height }
40
75
  };
41
76
  };
42
- viewportPlugin.registerBoundingRectProvider(provideRect);
77
+ viewportPlugin.registerBoundingRectProvider(docId, provideRect);
43
78
  const onScroll = () => {
44
- viewportPlugin.setViewportScrollMetrics({
79
+ viewportPlugin.setViewportScrollMetrics(docId, {
45
80
  scrollTop: container.scrollTop,
46
81
  scrollLeft: container.scrollLeft
47
82
  });
48
83
  };
49
84
  container.addEventListener("scroll", onScroll);
50
85
  const resizeObserver = new ResizeObserver(() => {
51
- if (cleanedUp) return;
52
- viewportPlugin.setViewportResizeMetrics({
86
+ viewportPlugin.setViewportResizeMetrics(docId, {
53
87
  width: container.offsetWidth,
54
88
  height: container.offsetHeight,
55
89
  clientWidth: container.clientWidth,
@@ -62,6 +96,7 @@ function useViewportRef() {
62
96
  });
63
97
  resizeObserver.observe(container);
64
98
  const unsubscribeScrollRequest = viewportPlugin.onScrollRequest(
99
+ docId,
65
100
  ({ x, y, behavior = "auto" }) => {
66
101
  requestAnimationFrame(() => {
67
102
  container.scrollTo({ left: x, top: y, behavior });
@@ -69,47 +104,38 @@ function useViewportRef() {
69
104
  }
70
105
  );
71
106
  return () => {
72
- cleanedUp = true;
73
- resizeObserver.disconnect();
74
- viewportPlugin.registerBoundingRectProvider(null);
107
+ viewportPlugin.unregisterViewport(docId);
108
+ viewportPlugin.registerBoundingRectProvider(docId, null);
75
109
  container.removeEventListener("scroll", onScroll);
76
110
  unsubscribeScrollRequest();
77
111
  };
78
112
  };
79
- let cleanup = null;
80
- watch(
81
- pluginRef,
82
- () => {
83
- if (cleanup) {
84
- cleanup();
85
- cleanup = null;
86
- }
87
- cleanup = setupViewport() || null;
88
- },
89
- { immediate: true }
90
- // Run immediately if plugin is already available
91
- );
92
113
  watch(
93
- containerRef,
94
- () => {
114
+ [pluginRef, containerRef, () => toValue(documentId)],
115
+ ([, , docId]) => {
95
116
  if (cleanup) {
96
117
  cleanup();
97
118
  cleanup = null;
98
119
  }
99
- cleanup = setupViewport() || null;
120
+ cleanup = setupViewport(docId) || null;
100
121
  },
101
122
  { immediate: true }
102
123
  );
103
- onUnmounted(() => {
124
+ onBeforeUnmount(() => {
104
125
  if (cleanup) {
105
126
  cleanup();
127
+ cleanup = null;
106
128
  }
107
129
  });
108
130
  return containerRef;
109
131
  }
110
132
  const _sfc_main = /* @__PURE__ */ defineComponent({
111
133
  __name: "viewport",
134
+ props: {
135
+ documentId: {}
136
+ },
112
137
  setup(__props) {
138
+ const props = __props;
113
139
  const attrs = useAttrs();
114
140
  const { provides: viewportProvides } = useViewportCapability();
115
141
  const viewportGap = ref(0);
@@ -120,7 +146,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
120
146
  },
121
147
  { immediate: true }
122
148
  );
123
- const viewportRef = useViewportRef();
149
+ const isGated = useIsViewportGated(() => props.documentId);
150
+ const viewportRef = useViewportRef(() => props.documentId);
124
151
  return (_ctx, _cache) => {
125
152
  return openBlock(), createElementBlock("div", mergeProps({
126
153
  ref_key: "viewportRef",
@@ -128,13 +155,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
128
155
  }, unref(attrs), {
129
156
  style: { padding: `${viewportGap.value}px`, width: "100%", height: "100%", overflow: "auto" }
130
157
  }), [
131
- renderSlot(_ctx.$slots, "default")
158
+ !unref(isGated) ? renderSlot(_ctx.$slots, "default", { key: 0 }) : createCommentVNode("", true)
132
159
  ], 16);
133
160
  };
134
161
  }
135
162
  });
136
163
  export {
137
164
  _sfc_main as Viewport,
165
+ useIsViewportGated,
138
166
  useViewportCapability,
139
167
  useViewportPlugin,
140
168
  useViewportRef,
@@ -1 +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 { ref, watch } from 'vue';\nimport { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { ScrollActivity, ViewportPlugin } from '@embedpdf/plugin-viewport';\n\nexport const useViewportPlugin = () => usePlugin<ViewportPlugin>(ViewportPlugin.id);\nexport const useViewportCapability = () => useCapability<ViewportPlugin>(ViewportPlugin.id);\n\nexport const useViewportScrollActivity = () => {\n const { provides } = useViewportCapability();\n const scrollActivity = ref<ScrollActivity>({\n isSmoothScrolling: false,\n isScrolling: false,\n });\n\n watch(\n provides,\n (providesValue, _, onCleanup) => {\n if (providesValue) {\n const unsubscribe = providesValue.onScrollActivity((activity) => {\n scrollActivity.value = activity;\n });\n onCleanup(unsubscribe);\n }\n },\n { immediate: true },\n );\n\n return scrollActivity;\n};\n","import { Rect } from '@embedpdf/models';\nimport { onMounted, onUnmounted, ref, watch } 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 // Setup function that runs when both plugin and container are available\n const setupViewport = () => {\n const viewportPlugin = pluginRef.value;\n const container = containerRef.value;\n\n if (!container || !viewportPlugin) return;\n\n let cleanedUp = false;\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 if (cleanedUp) return;\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 // Return cleanup function\n return () => {\n cleanedUp = true;\n resizeObserver.disconnect();\n viewportPlugin.registerBoundingRectProvider(null);\n container.removeEventListener('scroll', onScroll);\n unsubscribeScrollRequest();\n };\n };\n\n let cleanup: (() => void) | null = null;\n\n // Watch for changes in the plugin - this is the Vue equivalent of React's dependency array\n watch(\n pluginRef,\n () => {\n // Clean up previous setup if it exists\n if (cleanup) {\n cleanup();\n cleanup = null;\n }\n\n // Setup new viewport if plugin is available\n cleanup = setupViewport() || null;\n },\n { immediate: true }, // Run immediately if plugin is already available\n );\n\n // Also watch for container changes (though this is less likely to change)\n watch(\n containerRef,\n () => {\n // Clean up previous setup if it exists\n if (cleanup) {\n cleanup();\n cleanup = null;\n }\n\n // Setup new viewport if both plugin and container are available\n cleanup = setupViewport() || null;\n },\n { immediate: true },\n );\n\n onUnmounted(() => {\n if (cleanup) {\n cleanup();\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\n ref=\"viewportRef\"\n v-bind=\"attrs\"\n :style=\"{ padding: `${viewportGap}px`, width: '100%', height: '100%', overflow: 'auto' }\"\n >\n <slot />\n </div>\n</template>\n"],"names":["_openBlock","_createElementBlock","_mergeProps","_unref","_renderSlot"],"mappings":";;;;AAIO,MAAM,oBAAoB,MAAM,UAA0B,eAAe,EAAE;AAC3E,MAAM,wBAAwB,MAAM,cAA8B,eAAe,EAAE;AAEnF,MAAM,4BAA4B,MAAM;AACvC,QAAA,EAAE,SAAS,IAAI,sBAAsB;AAC3C,QAAM,iBAAiB,IAAoB;AAAA,IACzC,mBAAmB;AAAA,I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AA,MAAA,OAAA,QAAA,QAAA,QAAA,UAAA,OAAA;AAAA,MAAA;QAEjCC,WAAQ,KAAA,QAAA,SAAA;AAAA;;;;"}
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 { ref, watch, toValue, type MaybeRefOrGetter } from 'vue';\nimport { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { GateChangeEvent, ScrollActivity, ViewportPlugin } from '@embedpdf/plugin-viewport';\n\nexport const useViewportPlugin = () => usePlugin<ViewportPlugin>(ViewportPlugin.id);\nexport const useViewportCapability = () => useCapability<ViewportPlugin>(ViewportPlugin.id);\n\n/**\n * Hook to get the gated state of the viewport for a specific document.\n * The viewport children are not rendered when gated.\n * @param documentId Document ID (can be ref, computed, getter, or plain value).\n */\nexport const useIsViewportGated = (documentId: MaybeRefOrGetter<string>) => {\n const { provides } = useViewportCapability();\n const isGated = ref(false);\n\n watch(\n [provides, () => toValue(documentId)],\n ([providesValue, docId], _, onCleanup) => {\n if (!providesValue) {\n isGated.value = false;\n return;\n }\n\n // Set initial state\n isGated.value = providesValue.isGated(docId);\n\n const unsubscribe = providesValue.onGateChange((event: GateChangeEvent) => {\n // Filter by documentId\n if (event.documentId === docId) {\n isGated.value = event.isGated;\n }\n });\n\n onCleanup(unsubscribe);\n },\n { immediate: true },\n );\n\n return isGated;\n};\n\n/**\n * Hook to get scroll activity for a specific document\n * @param documentId Document ID (can be ref, computed, getter, or plain value).\n */\nexport const useViewportScrollActivity = (documentId: MaybeRefOrGetter<string>) => {\n const { provides } = useViewportCapability();\n const scrollActivity = ref<ScrollActivity>({\n isSmoothScrolling: false,\n isScrolling: false,\n });\n\n watch(\n [provides, () => toValue(documentId)],\n ([providesValue, docId], _, onCleanup) => {\n if (!providesValue) {\n scrollActivity.value = {\n isSmoothScrolling: false,\n isScrolling: false,\n };\n return;\n }\n\n const unsubscribe = providesValue.onScrollActivity((event) => {\n // Filter by documentId\n if (event.documentId === docId) {\n scrollActivity.value = event.activity;\n }\n });\n\n onCleanup(unsubscribe);\n },\n { immediate: true },\n );\n\n return scrollActivity;\n};\n","import { Rect } from '@embedpdf/models';\nimport { onBeforeUnmount, ref, watch, toValue, type MaybeRefOrGetter } from 'vue';\nimport { useViewportPlugin } from './use-viewport';\n\n/**\n * Hook to get a ref for the viewport container element with automatic setup/teardown\n * @param documentId Document ID (can be ref, computed, getter, or plain value).\n */\nexport function useViewportRef(documentId: MaybeRefOrGetter<string>) {\n const { plugin: pluginRef } = useViewportPlugin();\n const containerRef = ref<HTMLDivElement | null>(null);\n\n let cleanup: (() => void) | null = null;\n\n // Setup function that runs when both plugin and container are available\n const setupViewport = (docId: string) => {\n const viewportPlugin = pluginRef.value;\n const container = containerRef.value;\n\n if (!container || !viewportPlugin) return;\n\n // Register this viewport for the document\n try {\n viewportPlugin.registerViewport(docId);\n } catch (error) {\n console.error(`Failed to register viewport for document ${docId}:`, error);\n return;\n }\n\n // Provide rect calculator\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(docId, provideRect);\n\n // On scroll\n const onScroll = () => {\n viewportPlugin.setViewportScrollMetrics(docId, {\n scrollTop: container.scrollTop,\n scrollLeft: container.scrollLeft,\n });\n };\n container.addEventListener('scroll', onScroll);\n\n // On resize\n const resizeObserver = new ResizeObserver(() => {\n viewportPlugin.setViewportResizeMetrics(docId, {\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 // Subscribe to scroll requests for this document\n const unsubscribeScrollRequest = viewportPlugin.onScrollRequest(\n docId,\n ({ x, y, behavior = 'auto' }) => {\n requestAnimationFrame(() => {\n container.scrollTo({ left: x, top: y, behavior });\n });\n },\n );\n\n // Return cleanup function\n return () => {\n viewportPlugin.unregisterViewport(docId);\n viewportPlugin.registerBoundingRectProvider(docId, null);\n container.removeEventListener('scroll', onScroll);\n unsubscribeScrollRequest();\n };\n };\n\n // Watch for changes in plugin, container, or documentId\n watch(\n [pluginRef, containerRef, () => toValue(documentId)],\n ([, , docId]) => {\n // Clean up previous setup\n if (cleanup) {\n cleanup();\n cleanup = null;\n }\n\n // Setup new viewport\n cleanup = setupViewport(docId) || null;\n },\n { immediate: true },\n );\n\n onBeforeUnmount(() => {\n if (cleanup) {\n cleanup();\n cleanup = null;\n }\n });\n\n return containerRef;\n}\n","<script setup lang=\"ts\">\nimport { ref, watch, useAttrs } from 'vue';\nimport { useIsViewportGated, useViewportCapability, useViewportRef } from '../hooks';\n\n/* -------------------------------------------------- */\n/* props & attrs */\n/* -------------------------------------------------- */\ninterface Props {\n /**\n * The ID of the document that this viewport displays\n */\n documentId: string;\n}\n\nconst props = defineProps<Props>();\nconst attrs = useAttrs();\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/* Gating logic                                    */\n/* -------------------------------------------------- */\nconst isGated = useIsViewportGated(() => props.documentId);\n\n/* -------------------------------------------------- */\n/* element ref that wires up scroll / resize logic */\n/* -------------------------------------------------- */\nconst viewportRef = useViewportRef(() => props.documentId);\n</script>\n\n<template>\n <div\n ref=\"viewportRef\"\n v-bind=\"attrs\"\n :style=\"{ padding: `${viewportGap}px`, width: '100%', height: '100%', overflow: 'auto' }\"\n >\n <slot v-if=\"!isGated\" />\n </div>\n</template>\n"],"names":["_openBlock","_createElementBlock","_mergeProps","_unref","_renderSl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}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-viewport",
3
- "version": "1.5.0",
3
+ "version": "2.0.0-next.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.cjs",
@@ -35,13 +35,13 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@embedpdf/models": "1.5.0"
38
+ "@embedpdf/models": "2.0.0-next.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/react": "^18.2.0",
42
42
  "typescript": "^5.0.0",
43
- "@embedpdf/build": "1.1.0",
44
- "@embedpdf/core": "1.5.0"
43
+ "@embedpdf/core": "2.0.0-next.1",
44
+ "@embedpdf/build": "1.1.0"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "react": ">=16.8.0",
@@ -49,7 +49,7 @@
49
49
  "preact": "^10.26.4",
50
50
  "vue": ">=3.2.0",
51
51
  "svelte": ">=5 <6",
52
- "@embedpdf/core": "1.5.0"
52
+ "@embedpdf/core": "2.0.0-next.1"
53
53
  },
54
54
  "files": [
55
55
  "dist",