@embedpdf/plugin-stamp 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +980 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/actions.d.ts +14 -0
- package/dist/lib/defaults/name-map.d.ts +2 -0
- package/dist/lib/handlers/rubber-stamp.handler.d.ts +4 -0
- package/dist/lib/index.d.ts +11 -0
- package/dist/lib/manifest.d.ts +4 -0
- package/dist/lib/reducer.d.ts +5 -0
- package/dist/lib/stamp-plugin.d.ts +54 -0
- package/dist/lib/tools.d.ts +58 -0
- package/dist/lib/types.d.ts +135 -0
- package/dist/preact/adapter.d.ts +5 -0
- package/dist/preact/annotation.d.ts +1 -0
- package/dist/preact/core.d.ts +1 -0
- package/dist/preact/index.cjs +2 -0
- package/dist/preact/index.cjs.map +1 -0
- package/dist/preact/index.d.ts +1 -0
- package/dist/preact/index.js +147 -0
- package/dist/preact/index.js.map +1 -0
- package/dist/react/adapter.d.ts +2 -0
- package/dist/react/annotation.d.ts +1 -0
- package/dist/react/core.d.ts +1 -0
- package/dist/react/index.cjs +2 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +146 -0
- package/dist/react/index.js.map +1 -0
- package/dist/shared/components/index.d.ts +3 -0
- package/dist/shared/components/stamp-img.d.ts +10 -0
- package/dist/shared/components/stamp-preview-renderers.d.ts +2 -0
- package/dist/shared/components/stamp-renderer-registration.d.ts +1 -0
- package/dist/shared/hooks/index.d.ts +1 -0
- package/dist/shared/hooks/use-stamp.d.ts +18 -0
- package/dist/shared/index.d.ts +4 -0
- package/dist/shared-preact/components/index.d.ts +3 -0
- package/dist/shared-preact/components/stamp-img.d.ts +10 -0
- package/dist/shared-preact/components/stamp-preview-renderers.d.ts +2 -0
- package/dist/shared-preact/components/stamp-renderer-registration.d.ts +1 -0
- package/dist/shared-preact/hooks/index.d.ts +1 -0
- package/dist/shared-preact/hooks/use-stamp.d.ts +18 -0
- package/dist/shared-preact/index.d.ts +4 -0
- package/dist/shared-react/components/index.d.ts +3 -0
- package/dist/shared-react/components/stamp-img.d.ts +10 -0
- package/dist/shared-react/components/stamp-preview-renderers.d.ts +2 -0
- package/dist/shared-react/components/stamp-renderer-registration.d.ts +1 -0
- package/dist/shared-react/hooks/index.d.ts +1 -0
- package/dist/shared-react/hooks/use-stamp.d.ts +18 -0
- package/dist/shared-react/index.d.ts +4 -0
- package/dist/svelte/components/StampImg.svelte.d.ts +10 -0
- package/dist/svelte/components/StampPreview.svelte.d.ts +10 -0
- package/dist/svelte/components/StampRendererRegistration.svelte.d.ts +18 -0
- package/dist/svelte/components/index.d.ts +2 -0
- package/dist/svelte/components/stamp-preview-renderers.d.ts +2 -0
- package/dist/svelte/hooks/index.d.ts +1 -0
- package/dist/svelte/hooks/use-stamp.svelte.d.ts +23 -0
- package/dist/svelte/index.cjs +2 -0
- package/dist/svelte/index.cjs.map +1 -0
- package/dist/svelte/index.d.ts +4 -0
- package/dist/svelte/index.js +223 -0
- package/dist/svelte/index.js.map +1 -0
- package/dist/vue/components/index.d.ts +2 -0
- package/dist/vue/components/stamp-img.vue.d.ts +9 -0
- package/dist/vue/components/stamp-preview-renderers.d.ts +2 -0
- package/dist/vue/components/stamp-preview.vue.d.ts +10 -0
- package/dist/vue/components/stamp-renderer-registration.vue.d.ts +13 -0
- package/dist/vue/hooks/index.d.ts +1 -0
- package/dist/vue/hooks/use-stamp.d.ts +262 -0
- package/dist/vue/index.cjs +2 -0
- package/dist/vue/index.cjs.map +1 -0
- package/dist/vue/index.d.ts +4 -0
- package/dist/vue/index.js +235 -0
- package/dist/vue/index.js.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { createPluginPackage } from "@embedpdf/core";
|
|
2
|
+
import { StampPlugin, StampPluginPackage as StampPluginPackage$1 } from "@embedpdf/plugin-stamp";
|
|
3
|
+
export * from "@embedpdf/plugin-stamp";
|
|
4
|
+
import "svelte/internal/disclose-version";
|
|
5
|
+
import "svelte/internal/flags/legacy";
|
|
6
|
+
import * as $ from "svelte/internal/client";
|
|
7
|
+
import { onMount } from "svelte";
|
|
8
|
+
import { createRenderer, getRendererRegistry } from "@embedpdf/plugin-annotation/svelte";
|
|
9
|
+
import { PdfAnnotationSubtype, ignore, PdfErrorCode } from "@embedpdf/models";
|
|
10
|
+
import { useCapability, usePlugin } from "@embedpdf/core/svelte";
|
|
11
|
+
var root = $.from_html(`<img alt=""/>`);
|
|
12
|
+
function StampPreview($$anchor, $$props) {
|
|
13
|
+
$.push($$props, true);
|
|
14
|
+
const rotationDeg = $.derived(() => (4 - $$props.data.pageRotation) % 4 * 90);
|
|
15
|
+
var img = root();
|
|
16
|
+
let styles;
|
|
17
|
+
$.template_effect(() => {
|
|
18
|
+
$.set_attribute(img, "src", $$props.data.ghostUrl);
|
|
19
|
+
styles = $.set_style(img, "", styles, {
|
|
20
|
+
width: "100%",
|
|
21
|
+
height: "100%",
|
|
22
|
+
opacity: "0.6",
|
|
23
|
+
"object-fit": "contain",
|
|
24
|
+
"pointer-events": "none",
|
|
25
|
+
transform: $.get(rotationDeg) ? `rotate(${$.get(rotationDeg)}deg)` : void 0
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
$.append($$anchor, img);
|
|
29
|
+
$.pop();
|
|
30
|
+
}
|
|
31
|
+
const stampPreviewRenderers = [
|
|
32
|
+
createRenderer({
|
|
33
|
+
id: "stampPreview",
|
|
34
|
+
matchesPreview: (p) => p.type === PdfAnnotationSubtype.STAMP,
|
|
35
|
+
renderPreview: StampPreview
|
|
36
|
+
})
|
|
37
|
+
];
|
|
38
|
+
function StampRendererRegistration($$anchor, $$props) {
|
|
39
|
+
$.push($$props, false);
|
|
40
|
+
const registry = getRendererRegistry();
|
|
41
|
+
onMount(() => {
|
|
42
|
+
if (!registry) return;
|
|
43
|
+
return registry.register(stampPreviewRenderers);
|
|
44
|
+
});
|
|
45
|
+
$.init();
|
|
46
|
+
$.pop();
|
|
47
|
+
}
|
|
48
|
+
const useStampPlugin = () => usePlugin(StampPlugin.id);
|
|
49
|
+
const useStampCapability = () => useCapability(StampPlugin.id);
|
|
50
|
+
function useStampLibraries() {
|
|
51
|
+
const capability = useStampCapability();
|
|
52
|
+
let libraries = $.state($.proxy([]));
|
|
53
|
+
$.user_effect(() => {
|
|
54
|
+
if (!capability.provides) {
|
|
55
|
+
$.set(libraries, [], true);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
$.set(libraries, capability.provides.getLibraries(), true);
|
|
59
|
+
return capability.provides.onLibraryChange((libs) => {
|
|
60
|
+
$.set(libraries, libs, true);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
get libraries() {
|
|
65
|
+
return $.get(libraries);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function useStampsByCategory(getCategory) {
|
|
70
|
+
const capability = useStampCapability();
|
|
71
|
+
let stamps = $.state($.proxy([]));
|
|
72
|
+
const category = $.derived(getCategory);
|
|
73
|
+
$.user_effect(() => {
|
|
74
|
+
if (!capability.provides) {
|
|
75
|
+
$.set(stamps, [], true);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
$.set(stamps, capability.provides.getStampsByCategory($.get(category)), true);
|
|
79
|
+
return capability.provides.onLibraryChange(() => {
|
|
80
|
+
$.set(stamps, capability.provides.getStampsByCategory($.get(category)), true);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
get stamps() {
|
|
85
|
+
return $.get(stamps);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function useStampsByLibrary(getLibraryId, getCategory) {
|
|
90
|
+
const capability = useStampCapability();
|
|
91
|
+
let stamps = $.state($.proxy([]));
|
|
92
|
+
const libraryId = $.derived(getLibraryId);
|
|
93
|
+
const category = $.derived(() => getCategory == null ? void 0 : getCategory());
|
|
94
|
+
$.user_effect(() => {
|
|
95
|
+
if (!capability.provides) {
|
|
96
|
+
$.set(stamps, [], true);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const derive = () => {
|
|
100
|
+
var _a, _b;
|
|
101
|
+
const libraries = capability.provides.getLibraries();
|
|
102
|
+
const results = [];
|
|
103
|
+
for (const library of libraries) {
|
|
104
|
+
if ($.get(libraryId) && $.get(libraryId) !== "all" && library.id !== $.get(libraryId)) continue;
|
|
105
|
+
for (const stamp of library.stamps) {
|
|
106
|
+
if ($.get(category)) {
|
|
107
|
+
const libraryMatches = ((_a = library.categories) == null ? void 0 : _a.includes($.get(category))) ?? false;
|
|
108
|
+
const stampMatches = ((_b = stamp.categories) == null ? void 0 : _b.includes($.get(category))) ?? false;
|
|
109
|
+
if (!libraryMatches && !stampMatches) continue;
|
|
110
|
+
}
|
|
111
|
+
results.push({ library, stamp });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
$.set(stamps, results, true);
|
|
115
|
+
};
|
|
116
|
+
derive();
|
|
117
|
+
return capability.provides.onLibraryChange(derive);
|
|
118
|
+
});
|
|
119
|
+
return {
|
|
120
|
+
get stamps() {
|
|
121
|
+
return $.get(stamps);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function useActiveStamp(getDocumentId) {
|
|
126
|
+
const capability = useStampCapability();
|
|
127
|
+
let activeStamp = $.state(null);
|
|
128
|
+
const documentId = $.derived(getDocumentId);
|
|
129
|
+
$.user_effect(() => {
|
|
130
|
+
if (!capability.provides || !$.get(documentId)) {
|
|
131
|
+
$.set(activeStamp, null);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const scope = capability.provides.forDocument($.get(documentId));
|
|
135
|
+
$.set(activeStamp, scope.getActiveStamp(), true);
|
|
136
|
+
return scope.onActiveStampChange((stamp) => {
|
|
137
|
+
$.set(activeStamp, stamp, true);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
return {
|
|
141
|
+
get activeStamp() {
|
|
142
|
+
return $.get(activeStamp);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
var root_1 = $.from_html(`<img/>`);
|
|
147
|
+
function StampImg($$anchor, $$props) {
|
|
148
|
+
$.push($$props, true);
|
|
149
|
+
const imgProps = $.rest_props($$props, [
|
|
150
|
+
"$$slots",
|
|
151
|
+
"$$events",
|
|
152
|
+
"$$legacy",
|
|
153
|
+
"libraryId",
|
|
154
|
+
"pageIndex",
|
|
155
|
+
"width",
|
|
156
|
+
"dpr"
|
|
157
|
+
]);
|
|
158
|
+
const stampCapability = useStampCapability();
|
|
159
|
+
let url = $.state(void 0);
|
|
160
|
+
let urlRef = null;
|
|
161
|
+
$.user_effect(() => {
|
|
162
|
+
if (!stampCapability.provides) return;
|
|
163
|
+
const task = stampCapability.provides.renderStamp($$props.libraryId, $$props.pageIndex, $$props.width, $$props.dpr ?? window.devicePixelRatio);
|
|
164
|
+
task.wait(
|
|
165
|
+
(blob) => {
|
|
166
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
167
|
+
urlRef = objectUrl;
|
|
168
|
+
$.set(url, objectUrl, true);
|
|
169
|
+
},
|
|
170
|
+
ignore
|
|
171
|
+
);
|
|
172
|
+
return () => {
|
|
173
|
+
if (urlRef) {
|
|
174
|
+
URL.revokeObjectURL(urlRef);
|
|
175
|
+
urlRef = null;
|
|
176
|
+
} else {
|
|
177
|
+
task.abort({
|
|
178
|
+
code: PdfErrorCode.Cancelled,
|
|
179
|
+
message: "canceled stamp render task"
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
});
|
|
184
|
+
const handleImageLoad = () => {
|
|
185
|
+
if (urlRef) {
|
|
186
|
+
URL.revokeObjectURL(urlRef);
|
|
187
|
+
urlRef = null;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
var fragment = $.comment();
|
|
191
|
+
var node = $.first_child(fragment);
|
|
192
|
+
{
|
|
193
|
+
var consequent = ($$anchor2) => {
|
|
194
|
+
var img = root_1();
|
|
195
|
+
$.attribute_effect(img, () => ({
|
|
196
|
+
src: $.get(url),
|
|
197
|
+
onload: handleImageLoad,
|
|
198
|
+
...imgProps,
|
|
199
|
+
alt: "Stamp preview"
|
|
200
|
+
}));
|
|
201
|
+
$.replay_events(img);
|
|
202
|
+
$.append($$anchor2, img);
|
|
203
|
+
};
|
|
204
|
+
$.if(node, ($$render) => {
|
|
205
|
+
if ($.get(url)) $$render(consequent);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
$.append($$anchor, fragment);
|
|
209
|
+
$.pop();
|
|
210
|
+
}
|
|
211
|
+
const StampPluginPackage = createPluginPackage(StampPluginPackage$1).addUtility(StampRendererRegistration).build();
|
|
212
|
+
export {
|
|
213
|
+
StampImg,
|
|
214
|
+
StampPluginPackage,
|
|
215
|
+
StampRendererRegistration,
|
|
216
|
+
useActiveStamp,
|
|
217
|
+
useStampCapability,
|
|
218
|
+
useStampLibraries,
|
|
219
|
+
useStampPlugin,
|
|
220
|
+
useStampsByCategory,
|
|
221
|
+
useStampsByLibrary
|
|
222
|
+
};
|
|
223
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/svelte/components/StampPreview.svelte","../../src/svelte/components/stamp-preview-renderers.ts","../../src/svelte/components/StampRendererRegistration.svelte","../../src/svelte/hooks/use-stamp.svelte.ts","../../src/svelte/components/StampImg.svelte","../../src/svelte/index.ts"],"sourcesContent":["<script lang=\"ts\">\n import type { Rect } from '@embedpdf/models';\n import type { StampPreviewData } from '@embedpdf/plugin-stamp';\n\n interface StampPreviewProps {\n data: StampPreviewData;\n bounds: Rect;\n scale: number;\n }\n\n let { data }: StampPreviewProps = $props();\n\n const rotationDeg = $derived(((4 - data.pageRotation) % 4) * 90);\n</script>\n\n<img\n src={data.ghostUrl}\n style:width=\"100%\"\n style:height=\"100%\"\n style:opacity=\"0.6\"\n style:object-fit=\"contain\"\n style:pointer-events=\"none\"\n style:transform={rotationDeg ? `rotate(${rotationDeg}deg)` : undefined}\n alt=\"\"\n/>\n","import { PdfAnnotationSubtype } from '@embedpdf/models';\nimport type { StampPreviewData } from '@embedpdf/plugin-stamp';\nimport type { BoxedAnnotationRenderer } from '@embedpdf/plugin-annotation/svelte';\nimport { createRenderer } from '@embedpdf/plugin-annotation/svelte';\nimport StampPreview from './StampPreview.svelte';\n\nexport const stampPreviewRenderers: BoxedAnnotationRenderer[] = [\n createRenderer<never, StampPreviewData>({\n id: 'stampPreview',\n matchesPreview: (p) => p.type === PdfAnnotationSubtype.STAMP,\n renderPreview: StampPreview,\n }),\n];\n","<script lang=\"ts\">\n import { onMount } from 'svelte';\n import { getRendererRegistry } from '@embedpdf/plugin-annotation/svelte';\n import { stampPreviewRenderers } from './stamp-preview-renderers';\n\n const registry = getRendererRegistry();\n\n onMount(() => {\n if (!registry) return;\n return registry.register(stampPreviewRenderers);\n });\n</script>\n","import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { StampPlugin } from '@embedpdf/plugin-stamp';\nimport type { ResolvedStamp, StampLibrary, ActiveStampInfo } from '@embedpdf/plugin-stamp';\n\nexport const useStampPlugin = () => usePlugin<StampPlugin>(StampPlugin.id);\nexport const useStampCapability = () => useCapability<StampPlugin>(StampPlugin.id);\n\nexport function useStampLibraries() {\n const capability = useStampCapability();\n let libraries = $state<StampLibrary[]>([]);\n\n $effect(() => {\n if (!capability.provides) {\n libraries = [];\n return;\n }\n\n libraries = capability.provides.getLibraries();\n return capability.provides.onLibraryChange((libs) => {\n libraries = libs;\n });\n });\n\n return {\n get libraries() {\n return libraries;\n },\n };\n}\n\nexport function useStampsByCategory(getCategory: () => string) {\n const capability = useStampCapability();\n let stamps = $state<ResolvedStamp[]>([]);\n const category = $derived(getCategory());\n\n $effect(() => {\n if (!capability.provides) {\n stamps = [];\n return;\n }\n\n stamps = capability.provides.getStampsByCategory(category);\n return capability.provides.onLibraryChange(() => {\n stamps = capability.provides!.getStampsByCategory(category);\n });\n });\n\n return {\n get stamps() {\n return stamps;\n },\n };\n}\n\nexport function useStampsByLibrary(\n getLibraryId: () => string | undefined,\n getCategory?: () => string | undefined,\n) {\n const capability = useStampCapability();\n let stamps = $state<ResolvedStamp[]>([]);\n const libraryId = $derived(getLibraryId());\n const category = $derived(getCategory?.());\n\n $effect(() => {\n if (!capability.provides) {\n stamps = [];\n return;\n }\n\n const derive = () => {\n const libraries = capability.provides!.getLibraries();\n const results: ResolvedStamp[] = [];\n\n for (const library of libraries) {\n if (libraryId && libraryId !== 'all' && library.id !== libraryId) continue;\n\n for (const stamp of library.stamps) {\n if (category) {\n const libraryMatches = library.categories?.includes(category) ?? false;\n const stampMatches = stamp.categories?.includes(category) ?? false;\n if (!libraryMatches && !stampMatches) continue;\n }\n results.push({ library, stamp });\n }\n }\n\n stamps = results;\n };\n\n derive();\n return capability.provides.onLibraryChange(derive);\n });\n\n return {\n get stamps() {\n return stamps;\n },\n };\n}\n\nexport function useActiveStamp(getDocumentId: () => string) {\n const capability = useStampCapability();\n let activeStamp = $state<ActiveStampInfo | null>(null);\n const documentId = $derived(getDocumentId());\n\n $effect(() => {\n if (!capability.provides || !documentId) {\n activeStamp = null;\n return;\n }\n\n const scope = capability.provides.forDocument(documentId);\n activeStamp = scope.getActiveStamp();\n return scope.onActiveStampChange((stamp) => {\n activeStamp = stamp;\n });\n });\n\n return {\n get activeStamp() {\n return activeStamp;\n },\n };\n}\n","<script lang=\"ts\">\n import { ignore, PdfErrorCode } from '@embedpdf/models';\n import { useStampCapability } from '../hooks';\n import type { HTMLImgAttributes } from 'svelte/elements';\n\n interface Props extends HTMLImgAttributes {\n libraryId: string;\n pageIndex: number;\n width: number;\n dpr?: number;\n }\n\n const { libraryId, pageIndex, width, dpr, ...imgProps }: Props = $props();\n\n const stampCapability = useStampCapability();\n\n let url = $state<string | undefined>(undefined);\n let urlRef: string | null = null;\n\n $effect(() => {\n if (!stampCapability.provides) return;\n\n const task = stampCapability.provides.renderStamp(\n libraryId,\n pageIndex,\n width,\n dpr ?? window.devicePixelRatio,\n );\n\n task.wait((blob) => {\n const objectUrl = URL.createObjectURL(blob);\n urlRef = objectUrl;\n url = objectUrl;\n }, ignore);\n\n return () => {\n if (urlRef) {\n URL.revokeObjectURL(urlRef);\n urlRef = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled stamp render task',\n });\n }\n };\n });\n\n const handleImageLoad = () => {\n if (urlRef) {\n URL.revokeObjectURL(urlRef);\n urlRef = null;\n }\n };\n</script>\n\n{#if url}\n <img src={url} onload={handleImageLoad} {...imgProps} alt=\"Stamp preview\" />\n{/if}\n","import { createPluginPackage } from '@embedpdf/core';\nimport { StampPluginPackage as BaseStampPackage } from '@embedpdf/plugin-stamp';\nimport StampRendererRegistration from './components/StampRendererRegistration.svelte';\n\nexport * from './hooks';\nexport * from './components';\nexport * from '@embedpdf/plugin-stamp';\n\nexport const StampPluginPackage = createPluginPackage(BaseStampPackage)\n .addUtility(StampRendererRegistration)\n .build();\n"],"names":["BaseStampPackage"],"mappings":";;;;;;;;;;;yCAAA;;AAYQ,QAAA,+BAAyB,IAAC,QAAA,KAAQ,gBAAgB,IAAK,EAAE;MAGhE,MAAE,KAAA;;;AAAF,MAAA,cAAA,yBACW,QAAQ;yBADnB,KAAE,IAAA,QAAA;AAAA;;;;;uBAOgB,WAAW,IAAA,UAAA,EAAA,IAAa,WAAW,CAAA,SAAS;AAAA;;qBAP9D,GAAE;;AAFK;ACPD,MAAM,wBAAmD;AAAA,EAC9D,eAAwC;AAAA,IACtC,IAAI;AAAA,IACJ,gBAAgB,CAAC,MAAM,EAAE,SAAS,qBAAqB;AAAA,IACvD,eAAe;AAAA,EAAA,CAChB;AACH;sDCZA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Q,EAAA,WAAA,SAAA;AAAA;;;;;;;;AAE/C,QAAA,kBAAkB,mBAAkB;MAEtC,MAAM,EAAA,MAA2B,MAAS;AAC1C,MAAA,SAAwB;AAE5B,IAAA,YAAO,MAAO;AACP,QAAA,CAAA,gBAAgB,SAAQ;UAEvB,OAAO,gBAAgB,SAAS,YAAW,QAAA,WAAA,QAAA,WAAA,QAAA,OAAA,QAAA,OAIxC,OAAO,gBAAgB;AAGhC,SAAK;AAAA,MAAM,CAAA,SAAS;AACZ,cAAA,YAAY,IAAI,gBAAgB,IAAI;AAC1C,iBAAS;AACT,UAAA,IAAA,KAAM,WAAS,IAAA;AAAA,MACjB;AAAA,MAAG;AAAA;AAEU,WAAA,MAAA;AACP,UAAA,QAAQ;AACV,YAAI,gBAAgB,MAAM;AAC1B,iBAAS;AAAA,MACX,OAAO;AACL,aAAK,MAAK;AAAA,UACR,MAAM,aAAa;AAAA,UACnB,SAAS;AAAA;MAEb;AAAA,IACF;AAAA,EACF,CAAC;AAEK,QAAA,kBAAe,MAAS;AACxB,QAAA,QAAQ;AACV,UAAI,gBAAgB,MAAM;AAC1B,eAAS;AAAA,IACX;AAAA,EACF;;;;;UAIC,MAAG,OAAA;yBAAH,KAAG,OAAA;AAAA,mBAAM,GAAG;AAAA,gBAAU;AAAA,WAAqB;AAAA;;sBAA3C,GAAG;0BAAH,GAAG;AAAA;;gBADD,GAAG,EAAA,UAAA,UAAA;AAAA;;;;AAFA;AC9CD,MAAM,qBAAqB,oBAAoBA,oBAAgB,EACnE,WAAW,yBAAyB,EACpC,MAAA;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface StampImgProps {
|
|
2
|
+
libraryId: string;
|
|
3
|
+
pageIndex: number;
|
|
4
|
+
width: number;
|
|
5
|
+
dpr?: number;
|
|
6
|
+
}
|
|
7
|
+
declare const __VLS_export: import('vue').DefineComponent<StampImgProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<StampImgProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Rect } from '@embedpdf/models';
|
|
2
|
+
import { StampPreviewData } from '../../lib/index.ts';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
data: StampPreviewData;
|
|
5
|
+
bounds: Rect;
|
|
6
|
+
scale: number;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare var __VLS_1: {};
|
|
2
|
+
type __VLS_Slots = {} & {
|
|
3
|
+
default?: (props: typeof __VLS_1) => any;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_base: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
6
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
9
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
10
|
+
new (): {
|
|
11
|
+
$slots: S;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-stamp';
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { StampPlugin, StampLibrary, ResolvedStamp, ActiveStampInfo } from '../../lib/index.ts';
|
|
2
|
+
import { MaybeRefOrGetter } from 'vue';
|
|
3
|
+
export declare const useStampPlugin: () => import('@embedpdf/core/vue').PluginState<StampPlugin>;
|
|
4
|
+
export declare const useStampCapability: () => import('@embedpdf/core/vue').CapabilityState<Readonly<import('../../lib/index.ts').StampCapability>>;
|
|
5
|
+
export declare const useStampLibraries: () => {
|
|
6
|
+
libraries: import('vue').Ref<{
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
nameKey?: string | undefined;
|
|
10
|
+
document: {
|
|
11
|
+
id: string;
|
|
12
|
+
pageCount: number;
|
|
13
|
+
pages: {
|
|
14
|
+
index: number;
|
|
15
|
+
size: {
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
};
|
|
19
|
+
rotation: import('@embedpdf/models').Rotation;
|
|
20
|
+
}[];
|
|
21
|
+
isEncrypted: boolean;
|
|
22
|
+
isOwnerUnlocked: boolean;
|
|
23
|
+
permissions: number;
|
|
24
|
+
normalizedRotation: boolean;
|
|
25
|
+
};
|
|
26
|
+
stamps: {
|
|
27
|
+
id: string;
|
|
28
|
+
pageIndex: number;
|
|
29
|
+
name: import('@embedpdf/models').PdfAnnotationName;
|
|
30
|
+
subject: string;
|
|
31
|
+
subjectKey?: string | undefined;
|
|
32
|
+
label?: string | undefined;
|
|
33
|
+
categories?: string[] | undefined;
|
|
34
|
+
}[];
|
|
35
|
+
categories?: string[] | undefined;
|
|
36
|
+
readonly: boolean;
|
|
37
|
+
}[], StampLibrary[] | {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
nameKey?: string | undefined;
|
|
41
|
+
document: {
|
|
42
|
+
id: string;
|
|
43
|
+
pageCount: number;
|
|
44
|
+
pages: {
|
|
45
|
+
index: number;
|
|
46
|
+
size: {
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
};
|
|
50
|
+
rotation: import('@embedpdf/models').Rotation;
|
|
51
|
+
}[];
|
|
52
|
+
isEncrypted: boolean;
|
|
53
|
+
isOwnerUnlocked: boolean;
|
|
54
|
+
permissions: number;
|
|
55
|
+
normalizedRotation: boolean;
|
|
56
|
+
};
|
|
57
|
+
stamps: {
|
|
58
|
+
id: string;
|
|
59
|
+
pageIndex: number;
|
|
60
|
+
name: import('@embedpdf/models').PdfAnnotationName;
|
|
61
|
+
subject: string;
|
|
62
|
+
subjectKey?: string | undefined;
|
|
63
|
+
label?: string | undefined;
|
|
64
|
+
categories?: string[] | undefined;
|
|
65
|
+
}[];
|
|
66
|
+
categories?: string[] | undefined;
|
|
67
|
+
readonly: boolean;
|
|
68
|
+
}[]>;
|
|
69
|
+
};
|
|
70
|
+
export declare const useStampsByCategory: (category: MaybeRefOrGetter<string>) => import('vue').Ref<{
|
|
71
|
+
library: {
|
|
72
|
+
id: string;
|
|
73
|
+
name: string;
|
|
74
|
+
nameKey?: string | undefined;
|
|
75
|
+
document: {
|
|
76
|
+
id: string;
|
|
77
|
+
pageCount: number;
|
|
78
|
+
pages: {
|
|
79
|
+
index: number;
|
|
80
|
+
size: {
|
|
81
|
+
width: number;
|
|
82
|
+
height: number;
|
|
83
|
+
};
|
|
84
|
+
rotation: import('@embedpdf/models').Rotation;
|
|
85
|
+
}[];
|
|
86
|
+
isEncrypted: boolean;
|
|
87
|
+
isOwnerUnlocked: boolean;
|
|
88
|
+
permissions: number;
|
|
89
|
+
normalizedRotation: boolean;
|
|
90
|
+
};
|
|
91
|
+
stamps: {
|
|
92
|
+
id: string;
|
|
93
|
+
pageIndex: number;
|
|
94
|
+
name: import('@embedpdf/models').PdfAnnotationName;
|
|
95
|
+
subject: string;
|
|
96
|
+
subjectKey?: string | undefined;
|
|
97
|
+
label?: string | undefined;
|
|
98
|
+
categories?: string[] | undefined;
|
|
99
|
+
}[];
|
|
100
|
+
categories?: string[] | undefined;
|
|
101
|
+
readonly: boolean;
|
|
102
|
+
};
|
|
103
|
+
stamp: {
|
|
104
|
+
id: string;
|
|
105
|
+
pageIndex: number;
|
|
106
|
+
name: import('@embedpdf/models').PdfAnnotationName;
|
|
107
|
+
subject: string;
|
|
108
|
+
subjectKey?: string | undefined;
|
|
109
|
+
label?: string | undefined;
|
|
110
|
+
categories?: string[] | undefined;
|
|
111
|
+
};
|
|
112
|
+
}[], ResolvedStamp[] | {
|
|
113
|
+
library: {
|
|
114
|
+
id: string;
|
|
115
|
+
name: string;
|
|
116
|
+
nameKey?: string | undefined;
|
|
117
|
+
document: {
|
|
118
|
+
id: string;
|
|
119
|
+
pageCount: number;
|
|
120
|
+
pages: {
|
|
121
|
+
index: number;
|
|
122
|
+
size: {
|
|
123
|
+
width: number;
|
|
124
|
+
height: number;
|
|
125
|
+
};
|
|
126
|
+
rotation: import('@embedpdf/models').Rotation;
|
|
127
|
+
}[];
|
|
128
|
+
isEncrypted: boolean;
|
|
129
|
+
isOwnerUnlocked: boolean;
|
|
130
|
+
permissions: number;
|
|
131
|
+
normalizedRotation: boolean;
|
|
132
|
+
};
|
|
133
|
+
stamps: {
|
|
134
|
+
id: string;
|
|
135
|
+
pageIndex: number;
|
|
136
|
+
name: import('@embedpdf/models').PdfAnnotationName;
|
|
137
|
+
subject: string;
|
|
138
|
+
subjectKey?: string | undefined;
|
|
139
|
+
label?: string | undefined;
|
|
140
|
+
categories?: string[] | undefined;
|
|
141
|
+
}[];
|
|
142
|
+
categories?: string[] | undefined;
|
|
143
|
+
readonly: boolean;
|
|
144
|
+
};
|
|
145
|
+
stamp: {
|
|
146
|
+
id: string;
|
|
147
|
+
pageIndex: number;
|
|
148
|
+
name: import('@embedpdf/models').PdfAnnotationName;
|
|
149
|
+
subject: string;
|
|
150
|
+
subjectKey?: string | undefined;
|
|
151
|
+
label?: string | undefined;
|
|
152
|
+
categories?: string[] | undefined;
|
|
153
|
+
};
|
|
154
|
+
}[]>;
|
|
155
|
+
export declare const useStampsByLibrary: (libraryId: MaybeRefOrGetter<string | undefined>, category?: MaybeRefOrGetter<string | undefined>) => import('vue').Ref<{
|
|
156
|
+
library: {
|
|
157
|
+
id: string;
|
|
158
|
+
name: string;
|
|
159
|
+
nameKey?: string | undefined;
|
|
160
|
+
document: {
|
|
161
|
+
id: string;
|
|
162
|
+
pageCount: number;
|
|
163
|
+
pages: {
|
|
164
|
+
index: number;
|
|
165
|
+
size: {
|
|
166
|
+
width: number;
|
|
167
|
+
height: number;
|
|
168
|
+
};
|
|
169
|
+
rotation: import('@embedpdf/models').Rotation;
|
|
170
|
+
}[];
|
|
171
|
+
isEncrypted: boolean;
|
|
172
|
+
isOwnerUnlocked: boolean;
|
|
173
|
+
permissions: number;
|
|
174
|
+
normalizedRotation: boolean;
|
|
175
|
+
};
|
|
176
|
+
stamps: {
|
|
177
|
+
id: string;
|
|
178
|
+
pageIndex: number;
|
|
179
|
+
name: import('@embedpdf/models').PdfAnnotationName;
|
|
180
|
+
subject: string;
|
|
181
|
+
subjectKey?: string | undefined;
|
|
182
|
+
label?: string | undefined;
|
|
183
|
+
categories?: string[] | undefined;
|
|
184
|
+
}[];
|
|
185
|
+
categories?: string[] | undefined;
|
|
186
|
+
readonly: boolean;
|
|
187
|
+
};
|
|
188
|
+
stamp: {
|
|
189
|
+
id: string;
|
|
190
|
+
pageIndex: number;
|
|
191
|
+
name: import('@embedpdf/models').PdfAnnotationName;
|
|
192
|
+
subject: string;
|
|
193
|
+
subjectKey?: string | undefined;
|
|
194
|
+
label?: string | undefined;
|
|
195
|
+
categories?: string[] | undefined;
|
|
196
|
+
};
|
|
197
|
+
}[], ResolvedStamp[] | {
|
|
198
|
+
library: {
|
|
199
|
+
id: string;
|
|
200
|
+
name: string;
|
|
201
|
+
nameKey?: string | undefined;
|
|
202
|
+
document: {
|
|
203
|
+
id: string;
|
|
204
|
+
pageCount: number;
|
|
205
|
+
pages: {
|
|
206
|
+
index: number;
|
|
207
|
+
size: {
|
|
208
|
+
width: number;
|
|
209
|
+
height: number;
|
|
210
|
+
};
|
|
211
|
+
rotation: import('@embedpdf/models').Rotation;
|
|
212
|
+
}[];
|
|
213
|
+
isEncrypted: boolean;
|
|
214
|
+
isOwnerUnlocked: boolean;
|
|
215
|
+
permissions: number;
|
|
216
|
+
normalizedRotation: boolean;
|
|
217
|
+
};
|
|
218
|
+
stamps: {
|
|
219
|
+
id: string;
|
|
220
|
+
pageIndex: number;
|
|
221
|
+
name: import('@embedpdf/models').PdfAnnotationName;
|
|
222
|
+
subject: string;
|
|
223
|
+
subjectKey?: string | undefined;
|
|
224
|
+
label?: string | undefined;
|
|
225
|
+
categories?: string[] | undefined;
|
|
226
|
+
}[];
|
|
227
|
+
categories?: string[] | undefined;
|
|
228
|
+
readonly: boolean;
|
|
229
|
+
};
|
|
230
|
+
stamp: {
|
|
231
|
+
id: string;
|
|
232
|
+
pageIndex: number;
|
|
233
|
+
name: import('@embedpdf/models').PdfAnnotationName;
|
|
234
|
+
subject: string;
|
|
235
|
+
subjectKey?: string | undefined;
|
|
236
|
+
label?: string | undefined;
|
|
237
|
+
categories?: string[] | undefined;
|
|
238
|
+
};
|
|
239
|
+
}[]>;
|
|
240
|
+
export declare const useActiveStamp: (documentId: MaybeRefOrGetter<string>) => import('vue').Ref<{
|
|
241
|
+
libraryId: string;
|
|
242
|
+
stamp: {
|
|
243
|
+
id: string;
|
|
244
|
+
pageIndex: number;
|
|
245
|
+
name: import('@embedpdf/models').PdfAnnotationName;
|
|
246
|
+
subject: string;
|
|
247
|
+
subjectKey?: string | undefined;
|
|
248
|
+
label?: string | undefined;
|
|
249
|
+
categories?: string[] | undefined;
|
|
250
|
+
};
|
|
251
|
+
} | null, ActiveStampInfo | {
|
|
252
|
+
libraryId: string;
|
|
253
|
+
stamp: {
|
|
254
|
+
id: string;
|
|
255
|
+
pageIndex: number;
|
|
256
|
+
name: import('@embedpdf/models').PdfAnnotationName;
|
|
257
|
+
subject: string;
|
|
258
|
+
subjectKey?: string | undefined;
|
|
259
|
+
label?: string | undefined;
|
|
260
|
+
categories?: string[] | undefined;
|
|
261
|
+
};
|
|
262
|
+
} | null>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=require("@embedpdf/plugin-stamp"),r=require("vue"),a=require("@embedpdf/plugin-annotation/vue"),o=require("@embedpdf/models"),n=require("@embedpdf/core/vue"),i=["src"],l=r.defineComponent({__name:"stamp-preview",props:{data:{},bounds:{},scale:{}},setup(e){const t=e,a=r.computed(()=>(4-t.data.pageRotation)%4*90),o=r.computed(()=>({width:"100%",height:"100%",opacity:.6,objectFit:"contain",pointerEvents:"none",transform:a.value?`rotate(${a.value}deg)`:void 0}));return(t,a)=>(r.openBlock(),r.createElementBlock("img",{src:e.data.ghostUrl,style:r.normalizeStyle(o.value),alt:""},null,12,i))}}),s=[a.createRenderer({id:"stampPreview",matchesPreview:e=>e.type===o.PdfAnnotationSubtype.STAMP,renderPreview:l})],u=r.defineComponent({__name:"stamp-renderer-registration",setup:e=>(a.useRegisterRenderers(s),(e,t)=>r.renderSlot(e.$slots,"default"))}),p=()=>n.useCapability(t.StampPlugin.id),d=["src"],c=r.defineComponent({__name:"stamp-img",props:{libraryId:{},pageIndex:{},width:{},dpr:{}},setup(e){const t=e,{provides:a}=p(),n=r.ref(null);let i=null;function l(){i&&(URL.revokeObjectURL(i),i=null)}let s=null;return r.watch([()=>a.value,()=>t.libraryId,()=>t.pageIndex,()=>t.width,()=>t.dpr],([e,t,r,a,u],p,d)=>{if(s&&(s(),s=null),!e)return void(n.value=null);const c=e.renderStamp(t,r,a,u??window.devicePixelRatio);s=()=>c.abort({code:o.PdfErrorCode.Cancelled,message:"canceled stamp render task"}),c.wait(e=>{l();const t=URL.createObjectURL(e);i=t,n.value=t,s=null},o.ignore),d(()=>{s&&(s(),s=null),l()})},{immediate:!0}),(e,t)=>n.value?(r.openBlock(),r.createElementBlock("img",r.mergeProps({key:0,src:n.value},e.$attrs,{onLoad:l}),null,16,d)):r.createCommentVNode("",!0)}}),m=e.createPluginPackage(t.StampPluginPackage).addUtility(u).build();exports.StampImg=c,exports.StampPluginPackage=m,exports.StampRendererRegistration=u,exports.useActiveStamp=e=>{const{provides:t}=p(),a=r.ref(null);return r.watch([t,()=>r.toValue(e)],([e,t],r,o)=>{if(!e||!t)return void(a.value=null);const n=e.forDocument(t);a.value=n.getActiveStamp();o(n.onActiveStampChange(e=>{a.value=e}))},{immediate:!0}),a},exports.useStampCapability=p,exports.useStampLibraries=()=>{const{provides:e}=p(),t=r.ref([]);return r.watch(e,(e,r,a)=>{if(!e)return void(t.value=[]);t.value=e.getLibraries();a(e.onLibraryChange(e=>{t.value=e}))},{immediate:!0}),{libraries:t}},exports.useStampPlugin=()=>n.usePlugin(t.StampPlugin.id),exports.useStampsByCategory=e=>{const{provides:t}=p(),a=r.ref([]);return r.watch([t,()=>r.toValue(e)],([e,t],r,o)=>{if(!e)return void(a.value=[]);a.value=e.getStampsByCategory(t);o(e.onLibraryChange(()=>{a.value=e.getStampsByCategory(t)}))},{immediate:!0}),a},exports.useStampsByLibrary=(e,t)=>{const{provides:a}=p(),o=r.ref([]);return r.watch([a,()=>r.toValue(e),()=>r.toValue(t)],([e,t,r],a,n)=>{if(!e)return void(o.value=[]);const i=()=>{var a,n;const i=e.getLibraries(),l=[];for(const e of i)if(!t||"all"===t||e.id===t)for(const t of e.stamps){if(r){const o=(null==(a=e.categories)?void 0:a.includes(r))??!1,i=(null==(n=t.categories)?void 0:n.includes(r))??!1;if(!o&&!i)continue}l.push({library:e,stamp:t})}o.value=l};i();n(e.onLibraryChange(i))},{immediate:!0}),o},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/vue/components/stamp-preview.vue","../../src/vue/components/stamp-preview-renderers.ts","../../src/vue/components/stamp-renderer-registration.vue","../../src/vue/hooks/use-stamp.ts","../../src/vue/components/stamp-img.vue","../../src/vue/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue';\nimport type { Rect } from '@embedpdf/models';\nimport type { StampPreviewData } from '@embedpdf/plugin-stamp';\n\nconst props = defineProps<{\n data: StampPreviewData;\n bounds: Rect;\n scale: number;\n}>();\n\nconst rotationDeg = computed(() => ((4 - props.data.pageRotation) % 4) * 90);\n\nconst style = computed(() => ({\n width: '100%',\n height: '100%',\n opacity: 0.6,\n objectFit: 'contain' as const,\n pointerEvents: 'none' as const,\n transform: rotationDeg.value ? `rotate(${rotationDeg.value}deg)` : undefined,\n}));\n</script>\n\n<template>\n <img :src=\"data.ghostUrl\" :style=\"style\" alt=\"\" />\n</template>\n","import { PdfAnnotationSubtype } from '@embedpdf/models';\nimport type { StampPreviewData } from '@embedpdf/plugin-stamp';\nimport type { BoxedAnnotationRenderer } from '@embedpdf/plugin-annotation/vue';\nimport { createRenderer } from '@embedpdf/plugin-annotation/vue';\nimport StampPreview from './stamp-preview.vue';\n\nexport const stampPreviewRenderers: BoxedAnnotationRenderer[] = [\n createRenderer<never, StampPreviewData>({\n id: 'stampPreview',\n matchesPreview: (p) => p.type === PdfAnnotationSubtype.STAMP,\n renderPreview: StampPreview,\n }),\n];\n","<script setup lang=\"ts\">\nimport { useRegisterRenderers } from '@embedpdf/plugin-annotation/vue';\nimport { stampPreviewRenderers } from './stamp-preview-renderers';\n\nuseRegisterRenderers(stampPreviewRenderers);\n</script>\n\n<template>\n <slot />\n</template>\n","import { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { StampPlugin, StampLibrary, ResolvedStamp, ActiveStampInfo } from '@embedpdf/plugin-stamp';\nimport { ref, watch, toValue, type MaybeRefOrGetter } from 'vue';\n\nexport const useStampPlugin = () => usePlugin<StampPlugin>(StampPlugin.id);\nexport const useStampCapability = () => useCapability<StampPlugin>(StampPlugin.id);\n\nexport const useStampLibraries = () => {\n const { provides } = useStampCapability();\n const libraries = ref<StampLibrary[]>([]);\n\n watch(\n provides,\n (capability, _, onCleanup) => {\n if (!capability) {\n libraries.value = [];\n return;\n }\n\n libraries.value = capability.getLibraries();\n const unsubscribe = capability.onLibraryChange((libs) => {\n libraries.value = libs;\n });\n onCleanup(unsubscribe);\n },\n { immediate: true },\n );\n\n return { libraries };\n};\n\nexport const useStampsByCategory = (category: MaybeRefOrGetter<string>) => {\n const { provides } = useStampCapability();\n const stamps = ref<ResolvedStamp[]>([]);\n\n watch(\n [provides, () => toValue(category)],\n ([capability, cat], _, onCleanup) => {\n if (!capability) {\n stamps.value = [];\n return;\n }\n\n stamps.value = capability.getStampsByCategory(cat);\n const unsubscribe = capability.onLibraryChange(() => {\n stamps.value = capability.getStampsByCategory(cat);\n });\n onCleanup(unsubscribe);\n },\n { immediate: true },\n );\n\n return stamps;\n};\n\nexport const useStampsByLibrary = (\n libraryId: MaybeRefOrGetter<string | undefined>,\n category?: MaybeRefOrGetter<string | undefined>,\n) => {\n const { provides } = useStampCapability();\n const stamps = ref<ResolvedStamp[]>([]);\n\n watch(\n [provides, () => toValue(libraryId), () => toValue(category)],\n ([capability, libId, cat], _, onCleanup) => {\n if (!capability) {\n stamps.value = [];\n return;\n }\n\n const derive = () => {\n const libraries = capability.getLibraries();\n const results: ResolvedStamp[] = [];\n\n for (const library of libraries) {\n if (libId && libId !== 'all' && library.id !== libId) continue;\n\n for (const stamp of library.stamps) {\n if (cat) {\n const libraryMatches = library.categories?.includes(cat) ?? false;\n const stampMatches = stamp.categories?.includes(cat) ?? false;\n if (!libraryMatches && !stampMatches) continue;\n }\n results.push({ library, stamp });\n }\n }\n\n stamps.value = results;\n };\n\n derive();\n const unsubscribe = capability.onLibraryChange(derive);\n onCleanup(unsubscribe);\n },\n { immediate: true },\n );\n\n return stamps;\n};\n\nexport const useActiveStamp = (documentId: MaybeRefOrGetter<string>) => {\n const { provides } = useStampCapability();\n const activeStamp = ref<ActiveStampInfo | null>(null);\n\n watch(\n [provides, () => toValue(documentId)],\n ([capability, docId], _, onCleanup) => {\n if (!capability || !docId) {\n activeStamp.value = null;\n return;\n }\n\n const scope = capability.forDocument(docId);\n activeStamp.value = scope.getActiveStamp();\n const unsubscribe = scope.onActiveStampChange((stamp) => {\n activeStamp.value = stamp;\n });\n onCleanup(unsubscribe);\n },\n { immediate: true },\n );\n\n return activeStamp;\n};\n","<script setup lang=\"ts\">\nimport { ref, watch } from 'vue';\nimport { useStampCapability } from '../hooks';\nimport { ignore, PdfErrorCode } from '@embedpdf/models';\n\ninterface StampImgProps {\n libraryId: string;\n pageIndex: number;\n width: number;\n dpr?: number;\n}\n\nconst props = defineProps<StampImgProps>();\n\nconst { provides } = useStampCapability();\n\nconst url = ref<string | null>(null);\nlet urlToRevoke: string | null = null;\n\nfunction revoke() {\n if (urlToRevoke) {\n URL.revokeObjectURL(urlToRevoke);\n urlToRevoke = null;\n }\n}\n\nlet abortTask: (() => void) | null = null;\n\nwatch(\n [\n () => provides.value,\n () => props.libraryId,\n () => props.pageIndex,\n () => props.width,\n () => props.dpr,\n ],\n ([capability, libraryId, pageIndex, width, dpr], _, onCleanup) => {\n if (abortTask) {\n abortTask();\n abortTask = null;\n }\n\n if (!capability) {\n url.value = null;\n return;\n }\n\n const task = capability.renderStamp(\n libraryId,\n pageIndex,\n width,\n dpr ?? window.devicePixelRatio,\n );\n\n abortTask = () =>\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled stamp render task',\n });\n\n task.wait((blob) => {\n revoke();\n const objectUrl = URL.createObjectURL(blob);\n urlToRevoke = objectUrl;\n url.value = objectUrl;\n abortTask = null;\n }, ignore);\n\n onCleanup(() => {\n if (abortTask) {\n abortTask();\n abortTask = null;\n }\n revoke();\n });\n },\n { immediate: true },\n);\n</script>\n\n<template>\n <img v-if=\"url\" :src=\"url\" v-bind=\"$attrs\" @load=\"revoke\" />\n</template>\n","import { createPluginPackage } from '@embedpdf/core';\nimport { StampPluginPackage as BaseStampPackage } from '@embedpdf/plugin-stamp';\nimport StampRendererRegistration from './components/stamp-renderer-registration.vue';\n\nexport * from './hooks';\nexport * from './components';\nexport * from '@embedpdf/plugin-stamp';\n\nexport const StampPluginPackage = createPluginPackage(BaseStampPackage)\n .addUtility(StampRendererRegistration)\n .build();\n"],"names":["props","__props","rotationDeg","computed","data","pageRotation","style","width","height","opacity","objectFit","pointerEvents","transform","value","_createElementBlock","src","ghostUrl","alt","stampPreviewRenderers","createRenderer","id","matchesPreview","p","type","PdfAnnotationSubtype","STAMP","renderPreview","StampPreview","useRegisterRenderers","_renderSlot","_ctx","$slots","useStampCapability","useCapability","StampPlugin","provides","url","ref","urlToRevoke","revoke","URL","revokeObjectURL","abortTask","watch","libraryId","pageIndex","dpr","capability","_","onCleanup","task","renderStamp","window","devicePixelRatio","abort","code","PdfErrorCode","Cancelled","message","wait","blob","objectUrl","createObjectURL","ignore","immediate","_openBlock","_mergeProps","$attrs","onLoad","_hoisted_1","StampPluginPackage","createPluginPackage","BaseStampPackage","addUtility","StampRendererRegistration","build","documentId","activeStamp","toValue","docId","scope","forDocument","getActiveStamp","onActiveStampChange","stamp","libraries","getLibraries","onLibraryChange","libs","usePlugin","category","stamps","cat","getStampsByCategory","libId","derive","results","library","libraryMatches","_a","categories","includes","stampMatches","_b","push"],"mappings":"oXAKA,MAAMA,EAAQC,EAMRC,EAAcC,WAAS,KAAQ,EAAIH,EAAMI,KAAKC,cAAgB,EAAK,IAEnEC,EAAQH,EAAAA,SAAS,KAAA,CACrBI,MAAO,OACPC,OAAQ,OACRC,QAAS,GACTC,UAAW,UACXC,cAAe,OACfC,UAAWV,EAAYW,MAAQ,UAAUX,EAAYW,iBAAc,iCAKnEC,EAAAA,mBAAkD,MAAA,CAA5CC,IAAKd,EAAAG,KAAKY,SAAWV,uBAAOA,EAAAO,OAAOI,IAAI,mBClBlCC,EAAmD,CAC9DC,iBAAwC,CACtCC,GAAI,eACJC,eAAiBC,G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AO9E,MAAQ,IAIjB,MAAMkF,EAAS,aACb,MAAMV,EAAYtC,EAAWuC,eACvBU,EAA2B,GAEjC,IAAA,MAAWC,KAAWZ,EACpB,IAAIS,GAAmB,QAAVA,GAAmBG,EAAQ7E,KAAO0E,EAE/C,IAAA,MAAWV,KAASa,EAAQN,OAAQ,CAClC,GAAIC,EAAK,CACP,MAAMM,GAAiB,OAAAC,EAAAF,EAAQG,iBAAR,EAAAD,EAAoBE,SAAST,MAAQ,EACtDU,GAAe,OAAAC,EAAAnB,EAAMgB,iBAAN,EAAAG,EAAkBF,SAAST,MAAQ,EACxD,IAAKM,IAAmBI,EAAc,QACxC,CACAN,EAAQQ,KAAK,CAAEP,UAASb,SAC1B,CAGFO,EAAO9E,MAAQmF,GAGjBD,IAEA9C,EADoBF,EAAWwC,gBAAgBQ,KAGjD,CAAE/B,WAAW,IAGR2B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from './hooks';
|
|
2
|
+
export * from './components';
|
|
3
|
+
export * from '../lib/index.ts';
|
|
4
|
+
export declare const StampPluginPackage: import('@embedpdf/core').WithAutoMount<import('@embedpdf/core').PluginPackage<import('../lib/index.ts').StampPlugin, import('../lib/index.ts').StampPluginConfig, import('../lib/index.ts').StampState, import('../lib/index.ts').StampAction>>;
|