@embedpdf/plugin-interaction 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/contract/host.cjs +17 -0
- package/dist/contract/host.cjs.map +1 -0
- package/dist/contract/host.d.cts +3 -0
- package/dist/contract/host.d.ts +3 -0
- package/dist/contract/host.js +14 -0
- package/dist/contract/host.js.map +1 -0
- package/dist/contract-C9IFDdDd.d.cts +179 -0
- package/dist/contract-C9IFDdDd.d.ts +179 -0
- package/dist/contract-CmEMPz9L.js +19 -0
- package/dist/contract-CmEMPz9L.js.map +1 -0
- package/dist/contract-yO6QKpba.cjs +36 -0
- package/dist/contract-yO6QKpba.cjs.map +1 -0
- package/dist/contract.cjs +2 -2
- package/dist/contract.d.cts +2 -2
- package/dist/contract.d.ts +2 -2
- package/dist/contract.js +2 -2
- package/dist/host-contract-Crcu-9DW.d.ts +121 -0
- package/dist/host-contract-DCb-QVfd.d.cts +121 -0
- package/dist/index.cjs +347 -166
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -52
- package/dist/index.d.ts +23 -52
- package/dist/index.js +347 -163
- package/dist/index.js.map +1 -1
- package/package.json +7 -3
- package/dist/contract-B3tBU_U9.cjs +0 -36
- package/dist/contract-B3tBU_U9.cjs.map +0 -1
- package/dist/contract-CrM0i9pQ.js +0 -19
- package/dist/contract-CrM0i9pQ.js.map +0 -1
- package/dist/contract-F3gsFtSf.d.cts +0 -239
- package/dist/contract-F3gsFtSf.d.ts +0 -239
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { d as RegisterToolOptions, f as Tool, h as ToolId, l as Modifiers, o as InteractionCapability, t as Cursor, u as PointerKind } from "./contract-C9IFDdDd.js";
|
|
2
|
+
import { EventHook, PageRef, Unsubscribe } from "@embedpdf/core";
|
|
3
|
+
import { PageRotation, Point } from "@embedpdf/core-geometry";
|
|
4
|
+
//#region src/host-contract.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A tool as plugins see it: a public tool plus the behavior tags it turns on.
|
|
7
|
+
* A tool doesn't act by itself: handlers opt into tags (`enabledFor`), so a
|
|
8
|
+
* tool composes features without depending on them. A tool registered without
|
|
9
|
+
* tags has none.
|
|
10
|
+
*/
|
|
11
|
+
interface HostTool extends Tool {
|
|
12
|
+
/** The behavior tags the tool turns on, such as `'text-select'` or `'annotation-draw'`. */
|
|
13
|
+
readonly enables: ReadonlySet<string>;
|
|
14
|
+
/**
|
|
15
|
+
* The cursor over the space between pages. Most tools act only on pages, so
|
|
16
|
+
* the gaps show the plain arrow (`'default'`); a tool that works anywhere
|
|
17
|
+
* (pan) names its own (`'grab'`). Hover claims outrank both.
|
|
18
|
+
*/
|
|
19
|
+
readonly gapCursor?: Cursor;
|
|
20
|
+
}
|
|
21
|
+
/** A tool as a plugin registers it: its tags may be left out. */
|
|
22
|
+
type HostToolInput = Tool & Partial<Pick<HostTool, 'enables' | 'gapCursor'>>;
|
|
23
|
+
type Phase = 'down' | 'move' | 'up' | 'cancel';
|
|
24
|
+
/**
|
|
25
|
+
* One normalized pointer event. `viewport` is the source container's px. `page`
|
|
26
|
+
* is the resolved page hit (its `ref` and page-space point), present when the
|
|
27
|
+
* pointer is over a page, absent over gaps.
|
|
28
|
+
*/
|
|
29
|
+
interface PointerSample {
|
|
30
|
+
phase: Phase;
|
|
31
|
+
viewport: Point;
|
|
32
|
+
/** `scale` = view px per page unit; `rotation` = the page's total display
|
|
33
|
+
* rotation; `zoom` = the page's zoom relative to its 100% baseline. */
|
|
34
|
+
page?: {
|
|
35
|
+
ref: PageRef;
|
|
36
|
+
point: Point;
|
|
37
|
+
scale?: number;
|
|
38
|
+
rotation?: PageRotation;
|
|
39
|
+
zoom?: number;
|
|
40
|
+
};
|
|
41
|
+
modifiers: Modifiers;
|
|
42
|
+
/** Click count for a `down` (1 single, 2 double, 3 triple). Defaults to 1. */
|
|
43
|
+
clickCount?: number;
|
|
44
|
+
/** Absent when the source can't say: treat as 'mouse'. */
|
|
45
|
+
pointerType?: PointerKind;
|
|
46
|
+
/** Present when the sample was synthesized from a recognized gesture. */
|
|
47
|
+
gesture?: 'long-press';
|
|
48
|
+
/** The lens this sample came from (the stage plugin id); absent = route everywhere. */
|
|
49
|
+
source?: string;
|
|
50
|
+
/** Project this event onto a specific page's frame, unclamped; null when the source cannot. */
|
|
51
|
+
project?(page: PageRef): Point | null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A pointer handler contributed by a feature plugin: it declares which tools
|
|
55
|
+
* it is live under and a priority; the hub routes each gesture to the first
|
|
56
|
+
* handler that captures it.
|
|
57
|
+
*/
|
|
58
|
+
interface InteractionHandler {
|
|
59
|
+
id: string;
|
|
60
|
+
/** Higher wins the gesture. */
|
|
61
|
+
priority: number;
|
|
62
|
+
/** Usually `tool.enables.has('my-tag')`. */
|
|
63
|
+
enabledFor(tool: HostTool): boolean;
|
|
64
|
+
/** Return true to capture: subsequent move/up route here until pointer-up. */
|
|
65
|
+
onDown(sample: PointerSample): boolean;
|
|
66
|
+
onMove?(sample: PointerSample): void;
|
|
67
|
+
onUp?(sample: PointerSample): void;
|
|
68
|
+
/** The gesture was aborted, not completed. Falls back to `onUp` when absent. */
|
|
69
|
+
onCancel?(sample: PointerSample): void;
|
|
70
|
+
/** Pointer moved with no active gesture: cursor feedback only. */
|
|
71
|
+
onHover?(sample: PointerSample): void;
|
|
72
|
+
/** Touch consent, second rung: a pure read asked before a touch contact is classified. */
|
|
73
|
+
claimsTouch?(sample: PointerSample): boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The host lens: what pointer sources (the Stage surface, `PagePointerSource`)
|
|
77
|
+
* and feature plugins with gestures need. The same runtime token as the
|
|
78
|
+
* public contract, typed wider. Application code never needs it.
|
|
79
|
+
*/
|
|
80
|
+
interface InteractionHostCapability extends InteractionCapability {
|
|
81
|
+
getActiveTool(): HostTool;
|
|
82
|
+
listTools(): readonly HostTool[];
|
|
83
|
+
getTool(id: ToolId): HostTool | null;
|
|
84
|
+
/** Add a tool, with the behavior tags it turns on. The rules are those of the public `registerTool`. */
|
|
85
|
+
registerTool(tool: HostToolInput, options?: RegisterToolOptions): Unsubscribe;
|
|
86
|
+
/** Whether the active tool turns on a behavior tag such as `'text-select'`. */
|
|
87
|
+
activeToolEnables(behavior: string): boolean;
|
|
88
|
+
/** Pointer ingress: a source calls it for every normalized event. */
|
|
89
|
+
dispatchPointer(sample: PointerSample): void;
|
|
90
|
+
/** Touch-arbitration pre-flight: would any eligible handler claim this contact. Pure. */
|
|
91
|
+
wouldClaimTouch(sample: PointerSample): boolean;
|
|
92
|
+
/** Register a pointer handler; `source` scopes it to one lens. */
|
|
93
|
+
registerHandler(handler: InteractionHandler, options?: {
|
|
94
|
+
source?: string;
|
|
95
|
+
}): Unsubscribe;
|
|
96
|
+
/** Push or clear a cursor claim on the priority stack (hover feedback). */
|
|
97
|
+
claimCursor(token: string, cursor: Cursor | null, priority?: number): void;
|
|
98
|
+
/**
|
|
99
|
+
* Whether a hover claim holds the cursor: the pointer is over something a
|
|
100
|
+
* click acts on instead of the tool (an annotation, text). A handler's hover
|
|
101
|
+
* sees the claims of every handler above it, so a create handler asks this
|
|
102
|
+
* to know whether its click would reach it (its ghost shows only then).
|
|
103
|
+
*/
|
|
104
|
+
hasCursorClaim(): boolean;
|
|
105
|
+
/** The resolved cursor string. */
|
|
106
|
+
getCursor(): Cursor;
|
|
107
|
+
/** The resolved cursor changed. */
|
|
108
|
+
readonly onCursorChanged: EventHook<{
|
|
109
|
+
readonly cursor: Cursor;
|
|
110
|
+
}>;
|
|
111
|
+
}
|
|
112
|
+
declare const InteractionToken: import("@embedpdf/core").CapabilityToken<InteractionHostCapability>;
|
|
113
|
+
/**
|
|
114
|
+
* Resolve a sample against a gesture's home page: prefer the source's
|
|
115
|
+
* unclamped projection, fall back to the page hit only when it is the same
|
|
116
|
+
* page. Null: this sample can't speak for the home page.
|
|
117
|
+
*/
|
|
118
|
+
declare const samplePointOn: (sample: PointerSample, page: PageRef) => Point | null;
|
|
119
|
+
//#endregion
|
|
120
|
+
export { InteractionToken as a, samplePointOn as c, InteractionHostCapability as i, HostToolInput as n, Phase as o, InteractionHandler as r, PointerSample as s, HostTool as t };
|
|
121
|
+
//# sourceMappingURL=host-contract-Crcu-9DW.d.ts.map
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { d as RegisterToolOptions, f as Tool, h as ToolId, l as Modifiers, o as InteractionCapability, t as Cursor, u as PointerKind } from "./contract-C9IFDdDd.cjs";
|
|
2
|
+
import { EventHook, PageRef, Unsubscribe } from "@embedpdf/core";
|
|
3
|
+
import { PageRotation, Point } from "@embedpdf/core-geometry";
|
|
4
|
+
//#region src/host-contract.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A tool as plugins see it: a public tool plus the behavior tags it turns on.
|
|
7
|
+
* A tool doesn't act by itself: handlers opt into tags (`enabledFor`), so a
|
|
8
|
+
* tool composes features without depending on them. A tool registered without
|
|
9
|
+
* tags has none.
|
|
10
|
+
*/
|
|
11
|
+
interface HostTool extends Tool {
|
|
12
|
+
/** The behavior tags the tool turns on, such as `'text-select'` or `'annotation-draw'`. */
|
|
13
|
+
readonly enables: ReadonlySet<string>;
|
|
14
|
+
/**
|
|
15
|
+
* The cursor over the space between pages. Most tools act only on pages, so
|
|
16
|
+
* the gaps show the plain arrow (`'default'`); a tool that works anywhere
|
|
17
|
+
* (pan) names its own (`'grab'`). Hover claims outrank both.
|
|
18
|
+
*/
|
|
19
|
+
readonly gapCursor?: Cursor;
|
|
20
|
+
}
|
|
21
|
+
/** A tool as a plugin registers it: its tags may be left out. */
|
|
22
|
+
type HostToolInput = Tool & Partial<Pick<HostTool, 'enables' | 'gapCursor'>>;
|
|
23
|
+
type Phase = 'down' | 'move' | 'up' | 'cancel';
|
|
24
|
+
/**
|
|
25
|
+
* One normalized pointer event. `viewport` is the source container's px. `page`
|
|
26
|
+
* is the resolved page hit (its `ref` and page-space point), present when the
|
|
27
|
+
* pointer is over a page, absent over gaps.
|
|
28
|
+
*/
|
|
29
|
+
interface PointerSample {
|
|
30
|
+
phase: Phase;
|
|
31
|
+
viewport: Point;
|
|
32
|
+
/** `scale` = view px per page unit; `rotation` = the page's total display
|
|
33
|
+
* rotation; `zoom` = the page's zoom relative to its 100% baseline. */
|
|
34
|
+
page?: {
|
|
35
|
+
ref: PageRef;
|
|
36
|
+
point: Point;
|
|
37
|
+
scale?: number;
|
|
38
|
+
rotation?: PageRotation;
|
|
39
|
+
zoom?: number;
|
|
40
|
+
};
|
|
41
|
+
modifiers: Modifiers;
|
|
42
|
+
/** Click count for a `down` (1 single, 2 double, 3 triple). Defaults to 1. */
|
|
43
|
+
clickCount?: number;
|
|
44
|
+
/** Absent when the source can't say: treat as 'mouse'. */
|
|
45
|
+
pointerType?: PointerKind;
|
|
46
|
+
/** Present when the sample was synthesized from a recognized gesture. */
|
|
47
|
+
gesture?: 'long-press';
|
|
48
|
+
/** The lens this sample came from (the stage plugin id); absent = route everywhere. */
|
|
49
|
+
source?: string;
|
|
50
|
+
/** Project this event onto a specific page's frame, unclamped; null when the source cannot. */
|
|
51
|
+
project?(page: PageRef): Point | null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A pointer handler contributed by a feature plugin: it declares which tools
|
|
55
|
+
* it is live under and a priority; the hub routes each gesture to the first
|
|
56
|
+
* handler that captures it.
|
|
57
|
+
*/
|
|
58
|
+
interface InteractionHandler {
|
|
59
|
+
id: string;
|
|
60
|
+
/** Higher wins the gesture. */
|
|
61
|
+
priority: number;
|
|
62
|
+
/** Usually `tool.enables.has('my-tag')`. */
|
|
63
|
+
enabledFor(tool: HostTool): boolean;
|
|
64
|
+
/** Return true to capture: subsequent move/up route here until pointer-up. */
|
|
65
|
+
onDown(sample: PointerSample): boolean;
|
|
66
|
+
onMove?(sample: PointerSample): void;
|
|
67
|
+
onUp?(sample: PointerSample): void;
|
|
68
|
+
/** The gesture was aborted, not completed. Falls back to `onUp` when absent. */
|
|
69
|
+
onCancel?(sample: PointerSample): void;
|
|
70
|
+
/** Pointer moved with no active gesture: cursor feedback only. */
|
|
71
|
+
onHover?(sample: PointerSample): void;
|
|
72
|
+
/** Touch consent, second rung: a pure read asked before a touch contact is classified. */
|
|
73
|
+
claimsTouch?(sample: PointerSample): boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The host lens: what pointer sources (the Stage surface, `PagePointerSource`)
|
|
77
|
+
* and feature plugins with gestures need. The same runtime token as the
|
|
78
|
+
* public contract, typed wider. Application code never needs it.
|
|
79
|
+
*/
|
|
80
|
+
interface InteractionHostCapability extends InteractionCapability {
|
|
81
|
+
getActiveTool(): HostTool;
|
|
82
|
+
listTools(): readonly HostTool[];
|
|
83
|
+
getTool(id: ToolId): HostTool | null;
|
|
84
|
+
/** Add a tool, with the behavior tags it turns on. The rules are those of the public `registerTool`. */
|
|
85
|
+
registerTool(tool: HostToolInput, options?: RegisterToolOptions): Unsubscribe;
|
|
86
|
+
/** Whether the active tool turns on a behavior tag such as `'text-select'`. */
|
|
87
|
+
activeToolEnables(behavior: string): boolean;
|
|
88
|
+
/** Pointer ingress: a source calls it for every normalized event. */
|
|
89
|
+
dispatchPointer(sample: PointerSample): void;
|
|
90
|
+
/** Touch-arbitration pre-flight: would any eligible handler claim this contact. Pure. */
|
|
91
|
+
wouldClaimTouch(sample: PointerSample): boolean;
|
|
92
|
+
/** Register a pointer handler; `source` scopes it to one lens. */
|
|
93
|
+
registerHandler(handler: InteractionHandler, options?: {
|
|
94
|
+
source?: string;
|
|
95
|
+
}): Unsubscribe;
|
|
96
|
+
/** Push or clear a cursor claim on the priority stack (hover feedback). */
|
|
97
|
+
claimCursor(token: string, cursor: Cursor | null, priority?: number): void;
|
|
98
|
+
/**
|
|
99
|
+
* Whether a hover claim holds the cursor: the pointer is over something a
|
|
100
|
+
* click acts on instead of the tool (an annotation, text). A handler's hover
|
|
101
|
+
* sees the claims of every handler above it, so a create handler asks this
|
|
102
|
+
* to know whether its click would reach it (its ghost shows only then).
|
|
103
|
+
*/
|
|
104
|
+
hasCursorClaim(): boolean;
|
|
105
|
+
/** The resolved cursor string. */
|
|
106
|
+
getCursor(): Cursor;
|
|
107
|
+
/** The resolved cursor changed. */
|
|
108
|
+
readonly onCursorChanged: EventHook<{
|
|
109
|
+
readonly cursor: Cursor;
|
|
110
|
+
}>;
|
|
111
|
+
}
|
|
112
|
+
declare const InteractionToken: import("@embedpdf/core").CapabilityToken<InteractionHostCapability>;
|
|
113
|
+
/**
|
|
114
|
+
* Resolve a sample against a gesture's home page: prefer the source's
|
|
115
|
+
* unclamped projection, fall back to the page hit only when it is the same
|
|
116
|
+
* page. Null: this sample can't speak for the home page.
|
|
117
|
+
*/
|
|
118
|
+
declare const samplePointOn: (sample: PointerSample, page: PageRef) => Point | null;
|
|
119
|
+
//#endregion
|
|
120
|
+
export { InteractionToken as a, samplePointOn as c, InteractionHostCapability as i, HostToolInput as n, Phase as o, InteractionHandler as r, PointerSample as s, HostTool as t };
|
|
121
|
+
//# sourceMappingURL=host-contract-DCb-QVfd.d.cts.map
|