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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/{AnnotationListSnapshot-DDxHpJQU-BG32YXxG.d.ts → AnnotationListSnapshot-x6tKulNV-B799rYyi.d.cts} +223 -24
  2. package/dist/{AnnotationListSnapshot-DDxHpJQU-BG32YXxG.d.cts → AnnotationListSnapshot-x6tKulNV-B799rYyi.d.ts} +223 -24
  3. package/dist/actions.cjs +42 -0
  4. package/dist/actions.cjs.map +1 -0
  5. package/dist/actions.d.cts +18 -0
  6. package/dist/actions.d.ts +18 -0
  7. package/dist/actions.js +34 -0
  8. package/dist/actions.js.map +1 -0
  9. package/dist/annotation-BCED_p9H.d.cts +160 -0
  10. package/dist/annotation-anchors-CetwM1g7.js +15 -0
  11. package/dist/annotation-anchors-CetwM1g7.js.map +1 -0
  12. package/dist/annotation-anchors-DuYRBJLl.cjs +26 -0
  13. package/dist/annotation-anchors-DuYRBJLl.cjs.map +1 -0
  14. package/dist/annotation-hooks-BB5ZhPpf.cjs +16 -0
  15. package/dist/annotation-hooks-BB5ZhPpf.cjs.map +1 -0
  16. package/dist/annotation-hooks-Df8EmzDO.js +11 -0
  17. package/dist/annotation-hooks-Df8EmzDO.js.map +1 -0
  18. package/dist/annotation-k38KDlIZ.d.ts +160 -0
  19. package/dist/annotation-menu.cjs +5 -5
  20. package/dist/annotation-menu.cjs.map +1 -1
  21. package/dist/annotation-menu.js +2 -2
  22. package/dist/annotation-menu.js.map +1 -1
  23. package/dist/annotation.cjs +24 -29
  24. package/dist/annotation.cjs.map +1 -1
  25. package/dist/annotation.d.cts +2 -159
  26. package/dist/annotation.d.ts +2 -159
  27. package/dist/annotation.js +22 -27
  28. package/dist/annotation.js.map +1 -1
  29. package/dist/form-BwrLFpKN.js +805 -0
  30. package/dist/form-BwrLFpKN.js.map +1 -0
  31. package/dist/form-D-ZSfGmB.cjs +836 -0
  32. package/dist/form-D-ZSfGmB.cjs.map +1 -0
  33. package/dist/form.cjs +8 -551
  34. package/dist/form.d.cts +4 -21
  35. package/dist/form.d.ts +4 -21
  36. package/dist/form.js +3 -544
  37. package/dist/index.cjs +21 -11
  38. package/dist/index.d.cts +8 -7
  39. package/dist/index.d.ts +8 -7
  40. package/dist/index.js +9 -6
  41. package/dist/link.cjs +48 -8
  42. package/dist/link.cjs.map +1 -1
  43. package/dist/link.d.cts +2 -2
  44. package/dist/link.d.ts +2 -2
  45. package/dist/link.js +49 -9
  46. package/dist/link.js.map +1 -1
  47. package/dist/{runtime-Cvi0wQ4d.d.cts → runtime-DE76hlnl.d.ts} +13 -5
  48. package/dist/{runtime-DXxr8T4L.d.ts → runtime-umHA_xHt.d.cts} +13 -5
  49. package/dist/runtime.cjs +19 -0
  50. package/dist/runtime.cjs.map +1 -1
  51. package/dist/runtime.d.cts +2 -2
  52. package/dist/runtime.d.ts +2 -2
  53. package/dist/runtime.js +19 -1
  54. package/dist/runtime.js.map +1 -1
  55. package/dist/scrollbar.cjs +3 -3
  56. package/dist/scrollbar.cjs.map +1 -1
  57. package/dist/scrollbar.d.cts +1 -1
  58. package/dist/scrollbar.d.ts +1 -1
  59. package/dist/scrollbar.js +1 -1
  60. package/dist/scrollbar.js.map +1 -1
  61. package/dist/search.d.cts +1 -1
  62. package/dist/search.d.ts +1 -1
  63. package/dist/selection.cjs +2 -2
  64. package/dist/selection.cjs.map +1 -1
  65. package/dist/selection.d.cts +1 -1
  66. package/dist/selection.d.ts +1 -1
  67. package/dist/selection.js +1 -1
  68. package/dist/selection.js.map +1 -1
  69. package/dist/stage.cjs +2 -2
  70. package/dist/stage.cjs.map +1 -1
  71. package/dist/stage.d.cts +1 -1
  72. package/dist/stage.d.ts +1 -1
  73. package/dist/stage.js +1 -1
  74. package/dist/stage.js.map +1 -1
  75. package/dist/stamp.cjs +7 -0
  76. package/dist/stamp.cjs.map +1 -1
  77. package/dist/stamp.d.cts +2 -1
  78. package/dist/stamp.d.ts +2 -1
  79. package/dist/stamp.js +2 -1
  80. package/dist/stamp.js.map +1 -1
  81. package/dist/toolbar.cjs +4 -4
  82. package/dist/toolbar.cjs.map +1 -1
  83. package/dist/toolbar.d.cts +1 -1
  84. package/dist/toolbar.d.ts +1 -1
  85. package/dist/toolbar.js +1 -1
  86. package/dist/toolbar.js.map +1 -1
  87. package/package.json +30 -24
  88. package/dist/form.cjs.map +0 -1
  89. package/dist/form.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,9 +1,10 @@
1
+ import { ActionsUiHandlers, useActionsUiAdapter } from "./actions.cjs";
1
2
  import { AnchorTarget, Anchored, AnchoredPlacement, AnchoredProps, ProjectorBinding, ProjectorProvider, ViewProjector, useProjectorBinding } from "./anchored.cjs";
2
3
  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
+ import { C as usePage, S as useOptionalSelector, _ as useDocumentStatus, a as EmbedPDF, b as useKernelValue, c as Viewer, d as runtime_d_exports, f as shallowArray, g as useDocumentId, h as useCapabilityEvent, 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 useDocuments, w as useSelector, x as useOptionalCapability, y as useKernel } from "./runtime-umHA_xHt.cjs";
5
+ import { A as useCommentsHydration, C as filePickerProvider, D as useCommentThread, E as useAnnotationSelection, F as SelectionAnchor, I as sameAnchor, L as sameCreationDraftAnchor, M as useSelectionFlags, N as useSelectionProps, O as useCommentThreads, P as useAnnotationSelected, S as enrichCommentThreads, T as useAnnotationDefaults, _ as SelectionFlags, a as AnnotationPropsPatch, b as TextAlign, c as Border, d as Geom, f as LineEnding, g as RenderItem, h as PropSpec, i as AnnotationProps, j as useFilePickerProvider, k as useComments, l as CommentThreadView, m as PropKey, n as AnnotationLayer, o as AnnotationRenderer, p as LineEndings, r as AnnotationLayerProps, s as AnnotationRendererProps, t as AnnotationFlags, u as CreationDraftAnchor, v as SelectionProps, w as useAnnotation, x as TextStyle, y as Style } from "./annotation-BCED_p9H.cjs";
5
6
  import { isMacPlatform, useCommand, useCommandShortcuts, useCommands } from "./commands.cjs";
6
- import { FormLayer, FormScriptingUiHandlers, useForm, useFormField, useFormScriptingProvider } from "./form.cjs";
7
+ import { FormLayer, useForm, useFormField } from "./form.cjs";
7
8
  import { useI18n, useLocale, useT } from "./i18n.cjs";
8
9
  import { Stage, StageProps, StageTokenProp, useLayout, usePageList, usePages, useStage, useStageSettings, useZoom } from "./stage.cjs";
9
10
  import { Scrollbar, ScrollbarAxis, ScrollbarProps, useScrollMetrics } from "./scrollbar.cjs";
@@ -17,14 +18,14 @@ import { usePageEditor } from "./page-edit.cjs";
17
18
  import { useMetadata } from "./metadata.cjs";
18
19
  import { usePendingRedactions, useRedaction } from "./redaction.cjs";
19
20
  import { SearchLayer, useSearch, useSearchState } from "./search.cjs";
20
- import { useArmStampAsset, useStamp, useStampAssetPreviewUrl, useStampAssets, useStampLibraries } from "./stamp.cjs";
21
+ import { ByteStore, indexedDbByteStore, useArmStampAsset, useStamp, useStampAssetPreviewUrl, useStampAssets, useStampLibraries } from "./stamp.cjs";
21
22
  import { MenusHandle, SurfaceHandle, useMenus, useShell, useSurface } from "./shell.cjs";
22
23
  import { CollapsedGroupView, CustomSlotCtx, GroupDisclosureView, OverflowMenuView, StripView, StripViewGroup, Toolbar, ToolbarProps, useStripView } from "./toolbar.cjs";
23
24
  export * from "@embedpdf/plugin-annotation";
24
25
  export * from "@embedpdf/core";
25
- export * from "@embedpdf/plugin-render";
26
26
  export * from "@embedpdf/plugin-commands";
27
27
  export * from "@embedpdf/plugin-stage";
28
+ export * from "@embedpdf/plugin-render";
28
29
  export * from "@embedpdf/plugin-interaction";
29
30
  export * from "@embedpdf/plugin-selection";
30
31
  export * from "@embedpdf/plugin-link";
@@ -36,8 +37,8 @@ export * from "@embedpdf/plugin-stamp";
36
37
  export * from "@embedpdf/plugin-shell";
37
38
  export * from "@embedpdf/core-ui";
38
39
  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
+ export { ActionsUiHandlers, AnchorTarget, Anchored, AnchoredPlacement, AnchoredProps, AnnotationDraftMenu, AnnotationDraftMenuProps, AnnotationFlags, AnnotationLayer, AnnotationLayerProps, AnnotationMenu, AnnotationMenuProps, AnnotationProps, AnnotationPropsPatch, AnnotationRenderer, AnnotationRendererProps, Border, ByteStore, CollapsedGroupView, CommentThreadView, CreationDraftAnchor, CustomSlotCtx, DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, FormLayer, 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, indexedDbByteStore, isMacPlatform, makePageContext, openLinkTarget, sameAnchor, sameCreationDraftAnchor, shallowArray, useActionsUiAdapter, useActiveDocumentId, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useArmStampAsset, useCapability, useCapabilityEvent, useCommand, useCommandShortcuts, useCommands, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useDocumentId, useDocumentStatus, useDocuments, useFilePickerProvider, useForm, useFormField, 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
  }
41
42
  //#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
+ export { type ActionsUiHandlers, type AnchorTarget, Anchored, type AnchoredPlacement, AnchoredProps, AnnotationDraftMenu, AnnotationDraftMenuProps, type AnnotationFlags, AnnotationLayer, AnnotationLayerProps, AnnotationMenu, AnnotationMenuProps, type AnnotationProps, type AnnotationPropsPatch, AnnotationRenderer, AnnotationRendererProps, type Border, type ByteStore, CollapsedGroupView, CommentThreadView, type CreationDraftAnchor, CustomSlotCtx, DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, FormLayer, 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, type 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, indexedDbByteStore, isMacPlatform, makePageContext, openLinkTarget, sameAnchor, sameCreationDraftAnchor, shallowArray, useActionsUiAdapter, useActiveDocumentId, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useArmStampAsset, useCapability, useCapabilityEvent, useCommand, useCommandShortcuts, useCommands, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useDocumentId, useDocumentStatus, useDocuments, useFilePickerProvider, useForm, useFormField, 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
44
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
+ import { ActionsUiHandlers, useActionsUiAdapter } from "./actions.js";
1
2
  import { AnchorTarget, Anchored, AnchoredPlacement, AnchoredProps, ProjectorBinding, ProjectorProvider, ViewProjector, useProjectorBinding } from "./anchored.js";
2
3
  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
+ import { C as usePage, S as useOptionalSelector, _ as useDocumentStatus, a as EmbedPDF, b as useKernelValue, c as Viewer, d as runtime_d_exports, f as shallowArray, g as useDocumentId, h as useCapabilityEvent, 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 useDocuments, w as useSelector, x as useOptionalCapability, y as useKernel } from "./runtime-DE76hlnl.js";
5
+ import { A as useCommentsHydration, C as filePickerProvider, D as useCommentThread, E as useAnnotationSelection, F as SelectionAnchor, I as sameAnchor, L as sameCreationDraftAnchor, M as useSelectionFlags, N as useSelectionProps, O as useCommentThreads, P as useAnnotationSelected, S as enrichCommentThreads, T as useAnnotationDefaults, _ as SelectionFlags, a as AnnotationPropsPatch, b as TextAlign, c as Border, d as Geom, f as LineEnding, g as RenderItem, h as PropSpec, i as AnnotationProps, j as useFilePickerProvider, k as useComments, l as CommentThreadView, m as PropKey, n as AnnotationLayer, o as AnnotationRenderer, p as LineEndings, r as AnnotationLayerProps, s as AnnotationRendererProps, t as AnnotationFlags, u as CreationDraftAnchor, v as SelectionProps, w as useAnnotation, x as TextStyle, y as Style } from "./annotation-k38KDlIZ.js";
5
6
  import { isMacPlatform, useCommand, useCommandShortcuts, useCommands } from "./commands.js";
6
- import { FormLayer, FormScriptingUiHandlers, useForm, useFormField, useFormScriptingProvider } from "./form.js";
7
+ import { FormLayer, useForm, useFormField } from "./form.js";
7
8
  import { useI18n, useLocale, useT } from "./i18n.js";
8
9
  import { Stage, StageProps, StageTokenProp, useLayout, usePageList, usePages, useStage, useStageSettings, useZoom } from "./stage.js";
9
10
  import { Scrollbar, ScrollbarAxis, ScrollbarProps, useScrollMetrics } from "./scrollbar.js";
@@ -17,13 +18,13 @@ import { usePageEditor } from "./page-edit.js";
17
18
  import { useMetadata } from "./metadata.js";
18
19
  import { usePendingRedactions, useRedaction } from "./redaction.js";
19
20
  import { SearchLayer, useSearch, useSearchState } from "./search.js";
20
- import { useArmStampAsset, useStamp, useStampAssetPreviewUrl, useStampAssets, useStampLibraries } from "./stamp.js";
21
+ import { ByteStore, indexedDbByteStore, useArmStampAsset, useStamp, useStampAssetPreviewUrl, useStampAssets, useStampLibraries } from "./stamp.js";
21
22
  import { MenusHandle, SurfaceHandle, useMenus, useShell, useSurface } from "./shell.js";
22
23
  import { CollapsedGroupView, CustomSlotCtx, GroupDisclosureView, OverflowMenuView, StripView, StripViewGroup, Toolbar, ToolbarProps, useStripView } from "./toolbar.js";
23
24
  export * from "@embedpdf/core";
24
25
  export * from "@embedpdf/plugin-stage";
25
- export * from "@embedpdf/plugin-interaction";
26
26
  export * from "@embedpdf/plugin-render";
27
+ export * from "@embedpdf/plugin-interaction";
27
28
  export * from "@embedpdf/plugin-selection";
28
29
  export * from "@embedpdf/plugin-annotation";
29
30
  export * from "@embedpdf/plugin-link";
@@ -36,8 +37,8 @@ export * from "@embedpdf/plugin-commands";
36
37
  export * from "@embedpdf/plugin-shell";
37
38
  export * from "@embedpdf/core-ui";
38
39
  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
+ export { ActionsUiHandlers, AnchorTarget, Anchored, AnchoredPlacement, AnchoredProps, AnnotationDraftMenu, AnnotationDraftMenuProps, AnnotationFlags, AnnotationLayer, AnnotationLayerProps, AnnotationMenu, AnnotationMenuProps, AnnotationProps, AnnotationPropsPatch, AnnotationRenderer, AnnotationRendererProps, Border, ByteStore, CollapsedGroupView, CommentThreadView, CreationDraftAnchor, CustomSlotCtx, DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, FormLayer, 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, indexedDbByteStore, isMacPlatform, makePageContext, openLinkTarget, sameAnchor, sameCreationDraftAnchor, shallowArray, useActionsUiAdapter, useActiveDocumentId, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useArmStampAsset, useCapability, useCapabilityEvent, useCommand, useCommandShortcuts, useCommands, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useDocumentId, useDocumentStatus, useDocuments, useFilePickerProvider, useForm, useFormField, 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
  }
41
42
  //#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
+ export { type ActionsUiHandlers, type AnchorTarget, Anchored, type AnchoredPlacement, AnchoredProps, AnnotationDraftMenu, AnnotationDraftMenuProps, type AnnotationFlags, AnnotationLayer, AnnotationLayerProps, AnnotationMenu, AnnotationMenuProps, type AnnotationProps, type AnnotationPropsPatch, AnnotationRenderer, AnnotationRendererProps, type Border, type ByteStore, CollapsedGroupView, CommentThreadView, type CreationDraftAnchor, CustomSlotCtx, DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, FormLayer, 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, type 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, indexedDbByteStore, isMacPlatform, makePageContext, openLinkTarget, sameAnchor, sameCreationDraftAnchor, shallowArray, useActionsUiAdapter, useActiveDocumentId, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useArmStampAsset, useCapability, useCapabilityEvent, useCommand, useCommandShortcuts, useCommands, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useDocumentId, useDocumentStatus, useDocuments, useFilePickerProvider, useForm, useFormField, 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
44
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./rolldown-runtime-BBjsoOtd.js";
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 { DocumentGate, DocumentScope, EmbedPDF, PageProvider, Viewer, makePageContext, shallowArray, useActiveDocumentId, useCapability, useCapabilityEvent, useDocumentId, useDocumentStatus, useDocuments, useKernel, useKernelValue, useOptionalCapability, useOptionalSelector, usePage, useSelector } from "./runtime.js";
3
3
  import { Anchored, ProjectorProvider, useProjectorBinding } from "./anchored.js";
4
4
  import { Stage, useLayout, usePageList, usePages, useStage, useStageSettings, useZoom } from "./stage.js";
5
5
  import { Scrollbar, useScrollMetrics } from "./scrollbar.js";
@@ -7,24 +7,27 @@ import { PageView } from "./page-view.js";
7
7
  import { RenderLayer } from "./render.js";
8
8
  import { PagePointerSource, createClickCounter, useTool, useToolCursor, vibrationFeedback, wkFeedback } from "./interaction.js";
9
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";
10
+ import { n as sameCreationDraftAnchor, t as sameAnchor } from "./annotation-anchors-CetwM1g7.js";
11
+ import { t as useAnnotationSelected } from "./annotation-hooks-Df8EmzDO.js";
12
+ import { AnnotationLayer, enrichCommentThreads, filePickerProvider, useAnnotation, useAnnotationDefaults, useAnnotationSelection, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useFilePickerProvider, useSelectionFlags, useSelectionProps } from "./annotation.js";
11
13
  import { AnnotationDraftMenu, AnnotationMenu } from "./annotation-menu.js";
12
14
  import { LinkLayer, openLinkTarget, useLink } from "./link.js";
15
+ import { useActionsUiAdapter } from "./actions.js";
13
16
  import { useViews } from "./views.js";
14
17
  import { usePageEditor } from "./page-edit.js";
15
18
  import { useMetadata } from "./metadata.js";
16
19
  import { usePendingRedactions, useRedaction } from "./redaction.js";
17
- import { FormLayer, useForm, useFormField, useFormScriptingProvider } from "./form.js";
20
+ import { i as useFormField, r as useForm, t as FormLayer } from "./form-BwrLFpKN.js";
18
21
  import { SearchLayer, useSearch, useSearchState } from "./search.js";
19
- import { useArmStampAsset, useStamp, useStampAssetPreviewUrl, useStampAssets, useStampLibraries } from "./stamp.js";
22
+ import { indexedDbByteStore, useArmStampAsset, useStamp, useStampAssetPreviewUrl, useStampAssets, useStampLibraries } from "./stamp.js";
20
23
  import { useI18n, useLocale, useT } from "./i18n.js";
21
24
  import { isMacPlatform, useCommand, useCommandShortcuts, useCommands } from "./commands.js";
22
25
  import { useMenus, useShell, useSurface } from "./shell.js";
23
26
  import { Toolbar, useStripView } from "./toolbar.js";
24
27
  export * from "@embedpdf/core";
25
28
  export * from "@embedpdf/plugin-stage";
26
- export * from "@embedpdf/plugin-interaction";
27
29
  export * from "@embedpdf/plugin-render";
30
+ export * from "@embedpdf/plugin-interaction";
28
31
  export * from "@embedpdf/plugin-selection";
29
32
  export * from "@embedpdf/plugin-annotation";
30
33
  export * from "@embedpdf/plugin-link";
@@ -36,4 +39,4 @@ export * from "@embedpdf/plugin-stamp";
36
39
  export * from "@embedpdf/plugin-commands";
37
40
  export * from "@embedpdf/plugin-shell";
38
41
  export * from "@embedpdf/core-ui";
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 };
42
+ 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, indexedDbByteStore, isMacPlatform, makePageContext, openLinkTarget, sameAnchor, sameCreationDraftAnchor, shallowArray, useActionsUiAdapter, useActiveDocumentId, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useArmStampAsset, useCapability, useCapabilityEvent, useCommand, useCommandShortcuts, useCommands, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useDocumentId, useDocumentStatus, useDocuments, useFilePickerProvider, useForm, useFormField, 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 };
package/dist/link.cjs CHANGED
@@ -5,8 +5,9 @@ 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
+ let _embedpdf_plugin_interaction_contract = require("@embedpdf/plugin-interaction/contract");
9
9
  let _embedpdf_plugin_link = require("@embedpdf/plugin-link");
10
+ let _embedpdf_plugin_actions_contract = require("@embedpdf/plugin-actions/contract");
10
11
  //#region src/link.tsx
11
12
  /**
12
13
  * Resolve a target through the plugin and PERFORM the `uri` outcome — the ONE
@@ -16,8 +17,8 @@ let _embedpdf_plugin_link = require("@embedpdf/plugin-link");
16
17
  * anchors below, the selection menu's "Open link", the style editor's "Go to
17
18
  * link" — goes through here, so none of them can drop the uri outcome again.
18
19
  */
19
- function openLinkTarget(link, target) {
20
- const activation = link.activate(target);
20
+ function openLinkTarget(link, target, context) {
21
+ const activation = link.activate(target, context);
21
22
  if (activation.outcome === "uri") {
22
23
  const href = (0, _embedpdf_web.sanitizeExternalUri)(activation.uri);
23
24
  if (href && typeof window !== "undefined") window.open(href, "_blank", "noopener,noreferrer");
@@ -55,9 +56,11 @@ function labelOf(item) {
55
56
  function LinkLayer({ renderLink } = {}) {
56
57
  const page = require_runtime.usePage();
57
58
  const link = require_runtime.useCapability(_embedpdf_plugin_link.LinkToken);
59
+ const actions = require_runtime.useOptionalCapability(_embedpdf_plugin_actions_contract.ActionsToken);
60
+ const linkPump = (0, react.useMemo)(() => actions ? (0, _embedpdf_plugin_actions_contract.createHoverPump)(actions.dispatch) : null, [actions]);
58
61
  const items = require_runtime.useSelector(_embedpdf_plugin_link.LinkToken, (c) => c.linksOn(page.pon), require_runtime.shallowArray);
59
62
  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);
63
+ const editEnabled = require_runtime.useOptionalSelector(_embedpdf_plugin_interaction_contract.InteractionToken, (c) => c.activeTool()?.enables.has("annotation-edit") ?? false, false);
61
64
  (0, react.useEffect)(() => {
62
65
  link.ensurePage(page.pon);
63
66
  }, [link, page.pon]);
@@ -72,7 +75,28 @@ function LinkLayer({ renderLink } = {}) {
72
75
  },
73
76
  children: visible.map((item) => {
74
77
  const box = boxOf(item, page);
75
- const href = item.target.kind === "uri" ? (0, _embedpdf_web.sanitizeExternalUri)(item.target.uri) : null;
78
+ const chained = (item.activate?.root?.next.length ?? 0) > 0;
79
+ const href = item.target.kind === "uri" && !chained ? (0, _embedpdf_web.sanitizeExternalUri)(item.target.uri) : null;
80
+ const context = {
81
+ activate: item.activate,
82
+ ref: item.ref,
83
+ pon: page.pon
84
+ };
85
+ const linkSource = item.ref ? {
86
+ kind: "link",
87
+ annotation: item.ref,
88
+ pon: page.pon
89
+ } : null;
90
+ const notify = (event) => {
91
+ if (!actions || !item.ref || !linkSource) return;
92
+ actions.dispatch({
93
+ scope: "annotation",
94
+ event,
95
+ ref: item.ref,
96
+ pon: page.pon,
97
+ source: linkSource
98
+ });
99
+ };
76
100
  const native = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
77
101
  href: href ?? void 0,
78
102
  target: "_blank",
@@ -85,15 +109,31 @@ function LinkLayer({ renderLink } = {}) {
85
109
  if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
86
110
  if (href) return;
87
111
  e.preventDefault();
88
- openLinkTarget(link, item.target);
112
+ openLinkTarget(link, item.target, context);
89
113
  },
90
114
  onKeyDown: (e) => {
91
115
  if (e.key === "Enter" || e.key === " ") {
92
116
  e.preventDefault();
93
- openLinkTarget(link, item.target);
117
+ openLinkTarget(link, item.target, context);
94
118
  }
95
119
  },
96
- onPointerDown: (e) => e.stopPropagation(),
120
+ onPointerEnter: () => {
121
+ if (!linkPump || !item.ref || !item.hoverEvents) return;
122
+ linkPump.hover({
123
+ ref: item.ref,
124
+ pon: page.pon,
125
+ ...linkSource ? { source: linkSource } : {},
126
+ events: item.hoverEvents
127
+ });
128
+ },
129
+ onPointerLeave: () => linkPump?.hover(null),
130
+ onPointerUp: () => notify("mouseUp"),
131
+ onFocus: () => notify("focus"),
132
+ onBlur: () => notify("blur"),
133
+ onPointerDown: (e) => {
134
+ e.stopPropagation();
135
+ notify("mouseDown");
136
+ },
97
137
  style: {
98
138
  position: "absolute",
99
139
  left: box.left,
package/dist/link.cjs.map CHANGED
@@ -1 +1 @@
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() {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AAM,aAAa;IAAE;IAAM,iBAAiB;GAAO,CAAC,KAAK;GAC/D,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,MAAM,UAAP,EAAA,UAA+B,IAAoB,GAA9B,KAAK,EAAyB;EAC5D,CAAC;CACE,CAAA;AAET;AAEA,SAAgB,UAAU;CACxB,OAAON,gBAAAA,cAAcC,sBAAAA,SAAS;AAChC"}
1
+ {"version":3,"file":"link.cjs","names":["usePage","useCapability","LinkToken","useOptionalCapability","ActionsToken","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, useMemo } from 'react';\nimport { ActionsToken, createHoverPump } from '@embedpdf/plugin-actions/contract';\nimport type {\n ActionSource,\n PdfAnnotationEventKind,\n} from '@embedpdf/plugin-actions/contract';\nimport { InteractionToken } from '@embedpdf/plugin-interaction/contract';\nimport {\n LinkToken,\n type LinkActivateContext,\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 useOptionalCapability,\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(\n link: LinkCapability,\n target: PdfLinkTarget,\n context?: LinkActivateContext,\n): LinkActivation {\n const activation = link.activate(target, context);\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 // 'dispatched': the action engine took it — the actions UI adapter owns any\n // URI open (the no-double-open rule); this opener must do NOTHING.\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 // The link plane's /AA event feed: links are behavior-inert to the\n // annotation plane's hover feed while navigable (their pixels are THESE\n // anchors), so E/X/D/U/Fo/Bl can only fire from here. One shared pump per\n // layer — crossing layers still orders Exit before Enter because both\n // sides submit synchronously in DOM event order.\n const actions = useOptionalCapability(ActionsToken);\n const linkPump = useMemo(() => (actions ? createHoverPump(actions.dispatch) : null), [actions]);\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 a chain-free sanitized external URI; blocked\n // schemes, internal targets, and chain-bearing trees (/Next after the\n // URI) activate through the plugin instead — a native navigation\n // would perform the first action and silently drop the rest.\n const chained = (item.activate?.root?.next.length ?? 0) > 0;\n const href =\n item.target.kind === 'uri' && !chained ? sanitizeExternalUri(item.target.uri) : null;\n const context: LinkActivateContext = { activate: item.activate, ref: item.ref, pon: page.pon };\n const linkSource: ActionSource | null = item.ref\n ? { kind: 'link', annotation: item.ref, pon: page.pon }\n : null;\n const notify = (event: Exclude<PdfAnnotationEventKind, 'cursorEnter' | 'cursorExit'>) => {\n if (!actions || !item.ref || !linkSource) return;\n void actions.dispatch({\n scope: 'annotation',\n event,\n ref: item.ref,\n pon: page.pon,\n source: linkSource,\n });\n };\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, context);\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n openLinkTarget(link, item.target, context);\n }\n }}\n onPointerEnter={() => {\n if (!linkPump || !item.ref || !item.hoverEvents) return;\n linkPump.hover({\n ref: item.ref,\n pon: page.pon,\n ...(linkSource ? { source: linkSource } : {}),\n events: item.hoverEvents,\n });\n }}\n onPointerLeave={() => linkPump?.hover(null)}\n onPointerUp={() => notify('mouseUp')}\n onFocus={() => notify('focus')}\n onBlur={() => notify('blur')}\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) => {\n e.stopPropagation();\n notify('mouseDown');\n }}\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":";;;;;;;;;;;;;;;;;;;AAiDA,SAAgB,eACd,MACA,QACA,SACgB;CAChB,MAAM,aAAa,KAAK,SAAS,QAAQ,OAAO;CAChD,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;CAGA,OAAO;AACT;;;AAIA,SAAS,MAAM,MAAmB,MAAwB;CACxD,MAAM,KAAK,KAAK,UAAU,SAAS;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e;MACjB,eAAe,MAAM,KAAK,QAAQ,OAAO;KAC3C;IACF;IACA,sBAAsB;KACpB,IAAI,CAAC,YAAY,CAAC,KAAK,OAAO,CAAC,KAAK,aAAa;KACjD,SAAS,MAAM;MACb,KAAK,KAAK;MACV,KAAK,KAAK;MACV,GAAI,aAAa,EAAE,QAAQ,WAAW,IAAI,CAAC;MAC3C,QAAQ,KAAK;KACf,CAAC;IACH;IACA,sBAAsB,UAAU,MAAM,IAAI;IAC1C,mBAAmB,OAAO,SAAS;IACnC,eAAe,OAAO,OAAO;IAC7B,cAAc,OAAO,MAAM;IAG3B,gBAAgB,MAAM;KACpB,EAAE,gBAAgB;KAClB,OAAO,WAAW;IACpB;IACA,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,CAACC,MAAM,UAAP,EAAA,UAA+B,IAAoB,GAA9B,KAAK,EAAyB;EAC5D,CAAC;CACE,CAAA;AAET;AAEA,SAAgB,UAAU;CACxB,OAAOR,gBAAAA,cAAcC,sBAAAA,SAAS;AAChC"}
package/dist/link.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { LinkActivation, LinkCapability, LinkNavItem, PdfLinkTarget } from "@embedpdf/plugin-link";
2
+ import { LinkActivateContext, LinkActivation, LinkCapability, LinkNavItem, PdfLinkTarget } from "@embedpdf/plugin-link";
3
3
  export * from "@embedpdf/plugin-link";
4
4
  //#region src/link.d.ts
5
5
  /**
@@ -10,7 +10,7 @@ export * from "@embedpdf/plugin-link";
10
10
  * anchors below, the selection menu's "Open link", the style editor's "Go to
11
11
  * link" — goes through here, so none of them can drop the uri outcome again.
12
12
  */
13
- declare function openLinkTarget(link: LinkCapability, target: PdfLinkTarget): LinkActivation;
13
+ declare function openLinkTarget(link: LinkCapability, target: PdfLinkTarget, context?: LinkActivateContext): LinkActivation;
14
14
  interface LinkLayerProps {
15
15
  /** Wrap or replace a link's native anchor (badging, custom tooltips). */
16
16
  renderLink?: (args: {
package/dist/link.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { LinkActivation, LinkCapability, LinkNavItem, PdfLinkTarget } from "@embedpdf/plugin-link";
2
+ import { LinkActivateContext, LinkActivation, LinkCapability, LinkNavItem, PdfLinkTarget } from "@embedpdf/plugin-link";
3
3
  export * from "@embedpdf/plugin-link";
4
4
  //#region src/link.d.ts
5
5
  /**
@@ -10,7 +10,7 @@ export * from "@embedpdf/plugin-link";
10
10
  * anchors below, the selection menu's "Open link", the style editor's "Go to
11
11
  * link" — goes through here, so none of them can drop the uri outcome again.
12
12
  */
13
- declare function openLinkTarget(link: LinkCapability, target: PdfLinkTarget): LinkActivation;
13
+ declare function openLinkTarget(link: LinkCapability, target: PdfLinkTarget, context?: LinkActivateContext): LinkActivation;
14
14
  interface LinkLayerProps {
15
15
  /** Wrap or replace a link's native anchor (badging, custom tooltips). */
16
16
  renderLink?: (args: {
package/dist/link.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import "./rolldown-runtime-BBjsoOtd.js";
2
- import { shallowArray, useCapability, useOptionalSelector, usePage, useSelector } from "./runtime.js";
2
+ import { shallowArray, useCapability, useOptionalCapability, useOptionalSelector, usePage, useSelector } from "./runtime.js";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import * as React from "react";
5
- import { useEffect } from "react";
5
+ import { useEffect, useMemo } from "react";
6
6
  import { sanitizeExternalUri } from "@embedpdf/web";
7
- import { InteractionToken } from "@embedpdf/plugin-interaction";
7
+ import { InteractionToken } from "@embedpdf/plugin-interaction/contract";
8
8
  import { LinkToken } from "@embedpdf/plugin-link";
9
+ import { ActionsToken, createHoverPump } from "@embedpdf/plugin-actions/contract";
9
10
  export * from "@embedpdf/plugin-link";
10
11
  //#region src/link.tsx
11
12
  /**
@@ -16,8 +17,8 @@ export * from "@embedpdf/plugin-link";
16
17
  * anchors below, the selection menu's "Open link", the style editor's "Go to
17
18
  * link" — goes through here, so none of them can drop the uri outcome again.
18
19
  */
19
- function openLinkTarget(link, target) {
20
- const activation = link.activate(target);
20
+ function openLinkTarget(link, target, context) {
21
+ const activation = link.activate(target, context);
21
22
  if (activation.outcome === "uri") {
22
23
  const href = sanitizeExternalUri(activation.uri);
23
24
  if (href && typeof window !== "undefined") window.open(href, "_blank", "noopener,noreferrer");
@@ -55,6 +56,8 @@ function labelOf(item) {
55
56
  function LinkLayer({ renderLink } = {}) {
56
57
  const page = usePage();
57
58
  const link = useCapability(LinkToken);
59
+ const actions = useOptionalCapability(ActionsToken);
60
+ const linkPump = useMemo(() => actions ? createHoverPump(actions.dispatch) : null, [actions]);
58
61
  const items = useSelector(LinkToken, (c) => c.linksOn(page.pon), shallowArray);
59
62
  const engaged = useSelector(LinkToken, (c) => c.engaged());
60
63
  const editEnabled = useOptionalSelector(InteractionToken, (c) => c.activeTool()?.enables.has("annotation-edit") ?? false, false);
@@ -72,7 +75,28 @@ function LinkLayer({ renderLink } = {}) {
72
75
  },
73
76
  children: visible.map((item) => {
74
77
  const box = boxOf(item, page);
75
- const href = item.target.kind === "uri" ? sanitizeExternalUri(item.target.uri) : null;
78
+ const chained = (item.activate?.root?.next.length ?? 0) > 0;
79
+ const href = item.target.kind === "uri" && !chained ? sanitizeExternalUri(item.target.uri) : null;
80
+ const context = {
81
+ activate: item.activate,
82
+ ref: item.ref,
83
+ pon: page.pon
84
+ };
85
+ const linkSource = item.ref ? {
86
+ kind: "link",
87
+ annotation: item.ref,
88
+ pon: page.pon
89
+ } : null;
90
+ const notify = (event) => {
91
+ if (!actions || !item.ref || !linkSource) return;
92
+ actions.dispatch({
93
+ scope: "annotation",
94
+ event,
95
+ ref: item.ref,
96
+ pon: page.pon,
97
+ source: linkSource
98
+ });
99
+ };
76
100
  const native = /* @__PURE__ */ jsx("a", {
77
101
  href: href ?? void 0,
78
102
  target: "_blank",
@@ -85,15 +109,31 @@ function LinkLayer({ renderLink } = {}) {
85
109
  if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
86
110
  if (href) return;
87
111
  e.preventDefault();
88
- openLinkTarget(link, item.target);
112
+ openLinkTarget(link, item.target, context);
89
113
  },
90
114
  onKeyDown: (e) => {
91
115
  if (e.key === "Enter" || e.key === " ") {
92
116
  e.preventDefault();
93
- openLinkTarget(link, item.target);
117
+ openLinkTarget(link, item.target, context);
94
118
  }
95
119
  },
96
- onPointerDown: (e) => e.stopPropagation(),
120
+ onPointerEnter: () => {
121
+ if (!linkPump || !item.ref || !item.hoverEvents) return;
122
+ linkPump.hover({
123
+ ref: item.ref,
124
+ pon: page.pon,
125
+ ...linkSource ? { source: linkSource } : {},
126
+ events: item.hoverEvents
127
+ });
128
+ },
129
+ onPointerLeave: () => linkPump?.hover(null),
130
+ onPointerUp: () => notify("mouseUp"),
131
+ onFocus: () => notify("focus"),
132
+ onBlur: () => notify("blur"),
133
+ onPointerDown: (e) => {
134
+ e.stopPropagation();
135
+ notify("mouseDown");
136
+ },
97
137
  style: {
98
138
  position: "absolute",
99
139
  left: box.left,
package/dist/link.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"link.js","names":[],"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,OAAO,oBAAoB,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,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,OAAO,QAAQ;CACrB,MAAM,OAAO,cAAc,SAAS;CACpC,MAAM,QAAQ,YAAY,YAA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AQ;KACR,eAAe;IACjB;GACD,CAAA;GAEH,MAAM,MAAM,aAAa;IAAE;IAAM,iBAAiB;GAAO,CAAC,KAAK;GAC/D,OAAO,oBAAC,MAAM,UAAP,EAAA,UAA+B,IAAoB,GAA9B,KAAK,EAAyB;EAC5D,CAAC;CACE,CAAA;AAET;AAEA,SAAgB,UAAU;CACxB,OAAO,cAAc,SAAS;AAChC"}
1
+ {"version":3,"file":"link.js","names":[],"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, useMemo } from 'react';\nimport { ActionsToken, createHoverPump } from '@embedpdf/plugin-actions/contract';\nimport type {\n ActionSource,\n PdfAnnotationEventKind,\n} from '@embedpdf/plugin-actions/contract';\nimport { InteractionToken } from '@embedpdf/plugin-interaction/contract';\nimport {\n LinkToken,\n type LinkActivateContext,\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 useOptionalCapability,\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(\n link: LinkCapability,\n target: PdfLinkTarget,\n context?: LinkActivateContext,\n): LinkActivation {\n const activation = link.activate(target, context);\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 // 'dispatched': the action engine took it — the actions UI adapter owns any\n // URI open (the no-double-open rule); this opener must do NOTHING.\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 // The link plane's /AA event feed: links are behavior-inert to the\n // annotation plane's hover feed while navigable (their pixels are THESE\n // anchors), so E/X/D/U/Fo/Bl can only fire from here. One shared pump per\n // layer — crossing layers still orders Exit before Enter because both\n // sides submit synchronously in DOM event order.\n const actions = useOptionalCapability(ActionsToken);\n const linkPump = useMemo(() => (actions ? createHoverPump(actions.dispatch) : null), [actions]);\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 a chain-free sanitized external URI; blocked\n // schemes, internal targets, and chain-bearing trees (/Next after the\n // URI) activate through the plugin instead — a native navigation\n // would perform the first action and silently drop the rest.\n const chained = (item.activate?.root?.next.length ?? 0) > 0;\n const href =\n item.target.kind === 'uri' && !chained ? sanitizeExternalUri(item.target.uri) : null;\n const context: LinkActivateContext = { activate: item.activate, ref: item.ref, pon: page.pon };\n const linkSource: ActionSource | null = item.ref\n ? { kind: 'link', annotation: item.ref, pon: page.pon }\n : null;\n const notify = (event: Exclude<PdfAnnotationEventKind, 'cursorEnter' | 'cursorExit'>) => {\n if (!actions || !item.ref || !linkSource) return;\n void actions.dispatch({\n scope: 'annotation',\n event,\n ref: item.ref,\n pon: page.pon,\n source: linkSource,\n });\n };\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, context);\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n openLinkTarget(link, item.target, context);\n }\n }}\n onPointerEnter={() => {\n if (!linkPump || !item.ref || !item.hoverEvents) return;\n linkPump.hover({\n ref: item.ref,\n pon: page.pon,\n ...(linkSource ? { source: linkSource } : {}),\n events: item.hoverEvents,\n });\n }}\n onPointerLeave={() => linkPump?.hover(null)}\n onPointerUp={() => notify('mouseUp')}\n onFocus={() => notify('focus')}\n onBlur={() => notify('blur')}\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) => {\n e.stopPropagation();\n notify('mouseDown');\n }}\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":";;;;;;;;;;;;;;;;;;;AAiDA,SAAgB,eACd,MACA,QACA,SACgB;CAChB,MAAM,aAAa,KAAK,SAAS,QAAQ,OAAO;CAChD,IAAI,WAAW,YAAY,OAAO;EAChC,MAAM,OAAO,oBAAoB,WAAW,GAAG;EAC/C,IAAI,QAAQ,OAAO,WAAW,aAAa,OAAO,KAAK,MAAM,UAAU,qBAAqB;CAC9F;CAGA,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,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AO,OAAO;IAC7B,cAAc,OAAO,MAAM;IAG3B,gBAAgB,MAAM;KACpB,EAAE,gBAAgB;KAClB,OAAO,WAAW;IACpB;IACA,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,oBAAC,MAAM,UAAP,EAAA,UAA+B,IAAoB,GAA9B,KAAK,EAAyB;EAC5D,CAAC;CACE,CAAA;AAET;AAEA,SAAgB,UAAU;CACxB,OAAO,cAAc,SAAS;AAChC"}
@@ -1,9 +1,9 @@
1
+ import { AnyPlugin, CapabilityToken, Engine, EngineFactory, EventHook, InitialDocument, Kernel } from "@embedpdf/core";
1
2
  import * as React from "react";
2
- import { AnyPlugin, CapabilityToken, Engine, EngineFactory, InitialDocument, Kernel } from "@embedpdf/core";
3
3
  import { PageFrame, PageTransform, Point, Rect } from "@embedpdf/core-geometry";
4
- import { PageViewDemand } from "@embedpdf/plugin-render";
4
+ import { PageViewDemand } from "@embedpdf/plugin-render/contract";
5
5
  declare namespace runtime_d_exports {
6
- export { DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, PageContextValue, PageProvider, Viewer, ViewerProps, makePageContext, shallowArray, useActiveDocumentId, useCapability, useDocumentId, useDocumentStatus, useDocuments, useKernel, useKernelValue, useOptionalCapability, useOptionalSelector, usePage, useSelector };
6
+ export { DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, PageContextValue, PageProvider, Viewer, ViewerProps, makePageContext, shallowArray, useActiveDocumentId, useCapability, useCapabilityEvent, useDocumentId, useDocumentStatus, useDocuments, useKernel, useKernelValue, useOptionalCapability, useOptionalSelector, usePage, useSelector };
7
7
  }
8
8
  import * as import__embedpdf_core from "@embedpdf/core";
9
9
  declare function useKernel(): Kernel;
@@ -69,6 +69,14 @@ declare function useSelector<C, R>(token: CapabilityToken<C>, select: (cap: C) =
69
69
  * resolves to `fallback` for one frame, then re-renders against the new state.
70
70
  */
71
71
  declare function useOptionalSelector<C, R>(token: CapabilityToken<C>, select: (cap: C) => R, fallback: R, isEqual?: (a: R, b: R) => boolean): R;
72
+ /**
73
+ * Subscribe to a capability's {@link EventHook} for the mounted lifetime —
74
+ * `useCapabilityEvent(ActionsToken, (c) => c.onAction, handler)`. Events
75
+ * carry occurrences, never state (a late subscriber that needs the current
76
+ * value uses `useSelector`). The handler rides a ref, so a fresh closure per
77
+ * render never resubscribes. Null-safe: no plugin/document → no subscription.
78
+ */
79
+ declare function useCapabilityEvent<C, T>(token: CapabilityToken<C>, select: (cap: C) => EventHook<T>, handler: (event: T) => void): void;
72
80
  /** The document registry (open/close/active/list), reactive. */
73
81
  declare function useDocuments(): {
74
82
  docs: import("@embedpdf/core").DocInfo[];
@@ -204,5 +212,5 @@ declare const PageProvider: React.Provider<PageContextValue | null>;
204
212
  declare function usePage(): PageContextValue;
205
213
  declare function makePageContext(documentId: string, view: string, pon: number, pageIndex: number, frame: PageFrame, transform: PageTransform, getRect: () => DOMRect, getViewDemand?: () => PageViewDemand): PageContextValue;
206
214
  //#endregion
207
- export { useSelector as C, usePage as S, useDocuments as _, EmbedPDF as a, useOptionalCapability as b, Viewer as c, runtime_d_exports as d, shallowArray as f, useDocumentStatus as g, useDocumentId as h, DocumentScopeProps as i, ViewerProps as l, useCapability as m, DocumentGateProps as n, PageContextValue as o, useActiveDocumentId as p, DocumentScope as r, PageProvider as s, DocumentGate as t, makePageContext as u, useKernel as v, useOptionalSelector as x, useKernelValue as y };
208
- //# sourceMappingURL=runtime-Cvi0wQ4d.d.cts.map
215
+ export { usePage as C, useOptionalSelector as S, useDocumentStatus as _, EmbedPDF as a, useKernelValue as b, Viewer as c, runtime_d_exports as d, shallowArray as f, useDocumentId as g, useCapabilityEvent as h, DocumentScopeProps as i, ViewerProps as l, useCapability as m, DocumentGateProps as n, PageContextValue as o, useActiveDocumentId as p, DocumentScope as r, PageProvider as s, DocumentGate as t, makePageContext as u, useDocuments as v, useSelector as w, useOptionalCapability as x, useKernel as y };
216
+ //# sourceMappingURL=runtime-DE76hlnl.d.ts.map
@@ -1,9 +1,9 @@
1
- import { AnyPlugin, CapabilityToken, Engine, EngineFactory, InitialDocument, Kernel } from "@embedpdf/core";
2
1
  import * as React from "react";
2
+ import { AnyPlugin, CapabilityToken, Engine, EngineFactory, EventHook, InitialDocument, Kernel } from "@embedpdf/core";
3
3
  import { PageFrame, PageTransform, Point, Rect } from "@embedpdf/core-geometry";
4
- import { PageViewDemand } from "@embedpdf/plugin-render";
4
+ import { PageViewDemand } from "@embedpdf/plugin-render/contract";
5
5
  declare namespace runtime_d_exports {
6
- export { DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, PageContextValue, PageProvider, Viewer, ViewerProps, makePageContext, shallowArray, useActiveDocumentId, useCapability, useDocumentId, useDocumentStatus, useDocuments, useKernel, useKernelValue, useOptionalCapability, useOptionalSelector, usePage, useSelector };
6
+ export { DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, PageContextValue, PageProvider, Viewer, ViewerProps, makePageContext, shallowArray, useActiveDocumentId, useCapability, useCapabilityEvent, useDocumentId, useDocumentStatus, useDocuments, useKernel, useKernelValue, useOptionalCapability, useOptionalSelector, usePage, useSelector };
7
7
  }
8
8
  import * as import__embedpdf_core from "@embedpdf/core";
9
9
  declare function useKernel(): Kernel;
@@ -69,6 +69,14 @@ declare function useSelector<C, R>(token: CapabilityToken<C>, select: (cap: C) =
69
69
  * resolves to `fallback` for one frame, then re-renders against the new state.
70
70
  */
71
71
  declare function useOptionalSelector<C, R>(token: CapabilityToken<C>, select: (cap: C) => R, fallback: R, isEqual?: (a: R, b: R) => boolean): R;
72
+ /**
73
+ * Subscribe to a capability's {@link EventHook} for the mounted lifetime —
74
+ * `useCapabilityEvent(ActionsToken, (c) => c.onAction, handler)`. Events
75
+ * carry occurrences, never state (a late subscriber that needs the current
76
+ * value uses `useSelector`). The handler rides a ref, so a fresh closure per
77
+ * render never resubscribes. Null-safe: no plugin/document → no subscription.
78
+ */
79
+ declare function useCapabilityEvent<C, T>(token: CapabilityToken<C>, select: (cap: C) => EventHook<T>, handler: (event: T) => void): void;
72
80
  /** The document registry (open/close/active/list), reactive. */
73
81
  declare function useDocuments(): {
74
82
  docs: import("@embedpdf/core").DocInfo[];
@@ -204,5 +212,5 @@ declare const PageProvider: React.Provider<PageContextValue | null>;
204
212
  declare function usePage(): PageContextValue;
205
213
  declare function makePageContext(documentId: string, view: string, pon: number, pageIndex: number, frame: PageFrame, transform: PageTransform, getRect: () => DOMRect, getViewDemand?: () => PageViewDemand): PageContextValue;
206
214
  //#endregion
207
- export { useSelector as C, usePage as S, useDocuments as _, EmbedPDF as a, useOptionalCapability as b, Viewer as c, runtime_d_exports as d, shallowArray as f, useDocumentStatus as g, useDocumentId as h, DocumentScopeProps as i, ViewerProps as l, useCapability as m, DocumentGateProps as n, PageContextValue as o, useActiveDocumentId as p, DocumentScope as r, PageProvider as s, DocumentGate as t, makePageContext as u, useKernel as v, useOptionalSelector as x, useKernelValue as y };
208
- //# sourceMappingURL=runtime-DXxr8T4L.d.ts.map
215
+ export { usePage as C, useOptionalSelector as S, useDocumentStatus as _, EmbedPDF as a, useKernelValue as b, Viewer as c, runtime_d_exports as d, shallowArray as f, useDocumentId as g, useCapabilityEvent as h, DocumentScopeProps as i, ViewerProps as l, useCapability as m, DocumentGateProps as n, PageContextValue as o, useActiveDocumentId as p, DocumentScope as r, PageProvider as s, DocumentGate as t, makePageContext as u, useDocuments as v, useSelector as w, useOptionalCapability as x, useKernel as y };
216
+ //# sourceMappingURL=runtime-umHA_xHt.d.cts.map