@embedpdf/plugin-capture 1.0.5

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,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,129 @@
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
+ CAPTURE_PLUGIN_ID: () => CAPTURE_PLUGIN_ID,
24
+ CapturePlugin: () => CapturePlugin,
25
+ CapturePluginPackage: () => CapturePluginPackage,
26
+ manifest: () => manifest
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+
30
+ // src/lib/manifest.ts
31
+ var CAPTURE_PLUGIN_ID = "capture";
32
+ var manifest = {
33
+ id: CAPTURE_PLUGIN_ID,
34
+ name: "Capture Plugin",
35
+ version: "1.0.0",
36
+ provides: ["capture"],
37
+ requires: ["render", "interaction-manager"],
38
+ optional: [],
39
+ defaultConfig: {
40
+ enabled: true,
41
+ scale: 1,
42
+ imageType: "image/png",
43
+ withAnnotations: false
44
+ }
45
+ };
46
+
47
+ // src/lib/capture-plugin.ts
48
+ var import_core = require("@embedpdf/core");
49
+ var import_models = require("@embedpdf/models");
50
+ var CapturePlugin = class extends import_core.BasePlugin {
51
+ constructor(id, registry, config) {
52
+ super(id, registry);
53
+ this.captureArea$ = (0, import_core.createEmitter)();
54
+ this.config = config;
55
+ this.renderCapability = this.registry.getPlugin("render").provides();
56
+ this.interactionManagerCapability = this.registry.getPlugin("interaction-manager").provides();
57
+ this.interactionManagerCapability.registerMode({
58
+ id: "marqueeCapture",
59
+ scope: "page",
60
+ exclusive: true,
61
+ cursor: "crosshair"
62
+ });
63
+ }
64
+ async initialize(_) {
65
+ }
66
+ buildCapability() {
67
+ return {
68
+ onCaptureArea: this.captureArea$.on,
69
+ captureArea: this.captureArea.bind(this),
70
+ enableMarqueeCapture: this.enableMarqueeCapture.bind(this),
71
+ disableMarqueeCapture: this.disableMarqueeCapture.bind(this),
72
+ toggleMarqueeCapture: this.toggleMarqueeCapture.bind(this),
73
+ isMarqueeCaptureActive: () => this.interactionManagerCapability?.getActiveMode() === "marqueeCapture"
74
+ };
75
+ }
76
+ captureArea(pageIndex, rect) {
77
+ this.disableMarqueeCapture();
78
+ const task = this.renderCapability.renderPageRect({
79
+ pageIndex,
80
+ rect,
81
+ imageType: this.config.imageType,
82
+ scaleFactor: this.config.scale,
83
+ options: {
84
+ withAnnotations: this.config.withAnnotations || false
85
+ }
86
+ });
87
+ task.wait((blob) => {
88
+ this.captureArea$.emit({
89
+ pageIndex,
90
+ rect,
91
+ blob,
92
+ imageType: this.config.imageType || "image/png",
93
+ scale: this.config.scale || 1,
94
+ withAnnotations: this.config.withAnnotations || false
95
+ });
96
+ }, import_models.ignore);
97
+ }
98
+ enableMarqueeCapture() {
99
+ this.interactionManagerCapability?.activate("marqueeCapture");
100
+ }
101
+ disableMarqueeCapture() {
102
+ this.interactionManagerCapability?.activate("default");
103
+ }
104
+ toggleMarqueeCapture() {
105
+ if (this.interactionManagerCapability?.getActiveMode() === "marqueeCapture") {
106
+ this.interactionManagerCapability?.activate("default");
107
+ } else {
108
+ this.interactionManagerCapability?.activate("marqueeCapture");
109
+ }
110
+ }
111
+ };
112
+ CapturePlugin.id = "capture";
113
+
114
+ // src/lib/index.ts
115
+ var CapturePluginPackage = {
116
+ manifest,
117
+ create: (registry, _engine, config) => new CapturePlugin(CAPTURE_PLUGIN_ID, registry, config),
118
+ reducer: () => {
119
+ },
120
+ initialState: {}
121
+ };
122
+ // Annotate the CommonJS export names for ESM import in node:
123
+ 0 && (module.exports = {
124
+ CAPTURE_PLUGIN_ID,
125
+ CapturePlugin,
126
+ CapturePluginPackage,
127
+ manifest
128
+ });
129
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/lib/manifest.ts","../src/lib/capture-plugin.ts","../src/lib/index.ts"],"sourcesContent":["export * from './lib';\n","import { PluginManifest } from '@embedpdf/core';\nimport { CapturePluginConfig } from './types';\n\nexport const CAPTURE_PLUGIN_ID = 'capture';\n\nexport const manifest: PluginManifest<CapturePluginConfig> = {\n id: CAPTURE_PLUGIN_ID,\n name: 'Capture Plugin',\n version: '1.0.0',\n provides: ['capture'],\n requires: ['render', 'interaction-manager'],\n optional: [],\n defaultConfig: {\n enabled: true,\n scale: 1,\n imageType: 'image/png',\n withAnnotations: false,\n },\n};\n","import { BasePlugin, createEmitter, PluginRegistry } from '@embedpdf/core';\nimport {\n InteractionManagerCapability,\n InteractionManagerPlugin,\n} from '@embedpdf/plugin-interaction-manager';\nimport { RenderCapability, RenderPlugin } from '@embedpdf/plugin-render';\n\nimport { CaptureAreaEvent, CaptureCapability, CapturePluginConfig } from './types';\nimport { ignore, Rect } from '@embedpdf/models';\n\nexport class CapturePlugin extends BasePlugin<CapturePluginConfig, CaptureCapability> {\n static readonly id = 'capture' as const;\n\n private captureArea$ = createEmitter<CaptureAreaEvent>();\n\n private renderCapability: RenderCapability;\n private interactionManagerCapability: InteractionManagerCapability;\n private config: CapturePluginConfig;\n\n constructor(id: string, registry: PluginRegistry, config: CapturePluginConfig) {\n super(id, registry);\n\n this.config = config;\n\n this.renderCapability = this.registry.getPlugin<RenderPlugin>('render')!.provides();\n this.interactionManagerCapability = this.registry\n .getPlugin<InteractionManagerPlugin>('interaction-manager')!\n .provides();\n\n this.interactionManagerCapability.registerMode({\n id: 'marqueeCapture',\n scope: 'page',\n exclusive: true,\n cursor: 'crosshair',\n });\n }\n\n async initialize(_: CapturePluginConfig): Promise<void> {}\n\n protected buildCapability(): CaptureCapability {\n return {\n onCaptureArea: this.captureArea$.on,\n captureArea: this.captureArea.bind(this),\n enableMarqueeCapture: this.enableMarqueeCapture.bind(this),\n disableMarqueeCapture: this.disableMarqueeCapture.bind(this),\n toggleMarqueeCapture: this.toggleMarqueeCapture.bind(this),\n isMarqueeCaptureActive: () =>\n this.interactionManagerCapability?.getActiveMode() === 'marqueeCapture',\n };\n }\n\n private captureArea(pageIndex: number, rect: Rect) {\n this.disableMarqueeCapture();\n\n const task = this.renderCapability.renderPageRect({\n pageIndex,\n rect,\n imageType: this.config.imageType,\n scaleFactor: this.config.scale,\n options: {\n withAnnotations: this.config.withAnnotations || false,\n },\n });\n\n task.wait((blob) => {\n this.captureArea$.emit({\n pageIndex,\n rect,\n blob,\n imageType: this.config.imageType || 'image/png',\n scale: this.config.scale || 1,\n withAnnotations: this.config.withAnnotations || false,\n });\n }, ignore);\n }\n\n private enableMarqueeCapture() {\n this.interactionManagerCapability?.activate('marqueeCapture');\n }\n\n private disableMarqueeCapture() {\n this.interactionManagerCapability?.activate('default');\n }\n\n private toggleMarqueeCapture() {\n if (this.interactionManagerCapability?.getActiveMode() === 'marqueeCapture') {\n this.interactionManagerCapability?.activate('default');\n } else {\n this.interactionManagerCapability?.activate('marqueeCapture');\n }\n }\n}\n","import { PluginPackage } from '@embedpdf/core';\nimport { manifest, CAPTURE_PLUGIN_ID } from './manifest';\nimport { CapturePluginConfig } from './types';\nimport { CapturePlugin } from './capture-plugin';\n\nexport const CapturePluginPackage: PluginPackage<CapturePlugin, CapturePluginConfig> = {\n manifest,\n create: (registry, _engine, config) => new CapturePlugin(CAPTURE_PLUGIN_ID, registry, config),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './capture-plugin';\nexport * from './types';\nexport * from './manifest';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,IAAM,oBAAoB;AAE1B,IAAM,WAAgD;AAAA,EAC3D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,SAAS;AAAA,EACpB,UAAU,CAAC,UAAU,qBAAqB;AAAA,EAC1C,UAAU,CAAC;AAAA,EACX,eAAe;AAAA,IACb,SAAS;AAAA,IACT,OAAO;AAAA,IACP,WAAW;AAAA,IACX,iBAAiB;AAAA,EACnB;AACF;;;AClBA,kBAA0D;AAQ1D,oB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AAA,MAClD,CAAC;AAAA,IACH,GAAG,oBAAM;AAAA,EACX;AAAA,EAEQ,uBAAuB;AAC7B,SAAK,8BAA8B,SAAS,gBAAgB;AAAA,EAC9D;AAAA,EAEQ,wBAAwB;AAC9B,SAAK,8BAA8B,SAAS,SAAS;AAAA,EACvD;AAAA,EAEQ,uBAAuB;AAC7B,QAAI,KAAK,8BAA8B,cAAc,MAAM,kBAAkB;AAC3E,WAAK,8BAA8B,SAAS,SAAS;AAAA,IACvD,OAAO;AACL,WAAK,8BAA8B,SAAS,gBAAgB;AAAA,IAC9D;AAAA,EACF;AACF;AAjFa,cACK,KAAK;;;ACNhB,IAAM,uBAA0E;AAAA,EACrF;AAAA,EACA,QAAQ,CAAC,UAAU,SAAS,WAAW,IAAI,cAAc,mBAAmB,UAAU,MAAM;AAAA,EAC5F,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,cAAc,CAAC;AACjB;","names":[]}
@@ -0,0 +1,46 @@
1
+ import { BasePluginConfig, EventHook, BasePlugin, PluginRegistry, PluginManifest, PluginPackage } from '@embedpdf/core';
2
+ import { ImageConversionTypes, Rect } from '@embedpdf/models';
3
+
4
+ interface CapturePluginConfig extends BasePluginConfig {
5
+ scale?: number;
6
+ imageType?: ImageConversionTypes;
7
+ withAnnotations?: boolean;
8
+ }
9
+ interface CaptureAreaEvent {
10
+ pageIndex: number;
11
+ rect: Rect;
12
+ blob: Blob;
13
+ imageType: ImageConversionTypes;
14
+ scale: number;
15
+ withAnnotations: boolean;
16
+ }
17
+ interface CaptureCapability {
18
+ onCaptureArea: EventHook<CaptureAreaEvent>;
19
+ captureArea(pageIndex: number, rect: Rect): void;
20
+ enableMarqueeCapture: () => void;
21
+ disableMarqueeCapture: () => void;
22
+ toggleMarqueeCapture: () => void;
23
+ isMarqueeCaptureActive: () => boolean;
24
+ }
25
+
26
+ declare class CapturePlugin extends BasePlugin<CapturePluginConfig, CaptureCapability> {
27
+ static readonly id: "capture";
28
+ private captureArea$;
29
+ private renderCapability;
30
+ private interactionManagerCapability;
31
+ private config;
32
+ constructor(id: string, registry: PluginRegistry, config: CapturePluginConfig);
33
+ initialize(_: CapturePluginConfig): Promise<void>;
34
+ protected buildCapability(): CaptureCapability;
35
+ private captureArea;
36
+ private enableMarqueeCapture;
37
+ private disableMarqueeCapture;
38
+ private toggleMarqueeCapture;
39
+ }
40
+
41
+ declare const CAPTURE_PLUGIN_ID = "capture";
42
+ declare const manifest: PluginManifest<CapturePluginConfig>;
43
+
44
+ declare const CapturePluginPackage: PluginPackage<CapturePlugin, CapturePluginConfig>;
45
+
46
+ export { CAPTURE_PLUGIN_ID, type CaptureAreaEvent, type CaptureCapability, CapturePlugin, type CapturePluginConfig, CapturePluginPackage, manifest };
@@ -0,0 +1,46 @@
1
+ import { BasePluginConfig, EventHook, BasePlugin, PluginRegistry, PluginManifest, PluginPackage } from '@embedpdf/core';
2
+ import { ImageConversionTypes, Rect } from '@embedpdf/models';
3
+
4
+ interface CapturePluginConfig extends BasePluginConfig {
5
+ scale?: number;
6
+ imageType?: ImageConversionTypes;
7
+ withAnnotations?: boolean;
8
+ }
9
+ interface CaptureAreaEvent {
10
+ pageIndex: number;
11
+ rect: Rect;
12
+ blob: Blob;
13
+ imageType: ImageConversionTypes;
14
+ scale: number;
15
+ withAnnotations: boolean;
16
+ }
17
+ interface CaptureCapability {
18
+ onCaptureArea: EventHook<CaptureAreaEvent>;
19
+ captureArea(pageIndex: number, rect: Rect): void;
20
+ enableMarqueeCapture: () => void;
21
+ disableMarqueeCapture: () => void;
22
+ toggleMarqueeCapture: () => void;
23
+ isMarqueeCaptureActive: () => boolean;
24
+ }
25
+
26
+ declare class CapturePlugin extends BasePlugin<CapturePluginConfig, CaptureCapability> {
27
+ static readonly id: "capture";
28
+ private captureArea$;
29
+ private renderCapability;
30
+ private interactionManagerCapability;
31
+ private config;
32
+ constructor(id: string, registry: PluginRegistry, config: CapturePluginConfig);
33
+ initialize(_: CapturePluginConfig): Promise<void>;
34
+ protected buildCapability(): CaptureCapability;
35
+ private captureArea;
36
+ private enableMarqueeCapture;
37
+ private disableMarqueeCapture;
38
+ private toggleMarqueeCapture;
39
+ }
40
+
41
+ declare const CAPTURE_PLUGIN_ID = "capture";
42
+ declare const manifest: PluginManifest<CapturePluginConfig>;
43
+
44
+ declare const CapturePluginPackage: PluginPackage<CapturePlugin, CapturePluginConfig>;
45
+
46
+ export { CAPTURE_PLUGIN_ID, type CaptureAreaEvent, type CaptureCapability, CapturePlugin, type CapturePluginConfig, CapturePluginPackage, manifest };
package/dist/index.js ADDED
@@ -0,0 +1,99 @@
1
+ // src/lib/manifest.ts
2
+ var CAPTURE_PLUGIN_ID = "capture";
3
+ var manifest = {
4
+ id: CAPTURE_PLUGIN_ID,
5
+ name: "Capture Plugin",
6
+ version: "1.0.0",
7
+ provides: ["capture"],
8
+ requires: ["render", "interaction-manager"],
9
+ optional: [],
10
+ defaultConfig: {
11
+ enabled: true,
12
+ scale: 1,
13
+ imageType: "image/png",
14
+ withAnnotations: false
15
+ }
16
+ };
17
+
18
+ // src/lib/capture-plugin.ts
19
+ import { BasePlugin, createEmitter } from "@embedpdf/core";
20
+ import { ignore } from "@embedpdf/models";
21
+ var CapturePlugin = class extends BasePlugin {
22
+ constructor(id, registry, config) {
23
+ super(id, registry);
24
+ this.captureArea$ = createEmitter();
25
+ this.config = config;
26
+ this.renderCapability = this.registry.getPlugin("render").provides();
27
+ this.interactionManagerCapability = this.registry.getPlugin("interaction-manager").provides();
28
+ this.interactionManagerCapability.registerMode({
29
+ id: "marqueeCapture",
30
+ scope: "page",
31
+ exclusive: true,
32
+ cursor: "crosshair"
33
+ });
34
+ }
35
+ async initialize(_) {
36
+ }
37
+ buildCapability() {
38
+ return {
39
+ onCaptureArea: this.captureArea$.on,
40
+ captureArea: this.captureArea.bind(this),
41
+ enableMarqueeCapture: this.enableMarqueeCapture.bind(this),
42
+ disableMarqueeCapture: this.disableMarqueeCapture.bind(this),
43
+ toggleMarqueeCapture: this.toggleMarqueeCapture.bind(this),
44
+ isMarqueeCaptureActive: () => this.interactionManagerCapability?.getActiveMode() === "marqueeCapture"
45
+ };
46
+ }
47
+ captureArea(pageIndex, rect) {
48
+ this.disableMarqueeCapture();
49
+ const task = this.renderCapability.renderPageRect({
50
+ pageIndex,
51
+ rect,
52
+ imageType: this.config.imageType,
53
+ scaleFactor: this.config.scale,
54
+ options: {
55
+ withAnnotations: this.config.withAnnotations || false
56
+ }
57
+ });
58
+ task.wait((blob) => {
59
+ this.captureArea$.emit({
60
+ pageIndex,
61
+ rect,
62
+ blob,
63
+ imageType: this.config.imageType || "image/png",
64
+ scale: this.config.scale || 1,
65
+ withAnnotations: this.config.withAnnotations || false
66
+ });
67
+ }, ignore);
68
+ }
69
+ enableMarqueeCapture() {
70
+ this.interactionManagerCapability?.activate("marqueeCapture");
71
+ }
72
+ disableMarqueeCapture() {
73
+ this.interactionManagerCapability?.activate("default");
74
+ }
75
+ toggleMarqueeCapture() {
76
+ if (this.interactionManagerCapability?.getActiveMode() === "marqueeCapture") {
77
+ this.interactionManagerCapability?.activate("default");
78
+ } else {
79
+ this.interactionManagerCapability?.activate("marqueeCapture");
80
+ }
81
+ }
82
+ };
83
+ CapturePlugin.id = "capture";
84
+
85
+ // src/lib/index.ts
86
+ var CapturePluginPackage = {
87
+ manifest,
88
+ create: (registry, _engine, config) => new CapturePlugin(CAPTURE_PLUGIN_ID, registry, config),
89
+ reducer: () => {
90
+ },
91
+ initialState: {}
92
+ };
93
+ export {
94
+ CAPTURE_PLUGIN_ID,
95
+ CapturePlugin,
96
+ CapturePluginPackage,
97
+ manifest
98
+ };
99
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/manifest.ts","../src/lib/capture-plugin.ts","../src/lib/index.ts"],"sourcesContent":["import { PluginManifest } from '@embedpdf/core';\nimport { CapturePluginConfig } from './types';\n\nexport const CAPTURE_PLUGIN_ID = 'capture';\n\nexport const manifest: PluginManifest<CapturePluginConfig> = {\n id: CAPTURE_PLUGIN_ID,\n name: 'Capture Plugin',\n version: '1.0.0',\n provides: ['capture'],\n requires: ['render', 'interaction-manager'],\n optional: [],\n defaultConfig: {\n enabled: true,\n scale: 1,\n imageType: 'image/png',\n withAnnotations: false,\n },\n};\n","import { BasePlugin, createEmitter, PluginRegistry } from '@embedpdf/core';\nimport {\n InteractionManagerCapability,\n InteractionManagerPlugin,\n} from '@embedpdf/plugin-interaction-manager';\nimport { RenderCapability, RenderPlugin } from '@embedpdf/plugin-render';\n\nimport { CaptureAreaEvent, CaptureCapability, CapturePluginConfig } from './types';\nimport { ignore, Rect } from '@embedpdf/models';\n\nexport class CapturePlugin extends BasePlugin<CapturePluginConfig, CaptureCapability> {\n static readonly id = 'capture' as const;\n\n private captureArea$ = createEmitter<CaptureAreaEvent>();\n\n private renderCapability: RenderCapability;\n private interactionManagerCapability: InteractionManagerCapability;\n private config: CapturePluginConfig;\n\n constructor(id: string, registry: PluginRegistry, config: CapturePluginConfig) {\n super(id, registry);\n\n this.config = config;\n\n this.renderCapability = this.registry.getPlugin<RenderPlugin>('render')!.provides();\n this.interactionManagerCapability = this.registry\n .getPlugin<InteractionManagerPlugin>('interaction-manager')!\n .provides();\n\n this.interactionManagerCapability.registerMode({\n id: 'marqueeCapture',\n scope: 'page',\n exclusive: true,\n cursor: 'crosshair',\n });\n }\n\n async initialize(_: CapturePluginConfig): Promise<void> {}\n\n protected buildCapability(): CaptureCapability {\n return {\n onCaptureArea: this.captureArea$.on,\n captureArea: this.captureArea.bind(this),\n enableMarqueeCapture: this.enableMarqueeCapture.bind(this),\n disableMarqueeCapture: this.disableMarqueeCapture.bind(this),\n toggleMarqueeCapture: this.toggleMarqueeCapture.bind(this),\n isMarqueeCaptureActive: () =>\n this.interactionManagerCapability?.getActiveMode() === 'marqueeCapture',\n };\n }\n\n private captureArea(pageIndex: number, rect: Rect) {\n this.disableMarqueeCapture();\n\n const task = this.renderCapability.renderPageRect({\n pageIndex,\n rect,\n imageType: this.config.imageType,\n scaleFactor: this.config.scale,\n options: {\n withAnnotations: this.config.withAnnotations || false,\n },\n });\n\n task.wait((blob) => {\n this.captureArea$.emit({\n pageIndex,\n rect,\n blob,\n imageType: this.config.imageType || 'image/png',\n scale: this.config.scale || 1,\n withAnnotations: this.config.withAnnotations || false,\n });\n }, ignore);\n }\n\n private enableMarqueeCapture() {\n this.interactionManagerCapability?.activate('marqueeCapture');\n }\n\n private disableMarqueeCapture() {\n this.interactionManagerCapability?.activate('default');\n }\n\n private toggleMarqueeCapture() {\n if (this.interactionManagerCapability?.getActiveMode() === 'marqueeCapture') {\n this.interactionManagerCapability?.activate('default');\n } else {\n this.interactionManagerCapability?.activate('marqueeCapture');\n }\n }\n}\n","import { PluginPackage } from '@embedpdf/core';\nimport { manifest, CAPTURE_PLUGIN_ID } from './manifest';\nimport { CapturePluginConfig } from './types';\nimport { CapturePlugin } from './capture-plugin';\n\nexport const CapturePluginPackage: PluginPackage<CapturePlugin, CapturePluginConfig> = {\n manifest,\n create: (registry, _engine, config) => new CapturePlugin(CAPTURE_PLUGIN_ID, registry, config),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './capture-plugin';\nexport * from './types';\nexport * from './manifest';\n"],"mappings":";AAGO,IAAM,oBAAoB;AAE1B,IAAM,WAAgD;AAAA,EAC3D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,SAAS;AAAA,EACpB,UAAU,CAAC,UAAU,qBAAqB;AAAA,EAC1C,UAAU,CAAC;AAAA,EACX,eAAe;AAAA,IACb,SAAS;AAAA,IACT,OAAO;AAAA,IACP,WAAW;AAAA,IACX,iBAAiB;AAAA,EACnB;AACF;;;AClBA,SAAS,YAAY,qBAAqC;AAQ1D,SAAS,cAAoB;AAEtB,IAAM,gBAAN,cAA4B,WAAmD;AAAA,EASpF,YAAY,IAAY,UAA0B,QAA6B;AAC7E,UAAM,IAAI,QAAQ;AAPpB,SAAQ,eAAe,cAAgC;AAS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wB;AAC9B,SAAK,8BAA8B,SAAS,SAAS;AAAA,EACvD;AAAA,EAEQ,uBAAuB;AAC7B,QAAI,KAAK,8BAA8B,cAAc,MAAM,kBAAkB;AAC3E,WAAK,8BAA8B,SAAS,SAAS;AAAA,IACvD,OAAO;AACL,WAAK,8BAA8B,SAAS,gBAAgB;AAAA,IAC9D;AAAA,EACF;AACF;AAjFa,cACK,KAAK;;;ACNhB,IAAM,uBAA0E;AAAA,EACrF;AAAA,EACA,QAAQ,CAAC,UAAU,SAAS,WAAW,IAAI,cAAc,mBAAmB,UAAU,MAAM;AAAA,EAC5F,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,cAAc,CAAC;AACjB;","names":[]}
@@ -0,0 +1,121 @@
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/preact/index.ts
21
+ var preact_exports = {};
22
+ __export(preact_exports, {
23
+ MarqueeCapture: () => MarqueeCapture,
24
+ useCaptureCapability: () => useCaptureCapability,
25
+ useCapturePlugin: () => useCapturePlugin
26
+ });
27
+ module.exports = __toCommonJS(preact_exports);
28
+
29
+ // src/preact/hooks/use-capture.ts
30
+ var import_preact = require("@embedpdf/core/preact");
31
+ var import_plugin_capture = require("@embedpdf/plugin-capture");
32
+ var useCaptureCapability = () => (0, import_preact.useCapability)(import_plugin_capture.CapturePlugin.id);
33
+ var useCapturePlugin = () => (0, import_preact.usePlugin)(import_plugin_capture.CapturePlugin.id);
34
+
35
+ // src/preact/components/marquee-capture.tsx
36
+ var import_hooks = require("preact/hooks");
37
+ var import_preact2 = require("@embedpdf/plugin-interaction-manager/preact");
38
+ var import_jsx_runtime = require("preact/jsx-runtime");
39
+ var MarqueeCapture = ({
40
+ pageIndex,
41
+ scale,
42
+ pageWidth,
43
+ pageHeight,
44
+ className,
45
+ stroke = "rgba(33,150,243,0.8)",
46
+ fill = "rgba(33,150,243,0.15)"
47
+ }) => {
48
+ const { provides: capture } = useCaptureCapability();
49
+ const { register } = (0, import_preact2.usePointerHandlers)({ modeId: "marqueeCapture", pageIndex });
50
+ const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
51
+ const startRef = (0, import_hooks.useRef)(null);
52
+ const [rect, setRect] = (0, import_hooks.useState)(null);
53
+ const pageWidthPDF = pageWidth / scale;
54
+ const pageHeightPDF = pageHeight / scale;
55
+ const handlers = (0, import_hooks.useMemo)(
56
+ () => ({
57
+ onPointerDown: (pos, evt) => {
58
+ startRef.current = pos;
59
+ setRect({ origin: { x: pos.x, y: pos.y }, size: { width: 0, height: 0 } });
60
+ evt.target?.setPointerCapture?.(evt.pointerId);
61
+ },
62
+ onPointerMove: (pos) => {
63
+ if (!startRef.current) return;
64
+ const curX = clamp(pos.x, 0, pageWidthPDF);
65
+ const curY = clamp(pos.y, 0, pageHeightPDF);
66
+ const { x: sx, y: sy } = startRef.current;
67
+ const left = Math.min(sx, curX);
68
+ const top = Math.min(sy, curY);
69
+ const width = Math.abs(curX - sx);
70
+ const height = Math.abs(curY - sy);
71
+ setRect({ origin: { x: left, y: top }, size: { width, height } });
72
+ },
73
+ onPointerUp: (_, evt) => {
74
+ if (rect && capture) {
75
+ const dragPx = Math.max(rect.size.width, rect.size.height) * scale;
76
+ if (dragPx > 5) {
77
+ capture.captureArea(pageIndex, rect);
78
+ }
79
+ }
80
+ startRef.current = null;
81
+ setRect(null);
82
+ evt.target?.releasePointerCapture?.(evt.pointerId);
83
+ },
84
+ onPointerCancel: (_, evt) => {
85
+ startRef.current = null;
86
+ setRect(null);
87
+ evt.target?.releasePointerCapture?.(evt.pointerId);
88
+ }
89
+ }),
90
+ [pageWidthPDF, pageWidthPDF, capture, scale, rect, pageIndex]
91
+ );
92
+ (0, import_hooks.useEffect)(() => {
93
+ if (!register) return;
94
+ return register(handlers);
95
+ }, [register, handlers]);
96
+ if (!rect) return null;
97
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
98
+ "div",
99
+ {
100
+ style: {
101
+ position: "absolute",
102
+ pointerEvents: "none",
103
+ left: rect.origin.x * scale,
104
+ top: rect.origin.y * scale,
105
+ width: rect.size.width * scale,
106
+ height: rect.size.height * scale,
107
+ border: `1px solid ${stroke}`,
108
+ background: fill,
109
+ boxSizing: "border-box"
110
+ },
111
+ className
112
+ }
113
+ );
114
+ };
115
+ // Annotate the CommonJS export names for ESM import in node:
116
+ 0 && (module.exports = {
117
+ MarqueeCapture,
118
+ useCaptureCapability,
119
+ useCapturePlugin
120
+ });
121
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/preact/index.ts","../../src/preact/hooks/use-capture.ts","../../src/preact/components/marquee-capture.tsx"],"sourcesContent":["export * from './hooks';\nexport * from './components';\n","import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { CapturePlugin } from '@embedpdf/plugin-capture';\n\nexport const useCaptureCapability = () => useCapability<CapturePlugin>(CapturePlugin.id);\nexport const useCapturePlugin = () => usePlugin<CapturePlugin>(CapturePlugin.id);\n","/** @jsxImportSource preact */\nimport { useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport type { PointerEventHandlers } from '@embedpdf/plugin-interaction-manager';\nimport { usePointerHandlers } from '@embedpdf/plugin-interaction-manager/preact';\nimport { Rect } from '@embedpdf/models';\n\nimport { useCaptureCapability } from '../hooks/use-capture';\n\ninterface MarqueeCaptureProps {\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page */\n scale: number;\n /** Width of the page */\n pageWidth: number;\n /** Height of the page */\n pageHeight: number;\n /** Optional CSS class applied to the marquee rectangle */\n className?: string;\n /** Stroke / fill colours (defaults below) */\n stroke?: string;\n fill?: string;\n}\n\n/**\n * Draws a marquee rectangle while the user drags.\n * Hook it into the interaction-manager with modeId = 'marqueeCapture'.\n */\nexport const MarqueeCapture = ({\n pageIndex,\n scale,\n pageWidth,\n pageHeight,\n className,\n stroke = 'rgba(33,150,243,0.8)',\n fill = 'rgba(33,150,243,0.15)',\n}: MarqueeCaptureProps) => {\n /* ------------------------------------------------------------------ */\n /* capture capability */\n /* ------------------------------------------------------------------ */\n const { provides: capture } = useCaptureCapability();\n\n /* ------------------------------------------------------------------ */\n /* integration with interaction-manager */\n /* ------------------------------------------------------------------ */\n const { register } = usePointerHandlers({ modeId: 'marqueeCapture', pageIndex });\n\n /* ------------------------------------------------------------------ */\n /* helpers */\n /* ------------------------------------------------------------------ */\n const clamp = (v: number, min: number, max: number) => Math.max(min, Math.min(max, v));\n\n /* ------------------------------------------------------------------ */\n /* local state – start / current drag position */\n /* ------------------------------------------------------------------ */\n const startRef = useRef<{ x: number; y: number } | null>(null);\n const [rect, setRect] = useState<Rect | null>(null);\n\n /* page size in **PDF-space** (unscaled) ----------------------------- */\n const pageWidthPDF = pageWidth / scale;\n const pageHeightPDF = pageHeight / scale;\n\n /* ------------------------------------------------------------------ */\n /* pointer handlers */\n /* ------------------------------------------------------------------ */\n const handlers = useMemo<PointerEventHandlers<PointerEvent>>(\n () => ({\n onPointerDown: (pos, evt) => {\n startRef.current = pos;\n setRect({ origin: { x: pos.x, y: pos.y }, size: { width: 0, height: 0 } });\n (evt.target as HTMLElement)?.setPointerCapture?.(evt.pointerId);\n },\n onPointerMove: (pos) => {\n if (!startRef.current) return;\n /* clamp current position to the page bounds */\n const curX = clamp(pos.x, 0, pageWidthPDF);\n const curY = clamp(pos.y, 0, pageHeightPDF);\n\n const { x: sx, y: sy } = startRef.current;\n const left = Math.min(sx, curX);\n const top = Math.min(sy, curY);\n const width = Math.abs(curX - sx);\n const height = Math.abs(curY - sy);\n\n setRect({ origin: { x: left, y: top }, size: { width, height } });\n },\n onPointerUp: (_, evt) => {\n if (rect && capture) {\n const dragPx = Math.max(rect.size.width, rect.size.height) * scale;\n if (dragPx > 5) {\n // real drag → zoom to it\n capture.captureArea(pageIndex, rect);\n }\n }\n\n startRef.current = null;\n setRect(null);\n (evt.target as HTMLElement)?.releasePointerCapture?.(evt.pointerId);\n },\n onPointerCancel: (_, evt) => {\n startRef.current = null;\n setRect(null);\n (evt.target as HTMLElement)?.releasePointerCapture?.(evt.pointerId);\n },\n }),\n [pageWidthPDF, pageWidthPDF, capture, scale, rect, pageIndex],\n );\n\n /* register with the interaction-manager */\n useEffect(() => {\n if (!register) return;\n return register(handlers);\n }, [register, handlers]);\n\n /* ------------------------------------------------------------------ */\n /* render */\n /* ------------------------------------------------------------------ */\n if (!rect) return null; // nothing to draw\n\n return (\n <div\n /* Each page wrapper is position:relative, so absolute is fine */\n style={{\n position: 'absolute',\n pointerEvents: 'none',\n left: rect.origin.x * scale,\n top: rect.origin.y * scale,\n width: rect.size.width * scale,\n height: rect.size.height * scale,\n border: `1px solid ${stroke}`,\n background: fill,\n boxSizing: 'border-box',\n }}\n className={className}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAyC;AACzC,4BAA8B;AAEvB,IAAM,uBAAuB,UAAM,6BAA6B,oCAAc,EAAE;AAChF,IAAM,mBAAmB,UAAM,yBAAyB,oCAAc,EAAE;;;ACH/E,mBAAqD;AAErD,IAAAA,iBAAmC;AAqH/B;AA5FG,IAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;A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,YAAI,QAAQ,SAAS;AACnB,gBAAM,SAAS,KAAK,IAAI,KAAK,KAAK,OAAO,KAAK,KAAK,MAAM,IAAI;AAC7D,cAAI,SAAS,GAAG;AAEd,oBAAQ,YAAY,WAAW,IAAI;AAAA,UACrC;AAAA,QACF;AAEA,iBAAS,UAAU;AACnB,gBAAQ,IAAI;AACZ,QAAC,IAAI,QAAwB,wBAAwB,IAAI,SAAS;AAAA,MACpE;AAAA,MACA,iBAAiB,CAAC,GAAG,QAAQ;AAC3B,iBAAS,UAAU;AACnB,gBAAQ,IAAI;AACZ,QAAC,IAAI,QAAwB,wBAAwB,IAAI,SAAS;AAAA,MACpE;AAAA,IACF;AAAA,IACA,CAAC,cAAc,cAAc,SAAS,OAAO,MAAM,SAAS;AAAA,EAC9D;AAGA,8BAAU,MAAM;AACd,QAAI,CAAC,SAAU;AACf,WAAO,SAAS,QAAQ;AAAA,EAC1B,GAAG,CAAC,UAAU,QAAQ,CAAC;AAKvB,MAAI,CAAC,KAAM,QAAO;AAElB,SACE;AAAA,IAAC;AAAA;AAAA,MAEC,OAAO;AAAA,QACL,UAAU;AAAA,QACV,eAAe;AAAA,QACf,MAAM,KAAK,OAAO,IAAI;AAAA,QACtB,KAAK,KAAK,OAAO,IAAI;AAAA,QACrB,OAAO,KAAK,KAAK,QAAQ;AAAA,QACzB,QAAQ,KAAK,KAAK,SAAS;AAAA,QAC3B,QAAQ,aAAa,MAAM;AAAA,QAC3B,YAAY;AAAA,QACZ,WAAW;AAAA,MACb;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;","names":["import_preact"]}
@@ -0,0 +1,37 @@
1
+ import * as _embedpdf_plugin_capture from '@embedpdf/plugin-capture';
2
+ import { CapturePlugin } from '@embedpdf/plugin-capture';
3
+ import * as preact from 'preact';
4
+
5
+ declare const useCaptureCapability: () => {
6
+ provides: Readonly<_embedpdf_plugin_capture.CaptureCapability> | null;
7
+ isLoading: boolean;
8
+ ready: Promise<void>;
9
+ };
10
+ declare const useCapturePlugin: () => {
11
+ plugin: CapturePlugin | null;
12
+ isLoading: boolean;
13
+ ready: Promise<void>;
14
+ };
15
+
16
+ interface MarqueeCaptureProps {
17
+ /** Index of the page this layer lives on */
18
+ pageIndex: number;
19
+ /** Scale of the page */
20
+ scale: number;
21
+ /** Width of the page */
22
+ pageWidth: number;
23
+ /** Height of the page */
24
+ pageHeight: number;
25
+ /** Optional CSS class applied to the marquee rectangle */
26
+ className?: string;
27
+ /** Stroke / fill colours (defaults below) */
28
+ stroke?: string;
29
+ fill?: string;
30
+ }
31
+ /**
32
+ * Draws a marquee rectangle while the user drags.
33
+ * Hook it into the interaction-manager with modeId = 'marqueeCapture'.
34
+ */
35
+ declare const MarqueeCapture: ({ pageIndex, scale, pageWidth, pageHeight, className, stroke, fill, }: MarqueeCaptureProps) => preact.JSX.Element | null;
36
+
37
+ export { MarqueeCapture, useCaptureCapability, useCapturePlugin };
@@ -0,0 +1,37 @@
1
+ import * as _embedpdf_plugin_capture from '@embedpdf/plugin-capture';
2
+ import { CapturePlugin } from '@embedpdf/plugin-capture';
3
+ import * as preact from 'preact';
4
+
5
+ declare const useCaptureCapability: () => {
6
+ provides: Readonly<_embedpdf_plugin_capture.CaptureCapability> | null;
7
+ isLoading: boolean;
8
+ ready: Promise<void>;
9
+ };
10
+ declare const useCapturePlugin: () => {
11
+ plugin: CapturePlugin | null;
12
+ isLoading: boolean;
13
+ ready: Promise<void>;
14
+ };
15
+
16
+ interface MarqueeCaptureProps {
17
+ /** Index of the page this layer lives on */
18
+ pageIndex: number;
19
+ /** Scale of the page */
20
+ scale: number;
21
+ /** Width of the page */
22
+ pageWidth: number;
23
+ /** Height of the page */
24
+ pageHeight: number;
25
+ /** Optional CSS class applied to the marquee rectangle */
26
+ className?: string;
27
+ /** Stroke / fill colours (defaults below) */
28
+ stroke?: string;
29
+ fill?: string;
30
+ }
31
+ /**
32
+ * Draws a marquee rectangle while the user drags.
33
+ * Hook it into the interaction-manager with modeId = 'marqueeCapture'.
34
+ */
35
+ declare const MarqueeCapture: ({ pageIndex, scale, pageWidth, pageHeight, className, stroke, fill, }: MarqueeCaptureProps) => preact.JSX.Element | null;
36
+
37
+ export { MarqueeCapture, useCaptureCapability, useCapturePlugin };
@@ -0,0 +1,92 @@
1
+ // src/preact/hooks/use-capture.ts
2
+ import { useCapability, usePlugin } from "@embedpdf/core/preact";
3
+ import { CapturePlugin } from "@embedpdf/plugin-capture";
4
+ var useCaptureCapability = () => useCapability(CapturePlugin.id);
5
+ var useCapturePlugin = () => usePlugin(CapturePlugin.id);
6
+
7
+ // src/preact/components/marquee-capture.tsx
8
+ import { useEffect, useMemo, useRef, useState } from "preact/hooks";
9
+ import { usePointerHandlers } from "@embedpdf/plugin-interaction-manager/preact";
10
+ import { jsx } from "preact/jsx-runtime";
11
+ var MarqueeCapture = ({
12
+ pageIndex,
13
+ scale,
14
+ pageWidth,
15
+ pageHeight,
16
+ className,
17
+ stroke = "rgba(33,150,243,0.8)",
18
+ fill = "rgba(33,150,243,0.15)"
19
+ }) => {
20
+ const { provides: capture } = useCaptureCapability();
21
+ const { register } = usePointerHandlers({ modeId: "marqueeCapture", pageIndex });
22
+ const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
23
+ const startRef = useRef(null);
24
+ const [rect, setRect] = useState(null);
25
+ const pageWidthPDF = pageWidth / scale;
26
+ const pageHeightPDF = pageHeight / scale;
27
+ const handlers = useMemo(
28
+ () => ({
29
+ onPointerDown: (pos, evt) => {
30
+ startRef.current = pos;
31
+ setRect({ origin: { x: pos.x, y: pos.y }, size: { width: 0, height: 0 } });
32
+ evt.target?.setPointerCapture?.(evt.pointerId);
33
+ },
34
+ onPointerMove: (pos) => {
35
+ if (!startRef.current) return;
36
+ const curX = clamp(pos.x, 0, pageWidthPDF);
37
+ const curY = clamp(pos.y, 0, pageHeightPDF);
38
+ const { x: sx, y: sy } = startRef.current;
39
+ const left = Math.min(sx, curX);
40
+ const top = Math.min(sy, curY);
41
+ const width = Math.abs(curX - sx);
42
+ const height = Math.abs(curY - sy);
43
+ setRect({ origin: { x: left, y: top }, size: { width, height } });
44
+ },
45
+ onPointerUp: (_, evt) => {
46
+ if (rect && capture) {
47
+ const dragPx = Math.max(rect.size.width, rect.size.height) * scale;
48
+ if (dragPx > 5) {
49
+ capture.captureArea(pageIndex, rect);
50
+ }
51
+ }
52
+ startRef.current = null;
53
+ setRect(null);
54
+ evt.target?.releasePointerCapture?.(evt.pointerId);
55
+ },
56
+ onPointerCancel: (_, evt) => {
57
+ startRef.current = null;
58
+ setRect(null);
59
+ evt.target?.releasePointerCapture?.(evt.pointerId);
60
+ }
61
+ }),
62
+ [pageWidthPDF, pageWidthPDF, capture, scale, rect, pageIndex]
63
+ );
64
+ useEffect(() => {
65
+ if (!register) return;
66
+ return register(handlers);
67
+ }, [register, handlers]);
68
+ if (!rect) return null;
69
+ return /* @__PURE__ */ jsx(
70
+ "div",
71
+ {
72
+ style: {
73
+ position: "absolute",
74
+ pointerEvents: "none",
75
+ left: rect.origin.x * scale,
76
+ top: rect.origin.y * scale,
77
+ width: rect.size.width * scale,
78
+ height: rect.size.height * scale,
79
+ border: `1px solid ${stroke}`,
80
+ background: fill,
81
+ boxSizing: "border-box"
82
+ },
83
+ className
84
+ }
85
+ );
86
+ };
87
+ export {
88
+ MarqueeCapture,
89
+ useCaptureCapability,
90
+ useCapturePlugin
91
+ };
92
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/preact/hooks/use-capture.ts","../../src/preact/components/marquee-capture.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { CapturePlugin } from '@embedpdf/plugin-capture';\n\nexport const useCaptureCapability = () => useCapability<CapturePlugin>(CapturePlugin.id);\nexport const useCapturePlugin = () => usePlugin<CapturePlugin>(CapturePlugin.id);\n","/** @jsxImportSource preact */\nimport { useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport type { PointerEventHandlers } from '@embedpdf/plugin-interaction-manager';\nimport { usePointerHandlers } from '@embedpdf/plugin-interaction-manager/preact';\nimport { Rect } from '@embedpdf/models';\n\nimport { useCaptureCapability } from '../hooks/use-capture';\n\ninterface MarqueeCaptureProps {\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page */\n scale: number;\n /** Width of the page */\n pageWidth: number;\n /** Height of the page */\n pageHeight: number;\n /** Optional CSS class applied to the marquee rectangle */\n className?: string;\n /** Stroke / fill colours (defaults below) */\n stroke?: string;\n fill?: string;\n}\n\n/**\n * Draws a marquee rectangle while the user drags.\n * Hook it into the interaction-manager with modeId = 'marqueeCapture'.\n */\nexport const MarqueeCapture = ({\n pageIndex,\n scale,\n pageWidth,\n pageHeight,\n className,\n stroke = 'rgba(33,150,243,0.8)',\n fill = 'rgba(33,150,243,0.15)',\n}: MarqueeCaptureProps) => {\n /* ------------------------------------------------------------------ */\n /* capture capability */\n /* ------------------------------------------------------------------ */\n const { provides: capture } = useCaptureCapability();\n\n /* ------------------------------------------------------------------ */\n /* integration with interaction-manager */\n /* ------------------------------------------------------------------ */\n const { register } = usePointerHandlers({ modeId: 'marqueeCapture', pageIndex });\n\n /* ------------------------------------------------------------------ */\n /* helpers */\n /* ------------------------------------------------------------------ */\n const clamp = (v: number, min: number, max: number) => Math.max(min, Math.min(max, v));\n\n /* ------------------------------------------------------------------ */\n /* local state – start / current drag position */\n /* ------------------------------------------------------------------ */\n const startRef = useRef<{ x: number; y: number } | null>(null);\n const [rect, setRect] = useState<Rect | null>(null);\n\n /* page size in **PDF-space** (unscaled) ----------------------------- */\n const pageWidthPDF = pageWidth / scale;\n const pageHeightPDF = pageHeight / scale;\n\n /* ------------------------------------------------------------------ */\n /* pointer handlers */\n /* ------------------------------------------------------------------ */\n const handlers = useMemo<PointerEventHandlers<PointerEvent>>(\n () => ({\n onPointerDown: (pos, evt) => {\n startRef.current = pos;\n setRect({ origin: { x: pos.x, y: pos.y }, size: { width: 0, height: 0 } });\n (evt.target as HTMLElement)?.setPointerCapture?.(evt.pointerId);\n },\n onPointerMove: (pos) => {\n if (!startRef.current) return;\n /* clamp current position to the page bounds */\n const curX = clamp(pos.x, 0, pageWidthPDF);\n const curY = clamp(pos.y, 0, pageHeightPDF);\n\n const { x: sx, y: sy } = startRef.current;\n const left = Math.min(sx, curX);\n const top = Math.min(sy, curY);\n const width = Math.abs(curX - sx);\n const height = Math.abs(curY - sy);\n\n setRect({ origin: { x: left, y: top }, size: { width, height } });\n },\n onPointerUp: (_, evt) => {\n if (rect && capture) {\n const dragPx = Math.max(rect.size.width, rect.size.height) * scale;\n if (dragPx > 5) {\n // real drag → zoom to it\n capture.captureArea(pageIndex, rect);\n }\n }\n\n startRef.current = null;\n setRect(null);\n (evt.target as HTMLElement)?.releasePointerCapture?.(evt.pointerId);\n },\n onPointerCancel: (_, evt) => {\n startRef.current = null;\n setRect(null);\n (evt.target as HTMLElement)?.releasePointerCapture?.(evt.pointerId);\n },\n }),\n [pageWidthPDF, pageWidthPDF, capture, scale, rect, pageIndex],\n );\n\n /* register with the interaction-manager */\n useEffect(() => {\n if (!register) return;\n return register(handlers);\n }, [register, handlers]);\n\n /* ------------------------------------------------------------------ */\n /* render */\n /* ------------------------------------------------------------------ */\n if (!rect) return null; // nothing to draw\n\n return (\n <div\n /* Each page wrapper is position:relative, so absolute is fine */\n style={{\n position: 'absolute',\n pointerEvents: 'none',\n left: rect.origin.x * scale,\n top: rect.origin.y * scale,\n width: rect.size.width * scale,\n height: rect.size.height * scale,\n border: `1px solid ${stroke}`,\n background: fill,\n boxSizing: 'border-box',\n }}\n className={className}\n />\n );\n};\n"],"mappings":";AAAA,SAAS,eAAe,iBAAiB;AACzC,SAAS,qBAAqB;AAEvB,IAAM,uBAAuB,MAAM,cAA6B,cAAc,EAAE;AAChF,IAAM,mBAAmB,MAAM,UAAyB,cAAc,EAAE;;;ACH/E,SAAS,WAAW,SAAS,QAAQ,gBAAgB;AAErD,SAAS,0BAA0B;AAqH/B;AA5FG,IAAM,iBAAiB,CA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A,MACA,aAAa,CAAC,GAAG,QAAQ;AACvB,YAAI,QAAQ,SAAS;AACnB,gBAAM,SAAS,KAAK,IAAI,KAAK,KAAK,OAAO,KAAK,KAAK,MAAM,IAAI;AAC7D,cAAI,SAAS,GAAG;AAEd,oBAAQ,YAAY,WAAW,IAAI;AAAA,UACrC;AAAA,QACF;AAEA,iBAAS,UAAU;AACnB,gBAAQ,IAAI;AACZ,QAAC,IAAI,QAAwB,wBAAwB,IAAI,SAAS;AAAA,MACpE;AAAA,MACA,iBAAiB,CAAC,GAAG,QAAQ;AAC3B,iBAAS,UAAU;AACnB,gBAAQ,IAAI;AACZ,QAAC,IAAI,QAAwB,wBAAwB,IAAI,SAAS;AAAA,MACpE;AAAA,IACF;AAAA,IACA,CAAC,cAAc,cAAc,SAAS,OAAO,MAAM,SAAS;AAAA,EAC9D;AAGA,YAAU,MAAM;AACd,QAAI,CAAC,SAAU;AACf,WAAO,SAAS,QAAQ;AAAA,EAC1B,GAAG,CAAC,UAAU,QAAQ,CAAC;AAKvB,MAAI,CAAC,KAAM,QAAO;AAElB,SACE;AAAA,IAAC;AAAA;AAAA,MAEC,OAAO;AAAA,QACL,UAAU;AAAA,QACV,eAAe;AAAA,QACf,MAAM,KAAK,OAAO,IAAI;AAAA,QACtB,KAAK,KAAK,OAAO,IAAI;AAAA,QACrB,OAAO,KAAK,KAAK,QAAQ;AAAA,QACzB,QAAQ,KAAK,KAAK,SAAS;AAAA,QAC3B,QAAQ,aAAa,MAAM;AAAA,QAC3B,YAAY;AAAA,QACZ,WAAW;AAAA,MACb;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;","names":[]}
@@ -0,0 +1,121 @@
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/react/index.ts
21
+ var react_exports = {};
22
+ __export(react_exports, {
23
+ MarqueeCapture: () => MarqueeCapture,
24
+ useCaptureCapability: () => useCaptureCapability,
25
+ useCapturePlugin: () => useCapturePlugin
26
+ });
27
+ module.exports = __toCommonJS(react_exports);
28
+
29
+ // src/react/hooks/use-capture.ts
30
+ var import_react = require("@embedpdf/core/react");
31
+ var import_plugin_capture = require("@embedpdf/plugin-capture");
32
+ var useCaptureCapability = () => (0, import_react.useCapability)(import_plugin_capture.CapturePlugin.id);
33
+ var useCapturePlugin = () => (0, import_react.usePlugin)(import_plugin_capture.CapturePlugin.id);
34
+
35
+ // src/react/components/marquee-capture.tsx
36
+ var import_react2 = require("react");
37
+ var import_react3 = require("@embedpdf/plugin-interaction-manager/react");
38
+ var import_jsx_runtime = require("react/jsx-runtime");
39
+ var MarqueeCapture = ({
40
+ pageIndex,
41
+ scale,
42
+ pageWidth,
43
+ pageHeight,
44
+ className,
45
+ stroke = "rgba(33,150,243,0.8)",
46
+ fill = "rgba(33,150,243,0.15)"
47
+ }) => {
48
+ const { provides: capture } = useCaptureCapability();
49
+ const { register } = (0, import_react3.usePointerHandlers)({ modeId: "marqueeCapture", pageIndex });
50
+ const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
51
+ const startRef = (0, import_react2.useRef)(null);
52
+ const [rect, setRect] = (0, import_react2.useState)(null);
53
+ const pageWidthPDF = pageWidth / scale;
54
+ const pageHeightPDF = pageHeight / scale;
55
+ const handlers = (0, import_react2.useMemo)(
56
+ () => ({
57
+ onPointerDown: (pos, evt) => {
58
+ startRef.current = pos;
59
+ setRect({ origin: { x: pos.x, y: pos.y }, size: { width: 0, height: 0 } });
60
+ evt.target?.setPointerCapture?.(evt.pointerId);
61
+ },
62
+ onPointerMove: (pos) => {
63
+ if (!startRef.current) return;
64
+ const curX = clamp(pos.x, 0, pageWidthPDF);
65
+ const curY = clamp(pos.y, 0, pageHeightPDF);
66
+ const { x: sx, y: sy } = startRef.current;
67
+ const left = Math.min(sx, curX);
68
+ const top = Math.min(sy, curY);
69
+ const width = Math.abs(curX - sx);
70
+ const height = Math.abs(curY - sy);
71
+ setRect({ origin: { x: left, y: top }, size: { width, height } });
72
+ },
73
+ onPointerUp: (_, evt) => {
74
+ if (rect && capture) {
75
+ const dragPx = Math.max(rect.size.width, rect.size.height) * scale;
76
+ if (dragPx > 5) {
77
+ capture.captureArea(pageIndex, rect);
78
+ }
79
+ }
80
+ startRef.current = null;
81
+ setRect(null);
82
+ evt.target?.releasePointerCapture?.(evt.pointerId);
83
+ },
84
+ onPointerCancel: (_, evt) => {
85
+ startRef.current = null;
86
+ setRect(null);
87
+ evt.target?.releasePointerCapture?.(evt.pointerId);
88
+ }
89
+ }),
90
+ [pageWidthPDF, pageWidthPDF, capture, scale, rect, pageIndex]
91
+ );
92
+ (0, import_react2.useEffect)(() => {
93
+ if (!register) return;
94
+ return register(handlers);
95
+ }, [register, handlers]);
96
+ if (!rect) return null;
97
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
98
+ "div",
99
+ {
100
+ style: {
101
+ position: "absolute",
102
+ pointerEvents: "none",
103
+ left: rect.origin.x * scale,
104
+ top: rect.origin.y * scale,
105
+ width: rect.size.width * scale,
106
+ height: rect.size.height * scale,
107
+ border: `1px solid ${stroke}`,
108
+ background: fill,
109
+ boxSizing: "border-box"
110
+ },
111
+ className
112
+ }
113
+ );
114
+ };
115
+ // Annotate the CommonJS export names for ESM import in node:
116
+ 0 && (module.exports = {
117
+ MarqueeCapture,
118
+ useCaptureCapability,
119
+ useCapturePlugin
120
+ });
121
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/react/index.ts","../../src/react/hooks/use-capture.ts","../../src/react/components/marquee-capture.tsx"],"sourcesContent":["export * from './hooks';\nexport * from './components';\n","import { useCapability, usePlugin } from '@embedpdf/core/react';\nimport { CapturePlugin } from '@embedpdf/plugin-capture';\n\nexport const useCaptureCapability = () => useCapability<CapturePlugin>(CapturePlugin.id);\nexport const useCapturePlugin = () => usePlugin<CapturePlugin>(CapturePlugin.id);\n","import { useEffect, useMemo, useRef, useState } from 'react';\nimport type { PointerEventHandlers } from '@embedpdf/plugin-interaction-manager';\nimport { usePointerHandlers } from '@embedpdf/plugin-interaction-manager/react';\nimport { Rect } from '@embedpdf/models';\n\nimport { useCaptureCapability } from '../hooks/use-capture';\n\ninterface MarqueeCaptureProps {\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page */\n scale: number;\n /** Width of the page */\n pageWidth: number;\n /** Height of the page */\n pageHeight: number;\n /** Optional CSS class applied to the marquee rectangle */\n className?: string;\n /** Stroke / fill colours (defaults below) */\n stroke?: string;\n fill?: string;\n}\n\n/**\n * Draws a marquee rectangle while the user drags.\n * Hook it into the interaction-manager with modeId = 'marqueeCapture'.\n */\nexport const MarqueeCapture = ({\n pageIndex,\n scale,\n pageWidth,\n pageHeight,\n className,\n stroke = 'rgba(33,150,243,0.8)',\n fill = 'rgba(33,150,243,0.15)',\n}: MarqueeCaptureProps) => {\n /* ------------------------------------------------------------------ */\n /* capture capability */\n /* ------------------------------------------------------------------ */\n const { provides: capture } = useCaptureCapability();\n\n /* ------------------------------------------------------------------ */\n /* integration with interaction-manager */\n /* ------------------------------------------------------------------ */\n const { register } = usePointerHandlers({ modeId: 'marqueeCapture', pageIndex });\n\n /* ------------------------------------------------------------------ */\n /* helpers */\n /* ------------------------------------------------------------------ */\n const clamp = (v: number, min: number, max: number) => Math.max(min, Math.min(max, v));\n\n /* ------------------------------------------------------------------ */\n /* local state – start / current drag position */\n /* ------------------------------------------------------------------ */\n const startRef = useRef<{ x: number; y: number } | null>(null);\n const [rect, setRect] = useState<Rect | null>(null);\n\n /* page size in **PDF-space** (unscaled) ----------------------------- */\n const pageWidthPDF = pageWidth / scale;\n const pageHeightPDF = pageHeight / scale;\n\n /* ------------------------------------------------------------------ */\n /* pointer handlers */\n /* ------------------------------------------------------------------ */\n const handlers = useMemo<PointerEventHandlers<PointerEvent>>(\n () => ({\n onPointerDown: (pos, evt) => {\n startRef.current = pos;\n setRect({ origin: { x: pos.x, y: pos.y }, size: { width: 0, height: 0 } });\n (evt.target as HTMLElement)?.setPointerCapture?.(evt.pointerId);\n },\n onPointerMove: (pos) => {\n if (!startRef.current) return;\n /* clamp current position to the page bounds */\n const curX = clamp(pos.x, 0, pageWidthPDF);\n const curY = clamp(pos.y, 0, pageHeightPDF);\n\n const { x: sx, y: sy } = startRef.current;\n const left = Math.min(sx, curX);\n const top = Math.min(sy, curY);\n const width = Math.abs(curX - sx);\n const height = Math.abs(curY - sy);\n\n setRect({ origin: { x: left, y: top }, size: { width, height } });\n },\n onPointerUp: (_, evt) => {\n if (rect && capture) {\n const dragPx = Math.max(rect.size.width, rect.size.height) * scale;\n if (dragPx > 5) {\n // real drag → zoom to it\n capture.captureArea(pageIndex, rect);\n }\n }\n\n startRef.current = null;\n setRect(null);\n (evt.target as HTMLElement)?.releasePointerCapture?.(evt.pointerId);\n },\n onPointerCancel: (_, evt) => {\n startRef.current = null;\n setRect(null);\n (evt.target as HTMLElement)?.releasePointerCapture?.(evt.pointerId);\n },\n }),\n [pageWidthPDF, pageWidthPDF, capture, scale, rect, pageIndex],\n );\n\n /* register with the interaction-manager */\n useEffect(() => {\n if (!register) return;\n return register(handlers);\n }, [register, handlers]);\n\n /* ------------------------------------------------------------------ */\n /* render */\n /* ------------------------------------------------------------------ */\n if (!rect) return null; // nothing to draw\n\n return (\n <div\n /* Each page wrapper is position:relative, so absolute is fine */\n style={{\n position: 'absolute',\n pointerEvents: 'none',\n left: rect.origin.x * scale,\n top: rect.origin.y * scale,\n width: rect.size.width * scale,\n height: rect.size.height * scale,\n border: `1px solid ${stroke}`,\n background: fill,\n boxSizing: 'border-box',\n }}\n className={className}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAyC;AACzC,4BAA8B;AAEvB,IAAM,uBAAuB,UAAM,4BAA6B,oCAAc,EAAE;AAChF,IAAM,mBAAmB,UAAM,wBAAyB,oCAAc,EAAE;;;ACJ/E,IAAAA,gBAAqD;AAErD,IAAAA,gBAAmC;AAqH/B;AA5FG,IAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,OAAO;AACT,MAA2B;AAIzB,QAAM,EAAE,UAAU,QAAQ,IAAI,qBAAqB;AAKnD,QAAM,EAAE,SAAS,QAAI,kCAAmB,EAAE,QAAQ,kBAAkB,UAAU,CAAC;AAK/E,QAAM,QAAQ,CAAC,GAAW,KAAa,QAAgB,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC,CAAC;AAKrF,QAAM,eAAW,sBAAwC,IAAI;AAC7D,QAAM,CAAC,MAAM,OAAO,QAAI,wBAAsB,IAAI;AAGlD,QAAM,eAAe,YAAY;AACjC,QAAM,gBAAgB,aAAa;AAKnC,QAAM,eAAW;AAAA,IACf,OAAO;AAAA,MACL,eAAe,CAAC,KAAK,QAAQ;AAC3B,iBAAS,UAAU;AACnB,gBAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,GAAG,GAAG,IAAI,EAAE,GAAG,MAAM,EAAE,OAAO,GAAG,QAAQ,EAAE,EAAE,CAAC;AACzE,QAAC,IAAI,QAAwB,oBAAoB,IAAI,SAAS;AAAA,MAChE;AAAA,MACA,eA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e;AAAA,QACf,MAAM,KAAK,OAAO,IAAI;AAAA,QACtB,KAAK,KAAK,OAAO,IAAI;AAAA,QACrB,OAAO,KAAK,KAAK,QAAQ;AAAA,QACzB,QAAQ,KAAK,KAAK,SAAS;AAAA,QAC3B,QAAQ,aAAa,MAAM;AAAA,QAC3B,YAAY;AAAA,QACZ,WAAW;AAAA,MACb;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;","names":["import_react"]}
@@ -0,0 +1,37 @@
1
+ import * as _embedpdf_plugin_capture from '@embedpdf/plugin-capture';
2
+ import { CapturePlugin } from '@embedpdf/plugin-capture';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ declare const useCaptureCapability: () => {
6
+ provides: Readonly<_embedpdf_plugin_capture.CaptureCapability> | null;
7
+ isLoading: boolean;
8
+ ready: Promise<void>;
9
+ };
10
+ declare const useCapturePlugin: () => {
11
+ plugin: CapturePlugin | null;
12
+ isLoading: boolean;
13
+ ready: Promise<void>;
14
+ };
15
+
16
+ interface MarqueeCaptureProps {
17
+ /** Index of the page this layer lives on */
18
+ pageIndex: number;
19
+ /** Scale of the page */
20
+ scale: number;
21
+ /** Width of the page */
22
+ pageWidth: number;
23
+ /** Height of the page */
24
+ pageHeight: number;
25
+ /** Optional CSS class applied to the marquee rectangle */
26
+ className?: string;
27
+ /** Stroke / fill colours (defaults below) */
28
+ stroke?: string;
29
+ fill?: string;
30
+ }
31
+ /**
32
+ * Draws a marquee rectangle while the user drags.
33
+ * Hook it into the interaction-manager with modeId = 'marqueeCapture'.
34
+ */
35
+ declare const MarqueeCapture: ({ pageIndex, scale, pageWidth, pageHeight, className, stroke, fill, }: MarqueeCaptureProps) => react_jsx_runtime.JSX.Element | null;
36
+
37
+ export { MarqueeCapture, useCaptureCapability, useCapturePlugin };
@@ -0,0 +1,37 @@
1
+ import * as _embedpdf_plugin_capture from '@embedpdf/plugin-capture';
2
+ import { CapturePlugin } from '@embedpdf/plugin-capture';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ declare const useCaptureCapability: () => {
6
+ provides: Readonly<_embedpdf_plugin_capture.CaptureCapability> | null;
7
+ isLoading: boolean;
8
+ ready: Promise<void>;
9
+ };
10
+ declare const useCapturePlugin: () => {
11
+ plugin: CapturePlugin | null;
12
+ isLoading: boolean;
13
+ ready: Promise<void>;
14
+ };
15
+
16
+ interface MarqueeCaptureProps {
17
+ /** Index of the page this layer lives on */
18
+ pageIndex: number;
19
+ /** Scale of the page */
20
+ scale: number;
21
+ /** Width of the page */
22
+ pageWidth: number;
23
+ /** Height of the page */
24
+ pageHeight: number;
25
+ /** Optional CSS class applied to the marquee rectangle */
26
+ className?: string;
27
+ /** Stroke / fill colours (defaults below) */
28
+ stroke?: string;
29
+ fill?: string;
30
+ }
31
+ /**
32
+ * Draws a marquee rectangle while the user drags.
33
+ * Hook it into the interaction-manager with modeId = 'marqueeCapture'.
34
+ */
35
+ declare const MarqueeCapture: ({ pageIndex, scale, pageWidth, pageHeight, className, stroke, fill, }: MarqueeCaptureProps) => react_jsx_runtime.JSX.Element | null;
36
+
37
+ export { MarqueeCapture, useCaptureCapability, useCapturePlugin };
@@ -0,0 +1,92 @@
1
+ // src/react/hooks/use-capture.ts
2
+ import { useCapability, usePlugin } from "@embedpdf/core/react";
3
+ import { CapturePlugin } from "@embedpdf/plugin-capture";
4
+ var useCaptureCapability = () => useCapability(CapturePlugin.id);
5
+ var useCapturePlugin = () => usePlugin(CapturePlugin.id);
6
+
7
+ // src/react/components/marquee-capture.tsx
8
+ import { useEffect, useMemo, useRef, useState } from "react";
9
+ import { usePointerHandlers } from "@embedpdf/plugin-interaction-manager/react";
10
+ import { jsx } from "react/jsx-runtime";
11
+ var MarqueeCapture = ({
12
+ pageIndex,
13
+ scale,
14
+ pageWidth,
15
+ pageHeight,
16
+ className,
17
+ stroke = "rgba(33,150,243,0.8)",
18
+ fill = "rgba(33,150,243,0.15)"
19
+ }) => {
20
+ const { provides: capture } = useCaptureCapability();
21
+ const { register } = usePointerHandlers({ modeId: "marqueeCapture", pageIndex });
22
+ const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
23
+ const startRef = useRef(null);
24
+ const [rect, setRect] = useState(null);
25
+ const pageWidthPDF = pageWidth / scale;
26
+ const pageHeightPDF = pageHeight / scale;
27
+ const handlers = useMemo(
28
+ () => ({
29
+ onPointerDown: (pos, evt) => {
30
+ startRef.current = pos;
31
+ setRect({ origin: { x: pos.x, y: pos.y }, size: { width: 0, height: 0 } });
32
+ evt.target?.setPointerCapture?.(evt.pointerId);
33
+ },
34
+ onPointerMove: (pos) => {
35
+ if (!startRef.current) return;
36
+ const curX = clamp(pos.x, 0, pageWidthPDF);
37
+ const curY = clamp(pos.y, 0, pageHeightPDF);
38
+ const { x: sx, y: sy } = startRef.current;
39
+ const left = Math.min(sx, curX);
40
+ const top = Math.min(sy, curY);
41
+ const width = Math.abs(curX - sx);
42
+ const height = Math.abs(curY - sy);
43
+ setRect({ origin: { x: left, y: top }, size: { width, height } });
44
+ },
45
+ onPointerUp: (_, evt) => {
46
+ if (rect && capture) {
47
+ const dragPx = Math.max(rect.size.width, rect.size.height) * scale;
48
+ if (dragPx > 5) {
49
+ capture.captureArea(pageIndex, rect);
50
+ }
51
+ }
52
+ startRef.current = null;
53
+ setRect(null);
54
+ evt.target?.releasePointerCapture?.(evt.pointerId);
55
+ },
56
+ onPointerCancel: (_, evt) => {
57
+ startRef.current = null;
58
+ setRect(null);
59
+ evt.target?.releasePointerCapture?.(evt.pointerId);
60
+ }
61
+ }),
62
+ [pageWidthPDF, pageWidthPDF, capture, scale, rect, pageIndex]
63
+ );
64
+ useEffect(() => {
65
+ if (!register) return;
66
+ return register(handlers);
67
+ }, [register, handlers]);
68
+ if (!rect) return null;
69
+ return /* @__PURE__ */ jsx(
70
+ "div",
71
+ {
72
+ style: {
73
+ position: "absolute",
74
+ pointerEvents: "none",
75
+ left: rect.origin.x * scale,
76
+ top: rect.origin.y * scale,
77
+ width: rect.size.width * scale,
78
+ height: rect.size.height * scale,
79
+ border: `1px solid ${stroke}`,
80
+ background: fill,
81
+ boxSizing: "border-box"
82
+ },
83
+ className
84
+ }
85
+ );
86
+ };
87
+ export {
88
+ MarqueeCapture,
89
+ useCaptureCapability,
90
+ useCapturePlugin
91
+ };
92
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/react/hooks/use-capture.ts","../../src/react/components/marquee-capture.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/react';\nimport { CapturePlugin } from '@embedpdf/plugin-capture';\n\nexport const useCaptureCapability = () => useCapability<CapturePlugin>(CapturePlugin.id);\nexport const useCapturePlugin = () => usePlugin<CapturePlugin>(CapturePlugin.id);\n","import { useEffect, useMemo, useRef, useState } from 'react';\nimport type { PointerEventHandlers } from '@embedpdf/plugin-interaction-manager';\nimport { usePointerHandlers } from '@embedpdf/plugin-interaction-manager/react';\nimport { Rect } from '@embedpdf/models';\n\nimport { useCaptureCapability } from '../hooks/use-capture';\n\ninterface MarqueeCaptureProps {\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page */\n scale: number;\n /** Width of the page */\n pageWidth: number;\n /** Height of the page */\n pageHeight: number;\n /** Optional CSS class applied to the marquee rectangle */\n className?: string;\n /** Stroke / fill colours (defaults below) */\n stroke?: string;\n fill?: string;\n}\n\n/**\n * Draws a marquee rectangle while the user drags.\n * Hook it into the interaction-manager with modeId = 'marqueeCapture'.\n */\nexport const MarqueeCapture = ({\n pageIndex,\n scale,\n pageWidth,\n pageHeight,\n className,\n stroke = 'rgba(33,150,243,0.8)',\n fill = 'rgba(33,150,243,0.15)',\n}: MarqueeCaptureProps) => {\n /* ------------------------------------------------------------------ */\n /* capture capability */\n /* ------------------------------------------------------------------ */\n const { provides: capture } = useCaptureCapability();\n\n /* ------------------------------------------------------------------ */\n /* integration with interaction-manager */\n /* ------------------------------------------------------------------ */\n const { register } = usePointerHandlers({ modeId: 'marqueeCapture', pageIndex });\n\n /* ------------------------------------------------------------------ */\n /* helpers */\n /* ------------------------------------------------------------------ */\n const clamp = (v: number, min: number, max: number) => Math.max(min, Math.min(max, v));\n\n /* ------------------------------------------------------------------ */\n /* local state – start / current drag position */\n /* ------------------------------------------------------------------ */\n const startRef = useRef<{ x: number; y: number } | null>(null);\n const [rect, setRect] = useState<Rect | null>(null);\n\n /* page size in **PDF-space** (unscaled) ----------------------------- */\n const pageWidthPDF = pageWidth / scale;\n const pageHeightPDF = pageHeight / scale;\n\n /* ------------------------------------------------------------------ */\n /* pointer handlers */\n /* ------------------------------------------------------------------ */\n const handlers = useMemo<PointerEventHandlers<PointerEvent>>(\n () => ({\n onPointerDown: (pos, evt) => {\n startRef.current = pos;\n setRect({ origin: { x: pos.x, y: pos.y }, size: { width: 0, height: 0 } });\n (evt.target as HTMLElement)?.setPointerCapture?.(evt.pointerId);\n },\n onPointerMove: (pos) => {\n if (!startRef.current) return;\n /* clamp current position to the page bounds */\n const curX = clamp(pos.x, 0, pageWidthPDF);\n const curY = clamp(pos.y, 0, pageHeightPDF);\n\n const { x: sx, y: sy } = startRef.current;\n const left = Math.min(sx, curX);\n const top = Math.min(sy, curY);\n const width = Math.abs(curX - sx);\n const height = Math.abs(curY - sy);\n\n setRect({ origin: { x: left, y: top }, size: { width, height } });\n },\n onPointerUp: (_, evt) => {\n if (rect && capture) {\n const dragPx = Math.max(rect.size.width, rect.size.height) * scale;\n if (dragPx > 5) {\n // real drag → zoom to it\n capture.captureArea(pageIndex, rect);\n }\n }\n\n startRef.current = null;\n setRect(null);\n (evt.target as HTMLElement)?.releasePointerCapture?.(evt.pointerId);\n },\n onPointerCancel: (_, evt) => {\n startRef.current = null;\n setRect(null);\n (evt.target as HTMLElement)?.releasePointerCapture?.(evt.pointerId);\n },\n }),\n [pageWidthPDF, pageWidthPDF, capture, scale, rect, pageIndex],\n );\n\n /* register with the interaction-manager */\n useEffect(() => {\n if (!register) return;\n return register(handlers);\n }, [register, handlers]);\n\n /* ------------------------------------------------------------------ */\n /* render */\n /* ------------------------------------------------------------------ */\n if (!rect) return null; // nothing to draw\n\n return (\n <div\n /* Each page wrapper is position:relative, so absolute is fine */\n style={{\n position: 'absolute',\n pointerEvents: 'none',\n left: rect.origin.x * scale,\n top: rect.origin.y * scale,\n width: rect.size.width * scale,\n height: rect.size.height * scale,\n border: `1px solid ${stroke}`,\n background: fill,\n boxSizing: 'border-box',\n }}\n className={className}\n />\n );\n};\n"],"mappings":";AAAA,SAAS,eAAe,iBAAiB;AACzC,SAAS,qBAAqB;AAEvB,IAAM,uBAAuB,MAAM,cAA6B,cAAc,EAAE;AAChF,IAAM,mBAAmB,MAAM,UAAyB,cAAc,EAAE;;;ACJ/E,SAAS,WAAW,SAAS,QAAQ,gBAAgB;AAErD,SAAS,0BAA0B;AAqH/B;AA5FG,IAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,OAAO;AACT,MAA2B;AAIzB,QAAM,EAAE,UAAU,QAAQ,IAAI,qBAAqB;AAKnD,QAAM,EAAE,SAAS,IAAI,mBAAmB,EAAE,QAAQ,kBAAkB,UAAU,CAAC;AAK/E,QAAM,QAAQ,CAAC,GAAW,KAAa,QAAgB,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC,CAAC;AAKrF,QAAM,WAAW,OAAwC,IAAI;AAC7D,QAAM,CAAC,MAAM,OAAO,IAAI,SAAsB,IAAI;AAGlD,QAAM,eAAe,YAAY;AACjC,QAAM,gBAAgB,aAAa;AAKnC,QAAM,WAAW;AAAA,IACf,OAAO;AAAA,MACL,eAAe,CAAC,KAAK,QAAQ;AAC3B,iBAAS,UAAU;AACnB,gBAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,GAAG,GAAG,IAAI,EAAE,GAAG,MAAM,EAAE,OAAO,GAAG,QAAQ,EAAE,EAAE,CAAC;AACzE,QAAC,IAAI,QAAwB,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,MAEC,OAAO;AAAA,QACL,UAAU;AAAA,QACV,eAAe;AAAA,QACf,MAAM,KAAK,OAAO,IAAI;AAAA,QACtB,KAAK,KAAK,OAAO,IAAI;AAAA,QACrB,OAAO,KAAK,KAAK,QAAQ;AAAA,QACzB,QAAQ,KAAK,KAAK,SAAS;AAAA,QAC3B,QAAQ,aAAa,MAAM;AAAA,QAC3B,YAAY;AAAA,QACZ,WAAW;AAAA,MACb;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;","names":[]}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@embedpdf/plugin-capture",
3
+ "version": "1.0.5",
4
+ "type": "module",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs"
13
+ },
14
+ "./preact": {
15
+ "types": "./dist/preact/index.d.ts",
16
+ "import": "./dist/preact/index.js",
17
+ "require": "./dist/preact/index.cjs"
18
+ },
19
+ "./react": {
20
+ "types": "./dist/react/index.d.ts",
21
+ "import": "./dist/react/index.js",
22
+ "require": "./dist/react/index.cjs"
23
+ }
24
+ },
25
+ "dependencies": {
26
+ "@embedpdf/models": "1.0.5"
27
+ },
28
+ "devDependencies": {
29
+ "@types/react": "^18.2.0",
30
+ "tsup": "^8.0.0",
31
+ "typescript": "^5.0.0",
32
+ "@embedpdf/core": "1.0.5",
33
+ "@embedpdf/plugin-render": "1.0.5",
34
+ "@embedpdf/plugin-interaction-manager": "1.0.5"
35
+ },
36
+ "peerDependencies": {
37
+ "react": ">=16.8.0",
38
+ "react-dom": ">=16.8.0",
39
+ "preact": "^10.26.4",
40
+ "@embedpdf/core": "1.0.5",
41
+ "@embedpdf/plugin-interaction-manager": "1.0.5"
42
+ },
43
+ "files": [
44
+ "dist",
45
+ "README.md"
46
+ ],
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "https://github.com/embedpdf/embed-pdf-viewer",
50
+ "directory": "packages/plugin-download"
51
+ },
52
+ "homepage": "https://www.embedpdf.com/docs",
53
+ "bugs": {
54
+ "url": "https://github.com/embedpdf/embed-pdf-viewer/issues"
55
+ },
56
+ "publishConfig": {
57
+ "access": "public"
58
+ },
59
+ "scripts": {
60
+ "build": "PROJECT_CWD=$(pwd) pnpm -w p:build",
61
+ "build:watch": "PROJECT_CWD=$(pwd) pnpm -w p:build:watch",
62
+ "clean": "PROJECT_CWD=$(pwd) pnpm -w p:clean",
63
+ "lint": "PROJECT_CWD=$(pwd) pnpm -w p:lint",
64
+ "lint:fix": "PROJECT_CWD=$(pwd) pnpm -w p:lint:fix",
65
+ "typecheck": "PROJECT_CWD=$(pwd) pnpm -w p:typecheck"
66
+ }
67
+ }