@embedpdf/react 3.0.0-next.14 → 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 -784
  24. package/dist/annotation.d.cts +2 -2
  25. package/dist/annotation.d.ts +2 -2
  26. package/dist/annotation.js +2 -769
  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 +41 -2
  39. package/dist/form.d.ts +41 -2
  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 +200 -57
  54. package/dist/index.d.cts +31 -32
  55. package/dist/index.d.ts +31 -32
  56. package/dist/index.js +32 -30
  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 +36 -11
  74. package/dist/measurement.cjs.map +1 -1
  75. package/dist/measurement.d.cts +33 -7
  76. package/dist/measurement.d.ts +33 -7
  77. package/dist/measurement.js +35 -14
  78. package/dist/measurement.js.map +1 -1
  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 +37 -24
  126. package/dist/search.d.ts +37 -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 +37 -39
  190. package/dist/annotation-BCED_p9H.d.cts +0 -160
  191. package/dist/annotation-anchors-CetwM1g7.js +0 -15
  192. package/dist/annotation-anchors-CetwM1g7.js.map +0 -1
  193. package/dist/annotation-anchors-DuYRBJLl.cjs +0 -26
  194. package/dist/annotation-anchors-DuYRBJLl.cjs.map +0 -1
  195. package/dist/annotation-hooks-BB5ZhPpf.cjs +0 -16
  196. package/dist/annotation-hooks-BB5ZhPpf.cjs.map +0 -1
  197. package/dist/annotation-hooks-Df8EmzDO.js +0 -11
  198. package/dist/annotation-hooks-Df8EmzDO.js.map +0 -1
  199. package/dist/annotation-k38KDlIZ.d.ts +0 -160
  200. package/dist/annotation-menu.cjs +0 -64
  201. package/dist/annotation-menu.cjs.map +0 -1
  202. package/dist/annotation-menu.d.cts +0 -33
  203. package/dist/annotation-menu.d.ts +0 -33
  204. package/dist/annotation-menu.js +0 -48
  205. package/dist/annotation-menu.js.map +0 -1
  206. package/dist/annotation.cjs.map +0 -1
  207. package/dist/annotation.js.map +0 -1
  208. package/dist/form-BVumS7up.cjs +0 -926
  209. package/dist/form-BVumS7up.cjs.map +0 -1
  210. package/dist/form-Bdjk0Z3T.d.cts +0 -537
  211. package/dist/form-CK3mp99m.js +0 -895
  212. package/dist/form-CK3mp99m.js.map +0 -1
  213. package/dist/form-CYRYgthn.d.ts +0 -537
  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
@@ -0,0 +1,29 @@
1
+ import { CapabilityToken, SettingsOf, StateDeclaration } from "@embedpdf/core";
2
+ //#region src/state.d.ts
3
+ /** A declared state's hook: the whole state, or the value `select` picks from it. */
4
+ type StateHook<State> = <Selected = State>(select?: (state: State) => Selected) => Selected;
5
+ /** A plugin's settings hook: the settings, or the value `select` picks from them. */
6
+ type SettingsHook<Settings> = <Selected = Settings>(select?: (settings: Settings) => Selected) => Selected;
7
+ /**
8
+ * Turn a state declaration into its hook. The hook reads this subtree's
9
+ * document (the nearest <DocumentScope>, else the active one) and returns the
10
+ * declaration's `empty` while that document is missing or not ready, so it
11
+ * renders anywhere. It re-renders only when a field changes: the state, or the
12
+ * value `select` picks from it, is compared with {@link shallowEqual}. State
13
+ * the plugin loads on demand (the declaration's `ensure`) loads once a ready
14
+ * document's capability is in scope, for every document the hook reads.
15
+ */
16
+ declare function stateHook<Capability, State extends object>(declaration: StateDeclaration<Capability, State>): StateHook<State>;
17
+ /**
18
+ * Turn a plugin's token into its settings hook. A plugin's settings belong to
19
+ * the plugin as the app registered it, not to a document, so the hook reads
20
+ * them through the kernel (`kernel.settingsOf`): it works before the first
21
+ * document opens, and every document shows the same settings. It re-renders
22
+ * only when a setting changes: `getSettings()` keeps its object until then,
23
+ * and the value `select` picks is compared with {@link shallowEqual}. A token
24
+ * whose plugin isn't installed, or has no settings, throws: a setup mistake.
25
+ */
26
+ declare function settingsHook<Capability>(token: CapabilityToken<Capability>): SettingsHook<SettingsOf<Capability>>;
27
+ //#endregion
28
+ export { stateHook as i, StateHook as n, settingsHook as r, SettingsHook as t };
29
+ //# sourceMappingURL=state-0K1I5cM4.d.cts.map
@@ -0,0 +1,29 @@
1
+ import { CapabilityToken, SettingsOf, StateDeclaration } from "@embedpdf/core";
2
+ //#region src/state.d.ts
3
+ /** A declared state's hook: the whole state, or the value `select` picks from it. */
4
+ type StateHook<State> = <Selected = State>(select?: (state: State) => Selected) => Selected;
5
+ /** A plugin's settings hook: the settings, or the value `select` picks from them. */
6
+ type SettingsHook<Settings> = <Selected = Settings>(select?: (settings: Settings) => Selected) => Selected;
7
+ /**
8
+ * Turn a state declaration into its hook. The hook reads this subtree's
9
+ * document (the nearest <DocumentScope>, else the active one) and returns the
10
+ * declaration's `empty` while that document is missing or not ready, so it
11
+ * renders anywhere. It re-renders only when a field changes: the state, or the
12
+ * value `select` picks from it, is compared with {@link shallowEqual}. State
13
+ * the plugin loads on demand (the declaration's `ensure`) loads once a ready
14
+ * document's capability is in scope, for every document the hook reads.
15
+ */
16
+ declare function stateHook<Capability, State extends object>(declaration: StateDeclaration<Capability, State>): StateHook<State>;
17
+ /**
18
+ * Turn a plugin's token into its settings hook. A plugin's settings belong to
19
+ * the plugin as the app registered it, not to a document, so the hook reads
20
+ * them through the kernel (`kernel.settingsOf`): it works before the first
21
+ * document opens, and every document shows the same settings. It re-renders
22
+ * only when a setting changes: `getSettings()` keeps its object until then,
23
+ * and the value `select` picks is compared with {@link shallowEqual}. A token
24
+ * whose plugin isn't installed, or has no settings, throws: a setup mistake.
25
+ */
26
+ declare function settingsHook<Capability>(token: CapabilityToken<Capability>): SettingsHook<SettingsOf<Capability>>;
27
+ //#endregion
28
+ export { stateHook as i, StateHook as n, settingsHook as r, SettingsHook as t };
29
+ //# sourceMappingURL=state-0K1I5cM4.d.ts.map
@@ -0,0 +1,62 @@
1
+ import { g as useDocumentScope, x as useKernelValue } from "./runtime-B6xcPsEb.js";
2
+ import { shallowEqual } from "@embedpdf/core";
3
+ import { useEffect } from "react";
4
+ //#region src/state.ts
5
+ /**
6
+ * Declared state and settings as React hooks. A plugin declares its state once
7
+ * with `defineState` and its settings once in its definition (both in
8
+ * `@embedpdf/core`), and its React bindings are one line each:
9
+ *
10
+ * export const useSearchState = stateHook(searchState);
11
+ * export const useSearchSettings = settingsHook(SearchToken);
12
+ */
13
+ /**
14
+ * Turn a state declaration into its hook. The hook reads this subtree's
15
+ * document (the nearest <DocumentScope>, else the active one) and returns the
16
+ * declaration's `empty` while that document is missing or not ready, so it
17
+ * renders anywhere. It re-renders only when a field changes: the state, or the
18
+ * value `select` picks from it, is compared with {@link shallowEqual}. State
19
+ * the plugin loads on demand (the declaration's `ensure`) loads once a ready
20
+ * document's capability is in scope, for every document the hook reads.
21
+ */
22
+ function stateHook(declaration) {
23
+ const { ensure } = declaration;
24
+ const useDeclaredState = function useDeclaredState(select) {
25
+ const scoped = useDocumentScope();
26
+ return useKernelValue((kernel) => {
27
+ const capability = kernel.tryCapability(declaration.token, scoped ?? void 0);
28
+ const state = capability ? declaration.read(capability) : declaration.empty;
29
+ return select ? select(state) : state;
30
+ }, shallowEqual);
31
+ };
32
+ if (!ensure) return useDeclaredState;
33
+ return function useLoadedState(select) {
34
+ const scoped = useDocumentScope();
35
+ const capability = useKernelValue((kernel) => kernel.tryCapability(declaration.token, scoped ?? void 0), Object.is);
36
+ useEffect(() => {
37
+ if (capability) ensure(capability).catch(() => {});
38
+ }, [capability]);
39
+ return useDeclaredState(select);
40
+ };
41
+ }
42
+ /**
43
+ * Turn a plugin's token into its settings hook. A plugin's settings belong to
44
+ * the plugin as the app registered it, not to a document, so the hook reads
45
+ * them through the kernel (`kernel.settingsOf`): it works before the first
46
+ * document opens, and every document shows the same settings. It re-renders
47
+ * only when a setting changes: `getSettings()` keeps its object until then,
48
+ * and the value `select` picks is compared with {@link shallowEqual}. A token
49
+ * whose plugin isn't installed, or has no settings, throws: a setup mistake.
50
+ */
51
+ function settingsHook(token) {
52
+ return function useSettings(select) {
53
+ return useKernelValue((kernel) => {
54
+ const settings = kernel.settingsOf(token).getSettings();
55
+ return select ? select(settings) : settings;
56
+ }, shallowEqual);
57
+ };
58
+ }
59
+ //#endregion
60
+ export { stateHook as n, settingsHook as t };
61
+
62
+ //# sourceMappingURL=state-CbgxhwLA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-CbgxhwLA.js","names":[],"sources":["../src/state.ts"],"sourcesContent":["/**\n * Declared state and settings as React hooks. A plugin declares its state once\n * with `defineState` and its settings once in its definition (both in\n * `@embedpdf/core`), and its React bindings are one line each:\n *\n * export const useSearchState = stateHook(searchState);\n * export const useSearchSettings = settingsHook(SearchToken);\n */\nimport { useEffect } from 'react';\nimport { shallowEqual } from '@embedpdf/core';\nimport type { CapabilityToken, SettingsOf, StateDeclaration } from '@embedpdf/core';\nimport { useDocumentScope, useKernelValue } from './runtime';\n\n/** A declared state's hook: the whole state, or the value `select` picks from it. */\nexport type StateHook<State> = <Selected = State>(select?: (state: State) => Selected) => Selected;\n\n/** A plugin's settings hook: the settings, or the value `select` picks from them. */\nexport type SettingsHook<Settings> = <Selected = Settings>(\n select?: (settings: Settings) => Selected,\n) => Selected;\n\n/**\n * Turn a state declaration into its hook. The hook reads this subtree's\n * document (the nearest <DocumentScope>, else the active one) and returns the\n * declaration's `empty` while that document is missing or not ready, so it\n * renders anywhere. It re-renders only when a field changes: the state, or the\n * value `select` picks from it, is compared with {@link shallowEqual}. State\n * the plugin loads on demand (the declaration's `ensure`) loads once a ready\n * document's capability is in scope, for every document the hook reads.\n */\nexport function stateHook<Capability, State extends object>(\n declaration: StateDeclaration<Capability, State>,\n): StateHook<State> {\n const { ensure } = declaration;\n const useDeclaredState = function useDeclaredState<Selected = State>(\n select?: (state: State) => Selected,\n ): Selected {\n const scoped = useDocumentScope();\n // Resolve on every read, not once per render: a document that closes\n // between a store change and the next render then reads as `empty`,\n // never through its closed capability.\n return useKernelValue((kernel) => {\n const capability = kernel.tryCapability(declaration.token, scoped ?? undefined);\n const state = capability ? declaration.read(capability) : declaration.empty;\n return select ? select(state) : (state as unknown as Selected);\n }, shallowEqual);\n };\n if (!ensure) return useDeclaredState;\n return function useLoadedState<Selected = State>(select?: (state: State) => Selected): Selected {\n const scoped = useDocumentScope();\n const capability = useKernelValue(\n (kernel) => kernel.tryCapability(declaration.token, scoped ?? undefined),\n Object.is,\n );\n // The state says when the load fails (its status), so the rejection has nothing to add.\n useEffect(() => {\n if (capability) ensure(capability).catch(() => {});\n }, [capability]);\n return useDeclaredState(select);\n };\n}\n\n/**\n * Turn a plugin's token into its settings hook. A plugin's settings belong to\n * the plugin as the app registered it, not to a document, so the hook reads\n * them through the kernel (`kernel.settingsOf`): it works before the first\n * document opens, and every document shows the same settings. It re-renders\n * only when a setting changes: `getSettings()` keeps its object until then,\n * and the value `select` picks is compared with {@link shallowEqual}. A token\n * whose plugin isn't installed, or has no settings, throws: a setup mistake.\n */\nexport function settingsHook<Capability>(\n token: CapabilityToken<Capability>,\n): SettingsHook<SettingsOf<Capability>> {\n return function useSettings<Selected = SettingsOf<Capability>>(\n select?: (settings: SettingsOf<Capability>) => Selected,\n ): Selected {\n return useKernelValue((kernel) => {\n const settings = kernel.settingsOf(token).getSettings();\n return select ? select(settings) : (settings as unknown as Selected);\n }, shallowEqual);\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,UACd,aACkB;CAClB,MAAM,EAAE,WAAW;CACnB,MAAM,mBAAmB,SAAS,iBAChC,QACU;EACV,MAAM,SAAS,iBAAiB;EAIhC,OAAO,gBAAgB,WAAW;GAChC,MAAM,aAAa,OAAO,cAAc,YAAY,OAAO,UAAU,KAAA,CAAS;GAC9E,MAAM,QAAQ,aAAa,YAAY,KAAK,UAAU,IAAI,YAAY;GACtE,OAAO,SAAS,OAAO,KAAK,IAAK;EACnC,GAAG,YAAY;CACjB;CACA,IAAI,CAAC,QAAQ,OAAO;CACpB,OAAO,SAAS,eAAiC,QAA+C;EAC9F,MAAM,SAAS,iBAAiB;EAChC,MAAM,aAAa,gBAChB,WAAW,OAAO,cAAc,YAAY,OAAO,UAAU,KAAA,CAAS,GACvE,OAAO,EACT;EAEA,gBAAgB;GACd,IAAI,YAAY,OAAO,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC;EACnD,GAAG,CAAC,UAAU,CAAC;EACf,OAAO,iBAAiB,MAAM;CAChC;AACF;;;;;;;;;;AAWA,SAAgB,aACd,OACsC;CACtC,OAAO,SAAS,YACd,QACU;EACV,OAAO,gBAAgB,WAAW;GAChC,MAAM,WAAW,OAAO,WAAW,KAAK,CAAC,CAAC,YAAY;GACtD,OAAO,SAAS,OAAO,QAAQ,IAAK;EACtC,GAAG,YAAY;CACjB;AACF"}
@@ -0,0 +1,73 @@
1
+ const require_runtime = require("./runtime-fzpGv78v.cjs");
2
+ let _embedpdf_core = require("@embedpdf/core");
3
+ let react = require("react");
4
+ //#region src/state.ts
5
+ /**
6
+ * Declared state and settings as React hooks. A plugin declares its state once
7
+ * with `defineState` and its settings once in its definition (both in
8
+ * `@embedpdf/core`), and its React bindings are one line each:
9
+ *
10
+ * export const useSearchState = stateHook(searchState);
11
+ * export const useSearchSettings = settingsHook(SearchToken);
12
+ */
13
+ /**
14
+ * Turn a state declaration into its hook. The hook reads this subtree's
15
+ * document (the nearest <DocumentScope>, else the active one) and returns the
16
+ * declaration's `empty` while that document is missing or not ready, so it
17
+ * renders anywhere. It re-renders only when a field changes: the state, or the
18
+ * value `select` picks from it, is compared with {@link shallowEqual}. State
19
+ * the plugin loads on demand (the declaration's `ensure`) loads once a ready
20
+ * document's capability is in scope, for every document the hook reads.
21
+ */
22
+ function stateHook(declaration) {
23
+ const { ensure } = declaration;
24
+ const useDeclaredState = function useDeclaredState(select) {
25
+ const scoped = require_runtime.useDocumentScope();
26
+ return require_runtime.useKernelValue((kernel) => {
27
+ const capability = kernel.tryCapability(declaration.token, scoped ?? void 0);
28
+ const state = capability ? declaration.read(capability) : declaration.empty;
29
+ return select ? select(state) : state;
30
+ }, _embedpdf_core.shallowEqual);
31
+ };
32
+ if (!ensure) return useDeclaredState;
33
+ return function useLoadedState(select) {
34
+ const scoped = require_runtime.useDocumentScope();
35
+ const capability = require_runtime.useKernelValue((kernel) => kernel.tryCapability(declaration.token, scoped ?? void 0), Object.is);
36
+ (0, react.useEffect)(() => {
37
+ if (capability) ensure(capability).catch(() => {});
38
+ }, [capability]);
39
+ return useDeclaredState(select);
40
+ };
41
+ }
42
+ /**
43
+ * Turn a plugin's token into its settings hook. A plugin's settings belong to
44
+ * the plugin as the app registered it, not to a document, so the hook reads
45
+ * them through the kernel (`kernel.settingsOf`): it works before the first
46
+ * document opens, and every document shows the same settings. It re-renders
47
+ * only when a setting changes: `getSettings()` keeps its object until then,
48
+ * and the value `select` picks is compared with {@link shallowEqual}. A token
49
+ * whose plugin isn't installed, or has no settings, throws: a setup mistake.
50
+ */
51
+ function settingsHook(token) {
52
+ return function useSettings(select) {
53
+ return require_runtime.useKernelValue((kernel) => {
54
+ const settings = kernel.settingsOf(token).getSettings();
55
+ return select ? select(settings) : settings;
56
+ }, _embedpdf_core.shallowEqual);
57
+ };
58
+ }
59
+ //#endregion
60
+ Object.defineProperty(exports, "settingsHook", {
61
+ enumerable: true,
62
+ get: function() {
63
+ return settingsHook;
64
+ }
65
+ });
66
+ Object.defineProperty(exports, "stateHook", {
67
+ enumerable: true,
68
+ get: function() {
69
+ return stateHook;
70
+ }
71
+ });
72
+
73
+ //# sourceMappingURL=state-CsfZy_Eq.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-CsfZy_Eq.cjs","names":["useDocumentScope","useKernelValue","shallowEqual"],"sources":["../src/state.ts"],"sourcesContent":["/**\n * Declared state and settings as React hooks. A plugin declares its state once\n * with `defineState` and its settings once in its definition (both in\n * `@embedpdf/core`), and its React bindings are one line each:\n *\n * export const useSearchState = stateHook(searchState);\n * export const useSearchSettings = settingsHook(SearchToken);\n */\nimport { useEffect } from 'react';\nimport { shallowEqual } from '@embedpdf/core';\nimport type { CapabilityToken, SettingsOf, StateDeclaration } from '@embedpdf/core';\nimport { useDocumentScope, useKernelValue } from './runtime';\n\n/** A declared state's hook: the whole state, or the value `select` picks from it. */\nexport type StateHook<State> = <Selected = State>(select?: (state: State) => Selected) => Selected;\n\n/** A plugin's settings hook: the settings, or the value `select` picks from them. */\nexport type SettingsHook<Settings> = <Selected = Settings>(\n select?: (settings: Settings) => Selected,\n) => Selected;\n\n/**\n * Turn a state declaration into its hook. The hook reads this subtree's\n * document (the nearest <DocumentScope>, else the active one) and returns the\n * declaration's `empty` while that document is missing or not ready, so it\n * renders anywhere. It re-renders only when a field changes: the state, or the\n * value `select` picks from it, is compared with {@link shallowEqual}. State\n * the plugin loads on demand (the declaration's `ensure`) loads once a ready\n * document's capability is in scope, for every document the hook reads.\n */\nexport function stateHook<Capability, State extends object>(\n declaration: StateDeclaration<Capability, State>,\n): StateHook<State> {\n const { ensure } = declaration;\n const useDeclaredState = function useDeclaredState<Selected = State>(\n select?: (state: State) => Selected,\n ): Selected {\n const scoped = useDocumentScope();\n // Resolve on every read, not once per render: a document that closes\n // between a store change and the next render then reads as `empty`,\n // never through its closed capability.\n return useKernelValue((kernel) => {\n const capability = kernel.tryCapability(declaration.token, scoped ?? undefined);\n const state = capability ? declaration.read(capability) : declaration.empty;\n return select ? select(state) : (state as unknown as Selected);\n }, shallowEqual);\n };\n if (!ensure) return useDeclaredState;\n return function useLoadedState<Selected = State>(select?: (state: State) => Selected): Selected {\n const scoped = useDocumentScope();\n const capability = useKernelValue(\n (kernel) => kernel.tryCapability(declaration.token, scoped ?? undefined),\n Object.is,\n );\n // The state says when the load fails (its status), so the rejection has nothing to add.\n useEffect(() => {\n if (capability) ensure(capability).catch(() => {});\n }, [capability]);\n return useDeclaredState(select);\n };\n}\n\n/**\n * Turn a plugin's token into its settings hook. A plugin's settings belong to\n * the plugin as the app registered it, not to a document, so the hook reads\n * them through the kernel (`kernel.settingsOf`): it works before the first\n * document opens, and every document shows the same settings. It re-renders\n * only when a setting changes: `getSettings()` keeps its object until then,\n * and the value `select` picks is compared with {@link shallowEqual}. A token\n * whose plugin isn't installed, or has no settings, throws: a setup mistake.\n */\nexport function settingsHook<Capability>(\n token: CapabilityToken<Capability>,\n): SettingsHook<SettingsOf<Capability>> {\n return function useSettings<Selected = SettingsOf<Capability>>(\n select?: (settings: SettingsOf<Capability>) => Selected,\n ): Selected {\n return useKernelValue((kernel) => {\n const settings = kernel.settingsOf(token).getSettings();\n return select ? select(settings) : (settings as unknown as Selected);\n }, shallowEqual);\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,UACd,aACkB;CAClB,MAAM,EAAE,WAAW;CACnB,MAAM,mBAAmB,SAAS,iBAChC,QACU;EACV,MAAM,SAASA,gBAAAA,iBAAiB;EAIhC,OAAOC,gBAAAA,gBAAgB,WAAW;GAChC,MAAM,aAAa,OAAO,cAAc,YAAY,OAAO,UAAU,KAAA,CAAS;GAC9E,MAAM,QAAQ,aAAa,YAAY,KAAK,UAAU,IAAI,YAAY;GACtE,OAAO,SAAS,OAAO,KAAK,IAAK;EACnC,GAAGC,eAAAA,YAAY;CACjB;CACA,IAAI,CAAC,QAAQ,OAAO;CACpB,OAAO,SAAS,eAAiC,QAA+C;EAC9F,MAAM,SAASF,gBAAAA,iBAAiB;EAChC,MAAM,aAAaC,gBAAAA,gBAChB,WAAW,OAAO,cAAc,YAAY,OAAO,UAAU,KAAA,CAAS,GACvE,OAAO,EACT;EAEA,CAAA,GAAA,MAAA,UAAA,OAAgB;GACd,IAAI,YAAY,OAAO,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC;EACnD,GAAG,CAAC,UAAU,CAAC;EACf,OAAO,iBAAiB,MAAM;CAChC;AACF;;;;;;;;;;AAWA,SAAgB,aACd,OACsC;CACtC,OAAO,SAAS,YACd,QACU;EACV,OAAOA,gBAAAA,gBAAgB,WAAW;GAChC,MAAM,WAAW,OAAO,WAAW,KAAK,CAAC,CAAC,YAAY;GACtD,OAAO,SAAS,OAAO,QAAQ,IAAK;EACtC,GAAGC,eAAAA,YAAY;CACjB;AACF"}
@@ -0,0 +1,40 @@
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
+ import { createFontMounts, fontProgramsOf } from "@embedpdf/web";
3
+ import React, { useEffect, useState } from "react";
4
+ //#region src/font-mounts.ts
5
+ /**
6
+ * The engine's faces a part of a layer draws text in, mounted while it's
7
+ * there (`@embedpdf/web`'s `createFontMounts`, one set per component).
8
+ */
9
+ function useFontMounts(programs) {
10
+ const [mounts] = useState(() => createFontMounts());
11
+ useEffect(() => () => mounts.release(), [mounts]);
12
+ useEffect(() => mounts.mount(programs));
13
+ }
14
+ //#endregion
15
+ //#region src/svg-shapes.tsx
16
+ /**
17
+ * Scene shapes as React elements: `@embedpdf/web`'s element descriptions
18
+ * (`svgShapesOf`), one element each, a clipping `svg` with its children, and
19
+ * the faces their text draws in mounted while they show. The annotation and
20
+ * form layers draw their scenes through it.
21
+ */
22
+ function SvgShapes({ shapes }) {
23
+ useFontMounts(fontProgramsOf(shapes));
24
+ return /* @__PURE__ */ jsx(Fragment, { children: svgElements(shapes) });
25
+ }
26
+ /** SVG attribute names as React's props: `stroke-width` is `strokeWidth`. */
27
+ function reactProps(attributes) {
28
+ return Object.fromEntries(Object.entries(attributes).map(([name, value]) => [name.replace(/-([a-z])/g, (_dash, letter) => letter.toUpperCase()), value]));
29
+ }
30
+ function svgElements(shapes) {
31
+ return shapes.map((shape, index) => React.createElement(shape.tag, {
32
+ key: index,
33
+ ...reactProps(shape.attributes),
34
+ ...shape.blend ? { style: { mixBlendMode: shape.blend } } : {}
35
+ }, shape.children ? svgElements(shape.children) : shape.text));
36
+ }
37
+ //#endregion
38
+ export { useFontMounts as n, SvgShapes as t };
39
+
40
+ //# sourceMappingURL=svg-shapes-Dm1yTR1b.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg-shapes-Dm1yTR1b.js","names":[],"sources":["../src/font-mounts.ts","../src/svg-shapes.tsx"],"sourcesContent":["/**\n * The engine's faces a part of a layer draws text in, mounted while it's\n * there (`@embedpdf/web`'s `createFontMounts`, one set per component).\n */\nimport { createFontMounts, type MountableFontProgram } from '@embedpdf/web';\nimport { useEffect, useState } from 'react';\n\nexport function useFontMounts(programs: readonly MountableFontProgram[]): void {\n const [mounts] = useState(() => createFontMounts());\n useEffect(() => () => mounts.release(), [mounts]);\n useEffect(() => mounts.mount(programs));\n}\n","/**\n * Scene shapes as React elements: `@embedpdf/web`'s element descriptions\n * (`svgShapesOf`), one element each, a clipping `svg` with its children, and\n * the faces their text draws in mounted while they show. The annotation and\n * form layers draw their scenes through it.\n */\nimport { fontProgramsOf, type SvgShape } from '@embedpdf/web';\nimport React from 'react';\n\nimport { useFontMounts } from './font-mounts';\n\nexport function SvgShapes({ shapes }: { shapes: readonly SvgShape[] }) {\n useFontMounts(fontProgramsOf(shapes));\n return <>{svgElements(shapes)}</>;\n}\n\n/** SVG attribute names as React's props: `stroke-width` is `strokeWidth`. */\nfunction reactProps(attributes: Readonly<Record<string, string | number>>) {\n return Object.fromEntries(\n Object.entries(attributes).map(([name, value]) => [\n name.replace(/-([a-z])/g, (_dash, letter: string) => letter.toUpperCase()),\n value,\n ]),\n );\n}\n\nfunction svgElements(shapes: readonly SvgShape[]): React.ReactNode[] {\n return shapes.map((shape, index) =>\n React.createElement(\n shape.tag,\n {\n key: index,\n ...reactProps(shape.attributes),\n ...(shape.blend\n ? { style: { mixBlendMode: shape.blend as React.CSSProperties['mixBlendMode'] } }\n : {}),\n },\n shape.children ? svgElements(shape.children) : shape.text,\n ),\n );\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,cAAc,UAAiD;CAC7E,MAAM,CAAC,UAAU,eAAe,iBAAiB,CAAC;CAClD,sBAAsB,OAAO,QAAQ,GAAG,CAAC,MAAM,CAAC;CAChD,gBAAgB,OAAO,MAAM,QAAQ,CAAC;AACxC;;;;;;;;;ACAA,SAAgB,UAAU,EAAE,UAA2C;CACrE,cAAc,eAAe,MAAM,CAAC;CACpC,OAAO,oBAAA,UAAA,EAAA,UAAG,YAAY,MAAM,EAAI,CAAA;AAClC;;AAGA,SAAS,WAAW,YAAuD;CACzE,OAAO,OAAO,YACZ,OAAO,QAAQ,UAAU,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CAChD,KAAK,QAAQ,cAAc,OAAO,WAAmB,OAAO,YAAY,CAAC,GACzE,KACF,CAAC,CACH;AACF;AAEA,SAAS,YAAY,QAAgD;CACnE,OAAO,OAAO,KAAK,OAAO,UACxB,MAAM,cACJ,MAAM,KACN;EACE,KAAK;EACL,GAAG,WAAW,MAAM,UAAU;EAC9B,GAAI,MAAM,QACN,EAAE,OAAO,EAAE,cAAc,MAAM,MAA6C,EAAE,IAC9E,CAAC;CACP,GACA,MAAM,WAAW,YAAY,MAAM,QAAQ,IAAI,MAAM,IACvD,CACF;AACF"}
@@ -0,0 +1,53 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-DDXJien1.cjs");
2
+ let react_jsx_runtime = require("react/jsx-runtime");
3
+ let _embedpdf_web = require("@embedpdf/web");
4
+ let react = require("react");
5
+ react = require_rolldown_runtime.__toESM(react, 1);
6
+ //#region src/font-mounts.ts
7
+ /**
8
+ * The engine's faces a part of a layer draws text in, mounted while it's
9
+ * there (`@embedpdf/web`'s `createFontMounts`, one set per component).
10
+ */
11
+ function useFontMounts(programs) {
12
+ const [mounts] = (0, react.useState)(() => (0, _embedpdf_web.createFontMounts)());
13
+ (0, react.useEffect)(() => () => mounts.release(), [mounts]);
14
+ (0, react.useEffect)(() => mounts.mount(programs));
15
+ }
16
+ //#endregion
17
+ //#region src/svg-shapes.tsx
18
+ /**
19
+ * Scene shapes as React elements: `@embedpdf/web`'s element descriptions
20
+ * (`svgShapesOf`), one element each, a clipping `svg` with its children, and
21
+ * the faces their text draws in mounted while they show. The annotation and
22
+ * form layers draw their scenes through it.
23
+ */
24
+ function SvgShapes({ shapes }) {
25
+ useFontMounts((0, _embedpdf_web.fontProgramsOf)(shapes));
26
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: svgElements(shapes) });
27
+ }
28
+ /** SVG attribute names as React's props: `stroke-width` is `strokeWidth`. */
29
+ function reactProps(attributes) {
30
+ return Object.fromEntries(Object.entries(attributes).map(([name, value]) => [name.replace(/-([a-z])/g, (_dash, letter) => letter.toUpperCase()), value]));
31
+ }
32
+ function svgElements(shapes) {
33
+ return shapes.map((shape, index) => react.default.createElement(shape.tag, {
34
+ key: index,
35
+ ...reactProps(shape.attributes),
36
+ ...shape.blend ? { style: { mixBlendMode: shape.blend } } : {}
37
+ }, shape.children ? svgElements(shape.children) : shape.text));
38
+ }
39
+ //#endregion
40
+ Object.defineProperty(exports, "SvgShapes", {
41
+ enumerable: true,
42
+ get: function() {
43
+ return SvgShapes;
44
+ }
45
+ });
46
+ Object.defineProperty(exports, "useFontMounts", {
47
+ enumerable: true,
48
+ get: function() {
49
+ return useFontMounts;
50
+ }
51
+ });
52
+
53
+ //# sourceMappingURL=svg-shapes-zo0GNkc9.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg-shapes-zo0GNkc9.cjs","names":["React"],"sources":["../src/font-mounts.ts","../src/svg-shapes.tsx"],"sourcesContent":["/**\n * The engine's faces a part of a layer draws text in, mounted while it's\n * there (`@embedpdf/web`'s `createFontMounts`, one set per component).\n */\nimport { createFontMounts, type MountableFontProgram } from '@embedpdf/web';\nimport { useEffect, useState } from 'react';\n\nexport function useFontMounts(programs: readonly MountableFontProgram[]): void {\n const [mounts] = useState(() => createFontMounts());\n useEffect(() => () => mounts.release(), [mounts]);\n useEffect(() => mounts.mount(programs));\n}\n","/**\n * Scene shapes as React elements: `@embedpdf/web`'s element descriptions\n * (`svgShapesOf`), one element each, a clipping `svg` with its children, and\n * the faces their text draws in mounted while they show. The annotation and\n * form layers draw their scenes through it.\n */\nimport { fontProgramsOf, type SvgShape } from '@embedpdf/web';\nimport React from 'react';\n\nimport { useFontMounts } from './font-mounts';\n\nexport function SvgShapes({ shapes }: { shapes: readonly SvgShape[] }) {\n useFontMounts(fontProgramsOf(shapes));\n return <>{svgElements(shapes)}</>;\n}\n\n/** SVG attribute names as React's props: `stroke-width` is `strokeWidth`. */\nfunction reactProps(attributes: Readonly<Record<string, string | number>>) {\n return Object.fromEntries(\n Object.entries(attributes).map(([name, value]) => [\n name.replace(/-([a-z])/g, (_dash, letter: string) => letter.toUpperCase()),\n value,\n ]),\n );\n}\n\nfunction svgElements(shapes: readonly SvgShape[]): React.ReactNode[] {\n return shapes.map((shape, index) =>\n React.createElement(\n shape.tag,\n {\n key: index,\n ...reactProps(shape.attributes),\n ...(shape.blend\n ? { style: { mixBlendMode: shape.blend as React.CSSProperties['mixBlendMode'] } }\n : {}),\n },\n shape.children ? svgElements(shape.children) : shape.text,\n ),\n );\n}\n"],"mappings":";;;;;;;;;;AAOA,SAAgB,cAAc,UAAiD;CAC7E,MAAM,CAAC,WAAA,GAAA,MAAA,SAAA,QAAA,GAAA,cAAA,iBAAA,CAA0C,CAAC;CAClD,CAAA,GAAA,MAAA,UAAA,aAAsB,OAAO,QAAQ,GAAG,CAAC,MAAM,CAAC;CAChD,CAAA,GAAA,MAAA,UAAA,OAAgB,OAAO,MAAM,QAAQ,CAAC;AACxC;;;;;;;;;ACAA,SAAgB,UAAU,EAAE,UAA2C;CACrE,eAAA,GAAA,cAAA,eAAA,CAA6B,MAAM,CAAC;CACpC,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAA,kBAAA,UAAA,EAAA,UAAG,YAAY,MAAM,EAAI,CAAA;AAClC;;AAGA,SAAS,WAAW,YAAuD;CACzE,OAAO,OAAO,YACZ,OAAO,QAAQ,UAAU,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CAChD,KAAK,QAAQ,cAAc,OAAO,WAAmB,OAAO,YAAY,CAAC,GACzE,KACF,CAAC,CACH;AACF;AAEA,SAAS,YAAY,QAAgD;CACnE,OAAO,OAAO,KAAK,OAAO,UACxBA,MAAAA,QAAM,cACJ,MAAM,KACN;EACE,KAAK;EACL,GAAG,WAAW,MAAM,UAAU;EAC9B,GAAI,MAAM,QACN,EAAE,OAAO,EAAE,cAAc,MAAM,MAA6C,EAAE,IAC9E,CAAC;CACP,GACA,MAAM,WAAW,YAAY,MAAM,QAAQ,IAAI,MAAM,IACvD,CACF;AACF"}