@embedpdf/plugin-link 3.0.0-next.0

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/LICENSE ADDED
@@ -0,0 +1,192 @@
1
+ Copyright 2026 CloudPDF LTD
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use files in this distribution except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ https://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+
15
+ -----------------------------------------------------------------------
16
+
17
+ Apache License
18
+ Version 2.0, January 2004
19
+ http://www.apache.org/licenses/
20
+
21
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
22
+
23
+ 1. Definitions.
24
+
25
+ "License" shall mean the terms and conditions for use, reproduction,
26
+ and distribution as defined by Sections 1 through 9 of this document.
27
+
28
+ "Licensor" shall mean the copyright owner or entity authorized by
29
+ the copyright owner that is granting the License.
30
+
31
+ "Legal Entity" shall mean the union of the acting entity and all
32
+ other entities that control, are controlled by, or are under common
33
+ control with that entity. For the purposes of this definition,
34
+ "control" means (i) the power, direct or indirect, to cause the
35
+ direction or management of such entity, whether by contract or
36
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
37
+ outstanding shares, or (iii) beneficial ownership of such entity.
38
+
39
+ "You" (or "Your") shall mean an individual or Legal Entity
40
+ exercising permissions granted by this License.
41
+
42
+ "Source" form shall mean the preferred form for making modifications,
43
+ including but not limited to software source code, documentation
44
+ source, and configuration files.
45
+
46
+ "Object" form shall mean any form resulting from mechanical
47
+ transformation or translation of a Source form, including but
48
+ not limited to compiled object code, generated documentation,
49
+ and conversions to other media types.
50
+
51
+ "Work" shall mean the work of authorship, whether in Source or
52
+ Object form, made available under the License, as indicated by a
53
+ copyright notice that is included in or attached to the work
54
+ (an example is provided in the Appendix below).
55
+
56
+ "Derivative Works" shall mean any work, whether in Source or Object
57
+ form, that is based on (or derived from) the Work and for which the
58
+ editorial revisions, annotations, elaborations, or other modifications
59
+ represent, as a whole, an original work of authorship. For the purposes
60
+ of this License, Derivative Works shall not include works that remain
61
+ separable from, or merely link (or bind by name) to the interfaces of,
62
+ the Work and Derivative Works thereof.
63
+
64
+ "Contribution" shall mean any work of authorship, including
65
+ the original version of the Work and any modifications or additions
66
+ to that Work or Derivative Works thereof, that is intentionally
67
+ submitted to Licensor for inclusion in the Work by the copyright owner
68
+ or by an individual or Legal Entity authorized to submit on behalf of
69
+ the copyright owner. For the purposes of this definition, "submitted"
70
+ means any form of electronic, verbal, or written communication sent
71
+ to the Licensor or its representatives, including but not limited to
72
+ communication on electronic mailing lists, source code control systems,
73
+ and issue tracking systems that are managed by, or on behalf of, the
74
+ Licensor for the purpose of discussing and improving the Work, but
75
+ excluding communication that is conspicuously marked or otherwise
76
+ designated in writing by the copyright owner as "Not a Contribution."
77
+
78
+ "Contributor" shall mean Licensor and any individual or Legal Entity
79
+ on behalf of whom a Contribution has been received by Licensor and
80
+ subsequently incorporated within the Work.
81
+
82
+ 2. Grant of Copyright License. Subject to the terms and conditions of
83
+ this License, each Contributor hereby grants to You a perpetual,
84
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
85
+ copyright license to reproduce, prepare Derivative Works of,
86
+ publicly display, publicly perform, sublicense, and distribute the
87
+ Work and such Derivative Works in Source or Object form.
88
+
89
+ 3. Grant of Patent License. Subject to the terms and conditions of
90
+ this License, each Contributor hereby grants to You a perpetual,
91
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
92
+ (except as stated in this section) patent license to make, have made,
93
+ use, offer to sell, sell, import, and otherwise transfer the Work,
94
+ where such license applies only to those patent claims licensable
95
+ by such Contributor that are necessarily infringed by their
96
+ Contribution(s) alone or by combination of their Contribution(s)
97
+ with the Work to which such Contribution(s) was submitted. If You
98
+ institute patent litigation against any entity (including a
99
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
100
+ or a Contribution incorporated within the Work constitutes direct
101
+ or contributory patent infringement, then any patent licenses
102
+ granted to You under this License for that Work shall terminate
103
+ as of the date such litigation is filed.
104
+
105
+ 4. Redistribution. You may reproduce and distribute copies of the
106
+ Work or Derivative Works thereof in any medium, with or without
107
+ modifications, and in Source or Object form, provided that You
108
+ meet the following conditions:
109
+
110
+ (a) You must give any other recipients of the Work or
111
+ Derivative Works a copy of this License; and
112
+
113
+ (b) You must cause any modified files to carry prominent notices
114
+ stating that You changed the files; and
115
+
116
+ (c) You must retain, in the Source form of any Derivative Works
117
+ that You distribute, all copyright, patent, trademark, and
118
+ attribution notices from the Source form of the Work,
119
+ excluding those notices that do not pertain to any part of
120
+ the Derivative Works; and
121
+
122
+ (d) If the Work includes a "NOTICE" text file as part of its
123
+ distribution, then any Derivative Works that You distribute must
124
+ include a readable copy of the attribution notices contained
125
+ within such NOTICE file, excluding those notices that do not
126
+ pertain to any part of the Derivative Works, in at least one
127
+ of the following places: within a NOTICE text file distributed
128
+ as part of the Derivative Works; within the Source form or
129
+ documentation, if provided along with the Derivative Works; or,
130
+ within a display generated by the Derivative Works, if and
131
+ wherever such third-party notices normally appear. The contents
132
+ of the NOTICE file are for informational purposes only and
133
+ do not modify the License. You may add Your own attribution
134
+ notices within Derivative Works that You distribute, alongside
135
+ or as an addendum to the NOTICE text from the Work, provided
136
+ that such additional attribution notices cannot be construed
137
+ as modifying the License.
138
+
139
+ You may add Your own copyright statement to Your modifications and
140
+ may provide additional or different license terms and conditions
141
+ for use, reproduction, or distribution of Your modifications, or
142
+ for any such Derivative Works as a whole, provided Your use,
143
+ reproduction, and distribution of the Work otherwise complies with
144
+ the conditions stated in this License.
145
+
146
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
147
+ any Contribution intentionally submitted for inclusion in the Work
148
+ by You to the Licensor shall be under the terms and conditions of
149
+ this License, without any additional terms or conditions.
150
+ Notwithstanding the above, nothing herein shall supersede or modify
151
+ the terms of any separate license agreement you may have executed
152
+ with Licensor regarding such Contributions.
153
+
154
+ 6. Trademarks. This License does not grant permission to use the trade
155
+ names, trademarks, service marks, or product names of the Licensor,
156
+ except as required for reasonable and customary use in describing the
157
+ origin of the Work and reproducing the content of the NOTICE file.
158
+
159
+ 7. Disclaimer of Warranty. Unless required by applicable law or
160
+ agreed to in writing, Licensor provides the Work (and each
161
+ Contributor provides its Contributions) on an "AS IS" BASIS,
162
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
163
+ implied, including, without limitation, any warranties or conditions
164
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
165
+ PARTICULAR PURPOSE. You are solely responsible for determining the
166
+ appropriateness of using or redistributing the Work and assume any
167
+ risks associated with Your exercise of permissions under this License.
168
+
169
+ 8. Limitation of Liability. In no event and under no legal theory,
170
+ whether in tort (including negligence), contract, or otherwise,
171
+ unless required by applicable law (such as deliberate and grossly
172
+ negligent acts) or agreed to in writing, shall any Contributor be
173
+ liable to You for damages, including any direct, indirect, special,
174
+ incidental, or consequential damages of any character arising as a
175
+ result of this License or out of the use or inability to use the
176
+ Work (including but not limited to damages for loss of goodwill,
177
+ work stoppage, computer failure or malfunction, or any and all
178
+ other commercial damages or losses), even if such Contributor
179
+ has been advised of the possibility of such damages.
180
+
181
+ 9. Accepting Warranty or Additional Liability. While redistributing
182
+ the Work or Derivative Works thereof, You may choose to offer,
183
+ and charge a fee for, acceptance of support, warranty, indemnity,
184
+ or other liability obligations and/or rights consistent with this
185
+ License. However, in accepting such obligations, You may act only
186
+ on Your own behalf and on Your sole responsibility, not on behalf
187
+ of any other Contributor, and only if You agree to indemnify,
188
+ defend, and hold each Contributor harmless for any liability
189
+ incurred by, or claims asserted against, such Contributor by reason
190
+ of your accepting any such warranty or additional liability.
191
+
192
+ END OF TERMS AND CONDITIONS
package/dist/index.cjs ADDED
@@ -0,0 +1,196 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _embedpdf_core = require("@embedpdf/core");
3
+ let _embedpdf_plugin_interaction = require("@embedpdf/plugin-interaction");
4
+ let _embedpdf_plugin_stage = require("@embedpdf/plugin-stage");
5
+ let _embedpdf_plugin_annotation = require("@embedpdf/plugin-annotation");
6
+ let _embedpdf_plugin_annotation_internal = require("@embedpdf/plugin-annotation/internal");
7
+ let _embedpdf_core_annotation = require("@embedpdf/core-annotation");
8
+ //#region src/source.ts
9
+ function loadLinksPage(io, pon) {
10
+ const doc = io.doc;
11
+ const crop = io.document()?.pages.find((p) => p.pageObjectNumber === pon)?.boxes.crop;
12
+ if (!doc || !crop) return;
13
+ doc.page(pon).annotations.list().then((snap) => {
14
+ const items = [];
15
+ for (const dto of snap.annotations) {
16
+ if (dto.subtype !== "link" || dto.target == null) continue;
17
+ if (dto.flags.hidden || dto.flags.noView) continue;
18
+ items.push({
19
+ id: dto.ref.kind === "objectNumber" ? `obj:${dto.ref.annotObjectNumber}` : `idx:${pon}:${dto.index}`,
20
+ rect: (0, _embedpdf_core_annotation.pdfToContentRect)(dto.rect, crop),
21
+ target: dto.target
22
+ });
23
+ }
24
+ io.dispatch({
25
+ type: "SET_PAGE",
26
+ pon,
27
+ items
28
+ });
29
+ }, () => {});
30
+ }
31
+ //#endregion
32
+ //#region src/capability.ts
33
+ const EMPTY = [];
34
+ /**
35
+ * The navigation plane's surface. Data source is decided PER CALL (lazily,
36
+ * so plugin registration order can't matter): the annotation plugin's
37
+ * folded model when present — its `linkItemsOn` lens is memoized by model
38
+ * identity and already excludes hidden links — else this plugin's own
39
+ * engine-backed page cache (see source.ts).
40
+ */
41
+ function createLinkCapability(ctx, config = {}) {
42
+ const anno = () => ctx.tryGet(_embedpdf_plugin_annotation_internal.AnnotationToken);
43
+ const activate = (target) => {
44
+ const activation = (() => {
45
+ switch (target.kind) {
46
+ case "goto": {
47
+ const stage = ctx.tryGet(_embedpdf_plugin_stage.StageToken);
48
+ const layout = ctx.document()?.pages.find((p) => p.pageObjectNumber === target.destination.pageObjectNumber);
49
+ if (!stage || !layout) return {
50
+ outcome: "destination",
51
+ destination: target.destination
52
+ };
53
+ const { pageIndex, options } = (0, _embedpdf_plugin_stage.destinationToReveal)(target.destination, layout);
54
+ stage.reveal(pageIndex, {
55
+ ...options,
56
+ behavior: "smooth"
57
+ });
58
+ return { outcome: "revealed" };
59
+ }
60
+ case "uri": return {
61
+ outcome: "uri",
62
+ uri: target.uri
63
+ };
64
+ case "named": return {
65
+ outcome: "named",
66
+ name: target.name
67
+ };
68
+ default: return {
69
+ outcome: "reported",
70
+ target
71
+ };
72
+ }
73
+ })();
74
+ config.onActivate?.({
75
+ target,
76
+ activation
77
+ });
78
+ return activation;
79
+ };
80
+ return {
81
+ linksOn: (pon) => {
82
+ const host = anno();
83
+ if (host) return host.linkItemsOn(pon);
84
+ return ctx.getState().pages[pon] ?? EMPTY;
85
+ },
86
+ ensurePage: (pon) => {
87
+ const host = anno();
88
+ if (host) {
89
+ host.ensurePage(pon);
90
+ return;
91
+ }
92
+ if (!(pon in ctx.getState().pages)) loadLinksPage(ctx, pon);
93
+ },
94
+ engaged: () => ctx.tryGet(_embedpdf_plugin_interaction.InteractionToken)?.activeTool()?.enables.has("link-nav") ?? false,
95
+ activate
96
+ };
97
+ }
98
+ //#endregion
99
+ //#region src/effects.ts
100
+ /**
101
+ * Keeps the ENGINE-BACKED page cache honest in viewer-only deployments:
102
+ * any annotation mutation on a cached page (own or remote — the cache has
103
+ * no other refresh path, unlike the annotation plugin's optimistic model)
104
+ * refetches that page's links. With the annotation plugin present the
105
+ * folded model is the source and this effect never fires a fetch.
106
+ */
107
+ function registerLinkEffects(ctx) {
108
+ const doc = ctx.doc;
109
+ if (!doc) return;
110
+ const refetch = (pon) => {
111
+ if (ctx.tryGet(_embedpdf_plugin_annotation_internal.AnnotationToken)) return;
112
+ if (pon in ctx.getState().pages) loadLinksPage(ctx, pon);
113
+ };
114
+ const unsubscribe = doc.events.subscribe((event) => {
115
+ switch (event.type) {
116
+ case "annotation.created":
117
+ refetch(event.created.pageObjectNumber);
118
+ break;
119
+ case "annotation.updated":
120
+ refetch(event.updated.pageObjectNumber);
121
+ break;
122
+ case "annotation.moved":
123
+ if (event.moved.length) refetch(event.moved[0].pageObjectNumber);
124
+ break;
125
+ case "annotation.deleted":
126
+ refetch(event.pageObjectNumber);
127
+ break;
128
+ default: break;
129
+ }
130
+ });
131
+ ctx.cleanup(unsubscribe);
132
+ }
133
+ //#endregion
134
+ //#region src/reducer.ts
135
+ const initialLinkState = () => ({ pages: {} });
136
+ /** Pure. Engine-backed page cache only — the annotation-backed mode reads the
137
+ * annotation plugin's model and never touches this state. */
138
+ function linkReducer(state, a) {
139
+ switch (a.type) {
140
+ case "SET_PAGE": return {
141
+ ...state,
142
+ pages: {
143
+ ...state.pages,
144
+ [a.pon]: a.items
145
+ }
146
+ };
147
+ case "DROP_PAGE": {
148
+ if (!(a.pon in state.pages)) return state;
149
+ const pages = { ...state.pages };
150
+ delete pages[a.pon];
151
+ return {
152
+ ...state,
153
+ pages
154
+ };
155
+ }
156
+ }
157
+ }
158
+ //#endregion
159
+ //#region src/types.ts
160
+ const LinkToken = (0, _embedpdf_core.createCapabilityToken)("link");
161
+ //#endregion
162
+ //#region src/link.plugin.ts
163
+ /**
164
+ * The link plugin: the NAVIGATION plane. Document-scoped; requires only the
165
+ * interaction hub. Navigation works with no annotation plugin at all —
166
+ * links are read from the engine's link DTOs. When the annotation plugin IS
167
+ * present, its folded model becomes the data source (no double fetch) and a
168
+ * Behavior keeps links navigation-owned while a `link-nav` tool is active
169
+ * (pointer/pan/form-fill by default) — the single-active-tool hub IS the
170
+ * mode switch: grab the link tool and every link becomes an editable rect.
171
+ */
172
+ const linkPlugin = (config) => (0, _embedpdf_core.definePlugin)({
173
+ id: "link",
174
+ token: LinkToken,
175
+ scope: "document",
176
+ requires: [_embedpdf_plugin_interaction.InteractionToken],
177
+ optional: [_embedpdf_plugin_stage.StageToken, _embedpdf_plugin_annotation.AnnotationToken],
178
+ initialState: initialLinkState,
179
+ reduce: linkReducer,
180
+ capability: (ctx) => createLinkCapability(ctx, config),
181
+ effects: registerLinkEffects,
182
+ init: (ctx) => {
183
+ const interaction = ctx.get(_embedpdf_plugin_interaction.InteractionToken);
184
+ const annotation = ctx.tryGet(_embedpdf_plugin_annotation_internal.AnnotationToken);
185
+ if (annotation) annotation.registerBehavior({
186
+ id: "link-nav",
187
+ matches: (a) => a.subtype === "link",
188
+ engaged: () => interaction.activeTool()?.enables.has("link-nav") ?? false
189
+ });
190
+ }
191
+ });
192
+ //#endregion
193
+ exports.LinkToken = LinkToken;
194
+ exports.linkPlugin = linkPlugin;
195
+
196
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["AnnotationHostToken","StageToken","InteractionToken","AnnotationHostToken","InteractionToken","StageToken","AnnotationToken","AnnotationHostToken"],"sources":["../src/source.ts","../src/capability.ts","../src/effects.ts","../src/reducer.ts","../src/types.ts","../src/link.plugin.ts"],"sourcesContent":["import type { DocumentHandle, PageLayout } from '@embedpdf/core';\nimport { pdfToContentRect } from '@embedpdf/core-annotation';\nimport type { LinkAction, LinkNavItem } from './types';\n\n/**\n * The ENGINE-BACKED link source, for viewer-only deployments (no annotation\n * plugin): read a page's annotation list and keep just the navigable links —\n * standalone AND attached children alike (both are raw link DTOs here).\n * Shared by the capability's lazy `ensurePage` and the effects module's\n * event-driven refetch; both PluginContext and EffectContext satisfy the\n * structural `io` slice.\n */\nexport interface LinkSourceIO {\n doc: DocumentHandle | null;\n document(): { pages: readonly PageLayout[] } | null;\n dispatch(action: LinkAction): void;\n}\n\nexport function loadLinksPage(io: LinkSourceIO, pon: number): void {\n const doc = io.doc;\n const crop = io.document()?.pages.find((p) => p.pageObjectNumber === pon)?.boxes.crop;\n if (!doc || !crop) return;\n doc\n .page(pon)\n .annotations.list()\n .then(\n (snap) => {\n const items: LinkNavItem[] = [];\n for (const dto of snap.annotations) {\n if (dto.subtype !== 'link' || dto.target == null) continue;\n if (dto.flags.hidden || dto.flags.noView) continue;\n items.push({\n id:\n dto.ref.kind === 'objectNumber'\n ? `obj:${dto.ref.annotObjectNumber}`\n : `idx:${pon}:${dto.index}`,\n rect: pdfToContentRect(dto.rect, crop),\n target: dto.target,\n });\n }\n io.dispatch({ type: 'SET_PAGE', pon, items });\n },\n () => {},\n );\n}\n","import type { PluginContext } from '@embedpdf/core';\nimport type { PdfLinkTarget } from '@embedpdf/engine-core/runtime';\nimport { InteractionToken } from '@embedpdf/plugin-interaction';\nimport { destinationToReveal, StageToken } from '@embedpdf/plugin-stage';\n// The host lens (linkItemsOn) — same runtime token as the public one.\nimport { AnnotationToken as AnnotationHostToken } from '@embedpdf/plugin-annotation/internal';\nimport { loadLinksPage } from './source';\nimport type {\n LinkAction,\n LinkActivation,\n LinkCapability,\n LinkNavItem,\n LinkPluginConfig,\n LinkState,\n} from './types';\n\nconst EMPTY: LinkNavItem[] = [];\n\n/**\n * The navigation plane's surface. Data source is decided PER CALL (lazily,\n * so plugin registration order can't matter): the annotation plugin's\n * folded model when present — its `linkItemsOn` lens is memoized by model\n * identity and already excludes hidden links — else this plugin's own\n * engine-backed page cache (see source.ts).\n */\nexport function createLinkCapability(\n ctx: PluginContext<LinkState, LinkAction>,\n config: LinkPluginConfig = {},\n): LinkCapability {\n const anno = () => ctx.tryGet(AnnotationHostToken);\n\n const activate = (target: PdfLinkTarget): LinkActivation => {\n const activation = ((): LinkActivation => {\n switch (target.kind) {\n case 'goto': {\n const stage = ctx.tryGet(StageToken);\n const layout = ctx\n .document()\n ?.pages.find((p) => p.pageObjectNumber === target.destination.pageObjectNumber);\n if (!stage || !layout) {\n // No camera to drive — hand the embedder the explicit destination.\n return { outcome: 'destination', destination: target.destination };\n }\n const { pageIndex, options } = destinationToReveal(target.destination, layout);\n stage.reveal(pageIndex, { ...options, behavior: 'smooth' });\n return { outcome: 'revealed' };\n }\n case 'uri':\n // Opening is the FRAMEWORK layer's job (a real <a href> after\n // sanitizing) — this plugin never touches the DOM.\n return { outcome: 'uri', uri: target.uri };\n case 'named':\n return { outcome: 'named', name: target.name };\n default:\n // javascript / goto-remote / launch / unsupported: reported, never\n // executed here. JavaScript activation belongs to the scripting\n // orchestrator once it lands — the chain already rides the\n // annotation's base `actions`.\n return { outcome: 'reported', target };\n }\n })();\n config.onActivate?.({ target, activation });\n return activation;\n };\n\n return {\n linksOn: (pon) => {\n const host = anno();\n if (host) return host.linkItemsOn(pon);\n return ctx.getState().pages[pon] ?? EMPTY;\n },\n ensurePage: (pon) => {\n const host = anno();\n if (host) {\n host.ensurePage(pon); // the folded model is the source; it lazy-loads\n return;\n }\n if (!(pon in ctx.getState().pages)) loadLinksPage(ctx, pon);\n },\n engaged: () => ctx.tryGet(InteractionToken)?.activeTool()?.enables.has('link-nav') ?? false,\n activate,\n };\n}\n","import type { DocumentEvent, EffectContext } from '@embedpdf/core';\nimport { AnnotationToken as AnnotationHostToken } from '@embedpdf/plugin-annotation/internal';\nimport { loadLinksPage } from './source';\nimport type { LinkAction, LinkState } from './types';\n\n/**\n * Keeps the ENGINE-BACKED page cache honest in viewer-only deployments:\n * any annotation mutation on a cached page (own or remote — the cache has\n * no other refresh path, unlike the annotation plugin's optimistic model)\n * refetches that page's links. With the annotation plugin present the\n * folded model is the source and this effect never fires a fetch.\n */\nexport function registerLinkEffects(ctx: EffectContext<LinkState, LinkAction>): void {\n const doc = ctx.doc;\n if (!doc) return;\n\n const refetch = (pon: number): void => {\n if (ctx.tryGet(AnnotationHostToken)) return; // annotation model owns the data\n if (pon in ctx.getState().pages) loadLinksPage(ctx, pon);\n };\n\n const unsubscribe = doc.events.subscribe((event: DocumentEvent) => {\n switch (event.type) {\n case 'annotation.created':\n refetch(event.created.pageObjectNumber);\n break;\n case 'annotation.updated':\n refetch(event.updated.pageObjectNumber);\n break;\n case 'annotation.moved':\n if (event.moved.length) refetch(event.moved[0].pageObjectNumber);\n break;\n case 'annotation.deleted':\n refetch(event.pageObjectNumber);\n break;\n default:\n break;\n }\n });\n ctx.cleanup(unsubscribe);\n}\n","import type { LinkAction, LinkState } from './types';\n\nexport const initialLinkState = (): LinkState => ({ pages: {} });\n\n/** Pure. Engine-backed page cache only — the annotation-backed mode reads the\n * annotation plugin's model and never touches this state. */\nexport function linkReducer(state: LinkState, a: LinkAction): LinkState {\n switch (a.type) {\n case 'SET_PAGE':\n return { ...state, pages: { ...state.pages, [a.pon]: a.items } };\n case 'DROP_PAGE': {\n if (!(a.pon in state.pages)) return state;\n const pages = { ...state.pages };\n delete pages[a.pon];\n return { ...state, pages };\n }\n }\n}\n","import { createCapabilityToken, type PageObjectNumber } from '@embedpdf/core';\nimport type { PdfDestination, PdfLinkTarget } from '@embedpdf/engine-core/runtime';\nimport type { LinkNavItem } from '@embedpdf/plugin-annotation';\n\nexport type { LinkNavItem };\n// The wire target vocabulary, re-exported so app code building link editors\n// needs only this package (the annotation-props precedent).\nexport type { PdfDestination, PdfLinkTarget };\n\n/**\n * What one activation did. `revealed` = the stage moved the camera;\n * `destination` = no stage plugin — the embedder gets the explicit\n * destination to handle; `uri` = opening is the FRAMEWORK layer's job (the\n * plugin is DOM-free); `named` = a viewer verb (NextPage…) reported until\n * stage verbs land; `reported` = read-only/executable-shaped targets\n * (javascript / goto-remote / launch / unsupported) — surfaced, NEVER\n * executed here (javascript belongs to the scripting orchestrator).\n */\nexport type LinkActivation =\n | { outcome: 'revealed' }\n | { outcome: 'destination'; destination: PdfDestination }\n | { outcome: 'uri'; uri: string }\n | { outcome: 'named'; name: string }\n | { outcome: 'reported'; target: PdfLinkTarget }\n | { outcome: 'none' };\n\nexport interface LinkActivateEvent {\n target: PdfLinkTarget;\n activation: LinkActivation;\n}\n\nexport interface LinkPluginConfig {\n /** Every activation (navigations AND reported targets) — analytics /\n * custom handling. Called after the built-in handling ran. */\n onActivate?: (event: LinkActivateEvent) => void;\n}\n\n/**\n * The navigation plane of link annotations. Data comes from ONE of two\n * sources, picked at init: the annotation plugin's folded model when that\n * plugin is present (zero extra engine reads — it already lists every\n * page), or the plugin's own engine reads in viewer-only deployments.\n */\nexport interface LinkCapability {\n /** The clickable link areas of a page (content space, y-down). */\n linksOn(pon: PageObjectNumber): LinkNavItem[];\n /** Lazy-load a page's links (no-op when the annotation plugin owns the data). */\n ensurePage(pon: PageObjectNumber): void;\n /** Whether the navigation plane currently owns links: the active tool\n * enables `link-nav` (pointer/pan/form-fill by default). While false —\n * the link tool or any authoring tool is active — the annotation plane\n * owns them and the LinkLayer stands down. */\n engaged(): boolean;\n /** THE one activation entry point (framework layers call it on click). */\n activate(target: PdfLinkTarget): LinkActivation;\n}\n\n/** Engine-backed page cache (viewer-only deployments). */\nexport interface LinkState {\n pages: Record<number, LinkNavItem[]>;\n}\n\nexport type LinkAction =\n | { type: 'SET_PAGE'; pon: number; items: LinkNavItem[] }\n | { type: 'DROP_PAGE'; pon: number };\n\nexport const LinkToken = createCapabilityToken<LinkCapability>('link');\n","import { definePlugin } from '@embedpdf/core';\nimport { InteractionToken } from '@embedpdf/plugin-interaction';\nimport { StageToken } from '@embedpdf/plugin-stage';\nimport { AnnotationToken } from '@embedpdf/plugin-annotation';\n// Behavior registration lives on the HOST capability (framework/plugin\n// surface) — same runtime token, wider type. The form plugin's precedent.\nimport { AnnotationToken as AnnotationHostToken } from '@embedpdf/plugin-annotation/internal';\n\nimport { createLinkCapability } from './capability';\nimport { registerLinkEffects } from './effects';\nimport { initialLinkState, linkReducer } from './reducer';\nimport { LinkToken } from './types';\nimport type { LinkAction, LinkCapability, LinkPluginConfig, LinkState } from './types';\n\n/**\n * The link plugin: the NAVIGATION plane. Document-scoped; requires only the\n * interaction hub. Navigation works with no annotation plugin at all —\n * links are read from the engine's link DTOs. When the annotation plugin IS\n * present, its folded model becomes the data source (no double fetch) and a\n * Behavior keeps links navigation-owned while a `link-nav` tool is active\n * (pointer/pan/form-fill by default) — the single-active-tool hub IS the\n * mode switch: grab the link tool and every link becomes an editable rect.\n */\nexport const linkPlugin = (config?: LinkPluginConfig) =>\n definePlugin<LinkState, LinkAction, LinkCapability>({\n id: 'link',\n token: LinkToken,\n scope: 'document',\n requires: [InteractionToken],\n optional: [StageToken, AnnotationToken],\n initialState: initialLinkState,\n reduce: linkReducer,\n capability: (ctx) => createLinkCapability(ctx, config),\n effects: registerLinkEffects,\n init: (ctx) => {\n const interaction = ctx.get(InteractionToken);\n const annotation = ctx.tryGet(AnnotationHostToken);\n if (annotation) {\n annotation.registerBehavior({\n id: 'link-nav',\n matches: (a) => a.subtype === 'link',\n engaged: () => interaction.activeTool()?.enables.has('link-nav') ?? false,\n });\n }\n },\n });\n"],"mappings":";;;;;;;;AAkBA,SAAgB,cAAc,IAAkB,KAAmB;CACjE,MAAM,MAAM,GAAG;CACf,MAAM,OAAO,GAAG,SAAS,CAAC,EAAE,MAAM,MAAM,MAAM,EAAE,qBAAqB,GAAG,CAAC,EAAE,MAAM;CACjF,IAAI,CAAC,OAAO,CAAC,MAAM;CACnB,IACG,KAAK,GAAG,CAAC,CACT,YAAY,KAAK,CAAC,CAClB,MACE,SAAS;EACR,MAAM,QAAuB,CAAC;EAC9B,KAAK,MAAM,OAAO,KAAK,aAAa;GAClC,IAAI,IAAI,YAAY,UAAU,IAAI,UAAU,MAAM;GAClD,IAAI,IAAI,MAAM,UAAU,IAAI,MAAM,QAAQ;GAC1C,MAAM,KAAK;IACT,IACE,IAAI,IAAI,SAAS,iBACb,OAAO,IAAI,IAAI,sBACf,OAAO,IAAI,GAAG,IAAI;IACxB,OAAA,GAAA,0BAAA,iBAAA,CAAuB,IAAI,MAAM,IAAI;IACrC,QAAQ,IAAI;GACd,CAAC;EACH;EACA,GAAG,SAAS;GAAE,MAAM;GAAY;GAAK;EAAM,CAAC;CAC9C,SACM,CAAC,CACT;AACJ;;;AC5BA,MAAM,QAAuB,CAAC;;;;;;;;AAS9B,SAAgB,qBACd,KACA,SAA2B,C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c;CACd,QAAQ;CACR,aAAa,QAAQ,qBAAqB,KAAK,MAAM;CACrD,SAAS;CACT,OAAO,QAAQ;EACb,MAAM,cAAc,IAAI,IAAIF,6BAAAA,gBAAgB;EAC5C,MAAM,aAAa,IAAI,OAAOG,qCAAAA,eAAmB;EACjD,IAAI,YACF,WAAW,iBAAiB;GAC1B,IAAI;GACJ,UAAU,MAAM,EAAE,YAAY;GAC9B,eAAe,YAAY,WAAW,CAAC,EAAE,QAAQ,IAAI,UAAU,KAAK;EACtE,CAAC;CAEL;AACF,CAAC"}
@@ -0,0 +1,86 @@
1
+ import { PageObjectNumber } from "@embedpdf/core";
2
+ import { PdfDestination, PdfLinkTarget } from "@embedpdf/engine-core/runtime";
3
+ import { LinkNavItem } from "@embedpdf/plugin-annotation";
4
+ //#region src/types.d.ts
5
+ /**
6
+ * What one activation did. `revealed` = the stage moved the camera;
7
+ * `destination` = no stage plugin — the embedder gets the explicit
8
+ * destination to handle; `uri` = opening is the FRAMEWORK layer's job (the
9
+ * plugin is DOM-free); `named` = a viewer verb (NextPage…) reported until
10
+ * stage verbs land; `reported` = read-only/executable-shaped targets
11
+ * (javascript / goto-remote / launch / unsupported) — surfaced, NEVER
12
+ * executed here (javascript belongs to the scripting orchestrator).
13
+ */
14
+ type LinkActivation = {
15
+ outcome: 'revealed';
16
+ } | {
17
+ outcome: 'destination';
18
+ destination: PdfDestination;
19
+ } | {
20
+ outcome: 'uri';
21
+ uri: string;
22
+ } | {
23
+ outcome: 'named';
24
+ name: string;
25
+ } | {
26
+ outcome: 'reported';
27
+ target: PdfLinkTarget;
28
+ } | {
29
+ outcome: 'none';
30
+ };
31
+ interface LinkActivateEvent {
32
+ target: PdfLinkTarget;
33
+ activation: LinkActivation;
34
+ }
35
+ interface LinkPluginConfig {
36
+ /** Every activation (navigations AND reported targets) — analytics /
37
+ * custom handling. Called after the built-in handling ran. */
38
+ onActivate?: (event: LinkActivateEvent) => void;
39
+ }
40
+ /**
41
+ * The navigation plane of link annotations. Data comes from ONE of two
42
+ * sources, picked at init: the annotation plugin's folded model when that
43
+ * plugin is present (zero extra engine reads — it already lists every
44
+ * page), or the plugin's own engine reads in viewer-only deployments.
45
+ */
46
+ interface LinkCapability {
47
+ /** The clickable link areas of a page (content space, y-down). */
48
+ linksOn(pon: PageObjectNumber): LinkNavItem[];
49
+ /** Lazy-load a page's links (no-op when the annotation plugin owns the data). */
50
+ ensurePage(pon: PageObjectNumber): void;
51
+ /** Whether the navigation plane currently owns links: the active tool
52
+ * enables `link-nav` (pointer/pan/form-fill by default). While false —
53
+ * the link tool or any authoring tool is active — the annotation plane
54
+ * owns them and the LinkLayer stands down. */
55
+ engaged(): boolean;
56
+ /** THE one activation entry point (framework layers call it on click). */
57
+ activate(target: PdfLinkTarget): LinkActivation;
58
+ }
59
+ /** Engine-backed page cache (viewer-only deployments). */
60
+ interface LinkState {
61
+ pages: Record<number, LinkNavItem[]>;
62
+ }
63
+ type LinkAction = {
64
+ type: 'SET_PAGE';
65
+ pon: number;
66
+ items: LinkNavItem[];
67
+ } | {
68
+ type: 'DROP_PAGE';
69
+ pon: number;
70
+ };
71
+ declare const LinkToken: import("@embedpdf/core").CapabilityToken<LinkCapability>;
72
+ //#endregion
73
+ //#region src/link.plugin.d.ts
74
+ /**
75
+ * The link plugin: the NAVIGATION plane. Document-scoped; requires only the
76
+ * interaction hub. Navigation works with no annotation plugin at all —
77
+ * links are read from the engine's link DTOs. When the annotation plugin IS
78
+ * present, its folded model becomes the data source (no double fetch) and a
79
+ * Behavior keeps links navigation-owned while a `link-nav` tool is active
80
+ * (pointer/pan/form-fill by default) — the single-active-tool hub IS the
81
+ * mode switch: grab the link tool and every link becomes an editable rect.
82
+ */
83
+ declare const linkPlugin: (config?: LinkPluginConfig) => import("@embedpdf/core").PluginDef<LinkState, LinkAction, LinkCapability>;
84
+ //#endregion
85
+ export { type LinkActivateEvent, type LinkActivation, type LinkCapability, type LinkNavItem, type LinkPluginConfig, type LinkState, LinkToken, type PdfDestination, type PdfLinkTarget, linkPlugin };
86
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,86 @@
1
+ import { PageObjectNumber } from "@embedpdf/core";
2
+ import { LinkNavItem } from "@embedpdf/plugin-annotation";
3
+ import { PdfDestination, PdfLinkTarget } from "@embedpdf/engine-core/runtime";
4
+ //#region src/types.d.ts
5
+ /**
6
+ * What one activation did. `revealed` = the stage moved the camera;
7
+ * `destination` = no stage plugin — the embedder gets the explicit
8
+ * destination to handle; `uri` = opening is the FRAMEWORK layer's job (the
9
+ * plugin is DOM-free); `named` = a viewer verb (NextPage…) reported until
10
+ * stage verbs land; `reported` = read-only/executable-shaped targets
11
+ * (javascript / goto-remote / launch / unsupported) — surfaced, NEVER
12
+ * executed here (javascript belongs to the scripting orchestrator).
13
+ */
14
+ type LinkActivation = {
15
+ outcome: 'revealed';
16
+ } | {
17
+ outcome: 'destination';
18
+ destination: PdfDestination;
19
+ } | {
20
+ outcome: 'uri';
21
+ uri: string;
22
+ } | {
23
+ outcome: 'named';
24
+ name: string;
25
+ } | {
26
+ outcome: 'reported';
27
+ target: PdfLinkTarget;
28
+ } | {
29
+ outcome: 'none';
30
+ };
31
+ interface LinkActivateEvent {
32
+ target: PdfLinkTarget;
33
+ activation: LinkActivation;
34
+ }
35
+ interface LinkPluginConfig {
36
+ /** Every activation (navigations AND reported targets) — analytics /
37
+ * custom handling. Called after the built-in handling ran. */
38
+ onActivate?: (event: LinkActivateEvent) => void;
39
+ }
40
+ /**
41
+ * The navigation plane of link annotations. Data comes from ONE of two
42
+ * sources, picked at init: the annotation plugin's folded model when that
43
+ * plugin is present (zero extra engine reads — it already lists every
44
+ * page), or the plugin's own engine reads in viewer-only deployments.
45
+ */
46
+ interface LinkCapability {
47
+ /** The clickable link areas of a page (content space, y-down). */
48
+ linksOn(pon: PageObjectNumber): LinkNavItem[];
49
+ /** Lazy-load a page's links (no-op when the annotation plugin owns the data). */
50
+ ensurePage(pon: PageObjectNumber): void;
51
+ /** Whether the navigation plane currently owns links: the active tool
52
+ * enables `link-nav` (pointer/pan/form-fill by default). While false —
53
+ * the link tool or any authoring tool is active — the annotation plane
54
+ * owns them and the LinkLayer stands down. */
55
+ engaged(): boolean;
56
+ /** THE one activation entry point (framework layers call it on click). */
57
+ activate(target: PdfLinkTarget): LinkActivation;
58
+ }
59
+ /** Engine-backed page cache (viewer-only deployments). */
60
+ interface LinkState {
61
+ pages: Record<number, LinkNavItem[]>;
62
+ }
63
+ type LinkAction = {
64
+ type: 'SET_PAGE';
65
+ pon: number;
66
+ items: LinkNavItem[];
67
+ } | {
68
+ type: 'DROP_PAGE';
69
+ pon: number;
70
+ };
71
+ declare const LinkToken: import("@embedpdf/core").CapabilityToken<LinkCapability>;
72
+ //#endregion
73
+ //#region src/link.plugin.d.ts
74
+ /**
75
+ * The link plugin: the NAVIGATION plane. Document-scoped; requires only the
76
+ * interaction hub. Navigation works with no annotation plugin at all —
77
+ * links are read from the engine's link DTOs. When the annotation plugin IS
78
+ * present, its folded model becomes the data source (no double fetch) and a
79
+ * Behavior keeps links navigation-owned while a `link-nav` tool is active
80
+ * (pointer/pan/form-fill by default) — the single-active-tool hub IS the
81
+ * mode switch: grab the link tool and every link becomes an editable rect.
82
+ */
83
+ declare const linkPlugin: (config?: LinkPluginConfig) => import("@embedpdf/core").PluginDef<LinkState, LinkAction, LinkCapability>;
84
+ //#endregion
85
+ export { type LinkActivateEvent, type LinkActivation, type LinkCapability, type LinkNavItem, type LinkPluginConfig, type LinkState, LinkToken, type PdfDestination, type PdfLinkTarget, linkPlugin };
86
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,194 @@
1
+ import { createCapabilityToken, definePlugin } from "@embedpdf/core";
2
+ import { InteractionToken } from "@embedpdf/plugin-interaction";
3
+ import { StageToken, destinationToReveal } from "@embedpdf/plugin-stage";
4
+ import { AnnotationToken } from "@embedpdf/plugin-annotation";
5
+ import { AnnotationToken as AnnotationToken$1 } from "@embedpdf/plugin-annotation/internal";
6
+ import { pdfToContentRect } from "@embedpdf/core-annotation";
7
+ //#region src/source.ts
8
+ function loadLinksPage(io, pon) {
9
+ const doc = io.doc;
10
+ const crop = io.document()?.pages.find((p) => p.pageObjectNumber === pon)?.boxes.crop;
11
+ if (!doc || !crop) return;
12
+ doc.page(pon).annotations.list().then((snap) => {
13
+ const items = [];
14
+ for (const dto of snap.annotations) {
15
+ if (dto.subtype !== "link" || dto.target == null) continue;
16
+ if (dto.flags.hidden || dto.flags.noView) continue;
17
+ items.push({
18
+ id: dto.ref.kind === "objectNumber" ? `obj:${dto.ref.annotObjectNumber}` : `idx:${pon}:${dto.index}`,
19
+ rect: pdfToContentRect(dto.rect, crop),
20
+ target: dto.target
21
+ });
22
+ }
23
+ io.dispatch({
24
+ type: "SET_PAGE",
25
+ pon,
26
+ items
27
+ });
28
+ }, () => {});
29
+ }
30
+ //#endregion
31
+ //#region src/capability.ts
32
+ const EMPTY = [];
33
+ /**
34
+ * The navigation plane's surface. Data source is decided PER CALL (lazily,
35
+ * so plugin registration order can't matter): the annotation plugin's
36
+ * folded model when present — its `linkItemsOn` lens is memoized by model
37
+ * identity and already excludes hidden links — else this plugin's own
38
+ * engine-backed page cache (see source.ts).
39
+ */
40
+ function createLinkCapability(ctx, config = {}) {
41
+ const anno = () => ctx.tryGet(AnnotationToken$1);
42
+ const activate = (target) => {
43
+ const activation = (() => {
44
+ switch (target.kind) {
45
+ case "goto": {
46
+ const stage = ctx.tryGet(StageToken);
47
+ const layout = ctx.document()?.pages.find((p) => p.pageObjectNumber === target.destination.pageObjectNumber);
48
+ if (!stage || !layout) return {
49
+ outcome: "destination",
50
+ destination: target.destination
51
+ };
52
+ const { pageIndex, options } = destinationToReveal(target.destination, layout);
53
+ stage.reveal(pageIndex, {
54
+ ...options,
55
+ behavior: "smooth"
56
+ });
57
+ return { outcome: "revealed" };
58
+ }
59
+ case "uri": return {
60
+ outcome: "uri",
61
+ uri: target.uri
62
+ };
63
+ case "named": return {
64
+ outcome: "named",
65
+ name: target.name
66
+ };
67
+ default: return {
68
+ outcome: "reported",
69
+ target
70
+ };
71
+ }
72
+ })();
73
+ config.onActivate?.({
74
+ target,
75
+ activation
76
+ });
77
+ return activation;
78
+ };
79
+ return {
80
+ linksOn: (pon) => {
81
+ const host = anno();
82
+ if (host) return host.linkItemsOn(pon);
83
+ return ctx.getState().pages[pon] ?? EMPTY;
84
+ },
85
+ ensurePage: (pon) => {
86
+ const host = anno();
87
+ if (host) {
88
+ host.ensurePage(pon);
89
+ return;
90
+ }
91
+ if (!(pon in ctx.getState().pages)) loadLinksPage(ctx, pon);
92
+ },
93
+ engaged: () => ctx.tryGet(InteractionToken)?.activeTool()?.enables.has("link-nav") ?? false,
94
+ activate
95
+ };
96
+ }
97
+ //#endregion
98
+ //#region src/effects.ts
99
+ /**
100
+ * Keeps the ENGINE-BACKED page cache honest in viewer-only deployments:
101
+ * any annotation mutation on a cached page (own or remote — the cache has
102
+ * no other refresh path, unlike the annotation plugin's optimistic model)
103
+ * refetches that page's links. With the annotation plugin present the
104
+ * folded model is the source and this effect never fires a fetch.
105
+ */
106
+ function registerLinkEffects(ctx) {
107
+ const doc = ctx.doc;
108
+ if (!doc) return;
109
+ const refetch = (pon) => {
110
+ if (ctx.tryGet(AnnotationToken$1)) return;
111
+ if (pon in ctx.getState().pages) loadLinksPage(ctx, pon);
112
+ };
113
+ const unsubscribe = doc.events.subscribe((event) => {
114
+ switch (event.type) {
115
+ case "annotation.created":
116
+ refetch(event.created.pageObjectNumber);
117
+ break;
118
+ case "annotation.updated":
119
+ refetch(event.updated.pageObjectNumber);
120
+ break;
121
+ case "annotation.moved":
122
+ if (event.moved.length) refetch(event.moved[0].pageObjectNumber);
123
+ break;
124
+ case "annotation.deleted":
125
+ refetch(event.pageObjectNumber);
126
+ break;
127
+ default: break;
128
+ }
129
+ });
130
+ ctx.cleanup(unsubscribe);
131
+ }
132
+ //#endregion
133
+ //#region src/reducer.ts
134
+ const initialLinkState = () => ({ pages: {} });
135
+ /** Pure. Engine-backed page cache only — the annotation-backed mode reads the
136
+ * annotation plugin's model and never touches this state. */
137
+ function linkReducer(state, a) {
138
+ switch (a.type) {
139
+ case "SET_PAGE": return {
140
+ ...state,
141
+ pages: {
142
+ ...state.pages,
143
+ [a.pon]: a.items
144
+ }
145
+ };
146
+ case "DROP_PAGE": {
147
+ if (!(a.pon in state.pages)) return state;
148
+ const pages = { ...state.pages };
149
+ delete pages[a.pon];
150
+ return {
151
+ ...state,
152
+ pages
153
+ };
154
+ }
155
+ }
156
+ }
157
+ //#endregion
158
+ //#region src/types.ts
159
+ const LinkToken = createCapabilityToken("link");
160
+ //#endregion
161
+ //#region src/link.plugin.ts
162
+ /**
163
+ * The link plugin: the NAVIGATION plane. Document-scoped; requires only the
164
+ * interaction hub. Navigation works with no annotation plugin at all —
165
+ * links are read from the engine's link DTOs. When the annotation plugin IS
166
+ * present, its folded model becomes the data source (no double fetch) and a
167
+ * Behavior keeps links navigation-owned while a `link-nav` tool is active
168
+ * (pointer/pan/form-fill by default) — the single-active-tool hub IS the
169
+ * mode switch: grab the link tool and every link becomes an editable rect.
170
+ */
171
+ const linkPlugin = (config) => definePlugin({
172
+ id: "link",
173
+ token: LinkToken,
174
+ scope: "document",
175
+ requires: [InteractionToken],
176
+ optional: [StageToken, AnnotationToken],
177
+ initialState: initialLinkState,
178
+ reduce: linkReducer,
179
+ capability: (ctx) => createLinkCapability(ctx, config),
180
+ effects: registerLinkEffects,
181
+ init: (ctx) => {
182
+ const interaction = ctx.get(InteractionToken);
183
+ const annotation = ctx.tryGet(AnnotationToken$1);
184
+ if (annotation) annotation.registerBehavior({
185
+ id: "link-nav",
186
+ matches: (a) => a.subtype === "link",
187
+ engaged: () => interaction.activeTool()?.enables.has("link-nav") ?? false
188
+ });
189
+ }
190
+ });
191
+ //#endregion
192
+ export { LinkToken, linkPlugin };
193
+
194
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["AnnotationHostToken","AnnotationHostToken","AnnotationHostToken"],"sources":["../src/source.ts","../src/capability.ts","../src/effects.ts","../src/reducer.ts","../src/types.ts","../src/link.plugin.ts"],"sourcesContent":["import type { DocumentHandle, PageLayout } from '@embedpdf/core';\nimport { pdfToContentRect } from '@embedpdf/core-annotation';\nimport type { LinkAction, LinkNavItem } from './types';\n\n/**\n * The ENGINE-BACKED link source, for viewer-only deployments (no annotation\n * plugin): read a page's annotation list and keep just the navigable links —\n * standalone AND attached children alike (both are raw link DTOs here).\n * Shared by the capability's lazy `ensurePage` and the effects module's\n * event-driven refetch; both PluginContext and EffectContext satisfy the\n * structural `io` slice.\n */\nexport interface LinkSourceIO {\n doc: DocumentHandle | null;\n document(): { pages: readonly PageLayout[] } | null;\n dispatch(action: LinkAction): void;\n}\n\nexport function loadLinksPage(io: LinkSourceIO, pon: number): void {\n const doc = io.doc;\n const crop = io.document()?.pages.find((p) => p.pageObjectNumber === pon)?.boxes.crop;\n if (!doc || !crop) return;\n doc\n .page(pon)\n .annotations.list()\n .then(\n (snap) => {\n const items: LinkNavItem[] = [];\n for (const dto of snap.annotations) {\n if (dto.subtype !== 'link' || dto.target == null) continue;\n if (dto.flags.hidden || dto.flags.noView) continue;\n items.push({\n id:\n dto.ref.kind === 'objectNumber'\n ? `obj:${dto.ref.annotObjectNumber}`\n : `idx:${pon}:${dto.index}`,\n rect: pdfToContentRect(dto.rect, crop),\n target: dto.target,\n });\n }\n io.dispatch({ type: 'SET_PAGE', pon, items });\n },\n () => {},\n );\n}\n","import type { PluginContext } from '@embedpdf/core';\nimport type { PdfLinkTarget } from '@embedpdf/engine-core/runtime';\nimport { InteractionToken } from '@embedpdf/plugin-interaction';\nimport { destinationToReveal, StageToken } from '@embedpdf/plugin-stage';\n// The host lens (linkItemsOn) — same runtime token as the public one.\nimport { AnnotationToken as AnnotationHostToken } from '@embedpdf/plugin-annotation/internal';\nimport { loadLinksPage } from './source';\nimport type {\n LinkAction,\n LinkActivation,\n LinkCapability,\n LinkNavItem,\n LinkPluginConfig,\n LinkState,\n} from './types';\n\nconst EMPTY: LinkNavItem[] = [];\n\n/**\n * The navigation plane's surface. Data source is decided PER CALL (lazily,\n * so plugin registration order can't matter): the annotation plugin's\n * folded model when present — its `linkItemsOn` lens is memoized by model\n * identity and already excludes hidden links — else this plugin's own\n * engine-backed page cache (see source.ts).\n */\nexport function createLinkCapability(\n ctx: PluginContext<LinkState, LinkAction>,\n config: LinkPluginConfig = {},\n): LinkCapability {\n const anno = () => ctx.tryGet(AnnotationHostToken);\n\n const activate = (target: PdfLinkTarget): LinkActivation => {\n const activation = ((): LinkActivation => {\n switch (target.kind) {\n case 'goto': {\n const stage = ctx.tryGet(StageToken);\n const layout = ctx\n .document()\n ?.pages.find((p) => p.pageObjectNumber === target.destination.pageObjectNumber);\n if (!stage || !layout) {\n // No camera to drive — hand the embedder the explicit destination.\n return { outcome: 'destination', destination: target.destination };\n }\n const { pageIndex, options } = destinationToReveal(target.destination, layout);\n stage.reveal(pageIndex, { ...options, behavior: 'smooth' });\n return { outcome: 'revealed' };\n }\n case 'uri':\n // Opening is the FRAMEWORK layer's job (a real <a href> after\n // sanitizing) — this plugin never touches the DOM.\n return { outcome: 'uri', uri: target.uri };\n case 'named':\n return { outcome: 'named', name: target.name };\n default:\n // javascript / goto-remote / launch / unsupported: reported, never\n // executed here. JavaScript activation belongs to the scripting\n // orchestrator once it lands — the chain already rides the\n // annotation's base `actions`.\n return { outcome: 'reported', target };\n }\n })();\n config.onActivate?.({ target, activation });\n return activation;\n };\n\n return {\n linksOn: (pon) => {\n const host = anno();\n if (host) return host.linkItemsOn(pon);\n return ctx.getState().pages[pon] ?? EMPTY;\n },\n ensurePage: (pon) => {\n const host = anno();\n if (host) {\n host.ensurePage(pon); // the folded model is the source; it lazy-loads\n return;\n }\n if (!(pon in ctx.getState().pages)) loadLinksPage(ctx, pon);\n },\n engaged: () => ctx.tryGet(InteractionToken)?.activeTool()?.enables.has('link-nav') ?? false,\n activate,\n };\n}\n","import type { DocumentEvent, EffectContext } from '@embedpdf/core';\nimport { AnnotationToken as AnnotationHostToken } from '@embedpdf/plugin-annotation/internal';\nimport { loadLinksPage } from './source';\nimport type { LinkAction, LinkState } from './types';\n\n/**\n * Keeps the ENGINE-BACKED page cache honest in viewer-only deployments:\n * any annotation mutation on a cached page (own or remote — the cache has\n * no other refresh path, unlike the annotation plugin's optimistic model)\n * refetches that page's links. With the annotation plugin present the\n * folded model is the source and this effect never fires a fetch.\n */\nexport function registerLinkEffects(ctx: EffectContext<LinkState, LinkAction>): void {\n const doc = ctx.doc;\n if (!doc) return;\n\n const refetch = (pon: number): void => {\n if (ctx.tryGet(AnnotationHostToken)) return; // annotation model owns the data\n if (pon in ctx.getState().pages) loadLinksPage(ctx, pon);\n };\n\n const unsubscribe = doc.events.subscribe((event: DocumentEvent) => {\n switch (event.type) {\n case 'annotation.created':\n refetch(event.created.pageObjectNumber);\n break;\n case 'annotation.updated':\n refetch(event.updated.pageObjectNumber);\n break;\n case 'annotation.moved':\n if (event.moved.length) refetch(event.moved[0].pageObjectNumber);\n break;\n case 'annotation.deleted':\n refetch(event.pageObjectNumber);\n break;\n default:\n break;\n }\n });\n ctx.cleanup(unsubscribe);\n}\n","import type { LinkAction, LinkState } from './types';\n\nexport const initialLinkState = (): LinkState => ({ pages: {} });\n\n/** Pure. Engine-backed page cache only — the annotation-backed mode reads the\n * annotation plugin's model and never touches this state. */\nexport function linkReducer(state: LinkState, a: LinkAction): LinkState {\n switch (a.type) {\n case 'SET_PAGE':\n return { ...state, pages: { ...state.pages, [a.pon]: a.items } };\n case 'DROP_PAGE': {\n if (!(a.pon in state.pages)) return state;\n const pages = { ...state.pages };\n delete pages[a.pon];\n return { ...state, pages };\n }\n }\n}\n","import { createCapabilityToken, type PageObjectNumber } from '@embedpdf/core';\nimport type { PdfDestination, PdfLinkTarget } from '@embedpdf/engine-core/runtime';\nimport type { LinkNavItem } from '@embedpdf/plugin-annotation';\n\nexport type { LinkNavItem };\n// The wire target vocabulary, re-exported so app code building link editors\n// needs only this package (the annotation-props precedent).\nexport type { PdfDestination, PdfLinkTarget };\n\n/**\n * What one activation did. `revealed` = the stage moved the camera;\n * `destination` = no stage plugin — the embedder gets the explicit\n * destination to handle; `uri` = opening is the FRAMEWORK layer's job (the\n * plugin is DOM-free); `named` = a viewer verb (NextPage…) reported until\n * stage verbs land; `reported` = read-only/executable-shaped targets\n * (javascript / goto-remote / launch / unsupported) — surfaced, NEVER\n * executed here (javascript belongs to the scripting orchestrator).\n */\nexport type LinkActivation =\n | { outcome: 'revealed' }\n | { outcome: 'destination'; destination: PdfDestination }\n | { outcome: 'uri'; uri: string }\n | { outcome: 'named'; name: string }\n | { outcome: 'reported'; target: PdfLinkTarget }\n | { outcome: 'none' };\n\nexport interface LinkActivateEvent {\n target: PdfLinkTarget;\n activation: LinkActivation;\n}\n\nexport interface LinkPluginConfig {\n /** Every activation (navigations AND reported targets) — analytics /\n * custom handling. Called after the built-in handling ran. */\n onActivate?: (event: LinkActivateEvent) => void;\n}\n\n/**\n * The navigation plane of link annotations. Data comes from ONE of two\n * sources, picked at init: the annotation plugin's folded model when that\n * plugin is present (zero extra engine reads — it already lists every\n * page), or the plugin's own engine reads in viewer-only deployments.\n */\nexport interface LinkCapability {\n /** The clickable link areas of a page (content space, y-down). */\n linksOn(pon: PageObjectNumber): LinkNavItem[];\n /** Lazy-load a page's links (no-op when the annotation plugin owns the data). */\n ensurePage(pon: PageObjectNumber): void;\n /** Whether the navigation plane currently owns links: the active tool\n * enables `link-nav` (pointer/pan/form-fill by default). While false —\n * the link tool or any authoring tool is active — the annotation plane\n * owns them and the LinkLayer stands down. */\n engaged(): boolean;\n /** THE one activation entry point (framework layers call it on click). */\n activate(target: PdfLinkTarget): LinkActivation;\n}\n\n/** Engine-backed page cache (viewer-only deployments). */\nexport interface LinkState {\n pages: Record<number, LinkNavItem[]>;\n}\n\nexport type LinkAction =\n | { type: 'SET_PAGE'; pon: number; items: LinkNavItem[] }\n | { type: 'DROP_PAGE'; pon: number };\n\nexport const LinkToken = createCapabilityToken<LinkCapability>('link');\n","import { definePlugin } from '@embedpdf/core';\nimport { InteractionToken } from '@embedpdf/plugin-interaction';\nimport { StageToken } from '@embedpdf/plugin-stage';\nimport { AnnotationToken } from '@embedpdf/plugin-annotation';\n// Behavior registration lives on the HOST capability (framework/plugin\n// surface) — same runtime token, wider type. The form plugin's precedent.\nimport { AnnotationToken as AnnotationHostToken } from '@embedpdf/plugin-annotation/internal';\n\nimport { createLinkCapability } from './capability';\nimport { registerLinkEffects } from './effects';\nimport { initialLinkState, linkReducer } from './reducer';\nimport { LinkToken } from './types';\nimport type { LinkAction, LinkCapability, LinkPluginConfig, LinkState } from './types';\n\n/**\n * The link plugin: the NAVIGATION plane. Document-scoped; requires only the\n * interaction hub. Navigation works with no annotation plugin at all —\n * links are read from the engine's link DTOs. When the annotation plugin IS\n * present, its folded model becomes the data source (no double fetch) and a\n * Behavior keeps links navigation-owned while a `link-nav` tool is active\n * (pointer/pan/form-fill by default) — the single-active-tool hub IS the\n * mode switch: grab the link tool and every link becomes an editable rect.\n */\nexport const linkPlugin = (config?: LinkPluginConfig) =>\n definePlugin<LinkState, LinkAction, LinkCapability>({\n id: 'link',\n token: LinkToken,\n scope: 'document',\n requires: [InteractionToken],\n optional: [StageToken, AnnotationToken],\n initialState: initialLinkState,\n reduce: linkReducer,\n capability: (ctx) => createLinkCapability(ctx, config),\n effects: registerLinkEffects,\n init: (ctx) => {\n const interaction = ctx.get(InteractionToken);\n const annotation = ctx.tryGet(AnnotationHostToken);\n if (annotation) {\n annotation.registerBehavior({\n id: 'link-nav',\n matches: (a) => a.subtype === 'link',\n engaged: () => interaction.activeTool()?.enables.has('link-nav') ?? false,\n });\n }\n },\n });\n"],"mappings":";;;;;;;AAkBA,SAAgB,cAAc,IAAkB,KAAmB;CACjE,MAAM,MAAM,GAAG;CACf,MAAM,OAAO,GAAG,SAAS,CAAC,EAAE,MAAM,MAAM,MAAM,EAAE,q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,GAA0B;CACtE,QAAQ,EAAE,MAAV;EACE,KAAK,YACH,OAAO;GAAE,GAAG;GAAO,OAAO;IAAE,GAAG,MAAM;KAAQ,EAAE,MAAM,EAAE;GAAM;EAAE;EACjE,KAAK,aAAa;GAChB,IAAI,EAAE,EAAE,OAAO,MAAM,QAAQ,OAAO;GACpC,MAAM,QAAQ,EAAE,GAAG,MAAM,MAAM;GAC/B,OAAO,MAAM,EAAE;GACf,OAAO;IAAE,GAAG;IAAO;GAAM;EAC3B;CACF;AACF;;;ACiDA,MAAa,YAAY,sBAAsC,MAAM;;;;;;;;;;;;AC3CrE,MAAa,cAAc,WACzB,aAAoD;CAClD,IAAI;CACJ,OAAO;CACP,OAAO;CACP,UAAU,CAAC,gBAAgB;CAC3B,UAAU,CAAC,YAAY,eAAe;CACtC,cAAc;CACd,QAAQ;CACR,aAAa,QAAQ,qBAAqB,KAAK,MAAM;CACrD,SAAS;CACT,OAAO,QAAQ;EACb,MAAM,cAAc,IAAI,IAAI,gBAAgB;EAC5C,MAAM,aAAa,IAAI,OAAOC,iBAAmB;EACjD,IAAI,YACF,WAAW,iBAAiB;GAC1B,IAAI;GACJ,UAAU,MAAM,EAAE,YAAY;GAC9B,eAAe,YAAY,WAAW,CAAC,EAAE,QAAQ,IAAI,UAAU,KAAK;EACtE,CAAC;CAEL;AACF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@embedpdf/plugin-link",
3
+ "version": "3.0.0-next.0",
4
+ "private": false,
5
+ "description": "The navigation plane for PDF link annotations: per-page clickable link areas + one activate() entry point (GoTo → stage reveal, URI → framework opener). Works standalone in viewer deployments; with the annotation plugin present it reads the folded model (no double fetch) and a Behavior hands links to the editing plane when the link tool is active.",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ },
15
+ "./package.json": "./package.json"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "dependencies": {
21
+ "@embedpdf/core-annotation": "3.0.0-next.0",
22
+ "@embedpdf/core-geometry": "3.0.0-next.0",
23
+ "@embedpdf/core": "3.0.0-next.0",
24
+ "@embedpdf/plugin-annotation": "3.0.0-next.0",
25
+ "@embedpdf/plugin-interaction": "3.0.0-next.0",
26
+ "@embedpdf/engine-core": "3.0.0-next.0",
27
+ "@embedpdf/plugin-stage": "3.0.0-next.0"
28
+ },
29
+ "devDependencies": {
30
+ "typescript": "^5.0.0",
31
+ "vitest": "^2.1.9",
32
+ "@embedpdf/tooling-build": "0.0.0"
33
+ },
34
+ "license": "Apache-2.0",
35
+ "sideEffects": false,
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/embedpdf/embed-pdf-viewer.git",
39
+ "directory": "packages/plugin/link"
40
+ },
41
+ "scripts": {
42
+ "build": "epdf-build",
43
+ "clean": "rimraf dist",
44
+ "typecheck": "tsc -p tsconfig.json --noEmit",
45
+ "test": "vitest run --passWithNoTests"
46
+ }
47
+ }