@kreuzberg/node 4.0.0-rc.22 → 4.0.0-rc.24

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/index.d.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
+ /** Opaque handle to a worker pool */
4
+ export declare class JsWorkerPool {
5
+
6
+ }
7
+
3
8
  /**
4
9
  * Batch extract from multiple byte arrays (asynchronous).
5
10
  *
@@ -96,6 +101,40 @@ export declare function batchExtractBytesSync(dataList: Array<Buffer>, mimeTypes
96
101
  */
97
102
  export declare function batchExtractFiles(paths: Array<string>, config?: JsExtractionConfig | undefined | null): Promise<Array<JsExtractionResult>>
98
103
 
104
+ /**
105
+ * Extract multiple files using worker threads from the pool.
106
+ *
107
+ * Submits multiple file extraction tasks to the worker pool for concurrent
108
+ * processing. Files are processed in parallel up to the pool size limit.
109
+ *
110
+ * # Parameters
111
+ *
112
+ * * `pool` - Worker pool handle
113
+ * * `file_paths` - Array of file paths to extract
114
+ * * `config` - Optional extraction configuration applied to all files
115
+ *
116
+ * # Returns
117
+ *
118
+ * Promise resolving to array of extraction results in the same order as input paths.
119
+ *
120
+ * # Example
121
+ *
122
+ * ```typescript
123
+ * import { createWorkerPool, batchExtractFilesInWorker } from '@kreuzberg/node';
124
+ *
125
+ * const pool = createWorkerPool(4);
126
+ * const files = ['doc1.pdf', 'doc2.docx', 'doc3.xlsx'];
127
+ * const results = await batchExtractFilesInWorker(pool, files, {
128
+ * useCache: true
129
+ * });
130
+ *
131
+ * results.forEach((result, i) => {
132
+ * console.log(`File ${i + 1}: ${result.content.length} chars`);
133
+ * });
134
+ * ```
135
+ */
136
+ export declare function batchExtractFilesInWorker(pool: JsWorkerPool, filePaths: Array<string>, config?: JsExtractionConfig | undefined | null): Promise<Array<JsExtractionResult>>
137
+
99
138
  /**
100
139
  * Batch extract from multiple files (synchronous).
101
140
  *
@@ -167,6 +206,32 @@ export declare function clearPostProcessors(): void
167
206
  /** Clear all registered validators */
168
207
  export declare function clearValidators(): void
169
208
 
209
+ /**
210
+ * Close and shutdown a worker pool gracefully.
211
+ *
212
+ * Waits for all in-flight extraction tasks to complete before shutting down
213
+ * the pool. After calling this function, the pool handle becomes invalid.
214
+ *
215
+ * # Parameters
216
+ *
217
+ * * `pool` - Worker pool handle
218
+ *
219
+ * # Returns
220
+ *
221
+ * Promise that resolves when all workers have completed and pool is closed.
222
+ *
223
+ * # Example
224
+ *
225
+ * ```typescript
226
+ * import { createWorkerPool, closeWorkerPool } from '@kreuzberg/node';
227
+ *
228
+ * const pool = createWorkerPool(4);
229
+ * // ... use pool for extractions ...
230
+ * await closeWorkerPool(pool); // Wait for completion and cleanup
231
+ * ```
232
+ */
233
+ export declare function closeWorkerPool(pool: JsWorkerPool): Promise<void>
234
+
170
235
  /**
171
236
  * Get a specific field from config (represented as JSON string) by name via FFI.
172
237
  *
@@ -217,6 +282,31 @@ export declare function configMergeInternal(baseJson: string, overrideJson: stri
217
282
  */
218
283
  export declare function configValidateAndNormalize(jsonStr: string): string
219
284
 
285
+ /**
286
+ * Create a new worker pool for concurrent extraction operations.
287
+ *
288
+ * Creates a pool of worker threads for CPU-bound document extraction.
289
+ * Tasks submitted to the pool will be executed concurrently up to the pool size.
290
+ *
291
+ * # Parameters
292
+ *
293
+ * * `size` - Number of concurrent workers (defaults to CPU count)
294
+ *
295
+ * # Returns
296
+ *
297
+ * Worker pool handle that can be used with extraction functions.
298
+ *
299
+ * # Example
300
+ *
301
+ * ```typescript
302
+ * import { createWorkerPool } from '@kreuzberg/node';
303
+ *
304
+ * const pool = createWorkerPool(4); // 4 concurrent workers
305
+ * console.log(`Pool created with ${pool.size} workers`);
306
+ * ```
307
+ */
308
+ export declare function createWorkerPool(size?: number | undefined | null): JsWorkerPool
309
+
220
310
  /**
221
311
  * Detect MIME type from raw bytes.
222
312
  *
@@ -482,6 +572,38 @@ export declare function extractBytesSync(data: Buffer, mimeType: string, config?
482
572
  */
483
573
  export declare function extractFile(filePath: string, mimeType?: string | undefined | null, config?: JsExtractionConfig | undefined | null): Promise<JsExtractionResult>
484
574
 
575
+ /**
576
+ * Extract a file using a worker thread from the pool.
577
+ *
578
+ * Submits a file extraction task to the worker pool. The task will execute
579
+ * when a worker thread becomes available. This is useful for CPU-bound
580
+ * extraction operations that need to be run concurrently.
581
+ *
582
+ * # Parameters
583
+ *
584
+ * * `pool` - Worker pool handle
585
+ * * `file_path` - Path to the file to extract
586
+ * * `password` - Optional password for encrypted files
587
+ * * `config` - Optional extraction configuration
588
+ *
589
+ * # Returns
590
+ *
591
+ * Promise resolving to extraction result.
592
+ *
593
+ * # Example
594
+ *
595
+ * ```typescript
596
+ * import { createWorkerPool, extractFileInWorker } from '@kreuzberg/node';
597
+ *
598
+ * const pool = createWorkerPool(4);
599
+ * const result = await extractFileInWorker(pool, 'document.pdf', null, {
600
+ * useCache: true
601
+ * });
602
+ * console.log(result.content);
603
+ * ```
604
+ */
605
+ export declare function extractFileInWorker(pool: JsWorkerPool, filePath: string, password?: string | undefined | null, config?: JsExtractionConfig | undefined | null): Promise<JsExtractionResult>
606
+
485
607
  /**
486
608
  * Extract content from a file (synchronous).
487
609
  *
@@ -805,6 +927,32 @@ export declare function getValidOcrBackends(): Array<string>
805
927
  */
806
928
  export declare function getValidTokenReductionLevels(): Array<string>
807
929
 
930
+ /**
931
+ * Get worker pool statistics.
932
+ *
933
+ * Returns current statistics about the worker pool including size,
934
+ * active workers, and queued tasks.
935
+ *
936
+ * # Parameters
937
+ *
938
+ * * `pool` - Worker pool handle
939
+ *
940
+ * # Returns
941
+ *
942
+ * Pool statistics object with size, activeWorkers, and queuedTasks fields.
943
+ *
944
+ * # Example
945
+ *
946
+ * ```typescript
947
+ * import { createWorkerPool, getWorkerPoolStats } from '@kreuzberg/node';
948
+ *
949
+ * const pool = createWorkerPool(4);
950
+ * const stats = getWorkerPoolStats(pool);
951
+ * console.log(`Active: ${stats.activeWorkers}/${stats.size}`);
952
+ * ```
953
+ */
954
+ export declare function getWorkerPoolStats(pool: JsWorkerPool): WorkerPoolStats
955
+
808
956
  export interface JsChunk {
809
957
  content: string
810
958
  embedding?: number[] | undefined
@@ -900,6 +1048,21 @@ export interface JsExtractionResult {
900
1048
  detectedLanguages?: Array<string>
901
1049
  chunks?: Array<JsChunk>
902
1050
  images?: Array<JsExtractedImage>
1051
+ pages?: Array<JsPageContent>
1052
+ }
1053
+
1054
+ export interface JsHierarchicalBlock {
1055
+ text: string
1056
+ fontSize: number
1057
+ level: string
1058
+ bbox?: [number, number, number, number] | undefined
1059
+ }
1060
+
1061
+ export interface JsHierarchyConfig {
1062
+ enabled?: boolean
1063
+ kClusters?: number
1064
+ includeBbox?: boolean
1065
+ ocrCoverageThreshold?: number
903
1066
  }
904
1067
 
905
1068
  export interface JsHtmlOptions {
@@ -980,10 +1143,24 @@ export interface JsPageConfig {
980
1143
  markerFormat?: string
981
1144
  }
982
1145
 
1146
+ export interface JsPageContent {
1147
+ pageNumber: number
1148
+ content: string
1149
+ tables: Array<JsTable>
1150
+ images: Array<JsExtractedImage>
1151
+ hierarchy?: JsPageHierarchy
1152
+ }
1153
+
1154
+ export interface JsPageHierarchy {
1155
+ blockCount: number
1156
+ blocks: Array<JsHierarchicalBlock>
1157
+ }
1158
+
983
1159
  export interface JsPdfConfig {
984
1160
  extractImages?: boolean
985
1161
  passwords?: Array<string>
986
1162
  extractMetadata?: boolean
1163
+ hierarchy?: JsHierarchyConfig
987
1164
  }
988
1165
 
989
1166
  export interface JsPostProcessorConfig {
@@ -1594,3 +1771,9 @@ export declare function validateTesseractPsm(psm: number): boolean
1594
1771
  * ```
1595
1772
  */
1596
1773
  export declare function validateTokenReductionLevel(level: string): boolean
1774
+
1775
+ export interface WorkerPoolStats {
1776
+ size: number
1777
+ activeWorkers: number
1778
+ queuedTasks: number
1779
+ }
package/index.js CHANGED
@@ -77,8 +77,8 @@ function requireNative() {
77
77
  try {
78
78
  const binding = require('@kreuzberg/node-android-arm64')
79
79
  const bindingPackageVersion = require('@kreuzberg/node-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
82
  }
83
83
  return binding
84
84
  } catch (e) {
@@ -93,8 +93,8 @@ function requireNative() {
93
93
  try {
94
94
  const binding = require('@kreuzberg/node-android-arm-eabi')
95
95
  const bindingPackageVersion = require('@kreuzberg/node-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
98
  }
99
99
  return binding
100
100
  } catch (e) {
@@ -114,8 +114,8 @@ function requireNative() {
114
114
  try {
115
115
  const binding = require('@kreuzberg/node-win32-x64-gnu')
116
116
  const bindingPackageVersion = require('@kreuzberg/node-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
119
  }
120
120
  return binding
121
121
  } catch (e) {
@@ -130,8 +130,8 @@ function requireNative() {
130
130
  try {
131
131
  const binding = require('@kreuzberg/node-win32-x64-msvc')
132
132
  const bindingPackageVersion = require('@kreuzberg/node-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
135
  }
136
136
  return binding
137
137
  } catch (e) {
@@ -147,8 +147,8 @@ function requireNative() {
147
147
  try {
148
148
  const binding = require('@kreuzberg/node-win32-ia32-msvc')
149
149
  const bindingPackageVersion = require('@kreuzberg/node-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
152
  }
153
153
  return binding
154
154
  } catch (e) {
@@ -163,8 +163,8 @@ function requireNative() {
163
163
  try {
164
164
  const binding = require('@kreuzberg/node-win32-arm64-msvc')
165
165
  const bindingPackageVersion = require('@kreuzberg/node-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
168
  }
169
169
  return binding
170
170
  } catch (e) {
@@ -182,8 +182,8 @@ function requireNative() {
182
182
  try {
183
183
  const binding = require('@kreuzberg/node-darwin-universal')
184
184
  const bindingPackageVersion = require('@kreuzberg/node-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
187
  }
188
188
  return binding
189
189
  } catch (e) {
@@ -198,8 +198,8 @@ function requireNative() {
198
198
  try {
199
199
  const binding = require('@kreuzberg/node-darwin-x64')
200
200
  const bindingPackageVersion = require('@kreuzberg/node-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
203
  }
204
204
  return binding
205
205
  } catch (e) {
@@ -214,8 +214,8 @@ function requireNative() {
214
214
  try {
215
215
  const binding = require('@kreuzberg/node-darwin-arm64')
216
216
  const bindingPackageVersion = require('@kreuzberg/node-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
219
  }
220
220
  return binding
221
221
  } catch (e) {
@@ -234,8 +234,8 @@ function requireNative() {
234
234
  try {
235
235
  const binding = require('@kreuzberg/node-freebsd-x64')
236
236
  const bindingPackageVersion = require('@kreuzberg/node-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
239
  }
240
240
  return binding
241
241
  } catch (e) {
@@ -250,8 +250,8 @@ function requireNative() {
250
250
  try {
251
251
  const binding = require('@kreuzberg/node-freebsd-arm64')
252
252
  const bindingPackageVersion = require('@kreuzberg/node-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
255
  }
256
256
  return binding
257
257
  } catch (e) {
@@ -271,8 +271,8 @@ function requireNative() {
271
271
  try {
272
272
  const binding = require('@kreuzberg/node-linux-x64-musl')
273
273
  const bindingPackageVersion = require('@kreuzberg/node-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
276
  }
277
277
  return binding
278
278
  } catch (e) {
@@ -287,8 +287,8 @@ function requireNative() {
287
287
  try {
288
288
  const binding = require('@kreuzberg/node-linux-x64-gnu')
289
289
  const bindingPackageVersion = require('@kreuzberg/node-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
292
  }
293
293
  return binding
294
294
  } catch (e) {
@@ -305,8 +305,8 @@ function requireNative() {
305
305
  try {
306
306
  const binding = require('@kreuzberg/node-linux-arm64-musl')
307
307
  const bindingPackageVersion = require('@kreuzberg/node-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
310
  }
311
311
  return binding
312
312
  } catch (e) {
@@ -321,8 +321,8 @@ function requireNative() {
321
321
  try {
322
322
  const binding = require('@kreuzberg/node-linux-arm64-gnu')
323
323
  const bindingPackageVersion = require('@kreuzberg/node-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
326
  }
327
327
  return binding
328
328
  } catch (e) {
@@ -339,8 +339,8 @@ function requireNative() {
339
339
  try {
340
340
  const binding = require('@kreuzberg/node-linux-arm-musleabihf')
341
341
  const bindingPackageVersion = require('@kreuzberg/node-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
344
  }
345
345
  return binding
346
346
  } catch (e) {
@@ -355,8 +355,8 @@ function requireNative() {
355
355
  try {
356
356
  const binding = require('@kreuzberg/node-linux-arm-gnueabihf')
357
357
  const bindingPackageVersion = require('@kreuzberg/node-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
360
  }
361
361
  return binding
362
362
  } catch (e) {
@@ -373,8 +373,8 @@ function requireNative() {
373
373
  try {
374
374
  const binding = require('@kreuzberg/node-linux-loong64-musl')
375
375
  const bindingPackageVersion = require('@kreuzberg/node-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
378
  }
379
379
  return binding
380
380
  } catch (e) {
@@ -389,8 +389,8 @@ function requireNative() {
389
389
  try {
390
390
  const binding = require('@kreuzberg/node-linux-loong64-gnu')
391
391
  const bindingPackageVersion = require('@kreuzberg/node-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
394
  }
395
395
  return binding
396
396
  } catch (e) {
@@ -407,8 +407,8 @@ function requireNative() {
407
407
  try {
408
408
  const binding = require('@kreuzberg/node-linux-riscv64-musl')
409
409
  const bindingPackageVersion = require('@kreuzberg/node-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
412
  }
413
413
  return binding
414
414
  } catch (e) {
@@ -423,8 +423,8 @@ function requireNative() {
423
423
  try {
424
424
  const binding = require('@kreuzberg/node-linux-riscv64-gnu')
425
425
  const bindingPackageVersion = require('@kreuzberg/node-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
428
  }
429
429
  return binding
430
430
  } catch (e) {
@@ -440,8 +440,8 @@ function requireNative() {
440
440
  try {
441
441
  const binding = require('@kreuzberg/node-linux-ppc64-gnu')
442
442
  const bindingPackageVersion = require('@kreuzberg/node-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
445
  }
446
446
  return binding
447
447
  } catch (e) {
@@ -456,8 +456,8 @@ function requireNative() {
456
456
  try {
457
457
  const binding = require('@kreuzberg/node-linux-s390x-gnu')
458
458
  const bindingPackageVersion = require('@kreuzberg/node-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
461
  }
462
462
  return binding
463
463
  } catch (e) {
@@ -476,8 +476,8 @@ function requireNative() {
476
476
  try {
477
477
  const binding = require('@kreuzberg/node-openharmony-arm64')
478
478
  const bindingPackageVersion = require('@kreuzberg/node-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
481
  }
482
482
  return binding
483
483
  } catch (e) {
@@ -492,8 +492,8 @@ function requireNative() {
492
492
  try {
493
493
  const binding = require('@kreuzberg/node-openharmony-x64')
494
494
  const bindingPackageVersion = require('@kreuzberg/node-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
497
  }
498
498
  return binding
499
499
  } catch (e) {
@@ -508,8 +508,8 @@ function requireNative() {
508
508
  try {
509
509
  const binding = require('@kreuzberg/node-openharmony-arm')
510
510
  const bindingPackageVersion = require('@kreuzberg/node-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '4.0.0-rc.22' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.22 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '4.0.0-rc.24' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 4.0.0-rc.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -536,13 +536,17 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
536
536
  wasiBindingError = err
537
537
  }
538
538
  }
539
- if (!nativeBinding) {
539
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
540
540
  try {
541
541
  wasiBinding = require('@kreuzberg/node-wasm32-wasi')
542
542
  nativeBinding = wasiBinding
543
543
  } catch (err) {
544
544
  if (process.env.NAPI_RS_FORCE_WASI) {
545
- wasiBindingError.cause = err
545
+ if (!wasiBindingError) {
546
+ wasiBindingError = err
547
+ } else {
548
+ wasiBindingError.cause = err
549
+ }
546
550
  loadErrors.push(err)
547
551
  }
548
552
  }
@@ -572,24 +576,29 @@ if (!nativeBinding) {
572
576
  }
573
577
 
574
578
  module.exports = nativeBinding
579
+ module.exports.JsWorkerPool = nativeBinding.JsWorkerPool
575
580
  module.exports.batchExtractBytes = nativeBinding.batchExtractBytes
576
581
  module.exports.batchExtractBytesSync = nativeBinding.batchExtractBytesSync
577
582
  module.exports.batchExtractFiles = nativeBinding.batchExtractFiles
583
+ module.exports.batchExtractFilesInWorker = nativeBinding.batchExtractFilesInWorker
578
584
  module.exports.batchExtractFilesSync = nativeBinding.batchExtractFilesSync
579
585
  module.exports.classifyError = nativeBinding.classifyError
580
586
  module.exports.clearDocumentExtractors = nativeBinding.clearDocumentExtractors
581
587
  module.exports.clearOcrBackends = nativeBinding.clearOcrBackends
582
588
  module.exports.clearPostProcessors = nativeBinding.clearPostProcessors
583
589
  module.exports.clearValidators = nativeBinding.clearValidators
590
+ module.exports.closeWorkerPool = nativeBinding.closeWorkerPool
584
591
  module.exports.configGetFieldInternal = nativeBinding.configGetFieldInternal
585
592
  module.exports.configMergeInternal = nativeBinding.configMergeInternal
586
593
  module.exports.configValidateAndNormalize = nativeBinding.configValidateAndNormalize
594
+ module.exports.createWorkerPool = nativeBinding.createWorkerPool
587
595
  module.exports.detectMimeTypeFromBytes = nativeBinding.detectMimeTypeFromBytes
588
596
  module.exports.detectMimeTypeFromPath = nativeBinding.detectMimeTypeFromPath
589
597
  module.exports.discoverExtractionConfig = nativeBinding.discoverExtractionConfig
590
598
  module.exports.extractBytes = nativeBinding.extractBytes
591
599
  module.exports.extractBytesSync = nativeBinding.extractBytesSync
592
600
  module.exports.extractFile = nativeBinding.extractFile
601
+ module.exports.extractFileInWorker = nativeBinding.extractFileInWorker
593
602
  module.exports.extractFileSync = nativeBinding.extractFileSync
594
603
  module.exports.getEmbeddingPreset = nativeBinding.getEmbeddingPreset
595
604
  module.exports.getErrorCodeDescription = nativeBinding.getErrorCodeDescription
@@ -601,6 +610,7 @@ module.exports.getValidBinarizationMethods = nativeBinding.getValidBinarizationM
601
610
  module.exports.getValidLanguageCodes = nativeBinding.getValidLanguageCodes
602
611
  module.exports.getValidOcrBackends = nativeBinding.getValidOcrBackends
603
612
  module.exports.getValidTokenReductionLevels = nativeBinding.getValidTokenReductionLevels
613
+ module.exports.getWorkerPoolStats = nativeBinding.getWorkerPoolStats
604
614
  module.exports.listDocumentExtractors = nativeBinding.listDocumentExtractors
605
615
  module.exports.listEmbeddingPresets = nativeBinding.listEmbeddingPresets
606
616
  module.exports.listOcrBackends = nativeBinding.listOcrBackends
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kreuzberg/node",
3
- "version": "4.0.0-rc.22",
3
+ "version": "4.0.0-rc.24",
4
4
  "description": "Kreuzberg document intelligence - Node.js native bindings",
5
5
  "author": {
6
6
  "name": "Na'aman Hirschfeld",
@@ -101,13 +101,13 @@
101
101
  "version": "napi version"
102
102
  },
103
103
  "devDependencies": {
104
- "@napi-rs/cli": "^3.5.0",
104
+ "@napi-rs/cli": "^3.5.1",
105
105
  "@types/archiver": "^7.0.0",
106
106
  "@types/node": "^25.0.3",
107
107
  "@types/which": "^3.0.4",
108
108
  "@vitest/coverage-v8": "^4.0.16",
109
109
  "archiver": "^7.0.1",
110
- "oxlint": "^1.35.0",
110
+ "oxlint": "^1.36.0",
111
111
  "tsup": "^8.5.1",
112
112
  "typescript": "^5.9.3",
113
113
  "vitest": "^4.0.16"
@@ -117,8 +117,7 @@
117
117
  "which": "^6.0.0"
118
118
  },
119
119
  "optionalDependencies": {
120
- "@kreuzberg/node-darwin-arm64": "4.0.0-rc.22",
121
- "@kreuzberg/node-linux-x64-gnu": "4.0.0-rc.22",
122
- "@kreuzberg/node-win32-x64-msvc": "4.0.0-rc.22"
120
+ "@kreuzberg/node-linux-x64-gnu": "4.0.0-rc.24",
121
+ "@kreuzberg/node-win32-x64-msvc": "4.0.0-rc.24"
123
122
  }
124
123
  }