formatferry 1.0.19 → 1.0.21
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 +66 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22253,14 +22253,69 @@ function widgetToPositionedItems(ann) {
|
|
|
22253
22253
|
if (str.length === 0) return [];
|
|
22254
22254
|
return [mk(str)];
|
|
22255
22255
|
}
|
|
22256
|
-
if (ann.fieldType === "
|
|
22256
|
+
if (ann.fieldType === "Ch") {
|
|
22257
|
+
const raw = ann.fieldValue;
|
|
22258
|
+
const value = Array.isArray(raw) ? raw.join(", ") : raw;
|
|
22259
|
+
const str = (value ?? "").toString().trim();
|
|
22260
|
+
if (str.length === 0) return [];
|
|
22261
|
+
return [mk(str)];
|
|
22262
|
+
}
|
|
22263
|
+
if (ann.fieldType === "Btn" && ann.checkBox === true && !ann.radioButton) {
|
|
22257
22264
|
const value = ann.fieldValue;
|
|
22258
22265
|
const expected = ann.exportValue ?? ann.buttonValue ?? "Yes";
|
|
22259
22266
|
const checked = value != null && value !== "Off" && (Array.isArray(value) ? value.includes(expected) : String(value) === expected);
|
|
22260
22267
|
return [mk(checked ? "[X]" : "[ ]")];
|
|
22261
22268
|
}
|
|
22269
|
+
if (ann.fieldType === "Btn" && ann.radioButton === true) {
|
|
22270
|
+
return [];
|
|
22271
|
+
}
|
|
22272
|
+
if (ann.fieldType === "Sig") {
|
|
22273
|
+
const isSigned = ann.fieldValue != null && ann.fieldValue !== "";
|
|
22274
|
+
return [mk(isSigned ? "[Signed]" : "[Signature]")];
|
|
22275
|
+
}
|
|
22262
22276
|
return [];
|
|
22263
22277
|
}
|
|
22278
|
+
function groupRadioButtons(annotations) {
|
|
22279
|
+
const radios = annotations.filter(
|
|
22280
|
+
(a) => a.fieldType === "Btn" && a.radioButton === true && a.rect?.length === 4
|
|
22281
|
+
);
|
|
22282
|
+
if (radios.length === 0) return [];
|
|
22283
|
+
const groups = /* @__PURE__ */ new Map();
|
|
22284
|
+
for (const r of radios) {
|
|
22285
|
+
const name = r.fieldName ?? "__unnamed__";
|
|
22286
|
+
let arr = groups.get(name);
|
|
22287
|
+
if (!arr) {
|
|
22288
|
+
arr = [];
|
|
22289
|
+
groups.set(name, arr);
|
|
22290
|
+
}
|
|
22291
|
+
arr.push(r);
|
|
22292
|
+
}
|
|
22293
|
+
const items = [];
|
|
22294
|
+
for (const [, members] of groups) {
|
|
22295
|
+
const selected = members.find((m) => {
|
|
22296
|
+
const v = m.fieldValue;
|
|
22297
|
+
return v != null && v !== "Off";
|
|
22298
|
+
});
|
|
22299
|
+
for (const m of members) {
|
|
22300
|
+
const [llx, lly, urx, ury] = m.rect;
|
|
22301
|
+
const w = urx - llx;
|
|
22302
|
+
const h = ury - lly;
|
|
22303
|
+
if (w <= 0 || h <= 0) continue;
|
|
22304
|
+
const isSelected = m === selected;
|
|
22305
|
+
items.push({
|
|
22306
|
+
str: isSelected ? "[X]" : "[ ]",
|
|
22307
|
+
x: llx,
|
|
22308
|
+
y: lly,
|
|
22309
|
+
width: w,
|
|
22310
|
+
height: h,
|
|
22311
|
+
right: urx,
|
|
22312
|
+
rotation: 0,
|
|
22313
|
+
source: "acroform"
|
|
22314
|
+
});
|
|
22315
|
+
}
|
|
22316
|
+
}
|
|
22317
|
+
return items;
|
|
22318
|
+
}
|
|
22264
22319
|
function normalizeForDedup(s) {
|
|
22265
22320
|
return s.normalize("NFKC").replace(/\u200B|\u200C|\u200D|\uFEFF/g, "").replace(/\s+/g, " ").trim();
|
|
22266
22321
|
}
|
|
@@ -22891,7 +22946,10 @@ var PdfAdapter = class {
|
|
|
22891
22946
|
const p = textItemToPositioned(item);
|
|
22892
22947
|
if (p) hfPositioned.push(p);
|
|
22893
22948
|
}
|
|
22894
|
-
const hfWidgets =
|
|
22949
|
+
const hfWidgets = [
|
|
22950
|
+
...hfAnns.flatMap(widgetToPositionedItems),
|
|
22951
|
+
...groupRadioButtons(hfAnns)
|
|
22952
|
+
];
|
|
22895
22953
|
const hfItems = hfWidgets.length > 0 ? [...dedupAgainstWidgets(hfPositioned, hfWidgets), ...hfWidgets] : hfPositioned;
|
|
22896
22954
|
hfCandidates.push({ pageNum: pn, items: hfItems, viewportHeight: hfViewport.height });
|
|
22897
22955
|
} catch {
|
|
@@ -22919,7 +22977,10 @@ var PdfAdapter = class {
|
|
|
22919
22977
|
positionedText.push(positioned);
|
|
22920
22978
|
xPositions.push(positioned.x);
|
|
22921
22979
|
}
|
|
22922
|
-
const widgetItems =
|
|
22980
|
+
const widgetItems = [
|
|
22981
|
+
...annotations.flatMap(widgetToPositionedItems),
|
|
22982
|
+
...groupRadioButtons(annotations)
|
|
22983
|
+
];
|
|
22923
22984
|
const items = widgetItems.length > 0 ? [...dedupAgainstWidgets(positionedText, widgetItems), ...widgetItems] : positionedText;
|
|
22924
22985
|
if (getFeatureFlags().enablePdfEnhanced) {
|
|
22925
22986
|
applyLinkAnnotations(items, annotations);
|
|
@@ -25358,8 +25419,8 @@ import { readFileSync as readFileSync4 } from "fs";
|
|
|
25358
25419
|
import { resolve, dirname as dirname3 } from "path";
|
|
25359
25420
|
import { fileURLToPath } from "url";
|
|
25360
25421
|
var getVersion = () => {
|
|
25361
|
-
if ("1.0.
|
|
25362
|
-
return "1.0.
|
|
25422
|
+
if ("1.0.21") {
|
|
25423
|
+
return "1.0.21";
|
|
25363
25424
|
}
|
|
25364
25425
|
try {
|
|
25365
25426
|
const __dirname = dirname3(fileURLToPath(import.meta.url));
|