@embedpdf/plugin-interaction-manager 1.3.16 → 1.4.0
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/shared/components/global-pointer-provider.d.ts +7 -0
- package/dist/shared/components/index.d.ts +2 -0
- package/dist/shared/components/page-pointer-provider.d.ts +14 -0
- package/dist/shared/hooks/index.d.ts +1 -0
- package/dist/shared/hooks/use-interaction-manager.d.ts +31 -0
- package/dist/shared/index.d.ts +3 -0
- package/dist/shared/utils.d.ts +3 -0
- package/dist/svelte/components/GlobalPointerProvider.svelte.d.ts +9 -0
- package/dist/svelte/components/PagePointerProvider.svelte.d.ts +16 -0
- package/dist/svelte/components/index.d.ts +2 -0
- package/dist/svelte/hooks/index.d.ts +1 -0
- package/dist/svelte/hooks/use-interaction-manager.svelte.d.ts +33 -0
- package/dist/svelte/index.cjs +2 -0
- package/dist/svelte/index.cjs.map +1 -0
- package/dist/svelte/index.d.ts +3 -0
- package/dist/svelte/index.js +356 -0
- package/dist/svelte/index.js.map +1 -0
- package/package.json +14 -6
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactNode, HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
|
|
2
|
+
interface GlobalPointerProviderProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
style?: CSSProperties;
|
|
5
|
+
}
|
|
6
|
+
export declare const GlobalPointerProvider: ({ children, style, ...props }: GlobalPointerProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReactNode, HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
|
|
2
|
+
import { Position } from '@embedpdf/models';
|
|
3
|
+
interface PagePointerProviderProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
pageIndex: number;
|
|
6
|
+
pageWidth: number;
|
|
7
|
+
pageHeight: number;
|
|
8
|
+
rotation: number;
|
|
9
|
+
scale: number;
|
|
10
|
+
style?: CSSProperties;
|
|
11
|
+
convertEventToPoint?: (event: PointerEvent, element: HTMLElement) => Position;
|
|
12
|
+
}
|
|
13
|
+
export declare const PagePointerProvider: ({ pageIndex, children, pageWidth, pageHeight, rotation, scale, convertEventToPoint, style, ...props }: PagePointerProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-interaction-manager';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { InteractionManagerPlugin, InteractionManagerState, PointerEventHandlersWithLifecycle } from '../../index.ts';
|
|
2
|
+
export declare const useInteractionManagerPlugin: () => {
|
|
3
|
+
plugin: InteractionManagerPlugin | null;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare const useInteractionManagerCapability: () => {
|
|
8
|
+
provides: Readonly<import('../../index.ts').InteractionManagerCapability> | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
ready: Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
export declare function useInteractionManager(): {
|
|
13
|
+
provides: Readonly<import('../../index.ts').InteractionManagerCapability> | null;
|
|
14
|
+
state: InteractionManagerState;
|
|
15
|
+
};
|
|
16
|
+
export declare function useCursor(): {
|
|
17
|
+
setCursor: (token: string, cursor: string, prio?: number) => void;
|
|
18
|
+
removeCursor: (token: string) => void;
|
|
19
|
+
};
|
|
20
|
+
interface UsePointerHandlersOptions {
|
|
21
|
+
modeId?: string | string[];
|
|
22
|
+
pageIndex?: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function usePointerHandlers({ modeId, pageIndex }: UsePointerHandlersOptions): {
|
|
25
|
+
register: (handlers: PointerEventHandlersWithLifecycle, options?: {
|
|
26
|
+
modeId?: string | string[];
|
|
27
|
+
pageIndex?: number;
|
|
28
|
+
}) => (() => void) | undefined;
|
|
29
|
+
};
|
|
30
|
+
export declare function useIsPageExclusive(): boolean;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Position } from '@embedpdf/models';
|
|
2
|
+
import { InteractionManagerCapability, InteractionScope } from '../index.ts';
|
|
3
|
+
export declare function createPointerProvider(cap: InteractionManagerCapability, scope: InteractionScope, element: HTMLElement, convertEventToPoint?: (evt: PointerEvent, host: HTMLElement) => Position): () => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Snippet } from 'svelte';
|
|
2
|
+
import { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
interface GlobalPointerProviderProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
children: Snippet;
|
|
5
|
+
class?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const GlobalPointerProvider: import('svelte', { with: { "resolution-mode": "import" } }).Component<GlobalPointerProviderProps, {}, "">;
|
|
8
|
+
type GlobalPointerProvider = ReturnType<typeof GlobalPointerProvider>;
|
|
9
|
+
export default GlobalPointerProvider;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Position } from '@embedpdf/models';
|
|
2
|
+
import { Snippet } from 'svelte';
|
|
3
|
+
import { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
interface PagePointerProviderProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
children: Snippet;
|
|
6
|
+
pageIndex: number;
|
|
7
|
+
pageWidth: number;
|
|
8
|
+
pageHeight: number;
|
|
9
|
+
rotation: number;
|
|
10
|
+
scale: number;
|
|
11
|
+
class?: string;
|
|
12
|
+
convertEventToPoint?: (event: PointerEvent, element: HTMLElement) => Position;
|
|
13
|
+
}
|
|
14
|
+
declare const PagePointerProvider: import('svelte', { with: { "resolution-mode": "import" } }).Component<PagePointerProviderProps, {}, "">;
|
|
15
|
+
type PagePointerProvider = ReturnType<typeof PagePointerProvider>;
|
|
16
|
+
export default PagePointerProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-interaction-manager.svelte';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { InteractionManagerPlugin, InteractionManagerState, PointerEventHandlersWithLifecycle } from '../../lib/index.ts';
|
|
2
|
+
export declare const useInteractionManagerPlugin: () => {
|
|
3
|
+
plugin: InteractionManagerPlugin | null;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare const useInteractionManagerCapability: () => {
|
|
8
|
+
provides: Readonly<import('../../lib/index.ts').InteractionManagerCapability> | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
ready: Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
export declare function useInteractionManager(): {
|
|
13
|
+
readonly provides: Readonly<import('../../lib/index.ts').InteractionManagerCapability> | null;
|
|
14
|
+
readonly state: InteractionManagerState;
|
|
15
|
+
};
|
|
16
|
+
export declare function useCursor(): {
|
|
17
|
+
setCursor: (token: string, cursor: string, prio?: number) => void;
|
|
18
|
+
removeCursor: (token: string) => void;
|
|
19
|
+
};
|
|
20
|
+
interface UsePointerHandlersOptions {
|
|
21
|
+
modeId?: string | string[];
|
|
22
|
+
pageIndex?: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function usePointerHandlers({ modeId, pageIndex }: UsePointerHandlersOptions): {
|
|
25
|
+
register: (handlers: PointerEventHandlersWithLifecycle, options?: {
|
|
26
|
+
modeId?: string | string[];
|
|
27
|
+
pageIndex?: number;
|
|
28
|
+
}) => (() => void) | undefined;
|
|
29
|
+
};
|
|
30
|
+
export declare function useIsPageExclusive(): {
|
|
31
|
+
readonly isPageExclusive: boolean;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),require("svelte/internal/disclose-version");const e=require("svelte/internal/client"),t=require("@embedpdf/plugin-interaction-manager"),n=require("@embedpdf/core/svelte"),o=require("@embedpdf/models");function r(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}return t.default=e,Object.freeze(t)}const i=r(e),s=()=>n.useCapability(t.InteractionManagerPlugin.id);function l(){const e=i.derived(s),t=i.derived((()=>i.get(e).provides));let n=i.derived((()=>{var e;const n=null==(e=i.get(t))?void 0:e.getActiveInteractionMode();return"page"===(null==n?void 0:n.scope)&&!!n.exclusive}));return i.user_effect((()=>{if(i.get(t))return i.get(t).onModeChange((()=>{const e=i.get(t).getActiveInteractionMode();i.set(n,"page"===(null==e?void 0:e.scope)&&!!(null==e?void 0:e.exclusive))}))})),{get isPageExclusive(){return i.get(n)}}}const a={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"},c=["pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","mousedown","mouseup","mousemove","mouseenter","mouseleave","mousecancel","click","dblclick"],u="undefined"!=typeof PointerEvent?c:[...c,"touchstart","touchend","touchmove","touchcancel"];function d(e){return"undefined"!=typeof TouchEvent&&e instanceof TouchEvent}function p(e,t,n,o){let r=e.getHandlersForScope(t);const i=()=>{var t;return!1!==(null==(t=e.getActiveInteractionMode())?void 0:t.wantsRawTouch)},s={};let l=i();const c=e=>{u.forEach((t=>{const o=s[t]??(s[t]=b);var r;n.addEventListener(t,o,(r=e,t.startsWith("touch")?{passive:!r}:{passive:!1}))}))},p=()=>{u.forEach((e=>{const t=s[e];t&&n.removeEventListener(e,t)}))};c(l),n.style.touchAction=l?"none":"";const g=e.onModeChange((()=>{if("global"===t.type){const t=e.getActiveInteractionMode();n.style.cursor="global"===(null==t?void 0:t.scope)?t.cursor??"auto":"auto"}r=e.getHandlersForScope(t);const o=i();o!==l&&(p(),c(o),l=o,n.style.touchAction=l?"none":"")})),v=e.onHandlerChange((()=>{r=e.getHandlersForScope(t)})),f=e.getActiveInteractionMode(),h=e.getCurrentCursor();n.style.cursor="global"===t.type&&"global"!==(null==f?void 0:f.scope)?"auto":h;const y=e.onCursorChange((o=>{var r;"global"===t.type&&"global"!==(null==(r=e.getActiveInteractionMode())?void 0:r.scope)||(n.style.cursor=o)})),m=(e,t)=>{if(o)return o(e,t);const n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}};function b(t){var o;if(e.isPaused())return;const i=e.getExclusionRules();if(t.target&&function(e,t){var n,o,r;if(!e)return!1;let i=e;for(;i;){if(null==(n=t.classes)?void 0:n.length)for(const e of t.classes)if(null==(o=i.classList)?void 0:o.contains(e))return!0;if(null==(r=t.dataAttributes)?void 0:r.length)for(const e of t.dataAttributes)if(i.hasAttribute(e))return!0;i=i.parentElement}return!1}(t.target,i))return;const s=a[t.type];if(!s||!(null==r?void 0:r[s]))return;let c,u;if(d(t)&&l&&("touchmove"===t.type||"touchcancel"===t.type)&&t.preventDefault(),d(t)){const e="touchend"===t.type||"touchcancel"===t.type?t.changedTouches[0]:t.touches[0];if(!e)return;c=m(e,n),u={clientX:e.clientX,clientY:e.clientY,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,target:t.target,currentTarget:t.currentTarget,setPointerCapture:()=>{},releasePointerCapture:()=>{}}}else{const e=t;c=m(e,n),u={clientX:e.clientX,clientY:e.clientY,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey,target:e.target,currentTarget:e.currentTarget,setPointerCapture:()=>{var t,n;null==(n=null==(t=e.target)?void 0:t.setPointerCapture)||n.call(t,e.pointerId)},releasePointerCapture:()=>{var t,n;null==(n=null==(t=e.target)?void 0:t.releasePointerCapture)||n.call(t,e.pointerId)}}}null==(o=r[s])||o.call(r,c,u,e.getActiveMode())}return()=>{p(),g(),y(),v()}}var g=i.from_html("<div><!></div>");var v=i.from_html("<div></div>"),f=i.from_html("<div><!> <!></div>");exports.GlobalPointerProvider=function(e,t){i.push(t,!0);let n=i.rest_props(t,["$$slots","$$events","$$legacy","children","class"]),o=i.state(null);const r=i.derived(s),l=i.derived((()=>i.get(r).provides));i.user_effect((()=>{if(i.get(l)&&i.get(o))return p(i.get(l),{type:"global"},i.get(o))}));var a=g();i.attribute_effect(a,(()=>({class:t.class,...n,[i.STYLE]:{width:"100%",height:"100%"}})));var c=i.child(a);i.snippet(c,(()=>t.children)),i.reset(a),i.bind_this(a,(e=>i.set(o,e)),(()=>i.get(o))),i.append(e,a),i.pop()},exports.PagePointerProvider=function(e,t){i.push(t,!0);let n=i.rest_props(t,["$$slots","$$events","$$legacy","pageIndex","children","pageWidth","pageHeight","rotation","scale","convertEventToPoint","class"]),r=i.state(null);const a=i.derived(s),c=i.derived((()=>i.get(a).provides)),u=i.derived(l),d=i.derived((()=>(e,n)=>{const r=n.getBoundingClientRect(),i={x:e.clientX-r.left,y:e.clientY-r.top},s=o.transformSize({width:t.pageWidth,height:t.pageHeight},t.rotation,1);return o.restorePosition(s,i,t.rotation,t.scale)}));i.user_effect((()=>{if(i.get(c)&&i.get(r))return p(i.get(c),{type:"page",pageIndex:t.pageIndex},i.get(r),t.convertEventToPoint||i.get(d))}));var g=f();i.attribute_effect(g,(e=>({class:t.class,...n,[i.STYLE]:e})),[()=>({position:"relative",width:`${t.pageWidth}px`,height:`${t.pageHeight}px`})]);var h=i.child(g);i.snippet(h,(()=>t.children));var y=i.sibling(h,2),m=e=>{var t=v();i.set_style(t,"",{},{position:"absolute",top:"0",left:"0",right:"0",bottom:"0","z-index":"10"}),i.append(e,t)};i.if(y,(e=>{i.get(u)&&e(m)})),i.reset(g),i.bind_this(g,(e=>i.set(r,e)),(()=>i.get(r))),i.append(e,g),i.pop()},exports.useCursor=function(){const e=i.derived(s),t=i.derived((()=>i.get(e).provides));return{setCursor:(e,n,o=0)=>{var r;null==(r=i.get(t))||r.setCursor(e,n,o)},removeCursor:e=>{var n;null==(n=i.get(t))||n.removeCursor(e)}}},exports.useInteractionManager=function(){const e=i.derived(s),n=i.derived((()=>i.get(e).provides));let o=i.state(i.proxy(t.initialState));return i.user_effect((()=>{if(i.get(n))return i.get(n).onStateChange((e=>{i.set(o,e,!0)}))})),{get provides(){return i.get(n)},get state(){return i.get(o)}}},exports.useInteractionManagerCapability=s,exports.useInteractionManagerPlugin=()=>n.usePlugin(t.InteractionManagerPlugin.id),exports.useIsPageExclusive=l,exports.usePointerHandlers=function({modeId:e,pageIndex:t}){const n=i.derived(s),o=i.derived((()=>i.get(n).provides));return{register:(n,r)=>{var s,l;const a=(null==r?void 0:r.modeId)??e,c=(null==r?void 0:r.pageIndex)??t;return a?null==(s=i.get(o))?void 0:s.registerHandlers({modeId:a,handlers:n,pageIndex:c}):null==(l=i.get(o))?void 0:l.registerAlways({scope:void 0!==c?{type:"page",pageIndex:c}:{type:"global"},handlers:n})}}},Object.keys(t).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})}));
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-interaction-manager.svelte.ts","../../src/shared/utils.ts","../../src/svelte/components/GlobalPointerProvider.svelte","../../src/svelte/components/PagePointerProvider.svelte"],"sourcesContent":["import {\n initialState,\n InteractionManagerPlugin,\n InteractionManagerState,\n PointerEventHandlersWithLifecycle,\n} from '@embedpdf/plugin-interaction-manager';\nimport { useCapability, usePlugin } from '@embedpdf/core/svelte';\n\nexport const useInteractionManagerPlugin = () =>\n usePlugin<InteractionManagerPlugin>(InteractionManagerPlugin.id);\nexport const useInteractionManagerCapability = () =>\n useCapability<InteractionManagerPlugin>(InteractionManagerPlugin.id);\n\nexport function useInteractionManager() {\n const { provides } = $derived(useInteractionManagerCapability());\n let interactionManagerState = $state<InteractionManagerState>(initialState);\n\n $effect(() => {\n if (!provides) return;\n return provides.onStateChange((state) => {\n interactionManagerState = state;\n });\n });\n\n return {\n get provides() {\n return provides;\n },\n get state() {\n return interactionManagerState;\n },\n };\n}\n\nexport function useCursor() {\n const { provides } = $derived(useInteractionManagerCapability());\n return {\n setCursor: (token: string, cursor: string, prio = 0) => {\n provides?.setCursor(token, cursor, prio);\n },\n removeCursor: (token: string) => {\n provides?.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 } = $derived(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 return finalModeId\n ? provides?.registerHandlers({\n modeId: finalModeId,\n handlers,\n pageIndex: finalPageIndex,\n })\n : provides?.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 } = $derived(useInteractionManagerCapability());\n let isPageExclusive = $derived.by(() => {\n const m = cap?.getActiveInteractionMode();\n return m?.scope === 'page' && !!m.exclusive;\n });\n\n $effect(() => {\n if (!cap) return;\n\n return cap.onModeChange(() => {\n const mode = cap.getActiveInteractionMode();\n isPageExclusive = mode?.scope === 'page' && !!mode?.exclusive;\n });\n });\n\n return {\n get isPageExclusive() {\n return isPageExclusive;\n },\n };\n}\n","import { Position } from '@embedpdf/models';\nimport type {\n InteractionManagerCapability,\n InteractionScope,\n PointerEventHandlers,\n EmbedPdfPointerEvent,\n InteractionExclusionRules,\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 HAS_POINTER = typeof PointerEvent !== 'undefined';\n// If the browser supports Pointer Events, don't attach legacy touch events to avoid double-dispatch.\nconst allEventTypes = HAS_POINTER ? pointerEventTypes : [...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\nfunction isTouchEvent(evt: Event): evt is TouchEvent {\n return typeof TouchEvent !== 'undefined' && evt instanceof TouchEvent;\n}\n\n/**\n * Check if an element should be excluded based on rules\n * This is in the framework layer, not the plugin\n */\nfunction shouldExcludeElement(element: Element | null, rules: InteractionExclusionRules): boolean {\n if (!element) return false;\n\n let current: Element | null = element;\n\n while (current) {\n // Check classes\n if (rules.classes?.length) {\n for (const className of rules.classes) {\n if (current.classList?.contains(className)) {\n return true;\n }\n }\n }\n\n // Check data attributes\n if (rules.dataAttributes?.length) {\n for (const attr of rules.dataAttributes) {\n if (current.hasAttribute(attr)) {\n return true;\n }\n }\n }\n\n // Move up the DOM tree\n current = current.parentElement;\n }\n\n return 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 element.style.touchAction = attachedWithRawTouch ? 'none' : '';\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 element.style.touchAction = attachedWithRawTouch ? 'none' : '';\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 // Get exclusion rules from capability and check in framework layer\n const exclusionRules = cap.getExclusionRules();\n if (evt.target && shouldExcludeElement(evt.target as Element, exclusionRules)) {\n return; // Skip processing this event\n }\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 isTouchEvent(evt) &&\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 (isTouchEvent(evt)) {\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 setPointerCapture: () => {},\n releasePointerCapture: () => {},\n };\n } else {\n const pe = evt as PointerEvent;\n pos = toPos(pe, element);\n normEvt = {\n clientX: pe.clientX,\n clientY: pe.clientY,\n ctrlKey: pe.ctrlKey,\n shiftKey: pe.shiftKey,\n altKey: pe.altKey,\n metaKey: pe.metaKey,\n target: pe.target,\n currentTarget: pe.currentTarget,\n setPointerCapture: () => {\n (pe.target as HTMLElement)?.setPointerCapture?.(pe.pointerId);\n },\n releasePointerCapture: () => {\n (pe.target as HTMLElement)?.releasePointerCapture?.(pe.pointerId);\n },\n };\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","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import { useInteractionManagerCapability } from '../hooks';\n import { createPointerProvider } from '../../shared/utils';\n import type { HTMLAttributes } from 'svelte/elements';\n\n interface GlobalPointerProviderProps extends HTMLAttributes<HTMLDivElement> {\n children: Snippet;\n class?: string;\n }\n\n let { children, class: propsClass, ...restProps }: GlobalPointerProviderProps = $props();\n\n let ref = $state<HTMLDivElement | null>(null);\n const { provides: cap } = $derived(useInteractionManagerCapability());\n\n $effect(() => {\n if (!cap || !ref) return;\n\n return createPointerProvider(cap, { type: 'global' }, ref);\n });\n</script>\n\n<div bind:this={ref} style:width=\"100%\" style:height=\"100%\" class={propsClass} {...restProps}>\n {@render children()}\n</div>\n","<script lang=\"ts\">\n import { type Position, restorePosition, type Size, transformSize } from '@embedpdf/models';\n import type { Snippet } from 'svelte';\n import type { HTMLAttributes } from 'svelte/elements';\n import { createPointerProvider } from '../../shared/utils';\n import { useInteractionManagerCapability, useIsPageExclusive } from '../hooks';\n\n interface PagePointerProviderProps extends HTMLAttributes<HTMLDivElement> {\n children: Snippet;\n pageIndex: number;\n pageWidth: number;\n pageHeight: number;\n rotation: number;\n scale: number;\n class?: string;\n convertEventToPoint?: (event: PointerEvent, element: HTMLElement) => Position;\n }\n\n let {\n pageIndex,\n children,\n pageWidth,\n pageHeight,\n rotation,\n scale,\n convertEventToPoint,\n class: propsClass,\n ...restProps\n }: PagePointerProviderProps = $props();\n\n let ref = $state<HTMLDivElement | null>(null);\n\n const { provides: cap } = $derived(useInteractionManagerCapability());\n const isPageExclusive = $derived(useIsPageExclusive());\n\n // Memoize the default conversion function\n const defaultConvertEventToPoint = $derived.by(() => {\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\n const displaySize: Size = transformSize(\n { width: pageWidth, height: pageHeight },\n rotation,\n 1,\n );\n\n return restorePosition(displaySize, displayPoint, rotation, scale);\n };\n });\n\n $effect(() => {\n if (!cap || !ref) return;\n\n return createPointerProvider(\n cap,\n { type: 'page', pageIndex },\n ref,\n convertEventToPoint || defaultConvertEventToPoint,\n );\n });\n</script>\n\n<div\n bind:this={ref}\n style:position=\"relative\"\n style:width={`${pageWidth}px`}\n style:height={`${pageHeight}px`}\n class={propsClass}\n {...restProps}\n>\n {@render children()}\n {#if isPageExclusive}\n <div\n style:position=\"absolute\"\n style:top=\"0\"\n style:left=\"0\"\n style:right=\"0\"\n style:bottom=\"0\"\n style:z-index=\"10\"\n ></div>\n {/if}\n</div>\n"],"names":["useInteractionManagerCapability","useCapability","InteractionManagerPlugin","id","useIsPageExclusive","cap","provides","isPageExclusive","m","$","get","_a","getActiveInteractionMode","scope","exclusive","user_effect","onModeChange","mode","domEventMap","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","mousedown","mouseup","mousemove","mouseenter","mouseleave","mousecancel","click","dblclick","touchstart","touchend","touchmove","touchcancel","pointerEventTypes","allEventTypes","PointerEvent","isTouchEvent","evt","TouchEvent","createPointerProvider","element","convertEventToPoint","active","getHandlersForScope","wantsRawTouchNow","wantsRawTouch","listeners","attachedWithRawTouch","addListeners","raw","forEach","type","fn","handleEvent","addEventListener","startsWith","passive","removeListeners","removeEventListener","style","touchAction","stopMode","cursor","stopHandler","onHandlerChange","initialMode","initialCursor","getCurrentCursor","stopCursor","onCursorChange","c","toPos","e","host","r","getBoundingClientRect","x","clientX","left","y","clientY","top","isPaused","exclusionRules","getExclusionRules","target","rules","current","classes","length","className","_b","classList","contains","_c","dataAttributes","attr","hasAttribute","parentElement","shouldExcludeElement","handlerKey","pos","normEvt","preventDefault","tp","changedTouches","touches","ctrlKey","shiftKey","altKey","metaKey","currentTarget","setPointerCapture","releasePointerCapture","pe","call","pointerId","getActiveMode","restProps","rest_props","$$props","ref","bind_this","div","$$value","set","defaultConvertEventToPoint","derived","event","rect","displayPoint","displaySize","transformSize","width","pageWidth","height","restorePosition","rotation","scale","pageIndex","STYLE","$0","consequent","setCursor","token","prio","removeCursor","interactionManagerState","initialState","onStateChange","state","$__namespace","usePlugin","modeId","register","handlers","options","finalModeId","finalPageIndex","registerHandlers","registerAlways"],"mappings":"ijBAUaA,EACX,IAAAC,gBAAwCC,EAAAA,yBAAyBC,IAoEnD,SAAAC,sBACqBJ,GAAjBK,0BAAVC,WACJ,IAAAC,8BACIC,EAAAC,OAAAA,EAAAA,EAAAC,IAAIL,SAAK,EAAAM,EAAAC,2BACR,MAAa,UAAV,MAAHJ,OAAG,EAAAA,EAAAK,UAAsBL,EAAEM,SAAA,WAGpCL,EAAAM,2BACOV,gBAEEA,GAAIW,yBACHC,EAAAR,EAAAC,IAAOL,GAAIO,iCACjBL,EAAkC,UAAV,MAANU,OAAM,EAAAA,EAAAJ,i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A0B,0DAWjDR,EAAS,CAAAjH,EAAAuI,OAAAC,KAAA,wSAGR1I,MAAe2I,EAAA,eARTzI,EAAAqH,UAAAC,GAAAC,GAAAvH,EAAAwH,IAAAJ,iBAAAA,0BAHb,oBH9BgB,6BACgB7H,GAAtBM,0BAAAA,kBAEN6I,UAAW,CAACC,EAAelF,EAAgBmF,EAAO,WACtC5I,OAAAA,EAAAA,EAAAC,IAAAJ,KAAAK,EAAAwI,UAAUC,EAAOlF,EAAQmF,EAAA,EAErCC,aAAeF,yBACb9I,OAAUgJ,aAAaF,EAAA,EAG7B,gCA/BgB,6BACgBpJ,GAAtBM,0BAAAA,WACJ,IAAAiJ,kBAA0DC,EAAAA,sBAE9D/I,EAAAM,2BACOT,GACE,OAAAG,EAAAC,IAAAJ,GAASmJ,eAAeC,IACHC,EAAA1B,IAAAsB,EAAAG,GAAA,EAAA,GAC3B,KAIG,YAAApJ,gBACKA,EACT,EACI,SAAAoJ,gBACKH,IAGb,gFAvBE,IAAAK,YAAoC1J,EAAAA,yBAAyBC,4DA0C/C,UAAqB0J,OAAAA,EAAQd,UAAAA,sBACb/I,GAAtBM,0BAAAA,kBAENwJ,SACE,CAAAC,EACAC,aAGM,MAAAC,SAAcD,WAASH,SAAUA,EACjCK,SAAiBF,WAASjB,YAAaA,SAEtCkB,iBACH3J,aAAU6J,iBAAiB,CACzBN,OAAQI,EACRF,WACAhB,UAAWmB,IAEbzJ,OAAAA,EAAAA,EAAAC,IAAAJ,aAAU8J,eAAe,CACvBvJ,WACqB,IAAnBqJ,EACM,CAAA3G,KAAM,OAAQwF,UAAWmB,GACzB,CAAA3G,KAAM,UACdwG,cAIZ"}
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import "svelte/internal/disclose-version";
|
|
2
|
+
import * as $ from "svelte/internal/client";
|
|
3
|
+
import { InteractionManagerPlugin, initialState } from "@embedpdf/plugin-interaction-manager";
|
|
4
|
+
export * from "@embedpdf/plugin-interaction-manager";
|
|
5
|
+
import { useCapability, usePlugin } from "@embedpdf/core/svelte";
|
|
6
|
+
import { transformSize, restorePosition } from "@embedpdf/models";
|
|
7
|
+
const useInteractionManagerPlugin = () => usePlugin(InteractionManagerPlugin.id);
|
|
8
|
+
const useInteractionManagerCapability = () => useCapability(InteractionManagerPlugin.id);
|
|
9
|
+
function useInteractionManager() {
|
|
10
|
+
const $$d = $.derived(useInteractionManagerCapability), provides = $.derived(() => $.get($$d).provides);
|
|
11
|
+
let interactionManagerState = $.state($.proxy(initialState));
|
|
12
|
+
$.user_effect(() => {
|
|
13
|
+
if (!$.get(provides)) return;
|
|
14
|
+
return $.get(provides).onStateChange((state) => {
|
|
15
|
+
$.set(interactionManagerState, state, true);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
return {
|
|
19
|
+
get provides() {
|
|
20
|
+
return $.get(provides);
|
|
21
|
+
},
|
|
22
|
+
get state() {
|
|
23
|
+
return $.get(interactionManagerState);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function useCursor() {
|
|
28
|
+
const $$d_1 = $.derived(useInteractionManagerCapability), provides = $.derived(() => $.get($$d_1).provides);
|
|
29
|
+
return {
|
|
30
|
+
setCursor: (token, cursor, prio = 0) => {
|
|
31
|
+
var _a;
|
|
32
|
+
(_a = $.get(provides)) == null ? void 0 : _a.setCursor(token, cursor, prio);
|
|
33
|
+
},
|
|
34
|
+
removeCursor: (token) => {
|
|
35
|
+
var _a;
|
|
36
|
+
(_a = $.get(provides)) == null ? void 0 : _a.removeCursor(token);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function usePointerHandlers({ modeId, pageIndex }) {
|
|
41
|
+
const $$d_2 = $.derived(useInteractionManagerCapability), provides = $.derived(() => $.get($$d_2).provides);
|
|
42
|
+
return {
|
|
43
|
+
register: (handlers, options) => {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
const finalModeId = (options == null ? void 0 : options.modeId) ?? modeId;
|
|
46
|
+
const finalPageIndex = (options == null ? void 0 : options.pageIndex) ?? pageIndex;
|
|
47
|
+
return finalModeId ? (_a = $.get(provides)) == null ? void 0 : _a.registerHandlers({ modeId: finalModeId, handlers, pageIndex: finalPageIndex }) : (_b = $.get(provides)) == null ? void 0 : _b.registerAlways({
|
|
48
|
+
scope: finalPageIndex !== void 0 ? { type: "page", pageIndex: finalPageIndex } : { type: "global" },
|
|
49
|
+
handlers
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function useIsPageExclusive() {
|
|
55
|
+
const $$d_3 = $.derived(useInteractionManagerCapability), cap = $.derived(() => $.get($$d_3).provides);
|
|
56
|
+
let isPageExclusive = $.derived(() => {
|
|
57
|
+
var _a;
|
|
58
|
+
const m = (_a = $.get(cap)) == null ? void 0 : _a.getActiveInteractionMode();
|
|
59
|
+
return (m == null ? void 0 : m.scope) === "page" && !!m.exclusive;
|
|
60
|
+
});
|
|
61
|
+
$.user_effect(() => {
|
|
62
|
+
if (!$.get(cap)) return;
|
|
63
|
+
return $.get(cap).onModeChange(() => {
|
|
64
|
+
const mode = $.get(cap).getActiveInteractionMode();
|
|
65
|
+
$.set(isPageExclusive, (mode == null ? void 0 : mode.scope) === "page" && !!(mode == null ? void 0 : mode.exclusive));
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
get isPageExclusive() {
|
|
70
|
+
return $.get(isPageExclusive);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const domEventMap = {
|
|
75
|
+
pointerdown: "onPointerDown",
|
|
76
|
+
pointerup: "onPointerUp",
|
|
77
|
+
pointermove: "onPointerMove",
|
|
78
|
+
pointerenter: "onPointerEnter",
|
|
79
|
+
pointerleave: "onPointerLeave",
|
|
80
|
+
pointercancel: "onPointerCancel",
|
|
81
|
+
mousedown: "onMouseDown",
|
|
82
|
+
mouseup: "onMouseUp",
|
|
83
|
+
mousemove: "onMouseMove",
|
|
84
|
+
mouseenter: "onMouseEnter",
|
|
85
|
+
mouseleave: "onMouseLeave",
|
|
86
|
+
mousecancel: "onMouseCancel",
|
|
87
|
+
click: "onClick",
|
|
88
|
+
dblclick: "onDoubleClick",
|
|
89
|
+
/* touch → pointer fallback for very old browsers */
|
|
90
|
+
touchstart: "onPointerDown",
|
|
91
|
+
touchend: "onPointerUp",
|
|
92
|
+
touchmove: "onPointerMove",
|
|
93
|
+
touchcancel: "onPointerCancel"
|
|
94
|
+
};
|
|
95
|
+
const pointerEventTypes = [
|
|
96
|
+
"pointerdown",
|
|
97
|
+
"pointerup",
|
|
98
|
+
"pointermove",
|
|
99
|
+
"pointerenter",
|
|
100
|
+
"pointerleave",
|
|
101
|
+
"pointercancel",
|
|
102
|
+
"mousedown",
|
|
103
|
+
"mouseup",
|
|
104
|
+
"mousemove",
|
|
105
|
+
"mouseenter",
|
|
106
|
+
"mouseleave",
|
|
107
|
+
"mousecancel",
|
|
108
|
+
"click",
|
|
109
|
+
"dblclick"
|
|
110
|
+
];
|
|
111
|
+
const touchEventTypes = ["touchstart", "touchend", "touchmove", "touchcancel"];
|
|
112
|
+
const HAS_POINTER = typeof PointerEvent !== "undefined";
|
|
113
|
+
const allEventTypes = HAS_POINTER ? pointerEventTypes : [...pointerEventTypes, ...touchEventTypes];
|
|
114
|
+
function listenerOpts(eventType, wantsRawTouch) {
|
|
115
|
+
return eventType.startsWith("touch") ? { passive: !wantsRawTouch } : { passive: false };
|
|
116
|
+
}
|
|
117
|
+
function isTouchEvent(evt) {
|
|
118
|
+
return typeof TouchEvent !== "undefined" && evt instanceof TouchEvent;
|
|
119
|
+
}
|
|
120
|
+
function shouldExcludeElement(element, rules) {
|
|
121
|
+
var _a, _b, _c;
|
|
122
|
+
if (!element) return false;
|
|
123
|
+
let current = element;
|
|
124
|
+
while (current) {
|
|
125
|
+
if ((_a = rules.classes) == null ? void 0 : _a.length) {
|
|
126
|
+
for (const className of rules.classes) {
|
|
127
|
+
if ((_b = current.classList) == null ? void 0 : _b.contains(className)) {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if ((_c = rules.dataAttributes) == null ? void 0 : _c.length) {
|
|
133
|
+
for (const attr of rules.dataAttributes) {
|
|
134
|
+
if (current.hasAttribute(attr)) {
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
current = current.parentElement;
|
|
140
|
+
}
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
function createPointerProvider(cap, scope, element, convertEventToPoint) {
|
|
144
|
+
let active = cap.getHandlersForScope(scope);
|
|
145
|
+
const wantsRawTouchNow = () => {
|
|
146
|
+
var _a;
|
|
147
|
+
return ((_a = cap.getActiveInteractionMode()) == null ? void 0 : _a.wantsRawTouch) !== false;
|
|
148
|
+
};
|
|
149
|
+
const listeners = {};
|
|
150
|
+
let attachedWithRawTouch = wantsRawTouchNow();
|
|
151
|
+
const addListeners = (raw) => {
|
|
152
|
+
allEventTypes.forEach((type) => {
|
|
153
|
+
const fn = listeners[type] ?? (listeners[type] = handleEvent);
|
|
154
|
+
element.addEventListener(type, fn, listenerOpts(type, raw));
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
const removeListeners = () => {
|
|
158
|
+
allEventTypes.forEach((type) => {
|
|
159
|
+
const fn = listeners[type];
|
|
160
|
+
if (fn) element.removeEventListener(type, fn);
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
addListeners(attachedWithRawTouch);
|
|
164
|
+
element.style.touchAction = attachedWithRawTouch ? "none" : "";
|
|
165
|
+
const stopMode = cap.onModeChange(() => {
|
|
166
|
+
if (scope.type === "global") {
|
|
167
|
+
const mode = cap.getActiveInteractionMode();
|
|
168
|
+
element.style.cursor = (mode == null ? void 0 : mode.scope) === "global" ? mode.cursor ?? "auto" : "auto";
|
|
169
|
+
}
|
|
170
|
+
active = cap.getHandlersForScope(scope);
|
|
171
|
+
const raw = wantsRawTouchNow();
|
|
172
|
+
if (raw !== attachedWithRawTouch) {
|
|
173
|
+
removeListeners();
|
|
174
|
+
addListeners(raw);
|
|
175
|
+
attachedWithRawTouch = raw;
|
|
176
|
+
element.style.touchAction = attachedWithRawTouch ? "none" : "";
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
const stopHandler = cap.onHandlerChange(() => {
|
|
180
|
+
active = cap.getHandlersForScope(scope);
|
|
181
|
+
});
|
|
182
|
+
const initialMode = cap.getActiveInteractionMode();
|
|
183
|
+
const initialCursor = cap.getCurrentCursor();
|
|
184
|
+
element.style.cursor = scope.type === "global" && (initialMode == null ? void 0 : initialMode.scope) !== "global" ? "auto" : initialCursor;
|
|
185
|
+
const stopCursor = cap.onCursorChange((c) => {
|
|
186
|
+
var _a;
|
|
187
|
+
if (scope.type === "global" && ((_a = cap.getActiveInteractionMode()) == null ? void 0 : _a.scope) !== "global") return;
|
|
188
|
+
element.style.cursor = c;
|
|
189
|
+
});
|
|
190
|
+
const toPos = (e, host) => {
|
|
191
|
+
if (convertEventToPoint) return convertEventToPoint(e, host);
|
|
192
|
+
const r = host.getBoundingClientRect();
|
|
193
|
+
return { x: e.clientX - r.left, y: e.clientY - r.top };
|
|
194
|
+
};
|
|
195
|
+
function handleEvent(evt) {
|
|
196
|
+
var _a;
|
|
197
|
+
if (cap.isPaused()) return;
|
|
198
|
+
const exclusionRules = cap.getExclusionRules();
|
|
199
|
+
if (evt.target && shouldExcludeElement(evt.target, exclusionRules)) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const handlerKey = domEventMap[evt.type];
|
|
203
|
+
if (!handlerKey || !(active == null ? void 0 : active[handlerKey])) return;
|
|
204
|
+
if (isTouchEvent(evt) && attachedWithRawTouch && (evt.type === "touchmove" || evt.type === "touchcancel")) {
|
|
205
|
+
evt.preventDefault();
|
|
206
|
+
}
|
|
207
|
+
let pos;
|
|
208
|
+
let normEvt;
|
|
209
|
+
if (isTouchEvent(evt)) {
|
|
210
|
+
const tp = evt.type === "touchend" || evt.type === "touchcancel" ? evt.changedTouches[0] : evt.touches[0];
|
|
211
|
+
if (!tp) return;
|
|
212
|
+
pos = toPos(tp, element);
|
|
213
|
+
normEvt = {
|
|
214
|
+
clientX: tp.clientX,
|
|
215
|
+
clientY: tp.clientY,
|
|
216
|
+
ctrlKey: evt.ctrlKey,
|
|
217
|
+
shiftKey: evt.shiftKey,
|
|
218
|
+
altKey: evt.altKey,
|
|
219
|
+
metaKey: evt.metaKey,
|
|
220
|
+
target: evt.target,
|
|
221
|
+
currentTarget: evt.currentTarget,
|
|
222
|
+
setPointerCapture: () => {
|
|
223
|
+
},
|
|
224
|
+
releasePointerCapture: () => {
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
} else {
|
|
228
|
+
const pe = evt;
|
|
229
|
+
pos = toPos(pe, element);
|
|
230
|
+
normEvt = {
|
|
231
|
+
clientX: pe.clientX,
|
|
232
|
+
clientY: pe.clientY,
|
|
233
|
+
ctrlKey: pe.ctrlKey,
|
|
234
|
+
shiftKey: pe.shiftKey,
|
|
235
|
+
altKey: pe.altKey,
|
|
236
|
+
metaKey: pe.metaKey,
|
|
237
|
+
target: pe.target,
|
|
238
|
+
currentTarget: pe.currentTarget,
|
|
239
|
+
setPointerCapture: () => {
|
|
240
|
+
var _a2, _b;
|
|
241
|
+
(_b = (_a2 = pe.target) == null ? void 0 : _a2.setPointerCapture) == null ? void 0 : _b.call(_a2, pe.pointerId);
|
|
242
|
+
},
|
|
243
|
+
releasePointerCapture: () => {
|
|
244
|
+
var _a2, _b;
|
|
245
|
+
(_b = (_a2 = pe.target) == null ? void 0 : _a2.releasePointerCapture) == null ? void 0 : _b.call(_a2, pe.pointerId);
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
(_a = active[handlerKey]) == null ? void 0 : _a.call(active, pos, normEvt, cap.getActiveMode());
|
|
250
|
+
}
|
|
251
|
+
return () => {
|
|
252
|
+
removeListeners();
|
|
253
|
+
stopMode();
|
|
254
|
+
stopCursor();
|
|
255
|
+
stopHandler();
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
var root$1 = $.from_html(`<div><!></div>`);
|
|
259
|
+
function GlobalPointerProvider($$anchor, $$props) {
|
|
260
|
+
$.push($$props, true);
|
|
261
|
+
let restProps = $.rest_props($$props, ["$$slots", "$$events", "$$legacy", "children", "class"]);
|
|
262
|
+
let ref = $.state(null);
|
|
263
|
+
const $$d = $.derived(useInteractionManagerCapability), cap = $.derived(() => $.get($$d).provides);
|
|
264
|
+
$.user_effect(() => {
|
|
265
|
+
if (!$.get(cap) || !$.get(ref)) return;
|
|
266
|
+
return createPointerProvider($.get(cap), { type: "global" }, $.get(ref));
|
|
267
|
+
});
|
|
268
|
+
var div = root$1();
|
|
269
|
+
$.attribute_effect(div, () => ({
|
|
270
|
+
class: $$props.class,
|
|
271
|
+
...restProps,
|
|
272
|
+
[$.STYLE]: { width: "100%", height: "100%" }
|
|
273
|
+
}));
|
|
274
|
+
var node = $.child(div);
|
|
275
|
+
$.snippet(node, () => $$props.children);
|
|
276
|
+
$.reset(div);
|
|
277
|
+
$.bind_this(div, ($$value) => $.set(ref, $$value), () => $.get(ref));
|
|
278
|
+
$.append($$anchor, div);
|
|
279
|
+
$.pop();
|
|
280
|
+
}
|
|
281
|
+
var root_1 = $.from_html(`<div></div>`);
|
|
282
|
+
var root = $.from_html(`<div><!> <!></div>`);
|
|
283
|
+
function PagePointerProvider($$anchor, $$props) {
|
|
284
|
+
$.push($$props, true);
|
|
285
|
+
let restProps = $.rest_props($$props, [
|
|
286
|
+
"$$slots",
|
|
287
|
+
"$$events",
|
|
288
|
+
"$$legacy",
|
|
289
|
+
"pageIndex",
|
|
290
|
+
"children",
|
|
291
|
+
"pageWidth",
|
|
292
|
+
"pageHeight",
|
|
293
|
+
"rotation",
|
|
294
|
+
"scale",
|
|
295
|
+
"convertEventToPoint",
|
|
296
|
+
"class"
|
|
297
|
+
]);
|
|
298
|
+
let ref = $.state(null);
|
|
299
|
+
const $$d = $.derived(useInteractionManagerCapability), cap = $.derived(() => $.get($$d).provides);
|
|
300
|
+
const isPageExclusive = $.derived(useIsPageExclusive);
|
|
301
|
+
const defaultConvertEventToPoint = $.derived(() => {
|
|
302
|
+
return (event, element) => {
|
|
303
|
+
const rect = element.getBoundingClientRect();
|
|
304
|
+
const displayPoint = { x: event.clientX - rect.left, y: event.clientY - rect.top };
|
|
305
|
+
const displaySize = transformSize({ width: $$props.pageWidth, height: $$props.pageHeight }, $$props.rotation, 1);
|
|
306
|
+
return restorePosition(displaySize, displayPoint, $$props.rotation, $$props.scale);
|
|
307
|
+
};
|
|
308
|
+
});
|
|
309
|
+
$.user_effect(() => {
|
|
310
|
+
if (!$.get(cap) || !$.get(ref)) return;
|
|
311
|
+
return createPointerProvider($.get(cap), { type: "page", pageIndex: $$props.pageIndex }, $.get(ref), $$props.convertEventToPoint || $.get(defaultConvertEventToPoint));
|
|
312
|
+
});
|
|
313
|
+
var div = root();
|
|
314
|
+
$.attribute_effect(div, ($0) => ({ class: $$props.class, ...restProps, [$.STYLE]: $0 }), [
|
|
315
|
+
() => ({
|
|
316
|
+
position: "relative",
|
|
317
|
+
width: `${$$props.pageWidth}px`,
|
|
318
|
+
height: `${$$props.pageHeight}px`
|
|
319
|
+
})
|
|
320
|
+
]);
|
|
321
|
+
var node = $.child(div);
|
|
322
|
+
$.snippet(node, () => $$props.children);
|
|
323
|
+
var node_1 = $.sibling(node, 2);
|
|
324
|
+
{
|
|
325
|
+
var consequent = ($$anchor2) => {
|
|
326
|
+
var div_1 = root_1();
|
|
327
|
+
$.set_style(div_1, "", {}, {
|
|
328
|
+
position: "absolute",
|
|
329
|
+
top: "0",
|
|
330
|
+
left: "0",
|
|
331
|
+
right: "0",
|
|
332
|
+
bottom: "0",
|
|
333
|
+
"z-index": "10"
|
|
334
|
+
});
|
|
335
|
+
$.append($$anchor2, div_1);
|
|
336
|
+
};
|
|
337
|
+
$.if(node_1, ($$render) => {
|
|
338
|
+
if ($.get(isPageExclusive)) $$render(consequent);
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
$.reset(div);
|
|
342
|
+
$.bind_this(div, ($$value) => $.set(ref, $$value), () => $.get(ref));
|
|
343
|
+
$.append($$anchor, div);
|
|
344
|
+
$.pop();
|
|
345
|
+
}
|
|
346
|
+
export {
|
|
347
|
+
GlobalPointerProvider,
|
|
348
|
+
PagePointerProvider,
|
|
349
|
+
useCursor,
|
|
350
|
+
useInteractionManager,
|
|
351
|
+
useInteractionManagerCapability,
|
|
352
|
+
useInteractionManagerPlugin,
|
|
353
|
+
useIsPageExclusive,
|
|
354
|
+
usePointerHandlers
|
|
355
|
+
};
|
|
356
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-interaction-manager.svelte.ts","../../src/shared/utils.ts","../../src/svelte/components/GlobalPointerProvider.svelte","../../src/svelte/components/PagePointerProvider.svelte"],"sourcesContent":["import {\n initialState,\n InteractionManagerPlugin,\n InteractionManagerState,\n PointerEventHandlersWithLifecycle,\n} from '@embedpdf/plugin-interaction-manager';\nimport { useCapability, usePlugin } from '@embedpdf/core/svelte';\n\nexport const useInteractionManagerPlugin = () =>\n usePlugin<InteractionManagerPlugin>(InteractionManagerPlugin.id);\nexport const useInteractionManagerCapability = () =>\n useCapability<InteractionManagerPlugin>(InteractionManagerPlugin.id);\n\nexport function useInteractionManager() {\n const { provides } = $derived(useInteractionManagerCapability());\n let interactionManagerState = $state<InteractionManagerState>(initialState);\n\n $effect(() => {\n if (!provides) return;\n return provides.onStateChange((state) => {\n interactionManagerState = state;\n });\n });\n\n return {\n get provides() {\n return provides;\n },\n get state() {\n return interactionManagerState;\n },\n };\n}\n\nexport function useCursor() {\n const { provides } = $derived(useInteractionManagerCapability());\n return {\n setCursor: (token: string, cursor: string, prio = 0) => {\n provides?.setCursor(token, cursor, prio);\n },\n removeCursor: (token: string) => {\n provides?.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 } = $derived(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 return finalModeId\n ? provides?.registerHandlers({\n modeId: finalModeId,\n handlers,\n pageIndex: finalPageIndex,\n })\n : provides?.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 } = $derived(useInteractionManagerCapability());\n let isPageExclusive = $derived.by(() => {\n const m = cap?.getActiveInteractionMode();\n return m?.scope === 'page' && !!m.exclusive;\n });\n\n $effect(() => {\n if (!cap) return;\n\n return cap.onModeChange(() => {\n const mode = cap.getActiveInteractionMode();\n isPageExclusive = mode?.scope === 'page' && !!mode?.exclusive;\n });\n });\n\n return {\n get isPageExclusive() {\n return isPageExclusive;\n },\n };\n}\n","import { Position } from '@embedpdf/models';\nimport type {\n InteractionManagerCapability,\n InteractionScope,\n PointerEventHandlers,\n EmbedPdfPointerEvent,\n InteractionExclusionRules,\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 HAS_POINTER = typeof PointerEvent !== 'undefined';\n// If the browser supports Pointer Events, don't attach legacy touch events to avoid double-dispatch.\nconst allEventTypes = HAS_POINTER ? pointerEventTypes : [...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\nfunction isTouchEvent(evt: Event): evt is TouchEvent {\n return typeof TouchEvent !== 'undefined' && evt instanceof TouchEvent;\n}\n\n/**\n * Check if an element should be excluded based on rules\n * This is in the framework layer, not the plugin\n */\nfunction shouldExcludeElement(element: Element | null, rules: InteractionExclusionRules): boolean {\n if (!element) return false;\n\n let current: Element | null = element;\n\n while (current) {\n // Check classes\n if (rules.classes?.length) {\n for (const className of rules.classes) {\n if (current.classList?.contains(className)) {\n return true;\n }\n }\n }\n\n // Check data attributes\n if (rules.dataAttributes?.length) {\n for (const attr of rules.dataAttributes) {\n if (current.hasAttribute(attr)) {\n return true;\n }\n }\n }\n\n // Move up the DOM tree\n current = current.parentElement;\n }\n\n return 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 element.style.touchAction = attachedWithRawTouch ? 'none' : '';\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 element.style.touchAction = attachedWithRawTouch ? 'none' : '';\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 // Get exclusion rules from capability and check in framework layer\n const exclusionRules = cap.getExclusionRules();\n if (evt.target && shouldExcludeElement(evt.target as Element, exclusionRules)) {\n return; // Skip processing this event\n }\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 isTouchEvent(evt) &&\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 (isTouchEvent(evt)) {\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 setPointerCapture: () => {},\n releasePointerCapture: () => {},\n };\n } else {\n const pe = evt as PointerEvent;\n pos = toPos(pe, element);\n normEvt = {\n clientX: pe.clientX,\n clientY: pe.clientY,\n ctrlKey: pe.ctrlKey,\n shiftKey: pe.shiftKey,\n altKey: pe.altKey,\n metaKey: pe.metaKey,\n target: pe.target,\n currentTarget: pe.currentTarget,\n setPointerCapture: () => {\n (pe.target as HTMLElement)?.setPointerCapture?.(pe.pointerId);\n },\n releasePointerCapture: () => {\n (pe.target as HTMLElement)?.releasePointerCapture?.(pe.pointerId);\n },\n };\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","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import { useInteractionManagerCapability } from '../hooks';\n import { createPointerProvider } from '../../shared/utils';\n import type { HTMLAttributes } from 'svelte/elements';\n\n interface GlobalPointerProviderProps extends HTMLAttributes<HTMLDivElement> {\n children: Snippet;\n class?: string;\n }\n\n let { children, class: propsClass, ...restProps }: GlobalPointerProviderProps = $props();\n\n let ref = $state<HTMLDivElement | null>(null);\n const { provides: cap } = $derived(useInteractionManagerCapability());\n\n $effect(() => {\n if (!cap || !ref) return;\n\n return createPointerProvider(cap, { type: 'global' }, ref);\n });\n</script>\n\n<div bind:this={ref} style:width=\"100%\" style:height=\"100%\" class={propsClass} {...restProps}>\n {@render children()}\n</div>\n","<script lang=\"ts\">\n import { type Position, restorePosition, type Size, transformSize } from '@embedpdf/models';\n import type { Snippet } from 'svelte';\n import type { HTMLAttributes } from 'svelte/elements';\n import { createPointerProvider } from '../../shared/utils';\n import { useInteractionManagerCapability, useIsPageExclusive } from '../hooks';\n\n interface PagePointerProviderProps extends HTMLAttributes<HTMLDivElement> {\n children: Snippet;\n pageIndex: number;\n pageWidth: number;\n pageHeight: number;\n rotation: number;\n scale: number;\n class?: string;\n convertEventToPoint?: (event: PointerEvent, element: HTMLElement) => Position;\n }\n\n let {\n pageIndex,\n children,\n pageWidth,\n pageHeight,\n rotation,\n scale,\n convertEventToPoint,\n class: propsClass,\n ...restProps\n }: PagePointerProviderProps = $props();\n\n let ref = $state<HTMLDivElement | null>(null);\n\n const { provides: cap } = $derived(useInteractionManagerCapability());\n const isPageExclusive = $derived(useIsPageExclusive());\n\n // Memoize the default conversion function\n const defaultConvertEventToPoint = $derived.by(() => {\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\n const displaySize: Size = transformSize(\n { width: pageWidth, height: pageHeight },\n rotation,\n 1,\n );\n\n return restorePosition(displaySize, displayPoint, rotation, scale);\n };\n });\n\n $effect(() => {\n if (!cap || !ref) return;\n\n return createPointerProvider(\n cap,\n { type: 'page', pageIndex },\n ref,\n convertEventToPoint || defaultConvertEventToPoint,\n );\n });\n</script>\n\n<div\n bind:this={ref}\n style:position=\"relative\"\n style:width={`${pageWidth}px`}\n style:height={`${pageHeight}px`}\n class={propsClass}\n {...restProps}\n>\n {@render children()}\n {#if isPageExclusive}\n <div\n style:position=\"absolute\"\n style:top=\"0\"\n style:left=\"0\"\n style:right=\"0\"\n style:bottom=\"0\"\n style:z-index=\"10\"\n ></div>\n {/if}\n</div>\n"],"names":["_a"],"mappings":";;;;;;AAQa,MAAA,8BACX,MAAA,UAAoC,yBAAyB,EAAE;AACpD,MAAA,kCACX,MAAA,cAAwC,yBAAyB,EAAE;AAErD,SAAA,wBAAwB;wBACR,kCAAtB,sCAAA,QAAA;AACJ,MAAA,0CAA0D,YAAY,CAAA;AAE1E,IAAA,kBAAc;eACP,QAAU,EAAA;AACR,WAAA,EAAA,IAAA,QAAA,EAAS,cAAe,CAAA,UAAU;AACb,QAAA,IAAA,yBAAA,OAAA,IAAA;AAAA,KAC3B;AAAA,GACF;;IAGK,IAAA,WAAW;mBACN,QAAA;AAAA,IACT;AAAA,IACI,IAAA,QAAQ;mBACH,uBAAA;AAAA;;AAGb;AAEgB,SAAA,YAAY;0BACI,kCAAtB,wCAAA,QAAA;;IAEN,WAAW,CAAC,OAAe,QAAgB,OAAO,MAAM;;AAC5C,c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a,cAAY,QAAA,UAAA,QAAA,KAAA;AAAA,IACjD;AAAA,GACF;AAED,IAAA,YAAc,MAAA;AACP,QAAA,CAAA,EAAA,IAAA,GAAG,YAAK,GAAG,EAAA;WAET,sBAAqB,EAAA,IAC1B,GAAG,GAAA,EACD,MAAM,QAAQ,WAAS,QAAA,UAAA,GAAA,EAAA,IACzB,GAAG,GAAA,QAAA,uBAAA,EAAA,IACoB,0BAA0B,CAAA;AAAA,GAEpD;;8DASG,WAAS,CAAA,EAAA,KAAA,GAAA,GAAA,IAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;gBAGR,eAAe,EAAA,UAAA,UAAA;AAAA;;;AART,IAAA,UAAA,KAAA,CAAA,YAAA,EAAA,IAAA,2BAAA,GAAG,CAAA;;;AAHhB;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-interaction-manager",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -26,23 +26,30 @@
|
|
|
26
26
|
"types": "./dist/vue/index.d.ts",
|
|
27
27
|
"import": "./dist/vue/index.js",
|
|
28
28
|
"require": "./dist/vue/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./svelte": {
|
|
31
|
+
"types": "./dist/svelte/index.d.ts",
|
|
32
|
+
"svelte": "./dist/svelte/index.js",
|
|
33
|
+
"import": "./dist/svelte/index.js",
|
|
34
|
+
"require": "./dist/svelte/index.cjs"
|
|
29
35
|
}
|
|
30
36
|
},
|
|
31
37
|
"dependencies": {
|
|
32
|
-
"@embedpdf/models": "1.
|
|
38
|
+
"@embedpdf/models": "1.4.0"
|
|
33
39
|
},
|
|
34
40
|
"devDependencies": {
|
|
35
41
|
"@types/react": "^18.2.0",
|
|
36
42
|
"typescript": "^5.0.0",
|
|
37
|
-
"@embedpdf/
|
|
38
|
-
"@embedpdf/
|
|
43
|
+
"@embedpdf/core": "1.4.0",
|
|
44
|
+
"@embedpdf/build": "1.1.0"
|
|
39
45
|
},
|
|
40
46
|
"peerDependencies": {
|
|
41
47
|
"react": ">=16.8.0",
|
|
42
48
|
"react-dom": ">=16.8.0",
|
|
43
49
|
"preact": "^10.26.4",
|
|
44
50
|
"vue": ">=3.2.0",
|
|
45
|
-
"
|
|
51
|
+
"svelte": ">=5 <6",
|
|
52
|
+
"@embedpdf/core": "1.4.0"
|
|
46
53
|
},
|
|
47
54
|
"files": [
|
|
48
55
|
"dist",
|
|
@@ -65,7 +72,8 @@
|
|
|
65
72
|
"build:react": "vite build --mode react",
|
|
66
73
|
"build:preact": "vite build --mode preact",
|
|
67
74
|
"build:vue": "vite build --mode vue",
|
|
68
|
-
"build": "
|
|
75
|
+
"build:svelte": "vite build --mode svelte",
|
|
76
|
+
"build": "pnpm run clean && concurrently -c auto -n base,react,preact,vue,svelte \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\" \"vite build --mode vue\" \"vite build --mode svelte\"",
|
|
69
77
|
"clean": "rimraf dist",
|
|
70
78
|
"lint": "eslint src --color",
|
|
71
79
|
"lint:fix": "eslint src --color --fix"
|