@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
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-BfnpyfY0.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 };