@embedpdf/plugin-interaction-manager 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/actions.d.ts +9 -1
- package/dist/lib/interaction-manager-plugin.d.ts +1 -0
- package/dist/lib/types.d.ts +17 -2
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +102 -34
- package/dist/preact/index.js.map +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +102 -34
- package/dist/react/index.js.map +1 -1
- package/dist/shared-preact/utils.d.ts +0 -5
- package/dist/shared-react/utils.d.ts +0 -5
- package/dist/shared-vue/utils.d.ts +0 -5
- package/dist/vue/hooks/use-interaction-manager.d.ts +2 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +102 -34
- package/dist/vue/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import { Position } from '@embedpdf/models';
|
|
2
2
|
import { InteractionManagerCapability, InteractionScope } from '../lib/index.ts';
|
|
3
|
-
/**
|
|
4
|
-
* Hook one DOM element into the interaction-manager.
|
|
5
|
-
* – keeps handlers & cursor in-sync with the current mode
|
|
6
|
-
* – returns a teardown fn for React/Preact effects
|
|
7
|
-
*/
|
|
8
3
|
export declare function createPointerProvider(cap: InteractionManagerCapability, scope: InteractionScope, element: HTMLElement, convertEventToPoint?: (evt: PointerEvent, host: HTMLElement) => Position): () => void;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import { Position } from '@embedpdf/models';
|
|
2
2
|
import { InteractionManagerCapability, InteractionScope } from '../lib/index.ts';
|
|
3
|
-
/**
|
|
4
|
-
* Hook one DOM element into the interaction-manager.
|
|
5
|
-
* – keeps handlers & cursor in-sync with the current mode
|
|
6
|
-
* – returns a teardown fn for React/Preact effects
|
|
7
|
-
*/
|
|
8
3
|
export declare function createPointerProvider(cap: InteractionManagerCapability, scope: InteractionScope, element: HTMLElement, convertEventToPoint?: (evt: PointerEvent, host: HTMLElement) => Position): () => void;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import { Position } from '@embedpdf/models';
|
|
2
2
|
import { InteractionManagerCapability, InteractionScope } from '../lib/index.ts';
|
|
3
|
-
/**
|
|
4
|
-
* Hook one DOM element into the interaction-manager.
|
|
5
|
-
* – keeps handlers & cursor in-sync with the current mode
|
|
6
|
-
* – returns a teardown fn for React/Preact effects
|
|
7
|
-
*/
|
|
8
3
|
export declare function createPointerProvider(cap: InteractionManagerCapability, scope: InteractionScope, element: HTMLElement, convertEventToPoint?: (evt: PointerEvent, host: HTMLElement) => Position): () => void;
|
|
@@ -7,10 +7,12 @@ export declare function useInteractionManager(): {
|
|
|
7
7
|
readonly activeMode: string;
|
|
8
8
|
readonly cursor: string;
|
|
9
9
|
readonly paused: boolean;
|
|
10
|
+
readonly defaultMode: string;
|
|
10
11
|
}, {
|
|
11
12
|
readonly activeMode: string;
|
|
12
13
|
readonly cursor: string;
|
|
13
14
|
readonly paused: boolean;
|
|
15
|
+
readonly defaultMode: string;
|
|
14
16
|
}>>;
|
|
15
17
|
};
|
|
16
18
|
export declare function useCursor(): {
|
package/dist/vue/index.cjs
CHANGED
|
@@ -1,2 +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-interaction-manager"),n=require("@embedpdf/models");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),t=require("@embedpdf/core/vue"),o=require("@embedpdf/plugin-interaction-manager"),n=require("@embedpdf/models"),r={pointerdown:"onPointerDown",pointerup:"onPointerUp",pointermove:"onPointerMove",pointerenter:"onPointerEnter",pointerleave:"onPointerLeave",pointercancel:"onPointerCancel",mousedown:"onMouseDown",mouseup:"onMouseUp",mousemove:"onMouseMove",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mousecancel:"onMouseCancel",click:"onClick",dblclick:"onDoubleClick",touchstart:"onPointerDown",touchend:"onPointerUp",touchmove:"onPointerMove",touchcancel:"onPointerCancel"},l=["pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","mousedown","mouseup","mousemove","mouseenter","mouseleave","mousecancel","click","dblclick","touchstart","touchend","touchmove","touchcancel"];function a(e,t,o,n){let a=e.getHandlersForScope(t);const i=()=>{var t;return!1!==(null==(t=e.getActiveInteractionMode())?void 0:t.wantsRawTouch)},c={};let u=i();const s=e=>{l.forEach((t=>{const n=c[t]??(c[t]=y);var r;o.addEventListener(t,n,(r=e,t.startsWith("touch")?{passive:!r}:{passive:!1}))}))},p=()=>{l.forEach((e=>{const t=c[e];t&&o.removeEventListener(e,t)}))};s(u);const v=e.onModeChange((()=>{if("global"===t.type){const t=e.getActiveInteractionMode();o.style.cursor="global"===(null==t?void 0:t.scope)?t.cursor??"auto":"auto"}a=e.getHandlersForScope(t);const n=i();n!==u&&(p(),s(n),u=n)})),d=e.onHandlerChange((()=>{a=e.getHandlersForScope(t)})),g=e.getActiveInteractionMode(),f=e.getCurrentCursor();o.style.cursor="global"===t.type&&"global"!==(null==g?void 0:g.scope)?"auto":f;const h=e.onCursorChange((n=>{var r;"global"===t.type&&"global"!==(null==(r=e.getActiveInteractionMode())?void 0:r.scope)||(o.style.cursor=n)})),m=(e,t)=>{if(n)return n(e,t);const o=t.getBoundingClientRect();return{x:e.clientX-o.left,y:e.clientY-o.top}};function y(t){var n;if(e.isPaused())return;const l=r[t.type];if(!l||!(null==a?void 0:a[l]))return;let i,c;if(t instanceof TouchEvent&&u&&("touchmove"===t.type||"touchcancel"===t.type)&&t.preventDefault(),t instanceof TouchEvent){const e="touchend"===t.type||"touchcancel"===t.type?t.changedTouches[0]:t.touches[0];if(!e)return;i=m(e,o),c={clientX:e.clientX,clientY:e.clientY,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,target:t.target,currentTarget:t.currentTarget}}else{const e=t;i=m(e,o),c=e}null==(n=a[l])||n.call(a,i,c,e.getActiveMode())}return()=>{p(),v(),h(),d()}}const i=()=>t.useCapability(o.InteractionManagerPlugin.id);function c(){const{provides:t}=i(),o=e.ref(!1);return e.watchEffect((e=>{if(t.value){const n=t.value.getActiveInteractionMode();o.value="page"===(null==n?void 0:n.scope)&&!!(null==n?void 0:n.exclusive);e(t.value.onModeChange((()=>{if(!t.value)return;const e=t.value.getActiveInteractionMode();o.value="page"===(null==e?void 0:e.scope)&&!!(null==e?void 0:e.exclusive)})))}})),e.readonly(o)}const u=e.defineComponent({__name:"global-pointer-provider",setup(t){const o=e.ref(null),{provides:n}=i();return e.watchEffect((e=>{if(n.value&&o.value){e(a(n.value,{type:"global"},o.value))}})),(t,n)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"divRef",ref:o,style:{width:"100%",height:"100%"}},[e.renderSlot(t.$slots,"default")],512))}}),s={key:0,style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:10}},p=e.defineComponent({__name:"page-pointer-provider",props:{pageIndex:{},pageWidth:{},pageHeight:{},rotation:{},scale:{},convertEventToPoint:{type:Function}},setup(t){const o=t,r=e.ref(null),{provides:l}=i(),u=c(),p=e.computed((()=>(e,t)=>{const r=t.getBoundingClientRect(),l={x:e.clientX-r.left,y:e.clientY-r.top};return n.restorePosition({width:o.pageWidth,height:o.pageHeight},l,o.rotation,o.scale)}));return e.watchEffect((e=>{if(l.value&&r.value){e(a(l.value,{type:"page",pageIndex:o.pageIndex},r.value,o.convertEventToPoint||p.value))}})),(t,o)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"divRef",ref:r},[e.renderSlot(t.$slots,"default"),e.unref(u)?(e.openBlock(),e.createElementBlock("div",s)):e.createCommentVNode("",!0)],512))}});exports.GlobalPointerProvider=u,exports.PagePointerProvider=p,exports.useCursor=function(){const{provides:e}=i();return{setCursor:(t,o,n=0)=>{var r;null==(r=e.value)||r.setCursor(t,o,n)},removeCursor:t=>{var o;null==(o=e.value)||o.removeCursor(t)}}},exports.useInteractionManager=function(){const{provides:t}=i(),n=e.ref(o.initialState);return e.watchEffect((e=>{if(t.value){e(t.value.onStateChange((e=>{n.value=e})))}})),{provides:t,state:e.readonly(n)}},exports.useInteractionManagerCapability=i,exports.useInteractionManagerPlugin=()=>t.usePlugin(o.InteractionManagerPlugin.id),exports.useIsPageExclusive=c,exports.usePointerHandlers=function({modeId:e,pageIndex:t}){const{provides:o}=i();return{register:(n,r)=>{const l=(null==r?void 0:r.modeId)??e,a=(null==r?void 0:r.pageIndex)??t;if(o.value)return l?o.value.registerHandlers({modeId:l,handlers:n,pageIndex:a}):o.value.registerAlways({scope:void 0!==a?{type:"page",pageIndex:a}:{type:"global"},handlers:n})}}};
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/vue/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/shared/utils.ts","../../src/vue/hooks/use-interaction-manager.ts","../../src/vue/components/global-pointer-provider.vue","../../src/vue/components/page-pointer-provider.vue"],"sourcesContent":["import { Position } from '@embedpdf/models';\nimport type {\n InteractionManagerCapability,\n InteractionScope,\n PointerEventHandlers,\n} from '@embedpdf/plugin-interaction-manager';\n\n/**\n * Hook one DOM element into the interaction-manager.\n * – keeps handlers & cursor in-sync with the current mode\n * – returns a teardown fn for React/Preact effects\n */\nexport function createPointerProvider(\n cap: InteractionManagerCapability,\n scope: InteractionScope,\n element: HTMLElement,\n convertEventToPoint?: (evt: PointerEvent, host: HTMLElement) => Position,\n) {\n /* ------------------------------------------------------------------ */\n /* active handler set – hot-swapped on every mode change */\n /* ------------------------------------------------------------------ */\n let active: PointerEventHandlers | null = cap.getHandlersForScope(scope);\n\n const stopMode = cap.onModeChange(() => {\n if (scope.type === 'global') {\n const mode = cap.getActiveInteractionMode();\n element.style.cursor = mode?.scope === 'global' ? (mode.cursor ?? 'auto') : 'auto';\n }\n active = cap.getHandlersForScope(scope);\n });\n\n const stopHandler = cap.onHandlerChange(() => {\n active = cap.getHandlersForScope(scope);\n });\n\n /* ------------------------------------------------------------------ */\n /* cursor */\n /* ------------------------------------------------------------------ */\n const modeNow = cap.getActiveInteractionMode();\n const cursorNow = cap.getCurrentCursor();\n\n /** initial cursor -------------------------------------------------- */\n if (scope.type === 'global') {\n // global wrapper only shows the cursor while a *global* mode is active\n element.style.cursor = modeNow?.scope === 'global' ? cursorNow : 'auto';\n } else {\n // page wrappers always mirror the latest cursor\n element.style.cursor = cursorNow;\n }\n\n const stopCursor = cap.onCursorChange((c) => {\n /** ❖ Propagation rule\n * ─────────────────\n * • global provider updates its cursor *only* while the active\n * mode itself is ‘global’.\n * • page providers always sync (so they show the cursor during\n * a global mode as well). */\n if (scope.type === 'global') {\n const isGlobalMode = cap.getActiveInteractionMode()?.scope === 'global';\n if (!isGlobalMode) return; // active mode is page-scoped → ignore\n }\n element.style.cursor = c;\n });\n\n /* ------------------------------------------------------------------ */\n /* event wiring */\n /* ------------------------------------------------------------------ */\n type K = keyof PointerEventHandlers;\n const domEvent: Record<K, keyof HTMLElementEventMap> = {\n onPointerDown: 'pointerdown',\n onPointerUp: 'pointerup',\n onPointerMove: 'pointermove',\n onPointerEnter: 'pointerenter',\n onPointerLeave: 'pointerleave',\n onPointerCancel: 'pointercancel',\n onClick: 'click',\n onDoubleClick: 'dblclick',\n };\n\n /* one stable EventListener per key -> needed for removeEventListener */\n const listeners: Partial<Record<K, EventListener>> = {};\n\n const toPos = (e: PointerEvent, host: HTMLElement): Position => {\n if (convertEventToPoint) return convertEventToPoint(e, host);\n const r = host.getBoundingClientRect();\n return { x: e.clientX - r.left, y: e.clientY - r.top };\n };\n\n (Object.keys(domEvent) as K[]).forEach((k) => {\n listeners[k] = (evt: Event) => {\n if (cap.isPaused()) return;\n\n const pe = evt as PointerEvent; // safe – we only attach to pointer*\n const currentModeId = cap.getActiveMode();\n active?.[k]?.(toPos(pe, element), pe, currentModeId);\n /* if you need to stop default behaviour when no handler is active:\n * if (!active?.[k]) pe.preventDefault(); */\n };\n element.addEventListener(domEvent[k], listeners[k]!);\n });\n\n /* ------------------------------------------------------------------ */\n /* teardown */\n /* ------------------------------------------------------------------ */\n return () => {\n (Object.keys(domEvent) as K[]).forEach((k) =>\n element.removeEventListener(domEvent[k], listeners[k]!),\n );\n stopMode();\n stopCursor();\n stopHandler();\n };\n}\n","import { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport {\n initialState,\n InteractionManagerPlugin,\n InteractionManagerState,\n PointerEventHandlersWithLifecycle,\n} from '@embedpdf/plugin-interaction-manager';\nimport { ref, watchEffect, readonly } from 'vue';\n\nexport const useInteractionManagerPlugin = () =>\n usePlugin<InteractionManagerPlugin>(InteractionManagerPlugin.id);\nexport const useInteractionManagerCapability = () =>\n useCapability<InteractionManagerPlugin>(InteractionManagerPlugin.id);\n\nexport function useInteractionManager() {\n const { provides } = useInteractionManagerCapability();\n const state = ref<InteractionManagerState>(initialState);\n\n watchEffect((onCleanup) => {\n if (provides.value) {\n // onStateChange is a BehaviorEmitter, so it emits the current state upon subscription\n const unsubscribe = provides.value.onStateChange((newState) => {\n state.value = newState;\n });\n onCleanup(unsubscribe);\n }\n });\n\n return {\n provides,\n state: readonly(state),\n };\n}\n\nexport function useCursor() {\n const { provides } = useInteractionManagerCapability();\n return {\n setCursor: (token: string, cursor: string, prio = 0) => {\n provides.value?.setCursor(token, cursor, prio);\n },\n removeCursor: (token: string) => {\n provides.value?.removeCursor(token);\n },\n };\n}\n\ninterface UsePointerHandlersOptions {\n modeId?: string | string[];\n pageIndex?: number;\n}\n\nexport function usePointerHandlers({ modeId, pageIndex }: UsePointerHandlersOptions) {\n const { provides } = useInteractionManagerCapability();\n return {\n register: (\n handlers: PointerEventHandlersWithLifecycle,\n options?: { modeId?: string | string[]; pageIndex?: number },\n ) => {\n // Use provided options or fall back to hook-level options\n const finalModeId = options?.modeId ?? modeId;\n const finalPageIndex = options?.pageIndex ?? pageIndex;\n\n if (!provides.value) return;\n\n return finalModeId\n ? provides.value.registerHandlers({\n modeId: finalModeId,\n handlers,\n pageIndex: finalPageIndex,\n })\n : provides.value.registerAlways({\n scope:\n finalPageIndex !== undefined\n ? { type: 'page', pageIndex: finalPageIndex }\n : { type: 'global' },\n handlers,\n });\n },\n };\n}\n\nexport function useIsPageExclusive() {\n const { provides: cap } = useInteractionManagerCapability();\n const isPageExclusive = ref<boolean>(false);\n\n watchEffect((onCleanup) => {\n if (cap.value) {\n const mode = cap.value.getActiveInteractionMode();\n isPageExclusive.value = mode?.scope === 'page' && !!mode?.exclusive;\n\n const unsubscribe = cap.value.onModeChange(() => {\n if (!cap.value) return;\n const newMode = cap.value.getActiveInteractionMode();\n isPageExclusive.value = newMode?.scope === 'page' && !!newMode?.exclusive;\n });\n onCleanup(unsubscribe);\n }\n });\n\n return readonly(isPageExclusive);\n}\n","<script setup lang=\"ts\">\nimport { ref, watchEffect } from 'vue';\nimport { createPointerProvider } from '../../shared/utils';\nimport { useInteractionManagerCapability } from '../hooks';\n\nconst divRef = ref<HTMLDivElement | null>(null);\nconst { provides: cap } = useInteractionManagerCapability();\n\n// watchEffect automatically handles setup and teardown when capability or element is ready\nwatchEffect((onCleanup) => {\n if (cap.value && divRef.value) {\n const cleanup = createPointerProvider(cap.value, { type: 'global' }, divRef.value);\n onCleanup(cleanup);\n }\n});\n</script>\n\n<template>\n <div\n ref=\"divRef\"\n :style=\"{\n width: '100%',\n height: '100%',\n }\"\n >\n <slot />\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { ref, watchEffect, computed, StyleValue } from 'vue';\nimport { Position, restorePosition } from '@embedpdf/models';\nimport { createPointerProvider } from '../../shared/utils';\nimport { useInteractionManagerCapability, useIsPageExclusive } from '../hooks';\n\ninterface Props {\n pageIndex: number;\n pageWidth: number;\n pageHeight: number;\n rotation: number;\n scale: number;\n convertEventToPoint?: (event: PointerEvent, element: HTMLElement) => Position;\n}\n\nconst props = defineProps<Props>();\n\nconst divRef = ref<HTMLDivElement | null>(null);\nconst { provides: cap } = useInteractionManagerCapability();\nconst isPageExclusive = useIsPageExclusive();\n\nconst defaultConvertEventToPoint = computed(() => {\n return (event: PointerEvent, element: HTMLElement): Position => {\n const rect = element.getBoundingClientRect();\n const displayPoint = {\n x: event.clientX - rect.left,\n y: event.clientY - rect.top,\n };\n return restorePosition(\n { width: props.pageWidth, height: props.pageHeight },\n displayPoint,\n props.rotation,\n props.scale,\n );\n };\n});\n\nwatchEffect((onCleanup) => {\n if (cap.value && divRef.value) {\n const cleanup = createPointerProvider(\n cap.value,\n { type: 'page', pageIndex: props.pageIndex },\n divRef.value,\n props.convertEventToPoint || defaultConvertEventToPoint.value,\n );\n onCleanup(cleanup);\n }\n});\n</script>\n\n<template>\n <div ref=\"divRef\">\n <slot />\n <div\n v-if=\"isPageExclusive\"\n :style=\"{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, zIndex: 10 }\"\n />\n </div>\n</template>\n"],"names":["createPointerProvider","cap","scope","element","convertEventToPoint","active","getHandlersForScope","stopMode","onModeChange","type","mode","getActiveInteractionMode","style","cursor","stopHandler","onHandlerChange","modeNow","cursorNow","getCurrentCursor","stopCursor","onCursorChange","c","_a","domEvent","onPointerDown","onPointerUp","onPointerMove","onPointerEnter","onPointerLeave","onPointerCancel","onClick","onDoubleClick","listeners","Object","keys","forEach","k","evt","isPaused","pe","currentModeId","getActiveMode","call","e","host","r","getBoundingClientRect","x","clientX","left","y","clientY","top","toPos","addEventListener","removeEventListener","useInteractionManagerCapability","useCapability","InteractionManagerPlugin","id","useIsPageExclusive","provides","isPageExclusive","ref","readonly","vue$1","watchEffect","onCleanup","value","exclusive","newMode","divRef","_createElementBlock","createElementBlock","_renderSlot","_ctx","$slots","props","__props","defaultConvertEventToPoint","computed","event","rect","displayPoint","restorePosition","width","pageWidth","height","pageHeight","rotation","scale","pageIndex","_unref","_openBlock","_hoisted_1","setCursor","token","prio","removeCursor","state","initialState","onStateChange","newState","usePlugin","modeId","register","handlers","options","finalModeId","finalPageIndex","registerHandlers","registerAlways"],"mappings":"uNAYO,SAASA,EACdC,EACAC,EACAC,EACAC,GAKI,IAAAC,EAAsCJ,EAAIK,oBAAoBJ,GAE5D,MAAAK,EAAWN,EAAIO,cAAa,KAC5B,GAAe,WAAfN,EAAMO,KAAmB,CACrB,MAAAC,EAAOT,EAAIU,2BACjBR,EAAQS,MAAMC,OAAyB,YAAhB,MAAAH,OAAA,EAAAA,EAAMR,OAAsBQ,EAAKG,QAAU,OAAU,MAAA,CAErER,EAAAJ,EAAIK,oBAAoBJ,EAAK,IAGlCY,EAAcb,EAAIc,iBAAgB,KAC7BV,EAAAJ,EAAIK,oBAAoBJ,EAAK,IAMlCc,EAAUf,EAAIU,2BACdM,EAAYhB,EAAIiB,mBAGH,WAAfhB,EAAMO,KAERN,EAAQS,MAAMC,OAA4B,YAAV,MAATG,OAAS,EAAAA,EAAAd,OAAqBe,EAAY,OAGjEd,EAAQS,MAAMC,OAASI,EAGzB,MAAME,EAAalB,EAAImB,gBAAgBC,UAOjC,GAAe,WAAfnB,EAAMO,KAAmB,CAE3B,KAD+D,YAA1C,OAAAa,EAAArB,EAAIU,qCAA4BT,QAClC,MAAA,CAErBC,EAAQS,MAAMC,OAASQ,CAAA,IAOnBE,EAAiD,CACrDC,cAAe,cACfC,YAAa,YACbC,cAAe,cACfC,eAAgB,eAChBC,eAAgB,eAChBC,gBAAiB,gBACjBC,QAAS,QACTC,cAAe,YAIXC,EAA+C,CAAC,EAwBtD,OAhBCC,OAAOC,KAAKX,GAAkBY,SAASC,IAC5BJ,EAAAI,GAAMC,UACV,GAAApC,EAAIqC,WAAY,OAEpB,MAAMC,EAAKF,EACLG,E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QkC,CAAA,IAEK,KAIlB,CACLzC,WACAsC,MAAOnC,WAASmC,GAEpB,gFAvB2C,IACzCI,YAAoC7C,EAAAA,yBAAyBC,4DAyCxD,UAA4B6C,OAAEA,EAAQb,UAAAA,IACrC,MAAA9B,SAAEA,GAAaL,IACd,MAAA,CACLiD,SAAU,CACRC,EACAC,KAGM,MAAAC,SAAcD,WAASH,SAAUA,EACjCK,SAAiBF,WAAShB,YAAaA,EAEzC,GAAC9B,EAASO,MAEP,OAAAwC,EACH/C,EAASO,MAAM0C,iBAAiB,CAC9BN,OAAQI,EACRF,WACAf,UAAWkB,IAEbhD,EAASO,MAAM2C,eAAe,CAC5B7G,WACqB,IAAnB2G,EACI,CAAEpG,KAAM,OAAQkF,UAAWkB,GAC3B,CAAEpG,KAAM,UACdiG,YACD,EAGX"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/shared/utils.ts","../../src/vue/hooks/use-interaction-manager.ts","../../src/vue/components/global-pointer-provider.vue","../../src/vue/components/page-pointer-provider.vue"],"sourcesContent":["import { Position } from '@embedpdf/models';\nimport type {\n InteractionManagerCapability,\n InteractionScope,\n PointerEventHandlers,\n EmbedPdfPointerEvent,\n} from '@embedpdf/plugin-interaction-manager';\n\n/* -------------------------------------------------- */\n/* event → handler key lookup */\n/* -------------------------------------------------- */\ntype K = keyof PointerEventHandlers;\nconst domEventMap: Record<string, K> = {\n pointerdown: 'onPointerDown',\n pointerup: 'onPointerUp',\n pointermove: 'onPointerMove',\n pointerenter: 'onPointerEnter',\n pointerleave: 'onPointerLeave',\n pointercancel: 'onPointerCancel',\n\n mousedown: 'onMouseDown',\n mouseup: 'onMouseUp',\n mousemove: 'onMouseMove',\n mouseenter: 'onMouseEnter',\n mouseleave: 'onMouseLeave',\n mousecancel: 'onMouseCancel',\n\n click: 'onClick',\n dblclick: 'onDoubleClick',\n\n /* touch → pointer fallback for very old browsers */\n touchstart: 'onPointerDown',\n touchend: 'onPointerUp',\n touchmove: 'onPointerMove',\n touchcancel: 'onPointerCancel',\n};\n\nconst pointerEventTypes = [\n 'pointerdown',\n 'pointerup',\n 'pointermove',\n 'pointerenter',\n 'pointerleave',\n 'pointercancel',\n 'mousedown',\n 'mouseup',\n 'mousemove',\n 'mouseenter',\n 'mouseleave',\n 'mousecancel',\n 'click',\n 'dblclick',\n];\n\nconst touchEventTypes = ['touchstart', 'touchend', 'touchmove', 'touchcancel'];\nconst allEventTypes = [...pointerEventTypes, ...touchEventTypes];\n\n/* -------------------------------------------------- */\n/* helper: decide listener options per event type */\n/* -------------------------------------------------- */\nfunction listenerOpts(eventType: string, wantsRawTouch: boolean): AddEventListenerOptions {\n // Only touch events are toggled; pointer/mouse stay non-passive\n return eventType.startsWith('touch') ? { passive: !wantsRawTouch } : { passive: false };\n}\n\n/* -------------------------------------------------- */\n/* createPointerProvider */\n/* -------------------------------------------------- */\nexport function createPointerProvider(\n cap: InteractionManagerCapability,\n scope: InteractionScope,\n element: HTMLElement,\n convertEventToPoint?: (evt: PointerEvent, host: HTMLElement) => Position,\n) {\n /* ---------- live handler set --------------------------------------------------- */\n let active: PointerEventHandlers | null = cap.getHandlersForScope(scope);\n\n /* ---------- helper to compute current wantsRawTouch (defaults to true) --------- */\n const wantsRawTouchNow = () => cap.getActiveInteractionMode()?.wantsRawTouch !== false; // default → true\n\n /* ---------- dynamic listener (re)attachment ------------------------------------ */\n const listeners: Record<string, (evt: Event) => void> = {};\n let attachedWithRawTouch = wantsRawTouchNow(); // remember current mode’s wish\n\n const addListeners = (raw: boolean) => {\n allEventTypes.forEach((type) => {\n const fn = (listeners[type] ??= handleEvent);\n element.addEventListener(type, fn, listenerOpts(type, raw));\n });\n };\n const removeListeners = () => {\n allEventTypes.forEach((type) => {\n const fn = listeners[type];\n if (fn) element.removeEventListener(type, fn);\n });\n };\n\n /* attach for the first time */\n addListeners(attachedWithRawTouch);\n\n /* ---------- mode & handler change hooks --------------------------------------- */\n const stopMode = cap.onModeChange(() => {\n /* cursor baseline update for global wrapper */\n if (scope.type === 'global') {\n const mode = cap.getActiveInteractionMode();\n element.style.cursor = mode?.scope === 'global' ? (mode.cursor ?? 'auto') : 'auto';\n }\n\n active = cap.getHandlersForScope(scope);\n\n /* re-attach listeners if wantsRawTouch toggled */\n const raw = wantsRawTouchNow();\n if (raw !== attachedWithRawTouch) {\n removeListeners();\n addListeners(raw);\n attachedWithRawTouch = raw;\n }\n });\n\n const stopHandler = cap.onHandlerChange(() => {\n active = cap.getHandlersForScope(scope);\n });\n\n /* ---------- cursor sync -------------------------------------------------------- */\n const initialMode = cap.getActiveInteractionMode();\n const initialCursor = cap.getCurrentCursor();\n element.style.cursor =\n scope.type === 'global' && initialMode?.scope !== 'global' ? 'auto' : initialCursor;\n\n const stopCursor = cap.onCursorChange((c) => {\n if (scope.type === 'global' && cap.getActiveInteractionMode()?.scope !== 'global') return;\n element.style.cursor = c;\n });\n\n /* ---------- point conversion --------------------------------------------------- */\n const toPos = (e: { clientX: number; clientY: number }, host: HTMLElement): Position => {\n if (convertEventToPoint) return convertEventToPoint(e as PointerEvent, host);\n const r = host.getBoundingClientRect();\n return { x: e.clientX - r.left, y: e.clientY - r.top };\n };\n\n /* ---------- central event handler --------------------------------------------- */\n function handleEvent(evt: Event) {\n if (cap.isPaused()) return;\n\n const handlerKey = domEventMap[evt.type];\n if (!handlerKey || !active?.[handlerKey]) return;\n\n /* preventDefault only when mode really wants raw touch */\n if (\n evt instanceof TouchEvent &&\n attachedWithRawTouch &&\n (evt.type === 'touchmove' || evt.type === 'touchcancel')\n ) {\n evt.preventDefault();\n }\n\n // ----- normalise ----------------------------------------------------------------\n let pos!: Position;\n let normEvt!: EmbedPdfPointerEvent & {\n target: EventTarget | null;\n currentTarget: EventTarget | null;\n };\n\n if (evt instanceof TouchEvent) {\n const tp =\n evt.type === 'touchend' || evt.type === 'touchcancel'\n ? evt.changedTouches[0]\n : evt.touches[0];\n if (!tp) return;\n\n pos = toPos(tp, element);\n normEvt = {\n clientX: tp.clientX,\n clientY: tp.clientY,\n ctrlKey: evt.ctrlKey,\n shiftKey: evt.shiftKey,\n altKey: evt.altKey,\n metaKey: evt.metaKey,\n target: evt.target,\n currentTarget: evt.currentTarget,\n };\n } else {\n const pe = evt as PointerEvent;\n pos = toPos(pe, element);\n normEvt = pe;\n }\n\n active[handlerKey]?.(pos, normEvt, cap.getActiveMode());\n }\n\n /* ---------- teardown ----------------------------------------------------------- */\n return () => {\n removeListeners();\n stopMode();\n stopCursor();\n stopHandler();\n };\n}\n","import { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport {\n initialState,\n InteractionManagerPlugin,\n InteractionManagerState,\n PointerEventHandlersWithLifecycle,\n} from '@embedpdf/plugin-interaction-manager';\nimport { ref, watchEffect, readonly } from 'vue';\n\nexport const useInteractionManagerPlugin = () =>\n usePlugin<InteractionManagerPlugin>(InteractionManagerPlugin.id);\nexport const useInteractionManagerCapability = () =>\n useCapability<InteractionManagerPlugin>(InteractionManagerPlugin.id);\n\nexport function useInteractionManager() {\n const { provides } = useInteractionManagerCapability();\n const state = ref<InteractionManagerState>(initialState);\n\n watchEffect((onCleanup) => {\n if (provides.value) {\n // onStateChange is a BehaviorEmitter, so it emits the current state upon subscription\n const unsubscribe = provides.value.onStateChange((newState) => {\n state.value = newState;\n });\n onCleanup(unsubscribe);\n }\n });\n\n return {\n provides,\n state: readonly(state),\n };\n}\n\nexport function useCursor() {\n const { provides } = useInteractionManagerCapability();\n return {\n setCursor: (token: string, cursor: string, prio = 0) => {\n provides.value?.setCursor(token, cursor, prio);\n },\n removeCursor: (token: string) => {\n provides.value?.removeCursor(token);\n },\n };\n}\n\ninterface UsePointerHandlersOptions {\n modeId?: string | string[];\n pageIndex?: number;\n}\n\nexport function usePointerHandlers({ modeId, pageIndex }: UsePointerHandlersOptions) {\n const { provides } = useInteractionManagerCapability();\n return {\n register: (\n handlers: PointerEventHandlersWithLifecycle,\n options?: { modeId?: string | string[]; pageIndex?: number },\n ) => {\n // Use provided options or fall back to hook-level options\n const finalModeId = options?.modeId ?? modeId;\n const finalPageIndex = options?.pageIndex ?? pageIndex;\n\n if (!provides.value) return;\n\n return finalModeId\n ? provides.value.registerHandlers({\n modeId: finalModeId,\n handlers,\n pageIndex: finalPageIndex,\n })\n : provides.value.registerAlways({\n scope:\n finalPageIndex !== undefined\n ? { type: 'page', pageIndex: finalPageIndex }\n : { type: 'global' },\n handlers,\n });\n },\n };\n}\n\nexport function useIsPageExclusive() {\n const { provides: cap } = useInteractionManagerCapability();\n const isPageExclusive = ref<boolean>(false);\n\n watchEffect((onCleanup) => {\n if (cap.value) {\n const mode = cap.value.getActiveInteractionMode();\n isPageExclusive.value = mode?.scope === 'page' && !!mode?.exclusive;\n\n const unsubscribe = cap.value.onModeChange(() => {\n if (!cap.value) return;\n const newMode = cap.value.getActiveInteractionMode();\n isPageExclusive.value = newMode?.scope === 'page' && !!newMode?.exclusive;\n });\n onCleanup(unsubscribe);\n }\n });\n\n return readonly(isPageExclusive);\n}\n","<script setup lang=\"ts\">\nimport { ref, watchEffect } from 'vue';\nimport { createPointerProvider } from '../../shared/utils';\nimport { useInteractionManagerCapability } from '../hooks';\n\nconst divRef = ref<HTMLDivElement | null>(null);\nconst { provides: cap } = useInteractionManagerCapability();\n\n// watchEffect automatically handles setup and teardown when capability or element is ready\nwatchEffect((onCleanup) => {\n if (cap.value && divRef.value) {\n const cleanup = createPointerProvider(cap.value, { type: 'global' }, divRef.value);\n onCleanup(cleanup);\n }\n});\n</script>\n\n<template>\n <div\n ref=\"divRef\"\n :style=\"{\n width: '100%',\n height: '100%',\n }\"\n >\n <slot />\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { ref, watchEffect, computed, StyleValue } from 'vue';\nimport { Position, restorePosition } from '@embedpdf/models';\nimport { createPointerProvider } from '../../shared/utils';\nimport { useInteractionManagerCapability, useIsPageExclusive } from '../hooks';\n\ninterface Props {\n pageIndex: number;\n pageWidth: number;\n pageHeight: number;\n rotation: number;\n scale: number;\n convertEventToPoint?: (event: PointerEvent, element: HTMLElement) => Position;\n}\n\nconst props = defineProps<Props>();\n\nconst divRef = ref<HTMLDivElement | null>(null);\nconst { provides: cap } = useInteractionManagerCapability();\nconst isPageExclusive = useIsPageExclusive();\n\nconst defaultConvertEventToPoint = computed(() => {\n return (event: PointerEvent, element: HTMLElement): Position => {\n const rect = element.getBoundingClientRect();\n const displayPoint = {\n x: event.clientX - rect.left,\n y: event.clientY - rect.top,\n };\n return restorePosition(\n { width: props.pageWidth, height: props.pageHeight },\n displayPoint,\n props.rotation,\n props.scale,\n );\n };\n});\n\nwatchEffect((onCleanup) => {\n if (cap.value && divRef.value) {\n const cleanup = createPointerProvider(\n cap.value,\n { type: 'page', pageIndex: props.pageIndex },\n divRef.value,\n props.convertEventToPoint || defaultConvertEventToPoint.value,\n );\n onCleanup(cleanup);\n }\n});\n</script>\n\n<template>\n <div ref=\"divRef\">\n <slot />\n <div\n v-if=\"isPageExclusive\"\n :style=\"{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, zIndex: 10 }\"\n />\n </div>\n</template>\n"],"names":["domEventMap","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","mousedown","mouseup","mousemove","mouseenter","mouseleave","mousecancel","click","dblclick","touchstart","touchend","touchmove","touchcancel","allEventTypes","createPointerProvider","cap","scope","element","convertEventToPoint","active","getHandlersForScope","wantsRawTouchNow","_a","getActiveInteractionMode","wantsRawTouch","listeners","attachedWithRawTouch","addListeners","raw","forEach","type","fn","handleEvent","addEventListener","startsWith","passive","removeListeners","removeEventListener","stopMode","onModeChange","mode","style","cursor","stopHandler","onHandlerChange","initialMode","initialCursor","getCurrentCursor","stopCursor","onCursorChange","c","toPos","e","host","r","getBoundingClientRect","x","clientX","left","y","clientY","top","evt","isPaused","handlerKey","pos","normEvt","TouchEvent","preventDefault","tp","changedTouches","touches","ctrlKey","shiftKey","altKey","metaKey","target","currentTarget","pe","call","getActiveMode","useInteractionManagerCapability","useCapability","InteractionManagerPlugin","id","useIsPageExclusive","provides","isPageExclusive","ref","readonly","vue$1","watchEffect","onCleanup","value","exclusive","newMode","divRef","_createElementBlock","createElementBlock","_renderSlot","_ctx","$slots","props","__props","defaultConvertEventToPoint","computed","event","rect","displayPoint","restorePosition","width","pageWidth","height","pageHeight","rotation","scale","pageIndex","_unref","_openBlock","_hoisted_1","setCursor","token","prio","removeCursor","state","initialState","onStateChange","newState","usePlugin","modeId","register","handlers","options","finalModeId","finalPageIndex","registerHandlers","registerAlways"],"mappings":"uNAYMA,EAAiC,CACrCC,YAAa,gBACbC,UAAW,cACXC,YAAa,gBACbC,aAAc,iBACdC,aAAc,iBACdC,cAAe,kBAEfC,UAAW,cACXC,QAAS,YACTC,UAAW,cACXC,WAAY,eACZC,WAAY,eACZC,YAAa,gBAEbC,MAAO,UACPC,SAAU,gBAGVC,WAAY,gBACZC,SAAU,cACVC,UAAW,gBACXC,YAAa,mBAqBTC,EAAgB,CAjBpB,cACA,YACA,cACA,eACA,eACA,gBACA,YACA,UACA,YACA,aACA,aACA,cACA,QACA,WAGuB,aAAc,WAAY,YAAa,eAczD,SAASC,EACdC,EACAC,EACAC,EACAC,GAGI,IAAAC,EAAsCJ,EAAIK,oBAAoBJ,GAGlE,MAAMK,EAAmB,WAAU,OAA8C,KAAlD,OAAIC,EAAAP,EAAAQ,iCAAJ,EAAAD,EAAgCE,cAAkB,EAG3EC,EAAkD,CAAC,EACzD,IAAIC,EAAuBL,IAErB,MAAAM,EAAgBC,IACNf,EAAAgB,SAASC,IACf,MAAAC,EAAMN,EAAoBK,KAAAL,EAAAK,GAAAE,GA1BtC,IAAyCR,EA2BnCP,EAAQgB,iBAAiBH,EAAMC,GA3BIP,EA2BmBI,EAANE,EAzBnCI,WAAW,SAAW,CAAEC,SAAUX,GAAkB,CAAEW,SAAS,IAyBlB,GAC3D,EAEGC,EAAkB,KACRvB,EAAAgB,SAASC,IACf,MAAAC,EAAKN,EAAUK,GACjBC,GAAId,EAAQoB,oBAAoBP,EAAMC,EAAE,GAC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iC,eAAeC,IAChDH,EAAM/B,MAAQkC,CAAA,IAEK,KAIlB,CACLzC,WACAsC,MAAOnC,WAASmC,GAEpB,gFAvB2C,IACzCI,YAAoC7C,EAAAA,yBAAyBC,4DAyCxD,UAA4B6C,OAAEA,EAAQb,UAAAA,IACrC,MAAA9B,SAAEA,GAAaL,IACd,MAAA,CACLiD,SAAU,CACRC,EACAC,KAGM,MAAAC,SAAcD,WAASH,SAAUA,EACjCK,SAAiBF,WAAShB,YAAaA,EAEzC,GAAC9B,EAASO,MAEP,OAAAwC,EACH/C,EAASO,MAAM0C,iBAAiB,CAC9BN,OAAQI,EACRF,WACAf,UAAWkB,IAEbhD,EAASO,MAAM2C,eAAe,CAC5BxH,WACqB,IAAnBsH,EACI,CAAExG,KAAM,OAAQsF,UAAWkB,GAC3B,CAAExG,KAAM,UACdqG,YACD,EAGX"}
|
package/dist/vue/index.js
CHANGED
|
@@ -2,63 +2,131 @@ import { ref, watchEffect, readonly, defineComponent, createElementBlock, openBl
|
|
|
2
2
|
import { useCapability, usePlugin } from "@embedpdf/core/vue";
|
|
3
3
|
import { InteractionManagerPlugin, initialState } from "@embedpdf/plugin-interaction-manager";
|
|
4
4
|
import { restorePosition } from "@embedpdf/models";
|
|
5
|
+
const domEventMap = {
|
|
6
|
+
pointerdown: "onPointerDown",
|
|
7
|
+
pointerup: "onPointerUp",
|
|
8
|
+
pointermove: "onPointerMove",
|
|
9
|
+
pointerenter: "onPointerEnter",
|
|
10
|
+
pointerleave: "onPointerLeave",
|
|
11
|
+
pointercancel: "onPointerCancel",
|
|
12
|
+
mousedown: "onMouseDown",
|
|
13
|
+
mouseup: "onMouseUp",
|
|
14
|
+
mousemove: "onMouseMove",
|
|
15
|
+
mouseenter: "onMouseEnter",
|
|
16
|
+
mouseleave: "onMouseLeave",
|
|
17
|
+
mousecancel: "onMouseCancel",
|
|
18
|
+
click: "onClick",
|
|
19
|
+
dblclick: "onDoubleClick",
|
|
20
|
+
/* touch → pointer fallback for very old browsers */
|
|
21
|
+
touchstart: "onPointerDown",
|
|
22
|
+
touchend: "onPointerUp",
|
|
23
|
+
touchmove: "onPointerMove",
|
|
24
|
+
touchcancel: "onPointerCancel"
|
|
25
|
+
};
|
|
26
|
+
const pointerEventTypes = [
|
|
27
|
+
"pointerdown",
|
|
28
|
+
"pointerup",
|
|
29
|
+
"pointermove",
|
|
30
|
+
"pointerenter",
|
|
31
|
+
"pointerleave",
|
|
32
|
+
"pointercancel",
|
|
33
|
+
"mousedown",
|
|
34
|
+
"mouseup",
|
|
35
|
+
"mousemove",
|
|
36
|
+
"mouseenter",
|
|
37
|
+
"mouseleave",
|
|
38
|
+
"mousecancel",
|
|
39
|
+
"click",
|
|
40
|
+
"dblclick"
|
|
41
|
+
];
|
|
42
|
+
const touchEventTypes = ["touchstart", "touchend", "touchmove", "touchcancel"];
|
|
43
|
+
const allEventTypes = [...pointerEventTypes, ...touchEventTypes];
|
|
44
|
+
function listenerOpts(eventType, wantsRawTouch) {
|
|
45
|
+
return eventType.startsWith("touch") ? { passive: !wantsRawTouch } : { passive: false };
|
|
46
|
+
}
|
|
5
47
|
function createPointerProvider(cap, scope, element, convertEventToPoint) {
|
|
6
48
|
let active = cap.getHandlersForScope(scope);
|
|
49
|
+
const wantsRawTouchNow = () => {
|
|
50
|
+
var _a;
|
|
51
|
+
return ((_a = cap.getActiveInteractionMode()) == null ? void 0 : _a.wantsRawTouch) !== false;
|
|
52
|
+
};
|
|
53
|
+
const listeners = {};
|
|
54
|
+
let attachedWithRawTouch = wantsRawTouchNow();
|
|
55
|
+
const addListeners = (raw) => {
|
|
56
|
+
allEventTypes.forEach((type) => {
|
|
57
|
+
const fn = listeners[type] ?? (listeners[type] = handleEvent);
|
|
58
|
+
element.addEventListener(type, fn, listenerOpts(type, raw));
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const removeListeners = () => {
|
|
62
|
+
allEventTypes.forEach((type) => {
|
|
63
|
+
const fn = listeners[type];
|
|
64
|
+
if (fn) element.removeEventListener(type, fn);
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
addListeners(attachedWithRawTouch);
|
|
7
68
|
const stopMode = cap.onModeChange(() => {
|
|
8
69
|
if (scope.type === "global") {
|
|
9
70
|
const mode = cap.getActiveInteractionMode();
|
|
10
71
|
element.style.cursor = (mode == null ? void 0 : mode.scope) === "global" ? mode.cursor ?? "auto" : "auto";
|
|
11
72
|
}
|
|
12
73
|
active = cap.getHandlersForScope(scope);
|
|
74
|
+
const raw = wantsRawTouchNow();
|
|
75
|
+
if (raw !== attachedWithRawTouch) {
|
|
76
|
+
removeListeners();
|
|
77
|
+
addListeners(raw);
|
|
78
|
+
attachedWithRawTouch = raw;
|
|
79
|
+
}
|
|
13
80
|
});
|
|
14
81
|
const stopHandler = cap.onHandlerChange(() => {
|
|
15
82
|
active = cap.getHandlersForScope(scope);
|
|
16
83
|
});
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
element.style.cursor = (modeNow == null ? void 0 : modeNow.scope) === "global" ? cursorNow : "auto";
|
|
21
|
-
} else {
|
|
22
|
-
element.style.cursor = cursorNow;
|
|
23
|
-
}
|
|
84
|
+
const initialMode = cap.getActiveInteractionMode();
|
|
85
|
+
const initialCursor = cap.getCurrentCursor();
|
|
86
|
+
element.style.cursor = scope.type === "global" && (initialMode == null ? void 0 : initialMode.scope) !== "global" ? "auto" : initialCursor;
|
|
24
87
|
const stopCursor = cap.onCursorChange((c) => {
|
|
25
88
|
var _a;
|
|
26
|
-
if (scope.type === "global")
|
|
27
|
-
const isGlobalMode = ((_a = cap.getActiveInteractionMode()) == null ? void 0 : _a.scope) === "global";
|
|
28
|
-
if (!isGlobalMode) return;
|
|
29
|
-
}
|
|
89
|
+
if (scope.type === "global" && ((_a = cap.getActiveInteractionMode()) == null ? void 0 : _a.scope) !== "global") return;
|
|
30
90
|
element.style.cursor = c;
|
|
31
91
|
});
|
|
32
|
-
const domEvent = {
|
|
33
|
-
onPointerDown: "pointerdown",
|
|
34
|
-
onPointerUp: "pointerup",
|
|
35
|
-
onPointerMove: "pointermove",
|
|
36
|
-
onPointerEnter: "pointerenter",
|
|
37
|
-
onPointerLeave: "pointerleave",
|
|
38
|
-
onPointerCancel: "pointercancel",
|
|
39
|
-
onClick: "click",
|
|
40
|
-
onDoubleClick: "dblclick"
|
|
41
|
-
};
|
|
42
|
-
const listeners = {};
|
|
43
92
|
const toPos = (e, host) => {
|
|
44
93
|
if (convertEventToPoint) return convertEventToPoint(e, host);
|
|
45
94
|
const r = host.getBoundingClientRect();
|
|
46
95
|
return { x: e.clientX - r.left, y: e.clientY - r.top };
|
|
47
96
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
97
|
+
function handleEvent(evt) {
|
|
98
|
+
var _a;
|
|
99
|
+
if (cap.isPaused()) return;
|
|
100
|
+
const handlerKey = domEventMap[evt.type];
|
|
101
|
+
if (!handlerKey || !(active == null ? void 0 : active[handlerKey])) return;
|
|
102
|
+
if (evt instanceof TouchEvent && attachedWithRawTouch && (evt.type === "touchmove" || evt.type === "touchcancel")) {
|
|
103
|
+
evt.preventDefault();
|
|
104
|
+
}
|
|
105
|
+
let pos;
|
|
106
|
+
let normEvt;
|
|
107
|
+
if (evt instanceof TouchEvent) {
|
|
108
|
+
const tp = evt.type === "touchend" || evt.type === "touchcancel" ? evt.changedTouches[0] : evt.touches[0];
|
|
109
|
+
if (!tp) return;
|
|
110
|
+
pos = toPos(tp, element);
|
|
111
|
+
normEvt = {
|
|
112
|
+
clientX: tp.clientX,
|
|
113
|
+
clientY: tp.clientY,
|
|
114
|
+
ctrlKey: evt.ctrlKey,
|
|
115
|
+
shiftKey: evt.shiftKey,
|
|
116
|
+
altKey: evt.altKey,
|
|
117
|
+
metaKey: evt.metaKey,
|
|
118
|
+
target: evt.target,
|
|
119
|
+
currentTarget: evt.currentTarget
|
|
120
|
+
};
|
|
121
|
+
} else {
|
|
52
122
|
const pe = evt;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
}
|
|
123
|
+
pos = toPos(pe, element);
|
|
124
|
+
normEvt = pe;
|
|
125
|
+
}
|
|
126
|
+
(_a = active[handlerKey]) == null ? void 0 : _a.call(active, pos, normEvt, cap.getActiveMode());
|
|
127
|
+
}
|
|
58
128
|
return () => {
|
|
59
|
-
|
|
60
|
-
(k) => element.removeEventListener(domEvent[k], listeners[k])
|
|
61
|
-
);
|
|
129
|
+
removeListeners();
|
|
62
130
|
stopMode();
|
|
63
131
|
stopCursor();
|
|
64
132
|
stopHandler();
|
package/dist/vue/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/shared/utils.ts","../../src/vue/hooks/use-interaction-manager.ts","../../src/vue/components/global-pointer-provider.vue","../../src/vue/components/page-pointer-provider.vue"],"sourcesContent":["import { Position } from '@embedpdf/models';\nimport type {\n InteractionManagerCapability,\n InteractionScope,\n PointerEventHandlers,\n} from '@embedpdf/plugin-interaction-manager';\n\n/**\n * Hook one DOM element into the interaction-manager.\n * – keeps handlers & cursor in-sync with the current mode\n * – returns a teardown fn for React/Preact effects\n */\nexport function createPointerProvider(\n cap: InteractionManagerCapability,\n scope: InteractionScope,\n element: HTMLElement,\n convertEventToPoint?: (evt: PointerEvent, host: HTMLElement) => Position,\n) {\n /* ------------------------------------------------------------------ */\n /* active handler set – hot-swapped on every mode change */\n /* ------------------------------------------------------------------ */\n let active: PointerEventHandlers | null = cap.getHandlersForScope(scope);\n\n const stopMode = cap.onModeChange(() => {\n if (scope.type === 'global') {\n const mode = cap.getActiveInteractionMode();\n element.style.cursor = mode?.scope === 'global' ? (mode.cursor ?? 'auto') : 'auto';\n }\n active = cap.getHandlersForScope(scope);\n });\n\n const stopHandler = cap.onHandlerChange(() => {\n active = cap.getHandlersForScope(scope);\n });\n\n /* ------------------------------------------------------------------ */\n /* cursor */\n /* ------------------------------------------------------------------ */\n const modeNow = cap.getActiveInteractionMode();\n const cursorNow = cap.getCurrentCursor();\n\n /** initial cursor -------------------------------------------------- */\n if (scope.type === 'global') {\n // global wrapper only shows the cursor while a *global* mode is active\n element.style.cursor = modeNow?.scope === 'global' ? cursorNow : 'auto';\n } else {\n // page wrappers always mirror the latest cursor\n element.style.cursor = cursorNow;\n }\n\n const stopCursor = cap.onCursorChange((c) => {\n /** ❖ Propagation rule\n * ─────────────────\n * • global provider updates its cursor *only* while the active\n * mode itself is ‘global’.\n * • page providers always sync (so they show the cursor during\n * a global mode as well). */\n if (scope.type === 'global') {\n const isGlobalMode = cap.getActiveInteractionMode()?.scope === 'global';\n if (!isGlobalMode) return; // active mode is page-scoped → ignore\n }\n element.style.cursor = c;\n });\n\n /* ------------------------------------------------------------------ */\n /* event wiring */\n /* ------------------------------------------------------------------ */\n type K = keyof PointerEventHandlers;\n const domEvent: Record<K, keyof HTMLElementEventMap> = {\n onPointerDown: 'pointerdown',\n onPointerUp: 'pointerup',\n onPointerMove: 'pointermove',\n onPointerEnter: 'pointerenter',\n onPointerLeave: 'pointerleave',\n onPointerCancel: 'pointercancel',\n onClick: 'click',\n onDoubleClick: 'dblclick',\n };\n\n /* one stable EventListener per key -> needed for removeEventListener */\n const listeners: Partial<Record<K, EventListener>> = {};\n\n const toPos = (e: PointerEvent, host: HTMLElement): Position => {\n if (convertEventToPoint) return convertEventToPoint(e, host);\n const r = host.getBoundingClientRect();\n return { x: e.clientX - r.left, y: e.clientY - r.top };\n };\n\n (Object.keys(domEvent) as K[]).forEach((k) => {\n listeners[k] = (evt: Event) => {\n if (cap.isPaused()) return;\n\n const pe = evt as PointerEvent; // safe – we only attach to pointer*\n const currentModeId = cap.getActiveMode();\n active?.[k]?.(toPos(pe, element), pe, currentModeId);\n /* if you need to stop default behaviour when no handler is active:\n * if (!active?.[k]) pe.preventDefault(); */\n };\n element.addEventListener(domEvent[k], listeners[k]!);\n });\n\n /* ------------------------------------------------------------------ */\n /* teardown */\n /* ------------------------------------------------------------------ */\n return () => {\n (Object.keys(domEvent) as K[]).forEach((k) =>\n element.removeEventListener(domEvent[k], listeners[k]!),\n );\n stopMode();\n stopCursor();\n stopHandler();\n };\n}\n","import { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport {\n initialState,\n InteractionManagerPlugin,\n InteractionManagerState,\n PointerEventHandlersWithLifecycle,\n} from '@embedpdf/plugin-interaction-manager';\nimport { ref, watchEffect, readonly } from 'vue';\n\nexport const useInteractionManagerPlugin = () =>\n usePlugin<InteractionManagerPlugin>(InteractionManagerPlugin.id);\nexport const useInteractionManagerCapability = () =>\n useCapability<InteractionManagerPlugin>(InteractionManagerPlugin.id);\n\nexport function useInteractionManager() {\n const { provides } = useInteractionManagerCapability();\n const state = ref<InteractionManagerState>(initialState);\n\n watchEffect((onCleanup) => {\n if (provides.value) {\n // onStateChange is a BehaviorEmitter, so it emits the current state upon subscription\n const unsubscribe = provides.value.onStateChange((newState) => {\n state.value = newState;\n });\n onCleanup(unsubscribe);\n }\n });\n\n return {\n provides,\n state: readonly(state),\n };\n}\n\nexport function useCursor() {\n const { provides } = useInteractionManagerCapability();\n return {\n setCursor: (token: string, cursor: string, prio = 0) => {\n provides.value?.setCursor(token, cursor, prio);\n },\n removeCursor: (token: string) => {\n provides.value?.removeCursor(token);\n },\n };\n}\n\ninterface UsePointerHandlersOptions {\n modeId?: string | string[];\n pageIndex?: number;\n}\n\nexport function usePointerHandlers({ modeId, pageIndex }: UsePointerHandlersOptions) {\n const { provides } = useInteractionManagerCapability();\n return {\n register: (\n handlers: PointerEventHandlersWithLifecycle,\n options?: { modeId?: string | string[]; pageIndex?: number },\n ) => {\n // Use provided options or fall back to hook-level options\n const finalModeId = options?.modeId ?? modeId;\n const finalPageIndex = options?.pageIndex ?? pageIndex;\n\n if (!provides.value) return;\n\n return finalModeId\n ? provides.value.registerHandlers({\n modeId: finalModeId,\n handlers,\n pageIndex: finalPageIndex,\n })\n : provides.value.registerAlways({\n scope:\n finalPageIndex !== undefined\n ? { type: 'page', pageIndex: finalPageIndex }\n : { type: 'global' },\n handlers,\n });\n },\n };\n}\n\nexport function useIsPageExclusive() {\n const { provides: cap } = useInteractionManagerCapability();\n const isPageExclusive = ref<boolean>(false);\n\n watchEffect((onCleanup) => {\n if (cap.value) {\n const mode = cap.value.getActiveInteractionMode();\n isPageExclusive.value = mode?.scope === 'page' && !!mode?.exclusive;\n\n const unsubscribe = cap.value.onModeChange(() => {\n if (!cap.value) return;\n const newMode = cap.value.getActiveInteractionMode();\n isPageExclusive.value = newMode?.scope === 'page' && !!newMode?.exclusive;\n });\n onCleanup(unsubscribe);\n }\n });\n\n return readonly(isPageExclusive);\n}\n","<script setup lang=\"ts\">\nimport { ref, watchEffect } from 'vue';\nimport { createPointerProvider } from '../../shared/utils';\nimport { useInteractionManagerCapability } from '../hooks';\n\nconst divRef = ref<HTMLDivElement | null>(null);\nconst { provides: cap } = useInteractionManagerCapability();\n\n// watchEffect automatically handles setup and teardown when capability or element is ready\nwatchEffect((onCleanup) => {\n if (cap.value && divRef.value) {\n const cleanup = createPointerProvider(cap.value, { type: 'global' }, divRef.value);\n onCleanup(cleanup);\n }\n});\n</script>\n\n<template>\n <div\n ref=\"divRef\"\n :style=\"{\n width: '100%',\n height: '100%',\n }\"\n >\n <slot />\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { ref, watchEffect, computed, StyleValue } from 'vue';\nimport { Position, restorePosition } from '@embedpdf/models';\nimport { createPointerProvider } from '../../shared/utils';\nimport { useInteractionManagerCapability, useIsPageExclusive } from '../hooks';\n\ninterface Props {\n pageIndex: number;\n pageWidth: number;\n pageHeight: number;\n rotation: number;\n scale: number;\n convertEventToPoint?: (event: PointerEvent, element: HTMLElement) => Position;\n}\n\nconst props = defineProps<Props>();\n\nconst divRef = ref<HTMLDivElement | null>(null);\nconst { provides: cap } = useInteractionManagerCapability();\nconst isPageExclusive = useIsPageExclusive();\n\nconst defaultConvertEventToPoint = computed(() => {\n return (event: PointerEvent, element: HTMLElement): Position => {\n const rect = element.getBoundingClientRect();\n const displayPoint = {\n x: event.clientX - rect.left,\n y: event.clientY - rect.top,\n };\n return restorePosition(\n { width: props.pageWidth, height: props.pageHeight },\n displayPoint,\n props.rotation,\n props.scale,\n );\n };\n});\n\nwatchEffect((onCleanup) => {\n if (cap.value && divRef.value) {\n const cleanup = createPointerProvider(\n cap.value,\n { type: 'page', pageIndex: props.pageIndex },\n divRef.value,\n props.convertEventToPoint || defaultConvertEventToPoint.value,\n );\n onCleanup(cleanup);\n }\n});\n</script>\n\n<template>\n <div ref=\"divRef\">\n <slot />\n <div\n v-if=\"isPageExclusive\"\n :style=\"{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, zIndex: 10 }\"\n />\n </div>\n</template>\n"],"names":["_createElementBlock","_renderSlot","_unref","_openBlock"],"mappings":";;;;AAYO,SAAS,sBACd,KACA,OACA,SACA,qBACA;AAII,MAAA,SAAsC,IAAI,oBAAoB,KAAK;AAEjE,QAAA,WAAW,IAAI,aAAa,MAAM;AAClC,QAAA,MAAM,SAAS,UAAU;AACrB,YAAA,OAAO,IAAI,yBAAyB;AAC1C,cAAQ,MAAM,UAAS,6BAAM,WAAU,WAAY,KAAK,UAAU,SAAU;AAAA,IAAA;AAErE,aAAA,IAAI,oBAAoB,KAAK;AAAA,EAAA,CACvC;AAEK,QAAA,cAAc,IAAI,gBAAgB,MAAM;AACnC,aAAA,IAAI,oBAAoB,KAAK;AAAA,EAAA,CACvC;AAKK,QAAA,UAAU,IAAI,yBAAyB;AACvC,QAAA,YAAY,IAAI,iBAAiB;AAGnC,MAAA,MAAM,SAAS,UAAU;AAE3B,YAAQ,MAAM,UAAS,mCAAS,WAAU,WAAW,YAAY;AAAA,EAAA,OAC5D;AAEL,YAAQ,MAAM,SAAS;AAAA,EAAA;AAGzB,QAAM,aAAa,IAAI,eAAe,CAAC,MAAM;;AAOvC,QAAA,MAAM,SAAS,UAAU;AAC3B,YAAM,iBAAe,SAAI,yBAAyB,MAA7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;AAAA,UACd,IAAI;AAAA,UACJ,EAAE,MAAM,QAAQ,WAAW,MAAM,UAAU;AAAA,UAC3C,OAAO;AAAA,UACP,MAAM,uBAAuB,2BAA2B;AAAA,QAC1D;AACA,kBAAU,OAAO;AAAA,MAAA;AAAA,IACnB,CACD;;0BAICD,mBAMM,OAAA;AAAA,iBANG;AAAA,QAAJ,KAAI;AAAA,MAAA;QACPC,WAAQ,KAAA,QAAA,SAAA;AAAA,QAEAC,MAAe,eAAA,KADvBC,aAAAH,mBAGE,OAHF,UAGE;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/shared/utils.ts","../../src/vue/hooks/use-interaction-manager.ts","../../src/vue/components/global-pointer-provider.vue","../../src/vue/components/page-pointer-provider.vue"],"sourcesContent":["import { Position } from '@embedpdf/models';\nimport type {\n InteractionManagerCapability,\n InteractionScope,\n PointerEventHandlers,\n EmbedPdfPointerEvent,\n} from '@embedpdf/plugin-interaction-manager';\n\n/* -------------------------------------------------- */\n/* event → handler key lookup */\n/* -------------------------------------------------- */\ntype K = keyof PointerEventHandlers;\nconst domEventMap: Record<string, K> = {\n pointerdown: 'onPointerDown',\n pointerup: 'onPointerUp',\n pointermove: 'onPointerMove',\n pointerenter: 'onPointerEnter',\n pointerleave: 'onPointerLeave',\n pointercancel: 'onPointerCancel',\n\n mousedown: 'onMouseDown',\n mouseup: 'onMouseUp',\n mousemove: 'onMouseMove',\n mouseenter: 'onMouseEnter',\n mouseleave: 'onMouseLeave',\n mousecancel: 'onMouseCancel',\n\n click: 'onClick',\n dblclick: 'onDoubleClick',\n\n /* touch → pointer fallback for very old browsers */\n touchstart: 'onPointerDown',\n touchend: 'onPointerUp',\n touchmove: 'onPointerMove',\n touchcancel: 'onPointerCancel',\n};\n\nconst pointerEventTypes = [\n 'pointerdown',\n 'pointerup',\n 'pointermove',\n 'pointerenter',\n 'pointerleave',\n 'pointercancel',\n 'mousedown',\n 'mouseup',\n 'mousemove',\n 'mouseenter',\n 'mouseleave',\n 'mousecancel',\n 'click',\n 'dblclick',\n];\n\nconst touchEventTypes = ['touchstart', 'touchend', 'touchmove', 'touchcancel'];\nconst allEventTypes = [...pointerEventTypes, ...touchEventTypes];\n\n/* -------------------------------------------------- */\n/* helper: decide listener options per event type */\n/* -------------------------------------------------- */\nfunction listenerOpts(eventType: string, wantsRawTouch: boolean): AddEventListenerOptions {\n // Only touch events are toggled; pointer/mouse stay non-passive\n return eventType.startsWith('touch') ? { passive: !wantsRawTouch } : { passive: false };\n}\n\n/* -------------------------------------------------- */\n/* createPointerProvider */\n/* -------------------------------------------------- */\nexport function createPointerProvider(\n cap: InteractionManagerCapability,\n scope: InteractionScope,\n element: HTMLElement,\n convertEventToPoint?: (evt: PointerEvent, host: HTMLElement) => Position,\n) {\n /* ---------- live handler set --------------------------------------------------- */\n let active: PointerEventHandlers | null = cap.getHandlersForScope(scope);\n\n /* ---------- helper to compute current wantsRawTouch (defaults to true) --------- */\n const wantsRawTouchNow = () => cap.getActiveInteractionMode()?.wantsRawTouch !== false; // default → true\n\n /* ---------- dynamic listener (re)attachment ------------------------------------ */\n const listeners: Record<string, (evt: Event) => void> = {};\n let attachedWithRawTouch = wantsRawTouchNow(); // remember current mode’s wish\n\n const addListeners = (raw: boolean) => {\n allEventTypes.forEach((type) => {\n const fn = (listeners[type] ??= handleEvent);\n element.addEventListener(type, fn, listenerOpts(type, raw));\n });\n };\n const removeListeners = () => {\n allEventTypes.forEach((type) => {\n const fn = listeners[type];\n if (fn) element.removeEventListener(type, fn);\n });\n };\n\n /* attach for the first time */\n addListeners(attachedWithRawTouch);\n\n /* ---------- mode & handler change hooks --------------------------------------- */\n const stopMode = cap.onModeChange(() => {\n /* cursor baseline update for global wrapper */\n if (scope.type === 'global') {\n const mode = cap.getActiveInteractionMode();\n element.style.cursor = mode?.scope === 'global' ? (mode.cursor ?? 'auto') : 'auto';\n }\n\n active = cap.getHandlersForScope(scope);\n\n /* re-attach listeners if wantsRawTouch toggled */\n const raw = wantsRawTouchNow();\n if (raw !== attachedWithRawTouch) {\n removeListeners();\n addListeners(raw);\n attachedWithRawTouch = raw;\n }\n });\n\n const stopHandler = cap.onHandlerChange(() => {\n active = cap.getHandlersForScope(scope);\n });\n\n /* ---------- cursor sync -------------------------------------------------------- */\n const initialMode = cap.getActiveInteractionMode();\n const initialCursor = cap.getCurrentCursor();\n element.style.cursor =\n scope.type === 'global' && initialMode?.scope !== 'global' ? 'auto' : initialCursor;\n\n const stopCursor = cap.onCursorChange((c) => {\n if (scope.type === 'global' && cap.getActiveInteractionMode()?.scope !== 'global') return;\n element.style.cursor = c;\n });\n\n /* ---------- point conversion --------------------------------------------------- */\n const toPos = (e: { clientX: number; clientY: number }, host: HTMLElement): Position => {\n if (convertEventToPoint) return convertEventToPoint(e as PointerEvent, host);\n const r = host.getBoundingClientRect();\n return { x: e.clientX - r.left, y: e.clientY - r.top };\n };\n\n /* ---------- central event handler --------------------------------------------- */\n function handleEvent(evt: Event) {\n if (cap.isPaused()) return;\n\n const handlerKey = domEventMap[evt.type];\n if (!handlerKey || !active?.[handlerKey]) return;\n\n /* preventDefault only when mode really wants raw touch */\n if (\n evt instanceof TouchEvent &&\n attachedWithRawTouch &&\n (evt.type === 'touchmove' || evt.type === 'touchcancel')\n ) {\n evt.preventDefault();\n }\n\n // ----- normalise ----------------------------------------------------------------\n let pos!: Position;\n let normEvt!: EmbedPdfPointerEvent & {\n target: EventTarget | null;\n currentTarget: EventTarget | null;\n };\n\n if (evt instanceof TouchEvent) {\n const tp =\n evt.type === 'touchend' || evt.type === 'touchcancel'\n ? evt.changedTouches[0]\n : evt.touches[0];\n if (!tp) return;\n\n pos = toPos(tp, element);\n normEvt = {\n clientX: tp.clientX,\n clientY: tp.clientY,\n ctrlKey: evt.ctrlKey,\n shiftKey: evt.shiftKey,\n altKey: evt.altKey,\n metaKey: evt.metaKey,\n target: evt.target,\n currentTarget: evt.currentTarget,\n };\n } else {\n const pe = evt as PointerEvent;\n pos = toPos(pe, element);\n normEvt = pe;\n }\n\n active[handlerKey]?.(pos, normEvt, cap.getActiveMode());\n }\n\n /* ---------- teardown ----------------------------------------------------------- */\n return () => {\n removeListeners();\n stopMode();\n stopCursor();\n stopHandler();\n };\n}\n","import { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport {\n initialState,\n InteractionManagerPlugin,\n InteractionManagerState,\n PointerEventHandlersWithLifecycle,\n} from '@embedpdf/plugin-interaction-manager';\nimport { ref, watchEffect, readonly } from 'vue';\n\nexport const useInteractionManagerPlugin = () =>\n usePlugin<InteractionManagerPlugin>(InteractionManagerPlugin.id);\nexport const useInteractionManagerCapability = () =>\n useCapability<InteractionManagerPlugin>(InteractionManagerPlugin.id);\n\nexport function useInteractionManager() {\n const { provides } = useInteractionManagerCapability();\n const state = ref<InteractionManagerState>(initialState);\n\n watchEffect((onCleanup) => {\n if (provides.value) {\n // onStateChange is a BehaviorEmitter, so it emits the current state upon subscription\n const unsubscribe = provides.value.onStateChange((newState) => {\n state.value = newState;\n });\n onCleanup(unsubscribe);\n }\n });\n\n return {\n provides,\n state: readonly(state),\n };\n}\n\nexport function useCursor() {\n const { provides } = useInteractionManagerCapability();\n return {\n setCursor: (token: string, cursor: string, prio = 0) => {\n provides.value?.setCursor(token, cursor, prio);\n },\n removeCursor: (token: string) => {\n provides.value?.removeCursor(token);\n },\n };\n}\n\ninterface UsePointerHandlersOptions {\n modeId?: string | string[];\n pageIndex?: number;\n}\n\nexport function usePointerHandlers({ modeId, pageIndex }: UsePointerHandlersOptions) {\n const { provides } = useInteractionManagerCapability();\n return {\n register: (\n handlers: PointerEventHandlersWithLifecycle,\n options?: { modeId?: string | string[]; pageIndex?: number },\n ) => {\n // Use provided options or fall back to hook-level options\n const finalModeId = options?.modeId ?? modeId;\n const finalPageIndex = options?.pageIndex ?? pageIndex;\n\n if (!provides.value) return;\n\n return finalModeId\n ? provides.value.registerHandlers({\n modeId: finalModeId,\n handlers,\n pageIndex: finalPageIndex,\n })\n : provides.value.registerAlways({\n scope:\n finalPageIndex !== undefined\n ? { type: 'page', pageIndex: finalPageIndex }\n : { type: 'global' },\n handlers,\n });\n },\n };\n}\n\nexport function useIsPageExclusive() {\n const { provides: cap } = useInteractionManagerCapability();\n const isPageExclusive = ref<boolean>(false);\n\n watchEffect((onCleanup) => {\n if (cap.value) {\n const mode = cap.value.getActiveInteractionMode();\n isPageExclusive.value = mode?.scope === 'page' && !!mode?.exclusive;\n\n const unsubscribe = cap.value.onModeChange(() => {\n if (!cap.value) return;\n const newMode = cap.value.getActiveInteractionMode();\n isPageExclusive.value = newMode?.scope === 'page' && !!newMode?.exclusive;\n });\n onCleanup(unsubscribe);\n }\n });\n\n return readonly(isPageExclusive);\n}\n","<script setup lang=\"ts\">\nimport { ref, watchEffect } from 'vue';\nimport { createPointerProvider } from '../../shared/utils';\nimport { useInteractionManagerCapability } from '../hooks';\n\nconst divRef = ref<HTMLDivElement | null>(null);\nconst { provides: cap } = useInteractionManagerCapability();\n\n// watchEffect automatically handles setup and teardown when capability or element is ready\nwatchEffect((onCleanup) => {\n if (cap.value && divRef.value) {\n const cleanup = createPointerProvider(cap.value, { type: 'global' }, divRef.value);\n onCleanup(cleanup);\n }\n});\n</script>\n\n<template>\n <div\n ref=\"divRef\"\n :style=\"{\n width: '100%',\n height: '100%',\n }\"\n >\n <slot />\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { ref, watchEffect, computed, StyleValue } from 'vue';\nimport { Position, restorePosition } from '@embedpdf/models';\nimport { createPointerProvider } from '../../shared/utils';\nimport { useInteractionManagerCapability, useIsPageExclusive } from '../hooks';\n\ninterface Props {\n pageIndex: number;\n pageWidth: number;\n pageHeight: number;\n rotation: number;\n scale: number;\n convertEventToPoint?: (event: PointerEvent, element: HTMLElement) => Position;\n}\n\nconst props = defineProps<Props>();\n\nconst divRef = ref<HTMLDivElement | null>(null);\nconst { provides: cap } = useInteractionManagerCapability();\nconst isPageExclusive = useIsPageExclusive();\n\nconst defaultConvertEventToPoint = computed(() => {\n return (event: PointerEvent, element: HTMLElement): Position => {\n const rect = element.getBoundingClientRect();\n const displayPoint = {\n x: event.clientX - rect.left,\n y: event.clientY - rect.top,\n };\n return restorePosition(\n { width: props.pageWidth, height: props.pageHeight },\n displayPoint,\n props.rotation,\n props.scale,\n );\n };\n});\n\nwatchEffect((onCleanup) => {\n if (cap.value && divRef.value) {\n const cleanup = createPointerProvider(\n cap.value,\n { type: 'page', pageIndex: props.pageIndex },\n divRef.value,\n props.convertEventToPoint || defaultConvertEventToPoint.value,\n );\n onCleanup(cleanup);\n }\n});\n</script>\n\n<template>\n <div ref=\"divRef\">\n <slot />\n <div\n v-if=\"isPageExclusive\"\n :style=\"{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, zIndex: 10 }\"\n />\n </div>\n</template>\n"],"names":["_createElementBlock","_renderSlot","_unref","_openBlock"],"mappings":";;;;AAYA,MAAM,cAAiC;AAAA,EACrC,aAAa;AAAA,EACb,WAAW;AAAA,EACX,aAAa;AAAA,EACb,cAAc;AAAA,EACd,cAAc;AAAA,EACd,eAAe;AAAA,EAEf,WAAW;AAAA,EACX,SAAS;AAAA,EACT,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,aAAa;AAAA,EAEb,OAAO;AAAA,EACP,UAAU;AAAA;AAAA,EAGV,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,WAAW;AAAA,EACX,aAAa;AACf;AAEA,MAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,kBAAkB,CAAC,cAAc,YAAY,aAAa,aAAa;AAC7E,MAAM,gBAAgB,CAAC,GAAG,mBAAmB,GAAG,eAAe;AAK/D,SAAS,aAAa,WAAmB,eAAiD;AAEjF,SAAA,UAAU,WAAW,OAAO,IAAI,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AAW,QAAQ,MAAM,WAAW;AAAA,UACnD;AAAA,UACA,MAAM;AAAA,UACN,MAAM;AAAA,QACR;AAAA,MACF;AAAA,IAAA,CACD;AAED,gBAAY,CAAC,cAAc;AACrB,UAAA,IAAI,SAAS,OAAO,OAAO;AAC7B,cAAM,UAAU;AAAA,UACd,IAAI;AAAA,UACJ,EAAE,MAAM,QAAQ,WAAW,MAAM,UAAU;AAAA,UAC3C,OAAO;AAAA,UACP,MAAM,uBAAuB,2BAA2B;AAAA,QAC1D;AACA,kBAAU,OAAO;AAAA,MAAA;AAAA,IACnB,CACD;;0BAICD,mBAMM,OAAA;AAAA,iBANG;AAAA,QAAJ,KAAI;AAAA,MAAA;QACPC,WAAQ,KAAA,QAAA,SAAA;AAAA,QAEAC,MAAe,eAAA,KADvBC,aAAAH,mBAGE,OAHF,UAGE;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-interaction-manager",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@embedpdf/models": "1.0.
|
|
31
|
+
"@embedpdf/models": "1.0.16"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/react": "^18.2.0",
|
|
35
35
|
"typescript": "^5.0.0",
|
|
36
|
-
"@embedpdf/core": "1.0.
|
|
36
|
+
"@embedpdf/core": "1.0.16",
|
|
37
37
|
"@embedpdf/build": "1.0.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"react-dom": ">=16.8.0",
|
|
42
42
|
"preact": "^10.26.4",
|
|
43
43
|
"vue": ">=3.2.0",
|
|
44
|
-
"@embedpdf/core": "1.0.
|
|
44
|
+
"@embedpdf/core": "1.0.16"
|
|
45
45
|
},
|
|
46
46
|
"files": [
|
|
47
47
|
"dist",
|