@copio/sdk 0.1.5 → 0.1.7
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/THIRD_PARTY_NOTICES.md +34 -0
- package/dist/adapters/edge/index.js +2 -0
- package/dist/adapters/edge/index.js.map +7 -0
- package/dist/adapters/edge/null-edge-detector-adapter.js +2 -0
- package/dist/adapters/edge/null-edge-detector-adapter.js.map +7 -0
- package/dist/adapters/edge/scanic-wasm-adapter.js +2 -0
- package/dist/adapters/edge/scanic-wasm-adapter.js.map +7 -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/canvas-GKLGWNAJ.js +2 -0
- package/dist/cdn.js +189 -1409
- package/dist/chunk-25WAHT3G.js +2 -0
- package/dist/chunk-2VH2NPXW.js +175 -0
- package/dist/{chunk-DIU5BGU5.js → chunk-4D6GC55I.js} +2 -2
- package/dist/chunk-6QK7337A.js +2 -0
- package/dist/chunk-GLY5CGCY.js +2 -0
- package/dist/chunk-GU6OQMYK.js +4 -0
- package/dist/chunk-HCCNUPKB.js +2 -0
- package/dist/chunk-JIPKWRBK.js +2 -0
- package/dist/{chunk-GGERQ3CJ.js → chunk-NM4YYZYB.js} +3 -3
- package/dist/chunk-NNSM2I5L.js +2 -0
- package/dist/chunk-PBF7V4Z6.js +2 -0
- package/dist/chunk-PSGIWIRH.js +2 -0
- package/dist/chunk-Q7SOUI6D.js +2 -0
- package/dist/chunk-R6Q4OXDG.js +2 -0
- package/dist/chunk-SZHKZARU.js +2 -0
- package/dist/{chunk-J7HWZNIP.js → chunk-T5CPA7B2.js} +2 -2
- package/dist/chunk-V2D55DVU.js +1 -0
- package/dist/chunk-VPSUKD6F.js +2 -0
- package/dist/chunk-WZZ7FNDX.js +2 -0
- package/dist/chunk-ZILTJGT2.js +2 -0
- package/dist/core.js +1 -1
- package/dist/custom-elements.json +2358 -177
- package/dist/export.js +1 -1
- package/dist/fs-Y7NMZRBK.js +2 -0
- package/dist/handoff-transport-7YFK4RYL.js +2 -0
- package/dist/handoff.js +2 -0
- package/dist/http-CYZIMVXQ.js +2 -0
- package/dist/https-OLG7KUSR.js +2 -0
- package/dist/index.js +11 -11
- package/dist/ocr.js +1 -1
- package/dist/path2d-HD3LU76S.js +2 -0
- package/dist/scanic-mlDetector-BCSVQYFV.js +2 -0
- package/dist/scanic-ort.wasm.min-MU4NYSP2.js +2 -0
- package/dist/scanner.js +3 -1396
- package/dist/sync.js +1 -1
- package/dist/types/js/adapters/edge/edge-detector-port.d.ts +183 -0
- package/dist/types/js/adapters/edge/index.d.ts +3 -0
- package/dist/types/js/adapters/edge/null-edge-detector-adapter.d.ts +35 -0
- package/dist/types/js/adapters/edge/scanic-wasm-adapter.d.ts +54 -0
- package/dist/types/js/adapters/storage/indexeddb-adapter.d.ts +11 -0
- package/dist/types/js/adapters/storage/memory-adapter.d.ts +11 -0
- package/dist/types/js/adapters/storage/opfs-adapter.d.ts +11 -0
- package/dist/types/js/adapters/storage/storage-port.d.ts +27 -0
- package/dist/types/js/services/doc-repository.d.ts +6 -1
- package/dist/types/js/services/handoff-crypto.d.ts +84 -0
- package/dist/types/js/services/handoff-session.d.ts +257 -0
- package/dist/types/js/services/handoff-transport.d.ts +51 -0
- package/dist/types/js/services/ice-servers.d.ts +33 -1
- package/dist/types/js/services/migration-runner.d.ts +100 -0
- package/dist/types/js/utils/perspective.d.ts +70 -0
- package/dist/types/js/utils/utils.d.ts +19 -1
- package/dist/types/sdk/core.d.ts +52 -6
- package/dist/types/sdk/elements.d.ts +2 -0
- package/dist/types/sdk/events.d.ts +42 -0
- package/dist/types/sdk/handoff-session.d.ts +4 -0
- package/dist/types/sdk/handoff-styles.d.ts +9 -0
- package/dist/types/sdk/handoff.d.ts +108 -0
- package/dist/types/sdk/index.d.ts +5 -1
- package/dist/types/sdk/models.d.ts +248 -1
- package/dist/types/sdk/scanner.d.ts +94 -1
- package/dist/types/sdk/styles.d.ts +1 -1
- package/dist/types/sdk/version.d.ts +1 -1
- package/dist/url-NYR4TEJV.js +2 -0
- package/package.json +10 -3
- package/sdk/core.js +226 -13
- package/sdk/events.js +14 -0
- package/sdk/handoff-session.js +26 -0
- package/sdk/handoff-styles.js +531 -0
- package/sdk/handoff.js +1079 -0
- package/sdk/index.js +38 -1
- package/sdk/models.js +116 -4
- package/sdk/scanner.js +1517 -151
- package/sdk/styles.js +305 -22
- package/sdk/version.js +1 -1
- package/dist/canvas-FAXPLPXN.js +0 -2
- package/dist/chunk-4C666HHU.js +0 -2
- package/dist/chunk-FQRADJY6.js +0 -2
- package/dist/chunk-G5EUMLYT.js +0 -4
- package/dist/chunk-K4NR6OAC.js +0 -2
- package/dist/chunk-L4OVZN23.js +0 -2
- package/dist/chunk-MEE2NNYB.js +0 -2
- package/dist/chunk-O7IV7A6O.js +0 -2
- package/dist/chunk-Q7XPZMZA.js +0 -1395
- package/dist/chunk-WETG2JD7.js +0 -2
- package/dist/fs-HJ6WWW73.js +0 -2
- package/dist/http-FKJJMT2N.js +0 -2
- package/dist/https-MUBFLDZM.js +0 -2
- package/dist/path2d-QWN6DFCC.js +0 -2
- package/dist/url-ABJ6S2Y6.js +0 -2
package/dist/sync.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as
|
|
1
|
+
import{c as r}from"./chunk-NQW6FFN7.js";import{a as e}from"./chunk-R6Q4OXDG.js";import{b as o}from"./chunk-SZHKZARU.js";import"./chunk-YNY65JUJ.js";import"./chunk-ZT72PD2C.js";import"./chunk-25WAHT3G.js";export{r as CopioSyncDialog,e as SyncManager,o as getIceServers};
|
|
2
2
|
//# sourceMappingURL=sync.js.map
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EdgeDetectorPort — Outbound/Driven Port for Document Edge & Corner Detection
|
|
3
|
+
* (Hexagonal Architecture / CPO-073, CPO-074).
|
|
4
|
+
*
|
|
5
|
+
* Defines the contract that all edge detection adapters (ScanicWasmEdgeAdapter,
|
|
6
|
+
* NullEdgeDetectorAdapter, or optional ML detectors) must implement.
|
|
7
|
+
*
|
|
8
|
+
* Coordinates returned by `detect()` are normalized to `[0, 1]` in clockwise
|
|
9
|
+
* traversal order (`topLeft`, `topRight`, `bottomRight`, `bottomLeft`), along
|
|
10
|
+
* with pixel `corners`, a `confidence` score in `[0, 1]`, and `isFallback`.
|
|
11
|
+
*/
|
|
12
|
+
export type EdgePoint = {
|
|
13
|
+
/**
|
|
14
|
+
* - Coordinate (normalized [0, 1] or pixel coordinate)
|
|
15
|
+
*/
|
|
16
|
+
x: number;
|
|
17
|
+
/**
|
|
18
|
+
* - Coordinate (normalized [0, 1] or pixel coordinate)
|
|
19
|
+
*/
|
|
20
|
+
y: number;
|
|
21
|
+
};
|
|
22
|
+
export type EdgeQuad = {
|
|
23
|
+
topLeft: EdgePoint;
|
|
24
|
+
topRight: EdgePoint;
|
|
25
|
+
bottomRight: EdgePoint;
|
|
26
|
+
bottomLeft: EdgePoint;
|
|
27
|
+
};
|
|
28
|
+
export type EdgeDetectOptions = {
|
|
29
|
+
/**
|
|
30
|
+
* - Maximum dimension for downscaled detection (800 for static capture, 480 for live viewfinder)
|
|
31
|
+
*/
|
|
32
|
+
maxProcessingDimension?: number;
|
|
33
|
+
/**
|
|
34
|
+
* - Whether to run the 4-pass adaptive Canny cascade
|
|
35
|
+
*/
|
|
36
|
+
enableDetectionCascade?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* - Minimum confidence threshold before falling back or returning null
|
|
39
|
+
*/
|
|
40
|
+
minConfidence?: number;
|
|
41
|
+
/**
|
|
42
|
+
* - If true, returns the 5%-inset full-frame quad with `isFallback: true` when confidence < minConfidence
|
|
43
|
+
*/
|
|
44
|
+
fallbackOnLowConfidence?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* - Optional fixed Canny low threshold
|
|
47
|
+
*/
|
|
48
|
+
lowThreshold?: number;
|
|
49
|
+
/**
|
|
50
|
+
* - Optional fixed Canny high threshold
|
|
51
|
+
*/
|
|
52
|
+
highThreshold?: number;
|
|
53
|
+
/**
|
|
54
|
+
* - Optional morphological dilation kernel size
|
|
55
|
+
*/
|
|
56
|
+
dilationKernelSize?: number;
|
|
57
|
+
/**
|
|
58
|
+
* - Whether to apply morphological dilation
|
|
59
|
+
*/
|
|
60
|
+
applyDilation?: boolean;
|
|
61
|
+
};
|
|
62
|
+
export type EdgeDetectionResult = {
|
|
63
|
+
/**
|
|
64
|
+
* - Normalized [0, 1] clockwise 4-corner coordinates `{ topLeft, topRight, bottomRight, bottomLeft }`
|
|
65
|
+
*/
|
|
66
|
+
quad: EdgeQuad;
|
|
67
|
+
/**
|
|
68
|
+
* - Alias of `quad` (normalized [0, 1] clockwise corners)
|
|
69
|
+
*/
|
|
70
|
+
normalizedCorners: EdgeQuad;
|
|
71
|
+
/**
|
|
72
|
+
* - Normalized [0, 1] clockwise 4-corner coordinates `{ topLeft, topRight, bottomRight, bottomLeft }`
|
|
73
|
+
*/
|
|
74
|
+
corners: EdgeQuad;
|
|
75
|
+
/**
|
|
76
|
+
* - Pixel coordinates in the input image's coordinate space `{ topLeft, topRight, bottomRight, bottomLeft }`
|
|
77
|
+
*/
|
|
78
|
+
pixelCorners: EdgeQuad;
|
|
79
|
+
/**
|
|
80
|
+
* - Detection confidence score in `[0, 1]`
|
|
81
|
+
*/
|
|
82
|
+
confidence: number;
|
|
83
|
+
/**
|
|
84
|
+
* - Input image width in pixels
|
|
85
|
+
*/
|
|
86
|
+
width: number;
|
|
87
|
+
/**
|
|
88
|
+
* - Input image height in pixels
|
|
89
|
+
*/
|
|
90
|
+
height: number;
|
|
91
|
+
/**
|
|
92
|
+
* - True if a fallback inset quad was returned due to low confidence
|
|
93
|
+
*/
|
|
94
|
+
isFallback: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* - Execution time in milliseconds
|
|
97
|
+
*/
|
|
98
|
+
durationMs?: number;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* @typedef {Object} EdgePoint
|
|
102
|
+
* @property {number} x - Coordinate (normalized [0, 1] or pixel coordinate)
|
|
103
|
+
* @property {number} y - Coordinate (normalized [0, 1] or pixel coordinate)
|
|
104
|
+
*/
|
|
105
|
+
/**
|
|
106
|
+
* @typedef {Object} EdgeQuad
|
|
107
|
+
* @property {EdgePoint} topLeft
|
|
108
|
+
* @property {EdgePoint} topRight
|
|
109
|
+
* @property {EdgePoint} bottomRight
|
|
110
|
+
* @property {EdgePoint} bottomLeft
|
|
111
|
+
*/
|
|
112
|
+
/**
|
|
113
|
+
* @typedef {Object} EdgeDetectOptions
|
|
114
|
+
* @property {number} [maxProcessingDimension=800] - Maximum dimension for downscaled detection (800 for static capture, 480 for live viewfinder)
|
|
115
|
+
* @property {boolean} [enableDetectionCascade=true] - Whether to run the 4-pass adaptive Canny cascade
|
|
116
|
+
* @property {number} [minConfidence=0.55] - Minimum confidence threshold before falling back or returning null
|
|
117
|
+
* @property {boolean} [fallbackOnLowConfidence=false] - If true, returns the 5%-inset full-frame quad with `isFallback: true` when confidence < minConfidence
|
|
118
|
+
* @property {number} [lowThreshold] - Optional fixed Canny low threshold
|
|
119
|
+
* @property {number} [highThreshold] - Optional fixed Canny high threshold
|
|
120
|
+
* @property {number} [dilationKernelSize] - Optional morphological dilation kernel size
|
|
121
|
+
* @property {boolean} [applyDilation] - Whether to apply morphological dilation
|
|
122
|
+
*/
|
|
123
|
+
/**
|
|
124
|
+
* @typedef {Object} EdgeDetectionResult
|
|
125
|
+
* @property {EdgeQuad} quad - Normalized [0, 1] clockwise 4-corner coordinates `{ topLeft, topRight, bottomRight, bottomLeft }`
|
|
126
|
+
* @property {EdgeQuad} normalizedCorners - Alias of `quad` (normalized [0, 1] clockwise corners)
|
|
127
|
+
* @property {EdgeQuad} corners - Normalized [0, 1] clockwise 4-corner coordinates `{ topLeft, topRight, bottomRight, bottomLeft }`
|
|
128
|
+
* @property {EdgeQuad} pixelCorners - Pixel coordinates in the input image's coordinate space `{ topLeft, topRight, bottomRight, bottomLeft }`
|
|
129
|
+
* @property {number} confidence - Detection confidence score in `[0, 1]`
|
|
130
|
+
* @property {number} width - Input image width in pixels
|
|
131
|
+
* @property {number} height - Input image height in pixels
|
|
132
|
+
* @property {boolean} isFallback - True if a fallback inset quad was returned due to low confidence
|
|
133
|
+
* @property {number} [durationMs] - Execution time in milliseconds
|
|
134
|
+
*/
|
|
135
|
+
/**
|
|
136
|
+
* Default 5%-inset full-frame normalized quadrilateral used as fallback when no
|
|
137
|
+
* high-confidence document boundary is found (per ADR 0002 / CPO-074).
|
|
138
|
+
* @type {EdgeQuad}
|
|
139
|
+
*/
|
|
140
|
+
export declare const DEFAULT_FALLBACK_QUAD: EdgeQuad;
|
|
141
|
+
/**
|
|
142
|
+
* Clone a normalized or pixel quad.
|
|
143
|
+
* @param {EdgeQuad} quad
|
|
144
|
+
* @returns {EdgeQuad}
|
|
145
|
+
*/
|
|
146
|
+
export declare function cloneQuad(quad?: EdgeQuad): EdgeQuad;
|
|
147
|
+
/**
|
|
148
|
+
* Convert a normalized quad to an axis-aligned normalized crop rectangle { x, y, w, h }.
|
|
149
|
+
* @param {EdgeQuad} [quad]
|
|
150
|
+
* @returns {{ x: number, y: number, w: number, h: number }}
|
|
151
|
+
*/
|
|
152
|
+
export declare function quadToCropRect(quad?: EdgeQuad): {
|
|
153
|
+
x: number;
|
|
154
|
+
y: number;
|
|
155
|
+
w: number;
|
|
156
|
+
h: number;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Base contract for EdgeDetectorPort implementations.
|
|
160
|
+
*/
|
|
161
|
+
export declare class EdgeDetectorPort {
|
|
162
|
+
/**
|
|
163
|
+
* Detect 4 document corners in an image or video frame.
|
|
164
|
+
* @param {ImageData|{ data: Uint8ClampedArray|Uint8Array, width: number, height: number }|HTMLCanvasElement|OffscreenCanvas|HTMLImageElement|HTMLVideoElement|ImageBitmap|Blob|string} _image
|
|
165
|
+
* @param {EdgeDetectOptions} [_options]
|
|
166
|
+
* @returns {Promise<EdgeDetectionResult|null>}
|
|
167
|
+
*/
|
|
168
|
+
detect(_image: ImageData | {
|
|
169
|
+
data: Uint8ClampedArray | Uint8Array;
|
|
170
|
+
width: number;
|
|
171
|
+
height: number;
|
|
172
|
+
} | HTMLCanvasElement | OffscreenCanvas | HTMLImageElement | HTMLVideoElement | ImageBitmap | Blob | string, _options?: EdgeDetectOptions): Promise<EdgeDetectionResult | null>;
|
|
173
|
+
/**
|
|
174
|
+
* Obtain or initialize the underlying edge detection Web Worker / WASM runtime.
|
|
175
|
+
* @returns {Promise<any>}
|
|
176
|
+
*/
|
|
177
|
+
getEdgeWorker(): Promise<any>;
|
|
178
|
+
/**
|
|
179
|
+
* Terminate the active edge detection worker and release memory.
|
|
180
|
+
* @returns {Promise<void>}
|
|
181
|
+
*/
|
|
182
|
+
terminateEdgeWorker(): Promise<void>;
|
|
183
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NullEdgeDetectorAdapter — No-Op Driven Adapter for Document Edge Detection (CPO-074).
|
|
3
|
+
*
|
|
4
|
+
* Used when automatic edge detection is disabled or opted out by the developer,
|
|
5
|
+
* or in headless environments where no detector is desired.
|
|
6
|
+
* Guarantees ZERO dynamic imports, ZERO Worker instantiation, and ZERO WASM loads.
|
|
7
|
+
*/
|
|
8
|
+
import { EdgeDetectorPort } from './edge-detector-port.js';
|
|
9
|
+
export declare class NullEdgeDetectorAdapter extends EdgeDetectorPort {
|
|
10
|
+
#private;
|
|
11
|
+
/**
|
|
12
|
+
* @param {Object} [options]
|
|
13
|
+
* @param {boolean} [options.throwOnDetect=false] - Whether detect() should throw FEATURE_DISABLED instead of returning null
|
|
14
|
+
*/
|
|
15
|
+
constructor(options?: {
|
|
16
|
+
throwOnDetect?: boolean;
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Returns null (or throws FEATURE_DISABLED when configured) without spawning any Worker or WASM.
|
|
20
|
+
* @param {any} _image
|
|
21
|
+
* @param {import('./edge-detector-port.js').EdgeDetectOptions} [_options]
|
|
22
|
+
* @returns {Promise<import('./edge-detector-port.js').EdgeDetectionResult|null>}
|
|
23
|
+
*/
|
|
24
|
+
detect(_image: any, _options?: import('./edge-detector-port.js').EdgeDetectOptions): Promise<import('./edge-detector-port.js').EdgeDetectionResult | null>;
|
|
25
|
+
/**
|
|
26
|
+
* Returns null without instantiating any WASM or Web Worker thread.
|
|
27
|
+
* @returns {Promise<null>}
|
|
28
|
+
*/
|
|
29
|
+
getEdgeWorker(): Promise<null>;
|
|
30
|
+
/**
|
|
31
|
+
* No-op termination.
|
|
32
|
+
* @returns {Promise<void>}
|
|
33
|
+
*/
|
|
34
|
+
terminateEdgeWorker(): Promise<void>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ScanicWasmEdgeAdapter — Driven Adapter for Document Edge Detection
|
|
3
|
+
* powered by Scanic v1.7.1 Classical (MIT-licensed Rust -> WebAssembly) (CPO-074).
|
|
4
|
+
*
|
|
5
|
+
* Runs Canny edge detection + morphological dilation + 4-pass adaptive cascade
|
|
6
|
+
* inside a dedicated Web Worker (with automatic in-process fallback in headless
|
|
7
|
+
* Node.js or restricted Worker environments), keeping the main thread at 60 fps
|
|
8
|
+
* and adding 0 KB to the initial `<copio-scanner>` bundle.
|
|
9
|
+
*/
|
|
10
|
+
import { EdgeDetectorPort } from './edge-detector-port.js';
|
|
11
|
+
export declare class ScanicWasmEdgeAdapter extends EdgeDetectorPort {
|
|
12
|
+
#private;
|
|
13
|
+
/**
|
|
14
|
+
* @param {import('./edge-detector-port.js').EdgeDetectOptions & { workerPath?: string, useWorker?: boolean, detector?: 'classical' | 'ml' }} [options]
|
|
15
|
+
*/
|
|
16
|
+
constructor(options?: import('./edge-detector-port.js').EdgeDetectOptions & {
|
|
17
|
+
workerPath?: string;
|
|
18
|
+
useWorker?: boolean;
|
|
19
|
+
detector?: 'classical' | 'ml';
|
|
20
|
+
});
|
|
21
|
+
get detector(): any;
|
|
22
|
+
set detector(val: any);
|
|
23
|
+
/**
|
|
24
|
+
* Warm up / preload the ML neural model (DocCornerNet) ahead of time.
|
|
25
|
+
* @param {Object} [mlOptions]
|
|
26
|
+
* @returns {Promise<void>}
|
|
27
|
+
*/
|
|
28
|
+
preloadMl(mlOptions?: any): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Obtain or lazily initialize the dedicated Scanic Web Worker (or inline fallback in Node.js).
|
|
31
|
+
* @returns {Promise<Worker|{ isInlineFallback: true, terminate: () => void }>}
|
|
32
|
+
*/
|
|
33
|
+
getEdgeWorker(): Promise<Worker | {
|
|
34
|
+
isInlineFallback: true;
|
|
35
|
+
terminate: () => void;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* Detect the 4 corners of a document in the given image or video frame.
|
|
39
|
+
*
|
|
40
|
+
* @param {ImageData|{ data: Uint8ClampedArray|Uint8Array, width: number, height: number }|HTMLCanvasElement|OffscreenCanvas|HTMLImageElement|HTMLVideoElement|ImageBitmap|Blob|string} image
|
|
41
|
+
* @param {import('./edge-detector-port.js').EdgeDetectOptions} [options]
|
|
42
|
+
* @returns {Promise<import('./edge-detector-port.js').EdgeDetectionResult|null>}
|
|
43
|
+
*/
|
|
44
|
+
detect(image: ImageData | {
|
|
45
|
+
data: Uint8ClampedArray | Uint8Array;
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
} | HTMLCanvasElement | OffscreenCanvas | HTMLImageElement | HTMLVideoElement | ImageBitmap | Blob | string, options?: import('./edge-detector-port.js').EdgeDetectOptions): Promise<import('./edge-detector-port.js').EdgeDetectionResult | null>;
|
|
49
|
+
/**
|
|
50
|
+
* Terminate the active Web Worker and release WASM memory.
|
|
51
|
+
* @returns {Promise<void>}
|
|
52
|
+
*/
|
|
53
|
+
terminateEdgeWorker(): Promise<void>;
|
|
54
|
+
}
|
|
@@ -137,6 +137,17 @@ export declare class IndexedDbStorageAdapter extends StoragePort {
|
|
|
137
137
|
* @returns {Promise<void>}
|
|
138
138
|
*/
|
|
139
139
|
deletePage(docId: string, pageId: string): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Retrieves the current schema version from TinyBase values (CPO-013).
|
|
142
|
+
* @returns {Promise<number|null>}
|
|
143
|
+
*/
|
|
144
|
+
getSchemaVersion(): Promise<number | null>;
|
|
145
|
+
/**
|
|
146
|
+
* Persists the schema version into TinyBase values and flushes to IndexedDB (CPO-013).
|
|
147
|
+
* @param {number} version
|
|
148
|
+
* @returns {Promise<void>}
|
|
149
|
+
*/
|
|
150
|
+
setSchemaVersion(version: number): Promise<void>;
|
|
140
151
|
/**
|
|
141
152
|
* Subscribes to document changes via TinyBase table listener.
|
|
142
153
|
* @param {() => void} cb
|
|
@@ -101,6 +101,17 @@ export declare class MemoryStorageAdapter extends StoragePort {
|
|
|
101
101
|
* @returns {() => void}
|
|
102
102
|
*/
|
|
103
103
|
subscribe(cb: () => void): () => void;
|
|
104
|
+
/**
|
|
105
|
+
* Retrieves the current schema version from memory.
|
|
106
|
+
* @returns {Promise<number|null>}
|
|
107
|
+
*/
|
|
108
|
+
getSchemaVersion(): Promise<number | null>;
|
|
109
|
+
/**
|
|
110
|
+
* Persists the schema version in memory.
|
|
111
|
+
* @param {number} version
|
|
112
|
+
* @returns {Promise<void>}
|
|
113
|
+
*/
|
|
114
|
+
setSchemaVersion(version: number): Promise<void>;
|
|
104
115
|
/**
|
|
105
116
|
* Clears all in-memory data (useful for test isolation).
|
|
106
117
|
*/
|
|
@@ -151,6 +151,17 @@ export declare class OpfsStorageAdapter extends StoragePort {
|
|
|
151
151
|
* @returns {Promise<void>}
|
|
152
152
|
*/
|
|
153
153
|
deletePage(docId: string, pageId: string): Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* Retrieves the current schema version from storage (CPO-013).
|
|
156
|
+
* @returns {Promise<number|null>}
|
|
157
|
+
*/
|
|
158
|
+
getSchemaVersion(): Promise<number | null>;
|
|
159
|
+
/**
|
|
160
|
+
* Persists the schema version into TinyBase values and flushes to OPFS (CPO-013).
|
|
161
|
+
* @param {number} version
|
|
162
|
+
* @returns {Promise<void>}
|
|
163
|
+
*/
|
|
164
|
+
setSchemaVersion(version: number): Promise<void>;
|
|
154
165
|
/**
|
|
155
166
|
* Subscribes to document changes via TinyBase table listener.
|
|
156
167
|
* @param {() => void} cb
|
|
@@ -53,6 +53,7 @@ export type DocRow = {
|
|
|
53
53
|
* Base interface / contract for StoragePort implementations.
|
|
54
54
|
*/
|
|
55
55
|
export declare class StoragePort {
|
|
56
|
+
_schemaVersion: number;
|
|
56
57
|
/**
|
|
57
58
|
* Initializes the storage backend, opening connections and verifying availability.
|
|
58
59
|
* @returns {Promise<StorageInitResult>}
|
|
@@ -111,6 +112,32 @@ export declare class StoragePort {
|
|
|
111
112
|
* @returns {Promise<void>}
|
|
112
113
|
*/
|
|
113
114
|
deletePage(_docId: string, _pageId: string): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Retrieves the current schema version stored in persistence (CPO-013).
|
|
117
|
+
*
|
|
118
|
+
* Migration Contract for Custom Adapters:
|
|
119
|
+
* - Must return an integer representing the current stored schema version, or `null`
|
|
120
|
+
* if unversioned (e.g. fresh installation or pre-versioned database).
|
|
121
|
+
* - Default implementation stores the version in-memory on the adapter instance (`_schemaVersion`).
|
|
122
|
+
* - Persistent custom adapters (IndexedDB, OPFS, SQLite, REST/Cloud) SHOULD override this
|
|
123
|
+
* method to read from their persistent metadata store.
|
|
124
|
+
*
|
|
125
|
+
* @returns {Promise<number|null>} Stored schema version or null if unversioned.
|
|
126
|
+
*/
|
|
127
|
+
getSchemaVersion(): Promise<number | null>;
|
|
128
|
+
/**
|
|
129
|
+
* Persists the schema version in storage (CPO-013).
|
|
130
|
+
*
|
|
131
|
+
* Migration Contract for Custom Adapters:
|
|
132
|
+
* - Called automatically by the MigrationRunner when initializing a fresh database
|
|
133
|
+
* or upon the successful, verified completion of each migration step.
|
|
134
|
+
* - Persistent custom adapters SHOULD override this method to atomically write the
|
|
135
|
+
* integer version to their persistent metadata store.
|
|
136
|
+
*
|
|
137
|
+
* @param {number} version
|
|
138
|
+
* @returns {Promise<void>}
|
|
139
|
+
*/
|
|
140
|
+
setSchemaVersion(version: number): Promise<void>;
|
|
114
141
|
/**
|
|
115
142
|
* Subscribes to storage changes (document modifications, additions, deletions).
|
|
116
143
|
* @param {() => void} _cb
|
|
@@ -65,13 +65,18 @@ export declare class DocRepository {
|
|
|
65
65
|
*/
|
|
66
66
|
get store(): any;
|
|
67
67
|
/**
|
|
68
|
-
* Initializes the repository
|
|
68
|
+
* Initializes the repository, underlying storage adapter, and runs pending migrations.
|
|
69
69
|
* @returns {Promise<{ kind: string, persistent: boolean }>}
|
|
70
70
|
*/
|
|
71
71
|
init(): Promise<{
|
|
72
72
|
kind: string;
|
|
73
73
|
persistent: boolean;
|
|
74
74
|
}>;
|
|
75
|
+
/**
|
|
76
|
+
* Retrieves the current schema version from the underlying storage adapter (CPO-013).
|
|
77
|
+
* @returns {Promise<number|null>}
|
|
78
|
+
*/
|
|
79
|
+
getSchemaVersion(): Promise<number | null>;
|
|
75
80
|
/**
|
|
76
81
|
* Lists all documents with metadata synchronously if supported by adapter.
|
|
77
82
|
* @returns {DocMetadata[]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copio Handoff Cryptographic Primitives (CPO-090 / ADR 0002)
|
|
3
|
+
*
|
|
4
|
+
* Provides WebCrypto-based:
|
|
5
|
+
* - Ephemeral ECDH key generation on NIST curve P-256 (secp256r1)
|
|
6
|
+
* - Raw SPKI/uncompressed public key export and import
|
|
7
|
+
* - Shared secret derivation and AES-GCM-256 key establishment
|
|
8
|
+
* - Authenticated payload encryption and decryption with 12-byte random IVs
|
|
9
|
+
* - Safe URL-friendly Base64 encoding/decoding for arbitrary buffers
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Encodes an ArrayBuffer or Uint8Array into a URL-safe Base64 string.
|
|
13
|
+
* @param {Uint8Array|ArrayBuffer} bytes
|
|
14
|
+
* @returns {string}
|
|
15
|
+
*/
|
|
16
|
+
export declare function bytesToBase64Url(bytes: Uint8Array | ArrayBuffer): string;
|
|
17
|
+
/**
|
|
18
|
+
* Decodes a URL-safe Base64 string into a Uint8Array.
|
|
19
|
+
* @param {string} b64url
|
|
20
|
+
* @returns {Uint8Array}
|
|
21
|
+
*/
|
|
22
|
+
export declare function base64UrlToBytes(b64url: string): Uint8Array;
|
|
23
|
+
/**
|
|
24
|
+
* Encodes a UTF-8 string into URL-safe Base64.
|
|
25
|
+
* @param {string} str
|
|
26
|
+
* @returns {string}
|
|
27
|
+
*/
|
|
28
|
+
export declare function utf8ToBase64Url(str: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Decodes a URL-safe Base64 string into a UTF-8 string.
|
|
31
|
+
* @param {string} b64url
|
|
32
|
+
* @returns {string}
|
|
33
|
+
*/
|
|
34
|
+
export declare function base64UrlToUtf8(b64url: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Generates an ephemeral ECDH keypair (P-256).
|
|
37
|
+
* @returns {Promise<CryptoKeyPair>}
|
|
38
|
+
*/
|
|
39
|
+
export declare function generateEcdhKeyPair(): Promise<CryptoKeyPair>;
|
|
40
|
+
/**
|
|
41
|
+
* Exports an ECDH public key to a raw uncompressed point encoded as Base64URL.
|
|
42
|
+
* @param {CryptoKey} publicKey
|
|
43
|
+
* @returns {Promise<string>}
|
|
44
|
+
*/
|
|
45
|
+
export declare function exportPublicKey(publicKey: CryptoKey): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Imports an ECDH public key from a Base64URL-encoded raw uncompressed point.
|
|
48
|
+
* @param {string} b64url
|
|
49
|
+
* @returns {Promise<CryptoKey>}
|
|
50
|
+
*/
|
|
51
|
+
export declare function importPublicKey(b64url: string): Promise<CryptoKey>;
|
|
52
|
+
/**
|
|
53
|
+
* Derives a 256-bit AES-GCM shared key from a local private key and foreign public key.
|
|
54
|
+
* @param {CryptoKey} privateKey - Local ECDH private key
|
|
55
|
+
* @param {CryptoKey} foreignPublicKey - Remote peer ECDH public key
|
|
56
|
+
* @returns {Promise<CryptoKey>} Derived AES-GCM CryptoKey
|
|
57
|
+
*/
|
|
58
|
+
export declare function deriveSharedKey(privateKey: CryptoKey, foreignPublicKey: CryptoKey): Promise<CryptoKey>;
|
|
59
|
+
/**
|
|
60
|
+
* Encrypts arbitrary binary data, object, or string using AES-256-GCM.
|
|
61
|
+
* @param {CryptoKey} aesKey
|
|
62
|
+
* @param {Uint8Array|ArrayBuffer|string|Object} plaintext
|
|
63
|
+
* @returns {Promise<{ iv: string, ciphertext: string }>}
|
|
64
|
+
*/
|
|
65
|
+
export declare function encryptPayload(aesKey: CryptoKey, plaintext: Uint8Array | ArrayBuffer | string | any): Promise<{
|
|
66
|
+
iv: string;
|
|
67
|
+
ciphertext: string;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* Decrypts AES-256-GCM ciphertext using the given IV and shared key.
|
|
71
|
+
* @param {CryptoKey} aesKey
|
|
72
|
+
* @param {string|Uint8Array} iv
|
|
73
|
+
* @param {string|Uint8Array} ciphertext
|
|
74
|
+
* @returns {Promise<Uint8Array>} Decrypted bytes
|
|
75
|
+
*/
|
|
76
|
+
export declare function decryptPayload(aesKey: CryptoKey, iv: string | Uint8Array, ciphertext: string | Uint8Array): Promise<Uint8Array>;
|
|
77
|
+
/**
|
|
78
|
+
* Decrypts AES-256-GCM ciphertext and parses the result as a UTF-8 string or JSON.
|
|
79
|
+
* @param {CryptoKey} aesKey
|
|
80
|
+
* @param {string|Uint8Array} iv
|
|
81
|
+
* @param {string|Uint8Array} ciphertext
|
|
82
|
+
* @returns {Promise<any>}
|
|
83
|
+
*/
|
|
84
|
+
export declare function decryptJsonPayload(aesKey: CryptoKey, iv: string | Uint8Array, ciphertext: string | Uint8Array): Promise<any>;
|