@copio/sdk 0.1.2 → 0.1.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/LICENSE +661 -0
- package/LICENSE-COMMERCIAL.md +43 -0
- package/README.md +6 -1
- package/THIRD_PARTY_NOTICES.md +416 -0
- package/dist/adapters/image/canvas2d-adapter.js +1 -1
- package/dist/adapters/image/index.js +1 -1
- package/dist/adapters/image/null-image-processor-adapter.js +1 -1
- package/dist/adapters/index.js +1 -1
- package/dist/adapters/indexeddb-adapter.js +1 -1
- package/dist/adapters/memory-adapter.js +1 -1
- package/dist/adapters/ocr/index.js +1 -1
- package/dist/adapters/ocr/null-ocr-adapter.js +1 -1
- package/dist/adapters/ocr/tesseract-wasm-adapter.js +1 -1
- package/dist/adapters/pdf/index.js +1 -1
- package/dist/adapters/pdf/null-pdf-adapter.js +1 -1
- package/dist/adapters/pdf/pdfkit-adapter.js +1 -1
- package/dist/adapters/storage/index.js +1 -1
- package/dist/adapters/storage/indexeddb-adapter.js +1 -1
- package/dist/adapters/storage/memory-adapter.js +1 -1
- package/dist/adapters/sync/index.js +1 -1
- package/dist/adapters/sync/null-sync-adapter.js +1 -1
- package/dist/adapters/sync/peerjs-adapter.js +1 -1
- package/dist/cdn.js +106 -249
- package/dist/{chunk-A5G52Q2W.js → chunk-2AB5L3Y2.js} +2 -2
- package/dist/{chunk-DGGK5KEX.js → chunk-4ICUYKSR.js} +2 -2
- package/dist/{chunk-IZOWC74B.js → chunk-4XWSVHFW.js} +69 -198
- package/dist/{chunk-IUBYFIV6.js → chunk-4YYY7PHH.js} +2 -2
- package/dist/{chunk-N7Q34F2P.js → chunk-534NMCRQ.js} +4 -4
- package/dist/{chunk-UCV3MQ6I.js → chunk-5KUKBKWL.js} +1 -1
- package/dist/{chunk-E7JYVRJA.js → chunk-5OTO5WFV.js} +2 -2
- package/dist/{chunk-N4R55VRR.js → chunk-6DSLE3AY.js} +1 -1
- package/dist/chunk-DIU5BGU5.js +2 -0
- package/dist/chunk-DOKG4LX2.js +2 -0
- package/dist/{chunk-B2EK6INF.js → chunk-DY5ZSP4Q.js} +2 -2
- package/dist/chunk-FAVTIE3M.js +8 -0
- package/dist/chunk-FQRADJY6.js +2 -0
- package/dist/chunk-IH2AI54D.js +2 -0
- package/dist/{chunk-PVNRK4OH.js → chunk-J7HWZNIP.js} +2 -2
- package/dist/{chunk-SH4P4XSZ.js → chunk-KH5JE65X.js} +2 -2
- package/dist/chunk-MEE2NNYB.js +2 -0
- package/dist/{chunk-KIMVF5UG.js → chunk-NEEWG3OP.js} +1 -1
- package/dist/{chunk-YHLOPPXM.js → chunk-O6FQFVKY.js} +1 -1
- package/dist/chunk-RDCHJL6F.js +2 -0
- package/dist/{chunk-B7HT2X67.js → chunk-U3V3VZGO.js} +2 -2
- package/dist/{chunk-HN3336JN.js → chunk-ULTSZWZO.js} +1 -1
- package/dist/{chunk-BKZEOOH4.js → chunk-WETG2JD7.js} +2 -2
- package/dist/{chunk-V2FP4EEH.js → chunk-YNY65JUJ.js} +1 -1
- package/dist/chunk-ZT72PD2C.js +2 -0
- package/dist/core.js +1 -1
- package/dist/custom-elements.json +264 -102
- package/dist/export.js +1 -1
- package/dist/index.js +11 -19
- package/dist/ocr.js +1 -1
- package/dist/scanner.js +88 -217
- package/dist/sync.js +1 -1
- package/dist/types/js/adapters/storage/blob-store.d.ts +48 -0
- package/dist/types/js/adapters/storage/index.d.ts +11 -4
- package/dist/types/js/adapters/storage/indexeddb-adapter.d.ts +46 -9
- package/dist/types/js/adapters/storage/memory-adapter.d.ts +7 -0
- package/dist/types/js/adapters/storage/opfs-adapter.d.ts +160 -0
- package/dist/types/js/adapters/storage/storage-port.d.ts +7 -0
- package/dist/types/js/components/copio-header.d.ts +4 -0
- package/dist/types/js/routes/doc/copio-carousel.d.ts +1 -2
- package/dist/types/js/routes/doc/copio-images.d.ts +0 -4
- package/dist/types/js/routes/home/copio-row.d.ts +2 -2
- package/dist/types/js/routes/ocr/copio-doc-ocr-dialog.d.ts +0 -2
- package/dist/types/js/services/doc-repository.d.ts +1 -0
- package/dist/types/js/services/export-utils.d.ts +8 -12
- package/dist/types/js/services/ocr-service.d.ts +2 -1
- package/dist/types/js/utils/module-loader.d.ts +0 -6
- package/dist/types/js/utils/utils.d.ts +5 -3
- package/dist/types/sdk/core.d.ts +13 -2
- package/dist/types/sdk/events.d.ts +4 -4
- package/dist/types/sdk/index.d.ts +3 -3
- package/dist/types/sdk/models.d.ts +66 -0
- package/dist/types/sdk/styles.d.ts +1 -1
- package/dist/types/sdk/version.d.ts +1 -1
- package/package.json +4 -3
- package/sdk/cdn.js +1 -0
- package/sdk/core.js +60 -0
- package/sdk/events.js +3 -2
- package/sdk/index.js +4 -3
- package/sdk/license.js +1 -0
- package/sdk/models.js +79 -3
- package/sdk/scanner.js +45 -7
- package/sdk/styles.js +12 -5
- package/sdk/sync.js +1 -0
- package/sdk/version.js +2 -1
- package/dist/chunk-36F637QU.js +0 -2
- package/dist/chunk-4JPEWIT4.js +0 -2
- package/dist/chunk-B5BEYYR2.js +0 -8
- package/dist/chunk-G65H4ZTJ.js +0 -2
- package/dist/chunk-HS6GDZIS.js +0 -2
- package/dist/chunk-K6YP7EET.js +0 -8
- package/dist/chunk-LI54F6PA.js +0 -2
- package/dist/chunk-OI4WCW7E.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as r}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{d as r}from"./chunk-YNY65JUJ.js";import{h as c,i as a}from"./chunk-ZT72PD2C.js";var u="https://copio.metered.live/api/v1/turn/credentials?apiKey=d90f0b0b6bdf180ea68238f5c2185074ce37",f=[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun.relay.metered.ca:80"}],p=5e3;async function h(){let i=new AbortController,e=setTimeout(()=>i.abort(),p);try{let t=await fetch(u,{signal:i.signal,cache:"no-store"});if(!t.ok)throw new Error(`HTTP ${t.status}`);let s=await t.json();if(!Array.isArray(s)||s.length===0)throw new Error("Empty ICE server list");return[{urls:"stun:stun.l.google.com:19302"},...s]}catch(t){return console.warn("[Sync] Failed to fetch TURN credentials, using STUN only:",t),f}finally{clearTimeout(e)}}var m=3e4,l=class{#i=null;#t=null;#r=null;#e=null;#c=0;#n=null;constructor(e,t){this.#t=e,this.#r=t}get state(){return this.#e}#s(e){this.#e=e,this.#r&&this.#r(this.#e)}#o(e){clearTimeout(this.#n),this.#e&&this.#s({...this.#e,step:"error",message:e})}async#a(){let e=++this.#c,[t,s]=await Promise.all([h(),c()]);return e!==this.#c?null:new s({config:{iceServers:t}})}#h(e){e.on("error",s=>this.#o(s.message));let t=e.peerConnection;t&&t.addEventListener("iceconnectionstatechange",()=>{console.log("[Sync] ICE state:",t.iceConnectionState),t.iceConnectionState==="failed"&&this.#o("Could not connect to the other device. Check both are online and try again.")})}#l(){clearTimeout(this.#n),this.#n=setTimeout(()=>{let e=this.#e?.step;e&&e!=="done"&&e!=="error"&&this.#o("Connection timed out. Try again.")},m)}#d(e){let t=()=>{clearTimeout(this.#n),this.#s({...this.#e,step:"syncing"}),this.#p(e)};e.open?t():e.on("open",t)}startHost(){if(this.#e?.mode!=="host"){if(!navigator.onLine){r.warning("An internet connection is needed to link devices.",{icon:"wifi-off",duration:4e3});return}this.#s({mode:"host",step:"init"}),this.#u().catch(e=>{this.#s({mode:"host",step:"error",message:e.message})})}}async#u(){let e=await this.#a();e&&(this.#i=e,e.on("error",t=>this.#o(t.message)),e.on("open",async t=>{let s=`${location.origin}${location.pathname}?peer=${t}`,o=(await a())(0,"M");o.addData(s),o.make(),this.#s({mode:"host",step:"waiting",qrSvg:o.createSvgTag(4,8),url:s,peerId:t})}),e.on("connection",t=>{this.#l(),this.#h(t),this.#d(t)}))}startJoiner(e){this.#e?.mode!=="joiner"&&(this.#s({mode:"joiner",step:"connecting"}),this.#l(),this.#f(e).catch(t=>{this.#s({mode:"joiner",step:"error",message:t.message})}))}async#f(e){let t=await this.#a();t&&(this.#i=t,t.on("error",s=>this.#o(s.message)),t.on("open",()=>{let s=t.connect(e);this.#h(s),this.#d(s)}))}#p(e){e.on("data",async t=>{let s;try{s=typeof t=="string"?JSON.parse(t):t}catch(o){console.error("Failed to parse sync data:",o);return}let n=0;typeof this.#t?.importDocs=="function"?n=await this.#t.importDocs(s):typeof this.#t?.transaction=="function"&&this.#t.transaction(()=>{for(let[o,d]of Object.entries(s||{}))this.#t.hasRow("docs",o)||n++,this.#t.setRow("docs",o,d)}),this.#s({...this.#e,step:"done",added:n}),r.success(`Sync complete \u2014 ${n} doc${n!==1?"s":""} added`)}),(async()=>{try{let t;typeof this.#t?.exportAll=="function"?t=await this.#t.exportAll():typeof this.#t?.getTable=="function"?t=this.#t.getTable("docs"):t={},e.send(JSON.stringify(t))}catch(t){console.error("Failed to send sync data:",t),this.#o(t.message)}})()}close(){this.#c++,clearTimeout(this.#n),this.#i?.destroy(),this.#i=null,this.#s(null)}};export{h as a,l as b};
|
|
2
|
+
//# sourceMappingURL=chunk-WETG2JD7.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var v=null,C={success:{slVariant:"success",defaultIcon:"check-circle",defaultDuration:3e3},error:{slVariant:"danger",defaultIcon:"exclamation-octagon",defaultDuration:5e3},danger:{slVariant:"danger",defaultIcon:"exclamation-octagon",defaultDuration:5e3},warning:{slVariant:"warning",defaultIcon:"exclamation-triangle",defaultDuration:4e3},info:{slVariant:"primary",defaultIcon:"info-circle",defaultDuration:4e3},primary:{slVariant:"primary",defaultIcon:"info-circle",defaultDuration:4e3},neutral:{slVariant:"neutral",defaultIcon:"info-circle",defaultDuration:4e3}};function I(n){v=n||null}function g(){return v||(typeof document<"u"?document.body:null)}function k(){let a=customElements.get("sl-alert")?.toastStack;a&&a.querySelectorAll("sl-alert").forEach(u=>{typeof u.hide=="function"&&u.hide()})}async function w(n,a={}){let e={};if(typeof n=="string"||n instanceof HTMLElement?e={message:n,...a}:n&&typeof n=="object"&&(e={...n,...a}),typeof customElements<"u"&&!customElements.get("sl-alert")&&await Promise.race([customElements.whenDefined("sl-alert"),new Promise(t=>setTimeout(t,200))]),typeof customElements>"u"||!customElements.get("sl-alert"))return null;let u=customElements.get("sl-alert"),s=e.variant||"info",f=C[s]||C.info,r=e.container||g();if(u?.toastStack&&r){let t=u.toastStack;t.parentElement!==r&&r.appendChild(t),r!==document.body?(t.style.position="absolute",t.style.width="auto",t.style.maxWidth="calc(100% - 24px)",t.style.left="12px",t.style.right="12px",t.style.insetInlineStart="12px",t.style.insetInlineEnd="12px",e.position==="top"?(t.style.top="12px",t.style.bottom="auto"):(t.style.top="auto",t.style.bottom="16px"),t.style.maxHeight="100%",t.style.overflow="auto"):(t.style.position="",t.style.width="",t.style.left="",t.style.right="",t.style.top="",t.style.bottom="",t.style.insetInlineStart="",t.style.insetInlineEnd="",t.style.maxHeight="",t.style.maxWidth="",t.style.overflow="")}let o=document.createElement("sl-alert");o.variant=f.slVariant,o.closable=e.closable!==!1,o.duration=e.duration!==void 0?e.duration:f.defaultDuration;let d=e.icon!==void 0?e.icon:f.defaultIcon;if(d){let t=document.createElement("sl-icon");t.slot="icon",t.name=d,o.appendChild(t)}let i=document.createElement("span");if(e.message instanceof HTMLElement?i.appendChild(e.message):e.html?i.innerHTML=e.message||"":i.textContent=e.message||"",e.action){let t=document.createElement("div");t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="space-between",t.style.gap="0.75rem",t.style.width="100%",i.style.flex="1",t.appendChild(i);let l=document.createElement("sl-button");l.size="small",l.variant=e.action.variant||"text",l.textContent=e.action.text||"Action",l.style.color="inherit",l.style.fontWeight="600",l.style.padding="0",l.addEventListener("click",m=>{m.preventDefault(),m.stopPropagation(),typeof e.action.onClick=="function"&&e.action.onClick(m,o),e.action.autoClose!==!1&&o.hide()}),t.appendChild(l),o.appendChild(t)}else o.appendChild(i);let y=o.toast();return o.toastPromise=y,o}function D(n,a={}){return p.show({message:n,variant:"success",...a})}function S(n,a={}){return p.show({message:n,variant:"error",...a})}function M(n,a={}){return p.show({message:n,variant:"warning",...a})}function N(n,a={}){return p.show({message:n,variant:"info",...a})}function V(n,a,e={}){return p.show({message:n,variant:e?.variant||"primary",icon:e?.icon!==void 0?e.icon:"arrow-counterclockwise",duration:e?.duration!==void 0?e.duration:5e3,closable:e?.closable!==!1,action:{text:e?.actionText||"Undo",onClick:(u,s)=>{typeof a=="function"&&a(u,s)},autoClose:!0},...e})}async function P(n,a={}){let e={};if(typeof n=="string"?e={message:n,...a}:n&&typeof n=="object"&&(e={...n,...a}),typeof customElements<"u"&&(!customElements.get("sl-alert")||!customElements.get("sl-progress-bar"))&&await Promise.race([Promise.all([customElements.whenDefined("sl-alert"),customElements.whenDefined("sl-progress-bar")]),new Promise(c=>setTimeout(c,200))]),typeof customElements>"u"||!customElements.get("sl-alert"))return{alert:null,progressBar:null,update(){},close(){}};let u=e.container||g(),s=document.createElement("sl-alert");s.variant=e.variant||"primary",s.closable=e.closable===!0,s.duration=1/0;let f=e.icon!==void 0?e.icon:"arrow-down-circle";if(f){let c=document.createElement("sl-icon");c.slot="icon",c.name=f,s.appendChild(c)}let r=document.createElement("div");r.className="notify-progress-wrapper",r.style.display="flex",r.style.flexDirection="column",r.style.gap="0.35rem",r.style.minWidth="220px";let o=document.createElement("div");o.style.display="flex",o.style.justifyContent="space-between",o.style.alignItems="center",o.style.gap="0.5rem";let d=document.createElement("span");d.className="notify-progress-message",d.style.fontWeight="500",d.style.fontSize="0.9rem",d.textContent=e.message||"Processing...",o.appendChild(d);let i=document.createElement("span");i.className="notify-progress-status",i.style.fontSize="0.78rem",i.style.color="#64748b",i.style.fontWeight="600";let y=e.done!==void 0?e.done:0,t=e.total!==void 0?e.total:0;t>0?i.textContent=`${y} / ${t}`:e.value!==void 0&&(i.textContent=`${e.value}%`),o.appendChild(i),r.appendChild(o);let l=document.createElement("sl-progress-bar");t>0?l.value=Math.round(y/t*100):e.value!==void 0?l.value=e.value:l.indeterminate=!0,r.appendChild(l),s.appendChild(r);let m=customElements.get("sl-alert");if(m?.toastStack&&u){let c=m.toastStack;c.parentElement!==u&&u.appendChild(c)}return s.toast(),{alert:s,progressBar:l,update({done:c,total:h,value:x,message:E}={}){if(E!==void 0&&(d.textContent=E),h!==void 0&&c!==void 0){l.indeterminate=!1;let b=Math.min(100,Math.max(0,Math.round(c/Math.max(h,1)*100)));l.value=b,i.textContent=`${c} / ${h}`}else x!==void 0&&(l.indeterminate=!1,l.value=Math.min(100,Math.max(0,x)),i.textContent=`${Math.round(l.value)}%`)},close(){typeof s.hide=="function"&&s.hide()}}}var p=Object.assign(function(n,a){return w(n,a)},{show:w,success:D,error:S,warning:M,info:N,undo:V,progress:P,clear:k,setContainer:I,getContainer:g});export{I as a,g as b,k as c,p as d};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
2
|
+
//# sourceMappingURL=chunk-YNY65JUJ.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var c=".";function l(){return c}function m(e){typeof e=="string"&&(c=e.replace(/\/+$/,"")||".")}function w(e){if(!e)return"";if(/^(https?:|\/\/|data:|blob:)/i.test(e))return e;let n=e.replace(/^\/+/,""),r=c;return!r||r==="."?n:`${r}/${n}`}var s=new Map;function o(e,n){let r=n();if(r)return Promise.resolve(r);if(s.has(e))return s.get(e);let p=new Promise((i,d)=>{if(typeof document>"u"){d(new Error(`Cannot load script "${e}" in an environment without DOM document.`));return}let a=w(e),u=document.querySelector(`script[src="${a}"], script[src="${e}"]`);if(u){if(n()){i(n());return}u.addEventListener("load",()=>i(n()),{once:!0}),u.addEventListener("error",()=>d(new Error(`Failed to load "${e}": Network error`)),{once:!0});return}let t=document.createElement("script");t.src=a,t.async=!0,t.onload=()=>{let f=n();i(f)},t.onerror=()=>{s.delete(e),t.remove(),d(new Error(`Failed to load script "${e}": Network error`))},document.head.appendChild(t)});return s.set(e,p),p}async function j(){return o("js/lib/cropper.js",()=>window.Cropper)}async function x(){return o("js/lib/pdfkit.js",()=>window.PDFDocument)}async function y(){return o("js/lib/jszip.min.js",()=>window.JSZip)}async function P(){return o("js/lib/peerjs.min.js",()=>window.Peer)}async function $(){return o("js/lib/qrcode.js",()=>window.qrcode)}async function g(){return o("js/lib/tesseract.min.js",()=>window.Tesseract)}export{l as a,m as b,w as c,o as d,j as e,x as f,y as g,P as h,$ as i,g as j};
|
|
2
|
+
//# sourceMappingURL=chunk-ZT72PD2C.js.map
|
package/dist/core.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as o,b as p,c as q,d as r,e as x,f as y,g as z,h as A,i as B,j as C,k as D,l as E,m as F,n as G,o as H,p as I,q as J}from"./chunk-
|
|
1
|
+
import{a as o,b as p,c as q,d as r,e as x,f as y,g as z,h as A,i as B,j as C,k as D,l as E,m as F,n as G,o as H,p as I,q as J,r as K,s as L,t as M}from"./chunk-DOKG4LX2.js";import"./chunk-4GEMGDRU.js";import{a as e,b as f,c as g,d as h,e as i,f as j,g as k,h as l,j as m,k as n,l as v}from"./chunk-534NMCRQ.js";import{a as w}from"./chunk-KH5JE65X.js";import{a as u}from"./chunk-ULTSZWZO.js";import{c as d}from"./chunk-RDCHJL6F.js";import{e as c}from"./chunk-IH2AI54D.js";import{a as s}from"./chunk-U3V3VZGO.js";import"./chunk-6DSLE3AY.js";import{a as t}from"./chunk-5OTO5WFV.js";import"./chunk-O6FQFVKY.js";import"./chunk-ZT72PD2C.js";import{a as b}from"./chunk-FQRADJY6.js";import{a}from"./chunk-DIU5BGU5.js";import"./chunk-4C666HHU.js";export{q as BUILD_DATE,F as COPIO_EVENTS,v as Canvas2DAdapter,M as CopioEngine,I as DEFAULT_EXPORT_FORMATS,H as DEFAULT_FEATURES,J as DEFAULT_OCR_LANGUAGES,o as DocRepository,D as Document,u as ImageProcessorPort,c as IndexedDbStorageAdapter,b as MemoryStorageAdapter,w as NullImageProcessorAdapter,s as NullOcrAdapter,t as NullPdfAdapter,C as Page,E as ScanSession,a as StoragePort,r as VERSION,n as applyEdits,h as applySauvolaToImageData,d as createDefaultAdapter,A as cropOriginalToRotated,B as cropRotatedToOriginal,G as dispatchCopioEvent,p as docRepository,e as extractExif,g as fileToBase64,k as getCroppedSrc,L as getRegisteredService,y as hasActiveEdits,x as normalizeEditStack,l as normalizeEdits,f as randomId,K as registerService,m as renderEditsToCanvas,z as rotateCrop,j as rotateSrc,i as thresholdSrc};
|
|
2
2
|
//# sourceMappingURL=core.js.map
|