@embedpdf/plugin-interaction-manager 1.0.10 → 1.0.12
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 +2 -359
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -177
- package/dist/index.js +39 -41
- package/dist/index.js.map +1 -1
- package/dist/lib/actions.d.ts +28 -0
- package/dist/lib/helper.d.ts +2 -0
- package/dist/lib/index.d.ts +9 -0
- package/dist/lib/interaction-manager-plugin.d.ts +38 -0
- package/dist/lib/manifest.d.ts +4 -0
- package/dist/lib/reducer.d.ts +5 -0
- package/dist/{index.d.cts → lib/types.d.ts} +12 -83
- package/dist/preact/adapter.d.ts +4 -0
- package/dist/preact/core.d.ts +1 -0
- package/dist/preact/index.cjs +2 -258
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.d.ts +1 -58
- package/dist/preact/index.js +83 -40
- package/dist/preact/index.js.map +1 -1
- package/dist/react/adapter.d.ts +2 -0
- package/dist/react/core.d.ts +1 -0
- package/dist/react/index.cjs +2 -258
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.ts +1 -55
- package/dist/react/index.js +83 -38
- package/dist/react/index.js.map +1 -1
- package/dist/shared-preact/components/global-pointer-provider.d.ts +7 -0
- package/dist/shared-preact/components/index.d.ts +2 -0
- package/dist/shared-preact/components/page-pointer-provider.d.ts +14 -0
- package/dist/shared-preact/hooks/index.d.ts +1 -0
- package/dist/shared-preact/hooks/use-interaction-manager.d.ts +31 -0
- package/dist/shared-preact/index.d.ts +2 -0
- package/dist/shared-preact/utils.d.ts +8 -0
- package/dist/shared-react/components/global-pointer-provider.d.ts +7 -0
- package/dist/shared-react/components/index.d.ts +2 -0
- package/dist/shared-react/components/page-pointer-provider.d.ts +14 -0
- package/dist/shared-react/hooks/index.d.ts +1 -0
- package/dist/shared-react/hooks/use-interaction-manager.d.ts +31 -0
- package/dist/shared-react/index.d.ts +2 -0
- package/dist/shared-react/utils.d.ts +8 -0
- package/dist/shared-vue/utils.d.ts +8 -0
- package/dist/vue/components/global-pointer-provider.vue.d.ts +12 -0
- package/dist/vue/components/index.d.ts +2 -0
- package/dist/vue/components/page-pointer-provider.vue.d.ts +21 -0
- package/dist/vue/hooks/index.d.ts +1 -0
- package/dist/vue/hooks/use-interaction-manager.d.ts +31 -0
- package/dist/vue/index.cjs +2 -0
- package/dist/vue/index.cjs.map +1 -0
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/index.js +222 -0
- package/dist/vue/index.js.map +1 -0
- package/package.json +19 -11
- package/dist/chunk-Z7V2G6MS.js +0 -64
- package/dist/chunk-Z7V2G6MS.js.map +0 -1
- package/dist/preact/index.d.cts +0 -58
- package/dist/react/index.d.cts +0 -55
package/dist/preact/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/preact/components/global-pointer-provider.tsx","../../src/preact/hooks/use-interaction-manager.ts","../../src/preact/components/page-pointer-provider.tsx"],"sourcesContent":["/** @jsxImportSource preact */\nimport { ComponentChildren, JSX } from 'preact';\nimport { useEffect, useRef } from 'preact/hooks';\nimport { createPointerProvider } from '../../shared/utils';\n\nimport { useInteractionManagerCapability } from '../hooks';\n\ninterface GlobalPointerProviderProps extends JSX.HTMLAttributes<HTMLDivElement> {\n children: ComponentChildren;\n style?: JSX.CSSProperties;\n}\n\nexport const GlobalPointerProvider = ({\n children,\n style,\n ...props\n}: GlobalPointerProviderProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const { provides: cap } = useInteractionManagerCapability();\n\n useEffect(() => {\n if (!cap || !ref.current) return;\n\n return createPointerProvider(cap, { type: 'global' }, ref.current);\n }, [cap]);\n\n return (\n <div\n ref={ref}\n style={{\n width: '100%',\n height: '100%',\n ...style,\n }}\n {...props}\n >\n {children}\n </div>\n );\n};\n","import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport {\n initialState,\n InteractionManagerPlugin,\n InteractionManagerState,\n PointerEventHandlers,\n PointerEventHandlersWithLifecycle,\n} from '@embedpdf/plugin-interaction-manager';\nimport { useState, useEffect } from 'preact/hooks';\n\nexport const useInteractionManagerPlugin = () =>\n usePlugin<InteractionManagerPlugin>(InteractionManagerPlugin.id);\nexport const useInteractionManagerCapability = () =>\n useCapability<InteractionManagerPlugin>(InteractionManagerPlugin.id);\n\nexport function useInteractionManager() {\n const { provides } = useInteractionManagerCapability();\n const [state, setState] = useState<InteractionManagerState>(initialState);\n\n useEffect(() => {\n if (!provides) return;\n return provides.onStateChange((state) => {\n setState(state);\n });\n }, [provides]);\n\n return {\n provides,\n state,\n };\n}\n\nexport function useCursor() {\n const { provides } = 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 } = 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 } = useInteractionManagerCapability();\n\n const [isPageExclusive, setIsPageExclusive] = useState<boolean>(() => {\n const m = cap?.getActiveInteractionMode();\n return m?.scope === 'page' && !!m.exclusive;\n });\n\n useEffect(() => {\n if (!cap) return;\n\n return cap.onModeChange(() => {\n const mode = cap.getActiveInteractionMode();\n setIsPageExclusive(mode?.scope === 'page' && !!mode?.exclusive);\n });\n }, [cap]);\n\n return isPageExclusive;\n}\n","/** @jsxImportSource preact */\nimport { ComponentChildren, JSX } from 'preact';\nimport { useCallback, useEffect, useRef } from 'preact/hooks';\nimport { Position, restorePosition } from '@embedpdf/models';\nimport { createPointerProvider } from '../../shared/utils';\n\nimport { useInteractionManagerCapability, useIsPageExclusive } from '../hooks';\n\ninterface PagePointerProviderProps extends JSX.HTMLAttributes<HTMLDivElement> {\n children: ComponentChildren;\n pageIndex: number;\n pageWidth: number;\n pageHeight: number;\n rotation: number;\n scale: number;\n style?: JSX.CSSProperties;\n convertEventToPoint?: (event: PointerEvent, element: HTMLElement) => Position;\n}\n\nexport const PagePointerProvider = ({\n pageIndex,\n children,\n pageWidth,\n pageHeight,\n rotation,\n scale,\n convertEventToPoint,\n style,\n ...props\n}: PagePointerProviderProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const { provides: cap } = useInteractionManagerCapability();\n const isPageExclusive = useIsPageExclusive();\n\n const defaultConvertEventToPoint = useCallback(\n (event: PointerEvent, element: HTMLElement): Position => {\n const rect = element.getBoundingClientRect();\n const displayPoint = {\n x: event.clientX - rect.left,\n y: event.clientY - rect.top,\n };\n return restorePosition(\n { width: pageWidth, height: pageHeight },\n displayPoint,\n rotation,\n scale,\n );\n },\n [pageWidth, pageHeight, rotation, scale],\n );\n\n useEffect(() => {\n if (!cap || !ref.current) return;\n\n return createPointerProvider(\n cap,\n { type: 'page', pageIndex },\n ref.current,\n convertEventToPoint || defaultConvertEventToPoint,\n );\n }, [cap, pageIndex, convertEventToPoint, defaultConvertEventToPoint]);\n\n return (\n <div\n ref={ref}\n style={{\n ...style,\n }}\n {...props}\n >\n {children}\n {isPageExclusive && (\n <div style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, zIndex: 10 }} />\n )}\n </div>\n );\n};\n"],"mappings":";;;;;AAEA,SAAS,aAAAA,YAAW,cAAc;;;ACFlC,SAAS,eAAe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,kBAAkB,mBAAmB;AAE3C,QAAM,6BAA6B;AAAA,IACjC,CAAC,OAAqB,YAAmC;AACvD,YAAM,OAAO,QAAQ,sBAAsB;AAC3C,YAAM,eAAe;AAAA,QACnB,GAAG,MAAM,UAAU,KAAK;AAAA,QACxB,GAAG,MAAM,UAAU,KAAK;AAAA,MAC1B;AACA,aAAO;AAAA,QACL,EAAE,OAAO,WAAW,QAAQ,WAAW;AAAA,QACvC;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,WAAW,YAAY,UAAU,KAAK;AAAA,EACzC;AAEA,EAAAC,WAAU,MAAM;AACd,QAAI,CAAC,OAAO,CAAC,IAAI,QAAS;AAE1B,WAAO;AAAA,MACL;AAAA,MACA,EAAE,MAAM,QAAQ,UAAU;AAAA,MAC1B,IAAI;AAAA,MACJ,uBAAuB;AAAA,IACzB;AAAA,EACF,GAAG,CAAC,KAAK,WAAW,qBAAqB,0BAA0B,CAAC;AAEpE,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,OAAO;AAAA,QACL,GAAG;AAAA,MACL;AAAA,MACC,GAAG;AAAA,MAEH;AAAA;AAAA,QACA,mBACC,gBAAAF,KAAC,SAAI,OAAO,EAAE,UAAU,YAAY,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,GAAG;AAAA;AAAA;AAAA,EAE5F;AAEJ;","names":["useEffect","state","useEffect","useEffect","useRef","jsx","useRef","useEffect"]}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-interaction-manager.ts","../../src/shared/utils.ts","../../src/shared/components/global-pointer-provider.tsx","../../src/shared/components/page-pointer-provider.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport {\n initialState,\n InteractionManagerPlugin,\n InteractionManagerState,\n PointerEventHandlers,\n PointerEventHandlersWithLifecycle,\n} from '@embedpdf/plugin-interaction-manager';\nimport { useState, useEffect } from '@framework';\n\nexport const useInteractionManagerPlugin = () =>\n usePlugin<InteractionManagerPlugin>(InteractionManagerPlugin.id);\nexport const useInteractionManagerCapability = () =>\n useCapability<InteractionManagerPlugin>(InteractionManagerPlugin.id);\n\nexport function useInteractionManager() {\n const { provides } = useInteractionManagerCapability();\n const [state, setState] = useState<InteractionManagerState>(initialState);\n\n useEffect(() => {\n if (!provides) return;\n return provides.onStateChange((state) => {\n setState(state);\n });\n }, [provides]);\n\n return {\n provides,\n state,\n };\n}\n\nexport function useCursor() {\n const { provides } = 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 } = 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 } = useInteractionManagerCapability();\n\n const [isPageExclusive, setIsPageExclusive] = useState<boolean>(() => {\n const m = cap?.getActiveInteractionMode();\n return m?.scope === 'page' && !!m.exclusive;\n });\n\n useEffect(() => {\n if (!cap) return;\n\n return cap.onModeChange(() => {\n const mode = cap.getActiveInteractionMode();\n setIsPageExclusive(mode?.scope === 'page' && !!mode?.exclusive);\n });\n }, [cap]);\n\n return isPageExclusive;\n}\n","import { Position } from '@embedpdf/models';\nimport type {\n InteractionManagerCapability,\n InteractionScope,\n PointerEventHandlers,\n} from '@embedpdf/plugin-interaction-manager';\n\n/**\n * Hook one DOM element into the interaction-manager.\n * – keeps handlers & cursor in-sync with the current mode\n * – returns a teardown fn for React/Preact effects\n */\nexport function createPointerProvider(\n cap: InteractionManagerCapability,\n scope: InteractionScope,\n element: HTMLElement,\n convertEventToPoint?: (evt: PointerEvent, host: HTMLElement) => Position,\n) {\n /* ------------------------------------------------------------------ */\n /* active handler set – hot-swapped on every mode change */\n /* ------------------------------------------------------------------ */\n let active: PointerEventHandlers | null = cap.getHandlersForScope(scope);\n\n const stopMode = cap.onModeChange(() => {\n if (scope.type === 'global') {\n const mode = cap.getActiveInteractionMode();\n element.style.cursor = mode?.scope === 'global' ? (mode.cursor ?? 'auto') : 'auto';\n }\n active = cap.getHandlersForScope(scope);\n });\n\n const stopHandler = cap.onHandlerChange(() => {\n active = cap.getHandlersForScope(scope);\n });\n\n /* ------------------------------------------------------------------ */\n /* cursor */\n /* ------------------------------------------------------------------ */\n const modeNow = cap.getActiveInteractionMode();\n const cursorNow = cap.getCurrentCursor();\n\n /** initial cursor -------------------------------------------------- */\n if (scope.type === 'global') {\n // global wrapper only shows the cursor while a *global* mode is active\n element.style.cursor = modeNow?.scope === 'global' ? cursorNow : 'auto';\n } else {\n // page wrappers always mirror the latest cursor\n element.style.cursor = cursorNow;\n }\n\n const stopCursor = cap.onCursorChange((c) => {\n /** ❖ Propagation rule\n * ─────────────────\n * • global provider updates its cursor *only* while the active\n * mode itself is ‘global’.\n * • page providers always sync (so they show the cursor during\n * a global mode as well). */\n if (scope.type === 'global') {\n const isGlobalMode = cap.getActiveInteractionMode()?.scope === 'global';\n if (!isGlobalMode) return; // active mode is page-scoped → ignore\n }\n element.style.cursor = c;\n });\n\n /* ------------------------------------------------------------------ */\n /* event wiring */\n /* ------------------------------------------------------------------ */\n type K = keyof PointerEventHandlers;\n const domEvent: Record<K, keyof HTMLElementEventMap> = {\n onPointerDown: 'pointerdown',\n onPointerUp: 'pointerup',\n onPointerMove: 'pointermove',\n onPointerEnter: 'pointerenter',\n onPointerLeave: 'pointerleave',\n onPointerCancel: 'pointercancel',\n };\n\n /* one stable EventListener per key -> needed for removeEventListener */\n const listeners: Partial<Record<K, EventListener>> = {};\n\n const toPos = (e: PointerEvent, host: HTMLElement): Position => {\n if (convertEventToPoint) return convertEventToPoint(e, host);\n const r = host.getBoundingClientRect();\n return { x: e.clientX - r.left, y: e.clientY - r.top };\n };\n\n (Object.keys(domEvent) as K[]).forEach((k) => {\n listeners[k] = (evt: Event) => {\n if (cap.isPaused()) return;\n\n const pe = evt as PointerEvent; // safe – we only attach to pointer*\n const currentModeId = cap.getActiveMode();\n active?.[k]?.(toPos(pe, element), pe, currentModeId);\n /* if you need to stop default behaviour when no handler is active:\n * if (!active?.[k]) pe.preventDefault(); */\n };\n element.addEventListener(domEvent[k], listeners[k]!);\n });\n\n /* ------------------------------------------------------------------ */\n /* teardown */\n /* ------------------------------------------------------------------ */\n return () => {\n (Object.keys(domEvent) as K[]).forEach((k) =>\n element.removeEventListener(domEvent[k], listeners[k]!),\n );\n stopMode();\n stopCursor();\n stopHandler();\n };\n}\n","import { ReactNode, useEffect, useRef, HTMLAttributes, CSSProperties } from '@framework';\nimport { createPointerProvider } from '../utils';\n\nimport { useInteractionManagerCapability } from '../hooks';\n\ninterface GlobalPointerProviderProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n style?: CSSProperties;\n}\n\nexport const GlobalPointerProvider = ({\n children,\n style,\n ...props\n}: GlobalPointerProviderProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const { provides: cap } = useInteractionManagerCapability();\n\n useEffect(() => {\n if (!cap || !ref.current) return;\n\n return createPointerProvider(cap, { type: 'global' }, ref.current);\n }, [cap]);\n\n return (\n <div\n ref={ref}\n style={{\n width: '100%',\n height: '100%',\n ...style,\n }}\n {...props}\n >\n {children}\n </div>\n );\n};\n","import {\n ReactNode,\n useEffect,\n useRef,\n useCallback,\n HTMLAttributes,\n CSSProperties,\n} from '@framework';\nimport { Position, restorePosition } from '@embedpdf/models';\nimport { createPointerProvider } from '../utils';\n\nimport { useInteractionManagerCapability, useIsPageExclusive } from '../hooks';\n\ninterface PagePointerProviderProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n pageIndex: number;\n pageWidth: number;\n pageHeight: number;\n rotation: number;\n scale: number;\n style?: CSSProperties;\n convertEventToPoint?: (event: PointerEvent, element: HTMLElement) => Position;\n}\n\nexport const PagePointerProvider = ({\n pageIndex,\n children,\n pageWidth,\n pageHeight,\n rotation,\n scale,\n convertEventToPoint,\n style,\n ...props\n}: PagePointerProviderProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const { provides: cap } = useInteractionManagerCapability();\n const isPageExclusive = useIsPageExclusive();\n\n // Memoize the default conversion function\n const defaultConvertEventToPoint = useCallback(\n (event: PointerEvent, element: HTMLElement): Position => {\n const rect = element.getBoundingClientRect();\n const displayPoint = {\n x: event.clientX - rect.left,\n y: event.clientY - rect.top,\n };\n return restorePosition(\n { width: pageWidth, height: pageHeight },\n displayPoint,\n rotation,\n scale,\n );\n },\n [pageWidth, pageHeight, rotation, scale],\n );\n\n useEffect(() => {\n if (!cap || !ref.current) return;\n\n return createPointerProvider(\n cap,\n { type: 'page', pageIndex },\n ref.current,\n convertEventToPoint || defaultConvertEventToPoint,\n );\n }, [cap, pageIndex, convertEventToPoint, defaultConvertEventToPoint]);\n\n return (\n <div\n ref={ref}\n style={{\n ...style,\n }}\n {...props}\n >\n {children}\n {isPageExclusive && (\n <div style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, zIndex: 10 }} />\n )}\n </div>\n );\n};\n"],"names":["state"],"mappings":";;;;;AAUO,MAAM,8BAA8B,MACzC,UAAoC,yBAAyB,EAAE;AAC1D,MAAM,kCAAkC,MAC7C,cAAwC,yBAAyB,EAAE;AAE9D,SAAS,wBAAwB;AAChC,QAAA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var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/react/index.ts
|
|
21
|
-
var react_exports = {};
|
|
22
|
-
__export(react_exports, {
|
|
23
|
-
GlobalPointerProvider: () => GlobalPointerProvider,
|
|
24
|
-
PagePointerProvider: () => PagePointerProvider,
|
|
25
|
-
useCursor: () => useCursor,
|
|
26
|
-
useInteractionManager: () => useInteractionManager,
|
|
27
|
-
useInteractionManagerCapability: () => useInteractionManagerCapability,
|
|
28
|
-
useInteractionManagerPlugin: () => useInteractionManagerPlugin,
|
|
29
|
-
useIsPageExclusive: () => useIsPageExclusive,
|
|
30
|
-
usePointerHandlers: () => usePointerHandlers
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(react_exports);
|
|
33
|
-
|
|
34
|
-
// src/react/hooks/use-interaction-manager.ts
|
|
35
|
-
var import_react = require("@embedpdf/core/react");
|
|
36
|
-
var import_plugin_interaction_manager = require("@embedpdf/plugin-interaction-manager");
|
|
37
|
-
var import_react2 = require("react");
|
|
38
|
-
var useInteractionManagerPlugin = () => (0, import_react.usePlugin)(import_plugin_interaction_manager.InteractionManagerPlugin.id);
|
|
39
|
-
var useInteractionManagerCapability = () => (0, import_react.useCapability)(import_plugin_interaction_manager.InteractionManagerPlugin.id);
|
|
40
|
-
function useInteractionManager() {
|
|
41
|
-
const { provides } = useInteractionManagerCapability();
|
|
42
|
-
const [state, setState] = (0, import_react2.useState)(import_plugin_interaction_manager.initialState);
|
|
43
|
-
(0, import_react2.useEffect)(() => {
|
|
44
|
-
if (!provides) return;
|
|
45
|
-
return provides.onStateChange((state2) => {
|
|
46
|
-
setState(state2);
|
|
47
|
-
});
|
|
48
|
-
}, [provides]);
|
|
49
|
-
return {
|
|
50
|
-
provides,
|
|
51
|
-
state
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function useCursor() {
|
|
55
|
-
const { provides } = useInteractionManagerCapability();
|
|
56
|
-
return {
|
|
57
|
-
setCursor: (token, cursor, prio = 0) => {
|
|
58
|
-
provides?.setCursor(token, cursor, prio);
|
|
59
|
-
},
|
|
60
|
-
removeCursor: (token) => {
|
|
61
|
-
provides?.removeCursor(token);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function usePointerHandlers({ modeId, pageIndex }) {
|
|
66
|
-
const { provides } = useInteractionManagerCapability();
|
|
67
|
-
return {
|
|
68
|
-
register: (handlers, options) => {
|
|
69
|
-
const finalModeId = options?.modeId ?? modeId;
|
|
70
|
-
const finalPageIndex = options?.pageIndex ?? pageIndex;
|
|
71
|
-
return finalModeId ? provides?.registerHandlers({
|
|
72
|
-
modeId: finalModeId,
|
|
73
|
-
handlers,
|
|
74
|
-
pageIndex: finalPageIndex
|
|
75
|
-
}) : provides?.registerAlways({
|
|
76
|
-
scope: finalPageIndex !== void 0 ? { type: "page", pageIndex: finalPageIndex } : { type: "global" },
|
|
77
|
-
handlers
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
function useIsPageExclusive() {
|
|
83
|
-
const { provides: cap } = useInteractionManagerCapability();
|
|
84
|
-
const [isPageExclusive, setIsPageExclusive] = (0, import_react2.useState)(() => {
|
|
85
|
-
const m = cap?.getActiveInteractionMode();
|
|
86
|
-
return m?.scope === "page" && !!m.exclusive;
|
|
87
|
-
});
|
|
88
|
-
(0, import_react2.useEffect)(() => {
|
|
89
|
-
if (!cap) return;
|
|
90
|
-
return cap.onModeChange(() => {
|
|
91
|
-
const mode = cap.getActiveInteractionMode();
|
|
92
|
-
setIsPageExclusive(mode?.scope === "page" && !!mode?.exclusive);
|
|
93
|
-
});
|
|
94
|
-
}, [cap]);
|
|
95
|
-
return isPageExclusive;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// src/react/components/global-pointer-provider.tsx
|
|
99
|
-
var import_react3 = require("react");
|
|
100
|
-
|
|
101
|
-
// src/shared/utils.ts
|
|
102
|
-
function createPointerProvider(cap, scope, element, convertEventToPoint) {
|
|
103
|
-
let active = cap.getHandlersForScope(scope);
|
|
104
|
-
const stopMode = cap.onModeChange(() => {
|
|
105
|
-
if (scope.type === "global") {
|
|
106
|
-
const mode = cap.getActiveInteractionMode();
|
|
107
|
-
element.style.cursor = mode?.scope === "global" ? mode.cursor ?? "auto" : "auto";
|
|
108
|
-
}
|
|
109
|
-
active = cap.getHandlersForScope(scope);
|
|
110
|
-
});
|
|
111
|
-
const stopHandler = cap.onHandlerChange(() => {
|
|
112
|
-
active = cap.getHandlersForScope(scope);
|
|
113
|
-
});
|
|
114
|
-
const modeNow = cap.getActiveInteractionMode();
|
|
115
|
-
const cursorNow = cap.getCurrentCursor();
|
|
116
|
-
if (scope.type === "global") {
|
|
117
|
-
element.style.cursor = modeNow?.scope === "global" ? cursorNow : "auto";
|
|
118
|
-
} else {
|
|
119
|
-
element.style.cursor = cursorNow;
|
|
120
|
-
}
|
|
121
|
-
const stopCursor = cap.onCursorChange((c) => {
|
|
122
|
-
if (scope.type === "global") {
|
|
123
|
-
const isGlobalMode = cap.getActiveInteractionMode()?.scope === "global";
|
|
124
|
-
if (!isGlobalMode) return;
|
|
125
|
-
}
|
|
126
|
-
element.style.cursor = c;
|
|
127
|
-
});
|
|
128
|
-
const domEvent = {
|
|
129
|
-
onPointerDown: "pointerdown",
|
|
130
|
-
onPointerUp: "pointerup",
|
|
131
|
-
onPointerMove: "pointermove",
|
|
132
|
-
onPointerEnter: "pointerenter",
|
|
133
|
-
onPointerLeave: "pointerleave",
|
|
134
|
-
onPointerCancel: "pointercancel"
|
|
135
|
-
};
|
|
136
|
-
const listeners = {};
|
|
137
|
-
const toPos = (e, host) => {
|
|
138
|
-
if (convertEventToPoint) return convertEventToPoint(e, host);
|
|
139
|
-
const r = host.getBoundingClientRect();
|
|
140
|
-
return { x: e.clientX - r.left, y: e.clientY - r.top };
|
|
141
|
-
};
|
|
142
|
-
Object.keys(domEvent).forEach((k) => {
|
|
143
|
-
listeners[k] = (evt) => {
|
|
144
|
-
if (cap.isPaused()) return;
|
|
145
|
-
const pe = evt;
|
|
146
|
-
const currentModeId = cap.getActiveMode();
|
|
147
|
-
active?.[k]?.(toPos(pe, element), pe, currentModeId);
|
|
148
|
-
};
|
|
149
|
-
element.addEventListener(domEvent[k], listeners[k]);
|
|
150
|
-
});
|
|
151
|
-
return () => {
|
|
152
|
-
Object.keys(domEvent).forEach(
|
|
153
|
-
(k) => element.removeEventListener(domEvent[k], listeners[k])
|
|
154
|
-
);
|
|
155
|
-
stopMode();
|
|
156
|
-
stopCursor();
|
|
157
|
-
stopHandler();
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// src/react/components/global-pointer-provider.tsx
|
|
162
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
163
|
-
var GlobalPointerProvider = ({
|
|
164
|
-
children,
|
|
165
|
-
style,
|
|
166
|
-
...props
|
|
167
|
-
}) => {
|
|
168
|
-
const ref = (0, import_react3.useRef)(null);
|
|
169
|
-
const { provides: cap } = useInteractionManagerCapability();
|
|
170
|
-
(0, import_react3.useEffect)(() => {
|
|
171
|
-
if (!cap || !ref.current) return;
|
|
172
|
-
return createPointerProvider(cap, { type: "global" }, ref.current);
|
|
173
|
-
}, [cap]);
|
|
174
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
175
|
-
"div",
|
|
176
|
-
{
|
|
177
|
-
ref,
|
|
178
|
-
style: {
|
|
179
|
-
width: "100%",
|
|
180
|
-
height: "100%",
|
|
181
|
-
...style
|
|
182
|
-
},
|
|
183
|
-
...props,
|
|
184
|
-
children
|
|
185
|
-
}
|
|
186
|
-
);
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
// src/react/components/page-pointer-provider.tsx
|
|
190
|
-
var import_react4 = require("react");
|
|
191
|
-
var import_models = require("@embedpdf/models");
|
|
192
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
193
|
-
var PagePointerProvider = ({
|
|
194
|
-
pageIndex,
|
|
195
|
-
children,
|
|
196
|
-
pageWidth,
|
|
197
|
-
pageHeight,
|
|
198
|
-
rotation,
|
|
199
|
-
scale,
|
|
200
|
-
convertEventToPoint,
|
|
201
|
-
style,
|
|
202
|
-
...props
|
|
203
|
-
}) => {
|
|
204
|
-
const ref = (0, import_react4.useRef)(null);
|
|
205
|
-
const { provides: cap } = useInteractionManagerCapability();
|
|
206
|
-
const isPageExclusive = useIsPageExclusive();
|
|
207
|
-
const defaultConvertEventToPoint = (0, import_react4.useCallback)(
|
|
208
|
-
(event, element) => {
|
|
209
|
-
const rect = element.getBoundingClientRect();
|
|
210
|
-
const displayPoint = {
|
|
211
|
-
x: event.clientX - rect.left,
|
|
212
|
-
y: event.clientY - rect.top
|
|
213
|
-
};
|
|
214
|
-
return (0, import_models.restorePosition)(
|
|
215
|
-
{ width: pageWidth, height: pageHeight },
|
|
216
|
-
displayPoint,
|
|
217
|
-
rotation,
|
|
218
|
-
scale
|
|
219
|
-
);
|
|
220
|
-
},
|
|
221
|
-
[pageWidth, pageHeight, rotation, scale]
|
|
222
|
-
);
|
|
223
|
-
(0, import_react4.useEffect)(() => {
|
|
224
|
-
if (!cap || !ref.current) return;
|
|
225
|
-
return createPointerProvider(
|
|
226
|
-
cap,
|
|
227
|
-
{ type: "page", pageIndex },
|
|
228
|
-
ref.current,
|
|
229
|
-
convertEventToPoint || defaultConvertEventToPoint
|
|
230
|
-
);
|
|
231
|
-
}, [cap, pageIndex, convertEventToPoint, defaultConvertEventToPoint]);
|
|
232
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
233
|
-
"div",
|
|
234
|
-
{
|
|
235
|
-
ref,
|
|
236
|
-
style: {
|
|
237
|
-
...style
|
|
238
|
-
},
|
|
239
|
-
...props,
|
|
240
|
-
children: [
|
|
241
|
-
children,
|
|
242
|
-
isPageExclusive && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { position: "absolute", top: 0, left: 0, right: 0, bottom: 0, zIndex: 10 } })
|
|
243
|
-
]
|
|
244
|
-
}
|
|
245
|
-
);
|
|
246
|
-
};
|
|
247
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
248
|
-
0 && (module.exports = {
|
|
249
|
-
GlobalPointerProvider,
|
|
250
|
-
PagePointerProvider,
|
|
251
|
-
useCursor,
|
|
252
|
-
useInteractionManager,
|
|
253
|
-
useInteractionManagerCapability,
|
|
254
|
-
useInteractionManagerPlugin,
|
|
255
|
-
useIsPageExclusive,
|
|
256
|
-
usePointerHandlers
|
|
257
|
-
});
|
|
258
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/react"),t=require("@embedpdf/plugin-interaction-manager"),r=require("react"),n=require("react/jsx-runtime"),o=require("@embedpdf/models"),i=()=>e.useCapability(t.InteractionManagerPlugin.id);function s(){const{provides:e}=i(),[t,n]=r.useState((()=>{const t=null==e?void 0:e.getActiveInteractionMode();return"page"===(null==t?void 0:t.scope)&&!!t.exclusive}));return r.useEffect((()=>{if(e)return e.onModeChange((()=>{const t=e.getActiveInteractionMode();n("page"===(null==t?void 0:t.scope)&&!!(null==t?void 0:t.exclusive))}))}),[e]),t}function l(e,t,r,n){let o=e.getHandlersForScope(t);const i=e.onModeChange((()=>{if("global"===t.type){const t=e.getActiveInteractionMode();r.style.cursor="global"===(null==t?void 0:t.scope)?t.cursor??"auto":"auto"}o=e.getHandlersForScope(t)})),s=e.onHandlerChange((()=>{o=e.getHandlersForScope(t)})),l=e.getActiveInteractionMode(),u=e.getCurrentCursor();"global"===t.type?r.style.cursor="global"===(null==l?void 0:l.scope)?u:"auto":r.style.cursor=u;const a=e.onCursorChange((n=>{var o;if("global"===t.type){if(!("global"===(null==(o=e.getActiveInteractionMode())?void 0:o.scope)))return}r.style.cursor=n})),c={onPointerDown:"pointerdown",onPointerUp:"pointerup",onPointerMove:"pointermove",onPointerEnter:"pointerenter",onPointerLeave:"pointerleave",onPointerCancel:"pointercancel"},d={};return Object.keys(c).forEach((t=>{d[t]=i=>{var s;if(e.isPaused())return;const l=i,u=e.getActiveMode();null==(s=null==o?void 0:o[t])||s.call(o,((e,t)=>{if(n)return n(e,t);const r=t.getBoundingClientRect();return{x:e.clientX-r.left,y:e.clientY-r.top}})(l,r),l,u)},r.addEventListener(c[t],d[t])})),()=>{Object.keys(c).forEach((e=>r.removeEventListener(c[e],d[e]))),i(),a(),s()}}exports.GlobalPointerProvider=({children:e,style:t,...o})=>{const s=r.useRef(null),{provides:u}=i();return r.useEffect((()=>{if(u&&s.current)return l(u,{type:"global"},s.current)}),[u]),n.jsx("div",{ref:s,style:{width:"100%",height:"100%",...t},...o,children:e})},exports.PagePointerProvider=({pageIndex:e,children:t,pageWidth:u,pageHeight:a,rotation:c,scale:d,convertEventToPoint:p,style:g,...v})=>{const f=r.useRef(null),{provides:x}=i(),y=s(),h=r.useCallback(((e,t)=>{const r=t.getBoundingClientRect(),n={x:e.clientX-r.left,y:e.clientY-r.top};return o.restorePosition({width:u,height:a},n,c,d)}),[u,a,c,d]);return r.useEffect((()=>{if(x&&f.current)return l(x,{type:"page",pageIndex:e},f.current,p||h)}),[x,e,p,h]),n.jsxs("div",{ref:f,style:{...g},...v,children:[t,y&&n.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:10}})]})},exports.useCursor=function(){const{provides:e}=i();return{setCursor:(t,r,n=0)=>{null==e||e.setCursor(t,r,n)},removeCursor:t=>{null==e||e.removeCursor(t)}}},exports.useInteractionManager=function(){const{provides:e}=i(),[n,o]=r.useState(t.initialState);return r.useEffect((()=>{if(e)return e.onStateChange((e=>{o(e)}))}),[e]),{provides:e,state:n}},exports.useInteractionManagerCapability=i,exports.useInteractionManagerPlugin=()=>e.usePlugin(t.InteractionManagerPlugin.id),exports.useIsPageExclusive=s,exports.usePointerHandlers=function({modeId:e,pageIndex:t}){const{provides:r}=i();return{register:(n,o)=>{const i=(null==o?void 0:o.modeId)??e,s=(null==o?void 0:o.pageIndex)??t;return i?null==r?void 0:r.registerHandlers({modeId:i,handlers:n,pageIndex:s}):null==r?void 0:r.registerAlways({scope:void 0!==s?{type:"page",pageIndex:s}:{type:"global"},handlers:n})}}};
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
package/dist/react/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react/index.ts","../../src/react/hooks/use-interaction-manager.ts","../../src/react/components/global-pointer-provider.tsx","../../src/shared/utils.ts","../../src/react/components/page-pointer-provider.tsx"],"sourcesContent":["export * from './hooks';\nexport * from './components';\n","import { useCapability, usePlugin } from '@embedpdf/core/react';\nimport {\n initialState,\n InteractionManagerPlugin,\n InteractionManagerState,\n PointerEventHandlers,\n PointerEventHandlersWithLifecycle,\n} from '@embedpdf/plugin-interaction-manager';\nimport { useState, useEffect } from 'react';\n\nexport const useInteractionManagerPlugin = () =>\n usePlugin<InteractionManagerPlugin>(InteractionManagerPlugin.id);\nexport const useInteractionManagerCapability = () =>\n useCapability<InteractionManagerPlugin>(InteractionManagerPlugin.id);\n\nexport function useInteractionManager() {\n const { provides } = useInteractionManagerCapability();\n const [state, setState] = useState<InteractionManagerState>(initialState);\n\n useEffect(() => {\n if (!provides) return;\n return provides.onStateChange((state) => {\n setState(state);\n });\n }, [provides]);\n\n return {\n provides,\n state,\n };\n}\n\nexport function useCursor() {\n const { provides } = 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 } = 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 } = useInteractionManagerCapability();\n\n const [isPageExclusive, setIsPageExclusive] = useState<boolean>(() => {\n const m = cap?.getActiveInteractionMode();\n return m?.scope === 'page' && !!m.exclusive;\n });\n\n useEffect(() => {\n if (!cap) return;\n\n return cap.onModeChange(() => {\n const mode = cap.getActiveInteractionMode();\n setIsPageExclusive(mode?.scope === 'page' && !!mode?.exclusive);\n });\n }, [cap]);\n\n return isPageExclusive;\n}\n","import { ReactNode, useEffect, useRef } from 'react';\nimport { createPointerProvider } from '../../shared/utils';\n\nimport { useInteractionManagerCapability } from '../hooks';\n\ninterface GlobalPointerProviderProps extends React.HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n style?: React.CSSProperties;\n}\n\nexport const GlobalPointerProvider = ({\n children,\n style,\n ...props\n}: GlobalPointerProviderProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const { provides: cap } = useInteractionManagerCapability();\n\n useEffect(() => {\n if (!cap || !ref.current) return;\n\n return createPointerProvider(cap, { type: 'global' }, ref.current);\n }, [cap]);\n\n return (\n <div\n ref={ref}\n style={{\n width: '100%',\n height: '100%',\n ...style,\n }}\n {...props}\n >\n {children}\n </div>\n );\n};\n","import { Position } from '@embedpdf/models';\nimport type {\n InteractionManagerCapability,\n InteractionScope,\n PointerEventHandlers,\n} from '@embedpdf/plugin-interaction-manager';\n\n/**\n * Hook one DOM element into the interaction-manager.\n * – keeps handlers & cursor in-sync with the current mode\n * – returns a teardown fn for React/Preact effects\n */\nexport function createPointerProvider(\n cap: InteractionManagerCapability,\n scope: InteractionScope,\n element: HTMLElement,\n convertEventToPoint?: (evt: PointerEvent, host: HTMLElement) => Position,\n) {\n /* ------------------------------------------------------------------ */\n /* active handler set – hot-swapped on every mode change */\n /* ------------------------------------------------------------------ */\n let active: PointerEventHandlers | null = cap.getHandlersForScope(scope);\n\n const stopMode = cap.onModeChange(() => {\n if (scope.type === 'global') {\n const mode = cap.getActiveInteractionMode();\n element.style.cursor = mode?.scope === 'global' ? (mode.cursor ?? 'auto') : 'auto';\n }\n active = cap.getHandlersForScope(scope);\n });\n\n const stopHandler = cap.onHandlerChange(() => {\n active = cap.getHandlersForScope(scope);\n });\n\n /* ------------------------------------------------------------------ */\n /* cursor */\n /* ------------------------------------------------------------------ */\n const modeNow = cap.getActiveInteractionMode();\n const cursorNow = cap.getCurrentCursor();\n\n /** initial cursor -------------------------------------------------- */\n if (scope.type === 'global') {\n // global wrapper only shows the cursor while a *global* mode is active\n element.style.cursor = modeNow?.scope === 'global' ? cursorNow : 'auto';\n } else {\n // page wrappers always mirror the latest cursor\n element.style.cursor = cursorNow;\n }\n\n const stopCursor = cap.onCursorChange((c) => {\n /** ❖ Propagation rule\n * ─────────────────\n * • global provider updates its cursor *only* while the active\n * mode itself is ‘global’.\n * • page providers always sync (so they show the cursor during\n * a global mode as well). */\n if (scope.type === 'global') {\n const isGlobalMode = cap.getActiveInteractionMode()?.scope === 'global';\n if (!isGlobalMode) return; // active mode is page-scoped → ignore\n }\n element.style.cursor = c;\n });\n\n /* ------------------------------------------------------------------ */\n /* event wiring */\n /* ------------------------------------------------------------------ */\n type K = keyof PointerEventHandlers;\n const domEvent: Record<K, keyof HTMLElementEventMap> = {\n onPointerDown: 'pointerdown',\n onPointerUp: 'pointerup',\n onPointerMove: 'pointermove',\n onPointerEnter: 'pointerenter',\n onPointerLeave: 'pointerleave',\n onPointerCancel: 'pointercancel',\n };\n\n /* one stable EventListener per key -> needed for removeEventListener */\n const listeners: Partial<Record<K, EventListener>> = {};\n\n const toPos = (e: PointerEvent, host: HTMLElement): Position => {\n if (convertEventToPoint) return convertEventToPoint(e, host);\n const r = host.getBoundingClientRect();\n return { x: e.clientX - r.left, y: e.clientY - r.top };\n };\n\n (Object.keys(domEvent) as K[]).forEach((k) => {\n listeners[k] = (evt: Event) => {\n if (cap.isPaused()) return;\n\n const pe = evt as PointerEvent; // safe – we only attach to pointer*\n const currentModeId = cap.getActiveMode();\n active?.[k]?.(toPos(pe, element), pe, currentModeId);\n /* if you need to stop default behaviour when no handler is active:\n * if (!active?.[k]) pe.preventDefault(); */\n };\n element.addEventListener(domEvent[k], listeners[k]!);\n });\n\n /* ------------------------------------------------------------------ */\n /* teardown */\n /* ------------------------------------------------------------------ */\n return () => {\n (Object.keys(domEvent) as K[]).forEach((k) =>\n element.removeEventListener(domEvent[k], listeners[k]!),\n );\n stopMode();\n stopCursor();\n stopHandler();\n };\n}\n","import { ReactNode, useEffect, useRef, useCallback } from 'react';\nimport { Position, restorePosition } from '@embedpdf/models';\nimport { createPointerProvider } from '../../shared/utils';\n\nimport { useInteractionManagerCapability, useIsPageExclusive } from '../hooks';\n\ninterface PagePointerProviderProps extends React.HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n pageIndex: number;\n pageWidth: number;\n pageHeight: number;\n rotation: number;\n scale: number;\n style?: React.CSSProperties;\n convertEventToPoint?: (event: PointerEvent, element: HTMLElement) => Position;\n}\n\nexport const PagePointerProvider = ({\n pageIndex,\n children,\n pageWidth,\n pageHeight,\n rotation,\n scale,\n convertEventToPoint,\n style,\n ...props\n}: PagePointerProviderProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const { provides: cap } = useInteractionManagerCapability();\n const isPageExclusive = useIsPageExclusive();\n\n // Memoize the default conversion function\n const defaultConvertEventToPoint = useCallback(\n (event: PointerEvent, element: HTMLElement): Position => {\n const rect = element.getBoundingClientRect();\n const displayPoint = {\n x: event.clientX - rect.left,\n y: event.clientY - rect.top,\n };\n return restorePosition(\n { width: pageWidth, height: pageHeight },\n displayPoint,\n rotation,\n scale,\n );\n },\n [pageWidth, pageHeight, rotation, scale],\n );\n\n useEffect(() => {\n if (!cap || !ref.current) return;\n\n return createPointerProvider(\n cap,\n { type: 'page', pageIndex },\n ref.current,\n convertEventToPoint || defaultConvertEventToPoint,\n );\n }, [cap, pageIndex, convertEventToPoint, defaultConvertEventToPoint]);\n\n return (\n <div\n ref={ref}\n style={{\n ...style,\n }}\n {...props}\n >\n {children}\n {isPageExclusive && (\n <div style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, zIndex: 10 }} />\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAyC;AACzC,wCAMO;AACP,IAAAA,gBAAoC;AAE7B,IAAM,8BAA8B,UACzC,wBAAoC,2DAAyB,EAAE;AAC1D,IAAM,kCAAkC,UAC7C,4BAAwC,2DAAyB,EAAE;AAE9D,SAAS,wBAAwB;AACtC,QAAM,EAAE,SAAS,IAAI,gCAAgC;AACrD,QAAM,CAAC,OAAO,QAAQ,QAAI,wBAAkC,8CAAY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AA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAgC;AAC9B,QAAM,UAAM,sBAAuB,IAAI;AACvC,QAAM,EAAE,UAAU,IAAI,IAAI,gCAAgC;AAC1D,QAAM,kBAAkB,mBAAmB;AAG3C,QAAM,iCAA6B;AAAA,IACjC,CAAC,OAAqB,YAAmC;AACvD,YAAM,OAAO,QAAQ,sBAAsB;AAC3C,YAAM,eAAe;AAAA,QACnB,GAAG,MAAM,UAAU,KAAK;AAAA,QACxB,GAAG,MAAM,UAAU,KAAK;AAAA,MAC1B;AACA,iBAAO;AAAA,QACL,EAAE,OAAO,WAAW,QAAQ,WAAW;AAAA,QACvC;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,WAAW,YAAY,UAAU,KAAK;AAAA,EACzC;AAEA,+BAAU,MAAM;AACd,QAAI,CAAC,OAAO,CAAC,IAAI,QAAS;AAE1B,WAAO;AAAA,MACL;AAAA,MACA,EAAE,MAAM,QAAQ,UAAU;AAAA,MAC1B,IAAI;AAAA,MACJ,uBAAuB;AAAA,IACzB;AAAA,EACF,GAAG,CAAC,KAAK,WAAW,qBAAqB,0BAA0B,CAAC;AAEpE,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,OAAO;AAAA,QACL,GAAG;AAAA,MACL;AAAA,MACC,GAAG;AAAA,MAEH;AAAA;AAAA,QACA,mBACC,6CAAC,SAAI,OAAO,EAAE,UAAU,YAAY,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,GAAG;AAAA;AAAA;AAAA,EAE5F;AAEJ;","names":["import_react","state","import_react","import_react","import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-interaction-manager.ts","../../src/shared/utils.ts","../../src/shared/components/global-pointer-provider.tsx","../../src/shared/components/page-pointer-provider.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport {\n initialState,\n InteractionManagerPlugin,\n InteractionManagerState,\n PointerEventHandlers,\n PointerEventHandlersWithLifecycle,\n} from '@embedpdf/plugin-interaction-manager';\nimport { useState, useEffect } from '@framework';\n\nexport const useInteractionManagerPlugin = () =>\n usePlugin<InteractionManagerPlugin>(InteractionManagerPlugin.id);\nexport const useInteractionManagerCapability = () =>\n useCapability<InteractionManagerPlugin>(InteractionManagerPlugin.id);\n\nexport function useInteractionManager() {\n const { provides } = useInteractionManagerCapability();\n const [state, setState] = useState<InteractionManagerState>(initialState);\n\n useEffect(() => {\n if (!provides) return;\n return provides.onStateChange((state) => {\n setState(state);\n });\n }, [provides]);\n\n return {\n provides,\n state,\n };\n}\n\nexport function useCursor() {\n const { provides } = 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 } = 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 } = useInteractionManagerCapability();\n\n const [isPageExclusive, setIsPageExclusive] = useState<boolean>(() => {\n const m = cap?.getActiveInteractionMode();\n return m?.scope === 'page' && !!m.exclusive;\n });\n\n useEffect(() => {\n if (!cap) return;\n\n return cap.onModeChange(() => {\n const mode = cap.getActiveInteractionMode();\n setIsPageExclusive(mode?.scope === 'page' && !!mode?.exclusive);\n });\n }, [cap]);\n\n return isPageExclusive;\n}\n","import { Position } from '@embedpdf/models';\nimport type {\n InteractionManagerCapability,\n InteractionScope,\n PointerEventHandlers,\n} from '@embedpdf/plugin-interaction-manager';\n\n/**\n * Hook one DOM element into the interaction-manager.\n * – keeps handlers & cursor in-sync with the current mode\n * – returns a teardown fn for React/Preact effects\n */\nexport function createPointerProvider(\n cap: InteractionManagerCapability,\n scope: InteractionScope,\n element: HTMLElement,\n convertEventToPoint?: (evt: PointerEvent, host: HTMLElement) => Position,\n) {\n /* ------------------------------------------------------------------ */\n /* active handler set – hot-swapped on every mode change */\n /* ------------------------------------------------------------------ */\n let active: PointerEventHandlers | null = cap.getHandlersForScope(scope);\n\n const stopMode = cap.onModeChange(() => {\n if (scope.type === 'global') {\n const mode = cap.getActiveInteractionMode();\n element.style.cursor = mode?.scope === 'global' ? (mode.cursor ?? 'auto') : 'auto';\n }\n active = cap.getHandlersForScope(scope);\n });\n\n const stopHandler = cap.onHandlerChange(() => {\n active = cap.getHandlersForScope(scope);\n });\n\n /* ------------------------------------------------------------------ */\n /* cursor */\n /* ------------------------------------------------------------------ */\n const modeNow = cap.getActiveInteractionMode();\n const cursorNow = cap.getCurrentCursor();\n\n /** initial cursor -------------------------------------------------- */\n if (scope.type === 'global') {\n // global wrapper only shows the cursor while a *global* mode is active\n element.style.cursor = modeNow?.scope === 'global' ? cursorNow : 'auto';\n } else {\n // page wrappers always mirror the latest cursor\n element.style.cursor = cursorNow;\n }\n\n const stopCursor = cap.onCursorChange((c) => {\n /** ❖ Propagation rule\n * ─────────────────\n * • global provider updates its cursor *only* while the active\n * mode itself is ‘global’.\n * • page providers always sync (so they show the cursor during\n * a global mode as well). */\n if (scope.type === 'global') {\n const isGlobalMode = cap.getActiveInteractionMode()?.scope === 'global';\n if (!isGlobalMode) return; // active mode is page-scoped → ignore\n }\n element.style.cursor = c;\n });\n\n /* ------------------------------------------------------------------ */\n /* event wiring */\n /* ------------------------------------------------------------------ */\n type K = keyof PointerEventHandlers;\n const domEvent: Record<K, keyof HTMLElementEventMap> = {\n onPointerDown: 'pointerdown',\n onPointerUp: 'pointerup',\n onPointerMove: 'pointermove',\n onPointerEnter: 'pointerenter',\n onPointerLeave: 'pointerleave',\n onPointerCancel: 'pointercancel',\n };\n\n /* one stable EventListener per key -> needed for removeEventListener */\n const listeners: Partial<Record<K, EventListener>> = {};\n\n const toPos = (e: PointerEvent, host: HTMLElement): Position => {\n if (convertEventToPoint) return convertEventToPoint(e, host);\n const r = host.getBoundingClientRect();\n return { x: e.clientX - r.left, y: e.clientY - r.top };\n };\n\n (Object.keys(domEvent) as K[]).forEach((k) => {\n listeners[k] = (evt: Event) => {\n if (cap.isPaused()) return;\n\n const pe = evt as PointerEvent; // safe – we only attach to pointer*\n const currentModeId = cap.getActiveMode();\n active?.[k]?.(toPos(pe, element), pe, currentModeId);\n /* if you need to stop default behaviour when no handler is active:\n * if (!active?.[k]) pe.preventDefault(); */\n };\n element.addEventListener(domEvent[k], listeners[k]!);\n });\n\n /* ------------------------------------------------------------------ */\n /* teardown */\n /* ------------------------------------------------------------------ */\n return () => {\n (Object.keys(domEvent) as K[]).forEach((k) =>\n element.removeEventListener(domEvent[k], listeners[k]!),\n );\n stopMode();\n stopCursor();\n stopHandler();\n };\n}\n","import { ReactNode, useEffect, useRef, HTMLAttributes, CSSProperties } from '@framework';\nimport { createPointerProvider } from '../utils';\n\nimport { useInteractionManagerCapability } from '../hooks';\n\ninterface GlobalPointerProviderProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n style?: CSSProperties;\n}\n\nexport const GlobalPointerProvider = ({\n children,\n style,\n ...props\n}: GlobalPointerProviderProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const { provides: cap } = useInteractionManagerCapability();\n\n useEffect(() => {\n if (!cap || !ref.current) return;\n\n return createPointerProvider(cap, { type: 'global' }, ref.current);\n }, [cap]);\n\n return (\n <div\n ref={ref}\n style={{\n width: '100%',\n height: '100%',\n ...style,\n }}\n {...props}\n >\n {children}\n </div>\n );\n};\n","import {\n ReactNode,\n useEffect,\n useRef,\n useCallback,\n HTMLAttributes,\n CSSProperties,\n} from '@framework';\nimport { Position, restorePosition } from '@embedpdf/models';\nimport { createPointerProvider } from '../utils';\n\nimport { useInteractionManagerCapability, useIsPageExclusive } from '../hooks';\n\ninterface PagePointerProviderProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n pageIndex: number;\n pageWidth: number;\n pageHeight: number;\n rotation: number;\n scale: number;\n style?: CSSProperties;\n convertEventToPoint?: (event: PointerEvent, element: HTMLElement) => Position;\n}\n\nexport const PagePointerProvider = ({\n pageIndex,\n children,\n pageWidth,\n pageHeight,\n rotation,\n scale,\n convertEventToPoint,\n style,\n ...props\n}: PagePointerProviderProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const { provides: cap } = useInteractionManagerCapability();\n const isPageExclusive = useIsPageExclusive();\n\n // Memoize the default conversion function\n const defaultConvertEventToPoint = useCallback(\n (event: PointerEvent, element: HTMLElement): Position => {\n const rect = element.getBoundingClientRect();\n const displayPoint = {\n x: event.clientX - rect.left,\n y: event.clientY - rect.top,\n };\n return restorePosition(\n { width: pageWidth, height: pageHeight },\n displayPoint,\n rotation,\n scale,\n );\n },\n [pageWidth, pageHeight, rotation, scale],\n );\n\n useEffect(() => {\n if (!cap || !ref.current) return;\n\n return createPointerProvider(\n cap,\n { type: 'page', pageIndex },\n ref.current,\n convertEventToPoint || defaultConvertEventToPoint,\n );\n }, [cap, pageIndex, convertEventToPoint, defaultConvertEventToPoint]);\n\n return (\n <div\n ref={ref}\n style={{\n ...style,\n }}\n {...props}\n >\n {children}\n {isPageExclusive && (\n <div style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, zIndex: 10 }} />\n )}\n </div>\n );\n};\n"],"names":["useInteractionManagerCapability","useCapability","InteractionManagerPlugin","id","useIsPageExclusive","provides","cap","isPageExclusive","setIsPageExclusive","useState","m","getActiveInteractionMode","scope","exclusive","useEffect","onModeChange","mode","createPointerProvider","element","convertEventToPoint","active","getHandlersForScope","stopMode","type","style","cursor","stopHandler","onHandlerChange","modeNow","cursorNow","getCurrentCursor","stopCursor","onCursorChange","c","_a","domEvent","onPointerDown","onPointerUp","onPointerMove","onPointerEnter","onPointerLeave","onPointerCancel","listeners","Object","keys","forEach","k","evt","isPaused","pe","currentModeId","getActiveMode","call","e","host","r","getBoundingClientRect","x","clientX","left","y","clientY","top","toPos","addEventListener","removeEventListener","children","props","ref","useRef","current","jsxRuntime","jsx","width","height","pageIndex","pageWidth","pageHeight","rotation","scale","defaultConvertEventToPoint","useCallback","event","rect","displayPoint","restorePosition","jsxs","position","right","bottom","zIndex","setCursor","token","prio","removeCursor","state","setState","initialState","onStateChange","usePlugin","modeId","register","handlers","options","finalModeId","finalPageIndex","registerHandlers","registerAlways"],"mappings":"0PAYaA,EAAkC,IAC7CC,gBAAwCC,EAAAA,yBAAyBC,IAgE5D,SAASC,IACd,MAAQC,SAAUC,GAAQN,KAEnBO,EAAiBC,GAAsBC,YAAkB,KACxD,MAAAC,EAAS,MAALJ,OAAK,EAAAA,EAAAK,2BACf,MAAoB,UAAV,MAAHD,OAAG,EAAAA,EAAAE,UAAsBF,EAAEG,SAAA,IAY7B,OATPC,EAAAA,WAAU,KACR,GAAKR,EAEE,OAAAA,EAAIS,cAAa,KAChB,MAAAC,EAAOV,EAAIK,2BACjBH,EAAmC,gBAAhBQ,WAAMJ,iBAAsBI,WAAMH,WAAS,GAC/D,GACA,CAACP,IAEGC,CACT,CCnFO,SAASU,EACdX,EACAM,EACAM,EACAC,GAKI,IAAAC,EAAsCd,EAAIe,oBAAoBT,GAE5D,MAAAU,EAAWhB,EAAIS,cAAa,KAC5B,GAAe,WAAfH,EAAMW,KAAmB,CACrB,MAAAP,EAAOV,EAAIK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DG,WACC,MAAArF,SAAEA,GAAaL,IACd,MAAA,CACL2F,UAAW,CAACC,EAAenE,EAAgBoE,EAAO,KACtC,MAAAxF,GAAAA,EAAAsF,UAAUC,EAAOnE,EAAQoE,EAAA,EAErCC,aAAeF,IACb,MAAAvF,GAAAA,EAAUyF,aAAaF,EAAA,EAG7B,gCA3BO,WACC,MAAAvF,SAAEA,GAAaL,KACd+F,EAAOC,GAAYvF,EAAAA,SAAkCwF,EAAAA,cASrD,OAPPnF,EAAAA,WAAU,KACR,GAAKT,EACE,OAAAA,EAAS6F,eAAeH,IAC7BC,EAASD,EAAK,GACf,GACA,CAAC1F,IAEG,CACLA,WACA0F,QAEJ,gFApB2C,IACzCI,YAAoCjG,EAAAA,yBAAyBC,4DAsCxD,UAA4BiG,OAAEA,EAAQzB,UAAAA,IACrC,MAAAtE,SAAEA,GAAaL,IACd,MAAA,CACLqG,SAAU,CACRC,EACAC,KAGM,MAAAC,SAAcD,WAASH,SAAUA,EACjCK,SAAiBF,WAAS5B,YAAaA,EAEtC,OAAA6B,QACHnG,WAAUqG,iBAAiB,CACzBN,OAAQI,EACRF,WACA3B,UAAW8B,UAEbpG,WAAUsG,eAAe,CACvB/F,WACqB,IAAnB6F,EACI,CAAElF,KAAM,OAAQoD,UAAW8B,GAC3B,CAAElF,KAAM,UACd+E,YAAA,EAIZ"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,55 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { InteractionManagerPlugin, InteractionManagerState, PointerEventHandlersWithLifecycle } from '@embedpdf/plugin-interaction-manager';
|
|
3
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
-
import { ReactNode } from 'react';
|
|
5
|
-
import { Position } from '@embedpdf/models';
|
|
6
|
-
|
|
7
|
-
declare const useInteractionManagerPlugin: () => {
|
|
8
|
-
plugin: InteractionManagerPlugin | null;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
ready: Promise<void>;
|
|
11
|
-
};
|
|
12
|
-
declare const useInteractionManagerCapability: () => {
|
|
13
|
-
provides: Readonly<_embedpdf_plugin_interaction_manager.InteractionManagerCapability> | null;
|
|
14
|
-
isLoading: boolean;
|
|
15
|
-
ready: Promise<void>;
|
|
16
|
-
};
|
|
17
|
-
declare function useInteractionManager(): {
|
|
18
|
-
provides: Readonly<_embedpdf_plugin_interaction_manager.InteractionManagerCapability> | null;
|
|
19
|
-
state: InteractionManagerState;
|
|
20
|
-
};
|
|
21
|
-
declare function useCursor(): {
|
|
22
|
-
setCursor: (token: string, cursor: string, prio?: number) => void;
|
|
23
|
-
removeCursor: (token: string) => void;
|
|
24
|
-
};
|
|
25
|
-
interface UsePointerHandlersOptions {
|
|
26
|
-
modeId?: string | string[];
|
|
27
|
-
pageIndex?: number;
|
|
28
|
-
}
|
|
29
|
-
declare function usePointerHandlers({ modeId, pageIndex }: UsePointerHandlersOptions): {
|
|
30
|
-
register: (handlers: PointerEventHandlersWithLifecycle, options?: {
|
|
31
|
-
modeId?: string | string[];
|
|
32
|
-
pageIndex?: number;
|
|
33
|
-
}) => (() => void) | undefined;
|
|
34
|
-
};
|
|
35
|
-
declare function useIsPageExclusive(): boolean;
|
|
36
|
-
|
|
37
|
-
interface GlobalPointerProviderProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
38
|
-
children: ReactNode;
|
|
39
|
-
style?: React.CSSProperties;
|
|
40
|
-
}
|
|
41
|
-
declare const GlobalPointerProvider: ({ children, style, ...props }: GlobalPointerProviderProps) => react_jsx_runtime.JSX.Element;
|
|
42
|
-
|
|
43
|
-
interface PagePointerProviderProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
44
|
-
children: ReactNode;
|
|
45
|
-
pageIndex: number;
|
|
46
|
-
pageWidth: number;
|
|
47
|
-
pageHeight: number;
|
|
48
|
-
rotation: number;
|
|
49
|
-
scale: number;
|
|
50
|
-
style?: React.CSSProperties;
|
|
51
|
-
convertEventToPoint?: (event: PointerEvent, element: HTMLElement) => Position;
|
|
52
|
-
}
|
|
53
|
-
declare const PagePointerProvider: ({ pageIndex, children, pageWidth, pageHeight, rotation, scale, convertEventToPoint, style, ...props }: PagePointerProviderProps) => react_jsx_runtime.JSX.Element;
|
|
54
|
-
|
|
55
|
-
export { GlobalPointerProvider, PagePointerProvider, useCursor, useInteractionManager, useInteractionManagerCapability, useInteractionManagerPlugin, useIsPageExclusive, usePointerHandlers };
|
|
1
|
+
export * from '../shared-react';
|