@embedpdf/react 3.0.0-next.1 → 3.0.0-next.10

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 (104) hide show
  1. package/dist/AnnotationListSnapshot-DDxHpJQU-BG32YXxG.d.cts +347 -0
  2. package/dist/AnnotationListSnapshot-DDxHpJQU-BG32YXxG.d.ts +347 -0
  3. package/dist/anchored.cjs +89 -0
  4. package/dist/anchored.cjs.map +1 -0
  5. package/dist/anchored.d.cts +45 -0
  6. package/dist/anchored.d.ts +45 -0
  7. package/dist/anchored.js +60 -0
  8. package/dist/anchored.js.map +1 -0
  9. package/dist/annotation-menu.cjs +33 -84
  10. package/dist/annotation-menu.cjs.map +1 -1
  11. package/dist/annotation-menu.d.cts +28 -2
  12. package/dist/annotation-menu.d.ts +28 -2
  13. package/dist/annotation-menu.js +27 -78
  14. package/dist/annotation-menu.js.map +1 -1
  15. package/dist/annotation.cjs +752 -16
  16. package/dist/annotation.cjs.map +1 -0
  17. package/dist/annotation.d.cts +159 -2
  18. package/dist/annotation.d.ts +159 -2
  19. package/dist/annotation.js +737 -3
  20. package/dist/annotation.js.map +1 -0
  21. package/dist/commands.js +1 -0
  22. package/dist/commands.js.map +1 -1
  23. package/dist/form.cjs +3 -3
  24. package/dist/form.cjs.map +1 -1
  25. package/dist/form.d.cts +2 -2
  26. package/dist/form.d.ts +2 -2
  27. package/dist/form.js +3 -3
  28. package/dist/form.js.map +1 -1
  29. package/dist/index.cjs +34 -5
  30. package/dist/index.d.cts +14 -8
  31. package/dist/index.d.ts +14 -8
  32. package/dist/index.js +8 -6
  33. package/dist/interaction.cjs +17 -4
  34. package/dist/interaction.cjs.map +1 -1
  35. package/dist/interaction.d.cts +2 -2
  36. package/dist/interaction.d.ts +2 -2
  37. package/dist/interaction.js +7 -5
  38. package/dist/interaction.js.map +1 -1
  39. package/dist/link.cjs +29 -6
  40. package/dist/link.cjs.map +1 -1
  41. package/dist/link.d.cts +12 -3
  42. package/dist/link.d.ts +12 -3
  43. package/dist/link.js +31 -8
  44. package/dist/link.js.map +1 -1
  45. package/dist/metadata.js +1 -0
  46. package/dist/metadata.js.map +1 -1
  47. package/dist/page-edit.js +1 -0
  48. package/dist/page-edit.js.map +1 -1
  49. package/dist/page-view.cjs +62 -38
  50. package/dist/page-view.cjs.map +1 -1
  51. package/dist/page-view.js +59 -37
  52. package/dist/page-view.js.map +1 -1
  53. package/dist/redaction.js +1 -0
  54. package/dist/redaction.js.map +1 -1
  55. package/dist/render.cjs +67 -50
  56. package/dist/render.cjs.map +1 -1
  57. package/dist/render.d.cts +6 -19
  58. package/dist/render.d.ts +6 -19
  59. package/dist/render.js +71 -52
  60. package/dist/render.js.map +1 -1
  61. package/dist/rolldown-runtime-BBjsoOtd.js +27 -0
  62. package/dist/{runtime-DV98q7I0.d.ts → runtime-Cvi0wQ4d.d.cts} +23 -10
  63. package/dist/{runtime-CMxIuF2O.d.cts → runtime-DXxr8T4L.d.ts} +23 -10
  64. package/dist/runtime.cjs +6 -5
  65. package/dist/runtime.cjs.map +1 -1
  66. package/dist/runtime.d.cts +1 -1
  67. package/dist/runtime.d.ts +1 -1
  68. package/dist/runtime.js +7 -5
  69. package/dist/runtime.js.map +1 -1
  70. package/dist/search.cjs +36 -19
  71. package/dist/search.cjs.map +1 -1
  72. package/dist/search.d.cts +1 -1
  73. package/dist/search.d.ts +1 -1
  74. package/dist/search.js +36 -19
  75. package/dist/search.js.map +1 -1
  76. package/dist/selection.cjs +217 -22
  77. package/dist/selection.cjs.map +1 -1
  78. package/dist/selection.d.cts +60 -2
  79. package/dist/selection.d.ts +60 -2
  80. package/dist/selection.js +214 -27
  81. package/dist/selection.js.map +1 -1
  82. package/dist/shell.js +1 -0
  83. package/dist/shell.js.map +1 -1
  84. package/dist/stage.cjs +47 -146
  85. package/dist/stage.cjs.map +1 -1
  86. package/dist/stage.d.cts +18 -5
  87. package/dist/stage.d.ts +18 -5
  88. package/dist/stage.js +50 -148
  89. package/dist/stage.js.map +1 -1
  90. package/dist/stamp.js +1 -0
  91. package/dist/stamp.js.map +1 -1
  92. package/dist/toolbar.js +1 -0
  93. package/dist/toolbar.js.map +1 -1
  94. package/dist/views.js +1 -0
  95. package/dist/views.js.map +1 -1
  96. package/package.json +27 -26
  97. package/dist/AnnotationListSnapshot-W0RCsyDE-dWna4TTJ.d.cts +0 -2593
  98. package/dist/AnnotationListSnapshot-W0RCsyDE-dWna4TTJ.d.ts +0 -2593
  99. package/dist/annotation-B6jwfTCh.d.cts +0 -173
  100. package/dist/annotation-Ct6dFtzJ.cjs +0 -913
  101. package/dist/annotation-Ct6dFtzJ.cjs.map +0 -1
  102. package/dist/annotation-DjGWJljY.js +0 -829
  103. package/dist/annotation-DjGWJljY.js.map +0 -1
  104. package/dist/annotation-nUMefyjw.d.ts +0 -173
package/dist/index.cjs CHANGED
@@ -1,13 +1,14 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("./rolldown-runtime-DDXJien1.cjs");
3
3
  const require_runtime = require("./runtime.cjs");
4
- const require_interaction = require("./interaction.cjs");
4
+ const require_anchored = require("./anchored.cjs");
5
5
  const require_stage = require("./stage.cjs");
6
6
  const require_scrollbar = require("./scrollbar.cjs");
7
7
  const require_page_view = require("./page-view.cjs");
8
8
  const require_render = require("./render.cjs");
9
+ const require_interaction = require("./interaction.cjs");
9
10
  const require_selection = require("./selection.cjs");
10
- const require_annotation = require("./annotation-Ct6dFtzJ.cjs");
11
+ const require_annotation = require("./annotation.cjs");
11
12
  const require_annotation_menu = require("./annotation-menu.cjs");
12
13
  const require_link = require("./link.cjs");
13
14
  const require_views = require("./views.cjs");
@@ -21,6 +22,8 @@ const require_i18n = require("./i18n.cjs");
21
22
  const require_commands = require("./commands.cjs");
22
23
  const require_shell = require("./shell.cjs");
23
24
  const require_toolbar = require("./toolbar.cjs");
25
+ let _embedpdf_web = require("@embedpdf/web");
26
+ exports.Anchored = require_anchored.Anchored;
24
27
  exports.AnnotationDraftMenu = require_annotation_menu.AnnotationDraftMenu;
25
28
  exports.AnnotationLayer = require_annotation.AnnotationLayer;
26
29
  exports.AnnotationMenu = require_annotation_menu.AnnotationMenu;
@@ -29,23 +32,32 @@ exports.DocumentScope = require_runtime.DocumentScope;
29
32
  exports.EmbedPDF = require_runtime.EmbedPDF;
30
33
  exports.FormLayer = require_form.FormLayer;
31
34
  exports.LinkLayer = require_link.LinkLayer;
32
- exports.PageAnnotationDraftMenu = require_annotation.PageAnnotationDraftMenu;
33
- exports.PageAnnotationMenu = require_annotation.PageAnnotationMenu;
34
35
  exports.PagePointerSource = require_interaction.PagePointerSource;
35
36
  exports.PageProvider = require_runtime.PageProvider;
36
37
  exports.PageView = require_page_view.PageView;
38
+ exports.ProjectorProvider = require_anchored.ProjectorProvider;
37
39
  exports.RenderLayer = require_render.RenderLayer;
38
40
  exports.Scrollbar = require_scrollbar.Scrollbar;
39
41
  exports.SearchLayer = require_search.SearchLayer;
42
+ exports.SelectionClipboard = require_selection.SelectionClipboard;
43
+ exports.SelectionHandles = require_selection.SelectionHandles;
40
44
  exports.SelectionLayer = require_selection.SelectionLayer;
45
+ exports.SelectionMenu = require_selection.SelectionMenu;
41
46
  exports.Stage = require_stage.Stage;
42
- exports.TileLayer = require_render.TileLayer;
43
47
  exports.Toolbar = require_toolbar.Toolbar;
44
48
  exports.Viewer = require_runtime.Viewer;
49
+ Object.defineProperty(exports, "copySelection", {
50
+ enumerable: true,
51
+ get: function() {
52
+ return _embedpdf_web.copySelection;
53
+ }
54
+ });
45
55
  exports.createClickCounter = require_interaction.createClickCounter;
56
+ exports.enrichCommentThreads = require_annotation.enrichCommentThreads;
46
57
  exports.filePickerProvider = require_annotation.filePickerProvider;
47
58
  exports.isMacPlatform = require_commands.isMacPlatform;
48
59
  exports.makePageContext = require_runtime.makePageContext;
60
+ exports.openLinkTarget = require_link.openLinkTarget;
49
61
  exports.sameAnchor = require_annotation.sameAnchor;
50
62
  exports.sameCreationDraftAnchor = require_annotation.sameCreationDraftAnchor;
51
63
  exports.shallowArray = require_runtime.shallowArray;
@@ -59,6 +71,10 @@ exports.useCapability = require_runtime.useCapability;
59
71
  exports.useCommand = require_commands.useCommand;
60
72
  exports.useCommandShortcuts = require_commands.useCommandShortcuts;
61
73
  exports.useCommands = require_commands.useCommands;
74
+ exports.useCommentThread = require_annotation.useCommentThread;
75
+ exports.useCommentThreads = require_annotation.useCommentThreads;
76
+ exports.useComments = require_annotation.useComments;
77
+ exports.useCommentsHydration = require_annotation.useCommentsHydration;
62
78
  exports.useDocumentId = require_runtime.useDocumentId;
63
79
  exports.useDocumentStatus = require_runtime.useDocumentStatus;
64
80
  exports.useDocuments = require_runtime.useDocuments;
@@ -81,6 +97,7 @@ exports.usePageEditor = require_page_edit.usePageEditor;
81
97
  exports.usePageList = require_stage.usePageList;
82
98
  exports.usePages = require_stage.usePages;
83
99
  exports.usePendingRedactions = require_redaction.usePendingRedactions;
100
+ exports.useProjectorBinding = require_anchored.useProjectorBinding;
84
101
  exports.useRedaction = require_redaction.useRedaction;
85
102
  exports.useScrollMetrics = require_scrollbar.useScrollMetrics;
86
103
  exports.useSearch = require_search.useSearch;
@@ -103,6 +120,18 @@ exports.useTool = require_interaction.useTool;
103
120
  exports.useToolCursor = require_interaction.useToolCursor;
104
121
  exports.useViews = require_views.useViews;
105
122
  exports.useZoom = require_stage.useZoom;
123
+ Object.defineProperty(exports, "vibrationFeedback", {
124
+ enumerable: true,
125
+ get: function() {
126
+ return _embedpdf_web.vibrationFeedback;
127
+ }
128
+ });
129
+ Object.defineProperty(exports, "wkFeedback", {
130
+ enumerable: true,
131
+ get: function() {
132
+ return _embedpdf_web.wkFeedback;
133
+ }
134
+ });
106
135
  var _embedpdf_core = require("@embedpdf/core");
107
136
  Object.keys(_embedpdf_core).forEach(function(k) {
108
137
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
package/dist/index.d.cts CHANGED
@@ -1,16 +1,17 @@
1
- import { S as useSelector, _ as useKernel, a as EmbedPDF, b as useOptionalSelector, c as Viewer, d as shallowArray, f as useActiveDocumentId, g as useDocuments, h as useDocumentStatus, i as DocumentScopeProps, l as ViewerProps, m as useDocumentId, n as DocumentGateProps, o as PageContextValue, p as useCapability, r as DocumentScope, s as PageProvider, t as DocumentGate, u as makePageContext, v as useKernelValue, x as usePage, y as useOptionalCapability } from "./runtime-CMxIuF2O.cjs";
2
- import { A as useAnnotation, C as SelectionProps, D as filePickerProvider, E as TextStyle, F as useSelectionFlags, I as useSelectionProps, L as AnnotationMenuPlacement, M as useAnnotationSelected, N as useAnnotationSelection, O as sameAnchor, P as useFilePickerProvider, S as SelectionFlags, T as TextAlign, _ as PageAnnotationMenu, a as AnnotationLayerProps, b as RenderItem, c as AnnotationProps, d as AnnotationRendererProps, f as Border, g as PageAnnotationDraftMenu, h as LineEndings, i as AnnotationLayer, j as useAnnotationDefaults, k as sameCreationDraftAnchor, l as AnnotationPropsPatch, m as LineEnding, n as AnnotationDraftMenuRenderArgs, o as AnnotationMenuProps, p as Geom, r as AnnotationFlags, s as AnnotationMenuRenderArgs, t as AnnotationDraftMenuProps, u as AnnotationRenderer, v as PropKey, w as Style, x as SelectionAnchor, y as PropSpec } from "./annotation-B6jwfTCh.cjs";
3
- import { AnnotationDraftMenu, AnnotationMenu } from "./annotation-menu.cjs";
1
+ import { AnchorTarget, Anchored, AnchoredPlacement, AnchoredProps, ProjectorBinding, ProjectorProvider, ViewProjector, useProjectorBinding } from "./anchored.cjs";
2
+ import { AnnotationDraftMenu, AnnotationDraftMenuProps, AnnotationMenu, AnnotationMenuProps } from "./annotation-menu.cjs";
3
+ import { C as useSelector, S as usePage, _ as useDocuments, a as EmbedPDF, b as useOptionalCapability, c as Viewer, d as runtime_d_exports, f as shallowArray, g as useDocumentStatus, h as useDocumentId, i as DocumentScopeProps, l as ViewerProps, m as useCapability, n as DocumentGateProps, o as PageContextValue, p as useActiveDocumentId, r as DocumentScope, s as PageProvider, t as DocumentGate, u as makePageContext, v as useKernel, x as useOptionalSelector, y as useKernelValue } from "./runtime-Cvi0wQ4d.cjs";
4
+ import { AnnotationFlags, AnnotationLayer, AnnotationLayerProps, AnnotationProps, AnnotationPropsPatch, AnnotationRenderer, AnnotationRendererProps, Border, CommentThreadView, CreationDraftAnchor, Geom, LineEnding, LineEndings, PropKey, PropSpec, RenderItem, SelectionAnchor, SelectionFlags, SelectionProps, Style, TextAlign, TextStyle, enrichCommentThreads, filePickerProvider, sameAnchor, sameCreationDraftAnchor, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useFilePickerProvider, useSelectionFlags, useSelectionProps } from "./annotation.cjs";
4
5
  import { isMacPlatform, useCommand, useCommandShortcuts, useCommands } from "./commands.cjs";
5
6
  import { FormLayer, FormScriptingUiHandlers, useForm, useFormField, useFormScriptingProvider } from "./form.cjs";
6
7
  import { useI18n, useLocale, useT } from "./i18n.cjs";
7
8
  import { Stage, StageProps, StageTokenProp, useLayout, usePageList, usePages, useStage, useStageSettings, useZoom } from "./stage.cjs";
8
9
  import { Scrollbar, ScrollbarAxis, ScrollbarProps, useScrollMetrics } from "./scrollbar.cjs";
9
10
  import { PageView, PageViewProps } from "./page-view.cjs";
10
- import { RenderLayer, RenderLayerProps, TileLayer, TileLayerProps } from "./render.cjs";
11
- import { PagePointerSource, ToolCursorImage, ToolCursorSpec, createClickCounter, useTool, useToolCursor } from "./interaction.cjs";
12
- import { SelectionLayer, SelectionLayerProps, useSelection } from "./selection.cjs";
13
- import { LinkLayer, LinkLayerProps, useLink } from "./link.cjs";
11
+ import { RenderLayer, RenderLayerProps } from "./render.cjs";
12
+ import { PagePointerSource, ToolCursorImage, ToolCursorSpec, createClickCounter, useTool, useToolCursor, vibrationFeedback, wkFeedback } from "./interaction.cjs";
13
+ import { SelectionClipboard, SelectionClipboardProps, SelectionHandles, SelectionHandlesProps, SelectionLayer, SelectionLayerProps, SelectionMenu, SelectionMenuProps, copySelection, useSelection } from "./selection.cjs";
14
+ import { LinkLayer, LinkLayerProps, openLinkTarget, useLink } from "./link.cjs";
14
15
  import { UseViews, useViews } from "./views.cjs";
15
16
  import { usePageEditor } from "./page-edit.cjs";
16
17
  import { useMetadata } from "./metadata.cjs";
@@ -34,4 +35,9 @@ export * from "@embedpdf/plugin-redaction";
34
35
  export * from "@embedpdf/plugin-stamp";
35
36
  export * from "@embedpdf/plugin-shell";
36
37
  export * from "@embedpdf/core-ui";
37
- export { AnnotationDraftMenu, AnnotationDraftMenuProps, AnnotationDraftMenuRenderArgs, type AnnotationFlags, AnnotationLayer, AnnotationLayerProps, AnnotationMenu, type AnnotationMenuPlacement, AnnotationMenuProps, AnnotationMenuRenderArgs, type AnnotationProps, type AnnotationPropsPatch, AnnotationRenderer, AnnotationRendererProps, type Border, CollapsedGroupView, CustomSlotCtx, DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, FormLayer, type FormScriptingUiHandlers, type Geom, GroupDisclosureView, type LineEnding, type LineEndings, LinkLayer, LinkLayerProps, MenusHandle, OverflowMenuView, PageAnnotationDraftMenu, PageAnnotationMenu, PageContextValue, PagePointerSource, PageProvider, PageView, PageViewProps, type PropKey, type PropSpec, type RenderItem, RenderLayer, RenderLayerProps, Scrollbar, ScrollbarAxis, ScrollbarProps, SearchLayer, SelectionAnchor, type SelectionFlags, SelectionLayer, SelectionLayerProps, type SelectionProps, Stage, StageProps, StageTokenProp, StripView, StripViewGroup, type Style, SurfaceHandle, type TextAlign, type TextStyle, TileLayer, TileLayerProps, ToolCursorImage, ToolCursorSpec, Toolbar, ToolbarProps, UseViews, Viewer, ViewerProps, createClickCounter, filePickerProvider, isMacPlatform, makePageContext, sameAnchor, sameCreationDraftAnchor, shallowArray, useActiveDocumentId, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useArmStampAsset, useCapability, useCommand, useCommandShortcuts, useCommands, useDocumentId, useDocumentStatus, useDocuments, useFilePickerProvider, useForm, useFormField, useFormScriptingProvider, useI18n, useKernel, useKernelValue, useLayout, useLink, useLocale, useMenus, useMetadata, useOptionalCapability, useOptionalSelector, usePage, usePageEditor, usePageList, usePages, usePendingRedactions, useRedaction, useScrollMetrics, useSearch, useSearchState, useSelection, useSelectionFlags, useSelectionProps, useSelector, useShell, useStage, useStageSettings, useStamp, useStampAssetPreviewUrl, useStampAssets, useStampLibraries, useStripView, useSurface, useT, useTool, useToolCursor, useViews, useZoom };
38
+ declare namespace index_d_exports {
39
+ export { AnchorTarget, Anchored, AnchoredPlacement, AnchoredProps, AnnotationDraftMenu, AnnotationDraftMenuProps, AnnotationFlags, AnnotationLayer, AnnotationLayerProps, AnnotationMenu, AnnotationMenuProps, AnnotationProps, AnnotationPropsPatch, AnnotationRenderer, AnnotationRendererProps, Border, CollapsedGroupView, CommentThreadView, CreationDraftAnchor, CustomSlotCtx, DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, FormLayer, FormScriptingUiHandlers, Geom, GroupDisclosureView, LineEnding, LineEndings, LinkLayer, LinkLayerProps, MenusHandle, OverflowMenuView, PageContextValue, PagePointerSource, PageProvider, PageView, PageViewProps, ProjectorBinding, ProjectorProvider, PropKey, PropSpec, RenderItem, RenderLayer, RenderLayerProps, Scrollbar, ScrollbarAxis, ScrollbarProps, SearchLayer, SelectionAnchor, SelectionClipboard, SelectionClipboardProps, SelectionFlags, SelectionHandles, SelectionHandlesProps, SelectionLayer, SelectionLayerProps, SelectionMenu, SelectionMenuProps, SelectionProps, Stage, StageProps, StageTokenProp, StripView, StripViewGroup, Style, SurfaceHandle, TextAlign, TextStyle, ToolCursorImage, ToolCursorSpec, Toolbar, ToolbarProps, UseViews, ViewProjector, Viewer, ViewerProps, copySelection, createClickCounter, enrichCommentThreads, filePickerProvider, isMacPlatform, makePageContext, openLinkTarget, sameAnchor, sameCreationDraftAnchor, shallowArray, useActiveDocumentId, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useArmStampAsset, useCapability, useCommand, useCommandShortcuts, useCommands, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useDocumentId, useDocumentStatus, useDocuments, useFilePickerProvider, useForm, useFormField, useFormScriptingProvider, useI18n, useKernel, useKernelValue, useLayout, useLink, useLocale, useMenus, useMetadata, useOptionalCapability, useOptionalSelector, usePage, usePageEditor, usePageList, usePages, usePendingRedactions, useProjectorBinding, useRedaction, useScrollMetrics, useSearch, useSearchState, useSelection, useSelectionFlags, useSelectionProps, useSelector, useShell, useStage, useStageSettings, useStamp, useStampAssetPreviewUrl, useStampAssets, useStampLibraries, useStripView, useSurface, useT, useTool, useToolCursor, useViews, useZoom, vibrationFeedback, wkFeedback };
40
+ }
41
+ //#endregion
42
+ export { type AnchorTarget, Anchored, type AnchoredPlacement, AnchoredProps, AnnotationDraftMenu, AnnotationDraftMenuProps, type AnnotationFlags, AnnotationLayer, AnnotationLayerProps, AnnotationMenu, AnnotationMenuProps, type AnnotationProps, type AnnotationPropsPatch, AnnotationRenderer, AnnotationRendererProps, type Border, CollapsedGroupView, CommentThreadView, type CreationDraftAnchor, CustomSlotCtx, DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, FormLayer, type FormScriptingUiHandlers, type Geom, GroupDisclosureView, type LineEnding, type LineEndings, LinkLayer, LinkLayerProps, MenusHandle, OverflowMenuView, PageContextValue, PagePointerSource, PageProvider, PageView, PageViewProps, ProjectorBinding, ProjectorProvider, type PropKey, type PropSpec, type RenderItem, RenderLayer, RenderLayerProps, Scrollbar, ScrollbarAxis, ScrollbarProps, SearchLayer, SelectionAnchor, SelectionClipboard, SelectionClipboardProps, type SelectionFlags, SelectionHandles, SelectionHandlesProps, SelectionLayer, SelectionLayerProps, SelectionMenu, SelectionMenuProps, type SelectionProps, Stage, StageProps, StageTokenProp, StripView, StripViewGroup, type Style, SurfaceHandle, type TextAlign, type TextStyle, ToolCursorImage, ToolCursorSpec, Toolbar, ToolbarProps, UseViews, type ViewProjector, Viewer, ViewerProps, copySelection, createClickCounter, enrichCommentThreads, filePickerProvider, isMacPlatform, makePageContext, openLinkTarget, sameAnchor, sameCreationDraftAnchor, shallowArray, useActiveDocumentId, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useArmStampAsset, useCapability, useCommand, useCommandShortcuts, useCommands, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useDocumentId, useDocumentStatus, useDocuments, useFilePickerProvider, useForm, useFormField, useFormScriptingProvider, useI18n, useKernel, useKernelValue, useLayout, useLink, useLocale, useMenus, useMetadata, useOptionalCapability, useOptionalSelector, usePage, usePageEditor, usePageList, usePages, usePendingRedactions, useProjectorBinding, useRedaction, useScrollMetrics, useSearch, useSearchState, useSelection, useSelectionFlags, useSelectionProps, useSelector, useShell, useStage, useStageSettings, useStamp, useStampAssetPreviewUrl, useStampAssets, useStampLibraries, useStripView, useSurface, useT, useTool, useToolCursor, useViews, useZoom, vibrationFeedback, wkFeedback };
43
+ //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,16 +1,17 @@
1
- import { S as useSelector, _ as useKernel, a as EmbedPDF, b as useOptionalSelector, c as Viewer, d as shallowArray, f as useActiveDocumentId, g as useDocuments, h as useDocumentStatus, i as DocumentScopeProps, l as ViewerProps, m as useDocumentId, n as DocumentGateProps, o as PageContextValue, p as useCapability, r as DocumentScope, s as PageProvider, t as DocumentGate, u as makePageContext, v as useKernelValue, x as usePage, y as useOptionalCapability } from "./runtime-DV98q7I0.js";
2
- import { A as useAnnotation, C as SelectionProps, D as filePickerProvider, E as TextStyle, F as useSelectionFlags, I as useSelectionProps, L as AnnotationMenuPlacement, M as useAnnotationSelected, N as useAnnotationSelection, O as sameAnchor, P as useFilePickerProvider, S as SelectionFlags, T as TextAlign, _ as PageAnnotationMenu, a as AnnotationLayerProps, b as RenderItem, c as AnnotationProps, d as AnnotationRendererProps, f as Border, g as PageAnnotationDraftMenu, h as LineEndings, i as AnnotationLayer, j as useAnnotationDefaults, k as sameCreationDraftAnchor, l as AnnotationPropsPatch, m as LineEnding, n as AnnotationDraftMenuRenderArgs, o as AnnotationMenuProps, p as Geom, r as AnnotationFlags, s as AnnotationMenuRenderArgs, t as AnnotationDraftMenuProps, u as AnnotationRenderer, v as PropKey, w as Style, x as SelectionAnchor, y as PropSpec } from "./annotation-nUMefyjw.js";
3
- import { AnnotationDraftMenu, AnnotationMenu } from "./annotation-menu.js";
1
+ import { AnchorTarget, Anchored, AnchoredPlacement, AnchoredProps, ProjectorBinding, ProjectorProvider, ViewProjector, useProjectorBinding } from "./anchored.js";
2
+ import { AnnotationDraftMenu, AnnotationDraftMenuProps, AnnotationMenu, AnnotationMenuProps } from "./annotation-menu.js";
3
+ import { C as useSelector, S as usePage, _ as useDocuments, a as EmbedPDF, b as useOptionalCapability, c as Viewer, d as runtime_d_exports, f as shallowArray, g as useDocumentStatus, h as useDocumentId, i as DocumentScopeProps, l as ViewerProps, m as useCapability, n as DocumentGateProps, o as PageContextValue, p as useActiveDocumentId, r as DocumentScope, s as PageProvider, t as DocumentGate, u as makePageContext, v as useKernel, x as useOptionalSelector, y as useKernelValue } from "./runtime-DXxr8T4L.js";
4
+ import { AnnotationFlags, AnnotationLayer, AnnotationLayerProps, AnnotationProps, AnnotationPropsPatch, AnnotationRenderer, AnnotationRendererProps, Border, CommentThreadView, CreationDraftAnchor, Geom, LineEnding, LineEndings, PropKey, PropSpec, RenderItem, SelectionAnchor, SelectionFlags, SelectionProps, Style, TextAlign, TextStyle, enrichCommentThreads, filePickerProvider, sameAnchor, sameCreationDraftAnchor, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useFilePickerProvider, useSelectionFlags, useSelectionProps } from "./annotation.js";
4
5
  import { isMacPlatform, useCommand, useCommandShortcuts, useCommands } from "./commands.js";
5
6
  import { FormLayer, FormScriptingUiHandlers, useForm, useFormField, useFormScriptingProvider } from "./form.js";
6
7
  import { useI18n, useLocale, useT } from "./i18n.js";
7
8
  import { Stage, StageProps, StageTokenProp, useLayout, usePageList, usePages, useStage, useStageSettings, useZoom } from "./stage.js";
8
9
  import { Scrollbar, ScrollbarAxis, ScrollbarProps, useScrollMetrics } from "./scrollbar.js";
9
10
  import { PageView, PageViewProps } from "./page-view.js";
10
- import { RenderLayer, RenderLayerProps, TileLayer, TileLayerProps } from "./render.js";
11
- import { PagePointerSource, ToolCursorImage, ToolCursorSpec, createClickCounter, useTool, useToolCursor } from "./interaction.js";
12
- import { SelectionLayer, SelectionLayerProps, useSelection } from "./selection.js";
13
- import { LinkLayer, LinkLayerProps, useLink } from "./link.js";
11
+ import { RenderLayer, RenderLayerProps } from "./render.js";
12
+ import { PagePointerSource, ToolCursorImage, ToolCursorSpec, createClickCounter, useTool, useToolCursor, vibrationFeedback, wkFeedback } from "./interaction.js";
13
+ import { SelectionClipboard, SelectionClipboardProps, SelectionHandles, SelectionHandlesProps, SelectionLayer, SelectionLayerProps, SelectionMenu, SelectionMenuProps, copySelection, useSelection } from "./selection.js";
14
+ import { LinkLayer, LinkLayerProps, openLinkTarget, useLink } from "./link.js";
14
15
  import { UseViews, useViews } from "./views.js";
15
16
  import { usePageEditor } from "./page-edit.js";
16
17
  import { useMetadata } from "./metadata.js";
@@ -34,4 +35,9 @@ export * from "@embedpdf/plugin-stamp";
34
35
  export * from "@embedpdf/plugin-commands";
35
36
  export * from "@embedpdf/plugin-shell";
36
37
  export * from "@embedpdf/core-ui";
37
- export { AnnotationDraftMenu, AnnotationDraftMenuProps, AnnotationDraftMenuRenderArgs, type AnnotationFlags, AnnotationLayer, AnnotationLayerProps, AnnotationMenu, type AnnotationMenuPlacement, AnnotationMenuProps, AnnotationMenuRenderArgs, type AnnotationProps, type AnnotationPropsPatch, AnnotationRenderer, AnnotationRendererProps, type Border, CollapsedGroupView, CustomSlotCtx, DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, FormLayer, type FormScriptingUiHandlers, type Geom, GroupDisclosureView, type LineEnding, type LineEndings, LinkLayer, LinkLayerProps, MenusHandle, OverflowMenuView, PageAnnotationDraftMenu, PageAnnotationMenu, PageContextValue, PagePointerSource, PageProvider, PageView, PageViewProps, type PropKey, type PropSpec, type RenderItem, RenderLayer, RenderLayerProps, Scrollbar, ScrollbarAxis, ScrollbarProps, SearchLayer, SelectionAnchor, type SelectionFlags, SelectionLayer, SelectionLayerProps, type SelectionProps, Stage, StageProps, StageTokenProp, StripView, StripViewGroup, type Style, SurfaceHandle, type TextAlign, type TextStyle, TileLayer, TileLayerProps, ToolCursorImage, ToolCursorSpec, Toolbar, ToolbarProps, UseViews, Viewer, ViewerProps, createClickCounter, filePickerProvider, isMacPlatform, makePageContext, sameAnchor, sameCreationDraftAnchor, shallowArray, useActiveDocumentId, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useArmStampAsset, useCapability, useCommand, useCommandShortcuts, useCommands, useDocumentId, useDocumentStatus, useDocuments, useFilePickerProvider, useForm, useFormField, useFormScriptingProvider, useI18n, useKernel, useKernelValue, useLayout, useLink, useLocale, useMenus, useMetadata, useOptionalCapability, useOptionalSelector, usePage, usePageEditor, usePageList, usePages, usePendingRedactions, useRedaction, useScrollMetrics, useSearch, useSearchState, useSelection, useSelectionFlags, useSelectionProps, useSelector, useShell, useStage, useStageSettings, useStamp, useStampAssetPreviewUrl, useStampAssets, useStampLibraries, useStripView, useSurface, useT, useTool, useToolCursor, useViews, useZoom };
38
+ declare namespace index_d_exports {
39
+ export { AnchorTarget, Anchored, AnchoredPlacement, AnchoredProps, AnnotationDraftMenu, AnnotationDraftMenuProps, AnnotationFlags, AnnotationLayer, AnnotationLayerProps, AnnotationMenu, AnnotationMenuProps, AnnotationProps, AnnotationPropsPatch, AnnotationRenderer, AnnotationRendererProps, Border, CollapsedGroupView, CommentThreadView, CreationDraftAnchor, CustomSlotCtx, DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, FormLayer, FormScriptingUiHandlers, Geom, GroupDisclosureView, LineEnding, LineEndings, LinkLayer, LinkLayerProps, MenusHandle, OverflowMenuView, PageContextValue, PagePointerSource, PageProvider, PageView, PageViewProps, ProjectorBinding, ProjectorProvider, PropKey, PropSpec, RenderItem, RenderLayer, RenderLayerProps, Scrollbar, ScrollbarAxis, ScrollbarProps, SearchLayer, SelectionAnchor, SelectionClipboard, SelectionClipboardProps, SelectionFlags, SelectionHandles, SelectionHandlesProps, SelectionLayer, SelectionLayerProps, SelectionMenu, SelectionMenuProps, SelectionProps, Stage, StageProps, StageTokenProp, StripView, StripViewGroup, Style, SurfaceHandle, TextAlign, TextStyle, ToolCursorImage, ToolCursorSpec, Toolbar, ToolbarProps, UseViews, ViewProjector, Viewer, ViewerProps, copySelection, createClickCounter, enrichCommentThreads, filePickerProvider, isMacPlatform, makePageContext, openLinkTarget, sameAnchor, sameCreationDraftAnchor, shallowArray, useActiveDocumentId, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useArmStampAsset, useCapability, useCommand, useCommandShortcuts, useCommands, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useDocumentId, useDocumentStatus, useDocuments, useFilePickerProvider, useForm, useFormField, useFormScriptingProvider, useI18n, useKernel, useKernelValue, useLayout, useLink, useLocale, useMenus, useMetadata, useOptionalCapability, useOptionalSelector, usePage, usePageEditor, usePageList, usePages, usePendingRedactions, useProjectorBinding, useRedaction, useScrollMetrics, useSearch, useSearchState, useSelection, useSelectionFlags, useSelectionProps, useSelector, useShell, useStage, useStageSettings, useStamp, useStampAssetPreviewUrl, useStampAssets, useStampLibraries, useStripView, useSurface, useT, useTool, useToolCursor, useViews, useZoom, vibrationFeedback, wkFeedback };
40
+ }
41
+ //#endregion
42
+ export { type AnchorTarget, Anchored, type AnchoredPlacement, AnchoredProps, AnnotationDraftMenu, AnnotationDraftMenuProps, type AnnotationFlags, AnnotationLayer, AnnotationLayerProps, AnnotationMenu, AnnotationMenuProps, type AnnotationProps, type AnnotationPropsPatch, AnnotationRenderer, AnnotationRendererProps, type Border, CollapsedGroupView, CommentThreadView, type CreationDraftAnchor, CustomSlotCtx, DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, FormLayer, type FormScriptingUiHandlers, type Geom, GroupDisclosureView, type LineEnding, type LineEndings, LinkLayer, LinkLayerProps, MenusHandle, OverflowMenuView, PageContextValue, PagePointerSource, PageProvider, PageView, PageViewProps, ProjectorBinding, ProjectorProvider, type PropKey, type PropSpec, type RenderItem, RenderLayer, RenderLayerProps, Scrollbar, ScrollbarAxis, ScrollbarProps, SearchLayer, SelectionAnchor, SelectionClipboard, SelectionClipboardProps, type SelectionFlags, SelectionHandles, SelectionHandlesProps, SelectionLayer, SelectionLayerProps, SelectionMenu, SelectionMenuProps, type SelectionProps, Stage, StageProps, StageTokenProp, StripView, StripViewGroup, type Style, SurfaceHandle, type TextAlign, type TextStyle, ToolCursorImage, ToolCursorSpec, Toolbar, ToolbarProps, UseViews, type ViewProjector, Viewer, ViewerProps, copySelection, createClickCounter, enrichCommentThreads, filePickerProvider, isMacPlatform, makePageContext, openLinkTarget, sameAnchor, sameCreationDraftAnchor, shallowArray, useActiveDocumentId, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useArmStampAsset, useCapability, useCommand, useCommandShortcuts, useCommands, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useDocumentId, useDocumentStatus, useDocuments, useFilePickerProvider, useForm, useFormField, useFormScriptingProvider, useI18n, useKernel, useKernelValue, useLayout, useLink, useLocale, useMenus, useMetadata, useOptionalCapability, useOptionalSelector, usePage, usePageEditor, usePageList, usePages, usePendingRedactions, useProjectorBinding, useRedaction, useScrollMetrics, useSearch, useSearchState, useSelection, useSelectionFlags, useSelectionProps, useSelector, useShell, useStage, useStageSettings, useStamp, useStampAssetPreviewUrl, useStampAssets, useStampLibraries, useStripView, useSurface, useT, useTool, useToolCursor, useViews, useZoom, vibrationFeedback, wkFeedback };
43
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,13 +1,15 @@
1
+ import "./rolldown-runtime-BBjsoOtd.js";
1
2
  import { DocumentGate, DocumentScope, EmbedPDF, PageProvider, Viewer, makePageContext, shallowArray, useActiveDocumentId, useCapability, useDocumentId, useDocumentStatus, useDocuments, useKernel, useKernelValue, useOptionalCapability, useOptionalSelector, usePage, useSelector } from "./runtime.js";
2
- import { PagePointerSource, createClickCounter, useTool, useToolCursor } from "./interaction.js";
3
+ import { Anchored, ProjectorProvider, useProjectorBinding } from "./anchored.js";
3
4
  import { Stage, useLayout, usePageList, usePages, useStage, useStageSettings, useZoom } from "./stage.js";
4
5
  import { Scrollbar, useScrollMetrics } from "./scrollbar.js";
5
6
  import { PageView } from "./page-view.js";
6
- import { RenderLayer, TileLayer } from "./render.js";
7
- import { SelectionLayer, useSelection } from "./selection.js";
8
- import { a as sameAnchor, c as useAnnotationDefaults, d as useFilePickerProvider, f as useSelectionFlags, i as filePickerProvider, l as useAnnotationSelected, n as PageAnnotationDraftMenu, o as sameCreationDraftAnchor, p as useSelectionProps, r as PageAnnotationMenu, s as useAnnotation, t as AnnotationLayer, u as useAnnotationSelection } from "./annotation-DjGWJljY.js";
7
+ import { RenderLayer } from "./render.js";
8
+ import { PagePointerSource, createClickCounter, useTool, useToolCursor, vibrationFeedback, wkFeedback } from "./interaction.js";
9
+ import { SelectionClipboard, SelectionHandles, SelectionLayer, SelectionMenu, copySelection, useSelection } from "./selection.js";
10
+ import { AnnotationLayer, enrichCommentThreads, filePickerProvider, sameAnchor, sameCreationDraftAnchor, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useFilePickerProvider, useSelectionFlags, useSelectionProps } from "./annotation.js";
9
11
  import { AnnotationDraftMenu, AnnotationMenu } from "./annotation-menu.js";
10
- import { LinkLayer, useLink } from "./link.js";
12
+ import { LinkLayer, openLinkTarget, useLink } from "./link.js";
11
13
  import { useViews } from "./views.js";
12
14
  import { usePageEditor } from "./page-edit.js";
13
15
  import { useMetadata } from "./metadata.js";
@@ -34,4 +36,4 @@ export * from "@embedpdf/plugin-stamp";
34
36
  export * from "@embedpdf/plugin-commands";
35
37
  export * from "@embedpdf/plugin-shell";
36
38
  export * from "@embedpdf/core-ui";
37
- export { AnnotationDraftMenu, AnnotationLayer, AnnotationMenu, DocumentGate, DocumentScope, EmbedPDF, FormLayer, LinkLayer, PageAnnotationDraftMenu, PageAnnotationMenu, PagePointerSource, PageProvider, PageView, RenderLayer, Scrollbar, SearchLayer, SelectionLayer, Stage, TileLayer, Toolbar, Viewer, createClickCounter, filePickerProvider, isMacPlatform, makePageContext, sameAnchor, sameCreationDraftAnchor, shallowArray, useActiveDocumentId, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useArmStampAsset, useCapability, useCommand, useCommandShortcuts, useCommands, useDocumentId, useDocumentStatus, useDocuments, useFilePickerProvider, useForm, useFormField, useFormScriptingProvider, useI18n, useKernel, useKernelValue, useLayout, useLink, useLocale, useMenus, useMetadata, useOptionalCapability, useOptionalSelector, usePage, usePageEditor, usePageList, usePages, usePendingRedactions, useRedaction, useScrollMetrics, useSearch, useSearchState, useSelection, useSelectionFlags, useSelectionProps, useSelector, useShell, useStage, useStageSettings, useStamp, useStampAssetPreviewUrl, useStampAssets, useStampLibraries, useStripView, useSurface, useT, useTool, useToolCursor, useViews, useZoom };
39
+ export { Anchored, AnnotationDraftMenu, AnnotationLayer, AnnotationMenu, DocumentGate, DocumentScope, EmbedPDF, FormLayer, LinkLayer, PagePointerSource, PageProvider, PageView, ProjectorProvider, RenderLayer, Scrollbar, SearchLayer, SelectionClipboard, SelectionHandles, SelectionLayer, SelectionMenu, Stage, Toolbar, Viewer, copySelection, createClickCounter, enrichCommentThreads, filePickerProvider, isMacPlatform, makePageContext, openLinkTarget, sameAnchor, sameCreationDraftAnchor, shallowArray, useActiveDocumentId, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useArmStampAsset, useCapability, useCommand, useCommandShortcuts, useCommands, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useDocumentId, useDocumentStatus, useDocuments, useFilePickerProvider, useForm, useFormField, useFormScriptingProvider, useI18n, useKernel, useKernelValue, useLayout, useLink, useLocale, useMenus, useMetadata, useOptionalCapability, useOptionalSelector, usePage, usePageEditor, usePageList, usePages, usePendingRedactions, useProjectorBinding, useRedaction, useScrollMetrics, useSearch, useSearchState, useSelection, useSelectionFlags, useSelectionProps, useSelector, useShell, useStage, useStageSettings, useStamp, useStampAssetPreviewUrl, useStampAssets, useStampLibraries, useStripView, useSurface, useT, useTool, useToolCursor, useViews, useZoom, vibrationFeedback, wkFeedback };
@@ -4,8 +4,8 @@ const require_runtime = require("./runtime.cjs");
4
4
  let react_jsx_runtime = require("react/jsx-runtime");
5
5
  let react = require("react");
6
6
  react = require_rolldown_runtime.__toESM(react, 1);
7
- let _embedpdf_plugin_interaction = require("@embedpdf/plugin-interaction");
8
7
  let _embedpdf_web = require("@embedpdf/web");
8
+ let _embedpdf_plugin_interaction = require("@embedpdf/plugin-interaction");
9
9
  //#region src/interaction.tsx
10
10
  const mods = (e) => ({
11
11
  shift: e.shiftKey,
@@ -50,14 +50,15 @@ function PagePointerSource() {
50
50
  },
51
51
  page: {
52
52
  pon: page.pon,
53
- point: page.toPagePoint(e.clientX, e.clientY),
53
+ point: page.toContentPoint(e.clientX, e.clientY),
54
54
  scale: page.transform.viewScale,
55
55
  rotation: page.transform.rotation,
56
56
  zoom: page.transform.zoom
57
57
  },
58
- project: (pon) => pon === page.pon ? page.toPagePoint(e.clientX, e.clientY) : null,
58
+ project: (pon) => pon === page.pon ? page.toContentPoint(e.clientX, e.clientY) : null,
59
59
  modifiers: mods(e),
60
- clickCount
60
+ clickCount,
61
+ pointerType: e.pointerType || "mouse"
61
62
  };
62
63
  };
63
64
  let dragging = false;
@@ -140,6 +141,18 @@ exports.PagePointerSource = PagePointerSource;
140
141
  exports.createClickCounter = createClickCounter;
141
142
  exports.useTool = useTool;
142
143
  exports.useToolCursor = useToolCursor;
144
+ Object.defineProperty(exports, "vibrationFeedback", {
145
+ enumerable: true,
146
+ get: function() {
147
+ return _embedpdf_web.vibrationFeedback;
148
+ }
149
+ });
150
+ Object.defineProperty(exports, "wkFeedback", {
151
+ enumerable: true,
152
+ get: function() {
153
+ return _embedpdf_web.wkFeedback;
154
+ }
155
+ });
143
156
  Object.keys(_embedpdf_plugin_interaction).forEach(function(k) {
144
157
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
145
158
  enumerable: true,
@@ -1 +1 @@
1
- {"version":3,"file":"interaction.cjs","names":["usePage","useCapability","InteractionToken","useSelector"],"sources":["../src/interaction.tsx"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-interaction.\n *\n * <PagePointerSource> is the ONE pointer listener per page: it converts events to\n * page space via PageContext.toPagePoint and forwards normalized samples to the\n * hub. It binds only to the page context, so it works identically inside a\n * virtualized <Stage> page and a standalone <PageView>. Features never attach\n * their own pointer listeners — they register handlers with the hub.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-interaction';\nimport * as React from 'react';\nimport { useEffect, useRef } from 'react';\nimport { InteractionToken } from '@embedpdf/plugin-interaction';\nimport type { Modifiers, PointerSample } from '@embedpdf/plugin-interaction';\nimport { svgCursor } from '@embedpdf/web';\nimport type { SvgCursorOptions } from '@embedpdf/web';\nimport { useCapability, usePage, useSelector } from './runtime';\n\nconst mods = (e: PointerEvent): Modifiers => ({\n shift: e.shiftKey,\n alt: e.altKey,\n ctrl: e.ctrlKey,\n meta: e.metaKey,\n});\n\n/**\n * Robust multi-click counter. `pointerdown.detail` is 0/1 in several browsers, so\n * we count clicks ourselves from timing + proximity — the standard double/triple\n * detection. Input normalization belongs in the adapter; the hub/handlers stay pure.\n */\nexport function createClickCounter(maxGapMs = 400, maxDistPx = 6) {\n let last = 0;\n let lx = 0;\n let ly = 0;\n let count = 0;\n return (now: number, x: number, y: number): number => {\n count = now - last <= maxGapMs && Math.hypot(x - lx, y - ly) <= maxDistPx ? count + 1 : 1;\n last = now;\n lx = x;\n ly = y;\n return count;\n };\n}\n\nexport function PagePointerSource() {\n const page = usePage();\n const interaction = useCapability(InteractionToken);\n const cursor = useSelector(InteractionToken, (c) => c.cursor());\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n const clicks = createClickCounter();\n const sample = (\n phase: PointerSample['phase'],\n e: PointerEvent,\n clickCount = 1,\n ): PointerSample => {\n const r = el.getBoundingClientRect();\n return {\n phase,\n viewport: { x: e.clientX - r.left, y: e.clientY - r.top },\n // `scale`/`rotation`/`zoom` carry the same per-page environmental\n // context the Stage source resolves via `pageAt` — read off the page\n // transform so a standalone <PageView> drives handlers identically.\n page: {\n pon: page.pon,\n point: page.toPagePoint(e.clientX, e.clientY),\n scale: page.transform.viewScale,\n rotation: page.transform.rotation,\n zoom: page.transform.zoom,\n },\n // A per-page source can only project onto its OWN page — toPagePoint is\n // already unclamped (the drag listener lives on window), so a gesture\n // anchored here keeps tracking past the page bounds.\n project: (pon) => (pon === page.pon ? page.toPagePoint(e.clientX, e.clientY) : null),\n modifiers: mods(e),\n clickCount,\n };\n };\n let dragging = false;\n\n const down = (e: PointerEvent) => {\n if (e.button !== 0) return;\n dragging = true;\n interaction.dispatch(sample('down', e, clicks(Date.now(), e.clientX, e.clientY)));\n };\n // hover (no gesture): drive cursor feedback only — fires from the element\n const hover = (e: PointerEvent) => {\n if (dragging) return;\n interaction.dispatch(sample('move', e));\n };\n // active drag: track on window so it survives leaving the page bounds\n const drag = (e: PointerEvent) => {\n if (!dragging) return;\n interaction.dispatch(sample('move', e));\n };\n const up = (e: PointerEvent) => {\n if (!dragging) return;\n dragging = false;\n interaction.dispatch(sample('up', e));\n };\n\n el.addEventListener('pointerdown', down);\n el.addEventListener('pointermove', hover);\n window.addEventListener('pointermove', drag);\n window.addEventListener('pointerup', up);\n return () => {\n el.removeEventListener('pointerdown', down);\n el.removeEventListener('pointermove', hover);\n window.removeEventListener('pointermove', drag);\n window.removeEventListener('pointerup', up);\n };\n }, [interaction, page]);\n\n // Sits on top as the page's event surface; visual layers below use pointerEvents:none.\n return <div ref={ref} style={{ position: 'absolute', inset: 0, cursor, touchAction: 'none' }} />;\n}\n\n/** Read + switch the active tool (for a toolbar). */\nexport function useTool() {\n const interaction = useCapability(InteractionToken);\n const activeToolId = useSelector(InteractionToken, (c) => c.activeToolId());\n return {\n activeToolId,\n activate: interaction.activateTool,\n tools: interaction.tools(),\n };\n}\n\n/** One cursor slot: an SVG image ({@link SvgCursorOptions}) or a plain CSS\n * cursor string ('crosshair', 'url(…) 4 4, copy'). */\nexport type ToolCursorImage = SvgCursorOptions | string;\n\n/** What {@link useToolCursor} installs: the tool to reskin + its keyword map.\n * Apps build `svg` from the SAME icon their toolbar renders, so the cursor\n * and the button can never drift apart. */\nexport interface ToolCursorSpec {\n toolId: string;\n /** keyword → cursor: restyle the keywords this tool can show — its declared\n * base ('crosshair', 'copy') and hover claims ('text' over text) — in the\n * tool's identity. Keywords the map omits render as-is: a markup tool's\n * 'default' base stays the bare arrow, a foreign 'move' claim drops the\n * icon. An SVG value defaults its keyword `fallback` to the keyword it\n * replaces. */\n cursors: Record<string, ToolCursorImage>;\n}\n\nconst toCursor = (img: ToolCursorImage, fallback?: string): string =>\n typeof img === 'string'\n ? img\n : svgCursor(img.fallback === undefined && fallback ? { ...img, fallback } : img);\n\n/**\n * Give a tool IMAGE cursors — the armed-tool indicator. The cursor is the only\n * zero-latency pointer-locked pixel the platform has, and the hub already\n * arbitrates it: unmapped hover claims beat it over annotations/text, page\n * gaps fall back to the tool's `gapCursor`, and other UI (menus, form fill\n * controls) carries its own CSS cursor — so nothing chases the pointer in\n * DOM. `null` installs nothing. A re-render with new content rebuilds the\n * cursor (live recolor from tool defaults); unmount restores the tool's\n * declared cursors.\n */\nexport function useToolCursor(spec: ToolCursorSpec | null): void {\n const interaction = useCapability(InteractionToken);\n // Key the effect by VALUE: specs are built inline in render, and a\n // fresh-but-identical object must not thrash the skin.\n const key = spec && JSON.stringify(spec);\n const ref = useRef(spec);\n ref.current = spec;\n useEffect(() => {\n const s = ref.current;\n if (!s) return;\n interaction.setToolCursor(\n s.toolId,\n Object.fromEntries(Object.entries(s.cursors).map(([k, v]) => [k, toCursor(v, k)])),\n );\n return () => interaction.setToolCursor(s.toolId, null);\n }, [interaction, key]);\n}\n"],"mappings":";;;;;;;;;AAoBA,MAAM,QAAQ,OAAgC;CAC5C,OAAO,EAAE;CACT,KAAK,EAAE;CACP,MAAM,EAAE;CACR,MAAM,EAAE;AACV;;;;;;AAOA,SAAgB,mBAAmB,WAAW,KAAK,YAAY,GAAG;CAChE,IAAI,OAAO;CACX,IAAI,KAAK;CACT,IAAI,KAAK;CACT,IAAI,QAAQ;CACZ,QAAQ,KAAa,GAAW,MAAsB;EACpD,QAAQ,MAAM,QAAQ,YAAY,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,KAAK,YAAY,QAAQ,IAAI;EACxF,OAAO;EACP,KAAK;EACL,KAAK;EACL,OAAO;CACT;AACF;AAEA,SAAgB,oBAAoB;CAClC,MAAM,OAAOA,gBAAAA,QAAQ;CACrB,MAAM,cAAcC,gBAAAA,cAAcC,6BAAAA,gBAAgB;CAClD,MAAM,SAASC,gBAAAA,YAAYD,6BAAAA,mBAAmB,MAAM,EAAE,OAAO,CAAC;CAC9D,MAAM,OAAA,GAAA,MAAA,OAAA,CAA6B,IAAI;CAEvC,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,IAAI;EACT,MAAM,SAAS,mBAAmB;EAClC,MAAM,UACJ,OACA,GACA,aAAa,MACK;GAClB,MAAM,IAAI,GAAG,sBAAsB;GACnC,OAAO;IACL;IACA,UAAU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AY,OAAO;GAAG;GAAQ,aAAa;EAAO;CAAI,CAAA;AACjG;;AAGA,SAAgB,UAAU;CACxB,MAAM,cAAcD,gBAAAA,cAAcC,6BAAAA,gBAAgB;CAElD,OAAO;EACL,cAFmBC,gBAAAA,YAAYD,6BAAAA,mBAAmB,MAAM,EAAE,aAAa,CAE5D;EACX,UAAU,YAAY;EACtB,OAAO,YAAY,MAAM;CAC3B;AACF;AAoBA,MAAM,YAAY,KAAsB,aACtC,OAAO,QAAQ,WACX,OAAA,GAAA,cAAA,UAAA,CACU,IAAI,aAAa,KAAA,KAAa,WAAW;CAAE,GAAG;CAAK;AAAS,IAAI,GAAG;;;;;;;;;;;AAYnF,SAAgB,cAAc,MAAmC;CAC/D,MAAM,cAAcD,gBAAAA,cAAcC,6BAAAA,gBAAgB;CAGlD,MAAM,MAAM,QAAQ,KAAK,UAAU,IAAI;CACvC,MAAM,OAAA,GAAA,MAAA,OAAA,CAAa,IAAI;CACvB,IAAI,UAAU;CACd,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,MAAM,IAAI,IAAI;EACd,IAAI,CAAC,GAAG;EACR,YAAY,cACV,EAAE,QACF,OAAO,YAAY,OAAO,QAAQ,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CACnF;EACA,aAAa,YAAY,cAAc,EAAE,QAAQ,IAAI;CACvD,GAAG,CAAC,aAAa,GAAG,CAAC;AACvB"}
1
+ {"version":3,"file":"interaction.cjs","names":["usePage","useCapability","InteractionToken","useSelector"],"sources":["../src/interaction.tsx"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-interaction.\n *\n * <PagePointerSource> is the ONE pointer listener per page: it converts events to\n * page space via PageContext.toContentPoint and forwards normalized samples to the\n * hub. It binds only to the page context, so it works identically inside a\n * virtualized <Stage> page and a standalone <PageView>. Features never attach\n * their own pointer listeners — they register handlers with the hub.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-interaction';\n// The browser feedback providers live in @embedpdf/web (the plugin is\n// DOM-free); re-exported here so app code has one import for the feature.\nexport { vibrationFeedback, wkFeedback } from '@embedpdf/web';\nimport * as React from 'react';\nimport { useEffect, useRef } from 'react';\nimport { InteractionToken } from '@embedpdf/plugin-interaction';\nimport type { Modifiers, PointerSample } from '@embedpdf/plugin-interaction';\nimport { svgCursor } from '@embedpdf/web';\nimport type { SvgCursorOptions } from '@embedpdf/web';\nimport { useCapability, usePage, useSelector } from './runtime';\n\nconst mods = (e: PointerEvent): Modifiers => ({\n shift: e.shiftKey,\n alt: e.altKey,\n ctrl: e.ctrlKey,\n meta: e.metaKey,\n});\n\n/**\n * Robust multi-click counter. `pointerdown.detail` is 0/1 in several browsers, so\n * we count clicks ourselves from timing + proximity — the standard double/triple\n * detection. Input normalization belongs in the adapter; the hub/handlers stay pure.\n */\nexport function createClickCounter(maxGapMs = 400, maxDistPx = 6) {\n let last = 0;\n let lx = 0;\n let ly = 0;\n let count = 0;\n return (now: number, x: number, y: number): number => {\n count = now - last <= maxGapMs && Math.hypot(x - lx, y - ly) <= maxDistPx ? count + 1 : 1;\n last = now;\n lx = x;\n ly = y;\n return count;\n };\n}\n\nexport function PagePointerSource() {\n const page = usePage();\n const interaction = useCapability(InteractionToken);\n const cursor = useSelector(InteractionToken, (c) => c.cursor());\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n const clicks = createClickCounter();\n const sample = (\n phase: PointerSample['phase'],\n e: PointerEvent,\n clickCount = 1,\n ): PointerSample => {\n const r = el.getBoundingClientRect();\n return {\n phase,\n viewport: { x: e.clientX - r.left, y: e.clientY - r.top },\n // `scale`/`rotation`/`zoom` carry the same per-page environmental\n // context the Stage source resolves via `pageAt` — read off the page\n // transform so a standalone <PageView> drives handlers identically.\n page: {\n pon: page.pon,\n point: page.toContentPoint(e.clientX, e.clientY),\n scale: page.transform.viewScale,\n rotation: page.transform.rotation,\n zoom: page.transform.zoom,\n },\n // A per-page source can only project onto its OWN page — toContentPoint is\n // already unclamped (the drag listener lives on window), so a gesture\n // anchored here keeps tracking past the page bounds.\n project: (pon) => (pon === page.pon ? page.toContentPoint(e.clientX, e.clientY) : null),\n modifiers: mods(e),\n clickCount,\n pointerType: (e.pointerType || 'mouse') as PointerSample['pointerType'],\n };\n };\n let dragging = false;\n\n const down = (e: PointerEvent) => {\n if (e.button !== 0) return;\n dragging = true;\n interaction.dispatch(sample('down', e, clicks(Date.now(), e.clientX, e.clientY)));\n };\n // hover (no gesture): drive cursor feedback only — fires from the element\n const hover = (e: PointerEvent) => {\n if (dragging) return;\n interaction.dispatch(sample('move', e));\n };\n // active drag: track on window so it survives leaving the page bounds\n const drag = (e: PointerEvent) => {\n if (!dragging) return;\n interaction.dispatch(sample('move', e));\n };\n const up = (e: PointerEvent) => {\n if (!dragging) return;\n dragging = false;\n interaction.dispatch(sample('up', e));\n };\n\n el.addEventListener('pointerdown', down);\n el.addEventListener('pointermove', hover);\n window.addEventListener('pointermove', drag);\n window.addEventListener('pointerup', up);\n return () => {\n el.removeEventListener('pointerdown', down);\n el.removeEventListener('pointermove', hover);\n window.removeEventListener('pointermove', drag);\n window.removeEventListener('pointerup', up);\n };\n }, [interaction, page]);\n\n // Sits on top as the page's event surface; visual layers below use pointerEvents:none.\n return <div ref={ref} style={{ position: 'absolute', inset: 0, cursor, touchAction: 'none' }} />;\n}\n\n/** Read + switch the active tool (for a toolbar). */\nexport function useTool() {\n const interaction = useCapability(InteractionToken);\n const activeToolId = useSelector(InteractionToken, (c) => c.activeToolId());\n return {\n activeToolId,\n activate: interaction.activateTool,\n tools: interaction.tools(),\n };\n}\n\n/** One cursor slot: an SVG image ({@link SvgCursorOptions}) or a plain CSS\n * cursor string ('crosshair', 'url(…) 4 4, copy'). */\nexport type ToolCursorImage = SvgCursorOptions | string;\n\n/** What {@link useToolCursor} installs: the tool to reskin + its keyword map.\n * Apps build `svg` from the SAME icon their toolbar renders, so the cursor\n * and the button can never drift apart. */\nexport interface ToolCursorSpec {\n toolId: string;\n /** keyword → cursor: restyle the keywords this tool can show — its declared\n * base ('crosshair', 'copy') and hover claims ('text' over text) — in the\n * tool's identity. Keywords the map omits render as-is: a markup tool's\n * 'default' base stays the bare arrow, a foreign 'move' claim drops the\n * icon. An SVG value defaults its keyword `fallback` to the keyword it\n * replaces. */\n cursors: Record<string, ToolCursorImage>;\n}\n\nconst toCursor = (img: ToolCursorImage, fallback?: string): string =>\n typeof img === 'string'\n ? img\n : svgCursor(img.fallback === undefined && fallback ? { ...img, fallback } : img);\n\n/**\n * Give a tool IMAGE cursors — the armed-tool indicator. The cursor is the only\n * zero-latency pointer-locked pixel the platform has, and the hub already\n * arbitrates it: unmapped hover claims beat it over annotations/text, page\n * gaps fall back to the tool's `gapCursor`, and other UI (menus, form fill\n * controls) carries its own CSS cursor — so nothing chases the pointer in\n * DOM. `null` installs nothing. A re-render with new content rebuilds the\n * cursor (live recolor from tool defaults); unmount restores the tool's\n * declared cursors.\n */\nexport function useToolCursor(spec: ToolCursorSpec | null): void {\n const interaction = useCapability(InteractionToken);\n // Key the effect by VALUE: specs are built inline in render, and a\n // fresh-but-identical object must not thrash the skin.\n const key = spec && JSON.stringify(spec);\n const ref = useRef(spec);\n ref.current = spec;\n useEffect(() => {\n const s = ref.current;\n if (!s) return;\n interaction.setToolCursor(\n s.toolId,\n Object.fromEntries(Object.entries(s.cursors).map(([k, v]) => [k, toCursor(v, k)])),\n );\n return () => interaction.setToolCursor(s.toolId, null);\n }, [interaction, key]);\n}\n"],"mappings":";;;;;;;;;AAuBA,MAAM,QAAQ,OAAgC;CAC5C,OAAO,EAAE;CACT,KAAK,EAAE;CACP,MAAM,EAAE;CACR,MAAM,EAAE;AACV;;;;;;AAOA,SAAgB,mBAAmB,WAAW,KAAK,YAAY,GAAG;CAChE,IAAI,OAAO;CACX,IAAI,KAAK;CACT,IAAI,KAAK;CACT,IAAI,QAAQ;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AI;CACvB,IAAI,UAAU;CACd,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,MAAM,IAAI,IAAI;EACd,IAAI,CAAC,GAAG;EACR,YAAY,cACV,EAAE,QACF,OAAO,YAAY,OAAO,QAAQ,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CACnF;EACA,aAAa,YAAY,cAAc,EAAE,QAAQ,IAAI;CACvD,GAAG,CAAC,aAAa,GAAG,CAAC;AACvB"}
@@ -1,4 +1,4 @@
1
- import { SvgCursorOptions } from "@embedpdf/web";
1
+ import { SvgCursorOptions, vibrationFeedback, wkFeedback } from "@embedpdf/web";
2
2
  export * from "@embedpdf/plugin-interaction";
3
3
  //#region src/interaction.d.ts
4
4
  /**
@@ -42,5 +42,5 @@ interface ToolCursorSpec {
42
42
  */
43
43
  declare function useToolCursor(spec: ToolCursorSpec | null): void;
44
44
  //#endregion
45
- export { PagePointerSource, ToolCursorImage, ToolCursorSpec, createClickCounter, useTool, useToolCursor };
45
+ export { PagePointerSource, ToolCursorImage, ToolCursorSpec, createClickCounter, useTool, useToolCursor, vibrationFeedback, wkFeedback };
46
46
  //# sourceMappingURL=interaction.d.cts.map
@@ -1,4 +1,4 @@
1
- import { SvgCursorOptions } from "@embedpdf/web";
1
+ import { SvgCursorOptions, vibrationFeedback, wkFeedback } from "@embedpdf/web";
2
2
  export * from "@embedpdf/plugin-interaction";
3
3
  //#region src/interaction.d.ts
4
4
  /**
@@ -42,5 +42,5 @@ interface ToolCursorSpec {
42
42
  */
43
43
  declare function useToolCursor(spec: ToolCursorSpec | null): void;
44
44
  //#endregion
45
- export { PagePointerSource, ToolCursorImage, ToolCursorSpec, createClickCounter, useTool, useToolCursor };
45
+ export { PagePointerSource, ToolCursorImage, ToolCursorSpec, createClickCounter, useTool, useToolCursor, vibrationFeedback, wkFeedback };
46
46
  //# sourceMappingURL=interaction.d.ts.map
@@ -1,8 +1,9 @@
1
+ import "./rolldown-runtime-BBjsoOtd.js";
1
2
  import { useCapability, usePage, useSelector } from "./runtime.js";
2
3
  import { jsx } from "react/jsx-runtime";
3
4
  import { useEffect, useRef } from "react";
5
+ import { svgCursor, vibrationFeedback, wkFeedback } from "@embedpdf/web";
4
6
  import { InteractionToken } from "@embedpdf/plugin-interaction";
5
- import { svgCursor } from "@embedpdf/web";
6
7
  export * from "@embedpdf/plugin-interaction";
7
8
  //#region src/interaction.tsx
8
9
  const mods = (e) => ({
@@ -48,14 +49,15 @@ function PagePointerSource() {
48
49
  },
49
50
  page: {
50
51
  pon: page.pon,
51
- point: page.toPagePoint(e.clientX, e.clientY),
52
+ point: page.toContentPoint(e.clientX, e.clientY),
52
53
  scale: page.transform.viewScale,
53
54
  rotation: page.transform.rotation,
54
55
  zoom: page.transform.zoom
55
56
  },
56
- project: (pon) => pon === page.pon ? page.toPagePoint(e.clientX, e.clientY) : null,
57
+ project: (pon) => pon === page.pon ? page.toContentPoint(e.clientX, e.clientY) : null,
57
58
  modifiers: mods(e),
58
- clickCount
59
+ clickCount,
60
+ pointerType: e.pointerType || "mouse"
59
61
  };
60
62
  };
61
63
  let dragging = false;
@@ -134,6 +136,6 @@ function useToolCursor(spec) {
134
136
  }, [interaction, key]);
135
137
  }
136
138
  //#endregion
137
- export { PagePointerSource, createClickCounter, useTool, useToolCursor };
139
+ export { PagePointerSource, createClickCounter, useTool, useToolCursor, vibrationFeedback, wkFeedback };
138
140
 
139
141
  //# sourceMappingURL=interaction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interaction.js","names":[],"sources":["../src/interaction.tsx"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-interaction.\n *\n * <PagePointerSource> is the ONE pointer listener per page: it converts events to\n * page space via PageContext.toPagePoint and forwards normalized samples to the\n * hub. It binds only to the page context, so it works identically inside a\n * virtualized <Stage> page and a standalone <PageView>. Features never attach\n * their own pointer listeners — they register handlers with the hub.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-interaction';\nimport * as React from 'react';\nimport { useEffect, useRef } from 'react';\nimport { InteractionToken } from '@embedpdf/plugin-interaction';\nimport type { Modifiers, PointerSample } from '@embedpdf/plugin-interaction';\nimport { svgCursor } from '@embedpdf/web';\nimport type { SvgCursorOptions } from '@embedpdf/web';\nimport { useCapability, usePage, useSelector } from './runtime';\n\nconst mods = (e: PointerEvent): Modifiers => ({\n shift: e.shiftKey,\n alt: e.altKey,\n ctrl: e.ctrlKey,\n meta: e.metaKey,\n});\n\n/**\n * Robust multi-click counter. `pointerdown.detail` is 0/1 in several browsers, so\n * we count clicks ourselves from timing + proximity — the standard double/triple\n * detection. Input normalization belongs in the adapter; the hub/handlers stay pure.\n */\nexport function createClickCounter(maxGapMs = 400, maxDistPx = 6) {\n let last = 0;\n let lx = 0;\n let ly = 0;\n let count = 0;\n return (now: number, x: number, y: number): number => {\n count = now - last <= maxGapMs && Math.hypot(x - lx, y - ly) <= maxDistPx ? count + 1 : 1;\n last = now;\n lx = x;\n ly = y;\n return count;\n };\n}\n\nexport function PagePointerSource() {\n const page = usePage();\n const interaction = useCapability(InteractionToken);\n const cursor = useSelector(InteractionToken, (c) => c.cursor());\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n const clicks = createClickCounter();\n const sample = (\n phase: PointerSample['phase'],\n e: PointerEvent,\n clickCount = 1,\n ): PointerSample => {\n const r = el.getBoundingClientRect();\n return {\n phase,\n viewport: { x: e.clientX - r.left, y: e.clientY - r.top },\n // `scale`/`rotation`/`zoom` carry the same per-page environmental\n // context the Stage source resolves via `pageAt` — read off the page\n // transform so a standalone <PageView> drives handlers identically.\n page: {\n pon: page.pon,\n point: page.toPagePoint(e.clientX, e.clientY),\n scale: page.transform.viewScale,\n rotation: page.transform.rotation,\n zoom: page.transform.zoom,\n },\n // A per-page source can only project onto its OWN page — toPagePoint is\n // already unclamped (the drag listener lives on window), so a gesture\n // anchored here keeps tracking past the page bounds.\n project: (pon) => (pon === page.pon ? page.toPagePoint(e.clientX, e.clientY) : null),\n modifiers: mods(e),\n clickCount,\n };\n };\n let dragging = false;\n\n const down = (e: PointerEvent) => {\n if (e.button !== 0) return;\n dragging = true;\n interaction.dispatch(sample('down', e, clicks(Date.now(), e.clientX, e.clientY)));\n };\n // hover (no gesture): drive cursor feedback only — fires from the element\n const hover = (e: PointerEvent) => {\n if (dragging) return;\n interaction.dispatch(sample('move', e));\n };\n // active drag: track on window so it survives leaving the page bounds\n const drag = (e: PointerEvent) => {\n if (!dragging) return;\n interaction.dispatch(sample('move', e));\n };\n const up = (e: PointerEvent) => {\n if (!dragging) return;\n dragging = false;\n interaction.dispatch(sample('up', e));\n };\n\n el.addEventListener('pointerdown', down);\n el.addEventListener('pointermove', hover);\n window.addEventListener('pointermove', drag);\n window.addEventListener('pointerup', up);\n return () => {\n el.removeEventListener('pointerdown', down);\n el.removeEventListener('pointermove', hover);\n window.removeEventListener('pointermove', drag);\n window.removeEventListener('pointerup', up);\n };\n }, [interaction, page]);\n\n // Sits on top as the page's event surface; visual layers below use pointerEvents:none.\n return <div ref={ref} style={{ position: 'absolute', inset: 0, cursor, touchAction: 'none' }} />;\n}\n\n/** Read + switch the active tool (for a toolbar). */\nexport function useTool() {\n const interaction = useCapability(InteractionToken);\n const activeToolId = useSelector(InteractionToken, (c) => c.activeToolId());\n return {\n activeToolId,\n activate: interaction.activateTool,\n tools: interaction.tools(),\n };\n}\n\n/** One cursor slot: an SVG image ({@link SvgCursorOptions}) or a plain CSS\n * cursor string ('crosshair', 'url(…) 4 4, copy'). */\nexport type ToolCursorImage = SvgCursorOptions | string;\n\n/** What {@link useToolCursor} installs: the tool to reskin + its keyword map.\n * Apps build `svg` from the SAME icon their toolbar renders, so the cursor\n * and the button can never drift apart. */\nexport interface ToolCursorSpec {\n toolId: string;\n /** keyword → cursor: restyle the keywords this tool can show — its declared\n * base ('crosshair', 'copy') and hover claims ('text' over text) — in the\n * tool's identity. Keywords the map omits render as-is: a markup tool's\n * 'default' base stays the bare arrow, a foreign 'move' claim drops the\n * icon. An SVG value defaults its keyword `fallback` to the keyword it\n * replaces. */\n cursors: Record<string, ToolCursorImage>;\n}\n\nconst toCursor = (img: ToolCursorImage, fallback?: string): string =>\n typeof img === 'string'\n ? img\n : svgCursor(img.fallback === undefined && fallback ? { ...img, fallback } : img);\n\n/**\n * Give a tool IMAGE cursors — the armed-tool indicator. The cursor is the only\n * zero-latency pointer-locked pixel the platform has, and the hub already\n * arbitrates it: unmapped hover claims beat it over annotations/text, page\n * gaps fall back to the tool's `gapCursor`, and other UI (menus, form fill\n * controls) carries its own CSS cursor — so nothing chases the pointer in\n * DOM. `null` installs nothing. A re-render with new content rebuilds the\n * cursor (live recolor from tool defaults); unmount restores the tool's\n * declared cursors.\n */\nexport function useToolCursor(spec: ToolCursorSpec | null): void {\n const interaction = useCapability(InteractionToken);\n // Key the effect by VALUE: specs are built inline in render, and a\n // fresh-but-identical object must not thrash the skin.\n const key = spec && JSON.stringify(spec);\n const ref = useRef(spec);\n ref.current = spec;\n useEffect(() => {\n const s = ref.current;\n if (!s) return;\n interaction.setToolCursor(\n s.toolId,\n Object.fromEntries(Object.entries(s.cursors).map(([k, v]) => [k, toCursor(v, k)])),\n );\n return () => interaction.setToolCursor(s.toolId, null);\n }, [interaction, key]);\n}\n"],"mappings":";;;;;;;AAoBA,MAAM,QAAQ,OAAgC;CAC5C,OAAO,EAAE;CACT,KAAK,EAAE;CACP,MAAM,EAAE;CACR,MAAM,EAAE;AACV;;;;;;AAOA,SAAgB,mBAAmB,WAAW,KAAK,YAAY,GAAG;CAChE,IAAI,OAAO;CACX,IAAI,KAAK;CACT,IAAI,KAAK;CACT,IAAI,QAAQ;CACZ,QAAQ,KAAa,GAAW,MAAsB;EACpD,QAAQ,MAAM,QAAQ,YAAY,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,KAAK,YAAY,QAAQ,IAAI;EACxF,OAAO;EACP,K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cesContent":["/**\n * The React surface for @embedpdf/plugin-interaction.\n *\n * <PagePointerSource> is the ONE pointer listener per page: it converts events to\n * page space via PageContext.toContentPoint and forwards normalized samples to the\n * hub. It binds only to the page context, so it works identically inside a\n * virtualized <Stage> page and a standalone <PageView>. Features never attach\n * their own pointer listeners — they register handlers with the hub.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-interaction';\n// The browser feedback providers live in @embedpdf/web (the plugin is\n// DOM-free); re-exported here so app code has one import for the feature.\nexport { vibrationFeedback, wkFeedback } from '@embedpdf/web';\nimport * as React from 'react';\nimport { useEffect, useRef } from 'react';\nimport { InteractionToken } from '@embedpdf/plugin-interaction';\nimport type { Modifiers, PointerSample } from '@embedpdf/plugin-interaction';\nimport { svgCursor } from '@embedpdf/web';\nimport type { SvgCursorOptions } from '@embedpdf/web';\nimport { useCapability, usePage, useSelector } from './runtime';\n\nconst mods = (e: PointerEvent): Modifiers => ({\n shift: e.shiftKey,\n alt: e.altKey,\n ctrl: e.ctrlKey,\n meta: e.metaKey,\n});\n\n/**\n * Robust multi-click counter. `pointerdown.detail` is 0/1 in several browsers, so\n * we count clicks ourselves from timing + proximity — the standard double/triple\n * detection. Input normalization belongs in the adapter; the hub/handlers stay pure.\n */\nexport function createClickCounter(maxGapMs = 400, maxDistPx = 6) {\n let last = 0;\n let lx = 0;\n let ly = 0;\n let count = 0;\n return (now: number, x: number, y: number): number => {\n count = now - last <= maxGapMs && Math.hypot(x - lx, y - ly) <= maxDistPx ? count + 1 : 1;\n last = now;\n lx = x;\n ly = y;\n return count;\n };\n}\n\nexport function PagePointerSource() {\n const page = usePage();\n const interaction = useCapability(InteractionToken);\n const cursor = useSelector(InteractionToken, (c) => c.cursor());\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n const clicks = createClickCounter();\n const sample = (\n phase: PointerSample['phase'],\n e: PointerEvent,\n clickCount = 1,\n ): PointerSample => {\n const r = el.getBoundingClientRect();\n return {\n phase,\n viewport: { x: e.clientX - r.left, y: e.clientY - r.top },\n // `scale`/`rotation`/`zoom` carry the same per-page environmental\n // context the Stage source resolves via `pageAt` — read off the page\n // transform so a standalone <PageView> drives handlers identically.\n page: {\n pon: page.pon,\n point: page.toContentPoint(e.clientX, e.clientY),\n scale: page.transform.viewScale,\n rotation: page.transform.rotation,\n zoom: page.transform.zoom,\n },\n // A per-page source can only project onto its OWN page — toContentPoint is\n // already unclamped (the drag listener lives on window), so a gesture\n // anchored here keeps tracking past the page bounds.\n project: (pon) => (pon === page.pon ? page.toContentPoint(e.clientX, e.clientY) : null),\n modifiers: mods(e),\n clickCount,\n pointerType: (e.pointerType || 'mouse') as PointerSample['pointerType'],\n };\n };\n let dragging = false;\n\n const down = (e: PointerEvent) => {\n if (e.button !== 0) return;\n dragging = true;\n interaction.dispatch(sample('down', e, clicks(Date.now(), e.clientX, e.clientY)));\n };\n // hover (no gesture): drive cursor feedback only — fires from the element\n const hover = (e: PointerEvent) => {\n if (dragging) return;\n interaction.dispatch(sample('move', e));\n };\n // active drag: track on window so it survives leaving the page bounds\n const drag = (e: PointerEvent) => {\n if (!dragging) return;\n interaction.dispatch(sample('move', e));\n };\n const up = (e: PointerEvent) => {\n if (!dragging) return;\n dragging = false;\n interaction.dispatch(sample('up', e));\n };\n\n el.addEventListener('pointerdown', down);\n el.addEventListener('pointermove', hover);\n window.addEventListener('pointermove', drag);\n window.addEventListener('pointerup', up);\n return () => {\n el.removeEventListener('pointerdown', down);\n el.removeEventListener('pointermove', hover);\n window.removeEventListener('pointermove', drag);\n window.removeEventListener('pointerup', up);\n };\n }, [interaction, page]);\n\n // Sits on top as the page's event surface; visual layers below use pointerEvents:none.\n return <div ref={ref} style={{ position: 'absolute', inset: 0, cursor, touchAction: 'none' }} />;\n}\n\n/** Read + switch the active tool (for a toolbar). */\nexport function useTool() {\n const interaction = useCapability(InteractionToken);\n const activeToolId = useSelector(InteractionToken, (c) => c.activeToolId());\n return {\n activeToolId,\n activate: interaction.activateTool,\n tools: interaction.tools(),\n };\n}\n\n/** One cursor slot: an SVG image ({@link SvgCursorOptions}) or a plain CSS\n * cursor string ('crosshair', 'url(…) 4 4, copy'). */\nexport type ToolCursorImage = SvgCursorOptions | string;\n\n/** What {@link useToolCursor} installs: the tool to reskin + its keyword map.\n * Apps build `svg` from the SAME icon their toolbar renders, so the cursor\n * and the button can never drift apart. */\nexport interface ToolCursorSpec {\n toolId: string;\n /** keyword → cursor: restyle the keywords this tool can show — its declared\n * base ('crosshair', 'copy') and hover claims ('text' over text) — in the\n * tool's identity. Keywords the map omits render as-is: a markup tool's\n * 'default' base stays the bare arrow, a foreign 'move' claim drops the\n * icon. An SVG value defaults its keyword `fallback` to the keyword it\n * replaces. */\n cursors: Record<string, ToolCursorImage>;\n}\n\nconst toCursor = (img: ToolCursorImage, fallback?: string): string =>\n typeof img === 'string'\n ? img\n : svgCursor(img.fallback === undefined && fallback ? { ...img, fallback } : img);\n\n/**\n * Give a tool IMAGE cursors — the armed-tool indicator. The cursor is the only\n * zero-latency pointer-locked pixel the platform has, and the hub already\n * arbitrates it: unmapped hover claims beat it over annotations/text, page\n * gaps fall back to the tool's `gapCursor`, and other UI (menus, form fill\n * controls) carries its own CSS cursor — so nothing chases the pointer in\n * DOM. `null` installs nothing. A re-render with new content rebuilds the\n * cursor (live recolor from tool defaults); unmount restores the tool's\n * declared cursors.\n */\nexport function useToolCursor(spec: ToolCursorSpec | null): void {\n const interaction = useCapability(InteractionToken);\n // Key the effect by VALUE: specs are built inline in render, and a\n // fresh-but-identical object must not thrash the skin.\n const key = spec && JSON.stringify(spec);\n const ref = useRef(spec);\n ref.current = spec;\n useEffect(() => {\n const s = ref.current;\n if (!s) return;\n interaction.setToolCursor(\n s.toolId,\n Object.fromEntries(Object.entries(s.cursors).map(([k, v]) => [k, toCursor(v, k)])),\n );\n return () => interaction.setToolCursor(s.toolId, null);\n }, [interaction, key]);\n}\n"],"mappings":";;;;;;;;AAuBA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M,OAAO,IAAI;CACvB,IAAI,UAAU;CACd,gBAAgB;EACd,MAAM,IAAI,IAAI;EACd,IAAI,CAAC,GAAG;EACR,YAAY,cACV,EAAE,QACF,OAAO,YAAY,OAAO,QAAQ,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CACnF;EACA,aAAa,YAAY,cAAc,EAAE,QAAQ,IAAI;CACvD,GAAG,CAAC,aAAa,GAAG,CAAC;AACvB"}
package/dist/link.cjs CHANGED
@@ -5,16 +5,33 @@ let react_jsx_runtime = require("react/jsx-runtime");
5
5
  let react = require("react");
6
6
  react = require_rolldown_runtime.__toESM(react, 1);
7
7
  let _embedpdf_web = require("@embedpdf/web");
8
+ let _embedpdf_plugin_interaction = require("@embedpdf/plugin-interaction");
8
9
  let _embedpdf_plugin_link = require("@embedpdf/plugin-link");
9
10
  //#region src/link.tsx
11
+ /**
12
+ * Resolve a target through the plugin and PERFORM the `uri` outcome — the ONE
13
+ * place in the codebase that turns a link target into a browser tab. The
14
+ * plugin owns resolution (goto → stage reveal, policy, analytics) and stays
15
+ * DOM-free; opening is this framework layer's job. Every click path — the nav
16
+ * anchors below, the selection menu's "Open link", the style editor's "Go to
17
+ * link" — goes through here, so none of them can drop the uri outcome again.
18
+ */
19
+ function openLinkTarget(link, target) {
20
+ const activation = link.activate(target);
21
+ if (activation.outcome === "uri") {
22
+ const href = (0, _embedpdf_web.sanitizeExternalUri)(activation.uri);
23
+ if (href && typeof window !== "undefined") window.open(href, "_blank", "noopener,noreferrer");
24
+ }
25
+ return activation;
26
+ }
10
27
  /** Content rect → view px (the page wrapper's own space) — the same idiom as
11
28
  * the annotation and form layers: never re-derive `x * scale`. */
12
29
  function boxOf(item, page) {
13
- const tl = page.transform.pageToContent({
30
+ const tl = page.transform.toPixels({
14
31
  x: item.rect.x,
15
32
  y: item.rect.y
16
33
  });
17
- const br = page.transform.pageToContent({
34
+ const br = page.transform.toPixels({
18
35
  x: item.rect.x + item.rect.width,
19
36
  y: item.rect.y + item.rect.height
20
37
  });
@@ -40,20 +57,24 @@ function LinkLayer({ renderLink } = {}) {
40
57
  const link = require_runtime.useCapability(_embedpdf_plugin_link.LinkToken);
41
58
  const items = require_runtime.useSelector(_embedpdf_plugin_link.LinkToken, (c) => c.linksOn(page.pon), require_runtime.shallowArray);
42
59
  const engaged = require_runtime.useSelector(_embedpdf_plugin_link.LinkToken, (c) => c.engaged());
60
+ const editEnabled = require_runtime.useOptionalSelector(_embedpdf_plugin_interaction.InteractionToken, (c) => c.activeTool()?.enables.has("annotation-edit") ?? false, false);
43
61
  (0, react.useEffect)(() => {
44
62
  link.ensurePage(page.pon);
45
63
  }, [link, page.pon]);
46
64
  if (!engaged || !items.length) return null;
65
+ const visible = editEnabled ? items.filter((i) => !i.attached) : items;
66
+ if (!visible.length) return null;
47
67
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
48
68
  style: {
49
69
  position: "absolute",
50
70
  inset: 0,
51
71
  pointerEvents: "none"
52
72
  },
53
- children: items.map((item) => {
73
+ children: visible.map((item) => {
54
74
  const box = boxOf(item, page);
75
+ const href = item.target.kind === "uri" ? (0, _embedpdf_web.sanitizeExternalUri)(item.target.uri) : null;
55
76
  const native = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
56
- href: (item.target.kind === "uri" ? (0, _embedpdf_web.sanitizeExternalUri)(item.target.uri) : null) ?? void 0,
77
+ href: href ?? void 0,
57
78
  target: "_blank",
58
79
  rel: "noopener noreferrer",
59
80
  role: "link",
@@ -62,13 +83,14 @@ function LinkLayer({ renderLink } = {}) {
62
83
  "aria-label": labelOf(item),
63
84
  onClick: (e) => {
64
85
  if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
86
+ if (href) return;
65
87
  e.preventDefault();
66
- link.activate(item.target);
88
+ openLinkTarget(link, item.target);
67
89
  },
68
90
  onKeyDown: (e) => {
69
91
  if (e.key === "Enter" || e.key === " ") {
70
92
  e.preventDefault();
71
- link.activate(item.target);
93
+ openLinkTarget(link, item.target);
72
94
  }
73
95
  },
74
96
  onPointerDown: (e) => e.stopPropagation(),
@@ -95,6 +117,7 @@ function useLink() {
95
117
  }
96
118
  //#endregion
97
119
  exports.LinkLayer = LinkLayer;
120
+ exports.openLinkTarget = openLinkTarget;
98
121
  exports.useLink = useLink;
99
122
  Object.keys(_embedpdf_plugin_link).forEach(function(k) {
100
123
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
package/dist/link.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"link.cjs","names":["usePage","useCapability","LinkToken","useSelector","shallowArray","React"],"sources":["../src/link.tsx"],"sourcesContent":["/**\n * The React view of @embedpdf/plugin-link — the navigation plane's paint.\n *\n * One absolutely-positioned <a> per clickable link area, real anchors on\n * purpose: URIs get an `href` (middle-click, copy-link, status-bar preview\n * and keyboard focus for free), internal destinations activate through the\n * plugin (stage reveal). The layer stands down entirely while the active\n * tool doesn't enable `link-nav` — the annotation plane owns links then\n * (select / move / resize / retarget through the selection editor).\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-link';\nimport * as React from 'react';\nimport { useEffect } from 'react';\nimport { LinkToken, type LinkNavItem } from '@embedpdf/plugin-link';\nimport { sanitizeExternalUri } from '@embedpdf/web';\n\nimport { shallowArray, useCapability, usePage, useSelector } from './runtime';\nimport type { PageContextValue } from './runtime';\n\n/** Content rect → view px (the page wrapper's own space) — the same idiom as\n * the annotation and form layers: never re-derive `x * scale`. */\nfunction boxOf(item: LinkNavItem, page: PageContextValue) {\n const tl = page.transform.pageToContent({ x: item.rect.x, y: item.rect.y });\n const br = page.transform.pageToContent({\n x: item.rect.x + item.rect.width,\n y: item.rect.y + item.rect.height,\n });\n return { left: tl.x, top: tl.y, width: br.x - tl.x, height: br.y - tl.y };\n}\n\n/** A human label for the hover tooltip. Apps with i18n render their own via\n * `renderLink`; this is the sensible default. */\nfunction labelOf(item: LinkNavItem): string {\n switch (item.target.kind) {\n case 'uri':\n return item.target.uri;\n case 'goto':\n return 'Go to destination';\n case 'named':\n return item.target.name;\n default:\n return 'Link';\n }\n}\n\nexport interface LinkLayerProps {\n /** Wrap or replace a link's native anchor (badging, custom tooltips). */\n renderLink?: (args: {\n item: LinkNavItem;\n nativeComponent: React.ReactNode;\n }) => React.ReactNode | undefined;\n}\n\nexport function LinkLayer({ renderLink }: LinkLayerProps = {}) {\n const page = usePage();\n const link = useCapability(LinkToken);\n const items = useSelector(LinkToken, (c) => c.linksOn(page.pon), shallowArray);\n const engaged = useSelector(LinkToken, (c) => c.engaged());\n\n useEffect(() => {\n link.ensurePage(page.pon);\n }, [link, page.pon]);\n\n // An authoring tool is active → the annotation plane owns links (they're\n // plain editable rects there); no nav anchors, no swallowed pointer events.\n if (!engaged || !items.length) return null;\n\n return (\n <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>\n {items.map((item) => {\n const box = boxOf(item, page);\n // Real href ONLY for sanitized external URIs; blocked schemes and\n // internal targets activate through the plugin instead.\n const href = item.target.kind === 'uri' ? sanitizeExternalUri(item.target.uri) : null;\n const native = (\n <a\n href={href ?? undefined}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n role=\"link\"\n tabIndex={0}\n title={labelOf(item)}\n aria-label={labelOf(item)}\n onClick={(e) => {\n // Plain left-click activates through the plugin (stage reveal /\n // policy / analytics). Modified clicks and middle-clicks on a\n // real href keep their native browser behaviour.\n if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;\n e.preventDefault();\n link.activate(item.target);\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n link.activate(item.target);\n }\n }}\n // Keep the hub out of it: a down inside the anchor must not reach\n // the Stage's native listener (same isolation idiom as FreeText).\n onPointerDown={(e) => e.stopPropagation()}\n style={{\n position: 'absolute',\n left: box.left,\n top: box.top,\n width: box.width,\n height: box.height,\n cursor: 'pointer',\n pointerEvents: 'auto',\n }}\n />\n );\n const out = renderLink?.({ item, nativeComponent: native }) ?? native;\n return <React.Fragment key={item.id}>{out}</React.Fragment>;\n })}\n </div>\n );\n}\n\nexport function useLink() {\n return useCapability(LinkToken);\n}\n"],"mappings":";;;;;;;;;;;AAuBA,SAAS,MAAM,MAAmB,MAAwB;CACxD,MAAM,KAAK,KAAK,UAAU,cAAc;EAAE,GAAG,KAAK,KAAK;EAAG,GAAG,KAAK,KAAK;CAAE,CAAC;CAC1E,MAAM,KAAK,KAAK,UAAU,cAAc;EACtC,GAAG,KAAK,KAAK,IAAI,KAAK,KAAK;EAC3B,GAAG,KAAK,KAAK,IAAI,KAAK,KAAK;CAC7B,CAAC;CACD,OAAO;EAAE,MAAM,GAAG;EAAG,KAAK,GAAG;EAAG,OAAO,GAAG,IAAI,GAAG;EAAG,QAAQ,GAAG,IAAI,GAAG;CAAE;AAC1E;;;AAIA,SAAS,QAAQ,MAA2B;CAC1C,QAAQ,KAAK,OAAO,MAApB;EACE,KAAK,OACH,OAAO,KAAK,OAAO;EACrB,KAAK,QACH,OAAO;EACT,KAAK,SACH,OAAO,KAAK,OAAO;EACrB,SACE,OAAO;CACX;AACF;AAUA,SAAgB,UAAU,EAAE,eAA+B,CAAC,GAAG;CAC7D,MAAM,OAAOA,gBAAAA,QAAQ;CACrB,MAAM,OAAOC,gBAAAA,cAAcC,sBAAAA,SAAS;CACpC,MAAM,QAAQC,gBAAAA,YAAYD,sBAAAA,YAAY,MAAM,EAAE,QAAQ,KAAK,GAAG,GAAGE,gBAAAA,YAAY;CAC7E,MAAM,UAAUD,gBAAAA,YAAYD,sBAAAA,YAAY,MAAM,EAAE,QAAQ,CAAC;CAEzD,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,KAAK,WAAW,KAAK,GAAG;CAC1B,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC;CAInB,IAAI,CAAC,WAAW,CAAC,MAAM,QAAQ,OAAO;CAEtC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,OAAO;GAAE,UAAU;GAAY,OAAO;GAAG,eAAe;EAAO;EACjE,UAAA,MAAM,KAAK,SAAS;GACnB,MAAM,MAAM,MAAM,MAAM,IAAI;GAI5B,MAAM,SACJ,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;IACE,OAHS,KAAK,OAAO,SAAS,SAAA,GAAA,cAAA,oBAAA,CAA4B,KAAK,OAAO,GAAG,IAAI,SAG/D,KAAA;IACd,QAAO;IACP,KAAI;IACJ,MAAK;IACL,UAAU;IACV,OAAO,QAAQ,IAAI;IACnB,cAAY,QAAQ,IAAI;IACxB,UAAU,MAAM;KAId,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ;KACtD,EAAE,eAAe;KACjB,KAAK,SAAS,KAAK,MAAM;IAC3B;IACA,YAAY,MAAM;KAChB,IAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;MACtC,EAAE,eAAe;MACjB,KAAK,SAAS,KAAK,MAAM;KAC3B;IACF;IAGA,gBAAgB,MAAM,EAAE,gBAAgB;IACxC,OAAO;KACL,UAAU;KACV,MAAM,IAAI;KACV,KAAK,IAAI;KACT,OAAO,IAAI;KACX,QAAQ,IAAI;KACZ,QAAQ;KACR,eAAe;IACjB;GACD,CAAA;GAEH,MAAM,MAAM,aAAa;IAAE;IAAM,iBAAiB;GAAO,CAAC,KAAK;GAC/D,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACG,MAAM,UAAP,EAAA,UAA+B,IAAoB,GAA9B,KAAK,EAAyB;EAC5D,CAAC;CACE,CAAA;AAET;AAEA,SAAgB,UAAU;CACxB,OAAOJ,gBAAAA,cAAcC,sBAAAA,SAAS;AAChC"}
1
+ {"version":3,"file":"link.cjs","names":["usePage","useCapability","LinkToken","useSelector","shallowArray","useOptionalSelector","InteractionToken","React"],"sources":["../src/link.tsx"],"sourcesContent":["/**\n * The React view of @embedpdf/plugin-link — the navigation plane's paint.\n *\n * One absolutely-positioned <a> per clickable link area, real anchors on\n * purpose: URIs get an `href` (middle-click, copy-link, status-bar preview\n * and keyboard focus for free), internal destinations activate through the\n * plugin (stage reveal). The layer stands down entirely while the active\n * tool doesn't enable `link-nav` — the annotation plane owns links then\n * (select / move / resize / retarget through the selection editor).\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-link';\nimport * as React from 'react';\nimport { useEffect } from 'react';\nimport { InteractionToken } from '@embedpdf/plugin-interaction';\nimport {\n LinkToken,\n type LinkActivation,\n type LinkCapability,\n type LinkNavItem,\n type PdfLinkTarget,\n} from '@embedpdf/plugin-link';\nimport { sanitizeExternalUri } from '@embedpdf/web';\n\nimport {\n shallowArray,\n useCapability,\n useOptionalSelector,\n usePage,\n useSelector,\n} from './runtime';\nimport type { PageContextValue } from './runtime';\n\n/**\n * Resolve a target through the plugin and PERFORM the `uri` outcome — the ONE\n * place in the codebase that turns a link target into a browser tab. The\n * plugin owns resolution (goto → stage reveal, policy, analytics) and stays\n * DOM-free; opening is this framework layer's job. Every click path — the nav\n * anchors below, the selection menu's \"Open link\", the style editor's \"Go to\n * link\" — goes through here, so none of them can drop the uri outcome again.\n */\nexport function openLinkTarget(link: LinkCapability, target: PdfLinkTarget): LinkActivation {\n const activation = link.activate(target);\n if (activation.outcome === 'uri') {\n const href = sanitizeExternalUri(activation.uri);\n if (href && typeof window !== 'undefined') window.open(href, '_blank', 'noopener,noreferrer');\n }\n return activation;\n}\n\n/** Content rect → view px (the page wrapper's own space) — the same idiom as\n * the annotation and form layers: never re-derive `x * scale`. */\nfunction boxOf(item: LinkNavItem, page: PageContextValue) {\n const tl = page.transform.toPixels({ x: item.rect.x, y: item.rect.y });\n const br = page.transform.toPixels({\n x: item.rect.x + item.rect.width,\n y: item.rect.y + item.rect.height,\n });\n return { left: tl.x, top: tl.y, width: br.x - tl.x, height: br.y - tl.y };\n}\n\n/** A human label for the hover tooltip. Apps with i18n render their own via\n * `renderLink`; this is the sensible default. */\nfunction labelOf(item: LinkNavItem): string {\n switch (item.target.kind) {\n case 'uri':\n return item.target.uri;\n case 'goto':\n return 'Go to destination';\n case 'named':\n return item.target.name;\n default:\n return 'Link';\n }\n}\n\nexport interface LinkLayerProps {\n /** Wrap or replace a link's native anchor (badging, custom tooltips). */\n renderLink?: (args: {\n item: LinkNavItem;\n nativeComponent: React.ReactNode;\n }) => React.ReactNode | undefined;\n}\n\nexport function LinkLayer({ renderLink }: LinkLayerProps = {}) {\n const page = usePage();\n const link = useCapability(LinkToken);\n const items = useSelector(LinkToken, (c) => c.linksOn(page.pon), shallowArray);\n const engaged = useSelector(LinkToken, (c) => c.engaged());\n // One owner per pixel: an ATTACHED link is a property of its parent — while\n // the active tool can edit annotations, the parent owns those pixels and\n // the anchor stands down (select/move/resize work; no tooltip, no swallowed\n // pointer). Standalone document links navigate under any link-nav tool.\n const editEnabled = useOptionalSelector(\n InteractionToken,\n (c) => c.activeTool()?.enables.has('annotation-edit') ?? false,\n false,\n );\n\n useEffect(() => {\n link.ensurePage(page.pon);\n }, [link, page.pon]);\n\n // An authoring tool is active → the annotation plane owns links (they're\n // plain editable rects there); no nav anchors, no swallowed pointer events.\n if (!engaged || !items.length) return null;\n const visible = editEnabled ? items.filter((i) => !i.attached) : items;\n if (!visible.length) return null;\n\n return (\n <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>\n {visible.map((item) => {\n const box = boxOf(item, page);\n // Real href ONLY for sanitized external URIs; blocked schemes and\n // internal targets activate through the plugin instead.\n const href = item.target.kind === 'uri' ? sanitizeExternalUri(item.target.uri) : null;\n const native = (\n <a\n href={href ?? undefined}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n role=\"link\"\n tabIndex={0}\n title={labelOf(item)}\n aria-label={labelOf(item)}\n onClick={(e) => {\n // Modified clicks and middle-clicks on a real href keep their\n // native browser behaviour (new tab / copy link).\n if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;\n // A plain left-click on a real href: let the anchor be an\n // anchor — native navigation, target=_blank, status bar. Only\n // non-href targets (goto / named / blocked schemes) route\n // through the plugin, whose uri outcome the opener PERFORMS\n // (the old code preventDefault-ed AND dropped the outcome, so\n // clicking a URL link did nothing at all).\n if (href) return;\n e.preventDefault();\n openLinkTarget(link, item.target);\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n openLinkTarget(link, item.target);\n }\n }}\n // Keep the hub out of it: a down inside the anchor must not reach\n // the Stage's native listener (same isolation idiom as FreeText).\n onPointerDown={(e) => e.stopPropagation()}\n style={{\n position: 'absolute',\n left: box.left,\n top: box.top,\n width: box.width,\n height: box.height,\n cursor: 'pointer',\n pointerEvents: 'auto',\n }}\n />\n );\n const out = renderLink?.({ item, nativeComponent: native }) ?? native;\n return <React.Fragment key={item.id}>{out}</React.Fragment>;\n })}\n </div>\n );\n}\n\nexport function useLink() {\n return useCapability(LinkToken);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0CA,SAAgB,eAAe,MAAsB,QAAuC;CAC1F,MAAM,aAAa,KAAK,SAAS,MAAM;CACvC,IAAI,WAAW,YAAY,OAAO;EAChC,MAAM,QAAA,GAAA,cAAA,oBAAA,CAA2B,WAAW,GAAG;EAC/C,IAAI,QAAQ,OAAO,WAAW,aAAa,OAAO,KAAK,MAAM,UAAU,qBAAqB;CAC9F;CACA,OAAO;AACT;;;AAIA,SAAS,MAAM,MAAmB,MAAwB;CACxD,MAAM,KAAK,KAAK,UAAU,SAAS;EAAE,GAAG,KAAK,KAAK;EAAG,GAAG,KAAK,KAAK;CAAE,CAAC;CACrE,MAAM,KAAK,KAAK,UAAU,SAAS;EACjC,GAAG,KAAK,KAAK,IAAI,KAAK,KAAK;EAC3B,GAAG,KAAK,KAAK,IAAI,KAAK,KAAK;CAC7B,CAAC;CACD,OAAO;EAAE,MAAM,GAAG;EAAG,KAAK,GAAG;EAAG,O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