@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.
- package/dist/AnnotationList-DcyhF2kU-CiBFOq1z.d.cts +878 -0
- package/dist/AnnotationList-DcyhF2kU-CiBFOq1z.d.ts +878 -0
- package/dist/actions.cjs +25 -5
- package/dist/actions.cjs.map +1 -1
- package/dist/actions.d.cts +18 -5
- package/dist/actions.d.ts +18 -5
- package/dist/actions.js +22 -6
- package/dist/actions.js.map +1 -1
- package/dist/anchored-DeX95xSd.d.ts +85 -0
- package/dist/anchored-DzN3JywS.d.cts +85 -0
- package/dist/anchored.cjs +71 -28
- package/dist/anchored.cjs.map +1 -1
- package/dist/anchored.d.cts +2 -45
- package/dist/anchored.d.ts +2 -45
- package/dist/anchored.js +56 -19
- package/dist/anchored.js.map +1 -1
- package/dist/annotation-3UvABfJm.d.cts +305 -0
- package/dist/annotation-BNHQpMKv.cjs +806 -0
- package/dist/annotation-BNHQpMKv.cjs.map +1 -0
- package/dist/annotation-CDI8CFb3.js +684 -0
- package/dist/annotation-CDI8CFb3.js.map +1 -0
- package/dist/annotation-DhEfs0pH.d.ts +305 -0
- package/dist/annotation.cjs +20 -784
- package/dist/annotation.d.cts +2 -2
- package/dist/annotation.d.ts +2 -2
- package/dist/annotation.js +2 -769
- package/dist/attachment.cjs +39 -0
- package/dist/attachment.cjs.map +1 -0
- package/dist/attachment.d.cts +29 -0
- package/dist/attachment.d.ts +29 -0
- package/dist/attachment.js +28 -0
- package/dist/attachment.js.map +1 -0
- package/dist/commands.cjs +68 -28
- package/dist/commands.cjs.map +1 -1
- package/dist/commands.d.cts +37 -10
- package/dist/commands.d.ts +37 -10
- package/dist/commands.js +68 -31
- package/dist/commands.js.map +1 -1
- package/dist/form-BSGvjA5D.js +511 -0
- package/dist/form-BSGvjA5D.js.map +1 -0
- package/dist/form-BgztZyOK.cjs +548 -0
- package/dist/form-BgztZyOK.cjs.map +1 -0
- package/dist/form.cjs +5 -5
- package/dist/form.d.cts +41 -2
- package/dist/form.d.ts +41 -2
- package/dist/form.js +2 -3
- package/dist/history.cjs +38 -0
- package/dist/history.cjs.map +1 -0
- package/dist/history.d.cts +27 -0
- package/dist/history.d.ts +27 -0
- package/dist/history.js +27 -0
- package/dist/history.js.map +1 -0
- package/dist/i18n.cjs +26 -30
- package/dist/i18n.cjs.map +1 -1
- package/dist/i18n.d.cts +24 -21
- package/dist/i18n.d.ts +24 -21
- package/dist/i18n.js +24 -31
- package/dist/i18n.js.map +1 -1
- package/dist/index.cjs +227 -57
- package/dist/index.d.cts +35 -32
- package/dist/index.d.ts +35 -32
- package/dist/index.js +36 -30
- package/dist/inert-CmBEbKCn.cjs +19 -0
- package/dist/inert-CmBEbKCn.cjs.map +1 -0
- package/dist/inert-D8fkennb.js +14 -0
- package/dist/inert-D8fkennb.js.map +1 -0
- package/dist/interaction.cjs +48 -102
- package/dist/interaction.cjs.map +1 -1
- package/dist/interaction.d.cts +23 -32
- package/dist/interaction.d.ts +23 -32
- package/dist/interaction.js +33 -102
- package/dist/interaction.js.map +1 -1
- package/dist/link.cjs +65 -104
- package/dist/link.cjs.map +1 -1
- package/dist/link.d.cts +21 -16
- package/dist/link.d.ts +22 -17
- package/dist/link.js +67 -107
- package/dist/link.js.map +1 -1
- package/dist/measurement.cjs +36 -11
- package/dist/measurement.cjs.map +1 -1
- package/dist/measurement.d.cts +33 -7
- package/dist/measurement.d.ts +33 -7
- package/dist/measurement.js +35 -14
- package/dist/measurement.js.map +1 -1
- package/dist/metadata.cjs +20 -7
- package/dist/metadata.cjs.map +1 -1
- package/dist/metadata.d.cts +22 -7
- package/dist/metadata.d.ts +22 -7
- package/dist/metadata.js +20 -10
- package/dist/metadata.js.map +1 -1
- package/dist/outline.cjs +39 -0
- package/dist/outline.cjs.map +1 -0
- package/dist/outline.d.cts +31 -0
- package/dist/outline.d.ts +31 -0
- package/dist/outline.js +28 -0
- package/dist/outline.js.map +1 -0
- package/dist/page-edit.cjs +15 -3
- package/dist/page-edit.cjs.map +1 -1
- package/dist/page-edit.d.cts +17 -2
- package/dist/page-edit.d.ts +17 -2
- package/dist/page-edit.js +15 -5
- package/dist/page-edit.js.map +1 -1
- package/dist/page-layers-Bkaaz8Zf.js +26 -0
- package/dist/page-layers-Bkaaz8Zf.js.map +1 -0
- package/dist/page-layers-BloZDoOV.cjs +37 -0
- package/dist/page-layers-BloZDoOV.cjs.map +1 -0
- package/dist/page-view.cjs +89 -82
- package/dist/page-view.cjs.map +1 -1
- package/dist/page-view.d.cts +14 -7
- package/dist/page-view.d.ts +18 -11
- package/dist/page-view.js +86 -81
- package/dist/page-view.js.map +1 -1
- package/dist/redaction.cjs +30 -15
- package/dist/redaction.cjs.map +1 -1
- package/dist/redaction.d.cts +27 -9
- package/dist/redaction.d.ts +27 -9
- package/dist/redaction.js +29 -18
- package/dist/redaction.js.map +1 -1
- package/dist/render.cjs +71 -46
- package/dist/render.cjs.map +1 -1
- package/dist/render.d.cts +17 -5
- package/dist/render.d.ts +17 -5
- package/dist/render.js +70 -49
- package/dist/render.js.map +1 -1
- package/dist/runtime-BfnpyfY0.cjs +556 -0
- package/dist/runtime-BfnpyfY0.cjs.map +1 -0
- package/dist/runtime-DBEBlpQV.d.cts +237 -0
- package/dist/runtime-V3MVMb91.d.ts +237 -0
- package/dist/runtime-tD5iJU83.js +399 -0
- package/dist/runtime-tD5iJU83.js.map +1 -0
- package/dist/runtime.cjs +45 -324
- package/dist/runtime.d.cts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +2 -306
- package/dist/search.cjs +81 -50
- package/dist/search.cjs.map +1 -1
- package/dist/search.d.cts +37 -24
- package/dist/search.d.ts +37 -24
- package/dist/search.js +81 -53
- package/dist/search.js.map +1 -1
- package/dist/selection.cjs +105 -108
- package/dist/selection.cjs.map +1 -1
- package/dist/selection.d.cts +54 -26
- package/dist/selection.d.ts +56 -28
- package/dist/selection.js +103 -110
- package/dist/selection.js.map +1 -1
- package/dist/shell.cjs +36 -21
- package/dist/shell.cjs.map +1 -1
- package/dist/shell.d.cts +32 -17
- package/dist/shell.d.ts +32 -17
- package/dist/shell.js +36 -24
- package/dist/shell.js.map +1 -1
- package/dist/signature.cjs +29 -48
- package/dist/signature.cjs.map +1 -1
- package/dist/signature.d.cts +26 -26
- package/dist/signature.d.ts +26 -26
- package/dist/signature.js +30 -48
- package/dist/signature.js.map +1 -1
- package/dist/stage-B7BG2e8Q.cjs +369 -0
- package/dist/stage-B7BG2e8Q.cjs.map +1 -0
- package/dist/stage-BqfBjDu6.js +302 -0
- package/dist/stage-BqfBjDu6.js.map +1 -0
- package/dist/stage-ByFPD-Fv.d.cts +117 -0
- package/dist/stage-DaboaheR.d.ts +117 -0
- package/dist/stage-scope-CQgCuf1w.cjs +46 -0
- package/dist/stage-scope-CQgCuf1w.cjs.map +1 -0
- package/dist/stage-scope-D7ZeNduT.js +23 -0
- package/dist/stage-scope-D7ZeNduT.js.map +1 -0
- package/dist/stage.cjs +12 -235
- package/dist/stage.d.cts +2 -116
- package/dist/stage.d.ts +2 -116
- package/dist/stage.js +3 -228
- package/dist/stamp.cjs +41 -35
- package/dist/stamp.cjs.map +1 -1
- package/dist/stamp.d.cts +25 -18
- package/dist/stamp.d.ts +25 -18
- package/dist/stamp.js +40 -37
- package/dist/stamp.js.map +1 -1
- package/dist/state-0K1I5cM4.d.cts +29 -0
- package/dist/state-0K1I5cM4.d.ts +29 -0
- package/dist/state-CzI2KlZb.js +62 -0
- package/dist/state-CzI2KlZb.js.map +1 -0
- package/dist/state-Dtf8HAue.cjs +73 -0
- package/dist/state-Dtf8HAue.cjs.map +1 -0
- package/dist/svg-shapes-Dm1yTR1b.js +40 -0
- package/dist/svg-shapes-Dm1yTR1b.js.map +1 -0
- package/dist/svg-shapes-zo0GNkc9.cjs +53 -0
- package/dist/svg-shapes-zo0GNkc9.cjs.map +1 -0
- package/dist/toolbar.cjs +297 -295
- package/dist/toolbar.cjs.map +1 -1
- package/dist/toolbar.d.cts +58 -68
- package/dist/toolbar.d.ts +67 -77
- package/dist/toolbar.js +271 -293
- package/dist/toolbar.js.map +1 -1
- package/dist/view-manager.cjs +34 -0
- package/dist/view-manager.cjs.map +1 -0
- package/dist/view-manager.d.cts +21 -0
- package/dist/view-manager.d.ts +21 -0
- package/dist/view-manager.js +23 -0
- package/dist/view-manager.js.map +1 -0
- package/package.json +47 -39
- package/dist/annotation-BCED_p9H.d.cts +0 -160
- package/dist/annotation-anchors-CetwM1g7.js +0 -15
- package/dist/annotation-anchors-CetwM1g7.js.map +0 -1
- package/dist/annotation-anchors-DuYRBJLl.cjs +0 -26
- package/dist/annotation-anchors-DuYRBJLl.cjs.map +0 -1
- package/dist/annotation-hooks-BB5ZhPpf.cjs +0 -16
- package/dist/annotation-hooks-BB5ZhPpf.cjs.map +0 -1
- package/dist/annotation-hooks-Df8EmzDO.js +0 -11
- package/dist/annotation-hooks-Df8EmzDO.js.map +0 -1
- package/dist/annotation-k38KDlIZ.d.ts +0 -160
- package/dist/annotation-menu.cjs +0 -64
- package/dist/annotation-menu.cjs.map +0 -1
- package/dist/annotation-menu.d.cts +0 -33
- package/dist/annotation-menu.d.ts +0 -33
- package/dist/annotation-menu.js +0 -48
- package/dist/annotation-menu.js.map +0 -1
- package/dist/annotation.cjs.map +0 -1
- package/dist/annotation.js.map +0 -1
- package/dist/form-BVumS7up.cjs +0 -926
- package/dist/form-BVumS7up.cjs.map +0 -1
- package/dist/form-Bdjk0Z3T.d.cts +0 -537
- package/dist/form-CK3mp99m.js +0 -895
- package/dist/form-CK3mp99m.js.map +0 -1
- package/dist/form-CYRYgthn.d.ts +0 -537
- package/dist/rolldown-runtime-BBjsoOtd.js +0 -27
- package/dist/runtime-DE76hlnl.d.ts +0 -216
- package/dist/runtime-umHA_xHt.d.cts +0 -216
- package/dist/runtime.cjs.map +0 -1
- package/dist/runtime.js.map +0 -1
- package/dist/scrollbar.cjs +0 -241
- package/dist/scrollbar.cjs.map +0 -1
- package/dist/scrollbar.d.cts +0 -42
- package/dist/scrollbar.d.ts +0 -42
- package/dist/scrollbar.js +0 -213
- package/dist/scrollbar.js.map +0 -1
- package/dist/stage.cjs.map +0 -1
- package/dist/stage.js.map +0 -1
- package/dist/views.cjs +0 -35
- package/dist/views.cjs.map +0 -1
- package/dist/views.d.cts +0 -21
- package/dist/views.d.ts +0 -21
- package/dist/views.js +0 -27
- package/dist/views.js.map +0 -1
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-DDXJien1.cjs");
|
|
2
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
3
|
+
let _embedpdf_core = require("@embedpdf/core");
|
|
4
|
+
let _embedpdf_web = require("@embedpdf/web");
|
|
5
|
+
let react = require("react");
|
|
6
|
+
react = require_rolldown_runtime.__toESM(react, 1);
|
|
7
|
+
//#region src/theme.ts
|
|
8
|
+
/**
|
|
9
|
+
* The CSS variables of a theme, for a `style` prop: `<div style={epdfTheme({ accent })}>`.
|
|
10
|
+
* Everything inside the element follows them, and a CSS variable wins over any setting.
|
|
11
|
+
*/
|
|
12
|
+
function epdfTheme(theme) {
|
|
13
|
+
return (0, _embedpdf_web.epdfThemeVariables)(theme);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/dev.ts
|
|
17
|
+
/**
|
|
18
|
+
* Development-time guardrails. Every warning fires once per process (keyed),
|
|
19
|
+
* says what is wrong and what to do instead, and compiles out of production
|
|
20
|
+
* builds ({@link isDev}).
|
|
21
|
+
*/
|
|
22
|
+
const warned = /* @__PURE__ */ new Set();
|
|
23
|
+
/**
|
|
24
|
+
* Whether this is a development build, as the app's bundler says: every bundler replaces
|
|
25
|
+
* `process.env.NODE_ENV`, with `"production"` in a production build, so there this is `false`
|
|
26
|
+
* and the warnings behind it compile out. A page with no bundler has no `process` at all, and
|
|
27
|
+
* counts as development: the warnings help most while you try the package out.
|
|
28
|
+
*/
|
|
29
|
+
function isDev() {
|
|
30
|
+
try {
|
|
31
|
+
return process.env.NODE_ENV !== "production";
|
|
32
|
+
} catch {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Warn once per key. No-op in production. */
|
|
37
|
+
function devWarn(key, message) {
|
|
38
|
+
if (!isDev() || warned.has(key)) return;
|
|
39
|
+
warned.add(key);
|
|
40
|
+
console.warn(`[embedpdf] ${message}`);
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/runtime.tsx
|
|
44
|
+
const KernelCtx = (0, react.createContext)(null);
|
|
45
|
+
/** The document a subtree is bound to. null => use the active document. */
|
|
46
|
+
const DocumentScopeCtx = (0, react.createContext)(null);
|
|
47
|
+
function useKernel() {
|
|
48
|
+
const kernel = (0, react.useContext)(KernelCtx);
|
|
49
|
+
if (!kernel) throw new Error("useKernel must be used within <Viewer>/<EmbedPDF>");
|
|
50
|
+
return kernel;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Give a subtree a kernel someone else created and owns, so every hook in it
|
|
54
|
+
* works against that kernel. The full viewer's wrapper puts the children it
|
|
55
|
+
* slots into the viewer inside one. The provider never starts or destroys the
|
|
56
|
+
* kernel; `<Viewer>` is the component that owns one.
|
|
57
|
+
*/
|
|
58
|
+
function KernelProvider({ kernel, children }) {
|
|
59
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(KernelCtx.Provider, {
|
|
60
|
+
value: kernel,
|
|
61
|
+
children
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const shallowArray = (left, right) => left === right || left.length === right.length && left.every((item, i) => item === right[i]);
|
|
65
|
+
/** Read a value derived from the kernel, cached by equality (no tearing loop). */
|
|
66
|
+
function useKernelValue(select, isEqual = Object.is) {
|
|
67
|
+
const kernel = useKernel();
|
|
68
|
+
const last = (0, react.useRef)(null);
|
|
69
|
+
const get = () => {
|
|
70
|
+
const next = select(kernel);
|
|
71
|
+
if (last.current && isEqual(last.current.v, next)) return last.current.v;
|
|
72
|
+
last.current = { v: next };
|
|
73
|
+
return next;
|
|
74
|
+
};
|
|
75
|
+
return (0, react.useSyncExternalStore)(kernel.subscribe, get, get);
|
|
76
|
+
}
|
|
77
|
+
function useActiveDocumentId() {
|
|
78
|
+
return useKernelValue((kernel) => kernel.documents.getActiveId());
|
|
79
|
+
}
|
|
80
|
+
/** The document id for this subtree: the nearest <DocumentScope>, else the active doc. */
|
|
81
|
+
function useDocumentId() {
|
|
82
|
+
const scoped = useDocumentScope();
|
|
83
|
+
const active = useActiveDocumentId();
|
|
84
|
+
return scoped ?? active;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The document the nearest <DocumentScope> binds this subtree to, or null when
|
|
88
|
+
* it follows the active document. For resolvers that pass it to
|
|
89
|
+
* `kernel.tryCapability`, which reads the active document at call time; UI
|
|
90
|
+
* that needs the id itself uses {@link useDocumentId}.
|
|
91
|
+
*/
|
|
92
|
+
function useDocumentScope() {
|
|
93
|
+
return (0, react.useContext)(DocumentScopeCtx);
|
|
94
|
+
}
|
|
95
|
+
/** Bind a subtree to a specific document (panes, comparison). */
|
|
96
|
+
function DocumentScope({ id, children }) {
|
|
97
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocumentScopeCtx.Provider, {
|
|
98
|
+
value: id,
|
|
99
|
+
children
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Render children only while this subtree has a ready document — the
|
|
104
|
+
* structural way to say "this UI is defined over a document". An empty
|
|
105
|
+
* workspace is a legitimate, designable state (the Viewer no longer blocks on
|
|
106
|
+
* documents so chrome can render at t≈0): workspace-scoped UI (toolbars,
|
|
107
|
+
* commands, i18n) lives outside the gate; document-scoped UI (Stage, panels,
|
|
108
|
+
* page chrome) lives inside it. A document that waits for its password, or
|
|
109
|
+
* failed, renders `locked` or `error` with it, or else `fallback`. Sibling of
|
|
110
|
+
* <DocumentScope>, which picks which document; this one handles whether.
|
|
111
|
+
*/
|
|
112
|
+
function DocumentGate({ fallback = null, locked, error, children }) {
|
|
113
|
+
const document = useDocument();
|
|
114
|
+
if (document.status === "ready") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children });
|
|
115
|
+
if (document.status === "locked" && locked) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: locked(document) });
|
|
116
|
+
if (document.status === "error" && error) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: error(document) });
|
|
117
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: fallback });
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Resolve a capability by token, binding document-scoped ones to this
|
|
121
|
+
* subtree's document. Resolution is a reactive read (`tryCapability` through
|
|
122
|
+
* the kernel's one change stream), not a memoized call — under the
|
|
123
|
+
* request-time lifecycle a document can become resolvable while its id stays
|
|
124
|
+
* the same, so any id-keyed cache goes stale; subscribing makes staleness
|
|
125
|
+
* structurally impossible.
|
|
126
|
+
*
|
|
127
|
+
* Outside a document (none open, not ready yet, or none in scope), a document
|
|
128
|
+
* plugin resolves to its stand-in (`standInFor` from `@embedpdf/core`):
|
|
129
|
+
* rendering never fails, and a method called too early refuses with
|
|
130
|
+
* `not-ready` (a method that returns a promise rejects). A token no plugin
|
|
131
|
+
* provides still throws the kernel's reason, because that is a setup mistake.
|
|
132
|
+
*/
|
|
133
|
+
function useCapability(token) {
|
|
134
|
+
const kernel = useKernel();
|
|
135
|
+
const capability = useOptionalCapability(token);
|
|
136
|
+
if (capability) return capability;
|
|
137
|
+
if (kernel.scopeOf(token) === "document") return (0, _embedpdf_core.standInFor)(kernel, token);
|
|
138
|
+
return kernel.capability(token);
|
|
139
|
+
}
|
|
140
|
+
/** Like `useCapability`, but null while the token can't resolve (no plugin,
|
|
141
|
+
* no document, or a document that isn't ready yet). */
|
|
142
|
+
function useOptionalCapability(token) {
|
|
143
|
+
const scoped = useDocumentScope();
|
|
144
|
+
return useKernelValue((kernel) => kernel.tryCapability(token, scoped ?? void 0));
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Subscribe to a selector over a (document-resolved) capability. Strict:
|
|
148
|
+
* while the token can't resolve, it throws the kernel's reason (`no
|
|
149
|
+
* document`, `document is loading`), for code that knows a document exists,
|
|
150
|
+
* such as anything inside a <DocumentGate>. `useOptionalSelector` is its
|
|
151
|
+
* total twin.
|
|
152
|
+
*/
|
|
153
|
+
function useSelector(token, select, isEqual = Object.is) {
|
|
154
|
+
const kernel = useKernel();
|
|
155
|
+
const scoped = useDocumentScope();
|
|
156
|
+
const capability = useOptionalCapability(token) ?? kernel.capability(token, scoped ?? void 0);
|
|
157
|
+
const last = (0, react.useRef)(null);
|
|
158
|
+
const get = () => {
|
|
159
|
+
const next = select(capability);
|
|
160
|
+
if (last.current && isEqual(last.current.v, next)) return last.current.v;
|
|
161
|
+
last.current = { v: next };
|
|
162
|
+
return next;
|
|
163
|
+
};
|
|
164
|
+
return (0, react.useSyncExternalStore)(kernel.subscribe, get, get);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Null-safe `useSelector`: `fallback` whenever the token can't resolve — no
|
|
168
|
+
* provider, or a document-scoped token with no document. For chrome that stays
|
|
169
|
+
* mounted across the empty-workspace state (a zoom readout, a mode band).
|
|
170
|
+
*
|
|
171
|
+
* The `select` guard also swallows reads through a capability whose document
|
|
172
|
+
* closed between the store notification and this render — that teardown race
|
|
173
|
+
* resolves to `fallback` for one frame, then re-renders against the new state.
|
|
174
|
+
*/
|
|
175
|
+
function useOptionalSelector(token, select, fallback, isEqual = Object.is) {
|
|
176
|
+
const kernel = useKernel();
|
|
177
|
+
const capability = useOptionalCapability(token);
|
|
178
|
+
const last = (0, react.useRef)(null);
|
|
179
|
+
const get = () => {
|
|
180
|
+
let next;
|
|
181
|
+
if (capability === null) next = fallback;
|
|
182
|
+
else try {
|
|
183
|
+
next = select(capability);
|
|
184
|
+
} catch {
|
|
185
|
+
next = fallback;
|
|
186
|
+
}
|
|
187
|
+
if (last.current && isEqual(last.current.v, next)) return last.current.v;
|
|
188
|
+
last.current = { v: next };
|
|
189
|
+
return next;
|
|
190
|
+
};
|
|
191
|
+
return (0, react.useSyncExternalStore)(kernel.subscribe, get, get);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Subscribe to a capability's {@link EventHook} for the mounted lifetime —
|
|
195
|
+
* `useCapabilityEvent(ActionsToken, (actions) => actions.onExecuted, handler)`. Events
|
|
196
|
+
* carry occurrences, never state (a late subscriber that needs the current
|
|
197
|
+
* value uses `useSelector`). The handler rides a ref, so a fresh closure per
|
|
198
|
+
* render never resubscribes. Null-safe: no plugin/document → no subscription.
|
|
199
|
+
*/
|
|
200
|
+
function useCapabilityEvent(token, select, handler) {
|
|
201
|
+
const capability = useOptionalCapability(token);
|
|
202
|
+
const handlerRef = (0, react.useRef)(handler);
|
|
203
|
+
handlerRef.current = handler;
|
|
204
|
+
const selectRef = (0, react.useRef)(select);
|
|
205
|
+
selectRef.current = select;
|
|
206
|
+
(0, react.useEffect)(() => {
|
|
207
|
+
if (!capability) return;
|
|
208
|
+
return selectRef.current(capability)((event) => handlerRef.current(event));
|
|
209
|
+
}, [capability]);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The documents API: open, close, unlock, download, and the tabs. Inside a
|
|
213
|
+
* <DocumentScope>, the calls that leave out the document use that one, so
|
|
214
|
+
* `download()` without an id downloads the document in scope. The object
|
|
215
|
+
* never changes, so it's safe in effects and callbacks. What to show comes
|
|
216
|
+
* from `useDocument()` and `useDocumentsState()`.
|
|
217
|
+
*/
|
|
218
|
+
function useDocuments() {
|
|
219
|
+
return useCapability(_embedpdf_core.DocumentsToken);
|
|
220
|
+
}
|
|
221
|
+
/** Read a state declaration's value through the kernel, or the value `select` picks from it. */
|
|
222
|
+
function useDeclared(token, read, empty, select) {
|
|
223
|
+
const scoped = useDocumentScope();
|
|
224
|
+
return useKernelValue((kernel) => {
|
|
225
|
+
const capability = kernel.tryCapability(token, scoped ?? void 0);
|
|
226
|
+
const state = capability ? read(capability) : empty;
|
|
227
|
+
return select ? select(state) : state;
|
|
228
|
+
}, _embedpdf_core.shallowEqual);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* The document this component talks to: the one its <DocumentScope> names, or
|
|
232
|
+
* else the active one. Its `id`, `name`, `status`, `pageCount`,
|
|
233
|
+
* `hasUnsavedChanges`, and why it's locked or failed. With no document, an
|
|
234
|
+
* empty one that reads as still opening. Takes a selector, and re-renders only
|
|
235
|
+
* when what it returns changes.
|
|
236
|
+
*/
|
|
237
|
+
function useDocument(select) {
|
|
238
|
+
return useDeclared(_embedpdf_core.DocumentsToken, _embedpdf_core.documentState.read, _embedpdf_core.documentState.empty, select);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Every open document, in tab order (loading, locked and failed ones too),
|
|
242
|
+
* and the active one's id. Takes a selector, and re-renders only when what it
|
|
243
|
+
* returns changes.
|
|
244
|
+
*/
|
|
245
|
+
function useDocumentsState(select) {
|
|
246
|
+
return useDeclared(_embedpdf_core.DocumentsToken, _embedpdf_core.documentsState.read, _embedpdf_core.documentsState.empty, select);
|
|
247
|
+
}
|
|
248
|
+
/** Subscribe to one documents event for the mounted lifetime: `useDocumentsEvent((documents) => documents.onOpened, handler)`. */
|
|
249
|
+
function useDocumentsEvent(select, handler) {
|
|
250
|
+
useCapabilityEvent(_embedpdf_core.DocumentsToken, select, handler);
|
|
251
|
+
}
|
|
252
|
+
const NO_PAGES = Object.freeze([]);
|
|
253
|
+
/**
|
|
254
|
+
* The pages of the document this component talks to, in order: each with its
|
|
255
|
+
* `ref`, `index`, `label`, size and rotation. Needs no Stage, so a thumbnail
|
|
256
|
+
* list or a page picker works anywhere. The same array until a page is added,
|
|
257
|
+
* removed, moved or rotated; empty with no document.
|
|
258
|
+
*/
|
|
259
|
+
function usePageList() {
|
|
260
|
+
const documentId = useDocumentId();
|
|
261
|
+
return useKernelValue((kernel) => documentId ? kernel.documents.listPages(documentId) : NO_PAGES);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* The viewer's own settings (`<Viewer identity scope accent page>`), or the
|
|
265
|
+
* value `select` picks from them: the accent every part without a color of its
|
|
266
|
+
* own follows, and how pages look. What paints a page or an accent reads it
|
|
267
|
+
* here, through `paint()` from `@embedpdf/web`, so a CSS variable still wins.
|
|
268
|
+
*/
|
|
269
|
+
function useViewerSettings(select) {
|
|
270
|
+
return useKernelValue((kernel) => {
|
|
271
|
+
const settings = kernel.getSettings();
|
|
272
|
+
return select ? select(settings) : settings;
|
|
273
|
+
}, _embedpdf_core.shallowEqual);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Owns the kernel as an effect-scoped resource: each effect setup creates and
|
|
277
|
+
* starts exactly one kernel; each cleanup destroys exactly that one. That is
|
|
278
|
+
* the contract StrictMode exercises (two kernels in dev, the first fully
|
|
279
|
+
* destroyed) — the kernel itself is never restarted after destroy.
|
|
280
|
+
*
|
|
281
|
+
* The kernel is published to context the moment it exists — before `start()`
|
|
282
|
+
* resolves — so the `fallback` can use workspace capabilities (i18n copy on a
|
|
283
|
+
* loading screen). The one exception is the very first render, which happens
|
|
284
|
+
* before the effect: it renders nothing. Children mount once `start()` resolves
|
|
285
|
+
* — which never touches the engine, so the shell is alive while WASM compiles
|
|
286
|
+
* or the transport connects. `initialDocuments` open in the background and
|
|
287
|
+
* stream into the registry (`useDocuments()` is reactive); per-document
|
|
288
|
+
* loading UI is the Stage's job, not a root gate.
|
|
289
|
+
*
|
|
290
|
+
* Engine ownership. When `engine` is a thunk, the Viewer owns it: each effect
|
|
291
|
+
* setup constructs one engine (construction is synchronous and inert — boot
|
|
292
|
+
* happens lazily inside the engine) and each cleanup destroys exactly that one
|
|
293
|
+
* — after the kernel, so handles close first. When `engine` is an instance it
|
|
294
|
+
* is borrowed and never destroyed here; the Viewer only warms up a local
|
|
295
|
+
* engine so the WASM boot overlaps plugin initialization. StrictMode's
|
|
296
|
+
* double-mount therefore constructs two independent thunk engines and tears
|
|
297
|
+
* the first fully down, matching the kernel's own effect-scoped lifecycle.
|
|
298
|
+
* That means dev-only double resource use (two worker spawns, two font
|
|
299
|
+
* fetches, briefly overlapping) — deliberate, because it is exactly the
|
|
300
|
+
* leak-detection contract StrictMode exists to exercise; production mounts
|
|
301
|
+
* once and boots once.
|
|
302
|
+
*/
|
|
303
|
+
const Viewer = (0, react.forwardRef)(function Viewer({ engine, plugins, initialDocuments, fallback, renderError, onReady, identity, scope, accent, page, children }, ref) {
|
|
304
|
+
const initial = (0, react.useRef)({
|
|
305
|
+
engine,
|
|
306
|
+
plugins,
|
|
307
|
+
initialDocuments
|
|
308
|
+
});
|
|
309
|
+
const settings = (0, _embedpdf_core.viewerSettingsOf)({
|
|
310
|
+
identity,
|
|
311
|
+
scope,
|
|
312
|
+
accent,
|
|
313
|
+
page
|
|
314
|
+
});
|
|
315
|
+
const latestSettings = (0, react.useRef)(settings);
|
|
316
|
+
latestSettings.current = settings;
|
|
317
|
+
const warned = (0, react.useRef)(false);
|
|
318
|
+
if (isDev() && !warned.current) {
|
|
319
|
+
if (initial.current.engine !== engine || initial.current.plugins !== plugins) {
|
|
320
|
+
warned.current = true;
|
|
321
|
+
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.");
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
const [boot, setBoot] = (0, react.useState)({
|
|
325
|
+
phase: "booting",
|
|
326
|
+
kernel: null
|
|
327
|
+
});
|
|
328
|
+
const onReadyRef = (0, react.useRef)(onReady);
|
|
329
|
+
onReadyRef.current = onReady;
|
|
330
|
+
(0, react.useImperativeHandle)(ref, () => boot.phase === "ready" ? boot.kernel : null, [boot]);
|
|
331
|
+
(0, react.useEffect)(() => {
|
|
332
|
+
const captured = initial.current;
|
|
333
|
+
const ownsEngine = typeof captured.engine === "function";
|
|
334
|
+
const engine = ownsEngine ? captured.engine() : captured.engine;
|
|
335
|
+
if ((0, _embedpdf_core.isLocalEngine)(engine)) engine.warmup();
|
|
336
|
+
let kernel;
|
|
337
|
+
try {
|
|
338
|
+
kernel = (0, _embedpdf_core.createKernel)({
|
|
339
|
+
engine,
|
|
340
|
+
plugins: captured.plugins,
|
|
341
|
+
settings: latestSettings.current,
|
|
342
|
+
clock: (0, _embedpdf_web.browserClock)(),
|
|
343
|
+
printer: (0, _embedpdf_web.browserPrinter)()
|
|
344
|
+
});
|
|
345
|
+
} catch (error) {
|
|
346
|
+
setBoot({
|
|
347
|
+
phase: "error",
|
|
348
|
+
error
|
|
349
|
+
});
|
|
350
|
+
if (ownsEngine) engine.destroy();
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
let alive = true;
|
|
354
|
+
setBoot({
|
|
355
|
+
phase: "booting",
|
|
356
|
+
kernel
|
|
357
|
+
});
|
|
358
|
+
kernel.start().then(() => {
|
|
359
|
+
if (!alive) return;
|
|
360
|
+
onReadyRef.current?.(kernel);
|
|
361
|
+
setBoot({
|
|
362
|
+
phase: "ready",
|
|
363
|
+
kernel
|
|
364
|
+
});
|
|
365
|
+
kernel.documents.openAll(captured.initialDocuments ?? []);
|
|
366
|
+
}, (error) => {
|
|
367
|
+
if (alive) setBoot({
|
|
368
|
+
phase: "error",
|
|
369
|
+
error
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
return () => {
|
|
373
|
+
alive = false;
|
|
374
|
+
kernel.destroy().then(() => {
|
|
375
|
+
if (ownsEngine) engine.destroy();
|
|
376
|
+
});
|
|
377
|
+
};
|
|
378
|
+
}, []);
|
|
379
|
+
const liveKernel = boot.phase === "error" ? null : boot.kernel;
|
|
380
|
+
(0, react.useEffect)(() => {
|
|
381
|
+
liveKernel?.updateSettings(latestSettings.current);
|
|
382
|
+
});
|
|
383
|
+
if (boot.phase === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: renderError ? renderError(boot.error) : null });
|
|
384
|
+
if (!boot.kernel) return null;
|
|
385
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(KernelCtx.Provider, {
|
|
386
|
+
value: boot.kernel,
|
|
387
|
+
children: boot.phase === "ready" ? children : fallback ?? null
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
const EmbedPDF = Viewer;
|
|
391
|
+
const PageCtx = (0, react.createContext)(null);
|
|
392
|
+
const PageProvider = PageCtx.Provider;
|
|
393
|
+
function usePage() {
|
|
394
|
+
const context = (0, react.useContext)(PageCtx);
|
|
395
|
+
if (!context) throw new Error("usePage must be used inside <PageView> or a <Stage> page");
|
|
396
|
+
return context;
|
|
397
|
+
}
|
|
398
|
+
//#endregion
|
|
399
|
+
Object.defineProperty(exports, "DocumentGate", {
|
|
400
|
+
enumerable: true,
|
|
401
|
+
get: function() {
|
|
402
|
+
return DocumentGate;
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
Object.defineProperty(exports, "DocumentScope", {
|
|
406
|
+
enumerable: true,
|
|
407
|
+
get: function() {
|
|
408
|
+
return DocumentScope;
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
Object.defineProperty(exports, "EmbedPDF", {
|
|
412
|
+
enumerable: true,
|
|
413
|
+
get: function() {
|
|
414
|
+
return EmbedPDF;
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
Object.defineProperty(exports, "KernelProvider", {
|
|
418
|
+
enumerable: true,
|
|
419
|
+
get: function() {
|
|
420
|
+
return KernelProvider;
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
Object.defineProperty(exports, "PageProvider", {
|
|
424
|
+
enumerable: true,
|
|
425
|
+
get: function() {
|
|
426
|
+
return PageProvider;
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
Object.defineProperty(exports, "Viewer", {
|
|
430
|
+
enumerable: true,
|
|
431
|
+
get: function() {
|
|
432
|
+
return Viewer;
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
Object.defineProperty(exports, "devWarn", {
|
|
436
|
+
enumerable: true,
|
|
437
|
+
get: function() {
|
|
438
|
+
return devWarn;
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
Object.defineProperty(exports, "epdfTheme", {
|
|
442
|
+
enumerable: true,
|
|
443
|
+
get: function() {
|
|
444
|
+
return epdfTheme;
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
Object.defineProperty(exports, "shallowArray", {
|
|
448
|
+
enumerable: true,
|
|
449
|
+
get: function() {
|
|
450
|
+
return shallowArray;
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
Object.defineProperty(exports, "useActiveDocumentId", {
|
|
454
|
+
enumerable: true,
|
|
455
|
+
get: function() {
|
|
456
|
+
return useActiveDocumentId;
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
Object.defineProperty(exports, "useCapability", {
|
|
460
|
+
enumerable: true,
|
|
461
|
+
get: function() {
|
|
462
|
+
return useCapability;
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
Object.defineProperty(exports, "useCapabilityEvent", {
|
|
466
|
+
enumerable: true,
|
|
467
|
+
get: function() {
|
|
468
|
+
return useCapabilityEvent;
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
Object.defineProperty(exports, "useDocument", {
|
|
472
|
+
enumerable: true,
|
|
473
|
+
get: function() {
|
|
474
|
+
return useDocument;
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
Object.defineProperty(exports, "useDocumentId", {
|
|
478
|
+
enumerable: true,
|
|
479
|
+
get: function() {
|
|
480
|
+
return useDocumentId;
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
Object.defineProperty(exports, "useDocumentScope", {
|
|
484
|
+
enumerable: true,
|
|
485
|
+
get: function() {
|
|
486
|
+
return useDocumentScope;
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
Object.defineProperty(exports, "useDocuments", {
|
|
490
|
+
enumerable: true,
|
|
491
|
+
get: function() {
|
|
492
|
+
return useDocuments;
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
Object.defineProperty(exports, "useDocumentsEvent", {
|
|
496
|
+
enumerable: true,
|
|
497
|
+
get: function() {
|
|
498
|
+
return useDocumentsEvent;
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
Object.defineProperty(exports, "useDocumentsState", {
|
|
502
|
+
enumerable: true,
|
|
503
|
+
get: function() {
|
|
504
|
+
return useDocumentsState;
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
Object.defineProperty(exports, "useKernel", {
|
|
508
|
+
enumerable: true,
|
|
509
|
+
get: function() {
|
|
510
|
+
return useKernel;
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
Object.defineProperty(exports, "useKernelValue", {
|
|
514
|
+
enumerable: true,
|
|
515
|
+
get: function() {
|
|
516
|
+
return useKernelValue;
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
Object.defineProperty(exports, "useOptionalCapability", {
|
|
520
|
+
enumerable: true,
|
|
521
|
+
get: function() {
|
|
522
|
+
return useOptionalCapability;
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
Object.defineProperty(exports, "useOptionalSelector", {
|
|
526
|
+
enumerable: true,
|
|
527
|
+
get: function() {
|
|
528
|
+
return useOptionalSelector;
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
Object.defineProperty(exports, "usePage", {
|
|
532
|
+
enumerable: true,
|
|
533
|
+
get: function() {
|
|
534
|
+
return usePage;
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
Object.defineProperty(exports, "usePageList", {
|
|
538
|
+
enumerable: true,
|
|
539
|
+
get: function() {
|
|
540
|
+
return usePageList;
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
Object.defineProperty(exports, "useSelector", {
|
|
544
|
+
enumerable: true,
|
|
545
|
+
get: function() {
|
|
546
|
+
return useSelector;
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
Object.defineProperty(exports, "useViewerSettings", {
|
|
550
|
+
enumerable: true,
|
|
551
|
+
get: function() {
|
|
552
|
+
return useViewerSettings;
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
//# sourceMappingURL=runtime-BfnpyfY0.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-BfnpyfY0.cjs","names":["DocumentsToken","shallowEqual","documentState","documentsState"],"sources":["../src/theme.ts","../src/dev.ts","../src/runtime.tsx"],"sourcesContent":["/**\n * `epdfTheme()`: a theme written with setting names, as a style for the\n * element around your viewer. The variables and their lookup are framework-free\n * (`@embedpdf/web`); this only types the result as React's style.\n */\nimport type * as React from 'react';\nimport { epdfThemeVariables, type EpdfTheme } from '@embedpdf/web';\n\nexport type { EpdfTheme } from '@embedpdf/web';\n\n/**\n * The CSS variables of a theme, for a `style` prop: `<div style={epdfTheme({ accent })}>`.\n * Everything inside the element follows them, and a CSS variable wins over any setting.\n */\nexport function epdfTheme(theme: EpdfTheme): React.CSSProperties {\n return epdfThemeVariables(theme) as React.CSSProperties;\n}\n","/**\n * Development-time guardrails. Every warning fires once per process (keyed),\n * says what is wrong and what to do instead, and compiles out of production\n * builds ({@link isDev}).\n */\nconst warned = new Set<string>();\n\n/**\n * Whether this is a development build, as the app's bundler says: every bundler replaces\n * `process.env.NODE_ENV`, with `\"production\"` in a production build, so there this is `false`\n * and the warnings behind it compile out. A page with no bundler has no `process` at all, and\n * counts as development: the warnings help most while you try the package out.\n */\nexport function isDev(): boolean {\n try {\n return process.env.NODE_ENV !== 'production';\n } catch {\n return true;\n }\n}\n\n/** Warn once per key. No-op in production. */\nexport function devWarn(key: string, message: string): void {\n if (!isDev() || warned.has(key)) return;\n warned.add(key);\n console.warn(`[embedpdf] ${message}`);\n}\n\n/** Test seam: forget every warning so a suite can assert one fires again. */\nexport function resetDevWarnings(): void {\n warned.clear();\n}\n","/**\n * @embedpdf/react — the generic binding.\n *\n * Binds the kernel's one change stream to React (useSyncExternalStore), resolves\n * capabilities (document-scoped ones against the active or `<DocumentScope>`-given\n * document, with a stand-in while there is none), and provides the page\n * coordinate context. Every plugin and layer rides on this — there is no\n * per-plugin framework code.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/core';\n// What a page with a viewer needs from the browser: handing bytes to the user as a download,\n// and a font the engine draws with, for text you draw yourself.\nexport { mountWebFont, saveFile } from '@embedpdf/web';\n// The page context every layer draws through; its conversions are shared with every framework.\nexport { makePageContext } from '@embedpdf/web';\n// A theme written with setting names, as the style for the element around a viewer.\nexport { epdfTheme } from './theme';\nexport type { EpdfTheme } from './theme';\nimport * as React from 'react';\nimport {\n createContext,\n forwardRef,\n useContext,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport {\n DocumentsToken,\n createKernel,\n documentState,\n documentsState,\n isLocalEngine,\n shallowEqual,\n standInFor,\n viewerSettingsOf,\n} from '@embedpdf/core';\nimport type {\n AnyPlugin,\n CapabilityToken,\n DocumentInfo,\n DocumentsCapability,\n DocumentsState,\n Engine,\n EngineFactory,\n EventHook,\n FailedDocumentInfo,\n Identity,\n InitialDocument,\n Kernel,\n LockedDocumentInfo,\n PageInfo,\n ViewerPageSettings,\n ViewerSettings,\n} from '@embedpdf/core';\n// Pure coordinate math from the geometry base — not from stage-core. The\n// PageContext seam stays stage-agnostic (it must also serve standalone PageView).\nimport type { PageTransform } from '@embedpdf/core-geometry';\nimport type { PageViewDemand } from '@embedpdf/plugin-render/contract';\nimport { browserClock, browserPrinter } from '@embedpdf/web';\nimport type { PageContext } from '@embedpdf/web';\n\nimport { isDev } from './dev';\n\nconst KernelCtx = createContext<Kernel | null>(null);\n/** The document a subtree is bound to. null => use the active document. */\nconst DocumentScopeCtx = createContext<string | null>(null);\n\nexport function useKernel(): Kernel {\n const kernel = useContext(KernelCtx);\n if (!kernel) throw new Error('useKernel must be used within <Viewer>/<EmbedPDF>');\n return kernel;\n}\n\nexport interface KernelProviderProps {\n kernel: Kernel;\n children?: React.ReactNode;\n}\n/**\n * Give a subtree a kernel someone else created and owns, so every hook in it\n * works against that kernel. The full viewer's wrapper puts the children it\n * slots into the viewer inside one. The provider never starts or destroys the\n * kernel; `<Viewer>` is the component that owns one.\n */\nexport function KernelProvider({ kernel, children }: KernelProviderProps) {\n return <KernelCtx.Provider value={kernel}>{children}</KernelCtx.Provider>;\n}\n\nexport const shallowArray = <T,>(left: readonly T[], right: readonly T[]): boolean =>\n left === right || (left.length === right.length && left.every((item, i) => item === right[i]));\n\n/** Read a value derived from the kernel, cached by equality (no tearing loop). */\nexport function useKernelValue<R>(\n select: (kernel: Kernel) => R,\n isEqual: (left: R, right: R) => boolean = Object.is,\n): R {\n const kernel = useKernel();\n const last = useRef<{ v: R } | null>(null);\n const get = () => {\n const next = select(kernel);\n if (last.current && isEqual(last.current.v, next)) return last.current.v;\n last.current = { v: next };\n return next;\n };\n return useSyncExternalStore(kernel.subscribe, get, get);\n}\n\nexport function useActiveDocumentId(): string | null {\n return useKernelValue((kernel) => kernel.documents.getActiveId());\n}\n\n/** The document id for this subtree: the nearest <DocumentScope>, else the active doc. */\nexport function useDocumentId(): string | null {\n const scoped = useDocumentScope();\n const active = useActiveDocumentId();\n return scoped ?? active;\n}\n\n/**\n * The document the nearest <DocumentScope> binds this subtree to, or null when\n * it follows the active document. For resolvers that pass it to\n * `kernel.tryCapability`, which reads the active document at call time; UI\n * that needs the id itself uses {@link useDocumentId}.\n */\nexport function useDocumentScope(): string | null {\n return useContext(DocumentScopeCtx);\n}\n\nexport interface DocumentScopeProps {\n id: string;\n children: React.ReactNode;\n}\n/** Bind a subtree to a specific document (panes, comparison). */\nexport function DocumentScope({ id, children }: DocumentScopeProps) {\n return <DocumentScopeCtx.Provider value={id}>{children}</DocumentScopeCtx.Provider>;\n}\n\nexport interface DocumentGateProps {\n /** Shown while this subtree has no document: none is open, or it's still opening. */\n fallback?: React.ReactNode;\n /** Shown while the document waits for its password; `fallback` without it. */\n locked?: (document: LockedDocumentInfo) => React.ReactNode;\n /** Shown when the document couldn't be opened, with why; `fallback` without it. */\n error?: (document: FailedDocumentInfo) => React.ReactNode;\n children?: React.ReactNode;\n}\n/**\n * Render children only while this subtree has a ready document — the\n * structural way to say \"this UI is defined over a document\". An empty\n * workspace is a legitimate, designable state (the Viewer no longer blocks on\n * documents so chrome can render at t≈0): workspace-scoped UI (toolbars,\n * commands, i18n) lives outside the gate; document-scoped UI (Stage, panels,\n * page chrome) lives inside it. A document that waits for its password, or\n * failed, renders `locked` or `error` with it, or else `fallback`. Sibling of\n * <DocumentScope>, which picks which document; this one handles whether.\n */\nexport function DocumentGate({ fallback = null, locked, error, children }: DocumentGateProps) {\n const document = useDocument();\n if (document.status === 'ready') return <>{children}</>;\n if (document.status === 'locked' && locked) {\n return <>{locked(document as LockedDocumentInfo)}</>;\n }\n if (document.status === 'error' && error) return <>{error(document as FailedDocumentInfo)}</>;\n return <>{fallback}</>;\n}\n\n/**\n * Resolve a capability by token, binding document-scoped ones to this\n * subtree's document. Resolution is a reactive read (`tryCapability` through\n * the kernel's one change stream), not a memoized call — under the\n * request-time lifecycle a document can become resolvable while its id stays\n * the same, so any id-keyed cache goes stale; subscribing makes staleness\n * structurally impossible.\n *\n * Outside a document (none open, not ready yet, or none in scope), a document\n * plugin resolves to its stand-in (`standInFor` from `@embedpdf/core`):\n * rendering never fails, and a method called too early refuses with\n * `not-ready` (a method that returns a promise rejects). A token no plugin\n * provides still throws the kernel's reason, because that is a setup mistake.\n */\nexport function useCapability<T>(token: CapabilityToken<T>): T {\n const kernel = useKernel();\n const capability = useOptionalCapability(token);\n if (capability) return capability;\n if (kernel.scopeOf(token) === 'document') return standInFor(kernel, token);\n return kernel.capability(token);\n}\n\n/** Like `useCapability`, but null while the token can't resolve (no plugin,\n * no document, or a document that isn't ready yet). */\nexport function useOptionalCapability<T>(token: CapabilityToken<T>): T | null {\n const scoped = useDocumentScope();\n return useKernelValue((kernel) => kernel.tryCapability(token, scoped ?? undefined));\n}\n\n/**\n * Subscribe to a selector over a (document-resolved) capability. Strict:\n * while the token can't resolve, it throws the kernel's reason (`no\n * document`, `document is loading`), for code that knows a document exists,\n * such as anything inside a <DocumentGate>. `useOptionalSelector` is its\n * total twin.\n */\nexport function useSelector<C, R>(\n token: CapabilityToken<C>,\n select: (capability: C) => R,\n isEqual: (left: R, right: R) => boolean = Object.is,\n): R {\n const kernel = useKernel();\n const scoped = useDocumentScope();\n const capability = useOptionalCapability(token) ?? kernel.capability(token, scoped ?? undefined);\n const last = useRef<{ v: R } | null>(null);\n const get = () => {\n const next = select(capability);\n if (last.current && isEqual(last.current.v, next)) return last.current.v;\n last.current = { v: next };\n return next;\n };\n return useSyncExternalStore(kernel.subscribe, get, get);\n}\n\n/**\n * Null-safe `useSelector`: `fallback` whenever the token can't resolve — no\n * provider, or a document-scoped token with no document. For chrome that stays\n * mounted across the empty-workspace state (a zoom readout, a mode band).\n *\n * The `select` guard also swallows reads through a capability whose document\n * closed between the store notification and this render — that teardown race\n * resolves to `fallback` for one frame, then re-renders against the new state.\n */\nexport function useOptionalSelector<C, R>(\n token: CapabilityToken<C>,\n select: (capability: C) => R,\n fallback: R,\n isEqual: (left: R, right: R) => boolean = Object.is,\n): R {\n const kernel = useKernel();\n const capability = useOptionalCapability(token);\n const last = useRef<{ v: R } | null>(null);\n const get = () => {\n let next: R;\n if (capability === null) {\n next = fallback;\n } else {\n try {\n next = select(capability);\n } catch {\n next = fallback;\n }\n }\n if (last.current && isEqual(last.current.v, next)) return last.current.v;\n last.current = { v: next };\n return next;\n };\n return useSyncExternalStore(kernel.subscribe, get, get);\n}\n\n/**\n * Subscribe to a capability's {@link EventHook} for the mounted lifetime —\n * `useCapabilityEvent(ActionsToken, (actions) => actions.onExecuted, handler)`. Events\n * carry occurrences, never state (a late subscriber that needs the current\n * value uses `useSelector`). The handler rides a ref, so a fresh closure per\n * render never resubscribes. Null-safe: no plugin/document → no subscription.\n */\nexport function useCapabilityEvent<C, T>(\n token: CapabilityToken<C>,\n select: (capability: C) => EventHook<T>,\n handler: (event: T) => void,\n): void {\n const capability = useOptionalCapability(token);\n const handlerRef = useRef(handler);\n handlerRef.current = handler;\n const selectRef = useRef(select);\n selectRef.current = select;\n useEffect(() => {\n if (!capability) return;\n return selectRef.current(capability)((event) => handlerRef.current(event));\n }, [capability]);\n}\n\n/**\n * The documents API: open, close, unlock, download, and the tabs. Inside a\n * <DocumentScope>, the calls that leave out the document use that one, so\n * `download()` without an id downloads the document in scope. The object\n * never changes, so it's safe in effects and callbacks. What to show comes\n * from `useDocument()` and `useDocumentsState()`.\n */\nexport function useDocuments(): DocumentsCapability {\n return useCapability(DocumentsToken);\n}\n\n/** Read a state declaration's value through the kernel, or the value `select` picks from it. */\nfunction useDeclared<Capability, State extends object, Selected>(\n token: CapabilityToken<Capability>,\n read: (capability: Capability) => State,\n empty: State,\n select: ((state: State) => Selected) | undefined,\n): Selected {\n const scoped = useDocumentScope();\n return useKernelValue((kernel) => {\n const capability = kernel.tryCapability(token, scoped ?? undefined);\n const state = capability ? read(capability) : empty;\n return select ? select(state) : (state as unknown as Selected);\n }, shallowEqual);\n}\n\n/**\n * The document this component talks to: the one its <DocumentScope> names, or\n * else the active one. Its `id`, `name`, `status`, `pageCount`,\n * `hasUnsavedChanges`, and why it's locked or failed. With no document, an\n * empty one that reads as still opening. Takes a selector, and re-renders only\n * when what it returns changes.\n */\nexport function useDocument<Selected = DocumentInfo>(\n select?: (document: DocumentInfo) => Selected,\n): Selected {\n return useDeclared(DocumentsToken, documentState.read, documentState.empty, select);\n}\n\n/**\n * Every open document, in tab order (loading, locked and failed ones too),\n * and the active one's id. Takes a selector, and re-renders only when what it\n * returns changes.\n */\nexport function useDocumentsState<Selected = DocumentsState>(\n select?: (state: DocumentsState) => Selected,\n): Selected {\n return useDeclared(DocumentsToken, documentsState.read, documentsState.empty, select);\n}\n\n/** Subscribe to one documents event for the mounted lifetime: `useDocumentsEvent((documents) => documents.onOpened, handler)`. */\nexport function useDocumentsEvent<T>(\n select: (documents: DocumentsCapability) => EventHook<T>,\n handler: (event: T) => void,\n): void {\n useCapabilityEvent(DocumentsToken, select, handler);\n}\n\nconst NO_PAGES: readonly PageInfo[] = Object.freeze([]);\n\n/**\n * The pages of the document this component talks to, in order: each with its\n * `ref`, `index`, `label`, size and rotation. Needs no Stage, so a thumbnail\n * list or a page picker works anywhere. The same array until a page is added,\n * removed, moved or rotated; empty with no document.\n */\nexport function usePageList(): readonly PageInfo[] {\n const documentId = useDocumentId();\n return useKernelValue((kernel) =>\n documentId ? kernel.documents.listPages(documentId) : NO_PAGES,\n );\n}\n\n/**\n * The viewer's own settings (`<Viewer identity scope accent page>`), or the\n * value `select` picks from them: the accent every part without a color of its\n * own follows, and how pages look. What paints a page or an accent reads it\n * here, through `paint()` from `@embedpdf/web`, so a CSS variable still wins.\n */\nexport function useViewerSettings<Selected = ViewerSettings>(\n select?: (settings: ViewerSettings) => Selected,\n): Selected {\n return useKernelValue((kernel) => {\n const settings = kernel.getSettings();\n return select ? select(settings) : (settings as unknown as Selected);\n }, shallowEqual);\n}\n\n// `InitialDocument` is the kernel's type (re-exported via `export * from\n// '@embedpdf/core'` above) — one shared shape for every adapter.\n\nexport interface ViewerProps {\n /**\n * The engine, as an instance or a thunk. Engines construct synchronously and\n * boot lazily (`localEngine()` allocates nothing until first use), so\n * ownership follows the shape of what you pass:\n *\n * - An **instance** (`engine={engine}`) is borrowed: the Viewer uses it and\n * never destroys it, because you acquired it and therefore own it. The\n * common path — a module-scope `const engine = localEngine()` shared\n * across viewers and route changes. The Viewer warms up a local engine\n * on mount so the boot overlaps app initialization.\n * - A **thunk** (`engine={() => localEngine()}`) is viewer-owned: the\n * Viewer calls it on mount and `destroy()`s the result on unmount. Use it\n * for per-mount isolation (StrictMode/HMR-clean teardown, independent\n * multi-viewer engines).\n *\n * Init-only: captured on first render; later identity changes are ignored (dev warns).\n */\n engine: Engine | EngineFactory;\n /** Init-only: captured on first render; later identity changes are ignored (dev warns). */\n plugins: AnyPlugin[];\n /** Documents to open on startup (with optional tab names). Init-only. */\n initialDocuments?: InitialDocument[];\n fallback?: React.ReactNode;\n /** Rendered when kernel construction or `start()` fails. Without it a boot\n * failure renders nothing — but never a silent forever-fallback. */\n renderError?: (error: unknown) => React.ReactNode;\n /** Called once the kernel has started — before `children` mount and before\n * `initialDocuments` open. The imperative door for code outside React\n * (register commands, subscribe events). The `ref` carries the same kernel. */\n onReady?: (kernel: Kernel) => void;\n /**\n * Who the user is, for every document opened without an `identity` of its\n * own (which replaces this one). Documents opened after a change use the new\n * value; open ones keep theirs. The local engine only: the cloud engine reads\n * it from the document's token.\n */\n identity?: Identity;\n /**\n * What the user may do, as permissions, in every document opened without a\n * `scope` of its own (which replaces this one). Left out, they may do\n * everything. Changes reach the documents opened after them, as `identity`.\n */\n scope?: readonly string[];\n /** The color every part without a color of its own follows. CSS `--epdf-accent` wins over it. */\n accent?: string;\n /** How pages look: `background` before the picture arrives, and the `shadow` under each page. */\n page?: Partial<ViewerPageSettings>;\n children?: React.ReactNode;\n}\n\ntype BootState =\n | { phase: 'booting'; kernel: Kernel | null }\n | { phase: 'ready'; kernel: Kernel }\n | { phase: 'error'; error: unknown };\n\n/**\n * Owns the kernel as an effect-scoped resource: each effect setup creates and\n * starts exactly one kernel; each cleanup destroys exactly that one. That is\n * the contract StrictMode exercises (two kernels in dev, the first fully\n * destroyed) — the kernel itself is never restarted after destroy.\n *\n * The kernel is published to context the moment it exists — before `start()`\n * resolves — so the `fallback` can use workspace capabilities (i18n copy on a\n * loading screen). The one exception is the very first render, which happens\n * before the effect: it renders nothing. Children mount once `start()` resolves\n * — which never touches the engine, so the shell is alive while WASM compiles\n * or the transport connects. `initialDocuments` open in the background and\n * stream into the registry (`useDocuments()` is reactive); per-document\n * loading UI is the Stage's job, not a root gate.\n *\n * Engine ownership. When `engine` is a thunk, the Viewer owns it: each effect\n * setup constructs one engine (construction is synchronous and inert — boot\n * happens lazily inside the engine) and each cleanup destroys exactly that one\n * — after the kernel, so handles close first. When `engine` is an instance it\n * is borrowed and never destroyed here; the Viewer only warms up a local\n * engine so the WASM boot overlaps plugin initialization. StrictMode's\n * double-mount therefore constructs two independent thunk engines and tears\n * the first fully down, matching the kernel's own effect-scoped lifecycle.\n * That means dev-only double resource use (two worker spawns, two font\n * fetches, briefly overlapping) — deliberate, because it is exactly the\n * leak-detection contract StrictMode exists to exercise; production mounts\n * once and boots once.\n */\nexport const Viewer = forwardRef<Kernel | null, ViewerProps>(function Viewer(\n {\n engine,\n plugins,\n initialDocuments,\n fallback,\n renderError,\n onReady,\n identity,\n scope,\n accent,\n page,\n children,\n }: ViewerProps,\n ref,\n) {\n // Init-only inputs: the kernel's lifetime is the component's lifetime, so a\n // changed engine/plugins identity cannot mean \"rebuild the workspace\" —\n // that would silently drop every open document. Capture once, warn in dev.\n const initial = useRef({ engine, plugins, initialDocuments });\n // The viewer's settings follow the props. The first ones go to the kernel when it's\n // created, so the initial documents open with them; later ones as they change.\n const settings = viewerSettingsOf({ identity, scope, accent, page });\n const latestSettings = useRef(settings);\n latestSettings.current = settings;\n const warned = useRef(false);\n if (isDev() && !warned.current) {\n if (initial.current.engine !== engine || initial.current.plugins !== plugins) {\n warned.current = true;\n console.warn(\n '[embedpdf] <Viewer> engine/plugins are init-only. A changed identity is ignored — ' +\n 'pass stable references (module scope, useState, or useMemo). ' +\n 'An inline `plugins={[...]}` array recreates its identity every render.',\n );\n }\n }\n\n const [boot, setBoot] = useState<BootState>({ phase: 'booting', kernel: null });\n const onReadyRef = useRef(onReady);\n onReadyRef.current = onReady;\n // The ref is the started kernel (null before boot and after an error).\n useImperativeHandle<Kernel | null, Kernel | null>(\n ref,\n () => (boot.phase === 'ready' ? boot.kernel : null),\n [boot],\n );\n useEffect(() => {\n const captured = initial.current;\n // A thunk is viewer-owned: call it now, destroy on unmount. An instance is\n // borrowed: use as-is, never destroy. Construction is synchronous and inert\n // either way — the engine boots lazily on first use — so a local engine's\n // `warmup()` overlaps the WASM boot with plugin initialization.\n const ownsEngine = typeof captured.engine === 'function';\n const engine: Engine = ownsEngine\n ? (captured.engine as EngineFactory)()\n : (captured.engine as Engine);\n if (isLocalEngine(engine)) engine.warmup();\n let kernel: Kernel;\n try {\n kernel = createKernel({\n engine,\n plugins: captured.plugins,\n settings: latestSettings.current,\n clock: browserClock(),\n printer: browserPrinter(),\n });\n } catch (error) {\n setBoot({ phase: 'error', error }); // plan/graph errors surface, not throw mid-render\n if (ownsEngine) void engine.destroy();\n return;\n }\n let alive = true;\n setBoot({ phase: 'booting', kernel }); // context carries the kernel from this frame on\n kernel.start().then(\n () => {\n if (!alive) return; // unmounted mid-boot — don't open anything\n onReadyRef.current?.(kernel);\n setBoot({ phase: 'ready', kernel });\n // Kernel-owned boot policy: all tabs appear immediately in array\n // order; the `active` entry (else the first) is selected; failures\n // surface as tab status. See DocumentsCapability.openAll.\n kernel.documents.openAll(captured.initialDocuments ?? []);\n },\n (error) => {\n if (alive) setBoot({ phase: 'error', error });\n },\n );\n return () => {\n alive = false;\n // Kernel first (closes every document handle), then the engine we own —\n // ownership follows acquisition. `engine.destroy()` joins an in-flight\n // boot (or no-ops if it never started), so an unmount mid-boot is safe.\n void kernel.destroy().then(() => {\n if (ownsEngine) void engine.destroy();\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // After every render: props compare by value (an inline `page={{ shadow: 'none' }}` is a new\n // object each time), and settings that didn't change change nothing.\n const liveKernel = boot.phase === 'error' ? null : boot.kernel;\n useEffect(() => {\n liveKernel?.updateSettings(latestSettings.current);\n });\n\n if (boot.phase === 'error') {\n return <>{renderError ? renderError(boot.error) : null}</>;\n }\n if (!boot.kernel) return null; // pre-effect first render only\n return (\n <KernelCtx.Provider value={boot.kernel}>\n {boot.phase === 'ready' ? children : (fallback ?? null)}\n </KernelCtx.Provider>\n );\n});\nexport const EmbedPDF = Viewer;\n\n/**\n * PageContext — the seam. A layer depends only on this, never on the Stage. So the\n * same layer works inside a virtualized Stage and in a standalone <PageView>.\n * Its members are documented on `PageContext` in `@embedpdf/web`.\n */\nexport type PageContextValue = PageContext<PageTransform, PageViewDemand>;\n\nconst PageCtx = createContext<PageContextValue | null>(null);\nexport const PageProvider = PageCtx.Provider;\n\nexport function usePage(): PageContextValue {\n const context = useContext(PageCtx);\n if (!context) throw new Error('usePage must be used inside <PageView> or a <Stage> page');\n return context;\n}\n"],"mappings":";;;;;;;;;;;AAcA,SAAgB,UAAU,OAAuC;CAC/D,QAAA,GAAA,cAAA,mBAAA,CAA0B,KAAK;AACjC;;;;;;;;ACXA,MAAM,yBAAS,IAAI,IAAY;;;;;;;AAQ/B,SAAgB,QAAiB;CAC/B,IAAI;EACF,OAAO,QAAQ,IAAI,aAAa;CAClC,QAAQ;EACN,OAAO;CACT;AACF;;AAGA,SAAgB,QAAQ,KAAa,SAAuB;CAC1D,IAAI,CAAC,MAAM,KAAK,OAAO,IAAI,GAAG,GAAG;CACjC,OAAO,IAAI,GAAG;CACd,QAAQ,KAAK,cAAc,SAAS;AACtC;;;AC0CA,MAAM,aAAA,GAAA,MAAA,cAAA,CAAyC,IAAI;;AAEnD,MAAM,oBAAA,GAAA,MAAA,cAAA,CAAgD,IAAI;AAE1D,SAAgB,YAAoB;CAClC,MAAM,UAAA,GAAA,MAAA,WAAA,CAAoB,SAAS;CACnC,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,mDAAmD;CAChF,OAAO;AACT;;;;;;;AAYA,SAAgB,eAAe,EAAE,QAAQ,YAAiC;CACxE,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAU,UAAX;EAAoB,OAAO;EAAS;CAA6B,CAAA;AAC1E;AAEA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