@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.
Files changed (77) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.cjs +2 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +980 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/lib/actions.d.ts +14 -0
  8. package/dist/lib/defaults/name-map.d.ts +2 -0
  9. package/dist/lib/handlers/rubber-stamp.handler.d.ts +4 -0
  10. package/dist/lib/index.d.ts +11 -0
  11. package/dist/lib/manifest.d.ts +4 -0
  12. package/dist/lib/reducer.d.ts +5 -0
  13. package/dist/lib/stamp-plugin.d.ts +54 -0
  14. package/dist/lib/tools.d.ts +58 -0
  15. package/dist/lib/types.d.ts +135 -0
  16. package/dist/preact/adapter.d.ts +5 -0
  17. package/dist/preact/annotation.d.ts +1 -0
  18. package/dist/preact/core.d.ts +1 -0
  19. package/dist/preact/index.cjs +2 -0
  20. package/dist/preact/index.cjs.map +1 -0
  21. package/dist/preact/index.d.ts +1 -0
  22. package/dist/preact/index.js +147 -0
  23. package/dist/preact/index.js.map +1 -0
  24. package/dist/react/adapter.d.ts +2 -0
  25. package/dist/react/annotation.d.ts +1 -0
  26. package/dist/react/core.d.ts +1 -0
  27. package/dist/react/index.cjs +2 -0
  28. package/dist/react/index.cjs.map +1 -0
  29. package/dist/react/index.d.ts +1 -0
  30. package/dist/react/index.js +146 -0
  31. package/dist/react/index.js.map +1 -0
  32. package/dist/shared/components/index.d.ts +3 -0
  33. package/dist/shared/components/stamp-img.d.ts +10 -0
  34. package/dist/shared/components/stamp-preview-renderers.d.ts +2 -0
  35. package/dist/shared/components/stamp-renderer-registration.d.ts +1 -0
  36. package/dist/shared/hooks/index.d.ts +1 -0
  37. package/dist/shared/hooks/use-stamp.d.ts +18 -0
  38. package/dist/shared/index.d.ts +4 -0
  39. package/dist/shared-preact/components/index.d.ts +3 -0
  40. package/dist/shared-preact/components/stamp-img.d.ts +10 -0
  41. package/dist/shared-preact/components/stamp-preview-renderers.d.ts +2 -0
  42. package/dist/shared-preact/components/stamp-renderer-registration.d.ts +1 -0
  43. package/dist/shared-preact/hooks/index.d.ts +1 -0
  44. package/dist/shared-preact/hooks/use-stamp.d.ts +18 -0
  45. package/dist/shared-preact/index.d.ts +4 -0
  46. package/dist/shared-react/components/index.d.ts +3 -0
  47. package/dist/shared-react/components/stamp-img.d.ts +10 -0
  48. package/dist/shared-react/components/stamp-preview-renderers.d.ts +2 -0
  49. package/dist/shared-react/components/stamp-renderer-registration.d.ts +1 -0
  50. package/dist/shared-react/hooks/index.d.ts +1 -0
  51. package/dist/shared-react/hooks/use-stamp.d.ts +18 -0
  52. package/dist/shared-react/index.d.ts +4 -0
  53. package/dist/svelte/components/StampImg.svelte.d.ts +10 -0
  54. package/dist/svelte/components/StampPreview.svelte.d.ts +10 -0
  55. package/dist/svelte/components/StampRendererRegistration.svelte.d.ts +18 -0
  56. package/dist/svelte/components/index.d.ts +2 -0
  57. package/dist/svelte/components/stamp-preview-renderers.d.ts +2 -0
  58. package/dist/svelte/hooks/index.d.ts +1 -0
  59. package/dist/svelte/hooks/use-stamp.svelte.d.ts +23 -0
  60. package/dist/svelte/index.cjs +2 -0
  61. package/dist/svelte/index.cjs.map +1 -0
  62. package/dist/svelte/index.d.ts +4 -0
  63. package/dist/svelte/index.js +223 -0
  64. package/dist/svelte/index.js.map +1 -0
  65. package/dist/vue/components/index.d.ts +2 -0
  66. package/dist/vue/components/stamp-img.vue.d.ts +9 -0
  67. package/dist/vue/components/stamp-preview-renderers.d.ts +2 -0
  68. package/dist/vue/components/stamp-preview.vue.d.ts +10 -0
  69. package/dist/vue/components/stamp-renderer-registration.vue.d.ts +13 -0
  70. package/dist/vue/hooks/index.d.ts +1 -0
  71. package/dist/vue/hooks/use-stamp.d.ts +262 -0
  72. package/dist/vue/index.cjs +2 -0
  73. package/dist/vue/index.cjs.map +1 -0
  74. package/dist/vue/index.d.ts +4 -0
  75. package/dist/vue/index.js +235 -0
  76. package/dist/vue/index.js.map +1 -0
  77. package/package.json +84 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 CloudPDF
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=require("@embedpdf/models"),a=require("@embedpdf/plugin-annotation"),r="stamp",o={id:r,name:"Stamp Plugin",version:"1.0.0",provides:["stamp"],requires:["annotation"],optional:["i18n"],defaultConfig:{defaultLibrary:{id:"custom",name:"Custom Stamps",nameKey:"stamp.library.custom",categories:["custom","sidebar"]},manifests:[{url:"https://cdn.jsdelivr.net/npm/@embedpdf/default-stamps/{locale}/manifest.json",fallbackLocale:"en"}]}},n="STAMP/ADD_LIBRARY",i="STAMP/REMOVE_LIBRARY";function s(e){return{type:n,payload:e}}function l(e){return{type:i,payload:e}}const d={annotationType:t.PdfAnnotationSubtype.STAMP,create(e){const{onPreview:r,onCommit:o,getTool:n,pageSize:i,pageRotation:s,getToolContext:l}=e;return{onPointerMove:e=>{const a=l();if(!(null==a?void 0:a.stampSize))return;const{width:o,height:n}=a.stampSize;r({type:t.PdfAnnotationSubtype.STAMP,bounds:{origin:{x:e.x-o/2,y:e.y-n/2},size:{width:o,height:n}},data:{rect:{origin:{x:e.x-o/2,y:e.y-n/2},size:{width:o,height:n}},ghostUrl:a.ghostUrl,pageRotation:s}})},onPointerDown:d=>{var c;const m=n(),u=l();if(!m||!(null==u?void 0:u.stampSize))return;const{width:p,height:g}=u.stampSize,h={origin:{x:d.x-p/2,y:d.y-g/2},size:{width:p,height:g}};let f={...m.defaults,rect:h,type:t.PdfAnnotationSubtype.STAMP,name:u.stamp.name??m.defaults.name??t.PdfAnnotationName.Custom,subject:u.stamp.subject??m.defaults.subject??"Custom Stamp",flags:m.defaults.flags??["print"],pageIndex:e.pageIndex,id:t.uuidV4(),created:new Date};(null==(c=m.behavior)?void 0:c.insertUpright)&&(f=a.applyInsertUpright(f,s,!1)),f=a.clampAnnotationToPage(f,i),o(f,{appearance:u.appearance}),r(null)},onPointerLeave:()=>{r(null)}}}},c="rubberStamp",m=[a.defineAnnotationTool({id:c,name:"Rubber Stamp",labelKey:"stamp.rubberStamp",categories:["annotation","stamp","insert"],matchScore:()=>0,interaction:{exclusive:!0,cursor:"copy",isDraggable:!0,isResizable:!0,isRotatable:!1,lockAspectRatio:!0,isGroupDraggable:!0,isGroupResizable:!1,isGroupRotatable:!1},defaults:{type:t.PdfAnnotationSubtype.STAMP},behavior:{deactivateToolAfterCreate:!0,selectAfterCreate:!0,insertUpright:!0,useAppearanceStream:!0},pointerHandler:d})],u={Approved:t.PdfAnnotationName.Approved,Experimental:t.PdfAnnotationName.Experimental,NotApproved:t.PdfAnnotationName.NotApproved,AsIs:t.PdfAnnotationName.AsIs,Expired:t.PdfAnnotationName.Expired,NotForPublicRelease:t.PdfAnnotationName.NotForPublicRelease,Confidential:t.PdfAnnotationName.Confidential,Final:t.PdfAnnotationName.Final,Sold:t.PdfAnnotationName.Sold,Departmental:t.PdfAnnotationName.Departmental,ForComment:t.PdfAnnotationName.ForComment,TopSecret:t.PdfAnnotationName.TopSecret,Draft:t.PdfAnnotationName.Draft,ForPublicRelease:t.PdfAnnotationName.ForPublicRelease,Completed:t.PdfAnnotationName.Completed,Void:t.PdfAnnotationName.Void,PreliminaryResults:t.PdfAnnotationName.PreliminaryResults,InformationOnly:t.PdfAnnotationName.InformationOnly,Rejected:t.PdfAnnotationName.Rejected,Witness:t.PdfAnnotationName.Witness,InitialHere:t.PdfAnnotationName.InitialHere,SignHere:t.PdfAnnotationName.SignHere,Accepted:t.PdfAnnotationName.Accepted,Custom:t.PdfAnnotationName.Custom,Image:t.PdfAnnotationName.Image};const p=class extends e.BasePlugin{constructor(a,r,o){var n,i;if(super(a,r),this.config=o,this.instanceId=t.uuidV4(),this.libraries=new Map,this.libraryChange$=e.createEmitter(),this.activeStamp$=e.createScopedEmitter((e,t)=>({documentId:e,activeStamp:t})),this.managedManifests=[],this.annotation=null,this.i18n=null,this.localeUnsubscribe=null,this.toolChangeUnsubscribe=null,this.currentGhostUrl=null,this.annotation=(null==(n=r.getPlugin("annotation"))?void 0:n.provides())??null,this.annotation){for(const e of m)this.annotation.addTool(e);this.toolChangeUnsubscribe=this.annotation.onActiveToolChange(({documentId:e,tool:t})=>{(null==t?void 0:t.id)!==c&&(this.currentGhostUrl&&(URL.revokeObjectURL(this.currentGhostUrl),this.currentGhostUrl=null),this.activeStamp$.emit(e,null))})}this.i18n=(null==(i=r.getPlugin("i18n"))?void 0:i.provides())??null}async initialize(){if(this.config.libraries)for(const e of this.config.libraries)await this.loadLibraryInternal(e).toPromise();this.config.manifests&&this.config.manifests.length>0&&await this.initializeManifests()}buildCapability(){return{getLibraries:()=>this.getLibraries(),getStampsByCategory:e=>this.getStampsByCategory(e),renderStamp:(e,t,a,r)=>this.renderStamp(e,t,a,r),loadLibrary:e=>this.loadLibrary(e),loadLibraryFromManifest:e=>this.loadLibraryFromManifest(e),createNewLibrary:(e,t)=>this.createNewLibrary(e,t),addStampToLibrary:(e,t,a)=>this.addStampToLibrary(e,t,a),removeStampFromLibrary:(e,t)=>this.removeStampFromLibrary(e,t),updateStamp:(e,t,a)=>this.updateStamp(e,t,a),updateLibrary:(e,t)=>this.updateLibrary(e,t),removeLibrary:e=>this.removeLibrary(e),exportLibrary:e=>this.exportLibrary(e),forDocument:e=>this.createStampScope(e),onActiveStampChange:this.activeStamp$.onGlobal,onLibraryChange:this.libraryChange$.on}}getLibraries(){return Array.from(this.libraries.values())}getStampsByCategory(e){var t,a;const r=[];for(const o of this.libraries.values()){const n=(null==(t=o.categories)?void 0:t.includes(e))??!1;for(const t of o.stamps){const i=(null==(a=t.categories)?void 0:a.includes(e))??!1;(n||i)&&r.push({library:o,stamp:t})}}return r}renderStamp(e,a,r,o){const n=this.libraries.get(e);if(!n){const a=new t.Task;return a.reject({code:t.PdfErrorCode.NotFound,message:`Stamp library not found: ${e}`}),a}const i=n.document.pages[a];if(!i){const r=new t.Task;return r.reject({code:t.PdfErrorCode.NotFound,message:`Page ${a} not found in stamp library: ${e}`}),r}const s=r/i.size.width;return this.engine.renderPageRect(n.document,i,{origin:{x:0,y:0},size:i.size},{scaleFactor:s,dpr:o??1,withAnnotations:!0,rotation:i.rotation,transparentBackground:!0})}loadLibrary(e){return this.loadLibraryInternal(e)}createNewLibrary(e,a){const r=new t.Task,o=(null==a?void 0:a.id)??this.generateLibraryId(),n=this.getLibraryDocumentId(o);return this.engine.createDocument(n).wait(t=>{const n={id:o,name:e,nameKey:null==a?void 0:a.nameKey,document:t,stamps:[],categories:null==a?void 0:a.categories,readonly:(null==a?void 0:a.readonly)??!1};this.libraries.set(o,n),this.dispatch(s(o)),this.emitLibraryChange(),r.resolve(o)},t=>{this.logger.error("StampPlugin","CreateNewLibrary",`Failed to create library: ${e}`,t),r.fail(t)}),r}addStampToLibrary(e,a,r){const o=new t.Task,n=this.libraries.get(e);if(!n)return o.reject({code:t.PdfErrorCode.NotFound,message:`Stamp library not found: ${e}`}),o;if(n.readonly)return o.reject({code:t.PdfErrorCode.NotSupport,message:`Cannot add stamps to readonly library: ${e}`}),o;const i=`stamp-temp-${Date.now()}`;return this.engine.openDocumentBuffer({id:i,content:r}).wait(e=>{this.engine.importPages(n.document,e,[0]).wait(r=>{const i=r[0];n.document.pages.push(i),n.document.pageCount=n.document.pages.length;const s={...a,id:t.uuidV4(),pageIndex:i.index};n.stamps.push(s),this.engine.closeDocument(e).wait(()=>{this.emitLibraryChange(),o.resolve()},()=>{this.emitLibraryChange(),o.resolve()})},t=>{this.logger.error("StampPlugin","AddStampToLibrary","Failed to import page",t),this.engine.closeDocument(e).wait(()=>o.fail(t),()=>o.fail(t))})},e=>{this.logger.error("StampPlugin","AddStampToLibrary","Failed to open temp document",e),o.fail(e)}),o}createStampScope(e){return{createStampFromAnnotation:(t,a,r)=>this.createStampFromAnnotation(e,t,a,r),createStampFromAnnotations:(t,a,r)=>this.createStampFromAnnotations(e,t,a,r),activateStampPlacement:(t,a)=>this.activateStampPlacement(e,t,a),activateStampPlacementById:(t,a)=>this.activateStampPlacementById(e,t,a),getActiveStamp:()=>this.getActiveStamp(e),onActiveStampChange:this.activeStamp$.forScope(e)}}activateStampPlacementById(e,a,r){const o=new t.Task,n=this.libraries.get(a);if(!n)return o.reject({code:t.PdfErrorCode.NotFound,message:`Stamp library not found: ${a}`}),o;const i=n.stamps.find(e=>e.id===r);return i?this.activateStampPlacement(e,a,i):(o.reject({code:t.PdfErrorCode.NotFound,message:`Stamp ${r} not found in library: ${a}`}),o)}getActiveStamp(e){return this.activeStamp$.getValue(e)??null}activateStampPlacement(e,a,r){const o=new t.Task,n=this.libraries.get(a);if(!n)return o.reject({code:t.PdfErrorCode.NotFound,message:`Stamp library not found: ${a}`}),o;const i=n.document.pages[r.pageIndex];if(!i)return o.reject({code:t.PdfErrorCode.NotFound,message:`Page ${r.pageIndex} not found in library`}),o;const s=i.size;return this.engine.extractPages(n.document,[r.pageIndex]).wait(t=>{this.renderStamp(a,r.pageIndex,s.width,2).wait(n=>{var i;this.currentGhostUrl&&URL.revokeObjectURL(this.currentGhostUrl);const l=URL.createObjectURL(n);this.currentGhostUrl=l,null==(i=this.annotation)||i.setActiveTool(c,{appearance:t,ghostUrl:l,stampSize:s,libraryId:a,stamp:r}),this.activeStamp$.emit(e,{libraryId:a,stamp:r}),o.resolve()},e=>{this.logger.error("StampPlugin","ActivateStampPlacement","Failed to render stamp preview",e),o.fail(e)})},e=>{this.logger.error("StampPlugin","ActivateStampPlacement","Failed to extract stamp page",e),o.fail(e)}),o}createStampFromAnnotation(e,a,r,o){const n=new t.Task,i=this.getCoreDocument(e);if(!(null==i?void 0:i.document))return n.reject({code:t.PdfErrorCode.DocNotOpen,message:"document is not open"}),n;const s=i.document,l=s.pages[a.pageIndex];return l?(this.resolveTargetLibrary(o).wait(e=>{this.engine.exportAnnotationAppearanceAsPdf(s,l,a).wait(t=>{this.addStampToLibrary(e,r,t).wait(()=>n.resolve(),e=>n.fail(e))},e=>{this.logger.error("StampPlugin","CreateStampFromAnnotation","Failed to export annotation",e),n.fail(e)})},e=>n.fail(e)),n):(n.reject({code:t.PdfErrorCode.NotFound,message:`page ${a.pageIndex} not found`}),n)}createStampFromAnnotations(e,a,r,o){const n=new t.Task;if(0===a.length)return n.reject({code:t.PdfErrorCode.NotFound,message:"no annotations provided"}),n;const i=this.getCoreDocument(e);if(!(null==i?void 0:i.document))return n.reject({code:t.PdfErrorCode.DocNotOpen,message:"document is not open"}),n;const s=i.document,l=s.pages[a[0].pageIndex];return l?(this.resolveTargetLibrary(o).wait(e=>{this.engine.exportAnnotationsAppearanceAsPdf(s,l,a).wait(t=>{this.addStampToLibrary(e,r,t).wait(()=>n.resolve(),e=>n.fail(e))},e=>{this.logger.error("StampPlugin","CreateStampFromAnnotations","Failed to export annotations",e),n.fail(e)})},e=>n.fail(e)),n):(n.reject({code:t.PdfErrorCode.NotFound,message:`page ${a[0].pageIndex} not found`}),n)}resolveTargetLibrary(e){if(e&&this.libraries.has(e)){const a=new t.Task;return a.resolve(e),a}const a=this.config.defaultLibrary;if(!1===this.config.defaultLibrary||!a){const e=new t.Task;return e.reject({code:t.PdfErrorCode.NotSupport,message:"Default library creation is disabled"}),e}const r=a.id??"custom";if(this.libraries.has(r)){const e=new t.Task;return e.resolve(r),e}return this.createNewLibrary(a.name??"Custom Stamps",{id:r,nameKey:a.nameKey,categories:a.categories})}removeLibrary(e){const a=new t.Task,r=this.libraries.get(e);return r?(this.engine.closeDocument(r.document).wait(()=>{this.libraries.delete(e),this.dispatch(l(e)),this.emitLibraryChange(),a.resolve()},()=>{this.logger.warn("StampPlugin","RemoveLibrary",`Failed to close document for library: ${e}`),this.libraries.delete(e),this.dispatch(l(e)),this.emitLibraryChange(),a.resolve()}),a):(a.resolve(),a)}exportLibrary(e){const a=new t.Task,r=this.libraries.get(e);return r?(this.engine.saveAsCopy(r.document).wait(e=>{a.resolve({name:r.name,pdf:e,stamps:r.stamps,categories:r.categories})},t=>{this.logger.error("StampPlugin","ExportLibrary",`Failed to export library: ${e}`,t),a.fail(t)}),a):(a.reject({code:t.PdfErrorCode.NotFound,message:`Stamp library not found: ${e}`}),a)}loadLibraryInternal(e){const a=new t.Task,r=e.id??this.generateLibraryId(),o=this.getLibraryDocumentId(r);return("string"==typeof e.pdf?this.engine.openDocumentUrl({id:o,url:e.pdf}):this.engine.openDocumentBuffer({id:o,content:e.pdf})).wait(o=>{const n=e.stamps.map(e=>e.id?e:{...e,id:t.uuidV4()}),i={id:r,name:e.name,nameKey:e.nameKey,document:o,stamps:n,categories:e.categories,readonly:e.readonly??!1};this.libraries.set(r,i),this.dispatch(s(r)),this.emitLibraryChange(),a.resolve(r)},t=>{this.logger.error("StampPlugin","LoadLibrary",`Failed to load stamp library: ${e.name}`,t),a.fail(t)}),a}removeStampFromLibrary(e,a){const r=new t.Task,o=this.libraries.get(e);if(!o)return r.reject({code:t.PdfErrorCode.NotFound,message:`Stamp library not found: ${e}`}),r;if(o.readonly)return r.reject({code:t.PdfErrorCode.NotSupport,message:`Cannot remove stamps from readonly library: ${e}`}),r;const n=o.stamps.findIndex(e=>e.id===a);if(-1===n)return r.reject({code:t.PdfErrorCode.NotFound,message:`Stamp ${a} not found in library: ${e}`}),r;const i=o.stamps[n].pageIndex;return this.engine.deletePage(o.document,i).wait(()=>{o.stamps.splice(n,1),o.document.pages.splice(i,1),o.document.pageCount=o.document.pages.length;for(const e of o.stamps)e.pageIndex>i&&e.pageIndex--;for(let e=0;e<o.document.pages.length;e++)o.document.pages[e].index=e;this.emitLibraryChange(),r.resolve()},e=>{this.logger.error("StampPlugin","RemoveStampFromLibrary",`Failed to delete page for stamp ${a}`,e),r.fail(e)}),r}updateStamp(e,a,r){const o=new t.Task,n=this.libraries.get(e);if(!n)return o.reject({code:t.PdfErrorCode.NotFound,message:`Stamp library not found: ${e}`}),o;if(n.readonly)return o.reject({code:t.PdfErrorCode.NotSupport,message:`Cannot update stamps in readonly library: ${e}`}),o;const i=n.stamps.find(e=>e.id===a);return i?(Object.assign(i,r),this.emitLibraryChange(),o.resolve(),o):(o.reject({code:t.PdfErrorCode.NotFound,message:`Stamp ${a} not found in library: ${e}`}),o)}updateLibrary(e,a){const r=new t.Task,o=this.libraries.get(e);return o?o.readonly?(r.reject({code:t.PdfErrorCode.NotSupport,message:`Cannot update readonly library: ${e}`}),r):(void 0!==a.name&&(o.name=a.name),void 0!==a.nameKey&&(o.nameKey=a.nameKey),void 0!==a.categories&&(o.categories=a.categories),void 0!==a.readonly&&(o.readonly=a.readonly),this.emitLibraryChange(),r.resolve(),r):(r.reject({code:t.PdfErrorCode.NotFound,message:`Stamp library not found: ${e}`}),r)}loadLibraryFromManifest(e){return this.loadManifestUrl(e,!0)}async initializeManifests(){var e;const t=(null==(e=this.i18n)?void 0:e.getLocale())??"en";for(const a of this.config.manifests){const e=a.url.includes("{locale}"),r=e?t:"",o=a.url.replace("{locale}",r||t),n={source:a,localeAware:e,currentLocale:e?t:"",libraryId:null};this.managedManifests.push(n);try{const e=await this.loadManifestUrl(o,!0).toPromise();n.libraryId=e}catch{if(e&&a.fallbackLocale&&a.fallbackLocale!==t){const e=a.url.replace("{locale}",a.fallbackLocale);try{const t=await this.loadManifestUrl(e,!0).toPromise();n.libraryId=t,n.currentLocale=a.fallbackLocale}catch{this.logger.warn("StampPlugin","InitManifests",`Failed to load manifest (including fallback): ${a.url}`)}}else this.logger.warn("StampPlugin","InitManifests",`Failed to load manifest: ${o}`)}}this.i18n&&(this.localeUnsubscribe=this.i18n.onLocaleChange(e=>{this.handleLocaleChange(e.currentLocale)}))}async handleLocaleChange(e){for(const t of this.managedManifests){if(!t.localeAware||t.currentLocale===e)continue;if(t.libraryId){try{await this.removeLibrary(t.libraryId).toPromise()}catch{}t.libraryId=null}const a=t.source.url.replace("{locale}",e);try{const r=await this.loadManifestUrl(a,!0).toPromise();t.libraryId=r,t.currentLocale=e}catch{const a=t.source.fallbackLocale??"en";if(a!==e){const r=t.source.url.replace("{locale}",a);try{const e=await this.loadManifestUrl(r,!0).toPromise();t.libraryId=e,t.currentLocale=a}catch{this.logger.warn("StampPlugin","LocaleChange",`Failed to load manifest for locale ${e} (including fallback): ${t.source.url}`)}}else this.logger.warn("StampPlugin","LocaleChange",`Failed to load manifest for locale ${e}: ${t.source.url}`)}}}loadManifestUrl(e,a){const r=new t.Task;return fetch(e).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(o=>{const n=this.resolveManifestPdfUrl(e,o.pdf),i=o.stamps.map(e=>{return{id:e.id??t.uuidV4(),pageIndex:e.pageIndex,name:(a=e.name,a?u[a]??t.PdfAnnotationName.Custom:t.PdfAnnotationName.Custom),subject:e.subject,subjectKey:e.subjectKey,label:e.label,categories:e.categories};var a}),s={id:o.id,name:o.name,nameKey:o.nameKey,pdf:n,stamps:i,categories:o.categories,readonly:a};this.loadLibraryInternal(s).wait(e=>r.resolve(e),e=>r.fail(e))}).catch(a=>{this.logger.error("StampPlugin","LoadManifest",`Failed to fetch manifest: ${e}`,a),r.reject({code:t.PdfErrorCode.NotFound,message:`Failed to load stamp manifest: ${e}`})}),r}resolveManifestPdfUrl(e,t){if(t.startsWith("http://")||t.startsWith("https://")||t.startsWith("/"))return t;return e.substring(0,e.lastIndexOf("/")+1)+t}generateLibraryId(){return t.uuidV4()}getLibraryDocumentId(e){return`stamp-doc-${this.instanceId}-${e}`}emitLibraryChange(){this.libraryChange$.emit(this.getLibraries())}async destroy(){this.currentGhostUrl&&(URL.revokeObjectURL(this.currentGhostUrl),this.currentGhostUrl=null),this.toolChangeUnsubscribe&&(this.toolChangeUnsubscribe(),this.toolChangeUnsubscribe=null),this.localeUnsubscribe&&(this.localeUnsubscribe(),this.localeUnsubscribe=null),this.activeStamp$.clear();const e=Array.from(this.libraries.values());for(const t of e)try{await this.engine.closeDocument(t.document).toPromise()}catch{}this.libraries.clear(),this.managedManifests.length=0,super.destroy()}};p.id=r;let g=p;const h={libraryIds:[]},f=(e=h,t)=>{switch(t.type){case n:return{...e,libraryIds:[...e.libraryIds,t.payload]};case i:return{...e,libraryIds:e.libraryIds.filter(e=>e!==t.payload)};default:return e}},b={manifest:o,create:(e,t)=>new g(r,e,t),reducer:f,initialState:h};exports.ADD_STAMP_LIBRARY=n,exports.REMOVE_STAMP_LIBRARY=i,exports.RUBBER_STAMP_TOOL_ID=c,exports.STAMP_PLUGIN_ID=r,exports.StampPlugin=g,exports.StampPluginPackage=b,exports.addStampLibrary=s,exports.initialState=h,exports.manifest=o,exports.removeStampLibrary=l,exports.stampReducer=f;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/lib/manifest.ts","../src/lib/actions.ts","../src/lib/handlers/rubber-stamp.handler.ts","../src/lib/tools.ts","../src/lib/defaults/name-map.ts","../src/lib/stamp-plugin.ts","../src/lib/reducer.ts","../src/lib/index.ts"],"sourcesContent":["import { PluginManifest } from '@embedpdf/core';\nimport { StampPluginConfig } from './types';\n\nexport const STAMP_PLUGIN_ID = 'stamp';\n\nexport const manifest: PluginManifest<StampPluginConfig> = {\n id: STAMP_PLUGIN_ID,\n name: 'Stamp Plugin',\n version: '1.0.0',\n provides: ['stamp'],\n requires: ['annotation'],\n optional: ['i18n'],\n defaultConfig: {\n defaultLibrary: {\n id: 'custom',\n name: 'Custom Stamps',\n nameKey: 'stamp.library.custom',\n categories: ['custom', 'sidebar'],\n },\n manifests: [\n {\n url: 'https://cdn.jsdelivr.net/npm/@embedpdf/default-stamps/{locale}/manifest.json',\n fallbackLocale: 'en',\n },\n ],\n },\n};\n","import { Action } from '@embedpdf/core';\n\nexport const ADD_STAMP_LIBRARY = 'STAMP/ADD_LIBRARY';\nexport const REMOVE_STAMP_LIBRARY = 'STAMP/REMOVE_LIBRARY';\n\nexport interface AddStampLibraryAction extends Action {\n type: typeof ADD_STAMP_LIBRARY;\n payload: string;\n}\n\nexport interface RemoveStampLibraryAction extends Action {\n type: typeof REMOVE_STAMP_LIBRARY;\n payload: string;\n}\n\nexport type StampAction = AddStampLibraryAction | RemoveStampLibraryAction;\n\nexport function addStampLibrary(id: string): AddStampLibraryAction {\n return { type: ADD_STAMP_LIBRARY, payload: id };\n}\n\nexport function removeStampLibrary(id: string): RemoveStampLibraryAction {\n return { type: REMOVE_STAMP_LIBRARY, payload: id };\n}\n","import {\n PdfAnnotationName,\n PdfAnnotationSubtype,\n PdfStampAnnoObject,\n Rect,\n uuidV4,\n} from '@embedpdf/models';\nimport { HandlerFactory } from '@embedpdf/plugin-annotation';\nimport { applyInsertUpright, clampAnnotationToPage } from '@embedpdf/plugin-annotation';\nimport { RUBBER_STAMP_TOOL_ID } from '../tools';\n\nexport const rubberStampHandlerFactory: HandlerFactory<\n PdfStampAnnoObject,\n typeof RUBBER_STAMP_TOOL_ID\n> = {\n annotationType: PdfAnnotationSubtype.STAMP,\n create(context) {\n const { onPreview, onCommit, getTool, pageSize, pageRotation, getToolContext } = context;\n\n return {\n onPointerMove: (pos) => {\n const ctx = getToolContext();\n if (!ctx?.stampSize) return;\n const { width, height } = ctx.stampSize;\n onPreview({\n type: PdfAnnotationSubtype.STAMP,\n bounds: {\n origin: { x: pos.x - width / 2, y: pos.y - height / 2 },\n size: { width, height },\n },\n data: {\n rect: {\n origin: { x: pos.x - width / 2, y: pos.y - height / 2 },\n size: { width, height },\n },\n ghostUrl: ctx.ghostUrl,\n pageRotation,\n },\n });\n },\n\n onPointerDown: (pos) => {\n const tool = getTool();\n const ctx = getToolContext();\n if (!tool || !ctx?.stampSize) return;\n\n const { width, height } = ctx.stampSize;\n const rect: Rect = {\n origin: { x: pos.x - width / 2, y: pos.y - height / 2 },\n size: { width, height },\n };\n\n let anno: PdfStampAnnoObject = {\n ...tool.defaults,\n rect,\n type: PdfAnnotationSubtype.STAMP,\n name: ctx.stamp.name ?? tool.defaults.name ?? PdfAnnotationName.Custom,\n subject: ctx.stamp.subject ?? tool.defaults.subject ?? 'Custom Stamp',\n flags: tool.defaults.flags ?? ['print'],\n pageIndex: context.pageIndex,\n id: uuidV4(),\n created: new Date(),\n };\n\n if (tool.behavior?.insertUpright) {\n anno = applyInsertUpright(anno, pageRotation, false);\n }\n anno = clampAnnotationToPage(anno, pageSize);\n\n onCommit(anno, { appearance: ctx.appearance });\n onPreview(null);\n },\n\n onPointerLeave: () => {\n onPreview(null);\n },\n };\n },\n};\n","import { PdfAnnotationSubtype } from '@embedpdf/models';\nimport { defineAnnotationTool } from '@embedpdf/plugin-annotation';\nimport { rubberStampHandlerFactory } from './handlers/rubber-stamp.handler';\n\nexport const RUBBER_STAMP_TOOL_ID = 'rubberStamp' as const;\n\nexport const rubberStampTool = defineAnnotationTool({\n id: RUBBER_STAMP_TOOL_ID,\n name: 'Rubber Stamp',\n labelKey: 'stamp.rubberStamp',\n categories: ['annotation', 'stamp', 'insert'],\n matchScore: () => 0,\n interaction: {\n exclusive: true,\n cursor: 'copy',\n isDraggable: true,\n isResizable: true,\n isRotatable: false,\n lockAspectRatio: true,\n isGroupDraggable: true,\n isGroupResizable: false,\n isGroupRotatable: false,\n },\n defaults: {\n type: PdfAnnotationSubtype.STAMP,\n },\n behavior: {\n deactivateToolAfterCreate: true,\n selectAfterCreate: true,\n insertUpright: true,\n useAppearanceStream: true,\n },\n pointerHandler: rubberStampHandlerFactory,\n});\n\nexport const stampTools = [rubberStampTool];\n","import { PdfAnnotationName } from '@embedpdf/models';\n\nconst ANNOTATION_NAME_MAP: Record<string, PdfAnnotationName> = {\n Approved: PdfAnnotationName.Approved,\n Experimental: PdfAnnotationName.Experimental,\n NotApproved: PdfAnnotationName.NotApproved,\n AsIs: PdfAnnotationName.AsIs,\n Expired: PdfAnnotationName.Expired,\n NotForPublicRelease: PdfAnnotationName.NotForPublicRelease,\n Confidential: PdfAnnotationName.Confidential,\n Final: PdfAnnotationName.Final,\n Sold: PdfAnnotationName.Sold,\n Departmental: PdfAnnotationName.Departmental,\n ForComment: PdfAnnotationName.ForComment,\n TopSecret: PdfAnnotationName.TopSecret,\n Draft: PdfAnnotationName.Draft,\n ForPublicRelease: PdfAnnotationName.ForPublicRelease,\n Completed: PdfAnnotationName.Completed,\n Void: PdfAnnotationName.Void,\n PreliminaryResults: PdfAnnotationName.PreliminaryResults,\n InformationOnly: PdfAnnotationName.InformationOnly,\n Rejected: PdfAnnotationName.Rejected,\n Witness: PdfAnnotationName.Witness,\n InitialHere: PdfAnnotationName.InitialHere,\n SignHere: PdfAnnotationName.SignHere,\n Accepted: PdfAnnotationName.Accepted,\n Custom: PdfAnnotationName.Custom,\n Image: PdfAnnotationName.Image,\n};\n\nexport function parseAnnotationName(name?: string): PdfAnnotationName {\n if (!name) return PdfAnnotationName.Custom;\n return ANNOTATION_NAME_MAP[name] ?? PdfAnnotationName.Custom;\n}\n","import { BasePlugin, createEmitter, createScopedEmitter, PluginRegistry } from '@embedpdf/core';\nimport { Task, PdfErrorReason, PdfErrorCode, PdfAnnotationObject, uuidV4 } from '@embedpdf/models';\nimport { AnnotationCapability, AnnotationPlugin } from '@embedpdf/plugin-annotation';\nimport { I18nCapability, I18nPlugin } from '@embedpdf/plugin-i18n';\nimport {\n StampCapability,\n StampScope,\n ActiveStampChangeEvent,\n ActiveStampInfo,\n StampDefinition,\n StampDefinitionUpdate,\n StampLibrary,\n StampLibraryConfig,\n StampLibraryUpdate,\n StampManifest,\n StampManifestSource,\n StampPluginConfig,\n StampState,\n ExportedStampLibrary,\n ResolvedStamp,\n} from './types';\nimport { addStampLibrary, removeStampLibrary, StampAction } from './actions';\nimport { STAMP_PLUGIN_ID } from './manifest';\nimport { RUBBER_STAMP_TOOL_ID, stampTools } from './tools';\nimport { parseAnnotationName } from './defaults/name-map';\n\ninterface ManagedManifest {\n source: StampManifestSource;\n localeAware: boolean;\n currentLocale: string;\n libraryId: string | null;\n}\n\nexport class StampPlugin extends BasePlugin<\n StampPluginConfig,\n StampCapability,\n StampState,\n StampAction\n> {\n static readonly id = STAMP_PLUGIN_ID;\n\n private readonly instanceId = uuidV4();\n private readonly libraries = new Map<string, StampLibrary>();\n private readonly libraryChange$ = createEmitter<StampLibrary[]>();\n private readonly activeStamp$ = createScopedEmitter<\n ActiveStampInfo | null,\n ActiveStampChangeEvent,\n string\n >((documentId, activeStamp) => ({ documentId, activeStamp }));\n private readonly managedManifests: ManagedManifest[] = [];\n private annotation: AnnotationCapability | null = null;\n private i18n: I18nCapability | null = null;\n private localeUnsubscribe: (() => void) | null = null;\n private toolChangeUnsubscribe: (() => void) | null = null;\n private currentGhostUrl: string | null = null;\n\n constructor(\n id: string,\n registry: PluginRegistry,\n private config: StampPluginConfig,\n ) {\n super(id, registry);\n\n this.annotation = registry.getPlugin<AnnotationPlugin>('annotation')?.provides() ?? null;\n if (this.annotation) {\n for (const tool of stampTools) {\n this.annotation.addTool(tool);\n }\n this.toolChangeUnsubscribe = this.annotation.onActiveToolChange(({ documentId, tool }) => {\n if (tool?.id !== RUBBER_STAMP_TOOL_ID) {\n if (this.currentGhostUrl) {\n URL.revokeObjectURL(this.currentGhostUrl);\n this.currentGhostUrl = null;\n }\n this.activeStamp$.emit(documentId, null);\n }\n });\n }\n\n this.i18n = registry.getPlugin<I18nPlugin>('i18n')?.provides() ?? null;\n }\n\n async initialize(): Promise<void> {\n if (this.config.libraries) {\n for (const libConfig of this.config.libraries) {\n await this.loadLibraryInternal(libConfig).toPromise();\n }\n }\n\n if (this.config.manifests && this.config.manifests.length > 0) {\n await this.initializeManifests();\n }\n }\n\n protected buildCapability(): StampCapability {\n return {\n getLibraries: () => this.getLibraries(),\n getStampsByCategory: (category) => this.getStampsByCategory(category),\n renderStamp: (libraryId, pageIndex, width, dpr) =>\n this.renderStamp(libraryId, pageIndex, width, dpr),\n loadLibrary: (config) => this.loadLibrary(config),\n loadLibraryFromManifest: (url) => this.loadLibraryFromManifest(url),\n createNewLibrary: (name, options) => this.createNewLibrary(name, options),\n addStampToLibrary: (libraryId, stamp, pdf) => this.addStampToLibrary(libraryId, stamp, pdf),\n removeStampFromLibrary: (libraryId, stampId) =>\n this.removeStampFromLibrary(libraryId, stampId),\n updateStamp: (libraryId, stampId, updates) => this.updateStamp(libraryId, stampId, updates),\n updateLibrary: (libraryId, updates) => this.updateLibrary(libraryId, updates),\n removeLibrary: (id) => this.removeLibrary(id),\n exportLibrary: (id) => this.exportLibrary(id),\n forDocument: (documentId) => this.createStampScope(documentId),\n onActiveStampChange: this.activeStamp$.onGlobal,\n onLibraryChange: this.libraryChange$.on,\n };\n }\n\n getLibraries(): StampLibrary[] {\n return Array.from(this.libraries.values());\n }\n\n getStampsByCategory(category: string): ResolvedStamp[] {\n const results: ResolvedStamp[] = [];\n\n for (const library of this.libraries.values()) {\n const libraryMatches = library.categories?.includes(category) ?? false;\n\n for (const stamp of library.stamps) {\n const stampMatches = stamp.categories?.includes(category) ?? false;\n if (libraryMatches || stampMatches) {\n results.push({ library, stamp });\n }\n }\n }\n\n return results;\n }\n\n renderStamp(\n libraryId: string,\n pageIndex: number,\n width: number,\n dpr?: number,\n ): Task<Blob, PdfErrorReason> {\n const library = this.libraries.get(libraryId);\n if (!library) {\n const task = new Task<Blob, PdfErrorReason>();\n task.reject({\n code: PdfErrorCode.NotFound,\n message: `Stamp library not found: ${libraryId}`,\n });\n return task;\n }\n\n const page = library.document.pages[pageIndex];\n if (!page) {\n const task = new Task<Blob, PdfErrorReason>();\n task.reject({\n code: PdfErrorCode.NotFound,\n message: `Page ${pageIndex} not found in stamp library: ${libraryId}`,\n });\n return task;\n }\n\n const scaleFactor = width / page.size.width;\n\n return this.engine.renderPageRect(\n library.document,\n page,\n { origin: { x: 0, y: 0 }, size: page.size },\n {\n scaleFactor,\n dpr: dpr ?? 1,\n withAnnotations: true,\n rotation: page.rotation,\n transparentBackground: true,\n },\n );\n }\n\n loadLibrary(config: StampLibraryConfig): Task<string, PdfErrorReason> {\n return this.loadLibraryInternal(config);\n }\n\n createNewLibrary(\n name: string,\n options?: { categories?: string[]; id?: string; nameKey?: string; readonly?: boolean },\n ): Task<string, PdfErrorReason> {\n const task = new Task<string, PdfErrorReason>();\n const libraryId = options?.id ?? this.generateLibraryId();\n const documentId = this.getLibraryDocumentId(libraryId);\n\n this.engine.createDocument(documentId).wait(\n (doc) => {\n const library: StampLibrary = {\n id: libraryId,\n name,\n nameKey: options?.nameKey,\n document: doc,\n stamps: [],\n categories: options?.categories,\n readonly: options?.readonly ?? false,\n };\n\n this.libraries.set(libraryId, library);\n this.dispatch(addStampLibrary(libraryId));\n this.emitLibraryChange();\n task.resolve(libraryId);\n },\n (error) => {\n this.logger.error(\n 'StampPlugin',\n 'CreateNewLibrary',\n `Failed to create library: ${name}`,\n error,\n );\n task.fail(error);\n },\n );\n\n return task;\n }\n\n addStampToLibrary(\n libraryId: string,\n stamp: Omit<StampDefinition, 'id' | 'pageIndex'>,\n pdf: ArrayBuffer,\n ): Task<void, PdfErrorReason> {\n const task = new Task<void, PdfErrorReason>();\n\n const library = this.libraries.get(libraryId);\n if (!library) {\n task.reject({\n code: PdfErrorCode.NotFound,\n message: `Stamp library not found: ${libraryId}`,\n });\n return task;\n }\n\n if (library.readonly) {\n task.reject({\n code: PdfErrorCode.NotSupport,\n message: `Cannot add stamps to readonly library: ${libraryId}`,\n });\n return task;\n }\n\n const tempDocId = `stamp-temp-${Date.now()}`;\n\n this.engine.openDocumentBuffer({ id: tempDocId, content: pdf }).wait(\n (tempDoc) => {\n this.engine.importPages(library.document, tempDoc, [0]).wait(\n (newPages) => {\n const newPage = newPages[0];\n library.document.pages.push(newPage);\n library.document.pageCount = library.document.pages.length;\n\n const stampDef: StampDefinition = {\n ...stamp,\n id: uuidV4(),\n pageIndex: newPage.index,\n };\n library.stamps.push(stampDef);\n\n this.engine.closeDocument(tempDoc).wait(\n () => {\n this.emitLibraryChange();\n task.resolve();\n },\n () => {\n this.emitLibraryChange();\n task.resolve();\n },\n );\n },\n (error) => {\n this.logger.error('StampPlugin', 'AddStampToLibrary', 'Failed to import page', error);\n this.engine.closeDocument(tempDoc).wait(\n () => task.fail(error),\n () => task.fail(error),\n );\n },\n );\n },\n (error) => {\n this.logger.error(\n 'StampPlugin',\n 'AddStampToLibrary',\n 'Failed to open temp document',\n error,\n );\n task.fail(error);\n },\n );\n\n return task;\n }\n\n private createStampScope(documentId: string): StampScope {\n return {\n createStampFromAnnotation: (annotation, stamp, libraryId) =>\n this.createStampFromAnnotation(documentId, annotation, stamp, libraryId),\n createStampFromAnnotations: (annotations, stamp, libraryId) =>\n this.createStampFromAnnotations(documentId, annotations, stamp, libraryId),\n activateStampPlacement: (libraryId, stamp) =>\n this.activateStampPlacement(documentId, libraryId, stamp),\n activateStampPlacementById: (libraryId, stampId) =>\n this.activateStampPlacementById(documentId, libraryId, stampId),\n getActiveStamp: () => this.getActiveStamp(documentId),\n onActiveStampChange: this.activeStamp$.forScope(documentId),\n };\n }\n\n private activateStampPlacementById(\n documentId: string,\n libraryId: string,\n stampId: string,\n ): Task<void, PdfErrorReason> {\n const task = new Task<void, PdfErrorReason>();\n\n const library = this.libraries.get(libraryId);\n if (!library) {\n task.reject({\n code: PdfErrorCode.NotFound,\n message: `Stamp library not found: ${libraryId}`,\n });\n return task;\n }\n\n const stamp = library.stamps.find((s) => s.id === stampId);\n if (!stamp) {\n task.reject({\n code: PdfErrorCode.NotFound,\n message: `Stamp ${stampId} not found in library: ${libraryId}`,\n });\n return task;\n }\n\n return this.activateStampPlacement(documentId, libraryId, stamp);\n }\n\n private getActiveStamp(documentId: string): ActiveStampInfo | null {\n return this.activeStamp$.getValue(documentId) ?? null;\n }\n\n private activateStampPlacement(\n documentId: string,\n libraryId: string,\n stamp: StampDefinition,\n ): Task<void, PdfErrorReason> {\n const task = new Task<void, PdfErrorReason>();\n\n const library = this.libraries.get(libraryId);\n if (!library) {\n task.reject({\n code: PdfErrorCode.NotFound,\n message: `Stamp library not found: ${libraryId}`,\n });\n return task;\n }\n\n const page = library.document.pages[stamp.pageIndex];\n if (!page) {\n task.reject({\n code: PdfErrorCode.NotFound,\n message: `Page ${stamp.pageIndex} not found in library`,\n });\n return task;\n }\n\n const stampSize = page.size;\n\n this.engine.extractPages(library.document, [stamp.pageIndex]).wait(\n (appearance) => {\n this.renderStamp(libraryId, stamp.pageIndex, stampSize.width, 2).wait(\n (blob) => {\n if (this.currentGhostUrl) {\n URL.revokeObjectURL(this.currentGhostUrl);\n }\n const ghostUrl = URL.createObjectURL(blob);\n this.currentGhostUrl = ghostUrl;\n this.annotation?.setActiveTool(RUBBER_STAMP_TOOL_ID, {\n appearance,\n ghostUrl,\n stampSize,\n libraryId,\n stamp,\n });\n this.activeStamp$.emit(documentId, { libraryId, stamp });\n task.resolve();\n },\n (error) => {\n this.logger.error(\n 'StampPlugin',\n 'ActivateStampPlacement',\n 'Failed to render stamp preview',\n error,\n );\n task.fail(error);\n },\n );\n },\n (error) => {\n this.logger.error(\n 'StampPlugin',\n 'ActivateStampPlacement',\n 'Failed to extract stamp page',\n error,\n );\n task.fail(error);\n },\n );\n\n return task;\n }\n\n private createStampFromAnnotation(\n documentId: string,\n annotation: PdfAnnotationObject,\n stamp: Omit<StampDefinition, 'id' | 'pageIndex'>,\n libraryId?: string,\n ): Task<void, PdfErrorReason> {\n const task = new Task<void, PdfErrorReason>();\n\n const docState = this.getCoreDocument(documentId);\n if (!docState?.document) {\n task.reject({ code: PdfErrorCode.DocNotOpen, message: 'document is not open' });\n return task;\n }\n\n const doc = docState.document;\n const page = doc.pages[annotation.pageIndex];\n if (!page) {\n task.reject({\n code: PdfErrorCode.NotFound,\n message: `page ${annotation.pageIndex} not found`,\n });\n return task;\n }\n\n this.resolveTargetLibrary(libraryId).wait(\n (targetId) => {\n this.engine.exportAnnotationAppearanceAsPdf(doc, page, annotation).wait(\n (pdf) => {\n this.addStampToLibrary(targetId, stamp, pdf).wait(\n () => task.resolve(),\n (error) => task.fail(error),\n );\n },\n (error) => {\n this.logger.error(\n 'StampPlugin',\n 'CreateStampFromAnnotation',\n 'Failed to export annotation',\n error,\n );\n task.fail(error);\n },\n );\n },\n (error) => task.fail(error),\n );\n\n return task;\n }\n\n private createStampFromAnnotations(\n documentId: string,\n annotations: PdfAnnotationObject[],\n stamp: Omit<StampDefinition, 'id' | 'pageIndex'>,\n libraryId?: string,\n ): Task<void, PdfErrorReason> {\n const task = new Task<void, PdfErrorReason>();\n\n if (annotations.length === 0) {\n task.reject({ code: PdfErrorCode.NotFound, message: 'no annotations provided' });\n return task;\n }\n\n const docState = this.getCoreDocument(documentId);\n if (!docState?.document) {\n task.reject({ code: PdfErrorCode.DocNotOpen, message: 'document is not open' });\n return task;\n }\n\n const doc = docState.document;\n const page = doc.pages[annotations[0].pageIndex];\n if (!page) {\n task.reject({\n code: PdfErrorCode.NotFound,\n message: `page ${annotations[0].pageIndex} not found`,\n });\n return task;\n }\n\n this.resolveTargetLibrary(libraryId).wait(\n (targetId) => {\n this.engine.exportAnnotationsAppearanceAsPdf(doc, page, annotations).wait(\n (pdf) => {\n this.addStampToLibrary(targetId, stamp, pdf).wait(\n () => task.resolve(),\n (error) => task.fail(error),\n );\n },\n (error) => {\n this.logger.error(\n 'StampPlugin',\n 'CreateStampFromAnnotations',\n 'Failed to export annotations',\n error,\n );\n task.fail(error);\n },\n );\n },\n (error) => task.fail(error),\n );\n\n return task;\n }\n\n private resolveTargetLibrary(libraryId?: string): Task<string, PdfErrorReason> {\n if (libraryId && this.libraries.has(libraryId)) {\n const task = new Task<string, PdfErrorReason>();\n task.resolve(libraryId);\n return task;\n }\n\n const defaults = this.config.defaultLibrary;\n if (this.config.defaultLibrary === false || !defaults) {\n const task = new Task<string, PdfErrorReason>();\n task.reject({\n code: PdfErrorCode.NotSupport,\n message: 'Default library creation is disabled',\n });\n return task;\n }\n\n const defaultId = defaults.id ?? 'custom';\n\n if (this.libraries.has(defaultId)) {\n const task = new Task<string, PdfErrorReason>();\n task.resolve(defaultId);\n return task;\n }\n\n return this.createNewLibrary(defaults.name ?? 'Custom Stamps', {\n id: defaultId,\n nameKey: defaults.nameKey,\n categories: defaults.categories,\n });\n }\n\n removeLibrary(id: string): Task<void, PdfErrorReason> {\n const task = new Task<void, PdfErrorReason>();\n\n const library = this.libraries.get(id);\n if (!library) {\n task.resolve();\n return task;\n }\n\n this.engine.closeDocument(library.document).wait(\n () => {\n this.libraries.delete(id);\n this.dispatch(removeStampLibrary(id));\n this.emitLibraryChange();\n task.resolve();\n },\n () => {\n this.logger.warn(\n 'StampPlugin',\n 'RemoveLibrary',\n `Failed to close document for library: ${id}`,\n );\n this.libraries.delete(id);\n this.dispatch(removeStampLibrary(id));\n this.emitLibraryChange();\n task.resolve();\n },\n );\n\n return task;\n }\n\n exportLibrary(id: string): Task<ExportedStampLibrary, PdfErrorReason> {\n const task = new Task<ExportedStampLibrary, PdfErrorReason>();\n\n const library = this.libraries.get(id);\n if (!library) {\n task.reject({\n code: PdfErrorCode.NotFound,\n message: `Stamp library not found: ${id}`,\n });\n return task;\n }\n\n this.engine.saveAsCopy(library.document).wait(\n (pdf) => {\n task.resolve({\n name: library.name,\n pdf,\n stamps: library.stamps,\n categories: library.categories,\n });\n },\n (error) => {\n this.logger.error('StampPlugin', 'ExportLibrary', `Failed to export library: ${id}`, error);\n task.fail(error);\n },\n );\n\n return task;\n }\n\n private loadLibraryInternal(config: StampLibraryConfig): Task<string, PdfErrorReason> {\n const task = new Task<string, PdfErrorReason>();\n const libraryId = config.id ?? this.generateLibraryId();\n const documentId = this.getLibraryDocumentId(libraryId);\n\n const engineTask =\n typeof config.pdf === 'string'\n ? this.engine.openDocumentUrl({ id: documentId, url: config.pdf })\n : this.engine.openDocumentBuffer({ id: documentId, content: config.pdf });\n\n engineTask.wait(\n (doc) => {\n const stamps = config.stamps.map((s) => (s.id ? s : { ...s, id: uuidV4() }));\n\n const library: StampLibrary = {\n id: libraryId,\n name: config.name,\n nameKey: config.nameKey,\n document: doc,\n stamps,\n categories: config.categories,\n readonly: config.readonly ?? false,\n };\n\n this.libraries.set(libraryId, library);\n this.dispatch(addStampLibrary(libraryId));\n this.emitLibraryChange();\n\n task.resolve(libraryId);\n },\n (error) => {\n this.logger.error(\n 'StampPlugin',\n 'LoadLibrary',\n `Failed to load stamp library: ${config.name}`,\n error,\n );\n task.fail(error);\n },\n );\n\n return task;\n }\n\n removeStampFromLibrary(libraryId: string, stampId: string): Task<void, PdfErrorReason> {\n const task = new Task<void, PdfErrorReason>();\n\n const library = this.libraries.get(libraryId);\n if (!library) {\n task.reject({\n code: PdfErrorCode.NotFound,\n message: `Stamp library not found: ${libraryId}`,\n });\n return task;\n }\n\n if (library.readonly) {\n task.reject({\n code: PdfErrorCode.NotSupport,\n message: `Cannot remove stamps from readonly library: ${libraryId}`,\n });\n return task;\n }\n\n const stampIdx = library.stamps.findIndex((s) => s.id === stampId);\n if (stampIdx === -1) {\n task.reject({\n code: PdfErrorCode.NotFound,\n message: `Stamp ${stampId} not found in library: ${libraryId}`,\n });\n return task;\n }\n\n const pageIndex = library.stamps[stampIdx].pageIndex;\n\n this.engine.deletePage(library.document, pageIndex).wait(\n () => {\n library.stamps.splice(stampIdx, 1);\n library.document.pages.splice(pageIndex, 1);\n library.document.pageCount = library.document.pages.length;\n\n for (const s of library.stamps) {\n if (s.pageIndex > pageIndex) {\n s.pageIndex--;\n }\n }\n for (let i = 0; i < library.document.pages.length; i++) {\n library.document.pages[i].index = i;\n }\n\n this.emitLibraryChange();\n task.resolve();\n },\n (error) => {\n this.logger.error(\n 'StampPlugin',\n 'RemoveStampFromLibrary',\n `Failed to delete page for stamp ${stampId}`,\n error,\n );\n task.fail(error);\n },\n );\n\n return task;\n }\n\n updateStamp(\n libraryId: string,\n stampId: string,\n updates: StampDefinitionUpdate,\n ): Task<void, PdfErrorReason> {\n const task = new Task<void, PdfErrorReason>();\n\n const library = this.libraries.get(libraryId);\n if (!library) {\n task.reject({\n code: PdfErrorCode.NotFound,\n message: `Stamp library not found: ${libraryId}`,\n });\n return task;\n }\n\n if (library.readonly) {\n task.reject({\n code: PdfErrorCode.NotSupport,\n message: `Cannot update stamps in readonly library: ${libraryId}`,\n });\n return task;\n }\n\n const stamp = library.stamps.find((s) => s.id === stampId);\n if (!stamp) {\n task.reject({\n code: PdfErrorCode.NotFound,\n message: `Stamp ${stampId} not found in library: ${libraryId}`,\n });\n return task;\n }\n\n Object.assign(stamp, updates);\n this.emitLibraryChange();\n task.resolve();\n\n return task;\n }\n\n updateLibrary(libraryId: string, updates: StampLibraryUpdate): Task<void, PdfErrorReason> {\n const task = new Task<void, PdfErrorReason>();\n\n const library = this.libraries.get(libraryId);\n if (!library) {\n task.reject({\n code: PdfErrorCode.NotFound,\n message: `Stamp library not found: ${libraryId}`,\n });\n return task;\n }\n\n if (library.readonly) {\n task.reject({\n code: PdfErrorCode.NotSupport,\n message: `Cannot update readonly library: ${libraryId}`,\n });\n return task;\n }\n\n if (updates.name !== undefined) library.name = updates.name;\n if (updates.nameKey !== undefined) library.nameKey = updates.nameKey;\n if (updates.categories !== undefined) library.categories = updates.categories;\n if (updates.readonly !== undefined) library.readonly = updates.readonly;\n\n this.emitLibraryChange();\n task.resolve();\n\n return task;\n }\n\n loadLibraryFromManifest(url: string): Task<string, PdfErrorReason> {\n return this.loadManifestUrl(url, true);\n }\n\n private async initializeManifests(): Promise<void> {\n const currentLocale = this.i18n?.getLocale() ?? 'en';\n\n for (const source of this.config.manifests!) {\n const localeAware = source.url.includes('{locale}');\n const locale = localeAware ? currentLocale : '';\n const resolvedUrl = source.url.replace('{locale}', locale || currentLocale);\n\n const managed: ManagedManifest = {\n source,\n localeAware,\n currentLocale: localeAware ? currentLocale : '',\n libraryId: null,\n };\n this.managedManifests.push(managed);\n\n try {\n const libraryId = await this.loadManifestUrl(resolvedUrl, true).toPromise();\n managed.libraryId = libraryId;\n } catch {\n if (localeAware && source.fallbackLocale && source.fallbackLocale !== currentLocale) {\n const fallbackUrl = source.url.replace('{locale}', source.fallbackLocale);\n try {\n const libraryId = await this.loadManifestUrl(fallbackUrl, true).toPromise();\n managed.libraryId = libraryId;\n managed.currentLocale = source.fallbackLocale;\n } catch {\n this.logger.warn(\n 'StampPlugin',\n 'InitManifests',\n `Failed to load manifest (including fallback): ${source.url}`,\n );\n }\n } else {\n this.logger.warn(\n 'StampPlugin',\n 'InitManifests',\n `Failed to load manifest: ${resolvedUrl}`,\n );\n }\n }\n }\n\n if (this.i18n) {\n this.localeUnsubscribe = this.i18n.onLocaleChange((event) => {\n this.handleLocaleChange(event.currentLocale);\n });\n }\n }\n\n private async handleLocaleChange(newLocale: string): Promise<void> {\n for (const managed of this.managedManifests) {\n if (!managed.localeAware || managed.currentLocale === newLocale) {\n continue;\n }\n\n if (managed.libraryId) {\n try {\n await this.removeLibrary(managed.libraryId).toPromise();\n } catch {\n // Best effort removal\n }\n managed.libraryId = null;\n }\n\n const resolvedUrl = managed.source.url.replace('{locale}', newLocale);\n\n try {\n const libraryId = await this.loadManifestUrl(resolvedUrl, true).toPromise();\n managed.libraryId = libraryId;\n managed.currentLocale = newLocale;\n } catch {\n const fallback = managed.source.fallbackLocale ?? 'en';\n if (fallback !== newLocale) {\n const fallbackUrl = managed.source.url.replace('{locale}', fallback);\n try {\n const libraryId = await this.loadManifestUrl(fallbackUrl, true).toPromise();\n managed.libraryId = libraryId;\n managed.currentLocale = fallback;\n } catch {\n this.logger.warn(\n 'StampPlugin',\n 'LocaleChange',\n `Failed to load manifest for locale ${newLocale} (including fallback): ${managed.source.url}`,\n );\n }\n } else {\n this.logger.warn(\n 'StampPlugin',\n 'LocaleChange',\n `Failed to load manifest for locale ${newLocale}: ${managed.source.url}`,\n );\n }\n }\n }\n }\n\n private loadManifestUrl(url: string, readonly: boolean): Task<string, PdfErrorReason> {\n const task = new Task<string, PdfErrorReason>();\n\n fetch(url)\n .then((response) => {\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}: ${response.statusText}`);\n }\n return response.json() as Promise<StampManifest>;\n })\n .then((manifest) => {\n const pdfUrl = this.resolveManifestPdfUrl(url, manifest.pdf);\n\n const stamps: StampDefinition[] = manifest.stamps.map((entry) => ({\n id: entry.id ?? uuidV4(),\n pageIndex: entry.pageIndex,\n name: parseAnnotationName(entry.name),\n subject: entry.subject,\n subjectKey: entry.subjectKey,\n label: entry.label,\n categories: entry.categories,\n }));\n\n const config: StampLibraryConfig = {\n id: manifest.id,\n name: manifest.name,\n nameKey: manifest.nameKey,\n pdf: pdfUrl,\n stamps,\n categories: manifest.categories,\n readonly,\n };\n\n this.loadLibraryInternal(config).wait(\n (libraryId) => task.resolve(libraryId),\n (error) => task.fail(error),\n );\n })\n .catch((error) => {\n this.logger.error('StampPlugin', 'LoadManifest', `Failed to fetch manifest: ${url}`, error);\n task.reject({\n code: PdfErrorCode.NotFound,\n message: `Failed to load stamp manifest: ${url}`,\n });\n });\n\n return task;\n }\n\n private resolveManifestPdfUrl(manifestUrl: string, pdfPath: string): string {\n if (\n pdfPath.startsWith('http://') ||\n pdfPath.startsWith('https://') ||\n pdfPath.startsWith('/')\n ) {\n return pdfPath;\n }\n const base = manifestUrl.substring(0, manifestUrl.lastIndexOf('/') + 1);\n return base + pdfPath;\n }\n\n private generateLibraryId(): string {\n return uuidV4();\n }\n\n private getLibraryDocumentId(libraryId: string): string {\n return `stamp-doc-${this.instanceId}-${libraryId}`;\n }\n\n private emitLibraryChange(): void {\n this.libraryChange$.emit(this.getLibraries());\n }\n\n override async destroy(): Promise<void> {\n if (this.currentGhostUrl) {\n URL.revokeObjectURL(this.currentGhostUrl);\n this.currentGhostUrl = null;\n }\n if (this.toolChangeUnsubscribe) {\n this.toolChangeUnsubscribe();\n this.toolChangeUnsubscribe = null;\n }\n if (this.localeUnsubscribe) {\n this.localeUnsubscribe();\n this.localeUnsubscribe = null;\n }\n this.activeStamp$.clear();\n const libs = Array.from(this.libraries.values());\n for (const library of libs) {\n try {\n await this.engine.closeDocument(library.document).toPromise();\n } catch {\n // Best effort cleanup\n }\n }\n this.libraries.clear();\n this.managedManifests.length = 0;\n super.destroy();\n }\n}\n","import { Reducer } from '@embedpdf/core';\nimport { StampAction, ADD_STAMP_LIBRARY, REMOVE_STAMP_LIBRARY } from './actions';\nimport { StampState } from './types';\n\nexport const initialState: StampState = {\n libraryIds: [],\n};\n\nexport const stampReducer: Reducer<StampState, StampAction> = (state = initialState, action) => {\n switch (action.type) {\n case ADD_STAMP_LIBRARY:\n return {\n ...state,\n libraryIds: [...state.libraryIds, action.payload],\n };\n\n case REMOVE_STAMP_LIBRARY:\n return {\n ...state,\n libraryIds: state.libraryIds.filter((id) => id !== action.payload),\n };\n\n default:\n return state;\n }\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { manifest, STAMP_PLUGIN_ID } from './manifest';\nimport { StampPluginConfig, StampState } from './types';\nimport { StampPlugin } from './stamp-plugin';\nimport { stampReducer, initialState } from './reducer';\nimport { StampAction } from './actions';\n\nexport const StampPluginPackage: PluginPackage<\n StampPlugin,\n StampPluginConfig,\n StampState,\n StampAction\n> = {\n manifest,\n create: (registry, config) => new StampPlugin(STAMP_PLUGIN_ID, registry, config),\n reducer: stampReducer,\n initialState,\n};\n\nexport * from './stamp-plugin';\nexport * from './types';\nexport * from './manifest';\nexport * from './actions';\nexport * from './reducer';\nexport { RUBBER_STAMP_TOOL_ID } from './tools';\n"],"names":["STAMP_PLUGIN_ID","manifest","id","name","version","provides","requires","optional","defaultConfig","defaultLibrary","nameKey","categories","manifests","url","fallbackLocale","ADD_STAMP_LIBRARY","REMOVE_STAMP_LIBRARY","addStampLibrary","type","payload","removeStampLibrary","rubberStampHandlerFactory","annotationType","PdfAnnotationSubtype","STAMP","create","context","onPreview","onCommit","getTool","pageSize","pageRotation","getToolContext","onPointerMove","pos","ctx","stampSize","width","height","bounds","origin","x","y","size","data","rect","ghostUrl","onPointerDown","tool","anno","defaults","stamp","PdfAnnotationName","Custom","subject","flags","pageIndex","uuidV4","created","Date","_a","behavior","insertUpright","applyInsertUpright","clampAnnotationToPage","appearance","onPointerLeave","RUBBER_STAMP_TOOL_ID","stampTools","defineAnnotationTool","labelKey","matchScore","interaction","exclusive","cursor","isDraggable","isResizable","isRotatable","lockAspectRatio","isGroupDraggable","isGroupResizable","isGroupRotatable","deactivateToolAfterCreate","selectAfterCreate","useAppearanceStream","pointerHandler","ANNOTATION_NAME_MAP","Approved","Experimental","NotApproved","AsIs","Expired","NotForPublicRelease","Confidential","Final","Sold","Departmental","ForComment","TopSecret","Draft","ForPublicRelease","Completed","Void","PreliminaryResults","InformationOnly","Rejected","Witness","InitialHere","SignHere","Accepted","Image","_StampPlugin","BasePlugin","constructor","registry","config","super","this","instanceId","libraries","Map","libraryChange$","createEmitter","activeStamp$","createScopedEmitter","documentId","activeStamp","managedManifests","annotation","i18n","localeUnsubscribe","toolChangeUnsubscribe","currentGhostUrl","getPlugin","addTool","onActiveToolChange","URL","revokeObjectURL","emit","_b","initialize","libConfig","loadLibraryInternal","toPromise","length","initializeManifests","buildCapability","getLibraries","getStampsByCategory","category","renderStamp","libraryId","dpr","loadLibrary","loadLibraryFromManifest","createNewLibrary","options","addStampToLibrary","pdf","removeStampFromLibrary","stampId","updateStamp","updates","updateLibrary","removeLibrary","exportLibrary","forDocument","createStampScope","onActiveStampChange","onGlobal","onLibraryChange","on","Array","from","values","results","library","libraryMatches","includes","stamps","stampMatches","push","get","task","Task","reject","code","PdfErrorCode","NotFound","message","page","document","pages","scaleFactor","engine","renderPageRect","withAnnotations","rotation","transparentBackground","generateLibraryId","getLibraryDocumentId","createDocument","wait","doc","readonly","set","dispatch","emitLibraryChange","resolve","error","logger","fail","NotSupport","tempDocId","now","openDocumentBuffer","content","tempDoc","importPages","newPages","newPage","pageCount","stampDef","index","closeDocument","createStampFromAnnotation","createStampFromAnnotations","annotations","activateStampPlacement","activateStampPlacementById","getActiveStamp","forScope","find","s","getValue","extractPages","blob","createObjectURL","setActiveTool","docState","getCoreDocument","DocNotOpen","resolveTargetLibrary","targetId","exportAnnotationAppearanceAsPdf","exportAnnotationsAppearanceAsPdf","has","defaultId","delete","warn","saveAsCopy","openDocumentUrl","map","stampIdx","findIndex","deletePage","splice","i","Object","assign","loadManifestUrl","currentLocale","getLocale","source","localeAware","locale","resolvedUrl","replace","managed","fallbackUrl","onLocaleChange","event","handleLocaleChange","newLocale","fallback","fetch","then","response","ok","Error","status","statusText","json","pdfUrl","resolveManifestPdfUrl","entry","subjectKey","label","catch","manifestUrl","pdfPath","startsWith","substring","lastIndexOf","destroy","clear","libs","StampPlugin","initialState","libraryIds","stampReducer","state","action","filter","StampPluginPackage","reducer"],"mappings":"yLAGaA,EAAkB,QAElBC,EAA8C,CACzDC,GAAIF,EACJG,KAAM,eACNC,QAAS,QACTC,SAAU,CAAC,SACXC,SAAU,CAAC,cACXC,SAAU,CAAC,QACXC,cAAe,CACbC,eAAgB,CACdP,GAAI,SACJC,KAAM,gBACNO,QAAS,uBACTC,WAAY,CAAC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