@embedpdf/react 3.0.0-next.14 → 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 (244) hide show
  1. package/dist/AnnotationList-DcyhF2kU-CiBFOq1z.d.cts +878 -0
  2. package/dist/AnnotationList-DcyhF2kU-CiBFOq1z.d.ts +878 -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-3UvABfJm.d.cts +305 -0
  18. package/dist/annotation-BNHQpMKv.cjs +806 -0
  19. package/dist/annotation-BNHQpMKv.cjs.map +1 -0
  20. package/dist/annotation-CDI8CFb3.js +684 -0
  21. package/dist/annotation-CDI8CFb3.js.map +1 -0
  22. package/dist/annotation-DhEfs0pH.d.ts +305 -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/attachment.cjs +39 -0
  28. package/dist/attachment.cjs.map +1 -0
  29. package/dist/attachment.d.cts +29 -0
  30. package/dist/attachment.d.ts +29 -0
  31. package/dist/attachment.js +28 -0
  32. package/dist/attachment.js.map +1 -0
  33. package/dist/commands.cjs +68 -28
  34. package/dist/commands.cjs.map +1 -1
  35. package/dist/commands.d.cts +37 -10
  36. package/dist/commands.d.ts +37 -10
  37. package/dist/commands.js +68 -31
  38. package/dist/commands.js.map +1 -1
  39. package/dist/form-BSGvjA5D.js +511 -0
  40. package/dist/form-BSGvjA5D.js.map +1 -0
  41. package/dist/form-BgztZyOK.cjs +548 -0
  42. package/dist/form-BgztZyOK.cjs.map +1 -0
  43. package/dist/form.cjs +5 -5
  44. package/dist/form.d.cts +41 -2
  45. package/dist/form.d.ts +41 -2
  46. package/dist/form.js +2 -3
  47. package/dist/history.cjs +38 -0
  48. package/dist/history.cjs.map +1 -0
  49. package/dist/history.d.cts +27 -0
  50. package/dist/history.d.ts +27 -0
  51. package/dist/history.js +27 -0
  52. package/dist/history.js.map +1 -0
  53. package/dist/i18n.cjs +26 -30
  54. package/dist/i18n.cjs.map +1 -1
  55. package/dist/i18n.d.cts +24 -21
  56. package/dist/i18n.d.ts +24 -21
  57. package/dist/i18n.js +24 -31
  58. package/dist/i18n.js.map +1 -1
  59. package/dist/index.cjs +227 -57
  60. package/dist/index.d.cts +35 -32
  61. package/dist/index.d.ts +35 -32
  62. package/dist/index.js +36 -30
  63. package/dist/inert-CmBEbKCn.cjs +19 -0
  64. package/dist/inert-CmBEbKCn.cjs.map +1 -0
  65. package/dist/inert-D8fkennb.js +14 -0
  66. package/dist/inert-D8fkennb.js.map +1 -0
  67. package/dist/interaction.cjs +48 -102
  68. package/dist/interaction.cjs.map +1 -1
  69. package/dist/interaction.d.cts +23 -32
  70. package/dist/interaction.d.ts +23 -32
  71. package/dist/interaction.js +33 -102
  72. package/dist/interaction.js.map +1 -1
  73. package/dist/link.cjs +65 -104
  74. package/dist/link.cjs.map +1 -1
  75. package/dist/link.d.cts +21 -16
  76. package/dist/link.d.ts +22 -17
  77. package/dist/link.js +67 -107
  78. package/dist/link.js.map +1 -1
  79. package/dist/measurement.cjs +36 -11
  80. package/dist/measurement.cjs.map +1 -1
  81. package/dist/measurement.d.cts +33 -7
  82. package/dist/measurement.d.ts +33 -7
  83. package/dist/measurement.js +35 -14
  84. package/dist/measurement.js.map +1 -1
  85. package/dist/metadata.cjs +20 -7
  86. package/dist/metadata.cjs.map +1 -1
  87. package/dist/metadata.d.cts +22 -7
  88. package/dist/metadata.d.ts +22 -7
  89. package/dist/metadata.js +20 -10
  90. package/dist/metadata.js.map +1 -1
  91. package/dist/outline.cjs +39 -0
  92. package/dist/outline.cjs.map +1 -0
  93. package/dist/outline.d.cts +31 -0
  94. package/dist/outline.d.ts +31 -0
  95. package/dist/outline.js +28 -0
  96. package/dist/outline.js.map +1 -0
  97. package/dist/page-edit.cjs +15 -3
  98. package/dist/page-edit.cjs.map +1 -1
  99. package/dist/page-edit.d.cts +17 -2
  100. package/dist/page-edit.d.ts +17 -2
  101. package/dist/page-edit.js +15 -5
  102. package/dist/page-edit.js.map +1 -1
  103. package/dist/page-layers-Bkaaz8Zf.js +26 -0
  104. package/dist/page-layers-Bkaaz8Zf.js.map +1 -0
  105. package/dist/page-layers-BloZDoOV.cjs +37 -0
  106. package/dist/page-layers-BloZDoOV.cjs.map +1 -0
  107. package/dist/page-view.cjs +89 -82
  108. package/dist/page-view.cjs.map +1 -1
  109. package/dist/page-view.d.cts +14 -7
  110. package/dist/page-view.d.ts +18 -11
  111. package/dist/page-view.js +86 -81
  112. package/dist/page-view.js.map +1 -1
  113. package/dist/redaction.cjs +30 -15
  114. package/dist/redaction.cjs.map +1 -1
  115. package/dist/redaction.d.cts +27 -9
  116. package/dist/redaction.d.ts +27 -9
  117. package/dist/redaction.js +29 -18
  118. package/dist/redaction.js.map +1 -1
  119. package/dist/render.cjs +71 -46
  120. package/dist/render.cjs.map +1 -1
  121. package/dist/render.d.cts +17 -5
  122. package/dist/render.d.ts +17 -5
  123. package/dist/render.js +70 -49
  124. package/dist/render.js.map +1 -1
  125. package/dist/runtime-BfnpyfY0.cjs +556 -0
  126. package/dist/runtime-BfnpyfY0.cjs.map +1 -0
  127. package/dist/runtime-DBEBlpQV.d.cts +237 -0
  128. package/dist/runtime-V3MVMb91.d.ts +237 -0
  129. package/dist/runtime-tD5iJU83.js +399 -0
  130. package/dist/runtime-tD5iJU83.js.map +1 -0
  131. package/dist/runtime.cjs +45 -324
  132. package/dist/runtime.d.cts +2 -2
  133. package/dist/runtime.d.ts +2 -2
  134. package/dist/runtime.js +2 -306
  135. package/dist/search.cjs +81 -50
  136. package/dist/search.cjs.map +1 -1
  137. package/dist/search.d.cts +37 -24
  138. package/dist/search.d.ts +37 -24
  139. package/dist/search.js +81 -53
  140. package/dist/search.js.map +1 -1
  141. package/dist/selection.cjs +105 -108
  142. package/dist/selection.cjs.map +1 -1
  143. package/dist/selection.d.cts +54 -26
  144. package/dist/selection.d.ts +56 -28
  145. package/dist/selection.js +103 -110
  146. package/dist/selection.js.map +1 -1
  147. package/dist/shell.cjs +36 -21
  148. package/dist/shell.cjs.map +1 -1
  149. package/dist/shell.d.cts +32 -17
  150. package/dist/shell.d.ts +32 -17
  151. package/dist/shell.js +36 -24
  152. package/dist/shell.js.map +1 -1
  153. package/dist/signature.cjs +29 -48
  154. package/dist/signature.cjs.map +1 -1
  155. package/dist/signature.d.cts +26 -26
  156. package/dist/signature.d.ts +26 -26
  157. package/dist/signature.js +30 -48
  158. package/dist/signature.js.map +1 -1
  159. package/dist/stage-B7BG2e8Q.cjs +369 -0
  160. package/dist/stage-B7BG2e8Q.cjs.map +1 -0
  161. package/dist/stage-BqfBjDu6.js +302 -0
  162. package/dist/stage-BqfBjDu6.js.map +1 -0
  163. package/dist/stage-ByFPD-Fv.d.cts +117 -0
  164. package/dist/stage-DaboaheR.d.ts +117 -0
  165. package/dist/stage-scope-CQgCuf1w.cjs +46 -0
  166. package/dist/stage-scope-CQgCuf1w.cjs.map +1 -0
  167. package/dist/stage-scope-D7ZeNduT.js +23 -0
  168. package/dist/stage-scope-D7ZeNduT.js.map +1 -0
  169. package/dist/stage.cjs +12 -235
  170. package/dist/stage.d.cts +2 -116
  171. package/dist/stage.d.ts +2 -116
  172. package/dist/stage.js +3 -228
  173. package/dist/stamp.cjs +41 -35
  174. package/dist/stamp.cjs.map +1 -1
  175. package/dist/stamp.d.cts +25 -18
  176. package/dist/stamp.d.ts +25 -18
  177. package/dist/stamp.js +40 -37
  178. package/dist/stamp.js.map +1 -1
  179. package/dist/state-0K1I5cM4.d.cts +29 -0
  180. package/dist/state-0K1I5cM4.d.ts +29 -0
  181. package/dist/state-CzI2KlZb.js +62 -0
  182. package/dist/state-CzI2KlZb.js.map +1 -0
  183. package/dist/state-Dtf8HAue.cjs +73 -0
  184. package/dist/state-Dtf8HAue.cjs.map +1 -0
  185. package/dist/svg-shapes-Dm1yTR1b.js +40 -0
  186. package/dist/svg-shapes-Dm1yTR1b.js.map +1 -0
  187. package/dist/svg-shapes-zo0GNkc9.cjs +53 -0
  188. package/dist/svg-shapes-zo0GNkc9.cjs.map +1 -0
  189. package/dist/toolbar.cjs +297 -295
  190. package/dist/toolbar.cjs.map +1 -1
  191. package/dist/toolbar.d.cts +58 -68
  192. package/dist/toolbar.d.ts +67 -77
  193. package/dist/toolbar.js +271 -293
  194. package/dist/toolbar.js.map +1 -1
  195. package/dist/view-manager.cjs +34 -0
  196. package/dist/view-manager.cjs.map +1 -0
  197. package/dist/view-manager.d.cts +21 -0
  198. package/dist/view-manager.d.ts +21 -0
  199. package/dist/view-manager.js +23 -0
  200. package/dist/view-manager.js.map +1 -0
  201. package/package.json +47 -39
  202. package/dist/annotation-BCED_p9H.d.cts +0 -160
  203. package/dist/annotation-anchors-CetwM1g7.js +0 -15
  204. package/dist/annotation-anchors-CetwM1g7.js.map +0 -1
  205. package/dist/annotation-anchors-DuYRBJLl.cjs +0 -26
  206. package/dist/annotation-anchors-DuYRBJLl.cjs.map +0 -1
  207. package/dist/annotation-hooks-BB5ZhPpf.cjs +0 -16
  208. package/dist/annotation-hooks-BB5ZhPpf.cjs.map +0 -1
  209. package/dist/annotation-hooks-Df8EmzDO.js +0 -11
  210. package/dist/annotation-hooks-Df8EmzDO.js.map +0 -1
  211. package/dist/annotation-k38KDlIZ.d.ts +0 -160
  212. package/dist/annotation-menu.cjs +0 -64
  213. package/dist/annotation-menu.cjs.map +0 -1
  214. package/dist/annotation-menu.d.cts +0 -33
  215. package/dist/annotation-menu.d.ts +0 -33
  216. package/dist/annotation-menu.js +0 -48
  217. package/dist/annotation-menu.js.map +0 -1
  218. package/dist/annotation.cjs.map +0 -1
  219. package/dist/annotation.js.map +0 -1
  220. package/dist/form-BVumS7up.cjs +0 -926
  221. package/dist/form-BVumS7up.cjs.map +0 -1
  222. package/dist/form-Bdjk0Z3T.d.cts +0 -537
  223. package/dist/form-CK3mp99m.js +0 -895
  224. package/dist/form-CK3mp99m.js.map +0 -1
  225. package/dist/form-CYRYgthn.d.ts +0 -537
  226. package/dist/rolldown-runtime-BBjsoOtd.js +0 -27
  227. package/dist/runtime-DE76hlnl.d.ts +0 -216
  228. package/dist/runtime-umHA_xHt.d.cts +0 -216
  229. package/dist/runtime.cjs.map +0 -1
  230. package/dist/runtime.js.map +0 -1
  231. package/dist/scrollbar.cjs +0 -241
  232. package/dist/scrollbar.cjs.map +0 -1
  233. package/dist/scrollbar.d.cts +0 -42
  234. package/dist/scrollbar.d.ts +0 -42
  235. package/dist/scrollbar.js +0 -213
  236. package/dist/scrollbar.js.map +0 -1
  237. package/dist/stage.cjs.map +0 -1
  238. package/dist/stage.js.map +0 -1
  239. package/dist/views.cjs +0 -35
  240. package/dist/views.cjs.map +0 -1
  241. package/dist/views.d.cts +0 -21
  242. package/dist/views.d.ts +0 -21
  243. package/dist/views.js +0 -27
  244. package/dist/views.js.map +0 -1
@@ -0,0 +1,237 @@
1
+ import { AnyPlugin, CapabilityToken, DocumentInfo, DocumentsCapability, DocumentsState, Engine, EngineFactory, EventHook, FailedDocumentInfo, Identity, InitialDocument, Kernel, LockedDocumentInfo, PageInfo, ViewerPageSettings, ViewerSettings } from "@embedpdf/core";
2
+ import * as React from "react";
3
+ import { EpdfTheme, EpdfTheme as EpdfTheme$1, PageContext, makePageContext, mountWebFont, saveFile } from "@embedpdf/web";
4
+ import { PageTransform } from "@embedpdf/core-geometry";
5
+ import { PageViewDemand } from "@embedpdf/plugin-render/contract";
6
+ //#region src/theme.d.ts
7
+ /**
8
+ * The CSS variables of a theme, for a `style` prop: `<div style={epdfTheme({ accent })}>`.
9
+ * Everything inside the element follows them, and a CSS variable wins over any setting.
10
+ */
11
+ declare function epdfTheme(theme: EpdfTheme): React.CSSProperties;
12
+ //#endregion
13
+ //#region src/runtime.d.ts
14
+ declare function useKernel(): Kernel;
15
+ interface KernelProviderProps {
16
+ kernel: Kernel;
17
+ children?: React.ReactNode;
18
+ }
19
+ /**
20
+ * Give a subtree a kernel someone else created and owns, so every hook in it
21
+ * works against that kernel. The full viewer's wrapper puts the children it
22
+ * slots into the viewer inside one. The provider never starts or destroys the
23
+ * kernel; `<Viewer>` is the component that owns one.
24
+ */
25
+ declare function KernelProvider({ kernel, children }: KernelProviderProps): import("react/jsx-runtime").JSX.Element;
26
+ declare const shallowArray: <T>(left: readonly T[], right: readonly T[]) => boolean;
27
+ /** Read a value derived from the kernel, cached by equality (no tearing loop). */
28
+ declare function useKernelValue<R>(select: (kernel: Kernel) => R, isEqual?: (left: R, right: R) => boolean): R;
29
+ declare function useActiveDocumentId(): string | null;
30
+ /** The document id for this subtree: the nearest <DocumentScope>, else the active doc. */
31
+ declare function useDocumentId(): string | null;
32
+ /**
33
+ * The document the nearest <DocumentScope> binds this subtree to, or null when
34
+ * it follows the active document. For resolvers that pass it to
35
+ * `kernel.tryCapability`, which reads the active document at call time; UI
36
+ * that needs the id itself uses {@link useDocumentId}.
37
+ */
38
+ declare function useDocumentScope(): string | null;
39
+ interface DocumentScopeProps {
40
+ id: string;
41
+ children: React.ReactNode;
42
+ }
43
+ /** Bind a subtree to a specific document (panes, comparison). */
44
+ declare function DocumentScope({ id, children }: DocumentScopeProps): import("react/jsx-runtime").JSX.Element;
45
+ interface DocumentGateProps {
46
+ /** Shown while this subtree has no document: none is open, or it's still opening. */
47
+ fallback?: React.ReactNode;
48
+ /** Shown while the document waits for its password; `fallback` without it. */
49
+ locked?: (document: LockedDocumentInfo) => React.ReactNode;
50
+ /** Shown when the document couldn't be opened, with why; `fallback` without it. */
51
+ error?: (document: FailedDocumentInfo) => React.ReactNode;
52
+ children?: React.ReactNode;
53
+ }
54
+ /**
55
+ * Render children only while this subtree has a ready document — the
56
+ * structural way to say "this UI is defined over a document". An empty
57
+ * workspace is a legitimate, designable state (the Viewer no longer blocks on
58
+ * documents so chrome can render at t≈0): workspace-scoped UI (toolbars,
59
+ * commands, i18n) lives outside the gate; document-scoped UI (Stage, panels,
60
+ * page chrome) lives inside it. A document that waits for its password, or
61
+ * failed, renders `locked` or `error` with it, or else `fallback`. Sibling of
62
+ * <DocumentScope>, which picks which document; this one handles whether.
63
+ */
64
+ declare function DocumentGate({ fallback, locked, error, children }: DocumentGateProps): import("react/jsx-runtime").JSX.Element;
65
+ /**
66
+ * Resolve a capability by token, binding document-scoped ones to this
67
+ * subtree's document. Resolution is a reactive read (`tryCapability` through
68
+ * the kernel's one change stream), not a memoized call — under the
69
+ * request-time lifecycle a document can become resolvable while its id stays
70
+ * the same, so any id-keyed cache goes stale; subscribing makes staleness
71
+ * structurally impossible.
72
+ *
73
+ * Outside a document (none open, not ready yet, or none in scope), a document
74
+ * plugin resolves to its stand-in (`standInFor` from `@embedpdf/core`):
75
+ * rendering never fails, and a method called too early refuses with
76
+ * `not-ready` (a method that returns a promise rejects). A token no plugin
77
+ * provides still throws the kernel's reason, because that is a setup mistake.
78
+ */
79
+ declare function useCapability<T>(token: CapabilityToken<T>): T;
80
+ /** Like `useCapability`, but null while the token can't resolve (no plugin,
81
+ * no document, or a document that isn't ready yet). */
82
+ declare function useOptionalCapability<T>(token: CapabilityToken<T>): T | null;
83
+ /**
84
+ * Subscribe to a selector over a (document-resolved) capability. Strict:
85
+ * while the token can't resolve, it throws the kernel's reason (`no
86
+ * document`, `document is loading`), for code that knows a document exists,
87
+ * such as anything inside a <DocumentGate>. `useOptionalSelector` is its
88
+ * total twin.
89
+ */
90
+ declare function useSelector<C, R>(token: CapabilityToken<C>, select: (capability: C) => R, isEqual?: (left: R, right: R) => boolean): R;
91
+ /**
92
+ * Null-safe `useSelector`: `fallback` whenever the token can't resolve — no
93
+ * provider, or a document-scoped token with no document. For chrome that stays
94
+ * mounted across the empty-workspace state (a zoom readout, a mode band).
95
+ *
96
+ * The `select` guard also swallows reads through a capability whose document
97
+ * closed between the store notification and this render — that teardown race
98
+ * resolves to `fallback` for one frame, then re-renders against the new state.
99
+ */
100
+ declare function useOptionalSelector<C, R>(token: CapabilityToken<C>, select: (capability: C) => R, fallback: R, isEqual?: (left: R, right: R) => boolean): R;
101
+ /**
102
+ * Subscribe to a capability's {@link EventHook} for the mounted lifetime —
103
+ * `useCapabilityEvent(ActionsToken, (actions) => actions.onExecuted, handler)`. Events
104
+ * carry occurrences, never state (a late subscriber that needs the current
105
+ * value uses `useSelector`). The handler rides a ref, so a fresh closure per
106
+ * render never resubscribes. Null-safe: no plugin/document → no subscription.
107
+ */
108
+ declare function useCapabilityEvent<C, T>(token: CapabilityToken<C>, select: (capability: C) => EventHook<T>, handler: (event: T) => void): void;
109
+ /**
110
+ * The documents API: open, close, unlock, download, and the tabs. Inside a
111
+ * <DocumentScope>, the calls that leave out the document use that one, so
112
+ * `download()` without an id downloads the document in scope. The object
113
+ * never changes, so it's safe in effects and callbacks. What to show comes
114
+ * from `useDocument()` and `useDocumentsState()`.
115
+ */
116
+ declare function useDocuments(): DocumentsCapability;
117
+ /**
118
+ * The document this component talks to: the one its <DocumentScope> names, or
119
+ * else the active one. Its `id`, `name`, `status`, `pageCount`,
120
+ * `hasUnsavedChanges`, and why it's locked or failed. With no document, an
121
+ * empty one that reads as still opening. Takes a selector, and re-renders only
122
+ * when what it returns changes.
123
+ */
124
+ declare function useDocument<Selected = DocumentInfo>(select?: (document: DocumentInfo) => Selected): Selected;
125
+ /**
126
+ * Every open document, in tab order (loading, locked and failed ones too),
127
+ * and the active one's id. Takes a selector, and re-renders only when what it
128
+ * returns changes.
129
+ */
130
+ declare function useDocumentsState<Selected = DocumentsState>(select?: (state: DocumentsState) => Selected): Selected;
131
+ /** Subscribe to one documents event for the mounted lifetime: `useDocumentsEvent((documents) => documents.onOpened, handler)`. */
132
+ declare function useDocumentsEvent<T>(select: (documents: DocumentsCapability) => EventHook<T>, handler: (event: T) => void): void;
133
+ /**
134
+ * The pages of the document this component talks to, in order: each with its
135
+ * `ref`, `index`, `label`, size and rotation. Needs no Stage, so a thumbnail
136
+ * list or a page picker works anywhere. The same array until a page is added,
137
+ * removed, moved or rotated; empty with no document.
138
+ */
139
+ declare function usePageList(): readonly PageInfo[];
140
+ /**
141
+ * The viewer's own settings (`<Viewer identity scope accent page>`), or the
142
+ * value `select` picks from them: the accent every part without a color of its
143
+ * own follows, and how pages look. What paints a page or an accent reads it
144
+ * here, through `paint()` from `@embedpdf/web`, so a CSS variable still wins.
145
+ */
146
+ declare function useViewerSettings<Selected = ViewerSettings>(select?: (settings: ViewerSettings) => Selected): Selected;
147
+ interface ViewerProps {
148
+ /**
149
+ * The engine, as an instance or a thunk. Engines construct synchronously and
150
+ * boot lazily (`localEngine()` allocates nothing until first use), so
151
+ * ownership follows the shape of what you pass:
152
+ *
153
+ * - An **instance** (`engine={engine}`) is borrowed: the Viewer uses it and
154
+ * never destroys it, because you acquired it and therefore own it. The
155
+ * common path — a module-scope `const engine = localEngine()` shared
156
+ * across viewers and route changes. The Viewer warms up a local engine
157
+ * on mount so the boot overlaps app initialization.
158
+ * - A **thunk** (`engine={() => localEngine()}`) is viewer-owned: the
159
+ * Viewer calls it on mount and `destroy()`s the result on unmount. Use it
160
+ * for per-mount isolation (StrictMode/HMR-clean teardown, independent
161
+ * multi-viewer engines).
162
+ *
163
+ * Init-only: captured on first render; later identity changes are ignored (dev warns).
164
+ */
165
+ engine: Engine | EngineFactory;
166
+ /** Init-only: captured on first render; later identity changes are ignored (dev warns). */
167
+ plugins: AnyPlugin[];
168
+ /** Documents to open on startup (with optional tab names). Init-only. */
169
+ initialDocuments?: InitialDocument[];
170
+ fallback?: React.ReactNode;
171
+ /** Rendered when kernel construction or `start()` fails. Without it a boot
172
+ * failure renders nothing — but never a silent forever-fallback. */
173
+ renderError?: (error: unknown) => React.ReactNode;
174
+ /** Called once the kernel has started — before `children` mount and before
175
+ * `initialDocuments` open. The imperative door for code outside React
176
+ * (register commands, subscribe events). The `ref` carries the same kernel. */
177
+ onReady?: (kernel: Kernel) => void;
178
+ /**
179
+ * Who the user is, for every document opened without an `identity` of its
180
+ * own (which replaces this one). Documents opened after a change use the new
181
+ * value; open ones keep theirs. The local engine only: the cloud engine reads
182
+ * it from the document's token.
183
+ */
184
+ identity?: Identity;
185
+ /**
186
+ * What the user may do, as permissions, in every document opened without a
187
+ * `scope` of its own (which replaces this one). Left out, they may do
188
+ * everything. Changes reach the documents opened after them, as `identity`.
189
+ */
190
+ scope?: readonly string[];
191
+ /** The color every part without a color of its own follows. CSS `--epdf-accent` wins over it. */
192
+ accent?: string;
193
+ /** How pages look: `background` before the picture arrives, and the `shadow` under each page. */
194
+ page?: Partial<ViewerPageSettings>;
195
+ children?: React.ReactNode;
196
+ }
197
+ /**
198
+ * Owns the kernel as an effect-scoped resource: each effect setup creates and
199
+ * starts exactly one kernel; each cleanup destroys exactly that one. That is
200
+ * the contract StrictMode exercises (two kernels in dev, the first fully
201
+ * destroyed) — the kernel itself is never restarted after destroy.
202
+ *
203
+ * The kernel is published to context the moment it exists — before `start()`
204
+ * resolves — so the `fallback` can use workspace capabilities (i18n copy on a
205
+ * loading screen). The one exception is the very first render, which happens
206
+ * before the effect: it renders nothing. Children mount once `start()` resolves
207
+ * — which never touches the engine, so the shell is alive while WASM compiles
208
+ * or the transport connects. `initialDocuments` open in the background and
209
+ * stream into the registry (`useDocuments()` is reactive); per-document
210
+ * loading UI is the Stage's job, not a root gate.
211
+ *
212
+ * Engine ownership. When `engine` is a thunk, the Viewer owns it: each effect
213
+ * setup constructs one engine (construction is synchronous and inert — boot
214
+ * happens lazily inside the engine) and each cleanup destroys exactly that one
215
+ * — after the kernel, so handles close first. When `engine` is an instance it
216
+ * is borrowed and never destroyed here; the Viewer only warms up a local
217
+ * engine so the WASM boot overlaps plugin initialization. StrictMode's
218
+ * double-mount therefore constructs two independent thunk engines and tears
219
+ * the first fully down, matching the kernel's own effect-scoped lifecycle.
220
+ * That means dev-only double resource use (two worker spawns, two font
221
+ * fetches, briefly overlapping) — deliberate, because it is exactly the
222
+ * leak-detection contract StrictMode exists to exercise; production mounts
223
+ * once and boots once.
224
+ */
225
+ declare const Viewer: React.ForwardRefExoticComponent<ViewerProps & React.RefAttributes<Kernel | null>>;
226
+ declare const EmbedPDF: React.ForwardRefExoticComponent<ViewerProps & React.RefAttributes<Kernel | null>>;
227
+ /**
228
+ * PageContext — the seam. A layer depends only on this, never on the Stage. So the
229
+ * same layer works inside a virtualized Stage and in a standalone <PageView>.
230
+ * Its members are documented on `PageContext` in `@embedpdf/web`.
231
+ */
232
+ type PageContextValue = PageContext<PageTransform, PageViewDemand>;
233
+ declare const PageProvider: React.Provider<PageContextValue | null>;
234
+ declare function usePage(): PageContextValue;
235
+ //#endregion
236
+ export { usePageList as A, useDocumentsEvent as C, useOptionalCapability as D, useKernelValue as E, useViewerSettings as M, EpdfTheme$1 as N, useOptionalSelector as O, epdfTheme as P, useDocuments as S, useKernel as T, useCapability as _, EmbedPDF as a, useDocumentId as b, PageContextValue as c, ViewerProps as d, makePageContext as f, useActiveDocumentId as g, shallowArray as h, DocumentScopeProps as i, useSelector as j, usePage as k, PageProvider as l, saveFile as m, DocumentGateProps as n, KernelProvider as o, mountWebFont as p, DocumentScope as r, KernelProviderProps as s, DocumentGate as t, Viewer as u, useCapabilityEvent as v, useDocumentsState as w, useDocumentScope as x, useDocument as y };
237
+ //# sourceMappingURL=runtime-DBEBlpQV.d.cts.map
@@ -0,0 +1,237 @@
1
+ import { AnyPlugin, CapabilityToken, DocumentInfo, DocumentsCapability, DocumentsState, Engine, EngineFactory, EventHook, FailedDocumentInfo, Identity, InitialDocument, Kernel, LockedDocumentInfo, PageInfo, ViewerPageSettings, ViewerSettings } from "@embedpdf/core";
2
+ import { EpdfTheme, EpdfTheme as EpdfTheme$1, PageContext, makePageContext as makePageContext$1, mountWebFont, saveFile } from "@embedpdf/web";
3
+ import * as React$1 from "react";
4
+ import { PageTransform } from "@embedpdf/core-geometry";
5
+ import { PageViewDemand } from "@embedpdf/plugin-render/contract";
6
+ //#region src/theme.d.ts
7
+ /**
8
+ * The CSS variables of a theme, for a `style` prop: `<div style={epdfTheme({ accent })}>`.
9
+ * Everything inside the element follows them, and a CSS variable wins over any setting.
10
+ */
11
+ declare function epdfTheme(theme: EpdfTheme): React$1.CSSProperties;
12
+ //#endregion
13
+ //#region src/runtime.d.ts
14
+ declare function useKernel(): Kernel;
15
+ interface KernelProviderProps {
16
+ kernel: Kernel;
17
+ children?: React$1.ReactNode;
18
+ }
19
+ /**
20
+ * Give a subtree a kernel someone else created and owns, so every hook in it
21
+ * works against that kernel. The full viewer's wrapper puts the children it
22
+ * slots into the viewer inside one. The provider never starts or destroys the
23
+ * kernel; `<Viewer>` is the component that owns one.
24
+ */
25
+ declare function KernelProvider({ kernel, children }: KernelProviderProps): import("react/jsx-runtime").JSX.Element;
26
+ declare const shallowArray: <T>(left: readonly T[], right: readonly T[]) => boolean;
27
+ /** Read a value derived from the kernel, cached by equality (no tearing loop). */
28
+ declare function useKernelValue<R>(select: (kernel: Kernel) => R, isEqual?: (left: R, right: R) => boolean): R;
29
+ declare function useActiveDocumentId(): string | null;
30
+ /** The document id for this subtree: the nearest <DocumentScope>, else the active doc. */
31
+ declare function useDocumentId(): string | null;
32
+ /**
33
+ * The document the nearest <DocumentScope> binds this subtree to, or null when
34
+ * it follows the active document. For resolvers that pass it to
35
+ * `kernel.tryCapability`, which reads the active document at call time; UI
36
+ * that needs the id itself uses {@link useDocumentId}.
37
+ */
38
+ declare function useDocumentScope(): string | null;
39
+ interface DocumentScopeProps {
40
+ id: string;
41
+ children: React$1.ReactNode;
42
+ }
43
+ /** Bind a subtree to a specific document (panes, comparison). */
44
+ declare function DocumentScope({ id, children }: DocumentScopeProps): import("react/jsx-runtime").JSX.Element;
45
+ interface DocumentGateProps {
46
+ /** Shown while this subtree has no document: none is open, or it's still opening. */
47
+ fallback?: React$1.ReactNode;
48
+ /** Shown while the document waits for its password; `fallback` without it. */
49
+ locked?: (document: LockedDocumentInfo) => React$1.ReactNode;
50
+ /** Shown when the document couldn't be opened, with why; `fallback` without it. */
51
+ error?: (document: FailedDocumentInfo) => React$1.ReactNode;
52
+ children?: React$1.ReactNode;
53
+ }
54
+ /**
55
+ * Render children only while this subtree has a ready document — the
56
+ * structural way to say "this UI is defined over a document". An empty
57
+ * workspace is a legitimate, designable state (the Viewer no longer blocks on
58
+ * documents so chrome can render at t≈0): workspace-scoped UI (toolbars,
59
+ * commands, i18n) lives outside the gate; document-scoped UI (Stage, panels,
60
+ * page chrome) lives inside it. A document that waits for its password, or
61
+ * failed, renders `locked` or `error` with it, or else `fallback`. Sibling of
62
+ * <DocumentScope>, which picks which document; this one handles whether.
63
+ */
64
+ declare function DocumentGate({ fallback, locked, error, children }: DocumentGateProps): import("react/jsx-runtime").JSX.Element;
65
+ /**
66
+ * Resolve a capability by token, binding document-scoped ones to this
67
+ * subtree's document. Resolution is a reactive read (`tryCapability` through
68
+ * the kernel's one change stream), not a memoized call — under the
69
+ * request-time lifecycle a document can become resolvable while its id stays
70
+ * the same, so any id-keyed cache goes stale; subscribing makes staleness
71
+ * structurally impossible.
72
+ *
73
+ * Outside a document (none open, not ready yet, or none in scope), a document
74
+ * plugin resolves to its stand-in (`standInFor` from `@embedpdf/core`):
75
+ * rendering never fails, and a method called too early refuses with
76
+ * `not-ready` (a method that returns a promise rejects). A token no plugin
77
+ * provides still throws the kernel's reason, because that is a setup mistake.
78
+ */
79
+ declare function useCapability<T>(token: CapabilityToken<T>): T;
80
+ /** Like `useCapability`, but null while the token can't resolve (no plugin,
81
+ * no document, or a document that isn't ready yet). */
82
+ declare function useOptionalCapability<T>(token: CapabilityToken<T>): T | null;
83
+ /**
84
+ * Subscribe to a selector over a (document-resolved) capability. Strict:
85
+ * while the token can't resolve, it throws the kernel's reason (`no
86
+ * document`, `document is loading`), for code that knows a document exists,
87
+ * such as anything inside a <DocumentGate>. `useOptionalSelector` is its
88
+ * total twin.
89
+ */
90
+ declare function useSelector<C, R>(token: CapabilityToken<C>, select: (capability: C) => R, isEqual?: (left: R, right: R) => boolean): R;
91
+ /**
92
+ * Null-safe `useSelector`: `fallback` whenever the token can't resolve — no
93
+ * provider, or a document-scoped token with no document. For chrome that stays
94
+ * mounted across the empty-workspace state (a zoom readout, a mode band).
95
+ *
96
+ * The `select` guard also swallows reads through a capability whose document
97
+ * closed between the store notification and this render — that teardown race
98
+ * resolves to `fallback` for one frame, then re-renders against the new state.
99
+ */
100
+ declare function useOptionalSelector<C, R>(token: CapabilityToken<C>, select: (capability: C) => R, fallback: R, isEqual?: (left: R, right: R) => boolean): R;
101
+ /**
102
+ * Subscribe to a capability's {@link EventHook} for the mounted lifetime —
103
+ * `useCapabilityEvent(ActionsToken, (actions) => actions.onExecuted, handler)`. Events
104
+ * carry occurrences, never state (a late subscriber that needs the current
105
+ * value uses `useSelector`). The handler rides a ref, so a fresh closure per
106
+ * render never resubscribes. Null-safe: no plugin/document → no subscription.
107
+ */
108
+ declare function useCapabilityEvent<C, T>(token: CapabilityToken<C>, select: (capability: C) => EventHook<T>, handler: (event: T) => void): void;
109
+ /**
110
+ * The documents API: open, close, unlock, download, and the tabs. Inside a
111
+ * <DocumentScope>, the calls that leave out the document use that one, so
112
+ * `download()` without an id downloads the document in scope. The object
113
+ * never changes, so it's safe in effects and callbacks. What to show comes
114
+ * from `useDocument()` and `useDocumentsState()`.
115
+ */
116
+ declare function useDocuments(): DocumentsCapability;
117
+ /**
118
+ * The document this component talks to: the one its <DocumentScope> names, or
119
+ * else the active one. Its `id`, `name`, `status`, `pageCount`,
120
+ * `hasUnsavedChanges`, and why it's locked or failed. With no document, an
121
+ * empty one that reads as still opening. Takes a selector, and re-renders only
122
+ * when what it returns changes.
123
+ */
124
+ declare function useDocument<Selected = DocumentInfo>(select?: (document: DocumentInfo) => Selected): Selected;
125
+ /**
126
+ * Every open document, in tab order (loading, locked and failed ones too),
127
+ * and the active one's id. Takes a selector, and re-renders only when what it
128
+ * returns changes.
129
+ */
130
+ declare function useDocumentsState<Selected = DocumentsState>(select?: (state: DocumentsState) => Selected): Selected;
131
+ /** Subscribe to one documents event for the mounted lifetime: `useDocumentsEvent((documents) => documents.onOpened, handler)`. */
132
+ declare function useDocumentsEvent<T>(select: (documents: DocumentsCapability) => EventHook<T>, handler: (event: T) => void): void;
133
+ /**
134
+ * The pages of the document this component talks to, in order: each with its
135
+ * `ref`, `index`, `label`, size and rotation. Needs no Stage, so a thumbnail
136
+ * list or a page picker works anywhere. The same array until a page is added,
137
+ * removed, moved or rotated; empty with no document.
138
+ */
139
+ declare function usePageList(): readonly PageInfo[];
140
+ /**
141
+ * The viewer's own settings (`<Viewer identity scope accent page>`), or the
142
+ * value `select` picks from them: the accent every part without a color of its
143
+ * own follows, and how pages look. What paints a page or an accent reads it
144
+ * here, through `paint()` from `@embedpdf/web`, so a CSS variable still wins.
145
+ */
146
+ declare function useViewerSettings<Selected = ViewerSettings>(select?: (settings: ViewerSettings) => Selected): Selected;
147
+ interface ViewerProps {
148
+ /**
149
+ * The engine, as an instance or a thunk. Engines construct synchronously and
150
+ * boot lazily (`localEngine()` allocates nothing until first use), so
151
+ * ownership follows the shape of what you pass:
152
+ *
153
+ * - An **instance** (`engine={engine}`) is borrowed: the Viewer uses it and
154
+ * never destroys it, because you acquired it and therefore own it. The
155
+ * common path — a module-scope `const engine = localEngine()` shared
156
+ * across viewers and route changes. The Viewer warms up a local engine
157
+ * on mount so the boot overlaps app initialization.
158
+ * - A **thunk** (`engine={() => localEngine()}`) is viewer-owned: the
159
+ * Viewer calls it on mount and `destroy()`s the result on unmount. Use it
160
+ * for per-mount isolation (StrictMode/HMR-clean teardown, independent
161
+ * multi-viewer engines).
162
+ *
163
+ * Init-only: captured on first render; later identity changes are ignored (dev warns).
164
+ */
165
+ engine: Engine | EngineFactory;
166
+ /** Init-only: captured on first render; later identity changes are ignored (dev warns). */
167
+ plugins: AnyPlugin[];
168
+ /** Documents to open on startup (with optional tab names). Init-only. */
169
+ initialDocuments?: InitialDocument[];
170
+ fallback?: React$1.ReactNode;
171
+ /** Rendered when kernel construction or `start()` fails. Without it a boot
172
+ * failure renders nothing — but never a silent forever-fallback. */
173
+ renderError?: (error: unknown) => React$1.ReactNode;
174
+ /** Called once the kernel has started — before `children` mount and before
175
+ * `initialDocuments` open. The imperative door for code outside React
176
+ * (register commands, subscribe events). The `ref` carries the same kernel. */
177
+ onReady?: (kernel: Kernel) => void;
178
+ /**
179
+ * Who the user is, for every document opened without an `identity` of its
180
+ * own (which replaces this one). Documents opened after a change use the new
181
+ * value; open ones keep theirs. The local engine only: the cloud engine reads
182
+ * it from the document's token.
183
+ */
184
+ identity?: Identity;
185
+ /**
186
+ * What the user may do, as permissions, in every document opened without a
187
+ * `scope` of its own (which replaces this one). Left out, they may do
188
+ * everything. Changes reach the documents opened after them, as `identity`.
189
+ */
190
+ scope?: readonly string[];
191
+ /** The color every part without a color of its own follows. CSS `--epdf-accent` wins over it. */
192
+ accent?: string;
193
+ /** How pages look: `background` before the picture arrives, and the `shadow` under each page. */
194
+ page?: Partial<ViewerPageSettings>;
195
+ children?: React$1.ReactNode;
196
+ }
197
+ /**
198
+ * Owns the kernel as an effect-scoped resource: each effect setup creates and
199
+ * starts exactly one kernel; each cleanup destroys exactly that one. That is
200
+ * the contract StrictMode exercises (two kernels in dev, the first fully
201
+ * destroyed) — the kernel itself is never restarted after destroy.
202
+ *
203
+ * The kernel is published to context the moment it exists — before `start()`
204
+ * resolves — so the `fallback` can use workspace capabilities (i18n copy on a
205
+ * loading screen). The one exception is the very first render, which happens
206
+ * before the effect: it renders nothing. Children mount once `start()` resolves
207
+ * — which never touches the engine, so the shell is alive while WASM compiles
208
+ * or the transport connects. `initialDocuments` open in the background and
209
+ * stream into the registry (`useDocuments()` is reactive); per-document
210
+ * loading UI is the Stage's job, not a root gate.
211
+ *
212
+ * Engine ownership. When `engine` is a thunk, the Viewer owns it: each effect
213
+ * setup constructs one engine (construction is synchronous and inert — boot
214
+ * happens lazily inside the engine) and each cleanup destroys exactly that one
215
+ * — after the kernel, so handles close first. When `engine` is an instance it
216
+ * is borrowed and never destroyed here; the Viewer only warms up a local
217
+ * engine so the WASM boot overlaps plugin initialization. StrictMode's
218
+ * double-mount therefore constructs two independent thunk engines and tears
219
+ * the first fully down, matching the kernel's own effect-scoped lifecycle.
220
+ * That means dev-only double resource use (two worker spawns, two font
221
+ * fetches, briefly overlapping) — deliberate, because it is exactly the
222
+ * leak-detection contract StrictMode exists to exercise; production mounts
223
+ * once and boots once.
224
+ */
225
+ declare const Viewer: React$1.ForwardRefExoticComponent<ViewerProps & React$1.RefAttributes<Kernel | null>>;
226
+ declare const EmbedPDF: React$1.ForwardRefExoticComponent<ViewerProps & React$1.RefAttributes<Kernel | null>>;
227
+ /**
228
+ * PageContext — the seam. A layer depends only on this, never on the Stage. So the
229
+ * same layer works inside a virtualized Stage and in a standalone <PageView>.
230
+ * Its members are documented on `PageContext` in `@embedpdf/web`.
231
+ */
232
+ type PageContextValue = PageContext<PageTransform, PageViewDemand>;
233
+ declare const PageProvider: React$1.Provider<PageContextValue | null>;
234
+ declare function usePage(): PageContextValue;
235
+ //#endregion
236
+ export { usePageList as A, useDocumentsEvent as C, useOptionalCapability as D, useKernelValue as E, useViewerSettings as M, EpdfTheme$1 as N, useOptionalSelector as O, epdfTheme as P, useDocuments as S, useKernel as T, useCapability as _, EmbedPDF as a, useDocumentId as b, PageContextValue as c, ViewerProps as d, makePageContext$1 as f, useActiveDocumentId as g, shallowArray as h, DocumentScopeProps as i, useSelector as j, usePage as k, PageProvider as l, saveFile as m, DocumentGateProps as n, KernelProvider as o, mountWebFont as p, DocumentScope as r, KernelProviderProps as s, DocumentGate as t, Viewer as u, useCapabilityEvent as v, useDocumentsState as w, useDocumentScope as x, useDocument as y };
237
+ //# sourceMappingURL=runtime-V3MVMb91.d.ts.map