@embedpdf/react 3.0.0-next.13 → 3.0.0-next.15

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 (232) hide show
  1. package/dist/AnnotationList-CkijRHet-HEFNUIZe.d.cts +877 -0
  2. package/dist/AnnotationList-CkijRHet-HEFNUIZe.d.ts +877 -0
  3. package/dist/actions.cjs +25 -5
  4. package/dist/actions.cjs.map +1 -1
  5. package/dist/actions.d.cts +18 -5
  6. package/dist/actions.d.ts +18 -5
  7. package/dist/actions.js +22 -6
  8. package/dist/actions.js.map +1 -1
  9. package/dist/anchored-DeX95xSd.d.ts +85 -0
  10. package/dist/anchored-DzN3JywS.d.cts +85 -0
  11. package/dist/anchored.cjs +71 -28
  12. package/dist/anchored.cjs.map +1 -1
  13. package/dist/anchored.d.cts +2 -45
  14. package/dist/anchored.d.ts +2 -45
  15. package/dist/anchored.js +56 -19
  16. package/dist/anchored.js.map +1 -1
  17. package/dist/annotation-B48UT2ln.d.ts +302 -0
  18. package/dist/annotation-C1ttM8Wj.js +708 -0
  19. package/dist/annotation-C1ttM8Wj.js.map +1 -0
  20. package/dist/annotation-C9dVwo9b.d.cts +302 -0
  21. package/dist/annotation-Dex5EBda.cjs +830 -0
  22. package/dist/annotation-Dex5EBda.cjs.map +1 -0
  23. package/dist/annotation.cjs +20 -783
  24. package/dist/annotation.d.cts +2 -2
  25. package/dist/annotation.d.ts +2 -2
  26. package/dist/annotation.js +2 -768
  27. package/dist/commands.cjs +68 -28
  28. package/dist/commands.cjs.map +1 -1
  29. package/dist/commands.d.cts +37 -10
  30. package/dist/commands.d.ts +37 -10
  31. package/dist/commands.js +68 -31
  32. package/dist/commands.js.map +1 -1
  33. package/dist/form-55izw0jS.js +511 -0
  34. package/dist/form-55izw0jS.js.map +1 -0
  35. package/dist/form-BNqQfGGH.cjs +548 -0
  36. package/dist/form-BNqQfGGH.cjs.map +1 -0
  37. package/dist/form.cjs +5 -5
  38. package/dist/form.d.cts +32 -25
  39. package/dist/form.d.ts +32 -25
  40. package/dist/form.js +2 -3
  41. package/dist/history.cjs +38 -0
  42. package/dist/history.cjs.map +1 -0
  43. package/dist/history.d.cts +27 -0
  44. package/dist/history.d.ts +27 -0
  45. package/dist/history.js +27 -0
  46. package/dist/history.js.map +1 -0
  47. package/dist/i18n.cjs +26 -30
  48. package/dist/i18n.cjs.map +1 -1
  49. package/dist/i18n.d.cts +24 -21
  50. package/dist/i18n.d.ts +24 -21
  51. package/dist/i18n.js +24 -31
  52. package/dist/i18n.js.map +1 -1
  53. package/dist/index.cjs +213 -57
  54. package/dist/index.d.cts +32 -31
  55. package/dist/index.d.ts +32 -31
  56. package/dist/index.js +33 -29
  57. package/dist/inert-CmBEbKCn.cjs +19 -0
  58. package/dist/inert-CmBEbKCn.cjs.map +1 -0
  59. package/dist/inert-D8fkennb.js +14 -0
  60. package/dist/inert-D8fkennb.js.map +1 -0
  61. package/dist/interaction.cjs +48 -102
  62. package/dist/interaction.cjs.map +1 -1
  63. package/dist/interaction.d.cts +23 -32
  64. package/dist/interaction.d.ts +23 -32
  65. package/dist/interaction.js +33 -102
  66. package/dist/interaction.js.map +1 -1
  67. package/dist/link.cjs +65 -104
  68. package/dist/link.cjs.map +1 -1
  69. package/dist/link.d.cts +21 -16
  70. package/dist/link.d.ts +22 -17
  71. package/dist/link.js +67 -107
  72. package/dist/link.js.map +1 -1
  73. package/dist/measurement.cjs +56 -0
  74. package/dist/measurement.cjs.map +1 -0
  75. package/dist/measurement.d.cts +38 -0
  76. package/dist/measurement.d.ts +38 -0
  77. package/dist/measurement.js +42 -0
  78. package/dist/measurement.js.map +1 -0
  79. package/dist/metadata.cjs +20 -7
  80. package/dist/metadata.cjs.map +1 -1
  81. package/dist/metadata.d.cts +22 -7
  82. package/dist/metadata.d.ts +22 -7
  83. package/dist/metadata.js +20 -10
  84. package/dist/metadata.js.map +1 -1
  85. package/dist/page-edit.cjs +7 -3
  86. package/dist/page-edit.cjs.map +1 -1
  87. package/dist/page-edit.d.cts +6 -2
  88. package/dist/page-edit.d.ts +6 -2
  89. package/dist/page-edit.js +7 -4
  90. package/dist/page-edit.js.map +1 -1
  91. package/dist/page-layers-Bkaaz8Zf.js +26 -0
  92. package/dist/page-layers-Bkaaz8Zf.js.map +1 -0
  93. package/dist/page-layers-BloZDoOV.cjs +37 -0
  94. package/dist/page-layers-BloZDoOV.cjs.map +1 -0
  95. package/dist/page-view.cjs +89 -82
  96. package/dist/page-view.cjs.map +1 -1
  97. package/dist/page-view.d.cts +14 -7
  98. package/dist/page-view.d.ts +18 -11
  99. package/dist/page-view.js +86 -81
  100. package/dist/page-view.js.map +1 -1
  101. package/dist/redaction.cjs +30 -15
  102. package/dist/redaction.cjs.map +1 -1
  103. package/dist/redaction.d.cts +27 -9
  104. package/dist/redaction.d.ts +27 -9
  105. package/dist/redaction.js +29 -18
  106. package/dist/redaction.js.map +1 -1
  107. package/dist/render.cjs +71 -46
  108. package/dist/render.cjs.map +1 -1
  109. package/dist/render.d.cts +17 -5
  110. package/dist/render.d.ts +17 -5
  111. package/dist/render.js +70 -49
  112. package/dist/render.js.map +1 -1
  113. package/dist/runtime-B6xcPsEb.js +398 -0
  114. package/dist/runtime-B6xcPsEb.js.map +1 -0
  115. package/dist/runtime-DBEBlpQV.d.cts +237 -0
  116. package/dist/runtime-V3MVMb91.d.ts +237 -0
  117. package/dist/runtime-fzpGv78v.cjs +555 -0
  118. package/dist/runtime-fzpGv78v.cjs.map +1 -0
  119. package/dist/runtime.cjs +45 -324
  120. package/dist/runtime.d.cts +2 -2
  121. package/dist/runtime.d.ts +2 -2
  122. package/dist/runtime.js +2 -306
  123. package/dist/search.cjs +81 -50
  124. package/dist/search.cjs.map +1 -1
  125. package/dist/search.d.cts +36 -24
  126. package/dist/search.d.ts +36 -24
  127. package/dist/search.js +81 -53
  128. package/dist/search.js.map +1 -1
  129. package/dist/selection.cjs +105 -108
  130. package/dist/selection.cjs.map +1 -1
  131. package/dist/selection.d.cts +54 -26
  132. package/dist/selection.d.ts +56 -28
  133. package/dist/selection.js +103 -110
  134. package/dist/selection.js.map +1 -1
  135. package/dist/shell.cjs +36 -21
  136. package/dist/shell.cjs.map +1 -1
  137. package/dist/shell.d.cts +32 -17
  138. package/dist/shell.d.ts +32 -17
  139. package/dist/shell.js +36 -24
  140. package/dist/shell.js.map +1 -1
  141. package/dist/signature.cjs +29 -48
  142. package/dist/signature.cjs.map +1 -1
  143. package/dist/signature.d.cts +26 -26
  144. package/dist/signature.d.ts +26 -26
  145. package/dist/signature.js +30 -48
  146. package/dist/signature.js.map +1 -1
  147. package/dist/stage-BIG6aeVd.cjs +369 -0
  148. package/dist/stage-BIG6aeVd.cjs.map +1 -0
  149. package/dist/stage-ByFPD-Fv.d.cts +117 -0
  150. package/dist/stage-DaboaheR.d.ts +117 -0
  151. package/dist/stage-DoVekb83.js +302 -0
  152. package/dist/stage-DoVekb83.js.map +1 -0
  153. package/dist/stage-scope-CQgCuf1w.cjs +46 -0
  154. package/dist/stage-scope-CQgCuf1w.cjs.map +1 -0
  155. package/dist/stage-scope-D7ZeNduT.js +23 -0
  156. package/dist/stage-scope-D7ZeNduT.js.map +1 -0
  157. package/dist/stage.cjs +12 -235
  158. package/dist/stage.d.cts +2 -116
  159. package/dist/stage.d.ts +2 -116
  160. package/dist/stage.js +3 -228
  161. package/dist/stamp.cjs +41 -35
  162. package/dist/stamp.cjs.map +1 -1
  163. package/dist/stamp.d.cts +25 -18
  164. package/dist/stamp.d.ts +25 -18
  165. package/dist/stamp.js +40 -37
  166. package/dist/stamp.js.map +1 -1
  167. package/dist/state-0K1I5cM4.d.cts +29 -0
  168. package/dist/state-0K1I5cM4.d.ts +29 -0
  169. package/dist/state-CbgxhwLA.js +62 -0
  170. package/dist/state-CbgxhwLA.js.map +1 -0
  171. package/dist/state-CsfZy_Eq.cjs +73 -0
  172. package/dist/state-CsfZy_Eq.cjs.map +1 -0
  173. package/dist/svg-shapes-Dm1yTR1b.js +40 -0
  174. package/dist/svg-shapes-Dm1yTR1b.js.map +1 -0
  175. package/dist/svg-shapes-zo0GNkc9.cjs +53 -0
  176. package/dist/svg-shapes-zo0GNkc9.cjs.map +1 -0
  177. package/dist/toolbar.cjs +297 -295
  178. package/dist/toolbar.cjs.map +1 -1
  179. package/dist/toolbar.d.cts +58 -68
  180. package/dist/toolbar.d.ts +67 -77
  181. package/dist/toolbar.js +271 -293
  182. package/dist/toolbar.js.map +1 -1
  183. package/dist/view-manager.cjs +34 -0
  184. package/dist/view-manager.cjs.map +1 -0
  185. package/dist/view-manager.d.cts +21 -0
  186. package/dist/view-manager.d.ts +21 -0
  187. package/dist/view-manager.js +23 -0
  188. package/dist/view-manager.js.map +1 -0
  189. package/package.json +41 -38
  190. package/dist/AnnotationListSnapshot-D3mFut1e-C_GMpK25.d.cts +0 -546
  191. package/dist/AnnotationListSnapshot-D3mFut1e-C_GMpK25.d.ts +0 -546
  192. package/dist/annotation-BCED_p9H.d.cts +0 -160
  193. package/dist/annotation-anchors-CetwM1g7.js +0 -15
  194. package/dist/annotation-anchors-CetwM1g7.js.map +0 -1
  195. package/dist/annotation-anchors-DuYRBJLl.cjs +0 -26
  196. package/dist/annotation-anchors-DuYRBJLl.cjs.map +0 -1
  197. package/dist/annotation-hooks-BB5ZhPpf.cjs +0 -16
  198. package/dist/annotation-hooks-BB5ZhPpf.cjs.map +0 -1
  199. package/dist/annotation-hooks-Df8EmzDO.js +0 -11
  200. package/dist/annotation-hooks-Df8EmzDO.js.map +0 -1
  201. package/dist/annotation-k38KDlIZ.d.ts +0 -160
  202. package/dist/annotation-menu.cjs +0 -64
  203. package/dist/annotation-menu.cjs.map +0 -1
  204. package/dist/annotation-menu.d.cts +0 -33
  205. package/dist/annotation-menu.d.ts +0 -33
  206. package/dist/annotation-menu.js +0 -48
  207. package/dist/annotation-menu.js.map +0 -1
  208. package/dist/annotation.cjs.map +0 -1
  209. package/dist/annotation.js.map +0 -1
  210. package/dist/form-BVumS7up.cjs +0 -926
  211. package/dist/form-BVumS7up.cjs.map +0 -1
  212. package/dist/form-CK3mp99m.js +0 -895
  213. package/dist/form-CK3mp99m.js.map +0 -1
  214. package/dist/rolldown-runtime-BBjsoOtd.js +0 -27
  215. package/dist/runtime-DE76hlnl.d.ts +0 -216
  216. package/dist/runtime-umHA_xHt.d.cts +0 -216
  217. package/dist/runtime.cjs.map +0 -1
  218. package/dist/runtime.js.map +0 -1
  219. package/dist/scrollbar.cjs +0 -241
  220. package/dist/scrollbar.cjs.map +0 -1
  221. package/dist/scrollbar.d.cts +0 -42
  222. package/dist/scrollbar.d.ts +0 -42
  223. package/dist/scrollbar.js +0 -213
  224. package/dist/scrollbar.js.map +0 -1
  225. package/dist/stage.cjs.map +0 -1
  226. package/dist/stage.js.map +0 -1
  227. package/dist/views.cjs +0 -35
  228. package/dist/views.cjs.map +0 -1
  229. package/dist/views.d.cts +0 -21
  230. package/dist/views.d.ts +0 -21
  231. package/dist/views.js +0 -27
  232. package/dist/views.js.map +0 -1
package/dist/actions.cjs CHANGED
@@ -1,17 +1,34 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_runtime = require("./runtime.cjs");
3
- let react = require("react");
2
+ require("./rolldown-runtime-DDXJien1.cjs");
3
+ const require_runtime = require("./runtime-fzpGv78v.cjs");
4
+ const require_state = require("./state-CsfZy_Eq.cjs");
4
5
  let _embedpdf_web = require("@embedpdf/web");
6
+ let react = require("react");
5
7
  let _embedpdf_plugin_stage_contract = require("@embedpdf/plugin-stage/contract");
6
8
  let _embedpdf_plugin_actions = require("@embedpdf/plugin-actions");
7
9
  //#region src/actions.tsx
8
10
  /**
11
+ * The actions capability (executeNamed, execute, dispatch, the settings) of
12
+ * the surrounding `<DocumentScope>`'s document, else the active one. Outside
13
+ * a document, the settings calls work and every other method throws
14
+ * `not-ready`.
15
+ */
16
+ function useActions() {
17
+ return require_runtime.useCapability(_embedpdf_plugin_actions.ActionsToken);
18
+ }
19
+ /** The actions settings (`policy`, `triggers`, `openSequence`, `javascript`), with or without a document. Takes a selector. */
20
+ const useActionsSettings = require_state.settingsHook(_embedpdf_plugin_actions.ActionsToken);
21
+ /** Subscribe to one actions event for the mounted lifetime: `useActionsEvent((actions) => actions.onExecuted, handler)`. */
22
+ function useActionsEvent(select, handler) {
23
+ require_runtime.useCapabilityEvent(_embedpdf_plugin_actions.ActionsToken, select, handler);
24
+ }
25
+ /**
9
26
  * Install the UI adapter for the active document's action dispatcher. The
10
- * DEFAULT policy — the origin×phase visibility matrix, sanitizeExternalUri
27
+ * default policy — the origin×phase visibility matrix, sanitizeExternalUri
11
28
  * URI opens, browser print/alert fallbacks — is `@embedpdf/web`'s
12
- * `createDefaultActionsUiAdapter`, written ONCE for every binding; this
29
+ * `createDefaultActionsUiAdapter`, written once for every binding; this
13
30
  * hook is React glue only (late-bound handlers, stage navigation,
14
- * identity-safe install/uninstall). The doc.print AUTHORITY gate is
31
+ * identity-safe install/uninstall). The doc.print authority gate is
15
32
  * upstream (the actions plugin) and not overridable.
16
33
  */
17
34
  function useActionsUiAdapter(handlers) {
@@ -29,6 +46,9 @@ function useActionsUiAdapter(handlers) {
29
46
  }, [actions, stage]);
30
47
  }
31
48
  //#endregion
49
+ exports.useActions = useActions;
50
+ exports.useActionsEvent = useActionsEvent;
51
+ exports.useActionsSettings = useActionsSettings;
32
52
  exports.useActionsUiAdapter = useActionsUiAdapter;
33
53
  Object.keys(_embedpdf_plugin_actions).forEach(function(k) {
34
54
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
@@ -1 +1 @@
1
- {"version":3,"file":"actions.cjs","names":["useOptionalCapability","ActionsToken","StageToken"],"sources":["../src/actions.tsx"],"sourcesContent":["/**\n * The React view of @embedpdf/plugin-actions — the action engine's UI port.\n *\n * The plugin is DOM-free; opening tabs and printing are this layer's job.\n * `useActionsUiAdapter()` installs the browser-default adapter (the same\n * sanitizer + window.open the link layer uses; print = the browser dialog),\n * overridable per handler. Without it, `adapter`-routed actions (URI, Print)\n * report `no-adapter` diagnostics instead of executing.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-actions';\nimport { useEffect, useRef } from 'react';\nimport { ActionsToken, type ActionUiAdapter } from '@embedpdf/plugin-actions';\nimport { StageToken } from '@embedpdf/plugin-stage/contract';\nimport { createDefaultActionsUiAdapter } from '@embedpdf/web';\n\nimport { useOptionalCapability } from './runtime';\n\n/** Override any subset of the default adapter policy. */\nexport type ActionsUiHandlers = Partial<ActionUiAdapter>;\n\n/**\n * Install the UI adapter for the active document's action dispatcher. The\n * DEFAULT policy — the origin×phase visibility matrix, sanitizeExternalUri\n * URI opens, browser print/alert fallbacks — is `@embedpdf/web`'s\n * `createDefaultActionsUiAdapter`, written ONCE for every binding; this\n * hook is React glue only (late-bound handlers, stage navigation,\n * identity-safe install/uninstall). The doc.print AUTHORITY gate is\n * upstream (the actions plugin) and not overridable.\n */\nexport function useActionsUiAdapter(handlers?: ActionsUiHandlers): void {\n const actions = useOptionalCapability(ActionsToken);\n const stage = useOptionalCapability(StageToken);\n const handlersRef = useRef(handlers);\n handlersRef.current = handlers;\n\n useEffect(() => {\n if (!actions) return;\n const adapter: ActionUiAdapter = createDefaultActionsUiAdapter({\n overrides: () => handlersRef.current,\n goToPage: (page) => stage?.goToPage(page),\n });\n return actions.setUiAdapter(adapter);\n }, [actions, stage]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA+BA,SAAgB,oBAAoB,UAAoC;CACtE,MAAM,UAAUA,gBAAAA,sBAAsBC,yBAAAA,YAAY;CAClD,MAAM,QAAQD,gBAAAA,sBAAsBE,gCAAAA,UAAU;CAC9C,MAAM,eAAA,GAAA,MAAA,OAAA,CAAqB,QAAQ;CACnC,YAAY,UAAU;CAEtB,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,CAAC,SAAS;EACd,MAAM,WAAA,GAAA,cAAA,8BAAA,CAAyD;GAC7D,iBAAiB,YAAY;GAC7B,WAAW,SAAS,OAAO,SAAS,IAAI;EAC1C,CAAC;EACD,OAAO,QAAQ,aAAa,OAAO;CACrC,GAAG,CAAC,SAAS,KAAK,CAAC;AACrB"}
1
+ {"version":3,"file":"actions.cjs","names":["useCapability","ActionsToken","settingsHook","useOptionalCapability","StageToken"],"sources":["../src/actions.tsx"],"sourcesContent":["/**\n * The React view of @embedpdf/plugin-actions — the action engine's UI port.\n *\n * The plugin is DOM-free; opening tabs and printing are this layer's job.\n * `useActionsUiAdapter()` installs the browser-default adapter (the same\n * sanitizer + window.open the link layer uses; print = the browser dialog),\n * overridable per handler. Without it, `adapter`-routed actions (URI, Print)\n * report `no-adapter` diagnostics instead of executing.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-actions';\nimport { useEffect, useRef } from 'react';\nimport {\n ActionsToken,\n type ActionsCapability,\n type ActionUiAdapter,\n} from '@embedpdf/plugin-actions';\nimport { StageToken } from '@embedpdf/plugin-stage/contract';\nimport type { EventHook } from '@embedpdf/core';\nimport { createDefaultActionsUiAdapter } from '@embedpdf/web';\n\nimport { useCapability, useCapabilityEvent, useOptionalCapability } from './runtime';\nimport { settingsHook } from './state';\n\n/**\n * The actions capability (executeNamed, execute, dispatch, the settings) of\n * the surrounding `<DocumentScope>`'s document, else the active one. Outside\n * a document, the settings calls work and every other method throws\n * `not-ready`.\n */\nexport function useActions(): ActionsCapability {\n return useCapability(ActionsToken);\n}\n\n/** The actions settings (`policy`, `triggers`, `openSequence`, `javascript`), with or without a document. Takes a selector. */\nexport const useActionsSettings = settingsHook(ActionsToken);\n\n/** Subscribe to one actions event for the mounted lifetime: `useActionsEvent((actions) => actions.onExecuted, handler)`. */\nexport function useActionsEvent<T>(\n select: (actions: ActionsCapability) => EventHook<T>,\n handler: (event: T) => void,\n): void {\n useCapabilityEvent(ActionsToken, select, handler);\n}\n\n/** Override any subset of the default adapter policy. */\nexport type ActionsUiHandlers = Partial<ActionUiAdapter>;\n\n/**\n * Install the UI adapter for the active document's action dispatcher. The\n * default policy — the origin×phase visibility matrix, sanitizeExternalUri\n * URI opens, browser print/alert fallbacks — is `@embedpdf/web`'s\n * `createDefaultActionsUiAdapter`, written once for every binding; this\n * hook is React glue only (late-bound handlers, stage navigation,\n * identity-safe install/uninstall). The doc.print authority gate is\n * upstream (the actions plugin) and not overridable.\n */\nexport function useActionsUiAdapter(handlers?: ActionsUiHandlers): void {\n const actions = useOptionalCapability(ActionsToken);\n const stage = useOptionalCapability(StageToken);\n const handlersRef = useRef(handlers);\n handlersRef.current = handlers;\n\n useEffect(() => {\n if (!actions) return;\n const adapter: ActionUiAdapter = createDefaultActionsUiAdapter({\n overrides: () => handlersRef.current,\n goToPage: (page) => stage?.goToPage(page),\n });\n return actions.setUiAdapter(adapter);\n }, [actions, stage]);\n}\n"],"mappings":";;;;;;;;;;;;;;;AA+BA,SAAgB,aAAgC;CAC9C,OAAOA,gBAAAA,cAAcC,yBAAAA,YAAY;AACnC;;AAGA,MAAa,qBAAqBC,cAAAA,aAAaD,yBAAAA,YAAY;;AAG3D,SAAgB,gBACd,QACA,SACM;CACN,gBAAA,mBAAmBA,yBAAAA,cAAc,QAAQ,OAAO;AAClD;;;;;;;;;;AAcA,SAAgB,oBAAoB,UAAoC;CACtE,MAAM,UAAUE,gBAAAA,sBAAsBF,yBAAAA,YAAY;CAClD,MAAM,QAAQE,gBAAAA,sBAAsBC,gCAAAA,UAAU;CAC9C,MAAM,eAAA,GAAA,MAAA,OAAA,CAAqB,QAAQ;CACnC,YAAY,UAAU;CAEtB,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,CAAC,SAAS;EACd,MAAM,WAAA,GAAA,cAAA,8BAAA,CAAyD;GAC7D,iBAAiB,YAAY;GAC7B,WAAW,SAAS,OAAO,SAAS,IAAI;EAC1C,CAAC;EACD,OAAO,QAAQ,aAAa,OAAO;CACrC,GAAG,CAAC,SAAS,KAAK,CAAC;AACrB"}
@@ -1,18 +1,31 @@
1
- import { ActionUiAdapter } from "@embedpdf/plugin-actions";
1
+ import { t as SettingsHook } from "./state-0K1I5cM4.cjs";
2
+ import { EventHook } from "@embedpdf/core";
3
+ import { ActionUiAdapter, ActionsCapability } from "@embedpdf/plugin-actions";
2
4
  export * from "@embedpdf/plugin-actions";
3
5
  //#region src/actions.d.ts
6
+ /**
7
+ * The actions capability (executeNamed, execute, dispatch, the settings) of
8
+ * the surrounding `<DocumentScope>`'s document, else the active one. Outside
9
+ * a document, the settings calls work and every other method throws
10
+ * `not-ready`.
11
+ */
12
+ declare function useActions(): ActionsCapability;
13
+ /** The actions settings (`policy`, `triggers`, `openSequence`, `javascript`), with or without a document. Takes a selector. */
14
+ declare const useActionsSettings: SettingsHook<import("@embedpdf/plugin-actions").ActionsSettings>;
15
+ /** Subscribe to one actions event for the mounted lifetime: `useActionsEvent((actions) => actions.onExecuted, handler)`. */
16
+ declare function useActionsEvent<T>(select: (actions: ActionsCapability) => EventHook<T>, handler: (event: T) => void): void;
4
17
  /** Override any subset of the default adapter policy. */
5
18
  type ActionsUiHandlers = Partial<ActionUiAdapter>;
6
19
  /**
7
20
  * Install the UI adapter for the active document's action dispatcher. The
8
- * DEFAULT policy — the origin×phase visibility matrix, sanitizeExternalUri
21
+ * default policy — the origin×phase visibility matrix, sanitizeExternalUri
9
22
  * URI opens, browser print/alert fallbacks — is `@embedpdf/web`'s
10
- * `createDefaultActionsUiAdapter`, written ONCE for every binding; this
23
+ * `createDefaultActionsUiAdapter`, written once for every binding; this
11
24
  * hook is React glue only (late-bound handlers, stage navigation,
12
- * identity-safe install/uninstall). The doc.print AUTHORITY gate is
25
+ * identity-safe install/uninstall). The doc.print authority gate is
13
26
  * upstream (the actions plugin) and not overridable.
14
27
  */
15
28
  declare function useActionsUiAdapter(handlers?: ActionsUiHandlers): void;
16
29
  //#endregion
17
- export { ActionsUiHandlers, useActionsUiAdapter };
30
+ export { ActionsUiHandlers, useActions, useActionsEvent, useActionsSettings, useActionsUiAdapter };
18
31
  //# sourceMappingURL=actions.d.cts.map
package/dist/actions.d.ts CHANGED
@@ -1,18 +1,31 @@
1
- import { ActionUiAdapter } from "@embedpdf/plugin-actions";
1
+ import { t as SettingsHook } from "./state-0K1I5cM4.js";
2
+ import { EventHook } from "@embedpdf/core";
3
+ import { ActionUiAdapter, ActionsCapability } from "@embedpdf/plugin-actions";
2
4
  export * from "@embedpdf/plugin-actions";
3
5
  //#region src/actions.d.ts
6
+ /**
7
+ * The actions capability (executeNamed, execute, dispatch, the settings) of
8
+ * the surrounding `<DocumentScope>`'s document, else the active one. Outside
9
+ * a document, the settings calls work and every other method throws
10
+ * `not-ready`.
11
+ */
12
+ declare function useActions(): ActionsCapability;
13
+ /** The actions settings (`policy`, `triggers`, `openSequence`, `javascript`), with or without a document. Takes a selector. */
14
+ declare const useActionsSettings: SettingsHook<import("@embedpdf/plugin-actions").ActionsSettings>;
15
+ /** Subscribe to one actions event for the mounted lifetime: `useActionsEvent((actions) => actions.onExecuted, handler)`. */
16
+ declare function useActionsEvent<T>(select: (actions: ActionsCapability) => EventHook<T>, handler: (event: T) => void): void;
4
17
  /** Override any subset of the default adapter policy. */
5
18
  type ActionsUiHandlers = Partial<ActionUiAdapter>;
6
19
  /**
7
20
  * Install the UI adapter for the active document's action dispatcher. The
8
- * DEFAULT policy — the origin×phase visibility matrix, sanitizeExternalUri
21
+ * default policy — the origin×phase visibility matrix, sanitizeExternalUri
9
22
  * URI opens, browser print/alert fallbacks — is `@embedpdf/web`'s
10
- * `createDefaultActionsUiAdapter`, written ONCE for every binding; this
23
+ * `createDefaultActionsUiAdapter`, written once for every binding; this
11
24
  * hook is React glue only (late-bound handlers, stage navigation,
12
- * identity-safe install/uninstall). The doc.print AUTHORITY gate is
25
+ * identity-safe install/uninstall). The doc.print authority gate is
13
26
  * upstream (the actions plugin) and not overridable.
14
27
  */
15
28
  declare function useActionsUiAdapter(handlers?: ActionsUiHandlers): void;
16
29
  //#endregion
17
- export { ActionsUiHandlers, useActionsUiAdapter };
30
+ export { ActionsUiHandlers, useActions, useActionsEvent, useActionsSettings, useActionsUiAdapter };
18
31
  //# sourceMappingURL=actions.d.ts.map
package/dist/actions.js CHANGED
@@ -1,17 +1,33 @@
1
- import { useOptionalCapability } from "./runtime.js";
2
- import { useEffect, useRef } from "react";
1
+ import { S as useOptionalCapability, f as useCapability, p as useCapabilityEvent } from "./runtime-B6xcPsEb.js";
2
+ import { t as settingsHook } from "./state-CbgxhwLA.js";
3
3
  import { createDefaultActionsUiAdapter } from "@embedpdf/web";
4
+ import { useEffect, useRef } from "react";
4
5
  import { StageToken } from "@embedpdf/plugin-stage/contract";
5
6
  import { ActionsToken } from "@embedpdf/plugin-actions";
6
7
  export * from "@embedpdf/plugin-actions";
7
8
  //#region src/actions.tsx
8
9
  /**
10
+ * The actions capability (executeNamed, execute, dispatch, the settings) of
11
+ * the surrounding `<DocumentScope>`'s document, else the active one. Outside
12
+ * a document, the settings calls work and every other method throws
13
+ * `not-ready`.
14
+ */
15
+ function useActions() {
16
+ return useCapability(ActionsToken);
17
+ }
18
+ /** The actions settings (`policy`, `triggers`, `openSequence`, `javascript`), with or without a document. Takes a selector. */
19
+ const useActionsSettings = settingsHook(ActionsToken);
20
+ /** Subscribe to one actions event for the mounted lifetime: `useActionsEvent((actions) => actions.onExecuted, handler)`. */
21
+ function useActionsEvent(select, handler) {
22
+ useCapabilityEvent(ActionsToken, select, handler);
23
+ }
24
+ /**
9
25
  * Install the UI adapter for the active document's action dispatcher. The
10
- * DEFAULT policy — the origin×phase visibility matrix, sanitizeExternalUri
26
+ * default policy — the origin×phase visibility matrix, sanitizeExternalUri
11
27
  * URI opens, browser print/alert fallbacks — is `@embedpdf/web`'s
12
- * `createDefaultActionsUiAdapter`, written ONCE for every binding; this
28
+ * `createDefaultActionsUiAdapter`, written once for every binding; this
13
29
  * hook is React glue only (late-bound handlers, stage navigation,
14
- * identity-safe install/uninstall). The doc.print AUTHORITY gate is
30
+ * identity-safe install/uninstall). The doc.print authority gate is
15
31
  * upstream (the actions plugin) and not overridable.
16
32
  */
17
33
  function useActionsUiAdapter(handlers) {
@@ -29,6 +45,6 @@ function useActionsUiAdapter(handlers) {
29
45
  }, [actions, stage]);
30
46
  }
31
47
  //#endregion
32
- export { useActionsUiAdapter };
48
+ export { useActions, useActionsEvent, useActionsSettings, useActionsUiAdapter };
33
49
 
34
50
  //# sourceMappingURL=actions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"actions.js","names":[],"sources":["../src/actions.tsx"],"sourcesContent":["/**\n * The React view of @embedpdf/plugin-actions — the action engine's UI port.\n *\n * The plugin is DOM-free; opening tabs and printing are this layer's job.\n * `useActionsUiAdapter()` installs the browser-default adapter (the same\n * sanitizer + window.open the link layer uses; print = the browser dialog),\n * overridable per handler. Without it, `adapter`-routed actions (URI, Print)\n * report `no-adapter` diagnostics instead of executing.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-actions';\nimport { useEffect, useRef } from 'react';\nimport { ActionsToken, type ActionUiAdapter } from '@embedpdf/plugin-actions';\nimport { StageToken } from '@embedpdf/plugin-stage/contract';\nimport { createDefaultActionsUiAdapter } from '@embedpdf/web';\n\nimport { useOptionalCapability } from './runtime';\n\n/** Override any subset of the default adapter policy. */\nexport type ActionsUiHandlers = Partial<ActionUiAdapter>;\n\n/**\n * Install the UI adapter for the active document's action dispatcher. The\n * DEFAULT policy — the origin×phase visibility matrix, sanitizeExternalUri\n * URI opens, browser print/alert fallbacks — is `@embedpdf/web`'s\n * `createDefaultActionsUiAdapter`, written ONCE for every binding; this\n * hook is React glue only (late-bound handlers, stage navigation,\n * identity-safe install/uninstall). The doc.print AUTHORITY gate is\n * upstream (the actions plugin) and not overridable.\n */\nexport function useActionsUiAdapter(handlers?: ActionsUiHandlers): void {\n const actions = useOptionalCapability(ActionsToken);\n const stage = useOptionalCapability(StageToken);\n const handlersRef = useRef(handlers);\n handlersRef.current = handlers;\n\n useEffect(() => {\n if (!actions) return;\n const adapter: ActionUiAdapter = createDefaultActionsUiAdapter({\n overrides: () => handlersRef.current,\n goToPage: (page) => stage?.goToPage(page),\n });\n return actions.setUiAdapter(adapter);\n }, [actions, stage]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA+BA,SAAgB,oBAAoB,UAAoC;CACtE,MAAM,UAAU,sBAAsB,YAAY;CAClD,MAAM,QAAQ,sBAAsB,UAAU;CAC9C,MAAM,cAAc,OAAO,QAAQ;CACnC,YAAY,UAAU;CAEtB,gBAAgB;EACd,IAAI,CAAC,SAAS;EACd,MAAM,UAA2B,8BAA8B;GAC7D,iBAAiB,YAAY;GAC7B,WAAW,SAAS,OAAO,SAAS,IAAI;EAC1C,CAAC;EACD,OAAO,QAAQ,aAAa,OAAO;CACrC,GAAG,CAAC,SAAS,KAAK,CAAC;AACrB"}
1
+ {"version":3,"file":"actions.js","names":[],"sources":["../src/actions.tsx"],"sourcesContent":["/**\n * The React view of @embedpdf/plugin-actions — the action engine's UI port.\n *\n * The plugin is DOM-free; opening tabs and printing are this layer's job.\n * `useActionsUiAdapter()` installs the browser-default adapter (the same\n * sanitizer + window.open the link layer uses; print = the browser dialog),\n * overridable per handler. Without it, `adapter`-routed actions (URI, Print)\n * report `no-adapter` diagnostics instead of executing.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-actions';\nimport { useEffect, useRef } from 'react';\nimport {\n ActionsToken,\n type ActionsCapability,\n type ActionUiAdapter,\n} from '@embedpdf/plugin-actions';\nimport { StageToken } from '@embedpdf/plugin-stage/contract';\nimport type { EventHook } from '@embedpdf/core';\nimport { createDefaultActionsUiAdapter } from '@embedpdf/web';\n\nimport { useCapability, useCapabilityEvent, useOptionalCapability } from './runtime';\nimport { settingsHook } from './state';\n\n/**\n * The actions capability (executeNamed, execute, dispatch, the settings) of\n * the surrounding `<DocumentScope>`'s document, else the active one. Outside\n * a document, the settings calls work and every other method throws\n * `not-ready`.\n */\nexport function useActions(): ActionsCapability {\n return useCapability(ActionsToken);\n}\n\n/** The actions settings (`policy`, `triggers`, `openSequence`, `javascript`), with or without a document. Takes a selector. */\nexport const useActionsSettings = settingsHook(ActionsToken);\n\n/** Subscribe to one actions event for the mounted lifetime: `useActionsEvent((actions) => actions.onExecuted, handler)`. */\nexport function useActionsEvent<T>(\n select: (actions: ActionsCapability) => EventHook<T>,\n handler: (event: T) => void,\n): void {\n useCapabilityEvent(ActionsToken, select, handler);\n}\n\n/** Override any subset of the default adapter policy. */\nexport type ActionsUiHandlers = Partial<ActionUiAdapter>;\n\n/**\n * Install the UI adapter for the active document's action dispatcher. The\n * default policy — the origin×phase visibility matrix, sanitizeExternalUri\n * URI opens, browser print/alert fallbacks — is `@embedpdf/web`'s\n * `createDefaultActionsUiAdapter`, written once for every binding; this\n * hook is React glue only (late-bound handlers, stage navigation,\n * identity-safe install/uninstall). The doc.print authority gate is\n * upstream (the actions plugin) and not overridable.\n */\nexport function useActionsUiAdapter(handlers?: ActionsUiHandlers): void {\n const actions = useOptionalCapability(ActionsToken);\n const stage = useOptionalCapability(StageToken);\n const handlersRef = useRef(handlers);\n handlersRef.current = handlers;\n\n useEffect(() => {\n if (!actions) return;\n const adapter: ActionUiAdapter = createDefaultActionsUiAdapter({\n overrides: () => handlersRef.current,\n goToPage: (page) => stage?.goToPage(page),\n });\n return actions.setUiAdapter(adapter);\n }, [actions, stage]);\n}\n"],"mappings":";;;;;;;;;;;;;;AA+BA,SAAgB,aAAgC;CAC9C,OAAO,cAAc,YAAY;AACnC;;AAGA,MAAa,qBAAqB,aAAa,YAAY;;AAG3D,SAAgB,gBACd,QACA,SACM;CACN,mBAAmB,cAAc,QAAQ,OAAO;AAClD;;;;;;;;;;AAcA,SAAgB,oBAAoB,UAAoC;CACtE,MAAM,UAAU,sBAAsB,YAAY;CAClD,MAAM,QAAQ,sBAAsB,UAAU;CAC9C,MAAM,cAAc,OAAO,QAAQ;CACnC,YAAY,UAAU;CAEtB,gBAAgB;EACd,IAAI,CAAC,SAAS;EACd,MAAM,UAA2B,8BAA8B;GAC7D,iBAAiB,YAAY;GAC7B,WAAW,SAAS,OAAO,SAAS,IAAI;EAC1C,CAAC;EACD,OAAO,QAAQ,aAAa,OAAO;CACrC,GAAG,CAAC,SAAS,KAAK,CAAC;AACrB"}
@@ -0,0 +1,85 @@
1
+ import { AnchorTarget, AnchorTarget as AnchorTarget$1, AnchoredPlacement, AnchoredPlacement as AnchoredPlacement$1, AnchoredRect, AnchoredSide, PageViewEnv, ViewProjector, ViewProjector as ViewProjector$1 } from "@embedpdf/web";
2
+ import * as React$1 from "react";
3
+ //#region src/anchored.d.ts
4
+ /**
5
+ * What a page surface provides via context: the pure projection snapshot,
6
+ * bound to React's reactivity.
7
+ */
8
+ interface ProjectorBinding {
9
+ projector: ViewProjector;
10
+ /**
11
+ * Changes identity exactly when projection may have changed for
12
+ * state-driven reasons — the Stage uses its `visiblePages()` value (a
13
+ * stable reference that already folds camera, viewport, scene and DPR).
14
+ * Consumers re-render because the binding's identity changes with it;
15
+ * nothing reads this field, but it is what makes the memoized binding
16
+ * change, so do not "optimize" it away.
17
+ */
18
+ revision: unknown;
19
+ /** Browser-driven invalidation only (PageView scroll/resize — see
20
+ * `observeClientGeometry`). The Stage deliberately provides none. */
21
+ subscribe?: (callback: () => void) => () => void;
22
+ }
23
+ /** Installed by page surfaces (<Stage>, <PageView>) — not by app code. */
24
+ declare const ProjectorProvider: React$1.Provider<ProjectorBinding | null>;
25
+ /**
26
+ * The pages a surface shows right now, by object number. It is a value of its
27
+ * own, next to the projection, because it changes only when a page comes on
28
+ * screen or leaves it: anchored UI on other pages reads only this, so it
29
+ * isn't rendered again on every camera frame.
30
+ */
31
+ type ShownPages = ReadonlySet<number>;
32
+ /** Installed by page surfaces (<Stage>, <PageView>) — not by app code. */
33
+ declare const ShownPagesProvider: React$1.Provider<ShownPages | null>;
34
+ /** The surface's projector binding, or null outside any page surface — for
35
+ * chrome that degrades (and warns) instead of throwing. */
36
+ declare function useOptionalProjectorBinding(): ProjectorBinding | null;
37
+ /** The surface's projector binding. Reading it subscribes the caller to
38
+ * projection changes (the binding's identity is the revision). */
39
+ declare function useProjectorBinding(): ProjectorBinding;
40
+ interface AnchoredProps {
41
+ /**
42
+ * The box on a page to sit next to, in page coordinates: `{ page, bounds }`,
43
+ * with `avoid` points to keep clear of. `null`, or a target without
44
+ * `bounds` (a search match with no geometry), hides it.
45
+ */
46
+ anchor: (Omit<AnchorTarget, 'bounds'> & {
47
+ bounds?: AnchoredRect;
48
+ }) | null;
49
+ /**
50
+ * Where to sit: a side of the box, centred, or lined up with the side's
51
+ * start or end (`'top-end'`). Default 'top'.
52
+ */
53
+ placement?: AnchoredPlacement;
54
+ /**
55
+ * Gap in screen px between the box and the content, and between the content
56
+ * and the view's edge. Negative overlaps the box. Default 8.
57
+ */
58
+ gap?: number;
59
+ /**
60
+ * Stay where `placement` puts it: never flip to the other side, never move
61
+ * to stay in view, and scroll away with the box. For badges and status;
62
+ * menus leave it off. Default false.
63
+ */
64
+ pinned?: boolean;
65
+ children: React$1.ReactNode;
66
+ }
67
+ /**
68
+ * Position `children` around a page-space anchor, on whichever page surface
69
+ * is in scope. Projection runs during render from the shared pure helper.
70
+ * Once the content's size is measured, it flips to the opposite side when
71
+ * the chosen one has no room, and stays inside the view, unless `pinned`.
72
+ * Its wrapper's `data-placement` is where it sits now: `placement`, or the
73
+ * opposite side after a flip, so what opens from the content can open away
74
+ * from the box.
75
+ * Pointer isolation keeps a click inside anchored UI from reaching the
76
+ * surface's own listener (which would read it as a click outside).
77
+ *
78
+ * Anchored UI on a page that isn't shown renders nothing and reads only the
79
+ * pages on screen, so a document with hundreds of badges costs only the ones
80
+ * in view while people scroll and zoom.
81
+ */
82
+ declare function Anchored(props: AnchoredProps): import("react/jsx-runtime").JSX.Element | null;
83
+ //#endregion
84
+ export { AnchoredSide as a, ProjectorProvider as c, ViewProjector$1 as d, useOptionalProjectorBinding as f, AnchoredProps as i, ShownPages as l, Anchored as n, PageViewEnv as o, useProjectorBinding as p, AnchoredPlacement$1 as r, ProjectorBinding as s, AnchorTarget$1 as t, ShownPagesProvider as u };
85
+ //# sourceMappingURL=anchored-DeX95xSd.d.ts.map
@@ -0,0 +1,85 @@
1
+ import * as React from "react";
2
+ import { AnchorTarget, AnchorTarget as AnchorTarget$1, AnchoredPlacement, AnchoredPlacement as AnchoredPlacement$1, AnchoredRect, AnchoredSide, PageViewEnv, ViewProjector, ViewProjector as ViewProjector$1 } from "@embedpdf/web";
3
+ //#region src/anchored.d.ts
4
+ /**
5
+ * What a page surface provides via context: the pure projection snapshot,
6
+ * bound to React's reactivity.
7
+ */
8
+ interface ProjectorBinding {
9
+ projector: ViewProjector;
10
+ /**
11
+ * Changes identity exactly when projection may have changed for
12
+ * state-driven reasons — the Stage uses its `visiblePages()` value (a
13
+ * stable reference that already folds camera, viewport, scene and DPR).
14
+ * Consumers re-render because the binding's identity changes with it;
15
+ * nothing reads this field, but it is what makes the memoized binding
16
+ * change, so do not "optimize" it away.
17
+ */
18
+ revision: unknown;
19
+ /** Browser-driven invalidation only (PageView scroll/resize — see
20
+ * `observeClientGeometry`). The Stage deliberately provides none. */
21
+ subscribe?: (callback: () => void) => () => void;
22
+ }
23
+ /** Installed by page surfaces (<Stage>, <PageView>) — not by app code. */
24
+ declare const ProjectorProvider: React.Provider<ProjectorBinding | null>;
25
+ /**
26
+ * The pages a surface shows right now, by object number. It is a value of its
27
+ * own, next to the projection, because it changes only when a page comes on
28
+ * screen or leaves it: anchored UI on other pages reads only this, so it
29
+ * isn't rendered again on every camera frame.
30
+ */
31
+ type ShownPages = ReadonlySet<number>;
32
+ /** Installed by page surfaces (<Stage>, <PageView>) — not by app code. */
33
+ declare const ShownPagesProvider: React.Provider<ShownPages | null>;
34
+ /** The surface's projector binding, or null outside any page surface — for
35
+ * chrome that degrades (and warns) instead of throwing. */
36
+ declare function useOptionalProjectorBinding(): ProjectorBinding | null;
37
+ /** The surface's projector binding. Reading it subscribes the caller to
38
+ * projection changes (the binding's identity is the revision). */
39
+ declare function useProjectorBinding(): ProjectorBinding;
40
+ interface AnchoredProps {
41
+ /**
42
+ * The box on a page to sit next to, in page coordinates: `{ page, bounds }`,
43
+ * with `avoid` points to keep clear of. `null`, or a target without
44
+ * `bounds` (a search match with no geometry), hides it.
45
+ */
46
+ anchor: (Omit<AnchorTarget, 'bounds'> & {
47
+ bounds?: AnchoredRect;
48
+ }) | null;
49
+ /**
50
+ * Where to sit: a side of the box, centred, or lined up with the side's
51
+ * start or end (`'top-end'`). Default 'top'.
52
+ */
53
+ placement?: AnchoredPlacement;
54
+ /**
55
+ * Gap in screen px between the box and the content, and between the content
56
+ * and the view's edge. Negative overlaps the box. Default 8.
57
+ */
58
+ gap?: number;
59
+ /**
60
+ * Stay where `placement` puts it: never flip to the other side, never move
61
+ * to stay in view, and scroll away with the box. For badges and status;
62
+ * menus leave it off. Default false.
63
+ */
64
+ pinned?: boolean;
65
+ children: React.ReactNode;
66
+ }
67
+ /**
68
+ * Position `children` around a page-space anchor, on whichever page surface
69
+ * is in scope. Projection runs during render from the shared pure helper.
70
+ * Once the content's size is measured, it flips to the opposite side when
71
+ * the chosen one has no room, and stays inside the view, unless `pinned`.
72
+ * Its wrapper's `data-placement` is where it sits now: `placement`, or the
73
+ * opposite side after a flip, so what opens from the content can open away
74
+ * from the box.
75
+ * Pointer isolation keeps a click inside anchored UI from reaching the
76
+ * surface's own listener (which would read it as a click outside).
77
+ *
78
+ * Anchored UI on a page that isn't shown renders nothing and reads only the
79
+ * pages on screen, so a document with hundreds of badges costs only the ones
80
+ * in view while people scroll and zoom.
81
+ */
82
+ declare function Anchored(props: AnchoredProps): import("react/jsx-runtime").JSX.Element | null;
83
+ //#endregion
84
+ export { AnchoredSide as a, ProjectorProvider as c, ViewProjector$1 as d, useOptionalProjectorBinding as f, AnchoredProps as i, ShownPages as l, Anchored as n, PageViewEnv as o, useProjectorBinding as p, AnchoredPlacement$1 as r, ProjectorBinding as s, AnchorTarget$1 as t, ShownPagesProvider as u };
85
+ //# sourceMappingURL=anchored-DzN3JywS.d.cts.map
package/dist/anchored.cjs CHANGED
@@ -1,75 +1,116 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("./rolldown-runtime-DDXJien1.cjs");
3
3
  let react_jsx_runtime = require("react/jsx-runtime");
4
+ let _embedpdf_web = require("@embedpdf/web");
4
5
  let react = require("react");
5
6
  react = require_rolldown_runtime.__toESM(react, 1);
6
7
  let react_dom = require("react-dom");
7
- let _embedpdf_web = require("@embedpdf/web");
8
8
  //#region src/anchored.tsx
9
9
  /**
10
- * Anchored overlays — ONE primitive for every piece of UI that floats over
10
+ * Anchored overlays — one primitive for every piece of UI that floats over
11
11
  * page content (selection menus, draft menus, future popovers).
12
12
  *
13
13
  * The factoring:
14
- * - PLUGINS produce anchors (a content-space rect on a page, plus points
14
+ * - plugins produce anchors (a page-space rect on a page, plus points
15
15
  * to dodge) as capability reads.
16
- * - The projection SNAPSHOT contract and the placement math are shared,
16
+ * - The projection snapshot contract and the placement math are shared,
17
17
  * framework-neutral, in `@embedpdf/web` ({@link ViewProjector},
18
18
  * `projectAnchoredTarget`).
19
- * - SURFACES (<Stage>, <PageView>) provide a {@link ProjectorBinding}:
20
- * the snapshot plus REACT's way of knowing when it changed.
21
- * - <Anchored> renders at the projected position, isolates pointer
22
- * events, and portals when the space demands it.
19
+ * - surfaces (<Stage>, <PageView>) provide a {@link ProjectorBinding}:
20
+ * the snapshot plus react's way of knowing when it changed.
21
+ * - <Anchored> renders at the projected position, flips to the other
22
+ * side and stays inside the view once it knows its size (unless
23
+ * pinned), says where it sits in `data-placement`, isolates pointer
24
+ * events, and portals when the space demands it. On a page that isn't
25
+ * shown it renders nothing and doesn't follow the camera at all (see
26
+ * {@link ShownPages}).
23
27
  *
24
- * THE SCHEDULING LAW (this is what keeps menus glued to the content): a
28
+ * The scheduling law (this is what keeps menus glued to the content): a
25
29
  * state-driven projection change (the Stage camera) reaches consumers as a
26
- * NEW BINDING IDENTITY through context — surface and overlay re-render in
27
- * the SAME React commit, so they can never paint a frame apart. No
30
+ * new binding identity through context — surface and overlay re-render in
31
+ * the same React commit, so they can never paint a frame apart. No
28
32
  * listener sets, no post-commit notifications, no second menu-only render.
29
- * `subscribe` exists ONLY for genuinely browser-driven invalidation (a
33
+ * `subscribe` exists only for genuinely browser-driven invalidation (a
30
34
  * PageView moving because the document scrolled), where no state change
31
35
  * announces the move.
32
36
  */
33
37
  const ProjectorContext = (0, react.createContext)(null);
34
38
  /** Installed by page surfaces (<Stage>, <PageView>) — not by app code. */
35
39
  const ProjectorProvider = ProjectorContext.Provider;
40
+ const ShownPagesContext = (0, react.createContext)(null);
41
+ /** Installed by page surfaces (<Stage>, <PageView>) — not by app code. */
42
+ const ShownPagesProvider = ShownPagesContext.Provider;
43
+ /** The surface's projector binding, or null outside any page surface — for
44
+ * chrome that degrades (and warns) instead of throwing. */
45
+ function useOptionalProjectorBinding() {
46
+ return (0, react.useContext)(ProjectorContext);
47
+ }
36
48
  /** The surface's projector binding. Reading it subscribes the caller to
37
- * projection changes (the binding's identity IS the revision). */
49
+ * projection changes (the binding's identity is the revision). */
38
50
  function useProjectorBinding() {
39
51
  const binding = (0, react.useContext)(ProjectorContext);
40
52
  if (!binding) throw new Error("No ViewProjector in scope: mount anchored UI under <Stage> (overlay slot) or <PageView>.");
41
53
  return binding;
42
54
  }
43
55
  /**
44
- * Position `children` around a content-space anchor, on whichever page
45
- * surface is in scope. Projection runs during render from the shared pure
46
- * helper; pointer isolation keeps a click inside anchored UI from reaching
47
- * the surface's own listener (which would read it as click-outside).
56
+ * Position `children` around a page-space anchor, on whichever page surface
57
+ * is in scope. Projection runs during render from the shared pure helper.
58
+ * Once the content's size is measured, it flips to the opposite side when
59
+ * the chosen one has no room, and stays inside the view, unless `pinned`.
60
+ * Its wrapper's `data-placement` is where it sits now: `placement`, or the
61
+ * opposite side after a flip, so what opens from the content can open away
62
+ * from the box.
63
+ * Pointer isolation keeps a click inside anchored UI from reaching the
64
+ * surface's own listener (which would read it as a click outside).
65
+ *
66
+ * Anchored UI on a page that isn't shown renders nothing and reads only the
67
+ * pages on screen, so a document with hundreds of badges costs only the ones
68
+ * in view while people scroll and zoom.
48
69
  */
49
- function Anchored({ anchor, placement = "top", gap = 8, children }) {
70
+ function Anchored(props) {
71
+ const shown = (0, react.useContext)(ShownPagesContext);
72
+ if (!props.anchor?.bounds) return null;
73
+ if (shown && !shown.has(props.anchor.page.objectNumber)) return null;
74
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PlacedAnchored, { ...props });
75
+ }
76
+ /** Anchored UI on a page that is shown: it follows the camera. */
77
+ function PlacedAnchored({ anchor, placement = "top", gap = 8, pinned = false, children }) {
50
78
  const { projector, subscribe } = useProjectorBinding();
79
+ const [element, setElement] = (0, react.useState)(null);
80
+ const [fit, setFit] = (0, react.useState)(null);
51
81
  const [, force] = (0, react.useReducer)((x) => x + 1, 0);
52
82
  (0, react.useLayoutEffect)(() => subscribe ? subscribe(force) : void 0, [subscribe]);
53
83
  (0, react.useLayoutEffect)(() => {
54
84
  if (projector.space === "client") force();
55
85
  }, [projector, anchor]);
56
- const ref = (0, react.useRef)(null);
86
+ (0, react.useLayoutEffect)(() => {
87
+ if (!element) return;
88
+ return (0, _embedpdf_web.observeAnchoredFit)(element, projector.space, (next) => setFit((current) => (0, _embedpdf_web.sameAnchoredFit)(current, next) ? current : next));
89
+ }, [element, projector.space]);
57
90
  (0, react.useEffect)(() => {
58
- const el = ref.current;
59
- if (!el) return;
60
- const stop = (e) => e.stopPropagation();
61
- el.addEventListener("pointerdown", stop);
62
- return () => el.removeEventListener("pointerdown", stop);
63
- });
64
- if (!anchor) return null;
65
- const pos = (0, _embedpdf_web.projectAnchoredTarget)(projector, anchor, placement, gap);
91
+ if (!element) return;
92
+ const stop = (event) => event.stopPropagation();
93
+ element.addEventListener("pointerdown", stop);
94
+ return () => element.removeEventListener("pointerdown", stop);
95
+ }, [element]);
96
+ if (!anchor?.bounds) return null;
97
+ const pos = (0, _embedpdf_web.projectAnchoredTarget)(projector, {
98
+ ...anchor,
99
+ bounds: anchor.bounds
100
+ }, {
101
+ placement,
102
+ gap,
103
+ pinned
104
+ }, fit);
66
105
  if (!pos) return null;
67
106
  const node = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
68
- ref,
107
+ ref: setElement,
108
+ "data-placement": pos.placement,
69
109
  style: {
70
110
  position: projector.space === "client" ? "fixed" : "absolute",
71
111
  left: pos.left,
72
112
  top: pos.top,
113
+ width: "max-content",
73
114
  transform: pos.transform,
74
115
  pointerEvents: "auto"
75
116
  },
@@ -84,6 +125,8 @@ function Anchored({ anchor, placement = "top", gap = 8, children }) {
84
125
  //#endregion
85
126
  exports.Anchored = Anchored;
86
127
  exports.ProjectorProvider = ProjectorProvider;
128
+ exports.ShownPagesProvider = ShownPagesProvider;
129
+ exports.useOptionalProjectorBinding = useOptionalProjectorBinding;
87
130
  exports.useProjectorBinding = useProjectorBinding;
88
131
 
89
132
  //# sourceMappingURL=anchored.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"anchored.cjs","names":[],"sources":["../src/anchored.tsx"],"sourcesContent":["/**\n * Anchored overlays — ONE primitive for every piece of UI that floats over\n * page content (selection menus, draft menus, future popovers).\n *\n * The factoring:\n * - PLUGINS produce anchors (a content-space rect on a page, plus points\n * to dodge) as capability reads.\n * - The projection SNAPSHOT contract and the placement math are shared,\n * framework-neutral, in `@embedpdf/web` ({@link ViewProjector},\n * `projectAnchoredTarget`).\n * - SURFACES (<Stage>, <PageView>) provide a {@link ProjectorBinding}:\n * the snapshot plus REACT's way of knowing when it changed.\n * - <Anchored> renders at the projected position, isolates pointer\n * events, and portals when the space demands it.\n *\n * THE SCHEDULING LAW (this is what keeps menus glued to the content): a\n * state-driven projection change (the Stage camera) reaches consumers as a\n * NEW BINDING IDENTITY through context — surface and overlay re-render in\n * the SAME React commit, so they can never paint a frame apart. No\n * listener sets, no post-commit notifications, no second menu-only render.\n * `subscribe` exists ONLY for genuinely browser-driven invalidation (a\n * PageView moving because the document scrolled), where no state change\n * announces the move.\n */\nimport * as React from 'react';\nimport { createContext, useContext, useEffect, useLayoutEffect, useReducer, useRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport {\n projectAnchoredTarget,\n type AnchoredPlacement,\n type AnchorTarget,\n type ViewProjector,\n} from '@embedpdf/web';\n\nexport type { AnchoredPlacement, AnchorTarget, ViewProjector } from '@embedpdf/web';\n\n/**\n * What a page surface provides via context: the pure projection snapshot,\n * bound to React's reactivity.\n */\nexport interface ProjectorBinding {\n projector: ViewProjector;\n /**\n * Changes identity exactly when projection may have changed for\n * STATE-driven reasons — the Stage uses its `visiblePages()` value (a\n * stable reference that already folds camera, viewport, scene and DPR).\n * Consumers re-render because the binding's identity changes with it;\n * nothing reads this field, but it is what makes the memoized binding\n * change, so do not \"optimize\" it away.\n */\n revision: unknown;\n /** Browser-driven invalidation ONLY (PageView scroll/resize — see\n * `observeClientGeometry`). The Stage deliberately provides none. */\n subscribe?: (callback: () => void) => () => void;\n}\n\nconst ProjectorContext = createContext<ProjectorBinding | null>(null);\n\n/** Installed by page surfaces (<Stage>, <PageView>) — not by app code. */\nexport const ProjectorProvider = ProjectorContext.Provider;\n\n/** The surface's projector binding. Reading it subscribes the caller to\n * projection changes (the binding's identity IS the revision). */\nexport function useProjectorBinding(): ProjectorBinding {\n const binding = useContext(ProjectorContext);\n if (!binding) {\n throw new Error(\n 'No ViewProjector in scope: mount anchored UI under <Stage> (overlay slot) or <PageView>.',\n );\n }\n return binding;\n}\n\nexport interface AnchoredProps {\n anchor: AnchorTarget | null;\n /** Which side of the anchor to sit on. Default 'top'. */\n placement?: AnchoredPlacement;\n /** Gap in screen px between the anchor box and the content. Default 8. */\n gap?: number;\n children: React.ReactNode;\n}\n\n/**\n * Position `children` around a content-space anchor, on whichever page\n * surface is in scope. Projection runs during render from the shared pure\n * helper; pointer isolation keeps a click inside anchored UI from reaching\n * the surface's own listener (which would read it as click-outside).\n */\nexport function Anchored({ anchor, placement = 'top', gap = 8, children }: AnchoredProps) {\n const { projector, subscribe } = useProjectorBinding();\n\n // Browser-driven invalidation only (PageView). State-driven changes come\n // through the binding identity — no local bump involved.\n const [, force] = useReducer((x: number) => x + 1, 0);\n useLayoutEffect(() => (subscribe ? subscribe(force) : undefined), [subscribe]);\n // Client-space surfaces measure the DOM, which does not exist during the\n // surface's first render — force one post-commit pass so the position\n // appears as soon as it is measurable. (Solves measurability, not\n // reactivity.)\n useLayoutEffect(() => {\n if (projector.space === 'client') force();\n }, [projector, anchor]);\n\n const ref = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n const stop = (e: Event) => e.stopPropagation();\n el.addEventListener('pointerdown', stop);\n return () => el.removeEventListener('pointerdown', stop);\n });\n\n if (!anchor) return null;\n const pos = projectAnchoredTarget(projector, anchor, placement, gap);\n if (!pos) return null;\n\n const node = (\n <div\n ref={ref}\n style={{\n position: projector.space === 'client' ? 'fixed' : 'absolute',\n left: pos.left,\n top: pos.top,\n transform: pos.transform,\n pointerEvents: 'auto',\n }}\n >\n {children}\n </div>\n );\n if (projector.space === 'client') {\n if (typeof document === 'undefined') return null;\n return createPortal(node, document.body);\n }\n return node;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,MAAM,oBAAA,GAAA,MAAA,cAAA,CAA0D,IAAI;;AAGpE,MAAa,oBAAoB,iBAAiB;;;AAIlD,SAAgB,sBAAwC;CACtD,MAAM,WAAA,GAAA,MAAA,WAAA,CAAqB,gBAAgB;CAC3C,IAAI,CAAC,SACH,MAAM,IAAI,MACR,0FACF;CAEF,OAAO;AACT;;;;;;;AAiBA,SAAgB,SAAS,EAAE,QAAQ,YAAY,OAAO,MAAM,GAAG,YAA2B;CACxF,MAAM,EAAE,WAAW,cAAc,oBAAoB;CAIrD,MAAM,GAAG,UAAA,GAAA,MAAA,WAAA,EAAqB,MAAc,IAAI,GAAG,CAAC;CACpD,CAAA,GAAA,MAAA,gBAAA,OAAuB,YAAY,UAAU,KAAK,IAAI,KAAA,GAAY,CAAC,SAAS,CAAC;CAK7E,CAAA,GAAA,MAAA,gBAAA,OAAsB;EACpB,IAAI,UAAU,UAAU,UAAU,MAAM;CAC1C,GAAG,CAAC,WAAW,MAAM,CAAC;CAEtB,MAAM,OAAA,GAAA,MAAA,OAAA,CAA6B,IAAI;CACvC,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,IAAI;EACT,MAAM,QAAQ,MAAa,EAAE,gBAAgB;EAC7C,GAAG,iBAAiB,eAAe,IAAI;EACvC,aAAa,GAAG,oBAAoB,eAAe,IAAI;CACzD,CAAC;CAED,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,OAAA,GAAA,cAAA,sBAAA,CAA4B,WAAW,QAAQ,WAAW,GAAG;CACnE,IAAI,CAAC,KAAK,OAAO;CAEjB,MAAM,OACJ,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACO;EACL,OAAO;GACL,UAAU,UAAU,UAAU,WAAW,UAAU;GACnD,MAAM,IAAI;GACV,KAAK,IAAI;GACT,WAAW,IAAI;GACf,eAAe;EACjB;EAEC;CACE,CAAA;CAEP,IAAI,UAAU,UAAU,UAAU;EAChC,IAAI,OAAO,aAAa,aAAa,OAAO;EAC5C,QAAA,GAAA,UAAA,aAAA,CAAoB,MAAM,SAAS,IAAI;CACzC;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"anchored.cjs","names":[],"sources":["../src/anchored.tsx"],"sourcesContent":["/**\n * Anchored overlays — one primitive for every piece of UI that floats over\n * page content (selection menus, draft menus, future popovers).\n *\n * The factoring:\n * - plugins produce anchors (a page-space rect on a page, plus points\n * to dodge) as capability reads.\n * - The projection snapshot contract and the placement math are shared,\n * framework-neutral, in `@embedpdf/web` ({@link ViewProjector},\n * `projectAnchoredTarget`).\n * - surfaces (<Stage>, <PageView>) provide a {@link ProjectorBinding}:\n * the snapshot plus react's way of knowing when it changed.\n * - <Anchored> renders at the projected position, flips to the other\n * side and stays inside the view once it knows its size (unless\n * pinned), says where it sits in `data-placement`, isolates pointer\n * events, and portals when the space demands it. On a page that isn't\n * shown it renders nothing and doesn't follow the camera at all (see\n * {@link ShownPages}).\n *\n * The scheduling law (this is what keeps menus glued to the content): a\n * state-driven projection change (the Stage camera) reaches consumers as a\n * new binding identity through context — surface and overlay re-render in\n * the same React commit, so they can never paint a frame apart. No\n * listener sets, no post-commit notifications, no second menu-only render.\n * `subscribe` exists only for genuinely browser-driven invalidation (a\n * PageView moving because the document scrolled), where no state change\n * announces the move.\n */\nimport * as React from 'react';\nimport { createContext, useContext, useEffect, useLayoutEffect, useReducer, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport {\n observeAnchoredFit,\n projectAnchoredTarget,\n sameAnchoredFit,\n type AnchoredFit,\n type AnchoredPlacement,\n type AnchoredRect,\n type AnchorTarget,\n type ViewProjector,\n} from '@embedpdf/web';\n\nexport type {\n AnchoredPlacement,\n AnchoredSide,\n AnchorTarget,\n PageViewEnv,\n ViewProjector,\n} from '@embedpdf/web';\n\n/**\n * What a page surface provides via context: the pure projection snapshot,\n * bound to React's reactivity.\n */\nexport interface ProjectorBinding {\n projector: ViewProjector;\n /**\n * Changes identity exactly when projection may have changed for\n * state-driven reasons — the Stage uses its `visiblePages()` value (a\n * stable reference that already folds camera, viewport, scene and DPR).\n * Consumers re-render because the binding's identity changes with it;\n * nothing reads this field, but it is what makes the memoized binding\n * change, so do not \"optimize\" it away.\n */\n revision: unknown;\n /** Browser-driven invalidation only (PageView scroll/resize — see\n * `observeClientGeometry`). The Stage deliberately provides none. */\n subscribe?: (callback: () => void) => () => void;\n}\n\nconst ProjectorContext = createContext<ProjectorBinding | null>(null);\n\n/** Installed by page surfaces (<Stage>, <PageView>) — not by app code. */\nexport const ProjectorProvider = ProjectorContext.Provider;\n\n/**\n * The pages a surface shows right now, by object number. It is a value of its\n * own, next to the projection, because it changes only when a page comes on\n * screen or leaves it: anchored UI on other pages reads only this, so it\n * isn't rendered again on every camera frame.\n */\nexport type ShownPages = ReadonlySet<number>;\n\nconst ShownPagesContext = createContext<ShownPages | null>(null);\n\n/** Installed by page surfaces (<Stage>, <PageView>) — not by app code. */\nexport const ShownPagesProvider = ShownPagesContext.Provider;\n\n/** The surface's projector binding, or null outside any page surface — for\n * chrome that degrades (and warns) instead of throwing. */\nexport function useOptionalProjectorBinding(): ProjectorBinding | null {\n return useContext(ProjectorContext);\n}\n\n/** The surface's projector binding. Reading it subscribes the caller to\n * projection changes (the binding's identity is the revision). */\nexport function useProjectorBinding(): ProjectorBinding {\n const binding = useContext(ProjectorContext);\n if (!binding) {\n throw new Error(\n 'No ViewProjector in scope: mount anchored UI under <Stage> (overlay slot) or <PageView>.',\n );\n }\n return binding;\n}\n\nexport interface AnchoredProps {\n /**\n * The box on a page to sit next to, in page coordinates: `{ page, bounds }`,\n * with `avoid` points to keep clear of. `null`, or a target without\n * `bounds` (a search match with no geometry), hides it.\n */\n anchor: (Omit<AnchorTarget, 'bounds'> & { bounds?: AnchoredRect }) | null;\n /**\n * Where to sit: a side of the box, centred, or lined up with the side's\n * start or end (`'top-end'`). Default 'top'.\n */\n placement?: AnchoredPlacement;\n /**\n * Gap in screen px between the box and the content, and between the content\n * and the view's edge. Negative overlaps the box. Default 8.\n */\n gap?: number;\n /**\n * Stay where `placement` puts it: never flip to the other side, never move\n * to stay in view, and scroll away with the box. For badges and status;\n * menus leave it off. Default false.\n */\n pinned?: boolean;\n children: React.ReactNode;\n}\n\n/**\n * Position `children` around a page-space anchor, on whichever page surface\n * is in scope. Projection runs during render from the shared pure helper.\n * Once the content's size is measured, it flips to the opposite side when\n * the chosen one has no room, and stays inside the view, unless `pinned`.\n * Its wrapper's `data-placement` is where it sits now: `placement`, or the\n * opposite side after a flip, so what opens from the content can open away\n * from the box.\n * Pointer isolation keeps a click inside anchored UI from reaching the\n * surface's own listener (which would read it as a click outside).\n *\n * Anchored UI on a page that isn't shown renders nothing and reads only the\n * pages on screen, so a document with hundreds of badges costs only the ones\n * in view while people scroll and zoom.\n */\nexport function Anchored(props: AnchoredProps) {\n const shown = useContext(ShownPagesContext);\n if (!props.anchor?.bounds) return null;\n if (shown && !shown.has(props.anchor.page.objectNumber)) return null;\n return <PlacedAnchored {...props} />;\n}\n\n/** Anchored UI on a page that is shown: it follows the camera. */\nfunction PlacedAnchored({\n anchor,\n placement = 'top',\n gap = 8,\n pinned = false,\n children,\n}: AnchoredProps) {\n const { projector, subscribe } = useProjectorBinding();\n const [element, setElement] = useState<HTMLDivElement | null>(null);\n // The content's size and the view's: measured after the first commit, and\n // again whenever either resizes. A camera move changes neither.\n const [fit, setFit] = useState<AnchoredFit | null>(null);\n\n // Browser-driven invalidation only (PageView). State-driven changes come\n // through the binding identity — no local bump involved.\n const [, force] = useReducer((x: number) => x + 1, 0);\n useLayoutEffect(() => (subscribe ? subscribe(force) : undefined), [subscribe]);\n // Client-space surfaces measure the DOM, which does not exist during the\n // surface's first render — force one post-commit pass so the position\n // appears as soon as it is measurable. (Solves measurability, not\n // reactivity.)\n useLayoutEffect(() => {\n if (projector.space === 'client') force();\n }, [projector, anchor]);\n\n useLayoutEffect(() => {\n if (!element) return;\n return observeAnchoredFit(element, projector.space, (next) =>\n setFit((current) => (sameAnchoredFit(current, next) ? current : next)),\n );\n }, [element, projector.space]);\n\n useEffect(() => {\n if (!element) return;\n const stop = (event: Event) => event.stopPropagation();\n element.addEventListener('pointerdown', stop);\n return () => element.removeEventListener('pointerdown', stop);\n }, [element]);\n\n if (!anchor?.bounds) return null;\n const pos = projectAnchoredTarget(\n projector,\n { ...anchor, bounds: anchor.bounds },\n { placement, gap, pinned },\n fit,\n );\n if (!pos) return null;\n\n const node = (\n <div\n ref={setElement}\n data-placement={pos.placement}\n style={{\n position: projector.space === 'client' ? 'fixed' : 'absolute',\n left: pos.left,\n top: pos.top,\n // Its own width, wherever it sits: the size the placement measured.\n width: 'max-content',\n transform: pos.transform,\n pointerEvents: 'auto',\n }}\n >\n {children}\n </div>\n );\n if (projector.space === 'client') {\n if (typeof document === 'undefined') return null;\n return createPortal(node, document.body);\n }\n return node;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEA,MAAM,oBAAA,GAAA,MAAA,cAAA,CAA0D,IAAI;;AAGpE,MAAa,oBAAoB,iBAAiB;AAUlD,MAAM,qBAAA,GAAA,MAAA,cAAA,CAAqD,IAAI;;AAG/D,MAAa,qBAAqB,kBAAkB;;;AAIpD,SAAgB,8BAAuD;CACrE,QAAA,GAAA,MAAA,WAAA,CAAkB,gBAAgB;AACpC;;;AAIA,SAAgB,sBAAwC;CACtD,MAAM,WAAA,GAAA,MAAA,WAAA,CAAqB,gBAAgB;CAC3C,IAAI,CAAC,SACH,MAAM,IAAI,MACR,0FACF;CAEF,OAAO;AACT;;;;;;;;;;;;;;;;AA2CA,SAAgB,SAAS,OAAsB;CAC7C,MAAM,SAAA,GAAA,MAAA,WAAA,CAAmB,iBAAiB;CAC1C,IAAI,CAAC,MAAM,QAAQ,QAAQ,OAAO;CAClC,IAAI,SAAS,CAAC,MAAM,IAAI,MAAM,OAAO,KAAK,YAAY,GAAG,OAAO;CAChE,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD,EAAgB,GAAI,MAAQ,CAAA;AACrC;;AAGA,SAAS,eAAe,EACtB,QACA,YAAY,OACZ,MAAM,GACN,SAAS,OACT,YACgB;CAChB,MAAM,EAAE,WAAW,cAAc,oBAAoB;CACrD,MAAM,CAAC,SAAS,eAAA,GAAA,MAAA,SAAA,CAA8C,IAAI;CAGlE,MAAM,CAAC,KAAK,WAAA,GAAA,MAAA,SAAA,CAAuC,IAAI;CAIvD,MAAM,GAAG,UAAA,GAAA,MAAA,WAAA,EAAqB,MAAc,IAAI,GAAG,CAAC;CACpD,CAAA,GAAA,MAAA,gBAAA,OAAuB,YAAY,UAAU,KAAK,IAAI,KAAA,GAAY,CAAC,SAAS,CAAC;CAK7E,CAAA,GAAA,MAAA,gBAAA,OAAsB;EACpB,IAAI,UAAU,UAAU,UAAU,MAAM;CAC1C,GAAG,CAAC,WAAW,MAAM,CAAC;CAEtB,CAAA,GAAA,MAAA,gBAAA,OAAsB;EACpB,IAAI,CAAC,SAAS;EACd,QAAA,GAAA,cAAA,mBAAA,CAA0B,SAAS,UAAU,QAAQ,SACnD,QAAQ,aAAA,GAAA,cAAA,gBAAA,CAA6B,SAAS,IAAI,IAAI,UAAU,IAAK,CACvE;CACF,GAAG,CAAC,SAAS,UAAU,KAAK,CAAC;CAE7B,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,CAAC,SAAS;EACd,MAAM,QAAQ,UAAiB,MAAM,gBAAgB;EACrD,QAAQ,iBAAiB,eAAe,IAAI;EAC5C,aAAa,QAAQ,oBAAoB,eAAe,IAAI;CAC9D,GAAG,CAAC,OAAO,CAAC;CAEZ,IAAI,CAAC,QAAQ,QAAQ,OAAO;CAC5B,MAAM,OAAA,GAAA,cAAA,sBAAA,CACJ,WACA;EAAE,GAAG;EAAQ,QAAQ,OAAO;CAAO,GACnC;EAAE;EAAW;EAAK;CAAO,GACzB,GACF;CACA,IAAI,CAAC,KAAK,OAAO;CAEjB,MAAM,OACJ,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,KAAK;EACL,kBAAgB,IAAI;EACpB,OAAO;GACL,UAAU,UAAU,UAAU,WAAW,UAAU;GACnD,MAAM,IAAI;GACV,KAAK,IAAI;GAET,OAAO;GACP,WAAW,IAAI;GACf,eAAe;EACjB;EAEC;CACE,CAAA;CAEP,IAAI,UAAU,UAAU,UAAU;EAChC,IAAI,OAAO,aAAa,aAAa,OAAO;EAC5C,QAAA,GAAA,UAAA,aAAA,CAAoB,MAAM,SAAS,IAAI;CACzC;CACA,OAAO;AACT"}
@@ -1,45 +1,2 @@
1
- import * as React from "react";
2
- import { AnchorTarget, AnchorTarget as AnchorTarget$1, AnchoredPlacement, AnchoredPlacement as AnchoredPlacement$1, ViewProjector, ViewProjector as ViewProjector$1 } from "@embedpdf/web";
3
- //#region src/anchored.d.ts
4
- /**
5
- * What a page surface provides via context: the pure projection snapshot,
6
- * bound to React's reactivity.
7
- */
8
- interface ProjectorBinding {
9
- projector: ViewProjector$1;
10
- /**
11
- * Changes identity exactly when projection may have changed for
12
- * STATE-driven reasons — the Stage uses its `visiblePages()` value (a
13
- * stable reference that already folds camera, viewport, scene and DPR).
14
- * Consumers re-render because the binding's identity changes with it;
15
- * nothing reads this field, but it is what makes the memoized binding
16
- * change, so do not "optimize" it away.
17
- */
18
- revision: unknown;
19
- /** Browser-driven invalidation ONLY (PageView scroll/resize — see
20
- * `observeClientGeometry`). The Stage deliberately provides none. */
21
- subscribe?: (callback: () => void) => () => void;
22
- }
23
- /** Installed by page surfaces (<Stage>, <PageView>) — not by app code. */
24
- declare const ProjectorProvider: React.Provider<ProjectorBinding | null>;
25
- /** The surface's projector binding. Reading it subscribes the caller to
26
- * projection changes (the binding's identity IS the revision). */
27
- declare function useProjectorBinding(): ProjectorBinding;
28
- interface AnchoredProps {
29
- anchor: AnchorTarget$1 | null;
30
- /** Which side of the anchor to sit on. Default 'top'. */
31
- placement?: AnchoredPlacement$1;
32
- /** Gap in screen px between the anchor box and the content. Default 8. */
33
- gap?: number;
34
- children: React.ReactNode;
35
- }
36
- /**
37
- * Position `children` around a content-space anchor, on whichever page
38
- * surface is in scope. Projection runs during render from the shared pure
39
- * helper; pointer isolation keeps a click inside anchored UI from reaching
40
- * the surface's own listener (which would read it as click-outside).
41
- */
42
- declare function Anchored({ anchor, placement, gap, children }: AnchoredProps): import("react/jsx-runtime").JSX.Element | null;
43
- //#endregion
44
- export { type AnchorTarget, Anchored, type AnchoredPlacement, AnchoredProps, ProjectorBinding, ProjectorProvider, type ViewProjector, useProjectorBinding };
45
- //# sourceMappingURL=anchored.d.cts.map
1
+ import { a as AnchoredSide, c as ProjectorProvider, d as ViewProjector, f as useOptionalProjectorBinding, i as AnchoredProps, l as ShownPages, n as Anchored, o as PageViewEnv, p as useProjectorBinding, r as AnchoredPlacement, s as ProjectorBinding, t as AnchorTarget, u as ShownPagesProvider } from "./anchored-DzN3JywS.cjs";
2
+ export { type AnchorTarget, Anchored, type AnchoredPlacement, AnchoredProps, type AnchoredSide, type PageViewEnv, ProjectorBinding, ProjectorProvider, ShownPages, ShownPagesProvider, type ViewProjector, useOptionalProjectorBinding, useProjectorBinding };