@copio/sdk 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/LICENSE +661 -0
  2. package/LICENSE-COMMERCIAL.md +43 -0
  3. package/README.md +6 -1
  4. package/THIRD_PARTY_NOTICES.md +416 -0
  5. package/dist/adapters/image/canvas2d-adapter.js +1 -1
  6. package/dist/adapters/image/index.js +1 -1
  7. package/dist/adapters/image/null-image-processor-adapter.js +1 -1
  8. package/dist/adapters/index.js +1 -1
  9. package/dist/adapters/indexeddb-adapter.js +1 -1
  10. package/dist/adapters/memory-adapter.js +1 -1
  11. package/dist/adapters/ocr/index.js +1 -1
  12. package/dist/adapters/ocr/null-ocr-adapter.js +1 -1
  13. package/dist/adapters/ocr/tesseract-wasm-adapter.js +1 -1
  14. package/dist/adapters/pdf/index.js +1 -1
  15. package/dist/adapters/pdf/null-pdf-adapter.js +1 -1
  16. package/dist/adapters/pdf/pdfkit-adapter.js +1 -1
  17. package/dist/adapters/storage/index.js +1 -1
  18. package/dist/adapters/storage/indexeddb-adapter.js +1 -1
  19. package/dist/adapters/storage/memory-adapter.js +1 -1
  20. package/dist/adapters/sync/index.js +1 -1
  21. package/dist/adapters/sync/null-sync-adapter.js +1 -1
  22. package/dist/adapters/sync/peerjs-adapter.js +1 -1
  23. package/dist/cdn.js +106 -249
  24. package/dist/{chunk-A5G52Q2W.js → chunk-2AB5L3Y2.js} +2 -2
  25. package/dist/{chunk-DGGK5KEX.js → chunk-4ICUYKSR.js} +2 -2
  26. package/dist/{chunk-IZOWC74B.js → chunk-4XWSVHFW.js} +69 -198
  27. package/dist/{chunk-IUBYFIV6.js → chunk-4YYY7PHH.js} +2 -2
  28. package/dist/{chunk-N7Q34F2P.js → chunk-534NMCRQ.js} +4 -4
  29. package/dist/{chunk-UCV3MQ6I.js → chunk-5KUKBKWL.js} +1 -1
  30. package/dist/{chunk-E7JYVRJA.js → chunk-5OTO5WFV.js} +2 -2
  31. package/dist/{chunk-N4R55VRR.js → chunk-6DSLE3AY.js} +1 -1
  32. package/dist/chunk-DIU5BGU5.js +2 -0
  33. package/dist/chunk-DOKG4LX2.js +2 -0
  34. package/dist/{chunk-B2EK6INF.js → chunk-DY5ZSP4Q.js} +2 -2
  35. package/dist/chunk-FAVTIE3M.js +8 -0
  36. package/dist/chunk-FQRADJY6.js +2 -0
  37. package/dist/chunk-IH2AI54D.js +2 -0
  38. package/dist/{chunk-PVNRK4OH.js → chunk-J7HWZNIP.js} +2 -2
  39. package/dist/{chunk-SH4P4XSZ.js → chunk-KH5JE65X.js} +2 -2
  40. package/dist/chunk-MEE2NNYB.js +2 -0
  41. package/dist/{chunk-KIMVF5UG.js → chunk-NEEWG3OP.js} +1 -1
  42. package/dist/{chunk-YHLOPPXM.js → chunk-O6FQFVKY.js} +1 -1
  43. package/dist/chunk-RDCHJL6F.js +2 -0
  44. package/dist/{chunk-B7HT2X67.js → chunk-U3V3VZGO.js} +2 -2
  45. package/dist/{chunk-HN3336JN.js → chunk-ULTSZWZO.js} +1 -1
  46. package/dist/{chunk-BKZEOOH4.js → chunk-WETG2JD7.js} +2 -2
  47. package/dist/{chunk-V2FP4EEH.js → chunk-YNY65JUJ.js} +1 -1
  48. package/dist/chunk-ZT72PD2C.js +2 -0
  49. package/dist/core.js +1 -1
  50. package/dist/custom-elements.json +264 -102
  51. package/dist/export.js +1 -1
  52. package/dist/index.js +11 -19
  53. package/dist/ocr.js +1 -1
  54. package/dist/scanner.js +88 -217
  55. package/dist/sync.js +1 -1
  56. package/dist/types/js/adapters/storage/blob-store.d.ts +48 -0
  57. package/dist/types/js/adapters/storage/index.d.ts +11 -4
  58. package/dist/types/js/adapters/storage/indexeddb-adapter.d.ts +46 -9
  59. package/dist/types/js/adapters/storage/memory-adapter.d.ts +7 -0
  60. package/dist/types/js/adapters/storage/opfs-adapter.d.ts +160 -0
  61. package/dist/types/js/adapters/storage/storage-port.d.ts +7 -0
  62. package/dist/types/js/components/copio-header.d.ts +4 -0
  63. package/dist/types/js/routes/doc/copio-carousel.d.ts +1 -2
  64. package/dist/types/js/routes/doc/copio-images.d.ts +0 -4
  65. package/dist/types/js/routes/home/copio-row.d.ts +2 -2
  66. package/dist/types/js/routes/ocr/copio-doc-ocr-dialog.d.ts +0 -2
  67. package/dist/types/js/services/doc-repository.d.ts +1 -0
  68. package/dist/types/js/services/export-utils.d.ts +8 -12
  69. package/dist/types/js/services/ocr-service.d.ts +2 -1
  70. package/dist/types/js/utils/module-loader.d.ts +0 -6
  71. package/dist/types/js/utils/utils.d.ts +5 -3
  72. package/dist/types/sdk/core.d.ts +13 -2
  73. package/dist/types/sdk/events.d.ts +4 -4
  74. package/dist/types/sdk/index.d.ts +3 -3
  75. package/dist/types/sdk/models.d.ts +66 -0
  76. package/dist/types/sdk/styles.d.ts +1 -1
  77. package/dist/types/sdk/version.d.ts +1 -1
  78. package/package.json +4 -3
  79. package/sdk/cdn.js +1 -0
  80. package/sdk/core.js +60 -0
  81. package/sdk/events.js +3 -2
  82. package/sdk/index.js +4 -3
  83. package/sdk/license.js +1 -0
  84. package/sdk/models.js +79 -3
  85. package/sdk/scanner.js +45 -7
  86. package/sdk/styles.js +12 -5
  87. package/sdk/sync.js +1 -0
  88. package/sdk/version.js +2 -1
  89. package/dist/chunk-36F637QU.js +0 -2
  90. package/dist/chunk-4JPEWIT4.js +0 -2
  91. package/dist/chunk-B5BEYYR2.js +0 -8
  92. package/dist/chunk-G65H4ZTJ.js +0 -2
  93. package/dist/chunk-HS6GDZIS.js +0 -2
  94. package/dist/chunk-K6YP7EET.js +0 -8
  95. package/dist/chunk-LI54F6PA.js +0 -2
  96. package/dist/chunk-OI4WCW7E.js +0 -2
package/dist/sync.js CHANGED
@@ -1,2 +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};
1
+ import{a as o}from"./chunk-5KUKBKWL.js";import"./chunk-XEN5VKAV.js";import{a as r,b as e}from"./chunk-WETG2JD7.js";import"./chunk-YNY65JUJ.js";import"./chunk-ZT72PD2C.js";import"./chunk-4C666HHU.js";export{o as CopioSyncDialog,e as SyncManager,r as getIceServers};
2
2
  //# sourceMappingURL=sync.js.map
@@ -0,0 +1,48 @@
1
+ /**
2
+ * IndexedDbBlobStore — Native Blob persistence helper for IndexedDbStorageAdapter (CPO-012).
3
+ *
4
+ * Eliminates Base64 encoding overhead by storing binary page Blobs directly
5
+ * inside a dedicated IndexedDB object store ('copio-blobs').
6
+ */
7
+ export declare class IndexedDbBlobStore {
8
+ #private;
9
+ /**
10
+ * @param {string} [dbName='copio-blobs']
11
+ */
12
+ constructor(dbName?: string);
13
+ /**
14
+ * Saves a native Blob under the given key.
15
+ * @param {string} key
16
+ * @param {Blob} blob
17
+ * @returns {Promise<void>}
18
+ */
19
+ put(key: string, blob: Blob): Promise<void>;
20
+ /**
21
+ * Retrieves a native Blob by key.
22
+ * @param {string} key
23
+ * @returns {Promise<Blob|null>}
24
+ */
25
+ get(key: string): Promise<Blob | null>;
26
+ /**
27
+ * Deletes a Blob by key.
28
+ * @param {string} key
29
+ * @returns {Promise<void>}
30
+ */
31
+ delete(key: string): Promise<void>;
32
+ /**
33
+ * Deletes all Blobs whose key starts with the given prefix (e.g. `${docId}:`).
34
+ * @param {string} prefix
35
+ * @returns {Promise<void>}
36
+ */
37
+ deleteByPrefix(prefix: string): Promise<void>;
38
+ /**
39
+ * Startup sweep: removes any stored Blobs whose docId prefix is not in validDocIds.
40
+ * @param {string[]|Set<string>} validDocIds
41
+ * @returns {Promise<number>} Count of removed orphan blobs
42
+ */
43
+ sweepOrphans(validDocIds: string[] | Set<string>): Promise<number>;
44
+ /**
45
+ * Closes the database connection.
46
+ */
47
+ close(): Promise<void>;
48
+ }
@@ -1,22 +1,29 @@
1
1
  import { StoragePort } from './storage-port.js';
2
2
  import { MemoryStorageAdapter } from './memory-adapter.js';
3
3
  import { IndexedDbStorageAdapter } from './indexeddb-adapter.js';
4
- export { StoragePort, MemoryStorageAdapter, IndexedDbStorageAdapter };
4
+ import { OpfsStorageAdapter, probeOpfs } from './opfs-adapter.js';
5
+ export { StoragePort, MemoryStorageAdapter, IndexedDbStorageAdapter, OpfsStorageAdapter, probeOpfs, };
5
6
  /**
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.
7
+ * Creates the appropriate default storage adapter for the runtime environment (CPO-012).
8
+ * Selects OPFS in browsers when available, falling back to IndexedDbStorageAdapter,
9
+ * or MemoryStorageAdapter in Node.js / SSR or when forceMemory is explicitly specified.
9
10
  *
10
11
  * @param {Object} [options]
11
12
  * @param {boolean} [options.forceMemory] - Force use of MemoryStorageAdapter
13
+ * @param {boolean} [options.forceIndexedDb] - Force use of IndexedDbStorageAdapter
14
+ * @param {boolean} [options.forceOpfs] - Force use of OpfsStorageAdapter
12
15
  * @param {string} [options.dbName] - Database name for IndexedDB
16
+ * @param {string} [options.dirName] - Directory name for OPFS
13
17
  * @param {any} [options.store] - Optional TinyBase store instance
14
18
  * @param {any} [options.persister] - Optional TinyBase persister instance
15
19
  * @returns {StoragePort}
16
20
  */
17
21
  export declare function createDefaultAdapter(options?: {
18
22
  forceMemory?: boolean;
23
+ forceIndexedDb?: boolean;
24
+ forceOpfs?: boolean;
19
25
  dbName?: string;
26
+ dirName?: string;
20
27
  store?: any;
21
28
  persister?: any;
22
29
  }): StoragePort;
@@ -1,9 +1,22 @@
1
1
  import { StoragePort } from './storage-port.js';
2
2
  /**
3
- * IndexedDbStorageAdapter — TinyBase IndexedDB implementation of StoragePort (CPO-033).
3
+ * Converts a base64 Data URL to a native Blob instance.
4
+ * @param {any} dataUrlOrBlob
5
+ * @param {string} [defaultType='image/jpeg']
6
+ * @returns {Blob|null}
7
+ */
8
+ export declare function dataUrlToBlob(dataUrlOrBlob: any, defaultType?: string): Blob | null;
9
+ /**
10
+ * Converts a Blob to a Data URL (for backwards-compatibility / legacy fallbacks).
11
+ * @param {Blob} blob
12
+ * @returns {Promise<string>}
13
+ */
14
+ export declare function blobToDataUrl(blob: Blob): Promise<string>;
15
+ /**
16
+ * IndexedDbStorageAdapter — TinyBase IndexedDB implementation of StoragePort (CPO-033 / CPO-012).
4
17
  *
5
- * Wraps TinyBase and IndexedDbPersister behind the StoragePort contract, ensuring
6
- * existing database data ('copio-db') is preserved while isolating storage mechanics.
18
+ * Implements fallback storage with metadata in TinyBase and binary page data stored
19
+ * as native Blobs in an IndexedDB object store to avoid Base64 storage bloat.
7
20
  */
8
21
  export declare class IndexedDbStorageAdapter extends StoragePort {
9
22
  #private;
@@ -20,13 +33,29 @@ export declare class IndexedDbStorageAdapter extends StoragePort {
20
33
  });
21
34
  get store(): any;
22
35
  get persister(): any;
36
+ get blobStore(): any;
23
37
  /**
38
+ * Revokes all active object URLs for a specific document.
39
+ * @param {string} docId
40
+ */
41
+ revokeDocUrls(docId: string): void;
42
+ /**
43
+ * Revokes all active object URLs created by this adapter.
44
+ */
45
+ revokeAllUrls(): void;
46
+ /**
47
+ * Initializes the storage backend, opening connections and verifying availability.
24
48
  * @returns {Promise<{ kind: string, persistent: boolean }>}
25
49
  */
26
50
  init(): Promise<{
27
51
  kind: string;
28
52
  persistent: boolean;
29
53
  }>;
54
+ /**
55
+ * Startup sweep: removes any stored blobs whose document ID no longer exists.
56
+ * @returns {Promise<number>}
57
+ */
58
+ sweepOrphans(): Promise<number>;
30
59
  /**
31
60
  * Returns list of all stored documents synchronously from the TinyBase cache.
32
61
  * @returns {Array<{ id: string, name: string, pages: any[] }>}
@@ -46,7 +75,7 @@ export declare class IndexedDbStorageAdapter extends StoragePort {
46
75
  pages: any[];
47
76
  }>>;
48
77
  /**
49
- * Retrieves a document by its ID synchronously from the TinyBase cache.
78
+ * Retrieves a document by its ID synchronously from the TinyBase cache or in-memory cache.
50
79
  * @param {string} id
51
80
  * @returns {{ id: string, name: string, pages: any[] } | null}
52
81
  */
@@ -56,7 +85,7 @@ export declare class IndexedDbStorageAdapter extends StoragePort {
56
85
  pages: any[];
57
86
  } | null;
58
87
  /**
59
- * Retrieves a document by its ID.
88
+ * Retrieves a document by its ID, rehydrating page Blobs and Object URLs.
60
89
  * @param {string} id
61
90
  * @returns {Promise<{ id: string, name: string, pages: any[] } | null>}
62
91
  */
@@ -66,18 +95,26 @@ export declare class IndexedDbStorageAdapter extends StoragePort {
66
95
  pages: any[];
67
96
  } | null>;
68
97
  /**
69
- * Saves or updates a document.
98
+ * Saves or updates a document, persisting binary pages into native Blob storage
99
+ * and clean metadata into TinyBase.
70
100
  * @param {string} id
71
101
  * @param {import('./storage-port.js').DocRow} doc
72
102
  * @returns {Promise<void>}
73
103
  */
74
104
  saveDoc(id: string, doc: import('./storage-port.js').DocRow): Promise<void>;
75
105
  /**
76
- * Deletes a document.
106
+ * Deletes a document and its stored page Blobs.
77
107
  * @param {string} id
78
108
  * @returns {Promise<void>}
79
109
  */
80
110
  deleteDoc(id: string): Promise<void>;
111
+ /**
112
+ * Renames a document in TinyBase metadata and updates cache without rewriting blobs.
113
+ * @param {string} id
114
+ * @param {string} name
115
+ * @returns {Promise<void>}
116
+ */
117
+ renameDoc(id: string, name: string): Promise<void>;
81
118
  /**
82
119
  * Saves page data for a document.
83
120
  * @param {string} docId
@@ -87,14 +124,14 @@ export declare class IndexedDbStorageAdapter extends StoragePort {
87
124
  */
88
125
  savePage(docId: string, pageId: string, blobOrData: any): Promise<void>;
89
126
  /**
90
- * Retrieves page data.
127
+ * Retrieves page binary Blob or data.
91
128
  * @param {string} docId
92
129
  * @param {string} pageId
93
130
  * @returns {Promise<any>}
94
131
  */
95
132
  getPage(docId: string, pageId: string): Promise<any>;
96
133
  /**
97
- * Deletes page data.
134
+ * Deletes page binary Blob and metadata.
98
135
  * @param {string} docId
99
136
  * @param {string} pageId
100
137
  * @returns {Promise<void>}
@@ -66,6 +66,13 @@ export declare class MemoryStorageAdapter extends StoragePort {
66
66
  * @returns {Promise<void>}
67
67
  */
68
68
  deleteDoc(id: string): Promise<void>;
69
+ /**
70
+ * Renames a document in memory.
71
+ * @param {string} id
72
+ * @param {string} name
73
+ * @returns {Promise<void>}
74
+ */
75
+ renameDoc(id: string, name: string): Promise<void>;
69
76
  /**
70
77
  * Saves page data for a document.
71
78
  * @param {string} docId
@@ -0,0 +1,160 @@
1
+ import { StoragePort } from './storage-port.js';
2
+ /**
3
+ * Feature detection and write/read/delete probe for Origin Private File System (OPFS).
4
+ * Returns true only if OPFS is available and writable.
5
+ * @returns {Promise<boolean>}
6
+ */
7
+ export declare function probeOpfs(): Promise<boolean>;
8
+ /**
9
+ * TinyBase persister that saves and loads the store to/from a JSON file in an OPFS directory.
10
+ * @param {any} store - TinyBase store instance
11
+ * @param {() => FileSystemDirectoryHandle|null} getCopioDir - Function returning OPFS directory handle
12
+ * @param {string} [fileName='store.json']
13
+ */
14
+ export declare function createOpfsPersister(store: any, getCopioDir: () => FileSystemDirectoryHandle | null, fileName?: string): {
15
+ load: () => Promise<void>;
16
+ save: () => Promise<void>;
17
+ startAutoSave: () => void;
18
+ stopAutoSave: () => void;
19
+ getStatus: () => number;
20
+ getStore: () => any;
21
+ };
22
+ /**
23
+ * OpfsStorageAdapter — Primary OPFS implementation of StoragePort (CPO-012).
24
+ *
25
+ * Stores metadata in TinyBase persisted to `copio/store.json`, and page binary data
26
+ * as individual files in `copio/docs/{docId}/{pageId}.bin` in the Origin Private File System.
27
+ * Falls back to IndexedDbStorageAdapter if OPFS is unavailable or unsupported.
28
+ */
29
+ export declare class OpfsStorageAdapter extends StoragePort {
30
+ #private;
31
+ /**
32
+ * @param {Object} [options]
33
+ * @param {string} [options.dirName='copio'] - Root subfolder name in OPFS
34
+ * @param {any} [options.store] - Optional TinyBase store instance
35
+ * @param {boolean} [options.forceFallback=false] - Force fallback to IndexedDB
36
+ * @param {string} [options.dbName] - IndexedDB database name for fallback
37
+ * @param {any} [options.persister] - Optional TinyBase persister instance
38
+ */
39
+ constructor(options?: {
40
+ dirName?: string;
41
+ store?: any;
42
+ forceFallback?: boolean;
43
+ dbName?: string;
44
+ persister?: any;
45
+ });
46
+ get store(): any;
47
+ get persister(): any;
48
+ get isFallback(): boolean;
49
+ get fallbackAdapter(): any;
50
+ /**
51
+ * Revokes all active object URLs for a given document.
52
+ * @param {string} docId
53
+ */
54
+ revokeDocUrls(docId: string): void;
55
+ /**
56
+ * Revokes all active object URLs created by this adapter.
57
+ */
58
+ revokeAllUrls(): void;
59
+ /**
60
+ * Initializes the OPFS storage backend, performing a probe test and running startup sweeps.
61
+ * @returns {Promise<{ kind: string, persistent: boolean }>}
62
+ */
63
+ init(): Promise<{
64
+ kind: string;
65
+ persistent: boolean;
66
+ }>;
67
+ /**
68
+ * Startup sweep: removes any stored doc directories or page files that are no longer
69
+ * referenced in TinyBase metadata.
70
+ * @returns {Promise<number>} Count of removed orphan files and directories
71
+ */
72
+ sweepOrphans(): Promise<number>;
73
+ /**
74
+ * Returns list of all stored documents synchronously from TinyBase metadata.
75
+ * @returns {Array<{ id: string, name: string, pages: any[] }>}
76
+ */
77
+ listDocsSync(): Array<{
78
+ id: string;
79
+ name: string;
80
+ pages: any[];
81
+ }>;
82
+ /**
83
+ * Returns list of all stored documents.
84
+ * @returns {Promise<Array<{ id: string, name: string, pages: any[] }>>}
85
+ */
86
+ listDocs(): Promise<Array<{
87
+ id: string;
88
+ name: string;
89
+ pages: any[];
90
+ }>>;
91
+ /**
92
+ * Retrieves a document by its ID synchronously from TinyBase metadata or in-memory cache.
93
+ * @param {string} id
94
+ * @returns {{ id: string, name: string, pages: any[] } | null}
95
+ */
96
+ getDocSync(id: string): {
97
+ id: string;
98
+ name: string;
99
+ pages: any[];
100
+ } | null;
101
+ /**
102
+ * Retrieves a document by its ID, rehydrating page Blobs and Object URLs from OPFS.
103
+ * @param {string} id
104
+ * @returns {Promise<{ id: string, name: string, pages: any[] } | null>}
105
+ */
106
+ getDoc(id: string): Promise<{
107
+ id: string;
108
+ name: string;
109
+ pages: any[];
110
+ } | null>;
111
+ /**
112
+ * Saves or updates a document, writing binary pages as files to OPFS
113
+ * and clean metadata into TinyBase.
114
+ * @param {string} id
115
+ * @param {import('./storage-port.js').DocRow} doc
116
+ * @returns {Promise<void>}
117
+ */
118
+ saveDoc(id: string, doc: import('./storage-port.js').DocRow): Promise<void>;
119
+ /**
120
+ * Deletes a document, removing its folder in OPFS and its row from TinyBase.
121
+ * @param {string} id
122
+ * @returns {Promise<void>}
123
+ */
124
+ deleteDoc(id: string): Promise<void>;
125
+ /**
126
+ * Renames a document in TinyBase metadata and updates cache without rewriting page binaries.
127
+ * @param {string} id
128
+ * @param {string} name
129
+ * @returns {Promise<void>}
130
+ */
131
+ renameDoc(id: string, name: string): Promise<void>;
132
+ /**
133
+ * Saves page binary data or metadata for a document.
134
+ * @param {string} docId
135
+ * @param {string} pageId
136
+ * @param {any} blobOrData
137
+ * @returns {Promise<void>}
138
+ */
139
+ savePage(docId: string, pageId: string, blobOrData: any): Promise<void>;
140
+ /**
141
+ * Retrieves page binary Blob or data from OPFS.
142
+ * @param {string} docId
143
+ * @param {string} pageId
144
+ * @returns {Promise<any>}
145
+ */
146
+ getPage(docId: string, pageId: string): Promise<any>;
147
+ /**
148
+ * Deletes a page file from OPFS and removes it from TinyBase metadata.
149
+ * @param {string} docId
150
+ * @param {string} pageId
151
+ * @returns {Promise<void>}
152
+ */
153
+ deletePage(docId: string, pageId: string): Promise<void>;
154
+ /**
155
+ * Subscribes to document changes via TinyBase table listener.
156
+ * @param {() => void} cb
157
+ * @returns {() => void} Unsubscribe function
158
+ */
159
+ subscribe(cb: () => void): () => void;
160
+ }
@@ -76,6 +76,13 @@ export declare class StoragePort {
76
76
  * @returns {Promise<void>}
77
77
  */
78
78
  saveDoc(_id: string, _doc: DocRow): Promise<void>;
79
+ /**
80
+ * Renames an existing document.
81
+ * @param {string} _id
82
+ * @param {string} _name
83
+ * @returns {Promise<void>}
84
+ */
85
+ renameDoc(_id: string, _name: string): Promise<void>;
79
86
  /**
80
87
  * Deletes a document and its associated pages.
81
88
  * @param {string} _id
@@ -11,7 +11,11 @@ export declare class CopioHeader extends LitElement {
11
11
  _isPersisted: {
12
12
  state: boolean;
13
13
  };
14
+ storageKind: {
15
+ type: StringConstructor;
16
+ };
14
17
  };
18
+ constructor();
15
19
  connectedCallback(): Promise<void>;
16
20
  disconnectedCallback(): void;
17
21
  _formatBytes(bytes: any): string;
@@ -7,7 +7,6 @@ export declare class CopioCarousel extends LitElement {
7
7
  ocr: boolean;
8
8
  pdf: boolean;
9
9
  disconnectedCallback(): void;
10
- updated(changedProperties: any): void;
11
10
  static properties: {
12
11
  docId: {
13
12
  type: StringConstructor;
@@ -29,8 +28,8 @@ export declare class CopioCarousel extends LitElement {
29
28
  type: BooleanConstructor;
30
29
  };
31
30
  };
31
+ get visibleImages(): any[];
32
32
  get hasImages(): boolean;
33
- get hasMarkdown(): boolean;
34
33
  get pageCount(): number;
35
34
  static styles: any;
36
35
  constructor();
@@ -11,11 +11,7 @@ export declare class CopioImages extends HTMLElement {
11
11
  rotateImage(index: any): Promise<void>;
12
12
  thresholdImage(index: any): Promise<void>;
13
13
  resetImage(index: any): void;
14
- addBlankNote(): void;
15
14
  downloadImage(index: any): void;
16
- openTextDialog(index: any): void;
17
- applyTextEdit(): void;
18
- closeTextDialog(): void;
19
15
  showImageData(index: any): void;
20
16
  pdfToImages(file: any): Promise<{
21
17
  id: string;
@@ -31,7 +31,7 @@ export declare class CopioRow extends LitElement {
31
31
  };
32
32
  constructor();
33
33
  get hasImages(): boolean;
34
- get hasMarkdown(): boolean;
34
+ get visiblePages(): any[];
35
35
  get pageCount(): number;
36
36
  static styles: any;
37
37
  startRename(e: any): void;
@@ -43,7 +43,7 @@ export declare class CopioRow extends LitElement {
43
43
  handleDelete(): void;
44
44
  handleEdit(): void;
45
45
  handleDownload(): void;
46
+ handleDownloadSearchablePdf(): void;
46
47
  handleDownloadImages(): void;
47
- handleDownloadMarkdown(): void;
48
48
  render(): any;
49
49
  }
@@ -88,9 +88,7 @@ export declare class CopioDocOcrDialog extends LitElement {
88
88
  handleLangChange: (e: any) => void;
89
89
  handleTextInput: (e: any) => void;
90
90
  copyText: () => Promise<void>;
91
- downloadMarkdown: () => void;
92
91
  downloadText: () => void;
93
- saveAsNote: () => void;
94
92
  get _isSinglePage(): boolean;
95
93
  get _dialogLabel(): string;
96
94
  render(): any;
@@ -214,6 +214,7 @@ export declare class DocRepository {
214
214
  getAllDocs(): Promise<Record<string, DocWithPages>>;
215
215
  /**
216
216
  * Exports all documents formatted for wire transmission (e.g. P2P sync).
217
+ * Rehydrates Blobs to Data URLs so they serialize properly over WebRTC.
217
218
  * @returns {Promise<Record<string, { name: string, pages: string }>>}
218
219
  */
219
220
  exportAll(): Promise<Record<string, {
@@ -1,11 +1,3 @@
1
- /**
2
- * Render raw markdown string into a PDFDocument instance (PDFKit).
3
- */
4
- export declare function renderMarkdownToPdf(doc: any, rawContent: any): void;
5
- /**
6
- * Render a markdown page object to image data URLs by rendering PDF and extracting pages as images.
7
- */
8
- export declare function renderMarkdownToPageDataUrls(page: any): Promise<string[]>;
9
1
  /**
10
2
  * Export document pages as a PDF file download.
11
3
  * @param {string} docName
@@ -14,12 +6,20 @@ export declare function renderMarkdownToPageDataUrls(page: any): Promise<string[
14
6
  * @param {Function} [options.onProgress] - Callback invoked per page: (done, total) => void
15
7
  * @param {boolean} [options.showProgress=true] - Whether to show progress toast in UI
16
8
  * @param {boolean} [options.download=true] - Whether to trigger browser download
9
+ * @param {boolean} [options.searchable=false] - Whether to overlay invisible OCR text layer
10
+ * @param {string} [options.lang='eng'] - OCR language
11
+ * @param {Function} [options.recognizeImageText] - Custom OCR recognition function for tests or dependency injection
12
+ * @param {Function} [options.onOcrComplete] - Callback invoked when on-demand OCR finishes with updated pages
17
13
  * @returns {Promise<Blob|undefined>}
18
14
  */
19
15
  export declare function exportDocumentAsPdf(docName: string, pages: Array<any>, options?: {
20
16
  onProgress?: Function;
21
17
  showProgress?: boolean;
22
18
  download?: boolean;
19
+ searchable?: boolean;
20
+ lang?: string;
21
+ recognizeImageText?: Function;
22
+ onOcrComplete?: Function;
23
23
  }): Promise<Blob | undefined>;
24
24
  /**
25
25
  * Export document pages as individual images or a ZIP file.
@@ -36,7 +36,3 @@ export declare function exportDocumentAsImages(docName: string, pages: Array<any
36
36
  showProgress?: boolean;
37
37
  download?: boolean;
38
38
  }): Promise<Blob | undefined>;
39
- /**
40
- * Export markdown pages of a document as a .md file download.
41
- */
42
- export declare function exportDocumentAsMarkdown(docName: any, pages: any): void;
@@ -35,7 +35,7 @@ export declare function recognizeImageText(image: string | Blob | File | HTMLIma
35
35
  }>;
36
36
  /**
37
37
  * Batch recognize text from multiple pages
38
- * @param {Array<{ id: string, src?: string, type?: string, content?: string, name?: string }>} pages
38
+ * @param {Array<{ id: string, src?: string, blob?: Blob, type?: string, content?: string, name?: string }>} pages
39
39
  * @param {Object} options
40
40
  * @param {string} [options.lang='eng']
41
41
  * @param {Function} [options.onPageProgress] - ({ pageIndex, totalPages, pageProgress, overallProgress, message })
@@ -45,6 +45,7 @@ export declare function recognizeImageText(image: string | Blob | File | HTMLIma
45
45
  export declare function recognizeDocumentPages(pages: Array<{
46
46
  id: string;
47
47
  src?: string;
48
+ blob?: Blob;
48
49
  type?: string;
49
50
  content?: string;
50
51
  name?: string;
@@ -5,7 +5,6 @@
5
5
  * - Cropper.js (window.Cropper)
6
6
  * - PDFKit (window.PDFDocument)
7
7
  * - JSZip (window.JSZip)
8
- * - Marked (window.marked)
9
8
  * - PeerJS (window.Peer)
10
9
  * - QRCode (window.qrcode)
11
10
  * - Tesseract.js (window.Tesseract)
@@ -54,11 +53,6 @@ export declare function loadPdfKit(): Promise<any>;
54
53
  * @returns {Promise<any>}
55
54
  */
56
55
  export declare function loadJsZip(): Promise<any>;
57
- /**
58
- * Lazy loads marked markdown parser on demand.
59
- * @returns {Promise<any>}
60
- */
61
- export declare function loadMarked(): Promise<any>;
62
56
  /**
63
57
  * Lazy loads PeerJS on demand.
64
58
  * @returns {Promise<any>}
@@ -18,14 +18,16 @@ export declare function getCroppedSrc(cropper: any, originalSrc?: string): any;
18
18
  /**
19
19
  * Normalizes an edit stack object.
20
20
  * @param {Object} [edits]
21
- * @returns {{ crop: { x: number, y: number, width: number, height: number } | null, rotation: number, filter: string }}
21
+ * @returns {{ crop: { x: number, y: number, width?: number, height?: number, w?: number, h?: number } | null, rotation: number, filter: string }}
22
22
  */
23
23
  export declare function normalizeEdits(edits?: any): {
24
24
  crop: {
25
25
  x: number;
26
26
  y: number;
27
- width: number;
28
- height: number;
27
+ width?: number;
28
+ height?: number;
29
+ w?: number;
30
+ h?: number;
29
31
  } | null;
30
32
  rotation: number;
31
33
  filter: string;
@@ -14,7 +14,7 @@ import { BUILD_DATE, VERSION } from './version.js';
14
14
  import { NullOcrAdapter } from '../js/adapters/ocr/null-ocr-adapter.js';
15
15
  import { NullPdfAdapter } from '../js/adapters/pdf/null-pdf-adapter.js';
16
16
  import { ImageProcessorPort, Canvas2DAdapter, NullImageProcessorAdapter } from '../js/adapters/image/index.js';
17
- import { Document, Page, ScanSession, normalizeEditStack, hasActiveEdits } from './models.js';
17
+ import { Document, Page, ScanSession, normalizeEditStack, hasActiveEdits, rotateCrop, cropRotatedToOriginal, cropOriginalToRotated } from './models.js';
18
18
  export declare const DEFAULT_FEATURES: string[];
19
19
  export declare const DEFAULT_EXPORT_FORMATS: string[];
20
20
  export declare const DEFAULT_OCR_LANGUAGES: string[];
@@ -188,6 +188,13 @@ export declare class CopioEngine {
188
188
  */
189
189
  get imageProcessor(): ImageProcessorPort;
190
190
  setImageProcessor(processor: any): void;
191
+ /**
192
+ * Renders edits against an image source using the configured ImageProcessorPort.
193
+ * @param {string} src
194
+ * @param {Object} edits
195
+ * @returns {Promise<string>}
196
+ */
197
+ renderEdits(src: string, edits: any): Promise<string>;
191
198
  /**
192
199
  * Underlying document repository.
193
200
  * @returns {DocRepository}
@@ -255,11 +262,13 @@ export declare class CopioEngine {
255
262
  * @param {string|Array<Object>} [docIdOrPages]
256
263
  * @param {Object} [options]
257
264
  * @param {boolean} [options.download=false] - Whether to trigger browser download
265
+ * @param {boolean} [options.searchable=false] - Whether to generate searchable PDF with invisible OCR text layer
258
266
  * @param {Function} [options.onProgress] - Progress callback (done, total)
259
267
  * @returns {Promise<Blob>}
260
268
  */
261
269
  exportPdf(docIdOrPages?: string | Array<any>, options?: {
262
270
  download?: boolean;
271
+ searchable?: boolean;
263
272
  onProgress?: Function;
264
273
  }): Promise<Blob>;
265
274
  /**
@@ -269,11 +278,13 @@ export declare class CopioEngine {
269
278
  * @param {string|Array<Object>} [docIdOrPages]
270
279
  * @param {Object} [options]
271
280
  * @param {boolean} [options.download=false] - Whether to trigger browser download
281
+ * @param {boolean} [options.searchable=false] - Whether to generate searchable PDF with invisible OCR text layer
272
282
  * @param {Function} [options.onProgress] - Progress callback (done, total)
273
283
  * @returns {Promise<Blob>}
274
284
  */
275
285
  exportZip(docIdOrPages?: string | Array<any>, options?: {
276
286
  download?: boolean;
287
+ searchable?: boolean;
277
288
  onProgress?: Function;
278
289
  }): Promise<Blob>;
279
290
  /**
@@ -306,5 +317,5 @@ export declare class CopioEngine {
306
317
  onStateChange?: Function;
307
318
  }): Promise<any>;
308
319
  }
309
- export { DocRepository, docRepository, StoragePort, MemoryStorageAdapter, IndexedDbStorageAdapter, createDefaultAdapter, ImageProcessorPort, Canvas2DAdapter, NullImageProcessorAdapter, NullOcrAdapter, NullPdfAdapter, Document, Page, ScanSession, normalizeEditStack, hasActiveEdits, randomId, fileToBase64, thresholdSrc, rotateSrc, getCroppedSrc, extractExif, applyEdits, normalizeEdits, renderEditsToCanvas, applySauvolaToImageData, BUILD_DATE, VERSION, };
320
+ export { DocRepository, docRepository, StoragePort, MemoryStorageAdapter, IndexedDbStorageAdapter, createDefaultAdapter, ImageProcessorPort, Canvas2DAdapter, NullImageProcessorAdapter, NullOcrAdapter, NullPdfAdapter, Document, Page, ScanSession, normalizeEditStack, hasActiveEdits, rotateCrop, cropRotatedToOriginal, cropOriginalToRotated, randomId, fileToBase64, thresholdSrc, rotateSrc, getCroppedSrc, extractExif, applyEdits, normalizeEdits, renderEditsToCanvas, applySauvolaToImageData, BUILD_DATE, VERSION, };
310
321
  export { COPIO_EVENTS, dispatchCopioEvent } from './events.js';