@embedpdf/svelte 0.0.0-stage → 3.0.0-next.16

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 (269) hide show
  1. package/LICENSE +192 -0
  2. package/README.md +312 -2
  3. package/dist/actions/readers.svelte.d.ts +29 -0
  4. package/dist/actions/readers.svelte.js +55 -0
  5. package/dist/actions.d.ts +13 -0
  6. package/dist/actions.js +13 -0
  7. package/dist/anchored/Anchored.svelte +24 -0
  8. package/dist/anchored/Anchored.svelte.d.ts +4 -0
  9. package/dist/anchored/PlacedAnchored.svelte +97 -0
  10. package/dist/anchored/PlacedAnchored.svelte.d.ts +4 -0
  11. package/dist/anchored/context.d.ts +31 -0
  12. package/dist/anchored/context.js +36 -0
  13. package/dist/anchored/props.d.ts +29 -0
  14. package/dist/anchored/props.js +1 -0
  15. package/dist/anchored.d.ts +12 -0
  16. package/dist/anchored.js +2 -0
  17. package/dist/annotation/AnnotationChrome.svelte +173 -0
  18. package/dist/annotation/AnnotationChrome.svelte.d.ts +11 -0
  19. package/dist/annotation/AnnotationDraftMenu.svelte +27 -0
  20. package/dist/annotation/AnnotationDraftMenu.svelte.d.ts +4 -0
  21. package/dist/annotation/AnnotationFrame.svelte +46 -0
  22. package/dist/annotation/AnnotationFrame.svelte.d.ts +15 -0
  23. package/dist/annotation/AnnotationLayer.svelte +241 -0
  24. package/dist/annotation/AnnotationLayer.svelte.d.ts +4 -0
  25. package/dist/annotation/AnnotationLook.svelte +67 -0
  26. package/dist/annotation/AnnotationLook.svelte.d.ts +21 -0
  27. package/dist/annotation/AnnotationMenu.svelte +47 -0
  28. package/dist/annotation/AnnotationMenu.svelte.d.ts +4 -0
  29. package/dist/annotation/AnnotationRotationBadge.svelte +52 -0
  30. package/dist/annotation/AnnotationRotationBadge.svelte.d.ts +4 -0
  31. package/dist/annotation/AnnotationScene.svelte +27 -0
  32. package/dist/annotation/AnnotationScene.svelte.d.ts +7 -0
  33. package/dist/annotation/FreeTextBox.svelte +51 -0
  34. package/dist/annotation/FreeTextBox.svelte.d.ts +9 -0
  35. package/dist/annotation/NativeDrawing.svelte +61 -0
  36. package/dist/annotation/NativeDrawing.svelte.d.ts +10 -0
  37. package/dist/annotation/StampGhost.svelte +79 -0
  38. package/dist/annotation/StampGhost.svelte.d.ts +7 -0
  39. package/dist/annotation/chrome-paint.svelte.d.ts +30 -0
  40. package/dist/annotation/chrome-paint.svelte.js +27 -0
  41. package/dist/annotation/props.d.ts +181 -0
  42. package/dist/annotation/props.js +1 -0
  43. package/dist/annotation/readers.svelte.d.ts +59 -0
  44. package/dist/annotation/readers.svelte.js +136 -0
  45. package/dist/annotation/state.d.ts +18 -0
  46. package/dist/annotation/state.js +20 -0
  47. package/dist/annotation/text-box.svelte.d.ts +28 -0
  48. package/dist/annotation/text-box.svelte.js +87 -0
  49. package/dist/annotation.d.ts +32 -0
  50. package/dist/annotation.js +31 -0
  51. package/dist/attachment/readers.d.ts +23 -0
  52. package/dist/attachment/readers.js +21 -0
  53. package/dist/attachment.d.ts +13 -0
  54. package/dist/attachment.js +14 -0
  55. package/dist/commands/readers.svelte.d.ts +50 -0
  56. package/dist/commands/readers.svelte.js +83 -0
  57. package/dist/commands.d.ts +9 -0
  58. package/dist/commands.js +9 -0
  59. package/dist/form/ButtonControl.svelte +38 -0
  60. package/dist/form/ButtonControl.svelte.d.ts +11 -0
  61. package/dist/form/ComboControl.svelte +52 -0
  62. package/dist/form/ComboControl.svelte.d.ts +11 -0
  63. package/dist/form/FieldPictures.svelte +145 -0
  64. package/dist/form/FieldPictures.svelte.d.ts +3 -0
  65. package/dist/form/FormFocusRing.svelte +25 -0
  66. package/dist/form/FormFocusRing.svelte.d.ts +8 -0
  67. package/dist/form/FormLayer.svelte +98 -0
  68. package/dist/form/FormLayer.svelte.d.ts +3 -0
  69. package/dist/form/ListControl.svelte +49 -0
  70. package/dist/form/ListControl.svelte.d.ts +11 -0
  71. package/dist/form/NativeListBox.svelte +57 -0
  72. package/dist/form/NativeListBox.svelte.d.ts +4 -0
  73. package/dist/form/SignatureControl.svelte +53 -0
  74. package/dist/form/SignatureControl.svelte.d.ts +11 -0
  75. package/dist/form/TextControl.svelte +107 -0
  76. package/dist/form/TextControl.svelte.d.ts +11 -0
  77. package/dist/form/ToggleControl.svelte +50 -0
  78. package/dist/form/ToggleControl.svelte.d.ts +11 -0
  79. package/dist/form/WidgetBox.svelte +82 -0
  80. package/dist/form/WidgetBox.svelte.d.ts +15 -0
  81. package/dist/form/props.d.ts +21 -0
  82. package/dist/form/props.js +1 -0
  83. package/dist/form/readers.svelte.d.ts +46 -0
  84. package/dist/form/readers.svelte.js +52 -0
  85. package/dist/form/widget.d.ts +16 -0
  86. package/dist/form/widget.js +20 -0
  87. package/dist/form.d.ts +11 -0
  88. package/dist/form.js +12 -0
  89. package/dist/history/readers.d.ts +22 -0
  90. package/dist/history/readers.js +21 -0
  91. package/dist/history.d.ts +10 -0
  92. package/dist/history.js +11 -0
  93. package/dist/i18n/readers.svelte.d.ts +32 -0
  94. package/dist/i18n/readers.svelte.js +30 -0
  95. package/dist/i18n.d.ts +8 -0
  96. package/dist/i18n.js +9 -0
  97. package/dist/index.d.ts +30 -0
  98. package/dist/index.js +30 -0
  99. package/dist/interaction/PagePointerSource.svelte +37 -0
  100. package/dist/interaction/PagePointerSource.svelte.d.ts +3 -0
  101. package/dist/interaction/readers.svelte.d.ts +26 -0
  102. package/dist/interaction/readers.svelte.js +47 -0
  103. package/dist/interaction.d.ts +11 -0
  104. package/dist/interaction.js +13 -0
  105. package/dist/link/LinkLayer.svelte +164 -0
  106. package/dist/link/LinkLayer.svelte.d.ts +4 -0
  107. package/dist/link/props.d.ts +17 -0
  108. package/dist/link/props.js +1 -0
  109. package/dist/link/readers.svelte.d.ts +18 -0
  110. package/dist/link/readers.svelte.js +38 -0
  111. package/dist/link.d.ts +11 -0
  112. package/dist/link.js +11 -0
  113. package/dist/measurement/readers.d.ts +44 -0
  114. package/dist/measurement/readers.js +46 -0
  115. package/dist/measurement.d.ts +12 -0
  116. package/dist/measurement.js +13 -0
  117. package/dist/metadata/readers.d.ts +22 -0
  118. package/dist/metadata/readers.js +22 -0
  119. package/dist/metadata.d.ts +12 -0
  120. package/dist/metadata.js +13 -0
  121. package/dist/outline/readers.d.ts +26 -0
  122. package/dist/outline/readers.js +22 -0
  123. package/dist/outline.d.ts +12 -0
  124. package/dist/outline.js +13 -0
  125. package/dist/page-edit/readers.d.ts +17 -0
  126. package/dist/page-edit/readers.js +18 -0
  127. package/dist/page-edit.d.ts +12 -0
  128. package/dist/page-edit.js +13 -0
  129. package/dist/page-view/PageView.svelte +192 -0
  130. package/dist/page-view/PageView.svelte.d.ts +4 -0
  131. package/dist/page-view/props.d.ts +32 -0
  132. package/dist/page-view/props.js +1 -0
  133. package/dist/page-view.d.ts +8 -0
  134. package/dist/page-view.js +7 -0
  135. package/dist/redaction/readers.d.ts +37 -0
  136. package/dist/redaction/readers.js +38 -0
  137. package/dist/redaction.d.ts +12 -0
  138. package/dist/redaction.js +13 -0
  139. package/dist/render/RenderLayer.svelte +116 -0
  140. package/dist/render/RenderLayer.svelte.d.ts +4 -0
  141. package/dist/render/TileImage.svelte +65 -0
  142. package/dist/render/TileImage.svelte.d.ts +11 -0
  143. package/dist/render/TilePlane.svelte +88 -0
  144. package/dist/render/TilePlane.svelte.d.ts +7 -0
  145. package/dist/render/props.d.ts +16 -0
  146. package/dist/render/props.js +1 -0
  147. package/dist/render/readers.svelte.d.ts +9 -0
  148. package/dist/render/readers.svelte.js +13 -0
  149. package/dist/render.d.ts +10 -0
  150. package/dist/render.js +10 -0
  151. package/dist/runtime/DocumentGate.svelte +26 -0
  152. package/dist/runtime/DocumentGate.svelte.d.ts +4 -0
  153. package/dist/runtime/DocumentScope.svelte +14 -0
  154. package/dist/runtime/DocumentScope.svelte.d.ts +4 -0
  155. package/dist/runtime/KernelProvider.svelte +33 -0
  156. package/dist/runtime/KernelProvider.svelte.d.ts +4 -0
  157. package/dist/runtime/SvgShapes.svelte +30 -0
  158. package/dist/runtime/SvgShapes.svelte.d.ts +8 -0
  159. package/dist/runtime/Viewer.svelte +130 -0
  160. package/dist/runtime/Viewer.svelte.d.ts +4 -0
  161. package/dist/runtime/binding.svelte.d.ts +33 -0
  162. package/dist/runtime/binding.svelte.js +71 -0
  163. package/dist/runtime/capability-handle.d.ts +6 -0
  164. package/dist/runtime/capability-handle.js +71 -0
  165. package/dist/runtime/dev.d.ts +10 -0
  166. package/dist/runtime/dev.js +23 -0
  167. package/dist/runtime/documents.svelte.d.ts +34 -0
  168. package/dist/runtime/documents.svelte.js +49 -0
  169. package/dist/runtime/page-layers.svelte.d.ts +20 -0
  170. package/dist/runtime/page-layers.svelte.js +40 -0
  171. package/dist/runtime/page.d.ts +10 -0
  172. package/dist/runtime/page.js +23 -0
  173. package/dist/runtime/props.d.ts +63 -0
  174. package/dist/runtime/props.js +1 -0
  175. package/dist/runtime/readers.svelte.d.ts +47 -0
  176. package/dist/runtime/readers.svelte.js +122 -0
  177. package/dist/runtime/state.svelte.d.ts +35 -0
  178. package/dist/runtime/state.svelte.js +90 -0
  179. package/dist/runtime/theme.d.ts +12 -0
  180. package/dist/runtime/theme.js +15 -0
  181. package/dist/runtime/values.svelte.d.ts +28 -0
  182. package/dist/runtime/values.svelte.js +51 -0
  183. package/dist/runtime.d.ts +26 -0
  184. package/dist/runtime.js +25 -0
  185. package/dist/search/SearchLayer.svelte +94 -0
  186. package/dist/search/SearchLayer.svelte.d.ts +4 -0
  187. package/dist/search/props.d.ts +11 -0
  188. package/dist/search/props.js +1 -0
  189. package/dist/search/readers.svelte.d.ts +41 -0
  190. package/dist/search/readers.svelte.js +40 -0
  191. package/dist/search.d.ts +11 -0
  192. package/dist/search.js +11 -0
  193. package/dist/selection/SelectionClipboard.svelte +35 -0
  194. package/dist/selection/SelectionClipboard.svelte.d.ts +4 -0
  195. package/dist/selection/SelectionHandles.svelte +192 -0
  196. package/dist/selection/SelectionHandles.svelte.d.ts +4 -0
  197. package/dist/selection/SelectionLayer.svelte +67 -0
  198. package/dist/selection/SelectionLayer.svelte.d.ts +3 -0
  199. package/dist/selection/SelectionMenu.svelte +36 -0
  200. package/dist/selection/SelectionMenu.svelte.d.ts +4 -0
  201. package/dist/selection/props.d.ts +26 -0
  202. package/dist/selection/props.js +1 -0
  203. package/dist/selection/readers.svelte.d.ts +31 -0
  204. package/dist/selection/readers.svelte.js +26 -0
  205. package/dist/selection.d.ts +16 -0
  206. package/dist/selection.js +18 -0
  207. package/dist/shell/readers.svelte.d.ts +40 -0
  208. package/dist/shell/readers.svelte.js +40 -0
  209. package/dist/shell/surface-focus.svelte.d.ts +16 -0
  210. package/dist/shell/surface-focus.svelte.js +33 -0
  211. package/dist/shell.d.ts +12 -0
  212. package/dist/shell.js +11 -0
  213. package/dist/signature/readers.svelte.d.ts +43 -0
  214. package/dist/signature/readers.svelte.js +46 -0
  215. package/dist/signature.d.ts +15 -0
  216. package/dist/signature.js +16 -0
  217. package/dist/stage/PageSurface.svelte +126 -0
  218. package/dist/stage/PageSurface.svelte.d.ts +18 -0
  219. package/dist/stage/Scrollbar.svelte +148 -0
  220. package/dist/stage/Scrollbar.svelte.d.ts +4 -0
  221. package/dist/stage/Stage.svelte +181 -0
  222. package/dist/stage/Stage.svelte.d.ts +4 -0
  223. package/dist/stage/StageScope.svelte +14 -0
  224. package/dist/stage/StageScope.svelte.d.ts +9 -0
  225. package/dist/stage/props.d.ts +71 -0
  226. package/dist/stage/props.js +1 -0
  227. package/dist/stage/readers.svelte.d.ts +39 -0
  228. package/dist/stage/readers.svelte.js +84 -0
  229. package/dist/stage/stage-scope.d.ts +18 -0
  230. package/dist/stage/stage-scope.js +35 -0
  231. package/dist/stage/two-way.svelte.d.ts +13 -0
  232. package/dist/stage/two-way.svelte.js +26 -0
  233. package/dist/stage.d.ts +17 -0
  234. package/dist/stage.js +15 -0
  235. package/dist/stamp/readers.svelte.d.ts +50 -0
  236. package/dist/stamp/readers.svelte.js +76 -0
  237. package/dist/stamp.d.ts +16 -0
  238. package/dist/stamp.js +18 -0
  239. package/dist/toolbar/DefaultCollapsed.svelte +39 -0
  240. package/dist/toolbar/DefaultCollapsed.svelte.d.ts +9 -0
  241. package/dist/toolbar/DefaultCommand.svelte +33 -0
  242. package/dist/toolbar/DefaultCommand.svelte.d.ts +8 -0
  243. package/dist/toolbar/DefaultGroupTrigger.svelte +39 -0
  244. package/dist/toolbar/DefaultGroupTrigger.svelte.d.ts +9 -0
  245. package/dist/toolbar/DefaultOverflowMenu.svelte +106 -0
  246. package/dist/toolbar/DefaultOverflowMenu.svelte.d.ts +9 -0
  247. package/dist/toolbar/DefaultOverflowTrigger.svelte +25 -0
  248. package/dist/toolbar/DefaultOverflowTrigger.svelte.d.ts +7 -0
  249. package/dist/toolbar/Measured.svelte +46 -0
  250. package/dist/toolbar/Measured.svelte.d.ts +11 -0
  251. package/dist/toolbar/NativeSlotSocket.svelte +43 -0
  252. package/dist/toolbar/NativeSlotSocket.svelte.d.ts +11 -0
  253. package/dist/toolbar/Toolbar.svelte +314 -0
  254. package/dist/toolbar/Toolbar.svelte.d.ts +4 -0
  255. package/dist/toolbar/paint.d.ts +3 -0
  256. package/dist/toolbar/paint.js +9 -0
  257. package/dist/toolbar/props.d.ts +48 -0
  258. package/dist/toolbar/props.js +1 -0
  259. package/dist/toolbar/strip.svelte.d.ts +14 -0
  260. package/dist/toolbar/strip.svelte.js +35 -0
  261. package/dist/toolbar/views.d.ts +14 -0
  262. package/dist/toolbar/views.js +1 -0
  263. package/dist/toolbar.d.ts +16 -0
  264. package/dist/toolbar.js +12 -0
  265. package/dist/view-manager/readers.d.ts +19 -0
  266. package/dist/view-manager/readers.js +17 -0
  267. package/dist/view-manager.d.ts +11 -0
  268. package/dist/view-manager.js +12 -0
  269. package/package.json +207 -3
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The form plugin's readers: `useForm()` (the API), the state and the settings, `useFormEvent()`,
3
+ * `useFormValue()` (one field's value), and the colors `<FormLayer>` draws fields with.
4
+ */
5
+ import type { EventHook } from '@embedpdf/core';
6
+ import type { FormCapability, FormFieldRef, FormFieldValue } from '@embedpdf/plugin-form';
7
+ import { type FormColors } from '@embedpdf/web';
8
+ import { type CurrentValue, type MaybeGetter } from '../runtime/values.svelte.js';
9
+ /**
10
+ * The form API for the document in scope: reading, filling, form data and building. A handle:
11
+ * always the capability of the document in scope, so keep it whole (`form.setValue(…)`).
12
+ */
13
+ export declare function useForm(): FormCapability;
14
+ /**
15
+ * Subscribe to one form event while the component lives:
16
+ * `useFormEvent((form) => form.onValueChanged, handler)`.
17
+ */
18
+ export declare function useFormEvent<T>(select: (form: FormCapability) => EventHook<T>, handler: (event: T) => void): void;
19
+ /**
20
+ * The form's state: every field (`fields`), whether it's read (`status`), what kind of form the
21
+ * document has (`formKind`), and the field of the selected widget (`selectedField`), declared
22
+ * once in `formState`. A reactive object (`state.fields`), or with a selector one value as
23
+ * `{ current }` that changes only when what it picks changes. Empty without a document.
24
+ */
25
+ export declare const useFormState: import("../index.js").StateReader<{
26
+ fields: readonly import("@embedpdf/plugin-form").FormFieldDTO[];
27
+ status: import("@embedpdf/core").ResourceStatus;
28
+ formKind: import("@embedpdf/plugin-form").FormKind;
29
+ selectedField: import("@embedpdf/plugin-form").FormFieldDTO | null;
30
+ }>;
31
+ /**
32
+ * The form settings (`validation`, `focus`, `fields`), with or without a document. They belong
33
+ * to the plugin; change them with `useForm().updateSettings()`.
34
+ */
35
+ export declare const useFormSettings: import("../index.js").SettingsReader<import("@embedpdf/plugin-form").FormSettings & object>;
36
+ /**
37
+ * One field's value, in the shape `setValue()` takes, or `null`, as `{ current }`: it changes
38
+ * only when that field's value changes. Pass a function (`() => ref`) for a field that changes.
39
+ * `null` without a document.
40
+ */
41
+ export declare function useFormValue(ref: MaybeGetter<FormFieldRef>): CurrentValue<FormFieldValue | null>;
42
+ /**
43
+ * The colors the layer draws fields with: the form settings over the viewer's accent, each a
44
+ * `var(--epdf-form-*)` first, so CSS wins.
45
+ */
46
+ export declare function useFormColors(): CurrentValue<FormColors>;
@@ -0,0 +1,52 @@
1
+ import { FormToken, formState } from '@embedpdf/plugin-form';
2
+ import { formColorsOf } from '@embedpdf/web';
3
+ import { useViewerSettings } from '../runtime/documents.svelte.js';
4
+ import { useCapability, useCapabilityEvent, useOptionalSelector, } from '../runtime/readers.svelte.js';
5
+ import { settingsReader, stateReader } from '../runtime/state.svelte.js';
6
+ import { currentOf, derivedValue, valueOf, } from '../runtime/values.svelte.js';
7
+ /**
8
+ * The form API for the document in scope: reading, filling, form data and building. A handle:
9
+ * always the capability of the document in scope, so keep it whole (`form.setValue(…)`).
10
+ */
11
+ export function useForm() {
12
+ return useCapability(FormToken);
13
+ }
14
+ /**
15
+ * Subscribe to one form event while the component lives:
16
+ * `useFormEvent((form) => form.onValueChanged, handler)`.
17
+ */
18
+ export function useFormEvent(select, handler) {
19
+ useCapabilityEvent(FormToken, select, handler);
20
+ }
21
+ /**
22
+ * The form's state: every field (`fields`), whether it's read (`status`), what kind of form the
23
+ * document has (`formKind`), and the field of the selected widget (`selectedField`), declared
24
+ * once in `formState`. A reactive object (`state.fields`), or with a selector one value as
25
+ * `{ current }` that changes only when what it picks changes. Empty without a document.
26
+ */
27
+ export const useFormState = stateReader(formState);
28
+ /**
29
+ * The form settings (`validation`, `focus`, `fields`), with or without a document. They belong
30
+ * to the plugin; change them with `useForm().updateSettings()`.
31
+ */
32
+ export const useFormSettings = settingsReader(FormToken);
33
+ /**
34
+ * One field's value, in the shape `setValue()` takes, or `null`, as `{ current }`: it changes
35
+ * only when that field's value changes. Pass a function (`() => ref`) for a field that changes.
36
+ * `null` without a document.
37
+ */
38
+ export function useFormValue(ref) {
39
+ // The plugin keeps one value object per field until the field changes, so a reference
40
+ // comparison is enough.
41
+ return useOptionalSelector(FormToken, (form) => form.getValue(valueOf(ref)), null);
42
+ }
43
+ /**
44
+ * The colors the layer draws fields with: the form settings over the viewer's accent, each a
45
+ * `var(--epdf-form-*)` first, so CSS wins.
46
+ */
47
+ export function useFormColors() {
48
+ const accent = useViewerSettings((settings) => settings.accent);
49
+ const focus = useFormSettings((settings) => settings.focus);
50
+ const fields = useFormSettings((settings) => settings.fields);
51
+ return currentOf(derivedValue(() => formColorsOf({ focus: focus.current, fields: fields.current }, accent.current)));
52
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * What every control of `<FormLayer>` shares besides its box (`WidgetBox.svelte`): running the
3
+ * widget's action on a click, and the style of a control that fills the box, as CSS text. A
4
+ * Svelte `style` attribute is a string, while `@embedpdf/web` hands styles out as records
5
+ * (`cssText` writes one as text).
6
+ */
7
+ import type { FormWidgetItem } from '@embedpdf/plugin-form';
8
+ /**
9
+ * A click on a widget runs its `/A` action. ISO 32000 puts the activate action on the widget,
10
+ * whatever its field, and many forms ship "buttons" as read-only text fields with an `/A` that
11
+ * Acrobat runs; a widget without one is inert. The widget's address is read at the click: the
12
+ * engine gives a widget it has just placed its address later.
13
+ */
14
+ export declare function useWidgetActivation(annotationRef: () => FormWidgetItem['annotationRef']): () => void;
15
+ /** Fills the box it sits in, as CSS text. */
16
+ export declare const FILL: string;
@@ -0,0 +1,20 @@
1
+ // The layer's lens on the plugin: the same capability, typed wider for the framework layers.
2
+ import { FormToken as FormHostToken } from '@embedpdf/plugin-form/contract/host';
3
+ import { cssText, FORM_CONTROL_FILL } from '@embedpdf/web';
4
+ import { useCapability } from '../runtime/readers.svelte.js';
5
+ /**
6
+ * A click on a widget runs its `/A` action. ISO 32000 puts the activate action on the widget,
7
+ * whatever its field, and many forms ship "buttons" as read-only text fields with an `/A` that
8
+ * Acrobat runs; a widget without one is inert. The widget's address is read at the click: the
9
+ * engine gives a widget it has just placed its address later.
10
+ */
11
+ export function useWidgetActivation(annotationRef) {
12
+ const form = useCapability(FormHostToken);
13
+ return () => {
14
+ const target = annotationRef();
15
+ if (target)
16
+ void form.activateWidget(target);
17
+ };
18
+ }
19
+ /** Fills the box it sits in, as CSS text. */
20
+ export const FILL = cssText(FORM_CONTROL_FILL);
package/dist/form.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @embedpdf/svelte/form — filling and building forms.
3
+ *
4
+ * `<FormLayer>` puts a real HTML control over each field of its page, for people to fill in;
5
+ * `useForm()` reads, fills and builds the form from code; `useFormState()` follows the fields as
6
+ * a reactive object, `useFormValue()` one field's value as `{ current }`, `useFormSettings()` the
7
+ * settings, and `useFormEvent()` the plugin's events.
8
+ */
9
+ export * from '@embedpdf/plugin-form';
10
+ export { default as FormLayer } from './form/FormLayer.svelte';
11
+ export { useForm, useFormEvent, useFormSettings, useFormState, useFormValue, } from './form/readers.svelte.js';
package/dist/form.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @embedpdf/svelte/form — filling and building forms.
3
+ *
4
+ * `<FormLayer>` puts a real HTML control over each field of its page, for people to fill in;
5
+ * `useForm()` reads, fills and builds the form from code; `useFormState()` follows the fields as
6
+ * a reactive object, `useFormValue()` one field's value as `{ current }`, `useFormSettings()` the
7
+ * settings, and `useFormEvent()` the plugin's events.
8
+ */
9
+ // Registration travels with the UI.
10
+ export * from '@embedpdf/plugin-form';
11
+ export { default as FormLayer } from './form/FormLayer.svelte';
12
+ export { useForm, useFormEvent, useFormSettings, useFormState, useFormValue, } from './form/readers.svelte.js';
@@ -0,0 +1,22 @@
1
+ /** The history's readers: the API, the state declared once in `historyState`, and its events. */
2
+ import type { EventHook } from '@embedpdf/core';
3
+ import type { HistoryCapability } from '@embedpdf/plugin-history';
4
+ /**
5
+ * The history API (`undo`, `redo`, `canUndo`, `canRedo`, the labels, `clear`) of the nearest
6
+ * `<DocumentScope>`'s document, else the active one. Outside a ready document, every method
7
+ * throws `not-ready`. `canUndo()` is a read, so `disabled={!history.canUndo()}` updates by itself.
8
+ */
9
+ export declare function useHistory(): HistoryCapability;
10
+ /**
11
+ * Whether undo and redo can run, and what they would undo and redo (the page's State table,
12
+ * declared once in `historyState`), as a reactive object: `state.canUndo`. With a selector, the
13
+ * value it picks as `{ current }`, which changes only when that value does.
14
+ */
15
+ export declare const useHistoryState: import("../index.js").StateReader<{
16
+ canUndo: boolean;
17
+ canRedo: boolean;
18
+ undoLabel: import("@embedpdf/core").ChangeLabel | null;
19
+ redoLabel: import("@embedpdf/core").ChangeLabel | null;
20
+ }>;
21
+ /** Subscribe to one history event while the component lives: `useHistoryEvent((history) => history.onUndone, handler)`. */
22
+ export declare function useHistoryEvent<T>(select: (history: HistoryCapability) => EventHook<T>, handler: (event: T) => void): void;
@@ -0,0 +1,21 @@
1
+ import { HistoryToken, historyState } from '@embedpdf/plugin-history';
2
+ import { useCapability, useCapabilityEvent } from '../runtime/readers.svelte.js';
3
+ import { stateReader } from '../runtime/state.svelte.js';
4
+ /**
5
+ * The history API (`undo`, `redo`, `canUndo`, `canRedo`, the labels, `clear`) of the nearest
6
+ * `<DocumentScope>`'s document, else the active one. Outside a ready document, every method
7
+ * throws `not-ready`. `canUndo()` is a read, so `disabled={!history.canUndo()}` updates by itself.
8
+ */
9
+ export function useHistory() {
10
+ return useCapability(HistoryToken);
11
+ }
12
+ /**
13
+ * Whether undo and redo can run, and what they would undo and redo (the page's State table,
14
+ * declared once in `historyState`), as a reactive object: `state.canUndo`. With a selector, the
15
+ * value it picks as `{ current }`, which changes only when that value does.
16
+ */
17
+ export const useHistoryState = stateReader(historyState);
18
+ /** Subscribe to one history event while the component lives: `useHistoryEvent((history) => history.onUndone, handler)`. */
19
+ export function useHistoryEvent(select, handler) {
20
+ useCapabilityEvent(HistoryToken, select, handler);
21
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @embedpdf/svelte/history — undo and redo of what you change through the viewer, one history
3
+ * per open document. An action shows undone at once, even while it is still on its way:
4
+ *
5
+ * const history = useHistory();
6
+ * const state = useHistoryState(); // state.canUndo, state.undoLabel, …
7
+ * <button disabled={!state.canUndo} onclick={() => history.undo()}>Undo</button>
8
+ */
9
+ export * from '@embedpdf/plugin-history';
10
+ export { useHistory, useHistoryEvent, useHistoryState } from './history/readers.js';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @embedpdf/svelte/history — undo and redo of what you change through the viewer, one history
3
+ * per open document. An action shows undone at once, even while it is still on its way:
4
+ *
5
+ * const history = useHistory();
6
+ * const state = useHistoryState(); // state.canUndo, state.undoLabel, …
7
+ * <button disabled={!state.canUndo} onclick={() => history.undo()}>Undo</button>
8
+ */
9
+ // Registration travels with the UI.
10
+ export * from '@embedpdf/plugin-history';
11
+ export { useHistory, useHistoryEvent, useHistoryState } from './history/readers.js';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The i18n plugin's readers. The plugin belongs to the workspace and needs no engine, so they
3
+ * work from the first frame, before a document opens: a loading screen and a password prompt
4
+ * translate too.
5
+ */
6
+ import type { EventHook } from '@embedpdf/core';
7
+ import type { I18nCapability, TranslateOptions } from '@embedpdf/plugin-i18n';
8
+ /** The i18n API: `t`, `setLocale`, `addTranslations`, `registerLocale`, the settings calls. */
9
+ export declare function useI18n(): I18nCapability;
10
+ /** Subscribe to one i18n event while the component lives: `useI18nEvent((i18n) => i18n.onLocaleChanged, handler)`. */
11
+ export declare function useI18nEvent<T>(select: (i18n: I18nCapability) => EventHook<T>, handler: (event: T) => void): void;
12
+ /**
13
+ * The current language, how it reads, every language you can switch to, and the one loading
14
+ * (declared once in `i18nState`), as a reactive object (`useI18nState().direction`). Takes a
15
+ * selector.
16
+ */
17
+ export declare const useI18nState: import("../index.js").StateReader<{
18
+ locale: string;
19
+ direction: import("@embedpdf/plugin-i18n").TextDirection;
20
+ locales: readonly import("@embedpdf/plugin-i18n").LocaleInfo[];
21
+ loading: string | null;
22
+ }>;
23
+ /** The i18n settings (`locale`, `fallbackLocale`, `locales`, `loaders`). Takes a selector. */
24
+ export declare const useI18nSettings: import("../index.js").SettingsReader<import("@embedpdf/plugin-i18n").I18nSettings & object>;
25
+ /**
26
+ * A translate function that reads the current language each time it's called, so a template, a
27
+ * `$derived` or an effect that calls it updates when the language or the strings change:
28
+ *
29
+ * const t = useT();
30
+ * <span>{t('search.results', { params: { count } })}</span>
31
+ */
32
+ export declare function useT(): (key: string, options?: TranslateOptions) => string;
@@ -0,0 +1,30 @@
1
+ import { I18nToken, i18nState } from '@embedpdf/plugin-i18n';
2
+ import { useCapability, useCapabilityEvent, useSelector } from '../runtime/readers.svelte.js';
3
+ import { settingsReader, stateReader } from '../runtime/state.svelte.js';
4
+ /** The i18n API: `t`, `setLocale`, `addTranslations`, `registerLocale`, the settings calls. */
5
+ export function useI18n() {
6
+ return useCapability(I18nToken);
7
+ }
8
+ /** Subscribe to one i18n event while the component lives: `useI18nEvent((i18n) => i18n.onLocaleChanged, handler)`. */
9
+ export function useI18nEvent(select, handler) {
10
+ useCapabilityEvent(I18nToken, select, handler);
11
+ }
12
+ /**
13
+ * The current language, how it reads, every language you can switch to, and the one loading
14
+ * (declared once in `i18nState`), as a reactive object (`useI18nState().direction`). Takes a
15
+ * selector.
16
+ */
17
+ export const useI18nState = stateReader(i18nState);
18
+ /** The i18n settings (`locale`, `fallbackLocale`, `locales`, `loaders`). Takes a selector. */
19
+ export const useI18nSettings = settingsReader(I18nToken);
20
+ /**
21
+ * A translate function that reads the current language each time it's called, so a template, a
22
+ * `$derived` or an effect that calls it updates when the language or the strings change:
23
+ *
24
+ * const t = useT();
25
+ * <span>{t('search.results', { params: { count } })}</span>
26
+ */
27
+ export function useT() {
28
+ const translator = useSelector(I18nToken, (i18n) => i18n.getTranslator());
29
+ return (key, options) => translator.current(key, options);
30
+ }
package/dist/i18n.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @embedpdf/svelte/i18n — your viewer in the reader's language.
3
+ *
4
+ * The readers are the i18n plugin's API, state, settings and events; `useT()` gives a translate
5
+ * function that follows the language.
6
+ */
7
+ export * from '@embedpdf/plugin-i18n';
8
+ export { useI18n, useI18nEvent, useI18nSettings, useI18nState, useT } from './i18n/readers.svelte.js';
package/dist/i18n.js ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @embedpdf/svelte/i18n — your viewer in the reader's language.
3
+ *
4
+ * The readers are the i18n plugin's API, state, settings and events; `useT()` gives a translate
5
+ * function that follows the language.
6
+ */
7
+ // Registration travels with the UI.
8
+ export * from '@embedpdf/plugin-i18n';
9
+ export { useI18n, useI18nEvent, useI18nSettings, useI18nState, useT } from './i18n/readers.svelte.js';
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @embedpdf/svelte — every entry point at once. Apps import per feature
3
+ * (`@embedpdf/svelte/stage`), so a plugin they don't use stays out of the bundle.
4
+ */
5
+ export * from './runtime.js';
6
+ export * from './anchored.js';
7
+ export * from './stage.js';
8
+ export * from './render.js';
9
+ export * from './interaction.js';
10
+ export * from './commands.js';
11
+ export * from './toolbar.js';
12
+ export * from './shell.js';
13
+ export * from './i18n.js';
14
+ export * from './page-view.js';
15
+ export * from './selection.js';
16
+ export * from './search.js';
17
+ export * from './link.js';
18
+ export * from './actions.js';
19
+ export * from './view-manager.js';
20
+ export * from './page-edit.js';
21
+ export * from './metadata.js';
22
+ export * from './outline.js';
23
+ export * from './attachment.js';
24
+ export * from './history.js';
25
+ export * from './annotation.js';
26
+ export * from './redaction.js';
27
+ export * from './measurement.js';
28
+ export * from './stamp.js';
29
+ export * from './form.js';
30
+ export * from './signature.js';
package/dist/index.js ADDED
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @embedpdf/svelte — every entry point at once. Apps import per feature
3
+ * (`@embedpdf/svelte/stage`), so a plugin they don't use stays out of the bundle.
4
+ */
5
+ export * from './runtime.js';
6
+ export * from './anchored.js';
7
+ export * from './stage.js';
8
+ export * from './render.js';
9
+ export * from './interaction.js';
10
+ export * from './commands.js';
11
+ export * from './toolbar.js';
12
+ export * from './shell.js';
13
+ export * from './i18n.js';
14
+ export * from './page-view.js';
15
+ export * from './selection.js';
16
+ export * from './search.js';
17
+ export * from './link.js';
18
+ export * from './actions.js';
19
+ export * from './view-manager.js';
20
+ export * from './page-edit.js';
21
+ export * from './metadata.js';
22
+ export * from './outline.js';
23
+ export * from './attachment.js';
24
+ export * from './history.js';
25
+ export * from './annotation.js';
26
+ export * from './redaction.js';
27
+ export * from './measurement.js';
28
+ export * from './stamp.js';
29
+ export * from './form.js';
30
+ export * from './signature.js';
@@ -0,0 +1,37 @@
1
+ <!--
2
+ The one pointer listener per page: it turns pointer events into page points through the page
3
+ context and hands them to the interaction plugin. It binds only to the page context, so it
4
+ works the same on a Stage page and on a `<PageView>`. Features never listen to the pointer
5
+ themselves: they register handlers with the interaction plugin, and a tool of your own brings
6
+ its pointer methods (`registerTool`).
7
+ -->
8
+ <script lang="ts">
9
+ import { untrack } from 'svelte';
10
+ import { InteractionToken } from '@embedpdf/plugin-interaction/contract/host';
11
+ import { attachPagePointer } from '@embedpdf/web';
12
+ import { usePage } from '../runtime/page.js';
13
+ import { useOptionalCapability, useOptionalSelector } from '../runtime/readers.svelte.js';
14
+
15
+ const page = usePage();
16
+ // The pointer source is a host of the interaction plugin: it dispatches samples.
17
+ const interaction = useOptionalCapability(InteractionToken);
18
+ const cursor = useOptionalSelector(InteractionToken, (hub) => hub.getCursor(), 'default');
19
+
20
+ let element: HTMLDivElement | undefined;
21
+
22
+ // The listener is `@embedpdf/web`'s, shared with every framework. It reads the page when an
23
+ // event arrives: a zoom changes it, and a drag carries on through it.
24
+ $effect(() => {
25
+ const hub = interaction.current;
26
+ const target = element;
27
+ if (!hub || !target) return;
28
+ return untrack(() => attachPagePointer(target, hub, () => page));
29
+ });
30
+ </script>
31
+
32
+ <!-- On top, as the page's event surface; the drawing layers below take no pointer events. -->
33
+ <div
34
+ bind:this={element}
35
+ style="position: absolute; inset: 0; touch-action: none"
36
+ style:cursor={cursor.current}
37
+ ></div>
@@ -0,0 +1,3 @@
1
+ declare const PagePointerSource: import("svelte").Component<Record<string, never>, {}, "">;
2
+ type PagePointerSource = ReturnType<typeof PagePointerSource>;
3
+ export default PagePointerSource;
@@ -0,0 +1,26 @@
1
+ import type { EventHook } from '@embedpdf/core';
2
+ import type { InteractionCapability } from '@embedpdf/plugin-interaction';
3
+ import { type ToolCursorSpec } from '@embedpdf/web';
4
+ import { type MaybeGetter } from '../runtime/values.svelte.js';
5
+ /** The interaction API: switch tools, add your own, set their cursors. */
6
+ export declare function useInteraction(): InteractionCapability;
7
+ /** Subscribe to one interaction event while the component lives: `useInteractionEvent((interaction) => interaction.onToolChanged, handler)`. */
8
+ export declare function useInteractionEvent<T>(select: (interaction: InteractionCapability) => EventHook<T>, handler: (event: T) => void): void;
9
+ /**
10
+ * The tools' state: the active tool's id and every tool you can switch to (declared once in
11
+ * `interactionState`). Without a document there is no active tool (`null`) and no tool.
12
+ */
13
+ export declare const useInteractionState: import("../index.js").StateReader<{
14
+ activeToolId: import("@embedpdf/plugin-interaction").ToolId | null;
15
+ tools: readonly import("@embedpdf/plugin-interaction").Tool[];
16
+ }>;
17
+ /** The interaction settings (`defaultTool`, `tools`), with or without a document. */
18
+ export declare const useInteractionSettings: import("../index.js").SettingsReader<import("@embedpdf/plugin-interaction").InteractionSettings & object>;
19
+ /**
20
+ * Give a tool image cursors: the armed-tool indicator. The interaction plugin already decides
21
+ * which cursor shows (hover claims over annotations and text win, page gaps show the tool's
22
+ * `gapCursor`), so nothing chases the pointer in the DOM. Pass a function, so the cursor follows
23
+ * what it reads (a color); `null` installs nothing. Going away restores the tool's own cursors.
24
+ * Without a document it installs nothing until one is ready.
25
+ */
26
+ export declare function useToolCursor(spec: MaybeGetter<ToolCursorSpec | null>): void;
@@ -0,0 +1,47 @@
1
+ /** The interaction plugin's readers: its API, state, settings and events, and tool cursors. */
2
+ import { untrack } from 'svelte';
3
+ import { InteractionToken, interactionState } from '@embedpdf/plugin-interaction';
4
+ import { InteractionToken as InteractionHostToken } from '@embedpdf/plugin-interaction/contract/host';
5
+ import { toolCursorsOf } from '@embedpdf/web';
6
+ import { useCapability, useCapabilityEvent, useOptionalCapability, } from '../runtime/readers.svelte.js';
7
+ import { settingsReader, stateReader } from '../runtime/state.svelte.js';
8
+ import { valueOf } from '../runtime/values.svelte.js';
9
+ /** The interaction API: switch tools, add your own, set their cursors. */
10
+ export function useInteraction() {
11
+ return useCapability(InteractionToken);
12
+ }
13
+ /** Subscribe to one interaction event while the component lives: `useInteractionEvent((interaction) => interaction.onToolChanged, handler)`. */
14
+ export function useInteractionEvent(select, handler) {
15
+ useCapabilityEvent(InteractionToken, select, handler);
16
+ }
17
+ /**
18
+ * The tools' state: the active tool's id and every tool you can switch to (declared once in
19
+ * `interactionState`). Without a document there is no active tool (`null`) and no tool.
20
+ */
21
+ export const useInteractionState = stateReader(interactionState);
22
+ /** The interaction settings (`defaultTool`, `tools`), with or without a document. */
23
+ export const useInteractionSettings = settingsReader(InteractionToken);
24
+ /**
25
+ * Give a tool image cursors: the armed-tool indicator. The interaction plugin already decides
26
+ * which cursor shows (hover claims over annotations and text win, page gaps show the tool's
27
+ * `gapCursor`), so nothing chases the pointer in the DOM. Pass a function, so the cursor follows
28
+ * what it reads (a color); `null` installs nothing. Going away restores the tool's own cursors.
29
+ * Without a document it installs nothing until one is ready.
30
+ */
31
+ export function useToolCursor(spec) {
32
+ const interaction = useOptionalCapability(InteractionHostToken);
33
+ // By value: a function builds a fresh object every time, and an identical one must not
34
+ // replace the cursor.
35
+ const key = $derived.by(() => {
36
+ const current = valueOf(spec);
37
+ return current ? JSON.stringify(current) : null;
38
+ });
39
+ $effect(() => {
40
+ const host = interaction.current;
41
+ if (!host || key === null)
42
+ return;
43
+ const cursorSpec = untrack(() => valueOf(spec));
44
+ untrack(() => host.setToolCursor(cursorSpec.toolId, toolCursorsOf(cursorSpec.cursors)));
45
+ return () => host.setToolCursor(cursorSpec.toolId, null);
46
+ });
47
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @embedpdf/svelte/interaction — pointer input and tools.
3
+ *
4
+ * `<PagePointerSource>` is the one pointer listener per page; the readers are the interaction
5
+ * plugin's API, state, settings and events, and `useToolCursor()` gives a tool its cursors.
6
+ */
7
+ export * from '@embedpdf/plugin-interaction';
8
+ export { createClickCounter, svgCursor, vibrationFeedback, wkFeedback } from '@embedpdf/web';
9
+ export type { SvgCursorOptions, ToolCursorImage, ToolCursorSpec } from '@embedpdf/web';
10
+ export { default as PagePointerSource } from './interaction/PagePointerSource.svelte';
11
+ export { useInteraction, useInteractionEvent, useInteractionSettings, useInteractionState, useToolCursor, } from './interaction/readers.svelte.js';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @embedpdf/svelte/interaction — pointer input and tools.
3
+ *
4
+ * `<PagePointerSource>` is the one pointer listener per page; the readers are the interaction
5
+ * plugin's API, state, settings and events, and `useToolCursor()` gives a tool its cursors.
6
+ */
7
+ // Registration travels with the UI.
8
+ export * from '@embedpdf/plugin-interaction';
9
+ // The browser helpers live in @embedpdf/web (the plugin has no DOM); they're here too, so app
10
+ // code has one import for the feature.
11
+ export { createClickCounter, svgCursor, vibrationFeedback, wkFeedback } from '@embedpdf/web';
12
+ export { default as PagePointerSource } from './interaction/PagePointerSource.svelte';
13
+ export { useInteraction, useInteractionEvent, useInteractionSettings, useInteractionState, useToolCursor, } from './interaction/readers.svelte.js';