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