@copio/sdk 0.1.0 → 0.1.2
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/cdn.js +1 -1
- package/dist/{chunk-AU7NM25J.js → chunk-HS6GDZIS.js} +2 -2
- package/dist/{chunk-6IBEH4EW.js → chunk-IZOWC74B.js} +2 -2
- package/dist/core.js +1 -1
- package/dist/custom-elements.json +570 -570
- package/dist/index.js +1 -1
- package/dist/types/sdk/version.d.ts +1 -1
- package/package.json +24 -2
- package/sdk/version.js +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
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 as ve}from"./chunk-
|
|
1
|
+
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 as ve}from"./chunk-IZOWC74B.js";import{a as E,b as R,c as G,d as J,e as X,f as Y,g as ee,h as te,i as se,j as oe,k as re,o as a,p as ie,q as ae}from"./chunk-HS6GDZIS.js";import{a as we}from"./chunk-UCV3MQ6I.js";import{b as r,c as b}from"./chunk-XEN5VKAV.js";import"./chunk-V6E2SSSW.js";import{a as Pe}from"./chunk-A5G52Q2W.js";import{a as ke}from"./chunk-PVNRK4OH.js";import{a as Oe}from"./chunk-KIMVF5UG.js";import"./chunk-PUJYN435.js";import{a as m}from"./chunk-DGGK5KEX.js";import"./chunk-CWCS22CQ.js";import{a as u}from"./chunk-B2EK6INF.js";import"./chunk-4GEMGDRU.js";import{a as $,b as A,c as O,e as k,f as P,g as I,l as c}from"./chunk-N7Q34F2P.js";import{a as q}from"./chunk-SH4P4XSZ.js";import{a as Z}from"./chunk-HN3336JN.js";import{a as T}from"./chunk-36F637QU.js";import{a as w}from"./chunk-4JPEWIT4.js";import{a as F}from"./chunk-B7HT2X67.js";import{a as V}from"./chunk-N4R55VRR.js";import{a as Q}from"./chunk-E7JYVRJA.js";import{a as H}from"./chunk-YHLOPPXM.js";import{b as g}from"./chunk-BKZEOOH4.js";import{a as p,b as Se,c as Ce,d,e as h}from"./chunk-B5BEYYR2.js";import{c as Te,d as $e,e as Ae,f as y}from"./chunk-K6YP7EET.js";import{a as ne}from"./chunk-IUBYFIV6.js";import{a as le,b as ce,c as pe,d as i}from"./chunk-V2FP4EEH.js";import{a as D,b as N,c as _,d as L,e as M,f as U,g as z,h as B,i as W,j,k as K}from"./chunk-G65H4ZTJ.js";import{a as C}from"./chunk-OI4WCW7E.js";import{a as S}from"./chunk-LI54F6PA.js";import"./chunk-4C666HHU.js";var l=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),h(),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,s,t,o="eng"){this._pageIndex=null,this._openInternal(e,s,t,o)}openPage(e,s,t,o,n="eng"){this._pageIndex=o,this._openInternal(e,s,[t],n)}_openInternal(e,s,t,o){if(this.#e&&(this.#e.abort(),this.#e=null),this.docId=e,this.docName=s||"Document",this.pages=t||[],this.lang=o,this.progress=0,this.resultText="",this.confidence=0,this.copied=!1,(this.pages||[]).filter(x=>x.type!=="markdown"&&x.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(o)}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:s}=this.#e;try{let t=await d(this.pages,{lang:e,abortSignal:s,onPageProgress:({overallProgress:o,message:n})=>{this.isOpen&&!s.aborted&&(this.progress=Math.round((o||0)*100),this.statusMessage=n)}});this.isOpen&&!s.aborted&&(this.step="done",this.resultText=t.combinedText||"",this.confidence=t.averageConfidence||0,i.success("Text recognition complete"))}catch(t){if(t.name==="AbortError"||s.aborted)return;console.error("Document OCR Error:",t),this.isOpen&&(this.step="error",this.statusMessage=t.message||"Text recognition failed",i.error(t.message||"Text recognition failed"))}finally{this.#e?.signal===s&&(this.#e=null)}}handleLangChange=e=>{let s=e.target.value;this.lang=s,this.step="processing",this.progress=0,this.statusMessage="Starting OCR engine with new language...",this.startOcr(s)};handleTextInput=e=>{this.resultText=e.target.value};copyText=async()=>{if(this.resultText)try{await navigator.clipboard.writeText(this.resultText),this.copied=!0,i.success("Copied text to clipboard"),setTimeout(()=>{this.copied=!1},2e3)}catch(e){console.error("Failed to copy text:",e),i.error("Failed to copy text to clipboard")}};downloadMarkdown=()=>{if(!this.resultText)return;let e=(this.docName||"document").replace(/[/\\?%*:|"<>]/g,"_"),s=new Blob([this.resultText],{type:"text/markdown;charset=utf-8"}),t=URL.createObjectURL(s),o=document.createElement("a");o.href=t,o.download=`${e}-ocr.md`,o.click(),URL.revokeObjectURL(t),i.success(`Exported OCR markdown (${e}-ocr.md)`)};downloadText=()=>{if(!this.resultText)return;let e=(this.docName||"document").replace(/[/\\?%*:|"<>]/g,"_"),s=new Blob([this.resultText],{type:"text/plain;charset=utf-8"}),t=URL.createObjectURL(s),o=document.createElement("a");o.href=t,o.download=`${e}-ocr.txt`,o.click(),URL.revokeObjectURL(t),i.success(`Exported OCR text (${e}-ocr.txt)`)};saveAsNote=()=>{if(!this.resultText||!this.docId)return;let e={docId:this.docId,content:this.resultText,pageIndex:this._pageIndex};this.dispatchEvent(new CustomEvent("note:save",{bubbles:!0,composed:!1,detail:e})),i.success("Saved OCR text as note"),this.close()};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?r`
|
|
2
2
|
<sl-dialog
|
|
3
3
|
label="${this._dialogLabel}"
|
|
4
4
|
open
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const BUILD_DATE: string;
|
|
2
|
-
export declare const VERSION = "0.1.
|
|
2
|
+
export declare const VERSION = "0.1.2";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@copio/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Embeddable Web Components and Headless Services for Document Scanning, OCR, Editing, and P2P Sync.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -50,6 +50,28 @@
|
|
|
50
50
|
"sdk/scanner.js",
|
|
51
51
|
"*.css"
|
|
52
52
|
],
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
},
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "https://github.com/edwilliams/copio.git"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://copio.netlify.app",
|
|
61
|
+
"keywords": [
|
|
62
|
+
"copio",
|
|
63
|
+
"scanner",
|
|
64
|
+
"web-components",
|
|
65
|
+
"camera",
|
|
66
|
+
"ocr",
|
|
67
|
+
"pdf",
|
|
68
|
+
"document-scanner",
|
|
69
|
+
"crop",
|
|
70
|
+
"image-processing",
|
|
71
|
+
"pwa"
|
|
72
|
+
],
|
|
73
|
+
"author": "Ed Williams",
|
|
74
|
+
"license": "AGPL-3.0",
|
|
53
75
|
"scripts": {
|
|
54
76
|
"build": "npm run build --prefix scripts/bundle",
|
|
55
77
|
"build:sdk": "node scripts/build-sdk.mjs",
|
|
@@ -57,7 +79,7 @@
|
|
|
57
79
|
"export:cards": "node scripts/export-cards.mjs",
|
|
58
80
|
"lint": "oxlint",
|
|
59
81
|
"typecheck": "node scripts/sync-vendor-types.mjs && tsc --noEmit",
|
|
60
|
-
"
|
|
82
|
+
"prepare": "node scripts/sync-vendor-types.mjs",
|
|
61
83
|
"check:size": "node scripts/check-bundle-size.mjs",
|
|
62
84
|
"check:consumer": "tsc -p test/fixtures/ts-consumer/tsconfig.json",
|
|
63
85
|
"check:ci": "npm run lint && npm run typecheck && npm run build:sdk && npm run check:size && npm run check:consumer && npm test",
|
package/sdk/version.js
CHANGED