@copio/sdk 0.0.0-stage → 0.1.0
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/README.md +204 -2
- package/css/container.css +177 -0
- package/css/cropper.css +306 -0
- package/css/main.css +139 -0
- package/css/reset.css +204 -0
- package/css/shoelace.css +485 -0
- package/css/utils.css +689 -0
- package/dist/adapters/image/canvas2d-adapter.js +2 -0
- package/dist/adapters/image/canvas2d-adapter.js.map +7 -0
- package/dist/adapters/image/index.js +2 -0
- package/dist/adapters/image/index.js.map +7 -0
- package/dist/adapters/image/null-image-processor-adapter.js +2 -0
- package/dist/adapters/image/null-image-processor-adapter.js.map +7 -0
- package/dist/adapters/index.js +2 -0
- package/dist/adapters/index.js.map +7 -0
- package/dist/adapters/indexeddb-adapter.js +2 -0
- package/dist/adapters/indexeddb-adapter.js.map +7 -0
- package/dist/adapters/memory-adapter.js +2 -0
- package/dist/adapters/memory-adapter.js.map +7 -0
- package/dist/adapters/ocr/index.js +2 -0
- package/dist/adapters/ocr/index.js.map +7 -0
- package/dist/adapters/ocr/null-ocr-adapter.js +2 -0
- package/dist/adapters/ocr/null-ocr-adapter.js.map +7 -0
- package/dist/adapters/ocr/tesseract-wasm-adapter.js +2 -0
- package/dist/adapters/ocr/tesseract-wasm-adapter.js.map +7 -0
- package/dist/adapters/pdf/index.js +2 -0
- package/dist/adapters/pdf/index.js.map +7 -0
- package/dist/adapters/pdf/null-pdf-adapter.js +2 -0
- package/dist/adapters/pdf/null-pdf-adapter.js.map +7 -0
- package/dist/adapters/pdf/pdfkit-adapter.js +2 -0
- package/dist/adapters/pdf/pdfkit-adapter.js.map +7 -0
- package/dist/adapters/storage/index.js +2 -0
- package/dist/adapters/storage/index.js.map +7 -0
- package/dist/adapters/storage/indexeddb-adapter.js +2 -0
- package/dist/adapters/storage/indexeddb-adapter.js.map +7 -0
- package/dist/adapters/storage/memory-adapter.js +2 -0
- package/dist/adapters/storage/memory-adapter.js.map +7 -0
- package/dist/adapters/sync/index.js +2 -0
- package/dist/adapters/sync/index.js.map +7 -0
- package/dist/adapters/sync/null-sync-adapter.js +2 -0
- package/dist/adapters/sync/null-sync-adapter.js.map +7 -0
- package/dist/adapters/sync/peerjs-adapter.js +2 -0
- package/dist/adapters/sync/peerjs-adapter.js.map +7 -0
- package/dist/canvas-FAXPLPXN.js +2 -0
- package/dist/cdn.js +2770 -0
- package/dist/chunk-36F637QU.js +2 -0
- package/dist/chunk-4C666HHU.js +2 -0
- package/dist/chunk-4GEMGDRU.js +1 -0
- package/dist/chunk-4JPEWIT4.js +2 -0
- package/dist/chunk-6IBEH4EW.js +2601 -0
- package/dist/chunk-A5G52Q2W.js +2 -0
- package/dist/chunk-AU7NM25J.js +2 -0
- package/dist/chunk-B2EK6INF.js +2 -0
- package/dist/chunk-B5BEYYR2.js +8 -0
- package/dist/chunk-B7HT2X67.js +2 -0
- package/dist/chunk-BKZEOOH4.js +2 -0
- package/dist/chunk-CWCS22CQ.js +1 -0
- package/dist/chunk-DGGK5KEX.js +2 -0
- package/dist/chunk-E7JYVRJA.js +2 -0
- package/dist/chunk-G65H4ZTJ.js +2 -0
- package/dist/chunk-HN3336JN.js +2 -0
- package/dist/chunk-IUBYFIV6.js +12 -0
- package/dist/chunk-K6YP7EET.js +8 -0
- package/dist/chunk-KIMVF5UG.js +2 -0
- package/dist/chunk-LI54F6PA.js +2 -0
- package/dist/chunk-N4R55VRR.js +2 -0
- package/dist/chunk-N7Q34F2P.js +4 -0
- package/dist/chunk-OI4WCW7E.js +2 -0
- package/dist/chunk-PUJYN435.js +1 -0
- package/dist/chunk-PVNRK4OH.js +2 -0
- package/dist/chunk-SH4P4XSZ.js +2 -0
- package/dist/chunk-UCV3MQ6I.js +33 -0
- package/dist/chunk-V2FP4EEH.js +2 -0
- package/dist/chunk-V6E2SSSW.js +1 -0
- package/dist/chunk-XEN5VKAV.js +19 -0
- package/dist/chunk-YHLOPPXM.js +2 -0
- package/dist/core.js +2 -0
- package/dist/custom-elements.json +4779 -0
- package/dist/export.js +2 -0
- package/dist/fs-HJ6WWW73.js +2 -0
- package/dist/http-FKJJMT2N.js +2 -0
- package/dist/https-MUBFLDZM.js +2 -0
- package/dist/index.js +99 -0
- package/dist/ocr.js +2 -0
- package/dist/path2d-QWN6DFCC.js +2 -0
- package/dist/scanner.js +2631 -0
- package/dist/sync.js +2 -0
- package/dist/types/js/adapters/image/canvas2d-adapter.d.ts +42 -0
- package/dist/types/js/adapters/image/image-processor-port.d.ts +41 -0
- package/dist/types/js/adapters/image/index.d.ts +3 -0
- package/dist/types/js/adapters/image/null-image-processor-adapter.d.ts +13 -0
- package/dist/types/js/adapters/ocr/index.d.ts +3 -0
- package/dist/types/js/adapters/ocr/null-ocr-adapter.d.ts +39 -0
- package/dist/types/js/adapters/ocr/ocr-port.d.ts +139 -0
- package/dist/types/js/adapters/ocr/tesseract-wasm-adapter.d.ts +40 -0
- package/dist/types/js/adapters/pdf/index.d.ts +3 -0
- package/dist/types/js/adapters/pdf/null-pdf-adapter.d.ts +23 -0
- package/dist/types/js/adapters/pdf/pdf-port.d.ts +21 -0
- package/dist/types/js/adapters/pdf/pdfkit-adapter.d.ts +16 -0
- package/dist/types/js/adapters/storage/index.d.ts +22 -0
- package/dist/types/js/adapters/storage/indexeddb-adapter.d.ts +109 -0
- package/dist/types/js/adapters/storage/memory-adapter.d.ts +101 -0
- package/dist/types/js/adapters/storage/storage-port.d.ts +113 -0
- package/dist/types/js/adapters/sync/index.d.ts +3 -0
- package/dist/types/js/adapters/sync/null-sync-adapter.d.ts +14 -0
- package/dist/types/js/adapters/sync/peerjs-adapter.d.ts +16 -0
- package/dist/types/js/adapters/sync/sync-port.d.ts +18 -0
- package/dist/types/js/components/copio-header.d.ts +19 -0
- package/dist/types/js/components/copio-loader.d.ts +6 -0
- package/dist/types/js/core/store.d.ts +2 -0
- package/dist/types/js/routes/add-edit/copio-add-edit-dialog.d.ts +9 -0
- package/dist/types/js/routes/doc/copio-carousel.d.ts +43 -0
- package/dist/types/js/routes/doc/copio-images.d.ts +37 -0
- package/dist/types/js/routes/home/copio-row.d.ts +49 -0
- package/dist/types/js/routes/ocr/copio-doc-ocr-dialog.d.ts +97 -0
- package/dist/types/js/routes/sync/copio-sync-dialog.d.ts +13 -0
- package/dist/types/js/services/doc-repository.d.ts +233 -0
- package/dist/types/js/services/export-utils.d.ts +42 -0
- package/dist/types/js/services/ice-servers.d.ts +1 -0
- package/dist/types/js/services/notify.d.ts +82 -0
- package/dist/types/js/services/ocr-service.d.ts +64 -0
- package/dist/types/js/services/sync-service.d.ts +11 -0
- package/dist/types/js/styles/cropper-styles.d.ts +5 -0
- package/dist/types/js/utils/module-loader.d.ts +76 -0
- package/dist/types/js/utils/pdf-utils.d.ts +7 -0
- package/dist/types/js/utils/utils.d.ts +54 -0
- package/dist/types/sdk/cdn.d.ts +7 -0
- package/dist/types/sdk/core.d.ts +310 -0
- package/dist/types/sdk/elements.d.ts +25 -0
- package/dist/types/sdk/events.d.ts +227 -0
- package/dist/types/sdk/index.d.ts +37 -0
- package/dist/types/sdk/license.d.ts +12 -0
- package/dist/types/sdk/models.d.ts +174 -0
- package/dist/types/sdk/scanner.d.ts +68 -0
- package/dist/types/sdk/styles.d.ts +21 -0
- package/dist/types/sdk/sync.d.ts +7 -0
- package/dist/types/sdk/version.d.ts +2 -0
- package/dist/url-ABJ6S2Y6.js +2 -0
- package/package.json +72 -3
- package/sdk/cdn.js +13 -0
- package/sdk/core.js +961 -0
- package/sdk/events.js +99 -0
- package/sdk/index.js +137 -0
- package/sdk/license.js +28 -0
- package/sdk/models.js +177 -0
- package/sdk/scanner.js +1597 -0
- package/sdk/styles.js +1236 -0
- package/sdk/sync.js +12 -0
- package/sdk/version.js +7 -0
package/dist/sync.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as o}from"./chunk-UCV3MQ6I.js";import"./chunk-XEN5VKAV.js";import{a as r,b as e}from"./chunk-BKZEOOH4.js";import"./chunk-V2FP4EEH.js";import"./chunk-G65H4ZTJ.js";import"./chunk-4C666HHU.js";export{o as CopioSyncDialog,e as SyncManager,r as getIceServers};
|
|
2
|
+
//# sourceMappingURL=sync.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canvas2DAdapter (CPO-045 ImageProcessorPort implementation)
|
|
3
|
+
*
|
|
4
|
+
* Uses browser Canvas2D and image utilities (renderEditsToCanvas)
|
|
5
|
+
* for non-destructive rendering of crop, rotate, and Sauvola B&W filters.
|
|
6
|
+
*/
|
|
7
|
+
import { ImageProcessorPort } from './image-processor-port.js';
|
|
8
|
+
export declare class Canvas2DAdapter extends ImageProcessorPort {
|
|
9
|
+
/**
|
|
10
|
+
* Applies non-destructive edits (crop, rotate, filter) to an original image source.
|
|
11
|
+
* @param {string} originalSrc
|
|
12
|
+
* @param {Object} edits
|
|
13
|
+
* @returns {Promise<string>}
|
|
14
|
+
*/
|
|
15
|
+
renderEdits(originalSrc: string, edits?: any): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Crops an image source using normalized coordinates.
|
|
18
|
+
* @param {string} src
|
|
19
|
+
* @param {{ x: number, y: number, w: number, h: number }} crop
|
|
20
|
+
* @returns {Promise<string>}
|
|
21
|
+
*/
|
|
22
|
+
crop(src: string, crop: {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
w: number;
|
|
26
|
+
h: number;
|
|
27
|
+
}): Promise<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Rotates an image source.
|
|
30
|
+
* @param {string} src
|
|
31
|
+
* @param {number} degrees
|
|
32
|
+
* @returns {Promise<string>}
|
|
33
|
+
*/
|
|
34
|
+
rotate(src: string, degrees: number): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Applies Sauvola adaptive B&W threshold to an image source.
|
|
37
|
+
* @param {string} src
|
|
38
|
+
* @param {'bw'|'none'} filter
|
|
39
|
+
* @returns {Promise<string>}
|
|
40
|
+
*/
|
|
41
|
+
applyFilter(src: string, filter: 'bw' | 'none'): Promise<string>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ImageProcessorPort (Hexagonal Architecture Driven Outbound Port CPO-045)
|
|
3
|
+
*
|
|
4
|
+
* Defines the contract for offloading canvas transforms, crop extraction,
|
|
5
|
+
* rotation, and Sauvola adaptive threshold filter rendering.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ImageProcessorPort {
|
|
8
|
+
/**
|
|
9
|
+
* Applies non-destructive edits (crop, rotate, filter) to an original image source.
|
|
10
|
+
* @param {string} _originalSrc - Data URL or Object URL of the raw original image
|
|
11
|
+
* @param {Object} _edits - Edit stack { crop, rotate, filter }
|
|
12
|
+
* @returns {Promise<string>} Derived image data URL with edits applied
|
|
13
|
+
*/
|
|
14
|
+
renderEdits(_originalSrc: string, _edits: any): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Crops an image source.
|
|
17
|
+
* @param {string} _src
|
|
18
|
+
* @param {{ x: number, y: number, w: number, h: number }} _crop - Normalized coordinates
|
|
19
|
+
* @returns {Promise<string>}
|
|
20
|
+
*/
|
|
21
|
+
crop(_src: string, _crop: {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
w: number;
|
|
25
|
+
h: number;
|
|
26
|
+
}): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Rotates an image source by degrees.
|
|
29
|
+
* @param {string} _src
|
|
30
|
+
* @param {number} _degrees - 90, 180, 270
|
|
31
|
+
* @returns {Promise<string>}
|
|
32
|
+
*/
|
|
33
|
+
rotate(_src: string, _degrees: number): Promise<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Applies an adaptive or tonal filter to an image source.
|
|
36
|
+
* @param {string} _src
|
|
37
|
+
* @param {'bw'|'none'} _filter
|
|
38
|
+
* @returns {Promise<string>}
|
|
39
|
+
*/
|
|
40
|
+
applyFilter(_src: string, _filter: 'bw' | 'none'): Promise<string>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NullImageProcessorAdapter (CPO-045 ImageProcessorPort fallback)
|
|
3
|
+
*
|
|
4
|
+
* Safe no-op adapter for headless Node.js or environments without Canvas/DOM.
|
|
5
|
+
* Returns the original image source directly.
|
|
6
|
+
*/
|
|
7
|
+
import { ImageProcessorPort } from './image-processor-port.js';
|
|
8
|
+
export declare class NullImageProcessorAdapter extends ImageProcessorPort {
|
|
9
|
+
renderEdits(originalSrc: any, _edits: any): Promise<any>;
|
|
10
|
+
crop(src: any, _crop: any): Promise<any>;
|
|
11
|
+
rotate(src: any, _degrees: any): Promise<any>;
|
|
12
|
+
applyFilter(src: any, _filter: any): Promise<any>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NullOcrAdapter — No-Op Driven Adapter for OCR (CPO-042).
|
|
3
|
+
*
|
|
4
|
+
* Used when OCR feature is disabled or opted out by developer.
|
|
5
|
+
* Guarantees ZERO dynamic imports, ZERO Tesseract downloads, and ZERO WASM network requests.
|
|
6
|
+
*/
|
|
7
|
+
import { OcrPort } from './ocr-port.js';
|
|
8
|
+
export declare class NullOcrAdapter extends OcrPort {
|
|
9
|
+
/**
|
|
10
|
+
* Throws FEATURE_DISABLED error to prevent network requests.
|
|
11
|
+
* @param {string|Blob|File|HTMLImageElement|HTMLCanvasElement} _image
|
|
12
|
+
* @param {Object} [_options]
|
|
13
|
+
* @returns {Promise<any>}
|
|
14
|
+
*/
|
|
15
|
+
recognizeImageText(_image: string | Blob | File | HTMLImageElement | HTMLCanvasElement, _options?: any): Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* Throws FEATURE_DISABLED error to prevent network requests.
|
|
18
|
+
* @param {Array<{ id: string, src?: string, type?: string, content?: string, name?: string }>} _pages
|
|
19
|
+
* @param {Object} [_options]
|
|
20
|
+
* @returns {Promise<any>}
|
|
21
|
+
*/
|
|
22
|
+
recognizeDocumentPages(_pages: Array<{
|
|
23
|
+
id: string;
|
|
24
|
+
src?: string;
|
|
25
|
+
type?: string;
|
|
26
|
+
content?: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
}>, _options?: any): Promise<any>;
|
|
29
|
+
/**
|
|
30
|
+
* Null worker without instantiating any WASM or worker thread.
|
|
31
|
+
* @returns {Promise<null>}
|
|
32
|
+
*/
|
|
33
|
+
getOcrWorker(): Promise<null>;
|
|
34
|
+
/**
|
|
35
|
+
* No-op termination.
|
|
36
|
+
* @returns {Promise<void>}
|
|
37
|
+
*/
|
|
38
|
+
terminateOcrWorker(): Promise<void>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OcrPort — Outbound/Driven Port for Optical Character Recognition (Hexagonal Architecture / CPO-042, CPO-045).
|
|
3
|
+
*
|
|
4
|
+
* Defines the contract that all OCR adapters (Tesseract WASM, Null, Cloud) must implement.
|
|
5
|
+
*/
|
|
6
|
+
export type OcrProgress = {
|
|
7
|
+
/**
|
|
8
|
+
* - Progress status identifier
|
|
9
|
+
*/
|
|
10
|
+
status: string;
|
|
11
|
+
/**
|
|
12
|
+
* - Progress value (0 to 1)
|
|
13
|
+
*/
|
|
14
|
+
progress: number;
|
|
15
|
+
/**
|
|
16
|
+
* - Human-readable status message
|
|
17
|
+
*/
|
|
18
|
+
message: string;
|
|
19
|
+
/**
|
|
20
|
+
* - Raw worker message
|
|
21
|
+
*/
|
|
22
|
+
raw?: any;
|
|
23
|
+
};
|
|
24
|
+
export type OcrPageResult = {
|
|
25
|
+
/**
|
|
26
|
+
* - Page identifier
|
|
27
|
+
*/
|
|
28
|
+
id: string;
|
|
29
|
+
/**
|
|
30
|
+
* - Extracted text content
|
|
31
|
+
*/
|
|
32
|
+
text: string;
|
|
33
|
+
/**
|
|
34
|
+
* - OCR confidence score (0 to 100)
|
|
35
|
+
*/
|
|
36
|
+
confidence: number;
|
|
37
|
+
/**
|
|
38
|
+
* - Extracted words
|
|
39
|
+
*/
|
|
40
|
+
words?: Array<any>;
|
|
41
|
+
/**
|
|
42
|
+
* - Extracted lines
|
|
43
|
+
*/
|
|
44
|
+
lines?: Array<any>;
|
|
45
|
+
/**
|
|
46
|
+
* - Extracted paragraphs
|
|
47
|
+
*/
|
|
48
|
+
paragraphs?: Array<any>;
|
|
49
|
+
/**
|
|
50
|
+
* - hOCR markup
|
|
51
|
+
*/
|
|
52
|
+
hocr?: string;
|
|
53
|
+
};
|
|
54
|
+
export type OcrBatchResult = {
|
|
55
|
+
/**
|
|
56
|
+
* - Per-page extraction results
|
|
57
|
+
*/
|
|
58
|
+
pagesResults: OcrPageResult[];
|
|
59
|
+
/**
|
|
60
|
+
* - Aggregated document text
|
|
61
|
+
*/
|
|
62
|
+
combinedText: string;
|
|
63
|
+
/**
|
|
64
|
+
* - Average confidence percentage
|
|
65
|
+
*/
|
|
66
|
+
averageConfidence: number;
|
|
67
|
+
/**
|
|
68
|
+
* - True if no images were processed
|
|
69
|
+
*/
|
|
70
|
+
empty?: boolean;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* @typedef {Object} OcrProgress
|
|
74
|
+
* @property {string} status - Progress status identifier
|
|
75
|
+
* @property {number} progress - Progress value (0 to 1)
|
|
76
|
+
* @property {string} message - Human-readable status message
|
|
77
|
+
* @property {any} [raw] - Raw worker message
|
|
78
|
+
*/
|
|
79
|
+
/**
|
|
80
|
+
* @typedef {Object} OcrPageResult
|
|
81
|
+
* @property {string} id - Page identifier
|
|
82
|
+
* @property {string} text - Extracted text content
|
|
83
|
+
* @property {number} confidence - OCR confidence score (0 to 100)
|
|
84
|
+
* @property {Array<any>} [words] - Extracted words
|
|
85
|
+
* @property {Array<any>} [lines] - Extracted lines
|
|
86
|
+
* @property {Array<any>} [paragraphs] - Extracted paragraphs
|
|
87
|
+
* @property {string} [hocr] - hOCR markup
|
|
88
|
+
*/
|
|
89
|
+
/**
|
|
90
|
+
* @typedef {Object} OcrBatchResult
|
|
91
|
+
* @property {OcrPageResult[]} pagesResults - Per-page extraction results
|
|
92
|
+
* @property {string} combinedText - Aggregated document text
|
|
93
|
+
* @property {number} averageConfidence - Average confidence percentage
|
|
94
|
+
* @property {boolean} [empty] - True if no images were processed
|
|
95
|
+
*/
|
|
96
|
+
/**
|
|
97
|
+
* Base contract for OCR Port implementations.
|
|
98
|
+
*/
|
|
99
|
+
export declare class OcrPort {
|
|
100
|
+
/**
|
|
101
|
+
* Recognize text from a single image.
|
|
102
|
+
* @param {string|Blob|File|HTMLImageElement|HTMLCanvasElement} _image
|
|
103
|
+
* @param {Object} [_options]
|
|
104
|
+
* @returns {Promise<{ text: string, confidence: number, words?: any[], lines?: any[], paragraphs?: any[], hocr?: string }>}
|
|
105
|
+
*/
|
|
106
|
+
recognizeImageText(_image: string | Blob | File | HTMLImageElement | HTMLCanvasElement, _options?: any): Promise<{
|
|
107
|
+
text: string;
|
|
108
|
+
confidence: number;
|
|
109
|
+
words?: any[];
|
|
110
|
+
lines?: any[];
|
|
111
|
+
paragraphs?: any[];
|
|
112
|
+
hocr?: string;
|
|
113
|
+
}>;
|
|
114
|
+
/**
|
|
115
|
+
* Batch recognize text across multiple document pages.
|
|
116
|
+
* @param {Array<{ id: string, src?: string, type?: string, content?: string, name?: string }>} _pages
|
|
117
|
+
* @param {Object} [_options]
|
|
118
|
+
* @returns {Promise<OcrBatchResult>}
|
|
119
|
+
*/
|
|
120
|
+
recognizeDocumentPages(_pages: Array<{
|
|
121
|
+
id: string;
|
|
122
|
+
src?: string;
|
|
123
|
+
type?: string;
|
|
124
|
+
content?: string;
|
|
125
|
+
name?: string;
|
|
126
|
+
}>, _options?: any): Promise<OcrBatchResult>;
|
|
127
|
+
/**
|
|
128
|
+
* Obtain or initialize an active OCR worker instance.
|
|
129
|
+
* @param {string} [_lang='eng']
|
|
130
|
+
* @param {Function} [_onProgress]
|
|
131
|
+
* @returns {Promise<any>}
|
|
132
|
+
*/
|
|
133
|
+
getOcrWorker(_lang?: string, _onProgress?: Function): Promise<any>;
|
|
134
|
+
/**
|
|
135
|
+
* Terminate active OCR worker and release resources.
|
|
136
|
+
* @returns {Promise<void>}
|
|
137
|
+
*/
|
|
138
|
+
terminateOcrWorker(): Promise<void>;
|
|
139
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TesseractWasmAdapter — Default Driven Adapter for OCR via Tesseract.js WASM (CPO-042, CPO-045).
|
|
3
|
+
*/
|
|
4
|
+
import { OcrPort } from './ocr-port.js';
|
|
5
|
+
export declare class TesseractWasmAdapter extends OcrPort {
|
|
6
|
+
/**
|
|
7
|
+
* @param {string|Blob|File|HTMLImageElement|HTMLCanvasElement} image
|
|
8
|
+
* @param {Object} [options]
|
|
9
|
+
*/
|
|
10
|
+
recognizeImageText(image: string | Blob | File | HTMLImageElement | HTMLCanvasElement, options?: any): Promise<{
|
|
11
|
+
text: string;
|
|
12
|
+
confidence: number;
|
|
13
|
+
words: Array<any>;
|
|
14
|
+
lines: Array<any>;
|
|
15
|
+
paragraphs: Array<any>;
|
|
16
|
+
hocr?: string;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* @param {Array<{ id: string, src?: string, type?: string, content?: string, name?: string }>} pages
|
|
20
|
+
* @param {Object} [options]
|
|
21
|
+
*/
|
|
22
|
+
recognizeDocumentPages(pages: Array<{
|
|
23
|
+
id: string;
|
|
24
|
+
src?: string;
|
|
25
|
+
type?: string;
|
|
26
|
+
content?: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
}>, options?: any): Promise<{
|
|
29
|
+
pagesResults: any[];
|
|
30
|
+
combinedText: string;
|
|
31
|
+
averageConfidence: number;
|
|
32
|
+
empty?: boolean;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* @param {string} [lang='eng']
|
|
36
|
+
* @param {Function} [onProgress]
|
|
37
|
+
*/
|
|
38
|
+
getOcrWorker(lang?: string, onProgress?: Function): Promise<any>;
|
|
39
|
+
terminateOcrWorker(): Promise<void>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NullPdfAdapter — No-Op Driven Adapter for PDF (CPO-042).
|
|
3
|
+
*
|
|
4
|
+
* Used when PDF export/import is disabled or opted out by developer.
|
|
5
|
+
* Guarantees ZERO dynamic imports, ZERO PDFKit downloads, and ZERO network requests.
|
|
6
|
+
*/
|
|
7
|
+
import { PdfPort } from './pdf-port.js';
|
|
8
|
+
export declare class NullPdfAdapter extends PdfPort {
|
|
9
|
+
/**
|
|
10
|
+
* Throws FEATURE_DISABLED error to prevent network requests.
|
|
11
|
+
* @param {string} _docName
|
|
12
|
+
* @param {Array<any>} _pages
|
|
13
|
+
* @param {Object} [_options]
|
|
14
|
+
* @returns {Promise<any>}
|
|
15
|
+
*/
|
|
16
|
+
exportDocumentAsPdf(_docName: string, _pages: Array<any>, _options?: any): Promise<any>;
|
|
17
|
+
/**
|
|
18
|
+
* Returns empty array without importing pdf-utils or making network calls.
|
|
19
|
+
* @param {File|Blob|ArrayBuffer} _fileOrBuffer
|
|
20
|
+
* @returns {Promise<string[]>}
|
|
21
|
+
*/
|
|
22
|
+
renderPdfPagesToDataUrls(_fileOrBuffer: File | Blob | ArrayBuffer): Promise<string[]>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PdfPort — Outbound/Driven Port for PDF Export & Import (Hexagonal Architecture / CPO-042, CPO-045).
|
|
3
|
+
*
|
|
4
|
+
* Defines the contract that all PDF adapters (PDFKit, Null, Native/Browser) must implement.
|
|
5
|
+
*/
|
|
6
|
+
export declare class PdfPort {
|
|
7
|
+
/**
|
|
8
|
+
* Export document pages as a PDF Blob.
|
|
9
|
+
* @param {string} _docName
|
|
10
|
+
* @param {Array<any>} _pages
|
|
11
|
+
* @param {Object} [_options]
|
|
12
|
+
* @returns {Promise<Blob|undefined>}
|
|
13
|
+
*/
|
|
14
|
+
exportDocumentAsPdf(_docName: string, _pages: Array<any>, _options?: any): Promise<Blob | undefined>;
|
|
15
|
+
/**
|
|
16
|
+
* Render pages of a PDF File or ArrayBuffer to image data URLs.
|
|
17
|
+
* @param {File|Blob|ArrayBuffer} _fileOrBuffer
|
|
18
|
+
* @returns {Promise<string[]>}
|
|
19
|
+
*/
|
|
20
|
+
renderPdfPagesToDataUrls(_fileOrBuffer: File | Blob | ArrayBuffer): Promise<string[]>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PdfKitAdapter — Default Driven Adapter for PDF assembly via PDFKit (CPO-042, CPO-045).
|
|
3
|
+
*/
|
|
4
|
+
import { PdfPort } from './pdf-port.js';
|
|
5
|
+
export declare class PdfKitAdapter extends PdfPort {
|
|
6
|
+
/**
|
|
7
|
+
* @param {string} docName
|
|
8
|
+
* @param {Array<any>} pages
|
|
9
|
+
* @param {Object} [options]
|
|
10
|
+
*/
|
|
11
|
+
exportDocumentAsPdf(docName: string, pages: Array<any>, options?: any): Promise<Blob>;
|
|
12
|
+
/**
|
|
13
|
+
* @param {File|Blob|ArrayBuffer} fileOrBuffer
|
|
14
|
+
*/
|
|
15
|
+
renderPdfPagesToDataUrls(fileOrBuffer: File | Blob | ArrayBuffer): Promise<string[]>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { StoragePort } from './storage-port.js';
|
|
2
|
+
import { MemoryStorageAdapter } from './memory-adapter.js';
|
|
3
|
+
import { IndexedDbStorageAdapter } from './indexeddb-adapter.js';
|
|
4
|
+
export { StoragePort, MemoryStorageAdapter, IndexedDbStorageAdapter };
|
|
5
|
+
/**
|
|
6
|
+
* Creates the appropriate default storage adapter for the runtime environment.
|
|
7
|
+
* Selects IndexedDB in browsers, falling back to MemoryStorageAdapter in
|
|
8
|
+
* Node.js / SSR or when forceMemory is explicitly specified.
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} [options]
|
|
11
|
+
* @param {boolean} [options.forceMemory] - Force use of MemoryStorageAdapter
|
|
12
|
+
* @param {string} [options.dbName] - Database name for IndexedDB
|
|
13
|
+
* @param {any} [options.store] - Optional TinyBase store instance
|
|
14
|
+
* @param {any} [options.persister] - Optional TinyBase persister instance
|
|
15
|
+
* @returns {StoragePort}
|
|
16
|
+
*/
|
|
17
|
+
export declare function createDefaultAdapter(options?: {
|
|
18
|
+
forceMemory?: boolean;
|
|
19
|
+
dbName?: string;
|
|
20
|
+
store?: any;
|
|
21
|
+
persister?: any;
|
|
22
|
+
}): StoragePort;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { StoragePort } from './storage-port.js';
|
|
2
|
+
/**
|
|
3
|
+
* IndexedDbStorageAdapter — TinyBase IndexedDB implementation of StoragePort (CPO-033).
|
|
4
|
+
*
|
|
5
|
+
* Wraps TinyBase and IndexedDbPersister behind the StoragePort contract, ensuring
|
|
6
|
+
* existing database data ('copio-db') is preserved while isolating storage mechanics.
|
|
7
|
+
*/
|
|
8
|
+
export declare class IndexedDbStorageAdapter extends StoragePort {
|
|
9
|
+
#private;
|
|
10
|
+
/**
|
|
11
|
+
* @param {Object} [options]
|
|
12
|
+
* @param {any} [options.store] - Optional TinyBase store instance
|
|
13
|
+
* @param {any} [options.persister] - Optional TinyBase persister instance
|
|
14
|
+
* @param {string} [options.dbName] - Custom IndexedDB database name
|
|
15
|
+
*/
|
|
16
|
+
constructor(options?: {
|
|
17
|
+
store?: any;
|
|
18
|
+
persister?: any;
|
|
19
|
+
dbName?: string;
|
|
20
|
+
});
|
|
21
|
+
get store(): any;
|
|
22
|
+
get persister(): any;
|
|
23
|
+
/**
|
|
24
|
+
* @returns {Promise<{ kind: string, persistent: boolean }>}
|
|
25
|
+
*/
|
|
26
|
+
init(): Promise<{
|
|
27
|
+
kind: string;
|
|
28
|
+
persistent: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Returns list of all stored documents synchronously from the TinyBase cache.
|
|
32
|
+
* @returns {Array<{ id: string, name: string, pages: any[] }>}
|
|
33
|
+
*/
|
|
34
|
+
listDocsSync(): Array<{
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
pages: any[];
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Returns list of all stored documents.
|
|
41
|
+
* @returns {Promise<Array<{ id: string, name: string, pages: any[] }>>}
|
|
42
|
+
*/
|
|
43
|
+
listDocs(): Promise<Array<{
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
pages: any[];
|
|
47
|
+
}>>;
|
|
48
|
+
/**
|
|
49
|
+
* Retrieves a document by its ID synchronously from the TinyBase cache.
|
|
50
|
+
* @param {string} id
|
|
51
|
+
* @returns {{ id: string, name: string, pages: any[] } | null}
|
|
52
|
+
*/
|
|
53
|
+
getDocSync(id: string): {
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
pages: any[];
|
|
57
|
+
} | null;
|
|
58
|
+
/**
|
|
59
|
+
* Retrieves a document by its ID.
|
|
60
|
+
* @param {string} id
|
|
61
|
+
* @returns {Promise<{ id: string, name: string, pages: any[] } | null>}
|
|
62
|
+
*/
|
|
63
|
+
getDoc(id: string): Promise<{
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
pages: any[];
|
|
67
|
+
} | null>;
|
|
68
|
+
/**
|
|
69
|
+
* Saves or updates a document.
|
|
70
|
+
* @param {string} id
|
|
71
|
+
* @param {import('./storage-port.js').DocRow} doc
|
|
72
|
+
* @returns {Promise<void>}
|
|
73
|
+
*/
|
|
74
|
+
saveDoc(id: string, doc: import('./storage-port.js').DocRow): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Deletes a document.
|
|
77
|
+
* @param {string} id
|
|
78
|
+
* @returns {Promise<void>}
|
|
79
|
+
*/
|
|
80
|
+
deleteDoc(id: string): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Saves page data for a document.
|
|
83
|
+
* @param {string} docId
|
|
84
|
+
* @param {string} pageId
|
|
85
|
+
* @param {any} blobOrData
|
|
86
|
+
* @returns {Promise<void>}
|
|
87
|
+
*/
|
|
88
|
+
savePage(docId: string, pageId: string, blobOrData: any): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Retrieves page data.
|
|
91
|
+
* @param {string} docId
|
|
92
|
+
* @param {string} pageId
|
|
93
|
+
* @returns {Promise<any>}
|
|
94
|
+
*/
|
|
95
|
+
getPage(docId: string, pageId: string): Promise<any>;
|
|
96
|
+
/**
|
|
97
|
+
* Deletes page data.
|
|
98
|
+
* @param {string} docId
|
|
99
|
+
* @param {string} pageId
|
|
100
|
+
* @returns {Promise<void>}
|
|
101
|
+
*/
|
|
102
|
+
deletePage(docId: string, pageId: string): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Subscribes to document changes via TinyBase table listener.
|
|
105
|
+
* @param {() => void} cb
|
|
106
|
+
* @returns {() => void} Unsubscribe function
|
|
107
|
+
*/
|
|
108
|
+
subscribe(cb: () => void): () => void;
|
|
109
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { StoragePort } from './storage-port.js';
|
|
2
|
+
/**
|
|
3
|
+
* MemoryStorageAdapter — In-memory implementation of StoragePort (CPO-033).
|
|
4
|
+
*
|
|
5
|
+
* Useful for headless testing, Node.js environments, temporary scans,
|
|
6
|
+
* and ephemeral SDK use-cases without browser storage.
|
|
7
|
+
*/
|
|
8
|
+
export declare class MemoryStorageAdapter extends StoragePort {
|
|
9
|
+
#private;
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* @returns {Promise<{ kind: string, persistent: boolean }>}
|
|
13
|
+
*/
|
|
14
|
+
init(): Promise<{
|
|
15
|
+
kind: string;
|
|
16
|
+
persistent: boolean;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Returns list of all stored documents synchronously.
|
|
20
|
+
* @returns {Array<{ id: string, name: string, pages: any[] }>}
|
|
21
|
+
*/
|
|
22
|
+
listDocsSync(): Array<{
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
pages: any[];
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Returns list of all stored documents.
|
|
29
|
+
* @returns {Promise<Array<{ id: string, name: string, pages: any[] }>>}
|
|
30
|
+
*/
|
|
31
|
+
listDocs(): Promise<Array<{
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
pages: any[];
|
|
35
|
+
}>>;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves a document by its ID synchronously.
|
|
38
|
+
* @param {string} id
|
|
39
|
+
* @returns {{ id: string, name: string, pages: any[] } | null}
|
|
40
|
+
*/
|
|
41
|
+
getDocSync(id: string): {
|
|
42
|
+
id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
pages: any[];
|
|
45
|
+
} | null;
|
|
46
|
+
/**
|
|
47
|
+
* Retrieves a document by its ID.
|
|
48
|
+
* @param {string} id
|
|
49
|
+
* @returns {Promise<{ id: string, name: string, pages: any[] } | null>}
|
|
50
|
+
*/
|
|
51
|
+
getDoc(id: string): Promise<{
|
|
52
|
+
id: string;
|
|
53
|
+
name: string;
|
|
54
|
+
pages: any[];
|
|
55
|
+
} | null>;
|
|
56
|
+
/**
|
|
57
|
+
* Saves or updates a document.
|
|
58
|
+
* @param {string} id
|
|
59
|
+
* @param {import('./storage-port.js').DocRow} doc
|
|
60
|
+
* @returns {Promise<void>}
|
|
61
|
+
*/
|
|
62
|
+
saveDoc(id: string, doc: import('./storage-port.js').DocRow): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Deletes a document and its pages.
|
|
65
|
+
* @param {string} id
|
|
66
|
+
* @returns {Promise<void>}
|
|
67
|
+
*/
|
|
68
|
+
deleteDoc(id: string): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Saves page data for a document.
|
|
71
|
+
* @param {string} docId
|
|
72
|
+
* @param {string} pageId
|
|
73
|
+
* @param {any} blobOrData
|
|
74
|
+
* @returns {Promise<void>}
|
|
75
|
+
*/
|
|
76
|
+
savePage(docId: string, pageId: string, blobOrData: any): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Retrieves page data.
|
|
79
|
+
* @param {string} docId
|
|
80
|
+
* @param {string} pageId
|
|
81
|
+
* @returns {Promise<any>}
|
|
82
|
+
*/
|
|
83
|
+
getPage(docId: string, pageId: string): Promise<any>;
|
|
84
|
+
/**
|
|
85
|
+
* Deletes page data.
|
|
86
|
+
* @param {string} docId
|
|
87
|
+
* @param {string} pageId
|
|
88
|
+
* @returns {Promise<void>}
|
|
89
|
+
*/
|
|
90
|
+
deletePage(docId: string, pageId: string): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Subscribes to document changes.
|
|
93
|
+
* @param {() => void} cb
|
|
94
|
+
* @returns {() => void}
|
|
95
|
+
*/
|
|
96
|
+
subscribe(cb: () => void): () => void;
|
|
97
|
+
/**
|
|
98
|
+
* Clears all in-memory data (useful for test isolation).
|
|
99
|
+
*/
|
|
100
|
+
clear(): void;
|
|
101
|
+
}
|