@copio/sdk 0.1.3 → 0.1.4

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 (44) hide show
  1. package/README.md +154 -151
  2. package/dist/adapters/image/canvas2d-adapter.js +1 -1
  3. package/dist/adapters/image/index.js +1 -1
  4. package/dist/adapters/index.js +1 -1
  5. package/dist/adapters/indexeddb-adapter.js +1 -1
  6. package/dist/adapters/pdf/index.js +1 -1
  7. package/dist/adapters/pdf/pdfkit-adapter.js +1 -1
  8. package/dist/adapters/storage/index.js +1 -1
  9. package/dist/adapters/storage/indexeddb-adapter.js +1 -1
  10. package/dist/cdn.js +42 -1119
  11. package/dist/chunk-FFRDPFTS.js +1395 -0
  12. package/dist/{chunk-534NMCRQ.js → chunk-G5EUMLYT.js} +2 -2
  13. package/dist/{chunk-4YYY7PHH.js → chunk-GGERQ3CJ.js} +11 -11
  14. package/dist/{chunk-DOKG4LX2.js → chunk-IBF5HCYT.js} +2 -2
  15. package/dist/chunk-K4NR6OAC.js +2 -0
  16. package/dist/chunk-L4OVZN23.js +2 -0
  17. package/dist/chunk-NQW6FFN7.js +50 -0
  18. package/dist/core.js +1 -1
  19. package/dist/custom-elements.json +260 -1770
  20. package/dist/index.js +2 -2
  21. package/dist/scanner.js +16 -1120
  22. package/dist/sync.js +1 -1
  23. package/dist/types/sdk/elements.d.ts +0 -12
  24. package/dist/types/sdk/index.d.ts +0 -6
  25. package/dist/types/sdk/scanner.d.ts +2 -7
  26. package/dist/types/sdk/version.d.ts +1 -1
  27. package/package.json +1 -1
  28. package/sdk/index.js +0 -6
  29. package/sdk/scanner.js +5 -12
  30. package/sdk/version.js +1 -1
  31. package/dist/chunk-4XWSVHFW.js +0 -2472
  32. package/dist/chunk-5KUKBKWL.js +0 -33
  33. package/dist/chunk-DY5ZSP4Q.js +0 -2
  34. package/dist/chunk-IH2AI54D.js +0 -2
  35. package/dist/chunk-RDCHJL6F.js +0 -2
  36. package/dist/chunk-XEN5VKAV.js +0 -19
  37. package/dist/types/js/components/copio-header.d.ts +0 -23
  38. package/dist/types/js/components/copio-loader.d.ts +0 -6
  39. package/dist/types/js/core/store.d.ts +0 -2
  40. package/dist/types/js/routes/add-edit/copio-add-edit-dialog.d.ts +0 -9
  41. package/dist/types/js/routes/doc/copio-carousel.d.ts +0 -42
  42. package/dist/types/js/routes/doc/copio-images.d.ts +0 -33
  43. package/dist/types/js/routes/home/copio-row.d.ts +0 -49
  44. package/dist/types/js/styles/cropper-styles.d.ts +0 -5
package/README.md CHANGED
@@ -1,210 +1,213 @@
1
- # Copio
1
+ # `@copio/sdk`
2
2
 
3
- <div align="center">
4
- <img style="margin: 0 auto; max-width: 512px; border-radius: 16px; box-shadow: 0 8px 24px rgba(0,0,0,0.3);" src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4eb7cf55-5d05-497a-8745-9002f292c32a_512x512.png" alt="Copio Logo" />
3
+ **Embeddable document scanner Web Component (`<copio-scanner>`) and headless JavaScript engine (`CopioEngine`) for web applications.**
5
4
 
6
- <h3>The Private, Offline-First Document Scanner & Manager</h3>
5
+ Capture, crop, binarize, OCR, and compile multi-page Searchable PDFs 100% client-side in the browser — zero cloud uploads, zero per-scan API fees, and zero framework lock-in.
7
6
 
8
- <p><i>Capture, enhance, organise, and export multi-page documents — 100% in your browser with zero cloud dependencies.</i></p>
7
+ [![License: AGPL-3.0 / Commercial](https://img.shields.io/badge/License-AGPL--3.0%20%2F%20Commercial-0284c7)](LICENSE)
8
+ [![Scanner Bundle](https://img.shields.io/badge/scanner%20bundle-54%20KB%20gzip-16a34a)](#entry-points--bundle-sizes)
9
+ [![Zero Cloud Uploads](https://img.shields.io/badge/privacy-100%25%20on--device-10b981)](#use-cases)
9
10
 
10
- <div>
11
- <img src="https://img.shields.io/badge/License-AGPL--3.0%20%2F%20Commercial-blue?style=for-the-badge" alt="AGPL-3.0 / Commercial License" />
12
- <img src="https://img.shields.io/badge/Privacy-100%25%20Local-brightgreen?style=for-the-badge&logo=shield" alt="100% Local Privacy" />
13
- <img src="https://img.shields.io/badge/Offline-First-blue?style=for-the-badge&logo=pwa" alt="Offline First" />
14
- <img src="https://img.shields.io/badge/Sync-Peer--to--Peer%20WebRTC-purple?style=for-the-badge&logo=webrtc" alt="P2P Sync" />
15
- <img src="https://img.shields.io/badge/Platform-PWA%20%7C%20Android%20TWA-3ddc84?style=for-the-badge&logo=android" alt="PWA and Android TWA" />
16
- <img src="https://img.shields.io/badge/Built%20with-Lit%20%2B%20TinyBase-orange?style=for-the-badge&logo=lit" alt="Built with Lit & TinyBase" />
17
- </div>
18
- </div>
19
-
20
- <br/>
11
+ 👉 **[Live Interactive SDK Sandbox & Event Inspector →](https://copio.netlify.app)**
21
12
 
22
13
  ---
23
14
 
24
- ## 🌟 Overview
25
-
26
- **Copio** is a modern, lightweight, privacy-focused document scanning and document management application that runs entirely on your device.
27
-
28
- Whether you're digitising paper receipts, creating multi-page document archives, importing existing PDFs, or taking Markdown notes alongside your scans — Copio gives you the full power of a desktop document management suite with **zero cloud servers, zero user accounts, and zero data tracking**.
15
+ ## Built For
29
16
 
30
- > 📖 **Read the Story:** Learn about the vision and evolution of Copio in [Ed Williams' Substack post](https://edwilliams.substack.com/p/copio). Originally built in React in 2019, Copio was completely rebuilt in 2026 using Web Components (Lit) and TinyBase for ultimate performance and zero framework overhead.
17
+ - **Expense & AP Automation SaaS** — Single-shot receipt capture (`aspect="receipt"`) and multi-page vendor invoice scanning (`mode="batch" aspect="a4"`).
18
+ - **Fintech Onboarding & KYC** — Guided front-and-back ID / card capture (`aspect="card" max-pages="2"`).
19
+ - **Healthcare, Legal & Insurance Portals** — 100% on-device Sauvola B&W document cleanup, Tesseract WASM OCR, and Searchable PDF generation before uploading to your own storage (HIPAA / GDPR friendly).
20
+ - **Local-First & Offline PWAs** — Pluggable persistence across Origin Private File System (OPFS), IndexedDB, or ephemeral in-memory sessions.
31
21
 
32
22
  ---
33
23
 
34
- ## 🔥 Key Highlights
24
+ ## Install
35
25
 
36
- - 🔒 **100% Private & Serverless**: Your documents never leave your browser. Data is saved locally in IndexedDB using reactive storage.
37
- - ⚡ **Works Everywhere Offline**: Service Worker pre-caches all assets. Load it once and use it forever without an internet connection.
38
- - 🔤 **Client-Side OCR (Text Recognition)**: Extract text from scanned documents and images using WebAssembly (Tesseract.js WASM) with zero server uploads and multi-language support.
39
- - 🔄 **Serverless Peer-to-Peer Sync**: Transfer documents directly between your phone, tablet, and laptop via WebRTC and instant QR code pairing — no cloud middleman.
40
- - 📷 **Smart Camera & Ingestion**: Capture directly from your mobile or desktop camera with automatic EXIF orientation detection. Import existing images, multi-page PDFs, or Markdown files.
41
- - 🎨 **Pro-Grade Page Enhancements**: Interactive precision cropping, 360° rotation, and a high-contrast **Black & White Threshold filter** for turning shadow-heavy photos into crisp scanned paper.
42
- - 📑 **Hybrid Document Engine**: Combine camera scans, imported images, multi-page PDF pages, and Markdown notes seamlessly within a single document container.
43
- - 📤 **Client-Side PDF & ZIP Export**: Convert your multi-page documents into clean A4 PDFs or download all pages as a ZIP bundle directly in the browser using WebAssembly and client-side PDFKit.
44
- - 📱 **Native App Experience**: Install as a PWA on iOS, Desktop, and Android, or sideload the native-feeling Android Trusted Web Activity (TWA) APK.
45
-
46
- ---
26
+ ```bash
27
+ npm install @copio/sdk
28
+ ```
47
29
 
48
- ## 🛠️ Features Breakdown
49
-
50
- ### 📷 1. Ingestion & Capture
51
- - **Live Camera Capture**: Snap photos of documents directly within the web app.
52
- - **EXIF Auto-Correction**: Automatic rotation detection based on image EXIF metadata.
53
- - **Multi-Format Ingestion**: Upload images (`.jpg`, `.png`), multi-page PDF documents (`.pdf`), or Markdown files (`.md`, `.markdown`, `.txt`).
54
- - **PDF Page Extraction**: Automatically renders uploaded PDF pages as editable document pages.
55
-
56
- ### 🔤 2. Client-Side OCR & Text Extraction
57
- - **On-Device Text Recognition**: Powered by Tesseract.js WebAssembly running inside background Web Workers for smooth UI performance.
58
- - **Per-Page & Full-Document OCR**: Extract text from single pages or batch-process entire multi-page documents with live progress indicators.
59
- - **Convert to Markdown Note**: Turn any scanned page into an editable Markdown note with a single tap.
60
- - **Multi-Language Support**: English pre-cached offline, with on-demand support for Spanish, French, German, Italian, Portuguese, Chinese, Japanese, and more.
61
- - **One-Click Copy & Export**: Copy recognized text with confidence metrics or download as `.txt` / `.md`.
62
-
63
- ### ✂️ 3. Editing & Page Enhancement
64
- - **Interactive Cropping**: Adjust boundaries easily using Cropper.js.
65
- - **Rotation**: Rotate individual pages to correct orientation.
66
- - **Black & White Filter**: Convert shaded photos into high-contrast document scans.
67
- - **Drag-to-Reorder**: Reorder pages effortlessly using drag-and-drop.
68
- - **Metadata Inspector**: View EXIF data and file properties on demand.
69
-
70
- ### 📝 4. Hybrid Markdown & Note Taking
71
- - **Embedded Markdown Notes**: Mix text notes and document scans in the same document.
72
- - **Live Markdown Previewer**: View rich rendered Markdown notes in a full-screen carousel viewer.
73
- - **Markdown Text Editor**: Create and edit Markdown pages directly inside your document.
74
-
75
- ### 🔄 5. Serverless Peer-to-Peer Sync
76
- - **WebRTC Data Channels**: Pair devices directly using PeerJS.
77
- - **Instant QR Pairing**: Scan a QR code on your host device with your phone to link instantly.
78
- - **Zero Cloud Storage**: Direct browser-to-browser transmission keeping your documents strictly private.
79
-
80
- ### 📤 6. Flexible Exporting
81
- - **Client-Side PDF Generation**: Generate formatted multi-page A4 PDFs with proper margins and image scaling.
82
- - **Bulk Image Download**: Download individual pages or package entire documents into a compressed ZIP file.
83
- - **Markdown File Export**: Download Markdown components as `.md` files.
30
+ Works in **Vanilla JS, React, Vue, Svelte, and Angular** via native Shadow DOM custom elements (`<copio-scanner>`) with full TypeScript declarations (`.d.ts`) and Custom Elements Manifest (`custom-elements.json`).
84
31
 
85
32
  ---
86
33
 
87
- ## 🏗️ Tech Stack & Architecture
88
-
89
- Copio is designed with a lightweight, zero-framework-overhead philosophy for maximum speed, longevity, and offline reliability.
34
+ ## 30-Second Quickstart
90
35
 
91
- | Library / Tech | Purpose |
92
- |---|---|
93
- | 🧱 **[Lit](https://lit.dev)** | Ultra-fast Web Components base class & templating engine |
94
- | 🗃️ **[TinyBase](https://tinybase.org)** | Reactive browser store with auto-persisted IndexedDB storage |
95
- | 🔤 **[Tesseract.js](https://tesseract.projectnaptha.com/)** | Client-side WebAssembly Optical Character Recognition (OCR) |
96
- | 🎨 **[Shoelace](https://shoelace.style)** | Accessible UI component library (dialogs, icons, buttons) |
97
- | ✂️ **[Cropper.js](https://fengyuanchen.github.io/cropperjs/)** | Touch-friendly interactive image crop and rotation tool |
98
- | 📄 **[PDFKit](https://pdfkit.org)** | In-browser client-side PDF document compiler |
99
- | 📡 **[PeerJS](https://peerjs.com)** | WebRTC peer-to-peer data transport layer |
100
- | 📷 **[Exifr](https://mutiny.cz/exifr/)** | High-performance EXIF image metadata parser |
101
- | 🔀 **[Sortable.js](https://sortablejs.github.io/Sortable/)** | Touch & mouse drag-and-drop reordering |
102
- | 📱 **[Service Worker](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API)** | Full offline asset caching & progressive web app shell |
36
+ Import `@copio/sdk/scanner` (self-contained, ~54 KB gzipped) and drop `<copio-scanner>` into any modal, drawer, or page container:
103
37
 
38
+ ```html
39
+ <copio-scanner
40
+ id="scanner"
41
+ mode="batch"
42
+ aspect="a4"
43
+ theme="dark"
44
+ ></copio-scanner>
104
45
 
105
- ---
46
+ <script type="module">
47
+ import { COPIO_EVENTS } from '@copio/sdk/scanner';
106
48
 
107
- ## 🚀 Quick Start
49
+ const scanner = document.getElementById('scanner');
108
50
 
109
- ### 📖 User Guide
110
- 1. **Create a Document**: Click the **+** button and enter a title for your document.
111
- 2. **Add Content**: Tap the upload button to capture photos, upload image files, import PDFs, or create Markdown notes.
112
- 3. **Enhance & Reorder**: Tap any page thumbnail to crop, rotate, apply black & white threshold filters, or edit text. Drag thumbnails to reorder pages.
113
- 4. **Export & Share**: Tap the document dropdown menu to download as a multi-page PDF, a ZIP image bundle, or a Markdown file.
114
- 5. **Sync Across Devices**: Click **Link Device** in the header to generate a QR code for instant peer-to-peer sync with another browser or phone.
51
+ scanner.addEventListener(COPIO_EVENTS.SCAN_COMPLETE, (e) => {
52
+ const { pages, pageCount } = e.detail;
53
+ console.log(`Captured ${pageCount} page(s):`, pages);
54
+ });
55
+ </script>
56
+ ```
115
57
 
116
58
  ---
117
59
 
118
- ### 💻 Developer Setup
60
+ ## Common Integration Recipes
119
61
 
120
- #### Prerequisites
121
- - **Node.js** (v18+ recommended — required for bundler scripts only; the web app has zero runtime server dependencies).
122
- - A static HTTP/HTTPS server or `localhost` (HTTPS is required for Service Worker activation on non-localhost domains).
62
+ ### 1. Searchable PDF Export & Client-Side OCR
123
63
 
124
- #### Installation
64
+ Heavy WASM/PDF engines (`pdfkit` and `tesseract.js`) are **excluded** from `@copio/sdk/scanner` by default so your initial bundle stays small. Import `@copio/sdk` (or register `PdfKitAdapter` and `TesseractWasmAdapter`) when you need PDF compilation or OCR:
125
65
 
126
- ```bash
127
- # Clone the repository
128
- git clone https://github.com/edwilliams/copio.git
129
- cd copio
66
+ ```js
67
+ import { COPIO_EVENTS } from '@copio/sdk'; // Registers default PDF + OCR adapters
130
68
 
131
- # Install build dependencies
132
- npm install
133
- ```
69
+ const scanner = document.querySelector('copio-scanner');
134
70
 
135
- #### Build Bundles
71
+ // 1. Export a multi-page Searchable PDF (embeds an invisible, selectable OCR text layer)
72
+ const pdfBlob = await scanner.exportPdf({
73
+ docName: 'vendor-invoice-1042',
74
+ searchable: true, // Set false for standard image-only PDF
75
+ download: true, // Trigger browser download (or false to upload pdfBlob to S3)
76
+ onProgress: (done, total, msg) => console.log(msg || `${done}/${total}`),
77
+ });
136
78
 
137
- ```bash
138
- # Bundle client libraries into js/
139
- npm run build
79
+ // 2. Or run standalone OCR text & bounding-box extraction
80
+ const { text, pagesResults, averageConfidence } = await scanner.ocr();
81
+ console.log(`Recognized (${Math.round(averageConfidence)}% confidence):`, text);
140
82
  ```
141
83
 
142
- #### Run Locally
84
+ ### 2. Scenario Presets (Receipts, ID Cards, Multi-Page Invoices)
143
85
 
144
- Serve the project root using any static web server:
86
+ ```html
87
+ <!-- 1. Expense Receipt (Single Page, Tall Aspect Guide) -->
88
+ <copio-scanner mode="single" aspect="receipt" max-pages="1"></copio-scanner>
145
89
 
146
- ```bash
147
- # Using npx serve
148
- npx serve .
90
+ <!-- 2. KYC ID Card (Front & Back Guided Capture) -->
91
+ <copio-scanner mode="single" aspect="card" max-pages="2"></copio-scanner>
149
92
 
150
- # Or using Python
151
- python3 -m http.server 3000
93
+ <!-- 3. Multi-Page Document Batch -->
94
+ <copio-scanner mode="batch" aspect="a4"></copio-scanner>
152
95
  ```
153
96
 
154
- Open `http://localhost:3000` in your web browser.
97
+ ### 3. Headless Engine (`@copio/sdk/core`)
155
98
 
156
- ---
99
+ Building your own UI in Tailwind/React or processing files in a background pipeline? Use `CopioEngine` with zero DOM or UI dependencies:
157
100
 
158
- ## 📱 Mobile Installation & Android APK (TWA)
101
+ ```js
102
+ import { CopioEngine, MemoryStorageAdapter } from '@copio/sdk/core';
103
+ import { PdfKitAdapter, TesseractWasmAdapter } from '@copio/sdk';
159
104
 
160
- ### 📲 Progressive Web App (PWA)
161
- Open Copio in your mobile browser (Safari on iOS, Chrome on Android/Desktop) and select **Add to Home Screen** or **Install App**. Copio installs as a standalone application that works 100% offline.
105
+ const engine = new CopioEngine({
106
+ storage: new MemoryStorageAdapter(),
107
+ services: {
108
+ pdf: new PdfKitAdapter(),
109
+ ocr: new TesseractWasmAdapter(),
110
+ },
111
+ });
162
112
 
163
- ### 🤖 Android Trusted Web Activity (TWA)
164
- Copio can be compiled into a lightweight native Android APK shell using [Bubblewrap](https://developer.chrome.com/docs/android/trusted-web-activity/).
113
+ // Ingest File/Blob objects (auto-extracts EXIF orientation)
114
+ const pages = await engine.addFiles(fileInput.files);
165
115
 
166
- #### Install Pre-Built APK
167
- Download `app-release-signed.apk` from the [`copio-twa/`](../copio-twa/) directory, transfer it to your device, and tap to install (enable "Install from unknown sources" if prompted).
116
+ // Apply non-destructive edits (original image is always preserved)
117
+ await engine.applyEdit(null, pages[0].id, {
118
+ rotation: 90,
119
+ filter: 'bw', // Adaptive Sauvola B&W document thresholding
120
+ crop: { x: 20, y: 20, width: 600, height: 800 },
121
+ });
168
122
 
169
- #### Build Custom APK
170
- ```bash
171
- # Install Bubblewrap CLI globally
172
- npm install -g @bubblewrap/cli
123
+ // Compile Searchable PDF Blob for upload
124
+ const pdfBlob = await engine.exportPdf(null, { searchable: true });
125
+ ```
173
126
 
174
- # Navigate to TWA directory
175
- mkdir copio-twa && cd copio-twa
127
+ ### 4. Styling & Host Theme Tokens
128
+
129
+ `<copio-scanner>` uses encapsulated Shadow DOM so host CSS resets (e.g. Tailwind preflight) never break the scanner layout. Customize colors, radii, and typography with `--copio-*` CSS custom properties:
130
+
131
+ ```css
132
+ copio-scanner {
133
+ width: 100%;
134
+ height: 640px;
135
+ --copio-bg: #0b0f17;
136
+ --copio-surface: #131b26;
137
+ --copio-primary: #38bdf8;
138
+ --copio-success: #22c55e;
139
+ --copio-text: #f8fafc;
140
+ --copio-border-radius: 12px;
141
+ }
142
+ ```
176
143
 
177
- # Generate Android project from PWA manifest
178
- bubblewrap update --skipVersionUpgrade
144
+ ---
179
145
 
180
- # Build signed APK and App Bundle
181
- BUBBLEWRAP_KEYSTORE_PASSWORD=<your-password> \
182
- BUBBLEWRAP_KEY_PASSWORD=<your-password> \
183
- bubblewrap build
184
- ```
146
+ ## Entry Points & Bundle Sizes
185
147
 
186
- The output file `app-release-signed.apk` is ready for direct Android installation.
148
+ | Import Path | Gzip Size | What It Includes |
149
+ |---|---:|---|
150
+ | `@copio/sdk/scanner` | **~54 KB** | Self-contained `<copio-scanner>` Web Component (camera, framing guides, crop, rotate, B&W filter, undo/redo). Zero external chunks. |
151
+ | `@copio/sdk/core` | **~17 KB** | Headless `CopioEngine`, domain models (`Document`, `Page`, `EditStack`), and `StoragePort` adapters (`Memory`, `IndexedDB`). Zero DOM. |
152
+ | `@copio/sdk` | **~29 KB** | Full SDK entry point — exports `<copio-scanner>`, `CopioEngine`, and pre-registers lazy-loaded `PdfKitAdapter`, `TesseractWasmAdapter`, and `SyncManager`. |
153
+ | `@copio/sdk/sync` | **~5 KB** | WebRTC peer-to-peer sync (`SyncManager`, `CopioSyncDialog`). |
187
154
 
188
155
  ---
189
156
 
190
- ## 🔒 Privacy & Security Guarantee
191
-
192
- - **Zero Remote Storage**: All documents, images, and notes are stored strictly inside your browser's local `IndexedDB`.
193
- - **No Analytics / Telemetry**: No third-party trackers or external analytics scripts.
194
- - **Direct P2P Connections**: WebRTC sync connects your devices directly end-to-end without uploading data to server storage.
157
+ ## `<copio-scanner>` API Reference
158
+
159
+ ### Attributes / Properties
160
+
161
+ | Attribute | Property | Default | Description |
162
+ |---|---|---|---|
163
+ | `mode` | `scanner.mode` | `'single'` | `'single'` (auto-advances to workbench) or `'batch'` (continuous multi-page capture). |
164
+ | `aspect` | `scanner.aspect` | `'a4'` | Framing guide aspect ratio: `'a4'`, `'receipt'`, `'card'`, or `'free'`. |
165
+ | `max-pages` | `scanner.maxPages` | `0` | Maximum allowed pages (`0` = unlimited, `1` = single receipt, `2` = front/back ID). |
166
+ | `theme` | `scanner.theme` | `'dark'` | Built-in theme preset: `'dark'`, `'light'`, or `'brand'`. |
167
+ | `stage` | `scanner.stage` | `'viewfinder'` | Active view stage: `'viewfinder'` (camera/import) or `'workbench'` (crop/filter/reorder). |
168
+ | `features` | `scanner.features` | `'crop rotate filter ocr export sync'` | Space- or comma-separated list of enabled capabilities. |
169
+ | `ocr-languages` | `scanner.ocrLanguages` | `'eng'` | Language codes passed to Tesseract WASM (`'eng'`, `'fra'`, `'deu'`, `'spa'`, etc.). |
170
+ | `asset-base` | `scanner.assetBase` | `''` | Custom base URL for self-hosting lazy worker/WASM assets. |
171
+
172
+ ### Methods
173
+
174
+ | Method | Returns | Description |
175
+ |---|---|---|
176
+ | `addFiles(files)` | `Promise<Page[]>` | Ingest `FileList`, `File[]`, or `Blob[]` (images or existing PDFs) into the active scan session. |
177
+ | `getPages()` | `Promise<Page[]>` | Return current pages with `src` (edited), `originalSrc` (untouched), `edits`, and `ocrText`. |
178
+ | `clear()` | `Promise<void>` | Clear all pages in the current session and reset the scanner. |
179
+ | `exportPdf(opts?)` | `Promise<Blob>` | Compile pages into a PDF `Blob`. Pass `{ searchable: true, download: true, docName, onProgress }`. |
180
+ | `exportZip(opts?)` | `Promise<Blob>` | Package pages into a ZIP archive `Blob`. |
181
+ | `ocr(pageId?, opts?)` | `Promise<OcrResult>` | Run client-side OCR on all pages (or a single `pageId`) and attach `ocrText` / `ocrWords`. |
182
+
183
+ ### Custom Events (`COPIO_EVENTS`)
184
+
185
+ All events bubble and cross the Shadow DOM boundary (`composed: true`) with typed payload details on `event.detail`:
186
+
187
+ | Constant | Event Name | Payload (`event.detail`) |
188
+ |---|---|---|
189
+ | `COPIO_EVENTS.SCAN_COMPLETE` | `copio:scan-complete` | `{ pages, pageCount, docId, mode, aspect }` |
190
+ | `COPIO_EVENTS.PAGE_ADDED` | `copio:page-added` | `{ page, pageNumber, docId, source }` |
191
+ | `COPIO_EVENTS.PAGE_REMOVED` | `copio:page-removed` | `{ pageId, docId }` |
192
+ | `COPIO_EVENTS.PAGES_CHANGED` | `copio:pages-changed` | `{ pages, docId }` |
193
+ | `COPIO_EVENTS.OCR_COMPLETE` | `copio:ocr-complete` | `{ text, pages, averageConfidence, docId, pageId }` |
194
+ | `COPIO_EVENTS.EXPORT_COMPLETE` | `copio:export-complete` | `{ type, format, blob, searchable, docId }` |
195
+ | `COPIO_EVENTS.ERROR` | `copio:error` | `{ code, message, error }` |
195
196
 
196
197
  ---
197
198
 
198
- ## 🤝 Contributing
199
+ ## Ecosystem
199
200
 
200
- Contributions, feature suggestions, and bug reports are warmly welcomed! Feel free to open an issue or submit a pull request on GitHub.
201
+ `@copio/sdk` powers two open-source reference applications:
202
+ - **[`copio-documents`](https://github.com/edwilliams/copio-documents)** — Standalone offline-first document & Markdown notes workspace PWA with full-database WebRTC sync.
203
+ - **[`copio-cards`](https://github.com/edwilliams/copio-cards)** — Offline loyalty & ID card wallet PWA built on `<copio-scanner aspect="card">`.
201
204
 
202
205
  ---
203
206
 
204
- ## 📄 License
207
+ ## License
205
208
 
206
- Copio (`@copio/sdk`) is dual-licensed under the **GNU Affero General Public License v3.0** and a **Commercial License**:
209
+ `@copio/sdk` is dual-licensed under **AGPL-3.0** and a **Commercial License**:
207
210
 
208
- - **Community / Open Source:** Available under the [GNU Affero General Public License v3.0 (AGPL-3.0)](LICENSE) for open-source projects and evaluation. Any work embedding or linking to `@copio/sdk` must provide full source code under the AGPL-3.0.
209
- - **Commercial License:** For proprietary applications, closed-source SaaS products, or removing the "Powered by Copio" watermark. See [LICENSE-COMMERCIAL.md](LICENSE-COMMERCIAL.md) or contact `license@copio.dev`.
210
- - **Third-Party Notices:** Vendored third-party components and their respective permissive licences (MIT, BSD-3-Clause, Apache-2.0) are documented in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
211
+ - **Community / Open Source ([AGPL-3.0](LICENSE)):** Free for open-source projects, internal evaluation, and applications licensed under AGPL-3.0.
212
+ - **Commercial License ([LICENSE-COMMERCIAL.md](LICENSE-COMMERCIAL.md)):** One-time perpetual license for proprietary web applications and closed-source SaaS products (removes AGPL copyleft obligations and the Community watermark). Contact `license@copio.dev`.
213
+ - **Third-Party Notices:** Permissive licenses for vendored libraries are listed in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
@@ -1,2 +1,2 @@
1
- import{l as a}from"../../chunk-534NMCRQ.js";import"../../chunk-ULTSZWZO.js";import"../../chunk-4C666HHU.js";export{a as Canvas2DAdapter};
1
+ import{k as a}from"../../chunk-G5EUMLYT.js";import"../../chunk-ULTSZWZO.js";import"../../chunk-4C666HHU.js";export{a as Canvas2DAdapter};
2
2
  //# sourceMappingURL=canvas2d-adapter.js.map
@@ -1,2 +1,2 @@
1
- import"../../chunk-4GEMGDRU.js";import{l as b}from"../../chunk-534NMCRQ.js";import{a as c}from"../../chunk-KH5JE65X.js";import{a}from"../../chunk-ULTSZWZO.js";import"../../chunk-4C666HHU.js";export{b as Canvas2DAdapter,a as ImageProcessorPort,c as NullImageProcessorAdapter};
1
+ import"../../chunk-4GEMGDRU.js";import{k as b}from"../../chunk-G5EUMLYT.js";import{a as c}from"../../chunk-KH5JE65X.js";import{a}from"../../chunk-ULTSZWZO.js";import"../../chunk-4C666HHU.js";export{b as Canvas2DAdapter,a as ImageProcessorPort,c as NullImageProcessorAdapter};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import"../chunk-V6E2SSSW.js";import{a as l}from"../chunk-2AB5L3Y2.js";import{a as k}from"../chunk-J7HWZNIP.js";import{a as j}from"../chunk-NEEWG3OP.js";import"../chunk-PUJYN435.js";import{a as h}from"../chunk-4ICUYKSR.js";import"../chunk-CWCS22CQ.js";import{a as i}from"../chunk-DY5ZSP4Q.js";import"../chunk-4YYY7PHH.js";import"../chunk-4GEMGDRU.js";import{l as d}from"../chunk-534NMCRQ.js";import{a as g}from"../chunk-KH5JE65X.js";import{a as c}from"../chunk-ULTSZWZO.js";import{a as f,b as m,c as p}from"../chunk-RDCHJL6F.js";import{e}from"../chunk-IH2AI54D.js";import{a as x}from"../chunk-U3V3VZGO.js";import{a as t}from"../chunk-6DSLE3AY.js";import{a as b}from"../chunk-5OTO5WFV.js";import{a}from"../chunk-O6FQFVKY.js";import"../chunk-WETG2JD7.js";import"../chunk-FAVTIE3M.js";import"../chunk-MEE2NNYB.js";import"../chunk-YNY65JUJ.js";import"../chunk-ZT72PD2C.js";import{a as r}from"../chunk-FQRADJY6.js";import{a as o}from"../chunk-DIU5BGU5.js";import"../chunk-4C666HHU.js";export{d as Canvas2DAdapter,c as ImageProcessorPort,e as IndexedDbStorageAdapter,r as MemoryStorageAdapter,g as NullImageProcessorAdapter,x as NullOcrAdapter,b as NullPdfAdapter,l as NullSyncAdapter,t as OcrPort,m as OpfsStorageAdapter,i as PdfKitAdapter,a as PdfPort,k as PeerJsAdapter,o as StoragePort,j as SyncPort,h as TesseractWasmAdapter,p as createDefaultAdapter,f as probeOpfs};
1
+ import"../chunk-V6E2SSSW.js";import{a as l}from"../chunk-2AB5L3Y2.js";import{a as k}from"../chunk-J7HWZNIP.js";import{a as j}from"../chunk-NEEWG3OP.js";import"../chunk-PUJYN435.js";import{a as h}from"../chunk-4ICUYKSR.js";import"../chunk-CWCS22CQ.js";import{b as i}from"../chunk-GGERQ3CJ.js";import"../chunk-4GEMGDRU.js";import{k as d}from"../chunk-G5EUMLYT.js";import{a as g}from"../chunk-KH5JE65X.js";import{a as c}from"../chunk-ULTSZWZO.js";import{a as f,b as m,c as p}from"../chunk-K4NR6OAC.js";import{d as e}from"../chunk-L4OVZN23.js";import{a as x}from"../chunk-U3V3VZGO.js";import{a as t}from"../chunk-6DSLE3AY.js";import{a as b}from"../chunk-5OTO5WFV.js";import{a}from"../chunk-O6FQFVKY.js";import"../chunk-WETG2JD7.js";import"../chunk-FAVTIE3M.js";import"../chunk-MEE2NNYB.js";import"../chunk-YNY65JUJ.js";import"../chunk-ZT72PD2C.js";import{a as r}from"../chunk-FQRADJY6.js";import{a as o}from"../chunk-DIU5BGU5.js";import"../chunk-4C666HHU.js";export{d as Canvas2DAdapter,c as ImageProcessorPort,e as IndexedDbStorageAdapter,r as MemoryStorageAdapter,g as NullImageProcessorAdapter,x as NullOcrAdapter,b as NullPdfAdapter,l as NullSyncAdapter,t as OcrPort,m as OpfsStorageAdapter,i as PdfKitAdapter,a as PdfPort,k as PeerJsAdapter,o as StoragePort,j as SyncPort,h as TesseractWasmAdapter,p as createDefaultAdapter,f as probeOpfs};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import{c as a,d as b,e as c}from"../chunk-IH2AI54D.js";import"../chunk-DIU5BGU5.js";import"../chunk-4C666HHU.js";export{c as IndexedDbStorageAdapter,b as blobToDataUrl,a as dataUrlToBlob};
1
+ import{b as a,c as b,d as c}from"../chunk-L4OVZN23.js";import"../chunk-DIU5BGU5.js";import"../chunk-4C666HHU.js";export{c as IndexedDbStorageAdapter,b as blobToDataUrl,a as dataUrlToBlob};
2
2
  //# sourceMappingURL=indexeddb-adapter.js.map
@@ -1,2 +1,2 @@
1
- import"../../chunk-CWCS22CQ.js";import{a as c}from"../../chunk-DY5ZSP4Q.js";import"../../chunk-4YYY7PHH.js";import{a as b}from"../../chunk-5OTO5WFV.js";import{a}from"../../chunk-O6FQFVKY.js";import"../../chunk-MEE2NNYB.js";import"../../chunk-YNY65JUJ.js";import"../../chunk-ZT72PD2C.js";import"../../chunk-4C666HHU.js";export{b as NullPdfAdapter,c as PdfKitAdapter,a as PdfPort};
1
+ import"../../chunk-CWCS22CQ.js";import{b as c}from"../../chunk-GGERQ3CJ.js";import{a as b}from"../../chunk-5OTO5WFV.js";import{a}from"../../chunk-O6FQFVKY.js";import"../../chunk-MEE2NNYB.js";import"../../chunk-YNY65JUJ.js";import"../../chunk-ZT72PD2C.js";import"../../chunk-4C666HHU.js";export{b as NullPdfAdapter,c as PdfKitAdapter,a as PdfPort};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import{a}from"../../chunk-DY5ZSP4Q.js";import"../../chunk-4YYY7PHH.js";import"../../chunk-O6FQFVKY.js";import"../../chunk-MEE2NNYB.js";import"../../chunk-YNY65JUJ.js";import"../../chunk-ZT72PD2C.js";import"../../chunk-4C666HHU.js";export{a as PdfKitAdapter};
1
+ import{b as a}from"../../chunk-GGERQ3CJ.js";import"../../chunk-O6FQFVKY.js";import"../../chunk-MEE2NNYB.js";import"../../chunk-YNY65JUJ.js";import"../../chunk-ZT72PD2C.js";import"../../chunk-4C666HHU.js";export{a as PdfKitAdapter};
2
2
  //# sourceMappingURL=pdfkit-adapter.js.map
@@ -1,2 +1,2 @@
1
- import{a as d,b as e,c as f}from"../../chunk-RDCHJL6F.js";import{e as c}from"../../chunk-IH2AI54D.js";import{a as b}from"../../chunk-FQRADJY6.js";import{a}from"../../chunk-DIU5BGU5.js";import"../../chunk-4C666HHU.js";export{c as IndexedDbStorageAdapter,b as MemoryStorageAdapter,e as OpfsStorageAdapter,a as StoragePort,f as createDefaultAdapter,d as probeOpfs};
1
+ import{a as d,b as e,c as f}from"../../chunk-K4NR6OAC.js";import{d as c}from"../../chunk-L4OVZN23.js";import{a as b}from"../../chunk-FQRADJY6.js";import{a}from"../../chunk-DIU5BGU5.js";import"../../chunk-4C666HHU.js";export{c as IndexedDbStorageAdapter,b as MemoryStorageAdapter,e as OpfsStorageAdapter,a as StoragePort,f as createDefaultAdapter,d as probeOpfs};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import{c as a,d as b,e as c}from"../../chunk-IH2AI54D.js";import"../../chunk-DIU5BGU5.js";import"../../chunk-4C666HHU.js";export{c as IndexedDbStorageAdapter,b as blobToDataUrl,a as dataUrlToBlob};
1
+ import{b as a,c as b,d as c}from"../../chunk-L4OVZN23.js";import"../../chunk-DIU5BGU5.js";import"../../chunk-4C666HHU.js";export{c as IndexedDbStorageAdapter,b as blobToDataUrl,a as dataUrlToBlob};
2
2
  //# sourceMappingURL=indexeddb-adapter.js.map