@pdfmergy-embedpdf/plugin-attachment 2.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1571 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/attachment-plugin.d.ts +11 -0
- package/dist/lib/index.d.ts +7 -0
- package/dist/lib/manifest.d.ts +4 -0
- package/dist/lib/types.d.ts +13 -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 +1984 -0
- package/dist/preact/index.js.map +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 +1983 -0
- package/dist/react/index.js.map +1 -0
- package/dist/shared/hooks/index.d.ts +1 -0
- package/dist/shared/hooks/use-attachment.d.ts +11 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared-preact/hooks/index.d.ts +1 -0
- package/dist/shared-preact/hooks/use-attachment.d.ts +11 -0
- package/dist/shared-preact/index.d.ts +2 -0
- package/dist/shared-react/hooks/index.d.ts +1 -0
- package/dist/shared-react/hooks/use-attachment.d.ts +11 -0
- package/dist/shared-react/index.d.ts +2 -0
- package/dist/svelte/hooks/index.d.ts +1 -0
- package/dist/svelte/hooks/use-attachment.d.ts +11 -0
- package/dist/svelte/index.cjs +2 -0
- package/dist/svelte/index.cjs.map +1 -0
- package/dist/svelte/index.d.ts +1 -0
- package/dist/svelte/index.js +1952 -0
- package/dist/svelte/index.js.map +1 -0
- package/dist/vue/hooks/index.d.ts +1 -0
- package/dist/vue/hooks/use-attachment.d.ts +3 -0
- package/dist/vue/index.cjs +2 -0
- package/dist/vue/index.cjs.map +1 -0
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/index.js +1956 -0
- package/dist/vue/index.js.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-attachment';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AttachmentPlugin } from '../../index.ts';
|
|
2
|
+
export declare const useAttachmentPlugin: () => {
|
|
3
|
+
plugin: AttachmentPlugin | null;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare const useAttachmentCapability: () => {
|
|
8
|
+
provides: Readonly<import('../../index.ts').AttachmentCapability> | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
ready: Promise<void>;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-attachment';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AttachmentPlugin } from '../../lib/index.ts';
|
|
2
|
+
export declare const useAttachmentPlugin: () => {
|
|
3
|
+
plugin: AttachmentPlugin | null;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare const useAttachmentCapability: () => {
|
|
8
|
+
provides: Readonly<import('../../lib/index.ts').AttachmentCapability> | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
ready: Promise<void>;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-attachment';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AttachmentPlugin } from '../../lib/index.ts';
|
|
2
|
+
export declare const useAttachmentPlugin: () => {
|
|
3
|
+
plugin: AttachmentPlugin | null;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare const useAttachmentCapability: () => {
|
|
8
|
+
provides: Readonly<import('../../lib/index.ts').AttachmentCapability> | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
ready: Promise<void>;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-attachment';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AttachmentPlugin } from '../../lib/index.ts';
|
|
2
|
+
export declare const useAttachmentPlugin: () => {
|
|
3
|
+
plugin: AttachmentPlugin | null;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare const useAttachmentCapability: () => {
|
|
8
|
+
provides: Readonly<import('../../lib/index.ts').AttachmentCapability> | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
ready: Promise<void>;
|
|
11
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("svelte/internal/client");function t(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const i in e)if("default"!==i){const o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:()=>e[i]})}return t.default=e,Object.freeze(t)}require("svelte/internal/disclose-version");const i=t(e),o=i.proxy({registry:null,coreState:null,isInitializing:!0,pluginsReady:!1,activeDocumentId:null,activeDocument:null,documents:{},documentStates:[]});function s(e){const{registry:t}=o,s=i.proxy({plugin:null,isLoading:!0,ready:new Promise(()=>{})});if(null===t)return s;const l=t.getPlugin(e);if(!l)throw new Error(`Plugin ${e} not found`);return s.plugin=l,s.isLoading=!1,s.ready=l.ready(),s}const l=Object.freeze(["","","","\ufeff","",""]);new RegExp(`[${l.join("")}]`,"g");var r=(e=>(e[e.Unknown=-1]="Unknown",e[e.Courier=0]="Courier",e[e.Courier_Bold=1]="Courier_Bold",e[e.Courier_BoldOblique=2]="Courier_BoldOblique",e[e.Courier_Oblique=3]="Courier_Oblique",e[e.Helvetica=4]="Helvetica",e[e.Helvetica_Bold=5]="Helvetica_Bold",e[e.Helvetica_BoldOblique=6]="Helvetica_BoldOblique",e[e.Helvetica_Oblique=7]="Helvetica_Oblique",e[e.Times_Roman=8]="Times_Roman",e[e.Times_Bold=9]="Times_Bold",e[e.Times_BoldItalic=10]="Times_BoldItalic",e[e.Times_Italic=11]="Times_Italic",e[e.Symbol=12]="Symbol",e[e.ZapfDingbats=13]="ZapfDingbats",e))(r||{}),a=(e=>(e[e.Left=0]="Left",e[e.Center=1]="Center",e[e.Right=2]="Right",e))(a||{}),n=(e=>(e[e.Normal=0]="Normal",e[e.Multiply=1]="Multiply",e[e.Screen=2]="Screen",e[e.Overlay=3]="Overlay",e[e.Darken=4]="Darken",e[e.Lighten=5]="Lighten",e[e.ColorDodge=6]="ColorDodge",e[e.ColorBurn=7]="ColorBurn",e[e.HardLight=8]="HardLight",e[e.SoftLight=9]="SoftLight",e[e.Difference=10]="Difference",e[e.Exclusion=11]="Exclusion",e[e.Hue=12]="Hue",e[e.Saturation=13]="Saturation",e[e.Color=14]="Color",e[e.Luminosity=15]="Luminosity",e))(n||{});const c=Object.freeze({1:"invisible",2:"hidden",4:"print",8:"noZoom",16:"noRotate",32:"noView",64:"readOnly",128:"locked",256:"toggleNoView"});Object.entries(c).reduce((e,[t,i])=>(e[i]=Number(t),e),{});var u=(e=>(e[e.Print=4]="Print",e[e.ModifyContents=8]="ModifyContents",e[e.CopyContents=16]="CopyContents",e[e.ModifyAnnotations=32]="ModifyAnnotations",e[e.FillForms=256]="FillForms",e[e.ExtractForAccessibility=512]="ExtractForAccessibility",e[e.AssembleDocument=1024]="AssembleDocument",e[e.PrintHighQuality=2048]="PrintHighQuality",e[e.AllowAll=3900]="AllowAll",e))(u||{});const d=Object.freeze([{id:a.Left,label:"Left",css:"left"},{id:a.Center,label:"Center",css:"center"},{id:a.Right,label:"Right",css:"right"}]);d.reduce((e,t)=>(e[t.id]=t,e),{}),d.reduce((e,t)=>(e[t.css]=t.id,e),{}),d.map(e=>({value:e.id,label:e.label}));var m=(e=>(e.Courier="Courier",e.Helvetica="Helvetica",e.Times="Times",e.Symbol="Symbol",e.ZapfDingbats="ZapfDingbats",e.Unknown="Unknown",e))(m||{});r.Helvetica;const b={id:r.Helvetica,family:"Helvetica",bold:!1,italic:!1,label:"Helvetica",css:"Helvetica, Arial, sans-serif"},h=Object.freeze([{id:r.Courier,family:"Courier",bold:!1,italic:!1,label:"Courier",css:"Courier, monospace"},{id:r.Courier_Bold,family:"Courier",bold:!0,italic:!1,label:"Courier Bold",css:"Courier, monospace"},{id:r.Courier_BoldOblique,family:"Courier",bold:!0,italic:!0,label:"Courier Bold Oblique",css:"Courier, monospace"},{id:r.Courier_Oblique,family:"Courier",bold:!1,italic:!0,label:"Courier Oblique",css:"Courier, monospace"},b,{id:r.Helvetica_Bold,family:"Helvetica",bold:!0,italic:!1,label:"Helvetica Bold",css:"Helvetica, Arial, sans-serif"},{id:r.Helvetica_BoldOblique,family:"Helvetica",bold:!0,italic:!0,label:"Helvetica Bold Oblique",css:"Helvetica, Arial, sans-serif"},{id:r.Helvetica_Oblique,family:"Helvetica",bold:!1,italic:!0,label:"Helvetica Oblique",css:"Helvetica, Arial, sans-serif"},{id:r.Times_Roman,family:"Times",bold:!1,italic:!1,label:"Times Roman",css:'"Times New Roman", Times, serif'},{id:r.Times_Bold,family:"Times",bold:!0,italic:!1,label:"Times Bold",css:'"Times New Roman", Times, serif'},{id:r.Times_BoldItalic,family:"Times",bold:!0,italic:!0,label:"Times Bold Italic",css:'"Times New Roman", Times, serif'},{id:r.Times_Italic,family:"Times",bold:!1,italic:!0,label:"Times Italic",css:'"Times New Roman", Times, serif'},{id:r.Symbol,family:"Symbol",bold:!1,italic:!1,label:"Symbol",css:"Symbol, serif"},{id:r.ZapfDingbats,family:"ZapfDingbats",bold:!1,italic:!1,label:"Zapf Dingbats",css:"ZapfDingbats, serif"}]);h.reduce((e,t)=>(e[t.id]=t,e),{});const f=new Map;for(const ee of h)f.set(`${ee.family}_${ee.bold}_${ee.italic}`,ee.id);Object.values(m).filter(e=>"Unknown"!==e).map(e=>({value:e,label:e})),new Set(h.map(e=>e.family));const g=Object.freeze([{id:n.Normal,label:"Normal",css:"normal"},{id:n.Multiply,label:"Multiply",css:"multiply"},{id:n.Screen,label:"Screen",css:"screen"},{id:n.Overlay,label:"Overlay",css:"overlay"},{id:n.Darken,label:"Darken",css:"darken"},{id:n.Lighten,label:"Lighten",css:"lighten"},{id:n.ColorDodge,label:"Color Dodge",css:"color-dodge"},{id:n.ColorBurn,label:"Color Burn",css:"color-burn"},{id:n.HardLight,label:"Hard Light",css:"hard-light"},{id:n.SoftLight,label:"Soft Light",css:"soft-light"},{id:n.Difference,label:"Difference",css:"difference"},{id:n.Exclusion,label:"Exclusion",css:"exclusion"},{id:n.Hue,label:"Hue",css:"hue"},{id:n.Saturation,label:"Saturation",css:"saturation"},{id:n.Color,label:"Color",css:"color"},{id:n.Luminosity,label:"Luminosity",css:"luminosity"}]);g.reduce((e,t)=>(e[t.id]=t,e),{}),g.reduce((e,t)=>(e[t.css]=t.id,e),{}),g.map(e=>({value:e.id,label:e.label})),g.map(e=>e.id),u.Print,u.ModifyContents,u.CopyContents,u.ModifyAnnotations,u.FillForms,u.ExtractForAccessibility,u.AssembleDocument,u.PrintHighQuality,u.Print,u.ModifyContents,u.CopyContents,u.ModifyAnnotations,u.FillForms,u.ExtractForAccessibility,u.AssembleDocument,u.PrintHighQuality,u.Print,u.ModifyContents,u.CopyContents,u.ModifyAnnotations,u.FillForms,u.ExtractForAccessibility,u.AssembleDocument,u.PrintHighQuality,i.from_html("<!> <!>",1),i.from_html("<!> <!>",1);const C=Object.freeze(["","","","\ufeff","",""]);new RegExp(`[${C.join("")}]`,"g");var y=(e=>(e[e.Unknown=-1]="Unknown",e[e.Courier=0]="Courier",e[e.Courier_Bold=1]="Courier_Bold",e[e.Courier_BoldOblique=2]="Courier_BoldOblique",e[e.Courier_Oblique=3]="Courier_Oblique",e[e.Helvetica=4]="Helvetica",e[e.Helvetica_Bold=5]="Helvetica_Bold",e[e.Helvetica_BoldOblique=6]="Helvetica_BoldOblique",e[e.Helvetica_Oblique=7]="Helvetica_Oblique",e[e.Times_Roman=8]="Times_Roman",e[e.Times_Bold=9]="Times_Bold",e[e.Times_BoldItalic=10]="Times_BoldItalic",e[e.Times_Italic=11]="Times_Italic",e[e.Symbol=12]="Symbol",e[e.ZapfDingbats=13]="ZapfDingbats",e))(y||{}),v=(e=>(e[e.Left=0]="Left",e[e.Center=1]="Center",e[e.Right=2]="Right",e))(v||{}),p=(e=>(e[e.Normal=0]="Normal",e[e.Multiply=1]="Multiply",e[e.Screen=2]="Screen",e[e.Overlay=3]="Overlay",e[e.Darken=4]="Darken",e[e.Lighten=5]="Lighten",e[e.ColorDodge=6]="ColorDodge",e[e.ColorBurn=7]="ColorBurn",e[e.HardLight=8]="HardLight",e[e.SoftLight=9]="SoftLight",e[e.Difference=10]="Difference",e[e.Exclusion=11]="Exclusion",e[e.Hue=12]="Hue",e[e.Saturation=13]="Saturation",e[e.Color=14]="Color",e[e.Luminosity=15]="Luminosity",e))(p||{});const S=Object.freeze({1:"invisible",2:"hidden",4:"print",8:"noZoom",16:"noRotate",32:"noView",64:"readOnly",128:"locked",256:"toggleNoView"});Object.entries(S).reduce((e,[t,i])=>(e[i]=Number(t),e),{});var D=(e=>(e[e.Print=4]="Print",e[e.ModifyContents=8]="ModifyContents",e[e.CopyContents=16]="CopyContents",e[e.ModifyAnnotations=32]="ModifyAnnotations",e[e.FillForms=256]="FillForms",e[e.ExtractForAccessibility=512]="ExtractForAccessibility",e[e.AssembleDocument=1024]="AssembleDocument",e[e.PrintHighQuality=2048]="PrintHighQuality",e[e.AllowAll=3900]="AllowAll",e))(D||{});class T extends Error{constructor(e,t){super(`Permission denied. Required: ${e.map(e=>D[e]).join(", ")}`),this.requiredFlags=e,this.currentPermissions=t,this.name="PermissionDeniedError"}}const A=Object.freeze([{id:v.Left,label:"Left",css:"left"},{id:v.Center,label:"Center",css:"center"},{id:v.Right,label:"Right",css:"right"}]);A.reduce((e,t)=>(e[t.id]=t,e),{}),A.reduce((e,t)=>(e[t.css]=t.id,e),{}),A.map(e=>({value:e.id,label:e.label}));var H=(e=>(e.Courier="Courier",e.Helvetica="Helvetica",e.Times="Times",e.Symbol="Symbol",e.ZapfDingbats="ZapfDingbats",e.Unknown="Unknown",e))(H||{});y.Helvetica;const _={id:y.Helvetica,family:"Helvetica",bold:!1,italic:!1,label:"Helvetica",css:"Helvetica, Arial, sans-serif"},O=Object.freeze([{id:y.Courier,family:"Courier",bold:!1,italic:!1,label:"Courier",css:"Courier, monospace"},{id:y.Courier_Bold,family:"Courier",bold:!0,italic:!1,label:"Courier Bold",css:"Courier, monospace"},{id:y.Courier_BoldOblique,family:"Courier",bold:!0,italic:!0,label:"Courier Bold Oblique",css:"Courier, monospace"},{id:y.Courier_Oblique,family:"Courier",bold:!1,italic:!0,label:"Courier Oblique",css:"Courier, monospace"},_,{id:y.Helvetica_Bold,family:"Helvetica",bold:!0,italic:!1,label:"Helvetica Bold",css:"Helvetica, Arial, sans-serif"},{id:y.Helvetica_BoldOblique,family:"Helvetica",bold:!0,italic:!0,label:"Helvetica Bold Oblique",css:"Helvetica, Arial, sans-serif"},{id:y.Helvetica_Oblique,family:"Helvetica",bold:!1,italic:!0,label:"Helvetica Oblique",css:"Helvetica, Arial, sans-serif"},{id:y.Times_Roman,family:"Times",bold:!1,italic:!1,label:"Times Roman",css:'"Times New Roman", Times, serif'},{id:y.Times_Bold,family:"Times",bold:!0,italic:!1,label:"Times Bold",css:'"Times New Roman", Times, serif'},{id:y.Times_BoldItalic,family:"Times",bold:!0,italic:!0,label:"Times Bold Italic",css:'"Times New Roman", Times, serif'},{id:y.Times_Italic,family:"Times",bold:!1,italic:!0,label:"Times Italic",css:'"Times New Roman", Times, serif'},{id:y.Symbol,family:"Symbol",bold:!1,italic:!1,label:"Symbol",css:"Symbol, serif"},{id:y.ZapfDingbats,family:"ZapfDingbats",bold:!1,italic:!1,label:"Zapf Dingbats",css:"ZapfDingbats, serif"}]);O.reduce((e,t)=>(e[t.id]=t,e),{});const w=new Map;for(const ee of O)w.set(`${ee.family}_${ee.bold}_${ee.italic}`,ee.id);Object.values(H).filter(e=>"Unknown"!==e).map(e=>({value:e,label:e})),new Set(O.map(e=>e.family));const L=Object.freeze([{id:p.Normal,label:"Normal",css:"normal"},{id:p.Multiply,label:"Multiply",css:"multiply"},{id:p.Screen,label:"Screen",css:"screen"},{id:p.Overlay,label:"Overlay",css:"overlay"},{id:p.Darken,label:"Darken",css:"darken"},{id:p.Lighten,label:"Lighten",css:"lighten"},{id:p.ColorDodge,label:"Color Dodge",css:"color-dodge"},{id:p.ColorBurn,label:"Color Burn",css:"color-burn"},{id:p.HardLight,label:"Hard Light",css:"hard-light"},{id:p.SoftLight,label:"Soft Light",css:"soft-light"},{id:p.Difference,label:"Difference",css:"difference"},{id:p.Exclusion,label:"Exclusion",css:"exclusion"},{id:p.Hue,label:"Hue",css:"hue"},{id:p.Saturation,label:"Saturation",css:"saturation"},{id:p.Color,label:"Color",css:"color"},{id:p.Luminosity,label:"Luminosity",css:"luminosity"}]);L.reduce((e,t)=>(e[t.id]=t,e),{}),L.reduce((e,t)=>(e[t.css]=t.id,e),{}),L.map(e=>({value:e.id,label:e.label})),L.map(e=>e.id);D.Print,D.ModifyContents,D.CopyContents,D.ModifyAnnotations,D.FillForms,D.ExtractForAccessibility,D.AssembleDocument,D.PrintHighQuality;const B=[D.Print,D.ModifyContents,D.CopyContents,D.ModifyAnnotations,D.FillForms,D.ExtractForAccessibility,D.AssembleDocument,D.PrintHighQuality],F={[D.Print]:"print",[D.ModifyContents]:"modifyContents",[D.CopyContents]:"copyContents",[D.ModifyAnnotations]:"modifyAnnotations",[D.FillForms]:"fillForms",[D.ExtractForAccessibility]:"extractForAccessibility",[D.AssembleDocument]:"assembleDocument",[D.PrintHighQuality]:"printHighQuality"};function R(e,t){if(!e)return;if(t in e)return e[t];const i=F[t];return i&&i in e?e[i]:void 0}function k(e,t,i){var o;const s=e.documents[t],l=null==s?void 0:s.permissions,r=e.globalPermissions,a=(null==(o=null==s?void 0:s.document)?void 0:o.permissions)??D.AllowAll,n=R(null==l?void 0:l.overrides,i);if(void 0!==n)return n;const c=R(null==r?void 0:r.overrides,i);if(void 0!==c)return c;return!((null==l?void 0:l.enforceDocumentPermissions)??(null==r?void 0:r.enforceDocumentPermissions)??!0)||0!==(a&i)}function I(e,t){return B.reduce((i,o)=>k(e,t,o)?i|o:i,0)}class P{constructor(e,t){if(this.id=e,this.registry=t,this.cooldownActions={},this.debouncedTimeouts={},this.unsubscribeFromState=null,this.unsubscribeFromCoreStore=null,this.unsubscribeFromStartLoadingDocument=null,this.unsubscribeFromSetDocumentLoaded=null,this.unsubscribeFromCloseDocument=null,this.unsubscribeFromSetScale=null,this.unsubscribeFromSetRotation=null,e!==this.constructor.id)throw new Error(`Plugin ID mismatch: ${e} !== ${this.constructor.id}`);this.engine=this.registry.getEngine(),this.logger=this.registry.getLogger(),this.coreStore=this.registry.getStore(),this.pluginStore=this.coreStore.getPluginStore(this.id),this.unsubscribeFromState=this.pluginStore.subscribeToState((e,t,i)=>{this.onStoreUpdated(i,t)}),this.unsubscribeFromCoreStore=this.coreStore.subscribe((e,t,i)=>{this.onCoreStoreUpdated(i,t),t.core.activeDocumentId!==i.core.activeDocumentId&&this.onActiveDocumentChanged(i.core.activeDocumentId,t.core.activeDocumentId)}),this.unsubscribeFromStartLoadingDocument=this.coreStore.onAction("START_LOADING_DOCUMENT",e=>{this.onDocumentLoadingStarted(e.payload.documentId)}),this.unsubscribeFromSetDocumentLoaded=this.coreStore.onAction("SET_DOCUMENT_LOADED",e=>{this.onDocumentLoaded(e.payload.documentId)}),this.unsubscribeFromCloseDocument=this.coreStore.onAction("CLOSE_DOCUMENT",e=>{this.onDocumentClosed(e.payload.documentId)}),this.unsubscribeFromSetScale=this.coreStore.onAction("SET_SCALE",(e,t)=>{const i=e.payload.documentId??t.core.activeDocumentId;i&&this.onScaleChanged(i,e.payload.scale)}),this.unsubscribeFromSetRotation=this.coreStore.onAction("SET_ROTATION",(e,t)=>{const i=e.payload.documentId??t.core.activeDocumentId;i&&this.onRotationChanged(i,e.payload.rotation)}),this.readyPromise=new Promise(e=>{this.readyResolve=e}),this.readyResolve()}provides(){if(!this._capability){const e=this.buildCapability();this._capability=Object.freeze(e)}return this._capability}get state(){return this.pluginStore.getState()}get coreState(){return this.coreStore.getState()}getState(){return this.pluginStore.getState()}getCoreState(){return this.coreStore.getState()}dispatchCoreAction(e){return this.coreStore.dispatchToCore(e)}dispatchToAllPlugins(e){return this.coreStore.dispatch(e)}dispatch(e){return this.pluginStore.dispatch(e)}cooldownDispatch(e,t=100){const i=Date.now();return i-(this.cooldownActions[e.type]||0)>=t&&(this.cooldownActions[e.type]=i,this.dispatch(e),!0)}debouncedDispatch(e,t=100){const i=e.type;this.debouncedTimeouts[i]&&clearTimeout(this.debouncedTimeouts[i]),this.debouncedTimeouts[i]=setTimeout(()=>{this.dispatch(e),delete this.debouncedTimeouts[i]},t)}cancelDebouncedDispatch(e){this.debouncedTimeouts[e]&&(clearTimeout(this.debouncedTimeouts[e]),delete this.debouncedTimeouts[e])}subscribe(e){return this.pluginStore.subscribeToState(e)}subscribeToCoreStore(e){return this.coreStore.subscribe(e)}onStoreUpdated(e,t){}onCoreStoreUpdated(e,t){}onDocumentLoadingStarted(e){}onDocumentLoaded(e){}onDocumentClosed(e){}onActiveDocumentChanged(e,t){}onScaleChanged(e,t){}onRotationChanged(e,t){}destroy(){Object.values(this.debouncedTimeouts).forEach(e=>{clearTimeout(e)}),this.debouncedTimeouts={},this.unsubscribeFromState&&(this.unsubscribeFromState(),this.unsubscribeFromState=null),this.unsubscribeFromCoreStore&&(this.unsubscribeFromCoreStore(),this.unsubscribeFromCoreStore=null),this.unsubscribeFromStartLoadingDocument&&(this.unsubscribeFromStartLoadingDocument(),this.unsubscribeFromStartLoadingDocument=null),this.unsubscribeFromSetDocumentLoaded&&(this.unsubscribeFromSetDocumentLoaded(),this.unsubscribeFromSetDocumentLoaded=null),this.unsubscribeFromCloseDocument&&(this.unsubscribeFromCloseDocument(),this.unsubscribeFromCloseDocument=null),this.unsubscribeFromSetScale&&(this.unsubscribeFromSetScale(),this.unsubscribeFromSetScale=null),this.unsubscribeFromSetRotation&&(this.unsubscribeFromSetRotation(),this.unsubscribeFromSetRotation=null)}ready(){return this.readyPromise}markReady(){this.readyResolve()}resetReady(){this.readyPromise=new Promise(e=>{this.readyResolve=e})}getActiveDocumentId(){const e=this.coreState.core.activeDocumentId;if(!e)throw new Error("No active document");return e}getActiveDocumentIdOrNull(){return this.coreState.core.activeDocumentId}getCoreDocument(e){const t=e??this.getActiveDocumentIdOrNull();return t?this.coreState.core.documents[t]??null:null}getCoreDocumentOrThrow(e){const t=this.getCoreDocument(e);if(!t)throw new Error(`Document not found: ${e??"active"}`);return t}getDocumentPermissions(e){const t=e??this.coreState.core.activeDocumentId;return t?I(this.coreState.core,t):D.AllowAll}checkPermission(e,...t){const i=e??this.coreState.core.activeDocumentId;return!i||t.every(e=>k(this.coreState.core,i,e))}requirePermission(e,...t){const i=e??this.coreState.core.activeDocumentId;if(!i)return;const o=[];for(const s of t)k(this.coreState.core,i,s)||o.push(s);if(o.length>0){const e=I(this.coreState.core,i);throw new T(o,e)}}}class j extends Error{constructor(e){super(`Task aborted: ${JSON.stringify(e)}`),this.name="TaskAbortedError",this.reason=e}}class q extends Error{constructor(e){super(`Task rejected: ${JSON.stringify(e)}`),this.name="TaskRejectedError",this.reason=e}}class E{constructor(){this.state={stage:0},this.resolvedCallbacks=[],this.rejectedCallbacks=[],this._promise=null,this.progressCbs=[]}toPromise(){return this._promise||(this._promise=new Promise((e,t)=>{this.wait(t=>e(t),e=>{"abort"===e.type?t(new j(e.reason)):t(new q(e.reason))})})),this._promise}wait(e,t){switch(this.state.stage){case 0:this.resolvedCallbacks.push(e),this.rejectedCallbacks.push(t);break;case 1:e(this.state.result);break;case 2:t({type:"reject",reason:this.state.reason});break;case 3:t({type:"abort",reason:this.state.reason})}}resolve(e){if(0===this.state.stage){this.state={stage:1,result:e};for(const i of this.resolvedCallbacks)try{i(e)}catch(t){}this.resolvedCallbacks=[],this.rejectedCallbacks=[]}}reject(e){if(0===this.state.stage){this.state={stage:2,reason:e};for(const i of this.rejectedCallbacks)try{i({type:"reject",reason:e})}catch(t){}this.resolvedCallbacks=[],this.rejectedCallbacks=[]}}abort(e){if(0===this.state.stage){this.state={stage:3,reason:e};for(const i of this.rejectedCallbacks)try{i({type:"abort",reason:e})}catch(t){}this.resolvedCallbacks=[],this.rejectedCallbacks=[]}}fail(e){"abort"===e.type?this.abort(e.reason):this.reject(e.reason)}map(e,t){const i=new E,o=i.abort.bind(i);return i.abort=e=>{this.abort(e),o(e)},this.wait(o=>{if(0===i.state.stage)try{const s=e(o);s instanceof Promise?s.then(e=>{0===i.state.stage&&i.resolve(e)},e=>{0===i.state.stage&&i.reject(t(e))}):i.resolve(s)}catch(s){0===i.state.stage&&i.reject(t(s))}},e=>{0===i.state.stage&&i.fail(e)}),i}onProgress(e){this.progressCbs.push(e)}progress(e){for(const t of this.progressCbs)t(e)}static all(e){const t=new E;if(0===e.length)return t.resolve([]),t;const i=new Array(e.length);let o=0,s=!1;return e.forEach((l,r)=>{l.wait(l=>{s||(i[r]=l,o++,o===e.length&&(s=!0,t.resolve(i)))},e=>{s||(s=!0,"abort"===e.type?t.abort(e.reason):t.reject(e.reason))})}),t}static allSettled(e){const t=new E;if(0===e.length)return t.resolve([]),t;const i=new Array(e.length);let o=0;return e.forEach((s,l)=>{s.wait(s=>{i[l]={status:"resolved",value:s},o++,o===e.length&&t.resolve(i)},s=>{i[l]={status:"abort"===s.type?"aborted":"rejected",reason:s.reason},o++,o===e.length&&t.resolve(i)})}),t}static race(e){const t=new E;if(0===e.length)return t.reject("No tasks provided"),t;let i=!1;return e.forEach(e=>{e.wait(e=>{i||(i=!0,t.resolve(e))},e=>{i||(i=!0,"abort"===e.type?t.abort(e.reason):t.reject(e.reason))})}),t}static withProgress(e,t){const i=E.all(e);if(t){let i=0;e.forEach(o=>{o.wait(()=>{i++,t(i,e.length)},()=>{i++,t(i,e.length)})})}return i}}const N=Object.freeze(["","","","\ufeff","",""]);new RegExp(`[${N.join("")}]`,"g");var x=(e=>(e[e.Unknown=-1]="Unknown",e[e.Courier=0]="Courier",e[e.Courier_Bold=1]="Courier_Bold",e[e.Courier_BoldOblique=2]="Courier_BoldOblique",e[e.Courier_Oblique=3]="Courier_Oblique",e[e.Helvetica=4]="Helvetica",e[e.Helvetica_Bold=5]="Helvetica_Bold",e[e.Helvetica_BoldOblique=6]="Helvetica_BoldOblique",e[e.Helvetica_Oblique=7]="Helvetica_Oblique",e[e.Times_Roman=8]="Times_Roman",e[e.Times_Bold=9]="Times_Bold",e[e.Times_BoldItalic=10]="Times_BoldItalic",e[e.Times_Italic=11]="Times_Italic",e[e.Symbol=12]="Symbol",e[e.ZapfDingbats=13]="ZapfDingbats",e))(x||{}),M=(e=>(e[e.Left=0]="Left",e[e.Center=1]="Center",e[e.Right=2]="Right",e))(M||{}),Z=(e=>(e[e.Normal=0]="Normal",e[e.Multiply=1]="Multiply",e[e.Screen=2]="Screen",e[e.Overlay=3]="Overlay",e[e.Darken=4]="Darken",e[e.Lighten=5]="Lighten",e[e.ColorDodge=6]="ColorDodge",e[e.ColorBurn=7]="ColorBurn",e[e.HardLight=8]="HardLight",e[e.SoftLight=9]="SoftLight",e[e.Difference=10]="Difference",e[e.Exclusion=11]="Exclusion",e[e.Hue=12]="Hue",e[e.Saturation=13]="Saturation",e[e.Color=14]="Color",e[e.Luminosity=15]="Luminosity",e))(Z||{});const U=Object.freeze({1:"invisible",2:"hidden",4:"print",8:"noZoom",16:"noRotate",32:"noView",64:"readOnly",128:"locked",256:"toggleNoView"});Object.entries(U).reduce((e,[t,i])=>(e[i]=Number(t),e),{});var z=(e=>(e[e.Ok=0]="Ok",e[e.Unknown=1]="Unknown",e[e.NotFound=2]="NotFound",e[e.WrongFormat=3]="WrongFormat",e[e.Password=4]="Password",e[e.Security=5]="Security",e[e.PageError=6]="PageError",e[e.XFALoad=7]="XFALoad",e[e.XFALayout=8]="XFALayout",e[e.Cancelled=9]="Cancelled",e[e.Initialization=10]="Initialization",e[e.NotReady=11]="NotReady",e[e.NotSupport=12]="NotSupport",e[e.LoadDoc=13]="LoadDoc",e[e.DocNotOpen=14]="DocNotOpen",e[e.CantCloseDoc=15]="CantCloseDoc",e[e.CantCreateNewDoc=16]="CantCreateNewDoc",e[e.CantImportPages=17]="CantImportPages",e[e.CantCreateAnnot=18]="CantCreateAnnot",e[e.CantSetAnnotRect=19]="CantSetAnnotRect",e[e.CantSetAnnotContent=20]="CantSetAnnotContent",e[e.CantRemoveInkList=21]="CantRemoveInkList",e[e.CantAddInkStoke=22]="CantAddInkStoke",e[e.CantReadAttachmentSize=23]="CantReadAttachmentSize",e[e.CantReadAttachmentContent=24]="CantReadAttachmentContent",e[e.CantFocusAnnot=25]="CantFocusAnnot",e[e.CantSelectText=26]="CantSelectText",e[e.CantSelectOption=27]="CantSelectOption",e[e.CantCheckField=28]="CantCheckField",e[e.CantSetAnnotString=29]="CantSetAnnotString",e))(z||{});class ${static create(){return new E}static resolve(e){const t=new E;return t.resolve(e),t}static reject(e){const t=new E;return t.reject(e),t}static abort(e){const t=new E;return t.reject(e),t}}const Q=Object.freeze([{id:M.Left,label:"Left",css:"left"},{id:M.Center,label:"Center",css:"center"},{id:M.Right,label:"Right",css:"right"}]);Q.reduce((e,t)=>(e[t.id]=t,e),{}),Q.reduce((e,t)=>(e[t.css]=t.id,e),{}),Q.map(e=>({value:e.id,label:e.label}));var V=(e=>(e.Courier="Courier",e.Helvetica="Helvetica",e.Times="Times",e.Symbol="Symbol",e.ZapfDingbats="ZapfDingbats",e.Unknown="Unknown",e))(V||{});x.Helvetica;const X={id:x.Helvetica,family:"Helvetica",bold:!1,italic:!1,label:"Helvetica",css:"Helvetica, Arial, sans-serif"},J=Object.freeze([{id:x.Courier,family:"Courier",bold:!1,italic:!1,label:"Courier",css:"Courier, monospace"},{id:x.Courier_Bold,family:"Courier",bold:!0,italic:!1,label:"Courier Bold",css:"Courier, monospace"},{id:x.Courier_BoldOblique,family:"Courier",bold:!0,italic:!0,label:"Courier Bold Oblique",css:"Courier, monospace"},{id:x.Courier_Oblique,family:"Courier",bold:!1,italic:!0,label:"Courier Oblique",css:"Courier, monospace"},X,{id:x.Helvetica_Bold,family:"Helvetica",bold:!0,italic:!1,label:"Helvetica Bold",css:"Helvetica, Arial, sans-serif"},{id:x.Helvetica_BoldOblique,family:"Helvetica",bold:!0,italic:!0,label:"Helvetica Bold Oblique",css:"Helvetica, Arial, sans-serif"},{id:x.Helvetica_Oblique,family:"Helvetica",bold:!1,italic:!0,label:"Helvetica Oblique",css:"Helvetica, Arial, sans-serif"},{id:x.Times_Roman,family:"Times",bold:!1,italic:!1,label:"Times Roman",css:'"Times New Roman", Times, serif'},{id:x.Times_Bold,family:"Times",bold:!0,italic:!1,label:"Times Bold",css:'"Times New Roman", Times, serif'},{id:x.Times_BoldItalic,family:"Times",bold:!0,italic:!0,label:"Times Bold Italic",css:'"Times New Roman", Times, serif'},{id:x.Times_Italic,family:"Times",bold:!1,italic:!0,label:"Times Italic",css:'"Times New Roman", Times, serif'},{id:x.Symbol,family:"Symbol",bold:!1,italic:!1,label:"Symbol",css:"Symbol, serif"},{id:x.ZapfDingbats,family:"ZapfDingbats",bold:!1,italic:!1,label:"Zapf Dingbats",css:"ZapfDingbats, serif"}]);J.reduce((e,t)=>(e[t.id]=t,e),{});const W=new Map;for(const ee of J)W.set(`${ee.family}_${ee.bold}_${ee.italic}`,ee.id);Object.values(V).filter(e=>"Unknown"!==e).map(e=>({value:e,label:e})),new Set(J.map(e=>e.family));const G=Object.freeze([{id:Z.Normal,label:"Normal",css:"normal"},{id:Z.Multiply,label:"Multiply",css:"multiply"},{id:Z.Screen,label:"Screen",css:"screen"},{id:Z.Overlay,label:"Overlay",css:"overlay"},{id:Z.Darken,label:"Darken",css:"darken"},{id:Z.Lighten,label:"Lighten",css:"lighten"},{id:Z.ColorDodge,label:"Color Dodge",css:"color-dodge"},{id:Z.ColorBurn,label:"Color Burn",css:"color-burn"},{id:Z.HardLight,label:"Hard Light",css:"hard-light"},{id:Z.SoftLight,label:"Soft Light",css:"soft-light"},{id:Z.Difference,label:"Difference",css:"difference"},{id:Z.Exclusion,label:"Exclusion",css:"exclusion"},{id:Z.Hue,label:"Hue",css:"hue"},{id:Z.Saturation,label:"Saturation",css:"saturation"},{id:Z.Color,label:"Color",css:"color"},{id:Z.Luminosity,label:"Luminosity",css:"luminosity"}]);G.reduce((e,t)=>(e[t.id]=t,e),{}),G.reduce((e,t)=>(e[t.css]=t.id,e),{}),G.map(e=>({value:e.id,label:e.label})),G.map(e=>e.id);const K=class extends P{constructor(e,t){super(e,t)}async initialize(e){}buildCapability(){return{getAttachments:()=>this.getAttachments(),downloadAttachment:e=>this.downloadAttachment(e),forDocument:e=>this.createAttachmentScope(e)}}createAttachmentScope(e){return{getAttachments:()=>this.getAttachments(e),downloadAttachment:t=>this.downloadAttachment(t,e)}}downloadAttachment(e,t){const i=t??this.getActiveDocumentId(),o=this.coreState.core.documents[i];return(null==o?void 0:o.document)?this.engine.readAttachmentContent(o.document,e):$.reject({code:z.NotFound,message:`Document ${i} not found`})}getAttachments(e){const t=e??this.getActiveDocumentId(),i=this.coreState.core.documents[t];return(null==i?void 0:i.document)?this.engine.getAttachments(i.document):$.reject({code:z.NotFound,message:`Document ${t} not found`})}};K.id="attachment";let Y=K;exports.useAttachmentCapability=()=>function(e){const t=s(e),o=i.proxy({provides:null,isLoading:!0,ready:new Promise(()=>{})});return i.user_effect(()=>{if(!t.plugin)return o.provides=null,o.isLoading=t.isLoading,void(o.ready=t.ready);if(!t.plugin.provides)throw new Error(`Plugin ${e} does not provide a capability`);o.provides=t.plugin.provides(),o.isLoading=t.isLoading,o.ready=t.ready}),o}(Y.id),exports.useAttachmentPlugin=()=>s(Y.id);
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|