gutterpress 0.9.0-alpha.2 → 0.10.0-alpha.4
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/README.md +18 -4
- package/dist/api/index.d.ts +11 -5
- package/dist/api/index.js +20 -15
- package/dist/assets/preview/scripts/preview-bridge.d.ts +1 -0
- package/dist/assets/preview/scripts/preview-interface.d.ts +1 -0
- package/dist/{audit-nhn2pjz3.js → audit-k1vnfwvc.js} +10 -7
- package/dist/{build-san7fv2z.js → build-hqmwgvdw.js} +14 -8
- package/dist/checks/source/index.d.ts +1 -0
- package/dist/checks/source/layout-markers.d.ts +3 -0
- package/dist/checks/source/local-ref-parser.d.ts +28 -0
- package/dist/{cli-e5zhb0xs.js → cli-0r0tq16s.js} +17 -24
- package/dist/cli-46ycxe6r.js +18 -0
- package/dist/cli-c41yr7he.js +241 -0
- package/dist/cli-hp9r2pzt.js +2343 -0
- package/dist/{index-yzrh708h.js → cli-k1065rkg.js} +2 -5
- package/dist/{cli-k4bd06sd.js → cli-n25qycwz.js} +4986 -5889
- package/dist/{cli-najycadg.js → cli-ra0ed2xt.js} +69 -253
- package/dist/{cli-506tg37g.js → cli-revgt4pr.js} +2 -1
- package/dist/{cli-wchtvxvw.js → cli-v5mp7a6q.js} +14 -1
- package/dist/cli.js +20 -18
- package/dist/{doctor-hrk0kxxz.js → doctor-dxms7ehm.js} +4 -2
- package/dist/engine/compiler/build.d.ts +139 -0
- package/dist/engine/compiler/postprocess.d.ts +23 -0
- package/dist/engine/compiler/tier2.d.ts +78 -0
- package/dist/engine/shared/cdp.d.ts +104 -0
- package/dist/engine/shared/content-value.d.ts +64 -0
- package/dist/engine/shared/gcpm-extract.d.ts +119 -0
- package/dist/engine/shared/margin-box-support.d.ts +12 -0
- package/dist/engine/shared/pdf-inspect.d.ts +24 -0
- package/dist/engine/shared/synthesis.d.ts +155 -0
- package/dist/engine-wa7y9av9.js +41 -0
- package/dist/engine-z4p9sr4h.js +40 -0
- package/dist/gutterpress-agent-1ctgfz92.js +576 -0
- package/dist/gutterpress-viewer-cem7dmr5.js +2349 -0
- package/dist/{index-bynn850m.js → index-05y3dnxq.js} +3049 -4015
- package/dist/index-9tyq9kks.js +708 -0
- package/dist/{cli-yzrh708h.js → index-mdefp0y5.js} +1 -1
- package/dist/{index-wchtvxvw.js → index-v5mp7a6q.js} +14 -1
- package/dist/index-xxg4zfrg.js +1907 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +24 -17
- package/dist/lib/asset-inline.d.ts +36 -0
- package/dist/lib/browser-pool.d.ts +18 -0
- package/dist/lib/build-error.d.ts +1 -1
- package/dist/lib/build-preflight.d.ts +35 -2
- package/dist/lib/build-runner.d.ts +45 -17
- package/dist/lib/build-staging.d.ts +9 -55
- package/dist/lib/cli-args.d.ts +8 -0
- package/dist/lib/desktop.d.ts +2 -2
- package/dist/lib/embedded-assets.d.ts +1 -1
- package/dist/lib/engine.d.ts +33 -0
- package/dist/lib/ghostscript.d.ts +46 -1
- package/dist/lib/markdown/assemble.d.ts +18 -10
- package/dist/lib/markdown/gp-pin-scope.d.ts +1 -0
- package/dist/lib/markdown/gutterpress-css.d.ts +125 -0
- package/dist/lib/markdown/images.d.ts +26 -0
- package/dist/lib/markdown/index.d.ts +4 -2
- package/dist/lib/markdown/inline-source.d.ts +10 -0
- package/dist/lib/markdown/markers.d.ts +32 -0
- package/dist/lib/markdown/renderer.d.ts +8 -3
- package/dist/lib/markdown/source-range.d.ts +61 -0
- package/dist/lib/missing-asset-placeholder.d.ts +52 -0
- package/dist/lib/presets.d.ts +1 -1
- package/dist/lib/printsafe.d.ts +2 -3
- package/dist/lib/remote-auth/converge-merge.d.ts +48 -0
- package/dist/lib/remote-auth/image-clash.d.ts +17 -0
- package/dist/lib/remote-auth/recovery/classify.d.ts +55 -67
- package/dist/lib/remote-auth/recovery/inspect.d.ts +14 -13
- package/dist/lib/remote-auth/recovery/locks.d.ts +20 -0
- package/dist/lib/remote-auth/recovery/repair.d.ts +29 -0
- package/dist/lib/remote-auth/recovery/types.d.ts +8 -204
- package/dist/lib/remote-auth/sync-messages.d.ts +2 -3
- package/dist/lib/remote-auth/sync-types.d.ts +35 -63
- package/dist/lib/remote-auth/sync.d.ts +11 -18
- package/dist/lib/remote-auth/transport.d.ts +14 -7
- package/dist/lib/theme-import.d.ts +4 -5
- package/dist/{lint-96j9hrj4.js → lint-xjwm5ep8.js} +10 -7
- package/dist/{manifest.schema-z61rzw44.json → manifest.schema-zxgxnbg7.json} +21 -0
- package/dist/{new-8p38wavc.js → new-kwdwpf0j.js} +12 -8
- package/dist/{plugin-ees6nhkc.js → plugin-rg4tnn96.js} +10 -7
- package/dist/{preflight-1q6c2edh.js → preflight-3127y25z.js} +10 -7
- package/dist/preview/file-watcher.d.ts +13 -17
- package/dist/preview/lifecycle.d.ts +1 -1
- package/dist/{pagedjs-bridge-vn4hk9fx.js → preview-bridge-fz7vpk8m.js} +8 -0
- package/dist/preview-interface-435cczt5.js +1059 -0
- package/dist/{preview-y5a2zen1.js → preview-ncgfhqmw.js} +16 -9
- package/dist/preview-shell-c5mfa3q0.js +346 -0
- package/dist/{project-source-p0gn1wd5.js → project-source-ekcyp63q.js} +1 -1
- package/dist/{publish-rm9yb3wh.js → publish-pr0rwh6p.js} +10 -7
- package/dist/render.d.ts +3 -4
- package/dist/render.js +728 -64
- package/dist/{repair-zgq7q2g6.js → repair-8270smfw.js} +45 -79
- package/dist/schema/manifest.types.d.ts +38 -0
- package/dist/{source-provider-c1rjm2c0.js → source-provider-3tcj6qg2.js} +2 -2
- package/dist/source-provider-vanafrt9.js +40 -0
- package/dist/{theme-zz2ktzqs.css → theme-h5recz6c.css} +8 -7
- package/dist/{theme-570zmh2t.css → theme-j2bagrfx.css} +8 -7
- package/dist/{theme-nya4nqh6.css → theme-nn6d53zy.css} +8 -7
- package/dist/types.d.ts +7 -0
- package/dist/{validate-nr0xa6sa.js → validate-54e17rae.js} +10 -7
- package/package.json +6 -6
- package/dist/cli-yja077f6.js +0 -92
- package/dist/git-http-yrb4ag6z.js +0 -17
- package/dist/index-yja077f6.js +0 -92
- package/dist/lib/markdown/markdown-it-paged.d.ts +0 -30
- package/dist/lib/pagedjs-marker.d.ts +0 -42
- package/dist/lib/pagedjs.d.ts +0 -26
- package/dist/lib/pagination.d.ts +0 -149
- package/dist/lib/remote-auth/conflict-resolution.d.ts +0 -29
- package/dist/lib/remote-auth/recovery/abort-interrupted-operation.d.ts +0 -103
- package/dist/lib/remote-auth/recovery/backup.d.ts +0 -113
- package/dist/lib/remote-auth/recovery/context.d.ts +0 -47
- package/dist/lib/remote-auth/recovery/dispatch.d.ts +0 -28
- package/dist/lib/remote-auth/recovery/failsafe.d.ts +0 -33
- package/dist/lib/remote-auth/recovery/manual-guidance.d.ts +0 -28
- package/dist/lib/remote-auth/recovery/outcome-mapping.d.ts +0 -59
- package/dist/lib/remote-auth/recovery/policy.d.ts +0 -47
- package/dist/lib/remote-auth/recovery/recover-auth.d.ts +0 -42
- package/dist/lib/remote-auth/recovery/recover-binary-conflict.d.ts +0 -37
- package/dist/lib/remote-auth/recovery/recover-corrupt-index.d.ts +0 -40
- package/dist/lib/remote-auth/recovery/recover-detached-head.d.ts +0 -70
- package/dist/lib/remote-auth/recovery/recover-interrupted-cherry-pick.d.ts +0 -23
- package/dist/lib/remote-auth/recovery/recover-interrupted-merge.d.ts +0 -28
- package/dist/lib/remote-auth/recovery/recover-interrupted-rebase.d.ts +0 -39
- package/dist/lib/remote-auth/recovery/recover-merge-conflict.d.ts +0 -34
- package/dist/lib/remote-auth/recovery/recover-missing-git-dir.d.ts +0 -37
- package/dist/lib/remote-auth/recovery/recover-missing-objects.d.ts +0 -56
- package/dist/lib/remote-auth/recovery/recover-network.d.ts +0 -34
- package/dist/lib/remote-auth/recovery/recover-non-fast-forward.d.ts +0 -27
- package/dist/lib/remote-auth/recovery/recover-stale-lock.d.ts +0 -68
- package/dist/lib/remote-auth/recovery/recover-unrelated-histories.d.ts +0 -44
- package/dist/lib/remote-auth/recovery/recover-wrong-remote.d.ts +0 -35
- package/dist/lib/remote-auth/resolution-plan.d.ts +0 -64
- package/dist/paged.polyfill-n95pbxfn.js +0 -33288
- package/dist/pagedjs-interface-qxvzgwd7.js +0 -557
- package/dist/preview-shell-6dqexx1m.js +0 -581
- /package/dist/assets/{preview/scripts/pagedjs-bridge.d.ts → engine/gutterpress-agent.d.ts} +0 -0
- /package/dist/assets/{preview/scripts/pagedjs-interface.d.ts → engine/gutterpress-viewer.d.ts} +0 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
// src/lib/tool-probe.ts
|
|
2
|
+
import { platform } from "node:os";
|
|
3
|
+
|
|
4
|
+
// src/lib/exec.ts
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
import { join, resolve as resolvePath, delimiter } from "node:path";
|
|
7
|
+
function buildEnhancedPath(dir, existingPath, sep = delimiter) {
|
|
8
|
+
return `${dir}${sep}${existingPath}`;
|
|
9
|
+
}
|
|
10
|
+
var localBin = resolvePath(join(import.meta.dirname, "..", "..", "node_modules", ".bin"));
|
|
11
|
+
var enhancedPath = buildEnhancedPath(localBin, process.env.PATH ?? "");
|
|
12
|
+
function enhancedEnv() {
|
|
13
|
+
return { ...process.env, PATH: enhancedPath };
|
|
14
|
+
}
|
|
15
|
+
function run(cmd, args, opts = {}) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const p = spawn(cmd, args, { stdio: "inherit", cwd: opts.cwd, env: enhancedEnv() });
|
|
18
|
+
p.on("error", reject);
|
|
19
|
+
p.on("exit", (code) => {
|
|
20
|
+
if (code === 0)
|
|
21
|
+
return resolve();
|
|
22
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
23
|
+
reject(new Error(`${cmd} ${args.join(" ")} (cwd=${cwd}) exited ${code}`));
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
var EXIT_FLUSH_GRACE_MS = 2000;
|
|
28
|
+
function keepTail(buffer, chunk, limit) {
|
|
29
|
+
const joined = buffer + chunk;
|
|
30
|
+
return limit !== undefined && joined.length > limit ? joined.slice(-limit) : joined;
|
|
31
|
+
}
|
|
32
|
+
function spawnCapture(cmd, args, opts = {}) {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
const p = spawn(cmd, args, {
|
|
35
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
36
|
+
cwd: opts.cwd,
|
|
37
|
+
env: opts.env
|
|
38
|
+
});
|
|
39
|
+
let stdout = "";
|
|
40
|
+
let stderr = "";
|
|
41
|
+
let settled = false;
|
|
42
|
+
let exited = false;
|
|
43
|
+
let exitCode = null;
|
|
44
|
+
let exitSignal = null;
|
|
45
|
+
let killTimer;
|
|
46
|
+
let graceTimer;
|
|
47
|
+
const settle = (fn) => {
|
|
48
|
+
if (settled)
|
|
49
|
+
return;
|
|
50
|
+
settled = true;
|
|
51
|
+
if (killTimer)
|
|
52
|
+
clearTimeout(killTimer);
|
|
53
|
+
if (graceTimer)
|
|
54
|
+
clearTimeout(graceTimer);
|
|
55
|
+
fn();
|
|
56
|
+
};
|
|
57
|
+
const armKill = () => {
|
|
58
|
+
if (!opts.timeoutMs)
|
|
59
|
+
return;
|
|
60
|
+
if (killTimer)
|
|
61
|
+
clearTimeout(killTimer);
|
|
62
|
+
killTimer = setTimeout(() => {
|
|
63
|
+
settle(() => {
|
|
64
|
+
p.kill("SIGKILL");
|
|
65
|
+
reject(new Error(opts.timeoutMode === "idle" ? `${cmd} produced no output for ${opts.timeoutMs}ms and was stopped` : `${cmd} ${args.join(" ")} timed out after ${opts.timeoutMs}ms`));
|
|
66
|
+
});
|
|
67
|
+
}, opts.timeoutMs);
|
|
68
|
+
killTimer.unref();
|
|
69
|
+
};
|
|
70
|
+
armKill();
|
|
71
|
+
const finish = () => settle(() => resolve({ code: exitCode, signal: exitSignal, stdout, stderr }));
|
|
72
|
+
const armGrace = () => {
|
|
73
|
+
if (graceTimer)
|
|
74
|
+
clearTimeout(graceTimer);
|
|
75
|
+
graceTimer = setTimeout(finish, opts.exitGraceMs ?? EXIT_FLUSH_GRACE_MS);
|
|
76
|
+
graceTimer.unref();
|
|
77
|
+
};
|
|
78
|
+
const onData = (stream) => (d) => {
|
|
79
|
+
const text = d.toString();
|
|
80
|
+
if (stream === "stdout")
|
|
81
|
+
stdout = keepTail(stdout, text, opts.captureLimit);
|
|
82
|
+
else
|
|
83
|
+
stderr = keepTail(stderr, text, opts.captureLimit);
|
|
84
|
+
opts.onChunk?.(stream, text);
|
|
85
|
+
if (exited)
|
|
86
|
+
armGrace();
|
|
87
|
+
else if (opts.timeoutMode === "idle")
|
|
88
|
+
armKill();
|
|
89
|
+
};
|
|
90
|
+
p.stdout.on("data", onData("stdout"));
|
|
91
|
+
p.stderr.on("data", onData("stderr"));
|
|
92
|
+
p.on("error", (err) => settle(() => reject(err)));
|
|
93
|
+
p.on("exit", (code, signal) => {
|
|
94
|
+
exited = true;
|
|
95
|
+
exitCode = code;
|
|
96
|
+
exitSignal = signal;
|
|
97
|
+
if (killTimer) {
|
|
98
|
+
clearTimeout(killTimer);
|
|
99
|
+
killTimer = undefined;
|
|
100
|
+
}
|
|
101
|
+
armGrace();
|
|
102
|
+
});
|
|
103
|
+
p.on("close", finish);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
async function execCapture(cmd, args, opts = {}) {
|
|
107
|
+
const { code, signal, stdout, stderr } = await spawnCapture(cmd, args, {
|
|
108
|
+
cwd: opts.cwd,
|
|
109
|
+
env: enhancedEnv(),
|
|
110
|
+
timeoutMs: opts.timeoutMs
|
|
111
|
+
});
|
|
112
|
+
if (code === 0)
|
|
113
|
+
return { stdout, stderr };
|
|
114
|
+
throw new Error(code === null ? `${cmd} was killed by signal ${signal}
|
|
115
|
+
${stderr}` : `${cmd} exited ${code}
|
|
116
|
+
${stderr}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/lib/tool-probe.ts
|
|
120
|
+
var IS_WINDOWS = platform() === "win32";
|
|
121
|
+
var PROBE_CMD = IS_WINDOWS ? "where.exe" : "which";
|
|
122
|
+
async function isToolAvailable(tool) {
|
|
123
|
+
try {
|
|
124
|
+
await execCapture(PROBE_CMD, [tool]);
|
|
125
|
+
return true;
|
|
126
|
+
} catch {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async function findTool(tool) {
|
|
131
|
+
try {
|
|
132
|
+
const { stdout } = await execCapture(PROBE_CMD, [tool]);
|
|
133
|
+
const firstLine = stdout.split(/\r?\n/).find((line) => line.trim().length > 0);
|
|
134
|
+
return firstLine?.trim() || undefined;
|
|
135
|
+
} catch {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// src/lib/install-hints.ts
|
|
141
|
+
var INSTALL_HINTS = {
|
|
142
|
+
chromium: {
|
|
143
|
+
label: "Google Chrome, Chromium, or Microsoft Edge",
|
|
144
|
+
body: ` macOS: brew install --cask google-chrome
|
|
145
|
+
` + ` Ubuntu: sudo apt install -y chromium-browser
|
|
146
|
+
` + " Windows: https://www.google.com/chrome/ (Edge is auto-detected if pre-installed)"
|
|
147
|
+
},
|
|
148
|
+
gs: {
|
|
149
|
+
label: "Ghostscript",
|
|
150
|
+
body: ` macOS: brew install ghostscript
|
|
151
|
+
` + ` Ubuntu: sudo apt install -y ghostscript
|
|
152
|
+
` + " Windows: https://www.ghostscript.com/releases/gsdnld.html (standard installs are auto-detected; or: choco install ghostscript)"
|
|
153
|
+
},
|
|
154
|
+
qpdf: {
|
|
155
|
+
label: "qpdf",
|
|
156
|
+
body: ` macOS: brew install qpdf
|
|
157
|
+
` + ` Ubuntu: sudo apt install -y qpdf
|
|
158
|
+
` + " Windows: choco install qpdf (or: https://github.com/qpdf/qpdf/releases)"
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
function fullInstallHint(tool) {
|
|
162
|
+
const hint = INSTALL_HINTS[tool];
|
|
163
|
+
return `Install ${hint.label}:
|
|
164
|
+
${hint.body}`;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// src/lib/chromium.ts
|
|
168
|
+
import { existsSync } from "node:fs";
|
|
169
|
+
var SYSTEM_PATHS = [
|
|
170
|
+
process.env.CHROMIUM_PATH,
|
|
171
|
+
process.env.PUPPETEER_EXECUTABLE_PATH,
|
|
172
|
+
"/usr/bin/google-chrome",
|
|
173
|
+
"/usr/bin/google-chrome-stable",
|
|
174
|
+
"/usr/bin/chromium",
|
|
175
|
+
"/usr/bin/chromium-browser",
|
|
176
|
+
"/snap/bin/chromium",
|
|
177
|
+
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
178
|
+
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
179
|
+
"/opt/homebrew/bin/chromium",
|
|
180
|
+
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
|
|
181
|
+
"/Applications/Brave Browser.app/Contents/MacOS/Brave Browser",
|
|
182
|
+
"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
|
|
183
|
+
"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
|
|
184
|
+
process.env.LOCALAPPDATA ? `${process.env.LOCALAPPDATA}\\Google\\Chrome\\Application\\chrome.exe` : undefined,
|
|
185
|
+
"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe",
|
|
186
|
+
"C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe",
|
|
187
|
+
process.env.LOCALAPPDATA ? `${process.env.LOCALAPPDATA}\\Microsoft\\Edge\\Application\\msedge.exe` : undefined,
|
|
188
|
+
process.env.LOCALAPPDATA ? `${process.env.LOCALAPPDATA}\\BraveSoftware\\Brave-Browser\\Application\\brave.exe` : undefined
|
|
189
|
+
].filter(Boolean);
|
|
190
|
+
var PATH_CANDIDATES = [
|
|
191
|
+
"google-chrome",
|
|
192
|
+
"google-chrome-stable",
|
|
193
|
+
"chromium",
|
|
194
|
+
"chromium-browser",
|
|
195
|
+
"chrome",
|
|
196
|
+
"chrome.exe",
|
|
197
|
+
"msedge",
|
|
198
|
+
"msedge.exe",
|
|
199
|
+
"brave",
|
|
200
|
+
"brave-browser",
|
|
201
|
+
"brave.exe",
|
|
202
|
+
"vivaldi",
|
|
203
|
+
"vivaldi-stable",
|
|
204
|
+
"vivaldi.exe",
|
|
205
|
+
"opera",
|
|
206
|
+
"opera-stable",
|
|
207
|
+
"opera.exe"
|
|
208
|
+
];
|
|
209
|
+
async function resolveChromiumExecutable() {
|
|
210
|
+
for (const candidate of SYSTEM_PATHS) {
|
|
211
|
+
if (existsSync(candidate))
|
|
212
|
+
return candidate;
|
|
213
|
+
}
|
|
214
|
+
for (const candidate of PATH_CANDIDATES) {
|
|
215
|
+
const found = await findTool(candidate);
|
|
216
|
+
if (found)
|
|
217
|
+
return found;
|
|
218
|
+
}
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
async function requireChromiumExecutable() {
|
|
222
|
+
const found = await resolveChromiumExecutable();
|
|
223
|
+
if (found)
|
|
224
|
+
return found;
|
|
225
|
+
throw new Error([
|
|
226
|
+
"No Chrome / Chromium / Edge binary found. Gutterpress needs a Chromium-based browser to render PDFs.",
|
|
227
|
+
"",
|
|
228
|
+
"Install one of:",
|
|
229
|
+
INSTALL_HINTS.chromium.body,
|
|
230
|
+
"",
|
|
231
|
+
"Or point to an existing install:",
|
|
232
|
+
" CHROMIUM_PATH=/path/to/chrome gutterpress build ...",
|
|
233
|
+
"",
|
|
234
|
+
"The Gutterpress desktop app uses its own bundled browser for BOTH",
|
|
235
|
+
"PDF export and needs no separate install.",
|
|
236
|
+
"This message is about the CLI, which does need one."
|
|
237
|
+
].join(`
|
|
238
|
+
`));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export { run, spawnCapture, execCapture, isToolAvailable, findTool, INSTALL_HINTS, fullInstallHint, resolveChromiumExecutable, requireChromiumExecutable };
|