@kreuzberg/wasm 4.0.0-rc.6
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 +982 -0
- package/dist/adapters/wasm-adapter.d.mts +121 -0
- package/dist/adapters/wasm-adapter.d.ts +121 -0
- package/dist/adapters/wasm-adapter.js +241 -0
- package/dist/adapters/wasm-adapter.js.map +1 -0
- package/dist/adapters/wasm-adapter.mjs +221 -0
- package/dist/adapters/wasm-adapter.mjs.map +1 -0
- package/dist/index.d.mts +466 -0
- package/dist/index.d.ts +466 -0
- package/dist/index.js +383 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +384 -0
- package/dist/index.mjs.map +1 -0
- package/dist/kreuzberg_wasm.d.mts +758 -0
- package/dist/kreuzberg_wasm.d.ts +758 -0
- package/dist/kreuzberg_wasm.js +1913 -0
- package/dist/kreuzberg_wasm.mjs +48 -0
- package/dist/kreuzberg_wasm_bg.wasm +0 -0
- package/dist/kreuzberg_wasm_bg.wasm.d.ts +54 -0
- package/dist/ocr/registry.d.mts +102 -0
- package/dist/ocr/registry.d.ts +102 -0
- package/dist/ocr/registry.js +90 -0
- package/dist/ocr/registry.js.map +1 -0
- package/dist/ocr/registry.mjs +70 -0
- package/dist/ocr/registry.mjs.map +1 -0
- package/dist/ocr/tesseract-wasm-backend.d.mts +257 -0
- package/dist/ocr/tesseract-wasm-backend.d.ts +257 -0
- package/dist/ocr/tesseract-wasm-backend.js +454 -0
- package/dist/ocr/tesseract-wasm-backend.js.map +1 -0
- package/dist/ocr/tesseract-wasm-backend.mjs +424 -0
- package/dist/ocr/tesseract-wasm-backend.mjs.map +1 -0
- package/dist/runtime.d.mts +256 -0
- package/dist/runtime.d.ts +256 -0
- package/dist/runtime.js +172 -0
- package/dist/runtime.js.map +1 -0
- package/dist/runtime.mjs +152 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.js +107 -0
- package/dist/types-GJVIvbPy.d.mts +221 -0
- package/dist/types-GJVIvbPy.d.ts +221 -0
- package/package.json +138 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var index_exports = {};
|
|
30
|
+
__export(index_exports, {
|
|
31
|
+
TesseractWasmBackend: () => import_tesseract_wasm_backend2.TesseractWasmBackend,
|
|
32
|
+
batchExtractBytes: () => batchExtractBytes,
|
|
33
|
+
batchExtractBytesSync: () => batchExtractBytesSync,
|
|
34
|
+
batchExtractFiles: () => batchExtractFiles,
|
|
35
|
+
clearOcrBackends: () => import_registry2.clearOcrBackends,
|
|
36
|
+
configToJS: () => import_wasm_adapter2.configToJS,
|
|
37
|
+
detectRuntime: () => import_runtime2.detectRuntime,
|
|
38
|
+
enableOcr: () => enableOcr,
|
|
39
|
+
extractBytes: () => extractBytes,
|
|
40
|
+
extractBytesSync: () => extractBytesSync,
|
|
41
|
+
extractFile: () => extractFile,
|
|
42
|
+
extractFromFile: () => extractFromFile,
|
|
43
|
+
fileToUint8Array: () => import_wasm_adapter2.fileToUint8Array,
|
|
44
|
+
getInitializationError: () => getInitializationError,
|
|
45
|
+
getOcrBackend: () => import_registry2.getOcrBackend,
|
|
46
|
+
getRuntimeInfo: () => import_runtime2.getRuntimeInfo,
|
|
47
|
+
getRuntimeVersion: () => import_runtime2.getRuntimeVersion,
|
|
48
|
+
getVersion: () => getVersion,
|
|
49
|
+
getWasmCapabilities: () => import_runtime2.getWasmCapabilities,
|
|
50
|
+
hasBigInt: () => import_runtime2.hasBigInt,
|
|
51
|
+
hasBlob: () => import_runtime2.hasBlob,
|
|
52
|
+
hasFileApi: () => import_runtime2.hasFileApi,
|
|
53
|
+
hasModuleWorkers: () => import_runtime2.hasModuleWorkers,
|
|
54
|
+
hasSharedArrayBuffer: () => import_runtime2.hasSharedArrayBuffer,
|
|
55
|
+
hasWasm: () => import_runtime2.hasWasm,
|
|
56
|
+
hasWasmStreaming: () => import_runtime2.hasWasmStreaming,
|
|
57
|
+
hasWorkers: () => import_runtime2.hasWorkers,
|
|
58
|
+
initWasm: () => initWasm,
|
|
59
|
+
isBrowser: () => import_runtime2.isBrowser,
|
|
60
|
+
isBun: () => import_runtime2.isBun,
|
|
61
|
+
isDeno: () => import_runtime2.isDeno,
|
|
62
|
+
isInitialized: () => isInitialized,
|
|
63
|
+
isNode: () => import_runtime2.isNode,
|
|
64
|
+
isServerEnvironment: () => import_runtime2.isServerEnvironment,
|
|
65
|
+
isValidExtractionResult: () => import_wasm_adapter2.isValidExtractionResult,
|
|
66
|
+
isWebEnvironment: () => import_runtime2.isWebEnvironment,
|
|
67
|
+
jsToExtractionResult: () => import_wasm_adapter2.jsToExtractionResult,
|
|
68
|
+
listOcrBackends: () => import_registry2.listOcrBackends,
|
|
69
|
+
registerOcrBackend: () => import_registry2.registerOcrBackend,
|
|
70
|
+
unregisterOcrBackend: () => import_registry2.unregisterOcrBackend,
|
|
71
|
+
wrapWasmError: () => import_wasm_adapter2.wrapWasmError
|
|
72
|
+
});
|
|
73
|
+
module.exports = __toCommonJS(index_exports);
|
|
74
|
+
var import_wasm_adapter = require("./adapters/wasm-adapter.js");
|
|
75
|
+
var import_registry = require("./ocr/registry.js");
|
|
76
|
+
var import_tesseract_wasm_backend = require("./ocr/tesseract-wasm-backend.js");
|
|
77
|
+
var import_runtime = require("./runtime.js");
|
|
78
|
+
var import_wasm_adapter2 = require("./adapters/wasm-adapter.js");
|
|
79
|
+
var import_registry2 = require("./ocr/registry.js");
|
|
80
|
+
var import_tesseract_wasm_backend2 = require("./ocr/tesseract-wasm-backend.js");
|
|
81
|
+
var import_runtime2 = require("./runtime.js");
|
|
82
|
+
let wasm = null;
|
|
83
|
+
let initialized = false;
|
|
84
|
+
let initializationError = null;
|
|
85
|
+
let initializationPromise = null;
|
|
86
|
+
async function initWasm() {
|
|
87
|
+
if (initialized) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (initializationPromise) {
|
|
91
|
+
return initializationPromise;
|
|
92
|
+
}
|
|
93
|
+
initializationPromise = (async () => {
|
|
94
|
+
try {
|
|
95
|
+
if (!(0, import_runtime.hasWasm)()) {
|
|
96
|
+
throw new Error("WebAssembly is not supported in this environment");
|
|
97
|
+
}
|
|
98
|
+
let wasmModule;
|
|
99
|
+
try {
|
|
100
|
+
wasmModule = await import("../../pkg/kreuzberg_wasm");
|
|
101
|
+
} catch {
|
|
102
|
+
wasmModule = await import("./kreuzberg_wasm");
|
|
103
|
+
}
|
|
104
|
+
wasm = wasmModule;
|
|
105
|
+
if (wasm && typeof wasm.default === "function") {
|
|
106
|
+
await wasm.default();
|
|
107
|
+
}
|
|
108
|
+
initialized = true;
|
|
109
|
+
initializationError = null;
|
|
110
|
+
} catch (error) {
|
|
111
|
+
initializationError = error instanceof Error ? error : new Error(String(error));
|
|
112
|
+
throw (0, import_wasm_adapter.wrapWasmError)(error, "initializing Kreuzberg WASM module");
|
|
113
|
+
}
|
|
114
|
+
})();
|
|
115
|
+
return initializationPromise;
|
|
116
|
+
}
|
|
117
|
+
function isInitialized() {
|
|
118
|
+
return initialized;
|
|
119
|
+
}
|
|
120
|
+
function getVersion() {
|
|
121
|
+
if (!initialized) {
|
|
122
|
+
throw new Error("WASM module not initialized. Call initWasm() first.");
|
|
123
|
+
}
|
|
124
|
+
if (!wasm) {
|
|
125
|
+
throw new Error("WASM module not loaded. Call initWasm() first.");
|
|
126
|
+
}
|
|
127
|
+
return wasm.version();
|
|
128
|
+
}
|
|
129
|
+
function getInitializationError() {
|
|
130
|
+
return initializationError;
|
|
131
|
+
}
|
|
132
|
+
async function extractBytes(data, mimeType, config) {
|
|
133
|
+
if (!initialized) {
|
|
134
|
+
throw new Error("WASM module not initialized. Call initWasm() first.");
|
|
135
|
+
}
|
|
136
|
+
if (!wasm) {
|
|
137
|
+
throw new Error("WASM module not loaded. Call initWasm() first.");
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
if (!data || data.length === 0) {
|
|
141
|
+
throw new Error("Document data cannot be empty");
|
|
142
|
+
}
|
|
143
|
+
if (!mimeType) {
|
|
144
|
+
throw new Error("MIME type is required");
|
|
145
|
+
}
|
|
146
|
+
const normalizedConfig = (0, import_wasm_adapter.configToJS)(config ?? null);
|
|
147
|
+
const result = await wasm.extractBytes(data, mimeType, normalizedConfig);
|
|
148
|
+
if (!result) {
|
|
149
|
+
throw new Error("Invalid extraction result: no result from WASM module");
|
|
150
|
+
}
|
|
151
|
+
return (0, import_wasm_adapter.jsToExtractionResult)(result);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
throw (0, import_wasm_adapter.wrapWasmError)(error, "extracting from bytes");
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
async function extractFile(path, mimeType, config) {
|
|
157
|
+
if (!initialized) {
|
|
158
|
+
throw new Error("WASM module not initialized. Call initWasm() first.");
|
|
159
|
+
}
|
|
160
|
+
if (!wasm) {
|
|
161
|
+
throw new Error("WASM module not loaded. Call initWasm() first.");
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
if (!path) {
|
|
165
|
+
throw new Error("File path is required");
|
|
166
|
+
}
|
|
167
|
+
const runtime = (0, import_runtime.detectRuntime)();
|
|
168
|
+
if (runtime === "browser") {
|
|
169
|
+
throw new Error("Use extractBytes with fileToUint8Array for browser environments");
|
|
170
|
+
}
|
|
171
|
+
let fileData;
|
|
172
|
+
if (runtime === "node") {
|
|
173
|
+
const { readFile } = await import("node:fs/promises");
|
|
174
|
+
const buffer = await readFile(path);
|
|
175
|
+
fileData = new Uint8Array(buffer);
|
|
176
|
+
} else if (runtime === "deno") {
|
|
177
|
+
const deno = globalThis.Deno;
|
|
178
|
+
fileData = await deno.readFile(path);
|
|
179
|
+
} else if (runtime === "bun") {
|
|
180
|
+
const { readFile } = await import("node:fs/promises");
|
|
181
|
+
const buffer = await readFile(path);
|
|
182
|
+
fileData = new Uint8Array(buffer);
|
|
183
|
+
} else {
|
|
184
|
+
throw new Error(`Unsupported runtime for file extraction: ${runtime}`);
|
|
185
|
+
}
|
|
186
|
+
let detectedMimeType = mimeType;
|
|
187
|
+
if (!detectedMimeType) {
|
|
188
|
+
detectedMimeType = wasm.detectMimeFromBytes(fileData);
|
|
189
|
+
}
|
|
190
|
+
if (!detectedMimeType) {
|
|
191
|
+
throw new Error("Could not detect MIME type for file. Please provide mimeType parameter.");
|
|
192
|
+
}
|
|
193
|
+
detectedMimeType = wasm.normalizeMimeType(detectedMimeType);
|
|
194
|
+
return await extractBytes(fileData, detectedMimeType, config);
|
|
195
|
+
} catch (error) {
|
|
196
|
+
throw (0, import_wasm_adapter.wrapWasmError)(error, `extracting from file: ${path}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
async function extractFromFile(file, mimeType, config) {
|
|
200
|
+
if (!initialized) {
|
|
201
|
+
throw new Error("WASM module not initialized. Call initWasm() first.");
|
|
202
|
+
}
|
|
203
|
+
if (!wasm) {
|
|
204
|
+
throw new Error("WASM module not loaded. Call initWasm() first.");
|
|
205
|
+
}
|
|
206
|
+
try {
|
|
207
|
+
const bytes = await (0, import_wasm_adapter.fileToUint8Array)(file);
|
|
208
|
+
let type = mimeType ?? (file instanceof File ? file.type : "application/octet-stream");
|
|
209
|
+
type = wasm.normalizeMimeType(type);
|
|
210
|
+
return await extractBytes(bytes, type, config);
|
|
211
|
+
} catch (error) {
|
|
212
|
+
throw (0, import_wasm_adapter.wrapWasmError)(error, `extracting from ${file instanceof File ? "file" : "blob"}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function extractBytesSync(data, mimeType, config) {
|
|
216
|
+
if (!initialized) {
|
|
217
|
+
throw new Error("WASM module not initialized. Call initWasm() first.");
|
|
218
|
+
}
|
|
219
|
+
if (!wasm) {
|
|
220
|
+
throw new Error("WASM module not loaded. Call initWasm() first.");
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
if (!data || data.length === 0) {
|
|
224
|
+
throw new Error("Document data cannot be empty");
|
|
225
|
+
}
|
|
226
|
+
if (!mimeType) {
|
|
227
|
+
throw new Error("MIME type is required");
|
|
228
|
+
}
|
|
229
|
+
const normalizedConfig = (0, import_wasm_adapter.configToJS)(config ?? null);
|
|
230
|
+
const result = wasm.extractBytesSync(data, mimeType, normalizedConfig);
|
|
231
|
+
if (!result) {
|
|
232
|
+
throw new Error("Invalid extraction result: no result from WASM module");
|
|
233
|
+
}
|
|
234
|
+
return (0, import_wasm_adapter.jsToExtractionResult)(result);
|
|
235
|
+
} catch (error) {
|
|
236
|
+
throw (0, import_wasm_adapter.wrapWasmError)(error, "extracting from bytes (sync)");
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
async function batchExtractBytes(files, config) {
|
|
240
|
+
if (!initialized) {
|
|
241
|
+
throw new Error("WASM module not initialized. Call initWasm() first.");
|
|
242
|
+
}
|
|
243
|
+
if (!wasm) {
|
|
244
|
+
throw new Error("WASM module not loaded. Call initWasm() first.");
|
|
245
|
+
}
|
|
246
|
+
try {
|
|
247
|
+
if (!Array.isArray(files)) {
|
|
248
|
+
throw new Error("Files parameter must be an array");
|
|
249
|
+
}
|
|
250
|
+
if (files.length === 0) {
|
|
251
|
+
throw new Error("Files array cannot be empty");
|
|
252
|
+
}
|
|
253
|
+
const dataList = [];
|
|
254
|
+
const mimeTypes = [];
|
|
255
|
+
for (let i = 0; i < files.length; i += 1) {
|
|
256
|
+
const file = files[i];
|
|
257
|
+
if (!file || typeof file !== "object") {
|
|
258
|
+
throw new Error(`Invalid file at index ${i}: must be an object with data and mimeType`);
|
|
259
|
+
}
|
|
260
|
+
const f = file;
|
|
261
|
+
if (!(f.data instanceof Uint8Array)) {
|
|
262
|
+
throw new Error(`Invalid file at index ${i}: data must be Uint8Array`);
|
|
263
|
+
}
|
|
264
|
+
if (typeof f.mimeType !== "string") {
|
|
265
|
+
throw new Error(`Invalid file at index ${i}: mimeType must be a string`);
|
|
266
|
+
}
|
|
267
|
+
if (f.data.length === 0) {
|
|
268
|
+
throw new Error(`Invalid file at index ${i}: data cannot be empty`);
|
|
269
|
+
}
|
|
270
|
+
dataList.push(f.data);
|
|
271
|
+
mimeTypes.push(f.mimeType);
|
|
272
|
+
}
|
|
273
|
+
const normalizedConfig = (0, import_wasm_adapter.configToJS)(config ?? null);
|
|
274
|
+
const results = await wasm.batchExtractBytes(dataList, mimeTypes, normalizedConfig);
|
|
275
|
+
if (!Array.isArray(results)) {
|
|
276
|
+
throw new Error("Invalid batch extraction result: expected array");
|
|
277
|
+
}
|
|
278
|
+
return results.map((result, index) => {
|
|
279
|
+
if (!result) {
|
|
280
|
+
throw new Error(`Invalid extraction result at index ${index}: no result from WASM module`);
|
|
281
|
+
}
|
|
282
|
+
return (0, import_wasm_adapter.jsToExtractionResult)(result);
|
|
283
|
+
});
|
|
284
|
+
} catch (error) {
|
|
285
|
+
throw (0, import_wasm_adapter.wrapWasmError)(error, "batch extracting from bytes");
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
function batchExtractBytesSync(files, config) {
|
|
289
|
+
if (!initialized) {
|
|
290
|
+
throw new Error("WASM module not initialized. Call initWasm() first.");
|
|
291
|
+
}
|
|
292
|
+
if (!wasm) {
|
|
293
|
+
throw new Error("WASM module not loaded. Call initWasm() first.");
|
|
294
|
+
}
|
|
295
|
+
try {
|
|
296
|
+
if (!Array.isArray(files)) {
|
|
297
|
+
throw new Error("Files parameter must be an array");
|
|
298
|
+
}
|
|
299
|
+
if (files.length === 0) {
|
|
300
|
+
throw new Error("Files array cannot be empty");
|
|
301
|
+
}
|
|
302
|
+
const dataList = [];
|
|
303
|
+
const mimeTypes = [];
|
|
304
|
+
for (let i = 0; i < files.length; i += 1) {
|
|
305
|
+
const file = files[i];
|
|
306
|
+
if (!file || typeof file !== "object") {
|
|
307
|
+
throw new Error(`Invalid file at index ${i}: must be an object with data and mimeType`);
|
|
308
|
+
}
|
|
309
|
+
const f = file;
|
|
310
|
+
if (!(f.data instanceof Uint8Array)) {
|
|
311
|
+
throw new Error(`Invalid file at index ${i}: data must be Uint8Array`);
|
|
312
|
+
}
|
|
313
|
+
if (typeof f.mimeType !== "string") {
|
|
314
|
+
throw new Error(`Invalid file at index ${i}: mimeType must be a string`);
|
|
315
|
+
}
|
|
316
|
+
if (f.data.length === 0) {
|
|
317
|
+
throw new Error(`Invalid file at index ${i}: data cannot be empty`);
|
|
318
|
+
}
|
|
319
|
+
dataList.push(f.data);
|
|
320
|
+
mimeTypes.push(f.mimeType);
|
|
321
|
+
}
|
|
322
|
+
const normalizedConfig = (0, import_wasm_adapter.configToJS)(config ?? null);
|
|
323
|
+
const results = wasm.batchExtractBytesSync(dataList, mimeTypes, normalizedConfig);
|
|
324
|
+
if (!Array.isArray(results)) {
|
|
325
|
+
throw new Error("Invalid batch extraction result: expected array");
|
|
326
|
+
}
|
|
327
|
+
return results.map((result, index) => {
|
|
328
|
+
if (!result) {
|
|
329
|
+
throw new Error(`Invalid extraction result at index ${index}: no result from WASM module`);
|
|
330
|
+
}
|
|
331
|
+
return (0, import_wasm_adapter.jsToExtractionResult)(result);
|
|
332
|
+
});
|
|
333
|
+
} catch (error) {
|
|
334
|
+
throw (0, import_wasm_adapter.wrapWasmError)(error, "batch extracting from bytes (sync)");
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
async function batchExtractFiles(files, config) {
|
|
338
|
+
if (!initialized) {
|
|
339
|
+
throw new Error("WASM module not initialized. Call initWasm() first.");
|
|
340
|
+
}
|
|
341
|
+
try {
|
|
342
|
+
if (!Array.isArray(files)) {
|
|
343
|
+
throw new Error("Files parameter must be an array");
|
|
344
|
+
}
|
|
345
|
+
if (files.length === 0) {
|
|
346
|
+
throw new Error("Files array cannot be empty");
|
|
347
|
+
}
|
|
348
|
+
const byteFiles = [];
|
|
349
|
+
for (let i = 0; i < files.length; i += 1) {
|
|
350
|
+
const file = files[i];
|
|
351
|
+
if (!(file instanceof File)) {
|
|
352
|
+
throw new Error(`Invalid file at index ${i}: must be a File object`);
|
|
353
|
+
}
|
|
354
|
+
const bytes = await (0, import_wasm_adapter.fileToUint8Array)(file);
|
|
355
|
+
byteFiles.push({
|
|
356
|
+
data: bytes,
|
|
357
|
+
mimeType: file.type || "application/octet-stream"
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
return await batchExtractBytes(byteFiles, config);
|
|
361
|
+
} catch (error) {
|
|
362
|
+
throw (0, import_wasm_adapter.wrapWasmError)(error, "batch extracting from files");
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
async function enableOcr() {
|
|
366
|
+
if (!initialized) {
|
|
367
|
+
throw new Error("WASM module not initialized. Call initWasm() first.");
|
|
368
|
+
}
|
|
369
|
+
if (!(0, import_runtime.isBrowser)()) {
|
|
370
|
+
throw new Error(
|
|
371
|
+
"OCR is only available in browser environments. TesseractWasmBackend requires Web Workers and createImageBitmap."
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
try {
|
|
375
|
+
const backend = new import_tesseract_wasm_backend.TesseractWasmBackend();
|
|
376
|
+
await backend.initialize();
|
|
377
|
+
(0, import_registry.registerOcrBackend)(backend);
|
|
378
|
+
} catch (error) {
|
|
379
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
380
|
+
throw new Error(`Failed to enable OCR: ${message}`);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../typescript/index.ts"],"sourcesContent":["/**\n * Kreuzberg - WebAssembly Bindings for Browser and Runtime Environments\n *\n * This module provides WebAssembly bindings for Kreuzberg document intelligence,\n * enabling high-performance document extraction in browser and JavaScript runtime environments.\n *\n * ## Features\n *\n * - Extract text, metadata, and tables from documents\n * - Support for multiple document formats (PDF, Office, images, etc.)\n * - Browser and runtime-compatible WASM bindings\n * - Type-safe TypeScript interfaces\n * - Runtime detection and feature capability checking\n * - Automatic type conversion and error handling\n *\n * ## Installation\n *\n * ```bash\n * npm install @kreuzberg/wasm\n * ```\n *\n * ## Basic Usage\n *\n * ```typescript\n * import { extractBytes, initWasm } from '@kreuzberg/wasm';\n *\n * // Initialize WASM module once at app startup\n * await initWasm();\n *\n * // Extract from bytes\n * const bytes = new Uint8Array(buffer);\n * const result = await extractBytes(bytes, 'application/pdf');\n * console.log(result.content);\n * ```\n *\n * ## Browser Usage with File Input\n *\n * ```typescript\n * import { extractBytes, initWasm } from '@kreuzberg/wasm';\n * import { fileToUint8Array } from '@kreuzberg/wasm/adapters/wasm-adapter';\n *\n * // Initialize once at app startup\n * await initWasm();\n *\n * // Handle file input\n * const fileInput = document.getElementById('file');\n * fileInput.addEventListener('change', async (e) => {\n * const file = e.target.files?.[0];\n * if (file) {\n * const bytes = await fileToUint8Array(file);\n * const result = await extractBytes(bytes, file.type);\n * console.log(result.content);\n * }\n * });\n * ```\n *\n * ## Runtime Detection\n *\n * ```typescript\n * import { detectRuntime, getWasmCapabilities } from '@kreuzberg/wasm/runtime';\n *\n * const runtime = detectRuntime();\n * const caps = getWasmCapabilities();\n *\n * if (caps.hasWorkers) {\n * // Can use Web Workers for parallel processing\n * }\n * ```\n *\n * ## Configuration\n *\n * ```typescript\n * import { extractBytes, initWasm } from '@kreuzberg/wasm';\n * import type { ExtractionConfig } from '@kreuzberg/wasm';\n *\n * await initWasm();\n *\n * const config: ExtractionConfig = {\n * ocr: {\n * backend: 'tesseract',\n * language: 'eng'\n * },\n * chunking: {\n * maxChars: 1000,\n * chunkOverlap: 100\n * },\n * images: {\n * extractImages: true,\n * targetDpi: 150\n * }\n * };\n *\n * const result = await extractBytes(bytes, 'application/pdf', config);\n * ```\n */\n\nimport type { ExtractionConfig as ExtractionConfigType, ExtractionResult } from \"./types.js\";\n\nimport { configToJS, fileToUint8Array, jsToExtractionResult, wrapWasmError } from \"./adapters/wasm-adapter.js\";\nimport { registerOcrBackend } from \"./ocr/registry.js\";\nimport { TesseractWasmBackend } from \"./ocr/tesseract-wasm-backend.js\";\nimport { detectRuntime, hasWasm, isBrowser } from \"./runtime.js\";\n\nexport type {\n\tChunk,\n\tChunkingConfig,\n\tExtractedImage,\n\tExtractionConfig,\n\tExtractionResult,\n\tTable,\n} from \"./types.js\";\n\nexport type * from \"./types.js\";\n\n// Re-export adapter utilities for convenient access\nexport {\n\tconfigToJS,\n\tfileToUint8Array,\n\tisValidExtractionResult,\n\tjsToExtractionResult,\n\twrapWasmError,\n} from \"./adapters/wasm-adapter.js\";\n\n// Re-export OCR registry\nexport {\n\tclearOcrBackends,\n\tgetOcrBackend,\n\tlistOcrBackends,\n\tregisterOcrBackend,\n\tunregisterOcrBackend,\n} from \"./ocr/registry.js\";\n\n// Re-export OCR backends\nexport { TesseractWasmBackend } from \"./ocr/tesseract-wasm-backend.js\";\n\n// Re-export runtime utilities\nexport {\n\tdetectRuntime,\n\tgetRuntimeInfo,\n\tgetRuntimeVersion,\n\tgetWasmCapabilities,\n\thasBigInt,\n\thasBlob,\n\thasFileApi,\n\thasModuleWorkers,\n\thasSharedArrayBuffer,\n\thasWasm,\n\thasWasmStreaming,\n\thasWorkers,\n\tisBrowser,\n\tisBun,\n\tisDeno,\n\tisNode,\n\tisServerEnvironment,\n\tisWebEnvironment,\n\ttype RuntimeType,\n\ttype WasmCapabilities,\n} from \"./runtime.js\";\n\n// WASM binding imports (to be populated during build)\n// Type definition for the WASM module interface\ntype WasmModule = {\n\t// Extraction functions\n\textractBytes: (data: Uint8Array, mimeType: string, config: Record<string, unknown> | null) => Promise<unknown>;\n\textractBytesSync: (data: Uint8Array, mimeType: string, config: Record<string, unknown> | null) => unknown;\n\tbatchExtractBytes: (\n\t\tdataList: Uint8Array[],\n\t\tmimeTypes: string[],\n\t\tconfig: Record<string, unknown> | null,\n\t) => Promise<unknown>;\n\tbatchExtractBytesSync: (\n\t\tdataList: Uint8Array[],\n\t\tmimeTypes: string[],\n\t\tconfig: Record<string, unknown> | null,\n\t) => unknown;\n\textractFile: (file: File, mimeType: string | null, config: Record<string, unknown> | null) => Promise<unknown>;\n\tbatchExtractFiles: (files: File[], config: Record<string, unknown> | null) => Promise<unknown>;\n\n\t// MIME and file type utilities\n\tdetectMimeFromBytes: (data: Uint8Array) => string;\n\tnormalizeMimeType: (mimeType: string) => string;\n\tgetMimeFromExtension: (extension: string) => string | null;\n\tgetExtensionsForMime: (mimeType: string) => string[];\n\n\t// Configuration\n\tloadConfigFromString: (content: string, format: string) => Record<string, unknown>;\n\tdiscoverConfig: () => Record<string, unknown>;\n\n\t// Module information\n\tversion: () => string;\n\tget_module_info: () => ModuleInfo;\n\n\t// OCR backend management\n\tregister_ocr_backend: (backend: unknown) => void;\n\tunregister_ocr_backend: (name: string) => void;\n\tlist_ocr_backends: () => string[];\n\tclear_ocr_backends: () => void;\n\n\t// Post-processor management\n\tregister_post_processor: (processor: unknown) => void;\n\tunregister_post_processor: (name: string) => void;\n\tlist_post_processors: () => string[];\n\tclear_post_processors: () => void;\n\n\t// Validator management\n\tregister_validator: (validator: unknown) => void;\n\tunregister_validator: (name: string) => void;\n\tlist_validators: () => string[];\n\tclear_validators: () => void;\n\n\t// PDF/WASM utilities\n\tinitialize_pdfium_render: (pdfiumWasmModule: unknown, localWasmModule: unknown, debug: boolean) => boolean;\n\tread_block_from_callback_wasm: (param: number, position: number, pBuf: number, size: number) => number;\n\twrite_block_from_callback_wasm: (param: number, buf: number, size: number) => number;\n\n\t// Initialization\n\tdefault?: () => Promise<void>;\n};\n\n// ModuleInfo type definition\ntype ModuleInfo = {\n\tname: () => string;\n\tversion: () => string;\n\tfree: () => void;\n};\n\nlet wasm: WasmModule | null = null;\n\n/** Initialize flag */\nlet initialized = false;\n\n/** Initialization error (if any) */\nlet initializationError: Error | null = null;\n\n/** Initialization promise for handling concurrent init calls */\nlet initializationPromise: Promise<void> | null = null;\n\n/**\n * Initialize the WASM module\n *\n * This function must be called once before using any extraction functions.\n * It loads and initializes the WASM module in the current runtime environment,\n * automatically selecting the appropriate WASM variant for the detected runtime.\n *\n * Multiple calls to initWasm() are safe and will return immediately if already initialized.\n *\n * @throws {Error} If WASM module fails to load or is not supported in the current environment\n *\n * @example Basic Usage\n * ```typescript\n * import { initWasm } from '@kreuzberg/wasm';\n *\n * async function main() {\n * await initWasm();\n * // Now you can use extraction functions\n * }\n *\n * main().catch(console.error);\n * ```\n *\n * @example With Error Handling\n * ```typescript\n * import { initWasm, getWasmCapabilities } from '@kreuzberg/wasm';\n *\n * async function initializeKreuzberg() {\n * const caps = getWasmCapabilities();\n * if (!caps.hasWasm) {\n * throw new Error('WebAssembly is not supported in this environment');\n * }\n *\n * try {\n * await initWasm();\n * console.log('Kreuzberg initialized successfully');\n * } catch (error) {\n * console.error('Failed to initialize Kreuzberg:', error);\n * throw error;\n * }\n * }\n * ```\n */\nexport async function initWasm(): Promise<void> {\n\tif (initialized) {\n\t\treturn;\n\t}\n\n\t// Handle concurrent init calls\n\tif (initializationPromise) {\n\t\treturn initializationPromise;\n\t}\n\n\tinitializationPromise = (async () => {\n\t\ttry {\n\t\t\t// Check WASM support\n\t\t\tif (!hasWasm()) {\n\t\t\t\tthrow new Error(\"WebAssembly is not supported in this environment\");\n\t\t\t}\n\n\t\t\t// Dynamic WASM import and initialization\n\t\t\tlet wasmModule: unknown;\n\t\t\ttry {\n\t\t\t\t// Try importing from pkg directory (development/monorepo layout)\n\t\t\t\t// @ts-expect-error - Path may not exist at type-check time\n\t\t\t\twasmModule = await import(\"../../pkg/kreuzberg_wasm\");\n\t\t\t} catch {\n\t\t\t\t// Fallback to dist-relative path (published package layout)\n\t\t\t\t// @ts-expect-error - Dynamic import path\n\t\t\t\twasmModule = await import(\"./kreuzberg_wasm\");\n\t\t\t}\n\t\t\twasm = wasmModule as unknown as WasmModule;\n\n\t\t\t// Call default initialization if available (for some wasm-pack targets)\n\t\t\tif (wasm && typeof wasm.default === \"function\") {\n\t\t\t\tawait wasm.default();\n\t\t\t}\n\n\t\t\tinitialized = true;\n\t\t\tinitializationError = null;\n\t\t} catch (error) {\n\t\t\tinitializationError = error instanceof Error ? error : new Error(String(error));\n\t\t\tthrow wrapWasmError(error, \"initializing Kreuzberg WASM module\");\n\t\t}\n\t})();\n\n\treturn initializationPromise;\n}\n\n/**\n * Check if WASM module is initialized\n *\n * @returns True if WASM module is initialized, false otherwise\n *\n * @example\n * ```typescript\n * if (!isInitialized()) {\n * await initWasm();\n * }\n * ```\n */\nexport function isInitialized(): boolean {\n\treturn initialized;\n}\n\n/**\n * Get WASM module version\n *\n * @throws {Error} If WASM module is not initialized\n * @returns The version string of the WASM module\n *\n * @example\n * ```typescript\n * const version = getVersion();\n * console.log(`Using Kreuzberg ${version}`);\n * ```\n */\nexport function getVersion(): string {\n\tif (!initialized) {\n\t\tthrow new Error(\"WASM module not initialized. Call initWasm() first.\");\n\t}\n\n\tif (!wasm) {\n\t\tthrow new Error(\"WASM module not loaded. Call initWasm() first.\");\n\t}\n\n\treturn wasm.version();\n}\n\n/**\n * Get initialization error if module failed to load\n *\n * @returns The error that occurred during initialization, or null if no error\n *\n * @internal\n */\nexport function getInitializationError(): Error | null {\n\treturn initializationError;\n}\n\n/**\n * Extract content from bytes (document data)\n *\n * Extracts text, metadata, tables, images, and other content from document bytes.\n * Automatically detects document type from MIME type and applies appropriate extraction logic.\n *\n * @param data - The document bytes to extract from\n * @param mimeType - MIME type of the document (e.g., 'application/pdf', 'image/jpeg')\n * @param config - Optional extraction configuration\n * @returns Promise resolving to the extraction result\n * @throws {Error} If WASM module is not initialized or extraction fails\n *\n * @example Extract PDF\n * ```typescript\n * const bytes = new Uint8Array(buffer);\n * const result = await extractBytes(bytes, 'application/pdf');\n * console.log(result.content);\n * console.log(result.tables);\n * ```\n *\n * @example Extract with Configuration\n * ```typescript\n * const result = await extractBytes(bytes, 'application/pdf', {\n * ocr: {\n * backend: 'tesseract',\n * language: 'deu' // German\n * },\n * images: {\n * extractImages: true,\n * targetDpi: 200\n * }\n * });\n * ```\n *\n * @example Extract from File\n * ```typescript\n * const file = inputEvent.target.files[0];\n * const bytes = await fileToUint8Array(file);\n * const result = await extractBytes(bytes, file.type);\n * ```\n */\nexport async function extractBytes(\n\tdata: Uint8Array,\n\tmimeType: string,\n\tconfig?: ExtractionConfigType | null,\n): Promise<ExtractionResult> {\n\tif (!initialized) {\n\t\tthrow new Error(\"WASM module not initialized. Call initWasm() first.\");\n\t}\n\n\tif (!wasm) {\n\t\tthrow new Error(\"WASM module not loaded. Call initWasm() first.\");\n\t}\n\n\ttry {\n\t\t// Validate input\n\t\tif (!data || data.length === 0) {\n\t\t\tthrow new Error(\"Document data cannot be empty\");\n\t\t}\n\n\t\tif (!mimeType) {\n\t\t\tthrow new Error(\"MIME type is required\");\n\t\t}\n\n\t\t// Normalize config for WASM\n\t\tconst normalizedConfig = configToJS(config ?? null);\n\n\t\t// Call WASM function\n\t\tconst result = await wasm.extractBytes(data, mimeType, normalizedConfig);\n\n\t\t// Validate result\n\t\tif (!result) {\n\t\t\tthrow new Error(\"Invalid extraction result: no result from WASM module\");\n\t\t}\n\n\t\t// Convert and return result\n\t\treturn jsToExtractionResult(result);\n\t} catch (error) {\n\t\tthrow wrapWasmError(error, \"extracting from bytes\");\n\t}\n}\n\n/**\n * Extract content from a file on the file system\n *\n * Node.js and Deno specific function that reads a file from the file system\n * and extracts content from it. Automatically detects MIME type if not provided.\n *\n * @param path - Path to the file to extract from\n * @param mimeType - Optional MIME type of the file. If not provided, will attempt to detect\n * @param config - Optional extraction configuration\n * @returns Promise resolving to the extraction result\n * @throws {Error} If WASM module is not initialized, file doesn't exist, or extraction fails\n *\n * @example Extract with auto-detection\n * ```typescript\n * const result = await extractFile('./document.pdf');\n * console.log(result.content);\n * ```\n *\n * @example Extract with explicit MIME type\n * ```typescript\n * const result = await extractFile('./document.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document');\n * ```\n *\n * @example Extract from Node.js with config\n * ```typescript\n * import { extractFile } from '@kreuzberg/wasm';\n * import { readFile } from 'fs/promises';\n *\n * const result = await extractFile('./report.xlsx', null, {\n * chunking: {\n * maxChars: 1000\n * }\n * });\n * ```\n */\nexport async function extractFile(\n\tpath: string,\n\tmimeType?: string | null,\n\tconfig?: ExtractionConfigType | null,\n): Promise<ExtractionResult> {\n\tif (!initialized) {\n\t\tthrow new Error(\"WASM module not initialized. Call initWasm() first.\");\n\t}\n\n\tif (!wasm) {\n\t\tthrow new Error(\"WASM module not loaded. Call initWasm() first.\");\n\t}\n\n\ttry {\n\t\tif (!path) {\n\t\t\tthrow new Error(\"File path is required\");\n\t\t}\n\n\t\t// This function is only suitable for Node.js/Deno/Bun environments\n\t\t// Browser environments should use extractBytes with fileToUint8Array\n\t\tconst runtime = detectRuntime();\n\t\tif (runtime === \"browser\") {\n\t\t\tthrow new Error(\"Use extractBytes with fileToUint8Array for browser environments\");\n\t\t}\n\n\t\t// Read file based on runtime\n\t\tlet fileData: Uint8Array;\n\n\t\tif (runtime === \"node\") {\n\t\t\t// Node.js: use dynamic import to avoid issues in non-Node.js environments\n\t\t\tconst { readFile } = await import(\"node:fs/promises\");\n\t\t\tconst buffer = await readFile(path);\n\t\t\tfileData = new Uint8Array(buffer);\n\t\t} else if (runtime === \"deno\") {\n\t\t\t// Deno: use Deno.readFile\n\t\t\tconst deno = (globalThis as Record<string, unknown>).Deno as {\n\t\t\t\treadFile: (path: string) => Promise<Uint8Array>;\n\t\t\t};\n\t\t\tfileData = await deno.readFile(path);\n\t\t} else if (runtime === \"bun\") {\n\t\t\t// Bun: use dynamic import for fs/promises (compatible with Node.js API)\n\t\t\tconst { readFile } = await import(\"node:fs/promises\");\n\t\t\tconst buffer = await readFile(path);\n\t\t\tfileData = new Uint8Array(buffer);\n\t\t} else {\n\t\t\tthrow new Error(`Unsupported runtime for file extraction: ${runtime}`);\n\t\t}\n\n\t\t// Detect MIME type if not provided\n\t\tlet detectedMimeType = mimeType;\n\t\tif (!detectedMimeType) {\n\t\t\tdetectedMimeType = wasm.detectMimeFromBytes(fileData);\n\t\t}\n\n\t\tif (!detectedMimeType) {\n\t\t\tthrow new Error(\"Could not detect MIME type for file. Please provide mimeType parameter.\");\n\t\t}\n\n\t\t// Normalize MIME type\n\t\tdetectedMimeType = wasm.normalizeMimeType(detectedMimeType);\n\n\t\t// Call extractBytes with the file contents\n\t\treturn await extractBytes(fileData, detectedMimeType, config);\n\t} catch (error) {\n\t\tthrow wrapWasmError(error, `extracting from file: ${path}`);\n\t}\n}\n\n/**\n * Extract content from a File or Blob (browser-friendly wrapper)\n *\n * Convenience function that wraps fileToUint8Array and extractBytes,\n * providing a streamlined API for browser applications handling file inputs.\n *\n * @param file - The File or Blob to extract from\n * @param mimeType - Optional MIME type. If not provided, uses file.type if available\n * @param config - Optional extraction configuration\n * @returns Promise resolving to the extraction result\n * @throws {Error} If WASM module is not initialized or extraction fails\n *\n * @example Simple file extraction\n * ```typescript\n * const fileInput = document.getElementById('file');\n * fileInput.addEventListener('change', async (e) => {\n * const file = e.target.files?.[0];\n * if (file) {\n * const result = await extractFromFile(file);\n * console.log(result.content);\n * }\n * });\n * ```\n *\n * @example With configuration\n * ```typescript\n * const result = await extractFromFile(file, file.type, {\n * chunking: { maxChars: 1000 },\n * images: { extractImages: true }\n * });\n * ```\n */\nexport async function extractFromFile(\n\tfile: File | Blob,\n\tmimeType?: string | null,\n\tconfig?: ExtractionConfigType | null,\n): Promise<ExtractionResult> {\n\tif (!initialized) {\n\t\tthrow new Error(\"WASM module not initialized. Call initWasm() first.\");\n\t}\n\n\tif (!wasm) {\n\t\tthrow new Error(\"WASM module not loaded. Call initWasm() first.\");\n\t}\n\n\ttry {\n\t\tconst bytes = await fileToUint8Array(file);\n\t\tlet type = mimeType ?? (file instanceof File ? file.type : \"application/octet-stream\");\n\n\t\t// Normalize MIME type\n\t\ttype = wasm.normalizeMimeType(type);\n\n\t\treturn await extractBytes(bytes, type, config);\n\t} catch (error) {\n\t\tthrow wrapWasmError(error, `extracting from ${file instanceof File ? \"file\" : \"blob\"}`);\n\t}\n}\n\n/**\n * Extract content from bytes synchronously\n *\n * Synchronous version of extractBytes. Performs extraction without async operations.\n * Note: Some extraction features may still be async internally, but the wrapper is synchronous.\n *\n * @param data - The document bytes to extract from\n * @param mimeType - MIME type of the document\n * @param config - Optional extraction configuration\n * @returns The extraction result\n * @throws {Error} If WASM module is not initialized or extraction fails\n *\n * @example\n * ```typescript\n * const bytes = new Uint8Array(buffer);\n * const result = extractBytesSync(bytes, 'application/pdf');\n * console.log(result.content);\n * ```\n */\nexport function extractBytesSync(\n\tdata: Uint8Array,\n\tmimeType: string,\n\tconfig?: ExtractionConfigType | null,\n): ExtractionResult {\n\tif (!initialized) {\n\t\tthrow new Error(\"WASM module not initialized. Call initWasm() first.\");\n\t}\n\n\tif (!wasm) {\n\t\tthrow new Error(\"WASM module not loaded. Call initWasm() first.\");\n\t}\n\n\ttry {\n\t\t// Validate input\n\t\tif (!data || data.length === 0) {\n\t\t\tthrow new Error(\"Document data cannot be empty\");\n\t\t}\n\n\t\tif (!mimeType) {\n\t\t\tthrow new Error(\"MIME type is required\");\n\t\t}\n\n\t\t// Normalize config for WASM\n\t\tconst normalizedConfig = configToJS(config ?? null);\n\n\t\t// Call WASM function\n\t\tconst result = wasm.extractBytesSync(data, mimeType, normalizedConfig);\n\n\t\t// Validate result\n\t\tif (!result) {\n\t\t\tthrow new Error(\"Invalid extraction result: no result from WASM module\");\n\t\t}\n\n\t\t// Convert and return result\n\t\treturn jsToExtractionResult(result);\n\t} catch (error) {\n\t\tthrow wrapWasmError(error, \"extracting from bytes (sync)\");\n\t}\n}\n\n/**\n * Batch extract content from multiple byte arrays asynchronously\n *\n * Extracts content from multiple documents in a single batch operation,\n * allowing for more efficient processing of multiple files.\n *\n * @param files - Array of objects containing data (Uint8Array) and mimeType (string)\n * @param config - Optional extraction configuration applied to all files\n * @returns Promise resolving to array of extraction results\n * @throws {Error} If WASM module is not initialized or extraction fails\n *\n * @example\n * ```typescript\n * const files = [\n * { data: pdfBytes, mimeType: 'application/pdf' },\n * { data: docxBytes, mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' }\n * ];\n * const results = await batchExtractBytes(files);\n * results.forEach((result) => console.log(result.content));\n * ```\n */\nexport async function batchExtractBytes(\n\tfiles: Array<{ data: Uint8Array; mimeType: string }>,\n\tconfig?: ExtractionConfigType | null,\n): Promise<ExtractionResult[]> {\n\tif (!initialized) {\n\t\tthrow new Error(\"WASM module not initialized. Call initWasm() first.\");\n\t}\n\n\tif (!wasm) {\n\t\tthrow new Error(\"WASM module not loaded. Call initWasm() first.\");\n\t}\n\n\ttry {\n\t\t// Validate input\n\t\tif (!Array.isArray(files)) {\n\t\t\tthrow new Error(\"Files parameter must be an array\");\n\t\t}\n\n\t\tif (files.length === 0) {\n\t\t\tthrow new Error(\"Files array cannot be empty\");\n\t\t}\n\n\t\t// Extract data arrays and MIME types\n\t\tconst dataList: Uint8Array[] = [];\n\t\tconst mimeTypes: string[] = [];\n\n\t\tfor (let i = 0; i < files.length; i += 1) {\n\t\t\tconst file = files[i];\n\t\t\tif (!file || typeof file !== \"object\") {\n\t\t\t\tthrow new Error(`Invalid file at index ${i}: must be an object with data and mimeType`);\n\t\t\t}\n\n\t\t\tconst f = file as Record<string, unknown>;\n\n\t\t\tif (!(f.data instanceof Uint8Array)) {\n\t\t\t\tthrow new Error(`Invalid file at index ${i}: data must be Uint8Array`);\n\t\t\t}\n\n\t\t\tif (typeof f.mimeType !== \"string\") {\n\t\t\t\tthrow new Error(`Invalid file at index ${i}: mimeType must be a string`);\n\t\t\t}\n\n\t\t\tif (f.data.length === 0) {\n\t\t\t\tthrow new Error(`Invalid file at index ${i}: data cannot be empty`);\n\t\t\t}\n\n\t\t\tdataList.push(f.data);\n\t\t\tmimeTypes.push(f.mimeType);\n\t\t}\n\n\t\t// Normalize config for WASM\n\t\tconst normalizedConfig = configToJS(config ?? null);\n\n\t\t// Call WASM function\n\t\tconst results = await wasm.batchExtractBytes(dataList, mimeTypes, normalizedConfig);\n\n\t\t// Validate results\n\t\tif (!Array.isArray(results)) {\n\t\t\tthrow new Error(\"Invalid batch extraction result: expected array\");\n\t\t}\n\n\t\t// Convert each result\n\t\treturn results.map((result, index) => {\n\t\t\tif (!result) {\n\t\t\t\tthrow new Error(`Invalid extraction result at index ${index}: no result from WASM module`);\n\t\t\t}\n\n\t\t\treturn jsToExtractionResult(result);\n\t\t});\n\t} catch (error) {\n\t\tthrow wrapWasmError(error, \"batch extracting from bytes\");\n\t}\n}\n\n/**\n * Batch extract content from multiple byte arrays synchronously\n *\n * Synchronous version of batchExtractBytes. Extracts content from multiple documents\n * in a single batch operation without async operations.\n *\n * @param files - Array of objects containing data (Uint8Array) and mimeType (string)\n * @param config - Optional extraction configuration applied to all files\n * @returns Array of extraction results\n * @throws {Error} If WASM module is not initialized or extraction fails\n *\n * @example\n * ```typescript\n * const files = [\n * { data: pdfBytes, mimeType: 'application/pdf' },\n * { data: docxBytes, mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' }\n * ];\n * const results = batchExtractBytesSync(files);\n * results.forEach((result) => console.log(result.content));\n * ```\n */\nexport function batchExtractBytesSync(\n\tfiles: Array<{ data: Uint8Array; mimeType: string }>,\n\tconfig?: ExtractionConfigType | null,\n): ExtractionResult[] {\n\tif (!initialized) {\n\t\tthrow new Error(\"WASM module not initialized. Call initWasm() first.\");\n\t}\n\n\tif (!wasm) {\n\t\tthrow new Error(\"WASM module not loaded. Call initWasm() first.\");\n\t}\n\n\ttry {\n\t\t// Validate input\n\t\tif (!Array.isArray(files)) {\n\t\t\tthrow new Error(\"Files parameter must be an array\");\n\t\t}\n\n\t\tif (files.length === 0) {\n\t\t\tthrow new Error(\"Files array cannot be empty\");\n\t\t}\n\n\t\t// Extract data arrays and MIME types\n\t\tconst dataList: Uint8Array[] = [];\n\t\tconst mimeTypes: string[] = [];\n\n\t\tfor (let i = 0; i < files.length; i += 1) {\n\t\t\tconst file = files[i];\n\t\t\tif (!file || typeof file !== \"object\") {\n\t\t\t\tthrow new Error(`Invalid file at index ${i}: must be an object with data and mimeType`);\n\t\t\t}\n\n\t\t\tconst f = file as Record<string, unknown>;\n\n\t\t\tif (!(f.data instanceof Uint8Array)) {\n\t\t\t\tthrow new Error(`Invalid file at index ${i}: data must be Uint8Array`);\n\t\t\t}\n\n\t\t\tif (typeof f.mimeType !== \"string\") {\n\t\t\t\tthrow new Error(`Invalid file at index ${i}: mimeType must be a string`);\n\t\t\t}\n\n\t\t\tif (f.data.length === 0) {\n\t\t\t\tthrow new Error(`Invalid file at index ${i}: data cannot be empty`);\n\t\t\t}\n\n\t\t\tdataList.push(f.data);\n\t\t\tmimeTypes.push(f.mimeType);\n\t\t}\n\n\t\t// Normalize config for WASM\n\t\tconst normalizedConfig = configToJS(config ?? null);\n\n\t\t// Call WASM function\n\t\tconst results = wasm.batchExtractBytesSync(dataList, mimeTypes, normalizedConfig);\n\n\t\t// Validate results\n\t\tif (!Array.isArray(results)) {\n\t\t\tthrow new Error(\"Invalid batch extraction result: expected array\");\n\t\t}\n\n\t\t// Convert each result\n\t\treturn results.map((result, index) => {\n\t\t\tif (!result) {\n\t\t\t\tthrow new Error(`Invalid extraction result at index ${index}: no result from WASM module`);\n\t\t\t}\n\n\t\t\treturn jsToExtractionResult(result);\n\t\t});\n\t} catch (error) {\n\t\tthrow wrapWasmError(error, \"batch extracting from bytes (sync)\");\n\t}\n}\n\n/**\n * Batch extract content from multiple File objects asynchronously\n *\n * Convenience function that converts File objects to Uint8Array and calls batchExtractBytes.\n * Automatically uses the file.type as MIME type if available.\n *\n * @param files - Array of File objects to extract from\n * @param config - Optional extraction configuration applied to all files\n * @returns Promise resolving to array of extraction results\n * @throws {Error} If WASM module is not initialized, files cannot be read, or extraction fails\n *\n * @example\n * ```typescript\n * const fileInput = document.getElementById('files');\n * const files = Array.from(fileInput.files ?? []);\n * const results = await batchExtractFiles(files);\n * results.forEach((result, index) => {\n * console.log(`File ${index}: ${result.content.substring(0, 50)}...`);\n * });\n * ```\n */\nexport async function batchExtractFiles(\n\tfiles: File[],\n\tconfig?: ExtractionConfigType | null,\n): Promise<ExtractionResult[]> {\n\tif (!initialized) {\n\t\tthrow new Error(\"WASM module not initialized. Call initWasm() first.\");\n\t}\n\n\ttry {\n\t\t// Validate input\n\t\tif (!Array.isArray(files)) {\n\t\t\tthrow new Error(\"Files parameter must be an array\");\n\t\t}\n\n\t\tif (files.length === 0) {\n\t\t\tthrow new Error(\"Files array cannot be empty\");\n\t\t}\n\n\t\t// Convert all files to Uint8Array and collect MIME types\n\t\tconst byteFiles: Array<{ data: Uint8Array; mimeType: string }> = [];\n\n\t\tfor (let i = 0; i < files.length; i += 1) {\n\t\t\tconst file = files[i];\n\t\t\tif (!(file instanceof File)) {\n\t\t\t\tthrow new Error(`Invalid file at index ${i}: must be a File object`);\n\t\t\t}\n\n\t\t\tconst bytes = await fileToUint8Array(file);\n\t\t\tbyteFiles.push({\n\t\t\t\tdata: bytes,\n\t\t\t\tmimeType: file.type || \"application/octet-stream\",\n\t\t\t});\n\t\t}\n\n\t\t// Call batchExtractBytes with converted files\n\t\treturn await batchExtractBytes(byteFiles, config);\n\t} catch (error) {\n\t\tthrow wrapWasmError(error, \"batch extracting from files\");\n\t}\n}\n\n/**\n * Enable OCR functionality with tesseract-wasm backend\n *\n * Convenience function that automatically initializes and registers the Tesseract WASM backend.\n * This is the recommended approach for enabling OCR in WASM-based applications.\n *\n * ## Browser Requirement\n *\n * This function requires a browser environment with support for:\n * - WebWorkers (for Tesseract processing)\n * - createImageBitmap (for image conversion)\n * - Blob API\n *\n * ## Network Requirement\n *\n * Training data will be loaded from jsDelivr CDN on first use of each language.\n * Ensure network access to cdn.jsdelivr.net is available.\n *\n * @throws {Error} If not in browser environment or tesseract-wasm is not available\n *\n * @example Basic Usage\n * ```typescript\n * import { enableOcr, extractBytes, initWasm } from '@kreuzberg/wasm';\n *\n * async function main() {\n * // Initialize WASM module\n * await initWasm();\n *\n * // Enable OCR with tesseract-wasm\n * await enableOcr();\n *\n * // Now you can use OCR in extraction\n * const imageBytes = new Uint8Array(buffer);\n * const result = await extractBytes(imageBytes, 'image/png', {\n * ocr: { backend: 'tesseract-wasm', language: 'eng' }\n * });\n *\n * console.log(result.content); // Extracted text\n * }\n *\n * main().catch(console.error);\n * ```\n *\n * @example With Progress Tracking\n * ```typescript\n * import { enableOcr, TesseractWasmBackend } from '@kreuzberg/wasm';\n *\n * async function setupOcrWithProgress() {\n * const backend = new TesseractWasmBackend();\n * backend.setProgressCallback((progress) => {\n * console.log(`OCR Progress: ${progress}%`);\n * updateProgressBar(progress);\n * });\n *\n * await backend.initialize();\n * registerOcrBackend(backend);\n * }\n *\n * setupOcrWithProgress().catch(console.error);\n * ```\n *\n * @example Multiple Languages\n * ```typescript\n * import { enableOcr, extractBytes, initWasm } from '@kreuzberg/wasm';\n *\n * await initWasm();\n * await enableOcr();\n *\n * // Extract English text\n * const englishResult = await extractBytes(engImageBytes, 'image/png', {\n * ocr: { backend: 'tesseract-wasm', language: 'eng' }\n * });\n *\n * // Extract German text - model is cached after first use\n * const germanResult = await extractBytes(deImageBytes, 'image/png', {\n * ocr: { backend: 'tesseract-wasm', language: 'deu' }\n * });\n * ```\n */\nexport async function enableOcr(): Promise<void> {\n\t// Check if WASM module is initialized\n\tif (!initialized) {\n\t\tthrow new Error(\"WASM module not initialized. Call initWasm() first.\");\n\t}\n\n\t// Check if in browser environment\n\tif (!isBrowser()) {\n\t\tthrow new Error(\n\t\t\t\"OCR is only available in browser environments. TesseractWasmBackend requires Web Workers and createImageBitmap.\",\n\t\t);\n\t}\n\n\ttry {\n\t\t// Create and initialize backend\n\t\tconst backend = new TesseractWasmBackend();\n\t\tawait backend.initialize();\n\n\t\t// Register the backend\n\t\tregisterOcrBackend(backend);\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(`Failed to enable OCR: ${message}`);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkGA,0BAAkF;A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