@kreuzberg/node 4.2.3 → 4.2.5
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 +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +48 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -2
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.mts +58 -1
- package/dist/types.d.ts +58 -1
- package/dist/types.js.map +1 -1
- package/index.d.ts +23 -0
- package/index.js +52 -52
- package/package.json +8 -7
package/dist/index.mjs
CHANGED
|
@@ -7,6 +7,12 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
7
7
|
|
|
8
8
|
// typescript/core/binding.ts
|
|
9
9
|
import { createRequire } from "module";
|
|
10
|
+
function isNapiRuntime() {
|
|
11
|
+
if (typeof process === "undefined") return false;
|
|
12
|
+
if (process.versions?.["bun"]) return true;
|
|
13
|
+
if (process.versions?.node) return true;
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
10
16
|
var binding = null;
|
|
11
17
|
var bindingInitialized = false;
|
|
12
18
|
function createNativeBindingError(error) {
|
|
@@ -83,7 +89,7 @@ function getBinding() {
|
|
|
83
89
|
return binding;
|
|
84
90
|
}
|
|
85
91
|
try {
|
|
86
|
-
if (
|
|
92
|
+
if (isNapiRuntime()) {
|
|
87
93
|
binding = loadNativeBinding();
|
|
88
94
|
bindingInitialized = true;
|
|
89
95
|
return binding;
|
|
@@ -444,6 +450,8 @@ function normalizeExtractionConfig(config) {
|
|
|
444
450
|
setIfDefined(normalized, "pages", pages);
|
|
445
451
|
const htmlOptions = normalizeHtmlOptions(config.htmlOptions);
|
|
446
452
|
setIfDefined(normalized, "htmlOptions", htmlOptions);
|
|
453
|
+
setIfDefined(normalized, "outputFormat", config.outputFormat);
|
|
454
|
+
setIfDefined(normalized, "resultFormat", config.resultFormat);
|
|
447
455
|
return normalized;
|
|
448
456
|
}
|
|
449
457
|
|
|
@@ -510,6 +518,38 @@ function convertChunk(rawChunk) {
|
|
|
510
518
|
}
|
|
511
519
|
};
|
|
512
520
|
}
|
|
521
|
+
function convertElement(rawElement) {
|
|
522
|
+
if (!rawElement || typeof rawElement !== "object") {
|
|
523
|
+
return {
|
|
524
|
+
elementId: "",
|
|
525
|
+
elementType: "narrative_text",
|
|
526
|
+
text: "",
|
|
527
|
+
metadata: {}
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
const element = rawElement;
|
|
531
|
+
const elementMetadata = element["metadata"] ?? {};
|
|
532
|
+
return {
|
|
533
|
+
// biome-ignore lint/complexity/useLiteralKeys: required for strict TypeScript noPropertyAccessFromIndexSignature
|
|
534
|
+
elementId: element["element_id"] ?? element["elementId"] ?? "",
|
|
535
|
+
// biome-ignore lint/complexity/useLiteralKeys: required for strict TypeScript noPropertyAccessFromIndexSignature
|
|
536
|
+
elementType: element["element_type"] ?? element["elementType"] ?? "narrative_text",
|
|
537
|
+
// biome-ignore lint/complexity/useLiteralKeys: required for strict TypeScript noPropertyAccessFromIndexSignature
|
|
538
|
+
text: element["text"] ?? "",
|
|
539
|
+
metadata: {
|
|
540
|
+
// biome-ignore lint/complexity/useLiteralKeys: required for strict TypeScript noPropertyAccessFromIndexSignature
|
|
541
|
+
pageNumber: elementMetadata["page_number"] ?? elementMetadata["pageNumber"] ?? null,
|
|
542
|
+
// biome-ignore lint/complexity/useLiteralKeys: required for strict TypeScript noPropertyAccessFromIndexSignature
|
|
543
|
+
filename: elementMetadata["filename"] ?? null,
|
|
544
|
+
// biome-ignore lint/complexity/useLiteralKeys: required for strict TypeScript noPropertyAccessFromIndexSignature
|
|
545
|
+
coordinates: elementMetadata["coordinates"] ? elementMetadata["coordinates"] : null,
|
|
546
|
+
// biome-ignore lint/complexity/useLiteralKeys: required for strict TypeScript noPropertyAccessFromIndexSignature
|
|
547
|
+
elementIndex: elementMetadata["element_index"] ?? elementMetadata["elementIndex"] ?? null,
|
|
548
|
+
// biome-ignore lint/complexity/useLiteralKeys: required for strict TypeScript noPropertyAccessFromIndexSignature
|
|
549
|
+
additional: elementMetadata["additional"] ?? {}
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
}
|
|
513
553
|
function convertImage(rawImage) {
|
|
514
554
|
if (!rawImage || typeof rawImage !== "object") {
|
|
515
555
|
return {
|
|
@@ -583,6 +623,7 @@ function convertResult(rawResult) {
|
|
|
583
623
|
detectedLanguages: null,
|
|
584
624
|
chunks: null,
|
|
585
625
|
images: null,
|
|
626
|
+
elements: null,
|
|
586
627
|
pages: null
|
|
587
628
|
};
|
|
588
629
|
}
|
|
@@ -601,6 +642,7 @@ function convertResult(rawResult) {
|
|
|
601
642
|
detectedLanguages: Array.isArray(result["detectedLanguages"]) ? result["detectedLanguages"] : null,
|
|
602
643
|
chunks: null,
|
|
603
644
|
images: null,
|
|
645
|
+
elements: null,
|
|
604
646
|
pages: null
|
|
605
647
|
};
|
|
606
648
|
const chunksData = result["chunks"];
|
|
@@ -611,6 +653,10 @@ function convertResult(rawResult) {
|
|
|
611
653
|
if (Array.isArray(imagesData)) {
|
|
612
654
|
returnObj.images = imagesData.map((image) => convertImage(image));
|
|
613
655
|
}
|
|
656
|
+
const elementsData = result["elements"];
|
|
657
|
+
if (Array.isArray(elementsData)) {
|
|
658
|
+
returnObj.elements = elementsData.map((element) => convertElement(element));
|
|
659
|
+
}
|
|
614
660
|
const pagesData = result["pages"];
|
|
615
661
|
if (Array.isArray(pagesData)) {
|
|
616
662
|
returnObj.pages = pagesData.map((page) => convertPageContent(page));
|
|
@@ -1242,7 +1288,7 @@ function getEmbeddingPreset(name) {
|
|
|
1242
1288
|
}
|
|
1243
1289
|
|
|
1244
1290
|
// typescript/index.ts
|
|
1245
|
-
var __version__ = "4.2.
|
|
1291
|
+
var __version__ = "4.2.5";
|
|
1246
1292
|
export {
|
|
1247
1293
|
CacheError,
|
|
1248
1294
|
ErrorCode,
|