gutterpress 0.11.20-alpha.1 → 0.11.20-alpha.3
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/api/index.js +3 -2
- package/dist/{build-cmf4nbpm.js → build-a8ycsg80.js} +5 -4
- package/dist/checks/pdf/index.d.ts +1 -0
- package/dist/checks/pdf/safe-margins.d.ts +3 -0
- package/dist/{cli-x1nfhaf1.js → cli-9k2tb493.js} +461 -607
- package/dist/{cli-7shp2kmj.js → cli-hn9pk0hp.js} +1 -1
- package/dist/cli-sth219v1.js +418 -0
- package/dist/{cli-rtpm04dv.js → cli-x4p99w8d.js} +5 -5
- package/dist/{cli-mmm22cza.js → cli-y9bcya7r.js} +121 -20
- package/dist/cli.js +12 -12
- package/dist/{doctor-0d6esj02.js → doctor-wbjkrcpc.js} +2 -2
- package/dist/{engine-adxptzf0.js → engine-fdtv01a2.js} +2 -2
- package/dist/{engine-1v8kmv3a.js → engine-yxnnp3hx.js} +1 -1
- package/dist/{ext-65nfh7st.js → ext-pesyrs68.js} +5 -4
- package/dist/{gutterpress-viewer-0r4rt4de.js → gutterpress-viewer-1yse8cx3.js} +355 -102
- package/dist/{index-cngw658w.js → index-r87y7wzw.js} +1 -1
- package/dist/index-sth219v1.js +418 -0
- package/dist/{index-1y885h1j.js → index-tjvrchxj.js} +576 -623
- package/dist/{index-pnvzgftg.js → index-zagagnwq.js} +5 -5
- package/dist/index.js +4 -3
- package/dist/lib/build-fingerprint.d.ts +8 -0
- package/dist/lib/ghostscript.d.ts +70 -16
- package/dist/lib/pdf-inspect.d.ts +45 -0
- package/dist/lib/presets.d.ts +3 -1
- package/dist/{manifest.schema-nrykd2c6.json → manifest.schema-c9x8912a.json} +21 -3
- package/dist/{new-y4a2xz3g.js → new-8yah8z91.js} +5 -4
- package/dist/pdf-inspect-zdmy7qca.js +35 -0
- package/dist/{preflight-kt7wfgbd.js → preflight-8ccx4kdc.js} +5 -4
- package/dist/preview/file-watcher.d.ts +7 -1
- package/dist/{preview-bridge-evecsh4w.js → preview-bridge-8wjcjec3.js} +3 -2
- package/dist/{preview-interface-k2mj5kvq.js → preview-interface-nnmrxyqm.js} +37 -41
- package/dist/{preview-shell-7jfe6vsc.js → preview-shell-wk9k3gcd.js} +18 -6
- package/dist/{preview-5ze728kp.js → preview-w7v9w36q.js} +5 -4
- package/dist/{publish-5tpcyysh.js → publish-g5nh5myh.js} +5 -4
- package/dist/schema/manifest.types.d.ts +47 -8
- package/dist/test-helpers/testkit.d.ts +2 -2
- package/dist/{validate-p0hkqkfe.js → validate-1yh59x0x.js} +5 -4
- package/package.json +1 -1
|
@@ -9,7 +9,20 @@ import {
|
|
|
9
9
|
getAssetsDir,
|
|
10
10
|
lastPageMode,
|
|
11
11
|
parseSize
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-zagagnwq.js";
|
|
13
|
+
import {
|
|
14
|
+
countLinkAnnotations,
|
|
15
|
+
getImageResolutions,
|
|
16
|
+
getOpPass,
|
|
17
|
+
getOutlineCount,
|
|
18
|
+
getPageLabels,
|
|
19
|
+
getPageSize,
|
|
20
|
+
getTextPass,
|
|
21
|
+
isLoadable,
|
|
22
|
+
loadPdf,
|
|
23
|
+
pageHasMarks,
|
|
24
|
+
retainPdfCache
|
|
25
|
+
} from "./index-sth219v1.js";
|
|
13
26
|
import {
|
|
14
27
|
INSTALL_HINTS,
|
|
15
28
|
enhancedPath,
|
|
@@ -141,6 +154,11 @@ function resolvePort(raw) {
|
|
|
141
154
|
// src/lib/presets.ts
|
|
142
155
|
var PRESET_IDS = ["dtrpg", "book", "custom"];
|
|
143
156
|
var DTRPG_PRESET = {
|
|
157
|
+
id: "dtrpg",
|
|
158
|
+
spec: {
|
|
159
|
+
label: "DriveThruRPG — Quick Specifications for Print Books",
|
|
160
|
+
url: "https://help.drivethrupartners.com/hc/en-us/articles/12780800178583-Quick-Specifications-for-Print-Books"
|
|
161
|
+
},
|
|
144
162
|
defaultTargets: ["dtrpg"],
|
|
145
163
|
extensions: [],
|
|
146
164
|
source: {
|
|
@@ -152,6 +170,8 @@ var DTRPG_PRESET = {
|
|
|
152
170
|
icc: "profiles/CGATS21_CRPC1.icc",
|
|
153
171
|
stripAnnotations: true,
|
|
154
172
|
blackText: "k-only",
|
|
173
|
+
transparency: "flatten-page",
|
|
174
|
+
flattenPages: [],
|
|
155
175
|
rasterDpi: undefined
|
|
156
176
|
},
|
|
157
177
|
page: {
|
|
@@ -159,7 +179,8 @@ var DTRPG_PRESET = {
|
|
|
159
179
|
height: 810,
|
|
160
180
|
tolerance: 0.5,
|
|
161
181
|
bleed: 9,
|
|
162
|
-
safe:
|
|
182
|
+
safe: 36,
|
|
183
|
+
artSafe: 18
|
|
163
184
|
},
|
|
164
185
|
ink: {
|
|
165
186
|
maxTac: 240,
|
|
@@ -188,6 +209,10 @@ var DTRPG_PRESET = {
|
|
|
188
209
|
"pdf.print.embedded-fonts": {
|
|
189
210
|
enabled: true,
|
|
190
211
|
severity: "error"
|
|
212
|
+
},
|
|
213
|
+
"pdf.print.safe-margins": {
|
|
214
|
+
enabled: true,
|
|
215
|
+
severity: "error"
|
|
191
216
|
}
|
|
192
217
|
},
|
|
193
218
|
source: {
|
|
@@ -220,6 +245,7 @@ var DTRPG_PRESET = {
|
|
|
220
245
|
}
|
|
221
246
|
};
|
|
222
247
|
var BOOK_PRESET = {
|
|
248
|
+
id: "book",
|
|
223
249
|
defaultTargets: [],
|
|
224
250
|
extensions: [],
|
|
225
251
|
source: {
|
|
@@ -231,6 +257,8 @@ var BOOK_PRESET = {
|
|
|
231
257
|
icc: "profiles/CGATS21_CRPC1.icc",
|
|
232
258
|
stripAnnotations: true,
|
|
233
259
|
blackText: "icc",
|
|
260
|
+
transparency: "flatten-page",
|
|
261
|
+
flattenPages: [],
|
|
234
262
|
rasterDpi: undefined
|
|
235
263
|
},
|
|
236
264
|
page: {
|
|
@@ -238,7 +266,8 @@ var BOOK_PRESET = {
|
|
|
238
266
|
height: 648,
|
|
239
267
|
tolerance: 0.5,
|
|
240
268
|
bleed: undefined,
|
|
241
|
-
safe: 18
|
|
269
|
+
safe: 18,
|
|
270
|
+
artSafe: undefined
|
|
242
271
|
},
|
|
243
272
|
ink: {
|
|
244
273
|
maxTac: 400,
|
|
@@ -260,6 +289,10 @@ var BOOK_PRESET = {
|
|
|
260
289
|
enabled: true,
|
|
261
290
|
severity: "error"
|
|
262
291
|
},
|
|
292
|
+
"pdf.print.safe-margins": {
|
|
293
|
+
enabled: true,
|
|
294
|
+
severity: "warning"
|
|
295
|
+
},
|
|
263
296
|
"pdf.print.pdfx-markers": false,
|
|
264
297
|
"pdf.print.pdfx-metadata": false
|
|
265
298
|
},
|
|
@@ -294,6 +327,7 @@ var BOOK_PRESET = {
|
|
|
294
327
|
};
|
|
295
328
|
var CUSTOM_PRESET = {
|
|
296
329
|
...BOOK_PRESET,
|
|
330
|
+
id: "custom",
|
|
297
331
|
page: null,
|
|
298
332
|
defaultTargets: []
|
|
299
333
|
};
|
|
@@ -339,7 +373,8 @@ var DTRPG_TARGET = {
|
|
|
339
373
|
"pdf.structure.qpdf": { enabled: true, severity: "error" },
|
|
340
374
|
"pdf.print.pdfx-markers": { enabled: true, severity: "error" },
|
|
341
375
|
"pdf.print.pdfx-metadata": { enabled: true, severity: "error" },
|
|
342
|
-
"pdf.print.embedded-fonts": { enabled: true, severity: "error" }
|
|
376
|
+
"pdf.print.embedded-fonts": { enabled: true, severity: "error" },
|
|
377
|
+
"pdf.print.safe-margins": { enabled: true, severity: "error" }
|
|
343
378
|
},
|
|
344
379
|
assets: {
|
|
345
380
|
allowedColorSpaces: [...DTRPG_PRESET.validate.assets.allowedColorSpaces]
|
|
@@ -354,7 +389,8 @@ var DTRPG_TARGET = {
|
|
|
354
389
|
"pdf.structure.qpdf",
|
|
355
390
|
"pdf.print.pdfx-markers",
|
|
356
391
|
"pdf.print.pdfx-metadata",
|
|
357
|
-
"pdf.print.embedded-fonts"
|
|
392
|
+
"pdf.print.embedded-fonts",
|
|
393
|
+
"pdf.print.safe-margins"
|
|
358
394
|
],
|
|
359
395
|
requiredTools: ["qpdf", "gs"]
|
|
360
396
|
};
|
|
@@ -369,6 +405,7 @@ var ITCH_TARGET = {
|
|
|
369
405
|
"pdf.print.pdfx-markers": false,
|
|
370
406
|
"pdf.print.pdfx-metadata": false,
|
|
371
407
|
"pdf.print.ink-coverage": false,
|
|
408
|
+
"pdf.print.safe-margins": false,
|
|
372
409
|
"asset.image.tac-raster": false
|
|
373
410
|
},
|
|
374
411
|
assets: {
|
|
@@ -593,7 +630,8 @@ function resolveCustomPage(c, m) {
|
|
|
593
630
|
height,
|
|
594
631
|
tolerance: c.page?.tolerance ?? m.page?.tolerance ?? 0.5,
|
|
595
632
|
bleed: c.page?.bleed ?? m.page?.bleed,
|
|
596
|
-
safe: c.page?.safe ?? m.page?.safe
|
|
633
|
+
safe: c.page?.safe ?? m.page?.safe,
|
|
634
|
+
artSafe: c.page?.artSafe ?? m.page?.artSafe
|
|
597
635
|
};
|
|
598
636
|
}
|
|
599
637
|
function resolveWithPreset(cliOverrides, manifest, preset) {
|
|
@@ -626,6 +664,14 @@ function resolveWithPreset(cliOverrides, manifest, preset) {
|
|
|
626
664
|
if (lastPage !== undefined && lastPage !== "blank" && lastPage !== "short-by-one") {
|
|
627
665
|
throw new UsageError(`Manifest field \`print.lastPage\` must be "blank" or "short-by-one", got ${JSON.stringify(lastPage)}.`);
|
|
628
666
|
}
|
|
667
|
+
const transparency = c.pdfx?.transparency ?? m.pdfx?.transparency;
|
|
668
|
+
if (transparency !== undefined && transparency !== "flatten-page" && transparency !== "preserve-text") {
|
|
669
|
+
throw new UsageError(`Manifest field \`pdfx.transparency\` must be "flatten-page" or "preserve-text", got ${JSON.stringify(transparency)}.`);
|
|
670
|
+
}
|
|
671
|
+
const flattenPages = c.pdfx?.flattenPages ?? m.pdfx?.flattenPages;
|
|
672
|
+
if (flattenPages !== undefined && !(Array.isArray(flattenPages) && flattenPages.every((n) => Number.isInteger(n) && n >= 1))) {
|
|
673
|
+
throw new UsageError(`Manifest field \`pdfx.flattenPages\` must be a list of page numbers (1, 2, …), got ${JSON.stringify(flattenPages)}.`);
|
|
674
|
+
}
|
|
629
675
|
const rasterDpi = c.pdfx?.rasterDpi ?? m.pdfx?.rasterDpi;
|
|
630
676
|
if (rasterDpi !== undefined && !(Number.isInteger(rasterDpi) && rasterDpi >= 72 && rasterDpi <= 1200)) {
|
|
631
677
|
throw new UsageError(`Manifest field \`pdfx.rasterDpi\` must be a whole number from 72 to 1200, got ${JSON.stringify(rasterDpi)}.`);
|
|
@@ -638,6 +684,8 @@ function resolveWithPreset(cliOverrides, manifest, preset) {
|
|
|
638
684
|
return {
|
|
639
685
|
title: c.title ?? m.title ?? "Document",
|
|
640
686
|
authors: c.authors ?? m.authors ?? [],
|
|
687
|
+
preset: preset.id,
|
|
688
|
+
spec: preset.spec,
|
|
641
689
|
styles: c.styles ?? m.styles,
|
|
642
690
|
extensions,
|
|
643
691
|
targets: resolveTargets(c.targets ?? m.targets, preset.defaultTargets),
|
|
@@ -5744,8 +5792,8 @@ async function resolveGhostscript(targetPlatform = process.platform, env = proce
|
|
|
5744
5792
|
}
|
|
5745
5793
|
return targetPlatform === "win32" ? findWindowsGhostscriptInstall(env) : undefined;
|
|
5746
5794
|
}
|
|
5747
|
-
async function
|
|
5748
|
-
const { PDFDocument, PDFDict, PDFName, PDFNumber, PDFRawStream, PDFRef } = await import("pdf-lib");
|
|
5795
|
+
async function transparentPages(pdfBytes) {
|
|
5796
|
+
const { PDFDocument, PDFDict, PDFName, PDFNumber, PDFRawStream, PDFArray, PDFRef } = await import("pdf-lib");
|
|
5749
5797
|
let doc;
|
|
5750
5798
|
try {
|
|
5751
5799
|
doc = await PDFDocument.load(pdfBytes, {
|
|
@@ -5753,36 +5801,64 @@ async function hasLiveTransparency(pdfBytes) {
|
|
|
5753
5801
|
throwOnInvalidObject: false
|
|
5754
5802
|
});
|
|
5755
5803
|
} catch {
|
|
5756
|
-
return
|
|
5804
|
+
return [];
|
|
5757
5805
|
}
|
|
5758
5806
|
const ctx = doc.context;
|
|
5759
|
-
const
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
if (!dict)
|
|
5763
|
-
continue;
|
|
5807
|
+
const SKIP = new Set(["Parent", "Font", "Annots"]);
|
|
5808
|
+
const isSet = (v) => v !== undefined && String(v) !== "/None";
|
|
5809
|
+
const dictHasTransparency = (dict) => {
|
|
5764
5810
|
const smask = dict.get(PDFName.of("SMask"));
|
|
5765
5811
|
const subtype = String(dict.get(PDFName.of("Subtype")) ?? "");
|
|
5766
5812
|
const type = String(dict.get(PDFName.of("Type")) ?? "");
|
|
5767
|
-
if (subtype === "/Image" &&
|
|
5813
|
+
if (subtype === "/Image" && isSet(smask))
|
|
5768
5814
|
return true;
|
|
5769
|
-
if (type === "/ExtGState") {
|
|
5770
|
-
if (
|
|
5815
|
+
if (type === "/ExtGState" || dict.has(PDFName.of("ca")) || dict.has(PDFName.of("BM"))) {
|
|
5816
|
+
if (isSet(smask))
|
|
5771
5817
|
return true;
|
|
5772
5818
|
for (const key of ["ca", "CA"]) {
|
|
5773
|
-
const alpha = dict.get(PDFName.of(key));
|
|
5819
|
+
const alpha = ctx.lookup(dict.get(PDFName.of(key)));
|
|
5774
5820
|
if (alpha instanceof PDFNumber && alpha.asNumber() < 1)
|
|
5775
5821
|
return true;
|
|
5776
5822
|
}
|
|
5823
|
+
const bm = ctx.lookup(dict.get(PDFName.of("BM")));
|
|
5824
|
+
const mode = bm instanceof PDFArray ? bm.get(0) : bm;
|
|
5825
|
+
if (mode && !["/Normal", "/Compatible"].includes(String(mode)))
|
|
5826
|
+
return true;
|
|
5777
5827
|
}
|
|
5778
|
-
const group = dict.get(PDFName.of("Group"));
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5828
|
+
const group = ctx.lookup(dict.get(PDFName.of("Group")));
|
|
5829
|
+
return group instanceof PDFDict && String(group.get(PDFName.of("S"))) === "/Transparency";
|
|
5830
|
+
};
|
|
5831
|
+
const reaches = (root) => {
|
|
5832
|
+
const seen = new Set;
|
|
5833
|
+
const stack = [root];
|
|
5834
|
+
while (stack.length) {
|
|
5835
|
+
const node = stack.pop();
|
|
5836
|
+
const obj = node instanceof PDFRef ? ctx.lookup(node) : node;
|
|
5837
|
+
if (!obj || seen.has(obj))
|
|
5838
|
+
continue;
|
|
5839
|
+
seen.add(obj);
|
|
5840
|
+
if (obj instanceof PDFArray) {
|
|
5841
|
+
stack.push(...obj.asArray());
|
|
5842
|
+
continue;
|
|
5843
|
+
}
|
|
5844
|
+
const dict = obj instanceof PDFRawStream ? obj.dict : obj instanceof PDFDict ? obj : undefined;
|
|
5845
|
+
if (!dict)
|
|
5846
|
+
continue;
|
|
5847
|
+
if (dictHasTransparency(dict))
|
|
5782
5848
|
return true;
|
|
5849
|
+
for (const [key, value] of dict.entries()) {
|
|
5850
|
+
if (!SKIP.has(key.asString().slice(1)))
|
|
5851
|
+
stack.push(value);
|
|
5852
|
+
}
|
|
5783
5853
|
}
|
|
5784
|
-
|
|
5785
|
-
|
|
5854
|
+
return false;
|
|
5855
|
+
};
|
|
5856
|
+
const pages = [];
|
|
5857
|
+
doc.getPages().forEach((page, i) => {
|
|
5858
|
+
if (reaches(page.node))
|
|
5859
|
+
pages.push(i + 1);
|
|
5860
|
+
});
|
|
5861
|
+
return pages;
|
|
5786
5862
|
}
|
|
5787
5863
|
async function findPostScriptShadingPages(pdfBytes) {
|
|
5788
5864
|
const { PDFDocument, PDFDict, PDFName, PDFNumber, PDFRawStream, PDFRef } = await import("pdf-lib");
|
|
@@ -5853,6 +5929,75 @@ async function stripAnnotations(pdfPath, stagingDir) {
|
|
|
5853
5929
|
const out = await doc.save();
|
|
5854
5930
|
await writeFile3(pdfPath, out);
|
|
5855
5931
|
}
|
|
5932
|
+
function planTransparentPages(transparent, reasons, flattenPages, gradientPages) {
|
|
5933
|
+
const split = [];
|
|
5934
|
+
const artOnly = [];
|
|
5935
|
+
const kept = new Map;
|
|
5936
|
+
for (const n of transparent) {
|
|
5937
|
+
const reason = reasons.get(n);
|
|
5938
|
+
if (reason === "no-text")
|
|
5939
|
+
artOnly.push(n);
|
|
5940
|
+
else if (flattenPages.includes(n))
|
|
5941
|
+
kept.set(n, "listed");
|
|
5942
|
+
else if (reason)
|
|
5943
|
+
kept.set(n, reason);
|
|
5944
|
+
else if (gradientPages.includes(n))
|
|
5945
|
+
kept.set(n, "gradient");
|
|
5946
|
+
else
|
|
5947
|
+
split.push(n);
|
|
5948
|
+
}
|
|
5949
|
+
return { split, artOnly, kept };
|
|
5950
|
+
}
|
|
5951
|
+
async function flattenTransparentPages(pdfPath, pageNumbers, stagingDir, dpi = 300) {
|
|
5952
|
+
const pages = [...new Set(pageNumbers)].sort((a, b) => a - b);
|
|
5953
|
+
if (pages.length === 0)
|
|
5954
|
+
return;
|
|
5955
|
+
const ghostscript = await resolveGhostscript();
|
|
5956
|
+
if (!ghostscript) {
|
|
5957
|
+
throw new Error("Ghostscript executable not found. Install Ghostscript or set GHOSTSCRIPT_PATH to its command-line executable.");
|
|
5958
|
+
}
|
|
5959
|
+
const art = join3(stagingDir, "flatten-art.pdf");
|
|
5960
|
+
const text = join3(stagingDir, "flatten-text.pdf");
|
|
5961
|
+
const pageList = `-sPageList=${pages.join(",")}`;
|
|
5962
|
+
const gs = (...args) => run(ghostscript, [
|
|
5963
|
+
"-q",
|
|
5964
|
+
"-dBATCH",
|
|
5965
|
+
"-dNOPAUSE",
|
|
5966
|
+
"-dSAFER",
|
|
5967
|
+
"-dPreserveAnnots=false",
|
|
5968
|
+
"-dNO_PDFMARK_OUTLINES",
|
|
5969
|
+
...args
|
|
5970
|
+
]);
|
|
5971
|
+
try {
|
|
5972
|
+
await gs(pageList, "-sDEVICE=pdfimage24", "-dFILTERTEXT", `-r${dpi}`, `-sOutputFile=${art}`, pdfPath);
|
|
5973
|
+
await gs(pageList, "-sDEVICE=pdfwrite", "-dNOTRANSPARENCY", "-dFILTERIMAGE", "-dFILTERVECTOR", "-dCompatibilityLevel=1.3", `-sOutputFile=${text}`, pdfPath);
|
|
5974
|
+
const { PDFDocument, PDFName } = await import("pdf-lib");
|
|
5975
|
+
const doc = await PDFDocument.load(await readFile9(pdfPath), { updateMetadata: false });
|
|
5976
|
+
const artDoc = await PDFDocument.load(await readFile9(art));
|
|
5977
|
+
const textDoc = await PDFDocument.load(await readFile9(text));
|
|
5978
|
+
if (artDoc.getPageCount() !== pages.length || textDoc.getPageCount() !== pages.length) {
|
|
5979
|
+
throw new Error(`Ghostscript returned ${artDoc.getPageCount()} artwork and ${textDoc.getPageCount()} text pages for ${pages.length} transparent pages.`);
|
|
5980
|
+
}
|
|
5981
|
+
const artPages = await doc.embedPages(artDoc.getPages());
|
|
5982
|
+
const withText = textDoc.getPages().filter((p) => p.node.Contents());
|
|
5983
|
+
const embeddedText = await doc.embedPages(withText);
|
|
5984
|
+
const textPages = textDoc.getPages().map((p) => embeddedText[withText.indexOf(p)]);
|
|
5985
|
+
pages.forEach((pageNumber, i) => {
|
|
5986
|
+
const page = doc.getPage(pageNumber - 1);
|
|
5987
|
+
const { x, y, width, height } = page.getMediaBox();
|
|
5988
|
+
page.node.set(PDFName.of("Contents"), doc.context.obj([]));
|
|
5989
|
+
page.node.set(PDFName.of("Resources"), doc.context.obj({}));
|
|
5990
|
+
page.node.delete(PDFName.of("Group"));
|
|
5991
|
+
page.drawPage(artPages[i], { x, y, width, height });
|
|
5992
|
+
const textPage = textPages[i];
|
|
5993
|
+
if (textPage)
|
|
5994
|
+
page.drawPage(textPage, { x, y, width, height });
|
|
5995
|
+
});
|
|
5996
|
+
await writeFile3(pdfPath, await doc.save());
|
|
5997
|
+
} finally {
|
|
5998
|
+
await Promise.all([art, text].map((f) => unlink2(f).catch(() => {})));
|
|
5999
|
+
}
|
|
6000
|
+
}
|
|
5856
6001
|
function makePdfxDefPs(params) {
|
|
5857
6002
|
const pdfxVersion = params.pdfx === "x3" ? "PDF/X-3:2002" : "PDF/X-1:2001";
|
|
5858
6003
|
const pdfxConformance = params.pdfx === "x1a" ? "PDF/X-1a:2001" : null;
|
|
@@ -5944,6 +6089,10 @@ async function convertToPdfxCmyk(inputPdf, outPdf, config) {
|
|
|
5944
6089
|
"-dDownsampleColorImages=false",
|
|
5945
6090
|
"-dDownsampleGrayImages=false",
|
|
5946
6091
|
"-dDownsampleMonoImages=false",
|
|
6092
|
+
"-dAutoFilterColorImages=false",
|
|
6093
|
+
"-dColorImageFilter=/FlateEncode",
|
|
6094
|
+
"-dAutoFilterGrayImages=false",
|
|
6095
|
+
"-dGrayImageFilter=/FlateEncode",
|
|
5947
6096
|
...config.rasterDpi ? [`-r${config.rasterDpi}`] : [],
|
|
5948
6097
|
"-sProcessColorModel=DeviceCMYK",
|
|
5949
6098
|
"-sColorConversionStrategy=CMYK",
|
|
@@ -5994,7 +6143,7 @@ import git from "isomorphic-git";
|
|
|
5994
6143
|
// package.json
|
|
5995
6144
|
var package_default = {
|
|
5996
6145
|
name: "gutterpress",
|
|
5997
|
-
version: "0.11.20-alpha.
|
|
6146
|
+
version: "0.11.20-alpha.3",
|
|
5998
6147
|
description: "Markdown-to-PDF converter for professional print layout using a native Chromium print engine and Ghostscript.",
|
|
5999
6148
|
author: "itlackey",
|
|
6000
6149
|
license: "MPL-2.0",
|
|
@@ -6249,7 +6398,10 @@ async function writeBuildFingerprint(input) {
|
|
|
6249
6398
|
resolvedFlavor: input.pdfx.resolvedFlavor,
|
|
6250
6399
|
iccPath: input.pdfx.iccPath,
|
|
6251
6400
|
stripAnnotations: input.pdfx.stripAnnotations,
|
|
6252
|
-
blackText: input.pdfx.blackText ?? null
|
|
6401
|
+
blackText: input.pdfx.blackText ?? null,
|
|
6402
|
+
transparency: input.pdfx.transparency ?? null,
|
|
6403
|
+
flattenPages: input.pdfx.flattenPages ?? null,
|
|
6404
|
+
rasterDpi: input.pdfx.rasterDpi ?? null
|
|
6253
6405
|
},
|
|
6254
6406
|
outputDir: input.recordedOutputDir ? path10.resolve(input.recordedOutputDir) : outputDir
|
|
6255
6407
|
},
|
|
@@ -6591,346 +6743,6 @@ function inspectionFailed(checkId, message, extra = {}) {
|
|
|
6591
6743
|
};
|
|
6592
6744
|
}
|
|
6593
6745
|
|
|
6594
|
-
// src/lib/pdf-inspect.ts
|
|
6595
|
-
import { stat as stat2, readFile as readFile13 } from "node:fs/promises";
|
|
6596
|
-
import { getDocumentProxy } from "unpdf";
|
|
6597
|
-
import * as pdfjs from "unpdf/pdfjs";
|
|
6598
|
-
function getOps(mod) {
|
|
6599
|
-
if ("OPS" in mod && mod.OPS && typeof mod.OPS === "object") {
|
|
6600
|
-
return mod.OPS;
|
|
6601
|
-
}
|
|
6602
|
-
throw new Error("unpdf/pdfjs missing OPS export");
|
|
6603
|
-
}
|
|
6604
|
-
var OPS = getOps(pdfjs);
|
|
6605
|
-
var docCache = new Map;
|
|
6606
|
-
var DOC_CACHE_MAX = 8;
|
|
6607
|
-
function destroyEntry(entry) {
|
|
6608
|
-
entry.doc.then((d) => d.destroy()).catch(() => {});
|
|
6609
|
-
}
|
|
6610
|
-
var EVICT_DESTROY_GRACE_MS = 60000;
|
|
6611
|
-
var gracePending = new Map;
|
|
6612
|
-
function destroyEntryAfterGrace(entry) {
|
|
6613
|
-
const t = setTimeout(() => {
|
|
6614
|
-
gracePending.delete(t);
|
|
6615
|
-
destroyEntry(entry);
|
|
6616
|
-
}, EVICT_DESTROY_GRACE_MS);
|
|
6617
|
-
t.unref?.();
|
|
6618
|
-
gracePending.set(t, entry);
|
|
6619
|
-
}
|
|
6620
|
-
function evictLru() {
|
|
6621
|
-
while (docCache.size > DOC_CACHE_MAX) {
|
|
6622
|
-
const oldestKey = docCache.keys().next().value;
|
|
6623
|
-
if (oldestKey === undefined)
|
|
6624
|
-
break;
|
|
6625
|
-
const evicted = docCache.get(oldestKey);
|
|
6626
|
-
docCache.delete(oldestKey);
|
|
6627
|
-
if (evicted)
|
|
6628
|
-
destroyEntryAfterGrace(evicted);
|
|
6629
|
-
}
|
|
6630
|
-
}
|
|
6631
|
-
async function loadPdf(path11) {
|
|
6632
|
-
let st;
|
|
6633
|
-
try {
|
|
6634
|
-
st = await stat2(path11);
|
|
6635
|
-
} catch {
|
|
6636
|
-
return null;
|
|
6637
|
-
}
|
|
6638
|
-
const hit = docCache.get(path11);
|
|
6639
|
-
if (hit && hit.mtimeMs === st.mtimeMs && hit.size === st.size) {
|
|
6640
|
-
docCache.delete(path11);
|
|
6641
|
-
docCache.set(path11, hit);
|
|
6642
|
-
try {
|
|
6643
|
-
return await hit.doc;
|
|
6644
|
-
} catch {
|
|
6645
|
-
return null;
|
|
6646
|
-
}
|
|
6647
|
-
}
|
|
6648
|
-
if (hit)
|
|
6649
|
-
destroyEntry(hit);
|
|
6650
|
-
const docPromise = readFile13(path11).then((buf) => getDocumentProxy(new Uint8Array(buf)));
|
|
6651
|
-
docCache.delete(path11);
|
|
6652
|
-
docCache.set(path11, { mtimeMs: st.mtimeMs, size: st.size, doc: docPromise });
|
|
6653
|
-
evictLru();
|
|
6654
|
-
try {
|
|
6655
|
-
return await docPromise;
|
|
6656
|
-
} catch {
|
|
6657
|
-
if (docCache.get(path11)?.doc === docPromise)
|
|
6658
|
-
docCache.delete(path11);
|
|
6659
|
-
return null;
|
|
6660
|
-
}
|
|
6661
|
-
}
|
|
6662
|
-
var activeRetains = 0;
|
|
6663
|
-
function retainPdfCache() {
|
|
6664
|
-
activeRetains++;
|
|
6665
|
-
let released = false;
|
|
6666
|
-
return () => {
|
|
6667
|
-
if (released)
|
|
6668
|
-
return;
|
|
6669
|
-
released = true;
|
|
6670
|
-
activeRetains--;
|
|
6671
|
-
if (activeRetains === 0)
|
|
6672
|
-
clearPdfCache();
|
|
6673
|
-
};
|
|
6674
|
-
}
|
|
6675
|
-
function clearPdfCache() {
|
|
6676
|
-
for (const [t, entry] of gracePending) {
|
|
6677
|
-
clearTimeout(t);
|
|
6678
|
-
destroyEntry(entry);
|
|
6679
|
-
}
|
|
6680
|
-
gracePending.clear();
|
|
6681
|
-
for (const entry of docCache.values())
|
|
6682
|
-
destroyEntry(entry);
|
|
6683
|
-
docCache.clear();
|
|
6684
|
-
}
|
|
6685
|
-
function getPageSize(page) {
|
|
6686
|
-
const vp = page.getViewport({ scale: 1 });
|
|
6687
|
-
return { w: vp.width, h: vp.height };
|
|
6688
|
-
}
|
|
6689
|
-
async function getOutlineCount(doc) {
|
|
6690
|
-
try {
|
|
6691
|
-
const outline = await doc.getOutline();
|
|
6692
|
-
return outline ? outline.length : 0;
|
|
6693
|
-
} catch {
|
|
6694
|
-
return 0;
|
|
6695
|
-
}
|
|
6696
|
-
}
|
|
6697
|
-
async function getPageLabels(doc) {
|
|
6698
|
-
try {
|
|
6699
|
-
return await doc.getPageLabels();
|
|
6700
|
-
} catch {
|
|
6701
|
-
return null;
|
|
6702
|
-
}
|
|
6703
|
-
}
|
|
6704
|
-
async function countLinkAnnotations(doc, stopAtFirst = false) {
|
|
6705
|
-
let count = 0;
|
|
6706
|
-
for (let i = 1;i <= doc.numPages; i++) {
|
|
6707
|
-
try {
|
|
6708
|
-
const page = await doc.getPage(i);
|
|
6709
|
-
const annots = await page.getAnnotations();
|
|
6710
|
-
for (const a of annots) {
|
|
6711
|
-
if (a.subtype === "Link") {
|
|
6712
|
-
count++;
|
|
6713
|
-
if (stopAtFirst)
|
|
6714
|
-
return count;
|
|
6715
|
-
}
|
|
6716
|
-
}
|
|
6717
|
-
} catch {}
|
|
6718
|
-
}
|
|
6719
|
-
return count;
|
|
6720
|
-
}
|
|
6721
|
-
var textCache = new WeakMap;
|
|
6722
|
-
function getTextPass(doc) {
|
|
6723
|
-
let p = textCache.get(doc);
|
|
6724
|
-
if (!p) {
|
|
6725
|
-
p = (async () => {
|
|
6726
|
-
const textByPage = [];
|
|
6727
|
-
const positions = [];
|
|
6728
|
-
const runsByPage = [];
|
|
6729
|
-
for (let i = 1;i <= doc.numPages; i++) {
|
|
6730
|
-
try {
|
|
6731
|
-
const page = await doc.getPage(i);
|
|
6732
|
-
const tc = await page.getTextContent();
|
|
6733
|
-
let pageText = "";
|
|
6734
|
-
const runs = [];
|
|
6735
|
-
for (const item of tc.items) {
|
|
6736
|
-
const it = item;
|
|
6737
|
-
if (typeof it.str !== "string")
|
|
6738
|
-
continue;
|
|
6739
|
-
pageText += it.str;
|
|
6740
|
-
if (it.transform && it.str.trim().length > 0) {
|
|
6741
|
-
const x = it.transform[4];
|
|
6742
|
-
const y = it.transform[5];
|
|
6743
|
-
positions.push({ x, y });
|
|
6744
|
-
runs.push({ s: it.str, x, y, w: it.width ?? 0, h: it.height ?? 0 });
|
|
6745
|
-
}
|
|
6746
|
-
}
|
|
6747
|
-
textByPage.push(pageText);
|
|
6748
|
-
runsByPage.push(runs);
|
|
6749
|
-
} catch {
|
|
6750
|
-
textByPage.push("");
|
|
6751
|
-
runsByPage.push([]);
|
|
6752
|
-
}
|
|
6753
|
-
}
|
|
6754
|
-
return { textByPage, positions, runsByPage };
|
|
6755
|
-
})();
|
|
6756
|
-
textCache.set(doc, p);
|
|
6757
|
-
}
|
|
6758
|
-
return p;
|
|
6759
|
-
}
|
|
6760
|
-
var opCache = new WeakMap;
|
|
6761
|
-
function multiply(m1, m2) {
|
|
6762
|
-
return [
|
|
6763
|
-
m1[0] * m2[0] + m1[2] * m2[1],
|
|
6764
|
-
m1[1] * m2[0] + m1[3] * m2[1],
|
|
6765
|
-
m1[0] * m2[2] + m1[2] * m2[3],
|
|
6766
|
-
m1[1] * m2[2] + m1[3] * m2[3],
|
|
6767
|
-
m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
|
|
6768
|
-
m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
|
|
6769
|
-
];
|
|
6770
|
-
}
|
|
6771
|
-
function fontIsEmbedded(f) {
|
|
6772
|
-
if (f.isType3Font)
|
|
6773
|
-
return true;
|
|
6774
|
-
if (f.missingFile === true)
|
|
6775
|
-
return false;
|
|
6776
|
-
if (f.isStandardFont === true)
|
|
6777
|
-
return false;
|
|
6778
|
-
return true;
|
|
6779
|
-
}
|
|
6780
|
-
function getOpPass(doc) {
|
|
6781
|
-
let p = opCache.get(doc);
|
|
6782
|
-
if (!p) {
|
|
6783
|
-
p = (async () => {
|
|
6784
|
-
const imagesByPage = new Map;
|
|
6785
|
-
const fonts = [];
|
|
6786
|
-
const seenFonts = new Set;
|
|
6787
|
-
for (let i = 1;i <= doc.numPages; i++) {
|
|
6788
|
-
let page;
|
|
6789
|
-
try {
|
|
6790
|
-
page = await doc.getPage(i);
|
|
6791
|
-
} catch {
|
|
6792
|
-
continue;
|
|
6793
|
-
}
|
|
6794
|
-
let ops;
|
|
6795
|
-
try {
|
|
6796
|
-
ops = await page.getOperatorList();
|
|
6797
|
-
} catch {
|
|
6798
|
-
continue;
|
|
6799
|
-
}
|
|
6800
|
-
let ctm = [1, 0, 0, 1, 0, 0];
|
|
6801
|
-
const stack = [];
|
|
6802
|
-
const pageImages = [];
|
|
6803
|
-
for (let j = 0;j < ops.fnArray.length; j++) {
|
|
6804
|
-
const fn = ops.fnArray[j];
|
|
6805
|
-
const args = ops.argsArray[j];
|
|
6806
|
-
if (fn === OPS.save) {
|
|
6807
|
-
stack.push(ctm.slice());
|
|
6808
|
-
} else if (fn === OPS.restore) {
|
|
6809
|
-
ctm = stack.pop() ?? ctm;
|
|
6810
|
-
} else if (fn === OPS.transform) {
|
|
6811
|
-
ctm = multiply(ctm, args);
|
|
6812
|
-
} else if (fn === OPS.paintImageXObject || fn === OPS.paintImageXObjectRepeat || fn === OPS.paintInlineImageXObject) {
|
|
6813
|
-
const name = typeof args[0] === "string" ? args[0] : "(inline)";
|
|
6814
|
-
pageImages.push({
|
|
6815
|
-
name,
|
|
6816
|
-
placedW: Math.hypot(ctm[0], ctm[1]),
|
|
6817
|
-
placedH: Math.hypot(ctm[2], ctm[3]),
|
|
6818
|
-
x: ctm[4],
|
|
6819
|
-
y: ctm[5],
|
|
6820
|
-
page: i
|
|
6821
|
-
});
|
|
6822
|
-
} else if (fn === OPS.setFont) {
|
|
6823
|
-
const ref = args[0];
|
|
6824
|
-
if (typeof ref === "string" && !seenFonts.has(ref)) {
|
|
6825
|
-
seenFonts.add(ref);
|
|
6826
|
-
try {
|
|
6827
|
-
if (page.commonObjs.has(ref)) {
|
|
6828
|
-
const f = page.commonObjs.get(ref);
|
|
6829
|
-
fonts.push({
|
|
6830
|
-
name: f?.name ?? ref,
|
|
6831
|
-
embedded: fontIsEmbedded(f ?? {})
|
|
6832
|
-
});
|
|
6833
|
-
}
|
|
6834
|
-
} catch {}
|
|
6835
|
-
}
|
|
6836
|
-
}
|
|
6837
|
-
}
|
|
6838
|
-
if (pageImages.length > 0)
|
|
6839
|
-
imagesByPage.set(i, pageImages);
|
|
6840
|
-
}
|
|
6841
|
-
return { imagesByPage, fonts };
|
|
6842
|
-
})();
|
|
6843
|
-
opCache.set(doc, p);
|
|
6844
|
-
}
|
|
6845
|
-
return p;
|
|
6846
|
-
}
|
|
6847
|
-
function getImagePixelSize(page, name, timeoutMs = 2000) {
|
|
6848
|
-
return new Promise((resolve6) => {
|
|
6849
|
-
let done = false;
|
|
6850
|
-
const finish = (v) => {
|
|
6851
|
-
if (!done) {
|
|
6852
|
-
done = true;
|
|
6853
|
-
resolve6(v);
|
|
6854
|
-
}
|
|
6855
|
-
};
|
|
6856
|
-
const t = setTimeout(() => finish(null), timeoutMs);
|
|
6857
|
-
try {
|
|
6858
|
-
page.objs.get(name, (obj) => {
|
|
6859
|
-
clearTimeout(t);
|
|
6860
|
-
finish(obj && obj.width && obj.height ? { width: obj.width, height: obj.height } : null);
|
|
6861
|
-
});
|
|
6862
|
-
} catch {
|
|
6863
|
-
clearTimeout(t);
|
|
6864
|
-
finish(null);
|
|
6865
|
-
}
|
|
6866
|
-
});
|
|
6867
|
-
}
|
|
6868
|
-
var PAINT_OPS = new Set([
|
|
6869
|
-
"stroke",
|
|
6870
|
-
"closeStroke",
|
|
6871
|
-
"fill",
|
|
6872
|
-
"eoFill",
|
|
6873
|
-
"fillStroke",
|
|
6874
|
-
"eoFillStroke",
|
|
6875
|
-
"closeFillStroke",
|
|
6876
|
-
"closeEOFillStroke",
|
|
6877
|
-
"shadingFill",
|
|
6878
|
-
"paintImageXObject",
|
|
6879
|
-
"paintInlineImageXObject",
|
|
6880
|
-
"paintImageXObjectRepeat",
|
|
6881
|
-
"paintImageMaskXObject",
|
|
6882
|
-
"paintImageMaskXObjectGroup",
|
|
6883
|
-
"paintImageMaskXObjectRepeat",
|
|
6884
|
-
"paintSolidColorImageMask",
|
|
6885
|
-
"showText",
|
|
6886
|
-
"showSpacedText",
|
|
6887
|
-
"nextLineShowText",
|
|
6888
|
-
"nextLineSetSpacingShowText"
|
|
6889
|
-
].map((name) => OPS[name]).filter((op) => op !== undefined));
|
|
6890
|
-
async function pageHasMarks(doc, pageNum) {
|
|
6891
|
-
const ops = await (await doc.getPage(pageNum)).getOperatorList();
|
|
6892
|
-
return ops.fnArray.some((fn, i) => fn === OPS.constructPath ? PAINT_OPS.has(ops.argsArray[i][0]) : PAINT_OPS.has(fn));
|
|
6893
|
-
}
|
|
6894
|
-
async function getImageResolutions(doc) {
|
|
6895
|
-
const { imagesByPage } = await getOpPass(doc);
|
|
6896
|
-
const out = [];
|
|
6897
|
-
for (const [pageNum, imgs] of imagesByPage) {
|
|
6898
|
-
let page;
|
|
6899
|
-
try {
|
|
6900
|
-
page = await doc.getPage(pageNum);
|
|
6901
|
-
} catch {
|
|
6902
|
-
continue;
|
|
6903
|
-
}
|
|
6904
|
-
for (const img of imgs) {
|
|
6905
|
-
if (img.name === "(inline)")
|
|
6906
|
-
continue;
|
|
6907
|
-
const px = await getImagePixelSize(page, img.name);
|
|
6908
|
-
if (!px)
|
|
6909
|
-
continue;
|
|
6910
|
-
const placedWin = img.placedW / 72;
|
|
6911
|
-
const placedHin = img.placedH / 72;
|
|
6912
|
-
if (placedWin <= 0 || placedHin <= 0)
|
|
6913
|
-
continue;
|
|
6914
|
-
out.push({
|
|
6915
|
-
page: pageNum,
|
|
6916
|
-
xDpi: px.width / placedWin,
|
|
6917
|
-
yDpi: px.height / placedHin
|
|
6918
|
-
});
|
|
6919
|
-
}
|
|
6920
|
-
}
|
|
6921
|
-
return out;
|
|
6922
|
-
}
|
|
6923
|
-
async function isLoadable(doc) {
|
|
6924
|
-
try {
|
|
6925
|
-
for (let i = 1;i <= doc.numPages; i++) {
|
|
6926
|
-
await doc.getPage(i);
|
|
6927
|
-
}
|
|
6928
|
-
return true;
|
|
6929
|
-
} catch {
|
|
6930
|
-
return false;
|
|
6931
|
-
}
|
|
6932
|
-
}
|
|
6933
|
-
|
|
6934
6746
|
// src/checks/pdf/qpdf-structure.ts
|
|
6935
6747
|
var check2 = {
|
|
6936
6748
|
id: "pdf.structure.qpdf",
|
|
@@ -6987,6 +6799,79 @@ var check3 = {
|
|
|
6987
6799
|
};
|
|
6988
6800
|
registerCheck(check3);
|
|
6989
6801
|
|
|
6802
|
+
// src/checks/pdf/safe-margins.ts
|
|
6803
|
+
var TOLERANCE_PT = 0.5;
|
|
6804
|
+
var ABOVE_BASELINE = 0.8;
|
|
6805
|
+
var BELOW_BASELINE = 0.2;
|
|
6806
|
+
var inches = (pt) => `${+(pt / 72).toFixed(2)}in`;
|
|
6807
|
+
var check4 = {
|
|
6808
|
+
id: "pdf.print.safe-margins",
|
|
6809
|
+
name: "Safe margins",
|
|
6810
|
+
description: "Fails when text sits closer to the trim than `page.safe` (DriveThruRPG: 0.5in on every edge). Text only: art is judged in the preview's safe-area overlay, not here. Skipped when `page.safe` is not set",
|
|
6811
|
+
category: "pdf",
|
|
6812
|
+
phase: "post-build",
|
|
6813
|
+
async run(ctx) {
|
|
6814
|
+
const { width, height, bleed = 0, safe = 0 } = ctx.config.page;
|
|
6815
|
+
if (!ctx.pdfPath || !safe)
|
|
6816
|
+
return [];
|
|
6817
|
+
const doc = await loadPdf(ctx.pdfPath);
|
|
6818
|
+
if (!doc) {
|
|
6819
|
+
return [inspectionFailed(check4.id, "Could not parse the PDF's text positions.", { file: ctx.pdfPath })];
|
|
6820
|
+
}
|
|
6821
|
+
const rule = ctx.config.spec?.label ?? "page.safe";
|
|
6822
|
+
const results = [];
|
|
6823
|
+
try {
|
|
6824
|
+
for (let pageNum = 1;pageNum <= doc.numPages; pageNum++) {
|
|
6825
|
+
const recto = pageNum % 2 === 1;
|
|
6826
|
+
const trim = {
|
|
6827
|
+
left: recto ? 0 : bleed,
|
|
6828
|
+
right: width - (recto ? bleed : 0),
|
|
6829
|
+
bottom: bleed,
|
|
6830
|
+
top: height - bleed
|
|
6831
|
+
};
|
|
6832
|
+
const { items } = await (await doc.getPage(pageNum)).getTextContent();
|
|
6833
|
+
for (const item of items) {
|
|
6834
|
+
if (!("str" in item) || !item.str.trim())
|
|
6835
|
+
continue;
|
|
6836
|
+
const [a, b, c, d, e, f] = item.transform;
|
|
6837
|
+
const along = item.width / Math.hypot(a, b);
|
|
6838
|
+
const xs = [];
|
|
6839
|
+
const ys = [];
|
|
6840
|
+
for (const s of [0, 1]) {
|
|
6841
|
+
for (const u of [-BELOW_BASELINE, ABOVE_BASELINE]) {
|
|
6842
|
+
xs.push(e + s * along * a + u * c);
|
|
6843
|
+
ys.push(f + s * along * b + u * d);
|
|
6844
|
+
}
|
|
6845
|
+
}
|
|
6846
|
+
const gaps = [
|
|
6847
|
+
[recto ? "binding" : "outside", Math.min(...xs) - trim.left],
|
|
6848
|
+
[recto ? "outside" : "binding", trim.right - Math.max(...xs)],
|
|
6849
|
+
["bottom", Math.min(...ys) - trim.bottom],
|
|
6850
|
+
["top", trim.top - Math.max(...ys)]
|
|
6851
|
+
];
|
|
6852
|
+
const [edge, gap] = gaps.reduce((worst, g) => g[1] < worst[1] ? g : worst);
|
|
6853
|
+
const shortfall = safe - gap;
|
|
6854
|
+
if (shortfall <= TOLERANCE_PT)
|
|
6855
|
+
continue;
|
|
6856
|
+
const text = item.str.trim();
|
|
6857
|
+
results.push(finding(check4.id, {
|
|
6858
|
+
severity: "error",
|
|
6859
|
+
message: `Page ${pageNum}: "${text.slice(0, 40)}${text.length > 40 ? "…" : ""}" is ${inches(shortfall)} too close to the ${edge} edge.`,
|
|
6860
|
+
file: ctx.pdfPath,
|
|
6861
|
+
detail: `${rule}: text must stay at least ${inches(safe)} inside the trim on every edge.`,
|
|
6862
|
+
code: "text-outside-safe-margin",
|
|
6863
|
+
data: { page: pageNum, edge, shortfallPt: +shortfall.toFixed(2) }
|
|
6864
|
+
}));
|
|
6865
|
+
}
|
|
6866
|
+
}
|
|
6867
|
+
} catch {
|
|
6868
|
+
return [inspectionFailed(check4.id, "Could not read the PDF's text positions.", { file: ctx.pdfPath })];
|
|
6869
|
+
}
|
|
6870
|
+
return results;
|
|
6871
|
+
}
|
|
6872
|
+
};
|
|
6873
|
+
registerCheck(check4);
|
|
6874
|
+
|
|
6990
6875
|
// src/checks/pdf/pdfx-structure.ts
|
|
6991
6876
|
function isObject(value) {
|
|
6992
6877
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -7095,7 +6980,7 @@ function getPdfxMetadataIssues(objects, flavor) {
|
|
|
7095
6980
|
}
|
|
7096
6981
|
|
|
7097
6982
|
// src/checks/pdf/pdfx-markers.ts
|
|
7098
|
-
var
|
|
6983
|
+
var check5 = {
|
|
7099
6984
|
id: "pdf.print.pdfx-markers",
|
|
7100
6985
|
name: "PDF/X Markers",
|
|
7101
6986
|
description: "Checks PDF/X OutputIntent structure via qpdf JSON",
|
|
@@ -7114,27 +6999,27 @@ var check4 = {
|
|
|
7114
6999
|
const objects = parseQpdfObjectsJson(stdout);
|
|
7115
7000
|
if (!objects) {
|
|
7116
7001
|
return [
|
|
7117
|
-
inspectionFailed(
|
|
7002
|
+
inspectionFailed(check5.id, "Unable to parse qpdf JSON output for PDF/X checks.", { file: ctx.pdfPath })
|
|
7118
7003
|
];
|
|
7119
7004
|
}
|
|
7120
|
-
return getPdfxOutputIntentIssues(objects).map((message) => finding(
|
|
7005
|
+
return getPdfxOutputIntentIssues(objects).map((message) => finding(check5.id, {
|
|
7121
7006
|
severity: "error",
|
|
7122
7007
|
message,
|
|
7123
7008
|
file: ctx.pdfPath
|
|
7124
7009
|
}));
|
|
7125
7010
|
} catch {
|
|
7126
7011
|
return [
|
|
7127
|
-
inspectionFailed(
|
|
7012
|
+
inspectionFailed(check5.id, "Failed to inspect PDF objects with qpdf for PDF/X markers.", { file: ctx.pdfPath })
|
|
7128
7013
|
];
|
|
7129
7014
|
}
|
|
7130
7015
|
}
|
|
7131
7016
|
};
|
|
7132
|
-
registerCheck(
|
|
7017
|
+
registerCheck(check5);
|
|
7133
7018
|
|
|
7134
7019
|
// src/lib/pdf-parse.ts
|
|
7135
|
-
import { readFile as
|
|
7020
|
+
import { readFile as readFile13 } from "node:fs/promises";
|
|
7136
7021
|
async function readPdfBytes(pdfPath) {
|
|
7137
|
-
return
|
|
7022
|
+
return readFile13(pdfPath, "latin1");
|
|
7138
7023
|
}
|
|
7139
7024
|
function parseInkCov(out) {
|
|
7140
7025
|
const lines = out.split(/\r?\n/).filter((l) => l.includes("CMYK"));
|
|
@@ -7182,7 +7067,7 @@ async function getPerPageInkCoverage(pdfPath) {
|
|
|
7182
7067
|
}
|
|
7183
7068
|
|
|
7184
7069
|
// src/checks/pdf/color-spaces.ts
|
|
7185
|
-
var
|
|
7070
|
+
var check6 = {
|
|
7186
7071
|
id: "pdf.print.color-spaces",
|
|
7187
7072
|
name: "Color Spaces",
|
|
7188
7073
|
description: "Checks for forbidden color spaces (DeviceRGB, Lab, Separation, DeviceN)",
|
|
@@ -7195,7 +7080,7 @@ var check5 = {
|
|
|
7195
7080
|
const results = [];
|
|
7196
7081
|
if (/\/DeviceRGB/.test(bytes)) {
|
|
7197
7082
|
results.push({
|
|
7198
|
-
checkId:
|
|
7083
|
+
checkId: check6.id,
|
|
7199
7084
|
severity: "error",
|
|
7200
7085
|
message: "DeviceRGB found (interior must be CMYK or grayscale only).",
|
|
7201
7086
|
file: ctx.pdfPath
|
|
@@ -7203,7 +7088,7 @@ var check5 = {
|
|
|
7203
7088
|
}
|
|
7204
7089
|
if (/\/Lab\b/.test(bytes)) {
|
|
7205
7090
|
results.push({
|
|
7206
|
-
checkId:
|
|
7091
|
+
checkId: check6.id,
|
|
7207
7092
|
severity: "error",
|
|
7208
7093
|
message: "Lab color space found (not allowed).",
|
|
7209
7094
|
file: ctx.pdfPath
|
|
@@ -7211,7 +7096,7 @@ var check5 = {
|
|
|
7211
7096
|
}
|
|
7212
7097
|
if (/\/Separation/.test(bytes)) {
|
|
7213
7098
|
results.push({
|
|
7214
|
-
checkId:
|
|
7099
|
+
checkId: check6.id,
|
|
7215
7100
|
severity: "error",
|
|
7216
7101
|
message: "Spot color (Separation) found (not allowed).",
|
|
7217
7102
|
file: ctx.pdfPath
|
|
@@ -7219,7 +7104,7 @@ var check5 = {
|
|
|
7219
7104
|
}
|
|
7220
7105
|
if (/\/DeviceN/.test(bytes)) {
|
|
7221
7106
|
results.push({
|
|
7222
|
-
checkId:
|
|
7107
|
+
checkId: check6.id,
|
|
7223
7108
|
severity: "error",
|
|
7224
7109
|
message: "Spot color (DeviceN) found (not allowed).",
|
|
7225
7110
|
file: ctx.pdfPath
|
|
@@ -7228,10 +7113,10 @@ var check5 = {
|
|
|
7228
7113
|
return results;
|
|
7229
7114
|
}
|
|
7230
7115
|
};
|
|
7231
|
-
registerCheck(
|
|
7116
|
+
registerCheck(check6);
|
|
7232
7117
|
|
|
7233
7118
|
// src/checks/pdf/embedded-fonts.ts
|
|
7234
|
-
var
|
|
7119
|
+
var check7 = {
|
|
7235
7120
|
id: "pdf.print.embedded-fonts",
|
|
7236
7121
|
name: "Embedded Fonts",
|
|
7237
7122
|
description: "Verifies all fonts in the PDF are embedded",
|
|
@@ -7247,7 +7132,7 @@ var check6 = {
|
|
|
7247
7132
|
if (fonts.length === 0) {
|
|
7248
7133
|
return [
|
|
7249
7134
|
{
|
|
7250
|
-
checkId:
|
|
7135
|
+
checkId: check7.id,
|
|
7251
7136
|
severity: "warning",
|
|
7252
7137
|
message: "No fonts detected (unexpected).",
|
|
7253
7138
|
file: ctx.pdfPath,
|
|
@@ -7260,7 +7145,7 @@ var check6 = {
|
|
|
7260
7145
|
const names = notEmbedded.map((f) => f.name);
|
|
7261
7146
|
return [
|
|
7262
7147
|
{
|
|
7263
|
-
checkId:
|
|
7148
|
+
checkId: check7.id,
|
|
7264
7149
|
severity: "error",
|
|
7265
7150
|
message: `Not all fonts are embedded (${names.join(", ")}). Check @font-face and Chromium output.`,
|
|
7266
7151
|
file: ctx.pdfPath,
|
|
@@ -7272,10 +7157,10 @@ var check6 = {
|
|
|
7272
7157
|
return [];
|
|
7273
7158
|
}
|
|
7274
7159
|
};
|
|
7275
|
-
registerCheck(
|
|
7160
|
+
registerCheck(check7);
|
|
7276
7161
|
|
|
7277
7162
|
// src/checks/pdf/ink-coverage.ts
|
|
7278
|
-
var
|
|
7163
|
+
var check8 = {
|
|
7279
7164
|
id: "pdf.print.ink-coverage",
|
|
7280
7165
|
name: "Ink Coverage (TAC)",
|
|
7281
7166
|
description: "Checks total area coverage (TAC) against maximum ink limits",
|
|
@@ -7289,7 +7174,7 @@ var check7 = {
|
|
|
7289
7174
|
if (!inkResult.ok) {
|
|
7290
7175
|
return [
|
|
7291
7176
|
{
|
|
7292
|
-
checkId:
|
|
7177
|
+
checkId: check8.id,
|
|
7293
7178
|
severity: "warning",
|
|
7294
7179
|
message: "Ink coverage could not be measured",
|
|
7295
7180
|
file: ctx.pdfPath,
|
|
@@ -7314,7 +7199,7 @@ var check7 = {
|
|
|
7314
7199
|
}
|
|
7315
7200
|
return [
|
|
7316
7201
|
{
|
|
7317
|
-
checkId:
|
|
7202
|
+
checkId: check8.id,
|
|
7318
7203
|
severity: "warning",
|
|
7319
7204
|
message: `Total ink coverage too high on ${offending.length} page(s) (max ${maxTac.toFixed(1)}%, recommended <=${ctx.config.ink.maxTac}%)`,
|
|
7320
7205
|
file: ctx.pdfPath,
|
|
@@ -7338,10 +7223,10 @@ var check7 = {
|
|
|
7338
7223
|
];
|
|
7339
7224
|
}
|
|
7340
7225
|
};
|
|
7341
|
-
registerCheck(
|
|
7226
|
+
registerCheck(check8);
|
|
7342
7227
|
|
|
7343
7228
|
// src/checks/pdf/rasterized-pages.ts
|
|
7344
|
-
var
|
|
7229
|
+
var check9 = {
|
|
7345
7230
|
id: "pdf.print.rasterized-pages",
|
|
7346
7231
|
name: "Rasterized Pages",
|
|
7347
7232
|
description: "Detects pages that appear to be fully rasterized (CSS filters, blend modes, transparency)",
|
|
@@ -7381,7 +7266,7 @@ var check8 = {
|
|
|
7381
7266
|
rasterizedPages.sort((a, b) => a - b);
|
|
7382
7267
|
return [
|
|
7383
7268
|
{
|
|
7384
|
-
checkId:
|
|
7269
|
+
checkId: check9.id,
|
|
7385
7270
|
severity: "warning",
|
|
7386
7271
|
message: `Possible rasterized pages detected: ${rasterizedPages.join(", ")}`,
|
|
7387
7272
|
file: ctx.pdfPath,
|
|
@@ -7392,11 +7277,11 @@ var check8 = {
|
|
|
7392
7277
|
];
|
|
7393
7278
|
}
|
|
7394
7279
|
};
|
|
7395
|
-
registerCheck(
|
|
7280
|
+
registerCheck(check9);
|
|
7396
7281
|
|
|
7397
7282
|
// src/checks/pdf/black-text.ts
|
|
7398
|
-
import { readFile as
|
|
7399
|
-
var
|
|
7283
|
+
import { readFile as readFile14 } from "node:fs/promises";
|
|
7284
|
+
var check10 = {
|
|
7400
7285
|
id: "pdf.print.black-text",
|
|
7401
7286
|
name: "Black Text",
|
|
7402
7287
|
description: "Warns when text at or below 24pt is painted in a dark four-colour mix (black, or a near-black colour such as a dark brown)",
|
|
@@ -7408,11 +7293,11 @@ var check9 = {
|
|
|
7408
7293
|
return [];
|
|
7409
7294
|
try {
|
|
7410
7295
|
const { findRichBlackText, LARGE_TEXT_PT } = await import("./black-text-gray-7dz61456.js");
|
|
7411
|
-
const found = await findRichBlackText(await
|
|
7296
|
+
const found = await findRichBlackText(await readFile14(ctx.pdfPath));
|
|
7412
7297
|
if (found.runs === 0)
|
|
7413
7298
|
return [];
|
|
7414
7299
|
return [
|
|
7415
|
-
finding(
|
|
7300
|
+
finding(check10.id, {
|
|
7416
7301
|
severity: "warning",
|
|
7417
7302
|
message: `Dark four-colour text at ${LARGE_TEXT_PT}pt or smaller on page(s) ${found.pages.join(", ")}.`,
|
|
7418
7303
|
file: ctx.pdfPath,
|
|
@@ -7423,17 +7308,17 @@ var check9 = {
|
|
|
7423
7308
|
];
|
|
7424
7309
|
} catch {
|
|
7425
7310
|
return [
|
|
7426
|
-
inspectionFailed(
|
|
7311
|
+
inspectionFailed(check10.id, "Could not inspect the PDF's text colours.", {
|
|
7427
7312
|
file: ctx.pdfPath
|
|
7428
7313
|
})
|
|
7429
7314
|
];
|
|
7430
7315
|
}
|
|
7431
7316
|
}
|
|
7432
7317
|
};
|
|
7433
|
-
registerCheck(
|
|
7318
|
+
registerCheck(check10);
|
|
7434
7319
|
|
|
7435
7320
|
// src/checks/pdf/signature.ts
|
|
7436
|
-
var
|
|
7321
|
+
var check11 = {
|
|
7437
7322
|
id: "pdf.print.signature",
|
|
7438
7323
|
name: "Signature",
|
|
7439
7324
|
description: "Fails when the interior's page count does not fit the print signature (a multiple of it ending on a blank page, or one short of a multiple)",
|
|
@@ -7445,7 +7330,7 @@ var check10 = {
|
|
|
7445
7330
|
return [];
|
|
7446
7331
|
const doc = await loadPdf(ctx.pdfPath);
|
|
7447
7332
|
if (!doc) {
|
|
7448
|
-
return [inspectionFailed(
|
|
7333
|
+
return [inspectionFailed(check11.id, "Could not parse the PDF's page count.", { file: ctx.pdfPath })];
|
|
7449
7334
|
}
|
|
7450
7335
|
const size = ctx.config.print.signature;
|
|
7451
7336
|
const pages = doc.numPages;
|
|
@@ -7454,7 +7339,7 @@ var check10 = {
|
|
|
7454
7339
|
const data = { pages, signature: size };
|
|
7455
7340
|
if (pages % size !== 0) {
|
|
7456
7341
|
return [
|
|
7457
|
-
finding(
|
|
7342
|
+
finding(check11.id, {
|
|
7458
7343
|
severity: "error",
|
|
7459
7344
|
message: `Page count ${pages} does not fit a signature of ${size}: it must be a multiple of ${size}, or one short of one.`,
|
|
7460
7345
|
file: ctx.pdfPath,
|
|
@@ -7470,10 +7355,10 @@ var check10 = {
|
|
|
7470
7355
|
if (!await pageHasMarks(doc, pages))
|
|
7471
7356
|
return [];
|
|
7472
7357
|
} catch {
|
|
7473
|
-
return [inspectionFailed(
|
|
7358
|
+
return [inspectionFailed(check11.id, "Could not read the last page.", { file: ctx.pdfPath })];
|
|
7474
7359
|
}
|
|
7475
7360
|
return [
|
|
7476
|
-
finding(
|
|
7361
|
+
finding(check11.id, {
|
|
7477
7362
|
severity: "error",
|
|
7478
7363
|
message: `The last page (${pages}) has content, but the printer needs it blank for its own information.`,
|
|
7479
7364
|
file: ctx.pdfPath,
|
|
@@ -7484,10 +7369,10 @@ var check10 = {
|
|
|
7484
7369
|
];
|
|
7485
7370
|
}
|
|
7486
7371
|
};
|
|
7487
|
-
registerCheck(
|
|
7372
|
+
registerCheck(check11);
|
|
7488
7373
|
|
|
7489
7374
|
// src/checks/pdf/bookmarks.ts
|
|
7490
|
-
var
|
|
7375
|
+
var check12 = {
|
|
7491
7376
|
id: "pdf.nav.bookmarks",
|
|
7492
7377
|
name: "Bookmarks",
|
|
7493
7378
|
description: "Checks for PDF outline (bookmarks) tree",
|
|
@@ -7501,14 +7386,14 @@ var check11 = {
|
|
|
7501
7386
|
const doc = await loadPdf(ctx.pdfPath);
|
|
7502
7387
|
if (!doc) {
|
|
7503
7388
|
return [
|
|
7504
|
-
inspectionFailed(
|
|
7389
|
+
inspectionFailed(check12.id, "Could not inspect PDF for bookmarks.", {
|
|
7505
7390
|
file: ctx.pdfPath
|
|
7506
7391
|
})
|
|
7507
7392
|
];
|
|
7508
7393
|
}
|
|
7509
7394
|
if (await getOutlineCount(doc) === 0) {
|
|
7510
7395
|
return [
|
|
7511
|
-
finding(
|
|
7396
|
+
finding(check12.id, {
|
|
7512
7397
|
severity: "warning",
|
|
7513
7398
|
message: "PDF does not contain bookmarks (outline tree).",
|
|
7514
7399
|
file: ctx.pdfPath
|
|
@@ -7518,10 +7403,10 @@ var check11 = {
|
|
|
7518
7403
|
return [];
|
|
7519
7404
|
}
|
|
7520
7405
|
};
|
|
7521
|
-
registerCheck(
|
|
7406
|
+
registerCheck(check12);
|
|
7522
7407
|
|
|
7523
7408
|
// src/checks/pdf/toc-links.ts
|
|
7524
|
-
var
|
|
7409
|
+
var check13 = {
|
|
7525
7410
|
id: "pdf.nav.toc-links",
|
|
7526
7411
|
name: "TOC Links",
|
|
7527
7412
|
description: "Detects link annotations on TOC pages",
|
|
@@ -7536,7 +7421,7 @@ var check12 = {
|
|
|
7536
7421
|
if (!doc) {
|
|
7537
7422
|
return [
|
|
7538
7423
|
{
|
|
7539
|
-
checkId:
|
|
7424
|
+
checkId: check13.id,
|
|
7540
7425
|
severity: "warning",
|
|
7541
7426
|
message: "Could not inspect PDF for TOC links.",
|
|
7542
7427
|
file: ctx.pdfPath
|
|
@@ -7547,7 +7432,7 @@ var check12 = {
|
|
|
7547
7432
|
if (!hasLinks) {
|
|
7548
7433
|
return [
|
|
7549
7434
|
{
|
|
7550
|
-
checkId:
|
|
7435
|
+
checkId: check13.id,
|
|
7551
7436
|
severity: "warning",
|
|
7552
7437
|
message: "No link annotations found in PDF (expected for TOC).",
|
|
7553
7438
|
file: ctx.pdfPath
|
|
@@ -7557,10 +7442,10 @@ var check12 = {
|
|
|
7557
7442
|
return [];
|
|
7558
7443
|
}
|
|
7559
7444
|
};
|
|
7560
|
-
registerCheck(
|
|
7445
|
+
registerCheck(check13);
|
|
7561
7446
|
|
|
7562
7447
|
// src/checks/pdf/cross-refs.ts
|
|
7563
|
-
var
|
|
7448
|
+
var check14 = {
|
|
7564
7449
|
id: "pdf.nav.cross-refs",
|
|
7565
7450
|
name: "Cross References",
|
|
7566
7451
|
description: "Counts and verifies internal link annotations",
|
|
@@ -7573,7 +7458,7 @@ var check13 = {
|
|
|
7573
7458
|
if (!doc) {
|
|
7574
7459
|
return [
|
|
7575
7460
|
{
|
|
7576
|
-
checkId:
|
|
7461
|
+
checkId: check14.id,
|
|
7577
7462
|
severity: "info",
|
|
7578
7463
|
message: "Could not inspect PDF for cross-references.",
|
|
7579
7464
|
file: ctx.pdfPath
|
|
@@ -7583,7 +7468,7 @@ var check13 = {
|
|
|
7583
7468
|
const linkCount = await countLinkAnnotations(doc);
|
|
7584
7469
|
return [
|
|
7585
7470
|
{
|
|
7586
|
-
checkId:
|
|
7471
|
+
checkId: check14.id,
|
|
7587
7472
|
severity: "info",
|
|
7588
7473
|
message: `PDF contains ${linkCount} internal link annotation${linkCount !== 1 ? "s" : ""}.`,
|
|
7589
7474
|
file: ctx.pdfPath
|
|
@@ -7591,10 +7476,10 @@ var check13 = {
|
|
|
7591
7476
|
];
|
|
7592
7477
|
}
|
|
7593
7478
|
};
|
|
7594
|
-
registerCheck(
|
|
7479
|
+
registerCheck(check14);
|
|
7595
7480
|
|
|
7596
7481
|
// src/checks/pdf/page-labels.ts
|
|
7597
|
-
var
|
|
7482
|
+
var check15 = {
|
|
7598
7483
|
id: "pdf.nav.page-labels",
|
|
7599
7484
|
name: "Page Labels",
|
|
7600
7485
|
description: "Verifies PDF page labels / folio numbering",
|
|
@@ -7609,7 +7494,7 @@ var check14 = {
|
|
|
7609
7494
|
const labels = await getPageLabels(doc);
|
|
7610
7495
|
return [
|
|
7611
7496
|
{
|
|
7612
|
-
checkId:
|
|
7497
|
+
checkId: check15.id,
|
|
7613
7498
|
severity: "info",
|
|
7614
7499
|
message: labels && labels.length > 0 ? "PDF contains page labels." : "PDF does not contain explicit page labels.",
|
|
7615
7500
|
file: ctx.pdfPath
|
|
@@ -7617,10 +7502,10 @@ var check14 = {
|
|
|
7617
7502
|
];
|
|
7618
7503
|
}
|
|
7619
7504
|
};
|
|
7620
|
-
registerCheck(
|
|
7505
|
+
registerCheck(check15);
|
|
7621
7506
|
|
|
7622
7507
|
// src/checks/pdf/image-resolution.ts
|
|
7623
|
-
var
|
|
7508
|
+
var check16 = {
|
|
7624
7509
|
id: "pdf.print.image-resolution",
|
|
7625
7510
|
name: "Image Resolution",
|
|
7626
7511
|
description: "Checks DPI of images embedded in the PDF",
|
|
@@ -7647,7 +7532,7 @@ var check15 = {
|
|
|
7647
7532
|
lowResPages.sort((a, b) => a - b);
|
|
7648
7533
|
return [
|
|
7649
7534
|
{
|
|
7650
|
-
checkId:
|
|
7535
|
+
checkId: check16.id,
|
|
7651
7536
|
severity: "warning",
|
|
7652
7537
|
message: `Low-resolution images (below ${minDpi} DPI) found on pages: ${lowResPages.join(", ")}`,
|
|
7653
7538
|
file: ctx.pdfPath
|
|
@@ -7657,10 +7542,10 @@ var check15 = {
|
|
|
7657
7542
|
return [];
|
|
7658
7543
|
}
|
|
7659
7544
|
};
|
|
7660
|
-
registerCheck(
|
|
7545
|
+
registerCheck(check16);
|
|
7661
7546
|
|
|
7662
7547
|
// src/checks/pdf/transparency.ts
|
|
7663
|
-
var
|
|
7548
|
+
var check17 = {
|
|
7664
7549
|
id: "pdf.print.transparency",
|
|
7665
7550
|
name: "Transparency",
|
|
7666
7551
|
description: "Checks for transparency markers (/Transparency, /SMask, /BM) in the PDF",
|
|
@@ -7682,7 +7567,7 @@ var check16 = {
|
|
|
7682
7567
|
if (found.length > 0) {
|
|
7683
7568
|
return [
|
|
7684
7569
|
{
|
|
7685
|
-
checkId:
|
|
7570
|
+
checkId: check17.id,
|
|
7686
7571
|
severity: "warning",
|
|
7687
7572
|
message: `Transparency detected in PDF: ${found.join(", ")}. This may cause issues with some printers.`,
|
|
7688
7573
|
file: ctx.pdfPath
|
|
@@ -7692,7 +7577,7 @@ var check16 = {
|
|
|
7692
7577
|
return [];
|
|
7693
7578
|
}
|
|
7694
7579
|
};
|
|
7695
|
-
registerCheck(
|
|
7580
|
+
registerCheck(check17);
|
|
7696
7581
|
|
|
7697
7582
|
// src/checks/pdf/bleed.ts
|
|
7698
7583
|
function findBox(bytes, box) {
|
|
@@ -7702,7 +7587,7 @@ function findBox(bytes, box) {
|
|
|
7702
7587
|
return null;
|
|
7703
7588
|
return [Number(m[1]), Number(m[2]), Number(m[3]), Number(m[4])];
|
|
7704
7589
|
}
|
|
7705
|
-
var
|
|
7590
|
+
var check18 = {
|
|
7706
7591
|
id: "pdf.print.bleed",
|
|
7707
7592
|
name: "Bleed Box",
|
|
7708
7593
|
description: "Compares MediaBox vs TrimBox/BleedBox to verify bleed area",
|
|
@@ -7716,7 +7601,7 @@ var check17 = {
|
|
|
7716
7601
|
const bytes = await readPdfBytes(ctx.pdfPath).catch(() => "");
|
|
7717
7602
|
if (!bytes) {
|
|
7718
7603
|
return [
|
|
7719
|
-
inspectionFailed(
|
|
7604
|
+
inspectionFailed(check18.id, "Could not inspect PDF for bleed boxes.", {
|
|
7720
7605
|
file: ctx.pdfPath
|
|
7721
7606
|
})
|
|
7722
7607
|
];
|
|
@@ -7726,14 +7611,14 @@ var check17 = {
|
|
|
7726
7611
|
const bleed = findBox(bytes, "BleedBox");
|
|
7727
7612
|
if (!media) {
|
|
7728
7613
|
return [
|
|
7729
|
-
inspectionFailed(
|
|
7614
|
+
inspectionFailed(check18.id, "Could not parse MediaBox from PDF.", {
|
|
7730
7615
|
file: ctx.pdfPath
|
|
7731
7616
|
})
|
|
7732
7617
|
];
|
|
7733
7618
|
}
|
|
7734
7619
|
if (!trim && !bleed) {
|
|
7735
7620
|
return [
|
|
7736
|
-
finding(
|
|
7621
|
+
finding(check18.id, {
|
|
7737
7622
|
severity: "warning",
|
|
7738
7623
|
message: "No TrimBox or BleedBox found. Bleed area cannot be verified.",
|
|
7739
7624
|
file: ctx.pdfPath
|
|
@@ -7746,7 +7631,7 @@ var check17 = {
|
|
|
7746
7631
|
const bleedSize = ctx.config.validate.pdf.bleedSize;
|
|
7747
7632
|
if (mediaW - trimW < bleedSize * 2 * 0.9) {
|
|
7748
7633
|
return [
|
|
7749
|
-
finding(
|
|
7634
|
+
finding(check18.id, {
|
|
7750
7635
|
severity: "warning",
|
|
7751
7636
|
message: `Bleed area appears insufficient. Expected at least ${bleedSize}pt on each side.`,
|
|
7752
7637
|
file: ctx.pdfPath
|
|
@@ -7757,10 +7642,10 @@ var check17 = {
|
|
|
7757
7642
|
return [];
|
|
7758
7643
|
}
|
|
7759
7644
|
};
|
|
7760
|
-
registerCheck(
|
|
7645
|
+
registerCheck(check18);
|
|
7761
7646
|
|
|
7762
7647
|
// src/checks/pdf/pdfx-metadata.ts
|
|
7763
|
-
var
|
|
7648
|
+
var check19 = {
|
|
7764
7649
|
id: "pdf.print.pdfx-metadata",
|
|
7765
7650
|
name: "PDF/X Metadata",
|
|
7766
7651
|
description: "Verifies PDF/X DOCINFO metadata via qpdf JSON",
|
|
@@ -7779,30 +7664,30 @@ var check18 = {
|
|
|
7779
7664
|
const objects = parseQpdfObjectsJson(stdout);
|
|
7780
7665
|
if (!objects) {
|
|
7781
7666
|
return [
|
|
7782
|
-
inspectionFailed(
|
|
7667
|
+
inspectionFailed(check19.id, "Unable to parse qpdf JSON output for PDF/X metadata checks.", { file: ctx.pdfPath })
|
|
7783
7668
|
];
|
|
7784
7669
|
}
|
|
7785
|
-
return getPdfxMetadataIssues(objects, ctx.config.pdfx.flavor).map((message) => finding(
|
|
7670
|
+
return getPdfxMetadataIssues(objects, ctx.config.pdfx.flavor).map((message) => finding(check19.id, {
|
|
7786
7671
|
severity: "error",
|
|
7787
7672
|
message,
|
|
7788
7673
|
file: ctx.pdfPath
|
|
7789
7674
|
}));
|
|
7790
7675
|
} catch {
|
|
7791
7676
|
return [
|
|
7792
|
-
inspectionFailed(
|
|
7677
|
+
inspectionFailed(check19.id, "Failed to inspect PDF objects with qpdf for PDF/X metadata.", { file: ctx.pdfPath })
|
|
7793
7678
|
];
|
|
7794
7679
|
}
|
|
7795
7680
|
}
|
|
7796
7681
|
};
|
|
7797
|
-
registerCheck(
|
|
7682
|
+
registerCheck(check19);
|
|
7798
7683
|
|
|
7799
7684
|
// src/checks/source/htmlhint.ts
|
|
7800
7685
|
import { existsSync as existsSync9 } from "node:fs";
|
|
7801
|
-
import { readFile as
|
|
7686
|
+
import { readFile as readFile15 } from "node:fs/promises";
|
|
7802
7687
|
import htmlhint from "htmlhint";
|
|
7803
7688
|
var { HTMLHint } = htmlhint;
|
|
7804
7689
|
var CONFIG_NAMES2 = [".htmlhintrc"];
|
|
7805
|
-
var
|
|
7690
|
+
var check20 = {
|
|
7806
7691
|
id: "source.htmlhint",
|
|
7807
7692
|
name: "HTMLHint",
|
|
7808
7693
|
description: "Runs htmlhint with project config to validate generated HTML",
|
|
@@ -7818,11 +7703,11 @@ var check19 = {
|
|
|
7818
7703
|
const resolvedConfig = findConfigFile(ctx.inputDir, CONFIG_NAMES2, configPath);
|
|
7819
7704
|
if (!resolvedConfig && !configPath)
|
|
7820
7705
|
return [];
|
|
7821
|
-
const ruleset = resolvedConfig ? JSON.parse(await
|
|
7822
|
-
const html = await
|
|
7706
|
+
const ruleset = resolvedConfig ? JSON.parse(await readFile15(resolvedConfig, "utf8")) : HTMLHint.defaultRuleset;
|
|
7707
|
+
const html = await readFile15(ctx.htmlPath, "utf8");
|
|
7823
7708
|
const messages = HTMLHint.verify(html, ruleset);
|
|
7824
7709
|
return messages.map((m) => ({
|
|
7825
|
-
checkId:
|
|
7710
|
+
checkId: check20.id,
|
|
7826
7711
|
severity: m.type === "error" ? "error" : "warning",
|
|
7827
7712
|
message: `${m.rule.id}: ${m.message}`,
|
|
7828
7713
|
file: ctx.htmlPath,
|
|
@@ -7831,10 +7716,10 @@ var check19 = {
|
|
|
7831
7716
|
}));
|
|
7832
7717
|
}
|
|
7833
7718
|
};
|
|
7834
|
-
registerCheck(
|
|
7719
|
+
registerCheck(check20);
|
|
7835
7720
|
|
|
7836
7721
|
// src/checks/source/stylelint.ts
|
|
7837
|
-
import { readFile as
|
|
7722
|
+
import { readFile as readFile16 } from "node:fs/promises";
|
|
7838
7723
|
|
|
7839
7724
|
// src/lib/printsafe.ts
|
|
7840
7725
|
import postcss2 from "postcss";
|
|
@@ -8176,7 +8061,7 @@ function checkCssRaw(css, from) {
|
|
|
8176
8061
|
warnings.push({
|
|
8177
8062
|
rule: ruleRiskyProps,
|
|
8178
8063
|
severity: "warning",
|
|
8179
|
-
message: `"${decl.prop}: ${decl.value}"
|
|
8064
|
+
message: `"${decl.prop}: ${decl.value}" is at risk in PDF/X exports (--format pdfx): Chromium emits repeating-*-gradient() and conic-gradient() in a form Ghostscript has been seen to paint as nothing or as irregular stripes, so it can print blank or distorted, unless the page also uses transparency and Ghostscript flattens the whole page to an image, which keeps the gradient but loses that page's live text. Plain PDF output is unaffected. Use linear-gradient() or radial-gradient() instead; for 0deg/90deg stripes write "linear-gradient(90deg, #b33 0 6px, #c8c5bf 6px 10px)" with "background-size: 10px 100%", and for anything else a small tiled image.`,
|
|
8180
8065
|
...nodeLoc(decl)
|
|
8181
8066
|
});
|
|
8182
8067
|
} else if (isUnpairedFitContentWidth(decl)) {
|
|
@@ -8224,7 +8109,7 @@ function checkCssRaw(css, from) {
|
|
|
8224
8109
|
}
|
|
8225
8110
|
|
|
8226
8111
|
// src/checks/source/stylelint.ts
|
|
8227
|
-
var
|
|
8112
|
+
var check21 = {
|
|
8228
8113
|
id: "source.stylelint",
|
|
8229
8114
|
name: "Print-safety CSS",
|
|
8230
8115
|
description: "Checks CSS for print-safety issues (remote URLs, rasterizing effects, and page-layer containment)",
|
|
@@ -8241,10 +8126,10 @@ var check20 = {
|
|
|
8241
8126
|
for (const file of files) {
|
|
8242
8127
|
let css;
|
|
8243
8128
|
try {
|
|
8244
|
-
css = await
|
|
8129
|
+
css = await readFile16(file, "utf8");
|
|
8245
8130
|
} catch (err) {
|
|
8246
8131
|
results.push({
|
|
8247
|
-
checkId:
|
|
8132
|
+
checkId: check21.id,
|
|
8248
8133
|
severity: "error",
|
|
8249
8134
|
message: `Cannot read stylesheet: ${err instanceof Error ? err.message : String(err)}`,
|
|
8250
8135
|
file
|
|
@@ -8253,7 +8138,7 @@ var check20 = {
|
|
|
8253
8138
|
}
|
|
8254
8139
|
for (const w of checkCss(css, file, { rules: ctx.config.lint.rules })) {
|
|
8255
8140
|
results.push({
|
|
8256
|
-
checkId:
|
|
8141
|
+
checkId: check21.id,
|
|
8257
8142
|
severity: w.severity,
|
|
8258
8143
|
message: `${w.rule}: ${w.message}`,
|
|
8259
8144
|
file,
|
|
@@ -8265,15 +8150,15 @@ var check20 = {
|
|
|
8265
8150
|
return results;
|
|
8266
8151
|
}
|
|
8267
8152
|
};
|
|
8268
|
-
registerCheck(
|
|
8153
|
+
registerCheck(check21);
|
|
8269
8154
|
|
|
8270
8155
|
// src/checks/source/css-ownership.ts
|
|
8271
|
-
import { readFile as
|
|
8156
|
+
import { readFile as readFile17 } from "node:fs/promises";
|
|
8272
8157
|
import postcss3 from "postcss";
|
|
8273
8158
|
import { parse as parseYaml3 } from "yaml";
|
|
8274
8159
|
var CONFIG_NAMES3 = [".gutterpress/css-contract.yaml", ".gutterpress/css-contract.yml"];
|
|
8275
8160
|
async function loadContract(configPath) {
|
|
8276
|
-
const raw = await
|
|
8161
|
+
const raw = await readFile17(configPath, "utf8");
|
|
8277
8162
|
const parsed = parseYaml3(raw);
|
|
8278
8163
|
if (parsed && typeof parsed === "object")
|
|
8279
8164
|
return parsed;
|
|
@@ -8386,7 +8271,7 @@ function checkOwnership(root, file, maps) {
|
|
|
8386
8271
|
});
|
|
8387
8272
|
return out;
|
|
8388
8273
|
}
|
|
8389
|
-
var
|
|
8274
|
+
var check22 = {
|
|
8390
8275
|
id: "source.css-ownership",
|
|
8391
8276
|
name: "CSS ownership contract",
|
|
8392
8277
|
description: "Checks an optional per-project CSS ownership contract (.gutterpress/css-contract.yaml): which file may declare which properties/at-rules, and which selectors must never appear unscoped.",
|
|
@@ -8409,7 +8294,7 @@ var check21 = {
|
|
|
8409
8294
|
} catch (err) {
|
|
8410
8295
|
return [
|
|
8411
8296
|
{
|
|
8412
|
-
checkId:
|
|
8297
|
+
checkId: check22.id,
|
|
8413
8298
|
severity: "error",
|
|
8414
8299
|
message: `Failed to parse CSS ownership contract "${configPath}": ${err instanceof Error ? err.message : String(err)}`,
|
|
8415
8300
|
file: configPath
|
|
@@ -8424,7 +8309,7 @@ var check21 = {
|
|
|
8424
8309
|
continue;
|
|
8425
8310
|
let css;
|
|
8426
8311
|
try {
|
|
8427
|
-
css = await
|
|
8312
|
+
css = await readFile17(absFile, "utf8");
|
|
8428
8313
|
} catch {
|
|
8429
8314
|
continue;
|
|
8430
8315
|
}
|
|
@@ -8451,7 +8336,7 @@ var check21 = {
|
|
|
8451
8336
|
}
|
|
8452
8337
|
for (const v of violations) {
|
|
8453
8338
|
results.push({
|
|
8454
|
-
checkId:
|
|
8339
|
+
checkId: check22.id,
|
|
8455
8340
|
severity: "warning",
|
|
8456
8341
|
message: v.message,
|
|
8457
8342
|
file: absFile,
|
|
@@ -8463,14 +8348,14 @@ var check21 = {
|
|
|
8463
8348
|
return results;
|
|
8464
8349
|
}
|
|
8465
8350
|
};
|
|
8466
|
-
registerCheck(
|
|
8351
|
+
registerCheck(check22);
|
|
8467
8352
|
|
|
8468
8353
|
// src/checks/source/local-refs.ts
|
|
8469
8354
|
import { existsSync as existsSync10 } from "node:fs";
|
|
8470
8355
|
import { dirname as dirname3, resolve as resolve6 } from "node:path";
|
|
8471
8356
|
|
|
8472
8357
|
// src/checks/source/local-ref-parser.ts
|
|
8473
|
-
import { readFile as
|
|
8358
|
+
import { readFile as readFile18 } from "node:fs/promises";
|
|
8474
8359
|
function newlineOffsets(content) {
|
|
8475
8360
|
const offsets = [];
|
|
8476
8361
|
for (let i = 0;i < content.length; i++)
|
|
@@ -8539,7 +8424,7 @@ async function* renderedLocalRefs(ctx, checkId, results) {
|
|
|
8539
8424
|
for (const file of files) {
|
|
8540
8425
|
let refs;
|
|
8541
8426
|
try {
|
|
8542
|
-
refs = collectRenderedLocalRefs(await
|
|
8427
|
+
refs = collectRenderedLocalRefs(await readFile18(file, "utf8"));
|
|
8543
8428
|
} catch {
|
|
8544
8429
|
results.push(inspectionFailed(checkId, `Could not read source file: ${file}`, { file }));
|
|
8545
8430
|
continue;
|
|
@@ -8550,7 +8435,7 @@ async function* renderedLocalRefs(ctx, checkId, results) {
|
|
|
8550
8435
|
}
|
|
8551
8436
|
|
|
8552
8437
|
// src/checks/source/local-refs.ts
|
|
8553
|
-
var
|
|
8438
|
+
var check23 = {
|
|
8554
8439
|
id: "source.links.local-refs",
|
|
8555
8440
|
name: "Local Markdown References",
|
|
8556
8441
|
description: "Checks local markdown links and image refs resolve on disk",
|
|
@@ -8558,12 +8443,12 @@ var check22 = {
|
|
|
8558
8443
|
phase: "pre-build",
|
|
8559
8444
|
async run(ctx) {
|
|
8560
8445
|
const results = [];
|
|
8561
|
-
for await (const { ref, kind, line, file } of renderedLocalRefs(ctx,
|
|
8446
|
+
for await (const { ref, kind, line, file } of renderedLocalRefs(ctx, check23.id, results)) {
|
|
8562
8447
|
if (isNonFilesystemRef(ref))
|
|
8563
8448
|
continue;
|
|
8564
8449
|
const escape = kind === "image" ? proseImageRefError(ref, ctx.inputDir) : null;
|
|
8565
8450
|
if (escape) {
|
|
8566
|
-
results.push(finding(
|
|
8451
|
+
results.push(finding(check23.id, {
|
|
8567
8452
|
severity: "error",
|
|
8568
8453
|
message: escape,
|
|
8569
8454
|
file,
|
|
@@ -8573,7 +8458,7 @@ var check22 = {
|
|
|
8573
8458
|
}
|
|
8574
8459
|
if (localRefExists(ref, kind, file, ctx.inputDir))
|
|
8575
8460
|
continue;
|
|
8576
|
-
results.push(finding(
|
|
8461
|
+
results.push(finding(check23.id, {
|
|
8577
8462
|
severity: kind === "image" ? "warning" : "error",
|
|
8578
8463
|
code: kind === "image" ? "missing-image-placeholder" : undefined,
|
|
8579
8464
|
message: kind === "image" ? `Local image not found; build will substitute a magenta placeholder: ${ref}` : `Local reference not found: ${ref}`,
|
|
@@ -8598,7 +8483,7 @@ function localRefExists(ref, kind, sourceFile, projectRoot) {
|
|
|
8598
8483
|
return existsSync10(fileRelative);
|
|
8599
8484
|
}
|
|
8600
8485
|
}
|
|
8601
|
-
registerCheck(
|
|
8486
|
+
registerCheck(check23);
|
|
8602
8487
|
|
|
8603
8488
|
// src/lib/build-staging.ts
|
|
8604
8489
|
import path11 from "node:path";
|
|
@@ -8864,7 +8749,7 @@ async function createStageRoot() {
|
|
|
8864
8749
|
}
|
|
8865
8750
|
|
|
8866
8751
|
// src/checks/source/dangling-links.ts
|
|
8867
|
-
var
|
|
8752
|
+
var check24 = {
|
|
8868
8753
|
id: "source.links.dangling",
|
|
8869
8754
|
name: "Dangling Links",
|
|
8870
8755
|
description: "Flags relative links the printed book cannot open (their href is dropped at print time)",
|
|
@@ -8872,10 +8757,10 @@ var check23 = {
|
|
|
8872
8757
|
phase: "pre-build",
|
|
8873
8758
|
async run(ctx) {
|
|
8874
8759
|
const results = [];
|
|
8875
|
-
for await (const { ref, kind, line, file } of renderedLocalRefs(ctx,
|
|
8760
|
+
for await (const { ref, kind, line, file } of renderedLocalRefs(ctx, check24.id, results)) {
|
|
8876
8761
|
if (kind !== "link" || isPrintResolvableHref(ref))
|
|
8877
8762
|
continue;
|
|
8878
|
-
results.push(finding(
|
|
8763
|
+
results.push(finding(check24.id, {
|
|
8879
8764
|
severity: "warning",
|
|
8880
8765
|
code: "dangling-link",
|
|
8881
8766
|
data: { ref },
|
|
@@ -8887,11 +8772,11 @@ var check23 = {
|
|
|
8887
8772
|
return results;
|
|
8888
8773
|
}
|
|
8889
8774
|
};
|
|
8890
|
-
registerCheck(
|
|
8775
|
+
registerCheck(check24);
|
|
8891
8776
|
|
|
8892
8777
|
// src/checks/source/accessibility-alt-text.ts
|
|
8893
|
-
import { readFile as
|
|
8894
|
-
var
|
|
8778
|
+
import { readFile as readFile19 } from "node:fs/promises";
|
|
8779
|
+
var check25 = {
|
|
8895
8780
|
id: "source.accessibility.alt-text",
|
|
8896
8781
|
name: "Image Alt Text",
|
|
8897
8782
|
description: "Checks markdown images include non-empty alt text",
|
|
@@ -8904,7 +8789,7 @@ var check24 = {
|
|
|
8904
8789
|
const results = [];
|
|
8905
8790
|
for (const file of files) {
|
|
8906
8791
|
try {
|
|
8907
|
-
const content = await
|
|
8792
|
+
const content = await readFile19(file, "utf8");
|
|
8908
8793
|
const lines = content.split(`
|
|
8909
8794
|
`);
|
|
8910
8795
|
let inFence = false;
|
|
@@ -8920,7 +8805,7 @@ var check24 = {
|
|
|
8920
8805
|
if (alt.trim())
|
|
8921
8806
|
continue;
|
|
8922
8807
|
results.push({
|
|
8923
|
-
checkId:
|
|
8808
|
+
checkId: check25.id,
|
|
8924
8809
|
severity: "warning",
|
|
8925
8810
|
message: "Image is missing alt text",
|
|
8926
8811
|
file,
|
|
@@ -8945,11 +8830,11 @@ function extractImageAlts(line) {
|
|
|
8945
8830
|
}
|
|
8946
8831
|
return alts;
|
|
8947
8832
|
}
|
|
8948
|
-
registerCheck(
|
|
8833
|
+
registerCheck(check25);
|
|
8949
8834
|
|
|
8950
8835
|
// src/checks/source/accessibility-heading-order.ts
|
|
8951
|
-
import { readFile as
|
|
8952
|
-
var
|
|
8836
|
+
import { readFile as readFile20 } from "node:fs/promises";
|
|
8837
|
+
var check26 = {
|
|
8953
8838
|
id: "source.accessibility.heading-order",
|
|
8954
8839
|
name: "Heading Order",
|
|
8955
8840
|
description: "Checks markdown heading levels do not jump by more than one",
|
|
@@ -8962,7 +8847,7 @@ var check25 = {
|
|
|
8962
8847
|
const results = [];
|
|
8963
8848
|
for (const file of files) {
|
|
8964
8849
|
try {
|
|
8965
|
-
const content = await
|
|
8850
|
+
const content = await readFile20(file, "utf8");
|
|
8966
8851
|
const lines = content.split(`
|
|
8967
8852
|
`);
|
|
8968
8853
|
let inFence = false;
|
|
@@ -8977,7 +8862,7 @@ var check25 = {
|
|
|
8977
8862
|
if (inFence)
|
|
8978
8863
|
continue;
|
|
8979
8864
|
const comment = /^\s*<!--(.*)-->\s*$/.exec(line);
|
|
8980
|
-
if (comment && parseDisableDirective(comment[1])?.includes(
|
|
8865
|
+
if (comment && parseDisableDirective(comment[1])?.includes(check26.id)) {
|
|
8981
8866
|
silencedLine = i + 1;
|
|
8982
8867
|
continue;
|
|
8983
8868
|
}
|
|
@@ -8987,7 +8872,7 @@ var check25 = {
|
|
|
8987
8872
|
const level = match[1].length;
|
|
8988
8873
|
if (prevLevel != null && level > prevLevel + 1 && i !== silencedLine) {
|
|
8989
8874
|
results.push({
|
|
8990
|
-
checkId:
|
|
8875
|
+
checkId: check26.id,
|
|
8991
8876
|
severity: "warning",
|
|
8992
8877
|
message: `Heading level jump from h${prevLevel} to h${level}`,
|
|
8993
8878
|
file,
|
|
@@ -9001,10 +8886,10 @@ var check25 = {
|
|
|
9001
8886
|
return results;
|
|
9002
8887
|
}
|
|
9003
8888
|
};
|
|
9004
|
-
registerCheck(
|
|
8889
|
+
registerCheck(check26);
|
|
9005
8890
|
|
|
9006
8891
|
// src/checks/source/layout-markers.ts
|
|
9007
|
-
import { readFile as
|
|
8892
|
+
import { readFile as readFile21 } from "node:fs/promises";
|
|
9008
8893
|
|
|
9009
8894
|
// src/lib/unknown-classes.ts
|
|
9010
8895
|
import postcss4 from "postcss";
|
|
@@ -9107,12 +8992,12 @@ async function collectKnownClasses(ctx, plugins) {
|
|
|
9107
8992
|
const sheets = (await collectStyleDependencies(ctx.inputDir, roots)).filter((f) => /\.css$/i.test(f));
|
|
9108
8993
|
for (const sheet of sheets) {
|
|
9109
8994
|
try {
|
|
9110
|
-
addCssClasses(await
|
|
8995
|
+
addCssClasses(await readFile21(sheet, "utf8"), names);
|
|
9111
8996
|
} catch {}
|
|
9112
8997
|
}
|
|
9113
8998
|
return names;
|
|
9114
8999
|
}
|
|
9115
|
-
var
|
|
9000
|
+
var check27 = {
|
|
9116
9001
|
id: "source.markdown.layout-markers",
|
|
9117
9002
|
name: "Layout Markers",
|
|
9118
9003
|
description: "Reports @page/@section/@chapter marker arguments Gutterpress could not understand, plus any unknown gp-* class and any other class no stylesheet mentions",
|
|
@@ -9124,14 +9009,14 @@ var check26 = {
|
|
|
9124
9009
|
return [];
|
|
9125
9010
|
const results = [];
|
|
9126
9011
|
const plugins = await loadPlugins(ctx.config.extensions, ctx.inputDir, (ref, error2) => {
|
|
9127
|
-
results.push(inspectionFailed(
|
|
9012
|
+
results.push(inspectionFailed(check27.id, `Plugin "${ref}" could not be loaded, so markers it defines were not checked: ${error2.message}`));
|
|
9128
9013
|
});
|
|
9129
9014
|
const md = createMarkdownRenderer(plugins);
|
|
9130
9015
|
let known;
|
|
9131
9016
|
const knownClasses = () => known ??= collectKnownClasses(ctx, plugins);
|
|
9132
9017
|
for (const file of files) {
|
|
9133
9018
|
try {
|
|
9134
|
-
const content = await
|
|
9019
|
+
const content = await readFile21(file, "utf8");
|
|
9135
9020
|
const env = {};
|
|
9136
9021
|
const tokens = md.parse(content, env);
|
|
9137
9022
|
md.renderer.render(tokens, md.options, env);
|
|
@@ -9143,7 +9028,7 @@ var check26 = {
|
|
|
9143
9028
|
if (names.has(cls) || warnedLines.has(use.line))
|
|
9144
9029
|
continue;
|
|
9145
9030
|
const guess = nearestKnownClass(cls, names);
|
|
9146
|
-
results.push(finding(
|
|
9031
|
+
results.push(finding(check27.id, {
|
|
9147
9032
|
severity: "warning",
|
|
9148
9033
|
message: `Class ".${cls}" is not in any stylesheet (Gutterpress's own, the plugins', or this book's), so it styles nothing.` + (guess ? ` Did you mean ".${guess}"?` : "") + (use.count > 1 ? ` Used ${use.count} times in this file; the first is reported.` : ""),
|
|
9149
9034
|
file,
|
|
@@ -9153,7 +9038,7 @@ var check26 = {
|
|
|
9153
9038
|
}
|
|
9154
9039
|
}
|
|
9155
9040
|
for (const w of env.layoutWarnings ?? []) {
|
|
9156
|
-
results.push(finding(
|
|
9041
|
+
results.push(finding(check27.id, {
|
|
9157
9042
|
severity: w.severity ?? "warning",
|
|
9158
9043
|
message: w.message,
|
|
9159
9044
|
file,
|
|
@@ -9162,16 +9047,16 @@ var check26 = {
|
|
|
9162
9047
|
}));
|
|
9163
9048
|
}
|
|
9164
9049
|
} catch (error2) {
|
|
9165
|
-
results.push(inspectionFailed(
|
|
9050
|
+
results.push(inspectionFailed(check27.id, `Could not check layout markers in ${file}: ${error2 instanceof Error ? error2.message : String(error2)}`, { file }));
|
|
9166
9051
|
}
|
|
9167
9052
|
}
|
|
9168
9053
|
return results;
|
|
9169
9054
|
}
|
|
9170
9055
|
};
|
|
9171
|
-
registerCheck(
|
|
9056
|
+
registerCheck(check27);
|
|
9172
9057
|
|
|
9173
9058
|
// src/checks/source/merge-markers.ts
|
|
9174
|
-
import { readFile as
|
|
9059
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
9175
9060
|
import path12 from "node:path";
|
|
9176
9061
|
|
|
9177
9062
|
// src/checks/asset/extensions.ts
|
|
@@ -9201,7 +9086,7 @@ var CLOSE_SENTINEL = ">>>>>>> online version";
|
|
|
9201
9086
|
function withoutOnlineTag(relPath) {
|
|
9202
9087
|
return relPath.replace(/\.online(?=\.[^./]*$|$)/, "");
|
|
9203
9088
|
}
|
|
9204
|
-
var
|
|
9089
|
+
var check28 = {
|
|
9205
9090
|
id: "source.sync.merge-markers",
|
|
9206
9091
|
name: "Combined Versions",
|
|
9207
9092
|
description: "Finds passages and files still holding two versions (yours and the online copy) after a sync",
|
|
@@ -9213,9 +9098,9 @@ var check27 = {
|
|
|
9213
9098
|
for (const file of textFiles) {
|
|
9214
9099
|
let content;
|
|
9215
9100
|
try {
|
|
9216
|
-
content = await
|
|
9101
|
+
content = await readFile22(file, "utf8");
|
|
9217
9102
|
} catch {
|
|
9218
|
-
results.push(inspectionFailed(
|
|
9103
|
+
results.push(inspectionFailed(check28.id, `Could not read source file: ${file}`, { file }));
|
|
9219
9104
|
continue;
|
|
9220
9105
|
}
|
|
9221
9106
|
if (!content.includes(OPEN_SENTINEL) && !content.includes(CLOSE_SENTINEL))
|
|
@@ -9227,7 +9112,7 @@ var check27 = {
|
|
|
9227
9112
|
const line = lines[i].endsWith("\r") ? lines[i].slice(0, -1) : lines[i];
|
|
9228
9113
|
if (line === OPEN_SENTINEL) {
|
|
9229
9114
|
inBlock = true;
|
|
9230
|
-
results.push(finding(
|
|
9115
|
+
results.push(finding(check28.id, {
|
|
9231
9116
|
severity: "error",
|
|
9232
9117
|
code: "two-versions-passage",
|
|
9233
9118
|
message: "This passage has two versions (yours and the online copy) — keep what you want, then delete the marker lines.",
|
|
@@ -9236,7 +9121,7 @@ var check27 = {
|
|
|
9236
9121
|
}));
|
|
9237
9122
|
} else if (line === CLOSE_SENTINEL) {
|
|
9238
9123
|
if (!inBlock) {
|
|
9239
|
-
results.push(finding(
|
|
9124
|
+
results.push(finding(check28.id, {
|
|
9240
9125
|
severity: "error",
|
|
9241
9126
|
code: "leftover-version-marker",
|
|
9242
9127
|
message: "This marker line is left over from combining two versions — delete it.",
|
|
@@ -9257,7 +9142,7 @@ var check27 = {
|
|
|
9257
9142
|
});
|
|
9258
9143
|
for (const sibling of siblings.sort()) {
|
|
9259
9144
|
const rel = path12.relative(ctx.inputDir, sibling).split(path12.sep).join("/");
|
|
9260
|
-
results.push(finding(
|
|
9145
|
+
results.push(finding(check28.id, {
|
|
9261
9146
|
severity: "warning",
|
|
9262
9147
|
code: "kept-both-versions",
|
|
9263
9148
|
message: `Two versions of ${withoutOnlineTag(rel)} are in your book — keep the one you want, then delete the other.`,
|
|
@@ -9265,15 +9150,15 @@ var check27 = {
|
|
|
9265
9150
|
}));
|
|
9266
9151
|
}
|
|
9267
9152
|
} catch (error2) {
|
|
9268
|
-
results.push(inspectionFailed(
|
|
9153
|
+
results.push(inspectionFailed(check28.id, `Could not scan for kept-both files: ${error2 instanceof Error ? error2.message : String(error2)}`));
|
|
9269
9154
|
}
|
|
9270
9155
|
return results;
|
|
9271
9156
|
}
|
|
9272
9157
|
};
|
|
9273
|
-
registerCheck(
|
|
9158
|
+
registerCheck(check28);
|
|
9274
9159
|
|
|
9275
9160
|
// src/checks/source/characters.ts
|
|
9276
|
-
import { readFile as
|
|
9161
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
9277
9162
|
|
|
9278
9163
|
// src/checks/source/character-table.ts
|
|
9279
9164
|
var CHARACTER_PATTERN = new RegExp("[\\u0000-\\u0008\\u000B\\u000C\\u000E-\\u001F\\u007F-\\u00A0\\u00AD\\u00B4\\u02BC" + "\\u061C\\u2000-\\u2015\\u2018\\u2019\\u201B-\\u201D\\u201F\\u2022\\u2026" + "\\u2028-\\u202F\\u2032\\u2033\\u205F\\u2060\\u2066-\\u2069\\u2190\\u2192" + "\\u2194\\u21D2\\u2212\\u25AA\\u25E6\\u2605\\u2713\\u2714\\u2717\\u3000" + "\\uE000-\\uF8FF\\uFEFF\\uFF02\\uFF07\\uFFFD]" + "|\\p{Emoji_Presentation}|\\p{Extended_Pictographic}(?=\\uFE0F)", "gu");
|
|
@@ -9385,7 +9270,7 @@ function codePointLabel(char) {
|
|
|
9385
9270
|
|
|
9386
9271
|
// src/checks/source/characters.ts
|
|
9387
9272
|
var PROBE = new RegExp(CHARACTER_PATTERN.source, "u");
|
|
9388
|
-
var
|
|
9273
|
+
var check29 = {
|
|
9389
9274
|
id: "source.characters",
|
|
9390
9275
|
name: "Unusual Characters",
|
|
9391
9276
|
description: "Finds invisible and control characters, odd spaces, and pasted typography (em dashes, curly quotes, emoji) in markdown",
|
|
@@ -9396,9 +9281,9 @@ var check28 = {
|
|
|
9396
9281
|
for (const file of (ctx.markdownFiles ?? []).slice().sort()) {
|
|
9397
9282
|
let content;
|
|
9398
9283
|
try {
|
|
9399
|
-
content = await
|
|
9284
|
+
content = await readFile23(file, "utf8");
|
|
9400
9285
|
} catch {
|
|
9401
|
-
results.push(inspectionFailed(
|
|
9286
|
+
results.push(inspectionFailed(check29.id, `Could not read source file: ${file}`, { file }));
|
|
9402
9287
|
continue;
|
|
9403
9288
|
}
|
|
9404
9289
|
if (!PROBE.test(content))
|
|
@@ -9409,7 +9294,7 @@ var check28 = {
|
|
|
9409
9294
|
for (let i = 0;i < lines.length; i++) {
|
|
9410
9295
|
const line = lines[i];
|
|
9411
9296
|
const comment = /^\s*<!--(.*)-->\s*$/.exec(line);
|
|
9412
|
-
if (comment && parseDisableDirective(comment[1])?.includes(
|
|
9297
|
+
if (comment && parseDisableDirective(comment[1])?.includes(check29.id)) {
|
|
9413
9298
|
silencedLine = i + 1;
|
|
9414
9299
|
continue;
|
|
9415
9300
|
}
|
|
@@ -9418,7 +9303,7 @@ var check28 = {
|
|
|
9418
9303
|
for (const match of line.matchAll(CHARACTER_PATTERN)) {
|
|
9419
9304
|
const char = match[0];
|
|
9420
9305
|
const { name, code, fix } = describeCharacter(char);
|
|
9421
|
-
results.push(finding(
|
|
9306
|
+
results.push(finding(check29.id, {
|
|
9422
9307
|
severity: code === "typographer" ? "info" : "warning",
|
|
9423
9308
|
code,
|
|
9424
9309
|
message: `${name} (${codePointLabel(char)}). ${fix}`,
|
|
@@ -9433,19 +9318,19 @@ var check28 = {
|
|
|
9433
9318
|
return results;
|
|
9434
9319
|
}
|
|
9435
9320
|
};
|
|
9436
|
-
registerCheck(
|
|
9321
|
+
registerCheck(check29);
|
|
9437
9322
|
|
|
9438
9323
|
// src/checks/asset/image-file-size.ts
|
|
9439
|
-
import { stat as
|
|
9324
|
+
import { stat as stat3 } from "node:fs/promises";
|
|
9440
9325
|
|
|
9441
9326
|
// src/lib/image-inspect.ts
|
|
9442
|
-
import { stat as
|
|
9327
|
+
import { stat as stat2, readFile as readFile24 } from "node:fs/promises";
|
|
9443
9328
|
var DEFAULT_DPI = 72;
|
|
9444
9329
|
var cache = new Map;
|
|
9445
9330
|
async function inspectImage(path13) {
|
|
9446
9331
|
let st;
|
|
9447
9332
|
try {
|
|
9448
|
-
st = await
|
|
9333
|
+
st = await stat2(path13);
|
|
9449
9334
|
} catch {
|
|
9450
9335
|
return null;
|
|
9451
9336
|
}
|
|
@@ -9454,7 +9339,7 @@ async function inspectImage(path13) {
|
|
|
9454
9339
|
return hit.info;
|
|
9455
9340
|
let info3 = null;
|
|
9456
9341
|
try {
|
|
9457
|
-
const buf = await
|
|
9342
|
+
const buf = await readFile24(path13);
|
|
9458
9343
|
info3 = parseImage(buf);
|
|
9459
9344
|
} catch {
|
|
9460
9345
|
info3 = null;
|
|
@@ -9659,7 +9544,7 @@ async function collectImageFiles(dirs, exts, ignore2 = ASSET_SCAN_IGNORE_GLOBS)
|
|
|
9659
9544
|
}
|
|
9660
9545
|
|
|
9661
9546
|
// src/checks/asset/image-file-size.ts
|
|
9662
|
-
var
|
|
9547
|
+
var check30 = {
|
|
9663
9548
|
id: "asset.image.file-size",
|
|
9664
9549
|
name: "Image File Size",
|
|
9665
9550
|
description: "Checks that image files do not exceed the maximum size limit",
|
|
@@ -9676,18 +9561,18 @@ var check29 = {
|
|
|
9676
9561
|
const results = [];
|
|
9677
9562
|
for (const file of files) {
|
|
9678
9563
|
try {
|
|
9679
|
-
const info3 = await
|
|
9564
|
+
const info3 = await stat3(file);
|
|
9680
9565
|
if (info3.size > maxSize) {
|
|
9681
9566
|
const sizeMb = (info3.size / 1e6).toFixed(1);
|
|
9682
9567
|
const maxMb = (maxSize / 1e6).toFixed(1);
|
|
9683
|
-
results.push(finding(
|
|
9568
|
+
results.push(finding(check30.id, {
|
|
9684
9569
|
severity: "warning",
|
|
9685
9570
|
message: `Image file too large: ${sizeMb}MB (max ${maxMb}MB)`,
|
|
9686
9571
|
file
|
|
9687
9572
|
}));
|
|
9688
9573
|
}
|
|
9689
9574
|
} catch {
|
|
9690
|
-
results.push(inspectionFailed(
|
|
9575
|
+
results.push(inspectionFailed(check30.id, `Could not stat image file: ${file}`, {
|
|
9691
9576
|
file
|
|
9692
9577
|
}));
|
|
9693
9578
|
}
|
|
@@ -9695,10 +9580,10 @@ var check29 = {
|
|
|
9695
9580
|
return results;
|
|
9696
9581
|
}
|
|
9697
9582
|
};
|
|
9698
|
-
registerCheck(
|
|
9583
|
+
registerCheck(check30);
|
|
9699
9584
|
|
|
9700
9585
|
// src/checks/asset/image-resolution.ts
|
|
9701
|
-
var
|
|
9586
|
+
var check31 = {
|
|
9702
9587
|
id: "asset.image.resolution",
|
|
9703
9588
|
name: "Image Resolution",
|
|
9704
9589
|
description: "Checks source image DPI from embedded density metadata",
|
|
@@ -9720,7 +9605,7 @@ var check30 = {
|
|
|
9720
9605
|
const { xDpi, yDpi } = info3;
|
|
9721
9606
|
if (xDpi > 0 && yDpi > 0 && (xDpi < minDpi || yDpi < minDpi)) {
|
|
9722
9607
|
results.push({
|
|
9723
|
-
checkId:
|
|
9608
|
+
checkId: check31.id,
|
|
9724
9609
|
severity: "warning",
|
|
9725
9610
|
message: `Image resolution too low: ${xDpi}x${yDpi} DPI (minimum ${minDpi} DPI)`,
|
|
9726
9611
|
file
|
|
@@ -9730,7 +9615,7 @@ var check30 = {
|
|
|
9730
9615
|
return results;
|
|
9731
9616
|
}
|
|
9732
9617
|
};
|
|
9733
|
-
registerCheck(
|
|
9618
|
+
registerCheck(check31);
|
|
9734
9619
|
|
|
9735
9620
|
// src/checks/asset/image-color-space.ts
|
|
9736
9621
|
var LABEL = {
|
|
@@ -9738,7 +9623,7 @@ var LABEL = {
|
|
|
9738
9623
|
gray: "Gray",
|
|
9739
9624
|
cmyk: "CMYK"
|
|
9740
9625
|
};
|
|
9741
|
-
var
|
|
9626
|
+
var check32 = {
|
|
9742
9627
|
id: "asset.image.color-space",
|
|
9743
9628
|
name: "Image Color Space",
|
|
9744
9629
|
description: "Validates image color spaces against allowed list",
|
|
@@ -9759,7 +9644,7 @@ var check31 = {
|
|
|
9759
9644
|
const cs = info3?.colorSpace;
|
|
9760
9645
|
if (cs && !allowedLower.has(cs)) {
|
|
9761
9646
|
results.push({
|
|
9762
|
-
checkId:
|
|
9647
|
+
checkId: check32.id,
|
|
9763
9648
|
severity: "warning",
|
|
9764
9649
|
message: `Image uses ${LABEL[cs] ?? cs} color space (allowed: ${allowed.join(", ")})`,
|
|
9765
9650
|
file
|
|
@@ -9769,10 +9654,10 @@ var check31 = {
|
|
|
9769
9654
|
return results;
|
|
9770
9655
|
}
|
|
9771
9656
|
};
|
|
9772
|
-
registerCheck(
|
|
9657
|
+
registerCheck(check32);
|
|
9773
9658
|
|
|
9774
9659
|
// src/checks/asset/image-alpha.ts
|
|
9775
|
-
var
|
|
9660
|
+
var check33 = {
|
|
9776
9661
|
id: "asset.image.alpha-channel",
|
|
9777
9662
|
name: "Image Alpha Channel",
|
|
9778
9663
|
description: "Checks for alpha channels in PNG/TIFF images",
|
|
@@ -9790,7 +9675,7 @@ var check32 = {
|
|
|
9790
9675
|
const info3 = await inspectImage(file);
|
|
9791
9676
|
if (info3?.hasAlpha) {
|
|
9792
9677
|
results.push({
|
|
9793
|
-
checkId:
|
|
9678
|
+
checkId: check33.id,
|
|
9794
9679
|
severity: "warning",
|
|
9795
9680
|
message: "Image contains alpha channel, which may cause print issues",
|
|
9796
9681
|
file
|
|
@@ -9800,10 +9685,10 @@ var check32 = {
|
|
|
9800
9685
|
return results;
|
|
9801
9686
|
}
|
|
9802
9687
|
};
|
|
9803
|
-
registerCheck(
|
|
9688
|
+
registerCheck(check33);
|
|
9804
9689
|
|
|
9805
9690
|
// src/checks/asset/image-tac.ts
|
|
9806
|
-
var
|
|
9691
|
+
var check34 = {
|
|
9807
9692
|
id: "asset.image.tac-raster",
|
|
9808
9693
|
name: "Image TAC (Raster)",
|
|
9809
9694
|
description: "Rasterizes and checks TAC per image using Ghostscript",
|
|
@@ -9822,7 +9707,7 @@ var check33 = {
|
|
|
9822
9707
|
const ghostscript = await resolveGhostscript();
|
|
9823
9708
|
if (!ghostscript) {
|
|
9824
9709
|
return [
|
|
9825
|
-
inspectionFailed(
|
|
9710
|
+
inspectionFailed(check34.id, "Could not inspect image ink coverage: Ghostscript executable not found")
|
|
9826
9711
|
];
|
|
9827
9712
|
}
|
|
9828
9713
|
for (const file of files) {
|
|
@@ -9840,7 +9725,7 @@ var check33 = {
|
|
|
9840
9725
|
if (nums.length === 4 && nums.every((n) => Number.isFinite(n))) {
|
|
9841
9726
|
const tac = (nums[0] + nums[1] + nums[2] + nums[3]) * 100;
|
|
9842
9727
|
if (tac > maxTac) {
|
|
9843
|
-
results.push(finding(
|
|
9728
|
+
results.push(finding(check34.id, {
|
|
9844
9729
|
severity: "warning",
|
|
9845
9730
|
message: `Image TAC exceeds limit: ${tac.toFixed(1)}% (max ${maxTac}%)`,
|
|
9846
9731
|
file,
|
|
@@ -9852,16 +9737,16 @@ var check33 = {
|
|
|
9852
9737
|
}
|
|
9853
9738
|
}
|
|
9854
9739
|
} catch {
|
|
9855
|
-
results.push(inspectionFailed(
|
|
9740
|
+
results.push(inspectionFailed(check34.id, `Could not inspect image ink coverage: ${file}`, { file }));
|
|
9856
9741
|
}
|
|
9857
9742
|
}
|
|
9858
9743
|
return results;
|
|
9859
9744
|
}
|
|
9860
9745
|
};
|
|
9861
|
-
registerCheck(
|
|
9746
|
+
registerCheck(check34);
|
|
9862
9747
|
|
|
9863
9748
|
// src/checks/asset/approved-fonts.ts
|
|
9864
|
-
var
|
|
9749
|
+
var check35 = {
|
|
9865
9750
|
id: "asset.font.approved-files",
|
|
9866
9751
|
name: "Approved Font Files",
|
|
9867
9752
|
description: "Checks font files against the approved file patterns",
|
|
@@ -9900,7 +9785,7 @@ var check34 = {
|
|
|
9900
9785
|
for (const font of allFonts) {
|
|
9901
9786
|
if (!approvedFonts.has(font)) {
|
|
9902
9787
|
results.push({
|
|
9903
|
-
checkId:
|
|
9788
|
+
checkId: check35.id,
|
|
9904
9789
|
severity: "warning",
|
|
9905
9790
|
message: "Font file not in approved list",
|
|
9906
9791
|
file: font
|
|
@@ -9910,7 +9795,7 @@ var check34 = {
|
|
|
9910
9795
|
return results;
|
|
9911
9796
|
}
|
|
9912
9797
|
};
|
|
9913
|
-
registerCheck(
|
|
9798
|
+
registerCheck(check35);
|
|
9914
9799
|
|
|
9915
9800
|
// src/checks/asset/font-license.ts
|
|
9916
9801
|
import { existsSync as existsSync11 } from "node:fs";
|
|
@@ -9925,7 +9810,7 @@ var LICENSE_NAMES = [
|
|
|
9925
9810
|
"OFL-1.1.txt",
|
|
9926
9811
|
"COPYING"
|
|
9927
9812
|
];
|
|
9928
|
-
var
|
|
9813
|
+
var check36 = {
|
|
9929
9814
|
id: "asset.font.license",
|
|
9930
9815
|
name: "Font License",
|
|
9931
9816
|
description: "Checks for license files in font directories",
|
|
@@ -9952,7 +9837,7 @@ var check35 = {
|
|
|
9952
9837
|
const hasLicense = LICENSE_NAMES.some((name) => existsSync11(resolve7(fontDir, name)));
|
|
9953
9838
|
if (!hasLicense) {
|
|
9954
9839
|
results.push({
|
|
9955
|
-
checkId:
|
|
9840
|
+
checkId: check36.id,
|
|
9956
9841
|
severity: "warning",
|
|
9957
9842
|
message: `No font license file found in directory`,
|
|
9958
9843
|
file: fontDir
|
|
@@ -9962,10 +9847,10 @@ var check35 = {
|
|
|
9962
9847
|
return results;
|
|
9963
9848
|
}
|
|
9964
9849
|
};
|
|
9965
|
-
registerCheck(
|
|
9850
|
+
registerCheck(check36);
|
|
9966
9851
|
|
|
9967
9852
|
// src/checks/heuristic/text-density.ts
|
|
9968
|
-
var
|
|
9853
|
+
var check37 = {
|
|
9969
9854
|
id: "heuristic.whitespace.text-density",
|
|
9970
9855
|
name: "Text Density",
|
|
9971
9856
|
description: "Checks characters-per-page ratio",
|
|
@@ -9994,7 +9879,7 @@ var check36 = {
|
|
|
9994
9879
|
});
|
|
9995
9880
|
if (lowPages.length > 0) {
|
|
9996
9881
|
results.push({
|
|
9997
|
-
checkId:
|
|
9882
|
+
checkId: check37.id,
|
|
9998
9883
|
severity: "info",
|
|
9999
9884
|
message: `Low text density on pages: ${lowPages.join(", ")} (below ${range.min} chars)`,
|
|
10000
9885
|
file: ctx.pdfPath
|
|
@@ -10002,7 +9887,7 @@ var check36 = {
|
|
|
10002
9887
|
}
|
|
10003
9888
|
if (highPages.length > 0) {
|
|
10004
9889
|
results.push({
|
|
10005
|
-
checkId:
|
|
9890
|
+
checkId: check37.id,
|
|
10006
9891
|
severity: "info",
|
|
10007
9892
|
message: `High text density on pages: ${highPages.join(", ")} (above ${range.max} chars)`,
|
|
10008
9893
|
file: ctx.pdfPath
|
|
@@ -10011,11 +9896,11 @@ var check36 = {
|
|
|
10011
9896
|
return results;
|
|
10012
9897
|
}
|
|
10013
9898
|
};
|
|
10014
|
-
registerCheck(
|
|
9899
|
+
registerCheck(check37);
|
|
10015
9900
|
|
|
10016
9901
|
// src/checks/heuristic/section-density.ts
|
|
10017
|
-
import { readFile as
|
|
10018
|
-
var
|
|
9902
|
+
import { readFile as readFile25 } from "node:fs/promises";
|
|
9903
|
+
var check38 = {
|
|
10019
9904
|
id: "heuristic.chunking.section-density",
|
|
10020
9905
|
name: "Section Density",
|
|
10021
9906
|
description: "Checks heading/paragraph/callout density from source Markdown",
|
|
@@ -10031,7 +9916,7 @@ var check37 = {
|
|
|
10031
9916
|
const results = [];
|
|
10032
9917
|
for (const file of files) {
|
|
10033
9918
|
try {
|
|
10034
|
-
const content = await
|
|
9919
|
+
const content = await readFile25(file, "utf8");
|
|
10035
9920
|
const lines = content.split(`
|
|
10036
9921
|
`);
|
|
10037
9922
|
let currentSectionStart = 0;
|
|
@@ -10041,7 +9926,7 @@ var check37 = {
|
|
|
10041
9926
|
const line = lines[i];
|
|
10042
9927
|
if (/^#{1,6}\s/.test(line)) {
|
|
10043
9928
|
if (paragraphCount > maxParas) {
|
|
10044
|
-
results.push(finding(
|
|
9929
|
+
results.push(finding(check38.id, {
|
|
10045
9930
|
severity: "info",
|
|
10046
9931
|
message: `Section has ${paragraphCount} paragraphs (max recommended: ${maxParas})`,
|
|
10047
9932
|
file,
|
|
@@ -10061,7 +9946,7 @@ var check37 = {
|
|
|
10061
9946
|
}
|
|
10062
9947
|
}
|
|
10063
9948
|
if (paragraphCount > maxParas) {
|
|
10064
|
-
results.push(finding(
|
|
9949
|
+
results.push(finding(check38.id, {
|
|
10065
9950
|
severity: "info",
|
|
10066
9951
|
message: `Section has ${paragraphCount} paragraphs (max recommended: ${maxParas})`,
|
|
10067
9952
|
file,
|
|
@@ -10069,7 +9954,7 @@ var check37 = {
|
|
|
10069
9954
|
}));
|
|
10070
9955
|
}
|
|
10071
9956
|
} catch {
|
|
10072
|
-
results.push(inspectionFailed(
|
|
9957
|
+
results.push(inspectionFailed(check38.id, `Could not read source file: ${file}`, {
|
|
10073
9958
|
file
|
|
10074
9959
|
}));
|
|
10075
9960
|
}
|
|
@@ -10077,10 +9962,10 @@ var check37 = {
|
|
|
10077
9962
|
return results;
|
|
10078
9963
|
}
|
|
10079
9964
|
};
|
|
10080
|
-
registerCheck(
|
|
9965
|
+
registerCheck(check38);
|
|
10081
9966
|
|
|
10082
9967
|
// src/checks/heuristic/layer-count.ts
|
|
10083
|
-
var
|
|
9968
|
+
var check39 = {
|
|
10084
9969
|
id: "heuristic.decoration.layer-count",
|
|
10085
9970
|
name: "Layer Count",
|
|
10086
9971
|
description: "Counts image objects per page",
|
|
@@ -10105,7 +9990,7 @@ var check38 = {
|
|
|
10105
9990
|
heavyPages.sort((a, b) => a - b);
|
|
10106
9991
|
return [
|
|
10107
9992
|
{
|
|
10108
|
-
checkId:
|
|
9993
|
+
checkId: check39.id,
|
|
10109
9994
|
severity: "info",
|
|
10110
9995
|
message: `Pages with many image layers (>${maxLayers}): ${heavyPages.join(", ")}`,
|
|
10111
9996
|
file: ctx.pdfPath
|
|
@@ -10115,10 +10000,10 @@ var check38 = {
|
|
|
10115
10000
|
return [];
|
|
10116
10001
|
}
|
|
10117
10002
|
};
|
|
10118
|
-
registerCheck(
|
|
10003
|
+
registerCheck(check39);
|
|
10119
10004
|
|
|
10120
10005
|
// src/checks/heuristic/placement-variance.ts
|
|
10121
|
-
var
|
|
10006
|
+
var check40 = {
|
|
10122
10007
|
id: "heuristic.layout.placement-variance",
|
|
10123
10008
|
name: "Placement Variance",
|
|
10124
10009
|
description: "Analyzes text baseline coordinates for layout consistency",
|
|
@@ -10136,7 +10021,7 @@ var check39 = {
|
|
|
10136
10021
|
const uniqueX = new Set(positions.map((p) => Math.round(p.x)));
|
|
10137
10022
|
return [
|
|
10138
10023
|
{
|
|
10139
|
-
checkId:
|
|
10024
|
+
checkId: check40.id,
|
|
10140
10025
|
severity: "info",
|
|
10141
10026
|
message: `Layout analysis: ${uniqueX.size} unique horizontal text positions across ${positions.length} text blocks.`,
|
|
10142
10027
|
file: ctx.pdfPath
|
|
@@ -10144,7 +10029,7 @@ var check39 = {
|
|
|
10144
10029
|
];
|
|
10145
10030
|
}
|
|
10146
10031
|
};
|
|
10147
|
-
registerCheck(
|
|
10032
|
+
registerCheck(check40);
|
|
10148
10033
|
|
|
10149
10034
|
// src/checks/runner.ts
|
|
10150
10035
|
function getCheckSeverityOverride(checkId, config) {
|
|
@@ -10174,16 +10059,16 @@ async function runChecks(ctx, opts = {}) {
|
|
|
10174
10059
|
}
|
|
10175
10060
|
const release = retainPdfCache();
|
|
10176
10061
|
try {
|
|
10177
|
-
for (const
|
|
10062
|
+
for (const check41 of checks2) {
|
|
10178
10063
|
try {
|
|
10179
|
-
let results = await
|
|
10180
|
-
const severityOverride = getCheckSeverityOverride(
|
|
10064
|
+
let results = await check41.run(ctx);
|
|
10065
|
+
const severityOverride = getCheckSeverityOverride(check41.id, ctx.config);
|
|
10181
10066
|
if (severityOverride) {
|
|
10182
10067
|
for (const r of results) {
|
|
10183
10068
|
r.severity = severityOverride;
|
|
10184
10069
|
}
|
|
10185
10070
|
}
|
|
10186
|
-
const lintLevel = ruleLevel(ctx.config.lint.rules,
|
|
10071
|
+
const lintLevel = ruleLevel(ctx.config.lint.rules, check41.id);
|
|
10187
10072
|
if (lintLevel === "off")
|
|
10188
10073
|
results = [];
|
|
10189
10074
|
else if (lintLevel) {
|
|
@@ -10191,15 +10076,15 @@ async function runChecks(ctx, opts = {}) {
|
|
|
10191
10076
|
r.severity = lintLevel === "warn" ? "warning" : "error";
|
|
10192
10077
|
}
|
|
10193
10078
|
if (results.length === 0) {
|
|
10194
|
-
passed.push(
|
|
10079
|
+
passed.push(check41.id);
|
|
10195
10080
|
} else {
|
|
10196
10081
|
allResults.push(...results);
|
|
10197
10082
|
}
|
|
10198
10083
|
} catch (err) {
|
|
10199
10084
|
allResults.push({
|
|
10200
|
-
checkId:
|
|
10085
|
+
checkId: check41.id,
|
|
10201
10086
|
severity: "error",
|
|
10202
|
-
message: `Check "${
|
|
10087
|
+
message: `Check "${check41.id}" threw: ${err instanceof Error ? err.message : String(err)}`
|
|
10203
10088
|
});
|
|
10204
10089
|
}
|
|
10205
10090
|
}
|
|
@@ -10239,15 +10124,15 @@ function emptyReport() {
|
|
|
10239
10124
|
async function checkToolAvailability(config, opts = {}) {
|
|
10240
10125
|
const { checks: checks2 } = selectChecks(opts, config);
|
|
10241
10126
|
const toolToChecks = new Map;
|
|
10242
|
-
for (const
|
|
10243
|
-
if (!
|
|
10127
|
+
for (const check41 of checks2) {
|
|
10128
|
+
if (!check41.requiredTools?.length)
|
|
10244
10129
|
continue;
|
|
10245
|
-
for (const tool of
|
|
10130
|
+
for (const tool of check41.requiredTools) {
|
|
10246
10131
|
const existing = toolToChecks.get(tool);
|
|
10247
10132
|
if (existing) {
|
|
10248
|
-
existing.push(
|
|
10133
|
+
existing.push(check41.id);
|
|
10249
10134
|
} else {
|
|
10250
|
-
toolToChecks.set(tool, [
|
|
10135
|
+
toolToChecks.set(tool, [check41.id]);
|
|
10251
10136
|
}
|
|
10252
10137
|
}
|
|
10253
10138
|
}
|
|
@@ -10263,11 +10148,11 @@ async function checkToolAvailability(config, opts = {}) {
|
|
|
10263
10148
|
const missing = results.filter((r) => !r.found).map((r) => r.tool);
|
|
10264
10149
|
const missingSet = new Set(missing);
|
|
10265
10150
|
const skippedChecks = [];
|
|
10266
|
-
for (const
|
|
10267
|
-
if (!
|
|
10151
|
+
for (const check41 of checks2) {
|
|
10152
|
+
if (!check41.requiredTools?.length)
|
|
10268
10153
|
continue;
|
|
10269
|
-
if (
|
|
10270
|
-
skippedChecks.push(
|
|
10154
|
+
if (check41.requiredTools.some((t) => missingSet.has(t))) {
|
|
10155
|
+
skippedChecks.push(check41.id);
|
|
10271
10156
|
}
|
|
10272
10157
|
}
|
|
10273
10158
|
return { available, missing, skippedChecks, toolToChecks };
|
|
@@ -10540,7 +10425,7 @@ async function executeValidation(args) {
|
|
|
10540
10425
|
};
|
|
10541
10426
|
if (args.fix) {
|
|
10542
10427
|
const selected = selectChecks(runnerOptions, config).checks;
|
|
10543
|
-
if (selected.some((
|
|
10428
|
+
if (selected.some((check41) => check41.id === MARKDOWNLINT_CHECK_ID)) {
|
|
10544
10429
|
await applyMarkdownlintFixes(context);
|
|
10545
10430
|
} else {
|
|
10546
10431
|
log.warn(`--fix: ${MARKDOWNLINT_CHECK_ID} is not part of this run — no files were fixed.`);
|
|
@@ -10913,7 +10798,7 @@ class PdfOutput {
|
|
|
10913
10798
|
const rawPdf = pdfxMode ? path13.join(stage, "raw.pdf") : path13.resolve(pdfFile);
|
|
10914
10799
|
await fsp2.mkdir(path13.dirname(path13.resolve(pdfFile)), { recursive: true });
|
|
10915
10800
|
log.info("Rendering HTML to PDF via the Gutterpress engine (native Chromium pagination)");
|
|
10916
|
-
const { buildNativePdf } = await import("./engine-
|
|
10801
|
+
const { buildNativePdf } = await import("./engine-fdtv01a2.js");
|
|
10917
10802
|
const engineDiagnostics = await buildNativePdf(htmlFile, rawPdf, {
|
|
10918
10803
|
title: config.title,
|
|
10919
10804
|
author: config.authors.length > 0 ? config.authors.join(", ") : undefined,
|
|
@@ -10935,12 +10820,40 @@ class PdfOutput {
|
|
|
10935
10820
|
if (pdfxMode) {
|
|
10936
10821
|
const icc = opts.iccPath ?? config.pdfx.icc;
|
|
10937
10822
|
effectiveIccPath = await resolveIccProfile(icc, manifestDir, opts.iccPath);
|
|
10938
|
-
|
|
10939
|
-
|
|
10823
|
+
const rawBytes = await fsp2.readFile(rawPdf);
|
|
10824
|
+
const transparent = await transparentPages(rawBytes);
|
|
10825
|
+
const blankGradientPages = await findPostScriptShadingPages(rawBytes);
|
|
10826
|
+
const flattenedGradientPages = blankGradientPages.filter((n) => transparent.includes(n));
|
|
10827
|
+
const vectorGradientPages = blankGradientPages.filter((n) => !transparent.includes(n));
|
|
10828
|
+
const GRADIENT_FIX = "Replace it with a plain linear-gradient() or radial-gradient(), or a small tiled image. For 0deg/90deg stripes, `linear-gradient(90deg, #b33 0 6px, #c8c5bf 6px 10px)` with `background-size: 10px 100%` converts correctly.";
|
|
10829
|
+
const pageList = (pages) => `Page${pages.length === 1 ? "" : "s"} ${pages.join(", ")}`;
|
|
10830
|
+
if (vectorGradientPages.length > 0) {
|
|
10831
|
+
log.warn(`${pageList(vectorGradientPages)}: a repeating-*-gradient() or conic-gradient() ` + "can print blank or distorted — " + `Ghostscript has been seen to paint nothing, or irregular stripes, for it when converting to PDF/X; check the page visually. ${GRADIENT_FIX}`);
|
|
10832
|
+
}
|
|
10833
|
+
if (flattenedGradientPages.length > 0 && config.pdfx.transparency !== "preserve-text") {
|
|
10834
|
+
log.warn(`${pageList(flattenedGradientPages)}: a repeating-*-gradient() or conic-gradient() is painted only as part of the one raster image Ghostscript makes of the whole page, so the page loses its embedded fonts and searchable text. Check the page visually. ${GRADIENT_FIX}`);
|
|
10835
|
+
}
|
|
10836
|
+
const flattenPages = config.pdfx.flattenPages;
|
|
10837
|
+
if (transparent.length > 0 && config.pdfx.transparency === "preserve-text") {
|
|
10838
|
+
const { unsplittableTextReasons } = await import("./pdf-inspect-zdmy7qca.js");
|
|
10839
|
+
const reasons = await unsplittableTextReasons(rawBytes, transparent).catch((err) => {
|
|
10840
|
+
log.warn(`pdfx.transparency: preserve-text could not inspect this PDF's text (${err instanceof Error ? err.message : String(err)}), so every page that uses transparency is flattened whole, as with flatten-page.`);
|
|
10841
|
+
return null;
|
|
10842
|
+
});
|
|
10843
|
+
if (reasons) {
|
|
10844
|
+
const plan = planTransparentPages(transparent, reasons, flattenPages, blankGradientPages);
|
|
10845
|
+
await flattenTransparentPages(rawPdf, plan.split, stage, config.pdfx.rasterDpi);
|
|
10846
|
+
reportTransparentPlan(plan, pdfxMode, config.pdfx.rasterDpi ?? 300, pageList);
|
|
10847
|
+
}
|
|
10848
|
+
}
|
|
10849
|
+
const unused = flattenPages.filter((n) => !transparent.includes(n));
|
|
10850
|
+
if (flattenPages.length > 0 && config.pdfx.transparency !== "preserve-text") {
|
|
10851
|
+
log.warn("pdfx.flattenPages has no effect without pdfx.transparency: preserve-text.");
|
|
10852
|
+
} else if (unused.length > 0) {
|
|
10853
|
+
log.warn(`pdfx.flattenPages lists ${pageList(unused).toLowerCase()}, which ${unused.length === 1 ? "has" : "have"} no transparency (or do not exist): nothing to flatten there.`);
|
|
10940
10854
|
}
|
|
10941
|
-
|
|
10942
|
-
|
|
10943
|
-
log.warn(`Page${blankGradientPages.length === 1 ? "" : "s"} ${blankGradientPages.join(", ")}: ` + "a repeating-*-gradient() or conic-gradient() will print blank — " + "Ghostscript cannot convert it to PDF/X. Replace it with a plain linear-gradient() or radial-gradient(), or a small tiled image. For 0deg/90deg stripes, `linear-gradient(90deg, #b33 0 6px, #c8c5bf 6px 10px)` with `background-size: 10px 100%` converts correctly.");
|
|
10855
|
+
if (transparent.length > 0 && config.pdfx.transparency !== "preserve-text") {
|
|
10856
|
+
log.warn("This book uses transparency — an image with an alpha channel, or a CSS " + `rule like \`opacity\` or \`mix-blend-mode\`. PDF/${pdfxMode === "x1a" ? "X-1a" : "X-3"} has no way to represent that (both are based on PDF 1.3, which predates PDF transparency), so Ghostscript will flatten every page that uses it into a single raster ` + "image — that page loses its embedded fonts and searchable text in the " + "PDF/X output. To keep vector text, remove the `opacity`/blend rule and flatten any alpha-channel image against its intended background before including it (export it with no alpha channel), or build --format pdf instead of pdfx if this book doesn't need print-ready CMYK. Or set `pdfx.transparency: preserve-text` to keep the text live on the pages where that is possible. `pdfx.rasterDpi` sets the resolution of those page images (default 720).");
|
|
10944
10857
|
}
|
|
10945
10858
|
const shouldStrip = opts.stripAnnotations ?? config.pdfx.stripAnnotations;
|
|
10946
10859
|
shouldStripAnnotations = shouldStrip;
|
|
@@ -10983,7 +10896,10 @@ class PdfOutput {
|
|
|
10983
10896
|
resolvedFlavor: config.pdfx.flavor,
|
|
10984
10897
|
iccPath: effectiveIccPath,
|
|
10985
10898
|
stripAnnotations: shouldStripAnnotations,
|
|
10986
|
-
blackText: pdfxMode ? config.pdfx.blackText : null
|
|
10899
|
+
blackText: pdfxMode ? config.pdfx.blackText : null,
|
|
10900
|
+
transparency: pdfxMode ? config.pdfx.transparency : null,
|
|
10901
|
+
flattenPages: pdfxMode ? config.pdfx.flattenPages : null,
|
|
10902
|
+
rasterDpi: pdfxMode ? config.pdfx.rasterDpi ?? null : null
|
|
10987
10903
|
}
|
|
10988
10904
|
}, `Wrote: ${reportedPdf}`, { htmlPath: htmlFile, pdfPath: reportedPdf }, pdfName, engineDiagnostics);
|
|
10989
10905
|
} finally {
|
|
@@ -11020,11 +10936,40 @@ async function runBuild(opts) {
|
|
|
11020
10936
|
await fsp2.rm(ctx.workDir, { recursive: true, force: true });
|
|
11021
10937
|
}
|
|
11022
10938
|
}
|
|
10939
|
+
var FALLBACK_CAUSE = {
|
|
10940
|
+
listed: "listed in pdfx.flattenPages",
|
|
10941
|
+
"text-transparency": "text drawn with transparency or blending (opacity, mix-blend-mode, a soft mask, a translucent text-shadow); keep that text opaque",
|
|
10942
|
+
"type3-font": "text in a Type 3 font: for a synthetic bold (a weight the font has no face for), use a face with that weight or set the font's own weight; for -webkit-text-stroke, remove the stroke or accept this fallback",
|
|
10943
|
+
"text-pattern-or-clip": 'text filled with a pattern or used as a clip (SVG fill="url(#…)", gradient text, background-clip: text)',
|
|
10944
|
+
gradient: "a repeating or conic gradient; use a linear or radial gradient, or a small tiled image"
|
|
10945
|
+
};
|
|
10946
|
+
function reportTransparentPlan({ split, artOnly, kept }, pdfxMode, dpi, pageList) {
|
|
10947
|
+
const one = (pages, singular, plural) => pages.length === 1 ? singular : plural;
|
|
10948
|
+
if (split.length > 0) {
|
|
10949
|
+
log.warn(`${pageList(split)} ${one(split, "uses", "use")} transparency, which PDF/${pdfxMode === "x1a" ? "X-1a" : "X-3"} (PDF 1.3) cannot represent. Each was flattened to a ${dpi} DPI picture with its text kept live on top (pdfx.transparency: preserve-text), so fonts and searchable text survive. On those pages, rules, backgrounds and shapes are raster, and text always sits above the artwork: text another element covers shows through. List a page in pdfx.flattenPages to flatten it whole instead.`);
|
|
10950
|
+
}
|
|
10951
|
+
if (artOnly.length > 0) {
|
|
10952
|
+
log.info(`${pageList(artOnly)} ${one(artOnly, "uses", "use")} transparency but ${one(artOnly, "shows", "show")} no text, so there is no text to keep: Ghostscript flattens ${one(artOnly, "it", "each")} whole (resolution: pdfx.rasterDpi).`);
|
|
10953
|
+
}
|
|
10954
|
+
if (kept.size > 0) {
|
|
10955
|
+
const pages = [...kept.keys()];
|
|
10956
|
+
const byCause = new Map;
|
|
10957
|
+
for (const [n, cause] of kept)
|
|
10958
|
+
byCause.set(cause, [...byCause.get(cause) ?? [], n]);
|
|
10959
|
+
const lines = [...byCause].map(([cause, ns]) => ` - ${one(ns, "page", "pages")} ${ns.join(", ")}: ${FALLBACK_CAUSE[cause]}`);
|
|
10960
|
+
log.warn(`${pageList(pages)} could not keep ${one(pages, "its", "their")} text live; Ghostscript will flatten ${one(pages, "that page", "each of those pages")} into one raster image, losing its embedded fonts and searchable text. Each page lists the first cause found; fixing it can reveal another:
|
|
10961
|
+
` + lines.join(`
|
|
10962
|
+
`));
|
|
10963
|
+
}
|
|
10964
|
+
if (split.length === 0 && [...kept.values()].some((cause) => cause !== "listed")) {
|
|
10965
|
+
log.warn("pdfx.transparency: preserve-text kept no page's text live in this book: every page with transparency and text falls back (see above).");
|
|
10966
|
+
}
|
|
10967
|
+
}
|
|
11023
10968
|
// src/preview/lifecycle.ts
|
|
11024
10969
|
import path16 from "path";
|
|
11025
10970
|
import { tmpdir } from "os";
|
|
11026
10971
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
11027
|
-
import { readdir as readdir5, readFile as
|
|
10972
|
+
import { readdir as readdir5, readFile as readFile26, writeFile as writeFile6 } from "node:fs/promises";
|
|
11028
10973
|
|
|
11029
10974
|
// src/utils/file-utils.ts
|
|
11030
10975
|
import { promises as fs3 } from "fs";
|
|
@@ -11142,8 +11087,16 @@ async function renderPreviewBook(inputPath, config, opts) {
|
|
|
11142
11087
|
});
|
|
11143
11088
|
}
|
|
11144
11089
|
function injectPreviewScripts(html, page) {
|
|
11145
|
-
const area = page ? JSON.stringify({
|
|
11146
|
-
|
|
11090
|
+
const area = page ? JSON.stringify({
|
|
11091
|
+
width: page.width,
|
|
11092
|
+
height: page.height,
|
|
11093
|
+
bleed: page.bleed ?? 0,
|
|
11094
|
+
safe: page.safe ?? 0,
|
|
11095
|
+
artSafe: page.artSafe,
|
|
11096
|
+
preset: page.preset,
|
|
11097
|
+
spec: page.spec
|
|
11098
|
+
}) : "";
|
|
11099
|
+
const meta = area ? ` <meta name="gp-print-area" content='${area.replace(/&/g, "&").replace(/'/g, "'")}'>
|
|
11147
11100
|
` : "";
|
|
11148
11101
|
const scripts = meta + ` <script src="/engine/gutterpress-viewer.js"></script>
|
|
11149
11102
|
` + `<script src="/preview/scripts/preview-interface.js"></script>
|
|
@@ -11179,7 +11132,7 @@ async function generateAndWriteHtml(inputPath, tempDir, config, cssAssets, image
|
|
|
11179
11132
|
for (const ref of nextImageRefs)
|
|
11180
11133
|
imageRefs.add(ref);
|
|
11181
11134
|
}
|
|
11182
|
-
await fsp3.writeFile(path15.join(tempDir, BOOK_HTML_FILENAME), injectPreviewScripts(html, config.page), "utf-8");
|
|
11135
|
+
await fsp3.writeFile(path15.join(tempDir, BOOK_HTML_FILENAME), injectPreviewScripts(html, config.page && { ...config.page, preset: config.preset, spec: config.spec }), "utf-8");
|
|
11183
11136
|
}
|
|
11184
11137
|
function isDotPathUnderRoot(candidatePath, root) {
|
|
11185
11138
|
const normalizedRoot = root.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
@@ -11577,7 +11530,7 @@ async function cleanupOrphanTempDirs() {
|
|
|
11577
11530
|
const dir = path16.join(TEMP_DIR_BASE, entry);
|
|
11578
11531
|
const pidFile = path16.join(dir, PID_FILE_NAME);
|
|
11579
11532
|
try {
|
|
11580
|
-
const raw = await
|
|
11533
|
+
const raw = await readFile26(pidFile, "utf8");
|
|
11581
11534
|
const pid = parseInt(raw.trim(), 10);
|
|
11582
11535
|
if (!isProcessAlive(pid)) {
|
|
11583
11536
|
debug(`Removing orphan temp dir ${dir} (pid ${pid} not alive)`);
|
|
@@ -11684,7 +11637,7 @@ function createServerState(inputPath, tempDir, config, options) {
|
|
|
11684
11637
|
import http from "node:http";
|
|
11685
11638
|
import net from "node:net";
|
|
11686
11639
|
import { createHash as createHash5, randomUUID as randomUUID3 } from "node:crypto";
|
|
11687
|
-
import { readFile as
|
|
11640
|
+
import { readFile as readFile27, stat as stat4 } from "node:fs/promises";
|
|
11688
11641
|
import path17 from "path";
|
|
11689
11642
|
import { WebSocket, WebSocketServer } from "ws";
|
|
11690
11643
|
|
|
@@ -11773,7 +11726,7 @@ async function findAvailablePort(startPort, host = "127.0.0.1") {
|
|
|
11773
11726
|
async function serveStatic(absPath, res, cacheControl = "no-store", extraHeaders = {}) {
|
|
11774
11727
|
let filePath = absPath;
|
|
11775
11728
|
try {
|
|
11776
|
-
const s = await
|
|
11729
|
+
const s = await stat4(filePath);
|
|
11777
11730
|
if (s.isDirectory())
|
|
11778
11731
|
filePath = path17.join(filePath, "index.html");
|
|
11779
11732
|
} catch {
|
|
@@ -11783,7 +11736,7 @@ async function serveStatic(absPath, res, cacheControl = "no-store", extraHeaders
|
|
|
11783
11736
|
}
|
|
11784
11737
|
let data;
|
|
11785
11738
|
try {
|
|
11786
|
-
data = await
|
|
11739
|
+
data = await readFile27(filePath);
|
|
11787
11740
|
} catch {
|
|
11788
11741
|
res.writeHead(404);
|
|
11789
11742
|
res.end("Not Found");
|
|
@@ -11812,7 +11765,7 @@ async function serveRevalidatedStatic(req, absPath, res, validators) {
|
|
|
11812
11765
|
}
|
|
11813
11766
|
let fileStat;
|
|
11814
11767
|
try {
|
|
11815
|
-
fileStat = await
|
|
11768
|
+
fileStat = await stat4(absPath, { bigint: true });
|
|
11816
11769
|
} catch {
|
|
11817
11770
|
await serveStatic(absPath, res);
|
|
11818
11771
|
return;
|
|
@@ -11832,7 +11785,7 @@ async function serveRevalidatedStatic(req, absPath, res, validators) {
|
|
|
11832
11785
|
let data;
|
|
11833
11786
|
if (!validator || validator.stamp !== stamp) {
|
|
11834
11787
|
try {
|
|
11835
|
-
data = await
|
|
11788
|
+
data = await readFile27(absPath);
|
|
11836
11789
|
} catch {
|
|
11837
11790
|
await serveStatic(absPath, res);
|
|
11838
11791
|
return;
|
|
@@ -11860,7 +11813,7 @@ async function isMissingReferencedImage(pathname, absPath, refs) {
|
|
|
11860
11813
|
if (!refs.has(imageRefKey(pathname)))
|
|
11861
11814
|
return false;
|
|
11862
11815
|
try {
|
|
11863
|
-
await
|
|
11816
|
+
await stat4(absPath);
|
|
11864
11817
|
return false;
|
|
11865
11818
|
} catch (err) {
|
|
11866
11819
|
return err?.code === "ENOENT";
|
|
@@ -12144,7 +12097,7 @@ async function startPreviewServer(options) {
|
|
|
12144
12097
|
import { platform, arch, release } from "node:os";
|
|
12145
12098
|
|
|
12146
12099
|
// src/lib/remote-auth/token-store.ts
|
|
12147
|
-
import { chmod, mkdir as mkdir7, readFile as
|
|
12100
|
+
import { chmod, mkdir as mkdir7, readFile as readFile28, rename as rename4, writeFile as writeFile7 } from "node:fs/promises";
|
|
12148
12101
|
import os3 from "node:os";
|
|
12149
12102
|
import path18 from "node:path";
|
|
12150
12103
|
function credentialHostKey(hostOrUrl) {
|
|
@@ -12188,7 +12141,7 @@ class FileTokenStore {
|
|
|
12188
12141
|
async read() {
|
|
12189
12142
|
let raw;
|
|
12190
12143
|
try {
|
|
12191
|
-
raw = await
|
|
12144
|
+
raw = await readFile28(this.filePath, "utf8");
|
|
12192
12145
|
} catch (e) {
|
|
12193
12146
|
if (e?.code === "ENOENT") {
|
|
12194
12147
|
return { version: 1, credentials: {} };
|
|
@@ -12388,13 +12341,13 @@ async function getSystemDiagnostics() {
|
|
|
12388
12341
|
};
|
|
12389
12342
|
}
|
|
12390
12343
|
// src/lib/project-scaffold.ts
|
|
12391
|
-
import { access, copyFile, cp as cp2, mkdir as mkdir9, readdir as readdir6, readFile as
|
|
12344
|
+
import { access, copyFile, cp as cp2, mkdir as mkdir9, readdir as readdir6, readFile as readFile30, stat as stat5, writeFile as writeFile9 } from "node:fs/promises";
|
|
12392
12345
|
import { constants as FS, existsSync as existsSync14 } from "node:fs";
|
|
12393
12346
|
import path20 from "node:path";
|
|
12394
12347
|
|
|
12395
12348
|
// src/lib/page-size.ts
|
|
12396
12349
|
import { existsSync as existsSync13 } from "node:fs";
|
|
12397
|
-
import { mkdir as mkdir8, readFile as
|
|
12350
|
+
import { mkdir as mkdir8, readFile as readFile29, writeFile as writeFile8 } from "node:fs/promises";
|
|
12398
12351
|
import path19 from "node:path";
|
|
12399
12352
|
import postcss5 from "postcss";
|
|
12400
12353
|
import { Scalar as Scalar2 } from "yaml";
|
|
@@ -12428,8 +12381,8 @@ function pageSizeForChoice(choice) {
|
|
|
12428
12381
|
}
|
|
12429
12382
|
var round3 = (n) => Math.round(n * 1000) / 1000;
|
|
12430
12383
|
function cssLength(pt) {
|
|
12431
|
-
const
|
|
12432
|
-
return Math.abs(
|
|
12384
|
+
const inches2 = round3(pt / 72);
|
|
12385
|
+
return Math.abs(inches2 * 72 - pt) < 0.000001 ? `${inches2}in` : `${round3(pt)}pt`;
|
|
12433
12386
|
}
|
|
12434
12387
|
function formatPageSize(page) {
|
|
12435
12388
|
return `${cssLength(page.width)} ${cssLength(page.height)}`;
|
|
@@ -12499,7 +12452,7 @@ var relDisplay2 = (projectDir, abs) => path19.relative(projectDir, abs).split(pa
|
|
|
12499
12452
|
async function findCssSize(projectDir, sheets) {
|
|
12500
12453
|
let found = null;
|
|
12501
12454
|
for (const file of sheets) {
|
|
12502
|
-
const size = readPageSizeFromCss(await
|
|
12455
|
+
const size = readPageSizeFromCss(await readFile29(file, "utf8"));
|
|
12503
12456
|
if (size)
|
|
12504
12457
|
found = { file, size };
|
|
12505
12458
|
}
|
|
@@ -12526,7 +12479,7 @@ async function setPageSetup(projectDir, choice) {
|
|
|
12526
12479
|
const found = await findCssSize(projectDir, sheets);
|
|
12527
12480
|
const newSheet = path19.join(projectDir, "styles", "book.css");
|
|
12528
12481
|
const target = found?.file ?? sheets[sheets.length - 1] ?? newSheet;
|
|
12529
|
-
const before = existsSync13(target) ? await
|
|
12482
|
+
const before = existsSync13(target) ? await readFile29(target, "utf8") : "";
|
|
12530
12483
|
let after;
|
|
12531
12484
|
try {
|
|
12532
12485
|
after = setPageSizeInCss(before, size);
|
|
@@ -12735,7 +12688,7 @@ async function adoptFolder(options) {
|
|
|
12735
12688
|
}
|
|
12736
12689
|
let st;
|
|
12737
12690
|
try {
|
|
12738
|
-
st = await
|
|
12691
|
+
st = await stat5(dir);
|
|
12739
12692
|
} catch {
|
|
12740
12693
|
throw new CreateProjectErrorImpl("scaffold-io", `Folder not found: ${dir}`);
|
|
12741
12694
|
}
|
|
@@ -12816,7 +12769,7 @@ styles:
|
|
|
12816
12769
|
async function firstSourceFile(manifestPath) {
|
|
12817
12770
|
let text;
|
|
12818
12771
|
try {
|
|
12819
|
-
text = await
|
|
12772
|
+
text = await readFile30(manifestPath, "utf8");
|
|
12820
12773
|
} catch {
|
|
12821
12774
|
return;
|
|
12822
12775
|
}
|
|
@@ -12828,14 +12781,14 @@ async function firstSourceFile(manifestPath) {
|
|
|
12828
12781
|
return m ? m[1].trim() : undefined;
|
|
12829
12782
|
}
|
|
12830
12783
|
async function fillTemplateFile(filePath, substitutions) {
|
|
12831
|
-
let text = await
|
|
12784
|
+
let text = await readFile30(filePath, "utf8");
|
|
12832
12785
|
for (const [token, value] of Object.entries(substitutions)) {
|
|
12833
12786
|
text = text.split(token).join(value);
|
|
12834
12787
|
}
|
|
12835
12788
|
await writeFile9(filePath, text, "utf8");
|
|
12836
12789
|
}
|
|
12837
12790
|
// src/lib/extension-scaffold.ts
|
|
12838
|
-
import { access as access2, mkdir as mkdir10, readFile as
|
|
12791
|
+
import { access as access2, mkdir as mkdir10, readFile as readFile31, writeFile as writeFile10 } from "node:fs/promises";
|
|
12839
12792
|
import { constants as FS2 } from "node:fs";
|
|
12840
12793
|
import path21 from "node:path";
|
|
12841
12794
|
var EXTENSION_KINDS = ["plugin", "theme"];
|
|
@@ -12952,7 +12905,7 @@ async function scaffoldExtension(options) {
|
|
|
12952
12905
|
const src = await getAssetPath(`extension-templates/${kind}/${assetName}`);
|
|
12953
12906
|
const dest = path21.join(extensionDir, relDest);
|
|
12954
12907
|
await mkdir10(path21.dirname(dest), { recursive: true });
|
|
12955
|
-
const text = await
|
|
12908
|
+
const text = await readFile31(src, "utf8");
|
|
12956
12909
|
const table = relDest.endsWith(".json") ? jsonSafe : plain;
|
|
12957
12910
|
await writeFile10(dest, substitute(text, table), "utf8");
|
|
12958
12911
|
written.push(relDest);
|
|
@@ -12978,7 +12931,7 @@ function substitute(text, table) {
|
|
|
12978
12931
|
return out;
|
|
12979
12932
|
}
|
|
12980
12933
|
// src/lib/project-templates.ts
|
|
12981
|
-
import { cp as cp3, mkdir as mkdir11, readFile as
|
|
12934
|
+
import { cp as cp3, mkdir as mkdir11, readFile as readFile32, readdir as readdir7, stat as stat6, writeFile as writeFile11 } from "node:fs/promises";
|
|
12982
12935
|
import { constants as FS3, existsSync as existsSync15 } from "node:fs";
|
|
12983
12936
|
import { access as access3 } from "node:fs/promises";
|
|
12984
12937
|
import path22 from "node:path";
|
|
@@ -12990,7 +12943,7 @@ var BUILT_IN_TEMPLATE_IDS = [
|
|
|
12990
12943
|
];
|
|
12991
12944
|
async function readTemplateChoices(manifestPath) {
|
|
12992
12945
|
try {
|
|
12993
|
-
const text = await
|
|
12946
|
+
const text = await readFile32(manifestPath, "utf8");
|
|
12994
12947
|
const doc = parseDocument2(text);
|
|
12995
12948
|
const out = {};
|
|
12996
12949
|
const preset = doc.get("preset");
|
|
@@ -13172,7 +13125,7 @@ async function saveProjectAsTemplate(options) {
|
|
|
13172
13125
|
async function retokeniseManifest(manifestPath) {
|
|
13173
13126
|
let text;
|
|
13174
13127
|
try {
|
|
13175
|
-
text = await
|
|
13128
|
+
text = await readFile32(manifestPath, "utf8");
|
|
13176
13129
|
} catch {
|
|
13177
13130
|
return;
|
|
13178
13131
|
}
|
|
@@ -13193,7 +13146,7 @@ async function listCustomTemplates(templatesRoot) {
|
|
|
13193
13146
|
const dir = path22.join(templatesRoot, entry.name);
|
|
13194
13147
|
let label = prettify(entry.name);
|
|
13195
13148
|
try {
|
|
13196
|
-
const meta = JSON.parse(await
|
|
13149
|
+
const meta = JSON.parse(await readFile32(path22.join(dir, TEMPLATE_META_FILE), "utf8"));
|
|
13197
13150
|
if (typeof meta.label === "string" && meta.label)
|
|
13198
13151
|
label = meta.label;
|
|
13199
13152
|
} catch {}
|
|
@@ -13211,7 +13164,7 @@ async function listCustomTemplates(templatesRoot) {
|
|
|
13211
13164
|
}
|
|
13212
13165
|
async function importTemplateFromFolder(options) {
|
|
13213
13166
|
const { sourceDir, templatesRoot } = options;
|
|
13214
|
-
const srcStat = await
|
|
13167
|
+
const srcStat = await stat6(sourceDir);
|
|
13215
13168
|
if (!srcStat.isDirectory()) {
|
|
13216
13169
|
throw new Error("The chosen path is not a folder.");
|
|
13217
13170
|
}
|
|
@@ -13219,7 +13172,7 @@ async function importTemplateFromFolder(options) {
|
|
|
13219
13172
|
return saveProjectAsTemplate({ projectDir: sourceDir, name, templatesRoot });
|
|
13220
13173
|
}
|
|
13221
13174
|
// src/lib/snippets.ts
|
|
13222
|
-
import { readdir as readdir8, readFile as
|
|
13175
|
+
import { readdir as readdir8, readFile as readFile33, writeFile as writeFile12, mkdir as mkdir12, rm as rm4 } from "node:fs/promises";
|
|
13223
13176
|
import path23 from "node:path";
|
|
13224
13177
|
var SNIPPETS_DIR = "snippets";
|
|
13225
13178
|
var LEVEL_RANK = { project: 0, extension: 1, core: 2 };
|
|
@@ -13260,7 +13213,7 @@ async function scanSnippetFiles(dir) {
|
|
|
13260
13213
|
continue;
|
|
13261
13214
|
let body = "";
|
|
13262
13215
|
try {
|
|
13263
|
-
body = await
|
|
13216
|
+
body = await readFile33(path23.join(dir, fileName), "utf8");
|
|
13264
13217
|
} catch {
|
|
13265
13218
|
continue;
|
|
13266
13219
|
}
|
|
@@ -13349,7 +13302,7 @@ async function collectLibrary(projectDir) {
|
|
|
13349
13302
|
listed.component = name;
|
|
13350
13303
|
continue;
|
|
13351
13304
|
}
|
|
13352
|
-
const body = await
|
|
13305
|
+
const body = await readFile33(path23.join(entry.dir, rel), "utf8").catch(() => null);
|
|
13353
13306
|
if (body === null)
|
|
13354
13307
|
continue;
|
|
13355
13308
|
snippets2.push({
|
|
@@ -13418,7 +13371,7 @@ async function listLocationVariants(projectDir) {
|
|
|
13418
13371
|
}
|
|
13419
13372
|
// src/lib/extension-import.ts
|
|
13420
13373
|
import { existsSync as existsSync16 } from "node:fs";
|
|
13421
|
-
import { cp as cp4, mkdir as mkdir13, mkdtemp as mkdtemp2, readFile as
|
|
13374
|
+
import { cp as cp4, mkdir as mkdir13, mkdtemp as mkdtemp2, readFile as readFile34, rm as rm5, writeFile as writeFile13 } from "node:fs/promises";
|
|
13422
13375
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
13423
13376
|
import path24 from "node:path";
|
|
13424
13377
|
import { unzipSync } from "fflate";
|
|
@@ -13491,7 +13444,7 @@ async function finalizeExtensionImport(projectDir, sourceDir, relPaths, fallback
|
|
|
13491
13444
|
if (!existsSync16(cssPath)) {
|
|
13492
13445
|
throw new Error("A theme must contain a theme.css file.");
|
|
13493
13446
|
}
|
|
13494
|
-
const css = await
|
|
13447
|
+
const css = await readFile34(cssPath, "utf8");
|
|
13495
13448
|
const { reject, warnings: printFindings } = classifyThemeCssFindings(checkCss(css, "theme.css"));
|
|
13496
13449
|
if (reject) {
|
|
13497
13450
|
throw new Error(`theme.css could not be parsed — ${reject.message}`);
|
|
@@ -13519,7 +13472,7 @@ async function finalizeExtensionImport(projectDir, sourceDir, relPaths, fallback
|
|
|
13519
13472
|
for (let i = 0;i < extraSheets.length; i++) {
|
|
13520
13473
|
const rel = extraSheets[i];
|
|
13521
13474
|
const sheetPath = extraSheetPaths[i];
|
|
13522
|
-
const sheetCss = await
|
|
13475
|
+
const sheetCss = await readFile34(sheetPath, "utf8");
|
|
13523
13476
|
const { reject: sheetReject, warnings: sheetFindings } = classifyThemeCssFindings(checkCss(sheetCss, rel));
|
|
13524
13477
|
if (sheetReject) {
|
|
13525
13478
|
throw new Error(`${rel} could not be parsed — ${sheetReject.message}`);
|
|
@@ -13552,7 +13505,7 @@ async function completeLandedManifest(dest, id, meta, metaExists) {
|
|
|
13552
13505
|
let pkg = {};
|
|
13553
13506
|
if (metaExists) {
|
|
13554
13507
|
try {
|
|
13555
|
-
const parsed = JSON.parse(await
|
|
13508
|
+
const parsed = JSON.parse(await readFile34(file, "utf8"));
|
|
13556
13509
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
13557
13510
|
pkg = parsed;
|
|
13558
13511
|
}
|
|
@@ -13654,11 +13607,11 @@ async function importExtensionFromCssText(projectDir, css, name) {
|
|
|
13654
13607
|
async function importExtensionFromFile(projectDir, filePath) {
|
|
13655
13608
|
const ext = path24.extname(filePath).toLowerCase();
|
|
13656
13609
|
if (ext === ".zip") {
|
|
13657
|
-
const buf = await
|
|
13610
|
+
const buf = await readFile34(filePath);
|
|
13658
13611
|
return importExtensionFromZip(projectDir, new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength));
|
|
13659
13612
|
}
|
|
13660
13613
|
if (ext === ".css") {
|
|
13661
|
-
const css = await
|
|
13614
|
+
const css = await readFile34(filePath, "utf8");
|
|
13662
13615
|
return importExtensionFromCssText(projectDir, css, prettify(path24.basename(filePath, ".css")));
|
|
13663
13616
|
}
|
|
13664
13617
|
throw new Error("Choose a .zip extension package or a .css stylesheet.");
|
|
@@ -16039,7 +15992,7 @@ async function scorchedEarth(options) {
|
|
|
16039
15992
|
}
|
|
16040
15993
|
}
|
|
16041
15994
|
// src/lib/publish/run-publish.ts
|
|
16042
|
-
import { readdir as readdir12, stat as
|
|
15995
|
+
import { readdir as readdir12, stat as stat11 } from "node:fs/promises";
|
|
16043
15996
|
import path33 from "node:path";
|
|
16044
15997
|
|
|
16045
15998
|
// src/lib/publish/command-runner.ts
|
|
@@ -16270,7 +16223,7 @@ var drivethrurpgProvider = {
|
|
|
16270
16223
|
};
|
|
16271
16224
|
|
|
16272
16225
|
// src/lib/publish/providers/gdrive.ts
|
|
16273
|
-
import { mkdtemp as mkdtemp3, readFile as
|
|
16226
|
+
import { mkdtemp as mkdtemp3, readFile as readFile35, readdir as readdir11, rm as rm9, stat as stat8, writeFile as writeFile16 } from "node:fs/promises";
|
|
16274
16227
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
16275
16228
|
import path30 from "node:path";
|
|
16276
16229
|
import { Zip, ZipDeflate } from "fflate";
|
|
@@ -16662,12 +16615,12 @@ async function collectZipEntries(root, dir, out, onWarn) {
|
|
|
16662
16615
|
await collectZipEntries(root, full, out, onWarn);
|
|
16663
16616
|
} else if (entry.isFile()) {
|
|
16664
16617
|
const rel = path30.relative(root, full).split(path30.sep).join("/");
|
|
16665
|
-
out[rel] = await
|
|
16618
|
+
out[rel] = await readFile35(full);
|
|
16666
16619
|
} else if (entry.isSymbolicLink()) {
|
|
16667
|
-
const resolved = await
|
|
16620
|
+
const resolved = await stat8(full).catch(() => null);
|
|
16668
16621
|
if (resolved?.isFile()) {
|
|
16669
16622
|
const rel = path30.relative(root, full).split(path30.sep).join("/");
|
|
16670
|
-
out[rel] = await
|
|
16623
|
+
out[rel] = await readFile35(full);
|
|
16671
16624
|
} else if (resolved?.isDirectory()) {
|
|
16672
16625
|
await collectZipEntries(root, full, out, onWarn);
|
|
16673
16626
|
} else {
|
|
@@ -16737,7 +16690,7 @@ var gdriveProvider = {
|
|
|
16737
16690
|
cleanup: async () => {}
|
|
16738
16691
|
};
|
|
16739
16692
|
try {
|
|
16740
|
-
const artifactStat = await
|
|
16693
|
+
const artifactStat = await stat8(source.filePath);
|
|
16741
16694
|
const about = await driveAbout(fetchImpl, accessToken);
|
|
16742
16695
|
if (about.quota.limitBytes != null && about.quota.freeBytes != null) {
|
|
16743
16696
|
if (artifactStat.size > about.quota.freeBytes) {
|
|
@@ -16782,7 +16735,7 @@ var gdriveProvider = {
|
|
|
16782
16735
|
};
|
|
16783
16736
|
|
|
16784
16737
|
// src/lib/publish/butler.ts
|
|
16785
|
-
import { chmod as chmod2, mkdir as mkdir19, stat as
|
|
16738
|
+
import { chmod as chmod2, mkdir as mkdir19, stat as stat9, writeFile as writeFile17 } from "node:fs/promises";
|
|
16786
16739
|
import path31 from "node:path";
|
|
16787
16740
|
import { unzipSync as unzipSync2 } from "fflate";
|
|
16788
16741
|
var BUTLER_DOWNLOAD_TIMEOUT_MS = 300000;
|
|
@@ -16803,7 +16756,7 @@ function butlerBinaryName(platform2 = process.platform) {
|
|
|
16803
16756
|
}
|
|
16804
16757
|
async function fileExists2(p) {
|
|
16805
16758
|
try {
|
|
16806
|
-
return (await
|
|
16759
|
+
return (await stat9(p)).isFile();
|
|
16807
16760
|
} catch {
|
|
16808
16761
|
return false;
|
|
16809
16762
|
}
|
|
@@ -17046,7 +16999,7 @@ var kdpProvider = {
|
|
|
17046
16999
|
};
|
|
17047
17000
|
|
|
17048
17001
|
// src/lib/publish/providers/local-folder.ts
|
|
17049
|
-
import { cp as cp7, mkdir as mkdir20, stat as
|
|
17002
|
+
import { cp as cp7, mkdir as mkdir20, stat as stat10 } from "node:fs/promises";
|
|
17050
17003
|
import path32 from "node:path";
|
|
17051
17004
|
var LOCAL_PUBLISH_DEFAULT_DIR = "dist";
|
|
17052
17005
|
var info8 = {
|
|
@@ -17073,7 +17026,7 @@ var localFolderProvider = {
|
|
|
17073
17026
|
async preflight(req) {
|
|
17074
17027
|
const dir = localPublishDir(req);
|
|
17075
17028
|
try {
|
|
17076
|
-
const s = await
|
|
17029
|
+
const s = await stat10(dir);
|
|
17077
17030
|
if (!s.isDirectory()) {
|
|
17078
17031
|
return [
|
|
17079
17032
|
{ severity: "error", id: "local/not-a-folder", message: `${dir} exists but is not a folder.` }
|
|
@@ -17368,7 +17321,7 @@ var PDF_HINT = "Build the PDF first (gutterpress build, or export it from the ap
|
|
|
17368
17321
|
var HTML_HINT = "Build the website export first (gutterpress build --format html).";
|
|
17369
17322
|
async function artifactIssues(artifact) {
|
|
17370
17323
|
try {
|
|
17371
|
-
const s = await
|
|
17324
|
+
const s = await stat11(artifact.path);
|
|
17372
17325
|
if (artifact.format === "pdf" && !s.isFile()) {
|
|
17373
17326
|
return [
|
|
17374
17327
|
{
|
|
@@ -17414,7 +17367,7 @@ async function artifactIssues(artifact) {
|
|
|
17414
17367
|
var BUILD_FINGERPRINT_FILENAME = "build-fingerprint.json";
|
|
17415
17368
|
async function htmlDirIssues(dir) {
|
|
17416
17369
|
const issues = [];
|
|
17417
|
-
const isThere = async (rel) =>
|
|
17370
|
+
const isThere = async (rel) => stat11(path33.join(dir, rel)).then(() => true, () => false);
|
|
17418
17371
|
if (!await isThere(BOOK_HTML)) {
|
|
17419
17372
|
issues.push({
|
|
17420
17373
|
severity: "error",
|
|
@@ -17533,7 +17486,7 @@ async function disconnectPublishCredential(key, deps, options = {}) {
|
|
|
17533
17486
|
}
|
|
17534
17487
|
}
|
|
17535
17488
|
// src/lib/publish/selections.ts
|
|
17536
|
-
import { chmod as chmod3, mkdir as mkdir21, readFile as
|
|
17489
|
+
import { chmod as chmod3, mkdir as mkdir21, readFile as readFile36, writeFile as writeFile18 } from "node:fs/promises";
|
|
17537
17490
|
import path34 from "node:path";
|
|
17538
17491
|
class PublishSelectionsStore {
|
|
17539
17492
|
filePath;
|
|
@@ -17543,7 +17496,7 @@ class PublishSelectionsStore {
|
|
|
17543
17496
|
}
|
|
17544
17497
|
async read() {
|
|
17545
17498
|
try {
|
|
17546
|
-
const raw = await
|
|
17499
|
+
const raw = await readFile36(this.filePath, "utf8");
|
|
17547
17500
|
const parsed = JSON.parse(raw);
|
|
17548
17501
|
if (parsed && typeof parsed === "object") {
|
|
17549
17502
|
return {
|