formatferry 1.0.22 → 1.0.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/dist/index.js +15 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22089,17 +22089,18 @@ function esc(str) {
|
|
|
22089
22089
|
function isContent(node) {
|
|
22090
22090
|
return "id" in node && !("role" in node);
|
|
22091
22091
|
}
|
|
22092
|
-
function walkChildren(children, mcidMap, depth) {
|
|
22093
|
-
return children.map((c) => walkNode(c, mcidMap, depth)).join("");
|
|
22092
|
+
function walkChildren(children, mcidMap, depth, visitedMcids) {
|
|
22093
|
+
return children.map((c) => walkNode(c, mcidMap, depth, visitedMcids)).join("");
|
|
22094
22094
|
}
|
|
22095
|
-
function walkNode(node, mcidMap, depth = 0) {
|
|
22095
|
+
function walkNode(node, mcidMap, depth = 0, visitedMcids = /* @__PURE__ */ new Set()) {
|
|
22096
22096
|
if (depth > 50) return "";
|
|
22097
22097
|
if (isContent(node)) {
|
|
22098
|
+
visitedMcids.add(node.id);
|
|
22098
22099
|
const text = mcidMap.get(node.id) ?? "";
|
|
22099
22100
|
return esc(text);
|
|
22100
22101
|
}
|
|
22101
22102
|
const children = node.children ?? [];
|
|
22102
|
-
const inner = walkChildren(children, mcidMap, depth + 1);
|
|
22103
|
+
const inner = walkChildren(children, mcidMap, depth + 1, visitedMcids);
|
|
22103
22104
|
switch (node.role) {
|
|
22104
22105
|
case "H":
|
|
22105
22106
|
return `<h1>${inner}</h1>`;
|
|
@@ -22182,10 +22183,11 @@ async function structTreeToHtml(page) {
|
|
|
22182
22183
|
return null;
|
|
22183
22184
|
}
|
|
22184
22185
|
const mcidMap = buildMcidMap(textContent.items);
|
|
22185
|
-
const
|
|
22186
|
+
const claimedMcids = /* @__PURE__ */ new Set();
|
|
22187
|
+
const html = walkNode(structTree, mcidMap, 0, claimedMcids);
|
|
22186
22188
|
const textOnly = html.replace(/<[^>]+>/g, "").trim();
|
|
22187
22189
|
if (!textOnly) return null;
|
|
22188
|
-
return html;
|
|
22190
|
+
return { html, claimedMcids };
|
|
22189
22191
|
}
|
|
22190
22192
|
|
|
22191
22193
|
// ../../src/shared/adapters/pdf-adapter.ts
|
|
@@ -23071,7 +23073,10 @@ var PdfAdapter = class {
|
|
|
23071
23073
|
let structHtml = null;
|
|
23072
23074
|
try {
|
|
23073
23075
|
if (hasStructTree(page)) {
|
|
23074
|
-
|
|
23076
|
+
const structResult = await structTreeToHtml(page);
|
|
23077
|
+
if (structResult !== null) {
|
|
23078
|
+
structHtml = structResult.html;
|
|
23079
|
+
}
|
|
23075
23080
|
}
|
|
23076
23081
|
} catch {
|
|
23077
23082
|
}
|
|
@@ -23170,7 +23175,7 @@ var PdfAdapter = class {
|
|
|
23170
23175
|
const hasMinimalTextWithImages = totalTextLength < MIN_TEXT_CHARS_THRESHOLD && hasAnyImages;
|
|
23171
23176
|
if (hasNoText || hasMinimalTextWithImages) {
|
|
23172
23177
|
throw new PdfParseError(
|
|
23173
|
-
"
|
|
23178
|
+
"PDF contains only images \u2014 no text layer available.",
|
|
23174
23179
|
"IMAGE_ONLY"
|
|
23175
23180
|
);
|
|
23176
23181
|
}
|
|
@@ -25500,8 +25505,8 @@ import { readFileSync as readFileSync4 } from "fs";
|
|
|
25500
25505
|
import { resolve, dirname as dirname3 } from "path";
|
|
25501
25506
|
import { fileURLToPath } from "url";
|
|
25502
25507
|
var getVersion = () => {
|
|
25503
|
-
if ("1.0.
|
|
25504
|
-
return "1.0.
|
|
25508
|
+
if ("1.0.24") {
|
|
25509
|
+
return "1.0.24";
|
|
25505
25510
|
}
|
|
25506
25511
|
try {
|
|
25507
25512
|
const __dirname = dirname3(fileURLToPath(import.meta.url));
|