@embedpdf/plugin-interaction-manager 1.3.15 → 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/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t="INTERACTION/ACTIVATE_MODE",s="INTERACTION/PAUSE",a="INTERACTION/RESUME",o="INTERACTION/SET_CURSOR",i="INTERACTION/SET_DEFAULT_MODE",r="INTERACTION/SET_EXCLUSION_RULES",n="INTERACTION/ADD_EXCLUSION_CLASS",l="INTERACTION/REMOVE_EXCLUSION_CLASS",c="INTERACTION/ADD_EXCLUSION_ATTRIBUTE",u="INTERACTION/REMOVE_EXCLUSION_ATTRIBUTE",d=e=>({type:r,payload:{rules:e}});const h="pointerMode",g=class extends e.BasePlugin{constructor(t,s,a){super(t,s),this.modes=new Map,this.cursorClaims=new Map,this.buckets=new Map,this.alwaysGlobal=new Set,this.alwaysPage=new Map,this.onModeChange$=e.createEmitter(),this.onHandlerChange$=e.createEmitter(),this.onCursorChange$=e.createEmitter(),this.onStateChange$=e.createBehaviorEmitter(),this.registerMode({id:h,scope:"page",exclusive:!1,cursor:"auto"}),this.setDefaultMode(h),this.activate(h),a.exclusionRules&&this.dispatch(d(a.exclusionRules))}async initialize(e){}buildCapability(){return{activate:e=>this.activate(e),onModeChange:this.onModeChange$.on,onCursorChange:this.onCursorChange$.on,onHandlerChange:this.onHandlerChange$.on,onStateChange:this.onStateChange$.on,getActiveMode:()=>this.state.activeMode,getActiveInteractionMode:()=>this.getActiveInteractionMode(),activateDefaultMode:()=>this.activate(this.state.defaultMode),registerMode:e=>this.registerMode(e),registerHandlers:e=>this.registerHandlers(e),registerAlways:e=>this.registerAlways(e),setCursor:(e,t,s=0)=>this.setCursor(e,t,s),removeCursor:e=>this.removeCursor(e),getCurrentCursor:()=>this.state.cursor,getHandlersForScope:e=>this.getHandlersForScope(e),activeModeIsExclusive:()=>this.activeModeIsExclusive(),pause:()=>this.dispatch({type:s}),resume:()=>this.dispatch({type:a}),isPaused:()=>this.state.paused,setDefaultMode:e=>this.setDefaultMode(e),getDefaultMode:()=>this.state.defaultMode,getExclusionRules:()=>this.state.exclusionRules,setExclusionRules:e=>this.dispatch(d(e)),addExclusionClass:e=>this.dispatch((e=>({type:n,payload:{className:e}}))(e)),removeExclusionClass:e=>this.dispatch((e=>({type:l,payload:{className:e}}))(e)),addExclusionAttribute:e=>this.dispatch((e=>({type:c,payload:{attribute:e}}))(e)),removeExclusionAttribute:e=>this.dispatch((e=>({type:u,payload:{attribute:e}}))(e))}}activate(e){if(!this.modes.has(e))throw new Error(`[interaction] unknown mode '${e}'`);if(e===this.state.activeMode)return;const s=this.state.activeMode;this.cursorClaims.clear(),this.notifyHandlersInactive(s),this.dispatch((e=>({type:t,payload:{mode:e}}))(e)),this.emitCursor(),this.notifyHandlersActive(e),this.onModeChange$.emit({...this.state,activeMode:e})}setDefaultMode(e){if(!this.modes.has(e))throw new Error(`[interaction] cannot set unknown mode '${e}' as default`);this.dispatch({type:i,payload:{mode:e}})}notifyHandlersActive(e){this.alwaysGlobal.forEach((t=>{var s;null==(s=t.onHandlerActiveStart)||s.call(t,e)})),this.alwaysPage.forEach((t=>{t.forEach((t=>{var s;null==(s=t.onHandlerActiveStart)||s.call(t,e)}))}));const t=this.modes.get(e);if(!t)return;const s=this.buckets.get(e);s&&("global"===t.scope&&s.global.forEach((t=>{var s;null==(s=t.onHandlerActiveStart)||s.call(t,e)})),"page"===t.scope&&s.page.forEach(((t,s)=>{t.forEach((t=>{var s;null==(s=t.onHandlerActiveStart)||s.call(t,e)}))})))}notifyHandlersInactive(e){this.alwaysGlobal.forEach((t=>{var s;null==(s=t.onHandlerActiveEnd)||s.call(t,e)})),this.alwaysPage.forEach((t=>{t.forEach((t=>{var s;null==(s=t.onHandlerActiveEnd)||s.call(t,e)}))}));const t=this.modes.get(e);if(!t)return;const s=this.buckets.get(e);s&&("global"===t.scope&&s.global.forEach((t=>{var s;null==(s=t.onHandlerActiveEnd)||s.call(t,e)})),"page"===t.scope&&s.page.forEach(((t,s)=>{t.forEach((t=>{var s;null==(s=t.onHandlerActiveEnd)||s.call(t,e)}))})))}registerMode(e){this.modes.set(e.id,e),this.buckets.has(e.id)||this.buckets.set(e.id,{global:new Set,page:new Map})}registerHandlers({modeId:e,handlers:t,pageIndex:s}){const a=Array.isArray(e)?e:[e],o=[];for(const i of a){const e=this.buckets.get(i);if(!e)throw new Error(`unknown mode '${i}'`);if(null==s)e.global.add(t);else{const a=e.page.get(s)??new Set;a.add(t),e.page.set(s,a)}o.push((()=>{if(null==s)e.global.delete(t);else{const a=e.page.get(s);a&&(a.delete(t),0===a.size&&e.page.delete(s))}}))}return this.onHandlerChange$.emit({...this.state}),()=>{o.forEach((e=>e())),this.onHandlerChange$.emit({...this.state})}}registerAlways({scope:e,handlers:t}){if("global"===e.type)return this.alwaysGlobal.add(t),this.onHandlerChange$.emit({...this.state}),()=>this.alwaysGlobal.delete(t);const s=this.alwaysPage.get(e.pageIndex)??new Set;return s.add(t),this.alwaysPage.set(e.pageIndex,s),this.onHandlerChange$.emit({...this.state}),()=>{s.delete(t),this.onHandlerChange$.emit({...this.state})}}getHandlersForScope(e){if(!this.state)return null;const t=this.modes.get(this.state.activeMode);if(!t)return null;const s=this.buckets.get(t.id);if(!s)return null;const a=(e,t)=>e.size||t.size?function(e){const t=["onPointerDown","onPointerUp","onPointerMove","onPointerEnter","onPointerLeave","onPointerCancel","onMouseDown","onMouseUp","onMouseMove","onMouseEnter","onMouseLeave","onMouseCancel","onClick","onDoubleClick"],s={};for(const a of t)s[a]=(t,s,o)=>{var i;for(const r of e)null==(i=r[a])||i.call(r,t,s,o)};return s}([...e,...t]):null;if("global"===e.type){const e="global"===t.scope?s.global:new Set;return a(this.alwaysGlobal,e)}return a(this.alwaysPage.get(e.pageIndex)??new Set,"page"===t.scope?s.page.get(e.pageIndex)??new Set:new Set)}setCursor(e,t,s=0){this.cursorClaims.set(e,{cursor:t,priority:s}),this.emitCursor()}removeCursor(e){this.cursorClaims.delete(e),this.emitCursor()}emitCursor(){var e;const t=[...this.cursorClaims.values()].sort(((e,t)=>t.priority-e.priority))[0]??{cursor:(null==(e=this.modes.get(this.state.activeMode))?void 0:e.cursor)??"auto"};var s;t.cursor!==this.state.cursor&&(this.dispatch((s=t.cursor,{type:o,payload:{cursor:s}})),this.onCursorChange$.emit(t.cursor))}onStoreUpdated(e,t){this.onStateChange$.emit(t)}activeModeIsExclusive(){const e=this.modes.get(this.state.activeMode);return!!(null==e?void 0:e.exclusive)}getActiveInteractionMode(){return this.modes.get(this.state.activeMode)??null}async destroy(){this.onModeChange$.clear(),this.onCursorChange$.clear(),await super.destroy()}};g.id="interaction-manager";let p=g;const C="interaction-manager",E={id:C,name:"Interaction Manager Plugin",version:"1.0.0",provides:["interaction-manager"],requires:[],optional:[],defaultConfig:{enabled:!0,exclusionRules:{classes:[],dataAttributes:["data-no-interaction"]}}},v={activeMode:"pointerMode",defaultMode:"pointerMode",cursor:"auto",paused:!1,exclusionRules:{classes:[],dataAttributes:[]}},M=(e,d)=>{switch(d.type){case t:return{...e,activeMode:d.payload.mode};case o:return{...e,cursor:d.payload.cursor};case s:return{...e,paused:!0};case a:return{...e,paused:!1};case i:return{...e,defaultMode:d.payload.mode};case r:return{...e,exclusionRules:d.payload.rules};case n:return{...e,exclusionRules:{...e.exclusionRules,classes:[...e.exclusionRules.classes||[],d.payload.className].filter(((e,t,s)=>s.indexOf(e)===t))}};case l:return{...e,exclusionRules:{...e.exclusionRules,classes:(e.exclusionRules.classes||[]).filter((e=>e!==d.payload.className))}};case c:return{...e,exclusionRules:{...e.exclusionRules,dataAttributes:[...e.exclusionRules.dataAttributes||[],d.payload.attribute].filter(((e,t,s)=>s.indexOf(e)===t))}};case u:return{...e,exclusionRules:{...e.exclusionRules,dataAttributes:(e.exclusionRules.dataAttributes||[]).filter((e=>e!==d.payload.attribute))}};default:return e}},f={manifest:E,create:(e,t)=>new p(C,e,t),reducer:M,initialState:v};exports.INTERACTION_MANAGER_PLUGIN_ID=C,exports.InteractionManagerPlugin=p,exports.InteractionManagerPluginPackage=f,exports.initialState=v,exports.manifest=E,exports.reducer=M;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t="INTERACTION/ACTIVATE_MODE",s="INTERACTION/PAUSE",a="INTERACTION/RESUME",o="INTERACTION/SET_CURSOR",i="INTERACTION/SET_DEFAULT_MODE",r="INTERACTION/SET_EXCLUSION_RULES",n="INTERACTION/ADD_EXCLUSION_CLASS",l="INTERACTION/REMOVE_EXCLUSION_CLASS",c="INTERACTION/ADD_EXCLUSION_ATTRIBUTE",u="INTERACTION/REMOVE_EXCLUSION_ATTRIBUTE",d=e=>({type:r,payload:{rules:e}});const h="pointerMode",g=class extends e.BasePlugin{constructor(t,s,a){super(t,s),this.modes=new Map,this.cursorClaims=new Map,this.buckets=new Map,this.alwaysGlobal=new Set,this.alwaysPage=new Map,this.onModeChange$=e.createEmitter(),this.onHandlerChange$=e.createEmitter(),this.onCursorChange$=e.createEmitter(),this.onStateChange$=e.createBehaviorEmitter(),this.registerMode({id:h,scope:"page",exclusive:!1,cursor:"auto"}),this.setDefaultMode(h),this.activate(h),a.exclusionRules&&this.dispatch(d(a.exclusionRules))}async initialize(e){}buildCapability(){return{activate:e=>this.activate(e),onModeChange:this.onModeChange$.on,onCursorChange:this.onCursorChange$.on,onHandlerChange:this.onHandlerChange$.on,onStateChange:this.onStateChange$.on,getActiveMode:()=>this.state.activeMode,getActiveInteractionMode:()=>this.getActiveInteractionMode(),activateDefaultMode:()=>this.activate(this.state.defaultMode),registerMode:e=>this.registerMode(e),registerHandlers:e=>this.registerHandlers(e),registerAlways:e=>this.registerAlways(e),setCursor:(e,t,s=0)=>this.setCursor(e,t,s),removeCursor:e=>this.removeCursor(e),getCurrentCursor:()=>this.state.cursor,getHandlersForScope:e=>this.getHandlersForScope(e),activeModeIsExclusive:()=>this.activeModeIsExclusive(),pause:()=>this.dispatch({type:s}),resume:()=>this.dispatch({type:a}),isPaused:()=>this.registry.isDestroyed()||this.state.paused,setDefaultMode:e=>this.setDefaultMode(e),getDefaultMode:()=>this.state.defaultMode,getExclusionRules:()=>this.state.exclusionRules,setExclusionRules:e=>this.dispatch(d(e)),addExclusionClass:e=>this.dispatch((e=>({type:n,payload:{className:e}}))(e)),removeExclusionClass:e=>this.dispatch((e=>({type:l,payload:{className:e}}))(e)),addExclusionAttribute:e=>this.dispatch((e=>({type:c,payload:{attribute:e}}))(e)),removeExclusionAttribute:e=>this.dispatch((e=>({type:u,payload:{attribute:e}}))(e))}}activate(e){if(!this.modes.has(e))throw new Error(`[interaction] unknown mode '${e}'`);if(e===this.state.activeMode)return;const s=this.state.activeMode;this.cursorClaims.clear(),this.notifyHandlersInactive(s),this.dispatch((e=>({type:t,payload:{mode:e}}))(e)),this.emitCursor(),this.notifyHandlersActive(e),this.onModeChange$.emit({...this.state,activeMode:e})}setDefaultMode(e){if(!this.modes.has(e))throw new Error(`[interaction] cannot set unknown mode '${e}' as default`);this.dispatch({type:i,payload:{mode:e}})}notifyHandlersActive(e){this.alwaysGlobal.forEach((t=>{var s;null==(s=t.onHandlerActiveStart)||s.call(t,e)})),this.alwaysPage.forEach((t=>{t.forEach((t=>{var s;null==(s=t.onHandlerActiveStart)||s.call(t,e)}))}));const t=this.modes.get(e);if(!t)return;const s=this.buckets.get(e);s&&("global"===t.scope&&s.global.forEach((t=>{var s;null==(s=t.onHandlerActiveStart)||s.call(t,e)})),"page"===t.scope&&s.page.forEach(((t,s)=>{t.forEach((t=>{var s;null==(s=t.onHandlerActiveStart)||s.call(t,e)}))})))}notifyHandlersInactive(e){this.alwaysGlobal.forEach((t=>{var s;null==(s=t.onHandlerActiveEnd)||s.call(t,e)})),this.alwaysPage.forEach((t=>{t.forEach((t=>{var s;null==(s=t.onHandlerActiveEnd)||s.call(t,e)}))}));const t=this.modes.get(e);if(!t)return;const s=this.buckets.get(e);s&&("global"===t.scope&&s.global.forEach((t=>{var s;null==(s=t.onHandlerActiveEnd)||s.call(t,e)})),"page"===t.scope&&s.page.forEach(((t,s)=>{t.forEach((t=>{var s;null==(s=t.onHandlerActiveEnd)||s.call(t,e)}))})))}registerMode(e){this.modes.set(e.id,e),this.buckets.has(e.id)||this.buckets.set(e.id,{global:new Set,page:new Map})}registerHandlers({modeId:e,handlers:t,pageIndex:s}){const a=Array.isArray(e)?e:[e],o=[];for(const i of a){const e=this.buckets.get(i);if(!e)throw new Error(`unknown mode '${i}'`);if(null==s)e.global.add(t);else{const a=e.page.get(s)??new Set;a.add(t),e.page.set(s,a)}o.push((()=>{if(null==s)e.global.delete(t);else{const a=e.page.get(s);a&&(a.delete(t),0===a.size&&e.page.delete(s))}}))}return this.onHandlerChange$.emit({...this.state}),()=>{o.forEach((e=>e())),this.onHandlerChange$.emit({...this.state})}}registerAlways({scope:e,handlers:t}){if("global"===e.type)return this.alwaysGlobal.add(t),this.onHandlerChange$.emit({...this.state}),()=>this.alwaysGlobal.delete(t);const s=this.alwaysPage.get(e.pageIndex)??new Set;return s.add(t),this.alwaysPage.set(e.pageIndex,s),this.onHandlerChange$.emit({...this.state}),()=>{s.delete(t),this.onHandlerChange$.emit({...this.state})}}getHandlersForScope(e){if(!this.state)return null;const t=this.modes.get(this.state.activeMode);if(!t)return null;const s=this.buckets.get(t.id);if(!s)return null;const a=(e,t)=>e.size||t.size?function(e){const t=["onPointerDown","onPointerUp","onPointerMove","onPointerEnter","onPointerLeave","onPointerCancel","onMouseDown","onMouseUp","onMouseMove","onMouseEnter","onMouseLeave","onMouseCancel","onClick","onDoubleClick"],s={};for(const a of t)s[a]=(t,s,o)=>{var i;for(const r of e)null==(i=r[a])||i.call(r,t,s,o)};return s}([...e,...t]):null;if("global"===e.type){const e="global"===t.scope?s.global:new Set;return a(this.alwaysGlobal,e)}return a(this.alwaysPage.get(e.pageIndex)??new Set,"page"===t.scope?s.page.get(e.pageIndex)??new Set:new Set)}setCursor(e,t,s=0){this.cursorClaims.set(e,{cursor:t,priority:s}),this.emitCursor()}removeCursor(e){this.cursorClaims.delete(e),this.emitCursor()}emitCursor(){var e;const t=[...this.cursorClaims.values()].sort(((e,t)=>t.priority-e.priority))[0]??{cursor:(null==(e=this.modes.get(this.state.activeMode))?void 0:e.cursor)??"auto"};var s;t.cursor!==this.state.cursor&&(this.dispatch((s=t.cursor,{type:o,payload:{cursor:s}})),this.onCursorChange$.emit(t.cursor))}onStoreUpdated(e,t){this.onStateChange$.emit(t)}activeModeIsExclusive(){const e=this.modes.get(this.state.activeMode);return!!(null==e?void 0:e.exclusive)}getActiveInteractionMode(){return this.modes.get(this.state.activeMode)??null}async destroy(){this.onModeChange$.clear(),this.onCursorChange$.clear(),await super.destroy()}};g.id="interaction-manager";let p=g;const C="interaction-manager",E={id:C,name:"Interaction Manager Plugin",version:"1.0.0",provides:["interaction-manager"],requires:[],optional:[],defaultConfig:{enabled:!0,exclusionRules:{classes:[],dataAttributes:["data-no-interaction"]}}},v={activeMode:"pointerMode",defaultMode:"pointerMode",cursor:"auto",paused:!1,exclusionRules:{classes:[],dataAttributes:[]}},y=(e,d)=>{switch(d.type){case t:return{...e,activeMode:d.payload.mode};case o:return{...e,cursor:d.payload.cursor};case s:return{...e,paused:!0};case a:return{...e,paused:!1};case i:return{...e,defaultMode:d.payload.mode};case r:return{...e,exclusionRules:d.payload.rules};case n:return{...e,exclusionRules:{...e.exclusionRules,classes:[...e.exclusionRules.classes||[],d.payload.className].filter(((e,t,s)=>s.indexOf(e)===t))}};case l:return{...e,exclusionRules:{...e.exclusionRules,classes:(e.exclusionRules.classes||[]).filter((e=>e!==d.payload.className))}};case c:return{...e,exclusionRules:{...e.exclusionRules,dataAttributes:[...e.exclusionRules.dataAttributes||[],d.payload.attribute].filter(((e,t,s)=>s.indexOf(e)===t))}};case u:return{...e,exclusionRules:{...e.exclusionRules,dataAttributes:(e.exclusionRules.dataAttributes||[]).filter((e=>e!==d.payload.attribute))}};default:return e}},M={manifest:E,create:(e,t)=>new p(C,e,t),reducer:y,initialState:v};exports.INTERACTION_MANAGER_PLUGIN_ID=C,exports.InteractionManagerPlugin=p,exports.InteractionManagerPluginPackage=M,exports.initialState=v,exports.manifest=E,exports.reducer=y;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/lib/actions.ts","../src/lib/interaction-manager-plugin.ts","../src/lib/helper.ts","../src/lib/manifest.ts","../src/lib/reducer.ts","../src/lib/index.ts"],"sourcesContent":["import { Action } from '@embedpdf/core';\nimport { InteractionExclusionRules } from './types';\n\nexport const ACTIVATE_MODE = 'INTERACTION/ACTIVATE_MODE';\nexport const PAUSE_INTERACTION = 'INTERACTION/PAUSE';\nexport const RESUME_INTERACTION = 'INTERACTION/RESUME';\nexport const SET_CURSOR = 'INTERACTION/SET_CURSOR';\nexport const SET_DEFAULT_MODE = 'INTERACTION/SET_DEFAULT_MODE';\nexport const SET_EXCLUSION_RULES = 'INTERACTION/SET_EXCLUSION_RULES';\nexport const ADD_EXCLUSION_CLASS = 'INTERACTION/ADD_EXCLUSION_CLASS';\nexport const REMOVE_EXCLUSION_CLASS = 'INTERACTION/REMOVE_EXCLUSION_CLASS';\nexport const ADD_EXCLUSION_ATTRIBUTE = 'INTERACTION/ADD_EXCLUSION_ATTRIBUTE';\nexport const REMOVE_EXCLUSION_ATTRIBUTE = 'INTERACTION/REMOVE_EXCLUSION_ATTRIBUTE';\n\nexport interface SetExclusionRulesAction extends Action {\n type: typeof SET_EXCLUSION_RULES;\n payload: { rules: InteractionExclusionRules };\n}\n\nexport interface AddExclusionClassAction extends Action {\n type: typeof ADD_EXCLUSION_CLASS;\n payload: { className: string };\n}\n\nexport interface RemoveExclusionClassAction extends Action {\n type: typeof REMOVE_EXCLUSION_CLASS;\n payload: { className: string };\n}\n\nexport interface AddExclusionAttributeAction extends Action {\n type: typeof ADD_EXCLUSION_ATTRIBUTE;\n payload: { attribute: string };\n}\n\nexport interface RemoveExclusionAttributeAction extends Action {\n type: typeof REMOVE_EXCLUSION_ATTRIBUTE;\n payload: { attribute: string };\n}\n\nexport interface ActivateModeAction extends Action {\n type: typeof ACTIVATE_MODE;\n payload: { mode: string };\n}\n\nexport interface PauseInteractionAction extends Action {\n type: typeof PAUSE_INTERACTION;\n}\n\nexport interface ResumeInteractionAction extends Action {\n type: typeof RESUME_INTERACTION;\n}\n\nexport interface SetCursorAction extends Action {\n type: typeof SET_CURSOR;\n payload: { cursor: string };\n}\n\nexport interface SetDefaultModeAction extends Action {\n type: typeof SET_DEFAULT_MODE;\n payload: { mode: string };\n}\n\nexport const setExclusionRules = (rules: InteractionExclusionRules): SetExclusionRulesAction => ({\n type: SET_EXCLUSION_RULES,\n payload: { rules },\n});\n\nexport const addExclusionClass = (className: string): AddExclusionClassAction => ({\n type: ADD_EXCLUSION_CLASS,\n payload: { className },\n});\n\nexport const removeExclusionClass = (className: string): RemoveExclusionClassAction => ({\n type: REMOVE_EXCLUSION_CLASS,\n payload: { className },\n});\n\nexport const addExclusionAttribute = (attribute: string): AddExclusionAttributeAction => ({\n type: ADD_EXCLUSION_ATTRIBUTE,\n payload: { attribute },\n});\n\nexport const removeExclusionAttribute = (attribute: string): RemoveExclusionAttributeAction => ({\n type: REMOVE_EXCLUSION_ATTRIBUTE,\n payload: { attribute },\n});\n\nexport const activateMode = (mode: string): ActivateModeAction => ({\n type: ACTIVATE_MODE,\n payload: { mode },\n});\n\nexport const setCursor = (cursor: string): SetCursorAction => ({\n type: SET_CURSOR,\n payload: { cursor },\n});\n\nexport const setDefaultMode = (mode: string): SetDefaultModeAction => ({\n type: SET_DEFAULT_MODE,\n payload: { mode },\n});\n\nexport const pauseInteraction = (): PauseInteractionAction => ({\n type: PAUSE_INTERACTION,\n});\n\nexport const resumeInteraction = (): ResumeInteractionAction => ({\n type: RESUME_INTERACTION,\n});\n\nexport type InteractionManagerAction =\n | SetExclusionRulesAction\n | AddExclusionClassAction\n | RemoveExclusionClassAction\n | AddExclusionAttributeAction\n | RemoveExclusionAttributeAction\n | ActivateModeAction\n | PauseInteractionAction\n | ResumeInteractionAction\n | SetCursorAction\n | SetDefaultModeAction;\n","import { BasePlugin, createBehaviorEmitter, createEmitter, PluginRegistry } from '@embedpdf/core';\n\nimport {\n InteractionExclusionRules,\n InteractionManagerCapability,\n InteractionManagerPluginConfig,\n InteractionManagerState,\n InteractionMode,\n InteractionScope,\n PointerEventHandlers,\n PointerEventHandlersWithLifecycle,\n RegisterAlwaysOptions,\n RegisterHandlersOptions,\n} from './types';\nimport {\n activateMode,\n addExclusionAttribute,\n addExclusionClass,\n pauseInteraction,\n removeExclusionAttribute,\n removeExclusionClass,\n resumeInteraction,\n setCursor,\n setDefaultMode,\n setExclusionRules,\n} from './actions';\nimport { mergeHandlers } from './helper';\n\ninterface CursorClaim {\n cursor: string;\n priority: number;\n}\n\ntype HandlerSet = Set<PointerEventHandlersWithLifecycle>;\ntype PageHandlerMap = Map<number /*pageIdx*/, HandlerSet>;\n\ninterface ModeBuckets {\n /** handlers that listen on the global wrapper (only once per viewer) */\n global: HandlerSet;\n /** handlers that listen on a *specific* page wrapper */\n page: PageHandlerMap;\n}\n\nconst INITIAL_MODE = 'pointerMode';\n\nexport class InteractionManagerPlugin extends BasePlugin<\n InteractionManagerPluginConfig,\n InteractionManagerCapability,\n InteractionManagerState\n> {\n static readonly id = 'interaction-manager' as const;\n\n private modes = new Map<string, InteractionMode>();\n private cursorClaims = new Map<string, CursorClaim>();\n private buckets = new Map<string, ModeBuckets>();\n\n private alwaysGlobal = new Set<PointerEventHandlersWithLifecycle>();\n private alwaysPage = new Map<number, Set<PointerEventHandlersWithLifecycle>>();\n\n private readonly onModeChange$ = createEmitter<InteractionManagerState>();\n private readonly onHandlerChange$ = createEmitter<InteractionManagerState>();\n private readonly onCursorChange$ = createEmitter<string>();\n private readonly onStateChange$ = createBehaviorEmitter<InteractionManagerState>();\n\n constructor(id: string, registry: PluginRegistry, config: InteractionManagerPluginConfig) {\n super(id, registry);\n\n this.registerMode({\n id: INITIAL_MODE,\n scope: 'page',\n exclusive: false,\n cursor: 'auto',\n });\n\n this.setDefaultMode(INITIAL_MODE);\n this.activate(INITIAL_MODE);\n if (config.exclusionRules) {\n this.dispatch(setExclusionRules(config.exclusionRules));\n }\n }\n\n async initialize(_: InteractionManagerPluginConfig): Promise<void> {}\n\n protected buildCapability(): InteractionManagerCapability {\n return {\n activate: (modeId: string) => this.activate(modeId),\n onModeChange: this.onModeChange$.on,\n onCursorChange: this.onCursorChange$.on,\n onHandlerChange: this.onHandlerChange$.on,\n onStateChange: this.onStateChange$.on,\n getActiveMode: () => this.state.activeMode,\n getActiveInteractionMode: () => this.getActiveInteractionMode(),\n activateDefaultMode: () => this.activate(this.state.defaultMode),\n registerMode: (mode: InteractionMode) => this.registerMode(mode),\n registerHandlers: (options: RegisterHandlersOptions) => this.registerHandlers(options),\n registerAlways: (options: RegisterAlwaysOptions) => this.registerAlways(options),\n setCursor: (token: string, cursor: string, priority = 0) =>\n this.setCursor(token, cursor, priority),\n removeCursor: (token: string) => this.removeCursor(token),\n getCurrentCursor: () => this.state.cursor,\n getHandlersForScope: (scope: InteractionScope) => this.getHandlersForScope(scope),\n activeModeIsExclusive: () => this.activeModeIsExclusive(),\n pause: () => this.dispatch(pauseInteraction()),\n resume: () => this.dispatch(resumeInteraction()),\n isPaused: () => this.state.paused,\n setDefaultMode: (id: string) => this.setDefaultMode(id),\n getDefaultMode: () => this.state.defaultMode,\n getExclusionRules: () => this.state.exclusionRules,\n setExclusionRules: (rules: InteractionExclusionRules) =>\n this.dispatch(setExclusionRules(rules)),\n addExclusionClass: (className: string) => this.dispatch(addExclusionClass(className)),\n removeExclusionClass: (className: string) => this.dispatch(removeExclusionClass(className)),\n addExclusionAttribute: (attribute: string) => this.dispatch(addExclusionAttribute(attribute)),\n removeExclusionAttribute: (attribute: string) =>\n this.dispatch(removeExclusionAttribute(attribute)),\n };\n }\n\n private activate(mode: string) {\n if (!this.modes.has(mode)) {\n throw new Error(`[interaction] unknown mode '${mode}'`);\n }\n if (mode === this.state.activeMode) return;\n\n const previousMode = this.state.activeMode;\n this.cursorClaims.clear(); // prevent cursor leaks\n\n this.notifyHandlersInactive(previousMode);\n\n this.dispatch(activateMode(mode));\n this.emitCursor();\n\n // Call lifecycle hooks for handlers going active\n this.notifyHandlersActive(mode);\n\n this.onModeChange$.emit({ ...this.state, activeMode: mode });\n }\n\n private setDefaultMode(modeId: string) {\n if (!this.modes.has(modeId)) {\n throw new Error(`[interaction] cannot set unknown mode '${modeId}' as default`);\n }\n this.dispatch(setDefaultMode(modeId));\n }\n\n private notifyHandlersActive(modeId: string) {\n this.alwaysGlobal.forEach((handler) => {\n handler.onHandlerActiveStart?.(modeId);\n });\n\n this.alwaysPage.forEach((handlerSet) => {\n handlerSet.forEach((handler) => {\n handler.onHandlerActiveStart?.(modeId);\n });\n });\n\n const mode = this.modes.get(modeId);\n if (!mode) return;\n\n const bucket = this.buckets.get(modeId);\n if (!bucket) return;\n\n // Notify global handlers if mode is global\n if (mode.scope === 'global') {\n bucket.global.forEach((handler) => {\n handler.onHandlerActiveStart?.(modeId);\n });\n }\n\n // Notify page handlers if mode is page\n if (mode.scope === 'page') {\n bucket.page.forEach((handlerSet, pageIndex) => {\n handlerSet.forEach((handler) => {\n handler.onHandlerActiveStart?.(modeId);\n });\n });\n }\n }\n\n private notifyHandlersInactive(modeId: string) {\n this.alwaysGlobal.forEach((handler) => {\n handler.onHandlerActiveEnd?.(modeId);\n });\n\n this.alwaysPage.forEach((handlerSet) => {\n handlerSet.forEach((handler) => {\n handler.onHandlerActiveEnd?.(modeId);\n });\n });\n\n const mode = this.modes.get(modeId);\n if (!mode) return;\n\n const bucket = this.buckets.get(modeId);\n if (!bucket) return;\n\n // Notify global handlers if mode is global\n if (mode.scope === 'global') {\n bucket.global.forEach((handler) => {\n handler.onHandlerActiveEnd?.(modeId);\n });\n }\n\n // Notify page handlers if mode is page\n if (mode.scope === 'page') {\n bucket.page.forEach((handlerSet, pageIndex) => {\n handlerSet.forEach((handler) => {\n handler.onHandlerActiveEnd?.(modeId);\n });\n });\n }\n }\n\n private registerMode(mode: InteractionMode) {\n this.modes.set(mode.id, mode);\n if (!this.buckets.has(mode.id)) {\n this.buckets.set(mode.id, { global: new Set(), page: new Map() });\n }\n }\n\n /** ---------- pointer-handler handling ------------ */\n private registerHandlers({ modeId, handlers, pageIndex }: RegisterHandlersOptions): () => void {\n const modeIds = Array.isArray(modeId) ? modeId : [modeId];\n const cleanupFunctions: (() => void)[] = [];\n\n for (const id of modeIds) {\n const bucket = this.buckets.get(id);\n if (!bucket) throw new Error(`unknown mode '${id}'`);\n\n if (pageIndex == null) {\n bucket.global.add(handlers);\n } else {\n const set = bucket.page.get(pageIndex) ?? new Set();\n set.add(handlers);\n bucket.page.set(pageIndex, set);\n }\n\n // Create cleanup function for this specific mode\n cleanupFunctions.push(() => {\n if (pageIndex == null) {\n bucket.global.delete(handlers);\n } else {\n const set = bucket.page.get(pageIndex);\n if (set) {\n set.delete(handlers);\n if (set.size === 0) {\n bucket.page.delete(pageIndex);\n }\n }\n }\n });\n }\n\n this.onHandlerChange$.emit({ ...this.state });\n\n // Return a cleanup function that removes handlers from all registered modes\n return () => {\n cleanupFunctions.forEach((cleanup) => cleanup());\n this.onHandlerChange$.emit({ ...this.state });\n };\n }\n\n public registerAlways({ scope, handlers }: RegisterAlwaysOptions): () => void {\n if (scope.type === 'global') {\n this.alwaysGlobal.add(handlers);\n this.onHandlerChange$.emit({ ...this.state });\n return () => this.alwaysGlobal.delete(handlers);\n }\n const set = this.alwaysPage.get(scope.pageIndex) ?? new Set();\n set.add(handlers);\n this.alwaysPage.set(scope.pageIndex, set);\n this.onHandlerChange$.emit({ ...this.state });\n return () => {\n set.delete(handlers);\n this.onHandlerChange$.emit({ ...this.state });\n };\n }\n\n /** Returns the *merged* handler set that should be active for the given\n * provider (`global` wrapper or a single page wrapper).\n * – `alwaysGlobal` / `alwaysPage` are **always** active.\n * – Handlers that belong to the current mode are added on top **iff**\n * the mode’s own scope matches the provider’s scope. */\n private getHandlersForScope(scope: InteractionScope): PointerEventHandlers | null {\n if (!this.state) return null;\n\n const mode = this.modes.get(this.state.activeMode);\n if (!mode) return null;\n\n const bucket = this.buckets.get(mode.id);\n if (!bucket) return null;\n\n /** helper – merge two handler sets into one object (or `null` if both are empty) */\n const mergeSets = (a: HandlerSet, b: HandlerSet) =>\n a.size || b.size ? mergeHandlers([...a, ...b]) : null;\n\n /* ───────────────────── GLOBAL PROVIDER ─────────────────────── */\n if (scope.type === 'global') {\n const modeSpecific =\n mode.scope === 'global' // only include mode handlers if the\n ? bucket.global // mode itself is global-scoped\n : new Set<PointerEventHandlers>();\n return mergeSets(this.alwaysGlobal, modeSpecific);\n }\n\n /* ─────────────────────── PAGE PROVIDER ──────────────────────── */\n const alwaysPageSet = this.alwaysPage.get(scope.pageIndex) ?? new Set<PointerEventHandlers>();\n const modePageSet =\n mode.scope === 'page'\n ? (bucket.page.get(scope.pageIndex) ?? new Set<PointerEventHandlers>())\n : new Set<PointerEventHandlers>(); // global-scoped mode → ignore page buckets\n\n return mergeSets(alwaysPageSet, modePageSet);\n }\n\n /** ---------- cursor handling --------------------- */\n private setCursor(token: string, cursor: string, priority = 0) {\n this.cursorClaims.set(token, { cursor, priority });\n this.emitCursor();\n }\n private removeCursor(token: string) {\n this.cursorClaims.delete(token);\n this.emitCursor();\n }\n\n private emitCursor() {\n /* pick highest priority claim, else mode baseline */\n const top = [...this.cursorClaims.values()].sort((a, b) => b.priority - a.priority)[0] ?? {\n cursor: this.modes.get(this.state.activeMode)?.cursor ?? 'auto',\n };\n\n if (top.cursor !== this.state.cursor) {\n this.dispatch(setCursor(top.cursor));\n this.onCursorChange$.emit(top.cursor);\n }\n }\n\n override onStoreUpdated(_: InteractionManagerState, newState: InteractionManagerState): void {\n this.onStateChange$.emit(newState);\n }\n\n private activeModeIsExclusive(): boolean {\n const mode = this.modes.get(this.state.activeMode);\n return !!mode?.exclusive;\n }\n\n private getActiveInteractionMode(): InteractionMode | null {\n return this.modes.get(this.state.activeMode) ?? null;\n }\n\n // keep emitter clean\n async destroy(): Promise<void> {\n this.onModeChange$.clear();\n this.onCursorChange$.clear();\n await super.destroy();\n }\n}\n","import { PointerEventHandlers } from './types';\n\nexport function mergeHandlers(list: PointerEventHandlers[]): PointerEventHandlers {\n const keys: (keyof PointerEventHandlers)[] = [\n 'onPointerDown',\n 'onPointerUp',\n 'onPointerMove',\n 'onPointerEnter',\n 'onPointerLeave',\n 'onPointerCancel',\n 'onMouseDown',\n 'onMouseUp',\n 'onMouseMove',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseCancel',\n 'onClick',\n 'onDoubleClick',\n ];\n const out: Partial<PointerEventHandlers> = {};\n for (const k of keys) {\n out[k] = (evt: any, nativeEvt: any, modeId: string) => {\n for (const h of list) h[k]?.(evt, nativeEvt, modeId);\n };\n }\n return out as PointerEventHandlers;\n}\n","import { PluginManifest } from '@embedpdf/core';\nimport { InteractionManagerPluginConfig } from './types';\n\nexport const INTERACTION_MANAGER_PLUGIN_ID = 'interaction-manager';\n\nexport const manifest: PluginManifest<InteractionManagerPluginConfig> = {\n id: INTERACTION_MANAGER_PLUGIN_ID,\n name: 'Interaction Manager Plugin',\n version: '1.0.0',\n provides: ['interaction-manager'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n exclusionRules: {\n classes: [],\n dataAttributes: ['data-no-interaction'],\n },\n },\n};\n","import { Reducer } from '@embedpdf/core';\nimport {\n ACTIVATE_MODE,\n SET_DEFAULT_MODE,\n InteractionManagerAction,\n PAUSE_INTERACTION,\n RESUME_INTERACTION,\n SET_CURSOR,\n SET_EXCLUSION_RULES,\n ADD_EXCLUSION_CLASS,\n REMOVE_EXCLUSION_CLASS,\n ADD_EXCLUSION_ATTRIBUTE,\n REMOVE_EXCLUSION_ATTRIBUTE,\n} from './actions';\nimport { InteractionManagerState } from './types';\n\nexport const initialState: InteractionManagerState = {\n activeMode: 'pointerMode',\n defaultMode: 'pointerMode',\n cursor: 'auto',\n paused: false,\n exclusionRules: {\n classes: [],\n dataAttributes: [],\n },\n};\n\nexport const reducer: Reducer<InteractionManagerState, InteractionManagerAction> = (\n state,\n action,\n) => {\n switch (action.type) {\n case ACTIVATE_MODE:\n return {\n ...state,\n activeMode: action.payload.mode,\n };\n case SET_CURSOR:\n return {\n ...state,\n cursor: action.payload.cursor,\n };\n case PAUSE_INTERACTION:\n return {\n ...state,\n paused: true,\n };\n case RESUME_INTERACTION:\n return {\n ...state,\n paused: false,\n };\n case SET_DEFAULT_MODE:\n return {\n ...state,\n defaultMode: action.payload.mode,\n };\n case SET_EXCLUSION_RULES:\n return {\n ...state,\n exclusionRules: action.payload.rules,\n };\n\n case ADD_EXCLUSION_CLASS:\n return {\n ...state,\n exclusionRules: {\n ...state.exclusionRules,\n classes: [...(state.exclusionRules.classes || []), action.payload.className].filter(\n (v, i, a) => a.indexOf(v) === i,\n ), // Remove duplicates\n },\n };\n\n case REMOVE_EXCLUSION_CLASS:\n return {\n ...state,\n exclusionRules: {\n ...state.exclusionRules,\n classes: (state.exclusionRules.classes || []).filter(\n (c) => c !== action.payload.className,\n ),\n },\n };\n\n case ADD_EXCLUSION_ATTRIBUTE:\n return {\n ...state,\n exclusionRules: {\n ...state.exclusionRules,\n dataAttributes: [\n ...(state.exclusionRules.dataAttributes || []),\n action.payload.attribute,\n ].filter((v, i, a) => a.indexOf(v) === i),\n },\n };\n\n case REMOVE_EXCLUSION_ATTRIBUTE:\n return {\n ...state,\n exclusionRules: {\n ...state.exclusionRules,\n dataAttributes: (state.exclusionRules.dataAttributes || []).filter(\n (a) => a !== action.payload.attribute,\n ),\n },\n };\n default:\n return state;\n }\n};\n","import { PluginPackage } from '@embedpdf/core';\n\nimport { InteractionManagerPlugin } from './interaction-manager-plugin';\nimport { manifest, INTERACTION_MANAGER_PLUGIN_ID } from './manifest';\nimport { InteractionManagerPluginConfig, InteractionManagerState } from './types';\nimport { reducer, initialState } from './reducer';\nimport { InteractionManagerAction } from './actions';\n\nexport const InteractionManagerPluginPackage: PluginPackage<\n InteractionManagerPlugin,\n InteractionManagerPluginConfig,\n InteractionManagerState,\n InteractionManagerAction\n> = {\n manifest,\n create: (registry, config) =>\n new InteractionManagerPlugin(INTERACTION_MANAGER_PLUGIN_ID, registry, config),\n reducer,\n initialState,\n};\n\nexport * from './interaction-manager-plugin';\nexport * from './types';\nexport * from './manifest';\nexport * from './reducer';\n"],"names":["ACTIVATE_MODE","PAUSE_INTERACTION","RESUME_INTERACTION","SET_CURSOR","SET_DEFAULT_MODE","SET_EXCLUSION_RULES","ADD_EXCLUSION_CLASS","REMOVE_EXCLUSION_CLASS","ADD_EXCLUSION_ATTRIBUTE","REMOVE_EXCLUSION_ATTRIBUTE","setExclusionRules","rules","type","payload","INITIAL_MODE","_InteractionManagerPlugin","BasePlugin","constructor","id","registry","config","super","this","modes","Map","cursorClaims","buckets","alwaysGlobal","Set","alwaysPage","onModeChange$","createEmitter","onHandlerChange$","onCursorChange$","onStateChange$","createBehaviorEmitter","registerMode","scope","exclusive","cursor","setDefaultMode","activate","exclusionRules","dispatch","initialize","_","buildCapability","modeId","onModeChange","on","onCursorChange","onHandlerChange","onStateChange","getActiveMode","state","activeMode","getActiveInteractionMode","activateDefaultMode","defaultMode","mode","registerHandlers","options","registerAlways","setCursor","token","priority","removeCursor","getCurrentCursor","getHandlersForScope","activeModeIsExclusive","pause","resume","isPaused","paused","getDefaultMode","getExclusionRules","addExclusionClass","className","removeExclusionClass","addExclusionAttribute","attribute","removeExclusionAttribute","has","Error","previousMode","clear","notifyHandlersInactive","activateMode","emitCursor","notifyHandlersActive","emit","forEach","handler","_a","onHandlerActiveStart","call","handlerSet","get","bucket","global","page","pageIndex","onHandlerActiveEnd","set","handlers","modeIds","Array","isArray","cleanupFunctions","add","push","delete","size","cleanup","mergeSets","a","b","list","keys","out","k","evt","nativeEvt","h","mergeHandlers","modeSpecific","top","values","sort","onStoreUpdated","newState","destroy","InteractionManagerPlugin","INTERACTION_MANAGER_PLUGIN_ID","manifest","name","version","provides","requires","optional","defaultConfig","enabled","classes","dataAttributes","initialState","reducer","action","filter","v","i","indexOf","c","InteractionManagerPluginPackage","create"],"mappings":"kHAGaA,EAAgB,4BAChBC,EAAoB,oBACpBC,EAAqB,qBACrBC,EAAa,yBACbC,EAAmB,+BACnBC,EAAsB,kCACtBC,EAAsB,kCACtBC,EAAyB,qCACzBC,EAA0B,sCAC1BC,EAA6B,yCAkD7BC,EAAqBC,IAA+D,CAC/FC,KAAMP,EACNQ,QAAS,CAAEF,WCrBb,MAAMG,EAAe,cAERC,EAAN,cAAuCC,EAAAA,WAmB5C,WAAAC,CAAYC,EAAYC,EAA0BC,GAChDC,MAAMH,EAAIC,GAbJG,KAAAC,UAAYC,IACZF,KAAAG,iBAAmBD,IACnBF,KAAAI,YAAcF,IAEdF,KAAAK,iBAAmBC,IACnBN,KAAAO,eAAiBL,IAERF,KAAAQ,cAAgBC,kBAChBT,KAAAU,iBAAmBD,kBACnBT,KAAAW,gBAAkBF,kBAClBT,KAAAY,eAAiBC,0BAKhCb,KAAKc,aAAa,CAChBlB,GAAIJ,EACJuB,MAAO,OACPC,WAAW,EACXC,OAAQ,SAGVjB,KAAKkB,eAAe1B,GACpBQ,KAAKmB,SAAS3B,GACVM,EAAOsB,gBACTpB,KAAKqB,SAASjC,EAAkBU,EAAOsB,gBACzC,CAGF,gBAAME,CAAWC,GAAkD,CAEzD,eAAAC,GACD,MAAA,CACLL,SAAWM,GAAmBzB,KAAKmB,SAASM,GAC5CC,aAAc1B,KAAKQ,cAAcmB,GACjCC,eAAgB5B,KAAKW,gBAAgBgB,GACrCE,gBAAiB7B,KAAKU,iBAAiBiB,GACvCG,cAAe9B,KAAKY,eAAee,GACnCI,cAAe,IAAM/B,KAAKgC,MAAMC,WAChCC,yBAA0B,IAAMlC,KAAK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AS,IAAKxF,EAAMZ,eAAeoG,SAAW,GAAKI,EAAOrI,QAAQgE,WAAWsE,QAC3E,CAACC,EAAGC,EAAGlC,IAAMA,EAAEmC,QAAQF,KAAOC,MAKtC,KAAK9I,EACI,MAAA,IACF+C,EACHZ,eAAgB,IACXY,EAAMZ,eACToG,SAAUxF,EAAMZ,eAAeoG,SAAW,IAAIK,QAC3CI,GAAMA,IAAML,EAAOrI,QAAQgE,cAKpC,KAAKrE,EACI,MAAA,IACF8C,EACHZ,eAAgB,IACXY,EAAMZ,eACTqG,eAAgB,IACVzF,EAAMZ,eAAeqG,gBAAkB,GAC3CG,EAAOrI,QAAQmE,WACfmE,QAAO,CAACC,EAAGC,EAAGlC,IAAMA,EAAEmC,QAAQF,KAAOC,MAI7C,KAAK5I,EACI,MAAA,IACF6C,EACHZ,eAAgB,IACXY,EAAMZ,eACTqG,gBAAiBzF,EAAMZ,eAAeqG,gBAAkB,IAAII,QACzDhC,GAAMA,IAAM+B,EAAOrI,QAAQmE,cAIpC,QACS,OAAA1B,EAAA,ECpGAkG,EAKT,CACFlB,WACAmB,OAAQ,CAACtI,EAAUC,IACjB,IAAIgH,EAAyBC,EAA+BlH,EAAUC,GACxE6H,UACAD"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/lib/actions.ts","../src/lib/interaction-manager-plugin.ts","../src/lib/helper.ts","../src/lib/manifest.ts","../src/lib/reducer.ts","../src/lib/index.ts"],"sourcesContent":["import { Action } from '@embedpdf/core';\nimport { InteractionExclusionRules } from './types';\n\nexport const ACTIVATE_MODE = 'INTERACTION/ACTIVATE_MODE';\nexport const PAUSE_INTERACTION = 'INTERACTION/PAUSE';\nexport const RESUME_INTERACTION = 'INTERACTION/RESUME';\nexport const SET_CURSOR = 'INTERACTION/SET_CURSOR';\nexport const SET_DEFAULT_MODE = 'INTERACTION/SET_DEFAULT_MODE';\nexport const SET_EXCLUSION_RULES = 'INTERACTION/SET_EXCLUSION_RULES';\nexport const ADD_EXCLUSION_CLASS = 'INTERACTION/ADD_EXCLUSION_CLASS';\nexport const REMOVE_EXCLUSION_CLASS = 'INTERACTION/REMOVE_EXCLUSION_CLASS';\nexport const ADD_EXCLUSION_ATTRIBUTE = 'INTERACTION/ADD_EXCLUSION_ATTRIBUTE';\nexport const REMOVE_EXCLUSION_ATTRIBUTE = 'INTERACTION/REMOVE_EXCLUSION_ATTRIBUTE';\n\nexport interface SetExclusionRulesAction extends Action {\n type: typeof SET_EXCLUSION_RULES;\n payload: { rules: InteractionExclusionRules };\n}\n\nexport interface AddExclusionClassAction extends Action {\n type: typeof ADD_EXCLUSION_CLASS;\n payload: { className: string };\n}\n\nexport interface RemoveExclusionClassAction extends Action {\n type: typeof REMOVE_EXCLUSION_CLASS;\n payload: { className: string };\n}\n\nexport interface AddExclusionAttributeAction extends Action {\n type: typeof ADD_EXCLUSION_ATTRIBUTE;\n payload: { attribute: string };\n}\n\nexport interface RemoveExclusionAttributeAction extends Action {\n type: typeof REMOVE_EXCLUSION_ATTRIBUTE;\n payload: { attribute: string };\n}\n\nexport interface ActivateModeAction extends Action {\n type: typeof ACTIVATE_MODE;\n payload: { mode: string };\n}\n\nexport interface PauseInteractionAction extends Action {\n type: typeof PAUSE_INTERACTION;\n}\n\nexport interface ResumeInteractionAction extends Action {\n type: typeof RESUME_INTERACTION;\n}\n\nexport interface SetCursorAction extends Action {\n type: typeof SET_CURSOR;\n payload: { cursor: string };\n}\n\nexport interface SetDefaultModeAction extends Action {\n type: typeof SET_DEFAULT_MODE;\n payload: { mode: string };\n}\n\nexport const setExclusionRules = (rules: InteractionExclusionRules): SetExclusionRulesAction => ({\n type: SET_EXCLUSION_RULES,\n payload: { rules },\n});\n\nexport const addExclusionClass = (className: string): AddExclusionClassAction => ({\n type: ADD_EXCLUSION_CLASS,\n payload: { className },\n});\n\nexport const removeExclusionClass = (className: string): RemoveExclusionClassAction => ({\n type: REMOVE_EXCLUSION_CLASS,\n payload: { className },\n});\n\nexport const addExclusionAttribute = (attribute: string): AddExclusionAttributeAction => ({\n type: ADD_EXCLUSION_ATTRIBUTE,\n payload: { attribute },\n});\n\nexport const removeExclusionAttribute = (attribute: string): RemoveExclusionAttributeAction => ({\n type: REMOVE_EXCLUSION_ATTRIBUTE,\n payload: { attribute },\n});\n\nexport const activateMode = (mode: string): ActivateModeAction => ({\n type: ACTIVATE_MODE,\n payload: { mode },\n});\n\nexport const setCursor = (cursor: string): SetCursorAction => ({\n type: SET_CURSOR,\n payload: { cursor },\n});\n\nexport const setDefaultMode = (mode: string): SetDefaultModeAction => ({\n type: SET_DEFAULT_MODE,\n payload: { mode },\n});\n\nexport const pauseInteraction = (): PauseInteractionAction => ({\n type: PAUSE_INTERACTION,\n});\n\nexport const resumeInteraction = (): ResumeInteractionAction => ({\n type: RESUME_INTERACTION,\n});\n\nexport type InteractionManagerAction =\n | SetExclusionRulesAction\n | AddExclusionClassAction\n | RemoveExclusionClassAction\n | AddExclusionAttributeAction\n | RemoveExclusionAttributeAction\n | ActivateModeAction\n | PauseInteractionAction\n | ResumeInteractionAction\n | SetCursorAction\n | SetDefaultModeAction;\n","import { BasePlugin, createBehaviorEmitter, createEmitter, PluginRegistry } from '@embedpdf/core';\n\nimport {\n InteractionExclusionRules,\n InteractionManagerCapability,\n InteractionManagerPluginConfig,\n InteractionManagerState,\n InteractionMode,\n InteractionScope,\n PointerEventHandlers,\n PointerEventHandlersWithLifecycle,\n RegisterAlwaysOptions,\n RegisterHandlersOptions,\n} from './types';\nimport {\n activateMode,\n addExclusionAttribute,\n addExclusionClass,\n pauseInteraction,\n removeExclusionAttribute,\n removeExclusionClass,\n resumeInteraction,\n setCursor,\n setDefaultMode,\n setExclusionRules,\n} from './actions';\nimport { mergeHandlers } from './helper';\n\ninterface CursorClaim {\n cursor: string;\n priority: number;\n}\n\ntype HandlerSet = Set<PointerEventHandlersWithLifecycle>;\ntype PageHandlerMap = Map<number /*pageIdx*/, HandlerSet>;\n\ninterface ModeBuckets {\n /** handlers that listen on the global wrapper (only once per viewer) */\n global: HandlerSet;\n /** handlers that listen on a *specific* page wrapper */\n page: PageHandlerMap;\n}\n\nconst INITIAL_MODE = 'pointerMode';\n\nexport class InteractionManagerPlugin extends BasePlugin<\n InteractionManagerPluginConfig,\n InteractionManagerCapability,\n InteractionManagerState\n> {\n static readonly id = 'interaction-manager' as const;\n\n private modes = new Map<string, InteractionMode>();\n private cursorClaims = new Map<string, CursorClaim>();\n private buckets = new Map<string, ModeBuckets>();\n\n private alwaysGlobal = new Set<PointerEventHandlersWithLifecycle>();\n private alwaysPage = new Map<number, Set<PointerEventHandlersWithLifecycle>>();\n\n private readonly onModeChange$ = createEmitter<InteractionManagerState>();\n private readonly onHandlerChange$ = createEmitter<InteractionManagerState>();\n private readonly onCursorChange$ = createEmitter<string>();\n private readonly onStateChange$ = createBehaviorEmitter<InteractionManagerState>();\n\n constructor(id: string, registry: PluginRegistry, config: InteractionManagerPluginConfig) {\n super(id, registry);\n\n this.registerMode({\n id: INITIAL_MODE,\n scope: 'page',\n exclusive: false,\n cursor: 'auto',\n });\n\n this.setDefaultMode(INITIAL_MODE);\n this.activate(INITIAL_MODE);\n if (config.exclusionRules) {\n this.dispatch(setExclusionRules(config.exclusionRules));\n }\n }\n\n async initialize(_: InteractionManagerPluginConfig): Promise<void> {}\n\n protected buildCapability(): InteractionManagerCapability {\n return {\n activate: (modeId: string) => this.activate(modeId),\n onModeChange: this.onModeChange$.on,\n onCursorChange: this.onCursorChange$.on,\n onHandlerChange: this.onHandlerChange$.on,\n onStateChange: this.onStateChange$.on,\n getActiveMode: () => this.state.activeMode,\n getActiveInteractionMode: () => this.getActiveInteractionMode(),\n activateDefaultMode: () => this.activate(this.state.defaultMode),\n registerMode: (mode: InteractionMode) => this.registerMode(mode),\n registerHandlers: (options: RegisterHandlersOptions) => this.registerHandlers(options),\n registerAlways: (options: RegisterAlwaysOptions) => this.registerAlways(options),\n setCursor: (token: string, cursor: string, priority = 0) =>\n this.setCursor(token, cursor, priority),\n removeCursor: (token: string) => this.removeCursor(token),\n getCurrentCursor: () => this.state.cursor,\n getHandlersForScope: (scope: InteractionScope) => this.getHandlersForScope(scope),\n activeModeIsExclusive: () => this.activeModeIsExclusive(),\n pause: () => this.dispatch(pauseInteraction()),\n resume: () => this.dispatch(resumeInteraction()),\n // Treat a destroyed registry as \"paused\" so late DOM events are ignored during teardown.\n isPaused: () => this.registry.isDestroyed() || this.state.paused,\n setDefaultMode: (id: string) => this.setDefaultMode(id),\n getDefaultMode: () => this.state.defaultMode,\n getExclusionRules: () => this.state.exclusionRules,\n setExclusionRules: (rules: InteractionExclusionRules) =>\n this.dispatch(setExclusionRules(rules)),\n addExclusionClass: (className: string) => this.dispatch(addExclusionClass(className)),\n removeExclusionClass: (className: string) => this.dispatch(removeExclusionClass(className)),\n addExclusionAttribute: (attribute: string) => this.dispatch(addExclusionAttribute(attribute)),\n removeExclusionAttribute: (attribute: string) =>\n this.dispatch(removeExclusionAttribute(attribute)),\n };\n }\n\n private activate(mode: string) {\n if (!this.modes.has(mode)) {\n throw new Error(`[interaction] unknown mode '${mode}'`);\n }\n if (mode === this.state.activeMode) return;\n\n const previousMode = this.state.activeMode;\n this.cursorClaims.clear(); // prevent cursor leaks\n\n this.notifyHandlersInactive(previousMode);\n\n this.dispatch(activateMode(mode));\n this.emitCursor();\n\n // Call lifecycle hooks for handlers going active\n this.notifyHandlersActive(mode);\n\n this.onModeChange$.emit({ ...this.state, activeMode: mode });\n }\n\n private setDefaultMode(modeId: string) {\n if (!this.modes.has(modeId)) {\n throw new Error(`[interaction] cannot set unknown mode '${modeId}' as default`);\n }\n this.dispatch(setDefaultMode(modeId));\n }\n\n private notifyHandlersActive(modeId: string) {\n this.alwaysGlobal.forEach((handler) => {\n handler.onHandlerActiveStart?.(modeId);\n });\n\n this.alwaysPage.forEach((handlerSet) => {\n handlerSet.forEach((handler) => {\n handler.onHandlerActiveStart?.(modeId);\n });\n });\n\n const mode = this.modes.get(modeId);\n if (!mode) return;\n\n const bucket = this.buckets.get(modeId);\n if (!bucket) return;\n\n // Notify global handlers if mode is global\n if (mode.scope === 'global') {\n bucket.global.forEach((handler) => {\n handler.onHandlerActiveStart?.(modeId);\n });\n }\n\n // Notify page handlers if mode is page\n if (mode.scope === 'page') {\n bucket.page.forEach((handlerSet, pageIndex) => {\n handlerSet.forEach((handler) => {\n handler.onHandlerActiveStart?.(modeId);\n });\n });\n }\n }\n\n private notifyHandlersInactive(modeId: string) {\n this.alwaysGlobal.forEach((handler) => {\n handler.onHandlerActiveEnd?.(modeId);\n });\n\n this.alwaysPage.forEach((handlerSet) => {\n handlerSet.forEach((handler) => {\n handler.onHandlerActiveEnd?.(modeId);\n });\n });\n\n const mode = this.modes.get(modeId);\n if (!mode) return;\n\n const bucket = this.buckets.get(modeId);\n if (!bucket) return;\n\n // Notify global handlers if mode is global\n if (mode.scope === 'global') {\n bucket.global.forEach((handler) => {\n handler.onHandlerActiveEnd?.(modeId);\n });\n }\n\n // Notify page handlers if mode is page\n if (mode.scope === 'page') {\n bucket.page.forEach((handlerSet, pageIndex) => {\n handlerSet.forEach((handler) => {\n handler.onHandlerActiveEnd?.(modeId);\n });\n });\n }\n }\n\n private registerMode(mode: InteractionMode) {\n this.modes.set(mode.id, mode);\n if (!this.buckets.has(mode.id)) {\n this.buckets.set(mode.id, { global: new Set(), page: new Map() });\n }\n }\n\n /** ---------- pointer-handler handling ------------ */\n private registerHandlers({ modeId, handlers, pageIndex }: RegisterHandlersOptions): () => void {\n const modeIds = Array.isArray(modeId) ? modeId : [modeId];\n const cleanupFunctions: (() => void)[] = [];\n\n for (const id of modeIds) {\n const bucket = this.buckets.get(id);\n if (!bucket) throw new Error(`unknown mode '${id}'`);\n\n if (pageIndex == null) {\n bucket.global.add(handlers);\n } else {\n const set = bucket.page.get(pageIndex) ?? new Set();\n set.add(handlers);\n bucket.page.set(pageIndex, set);\n }\n\n // Create cleanup function for this specific mode\n cleanupFunctions.push(() => {\n if (pageIndex == null) {\n bucket.global.delete(handlers);\n } else {\n const set = bucket.page.get(pageIndex);\n if (set) {\n set.delete(handlers);\n if (set.size === 0) {\n bucket.page.delete(pageIndex);\n }\n }\n }\n });\n }\n\n this.onHandlerChange$.emit({ ...this.state });\n\n // Return a cleanup function that removes handlers from all registered modes\n return () => {\n cleanupFunctions.forEach((cleanup) => cleanup());\n this.onHandlerChange$.emit({ ...this.state });\n };\n }\n\n public registerAlways({ scope, handlers }: RegisterAlwaysOptions): () => void {\n if (scope.type === 'global') {\n this.alwaysGlobal.add(handlers);\n this.onHandlerChange$.emit({ ...this.state });\n return () => this.alwaysGlobal.delete(handlers);\n }\n const set = this.alwaysPage.get(scope.pageIndex) ?? new Set();\n set.add(handlers);\n this.alwaysPage.set(scope.pageIndex, set);\n this.onHandlerChange$.emit({ ...this.state });\n return () => {\n set.delete(handlers);\n this.onHandlerChange$.emit({ ...this.state });\n };\n }\n\n /** Returns the *merged* handler set that should be active for the given\n * provider (`global` wrapper or a single page wrapper).\n * – `alwaysGlobal` / `alwaysPage` are **always** active.\n * – Handlers that belong to the current mode are added on top **iff**\n * the mode’s own scope matches the provider’s scope. */\n private getHandlersForScope(scope: InteractionScope): PointerEventHandlers | null {\n if (!this.state) return null;\n\n const mode = this.modes.get(this.state.activeMode);\n if (!mode) return null;\n\n const bucket = this.buckets.get(mode.id);\n if (!bucket) return null;\n\n /** helper – merge two handler sets into one object (or `null` if both are empty) */\n const mergeSets = (a: HandlerSet, b: HandlerSet) =>\n a.size || b.size ? mergeHandlers([...a, ...b]) : null;\n\n /* ───────────────────── GLOBAL PROVIDER ─────────────────────── */\n if (scope.type === 'global') {\n const modeSpecific =\n mode.scope === 'global' // only include mode handlers if the\n ? bucket.global // mode itself is global-scoped\n : new Set<PointerEventHandlers>();\n return mergeSets(this.alwaysGlobal, modeSpecific);\n }\n\n /* ─────────────────────── PAGE PROVIDER ──────────────────────── */\n const alwaysPageSet = this.alwaysPage.get(scope.pageIndex) ?? new Set<PointerEventHandlers>();\n const modePageSet =\n mode.scope === 'page'\n ? (bucket.page.get(scope.pageIndex) ?? new Set<PointerEventHandlers>())\n : new Set<PointerEventHandlers>(); // global-scoped mode → ignore page buckets\n\n return mergeSets(alwaysPageSet, modePageSet);\n }\n\n /** ---------- cursor handling --------------------- */\n private setCursor(token: string, cursor: string, priority = 0) {\n this.cursorClaims.set(token, { cursor, priority });\n this.emitCursor();\n }\n private removeCursor(token: string) {\n this.cursorClaims.delete(token);\n this.emitCursor();\n }\n\n private emitCursor() {\n /* pick highest priority claim, else mode baseline */\n const top = [...this.cursorClaims.values()].sort((a, b) => b.priority - a.priority)[0] ?? {\n cursor: this.modes.get(this.state.activeMode)?.cursor ?? 'auto',\n };\n\n if (top.cursor !== this.state.cursor) {\n this.dispatch(setCursor(top.cursor));\n this.onCursorChange$.emit(top.cursor);\n }\n }\n\n override onStoreUpdated(_: InteractionManagerState, newState: InteractionManagerState): void {\n this.onStateChange$.emit(newState);\n }\n\n private activeModeIsExclusive(): boolean {\n const mode = this.modes.get(this.state.activeMode);\n return !!mode?.exclusive;\n }\n\n private getActiveInteractionMode(): InteractionMode | null {\n return this.modes.get(this.state.activeMode) ?? null;\n }\n\n // keep emitter clean\n async destroy(): Promise<void> {\n this.onModeChange$.clear();\n this.onCursorChange$.clear();\n await super.destroy();\n }\n}\n","import { PointerEventHandlers } from './types';\n\nexport function mergeHandlers(list: PointerEventHandlers[]): PointerEventHandlers {\n const keys: (keyof PointerEventHandlers)[] = [\n 'onPointerDown',\n 'onPointerUp',\n 'onPointerMove',\n 'onPointerEnter',\n 'onPointerLeave',\n 'onPointerCancel',\n 'onMouseDown',\n 'onMouseUp',\n 'onMouseMove',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseCancel',\n 'onClick',\n 'onDoubleClick',\n ];\n const out: Partial<PointerEventHandlers> = {};\n for (const k of keys) {\n out[k] = (evt: any, nativeEvt: any, modeId: string) => {\n for (const h of list) h[k]?.(evt, nativeEvt, modeId);\n };\n }\n return out as PointerEventHandlers;\n}\n","import { PluginManifest } from '@embedpdf/core';\nimport { InteractionManagerPluginConfig } from './types';\n\nexport const INTERACTION_MANAGER_PLUGIN_ID = 'interaction-manager';\n\nexport const manifest: PluginManifest<InteractionManagerPluginConfig> = {\n id: INTERACTION_MANAGER_PLUGIN_ID,\n name: 'Interaction Manager Plugin',\n version: '1.0.0',\n provides: ['interaction-manager'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n exclusionRules: {\n classes: [],\n dataAttributes: ['data-no-interaction'],\n },\n },\n};\n","import { Reducer } from '@embedpdf/core';\nimport {\n ACTIVATE_MODE,\n SET_DEFAULT_MODE,\n InteractionManagerAction,\n PAUSE_INTERACTION,\n RESUME_INTERACTION,\n SET_CURSOR,\n SET_EXCLUSION_RULES,\n ADD_EXCLUSION_CLASS,\n REMOVE_EXCLUSION_CLASS,\n ADD_EXCLUSION_ATTRIBUTE,\n REMOVE_EXCLUSION_ATTRIBUTE,\n} from './actions';\nimport { InteractionManagerState } from './types';\n\nexport const initialState: InteractionManagerState = {\n activeMode: 'pointerMode',\n defaultMode: 'pointerMode',\n cursor: 'auto',\n paused: false,\n exclusionRules: {\n classes: [],\n dataAttributes: [],\n },\n};\n\nexport const reducer: Reducer<InteractionManagerState, InteractionManagerAction> = (\n state,\n action,\n) => {\n switch (action.type) {\n case ACTIVATE_MODE:\n return {\n ...state,\n activeMode: action.payload.mode,\n };\n case SET_CURSOR:\n return {\n ...state,\n cursor: action.payload.cursor,\n };\n case PAUSE_INTERACTION:\n return {\n ...state,\n paused: true,\n };\n case RESUME_INTERACTION:\n return {\n ...state,\n paused: false,\n };\n case SET_DEFAULT_MODE:\n return {\n ...state,\n defaultMode: action.payload.mode,\n };\n case SET_EXCLUSION_RULES:\n return {\n ...state,\n exclusionRules: action.payload.rules,\n };\n\n case ADD_EXCLUSION_CLASS:\n return {\n ...state,\n exclusionRules: {\n ...state.exclusionRules,\n classes: [...(state.exclusionRules.classes || []), action.payload.className].filter(\n (v, i, a) => a.indexOf(v) === i,\n ), // Remove duplicates\n },\n };\n\n case REMOVE_EXCLUSION_CLASS:\n return {\n ...state,\n exclusionRules: {\n ...state.exclusionRules,\n classes: (state.exclusionRules.classes || []).filter(\n (c) => c !== action.payload.className,\n ),\n },\n };\n\n case ADD_EXCLUSION_ATTRIBUTE:\n return {\n ...state,\n exclusionRules: {\n ...state.exclusionRules,\n dataAttributes: [\n ...(state.exclusionRules.dataAttributes || []),\n action.payload.attribute,\n ].filter((v, i, a) => a.indexOf(v) === i),\n },\n };\n\n case REMOVE_EXCLUSION_ATTRIBUTE:\n return {\n ...state,\n exclusionRules: {\n ...state.exclusionRules,\n dataAttributes: (state.exclusionRules.dataAttributes || []).filter(\n (a) => a !== action.payload.attribute,\n ),\n },\n };\n default:\n return state;\n }\n};\n","import { PluginPackage } from '@embedpdf/core';\n\nimport { InteractionManagerPlugin } from './interaction-manager-plugin';\nimport { manifest, INTERACTION_MANAGER_PLUGIN_ID } from './manifest';\nimport { InteractionManagerPluginConfig, InteractionManagerState } from './types';\nimport { reducer, initialState } from './reducer';\nimport { InteractionManagerAction } from './actions';\n\nexport const InteractionManagerPluginPackage: PluginPackage<\n InteractionManagerPlugin,\n InteractionManagerPluginConfig,\n InteractionManagerState,\n InteractionManagerAction\n> = {\n manifest,\n create: (registry, config) =>\n new InteractionManagerPlugin(INTERACTION_MANAGER_PLUGIN_ID, registry, config),\n reducer,\n initialState,\n};\n\nexport * from './interaction-manager-plugin';\nexport * from './types';\nexport * from './manifest';\nexport * from './reducer';\n"],"names":["ACTIVATE_MODE","PAUSE_INTERACTION","RESUME_INTERACTION","SET_CURSOR","SET_DEFAULT_MODE","SET_EXCLUSION_RULES","ADD_EXCLUSION_CLASS","REMOVE_EXCLUSION_CLASS","ADD_EXCLUSION_ATTRIBUTE","REMOVE_EXCLUSION_ATTRIBUTE","setExclusionRules","rules","type","payload","INITIAL_MODE","_InteractionManagerPlugin","BasePlugin","constructor","id","registry","config","super","this","modes","Map","cursorClaims","buckets","alwaysGlobal","Set","alwaysPage","onModeChange$","createEmitter","onHandlerChange$","onCursorChange$","onStateChange$","createBehaviorEmitter","registerMode","scope","exclusive","cursor","setDefaultMode","activate","exclusionRules","dispatch","initialize","_","buildCapability","modeId","onModeChange","on","onCursorChange","onHandlerChange","onStateChange","getActiveMode","state","activeMode","getActiveInteractionMode","activateDefaultMode","defaultMode","mode","registerHandlers","options","registerAlways","setCursor","token","priority","removeCursor","getCurrentCursor","getHandlersForScope","activeModeIsExclusive","pause","resume","isPaused","isDestroyed","paused","getDefaultMode","getExclusionRules","addExclusionClass","className","removeExclusionClass","addExclusionAttribute","attribute","removeExclusionAttribute","has","Error","previousMode","clear","notifyHandlersInactive","activateMode","emitCursor","notifyHandlersActive","emit","forEach","handler","_a","onHandlerActiveStart","call","handlerSet","get","bucket","global","page","pageIndex","onHandlerActiveEnd","set","handlers","modeIds","Array","isArray","cleanupFunctions","add","push","delete","size","cleanup","mergeSets","a","b","list","keys","out","k","evt","nativeEvt","h","mergeHandlers","modeSpecific","top","values","sort","onStoreUpdated","newState","destroy","InteractionManagerPlugin","INTERACTION_MANAGER_PLUGIN_ID","manifest","name","version","provides","requires","optional","defaultConfig","enabled","classes","dataAttributes","initialState","reducer","action","filter","v","i","indexOf","c","InteractionManagerPluginPackage","create"],"mappings":"kHAGaA,EAAgB,4BAChBC,EAAoB,oBACpBC,EAAqB,qBACrBC,EAAa,yBACbC,EAAmB,+BACnBC,EAAsB,kCACtBC,EAAsB,kCACtBC,EAAyB,qCACzBC,EAA0B,sCAC1BC,EAA6B,yCAkD7BC,EAAqBC,IAA+D,CAC/FC,KAAMP,EACNQ,QAAS,CAAEF,WCrBb,MAAMG,EAAe,cAERC,EAAN,cAAuCC,EAAAA,WAmB5C,WAAAC,CAAYC,EAAYC,EAA0BC,GAChDC,MAAMH,EAAIC,GAbJG,KAAAC,UAAYC,IACZF,KAAAG,iBAAmBD,IACnBF,KAAAI,YAAcF,IAEdF,KAAAK,iBAAmBC,IACnBN,KAAAO,eAAiBL,IAER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,QACS,OAAA3B,EAAA,ECpGAmG,EAKT,CACFlB,WACAmB,OAAQ,CAACvI,EAAUC,IACjB,IAAIiH,EAAyBC,EAA+BnH,EAAUC,GACxE8H,UACAD"}
package/dist/index.js CHANGED
@@ -120,7 +120,8 @@ const _InteractionManagerPlugin = class _InteractionManagerPlugin extends BasePl
120
120
  activeModeIsExclusive: () => this.activeModeIsExclusive(),
121
121
  pause: () => this.dispatch(pauseInteraction()),
122
122
  resume: () => this.dispatch(resumeInteraction()),
123
- isPaused: () => this.state.paused,
123
+ // Treat a destroyed registry as "paused" so late DOM events are ignored during teardown.
124
+ isPaused: () => this.registry.isDestroyed() || this.state.paused,
124
125
  setDefaultMode: (id) => this.setDefaultMode(id),
125
126
  getDefaultMode: () => this.state.defaultMode,
126
127
  getExclusionRules: () => this.state.exclusionRules,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/lib/actions.ts","../src/lib/helper.ts","../src/lib/interaction-manager-plugin.ts","../src/lib/manifest.ts","../src/lib/reducer.ts","../src/lib/index.ts"],"sourcesContent":["import { Action } from '@embedpdf/core';\nimport { InteractionExclusionRules } from './types';\n\nexport const ACTIVATE_MODE = 'INTERACTION/ACTIVATE_MODE';\nexport const PAUSE_INTERACTION = 'INTERACTION/PAUSE';\nexport const RESUME_INTERACTION = 'INTERACTION/RESUME';\nexport const SET_CURSOR = 'INTERACTION/SET_CURSOR';\nexport const SET_DEFAULT_MODE = 'INTERACTION/SET_DEFAULT_MODE';\nexport const SET_EXCLUSION_RULES = 'INTERACTION/SET_EXCLUSION_RULES';\nexport const ADD_EXCLUSION_CLASS = 'INTERACTION/ADD_EXCLUSION_CLASS';\nexport const REMOVE_EXCLUSION_CLASS = 'INTERACTION/REMOVE_EXCLUSION_CLASS';\nexport const ADD_EXCLUSION_ATTRIBUTE = 'INTERACTION/ADD_EXCLUSION_ATTRIBUTE';\nexport const REMOVE_EXCLUSION_ATTRIBUTE = 'INTERACTION/REMOVE_EXCLUSION_ATTRIBUTE';\n\nexport interface SetExclusionRulesAction extends Action {\n type: typeof SET_EXCLUSION_RULES;\n payload: { rules: InteractionExclusionRules };\n}\n\nexport interface AddExclusionClassAction extends Action {\n type: typeof ADD_EXCLUSION_CLASS;\n payload: { className: string };\n}\n\nexport interface RemoveExclusionClassAction extends Action {\n type: typeof REMOVE_EXCLUSION_CLASS;\n payload: { className: string };\n}\n\nexport interface AddExclusionAttributeAction extends Action {\n type: typeof ADD_EXCLUSION_ATTRIBUTE;\n payload: { attribute: string };\n}\n\nexport interface RemoveExclusionAttributeAction extends Action {\n type: typeof REMOVE_EXCLUSION_ATTRIBUTE;\n payload: { attribute: string };\n}\n\nexport interface ActivateModeAction extends Action {\n type: typeof ACTIVATE_MODE;\n payload: { mode: string };\n}\n\nexport interface PauseInteractionAction extends Action {\n type: typeof PAUSE_INTERACTION;\n}\n\nexport interface ResumeInteractionAction extends Action {\n type: typeof RESUME_INTERACTION;\n}\n\nexport interface SetCursorAction extends Action {\n type: typeof SET_CURSOR;\n payload: { cursor: string };\n}\n\nexport interface SetDefaultModeAction extends Action {\n type: typeof SET_DEFAULT_MODE;\n payload: { mode: string };\n}\n\nexport const setExclusionRules = (rules: InteractionExclusionRules): SetExclusionRulesAction => ({\n type: SET_EXCLUSION_RULES,\n payload: { rules },\n});\n\nexport const addExclusionClass = (className: string): AddExclusionClassAction => ({\n type: ADD_EXCLUSION_CLASS,\n payload: { className },\n});\n\nexport const removeExclusionClass = (className: string): RemoveExclusionClassAction => ({\n type: REMOVE_EXCLUSION_CLASS,\n payload: { className },\n});\n\nexport const addExclusionAttribute = (attribute: string): AddExclusionAttributeAction => ({\n type: ADD_EXCLUSION_ATTRIBUTE,\n payload: { attribute },\n});\n\nexport const removeExclusionAttribute = (attribute: string): RemoveExclusionAttributeAction => ({\n type: REMOVE_EXCLUSION_ATTRIBUTE,\n payload: { attribute },\n});\n\nexport const activateMode = (mode: string): ActivateModeAction => ({\n type: ACTIVATE_MODE,\n payload: { mode },\n});\n\nexport const setCursor = (cursor: string): SetCursorAction => ({\n type: SET_CURSOR,\n payload: { cursor },\n});\n\nexport const setDefaultMode = (mode: string): SetDefaultModeAction => ({\n type: SET_DEFAULT_MODE,\n payload: { mode },\n});\n\nexport const pauseInteraction = (): PauseInteractionAction => ({\n type: PAUSE_INTERACTION,\n});\n\nexport const resumeInteraction = (): ResumeInteractionAction => ({\n type: RESUME_INTERACTION,\n});\n\nexport type InteractionManagerAction =\n | SetExclusionRulesAction\n | AddExclusionClassAction\n | RemoveExclusionClassAction\n | AddExclusionAttributeAction\n | RemoveExclusionAttributeAction\n | ActivateModeAction\n | PauseInteractionAction\n | ResumeInteractionAction\n | SetCursorAction\n | SetDefaultModeAction;\n","import { PointerEventHandlers } from './types';\n\nexport function mergeHandlers(list: PointerEventHandlers[]): PointerEventHandlers {\n const keys: (keyof PointerEventHandlers)[] = [\n 'onPointerDown',\n 'onPointerUp',\n 'onPointerMove',\n 'onPointerEnter',\n 'onPointerLeave',\n 'onPointerCancel',\n 'onMouseDown',\n 'onMouseUp',\n 'onMouseMove',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseCancel',\n 'onClick',\n 'onDoubleClick',\n ];\n const out: Partial<PointerEventHandlers> = {};\n for (const k of keys) {\n out[k] = (evt: any, nativeEvt: any, modeId: string) => {\n for (const h of list) h[k]?.(evt, nativeEvt, modeId);\n };\n }\n return out as PointerEventHandlers;\n}\n","import { BasePlugin, createBehaviorEmitter, createEmitter, PluginRegistry } from '@embedpdf/core';\n\nimport {\n InteractionExclusionRules,\n InteractionManagerCapability,\n InteractionManagerPluginConfig,\n InteractionManagerState,\n InteractionMode,\n InteractionScope,\n PointerEventHandlers,\n PointerEventHandlersWithLifecycle,\n RegisterAlwaysOptions,\n RegisterHandlersOptions,\n} from './types';\nimport {\n activateMode,\n addExclusionAttribute,\n addExclusionClass,\n pauseInteraction,\n removeExclusionAttribute,\n removeExclusionClass,\n resumeInteraction,\n setCursor,\n setDefaultMode,\n setExclusionRules,\n} from './actions';\nimport { mergeHandlers } from './helper';\n\ninterface CursorClaim {\n cursor: string;\n priority: number;\n}\n\ntype HandlerSet = Set<PointerEventHandlersWithLifecycle>;\ntype PageHandlerMap = Map<number /*pageIdx*/, HandlerSet>;\n\ninterface ModeBuckets {\n /** handlers that listen on the global wrapper (only once per viewer) */\n global: HandlerSet;\n /** handlers that listen on a *specific* page wrapper */\n page: PageHandlerMap;\n}\n\nconst INITIAL_MODE = 'pointerMode';\n\nexport class InteractionManagerPlugin extends BasePlugin<\n InteractionManagerPluginConfig,\n InteractionManagerCapability,\n InteractionManagerState\n> {\n static readonly id = 'interaction-manager' as const;\n\n private modes = new Map<string, InteractionMode>();\n private cursorClaims = new Map<string, CursorClaim>();\n private buckets = new Map<string, ModeBuckets>();\n\n private alwaysGlobal = new Set<PointerEventHandlersWithLifecycle>();\n private alwaysPage = new Map<number, Set<PointerEventHandlersWithLifecycle>>();\n\n private readonly onModeChange$ = createEmitter<InteractionManagerState>();\n private readonly onHandlerChange$ = createEmitter<InteractionManagerState>();\n private readonly onCursorChange$ = createEmitter<string>();\n private readonly onStateChange$ = createBehaviorEmitter<InteractionManagerState>();\n\n constructor(id: string, registry: PluginRegistry, config: InteractionManagerPluginConfig) {\n super(id, registry);\n\n this.registerMode({\n id: INITIAL_MODE,\n scope: 'page',\n exclusive: false,\n cursor: 'auto',\n });\n\n this.setDefaultMode(INITIAL_MODE);\n this.activate(INITIAL_MODE);\n if (config.exclusionRules) {\n this.dispatch(setExclusionRules(config.exclusionRules));\n }\n }\n\n async initialize(_: InteractionManagerPluginConfig): Promise<void> {}\n\n protected buildCapability(): InteractionManagerCapability {\n return {\n activate: (modeId: string) => this.activate(modeId),\n onModeChange: this.onModeChange$.on,\n onCursorChange: this.onCursorChange$.on,\n onHandlerChange: this.onHandlerChange$.on,\n onStateChange: this.onStateChange$.on,\n getActiveMode: () => this.state.activeMode,\n getActiveInteractionMode: () => this.getActiveInteractionMode(),\n activateDefaultMode: () => this.activate(this.state.defaultMode),\n registerMode: (mode: InteractionMode) => this.registerMode(mode),\n registerHandlers: (options: RegisterHandlersOptions) => this.registerHandlers(options),\n registerAlways: (options: RegisterAlwaysOptions) => this.registerAlways(options),\n setCursor: (token: string, cursor: string, priority = 0) =>\n this.setCursor(token, cursor, priority),\n removeCursor: (token: string) => this.removeCursor(token),\n getCurrentCursor: () => this.state.cursor,\n getHandlersForScope: (scope: InteractionScope) => this.getHandlersForScope(scope),\n activeModeIsExclusive: () => this.activeModeIsExclusive(),\n pause: () => this.dispatch(pauseInteraction()),\n resume: () => this.dispatch(resumeInteraction()),\n isPaused: () => this.state.paused,\n setDefaultMode: (id: string) => this.setDefaultMode(id),\n getDefaultMode: () => this.state.defaultMode,\n getExclusionRules: () => this.state.exclusionRules,\n setExclusionRules: (rules: InteractionExclusionRules) =>\n this.dispatch(setExclusionRules(rules)),\n addExclusionClass: (className: string) => this.dispatch(addExclusionClass(className)),\n removeExclusionClass: (className: string) => this.dispatch(removeExclusionClass(className)),\n addExclusionAttribute: (attribute: string) => this.dispatch(addExclusionAttribute(attribute)),\n removeExclusionAttribute: (attribute: string) =>\n this.dispatch(removeExclusionAttribute(attribute)),\n };\n }\n\n private activate(mode: string) {\n if (!this.modes.has(mode)) {\n throw new Error(`[interaction] unknown mode '${mode}'`);\n }\n if (mode === this.state.activeMode) return;\n\n const previousMode = this.state.activeMode;\n this.cursorClaims.clear(); // prevent cursor leaks\n\n this.notifyHandlersInactive(previousMode);\n\n this.dispatch(activateMode(mode));\n this.emitCursor();\n\n // Call lifecycle hooks for handlers going active\n this.notifyHandlersActive(mode);\n\n this.onModeChange$.emit({ ...this.state, activeMode: mode });\n }\n\n private setDefaultMode(modeId: string) {\n if (!this.modes.has(modeId)) {\n throw new Error(`[interaction] cannot set unknown mode '${modeId}' as default`);\n }\n this.dispatch(setDefaultMode(modeId));\n }\n\n private notifyHandlersActive(modeId: string) {\n this.alwaysGlobal.forEach((handler) => {\n handler.onHandlerActiveStart?.(modeId);\n });\n\n this.alwaysPage.forEach((handlerSet) => {\n handlerSet.forEach((handler) => {\n handler.onHandlerActiveStart?.(modeId);\n });\n });\n\n const mode = this.modes.get(modeId);\n if (!mode) return;\n\n const bucket = this.buckets.get(modeId);\n if (!bucket) return;\n\n // Notify global handlers if mode is global\n if (mode.scope === 'global') {\n bucket.global.forEach((handler) => {\n handler.onHandlerActiveStart?.(modeId);\n });\n }\n\n // Notify page handlers if mode is page\n if (mode.scope === 'page') {\n bucket.page.forEach((handlerSet, pageIndex) => {\n handlerSet.forEach((handler) => {\n handler.onHandlerActiveStart?.(modeId);\n });\n });\n }\n }\n\n private notifyHandlersInactive(modeId: string) {\n this.alwaysGlobal.forEach((handler) => {\n handler.onHandlerActiveEnd?.(modeId);\n });\n\n this.alwaysPage.forEach((handlerSet) => {\n handlerSet.forEach((handler) => {\n handler.onHandlerActiveEnd?.(modeId);\n });\n });\n\n const mode = this.modes.get(modeId);\n if (!mode) return;\n\n const bucket = this.buckets.get(modeId);\n if (!bucket) return;\n\n // Notify global handlers if mode is global\n if (mode.scope === 'global') {\n bucket.global.forEach((handler) => {\n handler.onHandlerActiveEnd?.(modeId);\n });\n }\n\n // Notify page handlers if mode is page\n if (mode.scope === 'page') {\n bucket.page.forEach((handlerSet, pageIndex) => {\n handlerSet.forEach((handler) => {\n handler.onHandlerActiveEnd?.(modeId);\n });\n });\n }\n }\n\n private registerMode(mode: InteractionMode) {\n this.modes.set(mode.id, mode);\n if (!this.buckets.has(mode.id)) {\n this.buckets.set(mode.id, { global: new Set(), page: new Map() });\n }\n }\n\n /** ---------- pointer-handler handling ------------ */\n private registerHandlers({ modeId, handlers, pageIndex }: RegisterHandlersOptions): () => void {\n const modeIds = Array.isArray(modeId) ? modeId : [modeId];\n const cleanupFunctions: (() => void)[] = [];\n\n for (const id of modeIds) {\n const bucket = this.buckets.get(id);\n if (!bucket) throw new Error(`unknown mode '${id}'`);\n\n if (pageIndex == null) {\n bucket.global.add(handlers);\n } else {\n const set = bucket.page.get(pageIndex) ?? new Set();\n set.add(handlers);\n bucket.page.set(pageIndex, set);\n }\n\n // Create cleanup function for this specific mode\n cleanupFunctions.push(() => {\n if (pageIndex == null) {\n bucket.global.delete(handlers);\n } else {\n const set = bucket.page.get(pageIndex);\n if (set) {\n set.delete(handlers);\n if (set.size === 0) {\n bucket.page.delete(pageIndex);\n }\n }\n }\n });\n }\n\n this.onHandlerChange$.emit({ ...this.state });\n\n // Return a cleanup function that removes handlers from all registered modes\n return () => {\n cleanupFunctions.forEach((cleanup) => cleanup());\n this.onHandlerChange$.emit({ ...this.state });\n };\n }\n\n public registerAlways({ scope, handlers }: RegisterAlwaysOptions): () => void {\n if (scope.type === 'global') {\n this.alwaysGlobal.add(handlers);\n this.onHandlerChange$.emit({ ...this.state });\n return () => this.alwaysGlobal.delete(handlers);\n }\n const set = this.alwaysPage.get(scope.pageIndex) ?? new Set();\n set.add(handlers);\n this.alwaysPage.set(scope.pageIndex, set);\n this.onHandlerChange$.emit({ ...this.state });\n return () => {\n set.delete(handlers);\n this.onHandlerChange$.emit({ ...this.state });\n };\n }\n\n /** Returns the *merged* handler set that should be active for the given\n * provider (`global` wrapper or a single page wrapper).\n * – `alwaysGlobal` / `alwaysPage` are **always** active.\n * – Handlers that belong to the current mode are added on top **iff**\n * the mode’s own scope matches the provider’s scope. */\n private getHandlersForScope(scope: InteractionScope): PointerEventHandlers | null {\n if (!this.state) return null;\n\n const mode = this.modes.get(this.state.activeMode);\n if (!mode) return null;\n\n const bucket = this.buckets.get(mode.id);\n if (!bucket) return null;\n\n /** helper – merge two handler sets into one object (or `null` if both are empty) */\n const mergeSets = (a: HandlerSet, b: HandlerSet) =>\n a.size || b.size ? mergeHandlers([...a, ...b]) : null;\n\n /* ───────────────────── GLOBAL PROVIDER ─────────────────────── */\n if (scope.type === 'global') {\n const modeSpecific =\n mode.scope === 'global' // only include mode handlers if the\n ? bucket.global // mode itself is global-scoped\n : new Set<PointerEventHandlers>();\n return mergeSets(this.alwaysGlobal, modeSpecific);\n }\n\n /* ─────────────────────── PAGE PROVIDER ──────────────────────── */\n const alwaysPageSet = this.alwaysPage.get(scope.pageIndex) ?? new Set<PointerEventHandlers>();\n const modePageSet =\n mode.scope === 'page'\n ? (bucket.page.get(scope.pageIndex) ?? new Set<PointerEventHandlers>())\n : new Set<PointerEventHandlers>(); // global-scoped mode → ignore page buckets\n\n return mergeSets(alwaysPageSet, modePageSet);\n }\n\n /** ---------- cursor handling --------------------- */\n private setCursor(token: string, cursor: string, priority = 0) {\n this.cursorClaims.set(token, { cursor, priority });\n this.emitCursor();\n }\n private removeCursor(token: string) {\n this.cursorClaims.delete(token);\n this.emitCursor();\n }\n\n private emitCursor() {\n /* pick highest priority claim, else mode baseline */\n const top = [...this.cursorClaims.values()].sort((a, b) => b.priority - a.priority)[0] ?? {\n cursor: this.modes.get(this.state.activeMode)?.cursor ?? 'auto',\n };\n\n if (top.cursor !== this.state.cursor) {\n this.dispatch(setCursor(top.cursor));\n this.onCursorChange$.emit(top.cursor);\n }\n }\n\n override onStoreUpdated(_: InteractionManagerState, newState: InteractionManagerState): void {\n this.onStateChange$.emit(newState);\n }\n\n private activeModeIsExclusive(): boolean {\n const mode = this.modes.get(this.state.activeMode);\n return !!mode?.exclusive;\n }\n\n private getActiveInteractionMode(): InteractionMode | null {\n return this.modes.get(this.state.activeMode) ?? null;\n }\n\n // keep emitter clean\n async destroy(): Promise<void> {\n this.onModeChange$.clear();\n this.onCursorChange$.clear();\n await super.destroy();\n }\n}\n","import { PluginManifest } from '@embedpdf/core';\nimport { InteractionManagerPluginConfig } from './types';\n\nexport const INTERACTION_MANAGER_PLUGIN_ID = 'interaction-manager';\n\nexport const manifest: PluginManifest<InteractionManagerPluginConfig> = {\n id: INTERACTION_MANAGER_PLUGIN_ID,\n name: 'Interaction Manager Plugin',\n version: '1.0.0',\n provides: ['interaction-manager'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n exclusionRules: {\n classes: [],\n dataAttributes: ['data-no-interaction'],\n },\n },\n};\n","import { Reducer } from '@embedpdf/core';\nimport {\n ACTIVATE_MODE,\n SET_DEFAULT_MODE,\n InteractionManagerAction,\n PAUSE_INTERACTION,\n RESUME_INTERACTION,\n SET_CURSOR,\n SET_EXCLUSION_RULES,\n ADD_EXCLUSION_CLASS,\n REMOVE_EXCLUSION_CLASS,\n ADD_EXCLUSION_ATTRIBUTE,\n REMOVE_EXCLUSION_ATTRIBUTE,\n} from './actions';\nimport { InteractionManagerState } from './types';\n\nexport const initialState: InteractionManagerState = {\n activeMode: 'pointerMode',\n defaultMode: 'pointerMode',\n cursor: 'auto',\n paused: false,\n exclusionRules: {\n classes: [],\n dataAttributes: [],\n },\n};\n\nexport const reducer: Reducer<InteractionManagerState, InteractionManagerAction> = (\n state,\n action,\n) => {\n switch (action.type) {\n case ACTIVATE_MODE:\n return {\n ...state,\n activeMode: action.payload.mode,\n };\n case SET_CURSOR:\n return {\n ...state,\n cursor: action.payload.cursor,\n };\n case PAUSE_INTERACTION:\n return {\n ...state,\n paused: true,\n };\n case RESUME_INTERACTION:\n return {\n ...state,\n paused: false,\n };\n case SET_DEFAULT_MODE:\n return {\n ...state,\n defaultMode: action.payload.mode,\n };\n case SET_EXCLUSION_RULES:\n return {\n ...state,\n exclusionRules: action.payload.rules,\n };\n\n case ADD_EXCLUSION_CLASS:\n return {\n ...state,\n exclusionRules: {\n ...state.exclusionRules,\n classes: [...(state.exclusionRules.classes || []), action.payload.className].filter(\n (v, i, a) => a.indexOf(v) === i,\n ), // Remove duplicates\n },\n };\n\n case REMOVE_EXCLUSION_CLASS:\n return {\n ...state,\n exclusionRules: {\n ...state.exclusionRules,\n classes: (state.exclusionRules.classes || []).filter(\n (c) => c !== action.payload.className,\n ),\n },\n };\n\n case ADD_EXCLUSION_ATTRIBUTE:\n return {\n ...state,\n exclusionRules: {\n ...state.exclusionRules,\n dataAttributes: [\n ...(state.exclusionRules.dataAttributes || []),\n action.payload.attribute,\n ].filter((v, i, a) => a.indexOf(v) === i),\n },\n };\n\n case REMOVE_EXCLUSION_ATTRIBUTE:\n return {\n ...state,\n exclusionRules: {\n ...state.exclusionRules,\n dataAttributes: (state.exclusionRules.dataAttributes || []).filter(\n (a) => a !== action.payload.attribute,\n ),\n },\n };\n default:\n return state;\n }\n};\n","import { PluginPackage } from '@embedpdf/core';\n\nimport { InteractionManagerPlugin } from './interaction-manager-plugin';\nimport { manifest, INTERACTION_MANAGER_PLUGIN_ID } from './manifest';\nimport { InteractionManagerPluginConfig, InteractionManagerState } from './types';\nimport { reducer, initialState } from './reducer';\nimport { InteractionManagerAction } from './actions';\n\nexport const InteractionManagerPluginPackage: PluginPackage<\n InteractionManagerPlugin,\n InteractionManagerPluginConfig,\n InteractionManagerState,\n InteractionManagerAction\n> = {\n manifest,\n create: (registry, config) =>\n new InteractionManagerPlugin(INTERACTION_MANAGER_PLUGIN_ID, registry, config),\n reducer,\n initialState,\n};\n\nexport * from './interaction-manager-plugin';\nexport * from './types';\nexport * from './manifest';\nexport * from './reducer';\n"],"names":[],"mappings":";AAGO,MAAM,gBAAgB;AACtB,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;AAC3B,MAAM,aAAa;AACnB,MAAM,mBAAmB;AACzB,MAAM,sBAAsB;AAC5B,MAAM,sBAAsB;AAC5B,MAAM,yBAAyB;AAC/B,MAAM,0BAA0B;AAChC,MAAM,6BAA6B;AAkD7B,MAAA,oBAAoB,CAAC,WAA+D;AAAA,EAC/F,MAAM;AAAA,EACN,SAAS,EAAE,MAAM;AACnB;AAEa,MAAA,oBAAoB,CAAC,eAAgD;AAAA,EAChF,MAAM;AAAA,EACN,SAAS,EAAE,UAAU;AACvB;AAEa,MAAA,uBAAuB,CAAC,eAAmD;AAAA,EACtF,MAAM;AAAA,EACN,SAAS,EAAE,UAAU;AACvB;AAEa,MAAA,wBAAwB,CAAC,eAAoD;AAAA,EACxF,MAAM;AAAA,EACN,SAAS,EAAE,UAAU;AACvB;AAEa,M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AAM,eAAe,WAAW,CAAI,GAAA;AAAA,YAC5C,CAAC,MAAM,MAAM,OAAO,QAAQ;AAAA,UAAA;AAAA,QAC9B;AAAA,MAEJ;AAAA,IAEF,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,gBAAgB;AAAA,UACd,GAAG,MAAM;AAAA,UACT,gBAAgB;AAAA,YACd,GAAI,MAAM,eAAe,kBAAkB,CAAC;AAAA,YAC5C,OAAO,QAAQ;AAAA,UAAA,EACf,OAAO,CAAC,GAAG,GAAG,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC;AAAA,QAAA;AAAA,MAE5C;AAAA,IAEF,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,gBAAgB;AAAA,UACd,GAAG,MAAM;AAAA,UACT,iBAAiB,MAAM,eAAe,kBAAkB,CAAI,GAAA;AAAA,YAC1D,CAAC,MAAM,MAAM,OAAO,QAAQ;AAAA,UAAA;AAAA,QAC9B;AAAA,MAEJ;AAAA,IACF;AACS,aAAA;AAAA,EAAA;AAEb;ACtGO,MAAM,kCAKT;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,UAAU,WACjB,IAAI,yBAAyB,+BAA+B,UAAU,MAAM;AAAA,EAC9E;AAAA,EACA;AACF;"}
1
+ {"version":3,"file":"index.js","sources":["../src/lib/actions.ts","../src/lib/helper.ts","../src/lib/interaction-manager-plugin.ts","../src/lib/manifest.ts","../src/lib/reducer.ts","../src/lib/index.ts"],"sourcesContent":["import { Action } from '@embedpdf/core';\nimport { InteractionExclusionRules } from './types';\n\nexport const ACTIVATE_MODE = 'INTERACTION/ACTIVATE_MODE';\nexport const PAUSE_INTERACTION = 'INTERACTION/PAUSE';\nexport const RESUME_INTERACTION = 'INTERACTION/RESUME';\nexport const SET_CURSOR = 'INTERACTION/SET_CURSOR';\nexport const SET_DEFAULT_MODE = 'INTERACTION/SET_DEFAULT_MODE';\nexport const SET_EXCLUSION_RULES = 'INTERACTION/SET_EXCLUSION_RULES';\nexport const ADD_EXCLUSION_CLASS = 'INTERACTION/ADD_EXCLUSION_CLASS';\nexport const REMOVE_EXCLUSION_CLASS = 'INTERACTION/REMOVE_EXCLUSION_CLASS';\nexport const ADD_EXCLUSION_ATTRIBUTE = 'INTERACTION/ADD_EXCLUSION_ATTRIBUTE';\nexport const REMOVE_EXCLUSION_ATTRIBUTE = 'INTERACTION/REMOVE_EXCLUSION_ATTRIBUTE';\n\nexport interface SetExclusionRulesAction extends Action {\n type: typeof SET_EXCLUSION_RULES;\n payload: { rules: InteractionExclusionRules };\n}\n\nexport interface AddExclusionClassAction extends Action {\n type: typeof ADD_EXCLUSION_CLASS;\n payload: { className: string };\n}\n\nexport interface RemoveExclusionClassAction extends Action {\n type: typeof REMOVE_EXCLUSION_CLASS;\n payload: { className: string };\n}\n\nexport interface AddExclusionAttributeAction extends Action {\n type: typeof ADD_EXCLUSION_ATTRIBUTE;\n payload: { attribute: string };\n}\n\nexport interface RemoveExclusionAttributeAction extends Action {\n type: typeof REMOVE_EXCLUSION_ATTRIBUTE;\n payload: { attribute: string };\n}\n\nexport interface ActivateModeAction extends Action {\n type: typeof ACTIVATE_MODE;\n payload: { mode: string };\n}\n\nexport interface PauseInteractionAction extends Action {\n type: typeof PAUSE_INTERACTION;\n}\n\nexport interface ResumeInteractionAction extends Action {\n type: typeof RESUME_INTERACTION;\n}\n\nexport interface SetCursorAction extends Action {\n type: typeof SET_CURSOR;\n payload: { cursor: string };\n}\n\nexport interface SetDefaultModeAction extends Action {\n type: typeof SET_DEFAULT_MODE;\n payload: { mode: string };\n}\n\nexport const setExclusionRules = (rules: InteractionExclusionRules): SetExclusionRulesAction => ({\n type: SET_EXCLUSION_RULES,\n payload: { rules },\n});\n\nexport const addExclusionClass = (className: string): AddExclusionClassAction => ({\n type: ADD_EXCLUSION_CLASS,\n payload: { className },\n});\n\nexport const removeExclusionClass = (className: string): RemoveExclusionClassAction => ({\n type: REMOVE_EXCLUSION_CLASS,\n payload: { className },\n});\n\nexport const addExclusionAttribute = (attribute: string): AddExclusionAttributeAction => ({\n type: ADD_EXCLUSION_ATTRIBUTE,\n payload: { attribute },\n});\n\nexport const removeExclusionAttribute = (attribute: string): RemoveExclusionAttributeAction => ({\n type: REMOVE_EXCLUSION_ATTRIBUTE,\n payload: { attribute },\n});\n\nexport const activateMode = (mode: string): ActivateModeAction => ({\n type: ACTIVATE_MODE,\n payload: { mode },\n});\n\nexport const setCursor = (cursor: string): SetCursorAction => ({\n type: SET_CURSOR,\n payload: { cursor },\n});\n\nexport const setDefaultMode = (mode: string): SetDefaultModeAction => ({\n type: SET_DEFAULT_MODE,\n payload: { mode },\n});\n\nexport const pauseInteraction = (): PauseInteractionAction => ({\n type: PAUSE_INTERACTION,\n});\n\nexport const resumeInteraction = (): ResumeInteractionAction => ({\n type: RESUME_INTERACTION,\n});\n\nexport type InteractionManagerAction =\n | SetExclusionRulesAction\n | AddExclusionClassAction\n | RemoveExclusionClassAction\n | AddExclusionAttributeAction\n | RemoveExclusionAttributeAction\n | ActivateModeAction\n | PauseInteractionAction\n | ResumeInteractionAction\n | SetCursorAction\n | SetDefaultModeAction;\n","import { PointerEventHandlers } from './types';\n\nexport function mergeHandlers(list: PointerEventHandlers[]): PointerEventHandlers {\n const keys: (keyof PointerEventHandlers)[] = [\n 'onPointerDown',\n 'onPointerUp',\n 'onPointerMove',\n 'onPointerEnter',\n 'onPointerLeave',\n 'onPointerCancel',\n 'onMouseDown',\n 'onMouseUp',\n 'onMouseMove',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseCancel',\n 'onClick',\n 'onDoubleClick',\n ];\n const out: Partial<PointerEventHandlers> = {};\n for (const k of keys) {\n out[k] = (evt: any, nativeEvt: any, modeId: string) => {\n for (const h of list) h[k]?.(evt, nativeEvt, modeId);\n };\n }\n return out as PointerEventHandlers;\n}\n","import { BasePlugin, createBehaviorEmitter, createEmitter, PluginRegistry } from '@embedpdf/core';\n\nimport {\n InteractionExclusionRules,\n InteractionManagerCapability,\n InteractionManagerPluginConfig,\n InteractionManagerState,\n InteractionMode,\n InteractionScope,\n PointerEventHandlers,\n PointerEventHandlersWithLifecycle,\n RegisterAlwaysOptions,\n RegisterHandlersOptions,\n} from './types';\nimport {\n activateMode,\n addExclusionAttribute,\n addExclusionClass,\n pauseInteraction,\n removeExclusionAttribute,\n removeExclusionClass,\n resumeInteraction,\n setCursor,\n setDefaultMode,\n setExclusionRules,\n} from './actions';\nimport { mergeHandlers } from './helper';\n\ninterface CursorClaim {\n cursor: string;\n priority: number;\n}\n\ntype HandlerSet = Set<PointerEventHandlersWithLifecycle>;\ntype PageHandlerMap = Map<number /*pageIdx*/, HandlerSet>;\n\ninterface ModeBuckets {\n /** handlers that listen on the global wrapper (only once per viewer) */\n global: HandlerSet;\n /** handlers that listen on a *specific* page wrapper */\n page: PageHandlerMap;\n}\n\nconst INITIAL_MODE = 'pointerMode';\n\nexport class InteractionManagerPlugin extends BasePlugin<\n InteractionManagerPluginConfig,\n InteractionManagerCapability,\n InteractionManagerState\n> {\n static readonly id = 'interaction-manager' as const;\n\n private modes = new Map<string, InteractionMode>();\n private cursorClaims = new Map<string, CursorClaim>();\n private buckets = new Map<string, ModeBuckets>();\n\n private alwaysGlobal = new Set<PointerEventHandlersWithLifecycle>();\n private alwaysPage = new Map<number, Set<PointerEventHandlersWithLifecycle>>();\n\n private readonly onModeChange$ = createEmitter<InteractionManagerState>();\n private readonly onHandlerChange$ = createEmitter<InteractionManagerState>();\n private readonly onCursorChange$ = createEmitter<string>();\n private readonly onStateChange$ = createBehaviorEmitter<InteractionManagerState>();\n\n constructor(id: string, registry: PluginRegistry, config: InteractionManagerPluginConfig) {\n super(id, registry);\n\n this.registerMode({\n id: INITIAL_MODE,\n scope: 'page',\n exclusive: false,\n cursor: 'auto',\n });\n\n this.setDefaultMode(INITIAL_MODE);\n this.activate(INITIAL_MODE);\n if (config.exclusionRules) {\n this.dispatch(setExclusionRules(config.exclusionRules));\n }\n }\n\n async initialize(_: InteractionManagerPluginConfig): Promise<void> {}\n\n protected buildCapability(): InteractionManagerCapability {\n return {\n activate: (modeId: string) => this.activate(modeId),\n onModeChange: this.onModeChange$.on,\n onCursorChange: this.onCursorChange$.on,\n onHandlerChange: this.onHandlerChange$.on,\n onStateChange: this.onStateChange$.on,\n getActiveMode: () => this.state.activeMode,\n getActiveInteractionMode: () => this.getActiveInteractionMode(),\n activateDefaultMode: () => this.activate(this.state.defaultMode),\n registerMode: (mode: InteractionMode) => this.registerMode(mode),\n registerHandlers: (options: RegisterHandlersOptions) => this.registerHandlers(options),\n registerAlways: (options: RegisterAlwaysOptions) => this.registerAlways(options),\n setCursor: (token: string, cursor: string, priority = 0) =>\n this.setCursor(token, cursor, priority),\n removeCursor: (token: string) => this.removeCursor(token),\n getCurrentCursor: () => this.state.cursor,\n getHandlersForScope: (scope: InteractionScope) => this.getHandlersForScope(scope),\n activeModeIsExclusive: () => this.activeModeIsExclusive(),\n pause: () => this.dispatch(pauseInteraction()),\n resume: () => this.dispatch(resumeInteraction()),\n // Treat a destroyed registry as \"paused\" so late DOM events are ignored during teardown.\n isPaused: () => this.registry.isDestroyed() || this.state.paused,\n setDefaultMode: (id: string) => this.setDefaultMode(id),\n getDefaultMode: () => this.state.defaultMode,\n getExclusionRules: () => this.state.exclusionRules,\n setExclusionRules: (rules: InteractionExclusionRules) =>\n this.dispatch(setExclusionRules(rules)),\n addExclusionClass: (className: string) => this.dispatch(addExclusionClass(className)),\n removeExclusionClass: (className: string) => this.dispatch(removeExclusionClass(className)),\n addExclusionAttribute: (attribute: string) => this.dispatch(addExclusionAttribute(attribute)),\n removeExclusionAttribute: (attribute: string) =>\n this.dispatch(removeExclusionAttribute(attribute)),\n };\n }\n\n private activate(mode: string) {\n if (!this.modes.has(mode)) {\n throw new Error(`[interaction] unknown mode '${mode}'`);\n }\n if (mode === this.state.activeMode) return;\n\n const previousMode = this.state.activeMode;\n this.cursorClaims.clear(); // prevent cursor leaks\n\n this.notifyHandlersInactive(previousMode);\n\n this.dispatch(activateMode(mode));\n this.emitCursor();\n\n // Call lifecycle hooks for handlers going active\n this.notifyHandlersActive(mode);\n\n this.onModeChange$.emit({ ...this.state, activeMode: mode });\n }\n\n private setDefaultMode(modeId: string) {\n if (!this.modes.has(modeId)) {\n throw new Error(`[interaction] cannot set unknown mode '${modeId}' as default`);\n }\n this.dispatch(setDefaultMode(modeId));\n }\n\n private notifyHandlersActive(modeId: string) {\n this.alwaysGlobal.forEach((handler) => {\n handler.onHandlerActiveStart?.(modeId);\n });\n\n this.alwaysPage.forEach((handlerSet) => {\n handlerSet.forEach((handler) => {\n handler.onHandlerActiveStart?.(modeId);\n });\n });\n\n const mode = this.modes.get(modeId);\n if (!mode) return;\n\n const bucket = this.buckets.get(modeId);\n if (!bucket) return;\n\n // Notify global handlers if mode is global\n if (mode.scope === 'global') {\n bucket.global.forEach((handler) => {\n handler.onHandlerActiveStart?.(modeId);\n });\n }\n\n // Notify page handlers if mode is page\n if (mode.scope === 'page') {\n bucket.page.forEach((handlerSet, pageIndex) => {\n handlerSet.forEach((handler) => {\n handler.onHandlerActiveStart?.(modeId);\n });\n });\n }\n }\n\n private notifyHandlersInactive(modeId: string) {\n this.alwaysGlobal.forEach((handler) => {\n handler.onHandlerActiveEnd?.(modeId);\n });\n\n this.alwaysPage.forEach((handlerSet) => {\n handlerSet.forEach((handler) => {\n handler.onHandlerActiveEnd?.(modeId);\n });\n });\n\n const mode = this.modes.get(modeId);\n if (!mode) return;\n\n const bucket = this.buckets.get(modeId);\n if (!bucket) return;\n\n // Notify global handlers if mode is global\n if (mode.scope === 'global') {\n bucket.global.forEach((handler) => {\n handler.onHandlerActiveEnd?.(modeId);\n });\n }\n\n // Notify page handlers if mode is page\n if (mode.scope === 'page') {\n bucket.page.forEach((handlerSet, pageIndex) => {\n handlerSet.forEach((handler) => {\n handler.onHandlerActiveEnd?.(modeId);\n });\n });\n }\n }\n\n private registerMode(mode: InteractionMode) {\n this.modes.set(mode.id, mode);\n if (!this.buckets.has(mode.id)) {\n this.buckets.set(mode.id, { global: new Set(), page: new Map() });\n }\n }\n\n /** ---------- pointer-handler handling ------------ */\n private registerHandlers({ modeId, handlers, pageIndex }: RegisterHandlersOptions): () => void {\n const modeIds = Array.isArray(modeId) ? modeId : [modeId];\n const cleanupFunctions: (() => void)[] = [];\n\n for (const id of modeIds) {\n const bucket = this.buckets.get(id);\n if (!bucket) throw new Error(`unknown mode '${id}'`);\n\n if (pageIndex == null) {\n bucket.global.add(handlers);\n } else {\n const set = bucket.page.get(pageIndex) ?? new Set();\n set.add(handlers);\n bucket.page.set(pageIndex, set);\n }\n\n // Create cleanup function for this specific mode\n cleanupFunctions.push(() => {\n if (pageIndex == null) {\n bucket.global.delete(handlers);\n } else {\n const set = bucket.page.get(pageIndex);\n if (set) {\n set.delete(handlers);\n if (set.size === 0) {\n bucket.page.delete(pageIndex);\n }\n }\n }\n });\n }\n\n this.onHandlerChange$.emit({ ...this.state });\n\n // Return a cleanup function that removes handlers from all registered modes\n return () => {\n cleanupFunctions.forEach((cleanup) => cleanup());\n this.onHandlerChange$.emit({ ...this.state });\n };\n }\n\n public registerAlways({ scope, handlers }: RegisterAlwaysOptions): () => void {\n if (scope.type === 'global') {\n this.alwaysGlobal.add(handlers);\n this.onHandlerChange$.emit({ ...this.state });\n return () => this.alwaysGlobal.delete(handlers);\n }\n const set = this.alwaysPage.get(scope.pageIndex) ?? new Set();\n set.add(handlers);\n this.alwaysPage.set(scope.pageIndex, set);\n this.onHandlerChange$.emit({ ...this.state });\n return () => {\n set.delete(handlers);\n this.onHandlerChange$.emit({ ...this.state });\n };\n }\n\n /** Returns the *merged* handler set that should be active for the given\n * provider (`global` wrapper or a single page wrapper).\n * – `alwaysGlobal` / `alwaysPage` are **always** active.\n * – Handlers that belong to the current mode are added on top **iff**\n * the mode’s own scope matches the provider’s scope. */\n private getHandlersForScope(scope: InteractionScope): PointerEventHandlers | null {\n if (!this.state) return null;\n\n const mode = this.modes.get(this.state.activeMode);\n if (!mode) return null;\n\n const bucket = this.buckets.get(mode.id);\n if (!bucket) return null;\n\n /** helper – merge two handler sets into one object (or `null` if both are empty) */\n const mergeSets = (a: HandlerSet, b: HandlerSet) =>\n a.size || b.size ? mergeHandlers([...a, ...b]) : null;\n\n /* ───────────────────── GLOBAL PROVIDER ─────────────────────── */\n if (scope.type === 'global') {\n const modeSpecific =\n mode.scope === 'global' // only include mode handlers if the\n ? bucket.global // mode itself is global-scoped\n : new Set<PointerEventHandlers>();\n return mergeSets(this.alwaysGlobal, modeSpecific);\n }\n\n /* ─────────────────────── PAGE PROVIDER ──────────────────────── */\n const alwaysPageSet = this.alwaysPage.get(scope.pageIndex) ?? new Set<PointerEventHandlers>();\n const modePageSet =\n mode.scope === 'page'\n ? (bucket.page.get(scope.pageIndex) ?? new Set<PointerEventHandlers>())\n : new Set<PointerEventHandlers>(); // global-scoped mode → ignore page buckets\n\n return mergeSets(alwaysPageSet, modePageSet);\n }\n\n /** ---------- cursor handling --------------------- */\n private setCursor(token: string, cursor: string, priority = 0) {\n this.cursorClaims.set(token, { cursor, priority });\n this.emitCursor();\n }\n private removeCursor(token: string) {\n this.cursorClaims.delete(token);\n this.emitCursor();\n }\n\n private emitCursor() {\n /* pick highest priority claim, else mode baseline */\n const top = [...this.cursorClaims.values()].sort((a, b) => b.priority - a.priority)[0] ?? {\n cursor: this.modes.get(this.state.activeMode)?.cursor ?? 'auto',\n };\n\n if (top.cursor !== this.state.cursor) {\n this.dispatch(setCursor(top.cursor));\n this.onCursorChange$.emit(top.cursor);\n }\n }\n\n override onStoreUpdated(_: InteractionManagerState, newState: InteractionManagerState): void {\n this.onStateChange$.emit(newState);\n }\n\n private activeModeIsExclusive(): boolean {\n const mode = this.modes.get(this.state.activeMode);\n return !!mode?.exclusive;\n }\n\n private getActiveInteractionMode(): InteractionMode | null {\n return this.modes.get(this.state.activeMode) ?? null;\n }\n\n // keep emitter clean\n async destroy(): Promise<void> {\n this.onModeChange$.clear();\n this.onCursorChange$.clear();\n await super.destroy();\n }\n}\n","import { PluginManifest } from '@embedpdf/core';\nimport { InteractionManagerPluginConfig } from './types';\n\nexport const INTERACTION_MANAGER_PLUGIN_ID = 'interaction-manager';\n\nexport const manifest: PluginManifest<InteractionManagerPluginConfig> = {\n id: INTERACTION_MANAGER_PLUGIN_ID,\n name: 'Interaction Manager Plugin',\n version: '1.0.0',\n provides: ['interaction-manager'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n exclusionRules: {\n classes: [],\n dataAttributes: ['data-no-interaction'],\n },\n },\n};\n","import { Reducer } from '@embedpdf/core';\nimport {\n ACTIVATE_MODE,\n SET_DEFAULT_MODE,\n InteractionManagerAction,\n PAUSE_INTERACTION,\n RESUME_INTERACTION,\n SET_CURSOR,\n SET_EXCLUSION_RULES,\n ADD_EXCLUSION_CLASS,\n REMOVE_EXCLUSION_CLASS,\n ADD_EXCLUSION_ATTRIBUTE,\n REMOVE_EXCLUSION_ATTRIBUTE,\n} from './actions';\nimport { InteractionManagerState } from './types';\n\nexport const initialState: InteractionManagerState = {\n activeMode: 'pointerMode',\n defaultMode: 'pointerMode',\n cursor: 'auto',\n paused: false,\n exclusionRules: {\n classes: [],\n dataAttributes: [],\n },\n};\n\nexport const reducer: Reducer<InteractionManagerState, InteractionManagerAction> = (\n state,\n action,\n) => {\n switch (action.type) {\n case ACTIVATE_MODE:\n return {\n ...state,\n activeMode: action.payload.mode,\n };\n case SET_CURSOR:\n return {\n ...state,\n cursor: action.payload.cursor,\n };\n case PAUSE_INTERACTION:\n return {\n ...state,\n paused: true,\n };\n case RESUME_INTERACTION:\n return {\n ...state,\n paused: false,\n };\n case SET_DEFAULT_MODE:\n return {\n ...state,\n defaultMode: action.payload.mode,\n };\n case SET_EXCLUSION_RULES:\n return {\n ...state,\n exclusionRules: action.payload.rules,\n };\n\n case ADD_EXCLUSION_CLASS:\n return {\n ...state,\n exclusionRules: {\n ...state.exclusionRules,\n classes: [...(state.exclusionRules.classes || []), action.payload.className].filter(\n (v, i, a) => a.indexOf(v) === i,\n ), // Remove duplicates\n },\n };\n\n case REMOVE_EXCLUSION_CLASS:\n return {\n ...state,\n exclusionRules: {\n ...state.exclusionRules,\n classes: (state.exclusionRules.classes || []).filter(\n (c) => c !== action.payload.className,\n ),\n },\n };\n\n case ADD_EXCLUSION_ATTRIBUTE:\n return {\n ...state,\n exclusionRules: {\n ...state.exclusionRules,\n dataAttributes: [\n ...(state.exclusionRules.dataAttributes || []),\n action.payload.attribute,\n ].filter((v, i, a) => a.indexOf(v) === i),\n },\n };\n\n case REMOVE_EXCLUSION_ATTRIBUTE:\n return {\n ...state,\n exclusionRules: {\n ...state.exclusionRules,\n dataAttributes: (state.exclusionRules.dataAttributes || []).filter(\n (a) => a !== action.payload.attribute,\n ),\n },\n };\n default:\n return state;\n }\n};\n","import { PluginPackage } from '@embedpdf/core';\n\nimport { InteractionManagerPlugin } from './interaction-manager-plugin';\nimport { manifest, INTERACTION_MANAGER_PLUGIN_ID } from './manifest';\nimport { InteractionManagerPluginConfig, InteractionManagerState } from './types';\nimport { reducer, initialState } from './reducer';\nimport { InteractionManagerAction } from './actions';\n\nexport const InteractionManagerPluginPackage: PluginPackage<\n InteractionManagerPlugin,\n InteractionManagerPluginConfig,\n InteractionManagerState,\n InteractionManagerAction\n> = {\n manifest,\n create: (registry, config) =>\n new InteractionManagerPlugin(INTERACTION_MANAGER_PLUGIN_ID, registry, config),\n reducer,\n initialState,\n};\n\nexport * from './interaction-manager-plugin';\nexport * from './types';\nexport * from './manifest';\nexport * from './reducer';\n"],"names":[],"mappings":";AAGO,MAAM,gBAAgB;AACtB,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;AAC3B,MAAM,aAAa;AACnB,MAAM,mBAAmB;AACzB,MAAM,sBAAsB;AAC5B,MAAM,sBAAsB;AAC5B,MAAM,yBAAyB;AAC/B,MAAM,0BAA0B;AAChC,MAAM,6BAA6B;AAkD7B,MAAA,oBAAoB,CAAC,WAA+D;AAAA,EAC/F,MAAM;A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Element> {
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,2 @@
1
+ export * from './global-pointer-provider';
2
+ export * from './page-pointer-provider';
@@ -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
+ export * from './hooks';
2
+ export * from './components';
3
+ export * from '../index.ts';
@@ -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,2 @@
1
+ export { default as GlobalPointerProvider } from './GlobalPointerProvider.svelte';
2
+ export { default as PagePointerProvider } from './PagePointerProvider.svelte';
@@ -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,iBAAsBI,WAAMH,WAAA,GACrD,KAIG,mBAAAP,gBACKA,IAGb,CCvFA,MAAMW,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,S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AAC,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,3 @@
1
+ export * from './components';
2
+ export * from './hooks';
3
+ export * from '../lib/index.ts';
@@ -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,cAAA,IAAA,QAAA,MAAA,mBAAA,UAAU,OAAO,QAAQ;AAAA,IACrC;AAAA,IACA,cAAA,CAAe,UAAkB;;kBAC/B,QAAA,yBAAU,aAAa;AAAA;;AAG7B;AAOgB,SAAA,mBAAqB,EAAA,QAAQ,aAAwC;0BACrD,kCAAtB,wCAAA,QAAA;;IAEN,UACE,CAAA,UACA,YACG;;AAEG,YAAA,eAAc,mCAAS,WAAU;AACjC,YAAA,kBAAiB,mCAAS,cAAa;aAEt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AA,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.15",
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.3.15"
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/core": "1.3.15",
38
- "@embedpdf/build": "1.0.1"
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
- "@embedpdf/core": "1.3.15"
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": "pnpm run clean && concurrently -c auto -n base,react,preact,vue \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\" \"vite build --mode vue\"",
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"