@embedpdf/plugin-capture 1.4.0 → 1.4.1
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/svelte/components/MarqueeCapture.svelte.d.ts +14 -0
- package/dist/svelte/components/index.d.ts +1 -0
- package/dist/svelte/hooks/index.d.ts +1 -0
- package/dist/svelte/hooks/use-capture.svelte.d.ts +15 -0
- package/dist/svelte/index.cjs +2 -0
- package/dist/svelte/index.cjs.map +1 -0
- package/dist/svelte/index.d.ts +3 -0
- package/dist/svelte/index.js +78 -0
- package/dist/svelte/index.js.map +1 -0
- package/package.json +16 -9
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface MarqueeCaptureProps {
|
|
2
|
+
/** Index of the page this layer lives on */
|
|
3
|
+
pageIndex: number;
|
|
4
|
+
/** Scale of the page */
|
|
5
|
+
scale: number;
|
|
6
|
+
/** Optional CSS class applied to the marquee rectangle */
|
|
7
|
+
class?: string;
|
|
8
|
+
/** Stroke / fill colours (defaults below) */
|
|
9
|
+
stroke?: string;
|
|
10
|
+
fill?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const MarqueeCapture: import('svelte', { with: { "resolution-mode": "import" } }).Component<MarqueeCaptureProps, {}, "">;
|
|
13
|
+
type MarqueeCapture = ReturnType<typeof MarqueeCapture>;
|
|
14
|
+
export default MarqueeCapture;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as MarqueeCapture } from './MarqueeCapture.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-capture.svelte';
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
};
|
|
12
|
+
export declare const useCapture: () => {
|
|
13
|
+
readonly provides: Readonly<import('../../lib/index.ts').CaptureCapability> | null;
|
|
14
|
+
isMarqueeCaptureActive: boolean;
|
|
15
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("svelte/internal/client"),t=require("@embedpdf/plugin-capture"),r=require("@embedpdf/core/svelte");function i(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const r in e)if("default"!==r){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}return t.default=e,Object.freeze(t)}require("svelte/internal/disclose-version");const s=i(e),o=()=>r.useCapability(t.CapturePlugin.id);var a=s.from_html("<div></div>");exports.MarqueeCapture=function(e,t){s.push(t,!0);let r=s.prop(t,"stroke",3,"rgba(33,150,243,0.8)"),i=s.prop(t,"fill",3,"rgba(33,150,243,0.15)");const n=o();let p=s.state(null);s.user_effect((()=>{if(n.provides)return n.provides.registerMarqueeOnPage({pageIndex:t.pageIndex,scale:t.scale,callback:{onPreview:e=>s.set(p,e,!0)}})}));var l=s.comment(),u=s.first_child(l),c=e=>{var o=a();let n;s.template_effect((e=>{s.set_class(o,1,s.clsx(t.class)),n=s.set_style(o,"",n,e)}),[()=>({position:"absolute","pointer-events":"none",left:s.get(p).origin.x*t.scale+"px",top:s.get(p).origin.y*t.scale+"px",width:s.get(p).size.width*t.scale+"px",height:s.get(p).size.height*t.scale+"px",border:`1px solid ${r()}`,background:i(),"box-sizing":"border-box"})]),s.append(e,o)};s.if(u,(e=>{s.get(p)&&e(c)})),s.append(e,l),s.pop()},exports.useCapture=()=>{const e=o(),t=s.proxy({get provides(){return e.provides},isMarqueeCaptureActive:!1});return s.user_effect((()=>{var r;return null==(r=e.provides)?void 0:r.onMarqueeCaptureActiveChange((e=>{t.isMarqueeCaptureActive=e}))})),t},exports.useCaptureCapability=o,exports.useCapturePlugin=()=>r.usePlugin(t.CapturePlugin.id),Object.keys(t).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})}));
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-capture.svelte.ts","../../src/svelte/components/MarqueeCapture.svelte"],"sourcesContent":["import { CapturePlugin } from '@embedpdf/plugin-capture';\nimport { useCapability, usePlugin } from '@embedpdf/core/svelte';\n\nexport const useCaptureCapability = () => useCapability<CapturePlugin>(CapturePlugin.id);\nexport const useCapturePlugin = () => usePlugin<CapturePlugin>(CapturePlugin.id);\n\nexport const useCapture = () => {\n const capability = useCaptureCapability();\n\n const state = $state({\n get provides() {\n return capability.provides;\n },\n isMarqueeCaptureActive: false,\n });\n\n $effect(() => {\n return capability.provides?.onMarqueeCaptureActiveChange((active) => {\n state.isMarqueeCaptureActive = active;\n });\n });\n\n return state;\n};\n","<script lang=\"ts\">\n import type { Rect } from '@embedpdf/models';\n import { useCaptureCapability } from '../hooks/use-capture.svelte';\n\n interface MarqueeCaptureProps {\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page */\n scale: number;\n /** Optional CSS class applied to the marquee rectangle */\n class?: string;\n /** Stroke / fill colours (defaults below) */\n stroke?: string;\n fill?: string;\n }\n\n let {\n pageIndex,\n scale,\n class: propsClass,\n stroke = 'rgba(33,150,243,0.8)',\n fill = 'rgba(33,150,243,0.15)',\n }: MarqueeCaptureProps = $props();\n\n const captureCapability = useCaptureCapability();\n let rect = $state<Rect | null>(null);\n\n $effect(() => {\n if (!captureCapability.provides) return;\n return captureCapability.provides.registerMarqueeOnPage({\n pageIndex,\n scale,\n callback: { onPreview: (val) => (rect = val) },\n });\n });\n</script>\n\n{#if rect}\n <div\n style:position=\"absolute\"\n style:pointer-events=\"none\"\n style:left={`${rect.origin.x * scale}px`}\n style:top={`${rect.origin.y * scale}px`}\n style:width={`${rect.size.width * scale}px`}\n style:height={`${rect.size.height * scale}px`}\n style:border={`1px solid ${stroke}`}\n style:background={fill}\n style:box-sizing=\"border-box\"\n class={propsClass}\n ></div>\n{/if}\n"],"names":["useCaptureCapability","useCapability","CapturePlugin","id","stroke","fill","captureCapability","rect","$","user_effect","provides","registerMarqueeOnPage","pageIndex","$$props","scale","callback","onPreview","val","set","origin","x","y","size","width","height","consequent","capability","state","isMarqueeCaptureActive","_a","onMarqueeCaptureActiveChange","active","usePlugin"],"mappings":"ugBAGaA,EAA6B,IAAAC,gBAA6BC,EAAAA,cAAcC,uFCiBjF,IAAAC,sBAAS,wBACTC,oBAAO,yBAGH,MAAAC,EAAoBN,IACtB,IAAAO,UAA2B,MAE/BC,EAAAC,aAAc,KACP,GAAAH,EAAkBI,SAChB,OAAAJ,EAAkBI,SAASC,sBAAqB,CACrDC,UAASC,EAAAD,UACTE,MAAKD,EAAAC,MACLC,UAAYC,UAAYC,GAAST,EAAAU,IAAAX,EAAOU,GAAG,oNAS9BV,GAAKY,OAAOC,EAACP,EAAAC,qBACdP,GAAKY,OAAOE,EAACR,EAAAC,uBACXP,GAAKe,KAAKC,MAAKV,EAAAC,wBACdP,GAAKe,KAAKE,OAAMX,EAAAC,+BACNV,iBACTC,mEATjBE,MAAIkB,EAAA,yBAFT,0BD5BQ,MAAAC,EAAa1B,IAEb2B,WACA,YAAAjB,GACK,OAAAgB,EAAWhB,QACpB,EACAkB,wBAAwB,IASnB,OANPpB,EAAAC,wBACS,OAAA,OAAAoB,EAAWH,EAAAhB,eAAU,EAAAmB,EAAAC,8BAA8BC,IACxDJ,EAAMC,uBAAyBG,CAAA,OAI5BJ,CAAA,0DAlB6B,IAAAK,YAAyB9B,EAAAA,cAAcC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as $ from "svelte/internal/client";
|
|
2
|
+
import { CapturePlugin } from "@embedpdf/plugin-capture";
|
|
3
|
+
export * from "@embedpdf/plugin-capture";
|
|
4
|
+
import { useCapability, usePlugin } from "@embedpdf/core/svelte";
|
|
5
|
+
import "svelte/internal/disclose-version";
|
|
6
|
+
const useCaptureCapability = () => useCapability(CapturePlugin.id);
|
|
7
|
+
const useCapturePlugin = () => usePlugin(CapturePlugin.id);
|
|
8
|
+
const useCapture = () => {
|
|
9
|
+
const capability = useCaptureCapability();
|
|
10
|
+
const state = $.proxy({
|
|
11
|
+
get provides() {
|
|
12
|
+
return capability.provides;
|
|
13
|
+
},
|
|
14
|
+
isMarqueeCaptureActive: false
|
|
15
|
+
});
|
|
16
|
+
$.user_effect(() => {
|
|
17
|
+
var _a;
|
|
18
|
+
return (_a = capability.provides) == null ? void 0 : _a.onMarqueeCaptureActiveChange((active) => {
|
|
19
|
+
state.isMarqueeCaptureActive = active;
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
return state;
|
|
23
|
+
};
|
|
24
|
+
var root_1 = $.from_html(`<div></div>`);
|
|
25
|
+
function MarqueeCapture($$anchor, $$props) {
|
|
26
|
+
$.push($$props, true);
|
|
27
|
+
let stroke = $.prop($$props, "stroke", 3, "rgba(33,150,243,0.8)"), fill = $.prop($$props, "fill", 3, "rgba(33,150,243,0.15)");
|
|
28
|
+
const captureCapability = useCaptureCapability();
|
|
29
|
+
let rect = $.state(null);
|
|
30
|
+
$.user_effect(() => {
|
|
31
|
+
if (!captureCapability.provides) return;
|
|
32
|
+
return captureCapability.provides.registerMarqueeOnPage({
|
|
33
|
+
pageIndex: $$props.pageIndex,
|
|
34
|
+
scale: $$props.scale,
|
|
35
|
+
callback: { onPreview: (val) => $.set(rect, val, true) }
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
var fragment = $.comment();
|
|
39
|
+
var node = $.first_child(fragment);
|
|
40
|
+
{
|
|
41
|
+
var consequent = ($$anchor2) => {
|
|
42
|
+
var div = root_1();
|
|
43
|
+
let styles;
|
|
44
|
+
$.template_effect(
|
|
45
|
+
($0) => {
|
|
46
|
+
$.set_class(div, 1, $.clsx($$props.class));
|
|
47
|
+
styles = $.set_style(div, "", styles, $0);
|
|
48
|
+
},
|
|
49
|
+
[
|
|
50
|
+
() => ({
|
|
51
|
+
position: "absolute",
|
|
52
|
+
"pointer-events": "none",
|
|
53
|
+
left: `${$.get(rect).origin.x * $$props.scale}px`,
|
|
54
|
+
top: `${$.get(rect).origin.y * $$props.scale}px`,
|
|
55
|
+
width: `${$.get(rect).size.width * $$props.scale}px`,
|
|
56
|
+
height: `${$.get(rect).size.height * $$props.scale}px`,
|
|
57
|
+
border: `1px solid ${stroke()}`,
|
|
58
|
+
background: fill(),
|
|
59
|
+
"box-sizing": "border-box"
|
|
60
|
+
})
|
|
61
|
+
]
|
|
62
|
+
);
|
|
63
|
+
$.append($$anchor2, div);
|
|
64
|
+
};
|
|
65
|
+
$.if(node, ($$render) => {
|
|
66
|
+
if ($.get(rect)) $$render(consequent);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
$.append($$anchor, fragment);
|
|
70
|
+
$.pop();
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
MarqueeCapture,
|
|
74
|
+
useCapture,
|
|
75
|
+
useCaptureCapability,
|
|
76
|
+
useCapturePlugin
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-capture.svelte.ts","../../src/svelte/components/MarqueeCapture.svelte"],"sourcesContent":["import { CapturePlugin } from '@embedpdf/plugin-capture';\nimport { useCapability, usePlugin } from '@embedpdf/core/svelte';\n\nexport const useCaptureCapability = () => useCapability<CapturePlugin>(CapturePlugin.id);\nexport const useCapturePlugin = () => usePlugin<CapturePlugin>(CapturePlugin.id);\n\nexport const useCapture = () => {\n const capability = useCaptureCapability();\n\n const state = $state({\n get provides() {\n return capability.provides;\n },\n isMarqueeCaptureActive: false,\n });\n\n $effect(() => {\n return capability.provides?.onMarqueeCaptureActiveChange((active) => {\n state.isMarqueeCaptureActive = active;\n });\n });\n\n return state;\n};\n","<script lang=\"ts\">\n import type { Rect } from '@embedpdf/models';\n import { useCaptureCapability } from '../hooks/use-capture.svelte';\n\n interface MarqueeCaptureProps {\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page */\n scale: number;\n /** Optional CSS class applied to the marquee rectangle */\n class?: string;\n /** Stroke / fill colours (defaults below) */\n stroke?: string;\n fill?: string;\n }\n\n let {\n pageIndex,\n scale,\n class: propsClass,\n stroke = 'rgba(33,150,243,0.8)',\n fill = 'rgba(33,150,243,0.15)',\n }: MarqueeCaptureProps = $props();\n\n const captureCapability = useCaptureCapability();\n let rect = $state<Rect | null>(null);\n\n $effect(() => {\n if (!captureCapability.provides) return;\n return captureCapability.provides.registerMarqueeOnPage({\n pageIndex,\n scale,\n callback: { onPreview: (val) => (rect = val) },\n });\n });\n</script>\n\n{#if rect}\n <div\n style:position=\"absolute\"\n style:pointer-events=\"none\"\n style:left={`${rect.origin.x * scale}px`}\n style:top={`${rect.origin.y * scale}px`}\n style:width={`${rect.size.width * scale}px`}\n style:height={`${rect.size.height * scale}px`}\n style:border={`1px solid ${stroke}`}\n style:background={fill}\n style:box-sizing=\"border-box\"\n class={propsClass}\n ></div>\n{/if}\n"],"names":[],"mappings":";;;;;AAGa,MAAA,uBAA6B,MAAA,cAA6B,cAAc,EAAE;AAC1E,MAAA,mBAAyB,MAAA,UAAyB,cAAc,EAAE;AAElE,MAAA,mBAAmB;AACxB,QAAA,aAAa,qBAAqB;QAElC;IACA,IAAA,WAAW;AACN,aAAA,WAAW;AAAA,IACpB;AAAA,IACA,wBAAwB;AAAA;AAG1B,IAAA,kBAAc;;AACL,YAAA,gBAAW,aAAX,mBAAqB,6BAA8B,CAAA,WAAW;AACnE,YAAM,yBAAyB;AAAA;GAElC;SAEM;AACT;;2CCvBA;;AAoBI,MAAA,sCAAS,sBAAsB,GAC/B,kCAAO,uBAAuB;AAG1B,QAAA,oBAAoB,qBAAoB;AAC1C,MAAA,eAA2B,IAAI;AAEnC,IAAA,YAAc,MAAA;AACP,QAAA,CAAA,kBAAkB,SAAQ;WACxB,kBAAkB,SAAS,sBAAqB;AAAA,MACrD,WAAS,QAAA;AAAA,MACT,OAAK,QAAA;AAAA,MACL,YAAY,WAAS,CAAG,QAAS,EAAA,IAAA,MAAO,KAAG,IAAA,EAAA;AAAA;GAE9C;;;;;;;;;;;;;;;;2BAOgB,IAAI,EAAC,OAAO,IAAC,QAAA,KAAA;AAAA,0BACd,IAAI,EAAC,OAAO,IAAC,QAAA,KAAA;AAAA,4BACX,IAAI,EAAC,KAAK,QAAK,QAAA,KAAA;AAAA,6BACd,IAAI,EAAC,KAAK,SAAM,QAAA,KAAA;AAAA,iCACN,OAAM,CAAA;AAAA,wBACf,KAAI;AAAA;;;;;;;gBATrB,IAAI,EAAA,UAAA,UAAA;AAAA;;;;AAFT;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-capture",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -26,27 +26,33 @@
|
|
|
26
26
|
"types": "./dist/vue/index.d.ts",
|
|
27
27
|
"import": "./dist/vue/index.js",
|
|
28
28
|
"require": "./dist/vue/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./svelte": {
|
|
31
|
+
"types": "./dist/svelte/index.d.ts",
|
|
32
|
+
"import": "./dist/svelte/index.js",
|
|
33
|
+
"require": "./dist/svelte/index.cjs"
|
|
29
34
|
}
|
|
30
35
|
},
|
|
31
36
|
"dependencies": {
|
|
32
|
-
"@embedpdf/models": "1.4.
|
|
37
|
+
"@embedpdf/models": "1.4.1"
|
|
33
38
|
},
|
|
34
39
|
"devDependencies": {
|
|
35
40
|
"@types/react": "^18.2.0",
|
|
36
41
|
"typescript": "^5.0.0",
|
|
37
42
|
"@embedpdf/build": "1.1.0",
|
|
38
|
-
"@embedpdf/
|
|
39
|
-
"@embedpdf/plugin-
|
|
40
|
-
"@embedpdf/
|
|
43
|
+
"@embedpdf/plugin-render": "1.4.1",
|
|
44
|
+
"@embedpdf/plugin-interaction-manager": "1.4.1",
|
|
45
|
+
"@embedpdf/core": "1.4.1"
|
|
41
46
|
},
|
|
42
47
|
"peerDependencies": {
|
|
43
48
|
"react": ">=16.8.0",
|
|
44
49
|
"react-dom": ">=16.8.0",
|
|
45
50
|
"preact": "^10.26.4",
|
|
46
51
|
"vue": ">=3.2.0",
|
|
47
|
-
"
|
|
48
|
-
"@embedpdf/
|
|
49
|
-
"@embedpdf/plugin-interaction-manager": "1.4.
|
|
52
|
+
"svelte": ">=5 <6",
|
|
53
|
+
"@embedpdf/core": "1.4.1",
|
|
54
|
+
"@embedpdf/plugin-interaction-manager": "1.4.1",
|
|
55
|
+
"@embedpdf/plugin-render": "1.4.1"
|
|
50
56
|
},
|
|
51
57
|
"files": [
|
|
52
58
|
"dist",
|
|
@@ -69,7 +75,8 @@
|
|
|
69
75
|
"build:react": "vite build --mode react",
|
|
70
76
|
"build:preact": "vite build --mode preact",
|
|
71
77
|
"build:vue": "vite build --mode vue",
|
|
72
|
-
"build": "
|
|
78
|
+
"build:svelte": "vite build --mode svelte",
|
|
79
|
+
"build": "pnpm run clean && concurrently -c auto -n base,react,preact,vue,svelte \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\" \"vite build --mode vue\" \"vite build --mode svelte\"",
|
|
73
80
|
"clean": "rimraf dist",
|
|
74
81
|
"lint": "eslint src --color",
|
|
75
82
|
"lint:fix": "eslint src --color --fix"
|