@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.
Files changed (56) hide show
  1. package/dist/index.cjs +2 -359
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.ts +1 -177
  4. package/dist/index.js +39 -41
  5. package/dist/index.js.map +1 -1
  6. package/dist/lib/actions.d.ts +28 -0
  7. package/dist/lib/helper.d.ts +2 -0
  8. package/dist/lib/index.d.ts +9 -0
  9. package/dist/lib/interaction-manager-plugin.d.ts +38 -0
  10. package/dist/lib/manifest.d.ts +4 -0
  11. package/dist/lib/reducer.d.ts +5 -0
  12. package/dist/{index.d.cts → lib/types.d.ts} +12 -83
  13. package/dist/preact/adapter.d.ts +4 -0
  14. package/dist/preact/core.d.ts +1 -0
  15. package/dist/preact/index.cjs +2 -258
  16. package/dist/preact/index.cjs.map +1 -1
  17. package/dist/preact/index.d.ts +1 -58
  18. package/dist/preact/index.js +83 -40
  19. package/dist/preact/index.js.map +1 -1
  20. package/dist/react/adapter.d.ts +2 -0
  21. package/dist/react/core.d.ts +1 -0
  22. package/dist/react/index.cjs +2 -258
  23. package/dist/react/index.cjs.map +1 -1
  24. package/dist/react/index.d.ts +1 -55
  25. package/dist/react/index.js +83 -38
  26. package/dist/react/index.js.map +1 -1
  27. package/dist/shared-preact/components/global-pointer-provider.d.ts +7 -0
  28. package/dist/shared-preact/components/index.d.ts +2 -0
  29. package/dist/shared-preact/components/page-pointer-provider.d.ts +14 -0
  30. package/dist/shared-preact/hooks/index.d.ts +1 -0
  31. package/dist/shared-preact/hooks/use-interaction-manager.d.ts +31 -0
  32. package/dist/shared-preact/index.d.ts +2 -0
  33. package/dist/shared-preact/utils.d.ts +8 -0
  34. package/dist/shared-react/components/global-pointer-provider.d.ts +7 -0
  35. package/dist/shared-react/components/index.d.ts +2 -0
  36. package/dist/shared-react/components/page-pointer-provider.d.ts +14 -0
  37. package/dist/shared-react/hooks/index.d.ts +1 -0
  38. package/dist/shared-react/hooks/use-interaction-manager.d.ts +31 -0
  39. package/dist/shared-react/index.d.ts +2 -0
  40. package/dist/shared-react/utils.d.ts +8 -0
  41. package/dist/shared-vue/utils.d.ts +8 -0
  42. package/dist/vue/components/global-pointer-provider.vue.d.ts +12 -0
  43. package/dist/vue/components/index.d.ts +2 -0
  44. package/dist/vue/components/page-pointer-provider.vue.d.ts +21 -0
  45. package/dist/vue/hooks/index.d.ts +1 -0
  46. package/dist/vue/hooks/use-interaction-manager.d.ts +31 -0
  47. package/dist/vue/index.cjs +2 -0
  48. package/dist/vue/index.cjs.map +1 -0
  49. package/dist/vue/index.d.ts +2 -0
  50. package/dist/vue/index.js +222 -0
  51. package/dist/vue/index.js.map +1 -0
  52. package/package.json +19 -11
  53. package/dist/chunk-Z7V2G6MS.js +0 -64
  54. package/dist/chunk-Z7V2G6MS.js.map +0 -1
  55. package/dist/preact/index.d.cts +0 -58
  56. package/dist/react/index.d.cts +0 -55
package/dist/index.js CHANGED
@@ -1,27 +1,22 @@
1
- // src/lib/interaction-manager-plugin.ts
2
- import { BasePlugin, createBehaviorEmitter, createEmitter } from "@embedpdf/core";
3
-
4
- // src/lib/actions.ts
5
- var ACTIVATE_MODE = "INTERACTION/ACTIVATE_MODE";
6
- var PAUSE_INTERACTION = "INTERACTION/PAUSE";
7
- var RESUME_INTERACTION = "INTERACTION/RESUME";
8
- var SET_CURSOR = "INTERACTION/SET_CURSOR";
9
- var activateMode = (mode) => ({
1
+ import { BasePlugin, createEmitter, createBehaviorEmitter } from "@embedpdf/core";
2
+ const ACTIVATE_MODE = "INTERACTION/ACTIVATE_MODE";
3
+ const PAUSE_INTERACTION = "INTERACTION/PAUSE";
4
+ const RESUME_INTERACTION = "INTERACTION/RESUME";
5
+ const SET_CURSOR = "INTERACTION/SET_CURSOR";
6
+ const activateMode = (mode) => ({
10
7
  type: ACTIVATE_MODE,
11
8
  payload: { mode }
12
9
  });
13
- var setCursor = (cursor) => ({
10
+ const setCursor = (cursor) => ({
14
11
  type: SET_CURSOR,
15
12
  payload: { cursor }
16
13
  });
17
- var pauseInteraction = () => ({
14
+ const pauseInteraction = () => ({
18
15
  type: PAUSE_INTERACTION
19
16
  });
20
- var resumeInteraction = () => ({
17
+ const resumeInteraction = () => ({
21
18
  type: RESUME_INTERACTION
22
19
  });
23
-
24
- // src/lib/helper.ts
25
20
  function mergeHandlers(list) {
26
21
  const keys = [
27
22
  "onPointerDown",
@@ -34,14 +29,13 @@ function mergeHandlers(list) {
34
29
  const out = {};
35
30
  for (const k of keys) {
36
31
  out[k] = (evt, nativeEvt, modeId) => {
37
- for (const h of list) h[k]?.(evt, nativeEvt, modeId);
32
+ var _a;
33
+ for (const h of list) (_a = h[k]) == null ? void 0 : _a.call(h, evt, nativeEvt, modeId);
38
34
  };
39
35
  }
40
36
  return out;
41
37
  }
42
-
43
- // src/lib/interaction-manager-plugin.ts
44
- var InteractionManagerPlugin = class extends BasePlugin {
38
+ const _InteractionManagerPlugin = class _InteractionManagerPlugin extends BasePlugin {
45
39
  constructor(id, registry) {
46
40
  super(id, registry);
47
41
  this.modes = /* @__PURE__ */ new Map();
@@ -100,11 +94,13 @@ var InteractionManagerPlugin = class extends BasePlugin {
100
94
  }
101
95
  notifyHandlersActive(modeId) {
102
96
  this.alwaysGlobal.forEach((handler) => {
103
- handler.onHandlerActiveStart?.(modeId);
97
+ var _a;
98
+ (_a = handler.onHandlerActiveStart) == null ? void 0 : _a.call(handler, modeId);
104
99
  });
105
100
  this.alwaysPage.forEach((handlerSet) => {
106
101
  handlerSet.forEach((handler) => {
107
- handler.onHandlerActiveStart?.(modeId);
102
+ var _a;
103
+ (_a = handler.onHandlerActiveStart) == null ? void 0 : _a.call(handler, modeId);
108
104
  });
109
105
  });
110
106
  const mode = this.modes.get(modeId);
@@ -113,24 +109,28 @@ var InteractionManagerPlugin = class extends BasePlugin {
113
109
  if (!bucket) return;
114
110
  if (mode.scope === "global") {
115
111
  bucket.global.forEach((handler) => {
116
- handler.onHandlerActiveStart?.(modeId);
112
+ var _a;
113
+ (_a = handler.onHandlerActiveStart) == null ? void 0 : _a.call(handler, modeId);
117
114
  });
118
115
  }
119
116
  if (mode.scope === "page") {
120
117
  bucket.page.forEach((handlerSet, pageIndex) => {
121
118
  handlerSet.forEach((handler) => {
122
- handler.onHandlerActiveStart?.(modeId);
119
+ var _a;
120
+ (_a = handler.onHandlerActiveStart) == null ? void 0 : _a.call(handler, modeId);
123
121
  });
124
122
  });
125
123
  }
126
124
  }
127
125
  notifyHandlersInactive(modeId) {
128
126
  this.alwaysGlobal.forEach((handler) => {
129
- handler.onHandlerActiveEnd?.(modeId);
127
+ var _a;
128
+ (_a = handler.onHandlerActiveEnd) == null ? void 0 : _a.call(handler, modeId);
130
129
  });
131
130
  this.alwaysPage.forEach((handlerSet) => {
132
131
  handlerSet.forEach((handler) => {
133
- handler.onHandlerActiveEnd?.(modeId);
132
+ var _a;
133
+ (_a = handler.onHandlerActiveEnd) == null ? void 0 : _a.call(handler, modeId);
134
134
  });
135
135
  });
136
136
  const mode = this.modes.get(modeId);
@@ -139,13 +139,15 @@ var InteractionManagerPlugin = class extends BasePlugin {
139
139
  if (!bucket) return;
140
140
  if (mode.scope === "global") {
141
141
  bucket.global.forEach((handler) => {
142
- handler.onHandlerActiveEnd?.(modeId);
142
+ var _a;
143
+ (_a = handler.onHandlerActiveEnd) == null ? void 0 : _a.call(handler, modeId);
143
144
  });
144
145
  }
145
146
  if (mode.scope === "page") {
146
147
  bucket.page.forEach((handlerSet, pageIndex) => {
147
148
  handlerSet.forEach((handler) => {
148
- handler.onHandlerActiveEnd?.(modeId);
149
+ var _a;
150
+ (_a = handler.onHandlerActiveEnd) == null ? void 0 : _a.call(handler, modeId);
149
151
  });
150
152
  });
151
153
  }
@@ -235,8 +237,9 @@ var InteractionManagerPlugin = class extends BasePlugin {
235
237
  this.emitCursor();
236
238
  }
237
239
  emitCursor() {
240
+ var _a;
238
241
  const top = [...this.cursorClaims.values()].sort((a, b) => b.priority - a.priority)[0] ?? {
239
- cursor: this.modes.get(this.state.activeMode)?.cursor ?? "auto"
242
+ cursor: ((_a = this.modes.get(this.state.activeMode)) == null ? void 0 : _a.cursor) ?? "auto"
240
243
  };
241
244
  if (top.cursor !== this.state.cursor) {
242
245
  this.dispatch(setCursor(top.cursor));
@@ -248,7 +251,7 @@ var InteractionManagerPlugin = class extends BasePlugin {
248
251
  }
249
252
  activeModeIsExclusive() {
250
253
  const mode = this.modes.get(this.state.activeMode);
251
- return !!mode?.exclusive;
254
+ return !!(mode == null ? void 0 : mode.exclusive);
252
255
  }
253
256
  getActiveInteractionMode() {
254
257
  return this.modes.get(this.state.activeMode) ?? null;
@@ -260,11 +263,10 @@ var InteractionManagerPlugin = class extends BasePlugin {
260
263
  await super.destroy();
261
264
  }
262
265
  };
263
- InteractionManagerPlugin.id = "interaction-manager";
264
-
265
- // src/lib/manifest.ts
266
- var INTERACTION_MANAGER_PLUGIN_ID = "interaction-manager";
267
- var manifest = {
266
+ _InteractionManagerPlugin.id = "interaction-manager";
267
+ let InteractionManagerPlugin = _InteractionManagerPlugin;
268
+ const INTERACTION_MANAGER_PLUGIN_ID = "interaction-manager";
269
+ const manifest = {
268
270
  id: INTERACTION_MANAGER_PLUGIN_ID,
269
271
  name: "Interaction Manager Plugin",
270
272
  version: "1.0.0",
@@ -275,14 +277,12 @@ var manifest = {
275
277
  enabled: true
276
278
  }
277
279
  };
278
-
279
- // src/lib/reducer.ts
280
- var initialState = {
280
+ const initialState = {
281
281
  activeMode: "default",
282
282
  cursor: "auto",
283
283
  paused: false
284
284
  };
285
- var reducer = (state, action) => {
285
+ const reducer = (state, action) => {
286
286
  switch (action.type) {
287
287
  case ACTIVATE_MODE:
288
288
  return {
@@ -308,9 +308,7 @@ var reducer = (state, action) => {
308
308
  return state;
309
309
  }
310
310
  };
311
-
312
- // src/lib/index.ts
313
- var InteractionManagerPluginPackage = {
311
+ const InteractionManagerPluginPackage = {
314
312
  manifest,
315
313
  create: (registry) => new InteractionManagerPlugin(INTERACTION_MANAGER_PLUGIN_ID, registry),
316
314
  reducer,
@@ -324,4 +322,4 @@ export {
324
322
  manifest,
325
323
  reducer
326
324
  };
327
- //# sourceMappingURL=index.js.map
325
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/interaction-manager-plugin.ts","../src/lib/actions.ts","../src/lib/helper.ts","../src/lib/manifest.ts","../src/lib/reducer.ts","../src/lib/index.ts"],"sourcesContent":["import { BasePlugin, createBehaviorEmitter, createEmitter, PluginRegistry } from '@embedpdf/core';\n\nimport {\n InteractionManagerCapability,\n InteractionManagerPluginConfig,\n InteractionManagerState,\n InteractionMode,\n InteractionScope,\n PointerEventHandlers,\n PointerEventHandlersWithLifecycle,\n RegisterAlwaysOptions,\n RegisterHandlersOptions,\n} from './types';\nimport { activateMode, pauseInteraction, resumeInteraction, setCursor } 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\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) {\n super(id, registry);\n\n this.registerMode({\n id: 'default',\n scope: 'page',\n exclusive: false,\n cursor: 'auto',\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 finish: () => this.activate('default'),\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 };\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 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 { Action } from '@embedpdf/core';\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';\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 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 pauseInteraction = (): PauseInteractionAction => ({\n type: PAUSE_INTERACTION,\n});\n\nexport const resumeInteraction = (): ResumeInteractionAction => ({\n type: RESUME_INTERACTION,\n});\n\nexport type InteractionManagerAction =\n | ActivateModeAction\n | PauseInteractionAction\n | ResumeInteractionAction\n | SetCursorAction;\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 ];\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 },\n};\n","import { Reducer } from '@embedpdf/core';\nimport {\n ACTIVATE_MODE,\n InteractionManagerAction,\n PAUSE_INTERACTION,\n RESUME_INTERACTION,\n SET_CURSOR,\n} from './actions';\nimport { InteractionManagerState } from './types';\n\nexport const initialState: InteractionManagerState = {\n activeMode: 'default',\n cursor: 'auto',\n paused: false,\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 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) => new InteractionManagerPlugin(INTERACTION_MANAGER_PLUGIN_ID, registry),\n reducer,\n initialState,\n};\n\nexport * from './interaction-manager-plugin';\nexport * from './types';\nexport * from './manifest';\nexport * from './reducer';\n"],"mappings":";AAAA,SAAS,YAAY,uBAAuB,qBAAqC;;;ACE1E,IAAM,gBAAgB;AACtB,IAAM,oBAAoB;AAC1B,IAAM,qBAAqB;AAC3B,IAAM,aAAa;AAoBnB,IAAM,eAAe,CAAC,UAAsC;AAAA,EACjE,MAAM;AAAA,EACN,SAAS,EAAE,KAAK;AAClB;AAEO,IAAM,YAAY,CAAC,YAAqC;AAAA,EAC7D,MAAM;AAAA,EACN,SAAS,EAAE,OAAO;AACpB;AAEO,IAAM,mBAAmB,OAA+B;AAAA,EAC7D,MAAM;AACR;AAEO,IAAM,oBAAoB,OAAgC;AAAA,EAC/D,MAAM;AACR;;;ACvCO,SAAS,cAAc,MAAoD;AAChF,QAAM,OAAuC;AAAA,IAC3C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;A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AAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,YAAY,OAAO,QAAQ;AAAA,MAC7B;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,QAAQ,OAAO,QAAQ;AAAA,MACzB;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,QAAQ;AAAA,MACV;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,QAAQ;AAAA,MACV;AAAA,IACF;AACE,aAAO;AAAA,EACX;AACF;;;ACpCO,IAAM,kCAKT;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,aAAa,IAAI,yBAAyB,+BAA+B,QAAQ;AAAA,EAC1F;AAAA,EACA;AACF;","names":[]}
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';\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';\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 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 pauseInteraction = (): PauseInteractionAction => ({\n type: PAUSE_INTERACTION,\n});\n\nexport const resumeInteraction = (): ResumeInteractionAction => ({\n type: RESUME_INTERACTION,\n});\n\nexport type InteractionManagerAction =\n | ActivateModeAction\n | PauseInteractionAction\n | ResumeInteractionAction\n | SetCursorAction;\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 ];\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 InteractionManagerCapability,\n InteractionManagerPluginConfig,\n InteractionManagerState,\n InteractionMode,\n InteractionScope,\n PointerEventHandlers,\n PointerEventHandlersWithLifecycle,\n RegisterAlwaysOptions,\n RegisterHandlersOptions,\n} from './types';\nimport { activateMode, pauseInteraction, resumeInteraction, setCursor } 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\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) {\n super(id, registry);\n\n this.registerMode({\n id: 'default',\n scope: 'page',\n exclusive: false,\n cursor: 'auto',\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 finish: () => this.activate('default'),\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 };\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 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 },\n};\n","import { Reducer } from '@embedpdf/core';\nimport {\n ACTIVATE_MODE,\n InteractionManagerAction,\n PAUSE_INTERACTION,\n RESUME_INTERACTION,\n SET_CURSOR,\n} from './actions';\nimport { InteractionManagerState } from './types';\n\nexport const initialState: InteractionManagerState = {\n activeMode: 'default',\n cursor: 'auto',\n paused: false,\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 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) => new InteractionManagerPlugin(INTERACTION_MANAGER_PLUGIN_ID, registry),\n reducer,\n initialState,\n};\n\nexport * from './interaction-manager-plugin';\nexport * from './types';\nexport * from './manifest';\nexport * from './reducer';\n"],"names":[],"mappings":";AAEO,MAAM,gBAAgB;AACtB,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;AAC3B,MAAM,aAAa;AAoBb,MAAA,eAAe,CAAC,UAAsC;AAAA,EACjE,MAAM;AAAA,EACN,SAAS,EAAE,KAAK;AAClB;AAEa,MAAA,YAAY,CAAC,YAAqC;AAAA,EAC7D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AU,CAAC;AAAA,EACX,eAAe;AAAA,IACb,SAAS;AAAA,EAAA;AAEb;ACLO,MAAM,eAAwC;AAAA,EACnD,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,QAAQ;AACV;AAEa,MAAA,UAAsE,CACjF,OACA,WACG;AACH,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,YAAY,OAAO,QAAQ;AAAA,MAC7B;AAAA,IACF,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,QAAQ,OAAO,QAAQ;AAAA,MACzB;AAAA,IACF,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,QAAQ;AAAA,MACV;AAAA,IACF,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,QAAQ;AAAA,MACV;AAAA,IACF;AACS,aAAA;AAAA,EAAA;AAEb;ACpCO,MAAM,kCAKT;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,aAAa,IAAI,yBAAyB,+BAA+B,QAAQ;AAAA,EAC1F;AAAA,EACA;AACF;"}
@@ -0,0 +1,28 @@
1
+ import { Action } from '@embedpdf/core';
2
+ export declare const ACTIVATE_MODE = "INTERACTION/ACTIVATE_MODE";
3
+ export declare const PAUSE_INTERACTION = "INTERACTION/PAUSE";
4
+ export declare const RESUME_INTERACTION = "INTERACTION/RESUME";
5
+ export declare const SET_CURSOR = "INTERACTION/SET_CURSOR";
6
+ export interface ActivateModeAction extends Action {
7
+ type: typeof ACTIVATE_MODE;
8
+ payload: {
9
+ mode: string;
10
+ };
11
+ }
12
+ export interface PauseInteractionAction extends Action {
13
+ type: typeof PAUSE_INTERACTION;
14
+ }
15
+ export interface ResumeInteractionAction extends Action {
16
+ type: typeof RESUME_INTERACTION;
17
+ }
18
+ export interface SetCursorAction extends Action {
19
+ type: typeof SET_CURSOR;
20
+ payload: {
21
+ cursor: string;
22
+ };
23
+ }
24
+ export declare const activateMode: (mode: string) => ActivateModeAction;
25
+ export declare const setCursor: (cursor: string) => SetCursorAction;
26
+ export declare const pauseInteraction: () => PauseInteractionAction;
27
+ export declare const resumeInteraction: () => ResumeInteractionAction;
28
+ export type InteractionManagerAction = ActivateModeAction | PauseInteractionAction | ResumeInteractionAction | SetCursorAction;
@@ -0,0 +1,2 @@
1
+ import { PointerEventHandlers } from './types';
2
+ export declare function mergeHandlers(list: PointerEventHandlers[]): PointerEventHandlers;
@@ -0,0 +1,9 @@
1
+ import { PluginPackage } from '@embedpdf/core';
2
+ import { InteractionManagerPlugin } from './interaction-manager-plugin';
3
+ import { InteractionManagerPluginConfig, InteractionManagerState } from './types';
4
+ import { InteractionManagerAction } from './actions';
5
+ export declare const InteractionManagerPluginPackage: PluginPackage<InteractionManagerPlugin, InteractionManagerPluginConfig, InteractionManagerState, InteractionManagerAction>;
6
+ export * from './interaction-manager-plugin';
7
+ export * from './types';
8
+ export * from './manifest';
9
+ export * from './reducer';
@@ -0,0 +1,38 @@
1
+ import { BasePlugin, PluginRegistry } from '@embedpdf/core';
2
+ import { InteractionManagerCapability, InteractionManagerPluginConfig, InteractionManagerState, RegisterAlwaysOptions } from './types';
3
+ export declare class InteractionManagerPlugin extends BasePlugin<InteractionManagerPluginConfig, InteractionManagerCapability, InteractionManagerState> {
4
+ static readonly id: "interaction-manager";
5
+ private modes;
6
+ private cursorClaims;
7
+ private buckets;
8
+ private alwaysGlobal;
9
+ private alwaysPage;
10
+ private readonly onModeChange$;
11
+ private readonly onHandlerChange$;
12
+ private readonly onCursorChange$;
13
+ private readonly onStateChange$;
14
+ constructor(id: string, registry: PluginRegistry);
15
+ initialize(_: InteractionManagerPluginConfig): Promise<void>;
16
+ protected buildCapability(): InteractionManagerCapability;
17
+ private activate;
18
+ private notifyHandlersActive;
19
+ private notifyHandlersInactive;
20
+ private registerMode;
21
+ /** ---------- pointer-handler handling ------------ */
22
+ private registerHandlers;
23
+ registerAlways({ scope, handlers }: RegisterAlwaysOptions): () => void;
24
+ /** Returns the *merged* handler set that should be active for the given
25
+ * provider (`global` wrapper or a single page wrapper).
26
+ * – `alwaysGlobal` / `alwaysPage` are **always** active.
27
+ * – Handlers that belong to the current mode are added on top **iff**
28
+ * the mode’s own scope matches the provider’s scope. */
29
+ private getHandlersForScope;
30
+ /** ---------- cursor handling --------------------- */
31
+ private setCursor;
32
+ private removeCursor;
33
+ private emitCursor;
34
+ onStoreUpdated(_: InteractionManagerState, newState: InteractionManagerState): void;
35
+ private activeModeIsExclusive;
36
+ private getActiveInteractionMode;
37
+ destroy(): Promise<void>;
38
+ }
@@ -0,0 +1,4 @@
1
+ import { PluginManifest } from '@embedpdf/core';
2
+ import { InteractionManagerPluginConfig } from './types';
3
+ export declare const INTERACTION_MANAGER_PLUGIN_ID = "interaction-manager";
4
+ export declare const manifest: PluginManifest<InteractionManagerPluginConfig>;
@@ -0,0 +1,5 @@
1
+ import { Reducer } from '@embedpdf/core';
2
+ import { InteractionManagerAction } from './actions';
3
+ import { InteractionManagerState } from './types';
4
+ export declare const initialState: InteractionManagerState;
5
+ export declare const reducer: Reducer<InteractionManagerState, InteractionManagerAction>;
@@ -1,9 +1,8 @@
1
- import { BasePluginConfig, EventHook, BasePlugin, PluginRegistry, Action, PluginManifest, Reducer, PluginPackage } from '@embedpdf/core';
1
+ import { BasePluginConfig, EventHook } from '@embedpdf/core';
2
2
  import { Position } from '@embedpdf/models';
3
-
4
- interface InteractionManagerPluginConfig extends BasePluginConfig {
3
+ export interface InteractionManagerPluginConfig extends BasePluginConfig {
5
4
  }
6
- interface InteractionManagerState {
5
+ export interface InteractionManagerState {
7
6
  /** Mode-id that is currently active (e.g. `"default"` or `"annotationCreation"`). */
8
7
  activeMode: string;
9
8
  /** Cursor that is currently active (e.g. `"auto"` or `"pointer"`). */
@@ -11,7 +10,7 @@ interface InteractionManagerState {
11
10
  /** Whether the interaction is paused */
12
11
  paused: boolean;
13
12
  }
14
- interface InteractionMode {
13
+ export interface InteractionMode {
15
14
  /** unique id */
16
15
  id: string;
17
16
  /** where the handlers should listen for events */
@@ -22,7 +21,7 @@ interface InteractionMode {
22
21
  /** baseline cursor while the mode is active (before any handler overrides it). */
23
22
  cursor?: string;
24
23
  }
25
- interface EmbedPdfPointerEvent {
24
+ export interface EmbedPdfPointerEvent {
26
25
  clientX: number;
27
26
  clientY: number;
28
27
  ctrlKey: boolean;
@@ -30,7 +29,7 @@ interface EmbedPdfPointerEvent {
30
29
  altKey: boolean;
31
30
  metaKey: boolean;
32
31
  }
33
- interface PointerEventHandlers<T = EmbedPdfPointerEvent> {
32
+ export interface PointerEventHandlers<T = EmbedPdfPointerEvent> {
34
33
  onPointerDown?(pos: Position, evt: T, modeId: string): void;
35
34
  onPointerUp?(pos: Position, evt: T, modeId: string): void;
36
35
  onPointerMove?(pos: Position, evt: T, modeId: string): void;
@@ -38,7 +37,7 @@ interface PointerEventHandlers<T = EmbedPdfPointerEvent> {
38
37
  onPointerLeave?(pos: Position, evt: T, modeId: string): void;
39
38
  onPointerCancel?(pos: Position, evt: T, modeId: string): void;
40
39
  }
41
- interface PointerEventHandlersWithLifecycle<T = EmbedPdfPointerEvent> extends PointerEventHandlers<T> {
40
+ export interface PointerEventHandlersWithLifecycle<T = EmbedPdfPointerEvent> extends PointerEventHandlers<T> {
42
41
  onHandlerActiveStart?(modeId: string): void;
43
42
  onHandlerActiveEnd?(modeId: string): void;
44
43
  }
@@ -49,8 +48,8 @@ interface PageInteractionScope {
49
48
  type: 'page';
50
49
  pageIndex: number;
51
50
  }
52
- type InteractionScope = GlobalInteractionScope | PageInteractionScope;
53
- interface RegisterHandlersOptions {
51
+ export type InteractionScope = GlobalInteractionScope | PageInteractionScope;
52
+ export interface RegisterHandlersOptions {
54
53
  /** the mode the handlers belong to */
55
54
  modeId: string | string[];
56
55
  /** callbacks */
@@ -58,11 +57,11 @@ interface RegisterHandlersOptions {
58
57
  /** if omitted ⇒ handlers listen on the *global* layer */
59
58
  pageIndex?: number;
60
59
  }
61
- interface RegisterAlwaysOptions {
60
+ export interface RegisterAlwaysOptions {
62
61
  scope: InteractionScope;
63
62
  handlers: PointerEventHandlersWithLifecycle;
64
63
  }
65
- interface InteractionManagerCapability {
64
+ export interface InteractionManagerCapability {
66
65
  /** returns the active mode id */
67
66
  getActiveMode(): string;
68
67
  /** returns the active interaction mode */
@@ -104,74 +103,4 @@ interface InteractionManagerCapability {
104
103
  /** Returns whether the interaction is paused */
105
104
  isPaused(): boolean;
106
105
  }
107
-
108
- declare class InteractionManagerPlugin extends BasePlugin<InteractionManagerPluginConfig, InteractionManagerCapability, InteractionManagerState> {
109
- static readonly id: "interaction-manager";
110
- private modes;
111
- private cursorClaims;
112
- private buckets;
113
- private alwaysGlobal;
114
- private alwaysPage;
115
- private readonly onModeChange$;
116
- private readonly onHandlerChange$;
117
- private readonly onCursorChange$;
118
- private readonly onStateChange$;
119
- constructor(id: string, registry: PluginRegistry);
120
- initialize(_: InteractionManagerPluginConfig): Promise<void>;
121
- protected buildCapability(): InteractionManagerCapability;
122
- private activate;
123
- private notifyHandlersActive;
124
- private notifyHandlersInactive;
125
- private registerMode;
126
- /** ---------- pointer-handler handling ------------ */
127
- private registerHandlers;
128
- registerAlways({ scope, handlers }: RegisterAlwaysOptions): () => void;
129
- /** Returns the *merged* handler set that should be active for the given
130
- * provider (`global` wrapper or a single page wrapper).
131
- * – `alwaysGlobal` / `alwaysPage` are **always** active.
132
- * – Handlers that belong to the current mode are added on top **iff**
133
- * the mode’s own scope matches the provider’s scope. */
134
- private getHandlersForScope;
135
- /** ---------- cursor handling --------------------- */
136
- private setCursor;
137
- private removeCursor;
138
- private emitCursor;
139
- onStoreUpdated(_: InteractionManagerState, newState: InteractionManagerState): void;
140
- private activeModeIsExclusive;
141
- private getActiveInteractionMode;
142
- destroy(): Promise<void>;
143
- }
144
-
145
- declare const ACTIVATE_MODE = "INTERACTION/ACTIVATE_MODE";
146
- declare const PAUSE_INTERACTION = "INTERACTION/PAUSE";
147
- declare const RESUME_INTERACTION = "INTERACTION/RESUME";
148
- declare const SET_CURSOR = "INTERACTION/SET_CURSOR";
149
- interface ActivateModeAction extends Action {
150
- type: typeof ACTIVATE_MODE;
151
- payload: {
152
- mode: string;
153
- };
154
- }
155
- interface PauseInteractionAction extends Action {
156
- type: typeof PAUSE_INTERACTION;
157
- }
158
- interface ResumeInteractionAction extends Action {
159
- type: typeof RESUME_INTERACTION;
160
- }
161
- interface SetCursorAction extends Action {
162
- type: typeof SET_CURSOR;
163
- payload: {
164
- cursor: string;
165
- };
166
- }
167
- type InteractionManagerAction = ActivateModeAction | PauseInteractionAction | ResumeInteractionAction | SetCursorAction;
168
-
169
- declare const INTERACTION_MANAGER_PLUGIN_ID = "interaction-manager";
170
- declare const manifest: PluginManifest<InteractionManagerPluginConfig>;
171
-
172
- declare const initialState: InteractionManagerState;
173
- declare const reducer: Reducer<InteractionManagerState, InteractionManagerAction>;
174
-
175
- declare const InteractionManagerPluginPackage: PluginPackage<InteractionManagerPlugin, InteractionManagerPluginConfig, InteractionManagerState, InteractionManagerAction>;
176
-
177
- export { type EmbedPdfPointerEvent, INTERACTION_MANAGER_PLUGIN_ID, type InteractionManagerCapability, InteractionManagerPlugin, type InteractionManagerPluginConfig, InteractionManagerPluginPackage, type InteractionManagerState, type InteractionMode, type InteractionScope, type PointerEventHandlers, type PointerEventHandlersWithLifecycle, type RegisterAlwaysOptions, type RegisterHandlersOptions, initialState, manifest, reducer };
106
+ export {};
@@ -0,0 +1,4 @@
1
+ export { useEffect, useRef, useState, useCallback } from 'preact/hooks';
2
+ export type { ComponentChildren as ReactNode } from 'preact';
3
+ export type CSSProperties = import('preact').JSX.CSSProperties;
4
+ export type HTMLAttributes<T = any> = import('preact').JSX.HTMLAttributes<T extends EventTarget ? T : never>;
@@ -0,0 +1 @@
1
+ export * from '@embedpdf/core/preact';