@embedpdf/plugin-capture 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -129
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -46
- package/dist/index.js +21 -19
- package/dist/index.js.map +1 -1
- package/dist/lib/capture-plugin.d.ts +16 -0
- package/dist/lib/index.d.ts +7 -0
- package/dist/lib/manifest.d.ts +4 -0
- package/dist/lib/types.d.ts +23 -0
- package/dist/preact/adapter.d.ts +1 -0
- package/dist/preact/core.d.ts +1 -0
- package/dist/preact/index.cjs +2 -121
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.d.ts +1 -37
- package/dist/preact/index.js +12 -12
- package/dist/preact/index.js.map +1 -1
- package/dist/preact/interaction-manager.d.ts +1 -0
- package/dist/react/adapter.d.ts +1 -0
- package/dist/react/core.d.ts +1 -0
- package/dist/react/index.cjs +2 -121
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.ts +1 -37
- package/dist/react/index.js +12 -12
- package/dist/react/index.js.map +1 -1
- package/dist/react/interaction-manager.d.ts +1 -0
- package/dist/shared-preact/components/index.d.ts +1 -0
- package/dist/shared-preact/components/marquee-capture.d.ts +21 -0
- package/dist/shared-preact/hooks/index.d.ts +1 -0
- package/dist/shared-preact/hooks/use-capture.d.ts +11 -0
- package/dist/shared-preact/index.d.ts +2 -0
- package/dist/shared-react/components/index.d.ts +1 -0
- package/dist/shared-react/components/marquee-capture.d.ts +21 -0
- package/dist/shared-react/hooks/index.d.ts +1 -0
- package/dist/shared-react/hooks/use-capture.d.ts +11 -0
- package/dist/shared-react/index.d.ts +2 -0
- package/package.json +16 -14
- package/dist/index.d.cts +0 -46
- package/dist/preact/index.d.cts +0 -37
- package/dist/react/index.d.cts +0 -37
package/dist/preact/index.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
// src/preact/hooks/use-capture.ts
|
|
2
1
|
import { useCapability, usePlugin } from "@embedpdf/core/preact";
|
|
3
2
|
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
3
|
import { jsx } from "preact/jsx-runtime";
|
|
11
|
-
|
|
4
|
+
import { useRef, useState, useMemo, useEffect } from "preact/hooks";
|
|
5
|
+
import { usePointerHandlers } from "@embedpdf/plugin-interaction-manager/preact";
|
|
6
|
+
const useCaptureCapability = () => useCapability(CapturePlugin.id);
|
|
7
|
+
const useCapturePlugin = () => usePlugin(CapturePlugin.id);
|
|
8
|
+
const MarqueeCapture = ({
|
|
12
9
|
pageIndex,
|
|
13
10
|
scale,
|
|
14
11
|
pageWidth,
|
|
@@ -27,9 +24,10 @@ var MarqueeCapture = ({
|
|
|
27
24
|
const handlers = useMemo(
|
|
28
25
|
() => ({
|
|
29
26
|
onPointerDown: (pos, evt) => {
|
|
27
|
+
var _a, _b;
|
|
30
28
|
startRef.current = pos;
|
|
31
29
|
setRect({ origin: { x: pos.x, y: pos.y }, size: { width: 0, height: 0 } });
|
|
32
|
-
evt.target
|
|
30
|
+
(_b = (_a = evt.target) == null ? void 0 : _a.setPointerCapture) == null ? void 0 : _b.call(_a, evt.pointerId);
|
|
33
31
|
},
|
|
34
32
|
onPointerMove: (pos) => {
|
|
35
33
|
if (!startRef.current) return;
|
|
@@ -43,6 +41,7 @@ var MarqueeCapture = ({
|
|
|
43
41
|
setRect({ origin: { x: left, y: top }, size: { width, height } });
|
|
44
42
|
},
|
|
45
43
|
onPointerUp: (_, evt) => {
|
|
44
|
+
var _a, _b;
|
|
46
45
|
if (rect && capture) {
|
|
47
46
|
const dragPx = Math.max(rect.size.width, rect.size.height) * scale;
|
|
48
47
|
if (dragPx > 5) {
|
|
@@ -51,12 +50,13 @@ var MarqueeCapture = ({
|
|
|
51
50
|
}
|
|
52
51
|
startRef.current = null;
|
|
53
52
|
setRect(null);
|
|
54
|
-
evt.target
|
|
53
|
+
(_b = (_a = evt.target) == null ? void 0 : _a.releasePointerCapture) == null ? void 0 : _b.call(_a, evt.pointerId);
|
|
55
54
|
},
|
|
56
55
|
onPointerCancel: (_, evt) => {
|
|
56
|
+
var _a, _b;
|
|
57
57
|
startRef.current = null;
|
|
58
58
|
setRect(null);
|
|
59
|
-
evt.target
|
|
59
|
+
(_b = (_a = evt.target) == null ? void 0 : _a.releasePointerCapture) == null ? void 0 : _b.call(_a, evt.pointerId);
|
|
60
60
|
}
|
|
61
61
|
}),
|
|
62
62
|
[pageWidthPDF, pageWidthPDF, capture, scale, rect, pageIndex]
|
|
@@ -89,4 +89,4 @@ export {
|
|
|
89
89
|
useCaptureCapability,
|
|
90
90
|
useCapturePlugin
|
|
91
91
|
};
|
|
92
|
-
//# sourceMappingURL=index.js.map
|
|
92
|
+
//# sourceMappingURL=index.js.map
|
package/dist/preact/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-capture.ts","../../src/shared/components/marquee-capture.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\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 '@framework';\nimport type { PointerEventHandlers } from '@embedpdf/plugin-interaction-manager';\nimport { usePointerHandlers } from '@embedpdf/plugin-interaction-manager/@framework';\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"],"names":[],"mappings":";;;;;AAGO,MAAM,uBAAuB,MAAM,cAA6B,cAAc,EAAE;AAChF,MAAM,mBAAmB,MAAM,UAAyB,cAAc,EAAE;ACuBxE,MAAM,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;AAK7C,QAAA,EAAE,aAAa,mBAAmB,EAAE,QAAQ,kBA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AAU;AACnB,gBAAQ,IAAI;AACX,wBAAI,WAAJ,mBAA4B,0BAA5B,4BAAoD,IAAI;AAAA,MAC3D;AAAA,MACA,iBAAiB,CAAC,GAAG,QAAQ;;AAC3B,iBAAS,UAAU;AACnB,gBAAQ,IAAI;AACX,wBAAI,WAAJ,mBAA4B,0BAA5B,4BAAoD,IAAI;AAAA,MAAS;AAAA,IACpE;AAAA,IAEF,CAAC,cAAc,cAAc,SAAS,OAAO,MAAM,SAAS;AAAA,EAC9D;AAGA,YAAU,MAAM;AACd,QAAI,CAAC,SAAU;AACf,WAAO,SAAS,QAAQ;AAAA,EAAA,GACvB,CAAC,UAAU,QAAQ,CAAC;AAKnB,MAAA,CAAC,KAAa,QAAA;AAGhB,SAAA;AAAA,IAAC;AAAA,IAAA;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,IAAA;AAAA,EACF;AAEJ;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@embedpdf/plugin-interaction-manager/preact';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useEffect, useMemo, useRef, useState } from 'react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@embedpdf/core/react';
|
package/dist/react/index.cjs
CHANGED
|
@@ -1,121 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
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
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/react"),r=require("@embedpdf/plugin-capture"),t=require("react/jsx-runtime"),i=require("react"),n=require("@embedpdf/plugin-interaction-manager/react"),a=()=>e.useCapability(r.CapturePlugin.id);exports.MarqueeCapture=({pageIndex:e,scale:r,pageWidth:u,pageHeight:l,className:o,stroke:s="rgba(33,150,243,0.8)",fill:p="rgba(33,150,243,0.15)"})=>{const{provides:d}=a(),{register:g}=n.usePointerHandlers({modeId:"marqueeCapture",pageIndex:e}),c=(e,r,t)=>Math.max(r,Math.min(t,e)),h=i.useRef(null),[x,b]=i.useState(null),m=u/r,P=l/r,f=i.useMemo((()=>({onPointerDown:(e,r)=>{var t,i;h.current=e,b({origin:{x:e.x,y:e.y},size:{width:0,height:0}}),null==(i=null==(t=r.target)?void 0:t.setPointerCapture)||i.call(t,r.pointerId)},onPointerMove:e=>{if(!h.current)return;const r=c(e.x,0,m),t=c(e.y,0,P),{x:i,y:n}=h.current,a=Math.min(i,r),u=Math.min(n,t),l=Math.abs(r-i),o=Math.abs(t-n);b({origin:{x:a,y:u},size:{width:l,height:o}})},onPointerUp:(t,i)=>{var n,a;if(x&&d){Math.max(x.size.width,x.size.height)*r>5&&d.captureArea(e,x)}h.current=null,b(null),null==(a=null==(n=i.target)?void 0:n.releasePointerCapture)||a.call(n,i.pointerId)},onPointerCancel:(e,r)=>{var t,i;h.current=null,b(null),null==(i=null==(t=r.target)?void 0:t.releasePointerCapture)||i.call(t,r.pointerId)}})),[m,m,d,r,x,e]);return i.useEffect((()=>{if(g)return g(f)}),[g,f]),x?t.jsx("div",{style:{position:"absolute",pointerEvents:"none",left:x.origin.x*r,top:x.origin.y*r,width:x.size.width*r,height:x.size.height*r,border:`1px solid ${s}`,background:p,boxSizing:"border-box"},className:o}):null},exports.useCaptureCapability=a,exports.useCapturePlugin=()=>e.usePlugin(r.CapturePlugin.id);
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
package/dist/react/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-capture.ts","../../src/shared/components/marquee-capture.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\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 '@framework';\nimport type { PointerEventHandlers } from '@embedpdf/plugin-interaction-manager';\nimport { usePointerHandlers } from '@embedpdf/plugin-interaction-manager/@framework';\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"],"names":["useCaptureCapability","useCapability","CapturePlugin","id","pageIndex","scale","pageWidth","pageHeight","className","stroke","fill","provides","capture","register","usePointerHandlers","modeId","clamp","v","min","max","Math","startRef","useRef","rect","setRect","useState","pageWidthPDF","pageHeightPDF","handlers","useMemo","onPointerDown","pos","evt","current","origin","x","y","size","width","height","_b","_a","target","setPointerCapture","call","pointerId","onPointerMove","curX","curY","sx","sy","left","top","abs","onPointerUp","_","captureArea","releasePointerCapture","onPointerCancel","useEffect","jsxRuntime","jsx","style","position","pointerEvents","border","background","boxSizing","usePlugin"],"mappings":"wQAGaA,EAAuB,IAAMC,gBAA6BC,EAAAA,cAAcC,2BCwBvD,EAC5BC,YACAC,QACAC,YACAC,aACAC,YACAC,SAAS,uBACTC,OAAO,4BAKP,MAAQC,SAAUC,GAAYZ,KAKxBa,SAAEA,GAAaC,EAAAA,mBAAmB,CAAEC,OAAQ,iBAAkBX,cAK9DY,EAAQ,CAACC,EAAWC,EAAaC,IAAgBC,KAAKD,IAAID,EAAKE,KAAKF,IAAIC,EAAKF,IAK7EI,EAAWC,SAAwC,OAClDC,EAAMC,GAAWC,EAAAA,SAAsB,MAGxCC,EAAepB,EAAYD,EAC3BsB,EAAgBpB,EAAaF,EAK7BuB,EAAWC,EAAAA,SACf,KAAO,CACLC,cAAe,CAACC,EAAKC,aACnBX,EAASY,QAAUF,EACnBP,EAAQ,CAAEU,OAAQ,CAAEC,EAAGJ,EAAII,EAAGC,EAAGL,EAAIK,GAAKC,KAAM,CAAEC,MAAO,EAAGC,OAAQ,KACnE,OAAAC,EAAA,OAAAC,EAAAT,EAAIU,aAAJ,EAAAD,EAA4BE,oBAA5BH,EAAAI,KAAAH,EAAgDT,EAAIa,UAAA,EAEvDC,cAAgBf,IACV,IAACV,EAASY,QAAS,OAEvB,MAAMc,EAAO/B,EAAMe,EAAII,EAAG,EAAGT,GACvBsB,EAAOhC,EAAMe,EAAIK,EAAG,EAAGT,IAErBQ,EAAGc,EAAIb,EAAGc,GAAO7B,EAASY,QAC5BkB,EAAO/B,KAAKF,IAAI+B,EAAIF,GACpBK,EAAMhC,KAAKF,IAAIgC,EAAIF,GACnBV,EAAQlB,KAAKiC,I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
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 };
|
|
1
|
+
export * from '../shared-react';
|
package/dist/react/index.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
// src/react/hooks/use-capture.ts
|
|
2
1
|
import { useCapability, usePlugin } from "@embedpdf/core/react";
|
|
3
2
|
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
3
|
import { jsx } from "react/jsx-runtime";
|
|
11
|
-
|
|
4
|
+
import { useRef, useState, useMemo, useEffect } from "react";
|
|
5
|
+
import { usePointerHandlers } from "@embedpdf/plugin-interaction-manager/react";
|
|
6
|
+
const useCaptureCapability = () => useCapability(CapturePlugin.id);
|
|
7
|
+
const useCapturePlugin = () => usePlugin(CapturePlugin.id);
|
|
8
|
+
const MarqueeCapture = ({
|
|
12
9
|
pageIndex,
|
|
13
10
|
scale,
|
|
14
11
|
pageWidth,
|
|
@@ -27,9 +24,10 @@ var MarqueeCapture = ({
|
|
|
27
24
|
const handlers = useMemo(
|
|
28
25
|
() => ({
|
|
29
26
|
onPointerDown: (pos, evt) => {
|
|
27
|
+
var _a, _b;
|
|
30
28
|
startRef.current = pos;
|
|
31
29
|
setRect({ origin: { x: pos.x, y: pos.y }, size: { width: 0, height: 0 } });
|
|
32
|
-
evt.target
|
|
30
|
+
(_b = (_a = evt.target) == null ? void 0 : _a.setPointerCapture) == null ? void 0 : _b.call(_a, evt.pointerId);
|
|
33
31
|
},
|
|
34
32
|
onPointerMove: (pos) => {
|
|
35
33
|
if (!startRef.current) return;
|
|
@@ -43,6 +41,7 @@ var MarqueeCapture = ({
|
|
|
43
41
|
setRect({ origin: { x: left, y: top }, size: { width, height } });
|
|
44
42
|
},
|
|
45
43
|
onPointerUp: (_, evt) => {
|
|
44
|
+
var _a, _b;
|
|
46
45
|
if (rect && capture) {
|
|
47
46
|
const dragPx = Math.max(rect.size.width, rect.size.height) * scale;
|
|
48
47
|
if (dragPx > 5) {
|
|
@@ -51,12 +50,13 @@ var MarqueeCapture = ({
|
|
|
51
50
|
}
|
|
52
51
|
startRef.current = null;
|
|
53
52
|
setRect(null);
|
|
54
|
-
evt.target
|
|
53
|
+
(_b = (_a = evt.target) == null ? void 0 : _a.releasePointerCapture) == null ? void 0 : _b.call(_a, evt.pointerId);
|
|
55
54
|
},
|
|
56
55
|
onPointerCancel: (_, evt) => {
|
|
56
|
+
var _a, _b;
|
|
57
57
|
startRef.current = null;
|
|
58
58
|
setRect(null);
|
|
59
|
-
evt.target
|
|
59
|
+
(_b = (_a = evt.target) == null ? void 0 : _a.releasePointerCapture) == null ? void 0 : _b.call(_a, evt.pointerId);
|
|
60
60
|
}
|
|
61
61
|
}),
|
|
62
62
|
[pageWidthPDF, pageWidthPDF, capture, scale, rect, pageIndex]
|
|
@@ -89,4 +89,4 @@ export {
|
|
|
89
89
|
useCaptureCapability,
|
|
90
90
|
useCapturePlugin
|
|
91
91
|
};
|
|
92
|
-
//# sourceMappingURL=index.js.map
|
|
92
|
+
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-capture.ts","../../src/shared/components/marquee-capture.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\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 '@framework';\nimport type { PointerEventHandlers } from '@embedpdf/plugin-interaction-manager';\nimport { usePointerHandlers } from '@embedpdf/plugin-interaction-manager/@framework';\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"],"names":[],"mappings":";;;;;AAGO,MAAM,uBAAuB,MAAM,cAA6B,cAAc,EAAE;AAChF,MAAM,mBAAmB,MAAM,UAAyB,cAAc,EAAE;ACuBxE,MAAM,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;AAK7C,QAAA,EAAE,aAAa,mBAAmB,EAAE,QAAQ,kBAAkB,WAAW;AAK/E,QAAM,QAAQ,CAAC,GAAW,KAAa,QAAgB,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC,CAAC;AAK/E,QAAA,WAAW,OAAwC,IAAI;AAC7D,QAAM,CAAC,MAAM,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,IAAI;AACX,wBAAI,WAAJ,mBAA4B,0BAA5B,4BAAoD,IAAI;AAAA,MAAS;AAAA,IACpE;AAAA,IAEF,CAAC,cAAc,cAAc,SAAS,OAAO,MAAM,SAAS;AAAA,EAC9D;AAGA,YAAU,MAAM;AACd,QAAI,CAAC,SAAU;AACf,WAAO,SAAS,QAAQ;AAAA,EAAA,GACvB,CAAC,UAAU,QAAQ,CAAC;AAKnB,MAAA,CAAC,KAAa,QAAA;AAGhB,SAAA;AAAA,IAAC;AAAA,IAAA;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,IAAA;AAAA,EACF;AAEJ;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@embedpdf/plugin-interaction-manager/react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './marquee-capture';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface MarqueeCaptureProps {
|
|
2
|
+
/** Index of the page this layer lives on */
|
|
3
|
+
pageIndex: number;
|
|
4
|
+
/** Scale of the page */
|
|
5
|
+
scale: number;
|
|
6
|
+
/** Width of the page */
|
|
7
|
+
pageWidth: number;
|
|
8
|
+
/** Height of the page */
|
|
9
|
+
pageHeight: number;
|
|
10
|
+
/** Optional CSS class applied to the marquee rectangle */
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Stroke / fill colours (defaults below) */
|
|
13
|
+
stroke?: string;
|
|
14
|
+
fill?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Draws a marquee rectangle while the user drags.
|
|
18
|
+
* Hook it into the interaction-manager with modeId = 'marqueeCapture'.
|
|
19
|
+
*/
|
|
20
|
+
export declare const MarqueeCapture: ({ pageIndex, scale, pageWidth, pageHeight, className, stroke, fill, }: MarqueeCaptureProps) => import("preact").JSX.Element | null;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-capture';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CapturePlugin } from '../../lib/index.ts';
|
|
2
|
+
export declare const useCaptureCapability: () => {
|
|
3
|
+
provides: Readonly<import('../../lib/index.ts').CaptureCapability> | null;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare const useCapturePlugin: () => {
|
|
8
|
+
plugin: CapturePlugin | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
ready: Promise<void>;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './marquee-capture';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface MarqueeCaptureProps {
|
|
2
|
+
/** Index of the page this layer lives on */
|
|
3
|
+
pageIndex: number;
|
|
4
|
+
/** Scale of the page */
|
|
5
|
+
scale: number;
|
|
6
|
+
/** Width of the page */
|
|
7
|
+
pageWidth: number;
|
|
8
|
+
/** Height of the page */
|
|
9
|
+
pageHeight: number;
|
|
10
|
+
/** Optional CSS class applied to the marquee rectangle */
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Stroke / fill colours (defaults below) */
|
|
13
|
+
stroke?: string;
|
|
14
|
+
fill?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Draws a marquee rectangle while the user drags.
|
|
18
|
+
* Hook it into the interaction-manager with modeId = 'marqueeCapture'.
|
|
19
|
+
*/
|
|
20
|
+
export declare const MarqueeCapture: ({ pageIndex, scale, pageWidth, pageHeight, className, stroke, fill, }: MarqueeCaptureProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-capture';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CapturePlugin } from '../../lib/index.ts';
|
|
2
|
+
export declare const useCaptureCapability: () => {
|
|
3
|
+
provides: Readonly<import('../../lib/index.ts').CaptureCapability> | null;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare const useCapturePlugin: () => {
|
|
8
|
+
plugin: CapturePlugin | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
ready: Promise<void>;
|
|
11
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-capture",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -23,22 +23,23 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@embedpdf/models": "1.0.
|
|
26
|
+
"@embedpdf/models": "1.0.12"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/react": "^18.2.0",
|
|
30
|
-
"tsup": "^8.0.0",
|
|
31
30
|
"typescript": "^5.0.0",
|
|
32
|
-
"@embedpdf/
|
|
33
|
-
"@embedpdf/
|
|
34
|
-
"@embedpdf/plugin-
|
|
31
|
+
"@embedpdf/build": "1.0.0",
|
|
32
|
+
"@embedpdf/core": "1.0.12",
|
|
33
|
+
"@embedpdf/plugin-render": "1.0.12",
|
|
34
|
+
"@embedpdf/plugin-interaction-manager": "1.0.12"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"react": ">=16.8.0",
|
|
38
38
|
"react-dom": ">=16.8.0",
|
|
39
39
|
"preact": "^10.26.4",
|
|
40
|
-
"@embedpdf/core": "1.0.
|
|
41
|
-
"@embedpdf/plugin-
|
|
40
|
+
"@embedpdf/core": "1.0.12",
|
|
41
|
+
"@embedpdf/plugin-render": "1.0.12",
|
|
42
|
+
"@embedpdf/plugin-interaction-manager": "1.0.12"
|
|
42
43
|
},
|
|
43
44
|
"files": [
|
|
44
45
|
"dist",
|
|
@@ -57,11 +58,12 @@
|
|
|
57
58
|
"access": "public"
|
|
58
59
|
},
|
|
59
60
|
"scripts": {
|
|
60
|
-
"build": "
|
|
61
|
-
"build:
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
61
|
+
"build:base": "vite build --mode base",
|
|
62
|
+
"build:react": "vite build --mode react",
|
|
63
|
+
"build:preact": "vite build --mode preact",
|
|
64
|
+
"build": "pnpm run clean && concurrently -c auto -n base,react,preact \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\"",
|
|
65
|
+
"clean": "rimraf dist",
|
|
66
|
+
"lint": "eslint src --color",
|
|
67
|
+
"lint:fix": "eslint src --color --fix"
|
|
66
68
|
}
|
|
67
69
|
}
|