@embedpdf/react 3.0.0-next.13 → 3.0.0-next.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/dist/AnnotationList-CkijRHet-HEFNUIZe.d.cts +877 -0
  2. package/dist/AnnotationList-CkijRHet-HEFNUIZe.d.ts +877 -0
  3. package/dist/actions.cjs +25 -5
  4. package/dist/actions.cjs.map +1 -1
  5. package/dist/actions.d.cts +18 -5
  6. package/dist/actions.d.ts +18 -5
  7. package/dist/actions.js +22 -6
  8. package/dist/actions.js.map +1 -1
  9. package/dist/anchored-DeX95xSd.d.ts +85 -0
  10. package/dist/anchored-DzN3JywS.d.cts +85 -0
  11. package/dist/anchored.cjs +71 -28
  12. package/dist/anchored.cjs.map +1 -1
  13. package/dist/anchored.d.cts +2 -45
  14. package/dist/anchored.d.ts +2 -45
  15. package/dist/anchored.js +56 -19
  16. package/dist/anchored.js.map +1 -1
  17. package/dist/annotation-B48UT2ln.d.ts +302 -0
  18. package/dist/annotation-C1ttM8Wj.js +708 -0
  19. package/dist/annotation-C1ttM8Wj.js.map +1 -0
  20. package/dist/annotation-C9dVwo9b.d.cts +302 -0
  21. package/dist/annotation-Dex5EBda.cjs +830 -0
  22. package/dist/annotation-Dex5EBda.cjs.map +1 -0
  23. package/dist/annotation.cjs +20 -783
  24. package/dist/annotation.d.cts +2 -2
  25. package/dist/annotation.d.ts +2 -2
  26. package/dist/annotation.js +2 -768
  27. package/dist/commands.cjs +68 -28
  28. package/dist/commands.cjs.map +1 -1
  29. package/dist/commands.d.cts +37 -10
  30. package/dist/commands.d.ts +37 -10
  31. package/dist/commands.js +68 -31
  32. package/dist/commands.js.map +1 -1
  33. package/dist/form-55izw0jS.js +511 -0
  34. package/dist/form-55izw0jS.js.map +1 -0
  35. package/dist/form-BNqQfGGH.cjs +548 -0
  36. package/dist/form-BNqQfGGH.cjs.map +1 -0
  37. package/dist/form.cjs +5 -5
  38. package/dist/form.d.cts +32 -25
  39. package/dist/form.d.ts +32 -25
  40. package/dist/form.js +2 -3
  41. package/dist/history.cjs +38 -0
  42. package/dist/history.cjs.map +1 -0
  43. package/dist/history.d.cts +27 -0
  44. package/dist/history.d.ts +27 -0
  45. package/dist/history.js +27 -0
  46. package/dist/history.js.map +1 -0
  47. package/dist/i18n.cjs +26 -30
  48. package/dist/i18n.cjs.map +1 -1
  49. package/dist/i18n.d.cts +24 -21
  50. package/dist/i18n.d.ts +24 -21
  51. package/dist/i18n.js +24 -31
  52. package/dist/i18n.js.map +1 -1
  53. package/dist/index.cjs +213 -57
  54. package/dist/index.d.cts +32 -31
  55. package/dist/index.d.ts +32 -31
  56. package/dist/index.js +33 -29
  57. package/dist/inert-CmBEbKCn.cjs +19 -0
  58. package/dist/inert-CmBEbKCn.cjs.map +1 -0
  59. package/dist/inert-D8fkennb.js +14 -0
  60. package/dist/inert-D8fkennb.js.map +1 -0
  61. package/dist/interaction.cjs +48 -102
  62. package/dist/interaction.cjs.map +1 -1
  63. package/dist/interaction.d.cts +23 -32
  64. package/dist/interaction.d.ts +23 -32
  65. package/dist/interaction.js +33 -102
  66. package/dist/interaction.js.map +1 -1
  67. package/dist/link.cjs +65 -104
  68. package/dist/link.cjs.map +1 -1
  69. package/dist/link.d.cts +21 -16
  70. package/dist/link.d.ts +22 -17
  71. package/dist/link.js +67 -107
  72. package/dist/link.js.map +1 -1
  73. package/dist/measurement.cjs +56 -0
  74. package/dist/measurement.cjs.map +1 -0
  75. package/dist/measurement.d.cts +38 -0
  76. package/dist/measurement.d.ts +38 -0
  77. package/dist/measurement.js +42 -0
  78. package/dist/measurement.js.map +1 -0
  79. package/dist/metadata.cjs +20 -7
  80. package/dist/metadata.cjs.map +1 -1
  81. package/dist/metadata.d.cts +22 -7
  82. package/dist/metadata.d.ts +22 -7
  83. package/dist/metadata.js +20 -10
  84. package/dist/metadata.js.map +1 -1
  85. package/dist/page-edit.cjs +7 -3
  86. package/dist/page-edit.cjs.map +1 -1
  87. package/dist/page-edit.d.cts +6 -2
  88. package/dist/page-edit.d.ts +6 -2
  89. package/dist/page-edit.js +7 -4
  90. package/dist/page-edit.js.map +1 -1
  91. package/dist/page-layers-Bkaaz8Zf.js +26 -0
  92. package/dist/page-layers-Bkaaz8Zf.js.map +1 -0
  93. package/dist/page-layers-BloZDoOV.cjs +37 -0
  94. package/dist/page-layers-BloZDoOV.cjs.map +1 -0
  95. package/dist/page-view.cjs +89 -82
  96. package/dist/page-view.cjs.map +1 -1
  97. package/dist/page-view.d.cts +14 -7
  98. package/dist/page-view.d.ts +18 -11
  99. package/dist/page-view.js +86 -81
  100. package/dist/page-view.js.map +1 -1
  101. package/dist/redaction.cjs +30 -15
  102. package/dist/redaction.cjs.map +1 -1
  103. package/dist/redaction.d.cts +27 -9
  104. package/dist/redaction.d.ts +27 -9
  105. package/dist/redaction.js +29 -18
  106. package/dist/redaction.js.map +1 -1
  107. package/dist/render.cjs +71 -46
  108. package/dist/render.cjs.map +1 -1
  109. package/dist/render.d.cts +17 -5
  110. package/dist/render.d.ts +17 -5
  111. package/dist/render.js +70 -49
  112. package/dist/render.js.map +1 -1
  113. package/dist/runtime-B6xcPsEb.js +398 -0
  114. package/dist/runtime-B6xcPsEb.js.map +1 -0
  115. package/dist/runtime-DBEBlpQV.d.cts +237 -0
  116. package/dist/runtime-V3MVMb91.d.ts +237 -0
  117. package/dist/runtime-fzpGv78v.cjs +555 -0
  118. package/dist/runtime-fzpGv78v.cjs.map +1 -0
  119. package/dist/runtime.cjs +45 -324
  120. package/dist/runtime.d.cts +2 -2
  121. package/dist/runtime.d.ts +2 -2
  122. package/dist/runtime.js +2 -306
  123. package/dist/search.cjs +81 -50
  124. package/dist/search.cjs.map +1 -1
  125. package/dist/search.d.cts +36 -24
  126. package/dist/search.d.ts +36 -24
  127. package/dist/search.js +81 -53
  128. package/dist/search.js.map +1 -1
  129. package/dist/selection.cjs +105 -108
  130. package/dist/selection.cjs.map +1 -1
  131. package/dist/selection.d.cts +54 -26
  132. package/dist/selection.d.ts +56 -28
  133. package/dist/selection.js +103 -110
  134. package/dist/selection.js.map +1 -1
  135. package/dist/shell.cjs +36 -21
  136. package/dist/shell.cjs.map +1 -1
  137. package/dist/shell.d.cts +32 -17
  138. package/dist/shell.d.ts +32 -17
  139. package/dist/shell.js +36 -24
  140. package/dist/shell.js.map +1 -1
  141. package/dist/signature.cjs +29 -48
  142. package/dist/signature.cjs.map +1 -1
  143. package/dist/signature.d.cts +26 -26
  144. package/dist/signature.d.ts +26 -26
  145. package/dist/signature.js +30 -48
  146. package/dist/signature.js.map +1 -1
  147. package/dist/stage-BIG6aeVd.cjs +369 -0
  148. package/dist/stage-BIG6aeVd.cjs.map +1 -0
  149. package/dist/stage-ByFPD-Fv.d.cts +117 -0
  150. package/dist/stage-DaboaheR.d.ts +117 -0
  151. package/dist/stage-DoVekb83.js +302 -0
  152. package/dist/stage-DoVekb83.js.map +1 -0
  153. package/dist/stage-scope-CQgCuf1w.cjs +46 -0
  154. package/dist/stage-scope-CQgCuf1w.cjs.map +1 -0
  155. package/dist/stage-scope-D7ZeNduT.js +23 -0
  156. package/dist/stage-scope-D7ZeNduT.js.map +1 -0
  157. package/dist/stage.cjs +12 -235
  158. package/dist/stage.d.cts +2 -116
  159. package/dist/stage.d.ts +2 -116
  160. package/dist/stage.js +3 -228
  161. package/dist/stamp.cjs +41 -35
  162. package/dist/stamp.cjs.map +1 -1
  163. package/dist/stamp.d.cts +25 -18
  164. package/dist/stamp.d.ts +25 -18
  165. package/dist/stamp.js +40 -37
  166. package/dist/stamp.js.map +1 -1
  167. package/dist/state-0K1I5cM4.d.cts +29 -0
  168. package/dist/state-0K1I5cM4.d.ts +29 -0
  169. package/dist/state-CbgxhwLA.js +62 -0
  170. package/dist/state-CbgxhwLA.js.map +1 -0
  171. package/dist/state-CsfZy_Eq.cjs +73 -0
  172. package/dist/state-CsfZy_Eq.cjs.map +1 -0
  173. package/dist/svg-shapes-Dm1yTR1b.js +40 -0
  174. package/dist/svg-shapes-Dm1yTR1b.js.map +1 -0
  175. package/dist/svg-shapes-zo0GNkc9.cjs +53 -0
  176. package/dist/svg-shapes-zo0GNkc9.cjs.map +1 -0
  177. package/dist/toolbar.cjs +297 -295
  178. package/dist/toolbar.cjs.map +1 -1
  179. package/dist/toolbar.d.cts +58 -68
  180. package/dist/toolbar.d.ts +67 -77
  181. package/dist/toolbar.js +271 -293
  182. package/dist/toolbar.js.map +1 -1
  183. package/dist/view-manager.cjs +34 -0
  184. package/dist/view-manager.cjs.map +1 -0
  185. package/dist/view-manager.d.cts +21 -0
  186. package/dist/view-manager.d.ts +21 -0
  187. package/dist/view-manager.js +23 -0
  188. package/dist/view-manager.js.map +1 -0
  189. package/package.json +41 -38
  190. package/dist/AnnotationListSnapshot-D3mFut1e-C_GMpK25.d.cts +0 -546
  191. package/dist/AnnotationListSnapshot-D3mFut1e-C_GMpK25.d.ts +0 -546
  192. package/dist/annotation-BCED_p9H.d.cts +0 -160
  193. package/dist/annotation-anchors-CetwM1g7.js +0 -15
  194. package/dist/annotation-anchors-CetwM1g7.js.map +0 -1
  195. package/dist/annotation-anchors-DuYRBJLl.cjs +0 -26
  196. package/dist/annotation-anchors-DuYRBJLl.cjs.map +0 -1
  197. package/dist/annotation-hooks-BB5ZhPpf.cjs +0 -16
  198. package/dist/annotation-hooks-BB5ZhPpf.cjs.map +0 -1
  199. package/dist/annotation-hooks-Df8EmzDO.js +0 -11
  200. package/dist/annotation-hooks-Df8EmzDO.js.map +0 -1
  201. package/dist/annotation-k38KDlIZ.d.ts +0 -160
  202. package/dist/annotation-menu.cjs +0 -64
  203. package/dist/annotation-menu.cjs.map +0 -1
  204. package/dist/annotation-menu.d.cts +0 -33
  205. package/dist/annotation-menu.d.ts +0 -33
  206. package/dist/annotation-menu.js +0 -48
  207. package/dist/annotation-menu.js.map +0 -1
  208. package/dist/annotation.cjs.map +0 -1
  209. package/dist/annotation.js.map +0 -1
  210. package/dist/form-BVumS7up.cjs +0 -926
  211. package/dist/form-BVumS7up.cjs.map +0 -1
  212. package/dist/form-CK3mp99m.js +0 -895
  213. package/dist/form-CK3mp99m.js.map +0 -1
  214. package/dist/rolldown-runtime-BBjsoOtd.js +0 -27
  215. package/dist/runtime-DE76hlnl.d.ts +0 -216
  216. package/dist/runtime-umHA_xHt.d.cts +0 -216
  217. package/dist/runtime.cjs.map +0 -1
  218. package/dist/runtime.js.map +0 -1
  219. package/dist/scrollbar.cjs +0 -241
  220. package/dist/scrollbar.cjs.map +0 -1
  221. package/dist/scrollbar.d.cts +0 -42
  222. package/dist/scrollbar.d.ts +0 -42
  223. package/dist/scrollbar.js +0 -213
  224. package/dist/scrollbar.js.map +0 -1
  225. package/dist/stage.cjs.map +0 -1
  226. package/dist/stage.js.map +0 -1
  227. package/dist/views.cjs +0 -35
  228. package/dist/views.cjs.map +0 -1
  229. package/dist/views.d.cts +0 -21
  230. package/dist/views.d.ts +0 -21
  231. package/dist/views.js +0 -27
  232. package/dist/views.js.map +0 -1
package/dist/runtime.cjs CHANGED
@@ -1,327 +1,50 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rolldown_runtime = require("./rolldown-runtime-DDXJien1.cjs");
3
- let react_jsx_runtime = require("react/jsx-runtime");
4
- let _embedpdf_core = require("@embedpdf/core");
5
- let react = require("react");
6
- react = require_rolldown_runtime.__toESM(react, 1);
7
- //#region src/runtime.tsx
8
- const KernelCtx = (0, react.createContext)(null);
9
- /** The document a subtree is bound to. null => use the active document. */
10
- const DocumentScopeCtx = (0, react.createContext)(null);
11
- function useKernel() {
12
- const k = (0, react.useContext)(KernelCtx);
13
- if (!k) throw new Error("useKernel must be used within <Viewer>/<EmbedPDF>");
14
- return k;
15
- }
16
- const shallowArray = (a, b) => a === b || a.length === b.length && a.every((x, i) => x === b[i]);
17
- /** Read a value derived from the kernel, cached by equality (no tearing loop). */
18
- function useKernelValue(select, isEqual = Object.is) {
19
- const kernel = useKernel();
20
- const last = (0, react.useRef)(null);
21
- const get = () => {
22
- const next = select(kernel);
23
- if (last.current && isEqual(last.current.v, next)) return last.current.v;
24
- last.current = { v: next };
25
- return next;
26
- };
27
- return (0, react.useSyncExternalStore)(kernel.subscribe, get, get);
28
- }
29
- function useActiveDocumentId() {
30
- return useKernelValue((k) => k.documents.activeId());
31
- }
32
- /** The document id for this subtree: the nearest <DocumentScope>, else the active doc. */
33
- function useDocumentId() {
34
- const scoped = (0, react.useContext)(DocumentScopeCtx);
35
- const active = useActiveDocumentId();
36
- return scoped ?? active;
37
- }
38
- /** Bind a subtree to a specific document (panes, comparison). */
39
- function DocumentScope({ id, children }) {
40
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocumentScopeCtx.Provider, {
41
- value: id,
42
- children
43
- });
44
- }
45
- /**
46
- * Render children only while this subtree has a READY document — the
47
- * structural way to say "this UI is defined over a document". An empty
48
- * workspace is a legitimate, designable state (the Viewer no longer blocks on
49
- * documents so chrome can render at t≈0): workspace-scoped UI (toolbars,
50
- * commands, i18n) lives OUTSIDE the gate; document-scoped UI (Stage, panels,
51
- * page chrome) lives inside it, or reads through `useOptionalSelector`.
52
- * A `loading`/`locked`/`error` tab renders `fallback` — so the gate's
53
- * fallback doubles as the per-tab boot state; richer chrome (a password
54
- * prompt, an error pane) branches on `useDocumentStatus()` beside the gate.
55
- * Sibling of <DocumentScope>, which picks WHICH document; this one handles
56
- * WHETHER.
57
- */
58
- function DocumentGate({ fallback = null, children }) {
59
- const docId = useDocumentId();
60
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: useKernelValue((k) => docId ? k.documents.get(docId)?.status === "ready" : false) ? children : fallback });
61
- }
62
- /** Lifecycle status of this subtree's document (loading/locked/ready/error),
63
- * or null with no document. The password prompt and error panes key off it. */
64
- function useDocumentStatus() {
65
- const docId = useDocumentId();
66
- return useKernelValue((k) => docId ? k.documents.get(docId)?.status ?? null : null);
67
- }
68
- /**
69
- * Resolve a capability by token, binding document-scoped ones to this
70
- * subtree's document. Resolution is a REACTIVE read (`tryCapability` through
71
- * the kernel's one change stream), not a memoized call — under the
72
- * request-time lifecycle a document can become resolvable while its id stays
73
- * the same, so any id-keyed cache goes stale; subscribing makes staleness
74
- * structurally impossible. Fail-fast: while unresolvable, this re-runs the
75
- * strict resolver so the kernel's truthful reason (`no capability` / `no
76
- * document` / `document is loading|locked`) is what throws.
77
- */
78
- function useCapability(token) {
79
- const kernel = useKernel();
80
- const scoped = (0, react.useContext)(DocumentScopeCtx);
81
- return useKernelValue((k) => k.tryCapability(token, scoped ?? void 0)) ?? kernel.capability(token, scoped ?? void 0);
82
- }
83
- /** Like `useCapability`, but null while the token can't resolve (no plugin,
84
- * no document, or a document that isn't ready yet). */
85
- function useOptionalCapability(token) {
86
- const scoped = (0, react.useContext)(DocumentScopeCtx);
87
- return useKernelValue((k) => k.tryCapability(token, scoped ?? void 0));
88
- }
89
- /** Subscribe to a selector over a (document-resolved) capability. */
90
- function useSelector(token, select, isEqual = Object.is) {
91
- const kernel = useKernel();
92
- const cap = useCapability(token);
93
- const last = (0, react.useRef)(null);
94
- const get = () => {
95
- const next = select(cap);
96
- if (last.current && isEqual(last.current.v, next)) return last.current.v;
97
- last.current = { v: next };
98
- return next;
99
- };
100
- return (0, react.useSyncExternalStore)(kernel.subscribe, get, get);
101
- }
102
- /**
103
- * Null-safe `useSelector`: `fallback` whenever the token can't resolve — no
104
- * provider, or a document-scoped token with no document. For chrome that stays
105
- * mounted across the empty-workspace state (a zoom readout, a mode band).
106
- * `useSelector` stays strict (fail-fast) for code that KNOWS a document exists
107
- * — e.g. anything inside a <DocumentGate>.
108
- *
109
- * The `select` guard also swallows reads through a capability whose document
110
- * closed between the store notification and this render — that teardown race
111
- * resolves to `fallback` for one frame, then re-renders against the new state.
112
- */
113
- function useOptionalSelector(token, select, fallback, isEqual = Object.is) {
114
- const kernel = useKernel();
115
- const cap = useOptionalCapability(token);
116
- const last = (0, react.useRef)(null);
117
- const get = () => {
118
- let next;
119
- if (cap === null) next = fallback;
120
- else try {
121
- next = select(cap);
122
- } catch {
123
- next = fallback;
124
- }
125
- if (last.current && isEqual(last.current.v, next)) return last.current.v;
126
- last.current = { v: next };
127
- return next;
128
- };
129
- return (0, react.useSyncExternalStore)(kernel.subscribe, get, get);
130
- }
131
- /**
132
- * Subscribe to a capability's {@link EventHook} for the mounted lifetime —
133
- * `useCapabilityEvent(ActionsToken, (c) => c.onAction, handler)`. Events
134
- * carry occurrences, never state (a late subscriber that needs the current
135
- * value uses `useSelector`). The handler rides a ref, so a fresh closure per
136
- * render never resubscribes. Null-safe: no plugin/document → no subscription.
137
- */
138
- function useCapabilityEvent(token, select, handler) {
139
- const cap = useOptionalCapability(token);
140
- const handlerRef = (0, react.useRef)(handler);
141
- handlerRef.current = handler;
142
- const selectRef = (0, react.useRef)(select);
143
- selectRef.current = select;
144
- (0, react.useEffect)(() => {
145
- if (!cap) return;
146
- return selectRef.current(cap)((event) => handlerRef.current(event));
147
- }, [cap]);
148
- }
149
- /** The document registry (open/close/active/list), reactive. */
150
- function useDocuments() {
151
- const kernel = useKernel();
152
- return {
153
- docs: useKernelValue((k) => k.documents.list(), _embedpdf_core.docInfoListEquals),
154
- activeId: useActiveDocumentId(),
155
- open: kernel.documents.open,
156
- unlock: kernel.documents.unlock,
157
- close: kernel.documents.close,
158
- setActive: kernel.documents.setActive,
159
- move: kernel.documents.move,
160
- swap: kernel.documents.swap,
161
- download: kernel.documents.download,
162
- downloadLayer: kernel.documents.downloadLayer
163
- };
164
- }
165
- /**
166
- * Owns the kernel as an EFFECT-scoped resource: each effect setup creates and
167
- * starts exactly one kernel; each cleanup destroys exactly that one. That is
168
- * the contract StrictMode exercises (two kernels in dev, the first fully
169
- * destroyed) — the kernel itself is never restarted after destroy.
170
- *
171
- * The kernel is published to context the moment it exists — before `start()`
172
- * resolves — so the `fallback` can use workspace capabilities (i18n copy on a
173
- * loading screen) exactly as before. The one exception is the very first
174
- * render, which happens before the effect: it renders nothing. Children mount
175
- * once `start()` resolves — which never touches the engine, so the shell is
176
- * alive while WASM compiles or the transport connects. `initialDocuments`
177
- * open in the BACKGROUND and stream into the registry (`useDocuments()` is
178
- * reactive); per-document loading UI is the Stage's job, not a root gate.
179
- *
180
- * ENGINE OWNERSHIP. When `engine` is a thunk, the Viewer OWNS it: each effect
181
- * setup constructs one engine (construction is synchronous and inert — boot
182
- * happens lazily inside the engine) and each cleanup destroys exactly that one
183
- * — after the kernel, so handles close first. When `engine` is an instance it
184
- * is BORROWED and never destroyed here; the Viewer only calls `warmup?.()` so
185
- * the WASM/transport boot overlaps plugin initialization. StrictMode's
186
- * double-mount therefore constructs two independent thunk engines and tears
187
- * the first fully down, matching the kernel's own effect-scoped lifecycle.
188
- * That means dev-only double resource use (two worker spawns, two font
189
- * fetches, briefly overlapping) — deliberate, because it is exactly the
190
- * leak-detection contract StrictMode exists to exercise; production mounts
191
- * once and boots once.
192
- */
193
- function Viewer({ engine, plugins, initialDocuments, fallback, renderError, children }) {
194
- const initial = (0, react.useRef)({
195
- engine,
196
- plugins,
197
- initialDocuments
198
- });
199
- const warned = (0, react.useRef)(false);
200
- if (process.env.NODE_ENV !== "production" && !warned.current) {
201
- if (initial.current.engine !== engine || initial.current.plugins !== plugins) {
202
- warned.current = true;
203
- console.warn("[embedpdf] <Viewer> engine/plugins are init-only. A changed identity is ignored — pass stable references (module scope, useState, or useMemo). An inline `plugins={[...]}` array recreates its identity every render.");
204
- }
2
+ const require_runtime = require("./runtime-fzpGv78v.cjs");
3
+ let _embedpdf_web = require("@embedpdf/web");
4
+ exports.DocumentGate = require_runtime.DocumentGate;
5
+ exports.DocumentScope = require_runtime.DocumentScope;
6
+ exports.EmbedPDF = require_runtime.EmbedPDF;
7
+ exports.KernelProvider = require_runtime.KernelProvider;
8
+ exports.PageProvider = require_runtime.PageProvider;
9
+ exports.Viewer = require_runtime.Viewer;
10
+ exports.epdfTheme = require_runtime.epdfTheme;
11
+ Object.defineProperty(exports, "makePageContext", {
12
+ enumerable: true,
13
+ get: function() {
14
+ return _embedpdf_web.makePageContext;
205
15
  }
206
- const [boot, setBoot] = (0, react.useState)({
207
- phase: "booting",
208
- kernel: null
209
- });
210
- (0, react.useEffect)(() => {
211
- const captured = initial.current;
212
- const ownsEngine = typeof captured.engine === "function";
213
- const engine = ownsEngine ? captured.engine() : captured.engine;
214
- engine.warmup?.();
215
- let kernel;
216
- try {
217
- kernel = (0, _embedpdf_core.createKernel)({
218
- engine,
219
- plugins: captured.plugins
220
- });
221
- } catch (error) {
222
- setBoot({
223
- phase: "error",
224
- error
225
- });
226
- if (ownsEngine) engine.destroy();
227
- return;
228
- }
229
- let alive = true;
230
- setBoot({
231
- phase: "booting",
232
- kernel
233
- });
234
- kernel.start().then(() => {
235
- if (!alive) return;
236
- setBoot({
237
- phase: "ready",
238
- kernel
239
- });
240
- kernel.documents.openAll(captured.initialDocuments ?? []);
241
- }, (error) => {
242
- if (alive) setBoot({
243
- phase: "error",
244
- error
245
- });
246
- });
247
- return () => {
248
- alive = false;
249
- kernel.destroy().then(() => {
250
- if (ownsEngine) engine.destroy();
251
- });
252
- };
253
- }, []);
254
- if (boot.phase === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: renderError ? renderError(boot.error) : null });
255
- if (!boot.kernel) return null;
256
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(KernelCtx.Provider, {
257
- value: boot.kernel,
258
- children: boot.phase === "ready" ? children : fallback ?? null
259
- });
260
- }
261
- const EmbedPDF = Viewer;
262
- const PageCtx = (0, react.createContext)(null);
263
- const PageProvider = PageCtx.Provider;
264
- function usePage() {
265
- const c = (0, react.useContext)(PageCtx);
266
- if (!c) throw new Error("usePage must be used inside <PageView> or a <Stage> page");
267
- return c;
268
- }
269
- function makePageContext(documentId, view, pon, pageIndex, frame, transform, getRect, getViewDemand) {
270
- return {
271
- documentId,
272
- view,
273
- pon,
274
- pageIndex,
275
- frame,
276
- transform,
277
- ...getViewDemand ? { getViewDemand } : {},
278
- toContentPoint: (cx, cy) => {
279
- const r = getRect();
280
- return transform.viewToContent({
281
- x: cx - r.left,
282
- y: cy - r.top
283
- });
284
- },
285
- toClientPoint: (p) => {
286
- const r = getRect();
287
- const v = transform.contentToView(p);
288
- return {
289
- x: r.left + v.x,
290
- y: r.top + v.y
291
- };
292
- },
293
- toClientRect: (rect) => {
294
- const r = getRect();
295
- const v = transform.contentToViewRect(rect);
296
- return {
297
- x: r.left + v.x,
298
- y: r.top + v.y,
299
- width: v.width,
300
- height: v.height
301
- };
302
- }
303
- };
304
- }
305
- //#endregion
306
- exports.DocumentGate = DocumentGate;
307
- exports.DocumentScope = DocumentScope;
308
- exports.EmbedPDF = EmbedPDF;
309
- exports.PageProvider = PageProvider;
310
- exports.Viewer = Viewer;
311
- exports.makePageContext = makePageContext;
312
- exports.shallowArray = shallowArray;
313
- exports.useActiveDocumentId = useActiveDocumentId;
314
- exports.useCapability = useCapability;
315
- exports.useCapabilityEvent = useCapabilityEvent;
316
- exports.useDocumentId = useDocumentId;
317
- exports.useDocumentStatus = useDocumentStatus;
318
- exports.useDocuments = useDocuments;
319
- exports.useKernel = useKernel;
320
- exports.useKernelValue = useKernelValue;
321
- exports.useOptionalCapability = useOptionalCapability;
322
- exports.useOptionalSelector = useOptionalSelector;
323
- exports.usePage = usePage;
324
- exports.useSelector = useSelector;
16
+ });
17
+ Object.defineProperty(exports, "mountWebFont", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return _embedpdf_web.mountWebFont;
21
+ }
22
+ });
23
+ Object.defineProperty(exports, "saveFile", {
24
+ enumerable: true,
25
+ get: function() {
26
+ return _embedpdf_web.saveFile;
27
+ }
28
+ });
29
+ exports.shallowArray = require_runtime.shallowArray;
30
+ exports.useActiveDocumentId = require_runtime.useActiveDocumentId;
31
+ exports.useCapability = require_runtime.useCapability;
32
+ exports.useCapabilityEvent = require_runtime.useCapabilityEvent;
33
+ exports.useDocument = require_runtime.useDocument;
34
+ exports.useDocumentId = require_runtime.useDocumentId;
35
+ exports.useDocumentScope = require_runtime.useDocumentScope;
36
+ exports.useDocuments = require_runtime.useDocuments;
37
+ exports.useDocumentsEvent = require_runtime.useDocumentsEvent;
38
+ exports.useDocumentsState = require_runtime.useDocumentsState;
39
+ exports.useKernel = require_runtime.useKernel;
40
+ exports.useKernelValue = require_runtime.useKernelValue;
41
+ exports.useOptionalCapability = require_runtime.useOptionalCapability;
42
+ exports.useOptionalSelector = require_runtime.useOptionalSelector;
43
+ exports.usePage = require_runtime.usePage;
44
+ exports.usePageList = require_runtime.usePageList;
45
+ exports.useSelector = require_runtime.useSelector;
46
+ exports.useViewerSettings = require_runtime.useViewerSettings;
47
+ var _embedpdf_core = require("@embedpdf/core");
325
48
  Object.keys(_embedpdf_core).forEach(function(k) {
326
49
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
327
50
  enumerable: true,
@@ -330,5 +53,3 @@ Object.keys(_embedpdf_core).forEach(function(k) {
330
53
  }
331
54
  });
332
55
  });
333
-
334
- //# sourceMappingURL=runtime.cjs.map
@@ -1,3 +1,3 @@
1
- import { C as usePage, S as useOptionalSelector, _ as useDocumentStatus, a as EmbedPDF, b as useKernelValue, c as Viewer, f as shallowArray, g as useDocumentId, h as useCapabilityEvent, i as DocumentScopeProps, l as ViewerProps, m as useCapability, n as DocumentGateProps, o as PageContextValue, p as useActiveDocumentId, r as DocumentScope, s as PageProvider, t as DocumentGate, u as makePageContext, v as useDocuments, w as useSelector, x as useOptionalCapability, y as useKernel } from "./runtime-umHA_xHt.cjs";
1
+ import { A as usePageList, C as useDocumentsEvent, D as useOptionalCapability, E as useKernelValue, M as useViewerSettings, N as EpdfTheme, O as useOptionalSelector, P as epdfTheme, S as useDocuments, T as useKernel, _ as useCapability, a as EmbedPDF, b as useDocumentId, c as PageContextValue, d as ViewerProps, f as makePageContext, g as useActiveDocumentId, h as shallowArray, i as DocumentScopeProps, j as useSelector, k as usePage, l as PageProvider, m as saveFile, n as DocumentGateProps, o as KernelProvider, p as mountWebFont, r as DocumentScope, s as KernelProviderProps, t as DocumentGate, u as Viewer, v as useCapabilityEvent, w as useDocumentsState, x as useDocumentScope, y as useDocument } from "./runtime-DBEBlpQV.cjs";
2
2
  export * from "@embedpdf/core";
3
- export { DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, PageContextValue, PageProvider, Viewer, ViewerProps, makePageContext, shallowArray, useActiveDocumentId, useCapability, useCapabilityEvent, useDocumentId, useDocumentStatus, useDocuments, useKernel, useKernelValue, useOptionalCapability, useOptionalSelector, usePage, useSelector };
3
+ export { DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, type EpdfTheme, KernelProvider, KernelProviderProps, PageContextValue, PageProvider, Viewer, ViewerProps, epdfTheme, makePageContext, mountWebFont, saveFile, shallowArray, useActiveDocumentId, useCapability, useCapabilityEvent, useDocument, useDocumentId, useDocumentScope, useDocuments, useDocumentsEvent, useDocumentsState, useKernel, useKernelValue, useOptionalCapability, useOptionalSelector, usePage, usePageList, useSelector, useViewerSettings };
package/dist/runtime.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { C as usePage, S as useOptionalSelector, _ as useDocumentStatus, a as EmbedPDF, b as useKernelValue, c as Viewer, f as shallowArray, g as useDocumentId, h as useCapabilityEvent, i as DocumentScopeProps, l as ViewerProps, m as useCapability, n as DocumentGateProps, o as PageContextValue, p as useActiveDocumentId, r as DocumentScope, s as PageProvider, t as DocumentGate, u as makePageContext, v as useDocuments, w as useSelector, x as useOptionalCapability, y as useKernel } from "./runtime-DE76hlnl.js";
1
+ import { A as usePageList, C as useDocumentsEvent, D as useOptionalCapability, E as useKernelValue, M as useViewerSettings, N as EpdfTheme, O as useOptionalSelector, P as epdfTheme, S as useDocuments, T as useKernel, _ as useCapability, a as EmbedPDF, b as useDocumentId, c as PageContextValue, d as ViewerProps, f as makePageContext, g as useActiveDocumentId, h as shallowArray, i as DocumentScopeProps, j as useSelector, k as usePage, l as PageProvider, m as saveFile, n as DocumentGateProps, o as KernelProvider, p as mountWebFont, r as DocumentScope, s as KernelProviderProps, t as DocumentGate, u as Viewer, v as useCapabilityEvent, w as useDocumentsState, x as useDocumentScope, y as useDocument } from "./runtime-V3MVMb91.js";
2
2
  export * from "@embedpdf/core";
3
- export { DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, PageContextValue, PageProvider, Viewer, ViewerProps, makePageContext, shallowArray, useActiveDocumentId, useCapability, useCapabilityEvent, useDocumentId, useDocumentStatus, useDocuments, useKernel, useKernelValue, useOptionalCapability, useOptionalSelector, usePage, useSelector };
3
+ export { DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, type EpdfTheme, KernelProvider, KernelProviderProps, PageContextValue, PageProvider, Viewer, ViewerProps, epdfTheme, makePageContext, mountWebFont, saveFile, shallowArray, useActiveDocumentId, useCapability, useCapabilityEvent, useDocument, useDocumentId, useDocumentScope, useDocuments, useDocumentsEvent, useDocumentsState, useKernel, useKernelValue, useOptionalCapability, useOptionalSelector, usePage, usePageList, useSelector, useViewerSettings };