@kreuzberg/wasm 4.0.0-rc.10

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.
@@ -0,0 +1,294 @@
1
+ /**
2
+ * Type definitions for Kreuzberg WASM bindings
3
+ *
4
+ * These types are generated from the Rust core library and define
5
+ * the interface for extraction, configuration, and results.
6
+ */
7
+ /**
8
+ * Token reduction configuration
9
+ */
10
+ interface TokenReductionConfig {
11
+ /** Token reduction mode */
12
+ mode?: string;
13
+ /** Preserve important words during reduction */
14
+ preserveImportantWords?: boolean;
15
+ }
16
+ /**
17
+ * Post-processor configuration
18
+ */
19
+ interface PostProcessorConfig {
20
+ /** Whether post-processing is enabled */
21
+ enabled?: boolean;
22
+ /** List of enabled processors */
23
+ enabledProcessors?: string[];
24
+ /** List of disabled processors */
25
+ disabledProcessors?: string[];
26
+ }
27
+ /**
28
+ * Configuration for document extraction
29
+ */
30
+ interface ExtractionConfig {
31
+ /** OCR configuration */
32
+ ocr?: OcrConfig;
33
+ /** Chunking configuration */
34
+ chunking?: ChunkingConfig;
35
+ /** Image extraction configuration */
36
+ images?: ImageExtractionConfig;
37
+ /** Page extraction configuration */
38
+ pages?: PageExtractionConfig;
39
+ /** Language detection configuration */
40
+ languageDetection?: LanguageDetectionConfig;
41
+ /** PDF extraction options */
42
+ pdfOptions?: PdfConfig;
43
+ /** Token reduction configuration */
44
+ tokenReduction?: TokenReductionConfig;
45
+ /** Post-processor configuration */
46
+ postprocessor?: PostProcessorConfig;
47
+ /** Whether to use caching */
48
+ useCache?: boolean;
49
+ /** Enable quality processing */
50
+ enableQualityProcessing?: boolean;
51
+ /** Force OCR even if text is available */
52
+ forceOcr?: boolean;
53
+ /** Maximum concurrent extractions */
54
+ maxConcurrentExtractions?: number;
55
+ }
56
+ /**
57
+ * Tesseract OCR configuration
58
+ */
59
+ interface TesseractConfig {
60
+ /** Tesseract page segmentation mode */
61
+ psm?: number;
62
+ /** Enable table detection */
63
+ enableTableDetection?: boolean;
64
+ /** Character whitelist for recognition */
65
+ tesseditCharWhitelist?: string;
66
+ }
67
+ /**
68
+ * OCR configuration
69
+ */
70
+ interface OcrConfig {
71
+ /** OCR backend to use */
72
+ backend?: string;
73
+ /** Language codes (ISO 639) */
74
+ languages?: string[];
75
+ /** Whether to perform OCR */
76
+ enabled?: boolean;
77
+ /** Tesseract-specific configuration */
78
+ tesseractConfig?: TesseractConfig;
79
+ /** Language code for OCR */
80
+ language?: string;
81
+ }
82
+ /**
83
+ * Chunking configuration
84
+ */
85
+ interface ChunkingConfig {
86
+ /** Maximum characters per chunk */
87
+ maxChars?: number;
88
+ /** Overlap between chunks */
89
+ maxOverlap?: number;
90
+ }
91
+ /**
92
+ * Image extraction configuration
93
+ */
94
+ interface ImageExtractionConfig {
95
+ /** Whether to extract images */
96
+ enabled?: boolean;
97
+ /** Target DPI for image extraction */
98
+ targetDpi?: number;
99
+ /** Maximum image dimension in pixels */
100
+ maxImageDimension?: number;
101
+ /** Automatically adjust DPI */
102
+ autoAdjustDpi?: boolean;
103
+ /** Minimum DPI threshold */
104
+ minDpi?: number;
105
+ /** Maximum DPI threshold */
106
+ maxDpi?: number;
107
+ }
108
+ /**
109
+ * PDF extraction configuration
110
+ */
111
+ interface PdfConfig {
112
+ /** Whether to extract images from PDF */
113
+ extractImages?: boolean;
114
+ /** Passwords for encrypted PDFs */
115
+ passwords?: string[];
116
+ /** Whether to extract metadata */
117
+ extractMetadata?: boolean;
118
+ }
119
+ /**
120
+ * Page extraction configuration
121
+ */
122
+ interface PageExtractionConfig {
123
+ /** Whether to extract per-page content */
124
+ enabled?: boolean;
125
+ }
126
+ /**
127
+ * Language detection configuration
128
+ */
129
+ interface LanguageDetectionConfig {
130
+ /** Whether to detect languages */
131
+ enabled?: boolean;
132
+ }
133
+ /**
134
+ * Result of document extraction
135
+ */
136
+ interface ExtractionResult {
137
+ /** Extracted text content */
138
+ content: string;
139
+ /** MIME type of the document */
140
+ mimeType: string;
141
+ /** Document metadata */
142
+ metadata: Metadata;
143
+ /** Extracted tables */
144
+ tables: Table[];
145
+ /** Detected languages (ISO 639 codes) */
146
+ detectedLanguages?: string[] | null;
147
+ /** Text chunks when chunking is enabled */
148
+ chunks?: Chunk[] | null;
149
+ /** Extracted images */
150
+ images?: ExtractedImage[] | null;
151
+ /** Per-page content */
152
+ pages?: PageContent[] | null;
153
+ }
154
+ /**
155
+ * Document metadata
156
+ */
157
+ interface Metadata {
158
+ /** Document title */
159
+ title?: string;
160
+ /** Document subject or description */
161
+ subject?: string;
162
+ /** Document author(s) */
163
+ authors?: string[];
164
+ /** Keywords/tags */
165
+ keywords?: string[];
166
+ /** Primary language (ISO 639 code) */
167
+ language?: string;
168
+ /** Creation timestamp (ISO 8601 format) */
169
+ createdAt?: string;
170
+ /** Last modification timestamp (ISO 8601 format) */
171
+ modifiedAt?: string;
172
+ /** User who created the document */
173
+ creator?: string;
174
+ /** User who last modified the document */
175
+ lastModifiedBy?: string;
176
+ /** Number of pages/slides */
177
+ pageCount?: number;
178
+ /** Format-specific metadata */
179
+ formatMetadata?: unknown;
180
+ /**
181
+ * Additional fields may be added at runtime by postprocessors.
182
+ * Use bracket notation to safely access unexpected properties.
183
+ */
184
+ [key: string]: unknown;
185
+ }
186
+ /**
187
+ * Extracted table
188
+ */
189
+ interface Table {
190
+ /** Table cells/rows */
191
+ cells?: string[][];
192
+ /** Table markdown representation */
193
+ markdown?: string;
194
+ /** Page number if available */
195
+ pageNumber?: number;
196
+ /** Table headers */
197
+ headers?: string[];
198
+ /** Table rows */
199
+ rows?: string[][];
200
+ }
201
+ /**
202
+ * Chunk metadata
203
+ */
204
+ interface ChunkMetadata {
205
+ /** Character start position in original content */
206
+ charStart: number;
207
+ /** Character end position in original content */
208
+ charEnd: number;
209
+ /** Token count if available */
210
+ tokenCount: number | null;
211
+ /** Index of this chunk */
212
+ chunkIndex: number;
213
+ /** Total number of chunks */
214
+ totalChunks: number;
215
+ }
216
+ /**
217
+ * Text chunk from chunked content
218
+ */
219
+ interface Chunk {
220
+ /** Chunk text content */
221
+ content: string;
222
+ /** Chunk metadata */
223
+ metadata?: ChunkMetadata;
224
+ /** Character position in original content (legacy) */
225
+ charIndex?: number;
226
+ /** Token count if available (legacy) */
227
+ tokenCount?: number;
228
+ /** Embedding vector if computed */
229
+ embedding?: number[] | null;
230
+ }
231
+ /**
232
+ * Extracted image from document
233
+ */
234
+ interface ExtractedImage {
235
+ /** Image data as Uint8Array or base64 string */
236
+ data: Uint8Array | string;
237
+ /** Image format/MIME type */
238
+ format?: string;
239
+ /** MIME type of the image */
240
+ mimeType?: string;
241
+ /** Image index in document */
242
+ imageIndex?: number;
243
+ /** Page number if available */
244
+ pageNumber?: number | null;
245
+ /** Image width in pixels */
246
+ width?: number | null;
247
+ /** Image height in pixels */
248
+ height?: number | null;
249
+ /** Color space of the image */
250
+ colorspace?: string | null;
251
+ /** Bits per color component */
252
+ bitsPerComponent?: number | null;
253
+ /** Whether this is a mask image */
254
+ isMask?: boolean;
255
+ /** Image description */
256
+ description?: string | null;
257
+ /** Optional OCR result from the image */
258
+ ocrResult?: ExtractionResult | string | null;
259
+ }
260
+ /**
261
+ * Per-page content
262
+ */
263
+ interface PageContent {
264
+ /** Page number (1-indexed) */
265
+ pageNumber: number;
266
+ /** Text content of the page */
267
+ content: string;
268
+ /** Tables on this page */
269
+ tables?: Table[];
270
+ /** Images on this page */
271
+ images?: ExtractedImage[];
272
+ }
273
+ /**
274
+ * OCR backend protocol/interface
275
+ */
276
+ interface OcrBackendProtocol {
277
+ /** Get the backend name */
278
+ name(): string;
279
+ /** Get supported language codes */
280
+ supportedLanguages?(): string[];
281
+ /** Initialize the backend */
282
+ initialize(options?: Record<string, unknown>): void | Promise<void>;
283
+ /** Shutdown the backend */
284
+ shutdown?(): void | Promise<void>;
285
+ /** Process an image with OCR */
286
+ processImage(imageData: Uint8Array | string, language?: string): Promise<{
287
+ content: string;
288
+ mime_type: string;
289
+ metadata?: Record<string, unknown>;
290
+ tables?: unknown[];
291
+ } | string>;
292
+ }
293
+
294
+ export type { Chunk as C, ExtractionConfig as E, ImageExtractionConfig as I, LanguageDetectionConfig as L, Metadata as M, OcrBackendProtocol as O, PageContent as P, Table as T, ExtractionResult as a, ChunkingConfig as b, ChunkMetadata as c, ExtractedImage as d, OcrConfig as e, PageExtractionConfig as f, PdfConfig as g, PostProcessorConfig as h, TesseractConfig as i, TokenReductionConfig as j };
@@ -0,0 +1,294 @@
1
+ /**
2
+ * Type definitions for Kreuzberg WASM bindings
3
+ *
4
+ * These types are generated from the Rust core library and define
5
+ * the interface for extraction, configuration, and results.
6
+ */
7
+ /**
8
+ * Token reduction configuration
9
+ */
10
+ interface TokenReductionConfig {
11
+ /** Token reduction mode */
12
+ mode?: string;
13
+ /** Preserve important words during reduction */
14
+ preserveImportantWords?: boolean;
15
+ }
16
+ /**
17
+ * Post-processor configuration
18
+ */
19
+ interface PostProcessorConfig {
20
+ /** Whether post-processing is enabled */
21
+ enabled?: boolean;
22
+ /** List of enabled processors */
23
+ enabledProcessors?: string[];
24
+ /** List of disabled processors */
25
+ disabledProcessors?: string[];
26
+ }
27
+ /**
28
+ * Configuration for document extraction
29
+ */
30
+ interface ExtractionConfig {
31
+ /** OCR configuration */
32
+ ocr?: OcrConfig;
33
+ /** Chunking configuration */
34
+ chunking?: ChunkingConfig;
35
+ /** Image extraction configuration */
36
+ images?: ImageExtractionConfig;
37
+ /** Page extraction configuration */
38
+ pages?: PageExtractionConfig;
39
+ /** Language detection configuration */
40
+ languageDetection?: LanguageDetectionConfig;
41
+ /** PDF extraction options */
42
+ pdfOptions?: PdfConfig;
43
+ /** Token reduction configuration */
44
+ tokenReduction?: TokenReductionConfig;
45
+ /** Post-processor configuration */
46
+ postprocessor?: PostProcessorConfig;
47
+ /** Whether to use caching */
48
+ useCache?: boolean;
49
+ /** Enable quality processing */
50
+ enableQualityProcessing?: boolean;
51
+ /** Force OCR even if text is available */
52
+ forceOcr?: boolean;
53
+ /** Maximum concurrent extractions */
54
+ maxConcurrentExtractions?: number;
55
+ }
56
+ /**
57
+ * Tesseract OCR configuration
58
+ */
59
+ interface TesseractConfig {
60
+ /** Tesseract page segmentation mode */
61
+ psm?: number;
62
+ /** Enable table detection */
63
+ enableTableDetection?: boolean;
64
+ /** Character whitelist for recognition */
65
+ tesseditCharWhitelist?: string;
66
+ }
67
+ /**
68
+ * OCR configuration
69
+ */
70
+ interface OcrConfig {
71
+ /** OCR backend to use */
72
+ backend?: string;
73
+ /** Language codes (ISO 639) */
74
+ languages?: string[];
75
+ /** Whether to perform OCR */
76
+ enabled?: boolean;
77
+ /** Tesseract-specific configuration */
78
+ tesseractConfig?: TesseractConfig;
79
+ /** Language code for OCR */
80
+ language?: string;
81
+ }
82
+ /**
83
+ * Chunking configuration
84
+ */
85
+ interface ChunkingConfig {
86
+ /** Maximum characters per chunk */
87
+ maxChars?: number;
88
+ /** Overlap between chunks */
89
+ maxOverlap?: number;
90
+ }
91
+ /**
92
+ * Image extraction configuration
93
+ */
94
+ interface ImageExtractionConfig {
95
+ /** Whether to extract images */
96
+ enabled?: boolean;
97
+ /** Target DPI for image extraction */
98
+ targetDpi?: number;
99
+ /** Maximum image dimension in pixels */
100
+ maxImageDimension?: number;
101
+ /** Automatically adjust DPI */
102
+ autoAdjustDpi?: boolean;
103
+ /** Minimum DPI threshold */
104
+ minDpi?: number;
105
+ /** Maximum DPI threshold */
106
+ maxDpi?: number;
107
+ }
108
+ /**
109
+ * PDF extraction configuration
110
+ */
111
+ interface PdfConfig {
112
+ /** Whether to extract images from PDF */
113
+ extractImages?: boolean;
114
+ /** Passwords for encrypted PDFs */
115
+ passwords?: string[];
116
+ /** Whether to extract metadata */
117
+ extractMetadata?: boolean;
118
+ }
119
+ /**
120
+ * Page extraction configuration
121
+ */
122
+ interface PageExtractionConfig {
123
+ /** Whether to extract per-page content */
124
+ enabled?: boolean;
125
+ }
126
+ /**
127
+ * Language detection configuration
128
+ */
129
+ interface LanguageDetectionConfig {
130
+ /** Whether to detect languages */
131
+ enabled?: boolean;
132
+ }
133
+ /**
134
+ * Result of document extraction
135
+ */
136
+ interface ExtractionResult {
137
+ /** Extracted text content */
138
+ content: string;
139
+ /** MIME type of the document */
140
+ mimeType: string;
141
+ /** Document metadata */
142
+ metadata: Metadata;
143
+ /** Extracted tables */
144
+ tables: Table[];
145
+ /** Detected languages (ISO 639 codes) */
146
+ detectedLanguages?: string[] | null;
147
+ /** Text chunks when chunking is enabled */
148
+ chunks?: Chunk[] | null;
149
+ /** Extracted images */
150
+ images?: ExtractedImage[] | null;
151
+ /** Per-page content */
152
+ pages?: PageContent[] | null;
153
+ }
154
+ /**
155
+ * Document metadata
156
+ */
157
+ interface Metadata {
158
+ /** Document title */
159
+ title?: string;
160
+ /** Document subject or description */
161
+ subject?: string;
162
+ /** Document author(s) */
163
+ authors?: string[];
164
+ /** Keywords/tags */
165
+ keywords?: string[];
166
+ /** Primary language (ISO 639 code) */
167
+ language?: string;
168
+ /** Creation timestamp (ISO 8601 format) */
169
+ createdAt?: string;
170
+ /** Last modification timestamp (ISO 8601 format) */
171
+ modifiedAt?: string;
172
+ /** User who created the document */
173
+ creator?: string;
174
+ /** User who last modified the document */
175
+ lastModifiedBy?: string;
176
+ /** Number of pages/slides */
177
+ pageCount?: number;
178
+ /** Format-specific metadata */
179
+ formatMetadata?: unknown;
180
+ /**
181
+ * Additional fields may be added at runtime by postprocessors.
182
+ * Use bracket notation to safely access unexpected properties.
183
+ */
184
+ [key: string]: unknown;
185
+ }
186
+ /**
187
+ * Extracted table
188
+ */
189
+ interface Table {
190
+ /** Table cells/rows */
191
+ cells?: string[][];
192
+ /** Table markdown representation */
193
+ markdown?: string;
194
+ /** Page number if available */
195
+ pageNumber?: number;
196
+ /** Table headers */
197
+ headers?: string[];
198
+ /** Table rows */
199
+ rows?: string[][];
200
+ }
201
+ /**
202
+ * Chunk metadata
203
+ */
204
+ interface ChunkMetadata {
205
+ /** Character start position in original content */
206
+ charStart: number;
207
+ /** Character end position in original content */
208
+ charEnd: number;
209
+ /** Token count if available */
210
+ tokenCount: number | null;
211
+ /** Index of this chunk */
212
+ chunkIndex: number;
213
+ /** Total number of chunks */
214
+ totalChunks: number;
215
+ }
216
+ /**
217
+ * Text chunk from chunked content
218
+ */
219
+ interface Chunk {
220
+ /** Chunk text content */
221
+ content: string;
222
+ /** Chunk metadata */
223
+ metadata?: ChunkMetadata;
224
+ /** Character position in original content (legacy) */
225
+ charIndex?: number;
226
+ /** Token count if available (legacy) */
227
+ tokenCount?: number;
228
+ /** Embedding vector if computed */
229
+ embedding?: number[] | null;
230
+ }
231
+ /**
232
+ * Extracted image from document
233
+ */
234
+ interface ExtractedImage {
235
+ /** Image data as Uint8Array or base64 string */
236
+ data: Uint8Array | string;
237
+ /** Image format/MIME type */
238
+ format?: string;
239
+ /** MIME type of the image */
240
+ mimeType?: string;
241
+ /** Image index in document */
242
+ imageIndex?: number;
243
+ /** Page number if available */
244
+ pageNumber?: number | null;
245
+ /** Image width in pixels */
246
+ width?: number | null;
247
+ /** Image height in pixels */
248
+ height?: number | null;
249
+ /** Color space of the image */
250
+ colorspace?: string | null;
251
+ /** Bits per color component */
252
+ bitsPerComponent?: number | null;
253
+ /** Whether this is a mask image */
254
+ isMask?: boolean;
255
+ /** Image description */
256
+ description?: string | null;
257
+ /** Optional OCR result from the image */
258
+ ocrResult?: ExtractionResult | string | null;
259
+ }
260
+ /**
261
+ * Per-page content
262
+ */
263
+ interface PageContent {
264
+ /** Page number (1-indexed) */
265
+ pageNumber: number;
266
+ /** Text content of the page */
267
+ content: string;
268
+ /** Tables on this page */
269
+ tables?: Table[];
270
+ /** Images on this page */
271
+ images?: ExtractedImage[];
272
+ }
273
+ /**
274
+ * OCR backend protocol/interface
275
+ */
276
+ interface OcrBackendProtocol {
277
+ /** Get the backend name */
278
+ name(): string;
279
+ /** Get supported language codes */
280
+ supportedLanguages?(): string[];
281
+ /** Initialize the backend */
282
+ initialize(options?: Record<string, unknown>): void | Promise<void>;
283
+ /** Shutdown the backend */
284
+ shutdown?(): void | Promise<void>;
285
+ /** Process an image with OCR */
286
+ processImage(imageData: Uint8Array | string, language?: string): Promise<{
287
+ content: string;
288
+ mime_type: string;
289
+ metadata?: Record<string, unknown>;
290
+ tables?: unknown[];
291
+ } | string>;
292
+ }
293
+
294
+ export type { Chunk as C, ExtractionConfig as E, ImageExtractionConfig as I, LanguageDetectionConfig as L, Metadata as M, OcrBackendProtocol as O, PageContent as P, Table as T, ExtractionResult as a, ChunkingConfig as b, ChunkMetadata as c, ExtractedImage as d, OcrConfig as e, PageExtractionConfig as f, PdfConfig as g, PostProcessorConfig as h, TesseractConfig as i, TokenReductionConfig as j };