@embedpdf/react 3.0.0-next.14 → 3.0.0-next.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AnnotationList-CkijRHet-HEFNUIZe.d.cts +877 -0
- package/dist/AnnotationList-CkijRHet-HEFNUIZe.d.ts +877 -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-B48UT2ln.d.ts +302 -0
- package/dist/annotation-C1ttM8Wj.js +708 -0
- package/dist/annotation-C1ttM8Wj.js.map +1 -0
- package/dist/annotation-C9dVwo9b.d.cts +302 -0
- package/dist/annotation-Dex5EBda.cjs +830 -0
- package/dist/annotation-Dex5EBda.cjs.map +1 -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/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-55izw0jS.js +511 -0
- package/dist/form-55izw0jS.js.map +1 -0
- package/dist/form-BNqQfGGH.cjs +548 -0
- package/dist/form-BNqQfGGH.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 +200 -57
- package/dist/index.d.cts +31 -32
- package/dist/index.d.ts +31 -32
- package/dist/index.js +32 -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/page-edit.cjs +7 -3
- package/dist/page-edit.cjs.map +1 -1
- package/dist/page-edit.d.cts +6 -2
- package/dist/page-edit.d.ts +6 -2
- package/dist/page-edit.js +7 -4
- 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-B6xcPsEb.js +398 -0
- package/dist/runtime-B6xcPsEb.js.map +1 -0
- package/dist/runtime-DBEBlpQV.d.cts +237 -0
- package/dist/runtime-V3MVMb91.d.ts +237 -0
- package/dist/runtime-fzpGv78v.cjs +555 -0
- package/dist/runtime-fzpGv78v.cjs.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-BIG6aeVd.cjs +369 -0
- package/dist/stage-BIG6aeVd.cjs.map +1 -0
- package/dist/stage-ByFPD-Fv.d.cts +117 -0
- package/dist/stage-DaboaheR.d.ts +117 -0
- package/dist/stage-DoVekb83.js +302 -0
- package/dist/stage-DoVekb83.js.map +1 -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-CbgxhwLA.js +62 -0
- package/dist/state-CbgxhwLA.js.map +1 -0
- package/dist/state-CsfZy_Eq.cjs +73 -0
- package/dist/state-CsfZy_Eq.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 +37 -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
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { AnyPlugin, CapabilityToken, Engine, EngineFactory, EventHook, InitialDocument, Kernel } from "@embedpdf/core";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { PageFrame, PageTransform, Point, Rect } from "@embedpdf/core-geometry";
|
|
4
|
-
import { PageViewDemand } from "@embedpdf/plugin-render/contract";
|
|
5
|
-
declare namespace runtime_d_exports {
|
|
6
|
-
export { DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, PageContextValue, PageProvider, Viewer, ViewerProps, makePageContext, shallowArray, useActiveDocumentId, useCapability, useCapabilityEvent, useDocumentId, useDocumentStatus, useDocuments, useKernel, useKernelValue, useOptionalCapability, useOptionalSelector, usePage, useSelector };
|
|
7
|
-
}
|
|
8
|
-
import * as import__embedpdf_core from "@embedpdf/core";
|
|
9
|
-
declare function useKernel(): Kernel;
|
|
10
|
-
declare const shallowArray: <T>(a: readonly T[], b: readonly T[]) => boolean;
|
|
11
|
-
/** Read a value derived from the kernel, cached by equality (no tearing loop). */
|
|
12
|
-
declare function useKernelValue<R>(select: (k: Kernel) => R, isEqual?: (a: R, b: R) => boolean): R;
|
|
13
|
-
declare function useActiveDocumentId(): string | null;
|
|
14
|
-
/** The document id for this subtree: the nearest <DocumentScope>, else the active doc. */
|
|
15
|
-
declare function useDocumentId(): string | null;
|
|
16
|
-
interface DocumentScopeProps {
|
|
17
|
-
id: string;
|
|
18
|
-
children: React.ReactNode;
|
|
19
|
-
}
|
|
20
|
-
/** Bind a subtree to a specific document (panes, comparison). */
|
|
21
|
-
declare function DocumentScope({ id, children }: DocumentScopeProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
interface DocumentGateProps {
|
|
23
|
-
/** Shown while this subtree has NO document (empty workspace, docs still opening). */
|
|
24
|
-
fallback?: React.ReactNode;
|
|
25
|
-
children: React.ReactNode;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Render children only while this subtree has a READY document — the
|
|
29
|
-
* structural way to say "this UI is defined over a document". An empty
|
|
30
|
-
* workspace is a legitimate, designable state (the Viewer no longer blocks on
|
|
31
|
-
* documents so chrome can render at t≈0): workspace-scoped UI (toolbars,
|
|
32
|
-
* commands, i18n) lives OUTSIDE the gate; document-scoped UI (Stage, panels,
|
|
33
|
-
* page chrome) lives inside it, or reads through `useOptionalSelector`.
|
|
34
|
-
* A `loading`/`locked`/`error` tab renders `fallback` — so the gate's
|
|
35
|
-
* fallback doubles as the per-tab boot state; richer chrome (a password
|
|
36
|
-
* prompt, an error pane) branches on `useDocumentStatus()` beside the gate.
|
|
37
|
-
* Sibling of <DocumentScope>, which picks WHICH document; this one handles
|
|
38
|
-
* WHETHER.
|
|
39
|
-
*/
|
|
40
|
-
declare function DocumentGate({ fallback, children }: DocumentGateProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
-
/** Lifecycle status of this subtree's document (loading/locked/ready/error),
|
|
42
|
-
* or null with no document. The password prompt and error panes key off it. */
|
|
43
|
-
declare function useDocumentStatus(): import("@embedpdf/core").DocStatus | null;
|
|
44
|
-
/**
|
|
45
|
-
* Resolve a capability by token, binding document-scoped ones to this
|
|
46
|
-
* subtree's document. Resolution is a REACTIVE read (`tryCapability` through
|
|
47
|
-
* the kernel's one change stream), not a memoized call — under the
|
|
48
|
-
* request-time lifecycle a document can become resolvable while its id stays
|
|
49
|
-
* the same, so any id-keyed cache goes stale; subscribing makes staleness
|
|
50
|
-
* structurally impossible. Fail-fast: while unresolvable, this re-runs the
|
|
51
|
-
* strict resolver so the kernel's truthful reason (`no capability` / `no
|
|
52
|
-
* document` / `document is loading|locked`) is what throws.
|
|
53
|
-
*/
|
|
54
|
-
declare function useCapability<T>(token: CapabilityToken<T>): T;
|
|
55
|
-
/** Like `useCapability`, but null while the token can't resolve (no plugin,
|
|
56
|
-
* no document, or a document that isn't ready yet). */
|
|
57
|
-
declare function useOptionalCapability<T>(token: CapabilityToken<T>): T | null;
|
|
58
|
-
/** Subscribe to a selector over a (document-resolved) capability. */
|
|
59
|
-
declare function useSelector<C, R>(token: CapabilityToken<C>, select: (cap: C) => R, isEqual?: (a: R, b: R) => boolean): R;
|
|
60
|
-
/**
|
|
61
|
-
* Null-safe `useSelector`: `fallback` whenever the token can't resolve — no
|
|
62
|
-
* provider, or a document-scoped token with no document. For chrome that stays
|
|
63
|
-
* mounted across the empty-workspace state (a zoom readout, a mode band).
|
|
64
|
-
* `useSelector` stays strict (fail-fast) for code that KNOWS a document exists
|
|
65
|
-
* — e.g. anything inside a <DocumentGate>.
|
|
66
|
-
*
|
|
67
|
-
* The `select` guard also swallows reads through a capability whose document
|
|
68
|
-
* closed between the store notification and this render — that teardown race
|
|
69
|
-
* resolves to `fallback` for one frame, then re-renders against the new state.
|
|
70
|
-
*/
|
|
71
|
-
declare function useOptionalSelector<C, R>(token: CapabilityToken<C>, select: (cap: C) => R, fallback: R, isEqual?: (a: R, b: R) => boolean): R;
|
|
72
|
-
/**
|
|
73
|
-
* Subscribe to a capability's {@link EventHook} for the mounted lifetime —
|
|
74
|
-
* `useCapabilityEvent(ActionsToken, (c) => c.onAction, handler)`. Events
|
|
75
|
-
* carry occurrences, never state (a late subscriber that needs the current
|
|
76
|
-
* value uses `useSelector`). The handler rides a ref, so a fresh closure per
|
|
77
|
-
* render never resubscribes. Null-safe: no plugin/document → no subscription.
|
|
78
|
-
*/
|
|
79
|
-
declare function useCapabilityEvent<C, T>(token: CapabilityToken<C>, select: (cap: C) => EventHook<T>, handler: (event: T) => void): void;
|
|
80
|
-
/** The document registry (open/close/active/list), reactive. */
|
|
81
|
-
declare function useDocuments(): {
|
|
82
|
-
docs: import("@embedpdf/core").DocInfo[];
|
|
83
|
-
activeId: string | null;
|
|
84
|
-
open: (input: import("@embedpdf/core").OpenSource, options?: import("@embedpdf/core").OpenDocumentOptions) => Promise<string>;
|
|
85
|
-
unlock: (id: string, input: {
|
|
86
|
-
password: string;
|
|
87
|
-
}) => Promise<void>;
|
|
88
|
-
close: (id: string) => Promise<void>;
|
|
89
|
-
setActive: (id: string) => void;
|
|
90
|
-
move: (id: string, toIndex: number) => void;
|
|
91
|
-
swap: (a: string, b: string) => void;
|
|
92
|
-
download: (id?: string, opts?: {
|
|
93
|
-
mode?: import("@embedpdf/core").PdfSaveMode;
|
|
94
|
-
}) => Promise<Uint8Array>;
|
|
95
|
-
downloadLayer: (id?: string) => Promise<Uint8Array>;
|
|
96
|
-
};
|
|
97
|
-
interface ViewerProps {
|
|
98
|
-
/**
|
|
99
|
-
* The engine, as an instance or a thunk. Engines construct synchronously and
|
|
100
|
-
* boot lazily (`localEngine()` allocates nothing until first use), so
|
|
101
|
-
* ownership follows the SHAPE of what you pass:
|
|
102
|
-
*
|
|
103
|
-
* - An **instance** (`engine={engine}`) is BORROWED: the Viewer uses it and
|
|
104
|
-
* never destroys it, because you acquired it and therefore own it. The
|
|
105
|
-
* common path — a module-scope `const engine = localEngine()` shared
|
|
106
|
-
* across viewers and route changes. The Viewer calls `engine.warmup?.()`
|
|
107
|
-
* on mount so the boot overlaps app initialization.
|
|
108
|
-
* - A **thunk** (`engine={() => localEngine()}`) is VIEWER-OWNED: the
|
|
109
|
-
* Viewer calls it on mount and `destroy()`s the result on unmount. Use it
|
|
110
|
-
* for per-mount isolation (StrictMode/HMR-clean teardown, independent
|
|
111
|
-
* multi-viewer engines).
|
|
112
|
-
*
|
|
113
|
-
* Init-only: captured on first render; later identity changes are ignored (dev warns).
|
|
114
|
-
*/
|
|
115
|
-
engine: Engine | EngineFactory;
|
|
116
|
-
/** Init-only: captured on first render; later identity changes are ignored (dev warns). */
|
|
117
|
-
plugins: AnyPlugin[];
|
|
118
|
-
/** Documents to open on startup (with optional tab names). Init-only. */
|
|
119
|
-
initialDocuments?: InitialDocument[];
|
|
120
|
-
fallback?: React.ReactNode;
|
|
121
|
-
/** Rendered when kernel construction or `start()` fails. Without it a boot
|
|
122
|
-
* failure renders nothing — but never a silent forever-fallback. */
|
|
123
|
-
renderError?: (error: unknown) => React.ReactNode;
|
|
124
|
-
children: React.ReactNode;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Owns the kernel as an EFFECT-scoped resource: each effect setup creates and
|
|
128
|
-
* starts exactly one kernel; each cleanup destroys exactly that one. That is
|
|
129
|
-
* the contract StrictMode exercises (two kernels in dev, the first fully
|
|
130
|
-
* destroyed) — the kernel itself is never restarted after destroy.
|
|
131
|
-
*
|
|
132
|
-
* The kernel is published to context the moment it exists — before `start()`
|
|
133
|
-
* resolves — so the `fallback` can use workspace capabilities (i18n copy on a
|
|
134
|
-
* loading screen) exactly as before. The one exception is the very first
|
|
135
|
-
* render, which happens before the effect: it renders nothing. Children mount
|
|
136
|
-
* once `start()` resolves — which never touches the engine, so the shell is
|
|
137
|
-
* alive while WASM compiles or the transport connects. `initialDocuments`
|
|
138
|
-
* open in the BACKGROUND and stream into the registry (`useDocuments()` is
|
|
139
|
-
* reactive); per-document loading UI is the Stage's job, not a root gate.
|
|
140
|
-
*
|
|
141
|
-
* ENGINE OWNERSHIP. When `engine` is a thunk, the Viewer OWNS it: each effect
|
|
142
|
-
* setup constructs one engine (construction is synchronous and inert — boot
|
|
143
|
-
* happens lazily inside the engine) and each cleanup destroys exactly that one
|
|
144
|
-
* — after the kernel, so handles close first. When `engine` is an instance it
|
|
145
|
-
* is BORROWED and never destroyed here; the Viewer only calls `warmup?.()` so
|
|
146
|
-
* the WASM/transport boot overlaps plugin initialization. StrictMode's
|
|
147
|
-
* double-mount therefore constructs two independent thunk engines and tears
|
|
148
|
-
* the first fully down, matching the kernel's own effect-scoped lifecycle.
|
|
149
|
-
* That means dev-only double resource use (two worker spawns, two font
|
|
150
|
-
* fetches, briefly overlapping) — deliberate, because it is exactly the
|
|
151
|
-
* leak-detection contract StrictMode exists to exercise; production mounts
|
|
152
|
-
* once and boots once.
|
|
153
|
-
*/
|
|
154
|
-
declare function Viewer({ engine, plugins, initialDocuments, fallback, renderError, children }: ViewerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
155
|
-
declare const EmbedPDF: typeof Viewer;
|
|
156
|
-
/**
|
|
157
|
-
* PageContext — the seam. A layer depends ONLY on this, never on the Stage. So the
|
|
158
|
-
* same layer works inside a virtualized Stage and in a standalone <PageView>.
|
|
159
|
-
*/
|
|
160
|
-
interface PageContextValue {
|
|
161
|
-
documentId: string;
|
|
162
|
-
/** Durable page identity (PDF object number) — use for keys / render / annotations. */
|
|
163
|
-
pon: number;
|
|
164
|
-
/** Display index (page N) — use for ordering / human-facing page numbers. */
|
|
165
|
-
pageIndex: number;
|
|
166
|
-
/**
|
|
167
|
-
* Reserved chrome bands around the page (screen px per side). The page-chrome
|
|
168
|
-
* slot renders into the outer box (content + frame); these thicknesses size
|
|
169
|
-
* the bands — a label in the bottom band is `bottom:0; height: frame.bottom`.
|
|
170
|
-
*/
|
|
171
|
-
frame: PageFrame;
|
|
172
|
-
/**
|
|
173
|
-
* The single bridge between PDF points, view px, and device px for this page.
|
|
174
|
-
* Layers do ALL coordinate work through it — `toPixels` to place content-
|
|
175
|
-
* space overlays, `renderScale`/`deviceWidth` to render, `contentWidth` for
|
|
176
|
-
* page-relative sizing. Never re-derive `x * scale` or `* dpr`.
|
|
177
|
-
*/
|
|
178
|
-
transform: PageTransform;
|
|
179
|
-
/** Client (screen) point → the viewer's coordinates (content point) — the
|
|
180
|
-
* one platform-bound hit-test. */
|
|
181
|
-
toContentPoint(clientX: number, clientY: number): Point;
|
|
182
|
-
/** Content point → client (screen) px — the exact inverse of `toContentPoint`
|
|
183
|
-
* (rotation applied). Lets viewport-space UI (e.g. a selection menu) anchor to a
|
|
184
|
-
* page point WITHOUT a Stage camera, so it works the same in `<PageView>`. */
|
|
185
|
-
toClientPoint(p: Point): Point;
|
|
186
|
-
/** Content rect → client (screen) px AABB. Rect analog of `toClientPoint`
|
|
187
|
-
* for upright viewport-space UI that frames a selected page region. */
|
|
188
|
-
toClientRect(rect: Rect): Rect;
|
|
189
|
-
/**
|
|
190
|
-
* The page-view DEMAND for raster planning uses dependency inversion:
|
|
191
|
-
* plugin-render defines the shape; the host that CREATED this
|
|
192
|
-
* context fills it — as a PULL. The Stage host's getter closes over the
|
|
193
|
-
* stage capability and reads `VisiblePage.visibleRect` live at call time
|
|
194
|
-
* (visibility is the STAGE's data; adapters never re-derive camera math or
|
|
195
|
-
* cache a copy). Three states, three meanings: a real sub-rect (visible),
|
|
196
|
-
* a ZERO rect (stage host, page currently off-screen — want nothing), and
|
|
197
|
-
* an undefined getter (stage-less `<PageView>` — whole page visible, which
|
|
198
|
-
* a thumbnail-sized demand turns into "never engages" by arithmetic).
|
|
199
|
-
*/
|
|
200
|
-
getViewDemand?: () => PageViewDemand;
|
|
201
|
-
/**
|
|
202
|
-
* The hosting VIEW's identity — the stage lens id (`stage.lensId()`) or a
|
|
203
|
-
* per-instance PageView id. IDENTITY, not an option: per-view raster
|
|
204
|
-
* planning (tiles) keys its state by this, so two views showing the SAME
|
|
205
|
-
* page never fight over one plan (a thumbnail rail's never-engaging demand
|
|
206
|
-
* must not disturb the main view's tiles). Every page context host must
|
|
207
|
-
* say which view it is.
|
|
208
|
-
*/
|
|
209
|
-
view: string;
|
|
210
|
-
}
|
|
211
|
-
declare const PageProvider: React.Provider<PageContextValue | null>;
|
|
212
|
-
declare function usePage(): PageContextValue;
|
|
213
|
-
declare function makePageContext(documentId: string, view: string, pon: number, pageIndex: number, frame: PageFrame, transform: PageTransform, getRect: () => DOMRect, getViewDemand?: () => PageViewDemand): PageContextValue;
|
|
214
|
-
//#endregion
|
|
215
|
-
export { usePage as C, useOptionalSelector as S, useDocumentStatus as _, EmbedPDF as a, useKernelValue as b, Viewer as c, runtime_d_exports as d, shallowArray as f, useDocumentId as g, useCapabilityEvent as h, DocumentScopeProps as i, ViewerProps as l, useCapability as m, DocumentGateProps as n, PageContextValue as o, useActiveDocumentId as p, DocumentScope as r, PageProvider as s, DocumentGate as t, makePageContext as u, useDocuments as v, useSelector as w, useOptionalCapability as x, useKernel as y };
|
|
216
|
-
//# sourceMappingURL=runtime-DE76hlnl.d.ts.map
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { AnyPlugin, CapabilityToken, Engine, EngineFactory, EventHook, InitialDocument, Kernel } from "@embedpdf/core";
|
|
3
|
-
import { PageFrame, PageTransform, Point, Rect } from "@embedpdf/core-geometry";
|
|
4
|
-
import { PageViewDemand } from "@embedpdf/plugin-render/contract";
|
|
5
|
-
declare namespace runtime_d_exports {
|
|
6
|
-
export { DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, PageContextValue, PageProvider, Viewer, ViewerProps, makePageContext, shallowArray, useActiveDocumentId, useCapability, useCapabilityEvent, useDocumentId, useDocumentStatus, useDocuments, useKernel, useKernelValue, useOptionalCapability, useOptionalSelector, usePage, useSelector };
|
|
7
|
-
}
|
|
8
|
-
import * as import__embedpdf_core from "@embedpdf/core";
|
|
9
|
-
declare function useKernel(): Kernel;
|
|
10
|
-
declare const shallowArray: <T>(a: readonly T[], b: readonly T[]) => boolean;
|
|
11
|
-
/** Read a value derived from the kernel, cached by equality (no tearing loop). */
|
|
12
|
-
declare function useKernelValue<R>(select: (k: Kernel) => R, isEqual?: (a: R, b: R) => boolean): R;
|
|
13
|
-
declare function useActiveDocumentId(): string | null;
|
|
14
|
-
/** The document id for this subtree: the nearest <DocumentScope>, else the active doc. */
|
|
15
|
-
declare function useDocumentId(): string | null;
|
|
16
|
-
interface DocumentScopeProps {
|
|
17
|
-
id: string;
|
|
18
|
-
children: React.ReactNode;
|
|
19
|
-
}
|
|
20
|
-
/** Bind a subtree to a specific document (panes, comparison). */
|
|
21
|
-
declare function DocumentScope({ id, children }: DocumentScopeProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
interface DocumentGateProps {
|
|
23
|
-
/** Shown while this subtree has NO document (empty workspace, docs still opening). */
|
|
24
|
-
fallback?: React.ReactNode;
|
|
25
|
-
children: React.ReactNode;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Render children only while this subtree has a READY document — the
|
|
29
|
-
* structural way to say "this UI is defined over a document". An empty
|
|
30
|
-
* workspace is a legitimate, designable state (the Viewer no longer blocks on
|
|
31
|
-
* documents so chrome can render at t≈0): workspace-scoped UI (toolbars,
|
|
32
|
-
* commands, i18n) lives OUTSIDE the gate; document-scoped UI (Stage, panels,
|
|
33
|
-
* page chrome) lives inside it, or reads through `useOptionalSelector`.
|
|
34
|
-
* A `loading`/`locked`/`error` tab renders `fallback` — so the gate's
|
|
35
|
-
* fallback doubles as the per-tab boot state; richer chrome (a password
|
|
36
|
-
* prompt, an error pane) branches on `useDocumentStatus()` beside the gate.
|
|
37
|
-
* Sibling of <DocumentScope>, which picks WHICH document; this one handles
|
|
38
|
-
* WHETHER.
|
|
39
|
-
*/
|
|
40
|
-
declare function DocumentGate({ fallback, children }: DocumentGateProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
-
/** Lifecycle status of this subtree's document (loading/locked/ready/error),
|
|
42
|
-
* or null with no document. The password prompt and error panes key off it. */
|
|
43
|
-
declare function useDocumentStatus(): import("@embedpdf/core").DocStatus | null;
|
|
44
|
-
/**
|
|
45
|
-
* Resolve a capability by token, binding document-scoped ones to this
|
|
46
|
-
* subtree's document. Resolution is a REACTIVE read (`tryCapability` through
|
|
47
|
-
* the kernel's one change stream), not a memoized call — under the
|
|
48
|
-
* request-time lifecycle a document can become resolvable while its id stays
|
|
49
|
-
* the same, so any id-keyed cache goes stale; subscribing makes staleness
|
|
50
|
-
* structurally impossible. Fail-fast: while unresolvable, this re-runs the
|
|
51
|
-
* strict resolver so the kernel's truthful reason (`no capability` / `no
|
|
52
|
-
* document` / `document is loading|locked`) is what throws.
|
|
53
|
-
*/
|
|
54
|
-
declare function useCapability<T>(token: CapabilityToken<T>): T;
|
|
55
|
-
/** Like `useCapability`, but null while the token can't resolve (no plugin,
|
|
56
|
-
* no document, or a document that isn't ready yet). */
|
|
57
|
-
declare function useOptionalCapability<T>(token: CapabilityToken<T>): T | null;
|
|
58
|
-
/** Subscribe to a selector over a (document-resolved) capability. */
|
|
59
|
-
declare function useSelector<C, R>(token: CapabilityToken<C>, select: (cap: C) => R, isEqual?: (a: R, b: R) => boolean): R;
|
|
60
|
-
/**
|
|
61
|
-
* Null-safe `useSelector`: `fallback` whenever the token can't resolve — no
|
|
62
|
-
* provider, or a document-scoped token with no document. For chrome that stays
|
|
63
|
-
* mounted across the empty-workspace state (a zoom readout, a mode band).
|
|
64
|
-
* `useSelector` stays strict (fail-fast) for code that KNOWS a document exists
|
|
65
|
-
* — e.g. anything inside a <DocumentGate>.
|
|
66
|
-
*
|
|
67
|
-
* The `select` guard also swallows reads through a capability whose document
|
|
68
|
-
* closed between the store notification and this render — that teardown race
|
|
69
|
-
* resolves to `fallback` for one frame, then re-renders against the new state.
|
|
70
|
-
*/
|
|
71
|
-
declare function useOptionalSelector<C, R>(token: CapabilityToken<C>, select: (cap: C) => R, fallback: R, isEqual?: (a: R, b: R) => boolean): R;
|
|
72
|
-
/**
|
|
73
|
-
* Subscribe to a capability's {@link EventHook} for the mounted lifetime —
|
|
74
|
-
* `useCapabilityEvent(ActionsToken, (c) => c.onAction, handler)`. Events
|
|
75
|
-
* carry occurrences, never state (a late subscriber that needs the current
|
|
76
|
-
* value uses `useSelector`). The handler rides a ref, so a fresh closure per
|
|
77
|
-
* render never resubscribes. Null-safe: no plugin/document → no subscription.
|
|
78
|
-
*/
|
|
79
|
-
declare function useCapabilityEvent<C, T>(token: CapabilityToken<C>, select: (cap: C) => EventHook<T>, handler: (event: T) => void): void;
|
|
80
|
-
/** The document registry (open/close/active/list), reactive. */
|
|
81
|
-
declare function useDocuments(): {
|
|
82
|
-
docs: import("@embedpdf/core").DocInfo[];
|
|
83
|
-
activeId: string | null;
|
|
84
|
-
open: (input: import("@embedpdf/core").OpenSource, options?: import("@embedpdf/core").OpenDocumentOptions) => Promise<string>;
|
|
85
|
-
unlock: (id: string, input: {
|
|
86
|
-
password: string;
|
|
87
|
-
}) => Promise<void>;
|
|
88
|
-
close: (id: string) => Promise<void>;
|
|
89
|
-
setActive: (id: string) => void;
|
|
90
|
-
move: (id: string, toIndex: number) => void;
|
|
91
|
-
swap: (a: string, b: string) => void;
|
|
92
|
-
download: (id?: string, opts?: {
|
|
93
|
-
mode?: import("@embedpdf/core").PdfSaveMode;
|
|
94
|
-
}) => Promise<Uint8Array>;
|
|
95
|
-
downloadLayer: (id?: string) => Promise<Uint8Array>;
|
|
96
|
-
};
|
|
97
|
-
interface ViewerProps {
|
|
98
|
-
/**
|
|
99
|
-
* The engine, as an instance or a thunk. Engines construct synchronously and
|
|
100
|
-
* boot lazily (`localEngine()` allocates nothing until first use), so
|
|
101
|
-
* ownership follows the SHAPE of what you pass:
|
|
102
|
-
*
|
|
103
|
-
* - An **instance** (`engine={engine}`) is BORROWED: the Viewer uses it and
|
|
104
|
-
* never destroys it, because you acquired it and therefore own it. The
|
|
105
|
-
* common path — a module-scope `const engine = localEngine()` shared
|
|
106
|
-
* across viewers and route changes. The Viewer calls `engine.warmup?.()`
|
|
107
|
-
* on mount so the boot overlaps app initialization.
|
|
108
|
-
* - A **thunk** (`engine={() => localEngine()}`) is VIEWER-OWNED: the
|
|
109
|
-
* Viewer calls it on mount and `destroy()`s the result on unmount. Use it
|
|
110
|
-
* for per-mount isolation (StrictMode/HMR-clean teardown, independent
|
|
111
|
-
* multi-viewer engines).
|
|
112
|
-
*
|
|
113
|
-
* Init-only: captured on first render; later identity changes are ignored (dev warns).
|
|
114
|
-
*/
|
|
115
|
-
engine: Engine | EngineFactory;
|
|
116
|
-
/** Init-only: captured on first render; later identity changes are ignored (dev warns). */
|
|
117
|
-
plugins: AnyPlugin[];
|
|
118
|
-
/** Documents to open on startup (with optional tab names). Init-only. */
|
|
119
|
-
initialDocuments?: InitialDocument[];
|
|
120
|
-
fallback?: React.ReactNode;
|
|
121
|
-
/** Rendered when kernel construction or `start()` fails. Without it a boot
|
|
122
|
-
* failure renders nothing — but never a silent forever-fallback. */
|
|
123
|
-
renderError?: (error: unknown) => React.ReactNode;
|
|
124
|
-
children: React.ReactNode;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Owns the kernel as an EFFECT-scoped resource: each effect setup creates and
|
|
128
|
-
* starts exactly one kernel; each cleanup destroys exactly that one. That is
|
|
129
|
-
* the contract StrictMode exercises (two kernels in dev, the first fully
|
|
130
|
-
* destroyed) — the kernel itself is never restarted after destroy.
|
|
131
|
-
*
|
|
132
|
-
* The kernel is published to context the moment it exists — before `start()`
|
|
133
|
-
* resolves — so the `fallback` can use workspace capabilities (i18n copy on a
|
|
134
|
-
* loading screen) exactly as before. The one exception is the very first
|
|
135
|
-
* render, which happens before the effect: it renders nothing. Children mount
|
|
136
|
-
* once `start()` resolves — which never touches the engine, so the shell is
|
|
137
|
-
* alive while WASM compiles or the transport connects. `initialDocuments`
|
|
138
|
-
* open in the BACKGROUND and stream into the registry (`useDocuments()` is
|
|
139
|
-
* reactive); per-document loading UI is the Stage's job, not a root gate.
|
|
140
|
-
*
|
|
141
|
-
* ENGINE OWNERSHIP. When `engine` is a thunk, the Viewer OWNS it: each effect
|
|
142
|
-
* setup constructs one engine (construction is synchronous and inert — boot
|
|
143
|
-
* happens lazily inside the engine) and each cleanup destroys exactly that one
|
|
144
|
-
* — after the kernel, so handles close first. When `engine` is an instance it
|
|
145
|
-
* is BORROWED and never destroyed here; the Viewer only calls `warmup?.()` so
|
|
146
|
-
* the WASM/transport boot overlaps plugin initialization. StrictMode's
|
|
147
|
-
* double-mount therefore constructs two independent thunk engines and tears
|
|
148
|
-
* the first fully down, matching the kernel's own effect-scoped lifecycle.
|
|
149
|
-
* That means dev-only double resource use (two worker spawns, two font
|
|
150
|
-
* fetches, briefly overlapping) — deliberate, because it is exactly the
|
|
151
|
-
* leak-detection contract StrictMode exists to exercise; production mounts
|
|
152
|
-
* once and boots once.
|
|
153
|
-
*/
|
|
154
|
-
declare function Viewer({ engine, plugins, initialDocuments, fallback, renderError, children }: ViewerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
155
|
-
declare const EmbedPDF: typeof Viewer;
|
|
156
|
-
/**
|
|
157
|
-
* PageContext — the seam. A layer depends ONLY on this, never on the Stage. So the
|
|
158
|
-
* same layer works inside a virtualized Stage and in a standalone <PageView>.
|
|
159
|
-
*/
|
|
160
|
-
interface PageContextValue {
|
|
161
|
-
documentId: string;
|
|
162
|
-
/** Durable page identity (PDF object number) — use for keys / render / annotations. */
|
|
163
|
-
pon: number;
|
|
164
|
-
/** Display index (page N) — use for ordering / human-facing page numbers. */
|
|
165
|
-
pageIndex: number;
|
|
166
|
-
/**
|
|
167
|
-
* Reserved chrome bands around the page (screen px per side). The page-chrome
|
|
168
|
-
* slot renders into the outer box (content + frame); these thicknesses size
|
|
169
|
-
* the bands — a label in the bottom band is `bottom:0; height: frame.bottom`.
|
|
170
|
-
*/
|
|
171
|
-
frame: PageFrame;
|
|
172
|
-
/**
|
|
173
|
-
* The single bridge between PDF points, view px, and device px for this page.
|
|
174
|
-
* Layers do ALL coordinate work through it — `toPixels` to place content-
|
|
175
|
-
* space overlays, `renderScale`/`deviceWidth` to render, `contentWidth` for
|
|
176
|
-
* page-relative sizing. Never re-derive `x * scale` or `* dpr`.
|
|
177
|
-
*/
|
|
178
|
-
transform: PageTransform;
|
|
179
|
-
/** Client (screen) point → the viewer's coordinates (content point) — the
|
|
180
|
-
* one platform-bound hit-test. */
|
|
181
|
-
toContentPoint(clientX: number, clientY: number): Point;
|
|
182
|
-
/** Content point → client (screen) px — the exact inverse of `toContentPoint`
|
|
183
|
-
* (rotation applied). Lets viewport-space UI (e.g. a selection menu) anchor to a
|
|
184
|
-
* page point WITHOUT a Stage camera, so it works the same in `<PageView>`. */
|
|
185
|
-
toClientPoint(p: Point): Point;
|
|
186
|
-
/** Content rect → client (screen) px AABB. Rect analog of `toClientPoint`
|
|
187
|
-
* for upright viewport-space UI that frames a selected page region. */
|
|
188
|
-
toClientRect(rect: Rect): Rect;
|
|
189
|
-
/**
|
|
190
|
-
* The page-view DEMAND for raster planning uses dependency inversion:
|
|
191
|
-
* plugin-render defines the shape; the host that CREATED this
|
|
192
|
-
* context fills it — as a PULL. The Stage host's getter closes over the
|
|
193
|
-
* stage capability and reads `VisiblePage.visibleRect` live at call time
|
|
194
|
-
* (visibility is the STAGE's data; adapters never re-derive camera math or
|
|
195
|
-
* cache a copy). Three states, three meanings: a real sub-rect (visible),
|
|
196
|
-
* a ZERO rect (stage host, page currently off-screen — want nothing), and
|
|
197
|
-
* an undefined getter (stage-less `<PageView>` — whole page visible, which
|
|
198
|
-
* a thumbnail-sized demand turns into "never engages" by arithmetic).
|
|
199
|
-
*/
|
|
200
|
-
getViewDemand?: () => PageViewDemand;
|
|
201
|
-
/**
|
|
202
|
-
* The hosting VIEW's identity — the stage lens id (`stage.lensId()`) or a
|
|
203
|
-
* per-instance PageView id. IDENTITY, not an option: per-view raster
|
|
204
|
-
* planning (tiles) keys its state by this, so two views showing the SAME
|
|
205
|
-
* page never fight over one plan (a thumbnail rail's never-engaging demand
|
|
206
|
-
* must not disturb the main view's tiles). Every page context host must
|
|
207
|
-
* say which view it is.
|
|
208
|
-
*/
|
|
209
|
-
view: string;
|
|
210
|
-
}
|
|
211
|
-
declare const PageProvider: React.Provider<PageContextValue | null>;
|
|
212
|
-
declare function usePage(): PageContextValue;
|
|
213
|
-
declare function makePageContext(documentId: string, view: string, pon: number, pageIndex: number, frame: PageFrame, transform: PageTransform, getRect: () => DOMRect, getViewDemand?: () => PageViewDemand): PageContextValue;
|
|
214
|
-
//#endregion
|
|
215
|
-
export { usePage as C, useOptionalSelector as S, useDocumentStatus as _, EmbedPDF as a, useKernelValue as b, Viewer as c, runtime_d_exports as d, shallowArray as f, useDocumentId as g, useCapabilityEvent as h, DocumentScopeProps as i, ViewerProps as l, useCapability as m, DocumentGateProps as n, PageContextValue as o, useActiveDocumentId as p, DocumentScope as r, PageProvider as s, DocumentGate as t, makePageContext as u, useDocuments as v, useSelector as w, useOptionalCapability as x, useKernel as y };
|
|
216
|
-
//# sourceMappingURL=runtime-umHA_xHt.d.cts.map
|
package/dist/runtime.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.cjs","names":["docInfoListEquals"],"sources":["../src/runtime.tsx"],"sourcesContent":["/**\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), and provides the page coordinate context. Every plugin and layer rides\n * on this — there is no per-plugin framework code.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/core';\nimport * as React from 'react';\nimport {\n createContext,\n useContext,\n useEffect,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport { createKernel, docInfoListEquals } from '@embedpdf/core';\nimport type {\n AnyPlugin,\n CapabilityToken,\n Engine,\n EngineFactory,\n EventHook,\n InitialDocument,\n Kernel,\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 { PageFrame, PageTransform, Point, Rect } from '@embedpdf/core-geometry';\nimport type { PageViewDemand } from '@embedpdf/plugin-render/contract';\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 k = useContext(KernelCtx);\n if (!k) throw new Error('useKernel must be used within <Viewer>/<EmbedPDF>');\n return k;\n}\n\nexport const shallowArray = <T,>(a: readonly T[], b: readonly T[]): boolean =>\n a === b || (a.length === b.length && a.every((x, i) => x === b[i]));\n\n/** Read a value derived from the kernel, cached by equality (no tearing loop). */\nexport function useKernelValue<R>(\n select: (k: Kernel) => R,\n isEqual: (a: R, b: 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((k) => k.documents.activeId());\n}\n\n/** The document id for this subtree: the nearest <DocumentScope>, else the active doc. */\nexport function useDocumentId(): string | null {\n const scoped = useContext(DocumentScopeCtx);\n const active = useActiveDocumentId();\n return scoped ?? active;\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 (empty workspace, docs still opening). */\n fallback?: 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, or reads through `useOptionalSelector`.\n * A `loading`/`locked`/`error` tab renders `fallback` — so the gate's\n * fallback doubles as the per-tab boot state; richer chrome (a password\n * prompt, an error pane) branches on `useDocumentStatus()` beside the gate.\n * Sibling of <DocumentScope>, which picks WHICH document; this one handles\n * WHETHER.\n */\nexport function DocumentGate({ fallback = null, children }: DocumentGateProps) {\n const docId = useDocumentId();\n const ready = useKernelValue((k) => (docId ? k.documents.get(docId)?.status === 'ready' : false));\n return <>{ready ? children : fallback}</>;\n}\n\n/** Lifecycle status of this subtree's document (loading/locked/ready/error),\n * or null with no document. The password prompt and error panes key off it. */\nexport function useDocumentStatus() {\n const docId = useDocumentId();\n return useKernelValue((k) => (docId ? (k.documents.get(docId)?.status ?? null) : null));\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. Fail-fast: while unresolvable, this re-runs the\n * strict resolver so the kernel's truthful reason (`no capability` / `no\n * document` / `document is loading|locked`) is what throws.\n */\nexport function useCapability<T>(token: CapabilityToken<T>): T {\n const kernel = useKernel();\n const scoped = useContext(DocumentScopeCtx);\n const cap = useKernelValue((k) => k.tryCapability(token, scoped ?? undefined));\n return cap ?? kernel.capability(token, scoped ?? undefined);\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 = useContext(DocumentScopeCtx);\n return useKernelValue((k) => k.tryCapability(token, scoped ?? undefined));\n}\n\n/** Subscribe to a selector over a (document-resolved) capability. */\nexport function useSelector<C, R>(\n token: CapabilityToken<C>,\n select: (cap: C) => R,\n isEqual: (a: R, b: R) => boolean = Object.is,\n): R {\n const kernel = useKernel();\n const cap = useCapability(token);\n const last = useRef<{ v: R } | null>(null);\n const get = () => {\n const next = select(cap);\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 * `useSelector` stays strict (fail-fast) for code that KNOWS a document exists\n * — e.g. anything inside a <DocumentGate>.\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: (cap: C) => R,\n fallback: R,\n isEqual: (a: R, b: R) => boolean = Object.is,\n): R {\n const kernel = useKernel();\n const cap = useOptionalCapability(token);\n const last = useRef<{ v: R } | null>(null);\n const get = () => {\n let next: R;\n if (cap === null) {\n next = fallback;\n } else {\n try {\n next = select(cap);\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, (c) => c.onAction, 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: (cap: C) => EventHook<T>,\n handler: (event: T) => void,\n): void {\n const cap = useOptionalCapability(token);\n const handlerRef = useRef(handler);\n handlerRef.current = handler;\n const selectRef = useRef(select);\n selectRef.current = select;\n useEffect(() => {\n if (!cap) return;\n return selectRef.current(cap)((event) => handlerRef.current(event));\n }, [cap]);\n}\n\n/** The document registry (open/close/active/list), reactive. */\nexport function useDocuments() {\n const kernel = useKernel();\n const docs = useKernelValue((k) => k.documents.list(), docInfoListEquals);\n const activeId = useActiveDocumentId();\n return {\n docs,\n activeId,\n open: kernel.documents.open,\n unlock: kernel.documents.unlock,\n close: kernel.documents.close,\n setActive: kernel.documents.setActive,\n move: kernel.documents.move,\n swap: kernel.documents.swap,\n download: kernel.documents.download,\n downloadLayer: kernel.documents.downloadLayer,\n };\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 calls `engine.warmup?.()`\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 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) exactly as before. The one exception is the very first\n * render, which happens before the effect: it renders nothing. Children mount\n * once `start()` resolves — which never touches the engine, so the shell is\n * alive while WASM compiles or the transport connects. `initialDocuments`\n * open in the BACKGROUND and stream into the registry (`useDocuments()` is\n * reactive); per-document 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 calls `warmup?.()` so\n * the WASM/transport 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 function Viewer({\n engine,\n plugins,\n initialDocuments,\n fallback,\n renderError,\n children,\n}: ViewerProps) {\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 const warned = useRef(false);\n if (process.env.NODE_ENV !== 'production' && !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 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 kick `warmup()`\n // to overlap the WASM/transport 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 engine.warmup?.();\n let kernel: Kernel;\n try {\n kernel = createKernel({ engine, plugins: captured.plugins });\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 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 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 */\nexport interface PageContextValue {\n documentId: string;\n /** Durable page identity (PDF object number) — use for keys / render / annotations. */\n pon: number;\n /** Display index (page N) — use for ordering / human-facing page numbers. */\n pageIndex: number;\n /**\n * Reserved chrome bands around the page (screen px per side). The page-chrome\n * slot renders into the outer box (content + frame); these thicknesses size\n * the bands — a label in the bottom band is `bottom:0; height: frame.bottom`.\n */\n frame: PageFrame;\n /**\n * The single bridge between PDF points, view px, and device px for this page.\n * Layers do ALL coordinate work through it — `toPixels` to place content-\n * space overlays, `renderScale`/`deviceWidth` to render, `contentWidth` for\n * page-relative sizing. Never re-derive `x * scale` or `* dpr`.\n */\n transform: PageTransform;\n /** Client (screen) point → the viewer's coordinates (content point) — the\n * one platform-bound hit-test. */\n toContentPoint(clientX: number, clientY: number): Point;\n /** Content point → client (screen) px — the exact inverse of `toContentPoint`\n * (rotation applied). Lets viewport-space UI (e.g. a selection menu) anchor to a\n * page point WITHOUT a Stage camera, so it works the same in `<PageView>`. */\n toClientPoint(p: Point): Point;\n /** Content rect → client (screen) px AABB. Rect analog of `toClientPoint`\n * for upright viewport-space UI that frames a selected page region. */\n toClientRect(rect: Rect): Rect;\n /**\n * The page-view DEMAND for raster planning uses dependency inversion:\n * plugin-render defines the shape; the host that CREATED this\n * context fills it — as a PULL. The Stage host's getter closes over the\n * stage capability and reads `VisiblePage.visibleRect` live at call time\n * (visibility is the STAGE's data; adapters never re-derive camera math or\n * cache a copy). Three states, three meanings: a real sub-rect (visible),\n * a ZERO rect (stage host, page currently off-screen — want nothing), and\n * an undefined getter (stage-less `<PageView>` — whole page visible, which\n * a thumbnail-sized demand turns into \"never engages\" by arithmetic).\n */\n getViewDemand?: () => PageViewDemand;\n /**\n * The hosting VIEW's identity — the stage lens id (`stage.lensId()`) or a\n * per-instance PageView id. IDENTITY, not an option: per-view raster\n * planning (tiles) keys its state by this, so two views showing the SAME\n * page never fight over one plan (a thumbnail rail's never-engaging demand\n * must not disturb the main view's tiles). Every page context host must\n * say which view it is.\n */\n view: string;\n}\n\nconst PageCtx = createContext<PageContextValue | null>(null);\nexport const PageProvider = PageCtx.Provider;\n\nexport function usePage(): PageContextValue {\n const c = useContext(PageCtx);\n if (!c) throw new Error('usePage must be used inside <PageView> or a <Stage> page');\n return c;\n}\n\nexport function makePageContext(\n documentId: string,\n view: string,\n pon: number,\n pageIndex: number,\n frame: PageFrame,\n transform: PageTransform,\n getRect: () => DOMRect,\n getViewDemand?: () => PageViewDemand,\n): PageContextValue {\n return {\n documentId,\n view,\n pon,\n pageIndex,\n frame,\n transform,\n ...(getViewDemand ? { getViewDemand } : {}),\n toContentPoint: (cx, cy) => {\n // `getRect()` is the rotated content wrapper's axis-aligned bounding box =\n // the page's DISPLAY box on screen. Convert client → box-local view px,\n // then invert rotation + scale via the transform (verified once in geometry,\n // not re-derived per framework adapter).\n const r = getRect();\n return transform.viewToContent({ x: cx - r.left, y: cy - r.top });\n },\n toClientPoint: (p) => {\n // Exact inverse of `toContentPoint`: page/content point → display-box view px\n // (rotation applied by the transform), offset by the same live display-box\n // origin. So the two can never drift, in either <Stage> or <PageView>.\n const r = getRect();\n const v = transform.contentToView(p);\n return { x: r.left + v.x, y: r.top + v.y };\n },\n toClientRect: (rect) => {\n const r = getRect();\n const v = transform.contentToViewRect(rect);\n return { x: r.left + v.x, y: r.top + v.y, width: v.width, height: v.height };\n },\n };\n}\n"],"mappings":";;;;;;;AAmCA,MAAM,aAAA,GAAA,MAAA,cAAA,CAAyC,IAAI;;AAEnD,MAAM,oBAAA,GAAA,MAAA,cAAA,CAAgD,IAAI;AAE1D,SAAgB,YAAoB;CAClC,MAAM,KAAA,GAAA,MAAA,WAAA,CAAe,SAAS;CAC9B,IAAI,CAAC,GAAG,MAAM,IAAI,MAAM,mDAAmD;CAC3E,OAAO;AACT;AAEA,MAAa,gBAAoB,GAAiB,MAChD,MAAM,KAAM,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,GAAG,MAAM,MAAM,EAAE,EAAE;;AAGnE,SAAgB,eACd,QACA,UAAmC,OAAO,IACvC;CACH,MAAM,SAAS,UAAU;CACzB,MAAM,QAAA,GAAA,MAAA,OAAA,CAA+B,IAAI;CACzC,MAAM,YAAY;EAChB,MAAM,OAAO,OAAO,MAAM;EAC1B,IAAI,KAAK,WAAW,QAAQ,KAAK,QAAQ,GAAG,IAAI,GAAG,OAAO,KAAK,QAAQ;EACvE,KAAK,UAAU,EAAE,GAAG,KAAK;EACzB,OAAO;CACT;CACA,QAAA,GAAA,MAAA,qBAAA,CAA4B,OAAO,WAAW,KAAK,GAAG;AACxD;AAEA,SAAgB,sBAAqC;CACnD,OAAO,gBAAgB,MAAM,EAAE,UAAU,SAAS,CAAC;AACrD;;AAGA,SAAgB,gBAA+B;CAC7C,MAAM,UAAA,GAAA,MAAA,WAAA,CAAoB,gBAAgB;CAC1C,MAAM,SAAS,oBAAoB;CACnC,OAAO,UAAU;AACnB;;AAOA,SAAgB,cAAc,EAAE,IAAI,YAAgC;CAClE,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,iBAAiB,UAAlB;EAA2B,OAAO;EAAK;CAAoC,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CACF;AACF"}
|
package/dist/runtime.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","names":[],"sources":["../src/runtime.tsx"],"sourcesContent":["/**\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), and provides the page coordinate context. Every plugin and layer rides\n * on this — there is no per-plugin framework code.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/core';\nimport * as React from 'react';\nimport {\n createContext,\n useContext,\n useEffect,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport { createKernel, docInfoListEquals } from '@embedpdf/core';\nimport type {\n AnyPlugin,\n CapabilityToken,\n Engine,\n EngineFactory,\n EventHook,\n InitialDocument,\n Kernel,\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 { PageFrame, PageTransform, Point, Rect } from '@embedpdf/core-geometry';\nimport type { PageViewDemand } from '@embedpdf/plugin-render/contract';\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 k = useContext(KernelCtx);\n if (!k) throw new Error('useKernel must be used within <Viewer>/<EmbedPDF>');\n return k;\n}\n\nexport const shallowArray = <T,>(a: readonly T[], b: readonly T[]): boolean =>\n a === b || (a.length === b.length && a.every((x, i) => x === b[i]));\n\n/** Read a value derived from the kernel, cached by equality (no tearing loop). */\nexport function useKernelValue<R>(\n select: (k: Kernel) => R,\n isEqual: (a: R, b: 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((k) => k.documents.activeId());\n}\n\n/** The document id for this subtree: the nearest <DocumentScope>, else the active doc. */\nexport function useDocumentId(): string | null {\n const scoped = useContext(DocumentScopeCtx);\n const active = useActiveDocumentId();\n return scoped ?? active;\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 (empty workspace, docs still opening). */\n fallback?: 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, or reads through `useOptionalSelector`.\n * A `loading`/`locked`/`error` tab renders `fallback` — so the gate's\n * fallback doubles as the per-tab boot state; richer chrome (a password\n * prompt, an error pane) branches on `useDocumentStatus()` beside the gate.\n * Sibling of <DocumentScope>, which picks WHICH document; this one handles\n * WHETHER.\n */\nexport function DocumentGate({ fallback = null, children }: DocumentGateProps) {\n const docId = useDocumentId();\n const ready = useKernelValue((k) => (docId ? k.documents.get(docId)?.status === 'ready' : false));\n return <>{ready ? children : fallback}</>;\n}\n\n/** Lifecycle status of this subtree's document (loading/locked/ready/error),\n * or null with no document. The password prompt and error panes key off it. */\nexport function useDocumentStatus() {\n const docId = useDocumentId();\n return useKernelValue((k) => (docId ? (k.documents.get(docId)?.status ?? null) : null));\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. Fail-fast: while unresolvable, this re-runs the\n * strict resolver so the kernel's truthful reason (`no capability` / `no\n * document` / `document is loading|locked`) is what throws.\n */\nexport function useCapability<T>(token: CapabilityToken<T>): T {\n const kernel = useKernel();\n const scoped = useContext(DocumentScopeCtx);\n const cap = useKernelValue((k) => k.tryCapability(token, scoped ?? undefined));\n return cap ?? kernel.capability(token, scoped ?? undefined);\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 = useContext(DocumentScopeCtx);\n return useKernelValue((k) => k.tryCapability(token, scoped ?? undefined));\n}\n\n/** Subscribe to a selector over a (document-resolved) capability. */\nexport function useSelector<C, R>(\n token: CapabilityToken<C>,\n select: (cap: C) => R,\n isEqual: (a: R, b: R) => boolean = Object.is,\n): R {\n const kernel = useKernel();\n const cap = useCapability(token);\n const last = useRef<{ v: R } | null>(null);\n const get = () => {\n const next = select(cap);\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 * `useSelector` stays strict (fail-fast) for code that KNOWS a document exists\n * — e.g. anything inside a <DocumentGate>.\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: (cap: C) => R,\n fallback: R,\n isEqual: (a: R, b: R) => boolean = Object.is,\n): R {\n const kernel = useKernel();\n const cap = useOptionalCapability(token);\n const last = useRef<{ v: R } | null>(null);\n const get = () => {\n let next: R;\n if (cap === null) {\n next = fallback;\n } else {\n try {\n next = select(cap);\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, (c) => c.onAction, 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: (cap: C) => EventHook<T>,\n handler: (event: T) => void,\n): void {\n const cap = useOptionalCapability(token);\n const handlerRef = useRef(handler);\n handlerRef.current = handler;\n const selectRef = useRef(select);\n selectRef.current = select;\n useEffect(() => {\n if (!cap) return;\n return selectRef.current(cap)((event) => handlerRef.current(event));\n }, [cap]);\n}\n\n/** The document registry (open/close/active/list), reactive. */\nexport function useDocuments() {\n const kernel = useKernel();\n const docs = useKernelValue((k) => k.documents.list(), docInfoListEquals);\n const activeId = useActiveDocumentId();\n return {\n docs,\n activeId,\n open: kernel.documents.open,\n unlock: kernel.documents.unlock,\n close: kernel.documents.close,\n setActive: kernel.documents.setActive,\n move: kernel.documents.move,\n swap: kernel.documents.swap,\n download: kernel.documents.download,\n downloadLayer: kernel.documents.downloadLayer,\n };\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 calls `engine.warmup?.()`\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 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) exactly as before. The one exception is the very first\n * render, which happens before the effect: it renders nothing. Children mount\n * once `start()` resolves — which never touches the engine, so the shell is\n * alive while WASM compiles or the transport connects. `initialDocuments`\n * open in the BACKGROUND and stream into the registry (`useDocuments()` is\n * reactive); per-document 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 calls `warmup?.()` so\n * the WASM/transport 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 function Viewer({\n engine,\n plugins,\n initialDocuments,\n fallback,\n renderError,\n children,\n}: ViewerProps) {\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 const warned = useRef(false);\n if (process.env.NODE_ENV !== 'production' && !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 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 kick `warmup()`\n // to overlap the WASM/transport 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 engine.warmup?.();\n let kernel: Kernel;\n try {\n kernel = createKernel({ engine, plugins: captured.plugins });\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 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 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 */\nexport interface PageContextValue {\n documentId: string;\n /** Durable page identity (PDF object number) — use for keys / render / annotations. */\n pon: number;\n /** Display index (page N) — use for ordering / human-facing page numbers. */\n pageIndex: number;\n /**\n * Reserved chrome bands around the page (screen px per side). The page-chrome\n * slot renders into the outer box (content + frame); these thicknesses size\n * the bands — a label in the bottom band is `bottom:0; height: frame.bottom`.\n */\n frame: PageFrame;\n /**\n * The single bridge between PDF points, view px, and device px for this page.\n * Layers do ALL coordinate work through it — `toPixels` to place content-\n * space overlays, `renderScale`/`deviceWidth` to render, `contentWidth` for\n * page-relative sizing. Never re-derive `x * scale` or `* dpr`.\n */\n transform: PageTransform;\n /** Client (screen) point → the viewer's coordinates (content point) — the\n * one platform-bound hit-test. */\n toContentPoint(clientX: number, clientY: number): Point;\n /** Content point → client (screen) px — the exact inverse of `toContentPoint`\n * (rotation applied). Lets viewport-space UI (e.g. a selection menu) anchor to a\n * page point WITHOUT a Stage camera, so it works the same in `<PageView>`. */\n toClientPoint(p: Point): Point;\n /** Content rect → client (screen) px AABB. Rect analog of `toClientPoint`\n * for upright viewport-space UI that frames a selected page region. */\n toClientRect(rect: Rect): Rect;\n /**\n * The page-view DEMAND for raster planning uses dependency inversion:\n * plugin-render defines the shape; the host that CREATED this\n * context fills it — as a PULL. The Stage host's getter closes over the\n * stage capability and reads `VisiblePage.visibleRect` live at call time\n * (visibility is the STAGE's data; adapters never re-derive camera math or\n * cache a copy). Three states, three meanings: a real sub-rect (visible),\n * a ZERO rect (stage host, page currently off-screen — want nothing), and\n * an undefined getter (stage-less `<PageView>` — whole page visible, which\n * a thumbnail-sized demand turns into \"never engages\" by arithmetic).\n */\n getViewDemand?: () => PageViewDemand;\n /**\n * The hosting VIEW's identity — the stage lens id (`stage.lensId()`) or a\n * per-instance PageView id. IDENTITY, not an option: per-view raster\n * planning (tiles) keys its state by this, so two views showing the SAME\n * page never fight over one plan (a thumbnail rail's never-engaging demand\n * must not disturb the main view's tiles). Every page context host must\n * say which view it is.\n */\n view: string;\n}\n\nconst PageCtx = createContext<PageContextValue | null>(null);\nexport const PageProvider = PageCtx.Provider;\n\nexport function usePage(): PageContextValue {\n const c = useContext(PageCtx);\n if (!c) throw new Error('usePage must be used inside <PageView> or a <Stage> page');\n return c;\n}\n\nexport function makePageContext(\n documentId: string,\n view: string,\n pon: number,\n pageIndex: number,\n frame: PageFrame,\n transform: PageTransform,\n getRect: () => DOMRect,\n getViewDemand?: () => PageViewDemand,\n): PageContextValue {\n return {\n documentId,\n view,\n pon,\n pageIndex,\n frame,\n transform,\n ...(getViewDemand ? { getViewDemand } : {}),\n toContentPoint: (cx, cy) => {\n // `getRect()` is the rotated content wrapper's axis-aligned bounding box =\n // the page's DISPLAY box on screen. Convert client → box-local view px,\n // then invert rotation + scale via the transform (verified once in geometry,\n // not re-derived per framework adapter).\n const r = getRect();\n return transform.viewToContent({ x: cx - r.left, y: cy - r.top });\n },\n toClientPoint: (p) => {\n // Exact inverse of `toContentPoint`: page/content point → display-box view px\n // (rotation applied by the transform), offset by the same live display-box\n // origin. So the two can never drift, in either <Stage> or <PageView>.\n const r = getRect();\n const v = transform.contentToView(p);\n return { x: r.left + v.x, y: r.top + v.y };\n },\n toClientRect: (rect) => {\n const r = getRect();\n const v = trans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