sygal-cli 0.3.0 → 0.3.1
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/dist/index.js +27 -6
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -58,6 +58,7 @@ var SUPPORTED_EXTENSIONS = {
|
|
|
58
58
|
eml: "message/rfc822",
|
|
59
59
|
ipynb: "application/x-ipynb+json",
|
|
60
60
|
zip: "application/zip",
|
|
61
|
+
rtf: "application/rtf",
|
|
61
62
|
// OCR (images) — HEIC/TIFF normalized to PNG before the API call (sharp)
|
|
62
63
|
png: "image/png",
|
|
63
64
|
jpg: "image/jpeg",
|
|
@@ -67,7 +68,8 @@ var SUPPORTED_EXTENSIONS = {
|
|
|
67
68
|
tiff: "image/tiff",
|
|
68
69
|
tif: "image/tiff",
|
|
69
70
|
heic: "image/heic",
|
|
70
|
-
heif: "image/heif"
|
|
71
|
+
heif: "image/heif",
|
|
72
|
+
avif: "image/avif"
|
|
71
73
|
};
|
|
72
74
|
function mimeForExtension(extension) {
|
|
73
75
|
return SUPPORTED_EXTENSIONS[extension.toLowerCase()] ?? null;
|
|
@@ -89,7 +91,7 @@ function countTokens(text) {
|
|
|
89
91
|
|
|
90
92
|
// ../core/src/image-normalize.ts
|
|
91
93
|
var import_sharp = __toESM(require("sharp"));
|
|
92
|
-
var NEEDS_PNG = /* @__PURE__ */ new Set([".heic", ".heif", ".tiff", ".tif"]);
|
|
94
|
+
var NEEDS_PNG = /* @__PURE__ */ new Set([".heic", ".heif", ".tiff", ".tif", ".avif"]);
|
|
93
95
|
function needsPngNormalization(ext) {
|
|
94
96
|
return NEEDS_PNG.has(ext.toLowerCase());
|
|
95
97
|
}
|
|
@@ -219,7 +221,9 @@ var SidecarManager = class {
|
|
|
219
221
|
const response = await this.request({ id: (0, import_node_crypto.randomUUID)(), cmd: "pdf_probe", path });
|
|
220
222
|
return {
|
|
221
223
|
pageCount: response.page_count ?? 0,
|
|
222
|
-
pagesTextLength: response.pages_text_length ?? []
|
|
224
|
+
pagesTextLength: response.pages_text_length ?? [],
|
|
225
|
+
pageWidth: response.page_width ?? void 0,
|
|
226
|
+
pageHeight: response.page_height ?? void 0
|
|
223
227
|
};
|
|
224
228
|
}
|
|
225
229
|
async renderPdfPage(path, page) {
|
|
@@ -674,7 +678,7 @@ var nvidiaProvider = {
|
|
|
674
678
|
async convertImage(img, mime, apiKey, signal, prompt) {
|
|
675
679
|
let payloadImg = img;
|
|
676
680
|
let payloadMime = mime;
|
|
677
|
-
if (payloadImg.length > NVIDIA_MAX_IMAGE_BYTES) {
|
|
681
|
+
if (payloadMime === "image/webp" || payloadImg.length > NVIDIA_MAX_IMAGE_BYTES) {
|
|
678
682
|
payloadImg = await shrinkToMaxBytes(payloadImg, NVIDIA_MAX_IMAGE_BYTES);
|
|
679
683
|
payloadMime = "image/jpeg";
|
|
680
684
|
}
|
|
@@ -829,7 +833,8 @@ var IMAGE_MIME = {
|
|
|
829
833
|
".tiff": "image/tiff",
|
|
830
834
|
".tif": "image/tiff",
|
|
831
835
|
".heic": "image/heic",
|
|
832
|
-
".heif": "image/heif"
|
|
836
|
+
".heif": "image/heif",
|
|
837
|
+
".avif": "image/avif"
|
|
833
838
|
};
|
|
834
839
|
var ApiOcrRunner = class {
|
|
835
840
|
constructor(settings, options = {}) {
|
|
@@ -850,7 +855,21 @@ var ApiOcrRunner = class {
|
|
|
850
855
|
let img = await (0, import_promises.readFile)(sourcePath);
|
|
851
856
|
let sendMime = mime;
|
|
852
857
|
if (needsPngNormalization(ext)) {
|
|
853
|
-
|
|
858
|
+
try {
|
|
859
|
+
img = await toPngBuffer(img);
|
|
860
|
+
} catch (err) {
|
|
861
|
+
const detail = err instanceof Error ? err.message.split("\n")[0] : String(err);
|
|
862
|
+
if (ext === ".heic" || ext === ".heif") {
|
|
863
|
+
throw new ConversionError(
|
|
864
|
+
"HEIC_HEVC_UNSUPPORTED",
|
|
865
|
+
`D\xE9codage ${ext.slice(1).toUpperCase()} (codec HEVC) impossible : ${detail}`
|
|
866
|
+
);
|
|
867
|
+
}
|
|
868
|
+
throw new ConversionError(
|
|
869
|
+
"IMAGE_DECODE_UNSUPPORTED",
|
|
870
|
+
`D\xE9codage ${ext.slice(1).toUpperCase()} impossible (format ou variante non pris en charge) : ${detail}`
|
|
871
|
+
);
|
|
872
|
+
}
|
|
854
873
|
sendMime = "image/png";
|
|
855
874
|
}
|
|
856
875
|
if (settings.customProviderId) {
|
|
@@ -1550,6 +1569,8 @@ var CONVERSION_CODE_MAP = {
|
|
|
1550
1569
|
OCR_REFUSED: "ocr_refused",
|
|
1551
1570
|
URL_FORBIDDEN: "url_forbidden",
|
|
1552
1571
|
URL_UNREACHABLE: "url_unreachable",
|
|
1572
|
+
HEIC_HEVC_UNSUPPORTED: "heic_hevc_unsupported",
|
|
1573
|
+
IMAGE_DECODE_UNSUPPORTED: "image_decode_unsupported",
|
|
1553
1574
|
UNKNOWN: "unknown"
|
|
1554
1575
|
};
|
|
1555
1576
|
var CliCodedError = class extends Error {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sygal-cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Sygal CLI - convert files and web pages to Markdown/JSON (local MarkItDown pipeline, OCR for images)",
|
|
5
5
|
"author": "Cyrill Semah",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"@sygal/core": "0.1.0"
|
|
38
38
|
},
|
|
39
39
|
"optionalDependencies": {
|
|
40
|
-
"@sygal/sidecar-
|
|
41
|
-
"@sygal/sidecar-
|
|
42
|
-
"@sygal/sidecar-
|
|
40
|
+
"@sygal/sidecar-darwin-arm64": "0.3.1",
|
|
41
|
+
"@sygal/sidecar-win32-x64": "0.3.1",
|
|
42
|
+
"@sygal/sidecar-linux-x64": "0.3.1"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "esbuild src/index.ts --bundle --platform=node --target=node20 --format=cjs --outfile=dist/index.js --external:sharp --external:gpt-tokenizer --external:commander --external:picocolors",
|