@embedpdf/vue 0.0.0-stage → 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 (405) hide show
  1. package/LICENSE +192 -0
  2. package/README.md +258 -2
  3. package/dist/Anchored.vue_vue_type_script_setup_true_lang-BEImlFso.cjs +124 -0
  4. package/dist/Anchored.vue_vue_type_script_setup_true_lang-BEImlFso.cjs.map +1 -0
  5. package/dist/Anchored.vue_vue_type_script_setup_true_lang-Brhh5jyF.js +125 -0
  6. package/dist/Anchored.vue_vue_type_script_setup_true_lang-Brhh5jyF.js.map +1 -0
  7. package/dist/AnchoredScope.vue_vue_type_script_setup_true_lang-BwtHXw73.cjs +20 -0
  8. package/dist/AnchoredScope.vue_vue_type_script_setup_true_lang-BwtHXw73.cjs.map +1 -0
  9. package/dist/AnchoredScope.vue_vue_type_script_setup_true_lang-Ulkr3a6R.js +21 -0
  10. package/dist/AnchoredScope.vue_vue_type_script_setup_true_lang-Ulkr3a6R.js.map +1 -0
  11. package/dist/DocumentScope.vue_vue_type_script_setup_true_lang-CtTu1FGX.js +191 -0
  12. package/dist/DocumentScope.vue_vue_type_script_setup_true_lang-CtTu1FGX.js.map +1 -0
  13. package/dist/DocumentScope.vue_vue_type_script_setup_true_lang-loLSm4lV.cjs +190 -0
  14. package/dist/DocumentScope.vue_vue_type_script_setup_true_lang-loLSm4lV.cjs.map +1 -0
  15. package/dist/FormLayer.vue_vue_type_script_setup_true_lang-BA0_VwFc.cjs +682 -0
  16. package/dist/FormLayer.vue_vue_type_script_setup_true_lang-BA0_VwFc.cjs.map +1 -0
  17. package/dist/FormLayer.vue_vue_type_script_setup_true_lang-DUqft-xs.js +683 -0
  18. package/dist/FormLayer.vue_vue_type_script_setup_true_lang-DUqft-xs.js.map +1 -0
  19. package/dist/LinkLayer.vue_vue_type_script_setup_true_lang-C5-eQD34.cjs +174 -0
  20. package/dist/LinkLayer.vue_vue_type_script_setup_true_lang-C5-eQD34.cjs.map +1 -0
  21. package/dist/LinkLayer.vue_vue_type_script_setup_true_lang-EzLaOP3g.js +175 -0
  22. package/dist/LinkLayer.vue_vue_type_script_setup_true_lang-EzLaOP3g.js.map +1 -0
  23. package/dist/PagePointerSource.vue_vue_type_script_setup_true_lang-CJt3vdBW.js +33 -0
  24. package/dist/PagePointerSource.vue_vue_type_script_setup_true_lang-CJt3vdBW.js.map +1 -0
  25. package/dist/PagePointerSource.vue_vue_type_script_setup_true_lang-Cw29c8Oa.cjs +32 -0
  26. package/dist/PagePointerSource.vue_vue_type_script_setup_true_lang-Cw29c8Oa.cjs.map +1 -0
  27. package/dist/PageView.vue_vue_type_script_setup_true_lang-CjrpumX2.cjs +151 -0
  28. package/dist/PageView.vue_vue_type_script_setup_true_lang-CjrpumX2.cjs.map +1 -0
  29. package/dist/PageView.vue_vue_type_script_setup_true_lang-O4AFc0_R.js +152 -0
  30. package/dist/PageView.vue_vue_type_script_setup_true_lang-O4AFc0_R.js.map +1 -0
  31. package/dist/Scrollbar.vue_vue_type_script_setup_true_lang-DrOORC1H.cjs +480 -0
  32. package/dist/Scrollbar.vue_vue_type_script_setup_true_lang-DrOORC1H.cjs.map +1 -0
  33. package/dist/Scrollbar.vue_vue_type_script_setup_true_lang-HbCryx1B.js +481 -0
  34. package/dist/Scrollbar.vue_vue_type_script_setup_true_lang-HbCryx1B.js.map +1 -0
  35. package/dist/SearchLayer.vue_vue_type_script_setup_true_lang-BlLIPH1B.js +118 -0
  36. package/dist/SearchLayer.vue_vue_type_script_setup_true_lang-BlLIPH1B.js.map +1 -0
  37. package/dist/SearchLayer.vue_vue_type_script_setup_true_lang-CQozZCvB.cjs +117 -0
  38. package/dist/SearchLayer.vue_vue_type_script_setup_true_lang-CQozZCvB.cjs.map +1 -0
  39. package/dist/SelectionClipboard.vue_vue_type_script_setup_true_lang-C4TUDuyu.js +302 -0
  40. package/dist/SelectionClipboard.vue_vue_type_script_setup_true_lang-C4TUDuyu.js.map +1 -0
  41. package/dist/SelectionClipboard.vue_vue_type_script_setup_true_lang-C8T9q6Kb.cjs +301 -0
  42. package/dist/SelectionClipboard.vue_vue_type_script_setup_true_lang-C8T9q6Kb.cjs.map +1 -0
  43. package/dist/SvgShapes.vue_vue_type_script_setup_true_lang-D_c-wINF.cjs +38 -0
  44. package/dist/SvgShapes.vue_vue_type_script_setup_true_lang-D_c-wINF.cjs.map +1 -0
  45. package/dist/SvgShapes.vue_vue_type_script_setup_true_lang-fOTs4aqv.js +39 -0
  46. package/dist/SvgShapes.vue_vue_type_script_setup_true_lang-fOTs4aqv.js.map +1 -0
  47. package/dist/actions.cjs +42 -0
  48. package/dist/actions.cjs.map +1 -0
  49. package/dist/actions.d.cts +41 -0
  50. package/dist/actions.d.ts +41 -0
  51. package/dist/actions.js +37 -0
  52. package/dist/actions.js.map +1 -0
  53. package/dist/anchored/Anchored.vue.d.cts +40 -0
  54. package/dist/anchored/Anchored.vue.d.ts +40 -0
  55. package/dist/anchored/AnchoredScope.vue.d.cts +17 -0
  56. package/dist/anchored/AnchoredScope.vue.d.ts +17 -0
  57. package/dist/anchored/PlacedAnchored.vue.d.cts +19 -0
  58. package/dist/anchored/PlacedAnchored.vue.d.ts +19 -0
  59. package/dist/anchored/projector.d.cts +32 -0
  60. package/dist/anchored/projector.d.ts +32 -0
  61. package/dist/anchored.cjs +13 -0
  62. package/dist/anchored.cjs.map +1 -0
  63. package/dist/anchored.d.cts +15 -0
  64. package/dist/anchored.d.ts +15 -0
  65. package/dist/anchored.js +13 -0
  66. package/dist/anchored.js.map +1 -0
  67. package/dist/annotation/AnnotationChrome.vue.d.cts +20 -0
  68. package/dist/annotation/AnnotationChrome.vue.d.ts +20 -0
  69. package/dist/annotation/AnnotationDraftMenu.vue.d.cts +26 -0
  70. package/dist/annotation/AnnotationDraftMenu.vue.d.ts +26 -0
  71. package/dist/annotation/AnnotationFrame.vue.d.cts +25 -0
  72. package/dist/annotation/AnnotationFrame.vue.d.ts +25 -0
  73. package/dist/annotation/AnnotationLayer.vue.d.cts +23 -0
  74. package/dist/annotation/AnnotationLayer.vue.d.ts +23 -0
  75. package/dist/annotation/AnnotationLook.vue.d.cts +21 -0
  76. package/dist/annotation/AnnotationLook.vue.d.ts +21 -0
  77. package/dist/annotation/AnnotationMenu.vue.d.cts +23 -0
  78. package/dist/annotation/AnnotationMenu.vue.d.ts +23 -0
  79. package/dist/annotation/AnnotationRotationBadge.vue.d.cts +26 -0
  80. package/dist/annotation/AnnotationRotationBadge.vue.d.ts +26 -0
  81. package/dist/annotation/AnnotationScene.vue.d.cts +7 -0
  82. package/dist/annotation/AnnotationScene.vue.d.ts +7 -0
  83. package/dist/annotation/FreeTextBox.vue.d.cts +9 -0
  84. package/dist/annotation/FreeTextBox.vue.d.ts +9 -0
  85. package/dist/annotation/NativeDrawing.vue.d.cts +10 -0
  86. package/dist/annotation/NativeDrawing.vue.d.ts +10 -0
  87. package/dist/annotation/StampGhost.vue.d.cts +7 -0
  88. package/dist/annotation/StampGhost.vue.d.ts +7 -0
  89. package/dist/annotation/composables.d.cts +76 -0
  90. package/dist/annotation/composables.d.ts +76 -0
  91. package/dist/annotation/state.d.cts +19 -0
  92. package/dist/annotation/state.d.ts +19 -0
  93. package/dist/annotation/text-box.d.cts +27 -0
  94. package/dist/annotation/text-box.d.ts +27 -0
  95. package/dist/annotation/types.d.cts +154 -0
  96. package/dist/annotation/types.d.ts +154 -0
  97. package/dist/annotation.cjs +29 -0
  98. package/dist/annotation.cjs.map +1 -0
  99. package/dist/annotation.d.cts +35 -0
  100. package/dist/annotation.d.ts +35 -0
  101. package/dist/annotation.js +23 -0
  102. package/dist/annotation.js.map +1 -0
  103. package/dist/capabilities-C7YzgPCX.js +164 -0
  104. package/dist/capabilities-C7YzgPCX.js.map +1 -0
  105. package/dist/capabilities-DVNJmgy7.cjs +163 -0
  106. package/dist/capabilities-DVNJmgy7.cjs.map +1 -0
  107. package/dist/commands.cjs +81 -0
  108. package/dist/commands.cjs.map +1 -0
  109. package/dist/commands.d.cts +61 -0
  110. package/dist/commands.d.ts +61 -0
  111. package/dist/commands.js +76 -0
  112. package/dist/commands.js.map +1 -0
  113. package/dist/composables-BGBsNDf9.cjs +25 -0
  114. package/dist/composables-BGBsNDf9.cjs.map +1 -0
  115. package/dist/composables-BuHvnUlo.cjs +1003 -0
  116. package/dist/composables-BuHvnUlo.cjs.map +1 -0
  117. package/dist/composables-CIkhKwAg.js +1004 -0
  118. package/dist/composables-CIkhKwAg.js.map +1 -0
  119. package/dist/composables-DwsZdg06.js +26 -0
  120. package/dist/composables-DwsZdg06.js.map +1 -0
  121. package/dist/dev-CtMlvxjZ.js +17 -0
  122. package/dist/dev-CtMlvxjZ.js.map +1 -0
  123. package/dist/dev-eeIS2B4c.cjs +16 -0
  124. package/dist/dev-eeIS2B4c.cjs.map +1 -0
  125. package/dist/dev.d.cts +11 -0
  126. package/dist/dev.d.ts +11 -0
  127. package/dist/documents-DUu5H4yH.js +34 -0
  128. package/dist/documents-DUu5H4yH.js.map +1 -0
  129. package/dist/documents-TQ1fMdWI.cjs +33 -0
  130. package/dist/documents-TQ1fMdWI.cjs.map +1 -0
  131. package/dist/form/ButtonControl.vue.d.cts +11 -0
  132. package/dist/form/ButtonControl.vue.d.ts +11 -0
  133. package/dist/form/ComboControl.vue.d.cts +11 -0
  134. package/dist/form/ComboControl.vue.d.ts +11 -0
  135. package/dist/form/FieldPictures.vue.d.cts +3 -0
  136. package/dist/form/FieldPictures.vue.d.ts +3 -0
  137. package/dist/form/FormFocusRing.vue.d.cts +8 -0
  138. package/dist/form/FormFocusRing.vue.d.ts +8 -0
  139. package/dist/form/FormLayer.vue.d.cts +3 -0
  140. package/dist/form/FormLayer.vue.d.ts +3 -0
  141. package/dist/form/ListControl.vue.d.cts +11 -0
  142. package/dist/form/ListControl.vue.d.ts +11 -0
  143. package/dist/form/NativeListBox.vue.d.cts +27 -0
  144. package/dist/form/NativeListBox.vue.d.ts +27 -0
  145. package/dist/form/SignatureControl.vue.d.cts +11 -0
  146. package/dist/form/SignatureControl.vue.d.ts +11 -0
  147. package/dist/form/TextControl.vue.d.cts +11 -0
  148. package/dist/form/TextControl.vue.d.ts +11 -0
  149. package/dist/form/ToggleControl.vue.d.cts +11 -0
  150. package/dist/form/ToggleControl.vue.d.ts +11 -0
  151. package/dist/form/composables.d.cts +52 -0
  152. package/dist/form/composables.d.ts +52 -0
  153. package/dist/form/widget-box.d.cts +34 -0
  154. package/dist/form/widget-box.d.ts +34 -0
  155. package/dist/form.cjs +17 -0
  156. package/dist/form.cjs.map +1 -0
  157. package/dist/form.d.cts +12 -0
  158. package/dist/form.d.ts +12 -0
  159. package/dist/form.js +11 -0
  160. package/dist/form.js.map +1 -0
  161. package/dist/history.cjs +22 -0
  162. package/dist/history.cjs.map +1 -0
  163. package/dist/history.d.cts +31 -0
  164. package/dist/history.d.ts +31 -0
  165. package/dist/history.js +17 -0
  166. package/dist/history.js.map +1 -0
  167. package/dist/i18n.cjs +29 -0
  168. package/dist/i18n.cjs.map +1 -0
  169. package/dist/i18n.d.cts +36 -0
  170. package/dist/i18n.d.ts +36 -0
  171. package/dist/i18n.js +24 -0
  172. package/dist/i18n.js.map +1 -0
  173. package/dist/index.cjs +391 -0
  174. package/dist/index.cjs.map +1 -0
  175. package/dist/index.d.cts +30 -0
  176. package/dist/index.d.ts +30 -0
  177. package/dist/index.js +223 -0
  178. package/dist/index.js.map +1 -0
  179. package/dist/interaction/PagePointerSource.vue.d.cts +3 -0
  180. package/dist/interaction/PagePointerSource.vue.d.ts +3 -0
  181. package/dist/interaction.cjs +63 -0
  182. package/dist/interaction.cjs.map +1 -0
  183. package/dist/interaction.d.cts +40 -0
  184. package/dist/interaction.d.ts +40 -0
  185. package/dist/interaction.js +47 -0
  186. package/dist/interaction.js.map +1 -0
  187. package/dist/link/LinkAnchor.vue.d.cts +9 -0
  188. package/dist/link/LinkAnchor.vue.d.ts +9 -0
  189. package/dist/link/LinkLayer.vue.d.cts +22 -0
  190. package/dist/link/LinkLayer.vue.d.ts +22 -0
  191. package/dist/link/composables.d.cts +29 -0
  192. package/dist/link/composables.d.ts +29 -0
  193. package/dist/link.cjs +14 -0
  194. package/dist/link.cjs.map +1 -0
  195. package/dist/link.d.cts +11 -0
  196. package/dist/link.d.ts +11 -0
  197. package/dist/link.js +8 -0
  198. package/dist/link.js.map +1 -0
  199. package/dist/measurement.cjs +43 -0
  200. package/dist/measurement.cjs.map +1 -0
  201. package/dist/measurement.d.cts +51 -0
  202. package/dist/measurement.d.ts +51 -0
  203. package/dist/measurement.js +38 -0
  204. package/dist/measurement.js.map +1 -0
  205. package/dist/metadata.cjs +22 -0
  206. package/dist/metadata.cjs.map +1 -0
  207. package/dist/metadata.d.cts +31 -0
  208. package/dist/metadata.d.ts +31 -0
  209. package/dist/metadata.js +17 -0
  210. package/dist/metadata.js.map +1 -0
  211. package/dist/page-D9XIuLSj.js +16 -0
  212. package/dist/page-D9XIuLSj.js.map +1 -0
  213. package/dist/page-Doy4_Sdz.cjs +15 -0
  214. package/dist/page-Doy4_Sdz.cjs.map +1 -0
  215. package/dist/page-edit.cjs +15 -0
  216. package/dist/page-edit.cjs.map +1 -0
  217. package/dist/page-edit.d.cts +16 -0
  218. package/dist/page-edit.d.ts +16 -0
  219. package/dist/page-edit.js +10 -0
  220. package/dist/page-edit.js.map +1 -0
  221. package/dist/page-layers-c-CJYAUO.cjs +30 -0
  222. package/dist/page-layers-c-CJYAUO.cjs.map +1 -0
  223. package/dist/page-layers-rlh4-1qr.js +31 -0
  224. package/dist/page-layers-rlh4-1qr.js.map +1 -0
  225. package/dist/page-layers.d.cts +21 -0
  226. package/dist/page-layers.d.ts +21 -0
  227. package/dist/page-view/PageView.vue.d.cts +42 -0
  228. package/dist/page-view/PageView.vue.d.ts +42 -0
  229. package/dist/page-view.cjs +5 -0
  230. package/dist/page-view.cjs.map +1 -0
  231. package/dist/page-view.d.cts +10 -0
  232. package/dist/page-view.d.ts +10 -0
  233. package/dist/page-view.js +5 -0
  234. package/dist/page-view.js.map +1 -0
  235. package/dist/projector-CDZn1kh1.js +32 -0
  236. package/dist/projector-CDZn1kh1.js.map +1 -0
  237. package/dist/projector-Cf7879sx.cjs +31 -0
  238. package/dist/projector-Cf7879sx.cjs.map +1 -0
  239. package/dist/redaction.cjs +34 -0
  240. package/dist/redaction.cjs.map +1 -0
  241. package/dist/redaction.d.cts +44 -0
  242. package/dist/redaction.d.ts +44 -0
  243. package/dist/redaction.js +29 -0
  244. package/dist/redaction.js.map +1 -0
  245. package/dist/render/RenderLayer.vue.d.cts +23 -0
  246. package/dist/render/RenderLayer.vue.d.ts +23 -0
  247. package/dist/render/TileImage.vue.d.cts +13 -0
  248. package/dist/render/TileImage.vue.d.ts +13 -0
  249. package/dist/render/TilePlane.vue.d.cts +7 -0
  250. package/dist/render/TilePlane.vue.d.ts +7 -0
  251. package/dist/render.cjs +262 -0
  252. package/dist/render.cjs.map +1 -0
  253. package/dist/render.d.cts +16 -0
  254. package/dist/render.d.ts +16 -0
  255. package/dist/render.js +257 -0
  256. package/dist/render.js.map +1 -0
  257. package/dist/runtime/DocumentGate.vue.d.cts +24 -0
  258. package/dist/runtime/DocumentGate.vue.d.ts +24 -0
  259. package/dist/runtime/DocumentScope.vue.d.cts +16 -0
  260. package/dist/runtime/DocumentScope.vue.d.ts +16 -0
  261. package/dist/runtime/KernelProvider.vue.d.cts +17 -0
  262. package/dist/runtime/KernelProvider.vue.d.ts +17 -0
  263. package/dist/runtime/SvgShapes.vue.d.cts +7 -0
  264. package/dist/runtime/SvgShapes.vue.d.ts +7 -0
  265. package/dist/runtime/Viewer.vue.d.cts +57 -0
  266. package/dist/runtime/Viewer.vue.d.ts +57 -0
  267. package/dist/runtime/capabilities.d.cts +52 -0
  268. package/dist/runtime/capabilities.d.ts +52 -0
  269. package/dist/runtime/documents.d.cts +42 -0
  270. package/dist/runtime/documents.d.ts +42 -0
  271. package/dist/runtime/kernel.d.cts +36 -0
  272. package/dist/runtime/kernel.d.ts +36 -0
  273. package/dist/runtime/page.d.cts +15 -0
  274. package/dist/runtime/page.d.ts +15 -0
  275. package/dist/runtime/refs.d.cts +12 -0
  276. package/dist/runtime/refs.d.ts +12 -0
  277. package/dist/runtime/surface-box.d.cts +12 -0
  278. package/dist/runtime/surface-box.d.ts +12 -0
  279. package/dist/runtime.cjs +53 -0
  280. package/dist/runtime.cjs.map +1 -0
  281. package/dist/runtime.d.cts +24 -0
  282. package/dist/runtime.d.ts +24 -0
  283. package/dist/runtime.js +38 -0
  284. package/dist/runtime.js.map +1 -0
  285. package/dist/scope-BQA4toWB.cjs +17 -0
  286. package/dist/scope-BQA4toWB.cjs.map +1 -0
  287. package/dist/scope-BgdCqnYb.js +18 -0
  288. package/dist/scope-BgdCqnYb.js.map +1 -0
  289. package/dist/search/SearchLayer.vue.d.cts +17 -0
  290. package/dist/search/SearchLayer.vue.d.ts +17 -0
  291. package/dist/search/composables.d.cts +31 -0
  292. package/dist/search/composables.d.ts +31 -0
  293. package/dist/search.cjs +17 -0
  294. package/dist/search.cjs.map +1 -0
  295. package/dist/search.d.cts +10 -0
  296. package/dist/search.d.ts +10 -0
  297. package/dist/search.js +11 -0
  298. package/dist/search.js.map +1 -0
  299. package/dist/selection/SelectionClipboard.vue.d.cts +24 -0
  300. package/dist/selection/SelectionClipboard.vue.d.ts +24 -0
  301. package/dist/selection/SelectionHandles.vue.d.cts +8 -0
  302. package/dist/selection/SelectionHandles.vue.d.ts +8 -0
  303. package/dist/selection/SelectionLayer.vue.d.cts +3 -0
  304. package/dist/selection/SelectionLayer.vue.d.ts +3 -0
  305. package/dist/selection/SelectionMenu.vue.d.cts +23 -0
  306. package/dist/selection/SelectionMenu.vue.d.ts +23 -0
  307. package/dist/selection/composables.d.cts +24 -0
  308. package/dist/selection/composables.d.ts +24 -0
  309. package/dist/selection.cjs +24 -0
  310. package/dist/selection.cjs.map +1 -0
  311. package/dist/selection.d.cts +16 -0
  312. package/dist/selection.d.ts +16 -0
  313. package/dist/selection.js +15 -0
  314. package/dist/selection.js.map +1 -0
  315. package/dist/shell.cjs +72 -0
  316. package/dist/shell.cjs.map +1 -0
  317. package/dist/shell.d.cts +56 -0
  318. package/dist/shell.d.ts +56 -0
  319. package/dist/shell.js +67 -0
  320. package/dist/shell.js.map +1 -0
  321. package/dist/signature/composables.d.cts +39 -0
  322. package/dist/signature/composables.d.ts +39 -0
  323. package/dist/signature.cjs +16 -0
  324. package/dist/signature.cjs.map +1 -0
  325. package/dist/signature.d.cts +15 -0
  326. package/dist/signature.d.ts +15 -0
  327. package/dist/signature.js +10 -0
  328. package/dist/signature.js.map +1 -0
  329. package/dist/stage/PageSurface.vue.d.cts +29 -0
  330. package/dist/stage/PageSurface.vue.d.ts +29 -0
  331. package/dist/stage/Scrollbar.vue.d.cts +32 -0
  332. package/dist/stage/Scrollbar.vue.d.ts +32 -0
  333. package/dist/stage/Stage.vue.d.cts +44 -0
  334. package/dist/stage/Stage.vue.d.ts +44 -0
  335. package/dist/stage/StageScope.vue.d.cts +17 -0
  336. package/dist/stage/StageScope.vue.d.ts +17 -0
  337. package/dist/stage/composables.d.cts +41 -0
  338. package/dist/stage/composables.d.ts +41 -0
  339. package/dist/stage/scope.d.cts +12 -0
  340. package/dist/stage/scope.d.ts +12 -0
  341. package/dist/stage.cjs +21 -0
  342. package/dist/stage.cjs.map +1 -0
  343. package/dist/stage.d.cts +17 -0
  344. package/dist/stage.d.ts +17 -0
  345. package/dist/stage.js +15 -0
  346. package/dist/stage.js.map +1 -0
  347. package/dist/stamp.cjs +68 -0
  348. package/dist/stamp.cjs.map +1 -0
  349. package/dist/stamp.d.cts +61 -0
  350. package/dist/stamp.d.ts +61 -0
  351. package/dist/stamp.js +61 -0
  352. package/dist/stamp.js.map +1 -0
  353. package/dist/state-DZg8q3v6.js +52 -0
  354. package/dist/state-DZg8q3v6.js.map +1 -0
  355. package/dist/state-M22NDJQo.cjs +51 -0
  356. package/dist/state-M22NDJQo.cjs.map +1 -0
  357. package/dist/state.d.cts +32 -0
  358. package/dist/state.d.ts +32 -0
  359. package/dist/strip-BSDB39Xh.cjs +743 -0
  360. package/dist/strip-BSDB39Xh.cjs.map +1 -0
  361. package/dist/strip-C3wLonKB.js +744 -0
  362. package/dist/strip-C3wLonKB.js.map +1 -0
  363. package/dist/surface-box-B9oa4YoG.js +12 -0
  364. package/dist/surface-box-B9oa4YoG.js.map +1 -0
  365. package/dist/surface-box-C7EvUOXp.cjs +11 -0
  366. package/dist/surface-box-C7EvUOXp.cjs.map +1 -0
  367. package/dist/theme.d.cts +13 -0
  368. package/dist/theme.d.ts +13 -0
  369. package/dist/toolbar/DefaultCollapsed.vue.d.cts +9 -0
  370. package/dist/toolbar/DefaultCollapsed.vue.d.ts +9 -0
  371. package/dist/toolbar/DefaultCommand.vue.d.cts +8 -0
  372. package/dist/toolbar/DefaultCommand.vue.d.ts +8 -0
  373. package/dist/toolbar/DefaultGroupTrigger.vue.d.cts +9 -0
  374. package/dist/toolbar/DefaultGroupTrigger.vue.d.ts +9 -0
  375. package/dist/toolbar/DefaultOverflowMenu.vue.d.cts +9 -0
  376. package/dist/toolbar/DefaultOverflowMenu.vue.d.ts +9 -0
  377. package/dist/toolbar/DefaultOverflowTrigger.vue.d.cts +10 -0
  378. package/dist/toolbar/DefaultOverflowTrigger.vue.d.ts +10 -0
  379. package/dist/toolbar/Measured.vue.d.cts +21 -0
  380. package/dist/toolbar/Measured.vue.d.ts +21 -0
  381. package/dist/toolbar/NativeSlotSocket.vue.d.cts +22 -0
  382. package/dist/toolbar/NativeSlotSocket.vue.d.ts +22 -0
  383. package/dist/toolbar/Toolbar.vue.d.cts +82 -0
  384. package/dist/toolbar/Toolbar.vue.d.ts +82 -0
  385. package/dist/toolbar/ToolbarPart.vue.d.cts +42 -0
  386. package/dist/toolbar/ToolbarPart.vue.d.ts +42 -0
  387. package/dist/toolbar/paint.d.cts +3 -0
  388. package/dist/toolbar/paint.d.ts +3 -0
  389. package/dist/toolbar/strip.d.cts +14 -0
  390. package/dist/toolbar/strip.d.ts +14 -0
  391. package/dist/toolbar/views.d.cts +15 -0
  392. package/dist/toolbar/views.d.ts +15 -0
  393. package/dist/toolbar.cjs +27 -0
  394. package/dist/toolbar.cjs.map +1 -0
  395. package/dist/toolbar.d.cts +14 -0
  396. package/dist/toolbar.d.ts +14 -0
  397. package/dist/toolbar.js +12 -0
  398. package/dist/toolbar.js.map +1 -0
  399. package/dist/view-manager.cjs +22 -0
  400. package/dist/view-manager.cjs.map +1 -0
  401. package/dist/view-manager.d.cts +24 -0
  402. package/dist/view-manager.d.ts +24 -0
  403. package/dist/view-manager.js +17 -0
  404. package/dist/view-manager.js.map +1 -0
  405. package/package.json +169 -3
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const pluginAnnotation = require("@embedpdf/plugin-annotation");
4
+ const composables = require("./composables-BuHvnUlo.cjs");
5
+ exports.AnnotationDraftMenu = composables._sfc_main;
6
+ exports.AnnotationLayer = composables._sfc_main$1;
7
+ exports.AnnotationMenu = composables._sfc_main$2;
8
+ exports.AnnotationRotationBadge = composables._sfc_main$3;
9
+ exports.filePickerProvider = composables.filePickerProvider;
10
+ exports.useAnnotation = composables.useAnnotation;
11
+ exports.useAnnotationAnchor = composables.useAnnotationAnchor;
12
+ exports.useAnnotationDefaults = composables.useAnnotationDefaults;
13
+ exports.useAnnotationEvent = composables.useAnnotationEvent;
14
+ exports.useAnnotationList = composables.useAnnotationList;
15
+ exports.useAnnotationProperties = composables.useAnnotationProperties;
16
+ exports.useAnnotationSettings = composables.useAnnotationSettings;
17
+ exports.useAnnotationState = composables.useAnnotationState;
18
+ exports.useCommentThread = composables.useCommentThread;
19
+ exports.useCommentThreads = composables.useCommentThreads;
20
+ exports.useComments = composables.useComments;
21
+ exports.useFilePickerProvider = composables.useFilePickerProvider;
22
+ exports.useRichTextEditor = composables.useRichTextEditor;
23
+ Object.keys(pluginAnnotation).forEach((k) => {
24
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
25
+ enumerable: true,
26
+ get: () => pluginAnnotation[k]
27
+ });
28
+ });
29
+ //# sourceMappingURL=annotation.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotation.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @embedpdf/vue/annotation: the Vue view of `@embedpdf/plugin-annotation`.
3
+ *
4
+ * `<AnnotationLayer>` draws a page's annotations, the selection's handles,
5
+ * the tool's preview and the text boxes being typed in, with `renderers` for
6
+ * your own looks and `#handle` / `#rotation-handle` slots for your own
7
+ * handles. `<AnnotationMenu>`, `<AnnotationDraftMenu>` and
8
+ * `<AnnotationRotationBadge>` float your UI over the selection, a shape being
9
+ * drawn and a turn in progress.
10
+ *
11
+ * The composables follow every plugin's four: `useAnnotation()` (the API),
12
+ * `useAnnotationState()` (status, selected, hovered, editing),
13
+ * `useAnnotationEvent()` and `useAnnotationSettings()`; the reads a component
14
+ * follows on their own are refs: `useAnnotationList()`,
15
+ * `useAnnotationDefaults()`, `useAnnotationProperties()`,
16
+ * `useAnnotationAnchor()`, and the comments' `useCommentThreads()` and
17
+ * `useCommentThread()`. `useRichTextEditor()` makes your element a text box's
18
+ * editor, and `useFilePickerProvider()` installs the file dialog behind
19
+ * click-then-pick tools.
20
+ *
21
+ * What isn't Vue lives in `@embedpdf/web`, the same for every framework: the
22
+ * scene as SVG elements, the chrome's paint and pixels, the text box editor,
23
+ * which drawing each annotation gets and the behaviors renderers register,
24
+ * and the object URLs of baked appearances and the stamp ghost.
25
+ */
26
+ export * from '@embedpdf/plugin-annotation';
27
+ export type { CreationDraftAnchor, RenderItem, LineEnding, LineEndings, Style, AnnotationFlags, FieldValues, TextAlign, TextStyle, } from '@embedpdf/core-annotation';
28
+ export { default as AnnotationLayer } from './annotation/AnnotationLayer.vue.cjs';
29
+ export { default as AnnotationMenu } from './annotation/AnnotationMenu.vue.cjs';
30
+ export { default as AnnotationDraftMenu } from './annotation/AnnotationDraftMenu.vue.cjs';
31
+ export { default as AnnotationRotationBadge } from './annotation/AnnotationRotationBadge.vue.cjs';
32
+ export { useAnnotationSettings, useAnnotationState } from './annotation/state.cjs';
33
+ export { filePickerProvider, useAnnotation, useAnnotationAnchor, useAnnotationDefaults, useAnnotationEvent, useAnnotationList, useAnnotationProperties, useCommentThread, useCommentThreads, useComments, useFilePickerProvider, } from './annotation/composables.cjs';
34
+ export { useRichTextEditor } from './annotation/text-box.cjs';
35
+ export type { AnnotationFrame, AnnotationInteractiveContext, AnnotationRenderer, AnnotationRendererProps, BehaviorRendererProps, CommentThreadView, HandleProps, RichTextEditor, RotationHandleProps, } from './annotation/types.cjs';
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @embedpdf/vue/annotation: the Vue view of `@embedpdf/plugin-annotation`.
3
+ *
4
+ * `<AnnotationLayer>` draws a page's annotations, the selection's handles,
5
+ * the tool's preview and the text boxes being typed in, with `renderers` for
6
+ * your own looks and `#handle` / `#rotation-handle` slots for your own
7
+ * handles. `<AnnotationMenu>`, `<AnnotationDraftMenu>` and
8
+ * `<AnnotationRotationBadge>` float your UI over the selection, a shape being
9
+ * drawn and a turn in progress.
10
+ *
11
+ * The composables follow every plugin's four: `useAnnotation()` (the API),
12
+ * `useAnnotationState()` (status, selected, hovered, editing),
13
+ * `useAnnotationEvent()` and `useAnnotationSettings()`; the reads a component
14
+ * follows on their own are refs: `useAnnotationList()`,
15
+ * `useAnnotationDefaults()`, `useAnnotationProperties()`,
16
+ * `useAnnotationAnchor()`, and the comments' `useCommentThreads()` and
17
+ * `useCommentThread()`. `useRichTextEditor()` makes your element a text box's
18
+ * editor, and `useFilePickerProvider()` installs the file dialog behind
19
+ * click-then-pick tools.
20
+ *
21
+ * What isn't Vue lives in `@embedpdf/web`, the same for every framework: the
22
+ * scene as SVG elements, the chrome's paint and pixels, the text box editor,
23
+ * which drawing each annotation gets and the behaviors renderers register,
24
+ * and the object URLs of baked appearances and the stamp ghost.
25
+ */
26
+ export * from '@embedpdf/plugin-annotation';
27
+ export type { CreationDraftAnchor, RenderItem, LineEnding, LineEndings, Style, AnnotationFlags, FieldValues, TextAlign, TextStyle, } from '@embedpdf/core-annotation';
28
+ export { default as AnnotationLayer } from './annotation/AnnotationLayer.vue.js';
29
+ export { default as AnnotationMenu } from './annotation/AnnotationMenu.vue.js';
30
+ export { default as AnnotationDraftMenu } from './annotation/AnnotationDraftMenu.vue.js';
31
+ export { default as AnnotationRotationBadge } from './annotation/AnnotationRotationBadge.vue.js';
32
+ export { useAnnotationSettings, useAnnotationState } from './annotation/state.js';
33
+ export { filePickerProvider, useAnnotation, useAnnotationAnchor, useAnnotationDefaults, useAnnotationEvent, useAnnotationList, useAnnotationProperties, useCommentThread, useCommentThreads, useComments, useFilePickerProvider, } from './annotation/composables.js';
34
+ export { useRichTextEditor } from './annotation/text-box.js';
35
+ export type { AnnotationFrame, AnnotationInteractiveContext, AnnotationRenderer, AnnotationRendererProps, BehaviorRendererProps, CommentThreadView, HandleProps, RichTextEditor, RotationHandleProps, } from './annotation/types.js';
@@ -0,0 +1,23 @@
1
+ export * from "@embedpdf/plugin-annotation";
2
+ import { _, a, b, c, f, u, d, e, g, h, i, j, k, l, m, n, o, p } from "./composables-CIkhKwAg.js";
3
+ export {
4
+ _ as AnnotationDraftMenu,
5
+ a as AnnotationLayer,
6
+ b as AnnotationMenu,
7
+ c as AnnotationRotationBadge,
8
+ f as filePickerProvider,
9
+ u as useAnnotation,
10
+ d as useAnnotationAnchor,
11
+ e as useAnnotationDefaults,
12
+ g as useAnnotationEvent,
13
+ h as useAnnotationList,
14
+ i as useAnnotationProperties,
15
+ j as useAnnotationSettings,
16
+ k as useAnnotationState,
17
+ l as useCommentThread,
18
+ m as useCommentThreads,
19
+ n as useComments,
20
+ o as useFilePickerProvider,
21
+ p as useRichTextEditor
22
+ };
23
+ //# sourceMappingURL=annotation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotation.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,164 @@
1
+ import { provide, computed, toValue, inject, watch, markRaw } from "vue";
2
+ import { standInFor, isReadMember } from "@embedpdf/core";
3
+ const ViewerKey = Symbol("embedpdf viewer");
4
+ const DocumentScopeKey = Symbol(
5
+ "embedpdf document scope"
6
+ );
7
+ function provideViewer(binding) {
8
+ provide(ViewerKey, binding);
9
+ }
10
+ function useViewerBinding() {
11
+ const binding = inject(ViewerKey, null);
12
+ if (!(binding == null ? void 0 : binding.kernel)) {
13
+ throw new Error(
14
+ "No <Viewer> above this component: EmbedPDF composables work in components rendered inside <Viewer>, not in the component that renders it."
15
+ );
16
+ }
17
+ return binding;
18
+ }
19
+ function useKernel() {
20
+ return useViewerBinding().kernel;
21
+ }
22
+ function useKernelValue(select, isEqual = Object.is) {
23
+ const { kernel, track } = useViewerBinding();
24
+ return computed((previous) => {
25
+ track();
26
+ const next = select(kernel);
27
+ return previous !== void 0 && isEqual(previous, next) ? previous : next;
28
+ });
29
+ }
30
+ const NO_SCOPE = computed(() => null);
31
+ function provideDocumentScope(id) {
32
+ provide(
33
+ DocumentScopeKey,
34
+ computed(() => toValue(id))
35
+ );
36
+ }
37
+ function useDocumentScope() {
38
+ return inject(DocumentScopeKey, NO_SCOPE);
39
+ }
40
+ function useActiveDocumentId() {
41
+ return useKernelValue((kernel) => kernel.documents.getActiveId());
42
+ }
43
+ function useDocumentId() {
44
+ const scope = useDocumentScope();
45
+ const active = useActiveDocumentId();
46
+ return computed(() => scope.value ?? active.value);
47
+ }
48
+ function useOptionalCapability(token) {
49
+ const scope = useDocumentScope();
50
+ return useKernelValue((kernel) => kernel.tryCapability(toValue(token), scope.value ?? void 0));
51
+ }
52
+ function useCapabilityRef(token) {
53
+ const kernel = useKernel();
54
+ const resolved = useOptionalCapability(token);
55
+ const capability = computed(() => {
56
+ const current = resolved.value;
57
+ if (current) return current;
58
+ const wanted = toValue(token);
59
+ if (kernel.scopeOf(wanted) === "document") return standInFor(kernel, wanted);
60
+ return kernel.capability(wanted);
61
+ });
62
+ void capability.value;
63
+ return capability;
64
+ }
65
+ function useCapability(token) {
66
+ return liveCapability(useCapabilityRef(token), useViewerBinding().track);
67
+ }
68
+ const isVueFlag = (key) => typeof key === "string" && key.startsWith("__v_");
69
+ function liveCapability(current, track) {
70
+ let latest = current.value;
71
+ watch(current, (capability) => latest = capability, { flush: "sync" });
72
+ const resolve = (tracked) => tracked ? current.value : latest;
73
+ return liveMember(resolve, track, null);
74
+ }
75
+ function liveMember(resolve, track, call) {
76
+ const members = /* @__PURE__ */ new Map();
77
+ const target = markRaw(call ? function member() {
78
+ } : {});
79
+ return new Proxy(target, {
80
+ apply: (_target, _this, args) => call(args),
81
+ has: (_target, key) => {
82
+ const value = resolve(false);
83
+ return (typeof value === "object" || typeof value === "function") && value !== null ? key in value : false;
84
+ },
85
+ get(_target, key) {
86
+ var _a;
87
+ if (isVueFlag(key)) return Reflect.get(target, key);
88
+ if (typeof key === "symbol" || key === "then") return void 0;
89
+ const value = (_a = resolve(false)) == null ? void 0 : _a[key];
90
+ if (typeof value !== "function" && (typeof value !== "object" || value === null)) {
91
+ return value;
92
+ }
93
+ let member = members.get(key);
94
+ if (!member) {
95
+ const invoke = (tracked, args) => {
96
+ const owner = resolve(tracked);
97
+ return Reflect.apply(owner[key], owner, args);
98
+ };
99
+ member = liveMember(
100
+ (tracked) => resolve(tracked)[key],
101
+ track,
102
+ isReadMember(key) ? (
103
+ // A computed of its own for each call: its reader wakes when the answer changes.
104
+ ((args) => computed(() => {
105
+ track();
106
+ return invoke(true, args);
107
+ }).value)
108
+ ) : (args) => invoke(false, args)
109
+ );
110
+ members.set(key, member);
111
+ }
112
+ return member;
113
+ }
114
+ });
115
+ }
116
+ function useSelector(token, select, isEqual = Object.is) {
117
+ const scope = useDocumentScope();
118
+ return useKernelValue((kernel) => {
119
+ const wanted = toValue(token);
120
+ const documentId = scope.value ?? void 0;
121
+ const capability = kernel.tryCapability(wanted, documentId) ?? kernel.capability(wanted, documentId);
122
+ return select(capability);
123
+ }, isEqual);
124
+ }
125
+ function useOptionalSelector(token, select, fallback, isEqual = Object.is) {
126
+ const scope = useDocumentScope();
127
+ return useKernelValue((kernel) => {
128
+ const capability = kernel.tryCapability(toValue(token), scope.value ?? void 0);
129
+ if (capability === null) return fallback;
130
+ try {
131
+ return select(capability);
132
+ } catch {
133
+ return fallback;
134
+ }
135
+ }, isEqual);
136
+ }
137
+ function useCapabilityEvent(token, select, handler) {
138
+ const capability = useOptionalCapability(token);
139
+ watch(
140
+ capability,
141
+ (current, _previous, onCleanup) => {
142
+ if (!current) return;
143
+ onCleanup(select(current)((event) => handler(event)));
144
+ },
145
+ { immediate: true, flush: "sync" }
146
+ );
147
+ }
148
+ export {
149
+ useCapability as a,
150
+ useCapabilityEvent as b,
151
+ useCapabilityRef as c,
152
+ useDocumentId as d,
153
+ useDocumentScope as e,
154
+ useKernel as f,
155
+ useKernelValue as g,
156
+ useOptionalCapability as h,
157
+ useOptionalSelector as i,
158
+ useSelector as j,
159
+ provideViewer as k,
160
+ useViewerBinding as l,
161
+ provideDocumentScope as p,
162
+ useActiveDocumentId as u
163
+ };
164
+ //# sourceMappingURL=capabilities-C7YzgPCX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities-C7YzgPCX.js","sources":["../src/runtime/kernel.ts","../src/runtime/capabilities.ts"],"sourcesContent":["/**\n * The kernel as Vue reads it. `<Viewer>` provides one {@link ViewerBinding}:\n * the kernel and a `track()` that makes a computed depend on the kernel's one\n * change stream. Every reader in the package is a computed over it\n * ({@link useKernelValue}), cached by an equality, so a component updates only\n * when the value it reads changed. `<DocumentScope>` provides the document a\n * subtree talks to.\n */\nimport { computed, inject, provide, toValue } from 'vue';\nimport type { InjectionKey, MaybeRefOrGetter, Ref } from 'vue';\nimport type { Kernel } from '@embedpdf/core';\n\n/** What `<Viewer>` gives the components inside it. */\nexport interface ViewerBinding {\n /** The kernel, from the moment `<Viewer>` creates it; null before that. */\n readonly kernel: Kernel | null;\n /** Read inside a computed: the computed runs again on every change the kernel announces. */\n track(): void;\n}\n\nconst ViewerKey: InjectionKey<ViewerBinding> = Symbol('embedpdf viewer');\nconst DocumentScopeKey: InjectionKey<Readonly<Ref<string | null>>> = Symbol(\n 'embedpdf document scope',\n);\n\n/** Installed by `<Viewer>`, not by app code. */\nexport function provideViewer(binding: ViewerBinding): void {\n provide(ViewerKey, binding);\n}\n\n/** The binding of the nearest `<Viewer>`, with its kernel. */\nexport function useViewerBinding(): ViewerBinding & { readonly kernel: Kernel } {\n const binding = inject(ViewerKey, null);\n if (!binding?.kernel) {\n // The usual cause in Vue: a composable called in the component that renders\n // <Viewer>, which can't inject what its own child provides.\n throw new Error(\n 'No <Viewer> above this component: EmbedPDF composables work in components rendered ' +\n 'inside <Viewer>, not in the component that renders it.',\n );\n }\n return binding as ViewerBinding & { readonly kernel: Kernel };\n}\n\n/** The kernel of the nearest `<Viewer>`. */\nexport function useKernel(): Kernel {\n return useViewerBinding().kernel;\n}\n\n/**\n * A value derived from the kernel, as a ref. `select` runs again on every\n * kernel change and on a change to any ref it reads; the ref keeps its value\n * while `isEqual` says the new one is the same, so nothing that reads it\n * updates.\n */\nexport function useKernelValue<Value>(\n select: (kernel: Kernel) => Value,\n isEqual: (left: Value, right: Value) => boolean = Object.is,\n): Readonly<Ref<Value>> {\n const { kernel, track } = useViewerBinding();\n // `previous` is undefined only on the first run, which has nothing to keep.\n return computed((previous: Value | undefined) => {\n track();\n const next = select(kernel);\n return previous !== undefined && isEqual(previous, next) ? previous : next;\n });\n}\n\nconst NO_SCOPE = computed((): string | null => null);\n\n/** Installed by `<DocumentScope>`: the document the subtree talks to. */\nexport function provideDocumentScope(id: MaybeRefOrGetter<string | null>): void {\n provide(\n DocumentScopeKey,\n computed(() => toValue(id)),\n );\n}\n\n/**\n * The document the nearest `<DocumentScope>` binds this subtree to, or null\n * when it follows the active document. For readers that pass it to\n * `kernel.tryCapability`; UI that needs the id itself uses {@link useDocumentId}.\n */\nexport function useDocumentScope(): Readonly<Ref<string | null>> {\n return inject(DocumentScopeKey, NO_SCOPE);\n}\n\n/** The active document's id, or null with none open. */\nexport function useActiveDocumentId(): Readonly<Ref<string | null>> {\n return useKernelValue((kernel) => kernel.documents.getActiveId());\n}\n\n/** The document id for this subtree: the nearest `<DocumentScope>`, else the active document. */\nexport function useDocumentId(): Readonly<Ref<string | null>> {\n const scope = useDocumentScope();\n const active = useActiveDocumentId();\n return computed(() => scope.value ?? active.value);\n}\n","/**\n * Capabilities as Vue reads them. A component's setup runs once, so the object\n * `useCapability()` returns is live: every call reaches the capability the\n * subtree resolves to now (the document in scope, or a stand-in while there is\n * none), and the object itself never changes. Selectors are refs, and an event\n * subscription follows the capability and ends with the component.\n *\n * Reads follow the capability vocabulary (docs/conventions/naming.md): a\n * method named `get*`, `list*`, `is*`, `has*` or `can*` reads state, so a call\n * to it in a template, a `computed` or a `watchEffect` updates when its answer\n * changes: `v-if=\"annotation.canCreate()\"` follows the permissions. Every other\n * method tracks nothing: a `watchEffect` that calls `stage.reveal(index)` runs\n * again only when `index` changes.\n */\nimport { computed, markRaw, toValue, watch } from 'vue';\nimport type { MaybeRefOrGetter, Ref } from 'vue';\nimport { isReadMember, standInFor } from '@embedpdf/core';\nimport type { CapabilityToken, EventHook } from '@embedpdf/core';\nimport { useDocumentScope, useKernel, useKernelValue, useViewerBinding } from './kernel';\n\n/**\n * Like {@link useCapability}, but a ref that is null while the token can't\n * resolve: no plugin, no document, or a document that isn't ready yet. It\n * changes when the subtree's document does, so a `watch` on it rebinds.\n */\nexport function useOptionalCapability<Capability>(\n token: MaybeRefOrGetter<CapabilityToken<Capability>>,\n): Readonly<Ref<Capability | null>> {\n const scope = useDocumentScope();\n return useKernelValue((kernel) => kernel.tryCapability(toValue(token), scope.value ?? undefined));\n}\n\n/**\n * The capability a subtree resolves to, as a ref: the document's while one is\n * ready, else the stand-in for a document plugin. A token no plugin provides\n * throws here, at setup: that is a setup mistake.\n */\nexport function useCapabilityRef<Capability>(\n token: MaybeRefOrGetter<CapabilityToken<Capability>>,\n): Readonly<Ref<Capability>> {\n const kernel = useKernel();\n const resolved = useOptionalCapability(token);\n const capability = computed(() => {\n const current = resolved.value;\n if (current) return current;\n const wanted = toValue(token);\n if (kernel.scopeOf(wanted) === 'document') return standInFor(kernel, wanted);\n return kernel.capability(wanted);\n });\n // Resolve once now, so a missing plugin fails where it is used.\n void capability.value;\n return capability;\n}\n\n/**\n * A plugin's API for this subtree: `const stage = useCapability(StageToken)`,\n * then `stage.zoomIn()` in a handler or a template. The object stays the same\n * for the component's life and always calls the capability of the document in\n * scope, so it is safe to keep in a closure. A read (`stage.getZoomLevel()`)\n * in a template or a computed updates when its answer changes.\n *\n * Outside a document (none open, not ready yet, or none in scope), a document\n * plugin's members belong to its stand-in: reading one never throws, so chrome\n * renders before the first document opens, and calling one refuses with\n * `PluginError('not-ready')`: a method that returns a promise rejects, the\n * others throw.\n */\nexport function useCapability<Capability>(\n token: MaybeRefOrGetter<CapabilityToken<Capability>>,\n): Capability {\n return liveCapability(useCapabilityRef(token), useViewerBinding().track);\n}\n\n/** Vue's own flags (`__v_skip`, `__v_isRef`): answered by the target, so Vue never wraps the object. */\nconst isVueFlag = (key: string | symbol): boolean =>\n typeof key === 'string' && key.startsWith('__v_');\n\ntype Members = Record<string, unknown>;\ntype Method = (...args: unknown[]) => unknown;\n\n/**\n * The object {@link useCapability} returns, over `current`, the capability the\n * subtree resolves to. A read resolves it in a `computed` of its own that also\n * follows the kernel, so whoever reads the call depends on its answer; a verb\n * resolves the capability as it is now, without making the caller depend on\n * anything.\n */\nfunction liveCapability<Capability>(\n current: Readonly<Ref<Capability>>,\n track: () => void,\n): Capability {\n // The capability now, kept without a dependency: what a verb calls.\n let latest = current.value;\n watch(current, (capability) => (latest = capability), { flush: 'sync' });\n const resolve = (tracked: boolean): unknown => (tracked ? current.value : latest);\n return liveMember(resolve, track, null) as Capability;\n}\n\n/**\n * A live member over `resolve(tracked)`: the capability, or a namespace in it\n * (`annotation.comments`). Members are cached by name, so `stage.zoomIn` is the\n * same function every time; a member that is a plain value is read as it is\n * now. Marked raw, so Vue never makes it reactive.\n */\nfunction liveMember(\n resolve: (tracked: boolean) => unknown,\n track: () => void,\n call: ((args: unknown[]) => unknown) | null,\n): object {\n const members = new Map<string, object>();\n // A function target, so a member can be called and can have members of its own.\n const target = markRaw(call ? function member() {} : {});\n return new Proxy(target, {\n apply: (_target, _this, args) => call!(args),\n has: (_target, key) => {\n const value = resolve(false);\n return (typeof value === 'object' || typeof value === 'function') && value !== null\n ? key in value\n : false;\n },\n get(_target, key) {\n if (isVueFlag(key)) return Reflect.get(target, key);\n // Not a thenable, and inspecting it never resolves anything.\n if (typeof key === 'symbol' || key === 'then') return undefined;\n const value = (resolve(false) as Members | null)?.[key];\n if (typeof value !== 'function' && (typeof value !== 'object' || value === null)) {\n return value;\n }\n let member = members.get(key);\n if (!member) {\n const invoke = (tracked: boolean, args: unknown[]): unknown => {\n const owner = resolve(tracked) as Members;\n // `Reflect.apply`, not `.apply`: a stand-in's member answers every property, `apply` too.\n return Reflect.apply(owner[key] as Method, owner, args);\n };\n member = liveMember(\n (tracked) => (resolve(tracked) as Members)[key],\n track,\n isReadMember(key)\n ? // A computed of its own for each call: its reader wakes when the answer changes.\n (args) =>\n computed(() => {\n track();\n return invoke(true, args);\n }).value\n : (args) => invoke(false, args),\n );\n members.set(key, member);\n }\n return member;\n },\n });\n}\n\n/**\n * A value read from a capability, as a ref. Strict: while the token can't\n * resolve, reading it throws the kernel's reason (`no document`, `document is\n * loading`), for code that knows a document exists, such as anything inside a\n * `<DocumentGate>`. {@link useOptionalSelector} is its total twin.\n */\nexport function useSelector<Capability, Value>(\n token: MaybeRefOrGetter<CapabilityToken<Capability>>,\n select: (capability: Capability) => Value,\n isEqual: (left: Value, right: Value) => boolean = Object.is,\n): Readonly<Ref<Value>> {\n const scope = useDocumentScope();\n return useKernelValue((kernel) => {\n const wanted = toValue(token);\n const documentId = scope.value ?? undefined;\n const capability =\n kernel.tryCapability(wanted, documentId) ?? kernel.capability(wanted, documentId);\n return select(capability);\n }, isEqual);\n}\n\n/**\n * Null-safe {@link useSelector}: `fallback` whenever the token can't resolve\n * (no provider, or a document-scoped token with no document). For chrome that\n * stays mounted across the empty workspace (a zoom readout, a mode band). A\n * read through a capability whose document closed a moment ago is `fallback`\n * too.\n */\nexport function useOptionalSelector<Capability, Value>(\n token: MaybeRefOrGetter<CapabilityToken<Capability>>,\n select: (capability: Capability) => Value,\n fallback: Value,\n isEqual: (left: Value, right: Value) => boolean = Object.is,\n): Readonly<Ref<Value>> {\n const scope = useDocumentScope();\n return useKernelValue((kernel) => {\n const capability = kernel.tryCapability(toValue(token), scope.value ?? undefined);\n if (capability === null) return fallback;\n try {\n return select(capability);\n } catch {\n return fallback;\n }\n }, isEqual);\n}\n\n/**\n * Subscribe to a capability's {@link EventHook} while the component lives:\n * `useCapabilityEvent(ActionsToken, (actions) => actions.onExecuted, handler)`.\n * Events carry occurrences, never state (a late subscriber that needs the\n * current value uses a selector). It subscribes to the document in scope, again\n * when that document changes, and ends with the component. Null-safe: with no\n * plugin or no document there is no subscription.\n */\nexport function useCapabilityEvent<Capability, Event>(\n token: MaybeRefOrGetter<CapabilityToken<Capability>>,\n select: (capability: Capability) => EventHook<Event>,\n handler: (event: Event) => void,\n): void {\n const capability = useOptionalCapability(token);\n // `sync`: subscribed in the same change that made the capability resolvable,\n // so no event between that change and the next render is missed.\n watch(\n capability,\n (current, _previous, onCleanup) => {\n if (!current) return;\n onCleanup(select(current)((event) => handler(event)));\n },\n { immediate: true, flush: 'sync' },\n );\n}\n"],"names":[],"mappings":";;AAoBA,MAAM,YAAyC,OAAO,iBAAiB;AACvE,MAAM,mBAA+D;AAAA,EACnE;AACF;AAGO,SAAS,cAAc,SAA8B;AAC1D,UAAQ,WAAW,OAAO;AAC5B;AAGO,SAAS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AC;AAAA,IACtD;AAAA,IACA,EAAE,WAAW,MAAM,OAAO,OAAA;AAAA,EAAO;AAErC;"}
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ const vue = require("vue");
3
+ const core = require("@embedpdf/core");
4
+ const ViewerKey = Symbol("embedpdf viewer");
5
+ const DocumentScopeKey = Symbol(
6
+ "embedpdf document scope"
7
+ );
8
+ function provideViewer(binding) {
9
+ vue.provide(ViewerKey, binding);
10
+ }
11
+ function useViewerBinding() {
12
+ const binding = vue.inject(ViewerKey, null);
13
+ if (!(binding == null ? void 0 : binding.kernel)) {
14
+ throw new Error(
15
+ "No <Viewer> above this component: EmbedPDF composables work in components rendered inside <Viewer>, not in the component that renders it."
16
+ );
17
+ }
18
+ return binding;
19
+ }
20
+ function useKernel() {
21
+ return useViewerBinding().kernel;
22
+ }
23
+ function useKernelValue(select, isEqual = Object.is) {
24
+ const { kernel, track } = useViewerBinding();
25
+ return vue.computed((previous) => {
26
+ track();
27
+ const next = select(kernel);
28
+ return previous !== void 0 && isEqual(previous, next) ? previous : next;
29
+ });
30
+ }
31
+ const NO_SCOPE = vue.computed(() => null);
32
+ function provideDocumentScope(id) {
33
+ vue.provide(
34
+ DocumentScopeKey,
35
+ vue.computed(() => vue.toValue(id))
36
+ );
37
+ }
38
+ function useDocumentScope() {
39
+ return vue.inject(DocumentScopeKey, NO_SCOPE);
40
+ }
41
+ function useActiveDocumentId() {
42
+ return useKernelValue((kernel) => kernel.documents.getActiveId());
43
+ }
44
+ function useDocumentId() {
45
+ const scope = useDocumentScope();
46
+ const active = useActiveDocumentId();
47
+ return vue.computed(() => scope.value ?? active.value);
48
+ }
49
+ function useOptionalCapability(token) {
50
+ const scope = useDocumentScope();
51
+ return useKernelValue((kernel) => kernel.tryCapability(vue.toValue(token), scope.value ?? void 0));
52
+ }
53
+ function useCapabilityRef(token) {
54
+ const kernel = useKernel();
55
+ const resolved = useOptionalCapability(token);
56
+ const capability = vue.computed(() => {
57
+ const current = resolved.value;
58
+ if (current) return current;
59
+ const wanted = vue.toValue(token);
60
+ if (kernel.scopeOf(wanted) === "document") return core.standInFor(kernel, wanted);
61
+ return kernel.capability(wanted);
62
+ });
63
+ void capability.value;
64
+ return capability;
65
+ }
66
+ function useCapability(token) {
67
+ return liveCapability(useCapabilityRef(token), useViewerBinding().track);
68
+ }
69
+ const isVueFlag = (key) => typeof key === "string" && key.startsWith("__v_");
70
+ function liveCapability(current, track) {
71
+ let latest = current.value;
72
+ vue.watch(current, (capability) => latest = capability, { flush: "sync" });
73
+ const resolve = (tracked) => tracked ? current.value : latest;
74
+ return liveMember(resolve, track, null);
75
+ }
76
+ function liveMember(resolve, track, call) {
77
+ const members = /* @__PURE__ */ new Map();
78
+ const target = vue.markRaw(call ? function member() {
79
+ } : {});
80
+ return new Proxy(target, {
81
+ apply: (_target, _this, args) => call(args),
82
+ has: (_target, key) => {
83
+ const value = resolve(false);
84
+ return (typeof value === "object" || typeof value === "function") && value !== null ? key in value : false;
85
+ },
86
+ get(_target, key) {
87
+ var _a;
88
+ if (isVueFlag(key)) return Reflect.get(target, key);
89
+ if (typeof key === "symbol" || key === "then") return void 0;
90
+ const value = (_a = resolve(false)) == null ? void 0 : _a[key];
91
+ if (typeof value !== "function" && (typeof value !== "object" || value === null)) {
92
+ return value;
93
+ }
94
+ let member = members.get(key);
95
+ if (!member) {
96
+ const invoke = (tracked, args) => {
97
+ const owner = resolve(tracked);
98
+ return Reflect.apply(owner[key], owner, args);
99
+ };
100
+ member = liveMember(
101
+ (tracked) => resolve(tracked)[key],
102
+ track,
103
+ core.isReadMember(key) ? (
104
+ // A computed of its own for each call: its reader wakes when the answer changes.
105
+ ((args) => vue.computed(() => {
106
+ track();
107
+ return invoke(true, args);
108
+ }).value)
109
+ ) : (args) => invoke(false, args)
110
+ );
111
+ members.set(key, member);
112
+ }
113
+ return member;
114
+ }
115
+ });
116
+ }
117
+ function useSelector(token, select, isEqual = Object.is) {
118
+ const scope = useDocumentScope();
119
+ return useKernelValue((kernel) => {
120
+ const wanted = vue.toValue(token);
121
+ const documentId = scope.value ?? void 0;
122
+ const capability = kernel.tryCapability(wanted, documentId) ?? kernel.capability(wanted, documentId);
123
+ return select(capability);
124
+ }, isEqual);
125
+ }
126
+ function useOptionalSelector(token, select, fallback, isEqual = Object.is) {
127
+ const scope = useDocumentScope();
128
+ return useKernelValue((kernel) => {
129
+ const capability = kernel.tryCapability(vue.toValue(token), scope.value ?? void 0);
130
+ if (capability === null) return fallback;
131
+ try {
132
+ return select(capability);
133
+ } catch {
134
+ return fallback;
135
+ }
136
+ }, isEqual);
137
+ }
138
+ function useCapabilityEvent(token, select, handler) {
139
+ const capability = useOptionalCapability(token);
140
+ vue.watch(
141
+ capability,
142
+ (current, _previous, onCleanup) => {
143
+ if (!current) return;
144
+ onCleanup(select(current)((event) => handler(event)));
145
+ },
146
+ { immediate: true, flush: "sync" }
147
+ );
148
+ }
149
+ exports.provideDocumentScope = provideDocumentScope;
150
+ exports.provideViewer = provideViewer;
151
+ exports.useActiveDocumentId = useActiveDocumentId;
152
+ exports.useCapability = useCapability;
153
+ exports.useCapabilityEvent = useCapabilityEvent;
154
+ exports.useCapabilityRef = useCapabilityRef;
155
+ exports.useDocumentId = useDocumentId;
156
+ exports.useDocumentScope = useDocumentScope;
157
+ exports.useKernel = useKernel;
158
+ exports.useKernelValue = useKernelValue;
159
+ exports.useOptionalCapability = useOptionalCapability;
160
+ exports.useOptionalSelector = useOptionalSelector;
161
+ exports.useSelector = useSelector;
162
+ exports.useViewerBinding = useViewerBinding;
163
+ //# sourceMappingURL=capabilities-DVNJmgy7.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities-DVNJmgy7.cjs","sources":["../src/runtime/kernel.ts","../src/runtime/capabilities.ts"],"sourcesContent":["/**\n * The kernel as Vue reads it. `<Viewer>` provides one {@link ViewerBinding}:\n * the kernel and a `track()` that makes a computed depend on the kernel's one\n * change stream. Every reader in the package is a computed over it\n * ({@link useKernelValue}), cached by an equality, so a component updates only\n * when the value it reads changed. `<DocumentScope>` provides the document a\n * subtree talks to.\n */\nimport { computed, inject, provide, toValue } from 'vue';\nimport type { InjectionKey, MaybeRefOrGetter, Ref } from 'vue';\nimport type { Kernel } from '@embedpdf/core';\n\n/** What `<Viewer>` gives the components inside it. */\nexport interface ViewerBinding {\n /** The kernel, from the moment `<Viewer>` creates it; null before that. */\n readonly kernel: Kernel | null;\n /** Read inside a computed: the computed runs again on every change the kernel announces. */\n track(): void;\n}\n\nconst ViewerKey: InjectionKey<ViewerBinding> = Symbol('embedpdf viewer');\nconst DocumentScopeKey: InjectionKey<Readonly<Ref<string | null>>> = Symbol(\n 'embedpdf document scope',\n);\n\n/** Installed by `<Viewer>`, not by app code. */\nexport function provideViewer(binding: ViewerBinding): void {\n provide(ViewerKey, binding);\n}\n\n/** The binding of the nearest `<Viewer>`, with its kernel. */\nexport function useViewerBinding(): ViewerBinding & { readonly kernel: Kernel } {\n const binding = inject(ViewerKey, null);\n if (!binding?.kernel) {\n // The usual cause in Vue: a composable called in the component that renders\n // <Viewer>, which can't inject what its own child provides.\n throw new Error(\n 'No <Viewer> above this component: EmbedPDF composables work in components rendered ' +\n 'inside <Viewer>, not in the component that renders it.',\n );\n }\n return binding as ViewerBinding & { readonly kernel: Kernel };\n}\n\n/** The kernel of the nearest `<Viewer>`. */\nexport function useKernel(): Kernel {\n return useViewerBinding().kernel;\n}\n\n/**\n * A value derived from the kernel, as a ref. `select` runs again on every\n * kernel change and on a change to any ref it reads; the ref keeps its value\n * while `isEqual` says the new one is the same, so nothing that reads it\n * updates.\n */\nexport function useKernelValue<Value>(\n select: (kernel: Kernel) => Value,\n isEqual: (left: Value, right: Value) => boolean = Object.is,\n): Readonly<Ref<Value>> {\n const { kernel, track } = useViewerBinding();\n // `previous` is undefined only on the first run, which has nothing to keep.\n return computed((previous: Value | undefined) => {\n track();\n const next = select(kernel);\n return previous !== undefined && isEqual(previous, next) ? previous : next;\n });\n}\n\nconst NO_SCOPE = computed((): string | null => null);\n\n/** Installed by `<DocumentScope>`: the document the subtree talks to. */\nexport function provideDocumentScope(id: MaybeRefOrGetter<string | null>): void {\n provide(\n DocumentScopeKey,\n computed(() => toValue(id)),\n );\n}\n\n/**\n * The document the nearest `<DocumentScope>` binds this subtree to, or null\n * when it follows the active document. For readers that pass it to\n * `kernel.tryCapability`; UI that needs the id itself uses {@link useDocumentId}.\n */\nexport function useDocumentScope(): Readonly<Ref<string | null>> {\n return inject(DocumentScopeKey, NO_SCOPE);\n}\n\n/** The active document's id, or null with none open. */\nexport function useActiveDocumentId(): Readonly<Ref<string | null>> {\n return useKernelValue((kernel) => kernel.documents.getActiveId());\n}\n\n/** The document id for this subtree: the nearest `<DocumentScope>`, else the active document. */\nexport function useDocumentId(): Readonly<Ref<string | null>> {\n const scope = useDocumentScope();\n const active = useActiveDocumentId();\n return computed(() => scope.value ?? active.value);\n}\n","/**\n * Capabilities as Vue reads them. A component's setup runs once, so the object\n * `useCapability()` returns is live: every call reaches the capability the\n * subtree resolves to now (the document in scope, or a stand-in while there is\n * none), and the object itself never changes. Selectors are refs, and an event\n * subscription follows the capability and ends with the component.\n *\n * Reads follow the capability vocabulary (docs/conventions/naming.md): a\n * method named `get*`, `list*`, `is*`, `has*` or `can*` reads state, so a call\n * to it in a template, a `computed` or a `watchEffect` updates when its answer\n * changes: `v-if=\"annotation.canCreate()\"` follows the permissions. Every other\n * method tracks nothing: a `watchEffect` that calls `stage.reveal(index)` runs\n * again only when `index` changes.\n */\nimport { computed, markRaw, toValue, watch } from 'vue';\nimport type { MaybeRefOrGetter, Ref } from 'vue';\nimport { isReadMember, standInFor } from '@embedpdf/core';\nimport type { CapabilityToken, EventHook } from '@embedpdf/core';\nimport { useDocumentScope, useKernel, useKernelValue, useViewerBinding } from './kernel';\n\n/**\n * Like {@link useCapability}, but a ref that is null while the token can't\n * resolve: no plugin, no document, or a document that isn't ready yet. It\n * changes when the subtree's document does, so a `watch` on it rebinds.\n */\nexport function useOptionalCapability<Capability>(\n token: MaybeRefOrGetter<CapabilityToken<Capability>>,\n): Readonly<Ref<Capability | null>> {\n const scope = useDocumentScope();\n return useKernelValue((kernel) => kernel.tryCapability(toValue(token), scope.value ?? undefined));\n}\n\n/**\n * The capability a subtree resolves to, as a ref: the document's while one is\n * ready, else the stand-in for a document plugin. A token no plugin provides\n * throws here, at setup: that is a setup mistake.\n */\nexport function useCapabilityRef<Capability>(\n token: MaybeRefOrGetter<CapabilityToken<Capability>>,\n): Readonly<Ref<Capability>> {\n const kernel = useKernel();\n const resolved = useOptionalCapability(token);\n const capability = computed(() => {\n const current = resolved.value;\n if (current) return current;\n const wanted = toValue(token);\n if (kernel.scopeOf(wanted) === 'document') return standInFor(kernel, wanted);\n return kernel.capability(wanted);\n });\n // Resolve once now, so a missing plugin fails where it is used.\n void capability.value;\n return capability;\n}\n\n/**\n * A plugin's API for this subtree: `const stage = useCapability(StageToken)`,\n * then `stage.zoomIn()` in a handler or a template. The object stays the same\n * for the component's life and always calls the capability of the document in\n * scope, so it is safe to keep in a closure. A read (`stage.getZoomLevel()`)\n * in a template or a computed updates when its answer changes.\n *\n * Outside a document (none open, not ready yet, or none in scope), a document\n * plugin's members belong to its stand-in: reading one never throws, so chrome\n * renders before the first document opens, and calling one refuses with\n * `PluginError('not-ready')`: a method that returns a promise rejects, the\n * others throw.\n */\nexport function useCapability<Capability>(\n token: MaybeRefOrGetter<CapabilityToken<Capability>>,\n): Capability {\n return liveCapability(useCapabilityRef(token), useViewerBinding().track);\n}\n\n/** Vue's own flags (`__v_skip`, `__v_isRef`): answered by the target, so Vue never wraps the object. */\nconst isVueFlag = (key: string | symbol): boolean =>\n typeof key === 'string' && key.startsWith('__v_');\n\ntype Members = Record<string, unknown>;\ntype Method = (...args: unknown[]) => unknown;\n\n/**\n * The object {@link useCapability} returns, over `current`, the capability the\n * subtree resolves to. A read resolves it in a `computed` of its own that also\n * follows the kernel, so whoever reads the call depends on its answer; a verb\n * resolves the capability as it is now, without making the caller depend on\n * anything.\n */\nfunction liveCapability<Capability>(\n current: Readonly<Ref<Capability>>,\n track: () => void,\n): Capability {\n // The capability now, kept without a dependency: what a verb calls.\n let latest = current.value;\n watch(current, (capability) => (latest = capability), { flush: 'sync' });\n const resolve = (tracked: boolean): unknown => (tracked ? current.value : latest);\n return liveMember(resolve, track, null) as Capability;\n}\n\n/**\n * A live member over `resolve(tracked)`: the capability, or a namespace in it\n * (`annotation.comments`). Members are cached by name, so `stage.zoomIn` is the\n * same function every time; a member that is a plain value is read as it is\n * now. Marked raw, so Vue never makes it reactive.\n */\nfunction liveMember(\n resolve: (tracked: boolean) => unknown,\n track: () => void,\n call: ((args: unknown[]) => unknown) | null,\n): object {\n const members = new Map<string, object>();\n // A function target, so a member can be called and can have members of its own.\n const target = markRaw(call ? function member() {} : {});\n return new Proxy(target, {\n apply: (_target, _this, args) => call!(args),\n has: (_target, key) => {\n const value = resolve(false);\n return (typeof value === 'object' || typeof value === 'function') && value !== null\n ? key in value\n : false;\n },\n get(_target, key) {\n if (isVueFlag(key)) return Reflect.get(target, key);\n // Not a thenable, and inspecting it never resolves anything.\n if (typeof key === 'symbol' || key === 'then') return undefined;\n const value = (resolve(false) as Members | null)?.[key];\n if (typeof value !== 'function' && (typeof value !== 'object' || value === null)) {\n return value;\n }\n let member = members.get(key);\n if (!member) {\n const invoke = (tracked: boolean, args: unknown[]): unknown => {\n const owner = resolve(tracked) as Members;\n // `Reflect.apply`, not `.apply`: a stand-in's member answers every property, `apply` too.\n return Reflect.apply(owner[key] as Method, owner, args);\n };\n member = liveMember(\n (tracked) => (resolve(tracked) as Members)[key],\n track,\n isReadMember(key)\n ? // A computed of its own for each call: its reader wakes when the answer changes.\n (args) =>\n computed(() => {\n track();\n return invoke(true, args);\n }).value\n : (args) => invoke(false, args),\n );\n members.set(key, member);\n }\n return member;\n },\n });\n}\n\n/**\n * A value read from a capability, as a ref. Strict: while the token can't\n * resolve, reading it throws the kernel's reason (`no document`, `document is\n * loading`), for code that knows a document exists, such as anything inside a\n * `<DocumentGate>`. {@link useOptionalSelector} is its total twin.\n */\nexport function useSelector<Capability, Value>(\n token: MaybeRefOrGetter<CapabilityToken<Capability>>,\n select: (capability: Capability) => Value,\n isEqual: (left: Value, right: Value) => boolean = Object.is,\n): Readonly<Ref<Value>> {\n const scope = useDocumentScope();\n return useKernelValue((kernel) => {\n const wanted = toValue(token);\n const documentId = scope.value ?? undefined;\n const capability =\n kernel.tryCapability(wanted, documentId) ?? kernel.capability(wanted, documentId);\n return select(capability);\n }, isEqual);\n}\n\n/**\n * Null-safe {@link useSelector}: `fallback` whenever the token can't resolve\n * (no provider, or a document-scoped token with no document). For chrome that\n * stays mounted across the empty workspace (a zoom readout, a mode band). A\n * read through a capability whose document closed a moment ago is `fallback`\n * too.\n */\nexport function useOptionalSelector<Capability, Value>(\n token: MaybeRefOrGetter<CapabilityToken<Capability>>,\n select: (capability: Capability) => Value,\n fallback: Value,\n isEqual: (left: Value, right: Value) => boolean = Object.is,\n): Readonly<Ref<Value>> {\n const scope = useDocumentScope();\n return useKernelValue((kernel) => {\n const capability = kernel.tryCapability(toValue(token), scope.value ?? undefined);\n if (capability === null) return fallback;\n try {\n return select(capability);\n } catch {\n return fallback;\n }\n }, isEqual);\n}\n\n/**\n * Subscribe to a capability's {@link EventHook} while the component lives:\n * `useCapabilityEvent(ActionsToken, (actions) => actions.onExecuted, handler)`.\n * Events carry occurrences, never state (a late subscriber that needs the\n * current value uses a selector). It subscribes to the document in scope, again\n * when that document changes, and ends with the component. Null-safe: with no\n * plugin or no document there is no subscription.\n */\nexport function useCapabilityEvent<Capability, Event>(\n token: MaybeRefOrGetter<CapabilityToken<Capability>>,\n select: (capability: Capability) => EventHook<Event>,\n handler: (event: Event) => void,\n): void {\n const capability = useOptionalCapability(token);\n // `sync`: subscribed in the same change that made the capability resolvable,\n // so no event between that change and the next render is missed.\n watch(\n capability,\n (current, _previous, onCleanup) => {\n if (!current) return;\n onCleanup(select(current)((event) => handler(event)));\n },\n { immediate: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AAM,SAAS,MAAS;AAChF,QAAI,eAAe,KAAM,QAAO;AAChC,QAAI;AACF,aAAO,OAAO,UAAU;AAAA,IAC1B,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF,GAAG,OAAO;AACZ;AAUO,SAAS,mBACd,OACA,QACA,SACM;AACN,QAAM,aAAa,sBAAsB,KAAK;AAG9CE,MAAAA;AAAAA,IACE;AAAA,IACA,CAAC,SAAS,WAAW,cAAc;AACjC,UAAI,CAAC,QAAS;AACd,gBAAU,OAAO,OAAO,EAAE,CAAC,UAAU,QAAQ,KAAK,CAAC,CAAC;AAAA,IACtD;AAAA,IACA,EAAE,WAAW,MAAM,OAAO,OAAA;AAAA,EAAO;AAErC;;;;;;;;;;;;;;;"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const pluginCommands = require("@embedpdf/plugin-commands");
4
+ const vue = require("vue");
5
+ const coreUi = require("@embedpdf/core-ui");
6
+ const host = require("@embedpdf/plugin-commands/contract/host");
7
+ const standard = require("@embedpdf/plugin-commands/standard");
8
+ const web = require("@embedpdf/web");
9
+ const dev = require("./dev-eeIS2B4c.cjs");
10
+ const capabilities = require("./capabilities-DVNJmgy7.cjs");
11
+ const state = require("./state-M22NDJQo.cjs");
12
+ const standardCommands = /* @__PURE__ */ standard.createStandardCommands(web.standardCommandsBrowser);
13
+ function useCommands() {
14
+ return capabilities.useCapability(pluginCommands.CommandsToken);
15
+ }
16
+ function useCommandsEvent(select, handler) {
17
+ capabilities.useCapabilityEvent(pluginCommands.CommandsToken, select, handler);
18
+ }
19
+ const useCommandsSettings = state.settingsComposable(pluginCommands.CommandsToken);
20
+ function formatShortcut(shortcut, options = {}) {
21
+ return coreUi.formatShortcut(shortcut, { isMac: options.isMac ?? web.isMacPlatform() });
22
+ }
23
+ function useCommand(id) {
24
+ const commands = capabilities.useCapability(pluginCommands.CommandsToken);
25
+ const documentId = capabilities.useDocumentId();
26
+ const resolved = capabilities.useKernelValue(
27
+ () => commands.resolveCommand(vue.toValue(id), documentId.value ?? void 0),
28
+ pluginCommands.resolvedCommandsEqual
29
+ );
30
+ return vue.computed(() => {
31
+ const command = resolved.value;
32
+ const requested = vue.toValue(id);
33
+ if (command === null) {
34
+ dev.devWarn(
35
+ `useCommand:${requested}`,
36
+ `useCommand(): ${pluginCommands.unknownCommandWarning(requested, commands.listCommandIds())}`
37
+ );
38
+ }
39
+ const scope = documentId.value ?? void 0;
40
+ return pluginCommands.boundCommandOf(
41
+ command ?? pluginCommands.unregisteredCommand(requested),
42
+ (commandId) => commands.execute(commandId, { documentId: scope }),
43
+ { isMac: web.isMacPlatform() }
44
+ );
45
+ });
46
+ }
47
+ function useCommandShortcuts(options = {}) {
48
+ const commands = capabilities.useCapability(host.CommandsToken);
49
+ const scoped = options.target !== void 0;
50
+ vue.watch(
51
+ () => [vue.toValue(options.isMac), vue.toValue(options.target)],
52
+ ([isMac, target], _previous, onCleanup) => {
53
+ if (scoped && !target) return;
54
+ onCleanup(
55
+ web.bindCommandShortcuts(commands, {
56
+ isMac,
57
+ target: target ?? void 0,
58
+ onRefused: (commandId, refusal) => {
59
+ var _a;
60
+ return (_a = options.onRefused) == null ? void 0 : _a.call(options, commandId, refusal);
61
+ }
62
+ })
63
+ );
64
+ },
65
+ { immediate: true, flush: "post" }
66
+ );
67
+ }
68
+ exports.formatShortcut = formatShortcut;
69
+ exports.standardCommands = standardCommands;
70
+ exports.useCommand = useCommand;
71
+ exports.useCommandShortcuts = useCommandShortcuts;
72
+ exports.useCommands = useCommands;
73
+ exports.useCommandsEvent = useCommandsEvent;
74
+ exports.useCommandsSettings = useCommandsSettings;
75
+ Object.keys(pluginCommands).forEach((k) => {
76
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
77
+ enumerable: true,
78
+ get: () => pluginCommands[k]
79
+ });
80
+ });
81
+ //# sourceMappingURL=commands.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.cjs","sources":["../src/commands.ts"],"sourcesContent":["/**\n * @embedpdf/vue/commands: the Vue surface of `@embedpdf/plugin-commands`. The\n * standard commands, a command as a button needs it, the settings, and keyboard\n * shortcuts. A command's state is derived from live state on read, so\n * `useCommand` re-reads it on the kernel's one change stream and its ref\n * changes only when what the command shows changed.\n */\n\n// One line per feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-commands';\nimport { computed, toValue, watch } from 'vue';\nimport type { MaybeRefOrGetter, Ref } from 'vue';\nimport { formatShortcut as formatKeys } from '@embedpdf/core-ui';\nimport {\n CommandsToken,\n boundCommandOf,\n resolvedCommandsEqual,\n unknownCommandWarning,\n unregisteredCommand,\n} from '@embedpdf/plugin-commands';\nimport type {\n BoundCommand,\n CommandId,\n CommandRefusal,\n CommandsCapability,\n} from '@embedpdf/plugin-commands';\nimport { CommandsToken as CommandsHostToken } from '@embedpdf/plugin-commands/contract/host';\nimport { createStandardCommands } from '@embedpdf/plugin-commands/standard';\nimport type { EventHook } from '@embedpdf/core';\nimport { bindCommandShortcuts, isMacPlatform, standardCommandsBrowser } from '@embedpdf/web';\nimport { devWarn } from './dev';\nimport { useCapability, useCapabilityEvent } from './runtime/capabilities';\nimport { useDocumentId, useKernelValue } from './runtime/kernel';\nimport { settingsComposable } from './state';\n\n/**\n * The commands every viewer has: zoom, pages, view rotation, `tool:<id>` for every tool, copy,\n * delete, download and print, with shortcuts and labels in EmbedPDF's eight languages. Spread\n * them into `commandsPlugin({ commands })`.\n */\nexport const standardCommands = /* @__PURE__ */ createStandardCommands(standardCommandsBrowser);\n\n/** The commands API: `execute`, `searchCommands`, `registerCommand`, the categories, the settings calls. The object never changes. */\nexport function useCommands(): CommandsCapability {\n return useCapability(CommandsToken);\n}\n\n/** Subscribe to one commands event while the component lives: `useCommandsEvent((commands) => commands.onExecuted, handler)`. */\nexport function useCommandsEvent<Event>(\n select: (commands: CommandsCapability) => EventHook<Event>,\n handler: (event: Event) => void,\n): void {\n useCapabilityEvent(CommandsToken, select, handler);\n}\n\n/**\n * The commands settings (`commands`, `disabledCategories`, `disabledCommands`, `notAllowed`) as refs,\n * with or without a document. Takes a selector.\n */\nexport const useCommandsSettings = settingsComposable(CommandsToken);\n\n/** A shortcut as a tooltip shows it, for this platform: `'⌘K'` on a Mac, `'Ctrl+K'` elsewhere. */\nexport function formatShortcut(shortcut: string, options: { isMac?: boolean } = {}): string {\n return formatKeys(shortcut, { isMac: options.isMac ?? isMacPlatform() });\n}\n\n/**\n * A command for this component's document (the nearest `<DocumentScope>`, else\n * the active one), as a ref: its label, icon, state, `run` and `shortcut`. Pass\n * a getter to follow a prop: `useCommand(() => props.id)`. The ref changes only\n * when what the command shows does. Always a command: an id no plugin\n * registered is labelled with its id, neither visible nor enabled, and warns\n * once in development.\n */\nexport function useCommand(id: MaybeRefOrGetter<string>): Readonly<Ref<BoundCommand>> {\n const commands = useCapability(CommandsToken);\n const documentId = useDocumentId();\n const resolved = useKernelValue(\n () => commands.resolveCommand(toValue(id), documentId.value ?? undefined),\n resolvedCommandsEqual,\n );\n return computed(() => {\n const command = resolved.value;\n const requested = toValue(id);\n if (command === null) {\n devWarn(\n `useCommand:${requested}`,\n `useCommand(): ${unknownCommandWarning(requested, commands.listCommandIds())}`,\n );\n }\n const scope = documentId.value ?? undefined;\n return boundCommandOf(\n command ?? unregisteredCommand(requested),\n (commandId) => commands.execute(commandId, { documentId: scope }),\n { isMac: isMacPlatform() },\n );\n });\n}\n\n/** Where {@link useCommandShortcuts} listens, and how it reads `Mod`. */\nexport interface CommandShortcutsOptions {\n /** Whether `Mod` is Cmd (a Mac) or Ctrl. Default: what the browser says. */\n isMac?: MaybeRefOrGetter<boolean | undefined>;\n /**\n * Listen only while focus is inside this element (a template ref), for a\n * page with more than one viewer. The keys work once it has mounted.\n */\n target?: MaybeRefOrGetter<HTMLElement | null | undefined>;\n /** Called when a key's command is turned off or not allowed, with why: say so to the user. */\n onRefused?: (commandId: CommandId, refusal: CommandRefusal) => void;\n}\n\n/**\n * Turn every command's shortcut into a working key, for the active document.\n * Call it once, near the top of your viewer. Keys typed into text fields are\n * left alone, and so is a key whose command can't run right now. A command\n * that's turned off or not allowed still takes its key, and `onRefused` says\n * why. The keys work anywhere on the page; with `target`, only while focus is\n * inside that element.\n * They stop when the component unmounts.\n */\nexport function useCommandShortcuts(options: CommandShortcutsOptions = {}): void {\n const commands = useCapability(CommandsHostToken);\n const scoped = options.target !== undefined;\n watch(\n () => [toValue(options.isMac), toValue(options.target)] as const,\n ([isMac, target], _previous, onCleanup) => {\n // A target that hasn't mounted yet binds nothing; its ref being set runs this again.\n if (scoped && !target) return;\n onCleanup(\n bindCommandShortcuts(commands, {\n isMac,\n target: target ?? undefined,\n onRefused: (commandId, refusal) => options.onRefused?.(commandId, refusal),\n }),\n );\n },\n { immediate: true, flush: 'post' },\n );\n}\n"],"names":["standardCommandsBrowser","useCapability","CommandsToken","useCapabilityEvent","settingsComposable","formatKeys","isMacPlatform","useDocumentId","useKernelValue","toValue","resolvedCommandsEqual","computed","devWarn","unknownCommandWarning","boundCommandOf","unregisteredCommand","CommandsHostToken","watch","bindCommandShortcuts"],"mappings":";;;;;;;;;;;AAwCO,MAAM,mEAA0DA,IAAAA,uBAAuB;AAGvF,SAAS,cAAkC;AAChD,SAAOC,aAAAA,cAAcC,eAAAA,aAAa;AACpC;AAGO,SAAS,iBACd,QACA,SACM;AACNC,kCAAmBD,eAAAA,eAAe,QAAQ,OAAO;AACnD;AAMO,MAAM,sBAAsBE,MAAAA,mBAAmBF,eAAAA,aAAa;AAG5D,SAAS,eAAe,UAAkB,UAA+B,IAAY;AAC1F,SAAOG,OAAAA,eAAW,UAAU,EAAE,OAAO,QAAQ,SAASC,IAAAA,cAAA,GAAiB;AACzE;AAUO,SAAS,WAAW,IAA2D;AACpF,QAAM,WAAWL,aAAAA,cAAcC,4BAAa;AAC5C,QAAM,aAAaK,aAAAA,cAAA;AACnB,QAAM,WAAWC,aAAAA;AAAAA,IAC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