@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
package/dist/export.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a,b
|
|
1
|
+
import{a,b}from"./chunk-MEE2NNYB.js";import"./chunk-YNY65JUJ.js";import"./chunk-ZT72PD2C.js";import"./chunk-4C666HHU.js";export{b as exportDocumentAsImages,a as exportDocumentAsPdf};
|
|
2
2
|
//# sourceMappingURL=export.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as he,b as me,c as fe,d as ue,e as xe,f as ye,g as be,h as Ce,i as Se,j as ve}from"./chunk-4XWSVHFW.js";import{a as N,b as c,c as V,d as F,e as ee,f as te,j as se,k as re,l as oe,m as ie,n as ae,r as a,s as ne,t as le}from"./chunk-DOKG4LX2.js";import{a as $e}from"./chunk-5KUKBKWL.js";import{b as o,c as b}from"./chunk-XEN5VKAV.js";import"./chunk-V6E2SSSW.js";import{a as Re}from"./chunk-2AB5L3Y2.js";import{a as Ie}from"./chunk-J7HWZNIP.js";import{a as Pe}from"./chunk-NEEWG3OP.js";import"./chunk-PUJYN435.js";import{a as u}from"./chunk-4ICUYKSR.js";import"./chunk-CWCS22CQ.js";import{a as x}from"./chunk-DY5ZSP4Q.js";import{a as ce}from"./chunk-4YYY7PHH.js";import"./chunk-4GEMGDRU.js";import{a as I,b as R,c as D,e as E,f as k,g as _,l as d}from"./chunk-534NMCRQ.js";import{a as Y}from"./chunk-KH5JE65X.js";import{a as X}from"./chunk-ULTSZWZO.js";import{a as w,b as O,c as P}from"./chunk-RDCHJL6F.js";import{e as $}from"./chunk-IH2AI54D.js";import{a as Q}from"./chunk-U3V3VZGO.js";import{a as H}from"./chunk-6DSLE3AY.js";import{a as q}from"./chunk-5OTO5WFV.js";import{a as Z}from"./chunk-O6FQFVKY.js";import{b as f}from"./chunk-WETG2JD7.js";import{a as g,b as Ae,c as Te,d as h,e as m}from"./chunk-FAVTIE3M.js";import{a as we,b as Oe,c as C}from"./chunk-MEE2NNYB.js";import{a as pe,b as de,c as ge,d as n}from"./chunk-YNY65JUJ.js";import{a as L,b as M,c as z,d as U,e as W,f as B,g as K,h as G,i as j,j as J}from"./chunk-ZT72PD2C.js";import{a as T}from"./chunk-FQRADJY6.js";import{a as A}from"./chunk-DIU5BGU5.js";import"./chunk-4C666HHU.js";var p=class extends b{#e=null;static properties={isOpen:{type:Boolean,state:!0},docId:{type:String,state:!0},docName:{type:String,state:!0},pages:{type:Array,state:!0},lang:{type:String,state:!0},step:{type:String,state:!0},progress:{type:Number,state:!0},statusMessage:{type:String,state:!0},resultText:{type:String,state:!0},confidence:{type:Number,state:!0},copied:{type:Boolean,state:!0}};createRenderRoot(){return this}disconnectedCallback(){super.disconnectedCallback(),this.#e&&(this.#e.abort(),this.#e=null),m(),this.isOpen=!1}constructor(){super(),this.isOpen=!1,this.docId="",this.docName="",this.pages=[],this.lang="eng",this.step="processing",this.progress=0,this.statusMessage="Starting OCR engine...",this.resultText="",this.confidence=0,this.copied=!1,this._pageIndex=null,this.#e=null}open(e,r,s,t="eng"){this._pageIndex=null,this._openInternal(e,r,s,t)}openPage(e,r,s,t,i="eng"){this._pageIndex=t,this._openInternal(e,r,[s],i)}_openInternal(e,r,s,t){if(this.#e&&(this.#e.abort(),this.#e=null),this.docId=e,this.docName=r||"Document",this.pages=s||[],this.lang=t,this.progress=0,this.resultText="",this.confidence=0,this.copied=!1,(this.pages||[]).filter(l=>l.src).length===0){this.step="empty",this.statusMessage="This document does not contain any image pages for text recognition.",this.isOpen=!0;return}this.step="processing",this.statusMessage=typeof window<"u"&&!window.Tesseract?"Downloading OCR engine...":"Starting OCR engine...",this.isOpen=!0,this.startOcr(t)}cancel=()=>{this.#e&&(this.#e.abort(),this.#e=null),this.close()};close=()=>{this.#e&&(this.#e.abort(),this.#e=null),this.isOpen=!1};async startOcr(e="eng"){this.#e&&(this.#e.abort(),this.#e=null),this.#e=new AbortController;let{signal:r}=this.#e;try{let s=await h(this.pages,{lang:e,abortSignal:r,onPageProgress:({overallProgress:t,message:i})=>{this.isOpen&&!r.aborted&&(this.progress=Math.round((t||0)*100),this.statusMessage=i)}});if(this.isOpen&&!r.aborted&&(this.step="done",this.resultText=s.combinedText||"",this.confidence=s.averageConfidence||0,n.success("Text recognition complete"),this.docId&&Array.isArray(s.pagesResults)))try{let t=await c.getDoc(this.docId);if(t&&Array.isArray(t.pages)){for(let i of s.pagesResults){let l=t.pages.find(v=>v.id===i.pageId)||t.pages[i.pageIndex];l&&(l.ocrText=i.text,l.ocrConfidence=i.confidence,l.ocrWords=i.words)}await c.saveDoc(this.docId,t)}}catch(t){console.warn("Could not persist OCR results to document:",t)}}catch(s){if(s.name==="AbortError"||r.aborted)return;console.error("Document OCR Error:",s),this.isOpen&&(this.step="error",this.statusMessage=s.message||"Text recognition failed",n.error(s.message||"Text recognition failed"))}finally{this.#e?.signal===r&&(this.#e=null)}}handleLangChange=e=>{let r=e.target.value;this.lang=r,this.step="processing",this.progress=0,this.statusMessage="Starting OCR engine with new language...",this.startOcr(r)};handleTextInput=e=>{this.resultText=e.target.value};copyText=async()=>{if(this.resultText)try{await navigator.clipboard.writeText(this.resultText),this.copied=!0,n.success("Copied text to clipboard"),setTimeout(()=>{this.copied=!1},2e3)}catch(e){console.error("Failed to copy text:",e),n.error("Failed to copy text to clipboard")}};downloadText=()=>{if(!this.resultText)return;let e=(this.docName||"document").replace(/[/\\?%*:|"<>]/g,"_"),r=new Blob([this.resultText],{type:"text/plain;charset=utf-8"}),s=URL.createObjectURL(r),t=document.createElement("a");t.href=s,t.download=`${e}-ocr.txt`,t.click(),URL.revokeObjectURL(s),n.success(`Exported OCR text (${e}-ocr.txt)`)};get _isSinglePage(){return this._pageIndex!==null}get _dialogLabel(){return this._isSinglePage?`Extract Text \u2014 ${this.docName} (Page ${this._pageIndex+1})`:`Extract All Text \u2014 ${this.docName}`}render(){return this.isOpen?o`
|
|
2
2
|
<sl-dialog
|
|
3
3
|
label="${this._dialogLabel}"
|
|
4
4
|
open
|
|
@@ -12,10 +12,10 @@ import{a as de,b as he,c as ge,d as me,e as ue,f as fe,g as xe,h as be,i as ye,j
|
|
|
12
12
|
@sl-change=${this.handleLangChange}
|
|
13
13
|
style="min-width: 180px;"
|
|
14
14
|
>
|
|
15
|
-
${
|
|
15
|
+
${g.map(e=>o`<sl-option value=${e.code}>${e.flag} ${e.label}</sl-option>`)}
|
|
16
16
|
</sl-select>
|
|
17
17
|
|
|
18
|
-
${this.step==="done"?
|
|
18
|
+
${this.step==="done"?o`
|
|
19
19
|
<sl-badge
|
|
20
20
|
variant=${this.confidence>=75?"success":this.confidence>=50?"warning":"danger"}
|
|
21
21
|
>
|
|
@@ -24,7 +24,7 @@ import{a as de,b as he,c as ge,d as me,e as ue,f as fe,g as xe,h as be,i as ye,j
|
|
|
24
24
|
`:""}
|
|
25
25
|
</div>
|
|
26
26
|
|
|
27
|
-
${this.step==="empty"?
|
|
27
|
+
${this.step==="empty"?o`
|
|
28
28
|
<div style="padding: 2.5rem 1rem; text-align: center; color: #64748b;">
|
|
29
29
|
<sl-icon name="file-earmark-x" style="font-size: 2.5rem; margin-bottom: 0.5rem; color: #94a3b8;"></sl-icon>
|
|
30
30
|
<p style="margin: 0; font-size: 1rem; color: #334155; font-weight: 500;">${this.statusMessage}</p>
|
|
@@ -32,7 +32,7 @@ import{a as de,b as he,c as ge,d as me,e as ue,f as fe,g as xe,h as be,i as ye,j
|
|
|
32
32
|
</div>
|
|
33
33
|
`:""}
|
|
34
34
|
|
|
35
|
-
${this.step==="processing"?
|
|
35
|
+
${this.step==="processing"?o`
|
|
36
36
|
<div style="padding: 2.5rem 1rem; text-align: center;">
|
|
37
37
|
<div style="font-size: 1.1rem; color: #0284c7; font-weight: 600; margin-bottom: 1rem;">
|
|
38
38
|
${this.statusMessage}
|
|
@@ -44,14 +44,14 @@ import{a as de,b as he,c as ge,d as me,e as ue,f as fe,g as xe,h as be,i as ye,j
|
|
|
44
44
|
</div>
|
|
45
45
|
`:""}
|
|
46
46
|
|
|
47
|
-
${this.step==="error"?
|
|
47
|
+
${this.step==="error"?o`
|
|
48
48
|
<div style="padding: 2rem; text-align: center; color: #ef4444;">
|
|
49
49
|
<sl-icon name="x-circle-fill" style="font-size: 2rem;"></sl-icon>
|
|
50
50
|
<p style="margin-top: 0.5rem;">${this.statusMessage}</p>
|
|
51
51
|
</div>
|
|
52
52
|
`:""}
|
|
53
53
|
|
|
54
|
-
${this.step==="done"?
|
|
54
|
+
${this.step==="done"?o`
|
|
55
55
|
<div>
|
|
56
56
|
<sl-textarea
|
|
57
57
|
rows="14"
|
|
@@ -62,18 +62,18 @@ import{a as de,b as he,c as ge,d as me,e as ue,f as fe,g as xe,h as be,i as ye,j
|
|
|
62
62
|
</div>
|
|
63
63
|
`:""}
|
|
64
64
|
|
|
65
|
-
${this.step==="processing"?
|
|
65
|
+
${this.step==="processing"?o`
|
|
66
66
|
<sl-button slot="footer" variant="default" @click=${this.cancel}>
|
|
67
67
|
<sl-icon slot="prefix" name="x-lg"></sl-icon>
|
|
68
68
|
Cancel
|
|
69
69
|
</sl-button>
|
|
70
70
|
`:""}
|
|
71
|
-
${this.step==="empty"||this.step==="error"?
|
|
71
|
+
${this.step==="empty"||this.step==="error"?o`
|
|
72
72
|
<sl-button slot="footer" variant="default" @click=${this.close}>
|
|
73
73
|
Close
|
|
74
74
|
</sl-button>
|
|
75
75
|
`:""}
|
|
76
|
-
${this.step==="done"?
|
|
76
|
+
${this.step==="done"?o`
|
|
77
77
|
<sl-button slot="footer" variant="default" @click=${this.close}>
|
|
78
78
|
Close
|
|
79
79
|
</sl-button>
|
|
@@ -85,15 +85,7 @@ import{a as de,b as he,c as ge,d as me,e as ue,f as fe,g as xe,h as be,i as ye,j
|
|
|
85
85
|
<sl-icon slot="prefix" name="download"></sl-icon>
|
|
86
86
|
Download .txt
|
|
87
87
|
</sl-button>
|
|
88
|
-
<sl-button slot="footer" variant="default" @click=${this.downloadMarkdown}>
|
|
89
|
-
<sl-icon slot="prefix" name="download"></sl-icon>
|
|
90
|
-
Download .md
|
|
91
|
-
</sl-button>
|
|
92
|
-
<sl-button slot="footer" variant="primary" @click=${this.saveAsNote}>
|
|
93
|
-
<sl-icon slot="prefix" name="file-earmark-plus"></sl-icon>
|
|
94
|
-
Save as Note
|
|
95
|
-
</sl-button>
|
|
96
88
|
`:""}
|
|
97
89
|
</sl-dialog>
|
|
98
|
-
`:""}};customElements.define("copio-doc-ocr-dialog",
|
|
90
|
+
`:""}};customElements.define("copio-doc-ocr-dialog",p);var y=class{constructor(e=null){this.key=e}setKey(e){this.key=e}getKey(){return this.key}isValid(){return!!this.key}getTier(){return this.key?this.key.startsWith("pro_")?"pro":this.key.startsWith("ent_")?"enterprise":"commercial":"community"}};a("export",C);a("ocr",new u);a("sync",f);a("pdf",new x);a("imageProcessor",new d);export{V as BUILD_DATE,ie as COPIO_EVENTS,d as Canvas2DAdapter,fe as CopioAddEditDialog,me as CopioCarousel,p as CopioDocOcrDialog,le as CopioEngine,xe as CopioHeader,he as CopioImages,ye as CopioLoader,ue as CopioRow,ve as CopioScanner,$e as CopioSyncDialog,N as DocRepository,re as Document,X as ImageProcessorPort,$ as IndexedDbStorageAdapter,y as LicenseManager,T as MemoryStorageAdapter,Y as NullImageProcessorAdapter,Q as NullOcrAdapter,q as NullPdfAdapter,Re as NullSyncAdapter,H as OcrPort,O as OpfsStorageAdapter,se as Page,x as PdfKitAdapter,Z as PdfPort,Ie as PeerJsAdapter,g as SUPPORTED_LANGUAGES,oe as ScanSession,A as StoragePort,f as SyncManager,Pe as SyncPort,u as TesseractWasmAdapter,F as VERSION,Se as adoptScannerStyles,ge as clearNotifications,P as createDefaultAdapter,ae as dispatchCopioEvent,c as docRepository,Oe as exportDocumentAsImages,we as exportDocumentAsPdf,I as extractExif,D as fileToBase64,L as getAssetBase,de as getContainer,_ as getCroppedSrc,Ae as getOcrWorker,ne as getRegisteredService,Ce as getScannerStyleSheet,te as hasActiveEdits,W as loadCropper,K as loadJsZip,B as loadPdfKit,G as loadPeerJs,j as loadQrCode,U as loadScript,J as loadTesseract,ee as normalizeEditStack,n as notify,w as probeOpfs,R as randomId,h as recognizeDocumentPages,Te as recognizeImageText,a as registerService,ce as renderPdfPagesToDataUrls,z as resolveAssetUrl,k as rotateSrc,be as scannerCss,M as setAssetBase,pe as setContainer,m as terminateOcrWorker,E as thresholdSrc};
|
|
99
91
|
//# sourceMappingURL=index.js.map
|
package/dist/ocr.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a,b,c,d,e}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e}from"./chunk-FAVTIE3M.js";import"./chunk-YNY65JUJ.js";import"./chunk-ZT72PD2C.js";import"./chunk-4C666HHU.js";export{a as SUPPORTED_LANGUAGES,b as getOcrWorker,d as recognizeDocumentPages,c as recognizeImageText,e as terminateOcrWorker};
|
|
2
2
|
//# sourceMappingURL=ocr.js.map
|