gutterpress 0.11.18 → 0.11.19-alpha.2
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 +2 -2
- package/dist/{build-67bj810g.js → build-wbfzx37g.js} +6 -6
- package/dist/{cdp-smdx6mr3.js → cdp-1hn3xsk2.js} +2 -2
- package/dist/{cdp-jg95s674.js → cdp-h0wa42cz.js} +1 -1
- package/dist/checks/source/character-table.d.ts +63 -0
- package/dist/checks/source/characters.d.ts +1 -0
- package/dist/checks/source/index.d.ts +1 -0
- package/dist/{cli-6q7trt7z.js → cli-55jd2t8p.js} +341 -163
- package/dist/{cli-7fkhgtfn.js → cli-asap4t1z.js} +4 -3
- package/dist/{cli-kkzka31p.js → cli-eyyggect.js} +1 -1
- package/dist/{cli-xe29z84b.js → cli-r7czdzyz.js} +74 -5
- package/dist/{cli-rg8jq04a.js → cli-xf9b7ptc.js} +1 -1
- package/dist/{cli-ptez7zcc.js → cli-xx94a1k6.js} +1 -1
- package/dist/cli.js +12 -12
- package/dist/{doctor-gcqb6xtj.js → doctor-mkhpss2t.js} +3 -3
- package/dist/{engine-wtnakejg.js → engine-fe0n7v9p.js} +3 -3
- package/dist/{engine-zy6fzs5a.js → engine-zehw6tkv.js} +2 -2
- package/dist/{ext-pkaghr3f.js → ext-vw89b9sm.js} +6 -6
- package/dist/{index-n8vs6pss.js → index-b866g2ph.js} +1 -1
- package/dist/{index-rzm1phg0.js → index-bt0qws5c.js} +4 -3
- package/dist/{index-e1hbmb5a.js → index-eqxs5118.js} +412 -167
- package/dist/index.js +3 -3
- package/dist/lib/exec.d.ts +2 -1
- package/dist/lib/ghostscript.d.ts +20 -0
- package/dist/{new-rnnavkc8.js → new-3g19kf7m.js} +6 -6
- package/dist/{preflight-4769yg8n.js → preflight-62r2cnyx.js} +6 -6
- package/dist/{preview-f9csmejj.js → preview-sjq8afwc.js} +6 -6
- package/dist/{publish-40yvnb62.js → publish-fq6gmn4e.js} +6 -6
- package/dist/{validate-pt921n11.js → validate-2zsqvbtk.js} +6 -6
- package/package.json +1 -1
|
@@ -16,11 +16,12 @@ function run(cmd, args, opts = {}) {
|
|
|
16
16
|
return new Promise((resolve, reject) => {
|
|
17
17
|
const p = spawn(cmd, args, { stdio: "inherit", cwd: opts.cwd, env: enhancedEnv() });
|
|
18
18
|
p.on("error", reject);
|
|
19
|
-
p.on("exit", (code) => {
|
|
19
|
+
p.on("exit", (code, signal) => {
|
|
20
20
|
if (code === 0)
|
|
21
21
|
return resolve();
|
|
22
22
|
const cwd = opts.cwd ?? process.cwd();
|
|
23
|
-
|
|
23
|
+
const what = signal ? `was killed by signal ${signal}` : `exited ${code}`;
|
|
24
|
+
reject(Object.assign(new Error(`${cmd} ${args.join(" ")} (cwd=${cwd}) ${what}`), { signal }));
|
|
24
25
|
});
|
|
25
26
|
});
|
|
26
27
|
}
|
|
@@ -240,4 +241,4 @@ async function requireChromiumExecutable() {
|
|
|
240
241
|
`));
|
|
241
242
|
}
|
|
242
243
|
|
|
243
|
-
export { run, spawnCapture, execCapture, isToolAvailable, findTool, INSTALL_HINTS, fullInstallHint, resolveChromiumExecutable, requireChromiumExecutable };
|
|
244
|
+
export { enhancedPath, run, spawnCapture, execCapture, isToolAvailable, findTool, INSTALL_HINTS, fullInstallHint, resolveChromiumExecutable, requireChromiumExecutable };
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
package_default
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-xf9b7ptc.js";
|
|
4
4
|
import {
|
|
5
|
+
enhancedPath,
|
|
5
6
|
execCapture,
|
|
6
7
|
findTool,
|
|
7
8
|
fullInstallHint,
|
|
8
9
|
isToolAvailable,
|
|
9
10
|
resolveChromiumExecutable,
|
|
10
|
-
run
|
|
11
|
-
|
|
11
|
+
run,
|
|
12
|
+
spawnCapture
|
|
13
|
+
} from "./cli-asap4t1z.js";
|
|
12
14
|
import {
|
|
13
15
|
__require
|
|
14
16
|
} from "./cli-37x76zdn.js";
|
|
@@ -170,6 +172,58 @@ async function hasLiveTransparency(pdfBytes) {
|
|
|
170
172
|
}
|
|
171
173
|
return false;
|
|
172
174
|
}
|
|
175
|
+
async function findPostScriptShadingPages(pdfBytes) {
|
|
176
|
+
const { PDFDocument, PDFDict, PDFName, PDFNumber, PDFRawStream, PDFRef } = await import("pdf-lib");
|
|
177
|
+
let doc;
|
|
178
|
+
try {
|
|
179
|
+
doc = await PDFDocument.load(pdfBytes, {
|
|
180
|
+
updateMetadata: false,
|
|
181
|
+
throwOnInvalidObject: false
|
|
182
|
+
});
|
|
183
|
+
} catch {
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
const ctx = doc.context;
|
|
187
|
+
const asDict = (obj) => {
|
|
188
|
+
const o = obj instanceof PDFRef ? ctx.lookup(obj) : obj;
|
|
189
|
+
return o instanceof PDFRawStream ? o.dict : o instanceof PDFDict ? o : undefined;
|
|
190
|
+
};
|
|
191
|
+
const num = (obj) => {
|
|
192
|
+
const o = obj instanceof PDFRef ? ctx.lookup(obj) : obj;
|
|
193
|
+
return o instanceof PDFNumber ? o.asNumber() : undefined;
|
|
194
|
+
};
|
|
195
|
+
const isPostScriptShading = (shading) => {
|
|
196
|
+
const dict = asDict(shading);
|
|
197
|
+
if (!dict || num(dict.get(PDFName.of("ShadingType"))) !== 1)
|
|
198
|
+
return false;
|
|
199
|
+
return num(asDict(dict.get(PDFName.of("Function")))?.get(PDFName.of("FunctionType"))) === 4;
|
|
200
|
+
};
|
|
201
|
+
const subDicts = (resources, key) => {
|
|
202
|
+
const group = asDict(resources.get(PDFName.of(key)));
|
|
203
|
+
return group ? group.entries().map(([, v]) => v) : [];
|
|
204
|
+
};
|
|
205
|
+
const seen = new Set;
|
|
206
|
+
const usesPostScriptShading = (resources) => {
|
|
207
|
+
if (!resources || seen.has(resources))
|
|
208
|
+
return false;
|
|
209
|
+
seen.add(resources);
|
|
210
|
+
if (subDicts(resources, "Shading").some(isPostScriptShading))
|
|
211
|
+
return true;
|
|
212
|
+
for (const pattern of subDicts(resources, "Pattern")) {
|
|
213
|
+
const dict = asDict(pattern);
|
|
214
|
+
if (dict && isPostScriptShading(dict.get(PDFName.of("Shading"))))
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
return subDicts(resources, "XObject").some((x) => usesPostScriptShading(asDict(asDict(x)?.get(PDFName.of("Resources")))));
|
|
218
|
+
};
|
|
219
|
+
const pages = [];
|
|
220
|
+
doc.getPages().forEach((page, i) => {
|
|
221
|
+
seen.clear();
|
|
222
|
+
if (usesPostScriptShading(asDict(page.node.Resources())))
|
|
223
|
+
pages.push(i + 1);
|
|
224
|
+
});
|
|
225
|
+
return pages;
|
|
226
|
+
}
|
|
173
227
|
async function stripAnnotations(pdfPath, stagingDir) {
|
|
174
228
|
const tmp = join(stagingDir, "annotations-stripped.pdf");
|
|
175
229
|
try {
|
|
@@ -297,7 +351,22 @@ async function convertToPdfxCmyk(inputPdf, outPdf, config) {
|
|
|
297
351
|
if (!ghostscript) {
|
|
298
352
|
throw new Error("Ghostscript executable not found. Install Ghostscript or set GHOSTSCRIPT_PATH to its command-line executable.");
|
|
299
353
|
}
|
|
300
|
-
await
|
|
354
|
+
const { code, signal, stdout, stderr } = await spawnCapture(ghostscript, args, {
|
|
355
|
+
env: { ...process.env, PATH: enhancedPath }
|
|
356
|
+
});
|
|
357
|
+
if (signal) {
|
|
358
|
+
const version = await execCapture(ghostscript, ["--version"]).then((r) => r.stdout.trim()).catch(() => "unknown version");
|
|
359
|
+
throw new Error(`Ghostscript ${version} crashed (${signal}) while converting to PDF/X. This is a Ghostscript bug, not a problem with the PDF. Ghostscript 10.02.1 has been seen to crash in the PDF 1.3 transparency flattening PDF/X requires, on a page with an alpha-channel image. Flattening that image against its background avoided it there; a newer Ghostscript may too. A plain PDF (--format pdf) does not run this step.`);
|
|
360
|
+
}
|
|
361
|
+
if (code !== 0) {
|
|
362
|
+
throw new Error(`${ghostscript} ${args.join(" ")} exited ${code}
|
|
363
|
+
${stdout}${stderr}`);
|
|
364
|
+
}
|
|
365
|
+
const at = stderr.indexOf("The following warnings");
|
|
366
|
+
if (at >= 0) {
|
|
367
|
+
log.warn(`Ghostscript reported problems converting to PDF/X:
|
|
368
|
+
${stderr.slice(at).trim()}`);
|
|
369
|
+
}
|
|
301
370
|
} finally {
|
|
302
371
|
await unlink(tmpDef).catch(() => {});
|
|
303
372
|
}
|
|
@@ -514,4 +583,4 @@ async function getSystemDiagnostics() {
|
|
|
514
583
|
};
|
|
515
584
|
}
|
|
516
585
|
|
|
517
|
-
export { setLogLevel, debug, info, warn, error, log, resolveGhostscript, hasLiveTransparency, stripAnnotations, stampCreator, convertToPdfxCmyk, PACKAGE_META, PACKAGE_VERSION, defaultConfigDir, FileTokenStore, getSystemDiagnostics };
|
|
586
|
+
export { setLogLevel, debug, info, warn, error, log, resolveGhostscript, hasLiveTransparency, findPostScriptShadingPages, stripAnnotations, stampCreator, convertToPdfxCmyk, PACKAGE_META, PACKAGE_VERSION, defaultConfigDir, FileTokenStore, getSystemDiagnostics };
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
// package.json
|
|
5
5
|
var package_default = {
|
|
6
6
|
name: "gutterpress",
|
|
7
|
-
version: "0.11.
|
|
7
|
+
version: "0.11.19-alpha.2",
|
|
8
8
|
description: "Markdown-to-PDF converter for professional print layout using a native Chromium print engine and Ghostscript.",
|
|
9
9
|
author: "itlackey",
|
|
10
10
|
license: "MPL-2.0",
|
package/dist/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
UsageError,
|
|
7
7
|
package_default,
|
|
8
8
|
rejectUnknownFlags
|
|
9
|
-
} from "./cli-
|
|
9
|
+
} from "./cli-xf9b7ptc.js";
|
|
10
10
|
import {
|
|
11
11
|
EXIT_CODES
|
|
12
12
|
} from "./cli-46ycxe6r.js";
|
|
@@ -18,14 +18,14 @@ import {
|
|
|
18
18
|
import { defineCommand, parseArgs, runMain } from "citty";
|
|
19
19
|
import { statSync } from "node:fs";
|
|
20
20
|
var SUBCOMMANDS = {
|
|
21
|
-
new: () => import("./new-
|
|
22
|
-
preview: () => import("./preview-
|
|
23
|
-
build: () => import("./build-
|
|
24
|
-
publish: () => import("./publish-
|
|
25
|
-
validate: () => import("./validate-
|
|
26
|
-
preflight: () => import("./preflight-
|
|
27
|
-
doctor: () => import("./doctor-
|
|
28
|
-
ext: () => import("./ext-
|
|
21
|
+
new: () => import("./new-3g19kf7m.js").then((m) => m.default),
|
|
22
|
+
preview: () => import("./preview-sjq8afwc.js").then((m) => m.default),
|
|
23
|
+
build: () => import("./build-wbfzx37g.js").then((m) => m.default),
|
|
24
|
+
publish: () => import("./publish-fq6gmn4e.js").then((m) => m.default),
|
|
25
|
+
validate: () => import("./validate-2zsqvbtk.js").then((m) => m.default),
|
|
26
|
+
preflight: () => import("./preflight-62r2cnyx.js").then((m) => m.default),
|
|
27
|
+
doctor: () => import("./doctor-mkhpss2t.js").then((m) => m.default),
|
|
28
|
+
ext: () => import("./ext-vw89b9sm.js").then((m) => m.default)
|
|
29
29
|
};
|
|
30
30
|
var VERSION = package_default.version;
|
|
31
31
|
var main = defineCommand({
|
|
@@ -50,7 +50,7 @@ async function preflightRequiredInvocations(rawArgs) {
|
|
|
50
50
|
const [command, ...commandArgs] = rawArgs;
|
|
51
51
|
try {
|
|
52
52
|
if (command === "new") {
|
|
53
|
-
const { newArgs } = await import("./new-
|
|
53
|
+
const { newArgs } = await import("./new-3g19kf7m.js");
|
|
54
54
|
rejectUnknownFlags(commandArgs, newArgs, "new");
|
|
55
55
|
const parsed = parseArgs(commandArgs, {
|
|
56
56
|
...newArgs,
|
|
@@ -62,7 +62,7 @@ async function preflightRequiredInvocations(rawArgs) {
|
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
if (command === "preflight") {
|
|
65
|
-
const { preflightArgs } = await import("./preflight-
|
|
65
|
+
const { preflightArgs } = await import("./preflight-62r2cnyx.js");
|
|
66
66
|
rejectUnknownFlags(commandArgs, preflightArgs, "preflight");
|
|
67
67
|
const parsed = parseArgs(commandArgs, {
|
|
68
68
|
...preflightArgs,
|
|
@@ -82,7 +82,7 @@ async function preflightRequiredInvocations(rawArgs) {
|
|
|
82
82
|
}
|
|
83
83
|
if (subcommand.startsWith("-"))
|
|
84
84
|
return;
|
|
85
|
-
const { EXT_SUBCOMMANDS, extAddArgs, extRemoveArgs, extEnableArgs, extDisableArgs } = await import("./ext-
|
|
85
|
+
const { EXT_SUBCOMMANDS, extAddArgs, extRemoveArgs, extEnableArgs, extDisableArgs } = await import("./ext-vw89b9sm.js");
|
|
86
86
|
if (!EXT_SUBCOMMANDS.includes(subcommand)) {
|
|
87
87
|
throw new UsageError(`gutterpress ext: unknown command "${subcommand}"`);
|
|
88
88
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getSystemDiagnostics,
|
|
3
3
|
log
|
|
4
|
-
} from "./cli-
|
|
4
|
+
} from "./cli-r7czdzyz.js";
|
|
5
5
|
import {
|
|
6
6
|
UsageError,
|
|
7
7
|
rejectExtraPositionals,
|
|
8
8
|
rejectUnknownFlags
|
|
9
|
-
} from "./cli-
|
|
9
|
+
} from "./cli-xf9b7ptc.js";
|
|
10
10
|
import"./cli-46ycxe6r.js";
|
|
11
|
-
import"./cli-
|
|
11
|
+
import"./cli-asap4t1z.js";
|
|
12
12
|
import"./cli-37x76zdn.js";
|
|
13
13
|
|
|
14
14
|
// src/commands/doctor.ts
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
build
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-xx94a1k6.js";
|
|
4
4
|
import {
|
|
5
5
|
BuildError
|
|
6
6
|
} from "./cli-46ycxe6r.js";
|
|
7
|
-
import"./cli-
|
|
8
|
-
import"./cli-
|
|
7
|
+
import"./cli-eyyggect.js";
|
|
8
|
+
import"./cli-asap4t1z.js";
|
|
9
9
|
import"./cli-37x76zdn.js";
|
|
10
10
|
|
|
11
11
|
// src/lib/engine.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
build
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-b866g2ph.js";
|
|
4
4
|
import {
|
|
5
5
|
BuildError
|
|
6
6
|
} from "./index-jt552wtf.js";
|
|
7
|
-
import"./index-
|
|
7
|
+
import"./index-bt0qws5c.js";
|
|
8
8
|
import"./index-37x76zdn.js";
|
|
9
9
|
|
|
10
10
|
// src/lib/engine.ts
|
|
@@ -12,22 +12,22 @@ import {
|
|
|
12
12
|
searchNpmExtensions,
|
|
13
13
|
setExtensionEnabled,
|
|
14
14
|
updateExtensions
|
|
15
|
-
} from "./cli-
|
|
16
|
-
import"./cli-
|
|
15
|
+
} from "./cli-55jd2t8p.js";
|
|
16
|
+
import"./cli-r7czdzyz.js";
|
|
17
17
|
import {
|
|
18
18
|
UsageError,
|
|
19
19
|
exitForUsage,
|
|
20
20
|
rejectExtraPositionals,
|
|
21
21
|
rejectUnknownFlags,
|
|
22
22
|
resolveProjectDir
|
|
23
|
-
} from "./cli-
|
|
23
|
+
} from "./cli-xf9b7ptc.js";
|
|
24
24
|
import"./cli-ht1bcqdd.js";
|
|
25
|
-
import"./cli-
|
|
25
|
+
import"./cli-xx94a1k6.js";
|
|
26
26
|
import {
|
|
27
27
|
EXIT_CODES
|
|
28
28
|
} from "./cli-46ycxe6r.js";
|
|
29
|
-
import"./cli-
|
|
30
|
-
import"./cli-
|
|
29
|
+
import"./cli-eyyggect.js";
|
|
30
|
+
import"./cli-asap4t1z.js";
|
|
31
31
|
import"./cli-5qr3z0qa.js";
|
|
32
32
|
import"./cli-v5mp7a6q.js";
|
|
33
33
|
import"./cli-37x76zdn.js";
|
|
@@ -26,11 +26,12 @@ function run(cmd, args, opts = {}) {
|
|
|
26
26
|
return new Promise((resolve, reject) => {
|
|
27
27
|
const p = spawn(cmd, args, { stdio: "inherit", cwd: opts.cwd, env: enhancedEnv() });
|
|
28
28
|
p.on("error", reject);
|
|
29
|
-
p.on("exit", (code) => {
|
|
29
|
+
p.on("exit", (code, signal) => {
|
|
30
30
|
if (code === 0)
|
|
31
31
|
return resolve();
|
|
32
32
|
const cwd = opts.cwd ?? process.cwd();
|
|
33
|
-
|
|
33
|
+
const what = signal ? `was killed by signal ${signal}` : `exited ${code}`;
|
|
34
|
+
reject(Object.assign(new Error(`${cmd} ${args.join(" ")} (cwd=${cwd}) ${what}`), { signal }));
|
|
34
35
|
});
|
|
35
36
|
});
|
|
36
37
|
}
|
|
@@ -498,4 +499,4 @@ class SessionImpl {
|
|
|
498
499
|
}
|
|
499
500
|
}
|
|
500
501
|
|
|
501
|
-
export { run, spawnCapture, execCapture, isToolAvailable, findTool, INSTALL_HINTS, fullInstallHint, resolveChromiumExecutable, requireChromiumExecutable, REQUIRED_MILESTONE, assertMilestone, readyProbeExpr, DEFAULT_PRINT_OPTS, launchChromium };
|
|
502
|
+
export { enhancedPath, run, spawnCapture, execCapture, isToolAvailable, findTool, INSTALL_HINTS, fullInstallHint, resolveChromiumExecutable, requireChromiumExecutable, REQUIRED_MILESTONE, assertMilestone, readyProbeExpr, DEFAULT_PRINT_OPTS, launchChromium };
|