@embedpdf/plugin-viewport 1.0.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 +21 -0
- package/dist/index.cjs +246 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +105 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.js +216 -0
- package/dist/index.js.map +1 -0
- package/dist/preact/index.cjs +124 -0
- package/dist/preact/index.cjs.map +1 -0
- package/dist/preact/index.d.cts +23 -0
- package/dist/preact/index.d.ts +23 -0
- package/dist/preact/index.js +95 -0
- package/dist/preact/index.js.map +1 -0
- package/dist/react/index.cjs +126 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +25 -0
- package/dist/react/index.d.ts +25 -0
- package/dist/react/index.js +96 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 CloudPDF
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
VIEWPORT_PLUGIN_ID: () => VIEWPORT_PLUGIN_ID,
|
|
24
|
+
ViewportPlugin: () => ViewportPlugin,
|
|
25
|
+
ViewportPluginPackage: () => ViewportPluginPackage,
|
|
26
|
+
manifest: () => manifest
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
|
|
30
|
+
// src/lib/manifest.ts
|
|
31
|
+
var VIEWPORT_PLUGIN_ID = "viewport";
|
|
32
|
+
var manifest = {
|
|
33
|
+
id: VIEWPORT_PLUGIN_ID,
|
|
34
|
+
name: "Viewport Plugin",
|
|
35
|
+
version: "1.0.0",
|
|
36
|
+
provides: ["viewport"],
|
|
37
|
+
requires: [],
|
|
38
|
+
optional: [],
|
|
39
|
+
defaultConfig: {
|
|
40
|
+
enabled: true,
|
|
41
|
+
viewportGap: 10,
|
|
42
|
+
scrollEndDelay: 300
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// src/lib/actions.ts
|
|
47
|
+
var SET_VIEWPORT_METRICS = "SET_VIEWPORT_METRICS";
|
|
48
|
+
var SET_VIEWPORT_SCROLL_METRICS = "SET_VIEWPORT_SCROLL_METRICS";
|
|
49
|
+
var SET_VIEWPORT_GAP = "SET_VIEWPORT_GAP";
|
|
50
|
+
var SET_SCROLL_ACTIVITY = "SET_SCROLL_ACTIVITY";
|
|
51
|
+
function setViewportGap(viewportGap) {
|
|
52
|
+
return {
|
|
53
|
+
type: SET_VIEWPORT_GAP,
|
|
54
|
+
payload: viewportGap
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function setViewportMetrics(viewportMetrics) {
|
|
58
|
+
return {
|
|
59
|
+
type: SET_VIEWPORT_METRICS,
|
|
60
|
+
payload: viewportMetrics
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function setViewportScrollMetrics(scrollMetrics) {
|
|
64
|
+
return {
|
|
65
|
+
type: SET_VIEWPORT_SCROLL_METRICS,
|
|
66
|
+
payload: scrollMetrics
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function setScrollActivity(isScrolling) {
|
|
70
|
+
return { type: SET_SCROLL_ACTIVITY, payload: isScrolling };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/lib/reducer.ts
|
|
74
|
+
var initialState = {
|
|
75
|
+
viewportGap: 0,
|
|
76
|
+
viewportMetrics: {
|
|
77
|
+
width: 0,
|
|
78
|
+
height: 0,
|
|
79
|
+
scrollTop: 0,
|
|
80
|
+
scrollLeft: 0,
|
|
81
|
+
clientWidth: 0,
|
|
82
|
+
clientHeight: 0,
|
|
83
|
+
scrollWidth: 0,
|
|
84
|
+
scrollHeight: 0,
|
|
85
|
+
relativePosition: {
|
|
86
|
+
x: 0,
|
|
87
|
+
y: 0
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
isScrolling: false
|
|
91
|
+
};
|
|
92
|
+
var viewportReducer = (state = initialState, action) => {
|
|
93
|
+
switch (action.type) {
|
|
94
|
+
case SET_VIEWPORT_GAP:
|
|
95
|
+
return { ...state, viewportGap: action.payload };
|
|
96
|
+
case SET_VIEWPORT_METRICS:
|
|
97
|
+
return {
|
|
98
|
+
...state,
|
|
99
|
+
viewportMetrics: {
|
|
100
|
+
width: action.payload.width,
|
|
101
|
+
height: action.payload.height,
|
|
102
|
+
scrollTop: action.payload.scrollTop,
|
|
103
|
+
scrollLeft: action.payload.scrollLeft,
|
|
104
|
+
clientWidth: action.payload.clientWidth,
|
|
105
|
+
clientHeight: action.payload.clientHeight,
|
|
106
|
+
scrollWidth: action.payload.scrollWidth,
|
|
107
|
+
scrollHeight: action.payload.scrollHeight,
|
|
108
|
+
relativePosition: {
|
|
109
|
+
x: action.payload.scrollWidth <= action.payload.clientWidth ? 0 : action.payload.scrollLeft / (action.payload.scrollWidth - action.payload.clientWidth),
|
|
110
|
+
y: action.payload.scrollHeight <= action.payload.clientHeight ? 0 : action.payload.scrollTop / (action.payload.scrollHeight - action.payload.clientHeight)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
case SET_VIEWPORT_SCROLL_METRICS:
|
|
115
|
+
return {
|
|
116
|
+
...state,
|
|
117
|
+
viewportMetrics: {
|
|
118
|
+
...state.viewportMetrics,
|
|
119
|
+
scrollTop: action.payload.scrollTop,
|
|
120
|
+
scrollLeft: action.payload.scrollLeft
|
|
121
|
+
},
|
|
122
|
+
isScrolling: true
|
|
123
|
+
};
|
|
124
|
+
case SET_SCROLL_ACTIVITY:
|
|
125
|
+
return { ...state, isScrolling: action.payload };
|
|
126
|
+
default:
|
|
127
|
+
return state;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// src/lib/viewport-plugin.ts
|
|
132
|
+
var import_core = require("@embedpdf/core");
|
|
133
|
+
var ViewportPlugin = class extends import_core.BasePlugin {
|
|
134
|
+
constructor(id, registry, config) {
|
|
135
|
+
super(id, registry);
|
|
136
|
+
this.id = id;
|
|
137
|
+
this.viewportMetrics$ = (0, import_core.createBehaviorEmitter)();
|
|
138
|
+
this.scrollMetrics$ = (0, import_core.createBehaviorEmitter)();
|
|
139
|
+
this.scrollReq$ = (0, import_core.createEmitter)();
|
|
140
|
+
this.scrollActivity$ = (0, import_core.createBehaviorEmitter)();
|
|
141
|
+
/* ------------------------------------------------------------------ */
|
|
142
|
+
/* “live rect” infrastructure */
|
|
143
|
+
/* ------------------------------------------------------------------ */
|
|
144
|
+
this.rectProvider = null;
|
|
145
|
+
if (config.viewportGap) {
|
|
146
|
+
this.dispatch(setViewportGap(config.viewportGap));
|
|
147
|
+
}
|
|
148
|
+
this.scrollEndDelay = config.scrollEndDelay || 300;
|
|
149
|
+
}
|
|
150
|
+
buildCapability() {
|
|
151
|
+
return {
|
|
152
|
+
getViewportGap: () => this.state.viewportGap,
|
|
153
|
+
getMetrics: () => this.state.viewportMetrics,
|
|
154
|
+
onScrollChange: this.scrollMetrics$.on,
|
|
155
|
+
onViewportChange: this.viewportMetrics$.on,
|
|
156
|
+
registerBoundingRectProvider: (fn) => {
|
|
157
|
+
this.rectProvider = fn;
|
|
158
|
+
},
|
|
159
|
+
getBoundingRect: () => this.rectProvider?.() ?? {
|
|
160
|
+
origin: { x: 0, y: 0 },
|
|
161
|
+
size: { width: 0, height: 0 }
|
|
162
|
+
},
|
|
163
|
+
setViewportMetrics: (viewportMetrics) => {
|
|
164
|
+
this.dispatch(setViewportMetrics(viewportMetrics));
|
|
165
|
+
},
|
|
166
|
+
setViewportScrollMetrics: this.setViewportScrollMetrics.bind(this),
|
|
167
|
+
scrollTo: (pos) => this.scrollTo(pos),
|
|
168
|
+
onScrollRequest: this.scrollReq$.on,
|
|
169
|
+
isScrolling: () => this.state.isScrolling,
|
|
170
|
+
onScrollActivity: this.scrollActivity$.on
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
bumpScrollActivity() {
|
|
174
|
+
if (this.scrollEndTimer) clearTimeout(this.scrollEndTimer);
|
|
175
|
+
this.scrollEndTimer = window.setTimeout(() => {
|
|
176
|
+
this.dispatch(setScrollActivity(false));
|
|
177
|
+
this.scrollEndTimer = void 0;
|
|
178
|
+
}, this.scrollEndDelay);
|
|
179
|
+
}
|
|
180
|
+
setViewportScrollMetrics(scrollMetrics) {
|
|
181
|
+
if (scrollMetrics.scrollTop !== this.state.viewportMetrics.scrollTop || scrollMetrics.scrollLeft !== this.state.viewportMetrics.scrollLeft) {
|
|
182
|
+
this.dispatch(setViewportScrollMetrics(scrollMetrics));
|
|
183
|
+
this.bumpScrollActivity();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
scrollTo(pos) {
|
|
187
|
+
const { x, y, center, behavior = "auto" } = pos;
|
|
188
|
+
if (center) {
|
|
189
|
+
const metrics = this.state.viewportMetrics;
|
|
190
|
+
const centeredX = x - metrics.clientWidth / 2;
|
|
191
|
+
const centeredY = y - metrics.clientHeight / 2;
|
|
192
|
+
this.scrollReq$.emit({
|
|
193
|
+
x: centeredX,
|
|
194
|
+
y: centeredY,
|
|
195
|
+
behavior
|
|
196
|
+
});
|
|
197
|
+
} else {
|
|
198
|
+
this.scrollReq$.emit({
|
|
199
|
+
x,
|
|
200
|
+
y,
|
|
201
|
+
behavior
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// Subscribe to store changes to notify onViewportChange
|
|
206
|
+
onStoreUpdated(prevState, newState) {
|
|
207
|
+
if (prevState !== newState) {
|
|
208
|
+
this.viewportMetrics$.emit(newState.viewportMetrics);
|
|
209
|
+
this.scrollMetrics$.emit({
|
|
210
|
+
scrollTop: newState.viewportMetrics.scrollTop,
|
|
211
|
+
scrollLeft: newState.viewportMetrics.scrollLeft
|
|
212
|
+
});
|
|
213
|
+
if (prevState.isScrolling !== newState.isScrolling) {
|
|
214
|
+
this.scrollActivity$.emit(newState.isScrolling);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
async initialize(_config) {
|
|
219
|
+
}
|
|
220
|
+
async destroy() {
|
|
221
|
+
super.destroy();
|
|
222
|
+
this.viewportMetrics$.clear();
|
|
223
|
+
this.scrollMetrics$.clear();
|
|
224
|
+
this.scrollReq$.clear();
|
|
225
|
+
this.scrollActivity$.clear();
|
|
226
|
+
this.rectProvider = null;
|
|
227
|
+
if (this.scrollEndTimer) clearTimeout(this.scrollEndTimer);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
ViewportPlugin.id = "viewport";
|
|
231
|
+
|
|
232
|
+
// src/lib/index.ts
|
|
233
|
+
var ViewportPluginPackage = {
|
|
234
|
+
manifest,
|
|
235
|
+
create: (registry, _engine, config) => new ViewportPlugin(VIEWPORT_PLUGIN_ID, registry, config),
|
|
236
|
+
reducer: viewportReducer,
|
|
237
|
+
initialState
|
|
238
|
+
};
|
|
239
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
240
|
+
0 && (module.exports = {
|
|
241
|
+
VIEWPORT_PLUGIN_ID,
|
|
242
|
+
ViewportPlugin,
|
|
243
|
+
ViewportPluginPackage,
|
|
244
|
+
manifest
|
|
245
|
+
});
|
|
246
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/lib/manifest.ts","../src/lib/actions.ts","../src/lib/reducer.ts","../src/lib/viewport-plugin.ts","../src/lib/index.ts"],"sourcesContent":["export * from './lib';\n","import { PluginManifest } from '@embedpdf/core';\n\nimport { ViewportPluginConfig } from './types';\n\nexport const VIEWPORT_PLUGIN_ID = 'viewport';\n\nexport const manifest: PluginManifest<ViewportPluginConfig> = {\n id: VIEWPORT_PLUGIN_ID,\n name: 'Viewport Plugin',\n version: '1.0.0',\n provides: ['viewport'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n viewportGap: 10,\n scrollEndDelay: 300,\n },\n};\n","import { Action } from '@embedpdf/core';\n\nimport { ViewportInputMetrics, ViewportScrollMetrics } from './types';\n\nexport const SET_VIEWPORT_METRICS = 'SET_VIEWPORT_METRICS';\nexport const SET_VIEWPORT_SCROLL_METRICS = 'SET_VIEWPORT_SCROLL_METRICS';\nexport const SET_VIEWPORT_GAP = 'SET_VIEWPORT_GAP';\nexport const SET_SCROLL_ACTIVITY = 'SET_SCROLL_ACTIVITY';\n\nexport interface SetViewportMetricsAction extends Action {\n type: typeof SET_VIEWPORT_METRICS;\n payload: ViewportInputMetrics;\n}\n\nexport interface SetViewportScrollMetricsAction extends Action {\n type: typeof SET_VIEWPORT_SCROLL_METRICS;\n payload: ViewportScrollMetrics;\n}\n\nexport interface SetViewportGapAction extends Action {\n type: typeof SET_VIEWPORT_GAP;\n payload: number;\n}\n\nexport interface SetScrollActivityAction extends Action {\n type: typeof SET_SCROLL_ACTIVITY;\n payload: boolean;\n}\n\nexport type ViewportAction =\n | SetViewportMetricsAction\n | SetViewportScrollMetricsAction\n | SetViewportGapAction\n | SetScrollActivityAction;\n\nexport function setViewportGap(viewportGap: number): SetViewportGapAction {\n return {\n type: SET_VIEWPORT_GAP,\n payload: viewportGap,\n };\n}\n\nexport function setViewportMetrics(\n viewportMetrics: ViewportInputMetrics,\n): SetViewportMetricsAction {\n return {\n type: SET_VIEWPORT_METRICS,\n payload: viewportMetrics,\n };\n}\n\nexport function setViewportScrollMetrics(\n scrollMetrics: ViewportScrollMetrics,\n): SetViewportScrollMetricsAction {\n return {\n type: SET_VIEWPORT_SCROLL_METRICS,\n payload: scrollMetrics,\n };\n}\n\nexport function setScrollActivity(isScrolling: boolean): SetScrollActivityAction {\n return { type: SET_SCROLL_ACTIVITY, payload: isScrolling };\n}\n","import { Reducer } from '@embedpdf/core';\n\nimport {\n SET_VIEWPORT_METRICS,\n SET_VIEWPORT_SCROLL_METRICS,\n SET_VIEWPORT_GAP,\n ViewportAction,\n SET_SCROLL_ACTIVITY,\n} from './actions';\nimport { ViewportState } from './types';\n\nexport const initialState: ViewportState = {\n viewportGap: 0,\n viewportMetrics: {\n width: 0,\n height: 0,\n scrollTop: 0,\n scrollLeft: 0,\n clientWidth: 0,\n clientHeight: 0,\n scrollWidth: 0,\n scrollHeight: 0,\n relativePosition: {\n x: 0,\n y: 0,\n },\n },\n isScrolling: false,\n};\n\nexport const viewportReducer: Reducer<ViewportState, ViewportAction> = (\n state = initialState,\n action,\n) => {\n switch (action.type) {\n case SET_VIEWPORT_GAP:\n return { ...state, viewportGap: action.payload };\n case SET_VIEWPORT_METRICS:\n return {\n ...state,\n viewportMetrics: {\n width: action.payload.width,\n height: action.payload.height,\n scrollTop: action.payload.scrollTop,\n scrollLeft: action.payload.scrollLeft,\n clientWidth: action.payload.clientWidth,\n clientHeight: action.payload.clientHeight,\n scrollWidth: action.payload.scrollWidth,\n scrollHeight: action.payload.scrollHeight,\n relativePosition: {\n x:\n action.payload.scrollWidth <= action.payload.clientWidth\n ? 0\n : action.payload.scrollLeft /\n (action.payload.scrollWidth - action.payload.clientWidth),\n y:\n action.payload.scrollHeight <= action.payload.clientHeight\n ? 0\n : action.payload.scrollTop /\n (action.payload.scrollHeight - action.payload.clientHeight),\n },\n },\n };\n case SET_VIEWPORT_SCROLL_METRICS:\n return {\n ...state,\n viewportMetrics: {\n ...state.viewportMetrics,\n scrollTop: action.payload.scrollTop,\n scrollLeft: action.payload.scrollLeft,\n },\n isScrolling: true,\n };\n case SET_SCROLL_ACTIVITY:\n return { ...state, isScrolling: action.payload };\n default:\n return state;\n }\n};\n","import { BasePlugin, PluginRegistry, createEmitter, createBehaviorEmitter } from '@embedpdf/core';\n\nimport {\n ViewportAction,\n setViewportMetrics,\n setViewportScrollMetrics,\n setViewportGap,\n setScrollActivity,\n} from './actions';\nimport {\n ViewportPluginConfig,\n ViewportState,\n ViewportCapability,\n ViewportMetrics,\n ViewportScrollMetrics,\n ViewportInputMetrics,\n ScrollToPayload,\n} from './types';\nimport { Rect } from '@embedpdf/models';\n\nexport class ViewportPlugin extends BasePlugin<\n ViewportPluginConfig,\n ViewportCapability,\n ViewportState,\n ViewportAction\n> {\n static readonly id = 'viewport' as const;\n\n private readonly viewportMetrics$ = createBehaviorEmitter<ViewportMetrics>();\n private readonly scrollMetrics$ = createBehaviorEmitter<ViewportScrollMetrics>();\n private readonly scrollReq$ = createEmitter<{\n x: number;\n y: number;\n behavior?: ScrollBehavior;\n }>();\n private readonly scrollActivity$ = createBehaviorEmitter<boolean>();\n\n /* ------------------------------------------------------------------ */\n /* “live rect” infrastructure */\n /* ------------------------------------------------------------------ */\n private rectProvider: (() => Rect) | null = null;\n\n private scrollEndTimer?: number;\n private readonly scrollEndDelay: number;\n\n constructor(\n public readonly id: string,\n registry: PluginRegistry,\n config: ViewportPluginConfig,\n ) {\n super(id, registry);\n\n if (config.viewportGap) {\n this.dispatch(setViewportGap(config.viewportGap));\n }\n\n this.scrollEndDelay = config.scrollEndDelay || 300;\n }\n\n protected buildCapability(): ViewportCapability {\n return {\n getViewportGap: () => this.state.viewportGap,\n getMetrics: () => this.state.viewportMetrics,\n onScrollChange: this.scrollMetrics$.on,\n onViewportChange: this.viewportMetrics$.on,\n registerBoundingRectProvider: (fn) => {\n this.rectProvider = fn;\n },\n getBoundingRect: (): Rect =>\n this.rectProvider?.() ?? {\n origin: { x: 0, y: 0 },\n size: { width: 0, height: 0 },\n },\n setViewportMetrics: (viewportMetrics: ViewportInputMetrics) => {\n this.dispatch(setViewportMetrics(viewportMetrics));\n },\n setViewportScrollMetrics: this.setViewportScrollMetrics.bind(this),\n scrollTo: (pos: ScrollToPayload) => this.scrollTo(pos),\n onScrollRequest: this.scrollReq$.on,\n isScrolling: () => this.state.isScrolling,\n onScrollActivity: this.scrollActivity$.on,\n };\n }\n\n private bumpScrollActivity() {\n if (this.scrollEndTimer) clearTimeout(this.scrollEndTimer);\n this.scrollEndTimer = window.setTimeout(() => {\n this.dispatch(setScrollActivity(false));\n this.scrollEndTimer = undefined;\n }, this.scrollEndDelay);\n }\n\n private setViewportScrollMetrics(scrollMetrics: ViewportScrollMetrics) {\n if (\n scrollMetrics.scrollTop !== this.state.viewportMetrics.scrollTop ||\n scrollMetrics.scrollLeft !== this.state.viewportMetrics.scrollLeft\n ) {\n this.dispatch(setViewportScrollMetrics(scrollMetrics));\n this.bumpScrollActivity();\n }\n }\n\n private scrollTo(pos: ScrollToPayload) {\n const { x, y, center, behavior = 'auto' } = pos;\n\n if (center) {\n const metrics = this.state.viewportMetrics;\n // Calculate the centered position by adding half the viewport dimensions\n const centeredX = x - metrics.clientWidth / 2;\n const centeredY = y - metrics.clientHeight / 2;\n\n this.scrollReq$.emit({\n x: centeredX,\n y: centeredY,\n behavior,\n });\n } else {\n this.scrollReq$.emit({\n x,\n y,\n behavior,\n });\n }\n }\n\n // Subscribe to store changes to notify onViewportChange\n override onStoreUpdated(prevState: ViewportState, newState: ViewportState): void {\n if (prevState !== newState) {\n this.viewportMetrics$.emit(newState.viewportMetrics);\n this.scrollMetrics$.emit({\n scrollTop: newState.viewportMetrics.scrollTop,\n scrollLeft: newState.viewportMetrics.scrollLeft,\n });\n if (prevState.isScrolling !== newState.isScrolling) {\n this.scrollActivity$.emit(newState.isScrolling);\n }\n }\n }\n\n async initialize(_config: ViewportPluginConfig) {\n // No initialization needed\n }\n\n async destroy(): Promise<void> {\n super.destroy();\n // Clear out any handlers\n this.viewportMetrics$.clear();\n this.scrollMetrics$.clear();\n this.scrollReq$.clear();\n this.scrollActivity$.clear();\n this.rectProvider = null;\n if (this.scrollEndTimer) clearTimeout(this.scrollEndTimer);\n }\n}\n","import { PluginPackage } from '@embedpdf/core';\n\nimport { ViewportAction } from './actions';\nimport { manifest, VIEWPORT_PLUGIN_ID } from './manifest';\nimport { viewportReducer, initialState } from './reducer';\nimport { ViewportPluginConfig, ViewportState } from './types';\nimport { ViewportPlugin } from './viewport-plugin';\n\nexport const ViewportPluginPackage: PluginPackage<\n ViewportPlugin,\n ViewportPluginConfig,\n ViewportState,\n ViewportAction\n> = {\n manifest,\n create: (registry, _engine, config) => new ViewportPlugin(VIEWPORT_PLUGIN_ID, registry, config),\n reducer: viewportReducer,\n initialState: initialState,\n};\n\nexport * from './viewport-plugin';\nexport * from './types';\nexport * from './manifest';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,qBAAqB;AAE3B,IAAM,WAAiD;AAAA,EAC5D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,UAAU;AAAA,EACrB,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,eAAe;AAAA,IACb,SAAS;AAAA,IACT,aAAa;AAAA,IACb,gBAAgB;AAAA,EAClB;AACF;;;ACdO,IAAM,uBAAuB;AAC7B,IAAM,8BAA8B;AACpC,IAAM,mBAAmB;AACzB,IAAM,sBAAsB;AA4B5B,SAAS,eAAe,aAA2C;AACxE,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AACF;AAEO,SAAS,mBACd,iBAC0B;AAC1B,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AACF;AAEO,SAAS,yBACd,eACgC;AAChC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AACF;AAEO,SAAS,kBAAkB,aAA+C;AAC/E,SAAO,EAAE,MAAM,qBAAqB,SAAS,YAAY;AAC3D;;;ACnDO,IAAM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C1B,SAAK,WAAW,MAAM;AACtB,SAAK,gBAAgB,MAAM;AAC3B,SAAK,eAAe;AACpB,QAAI,KAAK,eAAgB,cAAa,KAAK,cAAc;AAAA,EAC3D;AACF;AArIa,eAMK,KAAK;;;AClBhB,IAAM,wBAKT;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,UAAU,SAAS,WAAW,IAAI,eAAe,oBAAoB,UAAU,MAAM;AAAA,EAC9F,SAAS;AAAA,EACT;AACF;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { BasePluginConfig, EventControlOptions, EventHook, Action, BasePlugin, PluginRegistry, PluginManifest, PluginPackage } from '@embedpdf/core';
|
|
2
|
+
import { Rect } from '@embedpdf/models';
|
|
3
|
+
|
|
4
|
+
interface ViewportState {
|
|
5
|
+
viewportGap: number;
|
|
6
|
+
viewportMetrics: ViewportMetrics;
|
|
7
|
+
isScrolling: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface ViewportPluginConfig extends BasePluginConfig {
|
|
10
|
+
viewportGap?: number;
|
|
11
|
+
scrollEndDelay?: number;
|
|
12
|
+
}
|
|
13
|
+
interface ViewportInputMetrics {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
scrollTop: number;
|
|
17
|
+
scrollLeft: number;
|
|
18
|
+
clientWidth: number;
|
|
19
|
+
clientHeight: number;
|
|
20
|
+
scrollWidth: number;
|
|
21
|
+
scrollHeight: number;
|
|
22
|
+
}
|
|
23
|
+
interface ViewportMetrics extends ViewportInputMetrics {
|
|
24
|
+
relativePosition: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
interface ViewportScrollMetrics {
|
|
30
|
+
scrollTop: number;
|
|
31
|
+
scrollLeft: number;
|
|
32
|
+
}
|
|
33
|
+
interface ScrollControlOptions {
|
|
34
|
+
mode: 'debounce' | 'throttle';
|
|
35
|
+
wait: number;
|
|
36
|
+
}
|
|
37
|
+
interface ScrollToPayload {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
behavior?: ScrollBehavior;
|
|
41
|
+
center?: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface ViewportCapability {
|
|
44
|
+
getViewportGap: () => number;
|
|
45
|
+
getMetrics: () => ViewportMetrics;
|
|
46
|
+
setViewportMetrics: (metrics: ViewportInputMetrics) => void;
|
|
47
|
+
setViewportScrollMetrics: (metrics: ViewportScrollMetrics) => void;
|
|
48
|
+
onViewportChange: (handler: (metrics: ViewportMetrics) => void, options?: EventControlOptions) => (metrics: ViewportMetrics) => void;
|
|
49
|
+
scrollTo(position: ScrollToPayload): void;
|
|
50
|
+
onScrollRequest: EventHook<ScrollToPayload>;
|
|
51
|
+
onScrollChange: EventHook<ViewportScrollMetrics>;
|
|
52
|
+
onScrollActivity: EventHook<boolean>;
|
|
53
|
+
isScrolling: () => boolean;
|
|
54
|
+
getBoundingRect(): Rect;
|
|
55
|
+
registerBoundingRectProvider(fn: (() => Rect) | null): void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare const SET_VIEWPORT_METRICS = "SET_VIEWPORT_METRICS";
|
|
59
|
+
declare const SET_VIEWPORT_SCROLL_METRICS = "SET_VIEWPORT_SCROLL_METRICS";
|
|
60
|
+
declare const SET_VIEWPORT_GAP = "SET_VIEWPORT_GAP";
|
|
61
|
+
declare const SET_SCROLL_ACTIVITY = "SET_SCROLL_ACTIVITY";
|
|
62
|
+
interface SetViewportMetricsAction extends Action {
|
|
63
|
+
type: typeof SET_VIEWPORT_METRICS;
|
|
64
|
+
payload: ViewportInputMetrics;
|
|
65
|
+
}
|
|
66
|
+
interface SetViewportScrollMetricsAction extends Action {
|
|
67
|
+
type: typeof SET_VIEWPORT_SCROLL_METRICS;
|
|
68
|
+
payload: ViewportScrollMetrics;
|
|
69
|
+
}
|
|
70
|
+
interface SetViewportGapAction extends Action {
|
|
71
|
+
type: typeof SET_VIEWPORT_GAP;
|
|
72
|
+
payload: number;
|
|
73
|
+
}
|
|
74
|
+
interface SetScrollActivityAction extends Action {
|
|
75
|
+
type: typeof SET_SCROLL_ACTIVITY;
|
|
76
|
+
payload: boolean;
|
|
77
|
+
}
|
|
78
|
+
type ViewportAction = SetViewportMetricsAction | SetViewportScrollMetricsAction | SetViewportGapAction | SetScrollActivityAction;
|
|
79
|
+
|
|
80
|
+
declare class ViewportPlugin extends BasePlugin<ViewportPluginConfig, ViewportCapability, ViewportState, ViewportAction> {
|
|
81
|
+
readonly id: string;
|
|
82
|
+
static readonly id: "viewport";
|
|
83
|
+
private readonly viewportMetrics$;
|
|
84
|
+
private readonly scrollMetrics$;
|
|
85
|
+
private readonly scrollReq$;
|
|
86
|
+
private readonly scrollActivity$;
|
|
87
|
+
private rectProvider;
|
|
88
|
+
private scrollEndTimer?;
|
|
89
|
+
private readonly scrollEndDelay;
|
|
90
|
+
constructor(id: string, registry: PluginRegistry, config: ViewportPluginConfig);
|
|
91
|
+
protected buildCapability(): ViewportCapability;
|
|
92
|
+
private bumpScrollActivity;
|
|
93
|
+
private setViewportScrollMetrics;
|
|
94
|
+
private scrollTo;
|
|
95
|
+
onStoreUpdated(prevState: ViewportState, newState: ViewportState): void;
|
|
96
|
+
initialize(_config: ViewportPluginConfig): Promise<void>;
|
|
97
|
+
destroy(): Promise<void>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
declare const VIEWPORT_PLUGIN_ID = "viewport";
|
|
101
|
+
declare const manifest: PluginManifest<ViewportPluginConfig>;
|
|
102
|
+
|
|
103
|
+
declare const ViewportPluginPackage: PluginPackage<ViewportPlugin, ViewportPluginConfig, ViewportState, ViewportAction>;
|
|
104
|
+
|
|
105
|
+
export { type ScrollControlOptions, type ScrollToPayload, VIEWPORT_PLUGIN_ID, type ViewportCapability, type ViewportInputMetrics, type ViewportMetrics, ViewportPlugin, type ViewportPluginConfig, ViewportPluginPackage, type ViewportScrollMetrics, type ViewportState, manifest };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { BasePluginConfig, EventControlOptions, EventHook, Action, BasePlugin, PluginRegistry, PluginManifest, PluginPackage } from '@embedpdf/core';
|
|
2
|
+
import { Rect } from '@embedpdf/models';
|
|
3
|
+
|
|
4
|
+
interface ViewportState {
|
|
5
|
+
viewportGap: number;
|
|
6
|
+
viewportMetrics: ViewportMetrics;
|
|
7
|
+
isScrolling: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface ViewportPluginConfig extends BasePluginConfig {
|
|
10
|
+
viewportGap?: number;
|
|
11
|
+
scrollEndDelay?: number;
|
|
12
|
+
}
|
|
13
|
+
interface ViewportInputMetrics {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
scrollTop: number;
|
|
17
|
+
scrollLeft: number;
|
|
18
|
+
clientWidth: number;
|
|
19
|
+
clientHeight: number;
|
|
20
|
+
scrollWidth: number;
|
|
21
|
+
scrollHeight: number;
|
|
22
|
+
}
|
|
23
|
+
interface ViewportMetrics extends ViewportInputMetrics {
|
|
24
|
+
relativePosition: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
interface ViewportScrollMetrics {
|
|
30
|
+
scrollTop: number;
|
|
31
|
+
scrollLeft: number;
|
|
32
|
+
}
|
|
33
|
+
interface ScrollControlOptions {
|
|
34
|
+
mode: 'debounce' | 'throttle';
|
|
35
|
+
wait: number;
|
|
36
|
+
}
|
|
37
|
+
interface ScrollToPayload {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
behavior?: ScrollBehavior;
|
|
41
|
+
center?: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface ViewportCapability {
|
|
44
|
+
getViewportGap: () => number;
|
|
45
|
+
getMetrics: () => ViewportMetrics;
|
|
46
|
+
setViewportMetrics: (metrics: ViewportInputMetrics) => void;
|
|
47
|
+
setViewportScrollMetrics: (metrics: ViewportScrollMetrics) => void;
|
|
48
|
+
onViewportChange: (handler: (metrics: ViewportMetrics) => void, options?: EventControlOptions) => (metrics: ViewportMetrics) => void;
|
|
49
|
+
scrollTo(position: ScrollToPayload): void;
|
|
50
|
+
onScrollRequest: EventHook<ScrollToPayload>;
|
|
51
|
+
onScrollChange: EventHook<ViewportScrollMetrics>;
|
|
52
|
+
onScrollActivity: EventHook<boolean>;
|
|
53
|
+
isScrolling: () => boolean;
|
|
54
|
+
getBoundingRect(): Rect;
|
|
55
|
+
registerBoundingRectProvider(fn: (() => Rect) | null): void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare const SET_VIEWPORT_METRICS = "SET_VIEWPORT_METRICS";
|
|
59
|
+
declare const SET_VIEWPORT_SCROLL_METRICS = "SET_VIEWPORT_SCROLL_METRICS";
|
|
60
|
+
declare const SET_VIEWPORT_GAP = "SET_VIEWPORT_GAP";
|
|
61
|
+
declare const SET_SCROLL_ACTIVITY = "SET_SCROLL_ACTIVITY";
|
|
62
|
+
interface SetViewportMetricsAction extends Action {
|
|
63
|
+
type: typeof SET_VIEWPORT_METRICS;
|
|
64
|
+
payload: ViewportInputMetrics;
|
|
65
|
+
}
|
|
66
|
+
interface SetViewportScrollMetricsAction extends Action {
|
|
67
|
+
type: typeof SET_VIEWPORT_SCROLL_METRICS;
|
|
68
|
+
payload: ViewportScrollMetrics;
|
|
69
|
+
}
|
|
70
|
+
interface SetViewportGapAction extends Action {
|
|
71
|
+
type: typeof SET_VIEWPORT_GAP;
|
|
72
|
+
payload: number;
|
|
73
|
+
}
|
|
74
|
+
interface SetScrollActivityAction extends Action {
|
|
75
|
+
type: typeof SET_SCROLL_ACTIVITY;
|
|
76
|
+
payload: boolean;
|
|
77
|
+
}
|
|
78
|
+
type ViewportAction = SetViewportMetricsAction | SetViewportScrollMetricsAction | SetViewportGapAction | SetScrollActivityAction;
|
|
79
|
+
|
|
80
|
+
declare class ViewportPlugin extends BasePlugin<ViewportPluginConfig, ViewportCapability, ViewportState, ViewportAction> {
|
|
81
|
+
readonly id: string;
|
|
82
|
+
static readonly id: "viewport";
|
|
83
|
+
private readonly viewportMetrics$;
|
|
84
|
+
private readonly scrollMetrics$;
|
|
85
|
+
private readonly scrollReq$;
|
|
86
|
+
private readonly scrollActivity$;
|
|
87
|
+
private rectProvider;
|
|
88
|
+
private scrollEndTimer?;
|
|
89
|
+
private readonly scrollEndDelay;
|
|
90
|
+
constructor(id: string, registry: PluginRegistry, config: ViewportPluginConfig);
|
|
91
|
+
protected buildCapability(): ViewportCapability;
|
|
92
|
+
private bumpScrollActivity;
|
|
93
|
+
private setViewportScrollMetrics;
|
|
94
|
+
private scrollTo;
|
|
95
|
+
onStoreUpdated(prevState: ViewportState, newState: ViewportState): void;
|
|
96
|
+
initialize(_config: ViewportPluginConfig): Promise<void>;
|
|
97
|
+
destroy(): Promise<void>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
declare const VIEWPORT_PLUGIN_ID = "viewport";
|
|
101
|
+
declare const manifest: PluginManifest<ViewportPluginConfig>;
|
|
102
|
+
|
|
103
|
+
declare const ViewportPluginPackage: PluginPackage<ViewportPlugin, ViewportPluginConfig, ViewportState, ViewportAction>;
|
|
104
|
+
|
|
105
|
+
export { type ScrollControlOptions, type ScrollToPayload, VIEWPORT_PLUGIN_ID, type ViewportCapability, type ViewportInputMetrics, type ViewportMetrics, ViewportPlugin, type ViewportPluginConfig, ViewportPluginPackage, type ViewportScrollMetrics, type ViewportState, manifest };
|