@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/shell.d.ts CHANGED
@@ -1,27 +1,42 @@
1
- import { OpenSurfaceOptions, ShellCapability } from "@embedpdf/plugin-shell";
1
+ import { n as StateHook } from "./state-0K1I5cM4.js";
2
+ import { EventHook } from "@embedpdf/core";
3
+ import { SurfaceFocusOptions } from "@embedpdf/web";
4
+ import { RefObject } from "react";
5
+ import { OpenSurfaceOptions, ShellCapability, SurfaceProps } from "@embedpdf/plugin-shell";
2
6
  export * from "@embedpdf/plugin-shell";
3
7
  //#region src/shell.d.ts
4
- /** The raw capability — throws without a document; for gated subtrees. */
8
+ /** The shell capability: open and close panels, dialogs and menus. Without a document its methods throw `not-ready`. */
5
9
  declare function useShell(): ShellCapability;
10
+ /** Subscribe to one shell event for the mounted lifetime: `useShellEvent((shell) => shell.onSurfaceOpened, handler)`. */
11
+ declare function useShellEvent<T>(select: (shell: ShellCapability) => EventHook<T>, handler: (event: T) => void): void;
12
+ /**
13
+ * Which panels, dialogs and menus are open (the page's State table, declared
14
+ * once in `shellState`). Takes a selector, and re-renders only when what it
15
+ * returns changes. Without a document nothing is open.
16
+ */
17
+ declare const useShellState: StateHook<{
18
+ openSurfaces: readonly import("@embedpdf/plugin-shell").SurfaceState[];
19
+ openMenus: readonly string[];
20
+ }>;
6
21
  interface SurfaceHandle {
7
22
  readonly isOpen: boolean;
8
- readonly props: Readonly<Record<string, unknown>> | undefined;
9
- open(opts?: OpenSurfaceOptions): void;
23
+ /** The props the surface was opened with, or updated to; empty when it has none. */
24
+ readonly props: SurfaceProps;
25
+ open(options?: OpenSurfaceOptions): void;
10
26
  close(): void;
11
- toggle(opts?: OpenSurfaceOptions): void;
27
+ toggle(options?: OpenSurfaceOptions): void;
12
28
  }
13
- /** One named surface (panel / modal / overlay), bound to this subtree's
14
- * document. Reads as closed — and intents no-op — while no document is open. */
29
+ /** One named surface (panel, dialog, overlay) of this subtree's document. Reads as closed, and its verbs do nothing, while no document is open. */
15
30
  declare function useSurface(id: string): SurfaceHandle;
16
- interface MenusHandle {
17
- readonly open: readonly string[];
18
- isOpen(id: string): boolean;
19
- toggle(id: string): void;
20
- close(id: string): void;
21
- closeAll(): void;
22
- }
23
- /** The dropdown-menu stack for this subtree's document (empty without one). */
24
- declare function useMenus(): MenusHandle;
31
+ /**
32
+ * Put the cursor in `ref`'s element when the surface `id` asks for it: on every
33
+ * `open(id, { focus: true })`, a command whose panel says `focus` among them, and
34
+ * when the element mounts while the request is up (the panel opened, or its code
35
+ * loaded, because of it). A plain open never moves it. `select` selects an input's
36
+ * text, so typing replaces it. Reads the surface of this subtree's document; use
37
+ * it in the component that renders the element.
38
+ */
39
+ declare function useSurfaceFocus(id: string, ref: RefObject<HTMLElement | null>, options?: SurfaceFocusOptions): void;
25
40
  //#endregion
26
- export { MenusHandle, SurfaceHandle, useMenus, useShell, useSurface };
41
+ export { type SurfaceFocusOptions, SurfaceHandle, useShell, useShellEvent, useShellState, useSurface, useSurfaceFocus };
27
42
  //# sourceMappingURL=shell.d.ts.map
package/dist/shell.js CHANGED
@@ -1,25 +1,36 @@
1
- import "./rolldown-runtime-BBjsoOtd.js";
2
- import { useCapability, useOptionalCapability, useOptionalSelector } from "./runtime.js";
3
- import { useMemo } from "react";
4
- import { ShellToken } from "@embedpdf/plugin-shell";
1
+ import { C as useOptionalSelector, S as useOptionalCapability, f as useCapability, p as useCapabilityEvent } from "./runtime-B6xcPsEb.js";
2
+ import { n as stateHook } from "./state-CbgxhwLA.js";
3
+ import { createSurfaceFocusFollower } from "@embedpdf/web";
4
+ import { useEffect, useMemo, useState } from "react";
5
+ import { ShellToken, shellState } from "@embedpdf/plugin-shell";
5
6
  export * from "@embedpdf/plugin-shell";
6
7
  //#region src/shell.ts
7
- /** The raw capability — throws without a document; for gated subtrees. */
8
+ /** The shell capability: open and close panels, dialogs and menus. Without a document its methods throw `not-ready`. */
8
9
  function useShell() {
9
10
  return useCapability(ShellToken);
10
11
  }
11
- /** One named surface (panel / modal / overlay), bound to this subtree's
12
- * document. Reads as closed — and intents no-op — while no document is open. */
12
+ /** Subscribe to one shell event for the mounted lifetime: `useShellEvent((shell) => shell.onSurfaceOpened, handler)`. */
13
+ function useShellEvent(select, handler) {
14
+ useCapabilityEvent(ShellToken, select, handler);
15
+ }
16
+ /**
17
+ * Which panels, dialogs and menus are open (the page's State table, declared
18
+ * once in `shellState`). Takes a selector, and re-renders only when what it
19
+ * returns changes. Without a document nothing is open.
20
+ */
21
+ const useShellState = stateHook(shellState);
22
+ const NO_PROPS = Object.freeze({});
23
+ /** One named surface (panel, dialog, overlay) of this subtree's document. Reads as closed, and its verbs do nothing, while no document is open. */
13
24
  function useSurface(id) {
14
25
  const shell = useOptionalCapability(ShellToken);
15
- const isOpen = useOptionalSelector(ShellToken, (s) => s.isOpen(id), false);
16
- const props = useOptionalSelector(ShellToken, (s) => s.surfaceProps(id), void 0);
26
+ const isOpen = useOptionalSelector(ShellToken, (shell) => shell.isOpen(id), false);
27
+ const props = useOptionalSelector(ShellToken, (shell) => shell.getSurface(id)?.props ?? NO_PROPS, NO_PROPS);
17
28
  return useMemo(() => ({
18
29
  isOpen,
19
30
  props,
20
- open: (opts) => shell?.open(id, opts),
31
+ open: (options) => shell?.open(id, options),
21
32
  close: () => shell?.close(id),
22
- toggle: (opts) => shell?.toggle(id, opts)
33
+ toggle: (options) => shell?.toggle(id, options)
23
34
  }), [
24
35
  shell,
25
36
  id,
@@ -27,21 +38,22 @@ function useSurface(id) {
27
38
  props
28
39
  ]);
29
40
  }
30
- const NO_MENUS = [];
31
- const stringArrayEqual = (a, b) => a === b || a.length === b.length && a.every((x, i) => x === b[i]);
32
- /** The dropdown-menu stack for this subtree's document (empty without one). */
33
- function useMenus() {
41
+ /**
42
+ * Put the cursor in `ref`'s element when the surface `id` asks for it: on every
43
+ * `open(id, { focus: true })`, a command whose panel says `focus` among them, and
44
+ * when the element mounts while the request is up (the panel opened, or its code
45
+ * loaded, because of it). A plain open never moves it. `select` selects an input's
46
+ * text, so typing replaces it. Reads the surface of this subtree's document; use
47
+ * it in the component that renders the element.
48
+ */
49
+ function useSurfaceFocus(id, ref, options = {}) {
34
50
  const shell = useOptionalCapability(ShellToken);
35
- const open = useOptionalSelector(ShellToken, (s) => s.openMenus(), NO_MENUS, stringArrayEqual);
36
- return useMemo(() => ({
37
- open,
38
- isOpen: (id) => open.includes(id),
39
- toggle: (id) => shell?.toggleMenu(id),
40
- close: (id) => shell?.closeMenu(id),
41
- closeAll: () => shell?.closeAllMenus()
42
- }), [shell, open]);
51
+ const request = useOptionalSelector(ShellToken, (current) => current.getSurface(id)?.focusRequest ?? 0, 0);
52
+ const [follower] = useState(createSurfaceFocusFollower);
53
+ const select = options.select ?? false;
54
+ useEffect(() => follower.follow(ref.current, shell, request, { select }));
43
55
  }
44
56
  //#endregion
45
- export { useMenus, useShell, useSurface };
57
+ export { useShell, useShellEvent, useShellState, useSurface, useSurfaceFocus };
46
58
 
47
59
  //# sourceMappingURL=shell.js.map
package/dist/shell.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"shell.js","names":[],"sources":["../src/shell.ts"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-shell. The app owns every\n * surface's DOM; these hooks bind its open/closed state to the kernel so\n * commands can drive it and applications can restore it.\n *\n * These hooks are TOTAL: shell state is document-scoped, and chrome that uses\n * it (panel buttons, mode bands, menu anchors) stays mounted across the\n * empty-workspace state. With no document, surfaces read as closed, menus as\n * none, and intents no-op — mirroring how command execution `tryGet`s the\n * shell. Use the raw capability (`useShell`) when you need fail-fast access\n * inside a <DocumentGate>.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-shell';\nimport { useMemo } from 'react';\nimport { ShellToken } from '@embedpdf/plugin-shell';\nimport type { OpenSurfaceOptions, ShellCapability } from '@embedpdf/plugin-shell';\nimport { useCapability, useOptionalCapability, useOptionalSelector } from './runtime';\n\n/** The raw capability — throws without a document; for gated subtrees. */\nexport function useShell(): ShellCapability {\n return useCapability(ShellToken);\n}\n\nexport interface SurfaceHandle {\n readonly isOpen: boolean;\n readonly props: Readonly<Record<string, unknown>> | undefined;\n open(opts?: OpenSurfaceOptions): void;\n close(): void;\n toggle(opts?: OpenSurfaceOptions): void;\n}\n\n/** One named surface (panel / modal / overlay), bound to this subtree's\n * document. Reads as closed — and intents no-op — while no document is open. */\nexport function useSurface(id: string): SurfaceHandle {\n const shell = useOptionalCapability(ShellToken);\n const isOpen = useOptionalSelector(ShellToken, (s) => s.isOpen(id), false);\n const props = useOptionalSelector(ShellToken, (s) => s.surfaceProps(id), undefined);\n return useMemo(\n () => ({\n isOpen,\n props,\n open: (opts?: OpenSurfaceOptions) => shell?.open(id, opts),\n close: () => shell?.close(id),\n toggle: (opts?: OpenSurfaceOptions) => shell?.toggle(id, opts),\n }),\n [shell, id, isOpen, props],\n );\n}\n\nexport interface MenusHandle {\n readonly open: readonly string[];\n isOpen(id: string): boolean;\n toggle(id: string): void;\n close(id: string): void;\n closeAll(): void;\n}\n\nconst NO_MENUS: readonly string[] = [];\nconst stringArrayEqual = (a: readonly string[], b: readonly string[]) =>\n a === b || (a.length === b.length && a.every((x, i) => x === b[i]));\n\n/** The dropdown-menu stack for this subtree's document (empty without one). */\nexport function useMenus(): MenusHandle {\n const shell = useOptionalCapability(ShellToken);\n const open = useOptionalSelector(ShellToken, (s) => s.openMenus(), NO_MENUS, stringArrayEqual);\n return useMemo(\n () => ({\n open,\n isOpen: (id: string) => open.includes(id),\n toggle: (id: string) => shell?.toggleMenu(id),\n close: (id: string) => shell?.closeMenu(id),\n closeAll: () => shell?.closeAllMenus(),\n }),\n [shell, open],\n );\n}\n"],"mappings":";;;;;;;AAqBA,SAAgB,WAA4B;CAC1C,OAAO,cAAc,UAAU;AACjC;;;AAYA,SAAgB,WAAW,IAA2B;CACpD,MAAM,QAAQ,sBAAsB,UAAU;CAC9C,MAAM,SAAS,oBAAoB,aAAa,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK;CACzE,MAAM,QAAQ,oBAAoB,aAAa,MAAM,EAAE,aAAa,EAAE,GAAG,KAAA,CAAS;CAClF,OAAO,eACE;EACL;EACA;EACA,OAAO,SAA8B,OAAO,KAAK,IAAI,IAAI;EACzD,aAAa,OAAO,MAAM,EAAE;EAC5B,SAAS,SAA8B,OAAO,OAAO,IAAI,IAAI;CAC/D,IACA;EAAC;EAAO;EAAI;EAAQ;CAAK,CAC3B;AACF;AAUA,MAAM,WAA8B,CAAC;AACrC,MAAM,oBAAoB,GAAsB,MAC9C,MAAM,KAAM,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,GAAG,MAAM,MAAM,EAAE,EAAE;;AAGnE,SAAgB,WAAwB;CACtC,MAAM,QAAQ,sBAAsB,UAAU;CAC9C,MAAM,OAAO,oBAAoB,aAAa,MAAM,EAAE,UAAU,GAAG,UAAU,gBAAgB;CAC7F,OAAO,eACE;EACL;EACA,SAAS,OAAe,KAAK,SAAS,EAAE;EACxC,SAAS,OAAe,OAAO,WAAW,EAAE;EAC5C,QAAQ,OAAe,OAAO,UAAU,EAAE;EAC1C,gBAAgB,OAAO,cAAc;CACvC,IACA,CAAC,OAAO,IAAI,CACd;AACF"}
1
+ {"version":3,"file":"shell.js","names":[],"sources":["../src/shell.ts"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-shell. The app owns every\n * surface's DOM; these hooks bind its open/closed state to the kernel so\n * commands can drive it and applications can restore it.\n *\n * The state hooks work without a document: shell state is document-scoped,\n * and chrome that uses it (panel buttons, menu anchors) stays mounted across\n * the empty workspace. With no document every surface reads as closed, no menu\n * as open, and `useSurface`'s verbs do nothing. `useShell()` then returns the\n * stand-in, whose methods throw `not-ready`.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-shell';\nimport { useEffect, useMemo, useState, type RefObject } from 'react';\nimport { ShellToken, shellState } from '@embedpdf/plugin-shell';\nimport type { OpenSurfaceOptions, ShellCapability, SurfaceProps } from '@embedpdf/plugin-shell';\nimport type { EventHook } from '@embedpdf/core';\nimport { createSurfaceFocusFollower, type SurfaceFocusOptions } from '@embedpdf/web';\nimport {\n useCapability,\n useCapabilityEvent,\n useOptionalCapability,\n useOptionalSelector,\n} from './runtime';\nimport { stateHook } from './state';\n\n/** The shell capability: open and close panels, dialogs and menus. Without a document its methods throw `not-ready`. */\nexport function useShell(): ShellCapability {\n return useCapability(ShellToken);\n}\n\n/** Subscribe to one shell event for the mounted lifetime: `useShellEvent((shell) => shell.onSurfaceOpened, handler)`. */\nexport function useShellEvent<T>(\n select: (shell: ShellCapability) => EventHook<T>,\n handler: (event: T) => void,\n): void {\n useCapabilityEvent(ShellToken, select, handler);\n}\n\n/**\n * Which panels, dialogs and menus are open (the page's State table, declared\n * once in `shellState`). Takes a selector, and re-renders only when what it\n * returns changes. Without a document nothing is open.\n */\nexport const useShellState = stateHook(shellState);\n\nexport interface SurfaceHandle {\n readonly isOpen: boolean;\n /** The props the surface was opened with, or updated to; empty when it has none. */\n readonly props: SurfaceProps;\n open(options?: OpenSurfaceOptions): void;\n close(): void;\n toggle(options?: OpenSurfaceOptions): void;\n}\n\nconst NO_PROPS: SurfaceProps = Object.freeze({});\n\n/** One named surface (panel, dialog, overlay) of this subtree's document. Reads as closed, and its verbs do nothing, while no document is open. */\nexport function useSurface(id: string): SurfaceHandle {\n const shell = useOptionalCapability(ShellToken);\n const isOpen = useOptionalSelector(ShellToken, (shell) => shell.isOpen(id), false);\n const props = useOptionalSelector(\n ShellToken,\n (shell) => shell.getSurface(id)?.props ?? NO_PROPS,\n NO_PROPS,\n );\n return useMemo(\n () => ({\n isOpen,\n props,\n open: (options?: OpenSurfaceOptions) => shell?.open(id, options),\n close: () => shell?.close(id),\n toggle: (options?: OpenSurfaceOptions) => shell?.toggle(id, options),\n }),\n [shell, id, isOpen, props],\n );\n}\n\nexport type { SurfaceFocusOptions };\n\n/**\n * Put the cursor in `ref`'s element when the surface `id` asks for it: on every\n * `open(id, { focus: true })`, a command whose panel says `focus` among them, and\n * when the element mounts while the request is up (the panel opened, or its code\n * loaded, because of it). A plain open never moves it. `select` selects an input's\n * text, so typing replaces it. Reads the surface of this subtree's document; use\n * it in the component that renders the element.\n */\nexport function useSurfaceFocus(\n id: string,\n ref: RefObject<HTMLElement | null>,\n options: SurfaceFocusOptions = {},\n): void {\n const shell = useOptionalCapability(ShellToken);\n const request = useOptionalSelector(\n ShellToken,\n (current) => current.getSurface(id)?.focusRequest ?? 0,\n 0,\n );\n const [follower] = useState(createSurfaceFocusFollower);\n const select = options.select ?? false;\n // After every render, so an element that has just appeared is seen, and after the layout\n // effects, so a panel's frame has placed and shown it (a sheet's layer is hidden until then).\n useEffect(() => follower.follow(ref.current, shell, request, { select }));\n}\n"],"mappings":";;;;;;;;AA4BA,SAAgB,WAA4B;CAC1C,OAAO,cAAc,UAAU;AACjC;;AAGA,SAAgB,cACd,QACA,SACM;CACN,mBAAmB,YAAY,QAAQ,OAAO;AAChD;;;;;;AAOA,MAAa,gBAAgB,UAAU,UAAU;AAWjD,MAAM,WAAyB,OAAO,OAAO,CAAC,CAAC;;AAG/C,SAAgB,WAAW,IAA2B;CACpD,MAAM,QAAQ,sBAAsB,UAAU;CAC9C,MAAM,SAAS,oBAAoB,aAAa,UAAU,MAAM,OAAO,EAAE,GAAG,KAAK;CACjF,MAAM,QAAQ,oBACZ,aACC,UAAU,MAAM,WAAW,EAAE,CAAC,EAAE,SAAS,UAC1C,QACF;CACA,OAAO,eACE;EACL;EACA;EACA,OAAO,YAAiC,OAAO,KAAK,IAAI,OAAO;EAC/D,aAAa,OAAO,MAAM,EAAE;EAC5B,SAAS,YAAiC,OAAO,OAAO,IAAI,OAAO;CACrE,IACA;EAAC;EAAO;EAAI;EAAQ;CAAK,CAC3B;AACF;;;;;;;;;AAYA,SAAgB,gBACd,IACA,KACA,UAA+B,CAAC,GAC1B;CACN,MAAM,QAAQ,sBAAsB,UAAU;CAC9C,MAAM,UAAU,oBACd,aACC,YAAY,QAAQ,WAAW,EAAE,CAAC,EAAE,gBAAgB,GACrD,CACF;CACA,MAAM,CAAC,YAAY,SAAS,0BAA0B;CACtD,MAAM,SAAS,QAAQ,UAAU;CAGjC,gBAAgB,SAAS,OAAO,IAAI,SAAS,OAAO,SAAS,EAAE,OAAO,CAAC,CAAC;AAC1E"}
@@ -1,73 +1,54 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("./rolldown-runtime-DDXJien1.cjs");
3
- const require_runtime = require("./runtime.cjs");
3
+ const require_runtime = require("./runtime-fzpGv78v.cjs");
4
+ const require_state = require("./state-CsfZy_Eq.cjs");
4
5
  const require_stamp = require("./stamp.cjs");
5
6
  let react = require("react");
6
7
  let _embedpdf_plugin_signature = require("@embedpdf/plugin-signature");
7
- let _embedpdf_plugin_stamp_contract = require("@embedpdf/plugin-stamp/contract");
8
8
  //#region src/signature.tsx
9
9
  /**
10
- * The React view of @embedpdf/plugin-signature: the act of signing for the
11
- * surrounding `DocumentScope`, its live facts (snapshot, verdicts,
12
- * protection, target), and the one derivation a signatures panel needs —
13
- * the people (libraries of kind `signatures`) with their marks.
10
+ * The React view of @embedpdf/plugin-signature: signing for the surrounding
11
+ * document, its state (the signatures with their verdicts, what they allow,
12
+ * the target, a two-step signing in progress), and the one derivation a
13
+ * signatures panel needs: the people (libraries of kind `signatures`) with
14
+ * their marks.
14
15
  *
15
16
  * const signature = useSignature();
16
- * await signature.placeMark({ assetId }, { field: target }); // sign / fill / ask, by mode
17
+ * await signature.placeMark({ assetId }, { field: target }); // sign, fill or ask, by mode
17
18
  */
18
- /** The signature capability for the surrounding document. */
19
+ /** The signature API for the surrounding document. */
19
20
  function useSignature() {
20
21
  return require_runtime.useCapability(_embedpdf_plugin_signature.SignatureToken);
21
22
  }
22
- /** The last signature snapshot (null until the first read lands). */
23
- function useSignatureSnapshot() {
24
- return require_runtime.useSelector(_embedpdf_plugin_signature.SignatureToken, (c) => c.snapshot());
25
- }
26
- /** The last validation (null until one ran). */
27
- function useSignatureVerdicts() {
28
- return require_runtime.useSelector(_embedpdf_plugin_signature.SignatureToken, (c) => c.verdicts());
29
- }
30
- /** What the document's signatures forbid (null when nothing is signed or not yet read). */
31
- function useDocumentProtection() {
32
- return require_runtime.useSelector(_embedpdf_plugin_signature.SignatureToken, (c) => c.protection());
33
- }
34
- /** The field the next picked mark goes to, and whether a sign/fill is in flight. */
35
- function useSignatureTarget() {
36
- return {
37
- target: require_runtime.useSelector(_embedpdf_plugin_signature.SignatureToken, (c) => c.target()),
38
- busy: require_runtime.useSelector(_embedpdf_plugin_signature.SignatureToken, (c) => c.busy())
39
- };
40
- }
41
- /** Subscribe to the plugin's change events (signed / filled / ask / inspect / target / validated …). */
42
- function useSignatureEvent(handler) {
43
- require_runtime.useCapabilityEvent(_embedpdf_plugin_signature.SignatureToken, (c) => c.onChanged, handler);
23
+ /**
24
+ * The signatures' state: the signed fields with their verdicts, what they
25
+ * allow, the target, whether a signing runs, a two-step signing in progress,
26
+ * and whether they're read (the page's State table, declared once in
27
+ * `signatureState`). Takes a selector, and re-renders only when what it
28
+ * returns changes.
29
+ */
30
+ const useSignatureState = require_state.stateHook(_embedpdf_plugin_signature.signatureState);
31
+ /** The signature settings (`key`, `mode`, `trust`, `allowCertify`), with or without a document. Takes a selector. */
32
+ const useSignatureSettings = require_state.settingsHook(_embedpdf_plugin_signature.SignatureToken);
33
+ /** Subscribe to one of the plugin's events while mounted: `useSignatureEvent((signature) => signature.onSigned, handler)`. */
34
+ function useSignatureEvent(select, handler) {
35
+ require_runtime.useCapabilityEvent(_embedpdf_plugin_signature.SignatureToken, select, handler);
44
36
  }
45
37
  /**
46
- * The people whose marks this browser holds — one row per library of kind
47
- * `signatures`. Purely derived from the stamp plugin: rename, delete, and
48
- * export are the library verbs; nothing is stored beyond the file.
38
+ * The people whose marks this browser holds, one row per library of kind
39
+ * `signatures`, for a picker. Derived from the stamp plugin: rename, delete
40
+ * and export are the library verbs; nothing is stored beyond the file.
49
41
  */
50
42
  function useSignerRows() {
51
43
  const libraries = require_stamp.useStampLibraries({ kind: _embedpdf_plugin_signature.SIGNATURES_LIBRARY_KIND });
52
- const assets = require_runtime.useSelector(_embedpdf_plugin_stamp_contract.StampToken, (c) => c.assets(), require_runtime.shallowArray);
53
- return (0, react.useMemo)(() => libraries.map((library) => {
54
- const own = assets.filter((asset) => asset.libraryId === library.id);
55
- return {
56
- libraryId: library.id,
57
- name: library.name,
58
- library,
59
- signatures: own.filter((asset) => (0, _embedpdf_plugin_signature.markRoleOf)(asset) === "signature"),
60
- initials: own.find((asset) => (0, _embedpdf_plugin_signature.markRoleOf)(asset) === "initials") ?? null
61
- };
62
- }), [libraries, assets]);
44
+ const assets = require_stamp.useStampAssets();
45
+ return (0, react.useMemo)(() => (0, _embedpdf_plugin_signature.signerRowsOf)(libraries, assets), [libraries, assets]);
63
46
  }
64
47
  //#endregion
65
- exports.useDocumentProtection = useDocumentProtection;
66
48
  exports.useSignature = useSignature;
67
49
  exports.useSignatureEvent = useSignatureEvent;
68
- exports.useSignatureSnapshot = useSignatureSnapshot;
69
- exports.useSignatureTarget = useSignatureTarget;
70
- exports.useSignatureVerdicts = useSignatureVerdicts;
50
+ exports.useSignatureSettings = useSignatureSettings;
51
+ exports.useSignatureState = useSignatureState;
71
52
  exports.useSignerRows = useSignerRows;
72
53
  Object.keys(_embedpdf_plugin_signature).forEach(function(k) {
73
54
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
@@ -1 +1 @@
1
- {"version":3,"file":"signature.cjs","names":["useCapability","SignatureToken","useSelector","useStampLibraries","SIGNATURES_LIBRARY_KIND","StampToken","shallowArray"],"sources":["../src/signature.tsx"],"sourcesContent":["/**\n * The React view of @embedpdf/plugin-signature: the act of signing for the\n * surrounding `DocumentScope`, its live facts (snapshot, verdicts,\n * protection, target), and the one derivation a signatures panel needs —\n * the people (libraries of kind `signatures`) with their marks.\n *\n * const signature = useSignature();\n * await signature.placeMark({ assetId }, { field: target }); // sign / fill / ask, by mode\n */\nimport { useMemo } from 'react';\nimport {\n markRoleOf,\n SIGNATURES_LIBRARY_KIND,\n SignatureToken,\n type DocumentProtection,\n type FormFieldRef,\n type SignatureCapability,\n type SignatureChange,\n type SignatureSnapshot,\n type SignatureVerdict,\n} from '@embedpdf/plugin-signature';\nimport { StampToken, type StampAsset, type StampLibrary } from '@embedpdf/plugin-stamp/contract';\n\nimport { shallowArray, useCapability, useCapabilityEvent, useSelector } from './runtime';\nimport { useStampLibraries } from './stamp';\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-signature';\n\n/** The signature capability for the surrounding document. */\nexport function useSignature(): SignatureCapability {\n return useCapability(SignatureToken);\n}\n\n/** The last signature snapshot (null until the first read lands). */\nexport function useSignatureSnapshot(): SignatureSnapshot | null {\n return useSelector(SignatureToken, (c) => c.snapshot());\n}\n\n/** The last validation (null until one ran). */\nexport function useSignatureVerdicts(): SignatureVerdict[] | null {\n return useSelector(SignatureToken, (c) => c.verdicts());\n}\n\n/** What the document's signatures forbid (null when nothing is signed or not yet read). */\nexport function useDocumentProtection(): DocumentProtection | null {\n return useSelector(SignatureToken, (c) => c.protection());\n}\n\n/** The field the next picked mark goes to, and whether a sign/fill is in flight. */\nexport function useSignatureTarget(): { target: FormFieldRef | null; busy: boolean } {\n const target = useSelector(SignatureToken, (c) => c.target());\n const busy = useSelector(SignatureToken, (c) => c.busy());\n return { target, busy };\n}\n\n/** Subscribe to the plugin's change events (signed / filled / ask / inspect / target / validated …). */\nexport function useSignatureEvent(handler: (event: SignatureChange) => void): void {\n useCapabilityEvent(SignatureToken, (c) => c.onChanged, handler);\n}\n\n/** One person: a library of kind `signatures` with its marks split by role. */\nexport interface SignerRow {\n libraryId: string;\n name: string;\n library: StampLibrary;\n signatures: StampAsset[];\n initials: StampAsset | null;\n}\n\n/**\n * The people whose marks this browser holds — one row per library of kind\n * `signatures`. Purely derived from the stamp plugin: rename, delete, and\n * export are the library verbs; nothing is stored beyond the file.\n */\nexport function useSignerRows(): SignerRow[] {\n const libraries = useStampLibraries({ kind: SIGNATURES_LIBRARY_KIND });\n const assets = useSelector(StampToken, (c) => c.assets(), shallowArray);\n return useMemo(\n () =>\n libraries.map((library) => {\n const own = assets.filter((asset) => asset.libraryId === library.id);\n return {\n libraryId: library.id,\n name: library.name,\n library,\n signatures: own.filter((asset) => markRoleOf(asset) === 'signature'),\n initials: own.find((asset) => markRoleOf(asset) === 'initials') ?? null,\n };\n }),\n [libraries, assets],\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA8BA,SAAgB,eAAoC;CAClD,OAAOA,gBAAAA,cAAcC,2BAAAA,cAAc;AACrC;;AAGA,SAAgB,uBAAiD;CAC/D,OAAOC,gBAAAA,YAAYD,2BAAAA,iBAAiB,MAAM,EAAE,SAAS,CAAC;AACxD;;AAGA,SAAgB,uBAAkD;CAChE,OAAOC,gBAAAA,YAAYD,2BAAAA,iBAAiB,MAAM,EAAE,SAAS,CAAC;AACxD;;AAGA,SAAgB,wBAAmD;CACjE,OAAOC,gBAAAA,YAAYD,2BAAAA,iBAAiB,MAAM,EAAE,WAAW,CAAC;AAC1D;;AAGA,SAAgB,qBAAqE;CAGnF,OAAO;EAAE,QAFMC,gBAAAA,YAAYD,2BAAAA,iBAAiB,MAAM,EAAE,OAAO,CAE7C;EAAG,MADJC,gBAAAA,YAAYD,2BAAAA,iBAAiB,MAAM,EAAE,KAAK,CACnC;CAAE;AACxB;;AAGA,SAAgB,kBAAkB,SAAiD;CACjF,gBAAA,mBAAmBA,2BAAAA,iBAAiB,MAAM,EAAE,WAAW,OAAO;AAChE;;;;;;AAgBA,SAAgB,gBAA6B;CAC3C,MAAM,YAAYE,cAAAA,kBAAkB,EAAE,MAAMC,2BAAAA,wBAAwB,CAAC;CACrE,MAAM,SAASF,gBAAAA,YAAYG,gCAAAA,aAAa,MAAM,EAAE,OAAO,GAAGC,gBAAAA,YAAY;CACtE,QAAA,GAAA,MAAA,QAAA,OAEI,UAAU,KAAK,YAAY;EACzB,MAAM,MAAM,OAAO,QAAQ,UAAU,MAAM,cAAc,QAAQ,EAAE;EACnE,OAAO;GACL,WAAW,QAAQ;GACnB,MAAM,QAAQ;GACd;GACA,YAAY,IAAI,QAAQ,WAAA,GAAA,2BAAA,WAAA,CAAqB,KAAK,MAAM,WAAW;GACnE,UAAU,IAAI,MAAM,WAAA,GAAA,2BAAA,WAAA,CAAqB,KAAK,MAAM,UAAU,KAAK;EACrE;CACF,CAAC,GACH,CAAC,WAAW,MAAM,CACpB;AACF"}
1
+ {"version":3,"file":"signature.cjs","names":["useCapability","SignatureToken","stateHook","signatureState","settingsHook","useStampLibraries","SIGNATURES_LIBRARY_KIND","useStampAssets"],"sources":["../src/signature.tsx"],"sourcesContent":["/**\n * The React view of @embedpdf/plugin-signature: signing for the surrounding\n * document, its state (the signatures with their verdicts, what they allow,\n * the target, a two-step signing in progress), and the one derivation a\n * signatures panel needs: the people (libraries of kind `signatures`) with\n * their marks.\n *\n * const signature = useSignature();\n * await signature.placeMark({ assetId }, { field: target }); // sign, fill or ask, by mode\n */\nimport { useMemo } from 'react';\nimport type { EventHook } from '@embedpdf/core';\nimport {\n signatureState,\n signerRowsOf,\n SIGNATURES_LIBRARY_KIND,\n SignatureToken,\n type SignatureCapability,\n type SignerRow,\n} from '@embedpdf/plugin-signature';\n\nimport { useCapability, useCapabilityEvent } from './runtime';\nimport { useStampAssets, useStampLibraries } from './stamp';\nimport { settingsHook, stateHook } from './state';\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-signature';\n\n/** The signature API for the surrounding document. */\nexport function useSignature(): SignatureCapability {\n return useCapability(SignatureToken);\n}\n\n/**\n * The signatures' state: the signed fields with their verdicts, what they\n * allow, the target, whether a signing runs, a two-step signing in progress,\n * and whether they're read (the page's State table, declared once in\n * `signatureState`). Takes a selector, and re-renders only when what it\n * returns changes.\n */\nexport const useSignatureState = stateHook(signatureState);\n\n/** The signature settings (`key`, `mode`, `trust`, `allowCertify`), with or without a document. Takes a selector. */\nexport const useSignatureSettings = settingsHook(SignatureToken);\n\n/** Subscribe to one of the plugin's events while mounted: `useSignatureEvent((signature) => signature.onSigned, handler)`. */\nexport function useSignatureEvent<T>(\n select: (signature: SignatureCapability) => EventHook<T>,\n handler: (event: T) => void,\n): void {\n useCapabilityEvent(SignatureToken, select, handler);\n}\n\n/**\n * The people whose marks this browser holds, one row per library of kind\n * `signatures`, for a picker. Derived from the stamp plugin: rename, delete\n * and export are the library verbs; nothing is stored beyond the file.\n */\nexport function useSignerRows(): SignerRow[] {\n const libraries = useStampLibraries({ kind: SIGNATURES_LIBRARY_KIND });\n const assets = useStampAssets();\n return useMemo(() => signerRowsOf(libraries, assets), [libraries, assets]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,eAAoC;CAClD,OAAOA,gBAAAA,cAAcC,2BAAAA,cAAc;AACrC;;;;;;;;AASA,MAAa,oBAAoBC,cAAAA,UAAUC,2BAAAA,cAAc;;AAGzD,MAAa,uBAAuBC,cAAAA,aAAaH,2BAAAA,cAAc;;AAG/D,SAAgB,kBACd,QACA,SACM;CACN,gBAAA,mBAAmBA,2BAAAA,gBAAgB,QAAQ,OAAO;AACpD;;;;;;AAOA,SAAgB,gBAA6B;CAC3C,MAAM,YAAYI,cAAAA,kBAAkB,EAAE,MAAMC,2BAAAA,wBAAwB,CAAC;CACrE,MAAM,SAASC,cAAAA,eAAe;CAC9B,QAAA,GAAA,MAAA,QAAA,QAAA,GAAA,2BAAA,aAAA,CAAkC,WAAW,MAAM,GAAG,CAAC,WAAW,MAAM,CAAC;AAC3E"}
@@ -1,36 +1,36 @@
1
- import { DocumentProtection, FormFieldRef, SignatureCapability, SignatureChange, SignatureSnapshot, SignatureVerdict } from "@embedpdf/plugin-signature";
2
- import { StampAsset, StampLibrary } from "@embedpdf/plugin-stamp/contract";
1
+ import { n as StateHook, t as SettingsHook } from "./state-0K1I5cM4.cjs";
2
+ import { r as FormFieldRef, t as DocumentProtection } from "./AnnotationList-CkijRHet-HEFNUIZe.cjs";
3
+ import { EventHook } from "@embedpdf/core";
4
+ import { SignatureCapability, SignerRow } from "@embedpdf/plugin-signature";
3
5
  export * from "@embedpdf/plugin-signature";
4
6
  //#region src/signature.d.ts
5
- /** The signature capability for the surrounding document. */
7
+ /** The signature API for the surrounding document. */
6
8
  declare function useSignature(): SignatureCapability;
7
- /** The last signature snapshot (null until the first read lands). */
8
- declare function useSignatureSnapshot(): SignatureSnapshot | null;
9
- /** The last validation (null until one ran). */
10
- declare function useSignatureVerdicts(): SignatureVerdict[] | null;
11
- /** What the document's signatures forbid (null when nothing is signed or not yet read). */
12
- declare function useDocumentProtection(): DocumentProtection | null;
13
- /** The field the next picked mark goes to, and whether a sign/fill is in flight. */
14
- declare function useSignatureTarget(): {
9
+ /**
10
+ * The signatures' state: the signed fields with their verdicts, what they
11
+ * allow, the target, whether a signing runs, a two-step signing in progress,
12
+ * and whether they're read (the page's State table, declared once in
13
+ * `signatureState`). Takes a selector, and re-renders only when what it
14
+ * returns changes.
15
+ */
16
+ declare const useSignatureState: StateHook<{
17
+ signatures: readonly import("@embedpdf/plugin-signature").SignatureInfo[];
18
+ protection: DocumentProtection | null;
15
19
  target: FormFieldRef | null;
16
20
  busy: boolean;
17
- };
18
- /** Subscribe to the plugin's change events (signed / filled / ask / inspect / target / validated …). */
19
- declare function useSignatureEvent(handler: (event: SignatureChange) => void): void;
20
- /** One person: a library of kind `signatures` with its marks split by role. */
21
- interface SignerRow {
22
- libraryId: string;
23
- name: string;
24
- library: StampLibrary;
25
- signatures: StampAsset[];
26
- initials: StampAsset | null;
27
- }
21
+ pending: import("@embedpdf/plugin-signature").SignaturePending | null;
22
+ status: import("@embedpdf/core").ResourceStatus;
23
+ }>;
24
+ /** The signature settings (`key`, `mode`, `trust`, `allowCertify`), with or without a document. Takes a selector. */
25
+ declare const useSignatureSettings: SettingsHook<import("@embedpdf/plugin-signature").SignatureSettings>;
26
+ /** Subscribe to one of the plugin's events while mounted: `useSignatureEvent((signature) => signature.onSigned, handler)`. */
27
+ declare function useSignatureEvent<T>(select: (signature: SignatureCapability) => EventHook<T>, handler: (event: T) => void): void;
28
28
  /**
29
- * The people whose marks this browser holds — one row per library of kind
30
- * `signatures`. Purely derived from the stamp plugin: rename, delete, and
31
- * export are the library verbs; nothing is stored beyond the file.
29
+ * The people whose marks this browser holds, one row per library of kind
30
+ * `signatures`, for a picker. Derived from the stamp plugin: rename, delete
31
+ * and export are the library verbs; nothing is stored beyond the file.
32
32
  */
33
33
  declare function useSignerRows(): SignerRow[];
34
34
  //#endregion
35
- export { SignerRow, useDocumentProtection, useSignature, useSignatureEvent, useSignatureSnapshot, useSignatureTarget, useSignatureVerdicts, useSignerRows };
35
+ export { useSignature, useSignatureEvent, useSignatureSettings, useSignatureState, useSignerRows };
36
36
  //# sourceMappingURL=signature.d.cts.map
@@ -1,36 +1,36 @@
1
- import { DocumentProtection, FormFieldRef, SignatureCapability, SignatureChange, SignatureSnapshot, SignatureVerdict } from "@embedpdf/plugin-signature";
2
- import { StampAsset, StampLibrary } from "@embedpdf/plugin-stamp/contract";
1
+ import { n as StateHook, t as SettingsHook } from "./state-0K1I5cM4.js";
2
+ import { r as FormFieldRef, t as DocumentProtection } from "./AnnotationList-CkijRHet-HEFNUIZe.js";
3
+ import { EventHook } from "@embedpdf/core";
4
+ import { SignatureCapability, SignerRow } from "@embedpdf/plugin-signature";
3
5
  export * from "@embedpdf/plugin-signature";
4
6
  //#region src/signature.d.ts
5
- /** The signature capability for the surrounding document. */
7
+ /** The signature API for the surrounding document. */
6
8
  declare function useSignature(): SignatureCapability;
7
- /** The last signature snapshot (null until the first read lands). */
8
- declare function useSignatureSnapshot(): SignatureSnapshot | null;
9
- /** The last validation (null until one ran). */
10
- declare function useSignatureVerdicts(): SignatureVerdict[] | null;
11
- /** What the document's signatures forbid (null when nothing is signed or not yet read). */
12
- declare function useDocumentProtection(): DocumentProtection | null;
13
- /** The field the next picked mark goes to, and whether a sign/fill is in flight. */
14
- declare function useSignatureTarget(): {
9
+ /**
10
+ * The signatures' state: the signed fields with their verdicts, what they
11
+ * allow, the target, whether a signing runs, a two-step signing in progress,
12
+ * and whether they're read (the page's State table, declared once in
13
+ * `signatureState`). Takes a selector, and re-renders only when what it
14
+ * returns changes.
15
+ */
16
+ declare const useSignatureState: StateHook<{
17
+ signatures: readonly import("@embedpdf/plugin-signature").SignatureInfo[];
18
+ protection: DocumentProtection | null;
15
19
  target: FormFieldRef | null;
16
20
  busy: boolean;
17
- };
18
- /** Subscribe to the plugin's change events (signed / filled / ask / inspect / target / validated …). */
19
- declare function useSignatureEvent(handler: (event: SignatureChange) => void): void;
20
- /** One person: a library of kind `signatures` with its marks split by role. */
21
- interface SignerRow {
22
- libraryId: string;
23
- name: string;
24
- library: StampLibrary;
25
- signatures: StampAsset[];
26
- initials: StampAsset | null;
27
- }
21
+ pending: import("@embedpdf/plugin-signature").SignaturePending | null;
22
+ status: import("@embedpdf/core").ResourceStatus;
23
+ }>;
24
+ /** The signature settings (`key`, `mode`, `trust`, `allowCertify`), with or without a document. Takes a selector. */
25
+ declare const useSignatureSettings: SettingsHook<import("@embedpdf/plugin-signature").SignatureSettings>;
26
+ /** Subscribe to one of the plugin's events while mounted: `useSignatureEvent((signature) => signature.onSigned, handler)`. */
27
+ declare function useSignatureEvent<T>(select: (signature: SignatureCapability) => EventHook<T>, handler: (event: T) => void): void;
28
28
  /**
29
- * The people whose marks this browser holds — one row per library of kind
30
- * `signatures`. Purely derived from the stamp plugin: rename, delete, and
31
- * export are the library verbs; nothing is stored beyond the file.
29
+ * The people whose marks this browser holds, one row per library of kind
30
+ * `signatures`, for a picker. Derived from the stamp plugin: rename, delete
31
+ * and export are the library verbs; nothing is stored beyond the file.
32
32
  */
33
33
  declare function useSignerRows(): SignerRow[];
34
34
  //#endregion
35
- export { SignerRow, useDocumentProtection, useSignature, useSignatureEvent, useSignatureSnapshot, useSignatureTarget, useSignatureVerdicts, useSignerRows };
35
+ export { useSignature, useSignatureEvent, useSignatureSettings, useSignatureState, useSignerRows };
36
36
  //# sourceMappingURL=signature.d.ts.map
package/dist/signature.js CHANGED
@@ -1,67 +1,49 @@
1
- import "./rolldown-runtime-BBjsoOtd.js";
2
- import { shallowArray, useCapability, useCapabilityEvent, useSelector } from "./runtime.js";
3
- import { useStampLibraries } from "./stamp.js";
1
+ import { f as useCapability, p as useCapabilityEvent } from "./runtime-B6xcPsEb.js";
2
+ import { n as stateHook, t as settingsHook } from "./state-CbgxhwLA.js";
3
+ import { useStampAssets, useStampLibraries } from "./stamp.js";
4
4
  import { useMemo } from "react";
5
- import { SIGNATURES_LIBRARY_KIND, SignatureToken, markRoleOf } from "@embedpdf/plugin-signature";
6
- import { StampToken } from "@embedpdf/plugin-stamp/contract";
5
+ import { SIGNATURES_LIBRARY_KIND, SignatureToken, signatureState, signerRowsOf } from "@embedpdf/plugin-signature";
7
6
  export * from "@embedpdf/plugin-signature";
8
7
  //#region src/signature.tsx
9
8
  /**
10
- * The React view of @embedpdf/plugin-signature: the act of signing for the
11
- * surrounding `DocumentScope`, its live facts (snapshot, verdicts,
12
- * protection, target), and the one derivation a signatures panel needs —
13
- * the people (libraries of kind `signatures`) with their marks.
9
+ * The React view of @embedpdf/plugin-signature: signing for the surrounding
10
+ * document, its state (the signatures with their verdicts, what they allow,
11
+ * the target, a two-step signing in progress), and the one derivation a
12
+ * signatures panel needs: the people (libraries of kind `signatures`) with
13
+ * their marks.
14
14
  *
15
15
  * const signature = useSignature();
16
- * await signature.placeMark({ assetId }, { field: target }); // sign / fill / ask, by mode
16
+ * await signature.placeMark({ assetId }, { field: target }); // sign, fill or ask, by mode
17
17
  */
18
- /** The signature capability for the surrounding document. */
18
+ /** The signature API for the surrounding document. */
19
19
  function useSignature() {
20
20
  return useCapability(SignatureToken);
21
21
  }
22
- /** The last signature snapshot (null until the first read lands). */
23
- function useSignatureSnapshot() {
24
- return useSelector(SignatureToken, (c) => c.snapshot());
25
- }
26
- /** The last validation (null until one ran). */
27
- function useSignatureVerdicts() {
28
- return useSelector(SignatureToken, (c) => c.verdicts());
29
- }
30
- /** What the document's signatures forbid (null when nothing is signed or not yet read). */
31
- function useDocumentProtection() {
32
- return useSelector(SignatureToken, (c) => c.protection());
33
- }
34
- /** The field the next picked mark goes to, and whether a sign/fill is in flight. */
35
- function useSignatureTarget() {
36
- return {
37
- target: useSelector(SignatureToken, (c) => c.target()),
38
- busy: useSelector(SignatureToken, (c) => c.busy())
39
- };
40
- }
41
- /** Subscribe to the plugin's change events (signed / filled / ask / inspect / target / validated …). */
42
- function useSignatureEvent(handler) {
43
- useCapabilityEvent(SignatureToken, (c) => c.onChanged, handler);
22
+ /**
23
+ * The signatures' state: the signed fields with their verdicts, what they
24
+ * allow, the target, whether a signing runs, a two-step signing in progress,
25
+ * and whether they're read (the page's State table, declared once in
26
+ * `signatureState`). Takes a selector, and re-renders only when what it
27
+ * returns changes.
28
+ */
29
+ const useSignatureState = stateHook(signatureState);
30
+ /** The signature settings (`key`, `mode`, `trust`, `allowCertify`), with or without a document. Takes a selector. */
31
+ const useSignatureSettings = settingsHook(SignatureToken);
32
+ /** Subscribe to one of the plugin's events while mounted: `useSignatureEvent((signature) => signature.onSigned, handler)`. */
33
+ function useSignatureEvent(select, handler) {
34
+ useCapabilityEvent(SignatureToken, select, handler);
44
35
  }
45
36
  /**
46
- * The people whose marks this browser holds — one row per library of kind
47
- * `signatures`. Purely derived from the stamp plugin: rename, delete, and
48
- * export are the library verbs; nothing is stored beyond the file.
37
+ * The people whose marks this browser holds, one row per library of kind
38
+ * `signatures`, for a picker. Derived from the stamp plugin: rename, delete
39
+ * and export are the library verbs; nothing is stored beyond the file.
49
40
  */
50
41
  function useSignerRows() {
51
42
  const libraries = useStampLibraries({ kind: SIGNATURES_LIBRARY_KIND });
52
- const assets = useSelector(StampToken, (c) => c.assets(), shallowArray);
53
- return useMemo(() => libraries.map((library) => {
54
- const own = assets.filter((asset) => asset.libraryId === library.id);
55
- return {
56
- libraryId: library.id,
57
- name: library.name,
58
- library,
59
- signatures: own.filter((asset) => markRoleOf(asset) === "signature"),
60
- initials: own.find((asset) => markRoleOf(asset) === "initials") ?? null
61
- };
62
- }), [libraries, assets]);
43
+ const assets = useStampAssets();
44
+ return useMemo(() => signerRowsOf(libraries, assets), [libraries, assets]);
63
45
  }
64
46
  //#endregion
65
- export { useDocumentProtection, useSignature, useSignatureEvent, useSignatureSnapshot, useSignatureTarget, useSignatureVerdicts, useSignerRows };
47
+ export { useSignature, useSignatureEvent, useSignatureSettings, useSignatureState, useSignerRows };
66
48
 
67
49
  //# sourceMappingURL=signature.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"signature.js","names":[],"sources":["../src/signature.tsx"],"sourcesContent":["/**\n * The React view of @embedpdf/plugin-signature: the act of signing for the\n * surrounding `DocumentScope`, its live facts (snapshot, verdicts,\n * protection, target), and the one derivation a signatures panel needs —\n * the people (libraries of kind `signatures`) with their marks.\n *\n * const signature = useSignature();\n * await signature.placeMark({ assetId }, { field: target }); // sign / fill / ask, by mode\n */\nimport { useMemo } from 'react';\nimport {\n markRoleOf,\n SIGNATURES_LIBRARY_KIND,\n SignatureToken,\n type DocumentProtection,\n type FormFieldRef,\n type SignatureCapability,\n type SignatureChange,\n type SignatureSnapshot,\n type SignatureVerdict,\n} from '@embedpdf/plugin-signature';\nimport { StampToken, type StampAsset, type StampLibrary } from '@embedpdf/plugin-stamp/contract';\n\nimport { shallowArray, useCapability, useCapabilityEvent, useSelector } from './runtime';\nimport { useStampLibraries } from './stamp';\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-signature';\n\n/** The signature capability for the surrounding document. */\nexport function useSignature(): SignatureCapability {\n return useCapability(SignatureToken);\n}\n\n/** The last signature snapshot (null until the first read lands). */\nexport function useSignatureSnapshot(): SignatureSnapshot | null {\n return useSelector(SignatureToken, (c) => c.snapshot());\n}\n\n/** The last validation (null until one ran). */\nexport function useSignatureVerdicts(): SignatureVerdict[] | null {\n return useSelector(SignatureToken, (c) => c.verdicts());\n}\n\n/** What the document's signatures forbid (null when nothing is signed or not yet read). */\nexport function useDocumentProtection(): DocumentProtection | null {\n return useSelector(SignatureToken, (c) => c.protection());\n}\n\n/** The field the next picked mark goes to, and whether a sign/fill is in flight. */\nexport function useSignatureTarget(): { target: FormFieldRef | null; busy: boolean } {\n const target = useSelector(SignatureToken, (c) => c.target());\n const busy = useSelector(SignatureToken, (c) => c.busy());\n return { target, busy };\n}\n\n/** Subscribe to the plugin's change events (signed / filled / ask / inspect / target / validated …). */\nexport function useSignatureEvent(handler: (event: SignatureChange) => void): void {\n useCapabilityEvent(SignatureToken, (c) => c.onChanged, handler);\n}\n\n/** One person: a library of kind `signatures` with its marks split by role. */\nexport interface SignerRow {\n libraryId: string;\n name: string;\n library: StampLibrary;\n signatures: StampAsset[];\n initials: StampAsset | null;\n}\n\n/**\n * The people whose marks this browser holds — one row per library of kind\n * `signatures`. Purely derived from the stamp plugin: rename, delete, and\n * export are the library verbs; nothing is stored beyond the file.\n */\nexport function useSignerRows(): SignerRow[] {\n const libraries = useStampLibraries({ kind: SIGNATURES_LIBRARY_KIND });\n const assets = useSelector(StampToken, (c) => c.assets(), shallowArray);\n return useMemo(\n () =>\n libraries.map((library) => {\n const own = assets.filter((asset) => asset.libraryId === library.id);\n return {\n libraryId: library.id,\n name: library.name,\n library,\n signatures: own.filter((asset) => markRoleOf(asset) === 'signature'),\n initials: own.find((asset) => markRoleOf(asset) === 'initials') ?? null,\n };\n }),\n [libraries, assets],\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA8BA,SAAgB,eAAoC;CAClD,OAAO,cAAc,cAAc;AACrC;;AAGA,SAAgB,uBAAiD;CAC/D,OAAO,YAAY,iBAAiB,MAAM,EAAE,SAAS,CAAC;AACxD;;AAGA,SAAgB,uBAAkD;CAChE,OAAO,YAAY,iBAAiB,MAAM,EAAE,SAAS,CAAC;AACxD;;AAGA,SAAgB,wBAAmD;CACjE,OAAO,YAAY,iBAAiB,MAAM,EAAE,WAAW,CAAC;AAC1D;;AAGA,SAAgB,qBAAqE;CAGnF,OAAO;EAAE,QAFM,YAAY,iBAAiB,MAAM,EAAE,OAAO,CAE7C;EAAG,MADJ,YAAY,iBAAiB,MAAM,EAAE,KAAK,CACnC;CAAE;AACxB;;AAGA,SAAgB,kBAAkB,SAAiD;CACjF,mBAAmB,iBAAiB,MAAM,EAAE,WAAW,OAAO;AAChE;;;;;;AAgBA,SAAgB,gBAA6B;CAC3C,MAAM,YAAY,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;CACrE,MAAM,SAAS,YAAY,aAAa,MAAM,EAAE,OAAO,GAAG,YAAY;CACtE,OAAO,cAEH,UAAU,KAAK,YAAY;EACzB,MAAM,MAAM,OAAO,QAAQ,UAAU,MAAM,cAAc,QAAQ,EAAE;EACnE,OAAO;GACL,WAAW,QAAQ;GACnB,MAAM,QAAQ;GACd;GACA,YAAY,IAAI,QAAQ,UAAU,WAAW,KAAK,MAAM,WAAW;GACnE,UAAU,IAAI,MAAM,UAAU,WAAW,KAAK,MAAM,UAAU,KAAK;EACrE;CACF,CAAC,GACH,CAAC,WAAW,MAAM,CACpB;AACF"}
1
+ {"version":3,"file":"signature.js","names":[],"sources":["../src/signature.tsx"],"sourcesContent":["/**\n * The React view of @embedpdf/plugin-signature: signing for the surrounding\n * document, its state (the signatures with their verdicts, what they allow,\n * the target, a two-step signing in progress), and the one derivation a\n * signatures panel needs: the people (libraries of kind `signatures`) with\n * their marks.\n *\n * const signature = useSignature();\n * await signature.placeMark({ assetId }, { field: target }); // sign, fill or ask, by mode\n */\nimport { useMemo } from 'react';\nimport type { EventHook } from '@embedpdf/core';\nimport {\n signatureState,\n signerRowsOf,\n SIGNATURES_LIBRARY_KIND,\n SignatureToken,\n type SignatureCapability,\n type SignerRow,\n} from '@embedpdf/plugin-signature';\n\nimport { useCapability, useCapabilityEvent } from './runtime';\nimport { useStampAssets, useStampLibraries } from './stamp';\nimport { settingsHook, stateHook } from './state';\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-signature';\n\n/** The signature API for the surrounding document. */\nexport function useSignature(): SignatureCapability {\n return useCapability(SignatureToken);\n}\n\n/**\n * The signatures' state: the signed fields with their verdicts, what they\n * allow, the target, whether a signing runs, a two-step signing in progress,\n * and whether they're read (the page's State table, declared once in\n * `signatureState`). Takes a selector, and re-renders only when what it\n * returns changes.\n */\nexport const useSignatureState = stateHook(signatureState);\n\n/** The signature settings (`key`, `mode`, `trust`, `allowCertify`), with or without a document. Takes a selector. */\nexport const useSignatureSettings = settingsHook(SignatureToken);\n\n/** Subscribe to one of the plugin's events while mounted: `useSignatureEvent((signature) => signature.onSigned, handler)`. */\nexport function useSignatureEvent<T>(\n select: (signature: SignatureCapability) => EventHook<T>,\n handler: (event: T) => void,\n): void {\n useCapabilityEvent(SignatureToken, select, handler);\n}\n\n/**\n * The people whose marks this browser holds, one row per library of kind\n * `signatures`, for a picker. Derived from the stamp plugin: rename, delete\n * and export are the library verbs; nothing is stored beyond the file.\n */\nexport function useSignerRows(): SignerRow[] {\n const libraries = useStampLibraries({ kind: SIGNATURES_LIBRARY_KIND });\n const assets = useStampAssets();\n return useMemo(() => signerRowsOf(libraries, assets), [libraries, assets]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,SAAgB,eAAoC;CAClD,OAAO,cAAc,cAAc;AACrC;;;;;;;;AASA,MAAa,oBAAoB,UAAU,cAAc;;AAGzD,MAAa,uBAAuB,aAAa,cAAc;;AAG/D,SAAgB,kBACd,QACA,SACM;CACN,mBAAmB,gBAAgB,QAAQ,OAAO;AACpD;;;;;;AAOA,SAAgB,gBAA6B;CAC3C,MAAM,YAAY,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;CACrE,MAAM,SAAS,eAAe;CAC9B,OAAO,cAAc,aAAa,WAAW,MAAM,GAAG,CAAC,WAAW,MAAM,CAAC;AAC3E"}